Skip to content

Don't send I2C restart #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/qwiic_i2c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}