xQueueSendToFrontFromISR
[队列管理]
queue.h
BaseType_t xQueueSendToFrontFromISR
(
QueueHandle_t xQueue,
const void *pvItemToQueue,
BaseType_t *pxHigherPriorityTaskWoken
);
这是用于调用 xQueueGenericSendFromISR() 的宏。
从队列头部入队一个数据项。可在中断服务程序中使用此函数。
数据项通过复制而非引用入队,因此最好只发送较小的项,或者发送指向该项的指针。
- 参数:
-
xQueue | 队列的句柄,数据项将发布到此队列。 |
pvItemToQueue | 指向待入队数据项的指针。创建队列时定义了队列将保留的项的大小,因此固定数量的字节将从 pvItemToQueue 复制到队列存储区域。 |
pxHigherPriorityTaskWoken | 如果发送到队列导致某个任务解除阻塞,且被解除阻塞的任务的优先级高于当前运行的任务,则 xQueueSendToFrontFromISR() 会将 *pxHigherPriorityTaskWoken 设置为 pdTRUE。 如果 xQueueSendToFrontFromISR() 将此值设置为 pdTRUE,则应在中断退出前请求上下文切换。 从 FreeRTOSV7.3.0 开始,pxHigherPriorityTaskWoken 是一个可选参数,可设置为 NULL。 |
- 返回:
- 若数据成功发送至队列,则返回 pdPass,否则返回 errQUEUE_FULL。
用法示例:
void vBufferISR( void )
{
char cIn;
BaseType_t xHigherPriorityTaskWoken;
/* We have not woken a task at the start of the ISR. */
xHigherPriorityTaskWoken = pdFALSE;
/* Obtain a byte from the buffer. */
cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );
if( cIn == EMERGENCY_MESSAGE )
{
/* Post the byte to the front of the queue. */
xQueueSendToFrontFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );
}
else
{
/* Post the byte to the back of the queue. */
xQueueSendToBackFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );
}
/* Did sending to the queue unblock a higher priority task? */
if( xHigherPriorityTaskWoken )
{
/* Actual macro used here is port specific. */
taskYIELD_FROM_ISR ();
}
}
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|