下载 FreeRTOS
 

出色的 RTOS & 嵌入式软件

内核
最新资讯
简化任何设备的身份验证云连接。
利用 CoAP 设计节能型云连接 IoT 解决方案。
11.0.0 版 FreeRTOS 内核简介:
FreeRTOS 路线图和代码贡献流程。
使用 FreeRTOS 实现 OPC-UA over TSN。

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.