diff --git a/src/qwiic_i2c.cpp b/src/qwiic_i2c.cpp index 0d8ae20..5b992d9 100644 --- a/src/qwiic_i2c.cpp +++ b/src/qwiic_i2c.cpp @@ -145,10 +145,15 @@ int QwI2C::writeRegisterRegion(uint8_t i2c_address, uint8_t offset, uint8_t* dat nRemaining -= nToWrite; // Note - use nToWrite, not nSent, or lock on esp32 data += nSent; // move up to remaining data in buffer +#if defined(ARDUINO_ARCH_ESP32) + // if we are on ESP32, release bus no matter what + if (m_i2cPort->endTransmission()) +#else // only release bus if we've sent all data - if (m_i2cPort->endTransmission(nRemaining <= 0)) + if (m_i2cPort->endTransmission(nRemaining <= 0)) +#endif return -1; // the client didn't ACK } return length - nRemaining; -} \ No newline at end of file +}