]> git.sur5r.net Git - freertos/blobdiff - Source/include/queue.h
Continue work on the timers module.
[freertos] / Source / include / queue.h
index f305cb9c5e5dc897ea85f0a887b3fef4d4dd4e62..b044d04de4afe04ca30ebe17fdbe6fc73e4a67ba 100644 (file)
@@ -1,44 +1,62 @@
 /*\r
-       FreeRTOS.org V4.7.1 - Copyright (C) 2003-2008 Richard Barry.\r
-\r
-       This file is part of the FreeRTOS.org distribution.\r
-\r
-       FreeRTOS.org is free software; you can redistribute it and/or modify\r
-       it under the terms of the GNU General Public License as published by\r
-       the Free Software Foundation; either version 2 of the License, or\r
-       (at your option) any later version.\r
-\r
-       FreeRTOS.org is distributed in the hope that it will be useful,\r
-       but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-       GNU General Public License for more details.\r
-\r
-       You should have received a copy of the GNU General Public License\r
-       along with FreeRTOS.org; if not, write to the Free Software\r
-       Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
-\r
-       A special exception to the GPL can be applied should you wish to distribute\r
-       a combined work that includes FreeRTOS.org, without being obliged to provide\r
-       the source code for any proprietary components.  See the licensing section\r
-       of http://www.FreeRTOS.org for full details of how and when the exception\r
-       can be applied.\r
-\r
-       ***************************************************************************\r
-\r
-       Please ensure to read the configuration and relevant port sections of the \r
-       online documentation.\r
+    FreeRTOS V6.1.1 - Copyright (C) 2011 Real Time Engineers Ltd.\r
+\r
+    ***************************************************************************\r
+    *                                                                         *\r
+    * If you are:                                                             *\r
+    *                                                                         *\r
+    *    + New to FreeRTOS,                                                   *\r
+    *    + Wanting to learn FreeRTOS or multitasking in general quickly       *\r
+    *    + Looking for basic training,                                        *\r
+    *    + Wanting to improve your FreeRTOS skills and productivity           *\r
+    *                                                                         *\r
+    * then take a look at the FreeRTOS books - available as PDF or paperback  *\r
+    *                                                                         *\r
+    *        "Using the FreeRTOS Real Time Kernel - a Practical Guide"        *\r
+    *                  http://www.FreeRTOS.org/Documentation                  *\r
+    *                                                                         *\r
+    * A pdf reference manual is also available.  Both are usually delivered   *\r
+    * to your inbox within 20 minutes to two hours when purchased between 8am *\r
+    * and 8pm GMT (although please allow up to 24 hours in case of            *\r
+    * exceptional circumstances).  Thank you for your support!                *\r
+    *                                                                         *\r
+    ***************************************************************************\r
+\r
+    This file is part of the FreeRTOS distribution.\r
+\r
+    FreeRTOS is free software; you can redistribute it and/or modify it under\r
+    the terms of the GNU General Public License (version 2) as published by the\r
+    Free Software Foundation AND MODIFIED BY the FreeRTOS exception.\r
+    ***NOTE*** The exception to the GPL is included to allow you to distribute\r
+    a combined work that includes FreeRTOS without being obliged to provide the\r
+    source code for proprietary components outside of the FreeRTOS kernel.\r
+    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT\r
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\r
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for\r
+    more details. You should have received a copy of the GNU General Public \r
+    License and the FreeRTOS license exception along with FreeRTOS; if not it \r
+    can be viewed here: http://www.freertos.org/a00114.html and also obtained \r
+    by writing to Richard Barry, contact details for whom are available on the\r
+    FreeRTOS WEB site.\r
+\r
+    1 tab == 4 spaces!\r
+\r
+    http://www.FreeRTOS.org - Documentation, latest information, license and\r
+    contact details.\r
+\r
+    http://www.SafeRTOS.com - A version that is certified for use in safety\r
+    critical systems.\r
+\r
+    http://www.OpenRTOS.com - Commercial support, development, porting,\r
+    licensing and training services.\r
+*/\r
 \r
-       +++ http://www.FreeRTOS.org +++\r
-       Documentation, latest information, license and contact details.  \r
+#ifndef INC_FREERTOS_H\r
+       #error "#include FreeRTOS.h" must appear in source files before "#include queue.h"\r
+#endif\r
 \r
-       +++ http://www.SafeRTOS.com +++\r
-       A version that is certified for use in safety critical systems.\r
 \r
-       +++ http://www.OpenRTOS.com +++\r
-       Commercial support, development, porting, licensing and training services.\r
 \r
-       ***************************************************************************\r
-*/\r
 \r
 #ifndef QUEUE_H\r
 #define QUEUE_H\r
 #ifdef __cplusplus\r
 extern "C" {\r
 #endif\r
+\r
+\r
+#include "mpu_wrappers.h"\r
+\r
+\r
 typedef void * xQueueHandle;\r
 \r
+\r
 /* For internal use only. */\r
 #define        queueSEND_TO_BACK       ( 0 )\r
 #define        queueSEND_TO_FRONT      ( 1 )\r
@@ -57,9 +81,9 @@ typedef void * xQueueHandle;
  * queue. h\r
  * <pre>\r
  xQueueHandle xQueueCreate(\r
-                              unsigned portBASE_TYPE uxQueueLength,\r
-                              unsigned portBASE_TYPE uxItemSize\r
-                          );\r
+                                                         unsigned portBASE_TYPE uxQueueLength,\r
+                                                         unsigned portBASE_TYPE uxItemSize\r
+                                                 );\r
  * </pre>\r
  *\r
  * Creates a new queue instance.  This allocates the storage required by the\r
@@ -80,30 +104,30 @@ typedef void * xQueueHandle;
    <pre>\r
  struct AMessage\r
  {\r
-    portCHAR ucMessageID;\r
-    portCHAR ucData[ 20 ];\r
+       char ucMessageID;\r
+       char ucData[ 20 ];\r
  };\r
 \r
  void vATask( void *pvParameters )\r
  {\r
  xQueueHandle xQueue1, xQueue2;\r
 \r
-    // Create a queue capable of containing 10 unsigned long values.\r
-    xQueue1 = xQueueCreate( 10, sizeof( unsigned portLONG ) );\r
-    if( xQueue1 == 0 )\r
-    {\r
-        // Queue was not created and must not be used.\r
-    }\r
-\r
-    // Create a queue capable of containing 10 pointers to AMessage structures.\r
-    // These should be passed by pointer as they contain a lot of data.\r
-    xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );\r
-    if( xQueue2 == 0 )\r
-    {\r
-        // Queue was not created and must not be used.\r
-    }\r
-\r
-    // ... Rest of task code.\r
+       // Create a queue capable of containing 10 unsigned long values.\r
+       xQueue1 = xQueueCreate( 10, sizeof( unsigned long ) );\r
+       if( xQueue1 == 0 )\r
+       {\r
+               // Queue was not created and must not be used.\r
+       }\r
+\r
+       // Create a queue capable of containing 10 pointers to AMessage structures.\r
+       // These should be passed by pointer as they contain a lot of data.\r
+       xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );\r
+       if( xQueue2 == 0 )\r
+       {\r
+               // Queue was not created and must not be used.\r
+       }\r
+\r
+       // ... Rest of task code.\r
  }\r
  </pre>\r
  * \defgroup xQueueCreate xQueueCreate\r
@@ -115,10 +139,10 @@ xQueueHandle xQueueCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBA
  * queue. h\r
  * <pre>\r
  portBASE_TYPE xQueueSendToToFront(\r
-                                   xQueueHandle xQueue,\r
-                                   const void * pvItemToQueue,\r
-                                   portTickType xTicksToWait\r
-                               );\r
+                                                                  xQueueHandle xQueue,\r
+                                                                  const        void    *       pvItemToQueue,\r
+                                                                  portTickType xTicksToWait\r
+                                                          );\r
  * </pre>\r
  *\r
  * This is a macro that calls xQueueGenericSend().\r
@@ -137,9 +161,9 @@ xQueueHandle xQueueCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBA
  *\r
  * @param xTicksToWait The maximum amount of time the task should block\r
  * waiting for space to become available on the queue, should it already\r
