]> git.sur5r.net Git - freertos/blob - FreeRTOS/Source/include/queue.h
Update version number.
[freertos] / FreeRTOS / Source / include / queue.h
1 /*\r
2     FreeRTOS V7.5.1 - 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>void vQueueDelete( xQueueHandle xQueue );</pre>\r
928  *\r
929  * Delete a queue - freeing all the memory allocated for storing of items\r
930  * placed on the queue.\r
931  *\r
932  * @param xQueue A handle to the queue to be deleted.\r
933  *\r
934  * \defgroup vQueueDelete vQueueDelete\r
935  * \ingroup QueueManagement\r
936  */\r
937 void vQueueDelete( xQueueHandle xQueue ) PRIVILEGED_FUNCTION;\r
938 \r
939 /**\r
940  * queue. h\r
941  * <pre>\r
942  portBASE_TYPE xQueueSendToFrontFromISR(\r
943                                                                                  xQueueHandle xQueue,\r
944                                                                                  const void *pvItemToQueue,\r
945                                                                                  portBASE_TYPE *pxHigherPriorityTaskWoken\r
946                                                                           );\r
947  </pre>\r
948  *\r
949  * This is a macro that calls xQueueGenericSendFromISR().\r
950  *\r
951  * Post an item to the front of a queue.  It is safe to use this macro from\r
952  * within an interrupt service routine.\r
953  *\r
954  * Items are queued by copy not reference so it is preferable to only\r
955  * queue small items, especially when called from an ISR.  In most cases\r
956  * it would be preferable to store a pointer to the item being queued.\r
957  *\r
958  * @param xQueue The handle to the queue on which the item is to be posted.\r
959  *\r
960  * @param pvItemToQueue A pointer to the item that is to be placed on the\r
961  * queue.  The size of the items the queue will hold was defined when the\r
962  * queue was created, so this many bytes will be copied from pvItemToQueue\r
963  * into the queue storage area.\r
964  *\r
965  * @param pxHigherPriorityTaskWoken xQueueSendToFrontFromISR() will set\r
966  * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task\r
967  * to unblock, and the unblocked task has a priority higher than the currently\r
968  * running task.  If xQueueSendToFromFromISR() sets this value to pdTRUE then\r
969  * a context switch should be requested before the interrupt is exited.\r
970  *\r
971  * @return pdTRUE if the data was successfully sent to the queue, otherwise\r
972  * errQUEUE_FULL.\r
973  *\r
974  * Example usage for buffered IO (where the ISR can obtain more than one value\r
975  * per call):\r
976    <pre>\r
977  void vBufferISR( void )\r
978  {\r
979  char cIn;\r
980  portBASE_TYPE xHigherPrioritTaskWoken;\r
981 \r
982         // We have not woken a task at the start of the ISR.\r
983         xHigherPriorityTaskWoken = pdFALSE;\r
984 \r
985         // Loop until the buffer is empty.\r
986         do\r
987         {\r
988                 // Obtain a byte from the buffer.\r
989                 cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );\r
990 \r
991                 // Post the byte.\r
992                 xQueueSendToFrontFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );\r
993 \r
994         } while( portINPUT_BYTE( BUFFER_COUNT ) );\r
995 \r
996         // Now the buffer is empty we can switch context if necessary.\r
997         if( xHigherPriorityTaskWoken )\r
998         {\r
999                 taskYIELD ();\r
1000         }\r
1001  }\r
1002  </pre>\r
1003  *\r
1004  * \defgroup xQueueSendFromISR xQueueSendFromISR\r
1005  * \ingroup QueueManagement\r
1006  */\r
1007 #define xQueueSendToFrontFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_FRONT )\r
1008 \r
1009 \r
1010 /**\r
1011  * queue. h\r
1012  * <pre>\r
1013  portBASE_TYPE xQueueSendToBackFromISR(\r
1014                                                                                  xQueueHandle xQueue,\r
1015                                                                                  const void *pvItemToQueue,\r
1016                                                                                  portBASE_TYPE *pxHigherPriorityTaskWoken\r
1017                                                                           );\r
1018  </pre>\r
1019  *\r
1020  * This is a macro that calls xQueueGenericSendFromISR().\r
1021  *\r
1022  * Post an item to the back of a queue.  It is safe to use this macro from\r
1023  * within an interrupt service routine.\r
1024  *\r
1025  * Items are queued by copy not reference so it is preferable to only\r
1026  * queue small items, especially when called from an ISR.  In most cases\r
1027  * it would be preferable to store a pointer to the item being queued.\r
1028  *\r
1029  * @param xQueue The handle to the queue on which the item is to be posted.\r
1030  *\r
1031  * @param pvItemToQueue A pointer to the item that is to be placed on the\r
1032  * queue.  The size of the items the queue will hold was defined when the\r
1033  * queue was created, so this many bytes will be copied from pvItemToQueue\r
1034  * into the queue storage area.\r
1035  *\r
1036  * @param pxHigherPriorityTaskWoken xQueueSendToBackFromISR() will set\r
1037  * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task\r
1038  * to unblock, and the unblocked task has a priority higher than the currently\r
1039  * running task.  If xQueueSendToBackFromISR() sets this value to pdTRUE then\r
1040  * a context switch should be requested before the interrupt is exited.\r
1041  *\r
1042  * @return pdTRUE if the data was successfully sent to the queue, otherwise\r
1043  * errQUEUE_FULL.\r
1044  *\r
1045  * Example usage for buffered IO (where the ISR can obtain more than one value\r
1046  * per call):\r
1047    <pre>\r
1048  void vBufferISR( void )\r
1049  {\r
1050  char cIn;\r
1051  portBASE_TYPE xHigherPriorityTaskWoken;\r
1052 \r
1053         // We have not woken a task at the start of the ISR.\r
1054         xHigherPriorityTaskWoken = pdFALSE;\r
1055 \r
1056         // Loop until the buffer is empty.\r
1057         do\r
1058         {\r
1059                 // Obtain a byte from the buffer.\r
1060                 cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );\r
1061 \r
1062                 // Post the byte.\r
1063                 xQueueSendToBackFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );\r
1064 \r
1065         } while( portINPUT_BYTE( BUFFER_COUNT ) );\r
1066 \r
1067         // Now the buffer is empty we can switch context if necessary.\r
1068         if( xHigherPriorityTaskWoken )\r
1069         {\r
1070                 taskYIELD ();\r
1071         }\r
1072  }\r
1073  </pre>\r
1074  *\r
1075  * \defgroup xQueueSendFromISR xQueueSendFromISR\r
1076  * \ingroup QueueManagement\r
1077  */\r
1078 #define xQueueSendToBackFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK )\r
1079 \r
1080 /**\r
1081  * queue. h\r
1082  * <pre>\r
1083  portBASE_TYPE xQueueOverwriteFromISR(\r
1084                                                           xQueueHandle xQueue,\r
1085                                                           const void * pvItemToQueue,\r
1086                                                           portBASE_TYPE *pxHigherPriorityTaskWoken\r
1087                                                  );\r
1088  * </pre>\r
1089  *\r
1090  * A version of xQueueOverwrite() that can be used in an interrupt service\r
1091  * routine (ISR).\r
1092  *\r
1093  * Only for use with queues that can hold a single item - so the queue is either\r
1094  * empty or full.\r
1095  *\r
1096  * Post an item on a queue.  If the queue is already full then overwrite the\r
1097  * value held in the queue.  The item is queued by copy, not by reference.\r
1098  *\r
1099  * @param xQueue The handle to the queue on which the item is to be posted.\r
1100  *\r
1101  * @param pvItemToQueue A pointer to the item that is to be placed on the\r
1102  * queue.  The size of the items the queue will hold was defined when the\r
1103  * queue was created, so this many bytes will be copied from pvItemToQueue\r
1104  * into the queue storage area.\r
1105  *\r
1106  * @param pxHigherPriorityTaskWoken xQueueOverwriteFromISR() will set\r
1107  * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task\r
1108  * to unblock, and the unblocked task has a priority higher than the currently\r
1109  * running task.  If xQueueOverwriteFromISR() sets this value to pdTRUE then\r
1110  * a context switch should be requested before the interrupt is exited.\r
1111  *\r
1112  * @return xQueueOverwriteFromISR() is a macro that calls\r
1113  * xQueueGenericSendFromISR(), and therefore has the same return values as\r
1114  * xQueueSendToFrontFromISR().  However, pdPASS is the only value that can be\r
1115  * returned because xQueueOverwriteFromISR() will write to the queue even when\r
1116  * the queue is already full.\r
1117  *\r
1118  * Example usage:\r
1119    <pre>\r
1120 \r
1121  xQueueHandle xQueue;\r
1122  \r
1123  void vFunction( void *pvParameters )\r
1124  {\r
1125         // Create a queue to hold one unsigned long value.  It is strongly\r
1126         // recommended *not* to use xQueueOverwriteFromISR() on queues that can\r
1127         // contain more than one value, and doing so will trigger an assertion\r
1128         // if configASSERT() is defined.\r
1129         xQueue = xQueueCreate( 1, sizeof( unsigned long ) );\r
1130 }\r
1131 \r
1132 void vAnInterruptHandler( void )\r
1133 {\r
1134 // xHigherPriorityTaskWoken must be set to pdFALSE before it is used.\r
1135 portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;\r
1136 unsigned long ulVarToSend, ulValReceived;\r
1137 \r
1138         // Write the value 10 to the queue using xQueueOverwriteFromISR().\r
1139         ulVarToSend = 10;\r
1140         xQueueOverwriteFromISR( xQueue, &ulVarToSend, &xHigherPriorityTaskWoken );\r
1141 \r
1142         // The queue is full, but calling xQueueOverwriteFromISR() again will still\r
1143         // pass because the value held in the queue will be overwritten with the\r
1144         // new value.\r
1145         ulVarToSend = 100;\r
1146         xQueueOverwriteFromISR( xQueue, &ulVarToSend, &xHigherPriorityTaskWoken );\r
1147 \r
1148         // Reading from the queue will now return 100.\r
1149 \r
1150         // ...\r
1151         \r
1152         if( xHigherPrioritytaskWoken == pdTRUE )\r
1153         {\r
1154                 // Writing to the queue caused a task to unblock and the unblocked task\r
1155                 // has a priority higher than or equal to the priority of the currently\r
1156                 // executing task (the task this interrupt interrupted).  Perform a context\r
1157                 // switch so this interrupt returns directly to the unblocked task.\r
1158                 portYIELD_FROM_ISR(); // or portEND_SWITCHING_ISR() depending on the port.\r
1159         }\r
1160 }\r
1161  </pre>\r
1162  * \defgroup xQueueOverwriteFromISR xQueueOverwriteFromISR\r
1163  * \ingroup QueueManagement\r
1164  */\r
1165 #define xQueueOverwriteFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueOVERWRITE )\r
1166 \r
1167 /**\r
1168  * queue. h\r
1169  * <pre>\r
1170  portBASE_TYPE xQueueSendFromISR(\r
1171                                                                          xQueueHandle xQueue,\r
1172                                                                          const void *pvItemToQueue,\r
1173                                                                          portBASE_TYPE *pxHigherPriorityTaskWoken\r
1174                                                                 );\r
1175  </pre>\r
1176  *\r
1177  * This is a macro that calls xQueueGenericSendFromISR().  It is included\r
1178  * for backward compatibility with versions of FreeRTOS.org that did not\r
1179  * include the xQueueSendToBackFromISR() and xQueueSendToFrontFromISR()\r
1180  * macros.\r
1181  *\r
1182  * Post an item to the back of a queue.  It is safe to use this function from\r
1183  * within an interrupt service routine.\r
1184  *\r
1185  * Items are queued by copy not reference so it is preferable to only\r
1186  * queue small items, especially when called from an ISR.  In most cases\r
1187  * it would be preferable to store a pointer to the item being queued.\r
1188  *\r
1189  * @param xQueue The handle to the queue on which the item is to be posted.\r
1190  *\r
1191  * @param pvItemToQueue A pointer to the item that is to be placed on the\r
1192  * queue.  The size of the items the queue will hold was defined when the\r
1193  * queue was created, so this many bytes will be copied from pvItemToQueue\r
1194  * into the queue storage area.\r
1195  *\r
1196  * @param pxHigherPriorityTaskWoken xQueueSendFromISR() will set\r
1197  * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task\r
1198  * to unblock, and the unblocked task has a priority higher than the currently\r
1199  * running task.  If xQueueSendFromISR() sets this value to pdTRUE then\r
1200  * a context switch should be requested before the interrupt is exited.\r
1201  *\r
1202  * @return pdTRUE if the data was successfully sent to the queue, otherwise\r
1203  * errQUEUE_FULL.\r
1204  *\r
1205  * Example usage for buffered IO (where the ISR can obtain more than one value\r
1206  * per call):\r
1207    <pre>\r
1208  void vBufferISR( void )\r
1209  {\r
1210  char cIn;\r
1211  portBASE_TYPE xHigherPriorityTaskWoken;\r
1212 \r
1213         // We have not woken a task at the start of the ISR.\r
1214         xHigherPriorityTaskWoken = pdFALSE;\r
1215 \r
1216         // Loop until the buffer is empty.\r
1217         do\r
1218         {\r
1219                 // Obtain a byte from the buffer.\r
1220                 cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );\r
1221 \r
1222                 // Post the byte.\r
1223                 xQueueSendFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );\r
1224 \r
1225         } while( portINPUT_BYTE( BUFFER_COUNT ) );\r
1226 \r
1227         // Now the buffer is empty we can switch context if necessary.\r
1228         if( xHigherPriorityTaskWoken )\r
1229         {\r
1230                 // Actual macro used here is port specific.\r
1231                 taskYIELD_FROM_ISR ();\r
1232         }\r
1233  }\r
1234  </pre>\r
1235  *\r
1236  * \defgroup xQueueSendFromISR xQueueSendFromISR\r
1237  * \ingroup QueueManagement\r
1238  */\r
1239 #define xQueueSendFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK )\r
1240 \r
1241 /**\r
1242  * queue. h\r
1243  * <pre>\r
1244  portBASE_TYPE xQueueGenericSendFromISR(\r
1245                                                                                    xQueueHandle         xQueue,\r
1246                                                                                    const        void    *pvItemToQueue,\r
1247                                                                                    portBASE_TYPE        *pxHigherPriorityTaskWoken,\r
1248                                                                                    portBASE_TYPE        xCopyPosition\r
1249                                                                            );\r
1250  </pre>\r
1251  *\r
1252  * It is preferred that the macros xQueueSendFromISR(),\r
1253  * xQueueSendToFrontFromISR() and xQueueSendToBackFromISR() be used in place\r
1254  * of calling this function directly.\r
1255  *\r
1256  * Post an item on a queue.  It is safe to use this function from within an\r
1257  * interrupt service routine.\r
1258  *\r
1259  * Items are queued by copy not reference so it is preferable to only\r
1260  * queue small items, especially when called from an ISR.  In most cases\r
1261  * it would be preferable to store a pointer to the item being queued.\r
1262  *\r
1263  * @param xQueue The handle to the queue on which the item is to be posted.\r
1264  *\r
1265  * @param pvItemToQueue A pointer to the item that is to be placed on the\r
1266  * queue.  The size of the items the queue will hold was defined when the\r
1267  * queue was created, so this many bytes will be copied from pvItemToQueue\r
1268  * into the queue storage area.\r
1269  *\r
1270  * @param pxHigherPriorityTaskWoken xQueueGenericSendFromISR() will set\r
1271  * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task\r
1272  * to unblock, and the unblocked task has a priority higher than the currently\r
1273  * running task.  If xQueueGenericSendFromISR() sets this value to pdTRUE then\r
1274  * a context switch should be requested before the interrupt is exited.\r
1275  *\r
1276  * @param xCopyPosition Can take the value queueSEND_TO_BACK to place the\r
1277  * item at the back of the queue, or queueSEND_TO_FRONT to place the item\r
1278  * at the front of the queue (for high priority messages).\r
1279  *\r
1280  * @return pdTRUE if the data was successfully sent to the queue, otherwise\r
1281  * errQUEUE_FULL.\r
1282  *\r
1283  * Example usage for buffered IO (where the ISR can obtain more than one value\r
1284  * per call):\r
1285    <pre>\r
1286  void vBufferISR( void )\r
1287  {\r
1288  char cIn;\r
1289  portBASE_TYPE xHigherPriorityTaskWokenByPost;\r
1290 \r
1291         // We have not woken a task at the start of the ISR.\r
1292         xHigherPriorityTaskWokenByPost = pdFALSE;\r
1293 \r
1294         // Loop until the buffer is empty.\r
1295         do\r
1296         {\r
1297                 // Obtain a byte from the buffer.\r
1298                 cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );\r
1299 \r
1300                 // Post each byte.\r
1301                 xQueueGenericSendFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWokenByPost, queueSEND_TO_BACK );\r
1302 \r
1303         } while( portINPUT_BYTE( BUFFER_COUNT ) );\r
1304 \r
1305         // Now the buffer is empty we can switch context if necessary.  Note that the\r
1306         // name of the yield function required is port specific.\r
1307         if( xHigherPriorityTaskWokenByPost )\r
1308         {\r
1309                 taskYIELD_YIELD_FROM_ISR();\r
1310         }\r
1311  }\r
1312  </pre>\r
1313  *\r
1314  * \defgroup xQueueSendFromISR xQueueSendFromISR\r
1315  * \ingroup QueueManagement\r
1316  */\r
1317 signed portBASE_TYPE xQueueGenericSendFromISR( xQueueHandle xQueue, const void * const pvItemToQueue, signed portBASE_TYPE *pxHigherPriorityTaskWoken, portBASE_TYPE xCopyPosition ) PRIVILEGED_FUNCTION;\r
1318 \r
1319 /**\r
1320  * queue. h\r
1321  * <pre>\r
1322  portBASE_TYPE xQueueReceiveFromISR(\r
1323                                                                            xQueueHandle xQueue,\r
1324                                                                            void *pvBuffer,\r
1325                                                                            portBASE_TYPE *pxTaskWoken\r
1326                                                                    );\r
1327  * </pre>\r
1328  *\r
1329  * Receive an item from a queue.  It is safe to use this function from within an\r
1330  * interrupt service routine.\r
1331  *\r
1332  * @param xQueue The handle to the queue from which the item is to be\r
1333  * received.\r
1334  *\r
1335  * @param pvBuffer Pointer to the buffer into which the received item will\r
1336  * be copied.\r
1337  *\r
1338  * @param pxTaskWoken A task may be blocked waiting for space to become\r
1339  * available on the queue.  If xQueueReceiveFromISR causes such a task to\r
1340  * unblock *pxTaskWoken will get set to pdTRUE, otherwise *pxTaskWoken will\r
1341  * remain unchanged.\r
1342  *\r
1343  * @return pdTRUE if an item was successfully received from the queue,\r
1344  * otherwise pdFALSE.\r
1345  *\r
1346  * Example usage:\r
1347    <pre>\r
1348 \r
1349  xQueueHandle xQueue;\r
1350 \r
1351  // Function to create a queue and post some values.\r
1352  void vAFunction( void *pvParameters )\r
1353  {\r
1354  char cValueToPost;\r
1355  const portTickType xBlockTime = ( portTickType )0xff;\r
1356 \r
1357         // Create a queue capable of containing 10 characters.\r
1358         xQueue = xQueueCreate( 10, sizeof( char ) );\r
1359         if( xQueue == 0 )\r
1360         {\r
1361                 // Failed to create the queue.\r
1362         }\r
1363 \r
1364         // ...\r
1365 \r
1366         // Post some characters that will be used within an ISR.  If the queue\r
1367         // is full then this task will block for xBlockTime ticks.\r
1368         cValueToPost = 'a';\r
1369         xQueueSend( xQueue, ( void * ) &cValueToPost, xBlockTime );\r
1370         cValueToPost = 'b';\r
1371         xQueueSend( xQueue, ( void * ) &cValueToPost, xBlockTime );\r
1372 \r
1373         // ... keep posting characters ... this task may block when the queue\r
1374         // becomes full.\r
1375 \r
1376         cValueToPost = 'c';\r
1377         xQueueSend( xQueue, ( void * ) &cValueToPost, xBlockTime );\r
1378  }\r
1379 \r
1380  // ISR that outputs all the characters received on the queue.\r
1381  void vISR_Routine( void )\r
1382  {\r
1383  portBASE_TYPE xTaskWokenByReceive = pdFALSE;\r
1384  char cRxedChar;\r
1385 \r
1386         while( xQueueReceiveFromISR( xQueue, ( void * ) &cRxedChar, &xTaskWokenByReceive) )\r
1387         {\r
1388                 // A character was received.  Output the character now.\r
1389                 vOutputCharacter( cRxedChar );\r
1390 \r
1391                 // If removing the character from the queue woke the task that was\r
1392                 // posting onto the queue cTaskWokenByReceive will have been set to\r
1393                 // pdTRUE.  No matter how many times this loop iterates only one\r
1394                 // task will be woken.\r
1395         }\r
1396 \r
1397         if( cTaskWokenByPost != ( char ) pdFALSE;\r
1398         {\r
1399                 taskYIELD ();\r
1400         }\r
1401  }\r
1402  </pre>\r
1403  * \defgroup xQueueReceiveFromISR xQueueReceiveFromISR\r
1404  * \ingroup QueueManagement\r
1405  */\r
1406 signed portBASE_TYPE xQueueReceiveFromISR( xQueueHandle xQueue, const void * const pvBuffer, signed portBASE_TYPE *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;\r
1407 \r
1408 /*\r
1409  * Utilities to query queues that are safe to use from an ISR.  These utilities\r
1410  * should be used only from witin an ISR, or within a critical section.\r
1411  */\r
1412 signed portBASE_TYPE xQueueIsQueueEmptyFromISR( const xQueueHandle xQueue ) PRIVILEGED_FUNCTION;\r
1413 signed portBASE_TYPE xQueueIsQueueFullFromISR( const xQueueHandle xQueue ) PRIVILEGED_FUNCTION;\r
1414 unsigned portBASE_TYPE uxQueueMessagesWaitingFromISR( const xQueueHandle xQueue ) PRIVILEGED_FUNCTION;\r
1415 \r
1416 \r
1417 /*\r
1418  * xQueueAltGenericSend() is an alternative version of xQueueGenericSend().\r
1419  * Likewise xQueueAltGenericReceive() is an alternative version of\r
1420  * xQueueGenericReceive().\r
1421  *\r
1422  * The source code that implements the alternative (Alt) API is much\r
1423  * simpler      because it executes everything from within a critical section.\r
1424  * This is      the approach taken by many other RTOSes, but FreeRTOS.org has the\r
1425  * preferred fully featured API too.  The fully featured API has more\r
1426  * complex      code that takes longer to execute, but makes much less use of\r
1427  * critical sections.  Therefore the alternative API sacrifices interrupt\r
1428  * responsiveness to gain execution speed, whereas the fully featured API\r
1429  * sacrifices execution speed to ensure better interrupt responsiveness.\r
1430  */\r
1431 signed portBASE_TYPE xQueueAltGenericSend( xQueueHandle xQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition );\r
1432 signed portBASE_TYPE xQueueAltGenericReceive( xQueueHandle xQueue, void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking );\r
1433 #define xQueueAltSendToFront( xQueue, pvItemToQueue, xTicksToWait ) xQueueAltGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_FRONT )\r
1434 #define xQueueAltSendToBack( xQueue, pvItemToQueue, xTicksToWait ) xQueueAltGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK )\r
1435 #define xQueueAltReceive( xQueue, pvBuffer, xTicksToWait ) xQueueAltGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdFALSE )\r
1436 #define xQueueAltPeek( xQueue, pvBuffer, xTicksToWait ) xQueueAltGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdTRUE )\r
1437 \r
1438 /*\r
1439  * The functions defined above are for passing data to and from tasks.  The\r
1440  * functions below are the equivalents for passing data to and from\r
1441  * co-routines.\r
1442  *\r
1443  * These functions are called from the co-routine macro implementation and\r
1444  * should not be called directly from application code.  Instead use the macro\r
1445  * wrappers defined within croutine.h.\r
1446  */\r
1447 signed portBASE_TYPE xQueueCRSendFromISR( xQueueHandle xQueue, const void *pvItemToQueue, signed portBASE_TYPE xCoRoutinePreviouslyWoken );\r
1448 signed portBASE_TYPE xQueueCRReceiveFromISR( xQueueHandle xQueue, void *pvBuffer, signed portBASE_TYPE *pxTaskWoken );\r
1449 signed portBASE_TYPE xQueueCRSend( xQueueHandle xQueue, const void *pvItemToQueue, portTickType xTicksToWait );\r
1450 signed portBASE_TYPE xQueueCRReceive( xQueueHandle xQueue, void *pvBuffer, portTickType xTicksToWait );\r
1451 \r
1452 /*\r
1453  * For internal use only.  Use xSemaphoreCreateMutex(),\r
1454  * xSemaphoreCreateCounting() or xSemaphoreGetMutexHolder() instead of calling\r
1455  * these functions directly.\r
1456  */\r
1457 xQueueHandle xQueueCreateMutex( unsigned char ucQueueType ) PRIVILEGED_FUNCTION;\r
1458 xQueueHandle xQueueCreateCountingSemaphore( unsigned portBASE_TYPE uxCountValue, unsigned portBASE_TYPE uxInitialCount ) PRIVILEGED_FUNCTION;\r
1459 void* xQueueGetMutexHolder( xQueueHandle xSemaphore ) PRIVILEGED_FUNCTION;\r
1460 \r
1461 /*\r
1462  * For internal use only.  Use xSemaphoreTakeMutexRecursive() or\r
1463  * xSemaphoreGiveMutexRecursive() instead of calling these functions directly.\r
1464  */\r
1465 portBASE_TYPE xQueueTakeMutexRecursive( xQueueHandle xMutex, portTickType xBlockTime ) PRIVILEGED_FUNCTION;\r
1466 portBASE_TYPE xQueueGiveMutexRecursive( xQueueHandle pxMutex ) PRIVILEGED_FUNCTION;\r
1467 \r
1468 /*\r
1469  * Reset a queue back to its original empty state.  pdPASS is returned if the\r
1470  * queue is successfully reset.  pdFAIL is returned if the queue could not be\r
1471  * reset because there are tasks blocked on the queue waiting to either\r
1472  * receive from the queue or send to the queue.\r
1473  */\r
1474 #define xQueueReset( xQueue ) xQueueGenericReset( xQueue, pdFALSE )\r
1475 \r
1476 /*\r
1477  * The registry is provided as a means for kernel aware debuggers to\r
1478  * locate queues, semaphores and mutexes.  Call vQueueAddToRegistry() add\r
1479  * a queue, semaphore or mutex handle to the registry if you want the handle\r
1480  * to be available to a kernel aware debugger.  If you are not using a kernel\r
1481  * aware debugger then this function can be ignored.\r
1482  *\r
1483  * configQUEUE_REGISTRY_SIZE defines the maximum number of handles the\r
1484  * registry can hold.  configQUEUE_REGISTRY_SIZE must be greater than 0\r
1485  * within FreeRTOSConfig.h for the registry to be available.  Its value\r
1486  * does not effect the number of queues, semaphores and mutexes that can be\r
1487  * created - just the number that the registry can hold.\r
1488  *\r
1489  * @param xQueue The handle of the queue being added to the registry.  This\r
1490  * is the handle returned by a call to xQueueCreate().  Semaphore and mutex\r
1491  * handles can also be passed in here.\r
1492  *\r
1493  * @param pcName The name to be associated with the handle.  This is the\r
1494  * name that the kernel aware debugger will display.\r
1495  */\r
1496 #if configQUEUE_REGISTRY_SIZE > 0\r
1497         void vQueueAddToRegistry( xQueueHandle xQueue, signed char *pcName ) PRIVILEGED_FUNCTION;\r
1498 #endif\r
1499 \r
1500 /*\r
1501  * The registry is provided as a means for kernel aware debuggers to\r
1502  * locate queues, semaphores and mutexes.  Call vQueueAddToRegistry() add\r
1503  * a queue, semaphore or mutex handle to the registry if you want the handle\r
1504  * to be available to a kernel aware debugger, and vQueueUnregisterQueue() to\r
1505  * remove the queue, semaphore or mutex from the register.  If you are not using\r
1506  * a kernel aware debugger then this function can be ignored.\r
1507  *\r
1508  * @param xQueue The handle of the queue being removed from the registry.\r
1509  */\r
1510 #if configQUEUE_REGISTRY_SIZE > 0\r
1511         void vQueueUnregisterQueue( xQueueHandle xQueue ) PRIVILEGED_FUNCTION;\r
1512 #endif\r
1513 \r
1514 /*\r
1515  * Generic version of the queue creation function, which is in turn called by\r
1516  * any queue, semaphore or mutex creation function or macro.\r
1517  */\r
1518 xQueueHandle xQueueGenericCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBASE_TYPE uxItemSize, unsigned char ucQueueType ) PRIVILEGED_FUNCTION;\r
1519 \r
1520 /*\r
1521  * Queue sets provide a mechanism to allow a task to block (pend) on a read\r
1522  * operation from multiple queues or semaphores simultaneously.\r
1523  *\r
1524  * See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this\r
1525  * function.\r
1526  *\r
1527  * A queue set must be explicitly created using a call to xQueueCreateSet()\r
1528  * before it can be used.  Once created, standard FreeRTOS queues and semaphores\r
1529  * can be added to the set using calls to xQueueAddToSet().\r
1530  * xQueueSelectFromSet() is then used to determine which, if any, of the queues\r
1531  * or semaphores contained in the set is in a state where a queue read or\r
1532  * semaphore take operation would be successful.\r
1533  *\r
1534  * Note 1:  See the documentation on http://wwwFreeRTOS.org/RTOS-queue-sets.html\r
1535  * for reasons why queue sets are very rarely needed in practice as there are\r
1536  * simpler methods of blocking on multiple objects.\r
1537  *\r
1538  * Note 2:  Blocking on a queue set that contains a mutex will not cause the\r
1539  * mutex holder to inherit the priority of the blocked task.\r
1540  *\r
1541  * Note 3:  An additional 4 bytes of RAM is required for each space in a every\r
1542  * queue added to a queue set.  Therefore counting semaphores that have a high\r
1543  * maximum count value should not be added to a queue set.\r
1544  *\r
1545  * Note 4:  A receive (in the case of a queue) or take (in the case of a\r
1546  * semaphore) operation must not be performed on a member of a queue set unless\r
1547  * a call to xQueueSelectFromSet() has first returned a handle to that set member.\r
1548  *\r
1549  * @param uxEventQueueLength Queue sets store events that occur on\r
1550  * the queues and semaphores contained in the set.  uxEventQueueLength specifies\r
1551  * the maximum number of events that can be queued at once.  To be absolutely\r
1552  * certain that events are not lost uxEventQueueLength should be set to the\r
1553  * total sum of the length of the queues added to the set, where binary\r
1554  * semaphores and mutexes have a length of 1, and counting semaphores have a\r
1555  * length set by their maximum count value.  Examples:\r
1556  *  + If a queue set is to hold a queue of length 5, another queue of length 12,\r
1557  *    and a binary semaphore, then uxEventQueueLength should be set to\r
1558  *    (5 + 12 + 1), or 18.\r
1559  *  + If a queue set is to hold three binary semaphores then uxEventQueueLength\r
1560  *    should be set to (1 + 1 + 1 ), or 3.\r
1561  *  + If a queue set is to hold a counting semaphore that has a maximum count of\r
1562  *    5, and a counting semaphore that has a maximum count of 3, then\r
1563  *    uxEventQueueLength should be set to (5 + 3), or 8.\r
1564  *\r
1565  * @return If the queue set is created successfully then a handle to the created\r
1566  * queue set is returned.  Otherwise NULL is returned.\r
1567  */\r
1568 xQueueSetHandle xQueueCreateSet( unsigned portBASE_TYPE uxEventQueueLength ) PRIVILEGED_FUNCTION;\r
1569 \r
1570 /*\r
1571  * Adds a queue or semaphore to a queue set that was previously created by a\r
1572  * call to xQueueCreateSet().\r
1573  *\r
1574  * See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this\r
1575  * function.\r
1576  *\r
1577  * Note 1:  A receive (in the case of a queue) or take (in the case of a\r
1578  * semaphore) operation must not be performed on a member of a queue set unless\r
1579  * a call to xQueueSelectFromSet() has first returned a handle to that set member.\r
1580  *\r
1581  * @param xQueueOrSemaphore The handle of the queue or semaphore being added to\r
1582  * the queue set (cast to an xQueueSetMemberHandle type).\r
1583  *\r
1584  * @param xQueueSet The handle of the queue set to which the queue or semaphore\r
1585  * is being added.\r
1586  *\r
1587  * @return If the queue or semaphore was successfully added to the queue set\r
1588  * then pdPASS is returned.  If the queue could not be successfully added to the\r
1589  * queue set because it is already a member of a different queue set then pdFAIL\r
1590  * is returned.\r
1591  */\r
1592 portBASE_TYPE xQueueAddToSet( xQueueSetMemberHandle xQueueOrSemaphore, xQueueSetHandle xQueueSet ) PRIVILEGED_FUNCTION;\r
1593 \r
1594 /*\r
1595  * Removes a queue or semaphore from a queue set.  A queue or semaphore can only\r
1596  * be removed from a set if the queue or semaphore is empty.\r
1597  *\r
1598  * See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this\r
1599  * function.\r
1600  *\r
1601  * @param xQueueOrSemaphore The handle of the queue or semaphore being removed\r
1602  * from the queue set (cast to an xQueueSetMemberHandle type).\r
1603  *\r
1604  * @param xQueueSet The handle of the queue set in which the queue or semaphore\r
1605  * is included.\r
1606  *\r
1607  * @return If the queue or semaphore was successfully removed from the queue set\r
1608  * then pdPASS is returned.  If the queue was not in the queue set, or the\r
1609  * queue (or semaphore) was not empty, then pdFAIL is returned.\r
1610  */\r
1611 portBASE_TYPE xQueueRemoveFromSet( xQueueSetMemberHandle xQueueOrSemaphore, xQueueSetHandle xQueueSet ) PRIVILEGED_FUNCTION;\r
1612 \r
1613 /*\r
1614  * xQueueSelectFromSet() selects from the members of a queue set a queue or\r
1615  * semaphore that either contains data (in the case of a queue) or is available\r
1616  * to take (in the case of a semaphore).  xQueueSelectFromSet() effectively\r
1617  * allows a task to block (pend) on a read operation on all the queues and\r
1618  * semaphores in a queue set simultaneously.\r
1619  *\r
1620  * See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this\r
1621  * function.\r
1622  *\r
1623  * Note 1:  See the documentation on http://wwwFreeRTOS.org/RTOS-queue-sets.html\r
1624  * for reasons why queue sets are very rarely needed in practice as there are\r
1625  * simpler methods of blocking on multiple objects.\r
1626  *\r
1627  * Note 2:  Blocking on a queue set that contains a mutex will not cause the\r
1628  * mutex holder to inherit the priority of the blocked task.\r
1629  *\r
1630  * Note 3:  A receive (in the case of a queue) or take (in the case of a\r
1631  * semaphore) operation must not be performed on a member of a queue set unless\r
1632  * a call to xQueueSelectFromSet() has first returned a handle to that set member.\r
1633  *\r
1634  * @param xQueueSet The queue set on which the task will (potentially) block.\r
1635  *\r
1636  * @param xBlockTimeTicks The maximum time, in ticks, that the calling task will\r
1637  * remain in the Blocked state (with other tasks executing) to wait for a member\r
1638  * of the queue set to be ready for a successful queue read or semaphore take\r
1639  * operation.\r
1640  *\r
1641  * @return xQueueSelectFromSet() will return the handle of a queue (cast to\r
1642  * a xQueueSetMemberHandle type) contained in the queue set that contains data,\r
1643  * or the handle of a semaphore (cast to a xQueueSetMemberHandle type) contained\r
1644  * in the queue set that is available, or NULL if no such queue or semaphore\r
1645  * exists before before the specified block time expires.\r
1646  */\r
1647 xQueueSetMemberHandle xQueueSelectFromSet( xQueueSetHandle xQueueSet, portTickType xBlockTimeTicks ) PRIVILEGED_FUNCTION;\r
1648 \r
1649 /*\r
1650  * A version of xQueueSelectFromSet() that can be used from an ISR.\r
1651  */\r
1652 xQueueSetMemberHandle xQueueSelectFromSetFromISR( xQueueSetHandle xQueueSet ) PRIVILEGED_FUNCTION;\r
1653 \r
1654 /* Not public API functions. */\r
1655 void vQueueWaitForMessageRestricted( xQueueHandle xQueue, portTickType xTicksToWait ) PRIVILEGED_FUNCTION;\r
1656 portBASE_TYPE xQueueGenericReset( xQueueHandle xQueue, portBASE_TYPE xNewQueue ) PRIVILEGED_FUNCTION;\r
1657 void vQueueSetQueueNumber( xQueueHandle xQueue, unsigned char ucQueueNumber ) PRIVILEGED_FUNCTION;\r
1658 unsigned char ucQueueGetQueueNumber( xQueueHandle xQueue ) PRIVILEGED_FUNCTION;\r
1659 unsigned char ucQueueGetQueueType( xQueueHandle xQueue ) PRIVILEGED_FUNCTION;\r
1660 \r
1661 \r
1662 #ifdef __cplusplus\r
1663 }\r
1664 #endif\r
1665 \r
1666 #endif /* QUEUE_H */\r
1667 \r