i2c: Use u16 for data length
The length will never be negative. Signed-off-by: Tim Crawford <tcrawford@system76.com>
This commit is contained in:
committed by
Jeremy Soller
parent
784202383e
commit
2a3830fb57
@ -46,8 +46,8 @@ void i2c_stop(struct I2C * i2c) {
|
||||
TWCR = BIT(TWINT) | BIT(TWEN) | BIT(TWSTO);
|
||||
}
|
||||
|
||||
int16_t i2c_write(struct I2C * i2c, uint8_t * data, int16_t length) {
|
||||
int16_t i;
|
||||
int16_t i2c_write(struct I2C * i2c, uint8_t * data, uint16_t length) {
|
||||
uint16_t i;
|
||||
for (i = 0; i < length; i++) {
|
||||
// load data into data register
|
||||
TWDR = data[i];
|
||||
@ -65,8 +65,8 @@ int16_t i2c_write(struct I2C * i2c, uint8_t * data, int16_t length) {
|
||||
return i;
|
||||
}
|
||||
|
||||
int16_t i2c_read(struct I2C * i2c, uint8_t * data, int16_t length) {
|
||||
int16_t i;
|
||||
int16_t i2c_read(struct I2C * i2c, uint8_t * data, uint16_t length) {
|
||||
uint16_t i;
|
||||
for (i = 0; i < length; i++) {
|
||||
if ((i + 1) < length) {
|
||||
// start TWI module and acknowledge data after reception
|
||||
|
Reference in New Issue
Block a user