From 582d03353b5111b8030ec5a6954ec480acaaa6d3 Mon Sep 17 00:00:00 2001 From: Dino Tinitigan Date: Fri, 26 Feb 2016 11:04:59 -0800 Subject: [PATCH] i2c bus scan workaround -sends a byte of value 0 when doing an i2c bus scan --- libraries/Wire/Wire.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/libraries/Wire/Wire.cpp b/libraries/Wire/Wire.cpp index 49488102..423a9a3d 100644 --- a/libraries/Wire/Wire.cpp +++ b/libraries/Wire/Wire.cpp @@ -110,11 +110,9 @@ uint8_t TwoWire::endTransmission(uint8_t sendStop) if (txBufferLength >= 1) { err = i2c_writebytes(txBuffer, txBufferLength, !sendStop); } else { - /* FIXME: A zero byte transmit is typically used to check for an - * ACK from the slave device. This is currently not supported by - * this library implementation - */ - return 4; // Other error + //Workaround: I2C bus scan is currently implemented by sending an extra byte of value 0 + txBuffer[0] = 0; + err = i2c_writebytes(txBuffer, 1, !sendStop); } // empty buffer txBufferLength = 0;