- * be full.  The call will return immediately if this is set to 0.  The\r
- * time is defined in tick periods so the constant portTICK_RATE_MS\r
- * should be used to convert to real time if this is required.\r
+ * be full.  The call will return immediately if this is set to 0 and the\r
+ * queue is full.  The time is defined in tick periods so the constant\r
+ * portTICK_RATE_MS should be used to convert to real time if this is required.\r
  *\r
  * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL.\r
  *\r
@@ -147,43 +171,43 @@ xQueueHandle xQueueCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBA
    <pre>\r
  struct AMessage\r
  {\r
-    portCHAR ucMessageID;\r
-    portCHAR ucData[ 20 ];\r
+       char ucMessageID;\r
+       char ucData[ 20 ];\r
  } xMessage;\r
 \r
- unsigned portLONG ulVar = 10UL;\r
+ unsigned long ulVar = 10UL;\r
 \r
  void vATask( void *pvParameters )\r
  {\r
  xQueueHandle xQueue1, xQueue2;\r
  struct AMessage *pxMessage;\r
 \r
-    // Create a queue capable of containing 10 unsigned long values.\r
-    xQueue1 = xQueueCreate( 10, sizeof( unsigned portLONG ) );\r
-\r
-    // Create a queue capable of containing 10 pointers to AMessage structures.\r
-    // These should be passed by pointer as they contain a lot of data.\r
-    xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );\r
-\r
-    // ...\r
-\r
-    if( xQueue1 != 0 )\r
-    {\r
-        // Send an unsigned long.  Wait for 10 ticks for space to become\r
-        // available if necessary.\r
-        if( xQueueSendToFront( xQueue1, ( void * ) &ulVar, ( portTickType ) 10 ) != pdPASS )\r
-        {\r
-            // Failed to post the message, even after 10 ticks.\r
-        }\r
-    }\r
-\r
-    if( xQueue2 != 0 )\r
-    {\r
-        // Send a pointer to a struct AMessage object.  Don't block if the\r
-        // queue is already full.\r
-        pxMessage = & xMessage;\r
-        xQueueSendToFront( xQueue2, ( void * ) &pxMessage, ( portTickType ) 0 );\r
-    }\r
+       // Create a queue capable of containing 10 unsigned long values.\r
+       xQueue1 = xQueueCreate( 10, sizeof( unsigned long ) );\r
+\r
+       // Create a queue capable of containing 10 pointers to AMessage structures.\r
+       // These should be passed by pointer as they contain a lot of data.\r
+       xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );\r
+\r
+       // ...\r
+\r
+       if( xQueue1 != 0 )\r
+       {\r
+               // Send an unsigned long.  Wait for 10 ticks for space to become\r
+               // available if necessary.\r
+               if( xQueueSendToFront( xQueue1, ( void * ) &ulVar, ( portTickType ) 10 ) != pdPASS )\r
+               {\r
+                       // Failed to post the message, even after 10 ticks.\r
+               }\r
+       }\r
+\r
+       if( xQueue2 != 0 )\r
+       {\r
+               // Send a pointer to a struct AMessage object.  Don't block if the\r
+               // queue is already full.\r
+               pxMessage = & xMessage;\r
+               xQueueSendToFront( xQueue2, ( void * ) &pxMessage, ( portTickType ) 0 );\r
+       }\r
 \r
        // ... Rest of task code.\r
  }\r
@@ -197,10 +221,10 @@ xQueueHandle xQueueCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBA
  * queue. h\r
  * <pre>\r
  portBASE_TYPE xQueueSendToBack(\r
-                                   xQueueHandle xQueue,\r
-                                   const void * pvItemToQueue,\r
-                                   portTickType xTicksToWait\r
-                               );\r
+                                                                  xQueueHandle xQueue,\r
+                                                                  const        void    *       pvItemToQueue,\r
+                                                                  portTickType xTicksToWait\r
+                                                          );\r
  * </pre>\r
  *\r
  * This is a macro that calls xQueueGenericSend().\r
@@ -219,9 +243,9 @@ xQueueHandle xQueueCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBA
  *\r
  * @param xTicksToWait The maximum amount of time the task should block\r
  * waiting for space to become available on the queue, should it already\r
- * be full.  The call will return immediately if this is set to 0.  The\r
- * time is defined in tick periods so the constant portTICK_RATE_MS\r
- * should be used to convert to real time if this is required.\r
+ * be full.  The call will return immediately if this is set to 0 and the queue\r
+ * is full.  The  time is defined in tick periods so the constant\r
+ * portTICK_RATE_MS should be used to convert to real time if this is required.\r
  *\r
  * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL.\r
  *\r
@@ -229,43 +253,43 @@ xQueueHandle xQueueCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBA
    <pre>\r
  struct AMessage\r
  {\r
-    portCHAR ucMessageID;\r
-    portCHAR ucData[ 20 ];\r
+       char ucMessageID;\r
+       char ucData[ 20 ];\r
  } xMessage;\r
 \r
- unsigned portLONG ulVar = 10UL;\r
+ unsigned long ulVar = 10UL;\r
 \r
  void vATask( void *pvParameters )\r
  {\r
  xQueueHandle xQueue1, xQueue2;\r
  struct AMessage *pxMessage;\r
 \r
-    // Create a queue capable of containing 10 unsigned long values.\r
-    xQueue1 = xQueueCreate( 10, sizeof( unsigned portLONG ) );\r
-\r
-    // Create a queue capable of containing 10 pointers to AMessage structures.\r
-    // These should be passed by pointer as they contain a lot of data.\r
-    xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );\r
-\r
-    // ...\r
-\r
-    if( xQueue1 != 0 )\r
-    {\r
-        // Send an unsigned long.  Wait for 10 ticks for space to become\r
-        // available if necessary.\r
-        if( xQueueSendToBack( xQueue1, ( void * ) &ulVar, ( portTickType ) 10 ) != pdPASS )\r
-        {\r
-            // Failed to post the message, even after 10 ticks.\r
-        }\r
-    }\r
-\r
-    if( xQueue2 != 0 )\r
-    {\r
-        // Send a pointer to a struct AMessage object.  Don't block if the\r
-        // queue is already full.\r
-        pxMessage = & xMessage;\r
-        xQueueSendToBack( xQueue2, ( void * ) &pxMessage, ( portTickType ) 0 );\r
-    }\r
+       // Create a queue capable of containing 10 unsigned long values.\r
+       xQueue1 = xQueueCreate( 10, sizeof( unsigned long ) );\r
+\r
+       // Create a queue capable of containing 10 pointers to AMessage structures.\r
+       // These should be passed by pointer as they contain a lot of data.\r
+       xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );\r
+\r
+       // ...\r
+\r
+       if( xQueue1 != 0 )\r
+       {\r
+               // Send an unsigned long.  Wait for 10 ticks for space to become\r
+               // available if necessary.\r
+               if( xQueueSendToBack( xQueue1, ( void * ) &ulVar, ( portTickType ) 10 ) != pdPASS )\r
+               {\r
+                       // Failed to post the message, even after 10 ticks.\r
+               }\r
+       }\r
+\r
+       if( xQueue2 != 0 )\r
+       {\r
+               // Send a pointer to a struct AMessage object.  Don't block if the\r
+               // queue is already full.\r
+               pxMessage = & xMessage;\r
+               xQueueSendToBack( xQueue2, ( void * ) &pxMessage, ( portTickType ) 0 );\r
+       }\r
 \r
        // ... Rest of task code.\r
  }\r
@@ -279,10 +303,10 @@ xQueueHandle xQueueCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBA
  * queue. h\r
  * <pre>\r
  portBASE_TYPE xQueueSend(\r
-                              xQueueHandle xQueue,\r
-                              const void * pvItemToQueue,\r
-                              portTickType xTicksToWait\r
-                         );\r
+                                                         xQueueHandle xQueue,\r
+                                                         const void * pvItemToQueue,\r
+                                                         portTickType xTicksToWait\r
+                                                );\r
  * </pre>\r
  *\r
  * This is a macro that calls xQueueGenericSend().  It is included for\r
@@ -303,9 +327,9 @@ xQueueHandle xQueueCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBA
  *\r
  * @param xTicksToWait The maximum amount of time the task should block\r
  * waiting for space to become available on the queue, should it already\r
