2 FreeRTOS V7.3.0 - Copyright (C) 2012 Real Time Engineers Ltd.
\r
4 FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME. PLEASE VISIT
\r
5 http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
\r
7 ***************************************************************************
\r
9 * FreeRTOS tutorial books are available in pdf and paperback. *
\r
10 * Complete, revised, and edited pdf reference manuals are also *
\r
13 * Purchasing FreeRTOS documentation will not only help you, by *
\r
14 * ensuring you get running as quickly as possible and with an *
\r
15 * in-depth knowledge of how to use FreeRTOS, it will also help *
\r
16 * the FreeRTOS project to continue with its mission of providing *
\r
17 * professional grade, cross platform, de facto standard solutions *
\r
18 * for microcontrollers - completely free of charge! *
\r
20 * >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
\r
22 * Thank you for using FreeRTOS, and thank you for your support! *
\r
24 ***************************************************************************
\r
27 This file is part of the FreeRTOS distribution.
\r
29 FreeRTOS is free software; you can redistribute it and/or modify it under
\r
30 the terms of the GNU General Public License (version 2) as published by the
\r
31 Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
\r
32 >>>NOTE<<< The modification to the GPL is included to allow you to
\r
33 distribute a combined work that includes FreeRTOS without being obliged to
\r
34 provide the source code for proprietary components outside of the FreeRTOS
\r
35 kernel. FreeRTOS is distributed in the hope that it will be useful, but
\r
36 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
\r
37 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
\r
38 more details. You should have received a copy of the GNU General Public
\r
39 License and the FreeRTOS license exception along with FreeRTOS; if not it
\r
40 can be viewed here: http://www.freertos.org/a00114.html and also obtained
\r
41 by writing to Richard Barry, contact details for whom are available on the
\r
46 ***************************************************************************
\r
48 * Having a problem? Start by reading the FAQ "My application does *
\r
49 * not run, what could be wrong?" *
\r
51 * http://www.FreeRTOS.org/FAQHelp.html *
\r
53 ***************************************************************************
\r
56 http://www.FreeRTOS.org - Documentation, training, latest versions, license
\r
57 and contact details.
\r
59 http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
\r
60 including FreeRTOS+Trace - an indispensable productivity tool.
\r
62 Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell
\r
63 the code with commercial support, indemnification, and middleware, under
\r
64 the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also
\r
65 provide a safety engineered and independently SIL3 certified version under
\r
66 the SafeRTOS brand: http://www.SafeRTOS.com.
\r
73 #ifndef INC_FREERTOS_H
\r
74 #error "include FreeRTOS.h" must appear in source files before "include queue.h"
\r
82 #include "mpu_wrappers.h"
\r
85 * Type by which queues are referenced. For example, a call to xQueueCreate()
\r
86 * returns an xQueueHandle variable that can then be used as a parameter to
\r
87 * xQueueSend(), xQueueReceive(), etc.
\r
89 typedef void * xQueueHandle;
\r
92 * Type by which queue sets are referenced. For example, a call to
\r
93 * xQueueCreateSet() returns an xQueueSet variable that can then be used as a
\r
94 * parameter to xQueueSelectFromSet(), xQueueAddToSet(), etc.
\r
96 typedef void * xQueueSetHandle;
\r
99 * Queue sets can contain both queues and semaphores, so the
\r
100 * xQueueSetMemberHandle is defined as a type to be used where a parameter or
\r
101 * return value can be either an xQueueHandle or an xSemaphoreHandle.
\r
103 typedef void * xQueueSetMemberHandle;
\r
105 /* For internal use only. */
\r
106 #define queueSEND_TO_BACK ( 0 )
\r
107 #define queueSEND_TO_FRONT ( 1 )
\r
109 /* For internal use only. These definitions *must* match those in queue.c. */
\r
110 #define queueQUEUE_TYPE_BASE ( 0U )
\r
111 #define queueQUEUE_TYPE_MUTEX ( 1U )
\r
112 #define queueQUEUE_TYPE_COUNTING_SEMAPHORE ( 2U )
\r
113 #define queueQUEUE_TYPE_BINARY_SEMAPHORE ( 3U )
\r
114 #define queueQUEUE_TYPE_RECURSIVE_MUTEX ( 4U )
\r
119 xQueueHandle xQueueCreate(
\r
120 unsigned portBASE_TYPE uxQueueLength,
\r
121 unsigned portBASE_TYPE uxItemSize
\r
125 * Creates a new queue instance. This allocates the storage required by the
\r
126 * new queue and returns a handle for the queue.
\r
128 * @param uxQueueLength The maximum number of items that the queue can contain.
\r
130 * @param uxItemSize The number of bytes each item in the queue will require.
\r
131 * Items are queued by copy, not by reference, so this is the number of bytes
\r
132 * that will be copied for each posted item. Each item on the queue must be
\r
135 * @return If the queue is successfully create then a handle to the newly
\r
136 * created queue is returned. If the queue cannot be created then 0 is
\r
147 void vATask( void *pvParameters )
\r
149 xQueueHandle xQueue1, xQueue2;
\r
151 // Create a queue capable of containing 10 unsigned long values.
\r
152 xQueue1 = xQueueCreate( 10, sizeof( unsigned long ) );
\r
155 // Queue was not created and must not be used.
\r
158 // Create a queue capable of containing 10 pointers to AMessage structures.
\r
159 // These should be passed by pointer as they contain a lot of data.
\r
160 xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
\r
163 // Queue was not created and must not be used.
\r
166 // ... Rest of task code.
\r
169 * \defgroup xQueueCreate xQueueCreate
\r
170 * \ingroup QueueManagement
\r
172 #define xQueueCreate( uxQueueLength, uxItemSize ) xQueueGenericCreate( uxQueueLength, uxItemSize, queueQUEUE_TYPE_BASE )
\r
177 portBASE_TYPE xQueueSendToToFront(
\r
178 xQueueHandle xQueue,
\r
179 const void * pvItemToQueue,
\r
180 portTickType xTicksToWait
\r
184 * This is a macro that calls xQueueGenericSend().
\r
186 * Post an item to the front of a queue. The item is queued by copy, not by
\r
187 * reference. This function must not be called from an interrupt service
\r
188 * routine. See xQueueSendFromISR () for an alternative which may be used
\r
191 * @param xQueue The handle to the queue on which the item is to be posted.
\r
193 * @param pvItemToQueue A pointer to the item that is to be placed on the
\r
194 * queue. The size of the items the queue will hold was defined when the
\r
195 * queue was created, so this many bytes will be copied from pvItemToQueue
\r
196 * into the queue storage area.
\r
198 * @param xTicksToWait The maximum amount of time the task should block
\r
199 * waiting for space to become available on the queue, should it already
\r
200 * be full. The call will return immediately if this is set to 0 and the
\r
201 * queue is full. The time is defined in tick periods so the constant
\r
202 * portTICK_RATE_MS should be used to convert to real time if this is required.
\r
204 * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL.
\r
214 unsigned long ulVar = 10UL;
\r
216 void vATask( void *pvParameters )
\r
218 xQueueHandle xQueue1, xQueue2;
\r
219 struct AMessage *pxMessage;
\r
221 // Create a queue capable of containing 10 unsigned long values.
\r
222 xQueue1 = xQueueCreate( 10, sizeof( unsigned long ) );
\r
224 // Create a queue capable of containing 10 pointers to AMessage structures.
\r
225 // These should be passed by pointer as they contain a lot of data.
\r
226 xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
\r
232 // Send an unsigned long. Wait for 10 ticks for space to become
\r
233 // available if necessary.
\r
234 if( xQueueSendToFront( xQueue1, ( void * ) &ulVar, ( portTickType ) 10 ) != pdPASS )
\r
236 // Failed to post the message, even after 10 ticks.
\r
242 // Send a pointer to a struct AMessage object. Don't block if the
\r
243 // queue is already full.
\r
244 pxMessage = & xMessage;
\r
245 xQueueSendToFront( xQueue2, ( void * ) &pxMessage, ( portTickType ) 0 );
\r
248 // ... Rest of task code.
\r
251 * \defgroup xQueueSend xQueueSend
\r
252 * \ingroup QueueManagement
\r
254 #define xQueueSendToFront( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_FRONT )
\r
259 portBASE_TYPE xQueueSendToBack(
\r
260 xQueueHandle xQueue,
\r
261 const void * pvItemToQueue,
\r
262 portTickType xTicksToWait
\r
266 * This is a macro that calls xQueueGenericSend().
\r
268 * Post an item to the back of a queue. The item is queued by copy, not by
\r
269 * reference. This function must not be called from an interrupt service
\r
270 * routine. See xQueueSendFromISR () for an alternative which may be used
\r
273 * @param xQueue The handle to the queue on which the item is to be posted.
\r
275 * @param pvItemToQueue A pointer to the item that is to be placed on the
\r
276 * queue. The size of the items the queue will hold was defined when the
\r
277 * queue was created, so this many bytes will be copied from pvItemToQueue
\r
278 * into the queue storage area.
\r
280 * @param xTicksToWait The maximum amount of time the task should block
\r
281 * waiting for space to become available on the queue, should it already
\r
282 * be full. The call will return immediately if this is set to 0 and the queue
\r
283 * is full. The time is defined in tick periods so the constant
\r
284 * portTICK_RATE_MS should be used to convert to real time if this is required.
\r
286 * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL.
\r
296 unsigned long ulVar = 10UL;
\r
298 void vATask( void *pvParameters )
\r
300 xQueueHandle xQueue1, xQueue2;
\r
301 struct AMessage *pxMessage;
\r
303 // Create a queue capable of containing 10 unsigned long values.
\r
304 xQueue1 = xQueueCreate( 10, sizeof( unsigned long ) );
\r
306 // Create a queue capable of containing 10 pointers to AMessage structures.
\r
307 // These should be passed by pointer as they contain a lot of data.
\r
308 xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
\r
314 // Send an unsigned long. Wait for 10 ticks for space to become
\r
315 // available if necessary.
\r
316 if( xQueueSendToBack( xQueue1, ( void * ) &ulVar, ( portTickType ) 10 ) != pdPASS )
\r
318 // Failed to post the message, even after 10 ticks.
\r
324 // Send a pointer to a struct AMessage object. Don't block if the
\r
325 // queue is already full.
\r
326 pxMessage = & xMessage;
\r
327 xQueueSendToBack( xQueue2, ( void * ) &pxMessage, ( portTickType ) 0 );
\r
330 // ... Rest of task code.
\r
333 * \defgroup xQueueSend xQueueSend
\r
334 * \ingroup QueueManagement
\r
336 #define xQueueSendToBack( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK )
\r
341 portBASE_TYPE xQueueSend(
\r
342 xQueueHandle xQueue,
\r
343 const void * pvItemToQueue,
\r
344 portTickType xTicksToWait
\r
348 * This is a macro that calls xQueueGenericSend(). It is included for
\r
349 * backward compatibility with versions of FreeRTOS.org that did not
\r
350 * include the xQueueSendToFront() and xQueueSendToBack() macros. It is
\r
351 * equivalent to xQueueSendToBack().
\r
353 * Post an item on a queue. The item is queued by copy, not by reference.
\r
354 * This function must not be called from an interrupt service routine.
\r
355 * See xQueueSendFromISR () for an alternative which may be used in an ISR.
\r
357 * @param xQueue The handle to the queue on which the item is to be posted.
\r
359 * @param pvItemToQueue A pointer to the item that is to be placed on the
\r
360 * queue. The size of the items the queue will hold was defined when the
\r
361 * queue was created, so this many bytes will be copied from pvItemToQueue
\r
362 * into the queue storage area.
\r
364 * @param xTicksToWait The maximum amount of time the task should block
\r
365 * waiting for space to become available on the queue, should it already
\r
366 * be full. The call will return immediately if this is set to 0 and the
\r
367 * queue is full. The time is defined in tick periods so the constant
\r
368 * portTICK_RATE_MS should be used to convert to real time if this is required.
\r
370 * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL.
\r
380 unsigned long ulVar = 10UL;
\r
382 void vATask( void *pvParameters )
\r
384 xQueueHandle xQueue1, xQueue2;
\r
385 struct AMessage *pxMessage;
\r
387 // Create a queue capable of containing 10 unsigned long values.
\r
388 xQueue1 = xQueueCreate( 10, sizeof( unsigned long ) );
\r
390 // Create a queue capable of containing 10 pointers to AMessage structures.
\r
391 // These should be passed by pointer as they contain a lot of data.
\r
392 xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
\r
398 // Send an unsigned long. Wait for 10 ticks for space to become
\r
399 // available if necessary.
\r
400 if( xQueueSend( xQueue1, ( void * ) &ulVar, ( portTickType ) 10 ) != pdPASS )
\r
402 // Failed to post the message, even after 10 ticks.
\r
408 // Send a pointer to a struct AMessage object. Don't block if the
\r
409 // queue is already full.
\r
410 pxMessage = & xMessage;
\r
411 xQueueSend( xQueue2, ( void * ) &pxMessage, ( portTickType ) 0 );
\r
414 // ... Rest of task code.
\r
417 * \defgroup xQueueSend xQueueSend
\r
418 * \ingroup QueueManagement
\r
420 #define xQueueSend( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK )
\r
426 portBASE_TYPE xQueueGenericSend(
\r
427 xQueueHandle xQueue,
\r
428 const void * pvItemToQueue,
\r
429 portTickType xTicksToWait
\r
430 portBASE_TYPE xCopyPosition
\r
434 * It is preferred that the macros xQueueSend(), xQueueSendToFront() and
\r
435 * xQueueSendToBack() are used in place of calling this function directly.
\r
437 * Post an item on a queue. The item is queued by copy, not by reference.
\r
438 * This function must not be called from an interrupt service routine.
\r
439 * See xQueueSendFromISR () for an alternative which may be used in an ISR.
\r
441 * @param xQueue The handle to the queue on which the item is to be posted.
\r
443 * @param pvItemToQueue A pointer to the item that is to be placed on the
\r
444 * queue. The size of the items the queue will hold was defined when the
\r
445 * queue was created, so this many bytes will be copied from pvItemToQueue
\r
446 * into the queue storage area.
\r
448 * @param xTicksToWait The maximum amount of time the task should block
\r
449 * waiting for space to become available on the queue, should it already
\r
450 * be full. The call will return immediately if this is set to 0 and the
\r
451 * queue is full. The time is defined in tick periods so the constant
\r
452 * portTICK_RATE_MS should be used to convert to real time if this is required.
\r
454 * @param xCopyPosition Can take the value queueSEND_TO_BACK to place the
\r
455 * item at the back of the queue, or queueSEND_TO_FRONT to place the item
\r
456 * at the front of the queue (for high priority messages).
\r
458 * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL.
\r
468 unsigned long ulVar = 10UL;
\r
470 void vATask( void *pvParameters )
\r
472 xQueueHandle xQueue1, xQueue2;
\r
473 struct AMessage *pxMessage;
\r
475 // Create a queue capable of containing 10 unsigned long values.
\r
476 xQueue1 = xQueueCreate( 10, sizeof( unsigned long ) );
\r
478 // Create a queue capable of containing 10 pointers to AMessage structures.
\r
479 // These should be passed by pointer as they contain a lot of data.
\r
480 xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
\r
486 // Send an unsigned long. Wait for 10 ticks for space to become
\r
487 // available if necessary.
\r
488 if( xQueueGenericSend( xQueue1, ( void * ) &ulVar, ( portTickType ) 10, queueSEND_TO_BACK ) != pdPASS )
\r
490 // Failed to post the message, even after 10 ticks.
\r
496 // Send a pointer to a struct AMessage object. Don't block if the
\r
497 // queue is already full.
\r
498 pxMessage = & xMessage;
\r
499 xQueueGenericSend( xQueue2, ( void * ) &pxMessage, ( portTickType ) 0, queueSEND_TO_BACK );
\r
502 // ... Rest of task code.
\r
505 * \defgroup xQueueSend xQueueSend
\r
506 * \ingroup QueueManagement
\r
508 signed portBASE_TYPE xQueueGenericSend( xQueueHandle pxQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition );
\r
513 portBASE_TYPE xQueuePeek(
\r
514 xQueueHandle xQueue,
\r
516 portTickType xTicksToWait
\r
519 * This is a macro that calls the xQueueGenericReceive() function.
\r
521 * Receive an item from a queue without removing the item from the queue.
\r
522 * The item is received by copy so a buffer of adequate size must be
\r
523 * provided. The number of bytes copied into the buffer was defined when
\r
524 * the queue was created.
\r
526 * Successfully received items remain on the queue so will be returned again
\r
527 * by the next call, or a call to xQueueReceive().
\r
529 * This macro must not be used in an interrupt service routine.
\r
531 * @param pxQueue The handle to the queue from which the item is to be
\r
534 * @param pvBuffer Pointer to the buffer into which the received item will
\r
537 * @param xTicksToWait The maximum amount of time the task should block
\r
538 * waiting for an item to receive should the queue be empty at the time
\r
539 * of the call. The time is defined in tick periods so the constant
\r
540 * portTICK_RATE_MS should be used to convert to real time if this is required.
\r
541 * xQueuePeek() will return immediately if xTicksToWait is 0 and the queue
\r
544 * @return pdTRUE if an item was successfully received from the queue,
\r
545 * otherwise pdFALSE.
\r
555 xQueueHandle xQueue;
\r
557 // Task to create a queue and post a value.
\r
558 void vATask( void *pvParameters )
\r
560 struct AMessage *pxMessage;
\r
562 // Create a queue capable of containing 10 pointers to AMessage structures.
\r
563 // These should be passed by pointer as they contain a lot of data.
\r
564 xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) );
\r
567 // Failed to create the queue.
\r
572 // Send a pointer to a struct AMessage object. Don't block if the
\r
573 // queue is already full.
\r
574 pxMessage = & xMessage;
\r
575 xQueueSend( xQueue, ( void * ) &pxMessage, ( portTickType ) 0 );
\r
577 // ... Rest of task code.
\r
580 // Task to peek the data from the queue.
\r
581 void vADifferentTask( void *pvParameters )
\r
583 struct AMessage *pxRxedMessage;
\r
587 // Peek a message on the created queue. Block for 10 ticks if a
\r
588 // message is not immediately available.
\r
589 if( xQueuePeek( xQueue, &( pxRxedMessage ), ( portTickType ) 10 ) )
\r
591 // pcRxedMessage now points to the struct AMessage variable posted
\r
592 // by vATask, but the item still remains on the queue.
\r
596 // ... Rest of task code.
\r
599 * \defgroup xQueueReceive xQueueReceive
\r
600 * \ingroup QueueManagement
\r
602 #define xQueuePeek( xQueue, pvBuffer, xTicksToWait ) xQueueGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdTRUE )
\r
607 portBASE_TYPE xQueueReceive(
\r
608 xQueueHandle xQueue,
\r
610 portTickType xTicksToWait
\r
613 * This is a macro that calls the xQueueGenericReceive() function.
\r
615 * Receive an item from a queue. The item is received by copy so a buffer of
\r
616 * adequate size must be provided. The number of bytes copied into the buffer
\r
617 * was defined when the queue was created.
\r
619 * Successfully received items are removed from the queue.
\r
621 * This function must not be used in an interrupt service routine. See
\r
622 * xQueueReceiveFromISR for an alternative that can.
\r
624 * @param pxQueue The handle to the queue from which the item is to be
\r
627 * @param pvBuffer Pointer to the buffer into which the received item will
\r
630 * @param xTicksToWait The maximum amount of time the task should block
\r
631 * waiting for an item to receive should the queue be empty at the time
\r
632 * of the call. xQueueReceive() will return immediately if xTicksToWait
\r
633 * is zero and the queue is empty. The time is defined in tick periods so the
\r
634 * constant portTICK_RATE_MS should be used to convert to real time if this is
\r
637 * @return pdTRUE if an item was successfully received from the queue,
\r
638 * otherwise pdFALSE.
\r
648 xQueueHandle xQueue;
\r
650 // Task to create a queue and post a value.
\r
651 void vATask( void *pvParameters )
\r
653 struct AMessage *pxMessage;
\r
655 // Create a queue capable of containing 10 pointers to AMessage structures.
\r
656 // These should be passed by pointer as they contain a lot of data.
\r
657 xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) );
\r
660 // Failed to create the queue.
\r
665 // Send a pointer to a struct AMessage object. Don't block if the
\r
666 // queue is already full.
\r
667 pxMessage = & xMessage;
\r
668 xQueueSend( xQueue, ( void * ) &pxMessage, ( portTickType ) 0 );
\r
670 // ... Rest of task code.
\r
673 // Task to receive from the queue.
\r
674 void vADifferentTask( void *pvParameters )
\r
676 struct AMessage *pxRxedMessage;
\r
680 // Receive a message on the created queue. Block for 10 ticks if a
\r
681 // message is not immediately available.
\r
682 if( xQueueReceive( xQueue, &( pxRxedMessage ), ( portTickType ) 10 ) )
\r
684 // pcRxedMessage now points to the struct AMessage variable posted
\r
689 // ... Rest of task code.
\r
692 * \defgroup xQueueReceive xQueueReceive
\r
693 * \ingroup QueueManagement
\r
695 #define xQueueReceive( xQueue, pvBuffer, xTicksToWait ) xQueueGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdFALSE )
\r
701 portBASE_TYPE xQueueGenericReceive(
\r
702 xQueueHandle xQueue,
\r
704 portTickType xTicksToWait
\r
705 portBASE_TYPE xJustPeek
\r
708 * It is preferred that the macro xQueueReceive() be used rather than calling
\r
709 * this function directly.
\r
711 * Receive an item from a queue. The item is received by copy so a buffer of
\r
712 * adequate size must be provided. The number of bytes copied into the buffer
\r
713 * was defined when the queue was created.
\r
715 * This function must not be used in an interrupt service routine. See
\r
716 * xQueueReceiveFromISR for an alternative that can.
\r
718 * @param pxQueue The handle to the queue from which the item is to be
\r
721 * @param pvBuffer Pointer to the buffer into which the received item will
\r
724 * @param xTicksToWait The maximum amount of time the task should block
\r
725 * waiting for an item to receive should the queue be empty at the time
\r
726 * of the call. The time is defined in tick periods so the constant
\r
727 * portTICK_RATE_MS should be used to convert to real time if this is required.
\r
728 * xQueueGenericReceive() will return immediately if the queue is empty and
\r
729 * xTicksToWait is 0.
\r
731 * @param xJustPeek When set to true, the item received from the queue is not
\r
732 * actually removed from the queue - meaning a subsequent call to
\r
733 * xQueueReceive() will return the same item. When set to false, the item
\r
734 * being received from the queue is also removed from the queue.
\r
736 * @return pdTRUE if an item was successfully received from the queue,
\r
737 * otherwise pdFALSE.
\r
747 xQueueHandle xQueue;
\r
749 // Task to create a queue and post a value.
\r
750 void vATask( void *pvParameters )
\r
752 struct AMessage *pxMessage;
\r
754 // Create a queue capable of containing 10 pointers to AMessage structures.
\r
755 // These should be passed by pointer as they contain a lot of data.
\r
756 xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) );
\r
759 // Failed to create the queue.
\r
764 // Send a pointer to a struct AMessage object. Don't block if the
\r
765 // queue is already full.
\r
766 pxMessage = & xMessage;
\r
767 xQueueSend( xQueue, ( void * ) &pxMessage, ( portTickType ) 0 );
\r
769 // ... Rest of task code.
\r
772 // Task to receive from the queue.
\r
773 void vADifferentTask( void *pvParameters )
\r
775 struct AMessage *pxRxedMessage;
\r
779 // Receive a message on the created queue. Block for 10 ticks if a
\r
780 // message is not immediately available.
\r
781 if( xQueueGenericReceive( xQueue, &( pxRxedMessage ), ( portTickType ) 10 ) )
\r
783 // pcRxedMessage now points to the struct AMessage variable posted
\r
788 // ... Rest of task code.
\r
791 * \defgroup xQueueReceive xQueueReceive
\r
792 * \ingroup QueueManagement
\r
794 signed portBASE_TYPE xQueueGenericReceive( xQueueHandle xQueue, void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeek );
\r
798 * <pre>unsigned portBASE_TYPE uxQueueMessagesWaiting( const xQueueHandle xQueue );</pre>
\r
800 * Return the number of messages stored in a queue.
\r
802 * @param xQueue A handle to the queue being queried.
\r
804 * @return The number of messages available in the queue.
\r
806 * \page uxQueueMessagesWaiting uxQueueMessagesWaiting
\r
807 * \ingroup QueueManagement
\r
809 unsigned portBASE_TYPE uxQueueMessagesWaiting( const xQueueHandle xQueue );
\r
813 * <pre>void vQueueDelete( xQueueHandle xQueue );</pre>
\r
815 * Delete a queue - freeing all the memory allocated for storing of items
\r
816 * placed on the queue.
\r
818 * @param xQueue A handle to the queue to be deleted.
\r
820 * \page vQueueDelete vQueueDelete
\r
821 * \ingroup QueueManagement
\r
823 void vQueueDelete( xQueueHandle pxQueue );
\r
828 portBASE_TYPE xQueueSendToFrontFromISR(
\r
829 xQueueHandle pxQueue,
\r
830 const void *pvItemToQueue,
\r
831 portBASE_TYPE *pxHigherPriorityTaskWoken
\r
835 * This is a macro that calls xQueueGenericSendFromISR().
\r
837 * Post an item to the front of a queue. It is safe to use this macro from
\r
838 * within an interrupt service routine.
\r
840 * Items are queued by copy not reference so it is preferable to only
\r
841 * queue small items, especially when called from an ISR. In most cases
\r
842 * it would be preferable to store a pointer to the item being queued.
\r
844 * @param xQueue The handle to the queue on which the item is to be posted.
\r
846 * @param pvItemToQueue A pointer to the item that is to be placed on the
\r
847 * queue. The size of the items the queue will hold was defined when the
\r
848 * queue was created, so this many bytes will be copied from pvItemToQueue
\r
849 * into the queue storage area.
\r
851 * @param pxHigherPriorityTaskWoken xQueueSendToFrontFromISR() will set
\r
852 * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task
\r
853 * to unblock, and the unblocked task has a priority higher than the currently
\r
854 * running task. If xQueueSendToFromFromISR() sets this value to pdTRUE then
\r
855 * a context switch should be requested before the interrupt is exited.
\r
857 * @return pdTRUE if the data was successfully sent to the queue, otherwise
\r
860 * Example usage for buffered IO (where the ISR can obtain more than one value
\r
863 void vBufferISR( void )
\r
866 portBASE_TYPE xHigherPrioritTaskWoken;
\r
868 // We have not woken a task at the start of the ISR.
\r
869 xHigherPriorityTaskWoken = pdFALSE;
\r
871 // Loop until the buffer is empty.
\r
874 // Obtain a byte from the buffer.
\r
875 cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );
\r
878 xQueueSendToFrontFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );
\r
880 } while( portINPUT_BYTE( BUFFER_COUNT ) );
\r
882 // Now the buffer is empty we can switch context if necessary.
\r
883 if( xHigherPriorityTaskWoken )
\r
890 * \defgroup xQueueSendFromISR xQueueSendFromISR
\r
891 * \ingroup QueueManagement
\r
893 #define xQueueSendToFrontFromISR( pxQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( pxQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_FRONT )
\r
899 portBASE_TYPE xQueueSendToBackFromISR(
\r
900 xQueueHandle pxQueue,
\r
901 const void *pvItemToQueue,
\r
902 portBASE_TYPE *pxHigherPriorityTaskWoken
\r
906 * This is a macro that calls xQueueGenericSendFromISR().
\r
908 * Post an item to the back of a queue. It is safe to use this macro from
\r
909 * within an interrupt service routine.
\r
911 * Items are queued by copy not reference so it is preferable to only
\r
912 * queue small items, especially when called from an ISR. In most cases
\r
913 * it would be preferable to store a pointer to the item being queued.
\r
915 * @param xQueue The handle to the queue on which the item is to be posted.
\r
917 * @param pvItemToQueue A pointer to the item that is to be placed on the
\r
918 * queue. The size of the items the queue will hold was defined when the
\r
919 * queue was created, so this many bytes will be copied from pvItemToQueue
\r
920 * into the queue storage area.
\r
922 * @param pxHigherPriorityTaskWoken xQueueSendToBackFromISR() will set
\r
923 * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task
\r
924 * to unblock, and the unblocked task has a priority higher than the currently
\r
925 * running task. If xQueueSendToBackFromISR() sets this value to pdTRUE then
\r
926 * a context switch should be requested before the interrupt is exited.
\r
928 * @return pdTRUE if the data was successfully sent to the queue, otherwise
\r
931 * Example usage for buffered IO (where the ISR can obtain more than one value
\r
934 void vBufferISR( void )
\r
937 portBASE_TYPE xHigherPriorityTaskWoken;
\r
939 // We have not woken a task at the start of the ISR.
\r
940 xHigherPriorityTaskWoken = pdFALSE;
\r
942 // Loop until the buffer is empty.
\r
945 // Obtain a byte from the buffer.
\r
946 cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );
\r
949 xQueueSendToBackFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );
\r
951 } while( portINPUT_BYTE( BUFFER_COUNT ) );
\r
953 // Now the buffer is empty we can switch context if necessary.
\r
954 if( xHigherPriorityTaskWoken )
\r
961 * \defgroup xQueueSendFromISR xQueueSendFromISR
\r
962 * \ingroup QueueManagement
\r
964 #define xQueueSendToBackFromISR( pxQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( pxQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK )
\r
969 portBASE_TYPE xQueueSendFromISR(
\r
970 xQueueHandle pxQueue,
\r
971 const void *pvItemToQueue,
\r
972 portBASE_TYPE *pxHigherPriorityTaskWoken
\r
976 * This is a macro that calls xQueueGenericSendFromISR(). It is included
\r
977 * for backward compatibility with versions of FreeRTOS.org that did not
\r
978 * include the xQueueSendToBackFromISR() and xQueueSendToFrontFromISR()
\r
981 * Post an item to the back of a queue. It is safe to use this function from
\r
982 * within an interrupt service routine.
\r
984 * Items are queued by copy not reference so it is preferable to only
\r
985 * queue small items, especially when called from an ISR. In most cases
\r
986 * it would be preferable to store a pointer to the item being queued.
\r
988 * @param xQueue The handle to the queue on which the item is to be posted.
\r
990 * @param pvItemToQueue A pointer to the item that is to be placed on the
\r
991 * queue. The size of the items the queue will hold was defined when the
\r
992 * queue was created, so this many bytes will be copied from pvItemToQueue
\r
993 * into the queue storage area.
\r
995 * @param pxHigherPriorityTaskWoken xQueueSendFromISR() will set
\r
996 * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task
\r
997 * to unblock, and the unblocked task has a priority higher than the currently
\r
998 * running task. If xQueueSendFromISR() sets this value to pdTRUE then
\r
999 * a context switch should be requested before the interrupt is exited.
\r
1001 * @return pdTRUE if the data was successfully sent to the queue, otherwise
\r
1004 * Example usage for buffered IO (where the ISR can obtain more than one value
\r
1007 void vBufferISR( void )
\r
1010 portBASE_TYPE xHigherPriorityTaskWoken;
\r
1012 // We have not woken a task at the start of the ISR.
\r
1013 xHigherPriorityTaskWoken = pdFALSE;
\r
1015 // Loop until the buffer is empty.
\r
1018 // Obtain a byte from the buffer.
\r
1019 cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );
\r
1022 xQueueSendFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );
\r
1024 } while( portINPUT_BYTE( BUFFER_COUNT ) );
\r
1026 // Now the buffer is empty we can switch context if necessary.
\r
1027 if( xHigherPriorityTaskWoken )
\r
1029 // Actual macro used here is port specific.
\r
1030 taskYIELD_FROM_ISR ();
\r
1035 * \defgroup xQueueSendFromISR xQueueSendFromISR
\r
1036 * \ingroup QueueManagement
\r
1038 #define xQueueSendFromISR( pxQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( pxQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK )
\r
1043 portBASE_TYPE xQueueGenericSendFromISR(
\r
1044 xQueueHandle pxQueue,
\r
1045 const void *pvItemToQueue,
\r
1046 portBASE_TYPE *pxHigherPriorityTaskWoken,
\r
1047 portBASE_TYPE xCopyPosition
\r
1051 * It is preferred that the macros xQueueSendFromISR(),
\r
1052 * xQueueSendToFrontFromISR() and xQueueSendToBackFromISR() be used in place
\r
1053 * of calling this function directly.
\r
1055 * Post an item on a queue. It is safe to use this function from within an
\r
1056 * interrupt service routine.
\r
1058 * Items are queued by copy not reference so it is preferable to only
\r
1059 * queue small items, especially when called from an ISR. In most cases
\r
1060 * it would be preferable to store a pointer to the item being queued.
\r
1062 * @param xQueue The handle to the queue on which the item is to be posted.
\r
1064 * @param pvItemToQueue A pointer to the item that is to be placed on the
\r
1065 * queue. The size of the items the queue will hold was defined when the
\r
1066 * queue was created, so this many bytes will be copied from pvItemToQueue
\r
1067 * into the queue storage area.
\r
1069 * @param pxHigherPriorityTaskWoken xQueueGenericSendFromISR() will set
\r
1070 * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task
\r
1071 * to unblock, and the unblocked task has a priority higher than the currently
\r
1072 * running task. If xQueueGenericSendFromISR() sets this value to pdTRUE then
\r
1073 * a context switch should be requested before the interrupt is exited.
\r
1075 * @param xCopyPosition Can take the value queueSEND_TO_BACK to place the
\r
1076 * item at the back of the queue, or queueSEND_TO_FRONT to place the item
\r
1077 * at the front of the queue (for high priority messages).
\r
1079 * @return pdTRUE if the data was successfully sent to the queue, otherwise
\r
1082 * Example usage for buffered IO (where the ISR can obtain more than one value
\r
1085 void vBufferISR( void )
\r
1088 portBASE_TYPE xHigherPriorityTaskWokenByPost;
\r
1090 // We have not woken a task at the start of the ISR.
\r
1091 xHigherPriorityTaskWokenByPost = pdFALSE;
\r
1093 // Loop until the buffer is empty.
\r
1096 // Obtain a byte from the buffer.
\r
1097 cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );
\r
1099 // Post each byte.
\r
1100 xQueueGenericSendFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWokenByPost, queueSEND_TO_BACK );
\r
1102 } while( portINPUT_BYTE( BUFFER_COUNT ) );
\r
1104 // Now the buffer is empty we can switch context if necessary. Note that the
\r
1105 // name of the yield function required is port specific.
\r
1106 if( xHigherPriorityTaskWokenByPost )
\r
1108 taskYIELD_YIELD_FROM_ISR();
\r
1113 * \defgroup xQueueSendFromISR xQueueSendFromISR
\r
1114 * \ingroup QueueManagement
\r
1116 signed portBASE_TYPE xQueueGenericSendFromISR( xQueueHandle pxQueue, const void * const pvItemToQueue, signed portBASE_TYPE *pxHigherPriorityTaskWoken, portBASE_TYPE xCopyPosition );
\r
1121 portBASE_TYPE xQueueReceiveFromISR(
\r
1122 xQueueHandle pxQueue,
\r
1124 portBASE_TYPE *pxTaskWoken
\r
1128 * Receive an item from a queue. It is safe to use this function from within an
\r
1129 * interrupt service routine.
\r
1131 * @param pxQueue The handle to the queue from which the item is to be
\r
1134 * @param pvBuffer Pointer to the buffer into which the received item will
\r
1137 * @param pxTaskWoken A task may be blocked waiting for space to become
\r
1138 * available on the queue. If xQueueReceiveFromISR causes such a task to
\r
1139 * unblock *pxTaskWoken will get set to pdTRUE, otherwise *pxTaskWoken will
\r
1140 * remain unchanged.
\r
1142 * @return pdTRUE if an item was successfully received from the queue,
\r
1143 * otherwise pdFALSE.
\r
1148 xQueueHandle xQueue;
\r
1150 // Function to create a queue and post some values.
\r
1151 void vAFunction( void *pvParameters )
\r
1153 char cValueToPost;
\r
1154 const portTickType xBlockTime = ( portTickType )0xff;
\r
1156 // Create a queue capable of containing 10 characters.
\r
1157 xQueue = xQueueCreate( 10, sizeof( char ) );
\r
1160 // Failed to create the queue.
\r
1165 // Post some characters that will be used within an ISR. If the queue
\r
1166 // is full then this task will block for xBlockTime ticks.
\r
1167 cValueToPost = 'a';
\r
1168 xQueueSend( xQueue, ( void * ) &cValueToPost, xBlockTime );
\r
1169 cValueToPost = 'b';
\r
1170 xQueueSend( xQueue, ( void * ) &cValueToPost, xBlockTime );
\r
1172 // ... keep posting characters ... this task may block when the queue
\r
1175 cValueToPost = 'c';
\r
1176 xQueueSend( xQueue, ( void * ) &cValueToPost, xBlockTime );
\r
1179 // ISR that outputs all the characters received on the queue.
\r
1180 void vISR_Routine( void )
\r
1182 portBASE_TYPE xTaskWokenByReceive = pdFALSE;
\r
1185 while( xQueueReceiveFromISR( xQueue, ( void * ) &cRxedChar, &xTaskWokenByReceive) )
\r
1187 // A character was received. Output the character now.
\r
1188 vOutputCharacter( cRxedChar );
\r
1190 // If removing the character from the queue woke the task that was
\r
1191 // posting onto the queue cTaskWokenByReceive will have been set to
\r
1192 // pdTRUE. No matter how many times this loop iterates only one
\r
1193 // task will be woken.
\r
1196 if( cTaskWokenByPost != ( char ) pdFALSE;
\r
1202 * \defgroup xQueueReceiveFromISR xQueueReceiveFromISR
\r
1203 * \ingroup QueueManagement
\r
1205 signed portBASE_TYPE xQueueReceiveFromISR( xQueueHandle pxQueue, void * const pvBuffer, signed portBASE_TYPE *pxHigherPriorityTaskWoken );
\r
1208 * Utilities to query queues that are safe to use from an ISR. These utilities
\r
1209 * should be used only from witin an ISR, or within a critical section.
\r
1211 signed portBASE_TYPE xQueueIsQueueEmptyFromISR( const xQueueHandle pxQueue );
\r
1212 signed portBASE_TYPE xQueueIsQueueFullFromISR( const xQueueHandle pxQueue );
\r
1213 unsigned portBASE_TYPE uxQueueMessagesWaitingFromISR( const xQueueHandle pxQueue );
\r
1217 * xQueueAltGenericSend() is an alternative version of xQueueGenericSend().
\r
1218 * Likewise xQueueAltGenericReceive() is an alternative version of
\r
1219 * xQueueGenericReceive().
\r
1221 * The source code that implements the alternative (Alt) API is much
\r
1222 * simpler because it executes everything from within a critical section.
\r
1223 * This is the approach taken by many other RTOSes, but FreeRTOS.org has the
\r
1224 * preferred fully featured API too. The fully featured API has more
\r
1225 * complex code that takes longer to execute, but makes much less use of
\r
1226 * critical sections. Therefore the alternative API sacrifices interrupt
\r
1227 * responsiveness to gain execution speed, whereas the fully featured API
\r
1228 * sacrifices execution speed to ensure better interrupt responsiveness.
\r
1230 signed portBASE_TYPE xQueueAltGenericSend( xQueueHandle pxQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition );
\r
1231 signed portBASE_TYPE xQueueAltGenericReceive( xQueueHandle pxQueue, void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking );
\r
1232 #define xQueueAltSendToFront( xQueue, pvItemToQueue, xTicksToWait ) xQueueAltGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_FRONT )
\r
1233 #define xQueueAltSendToBack( xQueue, pvItemToQueue, xTicksToWait ) xQueueAltGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK )
\r
1234 #define xQueueAltReceive( xQueue, pvBuffer, xTicksToWait ) xQueueAltGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdFALSE )
\r
1235 #define xQueueAltPeek( xQueue, pvBuffer, xTicksToWait ) xQueueAltGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdTRUE )
\r
1238 * The functions defined above are for passing data to and from tasks. The
\r
1239 * functions below are the equivalents for passing data to and from
\r
1242 * These functions are called from the co-routine macro implementation and
\r
1243 * should not be called directly from application code. Instead use the macro
\r
1244 * wrappers defined within croutine.h.
\r
1246 signed portBASE_TYPE xQueueCRSendFromISR( xQueueHandle pxQueue, const void *pvItemToQueue, signed portBASE_TYPE xCoRoutinePreviouslyWoken );
\r
1247 signed portBASE_TYPE xQueueCRReceiveFromISR( xQueueHandle pxQueue, void *pvBuffer, signed portBASE_TYPE *pxTaskWoken );
\r
1248 signed portBASE_TYPE xQueueCRSend( xQueueHandle pxQueue, const void *pvItemToQueue, portTickType xTicksToWait );
\r
1249 signed portBASE_TYPE xQueueCRReceive( xQueueHandle pxQueue, void *pvBuffer, portTickType xTicksToWait );
\r
1252 * For internal use only. Use xSemaphoreCreateMutex(),
\r
1253 * xSemaphoreCreateCounting() or xSemaphoreGetMutexHolder() instead of calling
\r
1254 * these functions directly.
\r
1256 xQueueHandle xQueueCreateMutex( unsigned char ucQueueType );
\r
1257 xQueueHandle xQueueCreateCountingSemaphore( unsigned portBASE_TYPE uxCountValue, unsigned portBASE_TYPE uxInitialCount );
\r
1258 void* xQueueGetMutexHolder( xQueueHandle xSemaphore );
\r
1261 * For internal use only. Use xSemaphoreTakeMutexRecursive() or
\r
1262 * xSemaphoreGiveMutexRecursive() instead of calling these functions directly.
\r
1264 portBASE_TYPE xQueueTakeMutexRecursive( xQueueHandle pxMutex, portTickType xBlockTime );
\r
1265 portBASE_TYPE xQueueGiveMutexRecursive( xQueueHandle pxMutex );
\r
1268 * Reset a queue back to its original empty state. pdPASS is returned if the
\r
1269 * queue is successfully reset. pdFAIL is returned if the queue could not be
\r
1270 * reset because there are tasks blocked on the queue waiting to either
\r
1271 * receive from the queue or send to the queue.
\r
1273 #define xQueueReset( pxQueue ) xQueueGenericReset( pxQueue, pdFALSE )
\r
1276 * The registry is provided as a means for kernel aware debuggers to
\r
1277 * locate queues, semaphores and mutexes. Call vQueueAddToRegistry() add
\r
1278 * a queue, semaphore or mutex handle to the registry if you want the handle
\r
1279 * to be available to a kernel aware debugger. If you are not using a kernel
\r
1280 * aware debugger then this function can be ignored.
\r
1282 * configQUEUE_REGISTRY_SIZE defines the maximum number of handles the
\r
1283 * registry can hold. configQUEUE_REGISTRY_SIZE must be greater than 0
\r
1284 * within FreeRTOSConfig.h for the registry to be available. Its value
\r
1285 * does not effect the number of queues, semaphores and mutexes that can be
\r
1286 * created - just the number that the registry can hold.
\r
1288 * @param xQueue The handle of the queue being added to the registry. This
\r
1289 * is the handle returned by a call to xQueueCreate(). Semaphore and mutex
\r
1290 * handles can also be passed in here.
\r
1292 * @param pcName The name to be associated with the handle. This is the
\r
1293 * name that the kernel aware debugger will display.
\r
1295 #if configQUEUE_REGISTRY_SIZE > 0U
\r
1296 void vQueueAddToRegistry( xQueueHandle xQueue, signed char *pcName );
\r
1300 * Generic version of the queue creation function, which is in turn called by
\r
1301 * any queue, semaphore or mutex creation function or macro.
\r
1303 xQueueHandle xQueueGenericCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBASE_TYPE uxItemSize, unsigned char ucQueueType );
\r
1306 * Queue sets provide a mechanism to allow a task to block (pend) on a read
\r
1307 * operation from multiple queues or semaphores simultaneously.
\r
1309 * See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this
\r
1312 * A queue set must be explicitly created using a call to xQueueCreateSet()
\r
1313 * before it can be used. Once created, standard FreeRTOS queues and semaphores
\r
1314 * can be added to the set using calls to xQueueAddToSet().
\r
1315 * xQueueSelectFromSet() is then used to determine which, if any, of the queues
\r
1316 * or semaphores contained in the set is in a state where a queue read or
\r
1317 * semaphore take operation would be successful.
\r
1319 * Note 1: See the documentation on http://wwwFreeRTOS.org for reasons why
\r
1320 * queue sets are very rarely needed in practice as there are simpler
\r
1321 * alternatives. Queue sets are provided to allow FreeRTOS to be integrated
\r
1322 * with legacy third party driver code.
\r
1324 * Note 2: Blocking on a queue set that contains a mutex will not cause the
\r
1325 * mutex holder to inherit the priority of the blocked task.
\r
1327 * Note 3: An additional 4 bytes of RAM is required for each space in a every
\r
1328 * queue added to a queue set. Therefore counting semaphores with large maximum
\r
1329 * counts should not be added to queue sets.
\r
1331 * Note 4: A received (in the case of a queue) or take (in the case of a
\r
1332 * semaphore) operation must not be performed on a member of a queue set unless
\r
1333 * a call to xQueueSelect() has first returned a handle to that set member.
\r
1335 * @param uxEventQueueLength Queue sets themselves queue events that occur on
\r
1336 * the queues and semaphores contained in the set. uxEventQueueLength specifies
\r
1337 * the maximum number of events that can be queued at once. To be absolutely
\r
1338 * certain that events are not lost uxEventQueueLength should be set to the
\r
1339 * total sum of the length of the queues added to the set, where binary
\r
1340 * semaphores and mutexes have a length of 1, and counting semaphores have a
\r
1341 * length set by their maximum count value. Examples:
\r
1342 * + If a queue set is to hold a queue of length 5, another queue of length 12,
\r
1343 * and a binary semaphore, then uxEventQueueLength should be set to
\r
1344 * (5 + 12 + 1), or 18.
\r
1345 * + If a queue set is to hold three binary semaphores then uxEventQueueLength
\r
1346 * should be set to (1 + 1 + 1 ), or 3.
\r
1347 * + If a queue set is to hold a counting semaphore that has a maximum count of
\r
1348 * 5, and a counting semaphore that has a maximum count of 3, then
\r
1349 * uxEventQueueLength should be set to (5 + 3), or 8.
\r
1351 * @return If the queue set is created successfully then a handle to the created
\r
1352 * queue set is returned. Otherwise NULL is returned.
\r
1354 xQueueSetHandle xQueueCreateSet( unsigned portBASE_TYPE uxEventQueueLength );
\r
1357 * Adds a queue or semaphore to a queue set that was previously created by a
\r
1358 * call to xQueueCreateSet().
\r
1360 * See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this
\r
1363 * Note 1: A received (in the case of a queue) or take (in the case of a
\r
1364 * semaphore) operation must not be performed on a member of a queue set unless
\r
1365 * a call to xQueueSelect() has first returned a handle to that set member.
\r
1367 * @param xQueueOrSemaphore The handle of the queue or semaphore being added to
\r
1368 * the queue set (cast to an xQueueSetMemberHandle type).
\r
1370 * @param xQueueSet The handle of the queue set to which the queue or semaphore
\r
1373 * @return If the queue or semaphore was successfully added to the queue set
\r
1374 * then pdPASS is returned. If the queue could not be successfully added to the
\r
1375 * queue set because it is already a member of a different queue set then pdFAIL
\r
1378 portBASE_TYPE xQueueAddToSet( xQueueSetMemberHandle xQueueOrSemaphore, xQueueSetHandle xQueueSet );
\r
1381 * Removes a queue or semaphore from a queue set. A queue can only be removed
\r
1382 * from a set when it is empty.
\r
1384 * See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this
\r
1387 * @param xQueueOrSemaphore The handle of the queue or semaphore being removed
\r
1388 * from the queue set (cast to an xQueueSetMemberHandle type).
\r
1390 * @param xQueueSet The handle of the queue set in which the queue or semaphore
\r
1393 * @return If the queue or semaphore was successfully removed from the queue set
\r
1394 * then pdPASS is returned. If the queue was not in the queue set then pdFAIL
\r
1397 portBASE_TYPE xQueueRemoveFromSet( xQueueSetMemberHandle xQueueOrSemaphore, xQueueSetHandle xQueueSet );
\r
1400 * xQueueSelectFromSet() selects from the members of a queue set a queue or
\r
1401 * semaphore that either contains data (in the case of a queue) or is available
\r
1402 * to take (in the case of a semaphore). xQueueSelectFromSet() effectively
\r
1403 * allows a task to block (pend) on a read operation on all the queues and
\r
1404 * semaphores in a queue set simultaneously.
\r
1406 * See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this
\r
1409 * Note 1: See the documentation on http://wwwFreeRTOS.org for reasons why
\r
1410 * queue sets are very rarely needed in practice as there are simpler
\r
1411 * alternatives. Queue sets are provided to allow FreeRTOS to be integrated
\r
1412 * with legacy third party driver code.
\r
1414 * Note 2: Blocking on a queue set that contains a mutex will not cause the
\r
1415 * mutex holder to inherit the priority of the blocked task.
\r
1417 * Note 3: A received (in the case of a queue) or take (in the case of a
\r
1418 * semaphore) operation must not be performed on a member of a queue set unless
\r
1419 * a call to xQueueSelect() has first returned a handle to that set member.
\r
1421 * @param xQueueSet The queue set on which the task will (potentially) block.
\r
1423 * @param xBlockTimeTicks The maximum time, in ticks, that the calling task will
\r
1424 * remain in the Blocked state (with other tasks executing) to wait for a member
\r
1425 * of the queue set to be ready for a successful queue read or semaphore take
\r
1428 * @return xQueueSelectFromSet() will return the handle of a queue (cast to
\r
1429 * a xQueueSetMemberHandle type) contained in the queue set that contains data,
\r
1430 * or the handle of a semaphore (cast to a xQueueSetMemberHandle type) contained
\r
1431 * in the queue set that is available, or NULL if no such queue or semaphore
\r
1432 * exists before before the specified block time expires.
\r
1434 xQueueSetMemberHandle xQueueSelectFromSet( xQueueSetHandle xQueueSet, portTickType xBlockTimeTicks );
\r
1437 * A version of xQueueSelectFromSet() that can be used from an ISR.
\r
1439 xQueueSetMemberHandle xQueueSelectFromSetFromISR( xQueueSetHandle xQueueSet );
\r
1441 /* Not public API functions. */
\r
1442 void vQueueWaitForMessageRestricted( xQueueHandle pxQueue, portTickType xTicksToWait );
\r
1443 portBASE_TYPE xQueueGenericReset( xQueueHandle pxQueue, portBASE_TYPE xNewQueue );
\r
1446 #ifdef __cplusplus
\r
1450 #endif /* QUEUE_H */
\r