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