Page 1 of 1

Thread safety of a new I2C driver on ESP IDF v5.2

Posted: Wed Apr 24, 2024 2:09 pm
by grginho
Hello,

In the Documentation for the new I2C driver, it says this:
Thread Safety
The factory function i2c_new_master_bus() and i2c_new_slave_device() are guaranteed to be thread safe by the driver, which means, user can call them from different RTOS tasks without protection by extra locks. Other public I2C APIs are not thread safe. which means the user should avoid calling them from multiple tasks, if user strongly needs to call them in multiple tasks, please add extra lock.


Does this mean that only i2c_new_master_bus() and i2c_new_slave_device() are thread safe, and all other I2C functions are not thread safe?

Regards,

Dragan

Re: Thread safety of a new I2C driver on ESP IDF v5.2

Posted: Thu May 02, 2024 4:11 am
by owenjames
Yes, that's my understanding. I need to consider this as I want to upgrade from the legacy driver. I have been using https://github.com/ropg/i2c_manager as a thread-safe wrapper of the legacy driver.