- * be full.  The call will return immediately if this is set to 0.  The\r
- * time is defined in tick periods so the constant portTICK_RATE_MS\r
- * should be used to convert to real time if this is required.\r
+ * be full.  The call will return immediately if this is set to 0 and the\r
+ * queue is full.  The time is defined in tick periods so the constant\r
+ * portTICK_RATE_MS should be used to convert to real time if this is required.\r
  *\r
  * @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL.\r
  *\r
@@ -313,43 +337,43 @@ xQueueHandle xQueueCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBA
    <pre>\r
  struct AMessage\r
  {\r
-    portCHAR ucMessageID;\r
-    portCHAR ucData[ 20 ];\r
+       char ucMessageID;\r
+       char ucData[ 20 ];\r
  } xMessage;\r
 \r
- unsigned portLONG ulVar = 10UL;\r
+ unsigned long ulVar = 10UL;\r
 \r
  void vATask( void *pvParameters )\r
  {\r
  xQueueHandle xQueue1, xQueue2;\r
  struct AMessage *pxMessage;\r
 \r
-    // Create a queue capable of containing 10 unsigned long values.\r
-    xQueue1 = xQueueCreate( 10, sizeof( unsigned portLONG ) );\r
-\r
-    // Create a queue capable of containing 10 pointers to AMessage structures.\r
-    // These should be passed by pointer as they contain a lot of data.\r
-    xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );\r
-\r
-    // ...\r
-\r
-    if( xQueue1 != 0 )\r
-    {\r
-        // Send an unsigned long.  Wait for 10 ticks for space to become\r
-        // available if necessary.\r
-        if( xQueueSend( xQueue1, ( void * ) &ulVar, ( portTickType ) 10 ) != pdPASS )\r
-        {\r
-            // Failed to post the message, even after 10 ticks.\r
-        }\r
-    }\r
-\r
-    if( xQueue2 != 0 )\r
-    {\r
-        // Send a pointer to a struct AMessage object.  Don't block if the\r
-        // queue is already full.\r
-        pxMessage = & xMessage;\r
-        xQueueSend( xQueue2, ( void * ) &pxMessage, ( portTickType ) 0 );\r
-    }\r
+       // Create a queue capable of containing 10 unsigned long values.\r
+       xQueue1 = xQueueCreate( 10, sizeof( unsigned long ) );\r
+\r
+       // Create a queue capable of containing 10 pointers to AMessage structures.\r
+       // These should be passed by pointer as they contain a lot of data.\r
+       xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );\r
+\r
+       // ...\r
+\r
+       if( xQueue1 != 0 )\r
+       {\r
+               // Send an unsigned long.  Wait for 10 ticks for space to become\r
+               // available if necessary.\r
+               if( xQueueSend( xQueue1, ( void * ) &ulVar, ( portTickType ) 10 ) != pdPASS )\r
+               {\r
+                       // Failed to post the message, even after 10 ticks.\r
+               }\r
+       }\r
+\r
+       if( xQueue2 != 0 )\r
+       {\r
+               // Send a pointer to a struct AMessage object.  Don't block if the\r
+               // queue is already full.\r
+               pxMessage = & xMessage;\r
+               xQueueSend( xQueue2, ( void * ) &pxMessage, ( portTickType ) 0 );\r
+       }\r
 \r
        // ... Rest of task code.\r
  }\r
@@ -387,9 +411,9 @@ xQueueHandle xQueueCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBA
  *\r
  * @param xTicksToWait The maximum amount of time the task should block\r
  * waiting for space to become available on the queue, should it already\r
- * be full.  The call will return immediately if this is set to 0.  The\r
- * time is defined in tick periods so the constant portTICK_RATE_MS\r
- * should be used to convert to real time if this is required.\r
+ * be full.  The call will return immediately if this is set to 0 and the\r
+ * queue is full.  The time is defined in tick periods so the constant\r
+ * portTICK_RATE_MS should be used to convert to real time if this is required.\r
  *\r
  * @param xCopyPosition Can take the value queueSEND_TO_BACK to place the\r
  * item at the back of the queue, or queueSEND_TO_FRONT to place the item\r
@@ -401,43 +425,43 @@ xQueueHandle xQueueCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBA
    <pre>\r
  struct AMessage\r
  {\r
-    portCHAR ucMessageID;\r
-    portCHAR ucData[ 20 ];\r
+       char ucMessageID;\r
+       char ucData[ 20 ];\r
  } xMessage;\r
 \r
- unsigned portLONG ulVar = 10UL;\r
+ unsigned long ulVar = 10UL;\r
 \r
  void vATask( void *pvParameters )\r
  {\r
  xQueueHandle xQueue1, xQueue2;\r
  struct AMessage *pxMessage;\r
 \r
-    // Create a queue capable of containing 10 unsigned long values.\r
-    xQueue1 = xQueueCreate( 10, sizeof( unsigned portLONG ) );\r
-\r
-    // Create a queue capable of containing 10 pointers to AMessage structures.\r
-    // These should be passed by pointer as they contain a lot of data.\r
-    xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );\r
-\r
-    // ...\r
-\r
-    if( xQueue1 != 0 )\r
-    {\r
-        // Send an unsigned long.  Wait for 10 ticks for space to become\r
-        // available if necessary.\r
-        if( xQueueGenericSend( xQueue1, ( void * ) &ulVar, ( portTickType ) 10, queueSEND_TO_BACK ) != pdPASS )\r
-        {\r
-            // Failed to post the message, even after 10 ticks.\r
-        }\r
-    }\r
-\r
-    if( xQueue2 != 0 )\r
-    {\r
-        // Send a pointer to a struct AMessage object.  Don't block if the\r
-        // queue is already full.\r
-        pxMessage = & xMessage;\r
-        xQueueGenericSend( xQueue2, ( void * ) &pxMessage, ( portTickType ) 0, queueSEND_TO_BACK );\r
-    }\r
+       // Create a queue capable of containing 10 unsigned long values.\r
+       xQueue1 = xQueueCreate( 10, sizeof( unsigned long ) );\r
+\r
+       // Create a queue capable of containing 10 pointers to AMessage structures.\r
+       // These should be passed by pointer as they contain a lot of data.\r
+       xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );\r
+\r
+       // ...\r
+\r
+       if( xQueue1 != 0 )\r
+       {\r
+               // Send an unsigned long.  Wait for 10 ticks for space to become\r
+               // available if necessary.\r
+               if( xQueueGenericSend( xQueue1, ( void * ) &ulVar, ( portTickType ) 10, queueSEND_TO_BACK ) != pdPASS )\r
+               {\r
+                       // Failed to post the message, even after 10 ticks.\r
+               }\r
+       }\r
+\r
+       if( xQueue2 != 0 )\r
+       {\r
+               // Send a pointer to a struct AMessage object.  Don't block if the\r
+               // queue is already full.\r
+               pxMessage = & xMessage;\r
+               xQueueGenericSend( xQueue2, ( void * ) &pxMessage, ( portTickType ) 0, queueSEND_TO_BACK );\r
+       }\r
 \r
        // ... Rest of task code.\r
  }\r
@@ -445,16 +469,16 @@ xQueueHandle xQueueCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBA
  * \defgroup xQueueSend xQueueSend\r
  * \ingroup QueueManagement\r
  */\r
