]> git.sur5r.net Git - freertos/blob - FreeRTOS/Source/include/queue.h
c3e2ed500b03a226103f6e1d6e02ee2218bb1a23
[freertos] / FreeRTOS / Source / include / queue.h
1 /*\r
2     FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd.\r
3     All rights reserved\r
4 \r
5     VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
6 \r
7     This file is part of the FreeRTOS distribution.\r
8 \r
9     FreeRTOS is free software; you can redistribute it and/or modify it under\r
10     the terms of the GNU General Public License (version 2) as published by the\r
11     Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
12 \r
13     ***************************************************************************\r
14     >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
15     >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
16     >>!   obliged to provide the source code for proprietary components     !<<\r
17     >>!   outside of the FreeRTOS kernel.                                   !<<\r
18     ***************************************************************************\r
19 \r
20     FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
21     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
22     FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
23     link: http://www.freertos.org/a00114.html\r
24 \r
25     ***************************************************************************\r
26      *                                                                       *\r
27      *    FreeRTOS provides completely free yet professionally developed,    *\r
28      *    robust, strictly quality controlled, supported, and cross          *\r
29      *    platform software that is more than just the market leader, it     *\r
30      *    is the industry's de facto standard.                               *\r
31      *                                                                       *\r
32      *    Help yourself get started quickly while simultaneously helping     *\r
33      *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
34      *    tutorial book, reference manual, or both:                          *\r
35      *    http://www.FreeRTOS.org/Documentation                              *\r
36      *                                                                       *\r
37     ***************************************************************************\r
38 \r
39     http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
40     the FAQ page "My application does not run, what could be wrong?".  Have you\r
41     defined configASSERT()?\r
42 \r
43     http://www.FreeRTOS.org/support - In return for receiving this top quality\r
44     embedded software for free we request you assist our global community by\r
45     participating in the support forum.\r
46 \r
47     http://www.FreeRTOS.org/training - Investing in training allows your team to\r
48     be as productive as possible as early as possible.  Now you can receive\r
49     FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
50     Ltd, and the world's leading authority on the world's leading RTOS.\r
51 \r
52     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
53     including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
54     compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
55 \r
56     http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
57     Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
58 \r
59     http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
60     Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
61     licenses offer ticketed support, indemnification and commercial middleware.\r
62 \r
63     http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
64     engineered and independently SIL3 certified version for use in safety and\r
65     mission critical applications that require provable dependability.\r
66 \r
67     1 tab == 4 spaces!\r
68 */\r
69 \r
70 \r
71 #ifndef QUEUE_H\r
72 #define QUEUE_H\r
73 \r
74 #ifndef INC_FREERTOS_H\r
75         #error "include FreeRTOS.h" must appear in source files before "include queue.h"\r
76 #endif\r
77 \r
78 #ifdef __cplusplus\r
79 extern "C" {\r
80 #endif\r
81 \r
82 \r
83 /**\r
84  * Type by which queues are referenced.  For example, a call to xQueueCreate()\r
85  * returns an QueueHandle_t variable that can then be used as a parameter to\r
86  * xQueueSend(), xQueueReceive(), etc.\r
87  */\r
88 typedef void * QueueHandle_t;\r
89 \r
90 /**\r
91  * Type by which queue sets are referenced.  For example, a call to\r
92  * xQueueCreateSet() returns an xQueueSet variable that can then be used as a\r
93  * parameter to xQueueSelectFromSet(), xQueueAddToSet(), etc.\r
94  */\r
95 typedef void * QueueSetHandle_t;\r
96 \r
97 /**\r
98  * Queue sets can contain both queues and semaphores, so the\r
99  * QueueSetMemberHandle_t is defined as a type to be used where a parameter or\r
100  * return value can be either an QueueHandle_t or an SemaphoreHandle_t.\r
101  */\r
102 typedef void * QueueSetMemberHandle_t;\r
103 \r
104 /* For internal use only. */\r
105 #define queueSEND_TO_BACK               ( ( BaseType_t ) 0 )\r
106 #define queueSEND_TO_FRONT              ( ( BaseType_t ) 1 )\r
107 #define queueOVERWRITE                  ( ( BaseType_t ) 2 )\r
108 \r
109 /* For internal use only.  These definitions *must* match those in queue.c. */\r
110 #define queueQUEUE_TYPE_BASE                            ( ( uint8_t ) 0U )\r
111 #define queueQUEUE_TYPE_SET                                     ( ( uint8_t ) 0U )\r
112 #define queueQUEUE_TYPE_MUTEX                           ( ( uint8_t ) 1U )\r
113 #define queueQUEUE_TYPE_COUNTING_SEMAPHORE      ( ( uint8_t ) 2U )\r
114 #define queueQUEUE_TYPE_BINARY_SEMAPHORE        ( ( uint8_t ) 3U )\r
115 #define queueQUEUE_TYPE_RECURSIVE_MUTEX         ( ( uint8_t ) 4U )\r
116 \r
117 /**\r
118  * queue. h\r
119  * <pre>\r
120  QueueHandle_t xQueueCreate(\r
121                                                           UBaseType_t uxQueueLength,\r
122                                                           UBaseType_t uxItemSize\r
123                                                   );\r
124  * </pre>\r
125  *\r
126  * Creates a new queue instance.  This allocates the storage required by the\r
127  * new queue and returns a handle for the queue.\r
128  *\r
129  * @param uxQueueLength The maximum number of items that the queue can contain.\r
130  *\r
131  * @param uxItemSize The number of bytes each item in the queue will require.\r
132  * Items are queued by copy, not by reference, so this is the number of bytes\r
133  * that will be copied for each posted item.  Each item on the queue must be\r
134  * the same size.\r
135  *\r
136  * @return If the queue is successfully create then a handle to the newly\r
137  * created queue is returned.  If the queue cannot be created then 0 is\r
138  * returned.\r
139  *\r
140  * Example usage:\r
141    <pre>\r
142  struct AMessage\r
143  {\r
144         char ucMessageID;\r
145         char ucData[ 20 ];\r
146  };\r
147 \r
148  void vATask( void *pvParameters )\r
149  {\r
150  QueueHandle_t xQueue1, xQueue2;\r
151 \r
152         // Create a queue capable of containing 10 uint32_t values.\r
153         xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) );\r
154         if( xQueue1 == 0 )\r
155         {\r
156                 // Queue was not created and must not be used.\r
157         }\r
158 \r
159         // Create a queue capable of containing 10 pointers to AMessage structures.\r
160         // These should be passed by pointer as they contain a lot of data.\r
161         xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );\r
162         if( xQueue2 == 0 )\r
163         {\r
164                 // Queue was not created and must not be used.\r
165         }\r
166 \r
167         // ... Rest of task code.\r
168  }\r
169  </pre>\r
170  * \defgroup xQueueCreate xQueueCreate\r
171  * \ingroup QueueManagement\r
172  */\r
173 #define xQueueCreate( uxQueueLength, uxItemSize ) xQueueGenericCreate( uxQueueLength, uxItemSize, queueQUEUE_TYPE_BASE )\r
174 \r
175 /**\r
176  * queue. h\r
177  * <pre>\r
178  BaseType_t xQueueSendToToFront(\r
179                                                                    QueueHandle_t        xQueue,\r
180                                                                    const void           *pvItemToQueue,\r
181                                                                    TickType_t           xTicksToWait\r
182                                                            );\r
183  * </pre>\r
184  *\r
185  * This is a macro that calls xQueueGenericSend().\r
186  *\r
187  * Post an item to the front of a queue.  The item is queued by copy, not by\r
188  * reference.  This function must not be called from an interrupt service\r
189  * routine.  See xQueueSendFromISR () for an alternative which may be used\r
190  * in an ISR.\r
191  *\r
192  * @param xQueue The handle to the queue on which the item is to be posted.\r
193  *\r
194  * @param pvItemToQueue A pointer to the item that is to be placed on the\r
195  * queue.  The size of the items the queue will hold was defined when the\r
196  * queue was created, so this many bytes will be copied from pvItemToQueue\r
197  * into the queue storage area.\r
198  *\r
199  * @param xTicksToWait The maximum amount of time the task should block\r
200  * waiting for space to become available on the queue, should it already\r
201  * be full.  The call will return immediately if this is set to 0 and the\r
202  * queue is full.  The time is defined in tick periods so the constant\r
203  * portTICK_PERIOD_MS should be used to convert to real time if this is required.\r
204  *\r
205  * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL.\r
206  *\r
207  * Example usage:\r
208    <pre>\r
209  struct AMessage\r
210  {\r
211         char ucMessageID;\r
212         char ucData[ 20 ];\r
213  } xMessage;\r
214 \r
215  uint32_t ulVar = 10UL;\r
216 \r
217  void vATask( void *pvParameters )\r
218  {\r
219  QueueHandle_t xQueue1, xQueue2;\r
220  struct AMessage *pxMessage;\r
221 \r
222         // Create a queue capable of containing 10 uint32_t values.\r
223         xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) );\r
224 \r
225         // Create a queue capable of containing 10 pointers to AMessage structures.\r
226         // These should be passed by pointer as they contain a lot of data.\r
227         xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );\r
228 \r
229         // ...\r
230 \r
231         if( xQueue1 != 0 )\r
232         {\r
233                 // Send an uint32_t.  Wait for 10 ticks for space to become\r
234                 // available if necessary.\r
235                 if( xQueueSendToFront( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10 ) != pdPASS )\r
236                 {\r
237                         // Failed to post the message, even after 10 ticks.\r
238                 }\r
239         }\r
240 \r
241         if( xQueue2 != 0 )\r
242         {\r
243                 // Send a pointer to a struct AMessage object.  Don't block if the\r
244                 // queue is already full.\r
245                 pxMessage = & xMessage;\r
246                 xQueueSendToFront( xQueue2, ( void * ) &pxMessage, ( TickType_t ) 0 );\r
247         }\r
248 \r
249         // ... Rest of task code.\r
250  }\r
251  </pre>\r
252  * \defgroup xQueueSend xQueueSend\r
253  * \ingroup QueueManagement\r
254  */\r
255 #define xQueueSendToFront( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_FRONT )\r
256 \r
257 /**\r
258  * queue. h\r
259  * <pre>\r
260  BaseType_t xQueueSendToBack(\r
261                                                                    QueueHandle_t        xQueue,\r
262                                                                    const void           *pvItemToQueue,\r
263                                                                    TickType_t           xTicksToWait\r
264                                                            );\r
265  * </pre>\r
266  *\r
267  * This is a macro that calls xQueueGenericSend().\r
268  *\r
269  * Post an item to the back of a queue.  The item is queued by copy, not by\r
270  * reference.  This function must not be called from an interrupt service\r
271  * routine.  See xQueueSendFromISR () for an alternative which may be used\r
272  * in an ISR.\r
273  *\r
274  * @param xQueue The handle to the queue on which the item is to be posted.\r
275  *\r
276  * @param pvItemToQueue A pointer to the item that is to be placed on the\r
277  * queue.  The size of the items the queue will hold was defined when the\r
278  * queue was created, so this many bytes will be copied from pvItemToQueue\r
279  * into the queue storage area.\r
280  *\r
281  * @param xTicksToWait The maximum amount of time the task should block\r
282  * waiting for space to become available on the queue, should it already\r
283  * be full.  The call will return immediately if this is set to 0 and the queue\r
284  * is full.  The  time is defined in tick periods so the constant\r
285  * portTICK_PERIOD_MS should be used to convert to real time if this is required.\r
286  *\r
287  * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL.\r
288  *\r
289  * Example usage:\r
290    <pre>\r
291  struct AMessage\r
292  {\r
293         char ucMessageID;\r
294         char ucData[ 20 ];\r
295  } xMessage;\r
296 \r
297  uint32_t ulVar = 10UL;\r
298 \r
299  void vATask( void *pvParameters )\r
300  {\r
301  QueueHandle_t xQueue1, xQueue2;\r
302  struct AMessage *pxMessage;\r
303 \r
304         // Create a queue capable of containing 10 uint32_t values.\r
305         xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) );\r
306 \r
307         // Create a queue capable of containing 10 pointers to AMessage structures.\r
308         // These should be passed by pointer as they contain a lot of data.\r
309         xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );\r
310 \r
311         // ...\r
312 \r
313         if( xQueue1 != 0 )\r
314         {\r
315                 // Send an uint32_t.  Wait for 10 ticks for space to become\r
316                 // available if necessary.\r
317                 if( xQueueSendToBack( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10 ) != pdPASS )\r
318                 {\r
319                         // Failed to post the message, even after 10 ticks.\r
320                 }\r
321         }\r
322 \r
323         if( xQueue2 != 0 )\r
324         {\r
325                 // Send a pointer to a struct AMessage object.  Don't block if the\r
326                 // queue is already full.\r
327                 pxMessage = & xMessage;\r
328                 xQueueSendToBack( xQueue2, ( void * ) &pxMessage, ( TickType_t ) 0 );\r
329         }\r
330 \r
331         // ... Rest of task code.\r
332  }\r
333  </pre>\r
334  * \defgroup xQueueSend xQueueSend\r
335  * \ingroup QueueManagement\r
336  */\r
337 #define xQueueSendToBack( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK )\r
338 \r
339 /**\r
340  * queue. h\r
341  * <pre>\r
342  BaseType_t xQueueSend(\r
343                                                           QueueHandle_t xQueue,\r
344                                                           const void * pvItemToQueue,\r
345                                                           TickType_t xTicksToWait\r
346                                                  );\r
347  * </pre>\r
348  *\r
349  * This is a macro that calls xQueueGenericSend().  It is included for\r
350  * backward compatibility with versions of FreeRTOS.org that did not\r
351  * include the xQueueSendToFront() and xQueueSendToBack() macros.  It is\r
352  * equivalent to xQueueSendToBack().\r
353  *\r
354  * Post an item on a queue.  The item is queued by copy, not by reference.\r
355  * This function must not be called from an interrupt service routine.\r
356  * See xQueueSendFromISR () for an alternative which may be used in an ISR.\r
357  *\r
358  * @param xQueue The handle to the queue on which the item is to be posted.\r
359  *\r
360  * @param pvItemToQueue A pointer to the item that is to be placed on the\r
361  * queue.  The size of the items the queue will hold was defined when the\r
362  * queue was created, so this many bytes will be copied from pvItemToQueue\r
363  * into the queue storage area.\r
364  *\r
365  * @param xTicksToWait The maximum amount of time the task should block\r
366  * waiting for space to become available on the queue, should it already\r
367  * be full.  The call will return immediately if this is set to 0 and the\r
368  * queue is full.  The time is defined in tick periods so the constant\r
369  * portTICK_PERIOD_MS should be used to convert to real time if this is required.\r
370  *\r
371  * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL.\r
372  *\r
373  * Example usage:\r
374    <pre>\r
375  struct AMessage\r
376  {\r
377         char ucMessageID;\r
378         char ucData[ 20 ];\r
379  } xMessage;\r
380 \r
381  uint32_t ulVar = 10UL;\r
382 \r
383  void vATask( void *pvParameters )\r
384  {\r
385  QueueHandle_t xQueue1, xQueue2;\r
386  struct AMessage *pxMessage;\r
387 \r
388         // Create a queue capable of containing 10 uint32_t values.\r
389         xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) );\r
390 \r
391         // Create a queue capable of containing 10 pointers to AMessage structures.\r
392         // These should be passed by pointer as they contain a lot of data.\r
393         xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );\r
394 \r
395         // ...\r
396 \r
397         if( xQueue1 != 0 )\r
398         {\r
399                 // Send an uint32_t.  Wait for 10 ticks for space to become\r
400                 // available if necessary.\r
401                 if( xQueueSend( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10 ) != pdPASS )\r
402                 {\r
403                         // Failed to post the message, even after 10 ticks.\r
404                 }\r
405         }\r
406 \r
407         if( xQueue2 != 0 )\r
408         {\r
409                 // Send a pointer to a struct AMessage object.  Don't block if the\r
410                 // queue is already full.\r
411                 pxMessage = & xMessage;\r
412                 xQueueSend( xQueue2, ( void * ) &pxMessage, ( TickType_t ) 0 );\r
413         }\r
414 \r
415         // ... Rest of task code.\r
416  }\r
417  </pre>\r
418  * \defgroup xQueueSend xQueueSend\r
419  * \ingroup QueueManagement\r
420  */\r
421 #define xQueueSend( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK )\r
422 \r
423 /**\r
424  * queue. h\r
425  * <pre>\r
426  BaseType_t xQueueOverwrite(\r
427                                                           QueueHandle_t xQueue,\r
428                                                           const void * pvItemToQueue\r
429                                                  );\r
430  * </pre>\r
431  *\r
432  * Only for use with queues that have a length of one - so the queue is either\r
433  * empty or full.\r
434  *\r
435  * Post an item on a queue.  If the queue is already full then overwrite the\r
436  * value held in the queue.  The item is queued by copy, not by reference.\r
437  *\r
438  * This function must not be called from an interrupt service routine.\r
439  * See xQueueOverwriteFromISR () for an alternative which may be used in an ISR.\r
440  *\r
441  * @param xQueue The handle of the queue to which the data is being sent.\r
442  *\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
447  *\r
448  * @return xQueueOverwrite() is a macro that calls xQueueGenericSend(), and\r
449  * therefore has the same return values as xQueueSendToFront().  However, pdPASS\r
450  * is the only value that can be returned because xQueueOverwrite() will write\r
451  * to the queue even when the queue is already full.\r
452  *\r
453  * Example usage:\r
454    <pre>\r
455 \r
456  void vFunction( void *pvParameters )\r
457  {\r
458  QueueHandle_t xQueue;\r
459  uint32_t ulVarToSend, ulValReceived;\r
460 \r
461         // Create a queue to hold one uint32_t value.  It is strongly\r
462         // recommended *not* to use xQueueOverwrite() on queues that can\r
463         // contain more than one value, and doing so will trigger an assertion\r
464         // if configASSERT() is defined.\r
465         xQueue = xQueueCreate( 1, sizeof( uint32_t ) );\r
466 \r
467         // Write the value 10 to the queue using xQueueOverwrite().\r
468         ulVarToSend = 10;\r
469         xQueueOverwrite( xQueue, &ulVarToSend );\r
470 \r
471         // Peeking the queue should now return 10, but leave the value 10 in\r
472         // the queue.  A block time of zero is used as it is known that the\r
473         // queue holds a value.\r
474         ulValReceived = 0;\r
475         xQueuePeek( xQueue, &ulValReceived, 0 );\r
476 \r
477         if( ulValReceived != 10 )\r
478         {\r
479                 // Error unless the item was removed by a different task.\r
480         }\r
481 \r
482         // The queue is still full.  Use xQueueOverwrite() to overwrite the\r
483         // value held in the queue with 100.\r
484         ulVarToSend = 100;\r
485         xQueueOverwrite( xQueue, &ulVarToSend );\r
486 \r
487         // This time read from the queue, leaving the queue empty once more.\r
488         // A block time of 0 is used again.\r
489         xQueueReceive( xQueue, &ulValReceived, 0 );\r
490 \r
491         // The value read should be the last value written, even though the\r
492         // queue was already full when the value was written.\r
493         if( ulValReceived != 100 )\r
494         {\r
495                 // Error!\r
496         }\r
497 \r
498         // ...\r
499 }\r
500  </pre>\r
501  * \defgroup xQueueOverwrite xQueueOverwrite\r
502  * \ingroup QueueManagement\r
503  */\r
504 #define xQueueOverwrite( xQueue, pvItemToQueue ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), 0, queueOVERWRITE )\r
505 \r
506 \r
507 /**\r
508  * queue. h\r
509  * <pre>\r
510  BaseType_t xQueueGenericSend(\r
511                                                                         QueueHandle_t xQueue,\r
512                                                                         const void * pvItemToQueue,\r
513                                                                         TickType_t xTicksToWait\r
514                                                                         BaseType_t xCopyPosition\r
515                                                                 );\r
516  * </pre>\r
517  *\r
518  * It is preferred that the macros xQueueSend(), xQueueSendToFront() and\r
519  * xQueueSendToBack() are used in place of calling this function directly.\r
520  *\r
521  * Post an item on a queue.  The item is queued by copy, not by reference.\r
522  * This function must not be called from an interrupt service routine.\r
523  * See xQueueSendFromISR () for an alternative which may be used in an ISR.\r
524  *\r
525  * @param xQueue The handle to the queue on which the item is to be posted.\r
526  *\r
527  * @param pvItemToQueue A pointer to the item that is to be placed on the\r
528  * queue.  The size of the items the queue will hold was defined when the\r
529  * queue was created, so this many bytes will be copied from pvItemToQueue\r
530  * into the queue storage area.\r
531  *\r
532  * @param xTicksToWait The maximum amount of time the task should block\r
533  * waiting for space to become available on the queue, should it already\r
534  * be full.  The call will return immediately if this is set to 0 and the\r
535  * queue is full.  The time is defined in tick periods so the constant\r
536  * portTICK_PERIOD_MS should be used to convert to real time if this is required.\r
537  *\r
538  * @param xCopyPosition Can take the value queueSEND_TO_BACK to place the\r
539  * item at the back of the queue, or queueSEND_TO_FRONT to place the item\r
540  * at the front of the queue (for high priority messages).\r
541  *\r
542  * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL.\r
543  *\r
544  * Example usage:\r
545    <pre>\r
546  struct AMessage\r
547  {\r
548         char ucMessageID;\r
549         char ucData[ 20 ];\r
550  } xMessage;\r
551 \r
552  uint32_t ulVar = 10UL;\r
553 \r
554  void vATask( void *pvParameters )\r
555  {\r
556  QueueHandle_t xQueue1, xQueue2;\r
557  struct AMessage *pxMessage;\r
558 \r
559         // Create a queue capable of containing 10 uint32_t values.\r
560         xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) );\r
561 \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         xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );\r
565 \r
566         // ...\r
567 \r
568         if( xQueue1 != 0 )\r
569         {\r
570                 // Send an uint32_t.  Wait for 10 ticks for space to become\r
571                 // available if necessary.\r
572                 if( xQueueGenericSend( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10, queueSEND_TO_BACK ) != pdPASS )\r
573                 {\r
574                         // Failed to post the message, even after 10 ticks.\r
575                 }\r
576         }\r
577 \r
578         if( xQueue2 != 0 )\r
579         {\r
580                 // Send a pointer to a struct AMessage object.  Don't block if the\r
581                 // queue is already full.\r
582                 pxMessage = & xMessage;\r
583                 xQueueGenericSend( xQueue2, ( void * ) &pxMessage, ( TickType_t ) 0, queueSEND_TO_BACK );\r
584         }\r
585 \r
586         // ... Rest of task code.\r
587  }\r
588  </pre>\r
589  * \defgroup xQueueSend xQueueSend\r
590  * \ingroup QueueManagement\r
591  */\r
592 BaseType_t xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQueue, TickType_t xTicksToWait, const BaseType_t xCopyPosition ) PRIVILEGED_FUNCTION;\r
593 \r
594 /**\r
595  * queue. h\r
596  * <pre>\r
597  BaseType_t xQueuePeek(\r
598                                                          QueueHandle_t xQueue,\r
599                                                          void *pvBuffer,\r
600                                                          TickType_t xTicksToWait\r
601                                                  );</pre>\r
602  *\r
603  * This is a macro that calls the xQueueGenericReceive() function.\r
604  *\r
605  * Receive an item from a queue without removing the item from the queue.\r
606  * The item is received by copy so a buffer of adequate size must be\r
607  * provided.  The number of bytes copied into the buffer was defined when\r
608  * the queue was created.\r
609  *\r
610  * Successfully received items remain on the queue so will be returned again\r
611  * by the next call, or a call to xQueueReceive().\r
612  *\r
613  * This macro must not be used in an interrupt service routine.  See\r
614  * xQueuePeekFromISR() for an alternative that can be called from an interrupt\r
615  * service routine.\r
616  *\r
617  * @param xQueue The handle to the queue from which the item is to be\r
618  * received.\r
619  *\r
620  * @param pvBuffer Pointer to the buffer into which the received item will\r
621  * be copied.\r
622  *\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.  The time is defined in tick periods so the constant\r
626  * portTICK_PERIOD_MS should be used to convert to real time if this is required.\r
627  * xQueuePeek() will return immediately if xTicksToWait is 0 and the queue\r
628  * is empty.\r
629  *\r
630  * @return pdTRUE if an item was successfully received from the queue,\r
631  * otherwise pdFALSE.\r
632  *\r
633  * Example usage:\r
634    <pre>\r
635  struct AMessage\r
636  {\r
637         char ucMessageID;\r
638         char ucData[ 20 ];\r
639  } xMessage;\r
640 \r
641  QueueHandle_t xQueue;\r
642 \r
643  // Task to create a queue and post a value.\r
644  void vATask( void *pvParameters )\r
645  {\r
646  struct AMessage *pxMessage;\r
647 \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
651         if( xQueue == 0 )\r
652         {\r
653                 // Failed to create the queue.\r
654         }\r
655 \r
656         // ...\r
657 \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, ( TickType_t ) 0 );\r
662 \r
663         // ... Rest of task code.\r
664  }\r
665 \r
666  // Task to peek the data from the queue.\r
667  void vADifferentTask( void *pvParameters )\r
668  {\r
669  struct AMessage *pxRxedMessage;\r
670 \r
671         if( xQueue != 0 )\r
672         {\r
673                 // Peek a message on the created queue.  Block for 10 ticks if a\r
674                 // message is not immediately available.\r
675                 if( xQueuePeek( xQueue, &( pxRxedMessage ), ( TickType_t ) 10 ) )\r
676                 {\r
677                         // pcRxedMessage now points to the struct AMessage variable posted\r
678                         // by vATask, but the item still remains on the queue.\r
679                 }\r
680         }\r
681 \r
682         // ... Rest of task code.\r
683  }\r
684  </pre>\r
685  * \defgroup xQueueReceive xQueueReceive\r
686  * \ingroup QueueManagement\r
687  */\r
688 #define xQueuePeek( xQueue, pvBuffer, xTicksToWait ) xQueueGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdTRUE )\r
689 \r
690 /**\r
691  * queue. h\r
692  * <pre>\r
693  BaseType_t xQueuePeekFromISR(\r
694                                                                         QueueHandle_t xQueue,\r
695                                                                         void *pvBuffer,\r
696                                                                 );</pre>\r
697  *\r
698  * A version of xQueuePeek() that can be called from an interrupt service\r
699  * routine (ISR).\r
700  *\r
701  * Receive an item from a queue without removing the item from the queue.\r
702  * The item is received by copy so a buffer of adequate size must be\r
703  * provided.  The number of bytes copied into the buffer was defined when\r
704  * the queue was created.\r
705  *\r
706  * Successfully received items remain on the queue so will be returned again\r
707  * by the next call, or a call to xQueueReceive().\r
708  *\r
709  * @param xQueue The handle to the queue from which the item is to be\r
710  * received.\r
711  *\r
712  * @param pvBuffer Pointer to the buffer into which the received item will\r
713  * be copied.\r
714  *\r
715  * @return pdTRUE if an item was successfully received from the queue,\r
716  * otherwise pdFALSE.\r
717  *\r
718  * \defgroup xQueuePeekFromISR xQueuePeekFromISR\r
719  * \ingroup QueueManagement\r
720  */\r
721 BaseType_t xQueuePeekFromISR( QueueHandle_t xQueue, void * const pvBuffer ) PRIVILEGED_FUNCTION;\r
722 \r
723 /**\r
724  * queue. h\r
725  * <pre>\r
726  BaseType_t xQueueReceive(\r
727                                                                  QueueHandle_t xQueue,\r
728                                                                  void *pvBuffer,\r
729                                                                  TickType_t xTicksToWait\r
730                                                         );</pre>\r
731  *\r
732  * This is a macro that calls the xQueueGenericReceive() function.\r
733  *\r
734  * Receive an item from a queue.  The item is received by copy so a buffer of\r
735  * adequate size must be provided.  The number of bytes copied into the buffer\r
736  * was defined when the queue was created.\r
737  *\r
738  * Successfully received items are removed from the queue.\r
739  *\r
740  * This function must not be used in an interrupt service routine.  See\r
741  * xQueueReceiveFromISR for an alternative that can.\r
742  *\r
743  * @param xQueue The handle to the queue from which the item is to be\r
744  * received.\r
745  *\r
746  * @param pvBuffer Pointer to the buffer into which the received item will\r
747  * be copied.\r
748  *\r
749  * @param xTicksToWait The maximum amount of time the task should block\r
750  * waiting for an item to receive should the queue be empty at the time\r
751  * of the call.  xQueueReceive() will return immediately if xTicksToWait\r
752  * is zero and the queue is empty.  The time is defined in tick periods so the\r
753  * constant portTICK_PERIOD_MS should be used to convert to real time if this is\r
754  * required.\r
755  *\r
756  * @return pdTRUE if an item was successfully received from the queue,\r
757  * otherwise pdFALSE.\r
758  *\r
759  * Example usage:\r
760    <pre>\r
761  struct AMessage\r
762  {\r
763         char ucMessageID;\r
764         char ucData[ 20 ];\r
765  } xMessage;\r
766 \r
767  QueueHandle_t xQueue;\r
768 \r
769  // Task to create a queue and post a value.\r
770  void vATask( void *pvParameters )\r
771  {\r
772  struct AMessage *pxMessage;\r
773 \r
774         // Create a queue capable of containing 10 pointers to AMessage structures.\r
775         // These should be passed by pointer as they contain a lot of data.\r
776         xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) );\r
777         if( xQueue == 0 )\r
778         {\r
779                 // Failed to create the queue.\r
780         }\r
781 \r
782         // ...\r
783 \r
784         // Send a pointer to a struct AMessage object.  Don't block if the\r
785         // queue is already full.\r
786         pxMessage = & xMessage;\r
787         xQueueSend( xQueue, ( void * ) &pxMessage, ( TickType_t ) 0 );\r
788 \r
789         // ... Rest of task code.\r
790  }\r
791 \r
792  // Task to receive from the queue.\r
793  void vADifferentTask( void *pvParameters )\r
794  {\r
795  struct AMessage *pxRxedMessage;\r
796 \r
797         if( xQueue != 0 )\r
798         {\r
799                 // Receive a message on the created queue.  Block for 10 ticks if a\r
800                 // message is not immediately available.\r
801                 if( xQueueReceive( xQueue, &( pxRxedMessage ), ( TickType_t ) 10 ) )\r
802                 {\r
803                         // pcRxedMessage now points to the struct AMessage variable posted\r
804                         // by vATask.\r
805                 }\r
806         }\r
807 \r
808         // ... Rest of task code.\r
809  }\r
810  </pre>\r
811  * \defgroup xQueueReceive xQueueReceive\r
812  * \ingroup QueueManagement\r
813  */\r
814 #define xQueueReceive( xQueue, pvBuffer, xTicksToWait ) xQueueGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdFALSE )\r
815 \r
816 \r
817 /**\r
818  * queue. h\r
819  * <pre>\r
820  BaseType_t xQueueGenericReceive(\r
821                                                                            QueueHandle_t        xQueue,\r
822                                                                            void *pvBuffer,\r
823                                                                            TickType_t   xTicksToWait\r
824                                                                            BaseType_t   xJustPeek\r
825                                                                         );</pre>\r
826  *\r
827  * It is preferred that the macro xQueueReceive() be used rather than calling\r
828  * this function directly.\r
829  *\r
830  * Receive an item from a queue.  The item is received by copy so a buffer of\r
831  * adequate size must be provided.  The number of bytes copied into the buffer\r
832  * was defined when the queue was created.\r
833  *\r
834  * This function must not be used in an interrupt service routine.  See\r
835  * xQueueReceiveFromISR for an alternative that can.\r
836  *\r
837  * @param xQueue The handle to the queue from which the item is to be\r
838  * received.\r
839  *\r
840  * @param pvBuffer Pointer to the buffer into which the received item will\r
841  * be copied.\r
842  *\r
843  * @param xTicksToWait The maximum amount of time the task should block\r
844  * waiting for an item to receive should the queue be empty at the time\r
845  * of the call.  The time is defined in tick periods so the constant\r
846  * portTICK_PERIOD_MS should be used to convert to real time if this is required.\r
847  * xQueueGenericReceive() will return immediately if the queue is empty and\r
848  * xTicksToWait is 0.\r
849  *\r
850  * @param xJustPeek When set to true, the item received from the queue is not\r
851  * actually removed from the queue - meaning a subsequent call to\r
852  * xQueueReceive() will return the same item.  When set to false, the item\r
853  * being received from the queue is also removed from the queue.\r
854  *\r
855  * @return pdTRUE if an item was successfully received from the queue,\r
856  * otherwise pdFALSE.\r
857  *\r
858  * Example usage:\r
859    <pre>\r
860  struct AMessage\r
861  {\r
862         char ucMessageID;\r
863         char ucData[ 20 ];\r
864  } xMessage;\r
865 \r
866  QueueHandle_t xQueue;\r
867 \r
868  // Task to create a queue and post a value.\r
869  void vATask( void *pvParameters )\r
870  {\r
871  struct AMessage *pxMessage;\r
872 \r
873         // Create a queue capable of containing 10 pointers to AMessage structures.\r
874         // These should be passed by pointer as they contain a lot of data.\r
875         xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) );\r
876         if( xQueue == 0 )\r
877         {\r
878                 // Failed to create the queue.\r
879         }\r
880 \r
881         // ...\r
882 \r
883         // Send a pointer to a struct AMessage object.  Don't block if the\r
884         // queue is already full.\r
885         pxMessage = & xMessage;\r
886         xQueueSend( xQueue, ( void * ) &pxMessage, ( TickType_t ) 0 );\r
887 \r
888         // ... Rest of task code.\r
889  }\r
890 \r
891  // Task to receive from the queue.\r
892  void vADifferentTask( void *pvParameters )\r
893  {\r
894  struct AMessage *pxRxedMessage;\r
895 \r
896         if( xQueue != 0 )\r
897         {\r
898                 // Receive a message on the created queue.  Block for 10 ticks if a\r
899                 // message is not immediately available.\r
900                 if( xQueueGenericReceive( xQueue, &( pxRxedMessage ), ( TickType_t ) 10 ) )\r
901                 {\r
902                         // pcRxedMessage now points to the struct AMessage variable posted\r
903                         // by vATask.\r
904                 }\r
905         }\r
906 \r
907         // ... Rest of task code.\r
908  }\r
909  </pre>\r
910  * \defgroup xQueueReceive xQueueReceive\r
911  * \ingroup QueueManagement\r
912  */\r
913 BaseType_t xQueueGenericReceive( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait, const BaseType_t xJustPeek ) PRIVILEGED_FUNCTION;\r
914 \r
915 /**\r
916  * queue. h\r
917  * <pre>UBaseType_t uxQueueMessagesWaiting( const QueueHandle_t xQueue );</pre>\r
918  *\r
919  * Return the number of messages stored in a queue.\r
920  *\r
921  * @param xQueue A handle to the queue being queried.\r
922  *\r
923  * @return The number of messages available in the queue.\r
924  *\r
925  * \defgroup uxQueueMessagesWaiting uxQueueMessagesWaiting\r
926  * \ingroup QueueManagement\r
927  */\r
928 UBaseType_t uxQueueMessagesWaiting( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;\r
929 \r
930 /**\r
931  * queue. h\r
932  * <pre>UBaseType_t uxQueueSpacesAvailable( const QueueHandle_t xQueue );</pre>\r
933  *\r
934  * Return the number of free spaces available in a queue.  This is equal to the\r
935  * number of items that can be sent to the queue before the queue becomes full\r
936  * if no items are removed.\r
937  *\r
938  * @param xQueue A handle to the queue being queried.\r
939  *\r
940  * @return The number of spaces available in the queue.\r
941  *\r
942  * \defgroup uxQueueMessagesWaiting uxQueueMessagesWaiting\r
943  * \ingroup QueueManagement\r
944  */\r
945 UBaseType_t uxQueueSpacesAvailable( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;\r
946 \r
947 /**\r
948  * queue. h\r
949  * <pre>void vQueueDelete( QueueHandle_t xQueue );</pre>\r
950  *\r
951  * Delete a queue - freeing all the memory allocated for storing of items\r
952  * placed on the queue.\r
953  *\r
954  * @param xQueue A handle to the queue to be deleted.\r
955  *\r
956  * \defgroup vQueueDelete vQueueDelete\r
957  * \ingroup QueueManagement\r
958  */\r
959 void vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;\r
960 \r
961 /**\r
962  * queue. h\r
963  * <pre>\r
964  BaseType_t xQueueSendToFrontFromISR(\r
965                                                                                  QueueHandle_t xQueue,\r
966                                                                                  const void *pvItemToQueue,\r
967                                                                                  BaseType_t *pxHigherPriorityTaskWoken\r
968                                                                           );\r
969  </pre>\r
970  *\r
971  * This is a macro that calls xQueueGenericSendFromISR().\r
972  *\r
973  * Post an item to the front of a queue.  It is safe to use this macro from\r
974  * within an interrupt service routine.\r
975  *\r
976  * Items are queued by copy not reference so it is preferable to only\r
977  * queue small items, especially when called from an ISR.  In most cases\r
978  * it would be preferable to store a pointer to the item being queued.\r
979  *\r
980  * @param xQueue The handle to the queue on which the item is to be posted.\r
981  *\r
982  * @param pvItemToQueue A pointer to the item that is to be placed on the\r
983  * queue.  The size of the items the queue will hold was defined when the\r
984  * queue was created, so this many bytes will be copied from pvItemToQueue\r
985  * into the queue storage area.\r
986  *\r
987  * @param pxHigherPriorityTaskWoken xQueueSendToFrontFromISR() will set\r
988  * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task\r
989  * to unblock, and the unblocked task has a priority higher than the currently\r
990  * running task.  If xQueueSendToFromFromISR() sets this value to pdTRUE then\r
991  * a context switch should be requested before the interrupt is exited.\r
992  *\r
993  * @return pdTRUE if the data was successfully sent to the queue, otherwise\r
994  * errQUEUE_FULL.\r
995  *\r
996  * Example usage for buffered IO (where the ISR can obtain more than one value\r
997  * per call):\r
998    <pre>\r
999  void vBufferISR( void )\r
1000  {\r
1001  char cIn;\r
1002  BaseType_t xHigherPrioritTaskWoken;\r
1003 \r
1004         // We have not woken a task at the start of the ISR.\r
1005         xHigherPriorityTaskWoken = pdFALSE;\r
1006 \r
1007         // Loop until the buffer is empty.\r
1008         do\r
1009         {\r
1010                 // Obtain a byte from the buffer.\r
1011                 cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );\r
1012 \r
1013                 // Post the byte.\r
1014                 xQueueSendToFrontFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );\r
1015 \r
1016         } while( portINPUT_BYTE( BUFFER_COUNT ) );\r
1017 \r
1018         // Now the buffer is empty we can switch context if necessary.\r
1019         if( xHigherPriorityTaskWoken )\r
1020         {\r
1021                 taskYIELD ();\r
1022         }\r
1023  }\r
1024  </pre>\r
1025  *\r
1026  * \defgroup xQueueSendFromISR xQueueSendFromISR\r
1027  * \ingroup QueueManagement\r
1028  */\r
1029 #define xQueueSendToFrontFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_FRONT )\r
1030 \r
1031 \r
1032 /**\r
1033  * queue. h\r
1034  * <pre>\r
1035  BaseType_t xQueueSendToBackFromISR(\r
1036                                                                                  QueueHandle_t xQueue,\r
1037                                                                                  const void *pvItemToQueue,\r
1038                                                                                  BaseType_t *pxHigherPriorityTaskWoken\r
1039                                                                           );\r
1040  </pre>\r
1041  *\r
1042  * This is a macro that calls xQueueGenericSendFromISR().\r
1043  *\r
1044  * Post an item to the back of a queue.  It is safe to use this macro from\r
1045  * within an interrupt service routine.\r
1046  *\r
1047  * Items are queued by copy not reference so it is preferable to only\r
1048  * queue small items, especially when called from an ISR.  In most cases\r
1049  * it would be preferable to store a pointer to the item being queued.\r
1050  *\r
1051  * @param xQueue The handle to the queue on which the item is to be posted.\r
1052  *\r
1053  * @param pvItemToQueue A pointer to the item that is to be placed on the\r
1054  * queue.  The size of the items the queue will hold was defined when the\r
1055  * queue was created, so this many bytes will be copied from pvItemToQueue\r
1056  * into the queue storage area.\r
1057  *\r
1058  * @param pxHigherPriorityTaskWoken xQueueSendToBackFromISR() will set\r
1059  * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task\r
1060  * to unblock, and the unblocked task has a priority higher than the currently\r
1061  * running task.  If xQueueSendToBackFromISR() sets this value to pdTRUE then\r
1062  * a context switch should be requested before the interrupt is exited.\r
1063  *\r
1064  * @return pdTRUE if the data was successfully sent to the queue, otherwise\r
1065  * errQUEUE_FULL.\r
1066  *\r
1067  * Example usage for buffered IO (where the ISR can obtain more than one value\r
1068  * per call):\r
1069    <pre>\r
1070  void vBufferISR( void )\r
1071  {\r
1072  char cIn;\r
1073  BaseType_t xHigherPriorityTaskWoken;\r
1074 \r
1075         // We have not woken a task at the start of the ISR.\r
1076         xHigherPriorityTaskWoken = pdFALSE;\r
1077 \r
1078         // Loop until the buffer is empty.\r
1079         do\r
1080         {\r
1081                 // Obtain a byte from the buffer.\r
1082                 cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );\r
1083 \r
1084                 // Post the byte.\r
1085                 xQueueSendToBackFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );\r
1086 \r
1087         } while( portINPUT_BYTE( BUFFER_COUNT ) );\r
1088 \r
1089         // Now the buffer is empty we can switch context if necessary.\r
1090         if( xHigherPriorityTaskWoken )\r
1091         {\r
1092                 taskYIELD ();\r
1093         }\r
1094  }\r
1095  </pre>\r
1096  *\r
1097  * \defgroup xQueueSendFromISR xQueueSendFromISR\r
1098  * \ingroup QueueManagement\r
1099  */\r
1100 #define xQueueSendToBackFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK )\r
1101 \r
1102 /**\r
1103  * queue. h\r
1104  * <pre>\r
1105  BaseType_t xQueueOverwriteFromISR(\r
1106                                                           QueueHandle_t xQueue,\r
1107                                                           const void * pvItemToQueue,\r
1108                                                           BaseType_t *pxHigherPriorityTaskWoken\r
1109                                                  );\r
1110  * </pre>\r
1111  *\r
1112  * A version of xQueueOverwrite() that can be used in an interrupt service\r
1113  * routine (ISR).\r
1114  *\r
1115  * Only for use with queues that can hold a single item - so the queue is either\r
1116  * empty or full.\r
1117  *\r
1118  * Post an item on a queue.  If the queue is already full then overwrite the\r
1119  * value held in the queue.  The item is queued by copy, not by reference.\r
1120  *\r
1121  * @param xQueue The handle to the queue on which the item is to be posted.\r
1122  *\r
1123  * @param pvItemToQueue A pointer to the item that is to be placed on the\r
1124  * queue.  The size of the items the queue will hold was defined when the\r
1125  * queue was created, so this many bytes will be copied from pvItemToQueue\r
1126  * into the queue storage area.\r
1127  *\r
1128  * @param pxHigherPriorityTaskWoken xQueueOverwriteFromISR() will set\r
1129  * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task\r
1130  * to unblock, and the unblocked task has a priority higher than the currently\r
1131  * running task.  If xQueueOverwriteFromISR() sets this value to pdTRUE then\r
1132  * a context switch should be requested before the interrupt is exited.\r
1133  *\r
1134  * @return xQueueOverwriteFromISR() is a macro that calls\r
1135  * xQueueGenericSendFromISR(), and therefore has the same return values as\r
1136  * xQueueSendToFrontFromISR().  However, pdPASS is the only value that can be\r
1137  * returned because xQueueOverwriteFromISR() will write to the queue even when\r
1138  * the queue is already full.\r
1139  *\r
1140  * Example usage:\r
1141    <pre>\r
1142 \r
1143  QueueHandle_t xQueue;\r
1144 \r
1145  void vFunction( void *pvParameters )\r
1146  {\r
1147         // Create a queue to hold one uint32_t value.  It is strongly\r
1148         // recommended *not* to use xQueueOverwriteFromISR() on queues that can\r
1149         // contain more than one value, and doing so will trigger an assertion\r
1150         // if configASSERT() is defined.\r
1151         xQueue = xQueueCreate( 1, sizeof( uint32_t ) );\r
1152 }\r
1153 \r
1154 void vAnInterruptHandler( void )\r
1155 {\r
1156 // xHigherPriorityTaskWoken must be set to pdFALSE before it is used.\r
1157 BaseType_t xHigherPriorityTaskWoken = pdFALSE;\r
1158 uint32_t ulVarToSend, ulValReceived;\r
1159 \r
1160         // Write the value 10 to the queue using xQueueOverwriteFromISR().\r
1161         ulVarToSend = 10;\r
1162         xQueueOverwriteFromISR( xQueue, &ulVarToSend, &xHigherPriorityTaskWoken );\r
1163 \r
1164         // The queue is full, but calling xQueueOverwriteFromISR() again will still\r
1165         // pass because the value held in the queue will be overwritten with the\r
1166         // new value.\r
1167         ulVarToSend = 100;\r
1168         xQueueOverwriteFromISR( xQueue, &ulVarToSend, &xHigherPriorityTaskWoken );\r
1169 \r
1170         // Reading from the queue will now return 100.\r
1171 \r
1172         // ...\r
1173 \r
1174         if( xHigherPrioritytaskWoken == pdTRUE )\r
1175         {\r
1176                 // Writing to the queue caused a task to unblock and the unblocked task\r
1177                 // has a priority higher than or equal to the priority of the currently\r
1178                 // executing task (the task this interrupt interrupted).  Perform a context\r
1179                 // switch so this interrupt returns directly to the unblocked task.\r
1180                 portYIELD_FROM_ISR(); // or portEND_SWITCHING_ISR() depending on the port.\r
1181         }\r
1182 }\r
1183  </pre>\r
1184  * \defgroup xQueueOverwriteFromISR xQueueOverwriteFromISR\r
1185  * \ingroup QueueManagement\r
1186  */\r
1187 #define xQueueOverwriteFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueOVERWRITE )\r
1188 \r
1189 /**\r
1190  * queue. h\r
1191  * <pre>\r
1192  BaseType_t xQueueSendFromISR(\r
1193                                                                          QueueHandle_t xQueue,\r
1194                                                                          const void *pvItemToQueue,\r
1195                                                                          BaseType_t *pxHigherPriorityTaskWoken\r
1196                                                                 );\r
1197  </pre>\r
1198  *\r
1199  * This is a macro that calls xQueueGenericSendFromISR().  It is included\r
1200  * for backward compatibility with versions of FreeRTOS.org that did not\r
1201  * include the xQueueSendToBackFromISR() and xQueueSendToFrontFromISR()\r
1202  * macros.\r
1203  *\r
1204  * Post an item to the back of a queue.  It is safe to use this function from\r
1205  * within an interrupt service routine.\r
1206  *\r
1207  * Items are queued by copy not reference so it is preferable to only\r
1208  * queue small items, especially when called from an ISR.  In most cases\r
1209  * it would be preferable to store a pointer to the item being queued.\r
1210  *\r
1211  * @param xQueue The handle to the queue on which the item is to be posted.\r
1212  *\r
1213  * @param pvItemToQueue A pointer to the item that is to be placed on the\r
1214  * queue.  The size of the items the queue will hold was defined when the\r
1215  * queue was created, so this many bytes will be copied from pvItemToQueue\r
1216  * into the queue storage area.\r
1217  *\r
1218  * @param pxHigherPriorityTaskWoken xQueueSendFromISR() will set\r
1219  * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task\r
1220  * to unblock, and the unblocked task has a priority higher than the currently\r
1221  * running task.  If xQueueSendFromISR() sets this value to pdTRUE then\r
1222  * a context switch should be requested before the interrupt is exited.\r
1223  *\r
1224  * @return pdTRUE if the data was successfully sent to the queue, otherwise\r
1225  * errQUEUE_FULL.\r
1226  *\r
1227  * Example usage for buffered IO (where the ISR can obtain more than one value\r
1228  * per call):\r
1229    <pre>\r
1230  void vBufferISR( void )\r
1231  {\r
1232  char cIn;\r
1233  BaseType_t xHigherPriorityTaskWoken;\r
1234 \r
1235         // We have not woken a task at the start of the ISR.\r
1236         xHigherPriorityTaskWoken = pdFALSE;\r
1237 \r
1238         // Loop until the buffer is empty.\r
1239         do\r
1240         {\r
1241                 // Obtain a byte from the buffer.\r
1242                 cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );\r
1243 \r
1244                 // Post the byte.\r
1245                 xQueueSendFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );\r
1246 \r
1247         } while( portINPUT_BYTE( BUFFER_COUNT ) );\r
1248 \r
1249         // Now the buffer is empty we can switch context if necessary.\r
1250         if( xHigherPriorityTaskWoken )\r
1251         {\r
1252                 // Actual macro used here is port specific.\r
1253                 portYIELD_FROM_ISR ();\r
1254         }\r
1255  }\r
1256  </pre>\r
1257  *\r
1258  * \defgroup xQueueSendFromISR xQueueSendFromISR\r
1259  * \ingroup QueueManagement\r
1260  */\r
1261 #define xQueueSendFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK )\r
1262 \r
1263 /**\r
1264  * queue. h\r
1265  * <pre>\r
1266  BaseType_t xQueueGenericSendFromISR(\r
1267                                                                                    QueueHandle_t                xQueue,\r
1268                                                                                    const        void    *pvItemToQueue,\r
1269                                                                                    BaseType_t   *pxHigherPriorityTaskWoken,\r
1270                                                                                    BaseType_t   xCopyPosition\r
1271                                                                            );\r
1272  </pre>\r
1273  *\r
1274  * It is preferred that the macros xQueueSendFromISR(),\r
1275  * xQueueSendToFrontFromISR() and xQueueSendToBackFromISR() be used in place\r
1276  * of calling this function directly.  xQueueGiveFromISR() is an\r
1277  * equivalent for use by semaphores that don't actually copy any data.\r
1278  *\r
1279  * Post an item on a queue.  It is safe to use this function from within an\r
1280  * interrupt service routine.\r
1281  *\r
1282  * Items are queued by copy not reference so it is preferable to only\r
1283  * queue small items, especially when called from an ISR.  In most cases\r
1284  * it would be preferable to store a pointer to the item being queued.\r
1285  *\r
1286  * @param xQueue The handle to the queue on which the item is to be posted.\r
1287  *\r
1288  * @param pvItemToQueue A pointer to the item that is to be placed on the\r
1289  * queue.  The size of the items the queue will hold was defined when the\r
1290  * queue was created, so this many bytes will be copied from pvItemToQueue\r
1291  * into the queue storage area.\r
1292  *\r
1293  * @param pxHigherPriorityTaskWoken xQueueGenericSendFromISR() will set\r
1294  * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task\r
1295  * to unblock, and the unblocked task has a priority higher than the currently\r
1296  * running task.  If xQueueGenericSendFromISR() sets this value to pdTRUE then\r
1297  * a context switch should be requested before the interrupt is exited.\r
1298  *\r
1299  * @param xCopyPosition Can take the value queueSEND_TO_BACK to place the\r
1300  * item at the back of the queue, or queueSEND_TO_FRONT to place the item\r
1301  * at the front of the queue (for high priority messages).\r
1302  *\r
1303  * @return pdTRUE if the data was successfully sent to the queue, otherwise\r
1304  * errQUEUE_FULL.\r
1305  *\r
1306  * Example usage for buffered IO (where the ISR can obtain more than one value\r
1307  * per call):\r
1308    <pre>\r
1309  void vBufferISR( void )\r
1310  {\r
1311  char cIn;\r
1312  BaseType_t xHigherPriorityTaskWokenByPost;\r
1313 \r
1314         // We have not woken a task at the start of the ISR.\r
1315         xHigherPriorityTaskWokenByPost = pdFALSE;\r
1316 \r
1317         // Loop until the buffer is empty.\r
1318         do\r
1319         {\r
1320                 // Obtain a byte from the buffer.\r
1321                 cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );\r
1322 \r
1323                 // Post each byte.\r
1324                 xQueueGenericSendFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWokenByPost, queueSEND_TO_BACK );\r
1325 \r
1326         } while( portINPUT_BYTE( BUFFER_COUNT ) );\r
1327 \r
1328         // Now the buffer is empty we can switch context if necessary.  Note that the\r
1329         // name of the yield function required is port specific.\r
1330         if( xHigherPriorityTaskWokenByPost )\r
1331         {\r
1332                 taskYIELD_YIELD_FROM_ISR();\r
1333         }\r
1334  }\r
1335  </pre>\r
1336  *\r
1337  * \defgroup xQueueSendFromISR xQueueSendFromISR\r
1338  * \ingroup QueueManagement\r
1339  */\r
1340 BaseType_t xQueueGenericSendFromISR( QueueHandle_t xQueue, const void * const pvItemToQueue, BaseType_t * const pxHigherPriorityTaskWoken, const BaseType_t xCopyPosition ) PRIVILEGED_FUNCTION;\r
1341 BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue, BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;\r
1342 \r
1343 /**\r
1344  * queue. h\r
1345  * <pre>\r
1346  BaseType_t xQueueReceiveFromISR(\r
1347                                                                            QueueHandle_t        xQueue,\r
1348                                                                            void *pvBuffer,\r
1349                                                                            BaseType_t *pxTaskWoken\r
1350                                                                    );\r
1351  * </pre>\r
1352  *\r
1353  * Receive an item from a queue.  It is safe to use this function from within an\r
1354  * interrupt service routine.\r
1355  *\r
1356  * @param xQueue The handle to the queue from which the item is to be\r
1357  * received.\r
1358  *\r
1359  * @param pvBuffer Pointer to the buffer into which the received item will\r
1360  * be copied.\r
1361  *\r
1362  * @param pxTaskWoken A task may be blocked waiting for space to become\r
1363  * available on the queue.  If xQueueReceiveFromISR causes such a task to\r
1364  * unblock *pxTaskWoken will get set to pdTRUE, otherwise *pxTaskWoken will\r
1365  * remain unchanged.\r
1366  *\r
1367  * @return pdTRUE if an item was successfully received from the queue,\r
1368  * otherwise pdFALSE.\r
1369  *\r
1370  * Example usage:\r
1371    <pre>\r
1372 \r
1373  QueueHandle_t xQueue;\r
1374 \r
1375  // Function to create a queue and post some values.\r
1376  void vAFunction( void *pvParameters )\r
1377  {\r
1378  char cValueToPost;\r
1379  const TickType_t xTicksToWait = ( TickType_t )0xff;\r
1380 \r
1381         // Create a queue capable of containing 10 characters.\r
1382         xQueue = xQueueCreate( 10, sizeof( char ) );\r
1383         if( xQueue == 0 )\r
1384         {\r
1385                 // Failed to create the queue.\r
1386         }\r
1387 \r
1388         // ...\r
1389 \r
1390         // Post some characters that will be used within an ISR.  If the queue\r
1391         // is full then this task will block for xTicksToWait ticks.\r
1392         cValueToPost = 'a';\r
1393         xQueueSend( xQueue, ( void * ) &cValueToPost, xTicksToWait );\r
1394         cValueToPost = 'b';\r
1395         xQueueSend( xQueue, ( void * ) &cValueToPost, xTicksToWait );\r
1396 \r
1397         // ... keep posting characters ... this task may block when the queue\r
1398         // becomes full.\r
1399 \r
1400         cValueToPost = 'c';\r
1401         xQueueSend( xQueue, ( void * ) &cValueToPost, xTicksToWait );\r
1402  }\r
1403 \r
1404  // ISR that outputs all the characters received on the queue.\r
1405  void vISR_Routine( void )\r
1406  {\r
1407  BaseType_t xTaskWokenByReceive = pdFALSE;\r
1408  char cRxedChar;\r
1409 \r
1410         while( xQueueReceiveFromISR( xQueue, ( void * ) &cRxedChar, &xTaskWokenByReceive) )\r
1411         {\r
1412                 // A character was received.  Output the character now.\r
1413                 vOutputCharacter( cRxedChar );\r
1414 \r
1415                 // If removing the character from the queue woke the task that was\r
1416                 // posting onto the queue cTaskWokenByReceive will have been set to\r
1417                 // pdTRUE.  No matter how many times this loop iterates only one\r
1418                 // task will be woken.\r
1419         }\r
1420 \r
1421         if( cTaskWokenByPost != ( char ) pdFALSE;\r
1422         {\r
1423                 taskYIELD ();\r
1424         }\r
1425  }\r
1426  </pre>\r
1427  * \defgroup xQueueReceiveFromISR xQueueReceiveFromISR\r
1428  * \ingroup QueueManagement\r
1429  */\r
1430 BaseType_t xQueueReceiveFromISR( QueueHandle_t xQueue, void * const pvBuffer, BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;\r
1431 \r
1432 /*\r
1433  * Utilities to query queues that are safe to use from an ISR.  These utilities\r
1434  * should be used only from witin an ISR, or within a critical section.\r
1435  */\r
1436 BaseType_t xQueueIsQueueEmptyFromISR( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;\r
1437 BaseType_t xQueueIsQueueFullFromISR( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;\r
1438 UBaseType_t uxQueueMessagesWaitingFromISR( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;\r
1439 \r
1440 \r
1441 /*\r
1442  * xQueueAltGenericSend() is an alternative version of xQueueGenericSend().\r
1443  * Likewise xQueueAltGenericReceive() is an alternative version of\r
1444  * xQueueGenericReceive().\r
1445  *\r
1446  * The source code that implements the alternative (Alt) API is much\r
1447  * simpler      because it executes everything from within a critical section.\r
1448  * This is      the approach taken by many other RTOSes, but FreeRTOS.org has the\r
1449  * preferred fully featured API too.  The fully featured API has more\r
1450  * complex      code that takes longer to execute, but makes much less use of\r
1451  * critical sections.  Therefore the alternative API sacrifices interrupt\r
1452  * responsiveness to gain execution speed, whereas the fully featured API\r
1453  * sacrifices execution speed to ensure better interrupt responsiveness.\r
1454  */\r
1455 BaseType_t xQueueAltGenericSend( QueueHandle_t xQueue, const void * const pvItemToQueue, TickType_t xTicksToWait, BaseType_t xCopyPosition );\r
1456 BaseType_t xQueueAltGenericReceive( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait, BaseType_t xJustPeeking );\r
1457 #define xQueueAltSendToFront( xQueue, pvItemToQueue, xTicksToWait ) xQueueAltGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_FRONT )\r
1458 #define xQueueAltSendToBack( xQueue, pvItemToQueue, xTicksToWait ) xQueueAltGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK )\r
1459 #define xQueueAltReceive( xQueue, pvBuffer, xTicksToWait ) xQueueAltGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdFALSE )\r
1460 #define xQueueAltPeek( xQueue, pvBuffer, xTicksToWait ) xQueueAltGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdTRUE )\r
1461 \r
1462 /*\r
1463  * The functions defined above are for passing data to and from tasks.  The\r
1464  * functions below are the equivalents for passing data to and from\r
1465  * co-routines.\r
1466  *\r
1467  * These functions are called from the co-routine macro implementation and\r
1468  * should not be called directly from application code.  Instead use the macro\r
1469  * wrappers defined within croutine.h.\r
1470  */\r
1471 BaseType_t xQueueCRSendFromISR( QueueHandle_t xQueue, const void *pvItemToQueue, BaseType_t xCoRoutinePreviouslyWoken );\r
1472 BaseType_t xQueueCRReceiveFromISR( QueueHandle_t xQueue, void *pvBuffer, BaseType_t *pxTaskWoken );\r
1473 BaseType_t xQueueCRSend( QueueHandle_t xQueue, const void *pvItemToQueue, TickType_t xTicksToWait );\r
1474 BaseType_t xQueueCRReceive( QueueHandle_t xQueue, void *pvBuffer, TickType_t xTicksToWait );\r
1475 \r
1476 /*\r
1477  * For internal use only.  Use xSemaphoreCreateMutex(),\r
1478  * xSemaphoreCreateCounting() or xSemaphoreGetMutexHolder() instead of calling\r
1479  * these functions directly.\r
1480  */\r
1481 QueueHandle_t xQueueCreateMutex( const uint8_t ucQueueType ) PRIVILEGED_FUNCTION;\r
1482 QueueHandle_t xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount ) PRIVILEGED_FUNCTION;\r
1483 void* xQueueGetMutexHolder( QueueHandle_t xSemaphore ) PRIVILEGED_FUNCTION;\r
1484 \r
1485 /*\r
1486  * For internal use only.  Use xSemaphoreTakeMutexRecursive() or\r
1487  * xSemaphoreGiveMutexRecursive() instead of calling these functions directly.\r
1488  */\r
1489 BaseType_t xQueueTakeMutexRecursive( QueueHandle_t xMutex, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;\r
1490 BaseType_t xQueueGiveMutexRecursive( QueueHandle_t pxMutex ) PRIVILEGED_FUNCTION;\r
1491 \r
1492 /*\r
1493  * Reset a queue back to its original empty state.  The return value is now\r
1494  * obsolete and is always set to pdPASS.\r
1495  */\r
1496 #define xQueueReset( xQueue ) xQueueGenericReset( xQueue, pdFALSE )\r
1497 \r
1498 /*\r
1499  * The registry is provided as a means for kernel aware debuggers to\r
1500  * locate queues, semaphores and mutexes.  Call vQueueAddToRegistry() add\r
1501  * a queue, semaphore or mutex handle to the registry if you want the handle\r
1502  * to be available to a kernel aware debugger.  If you are not using a kernel\r
1503  * aware debugger then this function can be ignored.\r
1504  *\r
1505  * configQUEUE_REGISTRY_SIZE defines the maximum number of handles the\r
1506  * registry can hold.  configQUEUE_REGISTRY_SIZE must be greater than 0\r
1507  * within FreeRTOSConfig.h for the registry to be available.  Its value\r
1508  * does not effect the number of queues, semaphores and mutexes that can be\r
1509  * created - just the number that the registry can hold.\r
1510  *\r
1511  * @param xQueue The handle of the queue being added to the registry.  This\r
1512  * is the handle returned by a call to xQueueCreate().  Semaphore and mutex\r
1513  * handles can also be passed in here.\r
1514  *\r
1515  * @param pcName The name to be associated with the handle.  This is the\r
1516  * name that the kernel aware debugger will display.  The queue registry only\r
1517  * stores a pointer to the string - so the string must be persistent (global or\r
1518  * preferably in ROM/Flash), not on the stack.\r
1519  */\r
1520 #if configQUEUE_REGISTRY_SIZE > 0\r
1521         void vQueueAddToRegistry( QueueHandle_t xQueue, const char *pcName ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
1522 #endif\r
1523 \r
1524 /*\r
1525  * The registry is provided as a means for kernel aware debuggers to\r
1526  * locate queues, semaphores and mutexes.  Call vQueueAddToRegistry() add\r
1527  * a queue, semaphore or mutex handle to the registry if you want the handle\r
1528  * to be available to a kernel aware debugger, and vQueueUnregisterQueue() to\r
1529  * remove the queue, semaphore or mutex from the register.  If you are not using\r
1530  * a kernel aware debugger then this function can be ignored.\r
1531  *\r
1532  * @param xQueue The handle of the queue being removed from the registry.\r
1533  */\r
1534 #if configQUEUE_REGISTRY_SIZE > 0\r
1535         void vQueueUnregisterQueue( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;\r
1536 #endif\r
1537 \r
1538 /*\r
1539  * Generic version of the queue creation function, which is in turn called by\r
1540  * any queue, semaphore or mutex creation function or macro.\r
1541  */\r
1542 QueueHandle_t xQueueGenericCreate( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, const uint8_t ucQueueType ) PRIVILEGED_FUNCTION;\r
1543 \r
1544 /*\r
1545  * Queue sets provide a mechanism to allow a task to block (pend) on a read\r
1546  * operation from multiple queues or semaphores simultaneously.\r
1547  *\r
1548  * See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this\r
1549  * function.\r
1550  *\r
1551  * A queue set must be explicitly created using a call to xQueueCreateSet()\r
1552  * before it can be used.  Once created, standard FreeRTOS queues and semaphores\r
1553  * can be added to the set using calls to xQueueAddToSet().\r
1554  * xQueueSelectFromSet() is then used to determine which, if any, of the queues\r
1555  * or semaphores contained in the set is in a state where a queue read or\r
1556  * semaphore take operation would be successful.\r
1557  *\r
1558  * Note 1:  See the documentation on http://wwwFreeRTOS.org/RTOS-queue-sets.html\r
1559  * for reasons why queue sets are very rarely needed in practice as there are\r
1560  * simpler methods of blocking on multiple objects.\r
1561  *\r
1562  * Note 2:  Blocking on a queue set that contains a mutex will not cause the\r
1563  * mutex holder to inherit the priority of the blocked task.\r
1564  *\r
1565  * Note 3:  An additional 4 bytes of RAM is required for each space in a every\r
1566  * queue added to a queue set.  Therefore counting semaphores that have a high\r
1567  * maximum count value should not be added to a queue set.\r
1568  *\r
1569  * Note 4:  A receive (in the case of a queue) or take (in the case of a\r
1570  * semaphore) operation must not be performed on a member of a queue set unless\r
1571  * a call to xQueueSelectFromSet() has first returned a handle to that set member.\r
1572  *\r
1573  * @param uxEventQueueLength Queue sets store events that occur on\r
1574  * the queues and semaphores contained in the set.  uxEventQueueLength specifies\r
1575  * the maximum number of events that can be queued at once.  To be absolutely\r
1576  * certain that events are not lost uxEventQueueLength should be set to the\r
1577  * total sum of the length of the queues added to the set, where binary\r
1578  * semaphores and mutexes have a length of 1, and counting semaphores have a\r
1579  * length set by their maximum count value.  Examples:\r
1580  *  + If a queue set is to hold a queue of length 5, another queue of length 12,\r
1581  *    and a binary semaphore, then uxEventQueueLength should be set to\r
1582  *    (5 + 12 + 1), or 18.\r
1583  *  + If a queue set is to hold three binary semaphores then uxEventQueueLength\r
1584  *    should be set to (1 + 1 + 1 ), or 3.\r
1585  *  + If a queue set is to hold a counting semaphore that has a maximum count of\r
1586  *    5, and a counting semaphore that has a maximum count of 3, then\r
1587  *    uxEventQueueLength should be set to (5 + 3), or 8.\r
1588  *\r
1589  * @return If the queue set is created successfully then a handle to the created\r
1590  * queue set is returned.  Otherwise NULL is returned.\r
1591  */\r
1592 QueueSetHandle_t xQueueCreateSet( const UBaseType_t uxEventQueueLength ) PRIVILEGED_FUNCTION;\r
1593 \r
1594 /*\r
1595  * Adds a queue or semaphore to a queue set that was previously created by a\r
1596  * call to xQueueCreateSet().\r
1597  *\r
1598  * See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this\r
1599  * function.\r
1600  *\r
1601  * Note 1:  A receive (in the case of a queue) or take (in the case of a\r
1602  * semaphore) operation must not be performed on a member of a queue set unless\r
1603  * a call to xQueueSelectFromSet() has first returned a handle to that set member.\r
1604  *\r
1605  * @param xQueueOrSemaphore The handle of the queue or semaphore being added to\r
1606  * the queue set (cast to an QueueSetMemberHandle_t type).\r
1607  *\r
1608  * @param xQueueSet The handle of the queue set to which the queue or semaphore\r
1609  * is being added.\r
1610  *\r
1611  * @return If the queue or semaphore was successfully added to the queue set\r
1612  * then pdPASS is returned.  If the queue could not be successfully added to the\r
1613  * queue set because it is already a member of a different queue set then pdFAIL\r
1614  * is returned.\r
1615  */\r
1616 BaseType_t xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION;\r
1617 \r
1618 /*\r
1619  * Removes a queue or semaphore from a queue set.  A queue or semaphore can only\r
1620  * be removed from a set if the queue or semaphore is empty.\r
1621  *\r
1622  * See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this\r
1623  * function.\r
1624  *\r
1625  * @param xQueueOrSemaphore The handle of the queue or semaphore being removed\r
1626  * from the queue set (cast to an QueueSetMemberHandle_t type).\r
1627  *\r
1628  * @param xQueueSet The handle of the queue set in which the queue or semaphore\r
1629  * is included.\r
1630  *\r
1631  * @return If the queue or semaphore was successfully removed from the queue set\r
1632  * then pdPASS is returned.  If the queue was not in the queue set, or the\r
1633  * queue (or semaphore) was not empty, then pdFAIL is returned.\r
1634  */\r
1635 BaseType_t xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION;\r
1636 \r
1637 /*\r
1638  * xQueueSelectFromSet() selects from the members of a queue set a queue or\r
1639  * semaphore that either contains data (in the case of a queue) or is available\r
1640  * to take (in the case of a semaphore).  xQueueSelectFromSet() effectively\r
1641  * allows a task to block (pend) on a read operation on all the queues and\r
1642  * semaphores in a queue set simultaneously.\r
1643  *\r
1644  * See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this\r
1645  * function.\r
1646  *\r
1647  * Note 1:  See the documentation on http://wwwFreeRTOS.org/RTOS-queue-sets.html\r
1648  * for reasons why queue sets are very rarely needed in practice as there are\r
1649  * simpler methods of blocking on multiple objects.\r
1650  *\r
1651  * Note 2:  Blocking on a queue set that contains a mutex will not cause the\r
1652  * mutex holder to inherit the priority of the blocked task.\r
1653  *\r
1654  * Note 3:  A receive (in the case of a queue) or take (in the case of a\r
1655  * semaphore) operation must not be performed on a member of a queue set unless\r
1656  * a call to xQueueSelectFromSet() has first returned a handle to that set member.\r
1657  *\r
1658  * @param xQueueSet The queue set on which the task will (potentially) block.\r
1659  *\r
1660  * @param xTicksToWait The maximum time, in ticks, that the calling task will\r
1661  * remain in the Blocked state (with other tasks executing) to wait for a member\r
1662  * of the queue set to be ready for a successful queue read or semaphore take\r
1663  * operation.\r
1664  *\r
1665  * @return xQueueSelectFromSet() will return the handle of a queue (cast to\r
1666  * a QueueSetMemberHandle_t type) contained in the queue set that contains data,\r
1667  * or the handle of a semaphore (cast to a QueueSetMemberHandle_t type) contained\r
1668  * in the queue set that is available, or NULL if no such queue or semaphore\r
1669  * exists before before the specified block time expires.\r
1670  */\r
1671 QueueSetMemberHandle_t xQueueSelectFromSet( QueueSetHandle_t xQueueSet, const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;\r
1672 \r
1673 /*\r
1674  * A version of xQueueSelectFromSet() that can be used from an ISR.\r
1675  */\r
1676 QueueSetMemberHandle_t xQueueSelectFromSetFromISR( QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION;\r
1677 \r
1678 /* Not public API functions. */\r
1679 void vQueueWaitForMessageRestricted( QueueHandle_t xQueue, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;\r
1680 BaseType_t xQueueGenericReset( QueueHandle_t xQueue, BaseType_t xNewQueue ) PRIVILEGED_FUNCTION;\r
1681 void vQueueSetQueueNumber( QueueHandle_t xQueue, UBaseType_t uxQueueNumber ) PRIVILEGED_FUNCTION;\r
1682 UBaseType_t uxQueueGetQueueNumber( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;\r
1683 uint8_t ucQueueGetQueueType( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;\r
1684 \r
1685 \r
1686 #ifdef __cplusplus\r
1687 }\r
1688 #endif\r
1689 \r
1690 #endif /* QUEUE_H */\r
1691 \r