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 * xQueueSetCreate() returns an xQueueSet variable that can then be used as a
\r
94 * parameter to xQueueReadMultiple(), xQueueAddToQueueSet(), etc.
\r
96 typedef void * xQueueSetHandle;
\r
98 /* For internal use only. */
\r
99 #define queueSEND_TO_BACK ( 0 )
\r
100 #define queueSEND_TO_FRONT ( 1 )
\r
102 /* For internal use only. These definitions *must* match those in queue.c. */
\r
103 #define queueQUEUE_TYPE_BASE ( 0U )
\r
104 #define queueQUEUE_TYPE_MUTEX ( 1U )
\r
105 #define queueQUEUE_TYPE_COUNTING_SEMAPHORE ( 2U )
\r
106 #define queueQUEUE_TYPE_BINARY_SEMAPHORE ( 3U )
\r
107 #define queueQUEUE_TYPE_RECURSIVE_MUTEX ( 4U )
\r
112 xQueueHandle xQueueCreate(
\r
113 unsigned portBASE_TYPE uxQueueLength,
\r
114 unsigned portBASE_TYPE uxItemSize
\r
118 * Creates a new queue instance. This allocates the storage required by the
\r
119 * new queue and returns a handle for the queue.
\r
121 * @param uxQueueLength The maximum number of items that the queue can contain.
\r
123 * @param uxItemSize The number of bytes each item in the queue will require.
\r
124 * Items are queued by copy, not by reference, so this is the number of bytes
\r
125 * that will be copied for each posted item. Each item on the queue must be
\r
128 * @return If the queue is successfully create then a handle to the newly
\r
129 * created queue is returned. If the queue cannot be created then 0 is
\r
140 void vATask( void *pvParameters )
\r
142 xQueueHandle xQueue1, xQueue2;
\r
144 // Create a queue capable of containing 10 unsigned long values.
\r
145 xQueue1 = xQueueCreate( 10, sizeof( unsigned long ) );
\r
148 // Queue was not created and must not be used.
\r
151 // Create a queue capable of containing 10 pointers to AMessage structures.
\r
152 // These should be passed by pointer as they contain a lot of data.
\r
153 xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
\r
156 // Queue was not created and must not be used.
\r
159 // ... Rest of task code.
\r
162 * \defgroup xQueueCreate xQueueCreate
\r
163 * \ingroup QueueManagement
\r
165 #define xQueueCreate( uxQueueLength, uxItemSize ) xQueueGenericCreate( uxQueueLength, uxItemSize, queueQUEUE_TYPE_BASE )
\r
170 portBASE_TYPE xQueueSendToToFront(
\r
171 xQueueHandle xQueue,
\r
172 const void * pvItemToQueue,
\r
173 portTickType xTicksToWait
\r
177 * This is a macro that calls xQueueGenericSend().
\r
179 * Post an item to the front of a queue. The item is queued by copy, not by
\r
180 * reference. This function must not be called from an interrupt service
\r
181 * routine. See xQueueSendFromISR () for an alternative which may be used
\r
184 * @param xQueue The handle to the queue on which the item is to be posted.
\r
186 * @param pvItemToQueue A pointer to the item that is to be placed on the
\r
187 * queue. The size of the items the queue will hold was defined when the
\r
188 * queue was created, so this many bytes will be copied from pvItemToQueue
\r
189 * into the queue storage area.
\r
191 * @param xTicksToWait The maximum amount of time the task should block
\r
192 * waiting for space to become available on the queue, should it already
\r
193 * be full. The call will return immediately if this is set to 0 and the
\r
194 * queue is full. The time is defined in tick periods so the constant
\r
195 * portTICK_RATE_MS should be used to convert to real time if this is required.
\r
197 * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL.
\r
207 unsigned long ulVar = 10UL;
\r
209 void vATask( void *pvParameters )
\r
211 xQueueHandle xQueue1, xQueue2;
\r
212 struct AMessage *pxMessage;
\r
214 // Create a queue capable of containing 10 unsigned long values.
\r
215 xQueue1 = xQueueCreate( 10, sizeof( unsigned long ) );
\r
217 // Create a queue capable of containing 10 pointers to AMessage structures.
\r
218 // These should be passed by pointer as they contain a lot of data.
\r
219 xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
\r
225 // Send an unsigned long. Wait for 10 ticks for space to become
\r
226 // available if necessary.
\r
227 if( xQueueSendToFront( xQueue1, ( void * ) &ulVar, ( portTickType ) 10 ) != pdPASS )
\r
229 // Failed to post the message, even after 10 ticks.
\r
235 // Send a pointer to a struct AMessage object. Don't block if the
\r
236 // queue is already full.
\r
237 pxMessage = & xMessage;
\r
238 xQueueSendToFront( xQueue2, ( void * ) &pxMessage, ( portTickType ) 0 );
\r
241 // ... Rest of task code.
\r
244 * \defgroup xQueueSend xQueueSend
\r
245 * \ingroup QueueManagement
\r
247 #define xQueueSendToFront( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_FRONT )
\r
252 portBASE_TYPE xQueueSendToBack(
\r
253 xQueueHandle xQueue,
\r
254 const void * pvItemToQueue,
\r
255 portTickType xTicksToWait
\r
259 * This is a macro that calls xQueueGenericSend().
\r
261 * Post an item to the back of a queue. The item is queued by copy, not by
\r
262 * reference. This function must not be called from an interrupt service
\r
263 * routine. See xQueueSendFromISR () for an alternative which may be used
\r
266 * @param xQueue The handle to the queue on which the item is to be posted.
\r
268 * @param pvItemToQueue A pointer to the item that is to be placed on the
\r
269 * queue. The size of the items the queue will hold was defined when the
\r
270 * queue was created, so this many bytes will be copied from pvItemToQueue
\r
271 * into the queue storage area.
\r
273 * @param xTicksToWait The maximum amount of time the task should block
\r
274 * waiting for space to become available on the queue, should it already
\r
275 * be full. The call will return immediately if this is set to 0 and the queue
\r
276 * is full. The time is defined in tick periods so the constant
\r
277 * portTICK_RATE_MS should be used to convert to real time if this is required.
\r
279 * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL.
\r
289 unsigned long ulVar = 10UL;
\r
291 void vATask( void *pvParameters )
\r
293 xQueueHandle xQueue1, xQueue2;
\r
294 struct AMessage *pxMessage;
\r
296 // Create a queue capable of containing 10 unsigned long values.
\r
297 xQueue1 = xQueueCreate( 10, sizeof( unsigned long ) );
\r
299 // Create a queue capable of containing 10 pointers to AMessage structures.
\r
300 // These should be passed by pointer as they contain a lot of data.
\r
301 xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
\r
307 // Send an unsigned long. Wait for 10 ticks for space to become
\r
308 // available if necessary.
\r
309 if( xQueueSendToBack( xQueue1, ( void * ) &ulVar, ( portTickType ) 10 ) != pdPASS )
\r
311 // Failed to post the message, even after 10 ticks.
\r
317 // Send a pointer to a struct AMessage object. Don't block if the
\r
318 // queue is already full.
\r
319 pxMessage = & xMessage;
\r
320 xQueueSendToBack( xQueue2, ( void * ) &pxMessage, ( portTickType ) 0 );
\r
323 // ... Rest of task code.
\r
326 * \defgroup xQueueSend xQueueSend
\r
327 * \ingroup QueueManagement
\r
329 #define xQueueSendToBack( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK )
\r
334 portBASE_TYPE xQueueSend(
\r
335 xQueueHandle xQueue,
\r
336 const void * pvItemToQueue,
\r
337 portTickType xTicksToWait
\r
341 * This is a macro that calls xQueueGenericSend(). It is included for
\r
342 * backward compatibility with versions of FreeRTOS.org that did not
\r
343 * include the xQueueSendToFront() and xQueueSendToBack() macros. It is
\r
344 * equivalent to xQueueSendToBack().
\r
346 * Post an item on a queue. The item is queued by copy, not by reference.
\r
347 * This function must not be called from an interrupt service routine.
\r
348 * See xQueueSendFromISR () for an alternative which may be used in an ISR.
\r
350 * @param xQueue The handle to the queue on which the item is to be posted.
\r
352 * @param pvItemToQueue A pointer to the item that is to be placed on the
\r
353 * queue. The size of the items the queue will hold was defined when the
\r
354 * queue was created, so this many bytes will be copied from pvItemToQueue
\r
355 * into the queue storage area.
\r
357 * @param xTicksToWait The maximum amount of time the task should block
\r
358 * waiting for space to become available on the queue, should it already
\r
359 * be full. The call will return immediately if this is set to 0 and the
\r
360 * queue is full. The time is defined in tick periods so the constant
\r
361 * portTICK_RATE_MS should be used to convert to real time if this is required.
\r
363 * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL.
\r
373 unsigned long ulVar = 10UL;
\r
375 void vATask( void *pvParameters )
\r
377 xQueueHandle xQueue1, xQueue2;
\r
378 struct AMessage *pxMessage;
\r
380 // Create a queue capable of containing 10 unsigned long values.
\r
381 xQueue1 = xQueueCreate( 10, sizeof( unsigned long ) );
\r
383 // Create a queue capable of containing 10 pointers to AMessage structures.
\r
384 // These should be passed by pointer as they contain a lot of data.
\r
385 xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
\r
391 // Send an unsigned long. Wait for 10 ticks for space to become
\r
392 // available if necessary.
\r
393 if( xQueueSend( xQueue1, ( void * ) &ulVar, ( portTickType ) 10 ) != pdPASS )
\r
395 // Failed to post the message, even after 10 ticks.
\r
401 // Send a pointer to a struct AMessage object. Don't block if the
\r
402 // queue is already full.
\r
403 pxMessage = & xMessage;
\r
404 xQueueSend( xQueue2, ( void * ) &pxMessage, ( portTickType ) 0 );
\r
407 // ... Rest of task code.
\r
410 * \defgroup xQueueSend xQueueSend
\r
411 * \ingroup QueueManagement
\r
413 #define xQueueSend( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK )
\r
419 portBASE_TYPE xQueueGenericSend(
\r
420 xQueueHandle xQueue,
\r
421 const void * pvItemToQueue,
\r
422 portTickType xTicksToWait
\r
423 portBASE_TYPE xCopyPosition
\r
427 * It is preferred that the macros xQueueSend(), xQueueSendToFront() and
\r
428 * xQueueSendToBack() are used in place of calling this function directly.
\r
430 * Post an item on a queue. The item is queued by copy, not by reference.
\r
431 * This function must not be called from an interrupt service routine.
\r
432 * See xQueueSendFromISR () for an alternative which may be used in an ISR.
\r
434 * @param xQueue The handle to the queue on which the item is to be posted.
\r
436 * @param pvItemToQueue A pointer to the item that is to be placed on the
\r
437 * queue. The size of the items the queue will hold was defined when the
\r
438 * queue was created, so this many bytes will be copied from pvItemToQueue
\r
439 * into the queue storage area.
\r
441 * @param xTicksToWait The maximum amount of time the task should block
\r
442 * waiting for space to become available on the queue, should it already
\r
443 * be full. The call will return immediately if this is set to 0 and the
\r
444 * queue is full. The time is defined in tick periods so the constant
\r
445 * portTICK_RATE_MS should be used to convert to real time if this is required.
\r
447 * @param xCopyPosition Can take the value queueSEND_TO_BACK to place the
\r
448 * item at the back of the queue, or queueSEND_TO_FRONT to place the item
\r
449 * at the front of the queue (for high priority messages).
\r
451 * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL.
\r
461 unsigned long ulVar = 10UL;
\r
463 void vATask( void *pvParameters )
\r
465 xQueueHandle xQueue1, xQueue2;
\r
466 struct AMessage *pxMessage;
\r
468 // Create a queue capable of containing 10 unsigned long values.
\r
469 xQueue1 = xQueueCreate( 10, sizeof( unsigned long ) );
\r
471 // Create a queue capable of containing 10 pointers to AMessage structures.
\r
472 // These should be passed by pointer as they contain a lot of data.
\r
473 xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
\r
479 // Send an unsigned long. Wait for 10 ticks for space to become
\r
480 // available if necessary.
\r
481 if( xQueueGenericSend( xQueue1, ( void * ) &ulVar, ( portTickType ) 10, queueSEND_TO_BACK ) != pdPASS )
\r
483 // Failed to post the message, even after 10 ticks.
\r
489 // Send a pointer to a struct AMessage object. Don't block if the
\r
490 // queue is already full.
\r
491 pxMessage = & xMessage;
\r
492 xQueueGenericSend( xQueue2, ( void * ) &pxMessage, ( portTickType ) 0, queueSEND_TO_BACK );
\r
495 // ... Rest of task code.
\r
498 * \defgroup xQueueSend xQueueSend
\r
499 * \ingroup QueueManagement
\r
501 signed portBASE_TYPE xQueueGenericSend( xQueueHandle pxQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition );
\r
506 portBASE_TYPE xQueuePeek(
\r
507 xQueueHandle xQueue,
\r
509 portTickType xTicksToWait
\r
512 * This is a macro that calls the xQueueGenericReceive() function.
\r
514 * Receive an item from a queue without removing the item from the queue.
\r
515 * The item is received by copy so a buffer of adequate size must be
\r
516 * provided. The number of bytes copied into the buffer was defined when
\r
517 * the queue was created.
\r
519 * Successfully received items remain on the queue so will be returned again
\r
520 * by the next call, or a call to xQueueReceive().
\r
522 * This macro must not be used in an interrupt service routine.
\r
524 * @param pxQueue The handle to the queue from which the item is to be
\r
527 * @param pvBuffer Pointer to the buffer into which the received item will
\r
530 * @param xTicksToWait The maximum amount of time the task should block
\r
531 * waiting for an item to receive should the queue be empty at the time
\r
532 * of the call. The time is defined in tick periods so the constant
\r
533 * portTICK_RATE_MS should be used to convert to real time if this is required.
\r
534 * xQueuePeek() will return immediately if xTicksToWait is 0 and the queue
\r
537 * @return pdTRUE if an item was successfully received from the queue,
\r
538 * otherwise pdFALSE.
\r
548 xQueueHandle xQueue;
\r
550 // Task to create a queue and post a value.
\r
551 void vATask( void *pvParameters )
\r
553 struct AMessage *pxMessage;
\r
555 // Create a queue capable of containing 10 pointers to AMessage structures.
\r
556 // These should be passed by pointer as they contain a lot of data.
\r
557 xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) );
\r
560 // Failed to create the queue.
\r
565 // Send a pointer to a struct AMessage object. Don't block if the
\r
566 // queue is already full.
\r
567 pxMessage = & xMessage;
\r
568 xQueueSend( xQueue, ( void * ) &pxMessage, ( portTickType ) 0 );
\r
570 // ... Rest of task code.
\r
573 // Task to peek the data from the queue.
\r
574 void vADifferentTask( void *pvParameters )
\r
576 struct AMessage *pxRxedMessage;
\r
580 // Peek a message on the created queue. Block for 10 ticks if a
\r
581 // message is not immediately available.
\r
582 if( xQueuePeek( xQueue, &( pxRxedMessage ), ( portTickType ) 10 ) )
\r
584 // pcRxedMessage now points to the struct AMessage variable posted
\r
585 // by vATask, but the item still remains on the queue.
\r
589 // ... Rest of task code.
\r
592 * \defgroup xQueueReceive xQueueReceive
\r
593 * \ingroup QueueManagement
\r
595 #define xQueuePeek( xQueue, pvBuffer, xTicksToWait ) xQueueGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdTRUE )
\r
600 portBASE_TYPE xQueueReceive(
\r
601 xQueueHandle xQueue,
\r
603 portTickType xTicksToWait
\r
606 * This is a macro that calls the xQueueGenericReceive() function.
\r
608 * Receive an item from a queue. The item is received by copy so a buffer of
\r
609 * adequate size must be provided. The number of bytes copied into the buffer
\r
610 * was defined when the queue was created.
\r
612 * Successfully received items are removed from the queue.
\r
614 * This function must not be used in an interrupt service routine. See
\r
615 * xQueueReceiveFromISR for an alternative that can.
\r
617 * @param pxQueue The handle to the queue from which the item is to be
\r
620 * @param pvBuffer Pointer to the buffer into which the received item will
\r
623 * @param xTicksToWait The maximum amount of time the task should block
\r
624 * waiting for an item to receive should the queue be empty at the time
\r
625 * of the call. xQueueReceive() will return immediately if xTicksToWait
\r
626 * is zero and the queue is empty. The time is defined in tick periods so the
\r
627 * constant portTICK_RATE_MS should be used to convert to real time if this is
\r
630 * @return pdTRUE if an item was successfully received from the queue,
\r
631 * otherwise pdFALSE.
\r
641 xQueueHandle xQueue;
\r
643 // Task to create a queue and post a value.
\r
644 void vATask( void *pvParameters )
\r
646 struct AMessage *pxMessage;
\r
648 // Create a queue capable of containing 10 pointers to AMessage structures.
\r
649 // These should be passed by pointer as they contain a lot of data.
\r
650 xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) );
\r
653 // Failed to create the queue.
\r
658 // Send a pointer to a struct AMessage object. Don't block if the
\r
659 // queue is already full.
\r
660 pxMessage = & xMessage;
\r
661 xQueueSend( xQueue, ( void * ) &pxMessage, ( portTickType ) 0 );
\r
663 // ... Rest of task code.
\r
666 // Task to receive from the queue.
\r
667 void vADifferentTask( void *pvParameters )
\r
669 struct AMessage *pxRxedMessage;
\r
673 // Receive a message on the created queue. Block for 10 ticks if a
\r
674 // message is not immediately available.
\r
675 if( xQueueReceive( xQueue, &( pxRxedMessage ), ( portTickType ) 10 ) )
\r
677 // pcRxedMessage now points to the struct AMessage variable posted
\r
682 // ... Rest of task code.
\r
685 * \defgroup xQueueReceive xQueueReceive
\r
686 * \ingroup QueueManagement
\r
688 #define xQueueReceive( xQueue, pvBuffer, xTicksToWait ) xQueueGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdFALSE )
\r
694 portBASE_TYPE xQueueGenericReceive(
\r
695 xQueueHandle xQueue,
\r
697 portTickType xTicksToWait
\r
698 portBASE_TYPE xJustPeek
\r
701 * It is preferred that the macro xQueueReceive() be used rather than calling
\r
702 * this function directly.
\r
704 * Receive an item from a queue. The item is received by copy so a buffer of
\r
705 * adequate size must be provided. The number of bytes copied into the buffer
\r
706 * was defined when the queue was created.
\r
708 * This function must not be used in an interrupt service routine. See
\r
709 * xQueueReceiveFromISR for an alternative that can.
\r
711 * @param pxQueue The handle to the queue from which the item is to be
\r
714 * @param pvBuffer Pointer to the buffer into which the received item will
\r
717 * @param xTicksToWait The maximum amount of time the task should block
\r
718 * waiting for an item to receive should the queue be empty at the time
\r
719 * of the call. The time is defined in tick periods so the constant
\r
720 * portTICK_RATE_MS should be used to convert to real time if this is required.
\r
721 * xQueueGenericReceive() will return immediately if the queue is empty and
\r
722 * xTicksToWait is 0.
\r
724 * @param xJustPeek When set to true, the item received from the queue is not
\r
725 * actually removed from the queue - meaning a subsequent call to
\r
726 * xQueueReceive() will return the same item. When set to false, the item
\r
727 * being received from the queue is also removed from the queue.
\r
729 * @return pdTRUE if an item was successfully received from the queue,
\r
730 * otherwise pdFALSE.
\r
740 xQueueHandle xQueue;
\r
742 // Task to create a queue and post a value.
\r
743 void vATask( void *pvParameters )
\r
745 struct AMessage *pxMessage;
\r
747 // Create a queue capable of containing 10 pointers to AMessage structures.
\r
748 // These should be passed by pointer as they contain a lot of data.
\r
749 xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) );
\r
752 // Failed to create the queue.
\r
757 // Send a pointer to a struct AMessage object. Don't block if the
\r
758 // queue is already full.
\r
759 pxMessage = & xMessage;
\r
760 xQueueSend( xQueue, ( void * ) &pxMessage, ( portTickType ) 0 );
\r
762 // ... Rest of task code.
\r
765 // Task to receive from the queue.
\r
766 void vADifferentTask( void *pvParameters )
\r
768 struct AMessage *pxRxedMessage;
\r
772 // Receive a message on the created queue. Block for 10 ticks if a
\r
773 // message is not immediately available.
\r
774 if( xQueueGenericReceive( xQueue, &( pxRxedMessage ), ( portTickType ) 10 ) )
\r
776 // pcRxedMessage now points to the struct AMessage variable posted
\r
781 // ... Rest of task code.
\r
784 * \defgroup xQueueReceive xQueueReceive
\r
785 * \ingroup QueueManagement
\r
787 signed portBASE_TYPE xQueueGenericReceive( xQueueHandle xQueue, void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeek );
\r
791 * <pre>unsigned portBASE_TYPE uxQueueMessagesWaiting( const xQueueHandle xQueue );</pre>
\r
793 * Return the number of messages stored in a queue.
\r
795 * @param xQueue A handle to the queue being queried.
\r
797 * @return The number of messages available in the queue.
\r
799 * \page uxQueueMessagesWaiting uxQueueMessagesWaiting
\r
800 * \ingroup QueueManagement
\r
802 unsigned portBASE_TYPE uxQueueMessagesWaiting( const xQueueHandle xQueue );
\r
806 * <pre>void vQueueDelete( xQueueHandle xQueue );</pre>
\r
808 * Delete a queue - freeing all the memory allocated for storing of items
\r
809 * placed on the queue.
\r
811 * @param xQueue A handle to the queue to be deleted.
\r
813 * \page vQueueDelete vQueueDelete
\r
814 * \ingroup QueueManagement
\r
816 void vQueueDelete( xQueueHandle pxQueue );
\r
821 portBASE_TYPE xQueueSendToFrontFromISR(
\r
822 xQueueHandle pxQueue,
\r
823 const void *pvItemToQueue,
\r
824 portBASE_TYPE *pxHigherPriorityTaskWoken
\r
828 * This is a macro that calls xQueueGenericSendFromISR().
\r
830 * Post an item to the front of a queue. It is safe to use this macro from
\r
831 * within an interrupt service routine.
\r
833 * Items are queued by copy not reference so it is preferable to only
\r
834 * queue small items, especially when called from an ISR. In most cases
\r
835 * it would be preferable to store a pointer to the item being queued.
\r
837 * @param xQueue The handle to the queue on which the item is to be posted.
\r
839 * @param pvItemToQueue A pointer to the item that is to be placed on the
\r
840 * queue. The size of the items the queue will hold was defined when the
\r
841 * queue was created, so this many bytes will be copied from pvItemToQueue
\r
842 * into the queue storage area.
\r
844 * @param pxHigherPriorityTaskWoken xQueueSendToFrontFromISR() will set
\r
845 * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task
\r
846 * to unblock, and the unblocked task has a priority higher than the currently
\r
847 * running task. If xQueueSendToFromFromISR() sets this value to pdTRUE then
\r
848 * a context switch should be requested before the interrupt is exited.
\r
850 * @return pdTRUE if the data was successfully sent to the queue, otherwise
\r
853 * Example usage for buffered IO (where the ISR can obtain more than one value
\r
856 void vBufferISR( void )
\r
859 portBASE_TYPE xHigherPrioritTaskWoken;
\r
861 // We have not woken a task at the start of the ISR.
\r
862 xHigherPriorityTaskWoken = pdFALSE;
\r
864 // Loop until the buffer is empty.
\r
867 // Obtain a byte from the buffer.
\r
868 cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );
\r
871 xQueueSendToFrontFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );
\r
873 } while( portINPUT_BYTE( BUFFER_COUNT ) );
\r
875 // Now the buffer is empty we can switch context if necessary.
\r
876 if( xHigherPriorityTaskWoken )
\r
883 * \defgroup xQueueSendFromISR xQueueSendFromISR
\r
884 * \ingroup QueueManagement
\r
886 #define xQueueSendToFrontFromISR( pxQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( pxQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_FRONT )
\r
892 portBASE_TYPE xQueueSendToBackFromISR(
\r
893 xQueueHandle pxQueue,
\r
894 const void *pvItemToQueue,
\r
895 portBASE_TYPE *pxHigherPriorityTaskWoken
\r
899 * This is a macro that calls xQueueGenericSendFromISR().
\r
901 * Post an item to the back of a queue. It is safe to use this macro from
\r
902 * within an interrupt service routine.
\r
904 * Items are queued by copy not reference so it is preferable to only
\r
905 * queue small items, especially when called from an ISR. In most cases
\r
906 * it would be preferable to store a pointer to the item being queued.
\r
908 * @param xQueue The handle to the queue on which the item is to be posted.
\r
910 * @param pvItemToQueue A pointer to the item that is to be placed on the
\r
911 * queue. The size of the items the queue will hold was defined when the
\r
912 * queue was created, so this many bytes will be copied from pvItemToQueue
\r
913 * into the queue storage area.
\r
915 * @param pxHigherPriorityTaskWoken xQueueSendToBackFromISR() will set
\r
916 * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task
\r
917 * to unblock, and the unblocked task has a priority higher than the currently
\r
918 * running task. If xQueueSendToBackFromISR() sets this value to pdTRUE then
\r
919 * a context switch should be requested before the interrupt is exited.
\r
921 * @return pdTRUE if the data was successfully sent to the queue, otherwise
\r
924 * Example usage for buffered IO (where the ISR can obtain more than one value
\r
927 void vBufferISR( void )
\r
930 portBASE_TYPE xHigherPriorityTaskWoken;
\r
932 // We have not woken a task at the start of the ISR.
\r
933 xHigherPriorityTaskWoken = pdFALSE;
\r
935 // Loop until the buffer is empty.
\r
938 // Obtain a byte from the buffer.
\r
939 cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );
\r
942 xQueueSendToBackFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );
\r
944 } while( portINPUT_BYTE( BUFFER_COUNT ) );
\r
946 // Now the buffer is empty we can switch context if necessary.
\r
947 if( xHigherPriorityTaskWoken )
\r
954 * \defgroup xQueueSendFromISR xQueueSendFromISR
\r
955 * \ingroup QueueManagement
\r
957 #define xQueueSendToBackFromISR( pxQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( pxQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK )
\r
962 portBASE_TYPE xQueueSendFromISR(
\r
963 xQueueHandle pxQueue,
\r
964 const void *pvItemToQueue,
\r
965 portBASE_TYPE *pxHigherPriorityTaskWoken
\r
969 * This is a macro that calls xQueueGenericSendFromISR(). It is included
\r
970 * for backward compatibility with versions of FreeRTOS.org that did not
\r
971 * include the xQueueSendToBackFromISR() and xQueueSendToFrontFromISR()
\r
974 * Post an item to the back of a queue. It is safe to use this function from
\r
975 * within an interrupt service routine.
\r
977 * Items are queued by copy not reference so it is preferable to only
\r
978 * queue small items, especially when called from an ISR. In most cases
\r
979 * it would be preferable to store a pointer to the item being queued.
\r
981 * @param xQueue The handle to the queue on which the item is to be posted.
\r
983 * @param pvItemToQueue A pointer to the item that is to be placed on the
\r
984 * queue. The size of the items the queue will hold was defined when the
\r
985 * queue was created, so this many bytes will be copied from pvItemToQueue
\r
986 * into the queue storage area.
\r
988 * @param pxHigherPriorityTaskWoken xQueueSendFromISR() will set
\r
989 * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task
\r
990 * to unblock, and the unblocked task has a priority higher than the currently
\r
991 * running task. If xQueueSendFromISR() sets this value to pdTRUE then
\r
992 * a context switch should be requested before the interrupt is exited.
\r
994 * @return pdTRUE if the data was successfully sent to the queue, otherwise
\r
997 * Example usage for buffered IO (where the ISR can obtain more than one value
\r
1000 void vBufferISR( void )
\r
1003 portBASE_TYPE xHigherPriorityTaskWoken;
\r
1005 // We have not woken a task at the start of the ISR.
\r
1006 xHigherPriorityTaskWoken = pdFALSE;
\r
1008 // Loop until the buffer is empty.
\r
1011 // Obtain a byte from the buffer.
\r
1012 cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );
\r
1015 xQueueSendFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );
\r
1017 } while( portINPUT_BYTE( BUFFER_COUNT ) );
\r
1019 // Now the buffer is empty we can switch context if necessary.
\r
1020 if( xHigherPriorityTaskWoken )
\r
1022 // Actual macro used here is port specific.
\r
1023 taskYIELD_FROM_ISR ();
\r
1028 * \defgroup xQueueSendFromISR xQueueSendFromISR
\r
1029 * \ingroup QueueManagement
\r
1031 #define xQueueSendFromISR( pxQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( pxQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK )
\r
1036 portBASE_TYPE xQueueGenericSendFromISR(
\r
1037 xQueueHandle pxQueue,
\r
1038 const void *pvItemToQueue,
\r
1039 portBASE_TYPE *pxHigherPriorityTaskWoken,
\r
1040 portBASE_TYPE xCopyPosition
\r
1044 * It is preferred that the macros xQueueSendFromISR(),
\r
1045 * xQueueSendToFrontFromISR() and xQueueSendToBackFromISR() be used in place
\r
1046 * of calling this function directly.
\r
1048 * Post an item on a queue. It is safe to use this function from within an
\r
1049 * interrupt service routine.
\r
1051 * Items are queued by copy not reference so it is preferable to only
\r
1052 * queue small items, especially when called from an ISR. In most cases
\r
1053 * it would be preferable to store a pointer to the item being queued.
\r
1055 * @param xQueue The handle to the queue on which the item is to be posted.
\r
1057 * @param pvItemToQueue A pointer to the item that is to be placed on the
\r
1058 * queue. The size of the items the queue will hold was defined when the
\r
1059 * queue was created, so this many bytes will be copied from pvItemToQueue
\r
1060 * into the queue storage area.
\r
1062 * @param pxHigherPriorityTaskWoken xQueueGenericSendFromISR() will set
\r
1063 * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task
\r
1064 * to unblock, and the unblocked task has a priority higher than the currently
\r
1065 * running task. If xQueueGenericSendFromISR() sets this value to pdTRUE then
\r
1066 * a context switch should be requested before the interrupt is exited.
\r
1068 * @param xCopyPosition Can take the value queueSEND_TO_BACK to place the
\r
1069 * item at the back of the queue, or queueSEND_TO_FRONT to place the item
\r
1070 * at the front of the queue (for high priority messages).
\r
1072 * @return pdTRUE if the data was successfully sent to the queue, otherwise
\r
1075 * Example usage for buffered IO (where the ISR can obtain more than one value
\r
1078 void vBufferISR( void )
\r
1081 portBASE_TYPE xHigherPriorityTaskWokenByPost;
\r
1083 // We have not woken a task at the start of the ISR.
\r
1084 xHigherPriorityTaskWokenByPost = pdFALSE;
\r
1086 // Loop until the buffer is empty.
\r
1089 // Obtain a byte from the buffer.
\r
1090 cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );
\r
1092 // Post each byte.
\r
1093 xQueueGenericSendFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWokenByPost, queueSEND_TO_BACK );
\r
1095 } while( portINPUT_BYTE( BUFFER_COUNT ) );
\r
1097 // Now the buffer is empty we can switch context if necessary. Note that the
\r
1098 // name of the yield function required is port specific.
\r
1099 if( xHigherPriorityTaskWokenByPost )
\r
1101 taskYIELD_YIELD_FROM_ISR();
\r
1106 * \defgroup xQueueSendFromISR xQueueSendFromISR
\r
1107 * \ingroup QueueManagement
\r
1109 signed portBASE_TYPE xQueueGenericSendFromISR( xQueueHandle pxQueue, const void * const pvItemToQueue, signed portBASE_TYPE *pxHigherPriorityTaskWoken, portBASE_TYPE xCopyPosition );
\r
1114 portBASE_TYPE xQueueReceiveFromISR(
\r
1115 xQueueHandle pxQueue,
\r
1117 portBASE_TYPE *pxTaskWoken
\r
1121 * Receive an item from a queue. It is safe to use this function from within an
\r
1122 * interrupt service routine.
\r
1124 * @param pxQueue The handle to the queue from which the item is to be
\r
1127 * @param pvBuffer Pointer to the buffer into which the received item will
\r
1130 * @param pxTaskWoken A task may be blocked waiting for space to become
\r
1131 * available on the queue. If xQueueReceiveFromISR causes such a task to
\r
1132 * unblock *pxTaskWoken will get set to pdTRUE, otherwise *pxTaskWoken will
\r
1133 * remain unchanged.
\r
1135 * @return pdTRUE if an item was successfully received from the queue,
\r
1136 * otherwise pdFALSE.
\r
1141 xQueueHandle xQueue;
\r
1143 // Function to create a queue and post some values.
\r
1144 void vAFunction( void *pvParameters )
\r
1146 char cValueToPost;
\r
1147 const portTickType xBlockTime = ( portTickType )0xff;
\r
1149 // Create a queue capable of containing 10 characters.
\r
1150 xQueue = xQueueCreate( 10, sizeof( char ) );
\r
1153 // Failed to create the queue.
\r
1158 // Post some characters that will be used within an ISR. If the queue
\r
1159 // is full then this task will block for xBlockTime ticks.
\r
1160 cValueToPost = 'a';
\r
1161 xQueueSend( xQueue, ( void * ) &cValueToPost, xBlockTime );
\r
1162 cValueToPost = 'b';
\r
1163 xQueueSend( xQueue, ( void * ) &cValueToPost, xBlockTime );
\r
1165 // ... keep posting characters ... this task may block when the queue
\r
1168 cValueToPost = 'c';
\r
1169 xQueueSend( xQueue, ( void * ) &cValueToPost, xBlockTime );
\r
1172 // ISR that outputs all the characters received on the queue.
\r
1173 void vISR_Routine( void )
\r
1175 portBASE_TYPE xTaskWokenByReceive = pdFALSE;
\r
1178 while( xQueueReceiveFromISR( xQueue, ( void * ) &cRxedChar, &xTaskWokenByReceive) )
\r
1180 // A character was received. Output the character now.
\r
1181 vOutputCharacter( cRxedChar );
\r
1183 // If removing the character from the queue woke the task that was
\r
1184 // posting onto the queue cTaskWokenByReceive will have been set to
\r
1185 // pdTRUE. No matter how many times this loop iterates only one
\r
1186 // task will be woken.
\r
1189 if( cTaskWokenByPost != ( char ) pdFALSE;
\r
1195 * \defgroup xQueueReceiveFromISR xQueueReceiveFromISR
\r
1196 * \ingroup QueueManagement
\r
1198 signed portBASE_TYPE xQueueReceiveFromISR( xQueueHandle pxQueue, void * const pvBuffer, signed portBASE_TYPE *pxHigherPriorityTaskWoken );
\r
1201 * Utilities to query queues that are safe to use from an ISR. These utilities
\r
1202 * should be used only from witin an ISR, or within a critical section.
\r
1204 signed portBASE_TYPE xQueueIsQueueEmptyFromISR( const xQueueHandle pxQueue );
\r
1205 signed portBASE_TYPE xQueueIsQueueFullFromISR( const xQueueHandle pxQueue );
\r
1206 unsigned portBASE_TYPE uxQueueMessagesWaitingFromISR( const xQueueHandle pxQueue );
\r
1210 * xQueueAltGenericSend() is an alternative version of xQueueGenericSend().
\r
1211 * Likewise xQueueAltGenericReceive() is an alternative version of
\r
1212 * xQueueGenericReceive().
\r
1214 * The source code that implements the alternative (Alt) API is much
\r
1215 * simpler because it executes everything from within a critical section.
\r
1216 * This is the approach taken by many other RTOSes, but FreeRTOS.org has the
\r
1217 * preferred fully featured API too. The fully featured API has more
\r
1218 * complex code that takes longer to execute, but makes much less use of
\r
1219 * critical sections. Therefore the alternative API sacrifices interrupt
\r
1220 * responsiveness to gain execution speed, whereas the fully featured API
\r
1221 * sacrifices execution speed to ensure better interrupt responsiveness.
\r
1223 signed portBASE_TYPE xQueueAltGenericSend( xQueueHandle pxQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition );
\r
1224 signed portBASE_TYPE xQueueAltGenericReceive( xQueueHandle pxQueue, void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking );
\r
1225 #define xQueueAltSendToFront( xQueue, pvItemToQueue, xTicksToWait ) xQueueAltGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_FRONT )
\r
1226 #define xQueueAltSendToBack( xQueue, pvItemToQueue, xTicksToWait ) xQueueAltGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK )
\r
1227 #define xQueueAltReceive( xQueue, pvBuffer, xTicksToWait ) xQueueAltGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdFALSE )
\r
1228 #define xQueueAltPeek( xQueue, pvBuffer, xTicksToWait ) xQueueAltGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdTRUE )
\r
1231 * The functions defined above are for passing data to and from tasks. The
\r
1232 * functions below are the equivalents for passing data to and from
\r
1235 * These functions are called from the co-routine macro implementation and
\r
1236 * should not be called directly from application code. Instead use the macro
\r
1237 * wrappers defined within croutine.h.
\r
1239 signed portBASE_TYPE xQueueCRSendFromISR( xQueueHandle pxQueue, const void *pvItemToQueue, signed portBASE_TYPE xCoRoutinePreviouslyWoken );
\r
1240 signed portBASE_TYPE xQueueCRReceiveFromISR( xQueueHandle pxQueue, void *pvBuffer, signed portBASE_TYPE *pxTaskWoken );
\r
1241 signed portBASE_TYPE xQueueCRSend( xQueueHandle pxQueue, const void *pvItemToQueue, portTickType xTicksToWait );
\r
1242 signed portBASE_TYPE xQueueCRReceive( xQueueHandle pxQueue, void *pvBuffer, portTickType xTicksToWait );
\r
1245 * For internal use only. Use xSemaphoreCreateMutex(),
\r
1246 * xSemaphoreCreateCounting() or xSemaphoreGetMutexHolder() instead of calling
\r
1247 * these functions directly.
\r
1249 xQueueHandle xQueueCreateMutex( unsigned char ucQueueType );
\r
1250 xQueueHandle xQueueCreateCountingSemaphore( unsigned portBASE_TYPE uxCountValue, unsigned portBASE_TYPE uxInitialCount );
\r
1251 void* xQueueGetMutexHolder( xQueueHandle xSemaphore );
\r
1254 * For internal use only. Use xSemaphoreTakeMutexRecursive() or
\r
1255 * xSemaphoreGiveMutexRecursive() instead of calling these functions directly.
\r
1257 portBASE_TYPE xQueueTakeMutexRecursive( xQueueHandle pxMutex, portTickType xBlockTime );
\r
1258 portBASE_TYPE xQueueGiveMutexRecursive( xQueueHandle pxMutex );
\r
1261 * Reset a queue back to its original empty state. pdPASS is returned if the
\r
1262 * queue is successfully reset. pdFAIL is returned if the queue could not be
\r
1263 * reset because there are tasks blocked on the queue waiting to either
\r
1264 * receive from the queue or send to the queue.
\r
1266 #define xQueueReset( pxQueue ) xQueueGenericReset( pxQueue, pdFALSE )
\r
1269 * The registry is provided as a means for kernel aware debuggers to
\r
1270 * locate queues, semaphores and mutexes. Call vQueueAddToRegistry() add
\r
1271 * a queue, semaphore or mutex handle to the registry if you want the handle
\r
1272 * to be available to a kernel aware debugger. If you are not using a kernel
\r
1273 * aware debugger then this function can be ignored.
\r
1275 * configQUEUE_REGISTRY_SIZE defines the maximum number of handles the
\r
1276 * registry can hold. configQUEUE_REGISTRY_SIZE must be greater than 0
\r
1277 * within FreeRTOSConfig.h for the registry to be available. Its value
\r
1278 * does not effect the number of queues, semaphores and mutexes that can be
\r
1279 * created - just the number that the registry can hold.
\r
1281 * @param xQueue The handle of the queue being added to the registry. This
\r
1282 * is the handle returned by a call to xQueueCreate(). Semaphore and mutex
\r
1283 * handles can also be passed in here.
\r
1285 * @param pcName The name to be associated with the handle. This is the
\r
1286 * name that the kernel aware debugger will display.
\r
1288 #if configQUEUE_REGISTRY_SIZE > 0U
\r
1289 void vQueueAddToRegistry( xQueueHandle xQueue, signed char *pcName );
\r
1293 * Generic version of the queue creation function, which is in turn called by
\r
1294 * any queue, semaphore or mutex creation function or macro.
\r
1296 xQueueHandle xQueueGenericCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBASE_TYPE uxItemSize, unsigned char ucQueueType );
\r
1299 * Queue sets provide a mechanism to allow a task to block (pend) on a read
\r
1300 * operation from multiple queues or semaphores simultaneously.
\r
1302 * See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this
\r
1305 * A queue set must be explicitly created using a call to xQueueSetCreate()
\r
1306 * before it can be used. Once created, standard FreeRTOS queues and semaphores
\r
1307 * can be added to the set using calls to xQueueAddToQueueSet().
\r
1308 * xQueueReadMultiple() is then used to determine which, if any, of the queues
\r
1309 * or semaphores contained in the set is in a state where a queue read or
\r
1310 * semaphore take operation would be successful.
\r
1312 * Note 1: See the documentation on http://wwwFreeRTOS.org for reasons why
\r
1313 * queue sets are very rarely needed in practice as there are simpler
\r
1314 * alternatives. Queue sets are provided to allow FreeRTOS to be integrated
\r
1315 * with legacy third party driver code.
\r
1317 * Note 2: Blocking on a queue set that contains a mutex will not cause the
\r
1318 * mutex holder to inherit the priority of the blocked task.
\r
1320 * Note 3: An additional 4 bytes of RAM is required for each space in a every
\r
1321 * queue added to a queue set. Therefore counting semaphores with large maximum
\r
1322 * counts should not be added to queue sets.
\r
1324 * @param uxEventQueueLength Queue sets themselves queue events that occur on
\r
1325 * the queues and semaphores contained in the set. uxEventQueueLength specifies
\r
1326 * the maximum number of events that can be queued at once. To be absolutely
\r
1327 * certain that events are not lost uxEventQueueLength should be set to the
\r
1328 * total sum of the length of the queues added to the set, where binary
\r
1329 * semaphores and mutexes have a length of 1, and counting semaphores have a
\r
1330 * length set by their maximum count value. Examples:
\r
1331 * + If a queue set is to hold a queue of length 5, another queue of length 12,
\r
1332 * and a binary semaphore, then uxEventQueueLength should be set to
\r
1333 * (5 + 12 + 1), or 18.
\r
1334 * + If a queue set is to hold three binary semaphores then uxEventQueueLength
\r
1335 * should be set to (1 + 1 + 1 ), or 3.
\r
1336 * + If a queue set is to hold a counting semaphore that has a maximum count of
\r
1337 * 5, and a counting semaphore that has a maximum count of 3, then
\r
1338 * uxEventQueueLength should be set to (5 + 3), or 8.
\r
1340 * @return If the queue set is created successfully then a handle to the created
\r
1341 * queue set is returned. Otherwise NULL is returned.
\r
1343 xQueueSetHandle xQueueSetCreate( unsigned portBASE_TYPE uxEventQueueLength );
\r
1346 * Adds a queue or semaphore to a queue set that was previously created by a
\r
1347 * call to xQueueSetCreate().
\r
1349 * See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this
\r
1352 * @param xQueue The handle of the queue or semaphore being added to the
\r
1353 * queue set. Variables of type xSemaphoreHandle can be safely added to a
\r
1354 * queue set but may require casting to an xQueueHandle type to avoid compiler
\r
1357 * @param xQueueSet The handle of the queue set to which the queue or semaphore
\r
1360 * @return If the queue or semaphore was successfully added to the queue set
\r
1361 * then pdPASS is returned. If the queue could not be successfully added to the
\r
1362 * queue set because it is already a member of a different queue set then pdFAIL
\r
1365 portBASE_TYPE xQueueAddToQueueSet( xQueueHandle xQueue, xQueueSetHandle xQueueSet );
\r
1368 * Removes a queue or semaphore from a queue set.
\r
1370 * See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this
\r
1373 * @param xQueue The handle of the queue or semaphore being removed from the
\r
1374 * queue set. Variables of type xSemaphoreHandle can be safely used but may
\r
1375 * require casting to an xQueueHandle type to avoid compiler warnings.
\r
1377 * @param xQueueSet The handle of the queue set in which the queue or semaphore
\r
1380 * @return If the queue or semaphore was successfully removed from the queue set
\r
1381 * then pdPASS is returned. If the queue was not in the queue set then pdFAIL
\r
1384 portBASE_TYPE xQueueRemoveFromQueueSet( xQueueSetHandle xQueueSet, xQueueHandle xQueue );
\r
1387 * xQueueReadMultiple() allows a task to block (pend) on a read operation on
\r
1388 * all the queues and semaphores in a queue set simultaneously.
\r
1390 * See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this
\r
1393 * Note 1: See the documentation on http://wwwFreeRTOS.org for reasons why
\r
1394 * queue sets are very rarely needed in practice as there are simpler
\r
1395 * alternatives. Queue sets are provided to allow FreeRTOS to be integrated
\r
1396 * with legacy third party driver code.
\r
1398 * Note 2: Blocking on a queue set that contains a mutex will not cause the
\r
1399 * mutex holder to inherit the priority of the blocked task.
\r
1401 * @param xQueueSet The queue set on which the task will (potentially) block.
\r
1403 * @param xBlockTimeTicks The maximum time, in ticks, that the calling task will
\r
1404 * remain in the Blocked state (with other tasks executing) to wait for a member
\r
1405 * of the queue set to be ready for a successful queue read or semaphore take
\r
1408 * @return xQueueReadMultiple() will return the handle of a queue contained
\r
1409 * in the queue set that contains data, or the handle of a semaphore contained
\r
1410 * in the queue set that is available, or NULL if no such queue or semaphore
\r
1411 * exists before before the specified block time expires.
\r
1413 xQueueHandle xQueueReadMultiple( xQueueSetHandle xQueueSet, portTickType xBlockTimeTicks );
\r
1415 /* Not public API functions. */
\r
1416 void vQueueWaitForMessageRestricted( xQueueHandle pxQueue, portTickType xTicksToWait );
\r
1417 portBASE_TYPE xQueueGenericReset( xQueueHandle pxQueue, portBASE_TYPE xNewQueue );
\r
1420 #ifdef __cplusplus
\r
1424 #endif /* QUEUE_H */
\r