-signed portBASE_TYPE xQueueGenericSend( xQueueHandle xQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition );\r
+signed portBASE_TYPE xQueueGenericSend( xQueueHandle pxQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition );\r
 \r
 /**\r
  * queue. h\r
  * <pre>\r
  portBASE_TYPE xQueuePeek(\r
-                             xQueueHandle xQueue,\r
-                             void *pvBuffer,\r
-                             portTickType xTicksToWait\r
-                         );</pre>\r
+                                                        xQueueHandle xQueue,\r
+                                                        void *pvBuffer,\r
+                                                        portTickType xTicksToWait\r
+                                                );</pre>\r
  *\r
  * This is a macro that calls the xQueueGenericReceive() function.\r
  *\r
@@ -476,8 +500,10 @@ signed portBASE_TYPE xQueueGenericSend( xQueueHandle xQueue, const void * const
  *\r
  * @param xTicksToWait The maximum amount of time the task should block\r
  * waiting for an item to receive should the queue be empty at the time\r
- * of the call.    The time is defined in tick periods so the constant\r
+ * of the call.         The time is defined in tick periods so the constant\r
  * portTICK_RATE_MS should be used to convert to real time if this is required.\r
+ * xQueuePeek() will return immediately if xTicksToWait is 0 and the queue\r
+ * is empty.\r
  *\r
  * @return pdTRUE if an item was successfully received from the queue,\r
  * otherwise pdFALSE.\r
@@ -486,8 +512,8 @@ signed portBASE_TYPE xQueueGenericSend( xQueueHandle xQueue, const void * const
    <pre>\r
  struct AMessage\r
  {\r
-    portCHAR ucMessageID;\r
-    portCHAR ucData[ 20 ];\r
+       char ucMessageID;\r
+       char ucData[ 20 ];\r
  } xMessage;\r
 \r
  xQueueHandle xQueue;\r
@@ -497,20 +523,20 @@ signed portBASE_TYPE xQueueGenericSend( xQueueHandle xQueue, const void * const
  {\r
  struct AMessage *pxMessage;\r
 \r
-    // Create a queue capable of containing 10 pointers to AMessage structures.\r
-    // These should be passed by pointer as they contain a lot of data.\r
-    xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) );\r
-    if( xQueue == 0 )\r
-    {\r
-        // Failed to create the queue.\r
-    }\r
+       // Create a queue capable of containing 10 pointers to AMessage structures.\r
+       // These should be passed by pointer as they contain a lot of data.\r
+       xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) );\r
+       if( xQueue == 0 )\r
+       {\r
+               // Failed to create the queue.\r
+       }\r
 \r
-    // ...\r
+       // ...\r
 \r
-    // Send a pointer to a struct AMessage object.  Don't block if the\r
-    // queue is already full.\r
-    pxMessage = & xMessage;\r
-    xQueueSend( xQueue, ( void * ) &pxMessage, ( portTickType ) 0 );\r
+       // Send a pointer to a struct AMessage object.  Don't block if the\r
+       // queue is already full.\r
+       pxMessage = & xMessage;\r
+       xQueueSend( xQueue, ( void * ) &pxMessage, ( portTickType ) 0 );\r
 \r
        // ... Rest of task code.\r
  }\r
@@ -520,16 +546,16 @@ signed portBASE_TYPE xQueueGenericSend( xQueueHandle xQueue, const void * const
  {\r
  struct AMessage *pxRxedMessage;\r
 \r
-    if( xQueue != 0 )\r
-    {\r
-        // Peek a message on the created queue.  Block for 10 ticks if a\r
-        // message is not immediately available.\r
-        if( xQueuePeek( xQueue, &( pxRxedMessage ), ( portTickType ) 10 ) )\r
-        {\r
-            // pcRxedMessage now points to the struct AMessage variable posted\r
-            // by vATask, but the item still remains on the queue.\r
-        }\r
-    }\r
+       if( xQueue != 0 )\r
+       {\r
+               // Peek a message on the created queue.  Block for 10 ticks if a\r
+               // message is not immediately available.\r
+               if( xQueuePeek( xQueue, &( pxRxedMessage ), ( portTickType ) 10 ) )\r
+               {\r
+                       // pcRxedMessage now points to the struct AMessage variable posted\r
+                       // by vATask, but the item still remains on the queue.\r
+               }\r
+       }\r
 \r
        // ... Rest of task code.\r
  }\r
@@ -543,10 +569,10 @@ signed portBASE_TYPE xQueueGenericSend( xQueueHandle xQueue, const void * const
  * queue. h\r
  * <pre>\r
  portBASE_TYPE xQueueReceive(\r
-                                 xQueueHandle xQueue,\r
-                                 void *pvBuffer,\r
-                                 portTickType xTicksToWait\r
-                            );</pre>\r
+                                                                xQueueHandle xQueue,\r
+                                                                void *pvBuffer,\r
+                                                                portTickType xTicksToWait\r
+                                                       );</pre>\r
  *\r
  * This is a macro that calls the xQueueGenericReceive() function.\r
  *\r
@@ -567,8 +593,10 @@ signed portBASE_TYPE xQueueGenericSend( xQueueHandle xQueue, const void * const
  *\r
  * @param xTicksToWait The maximum amount of time the task should block\r
  * waiting for an item to receive should the queue be empty at the time\r
- * of the call.    The time is defined in tick periods so the constant\r
- * portTICK_RATE_MS should be used to convert to real time if this is required.\r
+ * of the call.         xQueueReceive() will return immediately if xTicksToWait\r
+ * is zero and the queue is empty.  The time is defined in tick periods so the\r
+ * constant portTICK_RATE_MS should be used to convert to real time if this is\r
+ * required.\r
  *\r
  * @return pdTRUE if an item was successfully received from the queue,\r
  * otherwise pdFALSE.\r
@@ -577,8 +605,8 @@ signed portBASE_TYPE xQueueGenericSend( xQueueHandle xQueue, const void * const
    <pre>\r
  struct AMessage\r
  {\r
-    portCHAR ucMessageID;\r
-    portCHAR ucData[ 20 ];\r
+       char ucMessageID;\r
+       char ucData[ 20 ];\r
  } xMessage;\r
 \r
  xQueueHandle xQueue;\r
@@ -588,20 +616,20 @@ signed portBASE_TYPE xQueueGenericSend( xQueueHandle xQueue, const void * const
  {\r
  struct AMessage *pxMessage;\r
 \r
-    // Create a queue capable of containing 10 pointers to AMessage structures.\r
-    // These should be passed by pointer as they contain a lot of data.\r
-    xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) );\r
-    if( xQueue == 0 )\r
-    {\r
-        // Failed to create the queue.\r
-    }\r
+       // Create a queue capable of containing 10 pointers to AMessage structures.\r
+       // These should be passed by pointer as they contain a lot of data.\r
+       xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) );\r
+       if( xQueue == 0 )\r
+       {\r
+               // Failed to create the queue.\r
+       }\r
 \r
-    // ...\r
+       // ...\r
 \r
-    // Send a pointer to a struct AMessage object.  Don't block if the\r
-    // queue is already full.\r
-    pxMessage = & xMessage;\r
-    xQueueSend( xQueue, ( void * ) &pxMessage, ( portTickType ) 0 );\r
+       // Send a pointer to a struct AMessage object.  Don't block if the\r
+       // queue is already full.\r
+       pxMessage = & xMessage;\r
+       xQueueSend( xQueue, ( void * ) &pxMessage, ( portTickType ) 0 );\r
 \r
        // ... Rest of task code.\r
  }\r
@@ -611,16 +639,16 @@ signed portBASE_TYPE xQueueGenericSend( xQueueHandle xQueue, const void * const
  {\r
  struct AMessage *pxRxedMessage;\r
 \r
-    if( xQueue != 0 )\r
-    {\r
-        // Receive a message on the created queue.  Block for 10 ticks if a\r
-        // message is not immediately available.\r
-        if( xQueueReceive( xQueue, &( pxRxedMessage ), ( portTickType ) 10 ) )\r
-        {\r
-            // pcRxedMessage now points to the struct AMessage variable posted\r
-            // by vATask.\r
-        }\r
-    }\r
+       if( xQueue != 0 )\r
+       {\r
+               // Receive a message on the created queue.  Block for 10 ticks if a\r
+               // message is not immediately available.\r
+               if( xQueueReceive( xQueue, &( pxRxedMessage ), ( portTickType ) 10 ) )\r
+               {\r
+                       // pcRxedMessage now points to the struct AMessage variable posted\r
+                       // by vATask.\r
+               }\r
+       }\r
 \r
        // ... Rest of task code.\r
  }\r
@@ -635,11 +663,11 @@ signed portBASE_TYPE xQueueGenericSend( xQueueHandle xQueue, const void * const
  * queue. h\r
  * <pre>\r
  portBASE_TYPE xQueueGenericReceive(\r
-                                       xQueueHandle xQueue,\r
-                                       void *pvBuffer,\r
-                                       portTickType xTicksToWait\r
-                                       portBASE_TYPE xJustPeek\r
-                                    );</pre>\r
+                                                                          xQueueHandle xQueue,\r
+                                                                          void *pvBuffer,\r
+                                                                          portTickType xTicksToWait\r
+                                                                          portBASE_TYPE        xJustPeek\r
+                                                                       );</pre>\r
  *\r
  * It is preferred that the macro xQueueReceive() be used rather than calling\r
  * this function directly.\r
@@ -659,8 +687,10 @@ signed portBASE_TYPE xQueueGenericSend( xQueueHandle xQueue, const void * const
  *\r
  * @param xTicksToWait The maximum amount of time the task should block\r
  * waiting for an item to receive should the queue be empty at the time\r
- * of the call.    The time is defined in tick periods so the constant\r
+ * of the call.         The time is defined in tick periods so the constant\r
  * portTICK_RATE_MS should be used to convert to real time if this is required.\r
+ * xQueueGenericReceive() will return immediately if the queue is empty and\r
+ * xTicksToWait is 0.\r
  *\r
  * @param xJustPeek When set to true, the item received from the queue is not\r
  * actually removed from the queue - meaning a subsequent call to\r
@@ -674,8 +704,8 @@ signed portBASE_TYPE xQueueGenericSend( xQueueHandle xQueue, const void * const
    <pre>\r
  struct AMessage\r
  {\r
-    portCHAR ucMessageID;\r
-    portCHAR ucData[ 20 ];\r
+       char ucMessageID;\r
+       char ucData[ 20 ];\r
  } xMessage;\r
 \r
  xQueueHandle xQueue;\r
@@ -685,20 +715,20 @@ signed portBASE_TYPE xQueueGenericSend( xQueueHandle xQueue, const void * const
  {\r
  struct AMessage *pxMessage;\r
 \r
-    // Create a queue capable of containing 10 pointers to AMessage structures.\r
-    // These should be passed by pointer as they contain a lot of data.\r
-    xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) );\r
-    if( xQueue == 0 )\r
-    {\r
-        // Failed to create the queue.\r
-    }\r
+       // Create a queue capable of containing 10 pointers to AMessage structures.\r
+       // These should be passed by pointer as they contain a lot of data.\r
+       xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) );\r
+       if( xQueue == 0 )\r
+       {\r
+               // Failed to create the queue.\r
+       }\r
 \r
-    // ...\r
+       // ...\r
 \r
-    // Send a pointer to a struct AMessage object.  Don't block if the\r
-    // queue is already full.\r
-    pxMessage = & xMessage;\r
-    xQueueSend( xQueue, ( void * ) &pxMessage, ( portTickType ) 0 );\r
+       // Send a pointer to a struct AMessage object.  Don't block if the\r
+       // queue is already full.\r
+       pxMessage = & xMessage;\r
+       xQueueSend( xQueue, ( void * ) &pxMessage, ( portTickType ) 0 );\r
 \r
        // ... Rest of task code.\r
  }\r
@@ -708,16 +738,16 @@ signed portBASE_TYPE xQueueGenericSend( xQueueHandle xQueue, const void * const
  {\r
  struct AMessage *pxRxedMessage;\r
 \r
-    if( xQueue != 0 )\r
-    {\r
-        // Receive a message on the created queue.  Block for 10 ticks if a\r
-        // message is not immediately available.\r
-        if( xQueueGenericReceive( xQueue, &( pxRxedMessage ), ( portTickType ) 10 ) )\r
-        {\r
-            // pcRxedMessage now points to the struct AMessage variable posted\r
-            // by vATask.\r
-        }\r
-    }\r
+       if( xQueue != 0 )\r
+       {\r
+               // Receive a message on the created queue.  Block for 10 ticks if a\r
+               // message is not immediately available.\r
+               if( xQueueGenericReceive( xQueue, &( pxRxedMessage ), ( portTickType ) 10 ) )\r
+               {\r
+                       // pcRxedMessage now points to the struct AMessage variable posted\r
+                       // by vATask.\r
+               }\r
+       }\r
 \r
        // ... Rest of task code.\r
  }\r
@@ -725,7 +755,7 @@ signed portBASE_TYPE xQueueGenericSend( xQueueHandle xQueue, const void * const
  * \defgroup xQueueReceive xQueueReceive\r
  * \ingroup QueueManagement\r
  */\r
