STM32: I2C: i2c_byte_read return value in case of error

To make clear that an error is being reported, we shall report -1,
2 being the timeout error for i2c_byte_write only.
pull/3488/head
Laurent MEUNIER 2017-01-03 18:06:19 +01:00
parent 455c2ecbea
commit 4297e3fd36
1 changed files with 3 additions and 3 deletions

View File

@ -525,7 +525,7 @@ int i2c_byte_read(i2c_t *obj, int last) {
timeout = FLAG_TIMEOUT;
while (__HAL_I2C_GET_FLAG(handle, I2C_FLAG_RXNE) == RESET) {
if ((timeout--) == 0) {
return 2;
return -1;
}
}
@ -622,7 +622,7 @@ int i2c_byte_read(i2c_t *obj, int last) {
while (!__HAL_I2C_GET_FLAG(handle, I2C_FLAG_TCR)) {
if ((timeout--) == 0) {
DEBUG_PRINTF("timeout in byte_read\r\n");
return 2;
return -1;
}
}
}
@ -637,7 +637,7 @@ int i2c_byte_read(i2c_t *obj, int last) {
timeout = FLAG_TIMEOUT;
while (!__HAL_I2C_GET_FLAG(handle, I2C_FLAG_RXNE)) {
if ((timeout--) == 0) {
return 2;
return -1;
}
}