[HAL][I2C] Update HAL_I2C_Mem_Read() to clear ACK bit once 3 bytes to read remain to be able to send the NACK once the transfer ends
diff --git a/Src/stm32l1xx_hal_i2c.c b/Src/stm32l1xx_hal_i2c.c
index 3fd7631..2f8da76 100644
--- a/Src/stm32l1xx_hal_i2c.c
+++ b/Src/stm32l1xx_hal_i2c.c
@@ -2823,6 +2823,11 @@
if (__HAL_I2C_GET_FLAG(hi2c, I2C_FLAG_BTF) == SET)
{
+ if (hi2c->XferSize == 3U)
+ {
+ /* Disable Acknowledge */
+ CLEAR_BIT(hi2c->Instance->CR1, I2C_CR1_ACK);
+ }
/* Read data from DR */
*hi2c->pBuffPtr = (uint8_t)hi2c->Instance->DR;