Skip to content

Commit dee2eb0

Browse files
authored
Merge pull request #214 from arduino/fix_i2c_scan
Wire: fix "Arduino way" I2C scan
2 parents 33d47e3 + da21f0e commit dee2eb0

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

libraries/Wire/Wire.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ void arduino::MbedI2C::beginTransmission(uint8_t address) {
6767
}
6868

6969
uint8_t arduino::MbedI2C::endTransmission(bool stopBit) {
70+
#ifndef TARGET_PORTENTA_H7
71+
if (usedTxBuffer == 0) {
72+
// we are scanning, return 0 if the addresed device responds with an ACK
73+
char buf[1];
74+
int ret = master->read(_address, buf, 1, !stopBit);
75+
return ret;
76+
}
77+
#endif
7078
if (master->write(_address, (const char *) txBuffer, usedTxBuffer, !stopBit) == 0) return 0;
7179
return 2;
7280
}

0 commit comments

Comments
 (0)