Skip to content

Commit 4297e3f

Browse files
committed
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.
1 parent 455c2ec commit 4297e3f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

targets/TARGET_STM/i2c_api.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ int i2c_byte_read(i2c_t *obj, int last) {
525525
timeout = FLAG_TIMEOUT;
526526
while (__HAL_I2C_GET_FLAG(handle, I2C_FLAG_RXNE) == RESET) {
527527
if ((timeout--) == 0) {
528-
return 2;
528+
return -1;
529529
}
530530
}
531531

@@ -622,7 +622,7 @@ int i2c_byte_read(i2c_t *obj, int last) {
622622
while (!__HAL_I2C_GET_FLAG(handle, I2C_FLAG_TCR)) {
623623
if ((timeout--) == 0) {
624624
DEBUG_PRINTF("timeout in byte_read\r\n");
625-
return 2;
625+
return -1;
626626
}
627627
}
628628
}
@@ -637,7 +637,7 @@ int i2c_byte_read(i2c_t *obj, int last) {
637637
timeout = FLAG_TIMEOUT;
638638
while (!__HAL_I2C_GET_FLAG(handle, I2C_FLAG_RXNE)) {
639639
if ((timeout--) == 0) {
640-
return 2;
640+
return -1;
641641
}
642642
}
643643

0 commit comments

Comments
 (0)