[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/stm32f2xx_hal_i2c.c b/Src/stm32f2xx_hal_i2c.c index 48eef2f..43e617d 100644 --- a/Src/stm32f2xx_hal_i2c.c +++ b/Src/stm32f2xx_hal_i2c.c
@@ -2831,6 +2831,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;