Updated Mar 2025
crQUEUE_SEND
croutine.h
1crQUEUE_SEND(2 CoRoutineHandle_t xHandle,3 QueueHandle_t xQueue,4 void *pvItemToQueue,5 TickType_t xTicksToWait,6 BaseType_t *pxResult7 )
crQUEUE_SEND
The macro's
crQUEUE_SEND()
crQUEUE_RECEIVE()
xQueueSend()
xQueueReceive()
crQUEUE_SEND
crQUEUE_RECEIVE
xQueueSend()
xQueueReceive()
crQUEUE_SEND
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:
-
xHandle
The handle of the calling co-routine. This is the
parameter of the co-routine function.xHandle -
xQueue
The handle of the queue on which the data will be posted. The handle is obtained as the return value when the queue is created using the
API function.xQueueCreate() -
pvItemToQueue
A pointer to the data being posted onto the queue. The number of bytes of each queued item is specified when the queue is created. This number of bytes is copied from
into the queue itself.pvItemToQueue -
xTickToDelay
The number of ticks that the co-routine should block to wait for space to become available on the queue, should space not be available immediately. The actual amount of time this equates to is defined by
(set in FreeRTOSConfig.h). The constantconfigTICK_RATE_HZcan be used to convert ticks to milliseconds (see example below).portTICK_PERIOD_MS -
pxResult
The variable pointed to by
will be set topxResultif data was successfully posted onto the queue, otherwise it will be set to an error defined within ProjDefs.h.pdPASS
Example usage:
1// Co-routine function that blocks for a fixed period then posts a number onto2// a queue.3static void prvCoRoutineFlashTask( CoRoutineHandle_t xHandle,4 UBaseType_t uxIndex )5{6 // Variables in co-routines must be declared static if they must maintain7 // value across a blocking call.8 static BaseType_t xNumberToPost = 0;9 static BaseType_t xResult;1011 // Co-routines must begin with a call to crSTART().12 crSTART( xHandle );1314 for( ;; )15 {16 // This assumes the queue has already been created.17 crQUEUE_SEND( xHandle,18 xCoRoutineQueue,19 &xNumberToPost,20 NO_DELAY,21 &xResult );2223 if( xResult != pdPASS )24 {25 // The message was not posted!26 }2728 // Increment the number to be posted onto the queue.29 xNumberToPost++;3031 // Delay for 100 ticks.32 crDELAY( xHandle, 100 );33 }3435 // Co-routines must end with a call to crEND().36 crEND();37 }