#include <Arduino.h>
void xTaskOne(void *xTask1)
{
while (1)
{
Serial.printf("TaskOne\r\n");
delay(500);
}
}
void xTaskTwo(void *xTask2)
{
while (1)
{
Serial.printf("TaskTwo \r\n");
delay(1000);
}
}
void setup()
{
Serial.begin(115200);
delay(20);
}
void loop()
{
//最后一个参数至关重要,决定这个任务创建在哪个核上.PRO_CPU 为 0, APP_CPU 为 1,或者 tskNO_AFFINITY 允许任务在两者上运行.
xTaskCreatePinnedToCore(xTaskOne, "TaskOne", 4096, NULL, 1, NULL, 0);
xTaskCreatePinnedToCore(xTaskTwo, "TaskTwo", 4096, NULL, 2, NULL, 1);
while (1)
{
Serial.printf("XTask is running\r\n");
delay(1000);
}
}