下载 FreeRTOS
 

出色的 RTOS & 嵌入式软件

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

xTimerStopFromISR
[定时器 API]

timers.h
 BaseType_t xTimerStopFromISR
             (
                 TimerHandle_t xTimer,
                 BaseType_t *pxHigherPriorityTaskWoken
             );

可从中断服务例程调用的 xTimerStop() 的版本。

参数:
xTimer   正在停止的定时器的句柄。
pxHigherPriorityTaskWoken   定时器服务/守护进程任务大部分时间 都处于阻塞状态,等待消息到达定时器 命令队列。 调用 xTimerStopFromISR() 会将消息写入 定时器命令队列,因此有可能将定时器服务/ 守护进程任务转换为非阻塞状态。 如果调用 xTimerStopFromISR(), 会导致定时器服务/守护进程任务退出阻塞状态,并且 守护进程任务的优先级等于或大于当前执行的 当前正在执行的任务(中断的任务),则会在 xTimerStopFromISR() 函数内部 将 *pxHigherPriorityTaskWoken 设置为 pdTRUE。 如果 xTimerStopFromISR() 将此值设置为 pdTRUE,则应在中断退出之前 那应在中断退出前执行上下文切换。
返回:
如果即使经过了 xBlockTime(以 tick 为单位)之后, 则返回 pdFAIL。 如果命令成功发送至定时器命令队列, 则返回 pdPASS。 实际处理命令的时间 取决于定时器服务/守护进程任务相对于系统中其他任务的 优先级。 定时器服务/守护进程 任务优先级由 configTIMER_TASK_PRIORITY 配置常量设置。
用法示例:

/* This scenario assumes xTimer has already been created and started.  When
an interrupt occurs, the timer should be simply stopped. */

/* The interrupt service routine that stops the timer. */
void vAnExampleInterruptServiceRoutine( void )
{
BaseType_t xHigherPriorityTaskWoken = pdFALSE;

    /* The interrupt has occurred - simply stop the timer.
    xHigherPriorityTaskWoken was set to pdFALSE where it was defined
    (within this function).  As this is an interrupt service routine, only
    FreeRTOS API functions that end in "FromISR" can be used. */
    if( xTimerStopFromISR( xTimer, &xHigherPriorityTaskWoken ) != pdPASS )
    {
        /* The stop command was not executed successfully.  Take appropriate
        action here. */
    }

    /* If xHigherPriorityTaskWoken equals pdTRUE, then a context switch
    should be performed.  The syntax required to perform a context switch
    from inside an ISR varies from port to port, and from compiler to
    compiler.  Inspect the demos for the port you are using to find the
    actual syntax required. */
    if( xHigherPriorityTaskWoken != pdFALSE )
    {
        /* Call the interrupt safe yield function here (actual function
        depends on the FreeRTOS port being used). */
    }
}





Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.