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:
parent
312c31dce5
commit
d00141b1d4
@ -101,13 +101,12 @@ uint8_t TwoWire::requestFrom(uint8_t addr, uint8_t size, uint8_t stop)
|
|||||||
|
|
||||||
uint8_t read = 0;
|
uint8_t read = 0;
|
||||||
|
|
||||||
if (i2c_acquire(ARDUINO_I2C_DEV) == 0) {
|
i2c_acquire(ARDUINO_I2C_DEV);
|
||||||
if (i2c_read_bytes(ARDUINO_I2C_DEV, addr, rxBuffer, size,
|
if (i2c_read_bytes(ARDUINO_I2C_DEV, addr, rxBuffer, size,
|
||||||
stop ? 0 : I2C_NOSTOP) == 0) {
|
stop ? 0 : I2C_NOSTOP) == 0) {
|
||||||
read = size;
|
read = size;
|
||||||
}
|
|
||||||
i2c_release(ARDUINO_I2C_DEV);
|
|
||||||
}
|
}
|
||||||
|
i2c_release(ARDUINO_I2C_DEV);
|
||||||
|
|
||||||
rxBufferIndex = 0;
|
rxBufferIndex = 0;
|
||||||
rxBufferLength = read;
|
rxBufferLength = read;
|
||||||
@ -136,9 +135,7 @@ uint8_t TwoWire::endTransmission(uint8_t stop)
|
|||||||
return txError;
|
return txError;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i2c_acquire(ARDUINO_I2C_DEV) != 0) {
|
i2c_acquire(ARDUINO_I2C_DEV);
|
||||||
return WIRE_PORT_ERROR_OTHER;
|
|
||||||
}
|
|
||||||
|
|
||||||
int res = i2c_write_bytes(ARDUINO_I2C_DEV,
|
int res = i2c_write_bytes(ARDUINO_I2C_DEV,
|
||||||
txAddress, txBuffer, txBufferLength,
|
txAddress, txBuffer, txBufferLength,
|
||||||
|
Loading…
Reference in New Issue
Block a user