Imaging having a timeout while sending something over I2C. This will set I2C to a locked state:
https://github.com/ChibiOS/ChibiOS/blob/00e51f29768d4592d5ba0d5cb54a325e73b474ea/os/hal/src/hal_i2c.c#L238-L241
However what if for some reason one would like to try again immediatly? In this case the following assert will emerge:
https://github.com/ChibiOS/ChibiOS/blob/00e51f29768d4592d5ba0d5cb54a325e73b474ea/os/hal/src/hal_i2c.c#L184
Is it a desired behaviour?
Hi,
It is the expected behavior, see the state machine diagram here:
http://chibios.sourceforge.net/docs3/hal/group___i2_c.html
An i2cStart() or i2cStop() is expected after entering the locked state, then you can try again. This gives the LLD a chance to implement a recovery strategy in the re-start. A timeout usually means that the I2C or the slave are misbehaving somehow, normally you don't get timeouts.
Do you see problems with this approach?
Giovanni