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