HAL_I2C_Slave_Transmit_IT hangs forever
Hi there,
On some MCUs, I've noticed that the second call to HAL_I2C_Slave_Transmit_IT hangs forever.
An example I have is on an STM32G030K6 (which doesn't seem to happen on a STM32G474RE).
I have set all pins to fast to ensure that's not the issue either.
The general paradigm is as follows:
The slave calls:
HAL_I2C_Slave_Receive_IT
The master calls:
HAL_I2C_Master_Transmit_IT
The slave callback:
HAL_I2C_SlaveRxCpltCallback
runs, then calls:
HAL_I2C_Slave_Transmit_IT
The master callback:
HAL_I2C_MasterRxCpltCallback
then completes the first "transfer".
At this point, everything seems OK.
One the next transfer, HAL_I2C_Slave_Transmit_IT never completes, because it sends 1 less of the buffer than requested, then the I2C_Slave_ISR_IT routine becomes stuck in an infinite loop. I checked this in a debugger. The issue seems to be that the i2c XferOptions is set to I2C_NO_OPTION_FRAME, but the I2C_Slave_ISR_IT function keeps not calling I2C_ITSlaveSeqCplt because the guards around calling this function won't fire when tmpoptions are set to I2C_NO_OPTION_FRAME.
There appears to even be a ticket about this here: https://github.com/STMicroelectronics/STM32CubeF4/issues/76 from June 2021, that has had zero progress. This ticket describes the issue quite nicely.
ST, is there any progress on this? Since it would appear that the I2C IT is, currently, for some of your MCUs, very very broken with HAL, and needs to be fixed.
Any suggestions/answers here would be much appreciated.
Thanks.