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