//LED CLASSIC BLINKING
#if CONFIG_FREERTOS_UNICORE
static const BaseType_t app_cpu =0;
#else
static const BaseType_t app_cpu = 1;
#endif
static const int led_pin = 5;
static const int rate1 = 500;
static const int rate2 = 100;
void toggle_led(void *parameters)
{
while(1)
{
digitalWrite(led_pin,HIGH);
vTaskDelay(rate1/portTICK_PERIOD_MS); // vTaskDelay measures on the number of ticks
digitalWrite(led_pin,LOW);
vTaskDelay(rate1/portTICK_PERIOD_MS);
}
}
void toggle_led2(void *parameters)
{
while(1)
{
digitalWrite(led_pin,HIGH);
vTaskDelay(rate2/portTICK_PERIOD_MS);
digitalWrite(led_pin,LOW);
vTaskDelay(rate2/portTICK_PERIOD_MS);
}
}
void setup() {
// put your setup code here, to run once:
// Serial.begin(115200);
pinMode(led_pin, OUTPUT);
//Serial.println("Hello, ESP32!");
xTaskCreatePinnedToCore( // Use xTaskCreate() in vanila FreeRTOS
toggle_led,
"Toggle led", //name of task
1024, //STACK SIZE vwords in FreeRTOS
NULL,//parameter to pass into the function
1,//task pariority,
NULL, //TASK HANDLE
app_cpu);
xTaskCreatePinnedToCore(toggle_led2,"Toggle led2",1024,NULL,1,NULL,app_cpu);
}
void loop() {
// put your main code here, to run repeatedly:
}