-signed portBASE_TYPE xQueueGenericReceive( xQueueHandle xQueue, const void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeek );\r
+signed portBASE_TYPE xQueueGenericReceive( xQueueHandle xQueue, void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeek );\r
 \r
 /**\r
  * queue. h\r
@@ -754,16 +784,16 @@ unsigned portBASE_TYPE uxQueueMessagesWaiting( const xQueueHandle xQueue );
  * \page vQueueDelete vQueueDelete\r
  * \ingroup QueueManagement\r
  */\r
-void vQueueDelete( xQueueHandle xQueue );\r
+void vQueueDelete( xQueueHandle pxQueue );\r
 \r
 /**\r
  * queue. h\r
  * <pre>\r
  portBASE_TYPE xQueueSendToFrontFromISR(\r
-                                         xQueueHandle pxQueue,\r
-                                         const void *pvItemToQueue,\r
-                                         portBASE_TYPE xTaskPreviouslyWoken\r
-                                      );\r
+                                                                                xQueueHandle pxQueue,\r
+                                                                                const void *pvItemToQueue,\r
+                                                                                portBASE_TYPE *pxHigherPriorityTaskWoken\r
+                                                                         );\r
  </pre>\r
  *\r
  * This is a macro that calls xQueueGenericSendFromISR().\r
@@ -782,66 +812,59 @@ void vQueueDelete( xQueueHandle xQueue );
  * queue was created, so this many bytes will be copied from pvItemToQueue\r
  * into the queue storage area.\r
  *\r
- * @param cTaskPreviouslyWoken This is included so an ISR can post onto\r
- * the same queue multiple times from a single interrupt.  The first call\r
- * should always pass in pdFALSE.  Subsequent calls should pass in\r
- * the value returned from the previous call.  See the file serial .c in the\r
- * PC port for a good example of this mechanism.\r
+ * @param pxHigherPriorityTaskWoken xQueueSendToFrontFromISR() will set\r
+ * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task\r
+ * to unblock, and the unblocked task has a priority higher than the currently\r
+ * running task.  If xQueueSendToFromFromISR() sets this value to pdTRUE then\r
+ * a context switch should be requested before the interrupt is exited.\r
  *\r
- * @return pdTRUE if a task was woken by posting onto the queue.  This is\r
- * used by the ISR to determine if a context switch may be required following\r
- * the ISR.\r
+ * @return pdTRUE if the data was successfully sent to the queue, otherwise\r
+ * errQUEUE_FULL.\r
  *\r
  * Example usage for buffered IO (where the ISR can obtain more than one value\r
  * per call):\r
    <pre>\r
  void vBufferISR( void )\r
  {\r
- portCHAR cIn;\r
- portBASE_TYPE xTaskWokenByPost;\r
-\r
-    // We have not woken a task at the start of the ISR.\r
-    cTaskWokenByPost = pdFALSE;\r
-\r
-    // Loop until the buffer is empty.\r
-    do\r
-    {\r
-        // Obtain a byte from the buffer.\r
-        cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );                                           \r
-\r
-        // Post the byte.  The first time round the loop cTaskWokenByPost\r
-        // will be pdFALSE.  If the queue send causes a task to wake we do\r
-        // not want the task to run until we have finished the ISR, so\r
-        // xQueueSendFromISR does not cause a context switch.  Also we\r
-        // don't want subsequent posts to wake any other tasks, so we store\r
-        // the return value back into cTaskWokenByPost so xQueueSendFromISR\r
-        // knows not to wake any task the next iteration of the loop.\r
-        xTaskWokenByPost = xQueueSendToFrontFromISR( xRxQueue, &cIn, cTaskWokenByPost );\r
-\r
-    } while( portINPUT_BYTE( BUFFER_COUNT ) );\r
-\r
-    // Now the buffer is empty we can switch context if necessary.\r
-    if( cTaskWokenByPost )\r
-    {\r
-        taskYIELD ();\r
-    }\r
+ char cIn;\r
+ portBASE_TYPE xHigherPrioritTaskWoken;\r
+\r
+       // We have not woken a task at the start of the ISR.\r
+       xHigherPriorityTaskWoken = pdFALSE;\r
+\r
+       // Loop until the buffer is empty.\r
+       do\r
+       {\r
+               // Obtain a byte from the buffer.\r
+               cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );\r
+\r
+               // Post the byte.\r
+               xQueueSendToFrontFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );\r
+\r
+       } while( portINPUT_BYTE( BUFFER_COUNT ) );\r
+\r
+       // Now the buffer is empty we can switch context if necessary.\r
+       if( xHigherPriorityTaskWoken )\r
+       {\r
+               taskYIELD ();\r
+       }\r
  }\r
  </pre>\r
  *\r
  * \defgroup xQueueSendFromISR xQueueSendFromISR\r
  * \ingroup QueueManagement\r
  */\r
