Thanks for your response.
I was trying to do something similar to the first option. I created a Task like this :
Code: Select all
void create_led_blink_tasks(){
BaseType_t xReturned;
xReturned = xTaskCreate(&led_blink,"LED_BLINK",2048,NULL,5,&led_task_handle);
if(xReturned == pdPASS )
{
/* The task was created. Use the task's handle to delete the task. */
ESP_LOGI(TAG, "LED BLINK TASK CREATED");
}
}
LED Blink Function as below :
Code: Select all
void led_blink(){
ESP_LOGI(TAG, "LED SLOW INITIATED");
while (1) {
g_led_duration = get_duration();
ESP_LOGI(TAG, "LED SLOW BLINKING");
gpio_set_level(LED,0);
vTaskDelay(g_led_duration/portTICK_RATE_MS);
gpio_set_level(LED,1);
vTaskDelay(g_led_duration/portTICK_RATE_MS);
}
}
Where g_led_duration is a variable that can be set by other functions depending on the requirement.
Now when I need to stop the LED Blinking (at this time, I need the LED to be either ON or OFF, not blinking), I am doing the following :
Code: Select all
void delete_led_blink_task()
{
ESP_LOGI(TAG, "LED TASK DELETED");
vTaskDelete(led_task_handle);
}
But doesn't seem to be working. What am I doing wrong?