»
(008) CubeIDE Implementation of USB Peripherals*
(018) C99 pointer*
(019) C99 With only value assignment*
(022) POSIX pthread multi-threads mutex*
(023) POSIX pthread multi-threads programming*
(027) C99 time and wait*
(028) High-precision calculation with GMP*
(029) Web Service Lib*
(030) International Components for Unicode (ICU)*
(031) Performance of C is higher than C++, because...*
🕹️(036) Timer Tasks in FreeRTOS
FreeRTOS中的定时任务:
TimerHandle_t xTimerCreate(
const char* pcName,//定时任务名
const TickType_t xTimerPeriodInTick, //以tick数为时基的定时器间隔时间
const UBaseType_t uxAutoReload, //是否为多次定时任务
void* const pvTimerID, //TimerID,传入回调函数用,可以指向任何数据类型的数据
TimerCallbackFunction_t pxCallbackFunction//定时任务的回调函数入口
)
回调函数pxCallbackFunction的例子:
void vTimerCallback(TimerHandle_t xTimer){
int *pValue = (int *)pvTimerGetTimerID();//在回调函数中获取pvTimerID
}
// 启动定时器
if (xTimerStart(xTimer, 0) != pdPASS) {
printf("Failed to start timer!\n");
}