Page 1 of 1

GPIO functions thread safe

Posted: Wed Jan 24, 2024 1:26 pm
by Cages123
Working on my first project with the ESP32 using ESP-IDF; the peripheral API documentation have a Thread safety section for each peripheral listing the thread safe functions. There is no such section on the GPIO API. Is gpio_set_level() function thread safe when called for different pins?

Example :TaskA controlling GPIO16 and TaskB controlling GPIO22

NB: The example uses the gpio_set_level() in one task and gpio_get_level() in separate task

Re: GPIO functions thread safe

Posted: Thu Jan 25, 2024 12:03 pm
by MicroController
Is gpio_set_level() function thread safe when called for different pins?
Yes. The function uses the W1TS/W1TC registers specifically provided by the hardware for atomic updates to the GPIO outputs.