I am using an STM32F407 on a customer board and have trouble with the I2C handling.
I am using the latest HAL HAL_I2C_MasterTransmitIT and HAL_I2C_MasterReceiveIT to poll data from a sensor.
The problem is that after a while the I2C lines lock up (both SDA and SCL low) and the HAL_I2C_MasterTransmitIT returns errors.
I do detect the error and try to handle the problem by deinit the I2C. I then reconfigure the I/O to software handle some clocking that release SDA if it is stuck by a slave on the bus. At that point I can see that the lines go high again so it is the I2C peripheral in the STM that is pulling it low ( I can also see that on the scope with the low level slightly above ground while when the lines are pulled by a slave device, the go lower).
I then reinit the I2C peripheral but as soon as the I2C is activated and connected to the I/O lines, the SDA and SCL are pulled low again.
So I can't seem to reset the I2C without restarting the whole chip.
Is there a other way to properly reset the I2C?
Also, what can be causing this lockup in the first place?