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