下载 FreeRTOS
 

出色的 RTOS & 嵌入式软件

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

xQueueSendToBackFromISR
[队列管理]

queue.h
BaseType_t xQueueSendToBackFromISR ( QueueHandle_t xQueue, const void *pvItemToQueue, BaseType_t *pxHigherPriorityTaskWoken );

此宏用于调用 xQueueGenericSendFromISR()。

从队列尾部入队一个数据项。可在中断服务程序中使用此函数。

数据项通过复制而非引用入队,因此最好只发送较小的项,尤其是从 ISR 调用时。

参数:
xQueue 队列的句柄,数据项将发布到此队列。
pvItemToQueue 指向待入队数据项的指针。创建队列时定义了队列将保留的项的大小,因此固定数量的字节将从 pvItemToQueue 复制到队列存储区域。
pxHigherPriorityTaskWoken 如果发送到队列导致某个任务解除阻塞,并且解除阻塞的任务的优先级高于当前运行的任务,则 xQueueSendTobackFromISR() 会将 *pxHigherPriorityTaskWoken 设置为 pdTRUE。 如果 xQueueSendTobackFromISR() 将此值设置为 pdTRUE,则应在退出中断之前请求上下文切换。

从 FreeRTOSV7.3.0 开始,pxHigherPriorityTaskWoken 是一个可选参数,可设置为 NULL。

返回:
若成功发送至队列,则返回 pdPASS,否则返回 errQUEUE_FULL。
缓冲 IO(每次调用 ISR 可以获取多个值)的用法示例:
void vBufferISR( void ) { char cIn; BaseType_t xHigherPriorityTaskWoken; /* We have not woken a task at the start of the ISR. */ xHigherPriorityTaskWoken = pdFALSE; /* Loop until the buffer is empty. */ do { /* Obtain a byte from the buffer. */ cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS ); /* Post the byte. */ xQueueSendToBackFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken ); } while( portINPUT_BYTE( BUFFER_COUNT ) ); /* Now the buffer is empty we can switch context if necessary. */ if( xHigherPriorityTaskWoken ) { /* Actual macro used here is port specific. */ taskYIELD_FROM_ISR (); } }





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