golioth / ostentus

i2c controlled ePaper display for Golioth Reference Designs
Apache License 2.0
1 stars 0 forks source link

Prevent Ostentus from dropping I2C messages when the FIFO is full #14

Closed cdwilson closed 9 months ago

cdwilson commented 9 months ago

I ran into an issue on the Modbus reference design when I was trying to add about 25 different slides to show the various parameters measured by the vibration sensor.

The current Ostentus firmware receives commands from the Zephyr-based controller as I2C messages and sticks them into a FIFO buffer for the MicroPython code to "pop" out of the FIFO and process. However, if you send lots of I2C messages too quickly, the PIOs in Ostentus will ack the I2C transactions (they appear to succeed), but the FIFO will silently drop the messages once the buffer is full. This corrupts the Ostentus display causing it to act strangely (missing slides, etc).

This PR disables the i2c_multi interface temporarily when the FIFO buffer is totally full and only re-enables it once there is space in the FIFO buffer to receive new I2C messages.

For devices trying to interface with Ostentus, there is no change in behavior until the FIFO on Ostentus is full. When the FIFO is full, trying to send additional I2C messages will fail, instead of appearing to succeed and then getting dropped silently by the FIFO code. This prevents Ostentus from getting corrupted and gives the controller the choice to retry the transaction or give up.

This PR also pulls in the latest i2c_multi fixes from the upstream repo and increases the FIFO_SIZE so that more slides can be used without filling up the buffer.

Check out https://github.com/golioth/libostentus/pull/11 for how to test this.