Suspending all FreeRTOS tasks to perform a blocking OTA function

zazas321
Posts: 231
Joined: Mon Feb 01, 2021 9:41 am

Suspending all FreeRTOS tasks to perform a blocking OTA function

Postby zazas321 » Wed Jul 28, 2021 11:32 am

Hello. I have my program running and have created many FreeRTOS including checking for button activity, checking for the rotary encoder activity, monitoring sensors and etc... When certain conditions are met, I want to perform an OTA (firmware update). I want to know if it is okay to call a blocking function within the FreeRTOS task?

For example, I have a task that periodically monitors the mechnical button on my device. If the button is pressed, I want to activate OTA.

I create a task to monitor button:

Code: Select all

  xTaskCreatePinnedToCore(
    Task_read_encoder
    ,  "Task_read_button"   // A name just for humans
    ,  4096  // This stack size can be checked & adjusted by reading the Stack Highwater
    ,  NULL
    ,  2  // Priority, with 3 (configMAX_PRIORITIES - 1) being the highest, and 0 being the lowest.
    ,  NULL 
    ,  ARDUINO_RUNNING_CORE);

and my read button task is as following:

Code: Select all

void Task_read_button(void *pvParameters)  // This is a task.
{
  (void) pvParameters;
  for (;;)
  {
    // read the input on analog pin A3:
  if(read_button_debounce() == 1)
  {
    Serial.print("Button click has been detected");
    START_OTA();
  }
    vTaskDelay(5);  // one tick delay (15ms) in between reads for stability
  }
}
The task wll read the button with a 5 ticks delay and if the button click is detected, it will start a blocking function START_OTA();

Who is online

Users browsing this forum: No registered users and 59 guests