SuperHouse / esp-open-rtos

Open source FreeRTOS-based ESP8266 software framework
BSD 3-Clause "New" or "Revised" License
1.52k stars 491 forks source link

taskENTER_CRITICAL() question #675

Closed Zaltora closed 5 years ago

Zaltora commented 5 years ago

Simple question, Use taskENTER_CRITICAL() and taskEXIT_CRITICAL() disable interrupt ? It didn't disable interrupt from GPIO or TIMER ?

AndreaGreco commented 5 years ago

It should disable all interrupt. You should used just for few operation, that must be atomic. It disable interrupt execution. Interrupt is not lost, it will be executed immediately after call exit critical.

Zaltora commented 5 years ago

okay, thank you ! I use it for 2 operation to get time and a measure in an atomic way. I was afraid that interrupt was lost. A second solution for me was this :

static bool flag_atomic;

void vApplicationTickHook(void)
{
  flag_atomic = false;
}

void myFunction(void)
{
   do {
         flag_atomic = true;
         // Operation 1 here
         // Operation 2 here
         // ....
   while(!flag_atomic);
}