ESP IDF handling multiple I2C tasks?


I’m trying to control an ssd1306 I2C display after reading data from an ADC and display it without having the I2C tasks bumping into each other and crashing the program so my question is: how to properly handle different I2C tasks that control different I2C on the same bus.

I’ve searched for a function to check wether the I2C bus is used by the system with no luck.

I’m using the ESP IDF SDK with ESP32 dev kit V1

I don’t know their SDK, but you can implement safe sharing with a little help from FreeRTOS.

One common pattern is to use a mutex to share the I2C driver. For example, you could provide an open function that takes the mutex and a close function that gives it. The open function could take a parameter indicating how long the caller is willing to wait for the I2C to become available. With this pattern, nobody is allowed to use the I2C driver outside of the open-close window.

Yeah it has to do with the thread safing of the ssd1306_hal implementation with u8g2 lib I’m not experienced enough to integrate thread safe I2C dev lib(one if available from a
guy called UncleRuss on github) just split the display bus to the other I2C controller of the ESP32 on different pins.