I2C slave mode.
Posted: Sun Nov 25, 2012 12:07 pm
Dear All,
I've noticed that chibios I2C driver doesn't implement I2C slave mode. I need that mode for my hardware as it consists of several identical MCUs on one I2C bus.
I've implemented I2C slave functionality by myself. Unfortunately, I've done it only for one MCU type: STM32F10XXX as I have only it. And it must be it doesn't work quite well at the moment: it works for separate read and write requests but it doesn't support read after write at the moment due to some reason. Anyway, it seems to me it would be useful to share the code. Slave mode functionality by default is invisible and everything is as without it. But if one defines I2C_USE_SLAVE_MODE to be TRUE i2cSlaveIoTimeout() function could be used
At the moment slave IO procedure is asynchronous. It returns immediately after invocation. But I2C works continuously after the very first call. To change IO data it's necessary to call the same procedure with different in and out buffers. I'm not sure it is in the mainstream of "chibios" but I'm ready to adjust it if necessary.
I've noticed that chibios I2C driver doesn't implement I2C slave mode. I need that mode for my hardware as it consists of several identical MCUs on one I2C bus.
I've implemented I2C slave functionality by myself. Unfortunately, I've done it only for one MCU type: STM32F10XXX as I have only it. And it must be it doesn't work quite well at the moment: it works for separate read and write requests but it doesn't support read after write at the moment due to some reason. Anyway, it seems to me it would be useful to share the code. Slave mode functionality by default is invisible and everything is as without it. But if one defines I2C_USE_SLAVE_MODE to be TRUE i2cSlaveIoTimeout() function could be used
At the moment slave IO procedure is asynchronous. It returns immediately after invocation. But I2C works continuously after the very first call. To change IO data it's necessary to call the same procedure with different in and out buffers. I'm not sure it is in the mainstream of "chibios" but I'm ready to adjust it if necessary.