RTOS软件定时器的使用

1.软件定时器的创建

1.1周期定时器的创建

TimerHandle_t AutoReloadTimer_Handle; 

AutoReloadTimer_Handle=xTimerCreate((const char* )"AutoReloadTimer", (TickType_t )1000, (UBaseType_t )pdTRUE, (void* )1, (TimerCallbackFunction_t)AutoReloadCallback); 

1.2单次定时器的创建

TimerHandle_t OneShotTimer_Handle; 

OneShotTimer_Handle=xTimerCreate((const char* )"OneShotTimer", (TickType_t )2000, (UBaseType_t )pdFALSE, (void* )2, (TimerCallbackFunction_t)OneShotCallback); 

2.开启定时器

xTimerStart(AutoReloadTimer_Handle,0);

xTimerStart(OneShotTimer_Handle,0);

3.关闭定时器

xTimerStop(AutoReloadTimer_Handle,0); 
xTimerStop(OneShotTimer_Handle,0);

posted @ 2020-05-05 13:38  -青云  阅读(1170)  评论(0编辑  收藏  举报