vTimerSetTimerID
[定时器 API]
timers.h
void vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID );
创建定时器时,会为软件定时器分配一个标识符 (ID),
您可随时使用 vTimerSetTimerID() API 函数更改此标识符。
如果将同一个回调函数分配给多个定时器,
则可以在回调函数内检查定时器标识符,
以确定哪个定时器实际已到期。
在定时器回调函数的调用之间,定时器标识符也可用于将数据存储在定时器中
。
-
参数:
-
xTimer
|
更新的计时器。
|
pvNewID
|
句柄,定时器标识符将被设置为此句柄。
|
用法示例:
/* A callback function assigned to a timer. */
void TimerCallbackFunction( TimerHandle_t pxExpiredTimer )
{
uint32_t ulCallCount;
/* A count of the number of times this timer has expired
and executed its callback function is stored in the
timer's ID. Retrieve the count, increment it, then save
it back into the timer's ID. */
ulCallCount =
( uint32_t ) pvTimerGetTimerID( pxExpiredTimer );
ulCallCount++;
vTimerSetTimerID( pxExpiredTimer, ( void * ) ulCallCount );
}
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.