2013-12-27 10:20 PM
I've just enhanced the existing STM32 I2C Master Mode only driver in ChiBiOS to include full multi-mastering support. I've found that the I2C controller does not provide any event interrupt to indicate the end of a received message when that message ends with a Repeated START condition.
For the case where the message ends with a STOP condition, there is the I2C_EV2_SLAVE_RXSTOP event. However, when the master does not give up the bus between messages, the first indication software that a message has ended is either the I2C_EV1_SLAVE_RXADRMATCH or I2C_EV1_SLAVE_TXADRMATCH events of a subsequent message. This sounds like it would be no big deal, but what if the master sends a long sequence of messages to different slaves on the bus, with all but the last terminated with Repeated START? In this case, none of the STM32 slaves will complete processing those messages until the last is terminated with a STOP condition. If the sequencing of these messages was important, that information is effectively lost. My solution for now is to configure a timer to generate a separate interrupt when the START occurs. This works very well, but requires a dedicated GPT for each I2C channel used. See this post for details: Is there some way of configuring the I2C controller to generate an interrupt when a message being received ends with a Repeated START? If so, where is this documented? Note that all slave responses end with a NACK'ed byte from the master, so these are never a problem. #i2c-repeated-start-stop-event