]> begriffs open source - freertos/blob - Source/include/queue.h
Minor comment addition to queue.h.
[freertos] / Source / include / queue.h
1 /*\r
2     FreeRTOS V6.1.1 - Copyright (C) 2011 Real Time Engineers Ltd.\r
3 \r
4     ***************************************************************************\r
5     *                                                                         *\r
6     * If you are:                                                             *\r
7     *                                                                         *\r
8     *    + New to FreeRTOS,                                                   *\r
9     *    + Wanting to learn FreeRTOS or multitasking in general quickly       *\r
10     *    + Looking for basic training,                                        *\r
11     *    + Wanting to improve your FreeRTOS skills and productivity           *\r
12     *                                                                         *\r
13     * then take a look at the FreeRTOS books - available as PDF or paperback  *\r
14     *                                                                         *\r
15     *        "Using the FreeRTOS Real Time Kernel - a Practical Guide"        *\r
16     *                  http://www.FreeRTOS.org/Documentation                  *\r
17     *                                                                         *\r
18     * A pdf reference manual is also available.  Both are usually delivered   *\r
19     * to your inbox within 20 minutes to two hours when purchased between 8am *\r
20     * and 8pm GMT (although please allow up to 24 hours in case of            *\r
21     * exceptional circumstances).  Thank you for your support!                *\r
22     *                                                                         *\r
23     ***************************************************************************\r
24 \r
25     This file is part of the FreeRTOS distribution.\r
26 \r
27     FreeRTOS is free software; you can redistribute it and/or modify it under\r
28     the terms of the GNU General Public License (version 2) as published by the\r
29     Free Software Foundation AND MODIFIED BY the FreeRTOS exception.\r
30     ***NOTE*** The exception to the GPL is included to allow you to distribute\r
31     a combined work that includes FreeRTOS without being obliged to provide the\r
32     source code for proprietary components outside of the FreeRTOS kernel.\r
33     FreeRTOS is distributed in the hope that it will be useful, but WITHOUT\r
34     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\r
35     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for\r
36     more details. You should have received a copy of the GNU General Public \r
37     License and the FreeRTOS license exception along with FreeRTOS; if not it \r
38     can be viewed here: http://www.freertos.org/a00114.html and also obtained \r
39     by writing to Richard Barry, contact details for whom are available on the\r
40     FreeRTOS WEB site.\r
41 \r
42     1 tab == 4 spaces!\r
43 \r
44     http://www.FreeRTOS.org - Documentation, latest information, license and\r
45     contact details.\r
46 \r
47     http://www.SafeRTOS.com - A version that is certified for use in safety\r
48     critical systems.\r
49 \r
50     http://www.OpenRTOS.com - Commercial support, development, porting,\r
51     licensing and training services.\r
52 */\r
53 \r
54 #ifndef INC_FREERTOS_H\r
55         #error "#include FreeRTOS.h" must appear in source files before "#include queue.h"\r
56 #endif\r
57 \r
58 \r
59 \r
60 \r
61 #ifndef QUEUE_H\r
62 #define QUEUE_H\r
63 \r
64 #ifdef __cplusplus\r
65 extern "C" {\r
66 #endif\r
67 \r
68 \r
69 #include "mpu_wrappers.h"\r
70 \r
71 /**\r
72  * Type by which queues are referenced.  For example, a call to xQueueCreate\r
73  * returns (via a pointer parameter) an xQueueHandle variable that can then\r
74  * be used as a parameter to xQueueSend(), xQueueReceive(), etc.\r
75  */\r
76 typedef void * xQueueHandle;\r
77 \r
78 \r
79 /* For internal use only. */\r
80 #define queueSEND_TO_BACK       ( 0 )\r
81 #define queueSEND_TO_FRONT      ( 1 )\r
82 \r
83 \r
84 /**\r
85  * queue. h\r
86  * <pre>\r
87  xQueueHandle xQueueCreate(\r
88                                                           unsigned portBASE_TYPE uxQueueLength,\r
89                                                           unsigned portBASE_TYPE uxItemSize\r
90                                                   );\r
91  * </pre>\r
92  *\r
93  * Creates a new queue instance.  This allocates the storage required by the\r
94  * new queue and returns a handle for the queue.\r
95  *\r
96  * @param uxQueueLength The maximum number of items that the queue can contain.\r
97  *\r
98  * @param uxItemSize The number of bytes each item in the queue will require.\r
99  * Items are queued by copy, not by reference, so this is the number of bytes\r
100  * that will be copied for each posted item.  Each item on the queue must be\r
101  * the same size.\r
102  *\r
103  * @return If the queue is successfully create then a handle to the newly\r
104  * created queue is returned.  If the queue cannot be created then 0 is\r
105  * returned.\r
106  *\r
107  * Example usage:\r
108    <pre>\r
109  struct AMessage\r
110  {\r
111         char ucMessageID;\r
112         char ucData[ 20 ];\r
113  };\r
114 \r
115  void vATask( void *pvParameters )\r
116  {\r
117  xQueueHandle xQueue1, xQueue2;\r
118 \r
119         // Create a queue capable of containing 10 unsigned long values.\r
120         xQueue1 = xQueueCreate( 10, sizeof( unsigned long ) );\r
121         if( xQueue1 == 0 )\r
122         {\r
123                 // Queue was not created and must not be used.\r
124         }\r
125 \r
126         // Create a queue capable of containing 10 pointers to AMessage structures.\r
127         // These should be passed by pointer as they contain a lot of data.\r
128         xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );\r
129         if( xQueue2 == 0 )\r
130         {\r
131                 // Queue was not created and must not be used.\r
132         }\r
133 \r
134         // ... Rest of task code.\r
135  }\r
136  </pre>\r
137  * \defgroup xQueueCreate xQueueCreate\r
138  * \ingroup QueueManagement\r
139  */\r
140 xQueueHandle xQueueCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBASE_TYPE uxItemSize );\r
141 \r
142 /**\r
143  * queue. h\r
144  * <pre>\r
145  portBASE_TYPE xQueueSendToToFront(\r
146                                                                    xQueueHandle xQueue,\r
147                                                                    const void   *       pvItemToQueue,\r
148                                                                    portTickType xTicksToWait\r
149                                                            );\r
150  * </pre>\r
151  *\r
152  * This is a macro that calls xQueueGenericSend().\r
153  *\r
154  * Post an item to the front of a queue.  The item is queued by copy, not by\r
155  * reference.  This function must not be called from an interrupt service\r
156  * routine.  See xQueueSendFromISR () for an alternative which may be used\r
157  * in an ISR.\r
158  *\r
159  * @param xQueue The handle to the queue on which the item is to be posted.\r
160  *\r
161  * @param pvItemToQueue A pointer to the item that is to be placed on the\r
162  * queue.  The size of the items the queue will hold was defined when the\r
163  * queue was created, so this many bytes will be copied from pvItemToQueue\r
164  * into the queue storage area.\r
165  *\r
166  * @param xTicksToWait The maximum amount of time the task should block\r
167  * waiting for space to become available on the queue, should it already\r
168  * be full.  The call will return immediately if this is set to 0 and the\r
169  * queue is full.  The time is defined in tick periods so the constant\r
170  * portTICK_RATE_MS should be used to convert to real time if this is required.\r
171  *\r
172  * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL.\r
173  *\r
174  * Example usage:\r
175    <pre>\r
176  struct AMessage\r
177  {\r
178         char ucMessageID;\r
179         char ucData[ 20 ];\r
180  } xMessage;\r
181 \r
182  unsigned long ulVar = 10UL;\r
183 \r
184  void vATask( void *pvParameters )\r
185  {\r
186  xQueueHandle xQueue1, xQueue2;\r
187  struct AMessage *pxMessage;\r
188 \r
189         // Create a queue capable of containing 10 unsigned long values.\r
190         xQueue1 = xQueueCreate( 10, sizeof( unsigned long ) );\r
191 \r
192         // Create a queue capable of containing 10 pointers to AMessage structures.\r
193         // These should be passed by pointer as they contain a lot of data.\r
194         xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );\r
195 \r
196         // ...\r
197 \r
198         if( xQueue1 != 0 )\r
199         {\r
200                 // Send an unsigned long.  Wait for 10 ticks for space to become\r
201                 // available if necessary.\r
202                 if( xQueueSendToFront( xQueue1, ( void * ) &ulVar, ( portTickType ) 10 ) != pdPASS )\r
203                 {\r
204                         // Failed to post the message, even after 10 ticks.\r
205                 }\r
206         }\r
207 \r
208         if( xQueue2 != 0 )\r
209         {\r
210                 // Send a pointer to a struct AMessage object.  Don't block if the\r
211                 // queue is already full.\r
212                 pxMessage = & xMessage;\r
213                 xQueueSendToFront( xQueue2, ( void * ) &pxMessage, ( portTickType ) 0 );\r
214         }\r
215 \r
216         // ... Rest of task code.\r
217  }\r
218  </pre>\r
219  * \defgroup xQueueSend xQueueSend\r
220  * \ingroup QueueManagement\r
221  */\r
222 #define xQueueSendToFront( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( xQueue, pvItemToQueue, xTicksToWait, queueSEND_TO_FRONT )\r
223 \r
224 /**\r
225  * queue. h\r
226  * <pre>\r
227  portBASE_TYPE xQueueSendToBack(\r
228                                                                    xQueueHandle xQueue,\r
229                                                                    const        void    *       pvItemToQueue,\r
230                                                                    portTickType xTicksToWait\r
231                                                            );\r
232  * </pre>\r
233  *\r
234  * This is a macro that calls xQueueGenericSend().\r
235  *\r
236  * Post an item to the back of a queue.  The item is queued by copy, not by\r
237  * reference.  This function must not be called from an interrupt service\r
238  * routine.  See xQueueSendFromISR () for an alternative which may be used\r
239  * in an ISR.\r
240  *\r
241  * @param xQueue The handle to the queue on which the item is to be posted.\r
242  *\r
243  * @param pvItemToQueue A pointer to the item that is to be placed on the\r
244  * queue.  The size of the items the queue will hold was defined when the\r
245  * queue was created, so this many bytes will be copied from pvItemToQueue\r
246  * into the queue storage area.\r
247  *\r
248  * @param xTicksToWait The maximum amount of time the task should block\r
249  * waiting for space to become available on the queue, should it already\r
250  * be full.  The call will return immediately if this is set to 0 and the queue\r
251  * is full.  The  time is defined in tick periods so the constant\r
252  * portTICK_RATE_MS should be used to convert to real time if this is required.\r
253  *\r
254  * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL.\r
255  *\r
256  * Example usage:\r
257    <pre>\r
258  struct AMessage\r
259  {\r
260         char ucMessageID;\r
261         char ucData[ 20 ];\r
262  } xMessage;\r
263 \r
264  unsigned long ulVar = 10UL;\r
265 \r
266  void vATask( void *pvParameters )\r
267  {\r
268  xQueueHandle xQueue1, xQueue2;\r
269  struct AMessage *pxMessage;\r
270 \r
271         // Create a queue capable of containing 10 unsigned long values.\r
272         xQueue1 = xQueueCreate( 10, sizeof( unsigned long ) );\r
273 \r
274         // Create a queue capable of containing 10 pointers to AMessage structures.\r
275         // These should be passed by pointer as they contain a lot of data.\r
276         xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );\r
277 \r
278         // ...\r
279 \r
280         if( xQueue1 != 0 )\r
281         {\r
282                 // Send an unsigned long.  Wait for 10 ticks for space to become\r
283                 // available if necessary.\r
284                 if( xQueueSendToBack( xQueue1, ( void * ) &ulVar, ( portTickType ) 10 ) != pdPASS )\r
285                 {\r
286                         // Failed to post the message, even after 10 ticks.\r
287                 }\r
288         }\r
289 \r
290         if( xQueue2 != 0 )\r
291         {\r
292                 // Send a pointer to a struct AMessage object.  Don't block if the\r
293                 // queue is already full.\r
294                 pxMessage = & xMessage;\r
295                 xQueueSendToBack( xQueue2, ( void * ) &pxMessage, ( portTickType ) 0 );\r
296         }\r
297 \r
298         // ... Rest of task code.\r
299  }\r
300  </pre>\r
301  * \defgroup xQueueSend xQueueSend\r
302  * \ingroup QueueManagement\r
303  */\r
304 #define xQueueSendToBack( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( xQueue, pvItemToQueue, xTicksToWait, queueSEND_TO_BACK )\r
305 \r
306 /**\r
307  * queue. h\r
308  * <pre>\r
309  portBASE_TYPE xQueueSend(\r
310                                                           xQueueHandle xQueue,\r
311                                                           const void * pvItemToQueue,\r
312                                                           portTickType xTicksToWait\r
313                                                  );\r
314  * </pre>\r
315  *\r
316  * This is a macro that calls xQueueGenericSend().  It is included for\r
317  * backward compatibility with versions of FreeRTOS.org that did not\r
318  * include the xQueueSendToFront() and xQueueSendToBack() macros.  It is\r
319  * equivalent to xQueueSendToBack().\r
320  *\r
321  * Post an item on a queue.  The item is queued by copy, not by reference.\r
322  * This function must not be called from an interrupt service routine.\r
323  * See xQueueSendFromISR () for an alternative which may be used in an ISR.\r
324  *\r
325  * @param xQueue The handle to the queue on which the item is to be posted.\r
326  *\r
327  * @param pvItemToQueue A pointer to the item that is to be placed on the\r
328  * queue.  The size of the items the queue will hold was defined when the\r
329  * queue was created, so this many bytes will be copied from pvItemToQueue\r
330  * into the queue storage area.\r
331  *\r
332  * @param xTicksToWait The maximum amount of time the task should block\r
333  * waiting for space to become available on the queue, should it already\r
334  * be full.  The call will return immediately if this is set to 0 and the\r
335  * queue is full.  The time is defined in tick periods so the constant\r
336  * portTICK_RATE_MS should be used to convert to real time if this is required.\r
337  *\r
338  * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL.\r
339  *\r
340  * Example usage:\r
341    <pre>\r
342  struct AMessage\r
343  {\r
344         char ucMessageID;\r
345         char ucData[ 20 ];\r
346  } xMessage;\r
347 \r
348  unsigned long ulVar = 10UL;\r
349 \r
350  void vATask( void *pvParameters )\r
351  {\r
352  xQueueHandle xQueue1, xQueue2;\r
353  struct AMessage *pxMessage;\r
354 \r
355         // Create a queue capable of containing 10 unsigned long values.\r
356         xQueue1 = xQueueCreate( 10, sizeof( unsigned long ) );\r
357 \r
358         // Create a queue capable of containing 10 pointers to AMessage structures.\r
359         // These should be passed by pointer as they contain a lot of data.\r
360         xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );\r
361 \r
362         // ...\r
363 \r
364         if( xQueue1 != 0 )\r
365         {\r
366                 // Send an unsigned long.  Wait for 10 ticks for space to become\r
367                 // available if necessary.\r
368                 if( xQueueSend( xQueue1, ( void * ) &ulVar, ( portTickType ) 10 ) != pdPASS )\r
369                 {\r
370                         // Failed to post the message, even after 10 ticks.\r
371                 }\r
372         }\r
373 \r
374         if( xQueue2 != 0 )\r
375         {\r
376                 // Send a pointer to a struct AMessage object.  Don't block if the\r
377                 // queue is already full.\r
378                 pxMessage = & xMessage;\r
379                 xQueueSend( xQueue2, ( void * ) &pxMessage, ( portTickType ) 0 );\r
380         }\r
381 \r
382         // ... Rest of task code.\r
383  }\r
384  </pre>\r
385  * \defgroup xQueueSend xQueueSend\r
386  * \ingroup QueueManagement\r
387  */\r
388 #define xQueueSend( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( xQueue, pvItemToQueue, xTicksToWait, queueSEND_TO_BACK )\r
389 \r
390 \r
391 /**\r
392  * queue. h\r
393  * <pre>\r
394  portBASE_TYPE xQueueGenericSend(\r
395                                                                         xQueueHandle xQueue,\r
396                                                                         const void * pvItemToQueue,\r
397                                                                         portTickType xTicksToWait\r
398                                                                         portBASE_TYPE xCopyPosition\r
399                                                                 );\r
400  * </pre>\r
401  *\r
402  * It is preferred that the macros xQueueSend(), xQueueSendToFront() and\r
403  * xQueueSendToBack() are used in place of calling this function directly.\r
404  *\r
405  * Post an item on a queue.  The item is queued by copy, not by reference.\r
406  * This function must not be called from an interrupt service routine.\r
407  * See xQueueSendFromISR () for an alternative which may be used in an ISR.\r
408  *\r
409  * @param xQueue The handle to the queue on which the item is to be posted.\r
410  *\r
411  * @param pvItemToQueue A pointer to the item that is to be placed on the\r
412  * queue.  The size of the items the queue will hold was defined when the\r
413  * queue was created, so this many bytes will be copied from pvItemToQueue\r
414  * into the queue storage area.\r
415  *\r
416  * @param xTicksToWait The maximum amount of time the task should block\r
417  * waiting for space to become available on the queue, should it already\r
418  * be full.  The call will return immediately if this is set to 0 and the\r
419  * queue is full.  The time is defined in tick periods so the constant\r
420  * portTICK_RATE_MS should be used to convert to real time if this is required.\r
421  *\r
422  * @param xCopyPosition Can take the value queueSEND_TO_BACK to place the\r
423  * item at the back of the queue, or queueSEND_TO_FRONT to place the item\r
424  * at the front of the queue (for high priority messages).\r
425  *\r
426  * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL.\r
427  *\r
428  * Example usage:\r
429    <pre>\r
430  struct AMessage\r
431  {\r
432         char ucMessageID;\r
433         char ucData[ 20 ];\r
434  } xMessage;\r
435 \r
436  unsigned long ulVar = 10UL;\r
437 \r
438  void vATask( void *pvParameters )\r
439  {\r
440  xQueueHandle xQueue1, xQueue2;\r
441  struct AMessage *pxMessage;\r
442 \r
443         // Create a queue capable of containing 10 unsigned long values.\r
444         xQueue1 = xQueueCreate( 10, sizeof( unsigned long ) );\r
445 \r
446         // Create a queue capable of containing 10 pointers to AMessage structures.\r
447         // These should be passed by pointer as they contain a lot of data.\r
448         xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );\r
449 \r
450         // ...\r
451 \r
452         if( xQueue1 != 0 )\r
453         {\r
454                 // Send an unsigned long.  Wait for 10 ticks for space to become\r
455                 // available if necessary.\r
456                 if( xQueueGenericSend( xQueue1, ( void * ) &ulVar, ( portTickType ) 10, queueSEND_TO_BACK ) != pdPASS )\r
457                 {\r
458                         // Failed to post the message, even after 10 ticks.\r
459                 }\r
460         }\r
461 \r
462         if( xQueue2 != 0 )\r
463         {\r
464                 // Send a pointer to a struct AMessage object.  Don't block if the\r
465                 // queue is already full.\r
466                 pxMessage = & xMessage;\r
467                 xQueueGenericSend( xQueue2, ( void * ) &pxMessage, ( portTickType ) 0, queueSEND_TO_BACK );\r
468         }\r
469 \r
470         // ... Rest of task code.\r
471  }\r
472  </pre>\r
473  * \defgroup xQueueSend xQueueSend\r
474  * \ingroup QueueManagement\r
475  */\r
476 signed portBASE_TYPE xQueueGenericSend( xQueueHandle pxQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition );\r
477 \r
478 /**\r
479  * queue. h\r
480  * <pre>\r
481  portBASE_TYPE xQueuePeek(\r
482                                                          xQueueHandle xQueue,\r
483                                                          void *pvBuffer,\r
484                                                          portTickType xTicksToWait\r
485                                                  );</pre>\r
486  *\r
487  * This is a macro that calls the xQueueGenericReceive() function.\r
488  *\r
489  * Receive an item from a queue without removing the item from the queue.\r
490  * The item is received by copy so a buffer of adequate size must be\r
491  * provided.  The number of bytes copied into the buffer was defined when\r
492  * the queue was created.\r
493  *\r
494  * Successfully received items remain on the queue so will be returned again\r
495  * by the next call, or a call to xQueueReceive().\r
496  *\r
497  * This macro must not be used in an interrupt service routine.\r
498  *\r
499  * @param pxQueue The handle to the queue from which the item is to be\r
500  * received.\r
501  *\r
502  * @param pvBuffer Pointer to the buffer into which the received item will\r
503  * be copied.\r
504  *\r
505  * @param xTicksToWait The maximum amount of time the task should block\r
506  * waiting for an item to receive should the queue be empty at the time\r
507  * of the call.  The time is defined in tick periods so the constant\r
508  * portTICK_RATE_MS should be used to convert to real time if this is required.\r
509  * xQueuePeek() will return immediately if xTicksToWait is 0 and the queue\r
510  * is empty.\r
511  *\r
512  * @return pdTRUE if an item was successfully received from the queue,\r
513  * otherwise pdFALSE.\r
514  *\r
515  * Example usage:\r
516    <pre>\r
517  struct AMessage\r
518  {\r
519         char ucMessageID;\r
520         char ucData[ 20 ];\r
521  } xMessage;\r
522 \r
523  xQueueHandle xQueue;\r
524 \r
525  // Task to create a queue and post a value.\r
526  void vATask( void *pvParameters )\r
527  {\r
528  struct AMessage *pxMessage;\r
529 \r
530         // Create a queue capable of containing 10 pointers to AMessage structures.\r
531         // These should be passed by pointer as they contain a lot of data.\r
532         xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) );\r
533         if( xQueue == 0 )\r
534         {\r
535                 // Failed to create the queue.\r
536         }\r
537 \r
538         // ...\r
539 \r
540         // Send a pointer to a struct AMessage object.  Don't block if the\r
541         // queue is already full.\r
542         pxMessage = & xMessage;\r
543         xQueueSend( xQueue, ( void * ) &pxMessage, ( portTickType ) 0 );\r
544 \r
545         // ... Rest of task code.\r
546  }\r
547 \r
548  // Task to peek the data from the queue.\r
549  void vADifferentTask( void *pvParameters )\r
550  {\r
551  struct AMessage *pxRxedMessage;\r
552 \r
553         if( xQueue != 0 )\r
554         {\r
555                 // Peek a message on the created queue.  Block for 10 ticks if a\r
556                 // message is not immediately available.\r
557                 if( xQueuePeek( xQueue, &( pxRxedMessage ), ( portTickType ) 10 ) )\r
558                 {\r
559                         // pcRxedMessage now points to the struct AMessage variable posted\r
560                         // by vATask, but the item still remains on the queue.\r
561                 }\r
562         }\r
563 \r
564         // ... Rest of task code.\r
565  }\r
566  </pre>\r
567  * \defgroup xQueueReceive xQueueReceive\r
568  * \ingroup QueueManagement\r
569  */\r
570 #define xQueuePeek( xQueue, pvBuffer, xTicksToWait ) xQueueGenericReceive( xQueue, pvBuffer, xTicksToWait, pdTRUE )\r
571 \r
572 /**\r
573  * queue. h\r
574  * <pre>\r
575  portBASE_TYPE xQueueReceive(\r
576                                                                  xQueueHandle xQueue,\r
577                                                                  void *pvBuffer,\r
578                                                                  portTickType xTicksToWait\r
579                                                         );</pre>\r
580  *\r
581  * This is a macro that calls the xQueueGenericReceive() function.\r
582  *\r
583  * Receive an item from a queue.  The item is received by copy so a buffer of\r
584  * adequate size must be provided.  The number of bytes copied into the buffer\r
585  * was defined when the queue was created.\r
586  *\r
587  * Successfully received items are removed from the queue.\r
588  *\r
589  * This function must not be used in an interrupt service routine.  See\r
590  * xQueueReceiveFromISR for an alternative that can.\r
591  *\r
592  * @param pxQueue The handle to the queue from which the item is to be\r
593  * received.\r
594  *\r
595  * @param pvBuffer Pointer to the buffer into which the received item will\r
596  * be copied.\r
597  *\r
598  * @param xTicksToWait The maximum amount of time the task should block\r
599  * waiting for an item to receive should the queue be empty at the time\r
600  * of the call.  xQueueReceive() will return immediately if xTicksToWait\r
601  * is zero and the queue is empty.  The time is defined in tick periods so the\r
602  * constant portTICK_RATE_MS should be used to convert to real time if this is\r
603  * required.\r
604  *\r
605  * @return pdTRUE if an item was successfully received from the queue,\r
606  * otherwise pdFALSE.\r
607  *\r
608  * Example usage:\r
609    <pre>\r
610  struct AMessage\r
611  {\r
612         char ucMessageID;\r
613         char ucData[ 20 ];\r
614  } xMessage;\r
615 \r
616  xQueueHandle xQueue;\r
617 \r
618  // Task to create a queue and post a value.\r
619  void vATask( void *pvParameters )\r
620  {\r
621  struct AMessage *pxMessage;\r
622 \r
623         // Create a queue capable of containing 10 pointers to AMessage structures.\r
624         // These should be passed by pointer as they contain a lot of data.\r
625         xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) );\r
626         if( xQueue == 0 )\r
627         {\r
628                 // Failed to create the queue.\r
629         }\r
630 \r
631         // ...\r
632 \r
633         // Send a pointer to a struct AMessage object.  Don't block if the\r
634         // queue is already full.\r
635         pxMessage = & xMessage;\r
636         xQueueSend( xQueue, ( void * ) &pxMessage, ( portTickType ) 0 );\r
637 \r
638         // ... Rest of task code.\r
639  }\r
640 \r
641  // Task to receive from the queue.\r
642  void vADifferentTask( void *pvParameters )\r
643  {\r
644  struct AMessage *pxRxedMessage;\r
645 \r
646         if( xQueue != 0 )\r
647         {\r
648                 // Receive a message on the created queue.  Block for 10 ticks if a\r
649                 // message is not immediately available.\r
650                 if( xQueueReceive( xQueue, &( pxRxedMessage ), ( portTickType ) 10 ) )\r
651                 {\r
652                         // pcRxedMessage now points to the struct AMessage variable posted\r
653                         // by vATask.\r
654                 }\r
655         }\r
656 \r
657         // ... Rest of task code.\r
658  }\r
659  </pre>\r
660  * \defgroup xQueueReceive xQueueReceive\r
661  * \ingroup QueueManagement\r
662  */\r
663 #define xQueueReceive( xQueue, pvBuffer, xTicksToWait ) xQueueGenericReceive( xQueue, pvBuffer, xTicksToWait, pdFALSE )\r
664 \r
665 \r
666 /**\r
667  * queue. h\r
668  * <pre>\r
669  portBASE_TYPE xQueueGenericReceive(\r
670                                                                            xQueueHandle xQueue,\r
671                                                                            void *pvBuffer,\r
672                                                                            portTickType xTicksToWait\r
673                                                                            portBASE_TYPE        xJustPeek\r
674                                                                         );</pre>\r
675  *\r
676  * It is preferred that the macro xQueueReceive() be used rather than calling\r
677  * this function directly.\r
678  *\r
679  * Receive an item from a queue.  The item is received by copy so a buffer of\r
680  * adequate size must be provided.  The number of bytes copied into the buffer\r
681  * was defined when the queue was created.\r
682  *\r
683  * This function must not be used in an interrupt service routine.  See\r
684  * xQueueReceiveFromISR for an alternative that can.\r
685  *\r
686  * @param pxQueue The handle to the queue from which the item is to be\r
687  * received.\r
688  *\r
689  * @param pvBuffer Pointer to the buffer into which the received item will\r
690  * be copied.\r
691  *\r
692  * @param xTicksToWait The maximum amount of time the task should block\r
693  * waiting for an item to receive should the queue be empty at the time\r
694  * of the call.  The time is defined in tick periods so the constant\r
695  * portTICK_RATE_MS should be used to convert to real time if this is required.\r
696  * xQueueGenericReceive() will return immediately if the queue is empty and\r
697  * xTicksToWait is 0.\r
698  *\r
699  * @param xJustPeek When set to true, the item received from the queue is not\r
700  * actually removed from the queue - meaning a subsequent call to\r
701  * xQueueReceive() will return the same item.  When set to false, the item\r
702  * being received from the queue is also removed from the queue.\r
703  *\r
704  * @return pdTRUE if an item was successfully received from the queue,\r
705  * otherwise pdFALSE.\r
706  *\r
707  * Example usage:\r
708    <pre>\r
709  struct AMessage\r
710  {\r
711         char ucMessageID;\r
712         char ucData[ 20 ];\r
713  } xMessage;\r
714 \r
715  xQueueHandle xQueue;\r
716 \r
717  // Task to create a queue and post a value.\r
718  void vATask( void *pvParameters )\r
719  {\r
720  struct AMessage *pxMessage;\r
721 \r
722         // Create a queue capable of containing 10 pointers to AMessage structures.\r
723         // These should be passed by pointer as they contain a lot of data.\r
724         xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) );\r
725         if( xQueue == 0 )\r
726         {\r
727                 // Failed to create the queue.\r
728         }\r
729 \r
730         // ...\r
731 \r
732         // Send a pointer to a struct AMessage object.  Don't block if the\r
733         // queue is already full.\r
734         pxMessage = & xMessage;\r
735         xQueueSend( xQueue, ( void * ) &pxMessage, ( portTickType ) 0 );\r
736 \r
737         // ... Rest of task code.\r
738  }\r
739 \r
740  // Task to receive from the queue.\r
741  void vADifferentTask( void *pvParameters )\r
742  {\r
743  struct AMessage *pxRxedMessage;\r
744 \r
745         if( xQueue != 0 )\r
746         {\r
747                 // Receive a message on the created queue.  Block for 10 ticks if a\r
748                 // message is not immediately available.\r
749                 if( xQueueGenericReceive( xQueue, &( pxRxedMessage ), ( portTickType ) 10 ) )\r
750                 {\r
751                         // pcRxedMessage now points to the struct AMessage variable posted\r
752                         // by vATask.\r
753                 }\r
754         }\r
755 \r
756         // ... Rest of task code.\r
757  }\r
758  </pre>\r
759  * \defgroup xQueueReceive xQueueReceive\r
760  * \ingroup QueueManagement\r
761  */\r
762 signed portBASE_TYPE xQueueGenericReceive( xQueueHandle xQueue, void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeek );\r
763 \r
764 /**\r
765  * queue. h\r
766  * <pre>unsigned portBASE_TYPE uxQueueMessagesWaiting( const xQueueHandle xQueue );</pre>\r
767  *\r
768  * Return the number of messages stored in a queue.\r
769  *\r
770  * @param xQueue A handle to the queue being queried.\r
771  *\r
772  * @return The number of messages available in the queue.\r
773  *\r
774  * \page uxQueueMessagesWaiting uxQueueMessagesWaiting\r
775  * \ingroup QueueManagement\r
776  */\r
777 unsigned portBASE_TYPE uxQueueMessagesWaiting( const xQueueHandle xQueue );\r
778 \r
779 /**\r
780  * queue. h\r
781  * <pre>void vQueueDelete( xQueueHandle xQueue );</pre>\r
782  *\r
783  * Delete a queue - freeing all the memory allocated for storing of items\r
784  * placed on the queue.\r
785  *\r
786  * @param xQueue A handle to the queue to be deleted.\r
787  *\r
788  * \page vQueueDelete vQueueDelete\r
789  * \ingroup QueueManagement\r
790  */\r
791 void vQueueDelete( xQueueHandle pxQueue );\r
792 \r
793 /**\r
794  * queue. h\r
795  * <pre>\r
796  portBASE_TYPE xQueueSendToFrontFromISR(\r
797                                                                                  xQueueHandle pxQueue,\r
798                                                                                  const void *pvItemToQueue,\r
799                                                                                  portBASE_TYPE *pxHigherPriorityTaskWoken\r
800                                                                           );\r
801  </pre>\r
802  *\r
803  * This is a macro that calls xQueueGenericSendFromISR().\r
804  *\r
805  * Post an item to the front of a queue.  It is safe to use this macro from\r
806  * within an interrupt service routine.\r
807  *\r
808  * Items are queued by copy not reference so it is preferable to only\r
809  * queue small items, especially when called from an ISR.  In most cases\r
810  * it would be preferable to store a pointer to the item being queued.\r
811  *\r
812  * @param xQueue The handle to the queue on which the item is to be posted.\r
813  *\r
814  * @param pvItemToQueue A pointer to the item that is to be placed on the\r
815  * queue.  The size of the items the queue will hold was defined when the\r
816  * queue was created, so this many bytes will be copied from pvItemToQueue\r
817  * into the queue storage area.\r
818  *\r
819  * @param pxHigherPriorityTaskWoken xQueueSendToFrontFromISR() will set\r
820  * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task\r
821  * to unblock, and the unblocked task has a priority higher than the currently\r
822  * running task.  If xQueueSendToFromFromISR() sets this value to pdTRUE then\r
823  * a context switch should be requested before the interrupt is exited.\r
824  *\r
825  * @return pdTRUE if the data was successfully sent to the queue, otherwise\r
826  * errQUEUE_FULL.\r
827  *\r
828  * Example usage for buffered IO (where the ISR can obtain more than one value\r
829  * per call):\r
830    <pre>\r
831  void vBufferISR( void )\r
832  {\r
833  char cIn;\r
834  portBASE_TYPE xHigherPrioritTaskWoken;\r
835 \r
836         // We have not woken a task at the start of the ISR.\r
837         xHigherPriorityTaskWoken = pdFALSE;\r
838 \r
839         // Loop until the buffer is empty.\r
840         do\r
841         {\r
842                 // Obtain a byte from the buffer.\r
843                 cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );\r
844 \r
845                 // Post the byte.\r
846                 xQueueSendToFrontFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );\r
847 \r
848         } while( portINPUT_BYTE( BUFFER_COUNT ) );\r
849 \r
850         // Now the buffer is empty we can switch context if necessary.\r
851         if( xHigherPriorityTaskWoken )\r
852         {\r
853                 taskYIELD ();\r
854         }\r
855  }\r
856  </pre>\r
857  *\r
858  * \defgroup xQueueSendFromISR xQueueSendFromISR\r
859  * \ingroup QueueManagement\r
860  */\r
861 #define xQueueSendToFrontFromISR( pxQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( pxQueue, pvItemToQueue, pxHigherPriorityTaskWoken, queueSEND_TO_FRONT )\r
862 \r
863 \r
864 /**\r
865  * queue. h\r
866  * <pre>\r
867  portBASE_TYPE xQueueSendToBackFromISR(\r
868                                                                                  xQueueHandle pxQueue,\r
869                                                                                  const void *pvItemToQueue,\r
870                                                                                  portBASE_TYPE *pxHigherPriorityTaskWoken\r
871                                                                           );\r
872  </pre>\r
873  *\r
874  * This is a macro that calls xQueueGenericSendFromISR().\r
875  *\r
876  * Post an item to the back of a queue.  It is safe to use this macro from\r
877  * within an interrupt service routine.\r
878  *\r
879  * Items are queued by copy not reference so it is preferable to only\r
880  * queue small items, especially when called from an ISR.  In most cases\r
881  * it would be preferable to store a pointer to the item being queued.\r
882  *\r
883  * @param xQueue The handle to the queue on which the item is to be posted.\r
884  *\r
885  * @param pvItemToQueue A pointer to the item that is to be placed on the\r
886  * queue.  The size of the items the queue will hold was defined when the\r
887  * queue was created, so this many bytes will be copied from pvItemToQueue\r
888  * into the queue storage area.\r
889  *\r
890  * @param pxHigherPriorityTaskWoken xQueueSendToBackFromISR() will set\r
891  * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task\r
892  * to unblock, and the unblocked task has a priority higher than the currently\r
893  * running task.  If xQueueSendToBackFromISR() sets this value to pdTRUE then\r
894  * a context switch should be requested before the interrupt is exited.\r
895  *\r
896  * @return pdTRUE if the data was successfully sent to the queue, otherwise\r
897  * errQUEUE_FULL.\r
898  *\r
899  * Example usage for buffered IO (where the ISR can obtain more than one value\r
900  * per call):\r
901    <pre>\r
902  void vBufferISR( void )\r
903  {\r
904  char cIn;\r
905  portBASE_TYPE xHigherPriorityTaskWoken;\r
906 \r
907         // We have not woken a task at the start of the ISR.\r
908         xHigherPriorityTaskWoken = pdFALSE;\r
909 \r
910         // Loop until the buffer is empty.\r
911         do\r
912         {\r
913                 // Obtain a byte from the buffer.\r
914                 cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );\r
915 \r
916                 // Post the byte.\r
917                 xQueueSendToBackFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );\r
918 \r
919         } while( portINPUT_BYTE( BUFFER_COUNT ) );\r
920 \r
921         // Now the buffer is empty we can switch context if necessary.\r
922         if( xHigherPriorityTaskWoken )\r
923         {\r
924                 taskYIELD ();\r
925         }\r
926  }\r
927  </pre>\r
928  *\r
929  * \defgroup xQueueSendFromISR xQueueSendFromISR\r
930  * \ingroup QueueManagement\r
931  */\r
932 #define xQueueSendToBackFromISR( pxQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( pxQueue, pvItemToQueue, pxHigherPriorityTaskWoken, queueSEND_TO_BACK )\r
933 \r
934 /**\r
935  * queue. h\r
936  * <pre>\r
937  portBASE_TYPE xQueueSendFromISR(\r
938                                                                          xQueueHandle pxQueue,\r
939                                                                          const void *pvItemToQueue,\r
940                                                                          portBASE_TYPE *pxHigherPriorityTaskWoken\r
941                                                                 );\r
942  </pre>\r
943  *\r
944  * This is a macro that calls xQueueGenericSendFromISR().  It is included\r
945  * for backward compatibility with versions of FreeRTOS.org that did not\r
946  * include the xQueueSendToBackFromISR() and xQueueSendToFrontFromISR()\r
947  * macros.\r
948  *\r
949  * Post an item to the back of a queue.  It is safe to use this function from\r
950  * within an interrupt service routine.\r
951  *\r
952  * Items are queued by copy not reference so it is preferable to only\r
953  * queue small items, especially when called from an ISR.  In most cases\r
954  * it would be preferable to store a pointer to the item being queued.\r
955  *\r
956  * @param xQueue The handle to the queue on which the item is to be posted.\r
957  *\r
958  * @param pvItemToQueue A pointer to the item that is to be placed on the\r
959  * queue.  The size of the items the queue will hold was defined when the\r
960  * queue was created, so this many bytes will be copied from pvItemToQueue\r
961  * into the queue storage area.\r
962  *\r
963  * @param pxHigherPriorityTaskWoken xQueueSendFromISR() will set\r
964  * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task\r
965  * to unblock, and the unblocked task has a priority higher than the currently\r
966  * running task.  If xQueueSendFromISR() sets this value to pdTRUE then\r
967  * a context switch should be requested before the interrupt is exited.\r
968  *\r
969  * @return pdTRUE if the data was successfully sent to the queue, otherwise\r
970  * errQUEUE_FULL.\r
971  *\r
972  * Example usage for buffered IO (where the ISR can obtain more than one value\r
973  * per call):\r
974    <pre>\r
975  void vBufferISR( void )\r
976  {\r
977  char cIn;\r
978  portBASE_TYPE xHigherPriorityTaskWoken;\r
979 \r
980         // We have not woken a task at the start of the ISR.\r
981         xHigherPriorityTaskWoken = pdFALSE;\r
982 \r
983         // Loop until the buffer is empty.\r
984         do\r
985         {\r
986                 // Obtain a byte from the buffer.\r
987                 cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );\r
988 \r
989                 // Post the byte.\r
990                 xQueueSendFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );\r
991 \r
992         } while( portINPUT_BYTE( BUFFER_COUNT ) );\r
993 \r
994         // Now the buffer is empty we can switch context if necessary.\r
995         if( xHigherPriorityTaskWoken )\r
996         {\r
997                 // Actual macro used here is port specific.\r
998                 taskYIELD_FROM_ISR ();\r
999         }\r
1000  }\r
1001  </pre>\r
1002  *\r
1003  * \defgroup xQueueSendFromISR xQueueSendFromISR\r
1004  * \ingroup QueueManagement\r
1005  */\r
1006 #define xQueueSendFromISR( pxQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( pxQueue, pvItemToQueue, pxHigherPriorityTaskWoken, queueSEND_TO_BACK )\r
1007 \r
1008 /**\r
1009  * queue. h\r
1010  * <pre>\r
1011  portBASE_TYPE xQueueGenericSendFromISR(\r
1012                                                                                    xQueueHandle pxQueue,\r
1013                                                                                    const        void    *pvItemToQueue,\r
1014                                                                                    portBASE_TYPE        *pxHigherPriorityTaskWoken,\r
1015                                                                                    portBASE_TYPE        xCopyPosition\r
1016                                                                            );\r
1017  </pre>\r
1018  *\r
1019  * It is preferred that the macros xQueueSendFromISR(),\r
1020  * xQueueSendToFrontFromISR() and xQueueSendToBackFromISR() be used in place\r
1021  * of calling this function directly.\r
1022  *\r
1023  * Post an item on a queue.  It is safe to use this function from within an\r
1024  * interrupt service routine.\r
1025  *\r
1026  * Items are queued by copy not reference so it is preferable to only\r
1027  * queue small items, especially when called from an ISR.  In most cases\r
1028  * it would be preferable to store a pointer to the item being queued.\r
1029  *\r
1030  * @param xQueue The handle to the queue on which the item is to be posted.\r
1031  *\r
1032  * @param pvItemToQueue A pointer to the item that is to be placed on the\r
1033  * queue.  The size of the items the queue will hold was defined when the\r
1034  * queue was created, so this many bytes will be copied from pvItemToQueue\r
1035  * into the queue storage area.\r
1036  *\r
1037  * @param pxHigherPriorityTaskWoken xQueueGenericSendFromISR() will set\r
1038  * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task\r
1039  * to unblock, and the unblocked task has a priority higher than the currently\r
1040  * running task.  If xQueueGenericSendFromISR() sets this value to pdTRUE then\r
1041  * a context switch should be requested before the interrupt is exited.\r
1042  *\r
1043  * @param xCopyPosition Can take the value queueSEND_TO_BACK to place the\r
1044  * item at the back of the queue, or queueSEND_TO_FRONT to place the item\r
1045  * at the front of the queue (for high priority messages).\r
1046  *\r
1047  * @return pdTRUE if the data was successfully sent to the queue, otherwise\r
1048  * errQUEUE_FULL.\r
1049  *\r
1050  * Example usage for buffered IO (where the ISR can obtain more than one value\r
1051  * per call):\r
1052    <pre>\r
1053  void vBufferISR( void )\r
1054  {\r
1055  char cIn;\r
1056  portBASE_TYPE xHigherPriorityTaskWokenByPost;\r
1057 \r
1058         // We have not woken a task at the start of the ISR.\r
1059         xHigherPriorityTaskWokenByPost = pdFALSE;\r
1060 \r
1061         // Loop until the buffer is empty.\r
1062         do\r
1063         {\r
1064                 // Obtain a byte from the buffer.\r
1065                 cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );\r
1066 \r
1067                 // Post each byte.\r
1068                 xQueueGenericSendFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWokenByPost, queueSEND_TO_BACK );\r
1069 \r
1070         } while( portINPUT_BYTE( BUFFER_COUNT ) );\r
1071 \r
1072         // Now the buffer is empty we can switch context if necessary.  Note that the\r
1073         // name of the yield function required is port specific.\r
1074         if( xHigherPriorityTaskWokenByPost )\r
1075         {\r
1076                 taskYIELD_YIELD_FROM_ISR();\r
1077         }\r
1078  }\r
1079  </pre>\r
1080  *\r
1081  * \defgroup xQueueSendFromISR xQueueSendFromISR\r
1082  * \ingroup QueueManagement\r
1083  */\r
1084 signed portBASE_TYPE xQueueGenericSendFromISR( xQueueHandle pxQueue, const void * const pvItemToQueue, signed portBASE_TYPE *pxHigherPriorityTaskWoken, portBASE_TYPE xCopyPosition );\r
1085 \r
1086 /**\r
1087  * queue. h\r
1088  * <pre>\r
1089  portBASE_TYPE xQueueReceiveFromISR(\r
1090                                                                            xQueueHandle pxQueue,\r
1091                                                                            void *pvBuffer,\r
1092                                                                            portBASE_TYPE        *pxTaskWoken\r
1093                                                                    );\r
1094  * </pre>\r
1095  *\r
1096  * Receive an item from a queue.  It is safe to use this function from within an\r
1097  * interrupt service routine.\r
1098  *\r
1099  * @param pxQueue The handle to the queue from which the item is to be\r
1100  * received.\r
1101  *\r
1102  * @param pvBuffer Pointer to the buffer into which the received item will\r
1103  * be copied.\r
1104  *\r
1105  * @param pxTaskWoken A task may be blocked waiting for space to become\r
1106  * available on the queue.  If xQueueReceiveFromISR causes such a task to\r
1107  * unblock *pxTaskWoken will get set to pdTRUE, otherwise *pxTaskWoken will\r
1108  * remain unchanged.\r
1109  *\r
1110  * @return pdTRUE if an item was successfully received from the queue,\r
1111  * otherwise pdFALSE.\r
1112  *\r
1113  * Example usage:\r
1114    <pre>\r
1115 \r
1116  xQueueHandle xQueue;\r
1117 \r
1118  // Function to create a queue and post some values.\r
1119  void vAFunction( void *pvParameters )\r
1120  {\r
1121  char cValueToPost;\r
1122  const portTickType xBlockTime = ( portTickType )0xff;\r
1123 \r
1124         // Create a queue capable of containing 10 characters.\r
1125         xQueue = xQueueCreate( 10, sizeof( char ) );\r
1126         if( xQueue == 0 )\r
1127         {\r
1128                 // Failed to create the queue.\r
1129         }\r
1130 \r
1131         // ...\r
1132 \r
1133         // Post some characters that will be used within an ISR.  If the queue\r
1134         // is full then this task will block for xBlockTime ticks.\r
1135         cValueToPost = 'a';\r
1136         xQueueSend( xQueue, ( void * ) &cValueToPost, xBlockTime );\r
1137         cValueToPost = 'b';\r
1138         xQueueSend( xQueue, ( void * ) &cValueToPost, xBlockTime );\r
1139 \r
1140         // ... keep posting characters ... this task may block when the queue\r
1141         // becomes full.\r
1142 \r
1143         cValueToPost = 'c';\r
1144         xQueueSend( xQueue, ( void * ) &cValueToPost, xBlockTime );\r
1145  }\r
1146 \r
1147  // ISR that outputs all the characters received on the queue.\r
1148  void vISR_Routine( void )\r
1149  {\r
1150  portBASE_TYPE xTaskWokenByReceive = pdFALSE;\r
1151  char cRxedChar;\r
1152 \r
1153         while( xQueueReceiveFromISR( xQueue, ( void * ) &cRxedChar, &xTaskWokenByReceive) )\r
1154         {\r
1155                 // A character was received.  Output the character now.\r
1156                 vOutputCharacter( cRxedChar );\r
1157 \r
1158                 // If removing the character from the queue woke the task that was\r
1159                 // posting onto the queue cTaskWokenByReceive will have been set to\r
1160                 // pdTRUE.  No matter how many times this loop iterates only one\r
1161                 // task will be woken.\r
1162         }\r
1163 \r
1164         if( cTaskWokenByPost != ( char ) pdFALSE;\r
1165         {\r
1166                 taskYIELD ();\r
1167         }\r
1168  }\r
1169  </pre>\r
1170  * \defgroup xQueueReceiveFromISR xQueueReceiveFromISR\r
1171  * \ingroup QueueManagement\r
1172  */\r
1173 signed portBASE_TYPE xQueueReceiveFromISR( xQueueHandle pxQueue, void * const pvBuffer, signed portBASE_TYPE *pxTaskWoken );\r
1174 \r
1175 /*\r
1176  * Utilities to query queue that are safe to use from an ISR.  These utilities\r
1177  * should be used only from witin an ISR, or within a critical section.\r
1178  */\r
1179 signed portBASE_TYPE xQueueIsQueueEmptyFromISR( const xQueueHandle pxQueue );\r
1180 signed portBASE_TYPE xQueueIsQueueFullFromISR( const xQueueHandle pxQueue );\r
1181 unsigned portBASE_TYPE uxQueueMessagesWaitingFromISR( const xQueueHandle pxQueue );\r
1182 \r
1183 \r
1184 /*\r
1185  * xQueueAltGenericSend() is an alternative version of xQueueGenericSend().\r
1186  * Likewise xQueueAltGenericReceive() is an alternative version of\r
1187  * xQueueGenericReceive().\r
1188  *\r
1189  * The source code that implements the alternative (Alt) API is much\r
1190  * simpler      because it executes everything from within a critical section.\r
1191  * This is      the approach taken by many other RTOSes, but FreeRTOS.org has the\r
1192  * preferred fully featured API too.  The fully featured API has more\r
1193  * complex      code that takes longer to execute, but makes much less use of\r
1194  * critical sections.  Therefore the alternative API sacrifices interrupt\r
1195  * responsiveness to gain execution speed, whereas the fully featured API\r
1196  * sacrifices execution speed to ensure better interrupt responsiveness.\r
1197  */\r
1198 signed portBASE_TYPE xQueueAltGenericSend( xQueueHandle pxQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition );\r
1199 signed portBASE_TYPE xQueueAltGenericReceive( xQueueHandle pxQueue, void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking );\r
1200 #define xQueueAltSendToFront( xQueue, pvItemToQueue, xTicksToWait ) xQueueAltGenericSend( xQueue, pvItemToQueue, xTicksToWait, queueSEND_TO_FRONT )\r
1201 #define xQueueAltSendToBack( xQueue, pvItemToQueue, xTicksToWait ) xQueueAltGenericSend( xQueue, pvItemToQueue, xTicksToWait, queueSEND_TO_BACK )\r
1202 #define xQueueAltReceive( xQueue, pvBuffer, xTicksToWait ) xQueueAltGenericReceive( xQueue, pvBuffer, xTicksToWait, pdFALSE )\r
1203 #define xQueueAltPeek( xQueue, pvBuffer, xTicksToWait ) xQueueAltGenericReceive( xQueue, pvBuffer, xTicksToWait, pdTRUE )\r
1204 \r
1205 /*\r
1206  * The functions defined above are for passing data to and from tasks.  The\r
1207  * functions below are the equivalents for passing data to and from\r
1208  * co-routines.\r
1209  *\r
1210  * These functions are called from the co-routine macro implementation and\r
1211  * should not be called directly from application code.  Instead use the macro\r
1212  * wrappers defined within croutine.h.\r
1213  */\r
1214 signed portBASE_TYPE xQueueCRSendFromISR( xQueueHandle pxQueue, const void *pvItemToQueue, signed portBASE_TYPE xCoRoutinePreviouslyWoken );\r
1215 signed portBASE_TYPE xQueueCRReceiveFromISR( xQueueHandle pxQueue, void *pvBuffer, signed portBASE_TYPE *pxTaskWoken );\r
1216 signed portBASE_TYPE xQueueCRSend( xQueueHandle pxQueue, const void *pvItemToQueue, portTickType xTicksToWait );\r
1217 signed portBASE_TYPE xQueueCRReceive( xQueueHandle pxQueue, void *pvBuffer, portTickType xTicksToWait );\r
1218 \r
1219 /*\r
1220  * For internal use only.  Use xSemaphoreCreateMutex() or\r
1221  * xSemaphoreCreateCounting() instead of calling these functions directly.\r
1222  */\r
1223 xQueueHandle xQueueCreateMutex( void );\r
1224 xQueueHandle xQueueCreateCountingSemaphore( unsigned portBASE_TYPE uxCountValue, unsigned portBASE_TYPE uxInitialCount );\r
1225 \r
1226 /*\r
1227  * For internal use only.  Use xSemaphoreTakeMutexRecursive() or\r
1228  * xSemaphoreGiveMutexRecursive() instead of calling these functions directly.\r
1229  */\r
1230 portBASE_TYPE xQueueTakeMutexRecursive( xQueueHandle pxMutex, portTickType xBlockTime );\r
1231 portBASE_TYPE xQueueGiveMutexRecursive( xQueueHandle pxMutex );\r
1232 \r
1233 /*\r
1234  * The registry is provided as a means for kernel aware debuggers to\r
1235  * locate queues, semaphores and mutexes.  Call vQueueAddToRegistry() add\r
1236  * a queue, semaphore or mutex handle to the registry if you want the handle\r
1237  * to be available to a kernel aware debugger.  If you are not using a kernel\r
1238  * aware debugger then this function can be ignored.\r
1239  *\r
1240  * configQUEUE_REGISTRY_SIZE defines the maximum number of handles the\r
1241  * registry can hold.  configQUEUE_REGISTRY_SIZE must be greater than 0\r
1242  * within FreeRTOSConfig.h for the registry to be available.  Its value\r
1243  * does not effect the number of queues, semaphores and mutexes that can be\r
1244  * created - just the number that the registry can hold.\r
1245  *\r
1246  * @param xQueue The handle of the queue being added to the registry.  This\r
1247  * is the handle returned by a call to xQueueCreate().  Semaphore and mutex\r
1248  * handles can also be passed in here.\r
1249  *\r
1250  * @param pcName The name to be associated with the handle.  This is the\r
1251  * name that the kernel aware debugger will display.\r
1252  */\r
1253 #if configQUEUE_REGISTRY_SIZE > 0\r
1254         void vQueueAddToRegistry( xQueueHandle xQueue, signed char *pcName );\r
1255 #endif\r
1256 \r
1257 /* Not a public API function, hence the 'Restricted' in the name. */\r
1258 void vQueueWaitForMessageRestricted( xQueueHandle pxQueue, portTickType xTicksToWait );\r
1259 \r
1260 \r
1261 #ifdef __cplusplus\r
1262 }\r
1263 #endif\r
1264 \r
1265 #endif /* QUEUE_H */\r
1266 \r