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