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