下载 FreeRTOS
 

出色的 RTOS & 嵌入式软件

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

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.