How to generate NACK on STM32F407
It is described in the Reference Manual, not in the datasheet. A NACK is sent when the I2C_CR1_ACK bit in I2C-&gt;CR1 is set to 0 before receiving the last byte.

HAL should manage this bit automatically according to the transfer size in the HAL_I2C_..._Receive... functions.