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