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