#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 = 2;
//Our task blink a led
void toggleLed1(void * parameter) {
while(1) {
digitalWrite(led_pin, HIGH);
vTaskDelay(500 / portTICK_PERIOD_MS );
digitalWrite(led_pin, LOW);
vTaskDelay(500 / portTICK_PERIOD_MS);
}
}
// homework to change the delay to another time
void toggleLed2(void * parameter) {
while(1) {
digitalWrite(led_pin, HIGH);
vTaskDelay(200 / portTICK_PERIOD_MS );
digitalWrite(led_pin, LOW);
vTaskDelay(200 / portTICK_PERIOD_MS);
}
}
void setup() {
pinMode(led_pin, OUTPUT);
// Task to run forever
xTaskCreatePinnedToCore(
toggleLed1, // Function to be called
"ToggleLed", // name of the function
1024, // stack size
NULL, // parameter to pass to the function
1, // priority
NULL , // task handle
app_cpu
);
xTaskCreatePinnedToCore(
toggleLed2, // Function to be called
"ToggleLed2", // name of the function
1024, // stack size
NULL, // parameter to pass to the function
1, // priority
NULL , // task handle
app_cpu
);
}
void loop() {
}