下载 FreeRTOS
 

出色的 RTOS & 嵌入式软件

内核
最新资讯
FreeRTOS-Plus-TCP 现具有统一的 IPv4 和 IPv6 功能,支持多接口。
为基于 FreeRTOS 的固件实现防砖化 MCU FOTA:
宣布停止支持 FreeRTOS 202012 LTS。
FreeRTOS 网站现已提供简体中文版本
新的 FreeRTOS Long Term Support 版本现已发布。

xTimerGetExpiryTime
[定时器 API]

timers.h
 TickType_t xTimerGetExpiryTime( TimerHandle_t xTimer );

返回软件定时器到期的时间, 即执行定时器回调函数的时间。

如果 xTimerGetExpiryTime() 返回的值小于当前时间, 则定时器会在 tick 计数溢出并归 0 后到期。 计数溢出在 RTOS 实现中进行处理, 因此定时器的回调函数会在正确时间执行, 无论是在 tick 计数溢出之前还是之后。

参数:
xTimer   被查询的定时器。
返回:
如果 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.