FreeRTOS 软件定时器
代码如下:
#include <stdio.h>
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
#include "esp_spi_flash.h"
#include "freertos/timers.h"
void Timer1Callback( TimerHandle_t xTimer ){
printf("OK you'v successfully start a software timer interrupt event\n");
}
void app_main(void)
{
TimerHandle_t xTimer1;
printf("START!!!\n");
xTimer1=xTimerCreate("Timer1",pdMS_TO_TICKS(1000),pdTRUE,(void *)0,Timer1Callback);//创建了一个定时器,名字为Timer1,1秒钟执行一次,并且会重装载,ID为0,回调函数为Timer1Callback
//创建好了定时器,下面就要启动
xTimerStart(xTimer1,0);//xTimerStart( TimerHandle_t xTimer, TickType_t xTicksToWait );我们无需进行等待,所以设置等待时间为0
}