Re: I2C Slave mode support?
Posted: Tue Nov 19, 2013 9:17 am
I propose the synchronous solution because initially the I2C driver was callback-based much like the SPI one. The problem was that the driver was very large and unreliable because STM32 I2C "limitations" so we decided to switch to a synchronous API which allowed us to work around all the problems.
Another advantage of the synchronous API is that it allows for SW I2C emulation that was our backup solution.
Another reason would be that if we want to make a single master/slave driver then both master and slave APIs should share a common design philosophy.
I don't know the I2C in depth but I imagine that we should follow this protocol:
1) A thread waits for an address match and gets what the master has to transmit.
2) Then the thread has to decode the request and decide how to answer (return data, NACK, other?).
Are two functions sufficient for this? something like: i2cSlaveWaitMessage() and i2cSlaveAnswerMessage().
My question is, what the behavior of the driver should be if a master sends an address but the slave is not yet in i2cSlaveWaitMessage()? Lets imagine this in terms of state machine.
Giovanni
Another advantage of the synchronous API is that it allows for SW I2C emulation that was our backup solution.
Another reason would be that if we want to make a single master/slave driver then both master and slave APIs should share a common design philosophy.
I don't know the I2C in depth but I imagine that we should follow this protocol:
1) A thread waits for an address match and gets what the master has to transmit.
2) Then the thread has to decode the request and decide how to answer (return data, NACK, other?).
Are two functions sufficient for this? something like: i2cSlaveWaitMessage() and i2cSlaveAnswerMessage().
My question is, what the behavior of the driver should be if a master sends an address but the slave is not yet in i2cSlaveWaitMessage()? Lets imagine this in terms of state machine.
Giovanni