// Use only core 1
#if CONFIG_FREERTOS_UNICORE
static const BaseType_t app_cpu = 0;
#else
static const BaseType_t app_cpu = 1;
#endif
// Pins
static const int led_pin_1 = 22; //LED_BUILTIN;
static const int led_pin_2 = 23;
// Our task: blink an LED
void toggleLED1(void *parameter)
{
while(1){
digitalWrite(led_pin_1, !digitalRead(led_pin_1));
vTaskDelay(500 / portTICK_PERIOD_MS);
}
}
void toggleLED2(void *parameter)
{
while(1){
digitalWrite(led_pin_2, !digitalRead(led_pin_2));
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
}
void setup() {
// put your setup code here, to run once:
// Configure pins
pinMode(led_pin_1, OUTPUT);
pinMode(led_pin_2, OUTPUT);
// Task to run forever
xTaskCreatePinnedToCore( // Use xTaskCreate() in vanilla FreeRTOS
toggleLED1, // Function to be called
"Toggle LED1", // Name of task
1024, // Stack size (bytes in ESP32, words in FreeRTOS)
NULL, // Parameter to pass to function
1, // Task priority (0 to to configMAX_PRIORITIES - 1)
NULL, // Task handle
app_cpu); // Run on one core for demo purposes (ESP32 only)
xTaskCreatePinnedToCore( // Use xTaskCreate() in vanilla FreeRTOS
toggleLED2, // Function to be called
"Toggle LED2", // Name of task
1024, // Stack size (bytes in ESP32, words in FreeRTOS)
NULL, // Parameter to pass to function
1, // Task priority (0 to to configMAX_PRIORITIES - 1)
NULL, // Task handle
app_cpu); // Run on one core for demo purposes (ESP32 only)
// If this was vanilla FreeRTOS, you'd want to call vTaskStartScheduler() in
// main after setting up your tasks.
}
void loop() {
// put your main code here, to run repeatedly:
}