xTimerGetExpiryTime
[定时器 API]
timers.h
TickType_t xTimerGetExpiryTime( TimerHandle_t xTimer );
返回软件定时器到期的时间,
即执行定时器回调函数的时间。
如果 xTimerGetExpiryTime() 返回的值小于当前时间,
则定时器会在 tick 计数溢出并归
0 后到期。 计数溢出在 RTOS 实现中进行处理,
因此定时器的回调函数会在正确时间执行,
无论是在 tick 计数溢出之前还是之后。
-
参数:
-
-
返回:
-
如果 xTimer 引用的定时器处于活动状态,
则返回定时器下一次到期的时间
(可能是在当前 tick 计数溢出之后,
请参阅上方注释)。
如果 xTimer 引用的定时器未处于活动状态,
则未定义返回值。
用法示例:
static void prvAFunction( TimerHandle_t xTimer )
{
TickType_t xRemainingTime;
/* Calculate the time that remains before the timer referenced by xTimer
expires. TickType_t is an unsigned type, so the subtraction will result in
the correct answer even if the timer will not expire until after the tick
count has overflowed. */
xRemainingTime = xTimerGetExpiryTime( xTimer ) - xTaskGetTickCount();
}
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.