-#define xQueueSendToFrontFromISR( pxQueue, pvItemToQueue, xTaskPreviouslyWoken ) xQueueGenericSendFromISR( pxQueue, pvItemToQueue, xTaskPreviouslyWoken, queueSEND_TO_FRONT )\r
+#define xQueueSendToFrontFromISR( pxQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( pxQueue, pvItemToQueue, pxHigherPriorityTaskWoken, queueSEND_TO_FRONT )\r
 \r
 \r
 /**\r
  * queue. h\r
  * <pre>\r
  portBASE_TYPE xQueueSendToBackFromISR(\r
-                                         xQueueHandle pxQueue,\r
-                                         const void *pvItemToQueue,\r
-                                         portBASE_TYPE xTaskPreviouslyWoken\r
-                                      );\r
+                                                                                xQueueHandle pxQueue,\r
+                                                                                const void *pvItemToQueue,\r
+                                                                                portBASE_TYPE *pxHigherPriorityTaskWoken\r
+                                                                         );\r
  </pre>\r
  *\r
  * This is a macro that calls xQueueGenericSendFromISR().\r
@@ -860,66 +883,58 @@ void vQueueDelete( xQueueHandle xQueue );
  * queue was created, so this many bytes will be copied from pvItemToQueue\r
  * into the queue storage area.\r
  *\r
- * @param cTaskPreviouslyWoken This is included so an ISR can post onto\r
- * the same queue multiple times from a single interrupt.  The first call\r
- * should always pass in pdFALSE.  Subsequent calls should pass in\r
- * the value returned from the previous call.  See the file serial .c in the\r
- * PC port for a good example of this mechanism.\r
+ * @param pxHigherPriorityTaskWoken xQueueSendToBackFromISR() will set\r
+ * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task\r
+ * to unblock, and the unblocked task has a priority higher than the currently\r
+ * running task.  If xQueueSendToBackFromISR() sets this value to pdTRUE then\r
+ * a context switch should be requested before the interrupt is exited.\r
  *\r
- * @return pdTRUE if a task was woken by posting onto the queue.  This is\r
- * used by the ISR to determine if a context switch may be required following\r
- * the ISR.\r
+ * @return pdTRUE if the data was successfully sent to the queue, otherwise\r
+ * errQUEUE_FULL.\r
  *\r
  * Example usage for buffered IO (where the ISR can obtain more than one value\r
  * per call):\r
    <pre>\r
  void vBufferISR( void )\r
  {\r
- portCHAR cIn;\r
- portBASE_TYPE xTaskWokenByPost;\r
-\r
-    // We have not woken a task at the start of the ISR.\r
-    cTaskWokenByPost = pdFALSE;\r
-\r
-    // Loop until the buffer is empty.\r
-    do\r
-    {\r
-        // Obtain a byte from the buffer.\r
-        cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );                                           \r
-\r
-        // Post the byte.  The first time round the loop cTaskWokenByPost\r
-        // will be pdFALSE.  If the queue send causes a task to wake we do\r
-        // not want the task to run until we have finished the ISR, so\r
-        // xQueueSendFromISR does not cause a context switch.  Also we\r
-        // don't want subsequent posts to wake any other tasks, so we store\r
-        // the return value back into cTaskWokenByPost so xQueueSendFromISR\r
-        // knows not to wake any task the next iteration of the loop.\r
-        xTaskWokenByPost = xQueueSendToBackFromISR( xRxQueue, &cIn, cTaskWokenByPost );\r
-\r
-    } while( portINPUT_BYTE( BUFFER_COUNT ) );\r
-\r
-    // Now the buffer is empty we can switch context if necessary.\r
-    if( cTaskWokenByPost )\r
-    {\r
-        taskYIELD ();\r
-    }\r
+ char cIn;\r
+ portBASE_TYPE xHigherPriorityTaskWoken;\r
+\r
+       // We have not woken a task at the start of the ISR.\r
+       xHigherPriorityTaskWoken = pdFALSE;\r
+\r
+       // Loop until the buffer is empty.\r
+       do\r
+       {\r
+               // Obtain a byte from the buffer.\r
+               cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );\r
+\r
+               // Post the byte.\r
+               xQueueSendToBackFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );\r
+\r
+       } while( portINPUT_BYTE( BUFFER_COUNT ) );\r
+\r
+       // Now the buffer is empty we can switch context if necessary.\r
+       if( xHigherPriorityTaskWoken )\r
+       {\r
+               taskYIELD ();\r
+       }\r
  }\r
  </pre>\r
  *\r
  * \defgroup xQueueSendFromISR xQueueSendFromISR\r
  * \ingroup QueueManagement\r
  */\r
-#define xQueueSendToBackFromISR( pxQueue, pvItemToQueue, xTaskPreviouslyWoken ) xQueueGenericSendFromISR( pxQueue, pvItemToQueue, xTaskPreviouslyWoken, queueSEND_TO_BACK )\r
-\r
+#define xQueueSendToBackFromISR( pxQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( pxQueue, pvItemToQueue, pxHigherPriorityTaskWoken, queueSEND_TO_BACK )\r
 \r
 /**\r
  * queue. h\r
  * <pre>\r
  portBASE_TYPE xQueueSendFromISR(\r
-                                     xQueueHandle pxQueue,\r
-                                     const void *pvItemToQueue,\r
-                                     portBASE_TYPE xTaskPreviouslyWoken\r
-                                );\r
+                                                                        xQueueHandle pxQueue,\r
+                                                                        const void *pvItemToQueue,\r
+                                                                        portBASE_TYPE *pxHigherPriorityTaskWoken\r
+                                                               );\r
  </pre>\r
  *\r
  * This is a macro that calls xQueueGenericSendFromISR().  It is included\r
@@ -941,66 +956,60 @@ void vQueueDelete( xQueueHandle xQueue );
  * queue was created, so this many bytes will be copied from pvItemToQueue\r
  * into the queue storage area.\r
  *\r
- * @param cTaskPreviouslyWoken This is included so an ISR can post onto\r
- * the same queue multiple times from a single interrupt.  The first call\r
- * should always pass in pdFALSE.  Subsequent calls should pass in\r
- * the value returned from the previous call.  See the file serial .c in the\r
- * PC port for a good example of this mechanism.\r
+ * @param pxHigherPriorityTaskWoken xQueueSendFromISR() will set\r
+ * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task\r
+ * to unblock, and the unblocked task has a priority higher than the currently\r
+ * running task.  If xQueueSendFromISR() sets this value to pdTRUE then\r
+ * a context switch should be requested before the interrupt is exited.\r
  *\r
- * @return pdTRUE if a task was woken by posting onto the queue.  This is\r
- * used by the ISR to determine if a context switch may be required following\r
- * the ISR.\r
+ * @return pdTRUE if the data was successfully sent to the queue, otherwise\r
+ * errQUEUE_FULL.\r
  *\r
  * Example usage for buffered IO (where the ISR can obtain more than one value\r
  * per call):\r
    <pre>\r
  void vBufferISR( void )\r
  {\r
- portCHAR cIn;\r
- portBASE_TYPE xTaskWokenByPost;\r
-\r
-    // We have not woken a task at the start of the ISR.\r
-    cTaskWokenByPost = pdFALSE;\r
-\r
-    // Loop until the buffer is empty.\r
-    do\r
-    {\r
-        // Obtain a byte from the buffer.\r
-        cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );                                           \r
-\r
-        // Post the byte.  The first time round the loop cTaskWokenByPost\r
-        // will be pdFALSE.  If the queue send causes a task to wake we do\r
-        // not want the task to run until we have finished the ISR, so\r
-        // xQueueSendFromISR does not cause a context switch.  Also we\r
-        // don't want subsequent posts to wake any other tasks, so we store\r
-        // the return value back into cTaskWokenByPost so xQueueSendFromISR\r
-        // knows not to wake any task the next iteration of the loop.\r
-        xTaskWokenByPost = xQueueSendFromISR( xRxQueue, &cIn, cTaskWokenByPost );\r
-\r
-    } while( portINPUT_BYTE( BUFFER_COUNT ) );\r
-\r
-    // Now the buffer is empty we can switch context if necessary.\r
-    if( cTaskWokenByPost )\r
-    {\r
-        taskYIELD ();\r
-    }\r
+ char cIn;\r
+ portBASE_TYPE xHigherPriorityTaskWoken;\r
+\r
+       // We have not woken a task at the start of the ISR.\r
+       xHigherPriorityTaskWoken = pdFALSE;\r
+\r
+       // Loop until the buffer is empty.\r
+       do\r
+       {\r
+               // Obtain a byte from the buffer.\r
+               cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );\r
+\r
+               // Post the byte.\r
+               xQueueSendFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );\r
+\r
+       } while( portINPUT_BYTE( BUFFER_COUNT ) );\r
+\r
+       // Now the buffer is empty we can switch context if necessary.\r
+       if( xHigherPriorityTaskWoken )\r
+       {\r
+               // Actual macro used here is port specific.\r
+               taskYIELD_FROM_ISR ();\r
+       }\r
  }\r
  </pre>\r
  *\r
  * \defgroup xQueueSendFromISR xQueueSendFromISR\r
  * \ingroup QueueManagement\r
  */\r
