Files
M5Stack/examples/Advanced/MultiTask/MultiTask.ino
T
0x1abin e08a7d7121 v0.1.4
2017-11-22 23:34:58 +08:00

69 lines
1.9 KiB
Arduino

#include <M5Stack.h>
void task1(void * pvParameters) {
for(;;) {
Serial.print("task1 Uptime (ms): ");
Serial.println(millis());
delay(100);
}
}
void task2(void * pvParameters) {
for(;;) {
Serial.print("task2 Uptime (ms): ");
Serial.println(millis());
delay(200);
}
}
void task3(void * pvParameters) {
for(;;) {
Serial.print("task3 Uptime (ms): ");
Serial.println(millis());
delay(1000);
}
}
void setup() {
M5.begin();
// Task 1
xTaskCreatePinnedToCore(
task1, /* Function to implement the task */
"task1", /* Name of the task */
4096, /* Stack size in words */
NULL, /* Task input parameter */
1, /* Priority of the task */
NULL, /* Task handle. */
0); /* Core where the task should run */
// Task 2
xTaskCreatePinnedToCore(
task2, /* Function to implement the task */
"task2", /* Name of the task */
4096, /* Stack size in words */
NULL, /* Task input parameter */
2, /* Priority of the task */
NULL, /* Task handle. */
0); /* Core where the task should run */
// Task 3
xTaskCreatePinnedToCore(
task3, /* Function to implement the task */
"task3", /* Name of the task */
4096, /* Stack size in words */
NULL, /* Task input parameter */
3, /* Priority of the task */
NULL, /* Task handle. */
0); /* Core where the task should run */
}
void loop() {
M5.update();
}