Hello,
Using ESP32 Gateway board I need to use both threads and create tasks in synchronous mode on both threads. How can I do that? Basically I want to create new tasks that will run after the previous task is ended.
I created a small Sketch to see the expected result:
#include "Arduino.h"
void FreertosTask1Dispatch(int Crt);
void FreertosTask1Code(void * pvParamaters);
TaskHandle_t FreertosTask1;
void FreertosTask1Dispatch(int Crt) {
Serial.println(Crt);
Serial.println(" - freertos dispatch function started.");
xTaskCreatePinnedToCore(
FreertosTask1Code, /* Function to implement the task */
"FreertosTask1Code", /* Name of the task */
10000, /* Stack size in words */
(void*)&Crt, /* Task input parameter */
1, /* Priority of the task */
&FreertosTask1, /* Task handle. */
0); /* Core where the task should run */
}
void FreertosTask1Code(void * pvParamaters) {
int Crt = *((int*)pvParamaters);
Serial.print(Crt);
Serial.println("- before delay.");
delay(6000);
Serial.print(Crt);
Serial.println("- after delay.");
vTaskDelete(NULL);
}
void Synchronous(int Crt)
{
Serial.print(Crt);
Serial.println("- before delay.");
delay(6000);
Serial.print(Crt);
Serial.println("- after delay.");
}
void setup() {
Serial.begin(256000);
Serial.println("Tasks on core 0");
for (int Crt = 0; Crt <= 15; Crt++) {
FreertosTask1Dispatch(Crt);
}
delay(10000);
//Expected result but using vTaskCreatePinnedToCore. How can I do that using vTaskCreatePinnedToCore?
Serial.println("Synchronous.");
for (int Crt = 0; Crt <= 15; Crt++) {
Synchronous(Crt);
}
return;
}
void loop() {
return;
}
Thanks