Skip to content

Wire: fix "Arduino way" I2C scan #214

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 1 commit into from
May 17, 2021
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
8 changes: 8 additions & 0 deletions libraries/Wire/Wire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ void arduino::MbedI2C::beginTransmission(uint8_t address) {
}

uint8_t arduino::MbedI2C::endTransmission(bool stopBit) {
#ifndef TARGET_PORTENTA_H7
if (usedTxBuffer == 0) {
// we are scanning, return 0 if the addresed device responds with an ACK
char buf[1];
int ret = master->read(_address, buf, 1, !stopBit);
return ret;
}
#endif
if (master->write(_address, (const char *) txBuffer, usedTxBuffer, !stopBit) == 0) return 0;
return 2;
}
Expand Down