Skip to content

Commit da21f0e

Browse files
committed
Wire: fix "Arduino way" I2C scan
1 parent 07c566d commit da21f0e

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)