1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

sys/arduino: update TwoWire class to new I2C API

This commit is contained in:
Gunar Schorcht 2021-11-25 13:45:23 +01:00
parent 312c31dce5
commit d00141b1d4

View File

@ -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,