-#define xQueueSendFromISR( pxQueue, pvItemToQueue, xTaskPreviouslyWoken ) xQueueGenericSendFromISR( pxQueue, pvItemToQueue, xTaskPreviouslyWoken, queueSEND_TO_BACK )\r
+#define xQueueSendFromISR( pxQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( pxQueue, pvItemToQueue, pxHigherPriorityTaskWoken, queueSEND_TO_BACK )\r
 \r
 /**\r
  * queue. h\r
  * <pre>\r
  portBASE_TYPE xQueueGenericSendFromISR(\r
-                                           xQueueHandle pxQueue,\r
-                                           const void *pvItemToQueue,\r
-                                           portBASE_TYPE xTaskPreviouslyWoken\r
-                                                                                  portBASE_TYPE xCopyPosition\r
-                                       );\r
+                                                                                  xQueueHandle pxQueue,\r
+                                                                                  const        void    *pvItemToQueue,\r
+                                                                                  portBASE_TYPE        *pxHigherPriorityTaskWoken,\r
+                                                                                  portBASE_TYPE        xCopyPosition\r
+                                                                          );\r
  </pre>\r
  *\r
  * It is preferred that the macros xQueueSendFromISR(),\r
@@ -1021,69 +1030,63 @@ void vQueueDelete( xQueueHandle xQueue );
  * queue was created, so this many bytes will be copied from pvItemToQueue\r
  * into the queue storage area.\r
  *\r
- * @param cTaskPreviouslyWoken This is included so an ISR can post onto\r
- * the same queue multiple times from a single interrupt.  The first call\r
- * should always pass in pdFALSE.  Subsequent calls should pass in\r
- * the value returned from the previous call.  See the file serial .c in the\r
- * PC port for a good example of this mechanism.\r
+ * @param pxHigherPriorityTaskWoken xQueueGenericSendFromISR() will set\r
+ * *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task\r
+ * to unblock, and the unblocked task has a priority higher than the currently\r
+ * running task.  If xQueueGenericSendFromISR() sets this value to pdTRUE then\r
+ * a context switch should be requested before the interrupt is exited.\r
  *\r
  * @param xCopyPosition Can take the value queueSEND_TO_BACK to place the\r
  * item at the back of the queue, or queueSEND_TO_FRONT to place the item\r
  * at the front of the queue (for high priority messages).\r
  *\r
- * @return pdTRUE if a task was woken by posting onto the queue.  This is\r
- * used by the ISR to determine if a context switch may be required following\r
- * the ISR.\r
+ * @return pdTRUE if the data was successfully sent to the queue, otherwise\r
+ * errQUEUE_FULL.\r
  *\r
  * Example usage for buffered IO (where the ISR can obtain more than one value\r
  * per call):\r
    <pre>\r
  void vBufferISR( void )\r
  {\r
- portCHAR cIn;\r
- portBASE_TYPE xTaskWokenByPost;\r
-\r
-    // We have not woken a task at the start of the ISR.\r
-    cTaskWokenByPost = pdFALSE;\r
-\r
-    // Loop until the buffer is empty.\r
-    do\r
-    {\r
-        // Obtain a byte from the buffer.\r
-        cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );                                           \r
-\r
-        // Post the byte.  The first time round the loop cTaskWokenByPost\r
-        // will be pdFALSE.  If the queue send causes a task to wake we do\r
-        // not want the task to run until we have finished the ISR, so\r
-        // xQueueSendFromISR does not cause a context switch.  Also we\r
-        // don't want subsequent posts to wake any other tasks, so we store\r
-        // the return value back into cTaskWokenByPost so xQueueSendFromISR\r
-        // knows not to wake any task the next iteration of the loop.\r
-        xTaskWokenByPost = xQueueGenericSendFromISR( xRxQueue, &cIn, cTaskWokenByPost, queueSEND_TO_BACK );\r
-\r
-    } while( portINPUT_BYTE( BUFFER_COUNT ) );\r
-\r
-    // Now the buffer is empty we can switch context if necessary.\r
-    if( cTaskWokenByPost )\r
-    {\r
-        taskYIELD ();\r
-    }\r
+ char cIn;\r
+ portBASE_TYPE xHigherPriorityTaskWokenByPost;\r
+\r
+       // We have not woken a task at the start of the ISR.\r
+       xHigherPriorityTaskWokenByPost = pdFALSE;\r
+\r
+       // Loop until the buffer is empty.\r
+       do\r
+       {\r
+               // Obtain a byte from the buffer.\r
+               cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );\r
+\r
+               // Post each byte.\r
+               xQueueGenericSendFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWokenByPost, queueSEND_TO_BACK );\r
+\r
+       } while( portINPUT_BYTE( BUFFER_COUNT ) );\r
+\r
+       // Now the buffer is empty we can switch context if necessary.  Note that the\r
+       // name of the yield function required is port specific.\r
+       if( xHigherPriorityTaskWokenByPost )\r
+       {\r
+               taskYIELD_YIELD_FROM_ISR();\r
+       }\r
  }\r
  </pre>\r
  *\r
  * \defgroup xQueueSendFromISR xQueueSendFromISR\r
  * \ingroup QueueManagement\r
  */\r
