[HAL][I2C] Update I2C_WaitOnFlagUntilTimeout to handle error case
diff --git a/Src/stm32l4xx_hal_i2c.c b/Src/stm32l4xx_hal_i2c.c index 3b2f3b5..ec04392 100644 --- a/Src/stm32l4xx_hal_i2c.c +++ b/Src/stm32l4xx_hal_i2c.c
@@ -7000,6 +7000,12 @@ { while (__HAL_I2C_GET_FLAG(hi2c, Flag) == Status) { + /* Check if an error is detected */ + if (I2C_IsErrorOccurred(hi2c, Timeout, Tickstart) != HAL_OK) + { + return HAL_ERROR; + } + /* Check for the Timeout */ if (Timeout != HAL_MAX_DELAY) {