Updated May 2025
xQueueSendFromISR
queue.h
1 BaseType_t xQueueSendFromISR2 (3 QueueHandle_t xQueue,4 const void *pvItemToQueue,5 BaseType_t *pxHigherPriorityTaskWoken6 );
This is a macro that calls
xQueueGenericSendFromISR()
xQueueSendToBackFromISR()
xQueueSendToFrontFromISR()
Post an item into the back of a queue. It is safe to use this function from within an interrupt service routine.
Items are queued by copy not reference so it is preferable to only queue small items, especially when called from an ISR. In most cases it would be preferable to store a pointer to the item being queued.
Parameters:
-
xQueue
The handle to the queue on which the item is to be posted.
-
pvItemToQueue
A pointer to the item that is to be placed on the queue. The size of the items the queue will hold was defined when the queue was created, so this many bytes will be copied from
into the queue storage area.pvItemToQueue -
pxHigherPriorityTaskWoken
will setxQueueSendFromISR()to*pxHigherPriorityTaskWokenif sending to the queue caused a task to unblock, and the unblocked task has a priority higher than the currently running task. IfpdTRUEsets this value toxQueueSendFromISR()then a context switch should be requested before the interrupt is exited. From FreeRTOS V7.3.0pdTRUEis an optional parameter and can be set to NULL.pxHigherPriorityTaskWoken
Returns:
- pdPASS if the data was successfully sent to the queue,
- errQUEUE_FULL otherwise.
Example usage for buffered IO (where the ISR can obtain more than one value per call):
1void vBufferISR( void )2{3 char cIn;4 BaseType_t xHigherPriorityTaskWoken;56 /* We have not woken a task at the start of the ISR. */7 xHigherPriorityTaskWoken = pdFALSE;89 /* Loop until the buffer is empty. */10 do11 {12 /* Obtain a byte from the buffer. */13 cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );1415 /* Post the byte. */16 xQueueSendFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );1718 } while( portINPUT_BYTE( BUFFER_COUNT ) );1920 /* Now the buffer is empty we can switch context if necessary. */21 if( xHigherPriorityTaskWoken )22 {23 /* Actual macro used here is port specific. */24 taskYIELD_FROM_ISR ();25 }26}