-signed portBASE_TYPE xQueueGenericSendFromISR( xQueueHandle pxQueue, const void * const pvItemToQueue, signed portBASE_TYPE xTaskPreviouslyWoken, portBASE_TYPE xCopyPosition );\r
+signed portBASE_TYPE xQueueGenericSendFromISR( xQueueHandle pxQueue, const void * const pvItemToQueue, signed portBASE_TYPE *pxHigherPriorityTaskWoken, portBASE_TYPE xCopyPosition );\r
 \r
 /**\r
  * queue. h\r
  * <pre>\r
  portBASE_TYPE xQueueReceiveFromISR(\r
-                                       xQueueHandle pxQueue,\r
-                                       void *pvBuffer,\r
-                                       portBASE_TYPE *pxTaskWoken\r
-                                   );\r
+                                                                          xQueueHandle pxQueue,\r
+                                                                          void *pvBuffer,\r
+                                                                          portBASE_TYPE        *pxTaskWoken\r
+                                                                  );\r
  * </pre>\r
  *\r
  * Receive an item from a queue.  It is safe to use this function from within an\r
@@ -1111,76 +1114,85 @@ signed portBASE_TYPE xQueueGenericSendFromISR( xQueueHandle pxQueue, const void
  // Function to create a queue and post some values.\r
  void vAFunction( void *pvParameters )\r
  {\r
portCHAR cValueToPost;\r
char cValueToPost;\r
  const portTickType xBlockTime = ( portTickType )0xff;\r
 \r
-    // Create a queue capable of containing 10 characters.\r
-    xQueue = xQueueCreate( 10, sizeof( portCHAR ) );\r
-    if( xQueue == 0 )\r
-    {\r
-        // Failed to create the queue.\r
-    }\r
+       // Create a queue capable of containing 10 characters.\r
+       xQueue = xQueueCreate( 10, sizeof( char ) );\r
+       if( xQueue == 0 )\r
+       {\r
+               // Failed to create the queue.\r
+       }\r
 \r
-    // ...\r
+       // ...\r
 \r
-    // Post some characters that will be used within an ISR.  If the queue\r
-    // is full then this task will block for xBlockTime ticks.\r
-    cValueToPost = 'a';\r
-    xQueueSend( xQueue, ( void * ) &cValueToPost, xBlockTime );\r
-    cValueToPost = 'b';\r
-    xQueueSend( xQueue, ( void * ) &cValueToPost, xBlockTime );\r
+       // Post some characters that will be used within an ISR.  If the queue\r
+       // is full then this task will block for xBlockTime ticks.\r
+       cValueToPost = 'a';\r
+       xQueueSend( xQueue, ( void * ) &cValueToPost, xBlockTime );\r
+       cValueToPost = 'b';\r
+       xQueueSend( xQueue, ( void * ) &cValueToPost, xBlockTime );\r
 \r
-    // ... keep posting characters ... this task may block when the queue\r
-    // becomes full.\r
+       // ... keep posting characters ... this task may block when the queue\r
+       // becomes full.\r
 \r
-    cValueToPost = 'c';\r
-    xQueueSend( xQueue, ( void * ) &cValueToPost, xBlockTime );\r
+       cValueToPost = 'c';\r
+       xQueueSend( xQueue, ( void * ) &cValueToPost, xBlockTime );\r
  }\r
 \r
  // ISR that outputs all the characters received on the queue.\r
  void vISR_Routine( void )\r
  {\r
  portBASE_TYPE xTaskWokenByReceive = pdFALSE;\r
portCHAR cRxedChar;\r
-\r
-    while( xQueueReceiveFromISR( xQueue, ( void * ) &cRxedChar, &xTaskWokenByReceive) )\r
-    {\r
-        // A character was received.  Output the character now.\r
-        vOutputCharacter( cRxedChar );\r
-\r
-        // If removing the character from the queue woke the task that was\r
-        // posting onto the queue cTaskWokenByReceive will have been set to\r
-        // pdTRUE.  No matter how many times this loop iterates only one\r
-        // task will be woken.\r
-    }\r
-\r
-    if( cTaskWokenByPost != ( portCHAR ) pdFALSE;\r
-    {\r
-        taskYIELD ();\r
-    }\r
char cRxedChar;\r
+\r
+       while( xQueueReceiveFromISR( xQueue, ( void * ) &cRxedChar, &xTaskWokenByReceive) )\r
+       {\r
+               // A character was received.  Output the character now.\r
+               vOutputCharacter( cRxedChar );\r
+\r
+               // If removing the character from the queue woke the task that was\r
+               // posting onto the queue cTaskWokenByReceive will have been set to\r
+               // pdTRUE.  No matter how many times this loop iterates only one\r
+               // task will be woken.\r
+       }\r
+\r
+       if( cTaskWokenByPost != ( char ) pdFALSE;\r
+       {\r
+               taskYIELD ();\r
+       }\r
  }\r
  </pre>\r
  * \defgroup xQueueReceiveFromISR xQueueReceiveFromISR\r
  * \ingroup QueueManagement\r
  */\r
-signed portBASE_TYPE xQueueReceiveFromISR( xQueueHandle pxQueue, const void * const pvBuffer, signed portBASE_TYPE *pxTaskWoken );\r
+signed portBASE_TYPE xQueueReceiveFromISR( xQueueHandle pxQueue, void * const pvBuffer, signed portBASE_TYPE *pxTaskWoken );\r
 \r
-/* \r
+/*\r
+ * Utilities to query queue that are safe to use from an ISR.  These utilities\r
+ * should be used only from witin an ISR, or within a critical section.\r
+ */\r
+signed portBASE_TYPE xQueueIsQueueEmptyFromISR( const xQueueHandle pxQueue );\r
+signed portBASE_TYPE xQueueIsQueueFullFromISR( const xQueueHandle pxQueue );\r
+unsigned portBASE_TYPE uxQueueMessagesWaitingFromISR( const xQueueHandle pxQueue );\r
+\r
+\r
+/*\r
  * xQueueAltGenericSend() is an alternative version of xQueueGenericSend().\r
  * Likewise xQueueAltGenericReceive() is an alternative version of\r
  * xQueueGenericReceive().\r
  *\r
- * The source code that implements the alternative (Alt) API is much \r
- * simpler     because it executes everything from within a critical section.  \r
- * This is     the approach taken by many other RTOSes, but FreeRTOS.org has the \r
- * preferred fully featured API too.  The fully featured API has more \r
- * complex     code that takes longer to execute, but makes much less use of \r
- * critical sections.  Therefore the alternative API sacrifices interrupt \r
+ * The source code that implements the alternative (Alt) API is much\r
+ * simpler     because it executes everything from within a critical section.\r
+ * This is     the approach taken by many other RTOSes, but FreeRTOS.org has the\r
+ * preferred fully featured API too.  The fully featured API has more\r
+ * complex     code that takes longer to execute, but makes much less use of\r
+ * critical sections.  Therefore the alternative API sacrifices interrupt\r
  * responsiveness to gain execution speed, whereas the fully featured API\r
  * sacrifices execution speed to ensure better interrupt responsiveness.\r
  */\r
 signed portBASE_TYPE xQueueAltGenericSend( xQueueHandle pxQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition );\r
-signed portBASE_TYPE xQueueAltGenericReceive( xQueueHandle pxQueue, const void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking );\r
+signed portBASE_TYPE xQueueAltGenericReceive( xQueueHandle pxQueue, void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking );\r
 #define xQueueAltSendToFront( xQueue, pvItemToQueue, xTicksToWait ) xQueueAltGenericSend( xQueue, pvItemToQueue, xTicksToWait, queueSEND_TO_FRONT )\r
 #define xQueueAltSendToBack( xQueue, pvItemToQueue, xTicksToWait ) xQueueAltGenericSend( xQueue, pvItemToQueue, xTicksToWait, queueSEND_TO_BACK )\r
 #define xQueueAltReceive( xQueue, pvBuffer, xTicksToWait ) xQueueAltGenericReceive( xQueue, pvBuffer, xTicksToWait, pdFALSE )\r
@@ -1211,8 +1223,35 @@ xQueueHandle xQueueCreateCountingSemaphore( unsigned portBASE_TYPE uxCountValue,
  * For internal use only.  Use xSemaphoreTakeMutexRecursive() or\r
  * xSemaphoreGiveMutexRecursive() instead of calling these functions directly.\r
  */\r
-portBASE_TYPE xQueueTakeMutexRecursive( xQueueHandle xMutex, portTickType xBlockTime );\r
-portBASE_TYPE xQueueGiveMutexRecursive( xQueueHandle xMutex );\r
+portBASE_TYPE xQueueTakeMutexRecursive( xQueueHandle pxMutex, portTickType xBlockTime );\r
+portBASE_TYPE xQueueGiveMutexRecursive( xQueueHandle pxMutex );\r
+\r
+/*\r
+ * The registry is provided as a means for kernel aware debuggers to\r
+ * locate queues, semaphores and mutexes.  Call vQueueAddToRegistry() add\r
+ * a queue, semaphore or mutex handle to the registry if you want the handle\r
+ * to be available to a kernel aware debugger.  If you are not using a kernel\r
+ * aware debugger then this function can be ignored.\r
+ *\r
+ * configQUEUE_REGISTRY_SIZE defines the maximum number of handles the\r
+ * registry can hold.  configQUEUE_REGISTRY_SIZE must be greater than 0\r
+ * within FreeRTOSConfig.h for the registry to be available.  Its value\r
+ * does not effect the number of queues, semaphores and mutexes that can be\r
+ * created - just the number that the registry can hold.\r
+ *\r
+ * @param xQueue The handle of the queue being added to the registry.  This\r
+ * is the handle returned by a call to xQueueCreate().  Semaphore and mutex\r
+ * handles can also be passed in here.\r
+ *\r
+ * @param pcName The name to be associated with the handle.  This is the\r
+ * name that the kernel aware debugger will display.\r
+ */\r
+#if configQUEUE_REGISTRY_SIZE > 0\r
+       void vQueueAddToRegistry( xQueueHandle xQueue, signed char *pcName );\r
+#endif\r
+\r
+\r
+\r
 \r
 #ifdef __cplusplus\r
 }\r