ESP32多线程
代码:
void setup()
{
// put your setup code here, to run once:
Serial.begin(115200);
delay(1000);
xTaskCreate(
taskOne, /* Task function. */
"TaskOne", /* String with name of task. */
10000, /* Stack size in bytes. */
NULL, /* Parameter passed as input of the task */
1, /* Priority of the task. */
NULL); /* Task handle. */
xTaskCreate(
taskTwo, /* Task function. */
"TaskTwo", /* String with name of task. */
10000, /* Stack size in bytes. */
NULL, /* Parameter passed as input of the task */
1, /* Priority of the task. */
NULL); /* Task handle. */
}
void loop()
{
// put your main code here, to run repeatedly:
delay(1000);
}
void taskOne(void *parameter)
{
for (int i = 0; i < 10; i++)
{
Serial.println("Hello from task 1");
delay(10000);
}
Serial.println("Ending task 1"