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