2021-10-31 11:58 PM
2021-11-01 06:33 AM
Did you try HAL_I2C_Master_Receive_IT? If it gets a NACK, it's going to do something. Either go to the error interrupt or still hit the transfer complete interrupt. Either way, it probably has enough information in the state machine to discern how many bytes were received.
2021-11-01 12:03 PM
I use slave so i tried HAL_I2C_Slave_Receive_IT. I found the similar question https://community.st.com/s/question/0D50X00009XkXWw/stm32-i2c-hal-slave-receive-callback-not-called, my problem looks the same.
2021-11-01 12:47 PM
Which STM32?
This is a general deficiency in the HAL, as it likely does interrupt for each byte you could probably override the lackluster implementation by goosing the appropriate counter within the device instance..
Look at the logic the code calling the call-back implements. The source is open and reviewable.