Touch Screen I2C bus sharing

I am using ESP32-S3 in ESP-IDF environment with RGB Panel and touch screen.
On the same I2C bus of the touch screen I have an RTC clock, so I occasionally need to read it.
Is there a method (mutex?) to not interfere with the touch screen management by LVGL?
Thanks.

I would recommend you to use the I2C only for the touchscreen and a diffrent I2C for your RTC.
If you want to do someting like drawing lines or scrolling motions you will recognize some lag if you touch the display in the right moment.

Else you could use an RTOS like FreeRTOS and use a semaphore to lock the I2C peripheral.

lv_conf.h :

/Input device read period in milliseconds/
#define LV_INDEV_DEF_READ_PERIOD 30 /[ms]/

…so I suppose that the touch reading occurs every 30 mS.
Therefore, in theory there is time to read my RTC (very few bytes)… I was wondering if there is already a mutex mechanism to avoid interference.

Indev callback isnt part of LVGL, then you can do here protection your way. LVGL call it as you show in conf, but this dont real must call I2C. Normal touch is based on IRQ, then no IRQ on 30ms pool = no I2C.
For not conflict I2C you only require same one thread use code for one I2C. Here no mutex required.

1 Like