Skip to content

Commit 09209bc

Browse files
authored
Wire.endTransmission() uses write() to enable I2C scanning
Revert PR #214, as discussed in issue 414.
1 parent 98b4b7b commit 09209bc

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

libraries/Wire/Wire.cpp

+3-10
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,9 @@ void arduino::MbedI2C::beginTransmission(uint8_t address) {
6969
}
7070

7171
uint8_t arduino::MbedI2C::endTransmission(bool stopBit) {
72-
#ifndef TARGET_PORTENTA_H7
73-
if (usedTxBuffer == 0) {
74-
// we are scanning, return 0 if the addresed device responds with an ACK
75-
char buf[1];
76-
int ret = master->read(_address, buf, 1, !stopBit);
77-
return ret;
78-
}
79-
#endif
8072
if (master->write(_address, (const char *) txBuffer, usedTxBuffer, !stopBit) == 0) return 0;
81-
return 2;
73+
if (usedTxBuffer == 0) return 2; // received NAK on transmit of address (without data)
74+
return 3; // received NAK on transmit of data
8275
}
8376

8477
uint8_t arduino::MbedI2C::endTransmission(void) {
@@ -188,4 +181,4 @@ arduino::MbedI2C Wire(I2C_SDA, I2C_SCL);
188181
#endif
189182
#if WIRE_HOWMANY > 1
190183
arduino::MbedI2C Wire1(I2C_SDA1, I2C_SCL1);
191-
#endif
184+
#endif

0 commit comments

Comments
 (0)