Updated May 2025
crQUEUE_SEND_FROM_ISR
croutine.h
1BaseType_t crQUEUE_SEND_FROM_ISR2 (3 QueueHandle_t xQueue,4 void *pvItemToQueue,5 BaseType_t xCoRoutinePreviouslyWoken6 )
crQUEUE_SEND_FROM_ISR()
The macros
crQUEUE_SEND_FROM_ISR()
crQUEUE_RECEIVE_FROM_ISR()
xQueueSendFromISR()
xQueueReceiveFromISR()
crQUEUE_SEND_FROM_ISR()
crQUEUE_RECEIVE_FROM_ISR()
xQueueSendFromISR()
xQueueReceiveFromISR()
crQUEUE_SEND_FROM_ISR
See the co-routine section of the web documentation for information on passing data between tasks and co-routines and between ISR's and co-routines.
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 -
xCoRoutinePreviouslyWoken
This is included so an ISR can post onto the same queue multiple times from a single interrupt. The first call should always pass in
. Subsequent calls should pass in the value returned from the previous call.pdFALSE
Returns:
- pdTRUE if a co-routine was woken by posting onto the queue. This is used by the ISR to determine if a context switch may be required following the ISR.
Example usage:
1// A co-routine that blocks on a queue waiting for characters to be received.2static void vReceivingCoRoutine( CoRoutineHandle_t xHandle,3 UBaseType_t uxIndex )4{5 char cRxedChar;6 BaseType_t xResult;78 // All co-routines must start with a call to crSTART().9 crSTART( xHandle );1011 for( ;; )12 {13 // Wait for data to become available on the queue. This assumes the14 // queue xCommsRxQueue has already been created!15 crQUEUE_RECEIVE( xHandle,16 xCommsRxQueue,17 &uxLEDToFlash,18 portMAX_DELAY,19 &xResult );2021 // Was a character received?22 if( xResult == pdPASS )23 {24 // Process the character here.25 }26 }2728 // All co-routines must end with a call to crEND().29 crEND();30}3132// An ISR that uses a queue to send characters received on a serial port to33// a co-routine.34void vUART_ISR( void )35{36 char cRxedChar;37 BaseType_t xCRWokenByPost = pdFALSE;3839 // We loop around reading characters until there are none left in the UART.40 while( UART_RX_REG_NOT_EMPTY() )41 {42 // Obtain the character from the UART.43 cRxedChar = UART_RX_REG;4445 // Post the character onto a queue. xCRWokenByPost will be pdFALSE46 // the first time around the loop. If the post causes a co-routine47 // to be woken (unblocked) then xCRWokenByPost will be set to pdTRUE.48 // In this manner we can ensure that if more than one co-routine is49 // blocked on the queue only one is woken by this ISR no matter how50 // many characters are posted to the queue.51 xCRWokenByPost = crQUEUE_SEND_FROM_ISR( xCommsRxQueue,52 &cRxedChar,53 xCRWokenByPost );54 }55}