Created
November 8, 2017 10:07
-
-
Save shirish47/5b2a04f81eab4281b5c69f678a4da352 to your computer and use it in GitHub Desktop.
how to use freeRTOS timer API's in ESP32 (basic). Needed it for stoping advertisement after some time as There is not time out functionality.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include "freertos/FreeRTOS.h" | |
#include "esp_log.h" | |
#include "freertos/timers.h" | |
#define TAG "TIME" | |
/* timer calls the function ping after interval time. xTimerCreate() takes interval in TICKs so | |
pdMS_TO_TICKS() converts ms interval to appropriate TICKS. pdTRUE will set timer to call periodically and if Set pdFALSE, | |
function is called once only */ | |
TimerHandle_t tmr; | |
int id = 1; | |
int interval = 5000; | |
void ping( TimerHandle_t xTimer ) | |
{ | |
ESP_LOGI(TAG,"tring tring!!!"); | |
} | |
void app_main() | |
{ | |
ESP_LOGI(TAG,"Timer Test.\n"); | |
tmr = xTimerCreate("MyTimer", pdMS_TO_TICKS(interval), pdTRUE, ( void * )id, &ping); | |
if( xTimerStart(tmr, 10 ) != pdPASS ) { | |
printf("Timer start error"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The statement "ESP_LOGI(TAG,"tring tring!!!");" is causing a task stack overflow in the timer task.