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