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