#include <Arduino_FreeRTOS.h>
TaskHandle_t my_handle;
void setup() {
Serial.begin(9600);
xTaskCreate(task1, "print task", 128, NULL, 2, &my_handle);
xTaskCreate(task2, "print task", 128, NULL, 2, NULL);
}
void loop() {
//this is an empty code
}
void task1(void *pvParameters){
while(1){
Serial.println("Configure the work. . . .");
//this function will immediately the task depending if its called
//vTaskDelete(my_handle);
//this function will suspend until it is called
vTaskSuspend(NULL);
}
}
void task2(void *pvParameters){
while(1){
//Serial.println("Periodic Task");
//vTaskDelay(1000/portTICK_PERIOD_MS);
//this function will resume once the function is called
//vTaskResume(my_handle);
//another way of doing it
vTaskSuspend(my_handle);
Serial.println("Periodic Task");
vTaskDelay(1000/portTICK_PERIOD_MS);
Serial.println("resume the task");
vTaskResume(my_handle);
}
}