lvgl / lvgl_esp32_drivers

Drivers for ESP32 to be used with LVGL
MIT License
330 stars 281 forks source link

Compatibility of i2c_manager with other components in the project. #173

Open SinglWolf opened 2 years ago

SinglWolf commented 2 years ago

In my project, I use several devices that are controlled via I2C. The i2cdev component is used to resolve multithreading conflicts. I decided to implement ssd1306 display support in my project. In this regard, I have a few questions. The most rational option is to abandon the vanilla i2cdev component and use 1 i2c_manager component in i2cdev compatibility mode. But, as I understood from the i2c_manager documentation, i2c_manager does not support separate clock frequency settings for each device. I have devices that operate at 100kHz, 400kHz and 1MHz. What should I do if i2c_manager is used? Set the maximum frequency to 1MHz? Will devices with a maximum frequency of, for example, 100kHz work? If I install i2c_manager for the entire project, how do I set the ssd1306 driver to work properly if i2c_manager runs in i2cdev compatibility mode?

mkfrey commented 2 years ago

The I2C drivers of ESP-IDF do not allow for different frequencies on the same I2C port. So if you are using the same port, you will have to use the frequency of the slave with the lowest frequency. Using higher frequencies on the bus doesn't make sense, because it can lead to unspecified behaviour of the devices not supporting the frequency.

If you use a different port (with different GPIO nums), you can act independently of the LVGL driver and implement your own thread safety mechanisms, but you will still need to use the lowest frequency supported by all of the devices on the same port.