From d00141b1d403f9a8b9e14bf4f1cb0f3fe0f201f7 Mon Sep 17 00:00:00 2001 From: Gunar Schorcht Date: Thu, 25 Nov 2021 13:45:23 +0100 Subject: [PATCH] sys/arduino: update TwoWire class to new I2C API --- sys/arduino/wireport.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/sys/arduino/wireport.cpp b/sys/arduino/wireport.cpp index 6488bb2483..290bd398b1 100644 --- a/sys/arduino/wireport.cpp +++ b/sys/arduino/wireport.cpp @@ -101,13 +101,12 @@ uint8_t TwoWire::requestFrom(uint8_t addr, uint8_t size, uint8_t stop) uint8_t read = 0; - if (i2c_acquire(ARDUINO_I2C_DEV) == 0) { - if (i2c_read_bytes(ARDUINO_I2C_DEV, addr, rxBuffer, size, - stop ? 0 : I2C_NOSTOP) == 0) { - read = size; - } - i2c_release(ARDUINO_I2C_DEV); + i2c_acquire(ARDUINO_I2C_DEV); + if (i2c_read_bytes(ARDUINO_I2C_DEV, addr, rxBuffer, size, + stop ? 0 : I2C_NOSTOP) == 0) { + read = size; } + i2c_release(ARDUINO_I2C_DEV); rxBufferIndex = 0; rxBufferLength = read; @@ -136,9 +135,7 @@ uint8_t TwoWire::endTransmission(uint8_t stop) return txError; } - if (i2c_acquire(ARDUINO_I2C_DEV) != 0) { - return WIRE_PORT_ERROR_OTHER; - } + i2c_acquire(ARDUINO_I2C_DEV); int res = i2c_write_bytes(ARDUINO_I2C_DEV, txAddress, txBuffer, txBufferLength,