GPIO functions thread safe

Cages123
Posts: 2
Joined: Tue Jan 09, 2024 12:36 pm

GPIO functions thread safe

Postby Cages123 » Wed Jan 24, 2024 1:26 pm

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

MicroController
Posts: 1708
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: GPIO functions thread safe

Postby MicroController » Thu Jan 25, 2024 12:03 pm

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.

Who is online

Users browsing this forum: No registered users and 76 guests