]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Source/queue.c
Update version number to V8.0.0 (without the release candidate number).
[freertos] / FreeRTOS / Source / queue.c
index f78591ad1159a9154350eac59dfbf0c37fe180e9..b571297254f92c1168bfead0d071cdcf8bcfa7c1 100644 (file)
@@ -1,45 +1,38 @@
 /*\r
-    FreeRTOS V7.3.0 - Copyright (C) 2012 Real Time Engineers Ltd.\r
+    FreeRTOS V8.0.0 - Copyright (C) 2014 Real Time Engineers Ltd.\r
+    All rights reserved\r
 \r
-    FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME.  PLEASE VISIT\r
-    http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
+    VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
 \r
     ***************************************************************************\r
      *                                                                       *\r
-     *    FreeRTOS tutorial books are available in pdf and paperback.        *\r
-     *    Complete, revised, and edited pdf reference manuals are also       *\r
-     *    available.                                                         *\r
+     *    FreeRTOS provides completely free yet professionally developed,    *\r
+     *    robust, strictly quality controlled, supported, and cross          *\r
+     *    platform software that has become a de facto standard.             *\r
      *                                                                       *\r
-     *    Purchasing FreeRTOS documentation will not only help you, by       *\r
-     *    ensuring you get running as quickly as possible and with an        *\r
-     *    in-depth knowledge of how to use FreeRTOS, it will also help       *\r
-     *    the FreeRTOS project to continue with its mission of providing     *\r
-     *    professional grade, cross platform, de facto standard solutions    *\r
-     *    for microcontrollers - completely free of charge!                  *\r
+     *    Help yourself get started quickly and support the FreeRTOS         *\r
+     *    project by purchasing a FreeRTOS tutorial book, reference          *\r
+     *    manual, or both from: http://www.FreeRTOS.org/Documentation        *\r
      *                                                                       *\r
-     *    >>> See http://www.FreeRTOS.org/Documentation for details. <<<     *\r
-     *                                                                       *\r
-     *    Thank you for using FreeRTOS, and thank you for your support!      *\r
+     *    Thank you!                                                         *\r
      *                                                                       *\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 modification to the GPL is included to allow you to\r
-    distribute a combined work that includes FreeRTOS without being obliged to\r
-    provide the source code for proprietary components outside of the FreeRTOS\r
-    kernel.  FreeRTOS is distributed in the hope that it will be useful, but\r
-    WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
-    or 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
+    Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
+\r
+    >>! NOTE: The modification to the GPL is included to allow you to distribute\r
+    >>! a combined work that includes FreeRTOS without being obliged to provide\r
+    >>! the source code for proprietary components outside of the FreeRTOS\r
+    >>! kernel.\r
+\r
+    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
+    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+    FOR A PARTICULAR PURPOSE.  Full license text is available from the following\r
+    link: http://www.freertos.org/a00114.html\r
 \r
     1 tab == 4 spaces!\r
 \r
      *                                                                       *\r
     ***************************************************************************\r
 \r
-\r
-    http://www.FreeRTOS.org - Documentation, training, latest versions, license\r
-    and contact details.\r
+    http://www.FreeRTOS.org - Documentation, books, training, latest versions,\r
+    license and Real Time Engineers Ltd. contact details.\r
 \r
     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
-    including FreeRTOS+Trace - an indispensable productivity tool.\r
+    including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
+    compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
+\r
+    http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High\r
+    Integrity Systems to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
+    licenses offer ticketed support, indemnification and middleware.\r
 \r
-    Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell\r
-    the code with commercial support, indemnification, and middleware, under\r
-    the OpenRTOS brand: http://www.OpenRTOS.com.  High Integrity Systems also\r
-    provide a safety engineered and independently SIL3 certified version under\r
-    the SafeRTOS brand: http://www.SafeRTOS.com.\r
+    http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
+    engineered and independently SIL3 certified version for use in safety and\r
+    mission critical applications that require provable dependability.\r
+\r
+    1 tab == 4 spaces!\r
 */\r
 \r
 #include <stdlib.h>\r
@@ -76,42 +73,50 @@ task.h is included from an application file. */
 \r
 #include "FreeRTOS.h"\r
 #include "task.h"\r
+#include "queue.h"\r
 \r
 #if ( configUSE_CO_ROUTINES == 1 )\r
        #include "croutine.h"\r
 #endif\r
 \r
-#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE\r
-\r
-/* Constants used with the cRxLock and xTxLock structure members. */\r
-#define queueUNLOCKED                                  ( ( signed portBASE_TYPE ) -1 )\r
-#define queueLOCKED_UNMODIFIED                 ( ( signed portBASE_TYPE ) 0 )\r
-\r
-#define queueERRONEOUS_UNBLOCK                 ( -1 )\r
-\r
-/* For internal use only. */\r
-#define        queueSEND_TO_BACK                               ( 0 )\r
-#define        queueSEND_TO_FRONT                              ( 1 )\r
-\r
-/* Effectively make a union out of the xQUEUE structure. */\r
+/* Lint e961 and e750 are suppressed as a MISRA exception justified because the\r
+MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be defined for the\r
+header files above, but not in this file, in order to generate the correct\r
+privileged Vs unprivileged linkage and placement. */\r
+#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750. */\r
+\r
+\r
+/* Constants used with the xRxLock and xTxLock structure members. */\r
+#define queueUNLOCKED                                  ( ( BaseType_t ) -1 )\r
+#define queueLOCKED_UNMODIFIED                 ( ( BaseType_t ) 0 )\r
+\r
+/* When the Queue_t structure is used to represent a base queue its pcHead and\r
+pcTail members are used as pointers into the queue storage area.  When the\r
+Queue_t structure is used to represent a mutex pcHead and pcTail pointers are\r
+not necessary, and the pcHead pointer is set to NULL to indicate that the\r
+pcTail pointer actually points to the mutex holder (if any).  Map alternative\r
+names to the pcHead and pcTail structure members to ensure the readability of\r
+the code is maintained despite this dual use of two structure members.  An\r
+alternative implementation would be to use a union, but use of a union is\r
+against the coding standard (although an exception to the standard has been\r
+permitted where the dual use also significantly changes the type of the\r
+structure member). */\r
 #define pxMutexHolder                                  pcTail\r
 #define uxQueueType                                            pcHead\r
-#define uxRecursiveCallCount                   pcReadFrom\r
 #define queueQUEUE_IS_MUTEX                            NULL\r
 \r
-/* Semaphores do not actually store or copy data, so have an items size of\r
+/* Semaphores do not actually store or copy data, so have an item size of\r
 zero. */\r
-#define queueSEMAPHORE_QUEUE_ITEM_LENGTH ( ( unsigned portBASE_TYPE ) 0 )\r
-#define queueDONT_BLOCK                                         ( ( portTickType ) 0U )\r
-#define queueMUTEX_GIVE_BLOCK_TIME              ( ( portTickType ) 0U )\r
-\r
-/* These definitions *must* match those in queue.h. */\r
-#define queueQUEUE_TYPE_BASE                           ( 0U )\r
-#define queueQUEUE_TYPE_MUTEX                          ( 1U )\r
-#define queueQUEUE_TYPE_COUNTING_SEMAPHORE     ( 2U )\r
-#define queueQUEUE_TYPE_BINARY_SEMAPHORE       ( 3U )\r
-#define queueQUEUE_TYPE_RECURSIVE_MUTEX                ( 4U )\r
-#define queueQUEUE_TYPE_SET                                    ( 0U )\r
+#define queueSEMAPHORE_QUEUE_ITEM_LENGTH ( ( UBaseType_t ) 0 )\r
+#define queueMUTEX_GIVE_BLOCK_TIME              ( ( TickType_t ) 0U )\r
+\r
+#if( configUSE_PREEMPTION == 0 )\r
+       /* If the cooperative scheduler is being used then a yield should not be\r
+       performed just because a higher priority task has been woken. */\r
+       #define queueYIELD_IF_USING_PREEMPTION()\r
+#else\r
+       #define queueYIELD_IF_USING_PREEMPTION() portYIELD_WITHIN_API()\r
+#endif\r
 \r
 /*\r
  * Definition of the queue used by the scheduler.\r
@@ -119,94 +124,38 @@ zero. */
  */\r
 typedef struct QueueDefinition\r
 {\r
-       signed char *pcHead;                                    /*< Points to the beginning of the queue storage area. */\r
-       signed char *pcTail;                                    /*< Points to the byte at the end of the queue storage area.  Once more byte is allocated than necessary to store the queue items, this is used as a marker. */\r
+       int8_t *pcHead;                                 /*< Points to the beginning of the queue storage area. */\r
+       int8_t *pcTail;                                 /*< Points to the byte at the end of the queue storage area.  Once more byte is allocated than necessary to store the queue items, this is used as a marker. */\r
+       int8_t *pcWriteTo;                              /*< Points to the free next place in the storage area. */\r
 \r
-       signed char *pcWriteTo;                                 /*< Points to the free next place in the storage area. */\r
-       signed char *pcReadFrom;                                /*< Points to the last place that a queued item was read from. */\r
+       union                                                   /* Use of a union is an exception to the coding standard to ensure two mutually exclusive structure members don't appear simultaneously (wasting RAM). */\r
+       {\r
+               int8_t *pcReadFrom;                     /*< Points to the last place that a queued item was read from when the structure is used as a queue. */\r
+               UBaseType_t uxRecursiveCallCount;/*< Maintains a count of the number of times a recursive mutex has been recursively 'taken' when the structure is used as a mutex. */\r
+       } u;\r
 \r
-       xList xTasksWaitingToSend;                              /*< List of tasks that are blocked waiting to post onto this queue.  Stored in priority order. */\r
-       xList xTasksWaitingToReceive;                   /*< List of tasks that are blocked waiting to read from this queue.  Stored in priority order. */\r
+       List_t xTasksWaitingToSend;             /*< List of tasks that are blocked waiting to post onto this queue.  Stored in priority order. */\r
+       List_t xTasksWaitingToReceive;  /*< List of tasks that are blocked waiting to read from this queue.  Stored in priority order. */\r
 \r
-       volatile unsigned portBASE_TYPE uxMessagesWaiting;/*< The number of items currently in the queue. */\r
-       unsigned portBASE_TYPE uxLength;                /*< The length of the queue defined as the number of items it will hold, not the number of bytes. */\r
-       unsigned portBASE_TYPE uxItemSize;              /*< The size of each items that the queue will hold. */\r
+       volatile UBaseType_t uxMessagesWaiting;/*< The number of items currently in the queue. */\r
+       UBaseType_t uxLength;                   /*< The length of the queue defined as the number of items it will hold, not the number of bytes. */\r
+       UBaseType_t uxItemSize;                 /*< The size of each items that the queue will hold. */\r
 \r
-       volatile signed portBASE_TYPE xRxLock;  /*< Stores the number of items received from the queue (removed from the queue) while the queue was locked.  Set to queueUNLOCKED when the queue is not locked. */\r
-       volatile signed portBASE_TYPE xTxLock;  /*< Stores the number of items transmitted to the queue (added to the queue) while the queue was locked.  Set to queueUNLOCKED when the queue is not locked. */\r
+       volatile BaseType_t xRxLock;    /*< Stores the number of items received from the queue (removed from the queue) while the queue was locked.  Set to queueUNLOCKED when the queue is not locked. */\r
+       volatile BaseType_t xTxLock;    /*< Stores the number of items transmitted to the queue (added to the queue) while the queue was locked.  Set to queueUNLOCKED when the queue is not locked. */\r
 \r
        #if ( configUSE_TRACE_FACILITY == 1 )\r
-               unsigned char ucQueueNumber;\r
-               unsigned char ucQueueType;\r
+               UBaseType_t uxQueueNumber;\r
+               uint8_t ucQueueType;\r
        #endif\r
 \r
        #if ( configUSE_QUEUE_SETS == 1 )\r
                struct QueueDefinition *pxQueueSetContainer;\r
        #endif\r
 \r
-} xQUEUE;\r
+} Queue_t;\r
 /*-----------------------------------------------------------*/\r
 \r
-/*\r
- * Inside this file xQueueHandle and xQueueSetHandle are both pointers to xQUEUE\r
- * structures.  To keep the definition private the API header file defines both\r
- * as pointers to void.\r
- */\r
-typedef xQUEUE * xQueueHandle;\r
-typedef xQUEUE * xQueueSetHandle;\r
-\r
-/**\r
- * Queue sets can contain both queues and semaphores, so the\r
- * xQueueSetMemberHandle is defined as a type to be used where a parameter or\r
- * return value can be either an xQueueHandle or an xSemaphoreHandle.\r
- */\r
-typedef xQUEUE * xQueueSetMemberHandle;\r
-\r
-/*\r
- * In order to implement strict data hiding, the queue.h header file defines\r
- * xQueueHandle and xQueueSetHandle as pointers to void.  In this file\r
- * xQueueHandle and xQueueSetHandle are defined as pointers to xQUEUE objects.\r
- * Therefore the queue.h header file cannot be included in this source file,\r
- * and the function prototypes are provided directly.\r
- */\r
-xQueueHandle xQueueGenericCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBASE_TYPE uxItemSize, unsigned char ucQueueType ) PRIVILEGED_FUNCTION;\r
-signed portBASE_TYPE xQueueGenericSend( xQueueHandle pxQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition ) PRIVILEGED_FUNCTION;\r
-unsigned portBASE_TYPE uxQueueMessagesWaiting( const xQueueHandle pxQueue ) PRIVILEGED_FUNCTION;\r
-void vQueueDelete( xQueueHandle xQueue ) PRIVILEGED_FUNCTION;\r
-signed portBASE_TYPE xQueueGenericSendFromISR( xQueueHandle pxQueue, const void * const pvItemToQueue, signed portBASE_TYPE *pxHigherPriorityTaskWoken, portBASE_TYPE xCopyPosition ) PRIVILEGED_FUNCTION;\r
-signed portBASE_TYPE xQueueGenericReceive( xQueueHandle pxQueue, void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking ) PRIVILEGED_FUNCTION;\r
-signed portBASE_TYPE xQueueReceiveFromISR( xQueueHandle pxQueue, void * const pvBuffer, signed portBASE_TYPE *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;\r
-xQueueHandle xQueueCreateMutex( unsigned char ucQueueType ) PRIVILEGED_FUNCTION;\r
-xQueueHandle xQueueCreateCountingSemaphore( unsigned portBASE_TYPE uxCountValue, unsigned portBASE_TYPE uxInitialCount ) PRIVILEGED_FUNCTION;\r
-portBASE_TYPE xQueueTakeMutexRecursive( xQueueHandle xMutex, portTickType xBlockTime ) PRIVILEGED_FUNCTION;\r
-portBASE_TYPE xQueueGiveMutexRecursive( xQueueHandle xMutex ) PRIVILEGED_FUNCTION;\r
-signed portBASE_TYPE xQueueAltGenericSend( xQueueHandle pxQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition ) PRIVILEGED_FUNCTION;\r
-signed portBASE_TYPE xQueueAltGenericReceive( xQueueHandle pxQueue, void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking ) PRIVILEGED_FUNCTION;\r
-signed portBASE_TYPE xQueueIsQueueEmptyFromISR( const xQueueHandle pxQueue ) PRIVILEGED_FUNCTION;\r
-signed portBASE_TYPE xQueueIsQueueFullFromISR( const xQueueHandle pxQueue ) PRIVILEGED_FUNCTION;\r
-unsigned portBASE_TYPE uxQueueMessagesWaitingFromISR( const xQueueHandle pxQueue ) PRIVILEGED_FUNCTION;\r
-void vQueueWaitForMessageRestricted( xQueueHandle pxQueue, portTickType xTicksToWait ) PRIVILEGED_FUNCTION;\r
-unsigned char ucQueueGetQueueNumber( xQueueHandle pxQueue ) PRIVILEGED_FUNCTION;\r
-void vQueueSetQueueNumber( xQueueHandle pxQueue, unsigned char ucQueueNumber ) PRIVILEGED_FUNCTION;\r
-unsigned char ucQueueGetQueueType( xQueueHandle pxQueue ) PRIVILEGED_FUNCTION;\r
-portBASE_TYPE xQueueGenericReset( xQueueHandle pxQueue, portBASE_TYPE xNewQueue ) PRIVILEGED_FUNCTION;\r
-xTaskHandle xQueueGetMutexHolder( xQueueHandle xSemaphore ) PRIVILEGED_FUNCTION;\r
-xQueueSetHandle xQueueCreateSet( unsigned portBASE_TYPE uxEventQueueLength ) PRIVILEGED_FUNCTION;\r
-xQueueSetMemberHandle xQueueSelectFromSet( xQueueSetHandle xQueueSet, portTickType xBlockTimeTicks ) PRIVILEGED_FUNCTION;\r
-portBASE_TYPE xQueueAddToSet( xQueueSetMemberHandle xQueueOrSemaphore, xQueueSetHandle xQueueSet ) PRIVILEGED_FUNCTION;\r
-portBASE_TYPE xQueueRemoveFromSet( xQueueSetMemberHandle xQueueOrSemaphore, xQueueSetHandle xQueueSet ) PRIVILEGED_FUNCTION;\r
-\r
-/*\r
- * Co-routine queue functions differ from task queue functions.  Co-routines are\r
- * an optional component.\r
- */\r
-#if ( configUSE_CO_ROUTINES == 1 )\r
-       signed portBASE_TYPE xQueueCRSendFromISR( xQueueHandle pxQueue, const void *pvItemToQueue, signed portBASE_TYPE xCoRoutinePreviouslyWoken ) PRIVILEGED_FUNCTION;\r
-       signed portBASE_TYPE xQueueCRReceiveFromISR( xQueueHandle pxQueue, void *pvBuffer, signed portBASE_TYPE *pxTaskWoken ) PRIVILEGED_FUNCTION;\r
-       signed portBASE_TYPE xQueueCRSend( xQueueHandle pxQueue, const void *pvItemToQueue, portTickType xTicksToWait ) PRIVILEGED_FUNCTION;\r
-       signed portBASE_TYPE xQueueCRReceive( xQueueHandle pxQueue, void *pvBuffer, portTickType xTicksToWait ) PRIVILEGED_FUNCTION;\r
-#endif\r
-\r
 /*\r
  * The queue registry is just a means for kernel aware debuggers to locate\r
  * queue structures.  It has no other purpose so is an optional component.\r
@@ -218,20 +167,16 @@ portBASE_TYPE xQueueRemoveFromSet( xQueueSetMemberHandle xQueueOrSemaphore, xQue
        more user friendly. */\r
        typedef struct QUEUE_REGISTRY_ITEM\r
        {\r
-               signed char *pcQueueName;\r
-               xQueueHandle xHandle;\r
-       } xQueueRegistryItem;\r
+               const char *pcQueueName; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
+               QueueHandle_t xHandle;\r
+       } QueueRegistryItem_t;\r
 \r
-       /* The queue registry is simply an array of xQueueRegistryItem structures.\r
+       /* The queue registry is simply an array of QueueRegistryItem_t structures.\r
        The pcQueueName member of a structure being NULL is indicative of the\r
        array position being vacant. */\r
-       xQueueRegistryItem xQueueRegistry[ configQUEUE_REGISTRY_SIZE ];\r
+       QueueRegistryItem_t xQueueRegistry[ configQUEUE_REGISTRY_SIZE ];\r
 \r
-       /* Removes a queue from the registry by simply setting the pcQueueName\r
-       member to NULL. */\r
-       static void vQueueUnregisterQueue( xQueueHandle xQueue ) PRIVILEGED_FUNCTION;\r
-       void vQueueAddToRegistry( xQueueHandle xQueue, signed char *pcQueueName ) PRIVILEGED_FUNCTION;\r
-#endif\r
+#endif /* configQUEUE_REGISTRY_SIZE */\r
 \r
 /*\r
  * Unlocks a queue locked by a call to prvLockQueue.  Locking a queue does not\r
@@ -241,39 +186,39 @@ portBASE_TYPE xQueueRemoveFromSet( xQueueSetMemberHandle xQueueOrSemaphore, xQue
  * to indicate that a task may require unblocking.  When the queue in unlocked\r
  * these lock counts are inspected, and the appropriate action taken.\r
  */\r
-static void prvUnlockQueue( xQueueHandle pxQueue ) PRIVILEGED_FUNCTION;\r
+static void prvUnlockQueue( Queue_t * const pxQueue ) PRIVILEGED_FUNCTION;\r
 \r
 /*\r
  * Uses a critical section to determine if there is any data in a queue.\r
  *\r
  * @return pdTRUE if the queue contains no items, otherwise pdFALSE.\r
  */\r
-static signed portBASE_TYPE prvIsQueueEmpty( const xQueueHandle pxQueue ) PRIVILEGED_FUNCTION;\r
+static BaseType_t prvIsQueueEmpty( const Queue_t *pxQueue ) PRIVILEGED_FUNCTION;\r
 \r
 /*\r
  * Uses a critical section to determine if there is any space in a queue.\r
  *\r
  * @return pdTRUE if there is no space, otherwise pdFALSE;\r
  */\r
-static signed portBASE_TYPE prvIsQueueFull( const xQueueHandle pxQueue ) PRIVILEGED_FUNCTION;\r
+static BaseType_t prvIsQueueFull( const Queue_t *pxQueue ) PRIVILEGED_FUNCTION;\r
 \r
 /*\r
  * Copies an item into the queue, either at the front of the queue or the\r
  * back of the queue.\r
  */\r
-static void prvCopyDataToQueue( xQUEUE *pxQueue, const void *pvItemToQueue, portBASE_TYPE xPosition ) PRIVILEGED_FUNCTION;\r
+static void prvCopyDataToQueue( Queue_t * const pxQueue, const void *pvItemToQueue, const BaseType_t xPosition ) PRIVILEGED_FUNCTION;\r
 \r
 /*\r
  * Copies an item out of a queue.\r
  */\r
-static void prvCopyDataFromQueue( xQUEUE * const pxQueue, const void *pvBuffer ) PRIVILEGED_FUNCTION;\r
+static void prvCopyDataFromQueue( Queue_t * const pxQueue, void * const pvBuffer ) PRIVILEGED_FUNCTION;\r
 \r
 #if ( configUSE_QUEUE_SETS == 1 )\r
        /*\r
         * Checks to see if a queue is a member of a queue set, and if so, notifies\r
         * the queue set that the queue contains data.\r
         */\r
-       static portBASE_TYPE prvNotifyQueueSetContainer( xQUEUE *pxQueue, portBASE_TYPE xCopyPosition );\r
+       static BaseType_t prvNotifyQueueSetContainer( const Queue_t * const pxQueue, const BaseType_t xCopyPosition ) PRIVILEGED_FUNCTION;\r
 #endif\r
 \r
 /*-----------------------------------------------------------*/\r
@@ -297,16 +242,18 @@ static void prvCopyDataFromQueue( xQUEUE * const pxQueue, const void *pvBuffer )
        taskEXIT_CRITICAL()\r
 /*-----------------------------------------------------------*/\r
 \r
-portBASE_TYPE xQueueGenericReset( xQueueHandle pxQueue, portBASE_TYPE xNewQueue )\r
+BaseType_t xQueueGenericReset( QueueHandle_t xQueue, BaseType_t xNewQueue )\r
 {\r
+Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
+\r
        configASSERT( pxQueue );\r
 \r
        taskENTER_CRITICAL();\r
        {\r
                pxQueue->pcTail = pxQueue->pcHead + ( pxQueue->uxLength * pxQueue->uxItemSize );\r
-               pxQueue->uxMessagesWaiting = ( unsigned portBASE_TYPE ) 0U;\r
+               pxQueue->uxMessagesWaiting = ( UBaseType_t ) 0U;\r
                pxQueue->pcWriteTo = pxQueue->pcHead;\r
-               pxQueue->pcReadFrom = pxQueue->pcHead + ( ( pxQueue->uxLength - ( unsigned portBASE_TYPE ) 1U ) * pxQueue->uxItemSize );\r
+               pxQueue->u.pcReadFrom = pxQueue->pcHead + ( ( pxQueue->uxLength - ( UBaseType_t ) 1U ) * pxQueue->uxItemSize );\r
                pxQueue->xRxLock = queueUNLOCKED;\r
                pxQueue->xTxLock = queueUNLOCKED;\r
 \r
@@ -314,16 +261,24 @@ portBASE_TYPE xQueueGenericReset( xQueueHandle pxQueue, portBASE_TYPE xNewQueue
                {\r
                        /* If there are tasks blocked waiting to read from the queue, then\r
                        the tasks will remain blocked as after this function exits the queue\r
-                       will still be empty.  If there are tasks blocked waiting to     write to\r
+                       will still be empty.  If there are tasks blocked waiting to write to\r
                        the queue, then one should be unblocked as after this function exits\r
                        it will be possible to write to it. */\r
                        if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )\r
                        {\r
                                if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) == pdTRUE )\r
                                {\r
-                                       portYIELD_WITHIN_API();\r
+                                       queueYIELD_IF_USING_PREEMPTION();\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
                                }\r
                        }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
                }\r
                else\r
                {\r
@@ -340,34 +295,34 @@ portBASE_TYPE xQueueGenericReset( xQueueHandle pxQueue, portBASE_TYPE xNewQueue
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-xQueueHandle xQueueGenericCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBASE_TYPE uxItemSize, unsigned char ucQueueType )\r
+QueueHandle_t xQueueGenericCreate( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, const uint8_t ucQueueType )\r
 {\r
-xQUEUE *pxNewQueue;\r
+Queue_t *pxNewQueue;\r
 size_t xQueueSizeInBytes;\r
-xQueueHandle xReturn = NULL;\r
+QueueHandle_t xReturn = NULL;\r
 \r
        /* Remove compiler warnings about unused parameters should\r
        configUSE_TRACE_FACILITY not be set to 1. */\r
        ( void ) ucQueueType;\r
 \r
        /* Allocate the new queue structure. */\r
-       if( uxQueueLength > ( unsigned portBASE_TYPE ) 0 )\r
+       if( uxQueueLength > ( UBaseType_t ) 0 )\r
        {\r
-               pxNewQueue = ( xQUEUE * ) pvPortMalloc( sizeof( xQUEUE ) );\r
+               pxNewQueue = ( Queue_t * ) pvPortMalloc( sizeof( Queue_t ) );\r
                if( pxNewQueue != NULL )\r
                {\r
                        /* Create the list of pointers to queue items.  The queue is one byte\r
                        longer than asked for to make wrap checking easier/faster. */\r
-                       xQueueSizeInBytes = ( size_t ) ( uxQueueLength * uxItemSize ) + ( size_t ) 1;\r
+                       xQueueSizeInBytes = ( size_t ) ( uxQueueLength * uxItemSize ) + ( size_t ) 1; /*lint !e961 MISRA exception as the casts are only redundant for some ports. */\r
 \r
-                       pxNewQueue->pcHead = ( signed char * ) pvPortMalloc( xQueueSizeInBytes );\r
+                       pxNewQueue->pcHead = ( int8_t * ) pvPortMalloc( xQueueSizeInBytes );\r
                        if( pxNewQueue->pcHead != NULL )\r
                        {\r
                                /* Initialise the queue members as described above where the\r
                                queue type is defined. */\r
                                pxNewQueue->uxLength = uxQueueLength;\r
                                pxNewQueue->uxItemSize = uxItemSize;\r
-                               xQueueGenericReset( pxNewQueue, pdTRUE );\r
+                               ( void ) xQueueGenericReset( pxNewQueue, pdTRUE );\r
 \r
                                #if ( configUSE_TRACE_FACILITY == 1 )\r
                                {\r
@@ -390,6 +345,14 @@ xQueueHandle xReturn = NULL;
                                vPortFree( pxNewQueue );\r
                        }\r
                }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
+       }\r
+       else\r
+       {\r
+               mtCOVERAGE_TEST_MARKER();\r
        }\r
 \r
        configASSERT( xReturn );\r
@@ -400,16 +363,16 @@ xQueueHandle xReturn = NULL;
 \r
 #if ( configUSE_MUTEXES == 1 )\r
 \r
-       xQueueHandle xQueueCreateMutex( unsigned char ucQueueType )\r
+       QueueHandle_t xQueueCreateMutex( const uint8_t ucQueueType )\r
        {\r
-       xQUEUE *pxNewQueue;\r
+       Queue_t *pxNewQueue;\r
 \r
                /* Prevent compiler warnings about unused parameters if\r
                configUSE_TRACE_FACILITY does not equal 1. */\r
                ( void ) ucQueueType;\r
 \r
                /* Allocate the new queue structure. */\r
-               pxNewQueue = ( xQUEUE * ) pvPortMalloc( sizeof( xQUEUE ) );\r
+               pxNewQueue = ( Queue_t * ) pvPortMalloc( sizeof( Queue_t ) );\r
                if( pxNewQueue != NULL )\r
                {\r
                        /* Information required for priority inheritance. */\r
@@ -419,14 +382,14 @@ xQueueHandle xReturn = NULL;
                        /* Queues used as a mutex no data is actually copied into or out\r
                        of the queue. */\r
                        pxNewQueue->pcWriteTo = NULL;\r
-                       pxNewQueue->pcReadFrom = NULL;\r
+                       pxNewQueue->u.pcReadFrom = NULL;\r
 \r
                        /* Each mutex has a length of 1 (like a binary semaphore) and\r
                        an item size of 0 as nothing is actually copied into or out\r
                        of the mutex. */\r
-                       pxNewQueue->uxMessagesWaiting = ( unsigned portBASE_TYPE ) 0U;\r
-                       pxNewQueue->uxLength = ( unsigned portBASE_TYPE ) 1U;\r
-                       pxNewQueue->uxItemSize = ( unsigned portBASE_TYPE ) 0U;\r
+                       pxNewQueue->uxMessagesWaiting = ( UBaseType_t ) 0U;\r
+                       pxNewQueue->uxLength = ( UBaseType_t ) 1U;\r
+                       pxNewQueue->uxItemSize = ( UBaseType_t ) 0U;\r
                        pxNewQueue->xRxLock = queueUNLOCKED;\r
                        pxNewQueue->xTxLock = queueUNLOCKED;\r
 \r
@@ -449,7 +412,7 @@ xQueueHandle xReturn = NULL;
                        traceCREATE_MUTEX( pxNewQueue );\r
 \r
                        /* Start with the semaphore in the expected state. */\r
-                       xQueueGenericSend( pxNewQueue, NULL, ( portTickType ) 0U, queueSEND_TO_BACK );\r
+                       ( void ) xQueueGenericSend( pxNewQueue, NULL, ( TickType_t ) 0U, queueSEND_TO_BACK );\r
                }\r
                else\r
                {\r
@@ -465,20 +428,20 @@ xQueueHandle xReturn = NULL;
 \r
 #if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xSemaphoreGetMutexHolder == 1 ) )\r
 \r
-       void* xQueueGetMutexHolder( xQueueHandle xSemaphore )\r
+       void* xQueueGetMutexHolder( QueueHandle_t xSemaphore )\r
        {\r
        void *pxReturn;\r
 \r
                /* This function is called by xSemaphoreGetMutexHolder(), and should not\r
-               be called directly.  Note:  This is is a good way of determining if the\r
+               be called directly.  Note:  This is a good way of determining if the\r
                calling task is the mutex holder, but not a good way of determining the\r
                identity of the mutex holder, as the holder may change between the\r
                following critical section exiting and the function returning. */\r
                taskENTER_CRITICAL();\r
                {\r
-                       if( xSemaphore->uxQueueType == queueQUEUE_IS_MUTEX )\r
+                       if( ( ( Queue_t * ) xSemaphore )->uxQueueType == queueQUEUE_IS_MUTEX )\r
                        {\r
-                               pxReturn = ( void * ) xSemaphore->pxMutexHolder;\r
+                               pxReturn = ( void * ) ( ( Queue_t * ) xSemaphore )->pxMutexHolder;\r
                        }\r
                        else\r
                        {\r
@@ -495,9 +458,10 @@ xQueueHandle xReturn = NULL;
 \r
 #if ( configUSE_RECURSIVE_MUTEXES == 1 )\r
 \r
-       portBASE_TYPE xQueueGiveMutexRecursive( xQueueHandle pxMutex )\r
+       BaseType_t xQueueGiveMutexRecursive( QueueHandle_t xMutex )\r
        {\r
-       portBASE_TYPE xReturn;\r
+       BaseType_t xReturn;\r
+       Queue_t * const pxMutex = ( Queue_t * ) xMutex;\r
 \r
                configASSERT( pxMutex );\r
 \r
@@ -507,7 +471,7 @@ xQueueHandle xReturn = NULL;
                this is the only condition we are interested in it does not matter if\r
                pxMutexHolder is accessed simultaneously by another task.  Therefore no\r
                mutual exclusion is required to test the pxMutexHolder variable. */\r
-               if( pxMutex->pxMutexHolder == xTaskGetCurrentTaskHandle() )\r
+               if( pxMutex->pxMutexHolder == ( void * ) xTaskGetCurrentTaskHandle() ) /*lint !e961 Not a redundant cast as TaskHandle_t is a typedef. */\r
                {\r
                        traceGIVE_MUTEX_RECURSIVE( pxMutex );\r
 \r
@@ -516,14 +480,18 @@ xQueueHandle xReturn = NULL;
                        uxRecursiveCallCount is only modified by the mutex holder, and as\r
                        there can only be one, no mutual exclusion is required to modify the\r
                        uxRecursiveCallCount member. */\r
-                       ( pxMutex->uxRecursiveCallCount )--;\r
+                       ( pxMutex->u.uxRecursiveCallCount )--;\r
 \r
                        /* Have we unwound the call count? */\r
-                       if( pxMutex->uxRecursiveCallCount == 0 )\r
+                       if( pxMutex->u.uxRecursiveCallCount == ( UBaseType_t ) 0 )\r
                        {\r
                                /* Return the mutex.  This will automatically unblock any other\r
                                task that might be waiting to access the mutex. */\r
-                               xQueueGenericSend( pxMutex, NULL, queueMUTEX_GIVE_BLOCK_TIME, queueSEND_TO_BACK );\r
+                               ( void ) xQueueGenericSend( pxMutex, NULL, queueMUTEX_GIVE_BLOCK_TIME, queueSEND_TO_BACK );\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
                        }\r
 \r
                        xReturn = pdPASS;\r
@@ -544,9 +512,10 @@ xQueueHandle xReturn = NULL;
 \r
 #if ( configUSE_RECURSIVE_MUTEXES == 1 )\r
 \r
-       portBASE_TYPE xQueueTakeMutexRecursive( xQueueHandle pxMutex, portTickType xBlockTime )\r
+       BaseType_t xQueueTakeMutexRecursive( QueueHandle_t xMutex, TickType_t xTicksToWait )\r
        {\r
-       portBASE_TYPE xReturn;\r
+       BaseType_t xReturn;\r
+       Queue_t * const pxMutex = ( Queue_t * ) xMutex;\r
 \r
                configASSERT( pxMutex );\r
 \r
@@ -555,20 +524,20 @@ xQueueHandle xReturn = NULL;
 \r
                traceTAKE_MUTEX_RECURSIVE( pxMutex );\r
 \r
-               if( pxMutex->pxMutexHolder == xTaskGetCurrentTaskHandle() )\r
+               if( pxMutex->pxMutexHolder == ( void * ) xTaskGetCurrentTaskHandle() ) /*lint !e961 Cast is not redundant as TaskHandle_t is a typedef. */\r
                {\r
-                       ( pxMutex->uxRecursiveCallCount )++;\r
+                       ( pxMutex->u.uxRecursiveCallCount )++;\r
                        xReturn = pdPASS;\r
                }\r
                else\r
                {\r
-                       xReturn = xQueueGenericReceive( pxMutex, NULL, xBlockTime, pdFALSE );\r
+                       xReturn = xQueueGenericReceive( pxMutex, NULL, xTicksToWait, pdFALSE );\r
 \r
                        /* pdPASS will only be returned if we successfully obtained the mutex,\r
                        we may have blocked to reach here. */\r
                        if( xReturn == pdPASS )\r
                        {\r
-                               ( pxMutex->uxRecursiveCallCount )++;\r
+                               ( pxMutex->u.uxRecursiveCallCount )++;\r
                        }\r
                        else\r
                        {\r
@@ -584,15 +553,18 @@ xQueueHandle xReturn = NULL;
 \r
 #if ( configUSE_COUNTING_SEMAPHORES == 1 )\r
 \r
-       xQueueHandle xQueueCreateCountingSemaphore( unsigned portBASE_TYPE uxCountValue, unsigned portBASE_TYPE uxInitialCount )\r
+       QueueHandle_t xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount )\r
        {\r
-       xQueueHandle pxHandle;\r
+       QueueHandle_t xHandle;\r
+\r
+               configASSERT( uxMaxCount != 0 );\r
+               configASSERT( uxInitialCount <= uxMaxCount );\r
 \r
-               pxHandle = xQueueGenericCreate( ( unsigned portBASE_TYPE ) uxCountValue, queueSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_COUNTING_SEMAPHORE );\r
+               xHandle = xQueueGenericCreate( uxMaxCount, queueSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_COUNTING_SEMAPHORE );\r
 \r
-               if( pxHandle != NULL )\r
+               if( xHandle != NULL )\r
                {\r
-                       pxHandle->uxMessagesWaiting = uxInitialCount;\r
+                       ( ( Queue_t * ) xHandle )->uxMessagesWaiting = uxInitialCount;\r
 \r
                        traceCREATE_COUNTING_SEMAPHORE();\r
                }\r
@@ -601,20 +573,28 @@ xQueueHandle xReturn = NULL;
                        traceCREATE_COUNTING_SEMAPHORE_FAILED();\r
                }\r
 \r
-               configASSERT( pxHandle );\r
-               return pxHandle;\r
+               configASSERT( xHandle );\r
+               return xHandle;\r
        }\r
 \r
 #endif /* configUSE_COUNTING_SEMAPHORES */\r
 /*-----------------------------------------------------------*/\r
 \r
-signed portBASE_TYPE xQueueGenericSend( xQueueHandle pxQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition )\r
+BaseType_t xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQueue, TickType_t xTicksToWait, const BaseType_t xCopyPosition )\r
 {\r
-signed portBASE_TYPE xEntryTimeSet = pdFALSE;\r
-xTimeOutType xTimeOut;\r
+BaseType_t xEntryTimeSet = pdFALSE;\r
+TimeOut_t xTimeOut;\r
+Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
 \r
        configASSERT( pxQueue );\r
-       configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( unsigned portBASE_TYPE ) 0U ) ) );\r
+       configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) );\r
+       configASSERT( !( ( xCopyPosition == queueOVERWRITE ) && ( pxQueue->uxLength != 1 ) ) );\r
+       #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )\r
+       {\r
+               configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) );\r
+       }\r
+       #endif\r
+\r
 \r
        /* This function relaxes the coding standard somewhat to allow return\r
        statements within the function itself.  This is done in the interest\r
@@ -623,9 +603,11 @@ xTimeOutType xTimeOut;
        {\r
                taskENTER_CRITICAL();\r
                {\r
-                       /* Is there room on the queue now?  To be running we must be\r
-                       the highest priority task wanting to access the queue. */\r
-                       if( pxQueue->uxMessagesWaiting < pxQueue->uxLength )\r
+                       /* Is there room on the queue now?  The running task must be\r
+                       the highest priority task wanting to access the queue.  If\r
+                       the head item in the queue is to be overwritten then it does\r
+                       not matter if the queue is full. */\r
+                       if( ( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) || ( xCopyPosition == queueOVERWRITE ) )\r
                        {\r
                                traceQUEUE_SEND( pxQueue );\r
                                prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition );\r
@@ -639,7 +621,11 @@ xTimeOutType xTimeOut;
                                                        /* The queue is a member of a queue set, and posting\r
                                                        to the queue set caused a higher priority task to\r
                                                        unblock. A context switch is required. */\r
-                                                       portYIELD_WITHIN_API();\r
+                                                       queueYIELD_IF_USING_PREEMPTION();\r
+                                               }\r
+                                               else\r
+                                               {\r
+                                                       mtCOVERAGE_TEST_MARKER();\r
                                                }\r
                                        }\r
                                        else\r
@@ -654,9 +640,17 @@ xTimeOutType xTimeOut;
                                                                our own so yield immediately.  Yes it is ok to\r
                                                                do this from within the critical section - the\r
                                                                kernel takes care of that. */\r
-                                                               portYIELD_WITHIN_API();\r
+                                                               queueYIELD_IF_USING_PREEMPTION();\r
+                                                       }\r
+                                                       else\r
+                                                       {\r
+                                                               mtCOVERAGE_TEST_MARKER();\r
                                                        }\r
                                                }\r
+                                               else\r
+                                               {\r
+                                                       mtCOVERAGE_TEST_MARKER();\r
+                                               }\r
                                        }\r
                                }\r
                                #else /* configUSE_QUEUE_SETS */\r
@@ -671,9 +665,17 @@ xTimeOutType xTimeOut;
                                                        our own so yield immediately.  Yes it is ok to do\r
                                                        this from within the critical section - the kernel\r
                                                        takes care of that. */\r
-                                                       portYIELD_WITHIN_API();\r
+                                                       queueYIELD_IF_USING_PREEMPTION();\r
+                                               }\r
+                                               else\r
+                                               {\r
+                                                       mtCOVERAGE_TEST_MARKER();\r
                                                }\r
                                        }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
                                }\r
                                #endif /* configUSE_QUEUE_SETS */\r
 \r
@@ -685,7 +687,7 @@ xTimeOutType xTimeOut;
                        }\r
                        else\r
                        {\r
-                               if( xTicksToWait == ( portTickType ) 0 )\r
+                               if( xTicksToWait == ( TickType_t ) 0 )\r
                                {\r
                                        /* The queue was full and no block time is specified (or\r
                                        the block time has expired) so leave now. */\r
@@ -703,6 +705,11 @@ xTimeOutType xTimeOut;
                                        vTaskSetTimeOutState( &xTimeOut );\r
                                        xEntryTimeSet = pdTRUE;\r
                                }\r
+                               else\r
+                               {\r
+                                       /* Entry time was already set. */\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
                        }\r
                }\r
                taskEXIT_CRITICAL();\r
@@ -762,13 +769,14 @@ xTimeOutType xTimeOut;
 \r
 #if ( configUSE_ALTERNATIVE_API == 1 )\r
 \r
-       signed portBASE_TYPE xQueueAltGenericSend( xQueueHandle pxQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition )\r
+       BaseType_t xQueueAltGenericSend( QueueHandle_t xQueue, const void * const pvItemToQueue, TickType_t xTicksToWait, BaseType_t xCopyPosition )\r
        {\r
-       signed portBASE_TYPE xEntryTimeSet = pdFALSE;\r
-       xTimeOutType xTimeOut;\r
+       BaseType_t xEntryTimeSet = pdFALSE;\r
+       TimeOut_t xTimeOut;\r
+       Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
 \r
                configASSERT( pxQueue );\r
-               configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( unsigned portBASE_TYPE ) 0U ) ) );\r
+               configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) );\r
 \r
                for( ;; )\r
                {\r
@@ -791,6 +799,14 @@ xTimeOutType xTimeOut;
                                                        our own so yield immediately. */\r
                                                        portYIELD_WITHIN_API();\r
                                                }\r
+                                               else\r
+                                               {\r
+                                                       mtCOVERAGE_TEST_MARKER();\r
+                                               }\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
                                        }\r
 \r
                                        taskEXIT_CRITICAL();\r
@@ -798,7 +814,7 @@ xTimeOutType xTimeOut;
                                }\r
                                else\r
                                {\r
-                                       if( xTicksToWait == ( portTickType ) 0 )\r
+                                       if( xTicksToWait == ( TickType_t ) 0 )\r
                                        {\r
                                                taskEXIT_CRITICAL();\r
                                                return errQUEUE_FULL;\r
@@ -822,6 +838,10 @@ xTimeOutType xTimeOut;
                                                vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToSend ), xTicksToWait );\r
                                                portYIELD_WITHIN_API();\r
                                        }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
                                }\r
                                else\r
                                {\r
@@ -839,23 +859,24 @@ xTimeOutType xTimeOut;
 \r
 #if ( configUSE_ALTERNATIVE_API == 1 )\r
 \r
-       signed portBASE_TYPE xQueueAltGenericReceive( xQueueHandle pxQueue, void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking )\r
+       BaseType_t xQueueAltGenericReceive( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait, BaseType_t xJustPeeking )\r
        {\r
-       signed portBASE_TYPE xEntryTimeSet = pdFALSE;\r
-       xTimeOutType xTimeOut;\r
-       signed char *pcOriginalReadPosition;\r
+       BaseType_t xEntryTimeSet = pdFALSE;\r
+       TimeOut_t xTimeOut;\r
+       int8_t *pcOriginalReadPosition;\r
+       Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
 \r
                configASSERT( pxQueue );\r
-               configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( unsigned portBASE_TYPE ) 0U ) ) );\r
+               configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) );\r
 \r
                for( ;; )\r
                {\r
                        taskENTER_CRITICAL();\r
                        {\r
-                               if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 )\r
+                               if( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 )\r
                                {\r
                                        /* Remember our read position in case we are just peeking. */\r
-                                       pcOriginalReadPosition = pxQueue->pcReadFrom;\r
+                                       pcOriginalReadPosition = pxQueue->u.pcReadFrom;\r
 \r
                                        prvCopyDataFromQueue( pxQueue, pvBuffer );\r
 \r
@@ -863,7 +884,7 @@ xTimeOutType xTimeOut;
                                        {\r
                                                traceQUEUE_RECEIVE( pxQueue );\r
 \r
-                                               /* We are actually removing data. */\r
+                                               /* Data is actually being removed (not just peeked). */\r
                                                --( pxQueue->uxMessagesWaiting );\r
 \r
                                                #if ( configUSE_MUTEXES == 1 )\r
@@ -872,7 +893,11 @@ xTimeOutType xTimeOut;
                                                        {\r
                                                                /* Record the information required to implement\r
                                                                priority inheritance should it become necessary. */\r
-                                                               pxQueue->pxMutexHolder = xTaskGetCurrentTaskHandle();\r
+                                                               pxQueue->pxMutexHolder = ( int8_t * ) xTaskGetCurrentTaskHandle();\r
+                                                       }\r
+                                                       else\r
+                                                       {\r
+                                                               mtCOVERAGE_TEST_MARKER();\r
                                                        }\r
                                                }\r
                                                #endif\r
@@ -883,6 +908,10 @@ xTimeOutType xTimeOut;
                                                        {\r
                                                                portYIELD_WITHIN_API();\r
                                                        }\r
+                                                       else\r
+                                                       {\r
+                                                               mtCOVERAGE_TEST_MARKER();\r
+                                                       }\r
                                                }\r
                                        }\r
                                        else\r
@@ -891,7 +920,7 @@ xTimeOutType xTimeOut;
 \r
                                                /* We are not removing the data, so reset our read\r
                                                pointer. */\r
-                                               pxQueue->pcReadFrom = pcOriginalReadPosition;\r
+                                               pxQueue->u.pcReadFrom = pcOriginalReadPosition;\r
 \r
                                                /* The data is being left in the queue, so see if there are\r
                                                any other tasks waiting for the data. */\r
@@ -904,8 +933,15 @@ xTimeOutType xTimeOut;
                                                                /* The task waiting has a higher priority than this task. */\r
                                                                portYIELD_WITHIN_API();\r
                                                        }\r
+                                                       else\r
+                                                       {\r
+                                                               mtCOVERAGE_TEST_MARKER();\r
+                                                       }\r
+                                               }\r
+                                               else\r
+                                               {\r
+                                                       mtCOVERAGE_TEST_MARKER();\r
                                                }\r
-\r
                                        }\r
 \r
                                        taskEXIT_CRITICAL();\r
@@ -913,7 +949,7 @@ xTimeOutType xTimeOut;
                                }\r
                                else\r
                                {\r
-                                       if( xTicksToWait == ( portTickType ) 0 )\r
+                                       if( xTicksToWait == ( TickType_t ) 0 )\r
                                        {\r
                                                taskEXIT_CRITICAL();\r
                                                traceQUEUE_RECEIVE_FAILED( pxQueue );\r
@@ -940,11 +976,15 @@ xTimeOutType xTimeOut;
                                                {\r
                                                        if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX )\r
                                                        {\r
-                                                               portENTER_CRITICAL();\r
+                                                               taskENTER_CRITICAL();\r
                                                                {\r
                                                                        vTaskPriorityInherit( ( void * ) pxQueue->pxMutexHolder );\r
                                                                }\r
-                                                               portEXIT_CRITICAL();\r
+                                                               taskEXIT_CRITICAL();\r
+                                                       }\r
+                                                       else\r
+                                                       {\r
+                                                               mtCOVERAGE_TEST_MARKER();\r
                                                        }\r
                                                }\r
                                                #endif\r
@@ -952,6 +992,10 @@ xTimeOutType xTimeOut;
                                                vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait );\r
                                                portYIELD_WITHIN_API();\r
                                        }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
                                }\r
                                else\r
                                {\r
@@ -968,28 +1012,46 @@ xTimeOutType xTimeOut;
 #endif /* configUSE_ALTERNATIVE_API */\r
 /*-----------------------------------------------------------*/\r
 \r
-signed portBASE_TYPE xQueueGenericSendFromISR( xQueueHandle pxQueue, const void * const pvItemToQueue, signed portBASE_TYPE *pxHigherPriorityTaskWoken, portBASE_TYPE xCopyPosition )\r
+BaseType_t xQueueGenericSendFromISR( QueueHandle_t xQueue, const void * const pvItemToQueue, BaseType_t * const pxHigherPriorityTaskWoken, const BaseType_t xCopyPosition )\r
 {\r
-signed portBASE_TYPE xReturn;\r
-unsigned portBASE_TYPE uxSavedInterruptStatus;\r
+BaseType_t xReturn;\r
+UBaseType_t uxSavedInterruptStatus;\r
+Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
 \r
        configASSERT( pxQueue );\r
-       configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( unsigned portBASE_TYPE ) 0U ) ) );\r
-\r
-       /* Similar to xQueueGenericSend, except we don't block if there is no room\r
-       in the queue.  Also we don't directly wake a task that was blocked on a\r
-       queue read, instead we return a flag to say whether a context switch is\r
-       required or not (i.e. has a task with a higher priority than us been woken\r
-       by this post). */\r
+       configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) );\r
+       configASSERT( !( ( xCopyPosition == queueOVERWRITE ) && ( pxQueue->uxLength != 1 ) ) );\r
+\r
+       /* RTOS ports that support interrupt nesting have the concept of a maximum\r
+       system call (or maximum API call) interrupt priority.  Interrupts that are\r
+       above the maximum system call priority are kept permanently enabled, even\r
+       when the RTOS kernel is in a critical section, but cannot make any calls to\r
+       FreeRTOS API functions.  If configASSERT() is defined in FreeRTOSConfig.h\r
+       then portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion\r
+       failure if a FreeRTOS API function is called from an interrupt that has been\r
+       assigned a priority above the configured maximum system call priority.\r
+       Only FreeRTOS functions that end in FromISR can be called from interrupts\r
+       that have been assigned a priority at or (logically) below the maximum\r
+       system call     interrupt priority.  FreeRTOS maintains a separate interrupt\r
+       safe API to ensure interrupt entry is as fast and as simple as possible.\r
+       More information (albeit Cortex-M specific) is provided on the following\r
+       link: http://www.freertos.org/RTOS-Cortex-M3-M4.html */\r
+       portASSERT_IF_INTERRUPT_PRIORITY_INVALID();\r
+\r
+       /* Similar to xQueueGenericSend, except without blocking if there is no room\r
+       in the queue.  Also don't directly wake a task that was blocked on a queue\r
+       read, instead return a flag to say whether a context switch is required or \r
+       not (i.e. has a task with a higher priority than us been woken by this \r
+       post). */\r
        uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();\r
        {\r
-               if( pxQueue->uxMessagesWaiting < pxQueue->uxLength )\r
+               if( ( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) || ( xCopyPosition == queueOVERWRITE ) )\r
                {\r
                        traceQUEUE_SEND_FROM_ISR( pxQueue );\r
 \r
                        prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition );\r
 \r
-                       /* If the queue is locked we do not alter the event list.  This will\r
+                       /* The event list is not altered if the queue is locked.  This will\r
                        be done when the queue is unlocked later. */\r
                        if( pxQueue->xTxLock == queueUNLOCKED )\r
                        {\r
@@ -1006,6 +1068,14 @@ unsigned portBASE_TYPE uxSavedInterruptStatus;
                                                        {\r
                                                                *pxHigherPriorityTaskWoken = pdTRUE;\r
                                                        }\r
+                                                       else\r
+                                                       {\r
+                                                               mtCOVERAGE_TEST_MARKER();\r
+                                                       }\r
+                                               }\r
+                                               else\r
+                                               {\r
+                                                       mtCOVERAGE_TEST_MARKER();\r
                                                }\r
                                        }\r
                                        else\r
@@ -1020,8 +1090,20 @@ unsigned portBASE_TYPE uxSavedInterruptStatus;
                                                                {\r
                                                                        *pxHigherPriorityTaskWoken = pdTRUE;\r
                                                                }\r
+                                                               else\r
+                                                               {\r
+                                                                       mtCOVERAGE_TEST_MARKER();\r
+                                                               }\r
+                                                       }\r
+                                                       else\r
+                                                       {\r
+                                                               mtCOVERAGE_TEST_MARKER();\r
                                                        }\r
                                                }\r
+                                               else\r
+                                               {\r
+                                                       mtCOVERAGE_TEST_MARKER();\r
+                                               }\r
                                        }\r
                                }\r
                                #else /* configUSE_QUEUE_SETS */\r
@@ -1036,8 +1118,20 @@ unsigned portBASE_TYPE uxSavedInterruptStatus;
                                                        {\r
                                                                *pxHigherPriorityTaskWoken = pdTRUE;\r
                                                        }\r
+                                                       else\r
+                                                       {\r
+                                                               mtCOVERAGE_TEST_MARKER();\r
+                                                       }\r
+                                               }\r
+                                               else\r
+                                               {\r
+                                                       mtCOVERAGE_TEST_MARKER();\r
                                                }\r
                                        }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
                                }\r
                                #endif /* configUSE_QUEUE_SETS */\r
                        }\r
@@ -1062,14 +1156,20 @@ unsigned portBASE_TYPE uxSavedInterruptStatus;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-signed portBASE_TYPE xQueueGenericReceive( xQueueHandle pxQueue, void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking )\r
+BaseType_t xQueueGenericReceive( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait, const BaseType_t xJustPeeking )\r
 {\r
-signed portBASE_TYPE xEntryTimeSet = pdFALSE;\r
-xTimeOutType xTimeOut;\r
-signed char *pcOriginalReadPosition;\r
+BaseType_t xEntryTimeSet = pdFALSE;\r
+TimeOut_t xTimeOut;\r
+int8_t *pcOriginalReadPosition;\r
+Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
 \r
        configASSERT( pxQueue );\r
-       configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( unsigned portBASE_TYPE ) 0U ) ) );\r
+       configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) );\r
+       #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )\r
+       {\r
+               configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) );\r
+       }\r
+       #endif\r
 \r
        /* This function relaxes the coding standard somewhat to allow return\r
        statements within the function itself.  This is done in the interest\r
@@ -1081,10 +1181,11 @@ signed char *pcOriginalReadPosition;
                {\r
                        /* Is there data in the queue now?  To be running we must be\r
                        the highest priority task wanting to access the queue. */\r
-                       if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 )\r
+                       if( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 )\r
                        {\r
-                               /* Remember our read position in case we are just peeking. */\r
-                               pcOriginalReadPosition = pxQueue->pcReadFrom;\r
+                               /* Remember the read position in case the queue is only being\r
+                               peeked. */\r
+                               pcOriginalReadPosition = pxQueue->u.pcReadFrom;\r
 \r
                                prvCopyDataFromQueue( pxQueue, pvBuffer );\r
 \r
@@ -1092,7 +1193,7 @@ signed char *pcOriginalReadPosition;
                                {\r
                                        traceQUEUE_RECEIVE( pxQueue );\r
 \r
-                                       /* We are actually removing data. */\r
+                                       /* Actually removing data, not just peeking. */\r
                                        --( pxQueue->uxMessagesWaiting );\r
 \r
                                        #if ( configUSE_MUTEXES == 1 )\r
@@ -1101,7 +1202,11 @@ signed char *pcOriginalReadPosition;
                                                {\r
                                                        /* Record the information required to implement\r
                                                        priority inheritance should it become necessary. */\r
-                                                       pxQueue->pxMutexHolder = xTaskGetCurrentTaskHandle();\r
+                                                       pxQueue->pxMutexHolder = ( int8_t * ) xTaskGetCurrentTaskHandle(); /*lint !e961 Cast is not redundant as TaskHandle_t is a typedef. */\r
+                                               }\r
+                                               else\r
+                                               {\r
+                                                       mtCOVERAGE_TEST_MARKER();\r
                                                }\r
                                        }\r
                                        #endif\r
@@ -1110,9 +1215,17 @@ signed char *pcOriginalReadPosition;
                                        {\r
                                                if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) == pdTRUE )\r
                                                {\r
-                                                       portYIELD_WITHIN_API();\r
+                                                       queueYIELD_IF_USING_PREEMPTION();\r
+                                               }\r
+                                               else\r
+                                               {\r
+                                                       mtCOVERAGE_TEST_MARKER();\r
                                                }\r
                                        }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
                                }\r
                                else\r
                                {\r
@@ -1120,7 +1233,7 @@ signed char *pcOriginalReadPosition;
 \r
                                        /* The data is not being removed, so reset the read\r
                                        pointer. */\r
-                                       pxQueue->pcReadFrom = pcOriginalReadPosition;\r
+                                       pxQueue->u.pcReadFrom = pcOriginalReadPosition;\r
 \r
                                        /* The data is being left in the queue, so see if there are\r
                                        any other tasks waiting for the data. */\r
@@ -1131,9 +1244,17 @@ signed char *pcOriginalReadPosition;
                                                if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )\r
                                                {\r
                                                        /* The task waiting has a higher priority than this task. */\r
-                                                       portYIELD_WITHIN_API();\r
+                                                       queueYIELD_IF_USING_PREEMPTION();\r
+                                               }\r
+                                               else\r
+                                               {\r
+                                                       mtCOVERAGE_TEST_MARKER();\r
                                                }\r
                                        }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
                                }\r
 \r
                                taskEXIT_CRITICAL();\r
@@ -1141,7 +1262,7 @@ signed char *pcOriginalReadPosition;
                        }\r
                        else\r
                        {\r
-                               if( xTicksToWait == ( portTickType ) 0 )\r
+                               if( xTicksToWait == ( TickType_t ) 0 )\r
                                {\r
                                        /* The queue was empty and no block time is specified (or\r
                                        the block time has expired) so leave now. */\r
@@ -1156,6 +1277,11 @@ signed char *pcOriginalReadPosition;
                                        vTaskSetTimeOutState( &xTimeOut );\r
                                        xEntryTimeSet = pdTRUE;\r
                                }\r
+                               else\r
+                               {\r
+                                       /* Entry time was already set. */\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
                        }\r
                }\r
                taskEXIT_CRITICAL();\r
@@ -1177,11 +1303,15 @@ signed char *pcOriginalReadPosition;
                                {\r
                                        if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX )\r
                                        {\r
-                                               portENTER_CRITICAL();\r
+                                               taskENTER_CRITICAL();\r
                                                {\r
                                                        vTaskPriorityInherit( ( void * ) pxQueue->pxMutexHolder );\r
                                                }\r
-                                               portEXIT_CRITICAL();\r
+                                               taskEXIT_CRITICAL();\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
                                        }\r
                                }\r
                                #endif\r
@@ -1192,6 +1322,10 @@ signed char *pcOriginalReadPosition;
                                {\r
                                        portYIELD_WITHIN_API();\r
                                }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
                        }\r
                        else\r
                        {\r
@@ -1211,27 +1345,45 @@ signed char *pcOriginalReadPosition;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-signed portBASE_TYPE xQueueReceiveFromISR( xQueueHandle pxQueue, void * const pvBuffer, signed portBASE_TYPE *pxHigherPriorityTaskWoken )\r
+BaseType_t xQueueReceiveFromISR( QueueHandle_t xQueue, void * const pvBuffer, BaseType_t * const pxHigherPriorityTaskWoken )\r
 {\r
-signed portBASE_TYPE xReturn;\r
-unsigned portBASE_TYPE uxSavedInterruptStatus;\r
+BaseType_t xReturn;\r
+UBaseType_t uxSavedInterruptStatus;\r
+Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
 \r
        configASSERT( pxQueue );\r
-       configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( unsigned portBASE_TYPE ) 0U ) ) );\r
+       configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) );\r
+\r
+       /* RTOS ports that support interrupt nesting have the concept of a maximum\r
+       system call (or maximum API call) interrupt priority.  Interrupts that are\r
+       above the maximum system call priority are kept permanently enabled, even\r
+       when the RTOS kernel is in a critical section, but cannot make any calls to\r
+       FreeRTOS API functions.  If configASSERT() is defined in FreeRTOSConfig.h\r
+       then portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion\r
+       failure if a FreeRTOS API function is called from an interrupt that has been\r
+       assigned a priority above the configured maximum system call priority.\r
+       Only FreeRTOS functions that end in FromISR can be called from interrupts\r
+       that have been assigned a priority at or (logically) below the maximum\r
+       system call     interrupt priority.  FreeRTOS maintains a separate interrupt\r
+       safe API to ensure interrupt entry is as fast and as simple as possible.\r
+       More information (albeit Cortex-M specific) is provided on the following\r
+       link: http://www.freertos.org/RTOS-Cortex-M3-M4.html */\r
+       portASSERT_IF_INTERRUPT_PRIORITY_INVALID();\r
 \r
        uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();\r
        {\r
-               /* We cannot block from an ISR, so check there is data available. */\r
-               if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 )\r
+               /* Cannot block in an ISR, so check there is data available. */\r
+               if( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 )\r
                {\r
                        traceQUEUE_RECEIVE_FROM_ISR( pxQueue );\r
 \r
                        prvCopyDataFromQueue( pxQueue, pvBuffer );\r
                        --( pxQueue->uxMessagesWaiting );\r
 \r
-                       /* If the queue is locked we will not modify the event list.  Instead\r
-                       we update the lock count so the task that unlocks the queue will know\r
-                       that an ISR has removed data while the queue was locked. */\r
+                       /* If the queue is locked the event list will not be modified.\r
+                       Instead update the lock count so the task that unlocks the queue\r
+                       will know that an ISR has removed data while the queue was\r
+                       locked. */\r
                        if( pxQueue->xRxLock == queueUNLOCKED )\r
                        {\r
                                if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )\r
@@ -1244,8 +1396,20 @@ unsigned portBASE_TYPE uxSavedInterruptStatus;
                                                {\r
                                                        *pxHigherPriorityTaskWoken = pdTRUE;\r
                                                }\r
+                                               else\r
+                                               {\r
+                                                       mtCOVERAGE_TEST_MARKER();\r
+                                               }\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
                                        }\r
                                }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
                        }\r
                        else\r
                        {\r
@@ -1268,48 +1432,130 @@ unsigned portBASE_TYPE uxSavedInterruptStatus;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-unsigned portBASE_TYPE uxQueueMessagesWaiting( const xQueueHandle pxQueue )\r
+BaseType_t xQueuePeekFromISR( QueueHandle_t xQueue,  void * const pvBuffer )\r
 {\r
-unsigned portBASE_TYPE uxReturn;\r
+BaseType_t xReturn;\r
+UBaseType_t uxSavedInterruptStatus;\r
+int8_t *pcOriginalReadPosition;\r
+Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
 \r
        configASSERT( pxQueue );\r
+       configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) );\r
+\r
+       /* RTOS ports that support interrupt nesting have the concept of a maximum\r
+       system call (or maximum API call) interrupt priority.  Interrupts that are\r
+       above the maximum system call priority are kept permanently enabled, even\r
+       when the RTOS kernel is in a critical section, but cannot make any calls to\r
+       FreeRTOS API functions.  If configASSERT() is defined in FreeRTOSConfig.h\r
+       then portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion\r
+       failure if a FreeRTOS API function is called from an interrupt that has been\r
+       assigned a priority above the configured maximum system call priority.\r
+       Only FreeRTOS functions that end in FromISR can be called from interrupts\r
+       that have been assigned a priority at or (logically) below the maximum\r
+       system call     interrupt priority.  FreeRTOS maintains a separate interrupt\r
+       safe API to ensure interrupt entry is as fast and as simple as possible.\r
+       More information (albeit Cortex-M specific) is provided on the following\r
+       link: http://www.freertos.org/RTOS-Cortex-M3-M4.html */\r
+       portASSERT_IF_INTERRUPT_PRIORITY_INVALID();\r
+\r
+       uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();\r
+       {\r
+               /* Cannot block in an ISR, so check there is data available. */\r
+               if( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 )\r
+               {\r
+                       traceQUEUE_PEEK_FROM_ISR( pxQueue );\r
+\r
+                       /* Remember the read position so it can be reset as nothing is\r
+                       actually being removed from the queue. */\r
+                       pcOriginalReadPosition = pxQueue->u.pcReadFrom;\r
+                       prvCopyDataFromQueue( pxQueue, pvBuffer );\r
+                       pxQueue->u.pcReadFrom = pcOriginalReadPosition;\r
+\r
+                       xReturn = pdPASS;\r
+               }\r
+               else\r
+               {\r
+                       xReturn = pdFAIL;\r
+                       traceQUEUE_PEEK_FROM_ISR_FAILED( pxQueue );\r
+               }\r
+       }\r
+       portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus );\r
+\r
+       return xReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+UBaseType_t uxQueueMessagesWaiting( const QueueHandle_t xQueue )\r
+{\r
+UBaseType_t uxReturn;\r
+\r
+       configASSERT( xQueue );\r
 \r
        taskENTER_CRITICAL();\r
-               uxReturn = pxQueue->uxMessagesWaiting;\r
+       {\r
+               uxReturn = ( ( Queue_t * ) xQueue )->uxMessagesWaiting;\r
+       }\r
        taskEXIT_CRITICAL();\r
 \r
        return uxReturn;\r
-}\r
+} /*lint !e818 Pointer cannot be declared const as xQueue is a typedef not pointer. */\r
 /*-----------------------------------------------------------*/\r
 \r
-unsigned portBASE_TYPE uxQueueMessagesWaitingFromISR( const xQueueHandle pxQueue )\r
+UBaseType_t uxQueueSpacesAvailable( const QueueHandle_t xQueue )\r
 {\r
-unsigned portBASE_TYPE uxReturn;\r
+UBaseType_t uxReturn;\r
+Queue_t *pxQueue;\r
 \r
+       pxQueue = ( Queue_t * ) xQueue;\r
        configASSERT( pxQueue );\r
 \r
-       uxReturn = pxQueue->uxMessagesWaiting;\r
+       taskENTER_CRITICAL();\r
+       {\r
+               uxReturn = pxQueue->uxLength - pxQueue->uxMessagesWaiting;\r
+       }\r
+       taskEXIT_CRITICAL();\r
+\r
+       return uxReturn;\r
+} /*lint !e818 Pointer cannot be declared const as xQueue is a typedef not pointer. */\r
+/*-----------------------------------------------------------*/\r
+\r
+UBaseType_t uxQueueMessagesWaitingFromISR( const QueueHandle_t xQueue )\r
+{\r
+UBaseType_t uxReturn;\r
+\r
+       configASSERT( xQueue );\r
+\r
+       uxReturn = ( ( Queue_t * ) xQueue )->uxMessagesWaiting;\r
 \r
        return uxReturn;\r
-}\r
+} /*lint !e818 Pointer cannot be declared const as xQueue is a typedef not pointer. */\r
 /*-----------------------------------------------------------*/\r
 \r
-void vQueueDelete( xQueueHandle pxQueue )\r
+void vQueueDelete( QueueHandle_t xQueue )\r
 {\r
+Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
+\r
        configASSERT( pxQueue );\r
 \r
        traceQUEUE_DELETE( pxQueue );\r
-       vQueueUnregisterQueue( pxQueue );\r
-       vPortFree( pxQueue->pcHead );\r
+       #if ( configQUEUE_REGISTRY_SIZE > 0 )\r
+       {\r
+               vQueueUnregisterQueue( pxQueue );\r
+       }\r
+       #endif\r
+       if( pxQueue->pcHead != NULL )\r
+       {\r
+               vPortFree( pxQueue->pcHead );\r
+       }\r
        vPortFree( pxQueue );\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
 #if ( configUSE_TRACE_FACILITY == 1 )\r
 \r
-       unsigned char ucQueueGetQueueNumber( xQueueHandle pxQueue )\r
+       UBaseType_t uxQueueGetQueueNumber( QueueHandle_t xQueue )\r
        {\r
-               return pxQueue->ucQueueNumber;\r
+               return ( ( Queue_t * ) xQueue )->uxQueueNumber;\r
        }\r
 \r
 #endif /* configUSE_TRACE_FACILITY */\r
@@ -1317,9 +1563,9 @@ void vQueueDelete( xQueueHandle pxQueue )
 \r
 #if ( configUSE_TRACE_FACILITY == 1 )\r
 \r
-       void vQueueSetQueueNumber( xQueueHandle pxQueue, unsigned char ucQueueNumber )\r
+       void vQueueSetQueueNumber( QueueHandle_t xQueue, UBaseType_t uxQueueNumber )\r
        {\r
-               pxQueue->ucQueueNumber = ucQueueNumber;\r
+               ( ( Queue_t * ) xQueue )->uxQueueNumber = uxQueueNumber;\r
        }\r
 \r
 #endif /* configUSE_TRACE_FACILITY */\r
@@ -1327,17 +1573,17 @@ void vQueueDelete( xQueueHandle pxQueue )
 \r
 #if ( configUSE_TRACE_FACILITY == 1 )\r
 \r
-       unsigned char ucQueueGetQueueType( xQueueHandle pxQueue )\r
+       uint8_t ucQueueGetQueueType( QueueHandle_t xQueue )\r
        {\r
-               return pxQueue->ucQueueType;\r
+               return ( ( Queue_t * ) xQueue )->ucQueueType;\r
        }\r
 \r
 #endif /* configUSE_TRACE_FACILITY */\r
 /*-----------------------------------------------------------*/\r
 \r
-static void prvCopyDataToQueue( xQUEUE *pxQueue, const void *pvItemToQueue, portBASE_TYPE xPosition )\r
+static void prvCopyDataToQueue( Queue_t * const pxQueue, const void *pvItemToQueue, const BaseType_t xPosition )\r
 {\r
-       if( pxQueue->uxItemSize == ( unsigned portBASE_TYPE ) 0 )\r
+       if( pxQueue->uxItemSize == ( UBaseType_t ) 0 )\r
        {\r
                #if ( configUSE_MUTEXES == 1 )\r
                {\r
@@ -1347,25 +1593,57 @@ static void prvCopyDataToQueue( xQUEUE *pxQueue, const void *pvItemToQueue, port
                                vTaskPriorityDisinherit( ( void * ) pxQueue->pxMutexHolder );\r
                                pxQueue->pxMutexHolder = NULL;\r
                        }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
                }\r
-               #endif\r
+               #endif /* configUSE_MUTEXES */\r
        }\r
        else if( xPosition == queueSEND_TO_BACK )\r
        {\r
-               memcpy( ( void * ) pxQueue->pcWriteTo, pvItemToQueue, ( unsigned ) pxQueue->uxItemSize );\r
+               ( void ) memcpy( ( void * ) pxQueue->pcWriteTo, pvItemToQueue, ( size_t ) pxQueue->uxItemSize ); /*lint !e961 !e418 MISRA exception as the casts are only redundant for some ports, plus previous logic ensures a null pointer can only be passed to memcpy() if the copy size is 0. */\r
                pxQueue->pcWriteTo += pxQueue->uxItemSize;\r
-               if( pxQueue->pcWriteTo >= pxQueue->pcTail )\r
+               if( pxQueue->pcWriteTo >= pxQueue->pcTail ) /*lint !e946 MISRA exception justified as comparison of pointers is the cleanest solution. */\r
                {\r
                        pxQueue->pcWriteTo = pxQueue->pcHead;\r
                }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
        }\r
        else\r
        {\r
-               memcpy( ( void * ) pxQueue->pcReadFrom, pvItemToQueue, ( unsigned ) pxQueue->uxItemSize );\r
-               pxQueue->pcReadFrom -= pxQueue->uxItemSize;\r
-               if( pxQueue->pcReadFrom < pxQueue->pcHead )\r
+               ( void ) memcpy( ( void * ) pxQueue->u.pcReadFrom, pvItemToQueue, ( size_t ) pxQueue->uxItemSize ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */\r
+               pxQueue->u.pcReadFrom -= pxQueue->uxItemSize;\r
+               if( pxQueue->u.pcReadFrom < pxQueue->pcHead ) /*lint !e946 MISRA exception justified as comparison of pointers is the cleanest solution. */\r
+               {\r
+                       pxQueue->u.pcReadFrom = ( pxQueue->pcTail - pxQueue->uxItemSize );\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
+\r
+               if( xPosition == queueOVERWRITE )\r
+               {\r
+                       if( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 )\r
+                       {\r
+                               /* An item is not being added but overwritten, so subtract\r
+                               one from the recorded number of items in the queue so when\r
+                               one is added again below the number of recorded items remains\r
+                               correct. */\r
+                               --( pxQueue->uxMessagesWaiting );\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+               }\r
+               else\r
                {\r
-                       pxQueue->pcReadFrom = ( pxQueue->pcTail - pxQueue->uxItemSize );\r
+                       mtCOVERAGE_TEST_MARKER();\r
                }\r
        }\r
 \r
@@ -1373,21 +1651,29 @@ static void prvCopyDataToQueue( xQUEUE *pxQueue, const void *pvItemToQueue, port
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-static void prvCopyDataFromQueue( xQUEUE * const pxQueue, const void *pvBuffer )\r
+static void prvCopyDataFromQueue( Queue_t * const pxQueue, void * const pvBuffer )\r
 {\r
        if( pxQueue->uxQueueType != queueQUEUE_IS_MUTEX )\r
        {\r
-               pxQueue->pcReadFrom += pxQueue->uxItemSize;\r
-               if( pxQueue->pcReadFrom >= pxQueue->pcTail )\r
+               pxQueue->u.pcReadFrom += pxQueue->uxItemSize;\r
+               if( pxQueue->u.pcReadFrom >= pxQueue->pcTail ) /*lint !e946 MISRA exception justified as use of the relational operator is the cleanest solutions. */\r
+               {\r
+                       pxQueue->u.pcReadFrom = pxQueue->pcHead;\r
+               }\r
+               else\r
                {\r
-                       pxQueue->pcReadFrom = pxQueue->pcHead;\r
+                       mtCOVERAGE_TEST_MARKER();\r
                }\r
-               memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->pcReadFrom, ( unsigned ) pxQueue->uxItemSize );\r
+               ( void ) memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->u.pcReadFrom, ( size_t ) pxQueue->uxItemSize ); /*lint !e961 !e418 MISRA exception as the casts are only redundant for some ports.  Also previous logic ensures a null pointer can only be passed to memcpy() when the count is 0. */\r
+       }\r
+       else\r
+       {\r
+               mtCOVERAGE_TEST_MARKER();\r
        }\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-static void prvUnlockQueue( xQueueHandle pxQueue )\r
+static void prvUnlockQueue( Queue_t * const pxQueue )\r
 {\r
        /* THIS FUNCTION MUST BE CALLED WITH THE SCHEDULER SUSPENDED. */\r
 \r
@@ -1413,6 +1699,10 @@ static void prvUnlockQueue( xQueueHandle pxQueue )
                                                A context switch is required. */\r
                                                vTaskMissedYield();\r
                                        }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
                                }\r
                                else\r
                                {\r
@@ -1426,6 +1716,10 @@ static void prvUnlockQueue( xQueueHandle pxQueue )
                                                        context switch is required. */\r
                                                        vTaskMissedYield();\r
                                                }\r
+                                               else\r
+                                               {\r
+                                                       mtCOVERAGE_TEST_MARKER();\r
+                                               }\r
                                        }\r
                                        else\r
                                        {\r
@@ -1445,6 +1739,10 @@ static void prvUnlockQueue( xQueueHandle pxQueue )
                                                context switch is required. */\r
                                                vTaskMissedYield();\r
                                        }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
                                }\r
                                else\r
                                {\r
@@ -1471,6 +1769,10 @@ static void prvUnlockQueue( xQueueHandle pxQueue )
                                {\r
                                        vTaskMissedYield();\r
                                }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
 \r
                                --( pxQueue->xRxLock );\r
                        }\r
@@ -1486,57 +1788,90 @@ static void prvUnlockQueue( xQueueHandle pxQueue )
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-static signed portBASE_TYPE prvIsQueueEmpty( const xQueueHandle pxQueue )\r
+static BaseType_t prvIsQueueEmpty( const Queue_t *pxQueue )\r
 {\r
-signed portBASE_TYPE xReturn;\r
+BaseType_t xReturn;\r
 \r
        taskENTER_CRITICAL();\r
-               xReturn = ( pxQueue->uxMessagesWaiting == ( unsigned portBASE_TYPE ) 0 );\r
+       {\r
+               if( pxQueue->uxMessagesWaiting == ( UBaseType_t )  0 )\r
+               {\r
+                       xReturn = pdTRUE;\r
+               }\r
+               else\r
+               {\r
+                       xReturn = pdFALSE;\r
+               }\r
+       }\r
        taskEXIT_CRITICAL();\r
 \r
        return xReturn;\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-signed portBASE_TYPE xQueueIsQueueEmptyFromISR( const xQueueHandle pxQueue )\r
+BaseType_t xQueueIsQueueEmptyFromISR( const QueueHandle_t xQueue )\r
 {\r
-signed portBASE_TYPE xReturn;\r
+BaseType_t xReturn;\r
 \r
-       configASSERT( pxQueue );\r
-       xReturn = ( pxQueue->uxMessagesWaiting == ( unsigned portBASE_TYPE ) 0 );\r
+       configASSERT( xQueue );\r
+       if( ( ( Queue_t * ) xQueue )->uxMessagesWaiting == ( UBaseType_t ) 0 )\r
+       {\r
+               xReturn = pdTRUE;\r
+       }\r
+       else\r
+       {\r
+               xReturn = pdFALSE;\r
+       }\r
 \r
        return xReturn;\r
-}\r
+} /*lint !e818 xQueue could not be pointer to const because it is a typedef. */\r
 /*-----------------------------------------------------------*/\r
 \r
-static signed portBASE_TYPE prvIsQueueFull( const xQueueHandle pxQueue )\r
+static BaseType_t prvIsQueueFull( const Queue_t *pxQueue )\r
 {\r
-signed portBASE_TYPE xReturn;\r
+BaseType_t xReturn;\r
 \r
        taskENTER_CRITICAL();\r
-               xReturn = ( pxQueue->uxMessagesWaiting == pxQueue->uxLength );\r
+       {\r
+               if( pxQueue->uxMessagesWaiting == pxQueue->uxLength )\r
+               {\r
+                       xReturn = pdTRUE;\r
+               }\r
+               else\r
+               {\r
+                       xReturn = pdFALSE;\r
+               }\r
+       }\r
        taskEXIT_CRITICAL();\r
 \r
        return xReturn;\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-signed portBASE_TYPE xQueueIsQueueFullFromISR( const xQueueHandle pxQueue )\r
+BaseType_t xQueueIsQueueFullFromISR( const QueueHandle_t xQueue )\r
 {\r
-signed portBASE_TYPE xReturn;\r
+BaseType_t xReturn;\r
 \r
-       configASSERT( pxQueue );\r
-       xReturn = ( pxQueue->uxMessagesWaiting == pxQueue->uxLength );\r
+       configASSERT( xQueue );\r
+       if( ( ( Queue_t * ) xQueue )->uxMessagesWaiting == ( ( Queue_t * ) xQueue )->uxLength )\r
+       {\r
+               xReturn = pdTRUE;\r
+       }\r
+       else\r
+       {\r
+               xReturn = pdFALSE;\r
+       }\r
 \r
        return xReturn;\r
-}\r
+} /*lint !e818 xQueue could not be pointer to const because it is a typedef. */\r
 /*-----------------------------------------------------------*/\r
 \r
 #if ( configUSE_CO_ROUTINES == 1 )\r
 \r
-       signed portBASE_TYPE xQueueCRSend( xQueueHandle pxQueue, const void *pvItemToQueue, portTickType xTicksToWait )\r
+       BaseType_t xQueueCRSend( QueueHandle_t xQueue, const void *pvItemToQueue, TickType_t xTicksToWait )\r
        {\r
-       signed portBASE_TYPE xReturn;\r
+       BaseType_t xReturn;\r
+       Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
 \r
                /* If the queue is already full we may have to block.  A critical section\r
                is required to prevent an interrupt removing something from the queue\r
@@ -1547,7 +1882,7 @@ signed portBASE_TYPE xReturn;
                        {\r
                                /* The queue is full - do we want to block or just leave without\r
                                posting? */\r
-                               if( xTicksToWait > ( portTickType ) 0 )\r
+                               if( xTicksToWait > ( TickType_t ) 0 )\r
                                {\r
                                        /* As this is called from a coroutine we cannot block directly, but\r
                                        return indicating that we need to block. */\r
@@ -1564,8 +1899,6 @@ signed portBASE_TYPE xReturn;
                }\r
                portENABLE_INTERRUPTS();\r
 \r
-               portNOP();\r
-\r
                portDISABLE_INTERRUPTS();\r
                {\r
                        if( pxQueue->uxMessagesWaiting < pxQueue->uxLength )\r
@@ -1587,6 +1920,14 @@ signed portBASE_TYPE xReturn;
                                                that a yield might be appropriate. */\r
                                                xReturn = errQUEUE_YIELD;\r
                                        }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
                                }\r
                        }\r
                        else\r
@@ -1604,20 +1945,21 @@ signed portBASE_TYPE xReturn;
 \r
 #if ( configUSE_CO_ROUTINES == 1 )\r
 \r
-       signed portBASE_TYPE xQueueCRReceive( xQueueHandle pxQueue, void *pvBuffer, portTickType xTicksToWait )\r
+       BaseType_t xQueueCRReceive( QueueHandle_t xQueue, void *pvBuffer, TickType_t xTicksToWait )\r
        {\r
-       signed portBASE_TYPE xReturn;\r
+       BaseType_t xReturn;\r
+       Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
 \r
                /* If the queue is already empty we may have to block.  A critical section\r
                is required to prevent an interrupt adding something to the queue\r
                between the check to see if the queue is empty and blocking on the queue. */\r
                portDISABLE_INTERRUPTS();\r
                {\r
-                       if( pxQueue->uxMessagesWaiting == ( unsigned portBASE_TYPE ) 0 )\r
+                       if( pxQueue->uxMessagesWaiting == ( UBaseType_t ) 0 )\r
                        {\r
                                /* There are no messages in the queue, do we want to block or just\r
                                leave with nothing? */\r
-                               if( xTicksToWait > ( portTickType ) 0 )\r
+                               if( xTicksToWait > ( TickType_t ) 0 )\r
                                {\r
                                        /* As this is a co-routine we cannot block directly, but return\r
                                        indicating that we need to block. */\r
@@ -1631,23 +1973,29 @@ signed portBASE_TYPE xReturn;
                                        return errQUEUE_FULL;\r
                                }\r
                        }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
                }\r
                portENABLE_INTERRUPTS();\r
 \r
-               portNOP();\r
-\r
                portDISABLE_INTERRUPTS();\r
                {\r
-                       if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 )\r
+                       if( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 )\r
                        {\r
                                /* Data is available from the queue. */\r
-                               pxQueue->pcReadFrom += pxQueue->uxItemSize;\r
-                               if( pxQueue->pcReadFrom >= pxQueue->pcTail )\r
+                               pxQueue->u.pcReadFrom += pxQueue->uxItemSize;\r
+                               if( pxQueue->u.pcReadFrom >= pxQueue->pcTail )\r
+                               {\r
+                                       pxQueue->u.pcReadFrom = pxQueue->pcHead;\r
+                               }\r
+                               else\r
                                {\r
-                                       pxQueue->pcReadFrom = pxQueue->pcHead;\r
+                                       mtCOVERAGE_TEST_MARKER();\r
                                }\r
                                --( pxQueue->uxMessagesWaiting );\r
-                               memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->pcReadFrom, ( unsigned ) pxQueue->uxItemSize );\r
+                               ( void ) memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->u.pcReadFrom, ( unsigned ) pxQueue->uxItemSize );\r
 \r
                                xReturn = pdPASS;\r
 \r
@@ -1662,6 +2010,14 @@ signed portBASE_TYPE xReturn;
                                        {\r
                                                xReturn = errQUEUE_YIELD;\r
                                        }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
                                }\r
                        }\r
                        else\r
@@ -1679,8 +2035,10 @@ signed portBASE_TYPE xReturn;
 \r
 #if ( configUSE_CO_ROUTINES == 1 )\r
 \r
-       signed portBASE_TYPE xQueueCRSendFromISR( xQueueHandle pxQueue, const void *pvItemToQueue, signed portBASE_TYPE xCoRoutinePreviouslyWoken )\r
+       BaseType_t xQueueCRSendFromISR( QueueHandle_t xQueue, const void *pvItemToQueue, BaseType_t xCoRoutinePreviouslyWoken )\r
        {\r
+       Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
+\r
                /* Cannot block within an ISR so if there is no space on the queue then\r
                exit without doing anything. */\r
                if( pxQueue->uxMessagesWaiting < pxQueue->uxLength )\r
@@ -1697,9 +2055,25 @@ signed portBASE_TYPE xReturn;
                                        {\r
                                                return pdTRUE;\r
                                        }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
                                }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
                        }\r
                }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
 \r
                return xCoRoutinePreviouslyWoken;\r
        }\r
@@ -1709,22 +2083,27 @@ signed portBASE_TYPE xReturn;
 \r
 #if ( configUSE_CO_ROUTINES == 1 )\r
 \r
-       signed portBASE_TYPE xQueueCRReceiveFromISR( xQueueHandle pxQueue, void *pvBuffer, signed portBASE_TYPE *pxCoRoutineWoken )\r
+       BaseType_t xQueueCRReceiveFromISR( QueueHandle_t xQueue, void *pvBuffer, BaseType_t *pxCoRoutineWoken )\r
        {\r
-       signed portBASE_TYPE xReturn;\r
+       BaseType_t xReturn;\r
+       Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
 \r
                /* We cannot block from an ISR, so check there is data available. If\r
                not then just leave without doing anything. */\r
-               if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 )\r
+               if( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 )\r
                {\r
                        /* Copy the data from the queue. */\r
-                       pxQueue->pcReadFrom += pxQueue->uxItemSize;\r
-                       if( pxQueue->pcReadFrom >= pxQueue->pcTail )\r
+                       pxQueue->u.pcReadFrom += pxQueue->uxItemSize;\r
+                       if( pxQueue->u.pcReadFrom >= pxQueue->pcTail )\r
+                       {\r
+                               pxQueue->u.pcReadFrom = pxQueue->pcHead;\r
+                       }\r
+                       else\r
                        {\r
-                               pxQueue->pcReadFrom = pxQueue->pcHead;\r
+                               mtCOVERAGE_TEST_MARKER();\r
                        }\r
                        --( pxQueue->uxMessagesWaiting );\r
-                       memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->pcReadFrom, ( unsigned ) pxQueue->uxItemSize );\r
+                       ( void ) memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->u.pcReadFrom, ( unsigned ) pxQueue->uxItemSize );\r
 \r
                        if( ( *pxCoRoutineWoken ) == pdFALSE )\r
                        {\r
@@ -1734,8 +2113,20 @@ signed portBASE_TYPE xReturn;
                                        {\r
                                                *pxCoRoutineWoken = pdTRUE;\r
                                        }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
                                }\r
                        }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
 \r
                        xReturn = pdPASS;\r
                }\r
@@ -1752,21 +2143,27 @@ signed portBASE_TYPE xReturn;
 \r
 #if ( configQUEUE_REGISTRY_SIZE > 0 )\r
 \r
-       void vQueueAddToRegistry( xQueueHandle xQueue, signed char *pcQueueName )\r
+       void vQueueAddToRegistry( QueueHandle_t xQueue, const char *pcQueueName ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
        {\r
-       unsigned portBASE_TYPE ux;\r
+       UBaseType_t ux;\r
 \r
                /* See if there is an empty space in the registry.  A NULL name denotes\r
                a free slot. */\r
-               for( ux = ( unsigned portBASE_TYPE ) 0U; ux < ( unsigned portBASE_TYPE ) configQUEUE_REGISTRY_SIZE; ux++ )\r
+               for( ux = ( UBaseType_t ) 0U; ux < ( UBaseType_t ) configQUEUE_REGISTRY_SIZE; ux++ )\r
                {\r
                        if( xQueueRegistry[ ux ].pcQueueName == NULL )\r
                        {\r
                                /* Store the information on this queue. */\r
                                xQueueRegistry[ ux ].pcQueueName = pcQueueName;\r
                                xQueueRegistry[ ux ].xHandle = xQueue;\r
+\r
+                               traceQUEUE_REGISTRY_ADD( xQueue, pcQueueName );\r
                                break;\r
                        }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
                }\r
        }\r
 \r
@@ -1775,13 +2172,13 @@ signed portBASE_TYPE xReturn;
 \r
 #if ( configQUEUE_REGISTRY_SIZE > 0 )\r
 \r
-       static void vQueueUnregisterQueue( xQueueHandle xQueue )\r
+       void vQueueUnregisterQueue( QueueHandle_t xQueue )\r
        {\r
-       unsigned portBASE_TYPE ux;\r
+       UBaseType_t ux;\r
 \r
                /* See if the handle of the queue being unregistered in actually in the\r
                registry. */\r
-               for( ux = ( unsigned portBASE_TYPE ) 0U; ux < ( unsigned portBASE_TYPE ) configQUEUE_REGISTRY_SIZE; ux++ )\r
+               for( ux = ( UBaseType_t ) 0U; ux < ( UBaseType_t ) configQUEUE_REGISTRY_SIZE; ux++ )\r
                {\r
                        if( xQueueRegistry[ ux ].xHandle == xQueue )\r
                        {\r
@@ -1789,17 +2186,23 @@ signed portBASE_TYPE xReturn;
                                xQueueRegistry[ ux ].pcQueueName = NULL;\r
                                break;\r
                        }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
                }\r
 \r
-       }\r
+       } /*lint !e818 xQueue could not be pointer to const because it is a typedef. */\r
 \r
 #endif /* configQUEUE_REGISTRY_SIZE */\r
 /*-----------------------------------------------------------*/\r
 \r
 #if ( configUSE_TIMERS == 1 )\r
 \r
-       void vQueueWaitForMessageRestricted( xQueueHandle pxQueue, portTickType xTicksToWait )\r
+       void vQueueWaitForMessageRestricted( QueueHandle_t xQueue, TickType_t xTicksToWait )\r
        {\r
+       Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
+\r
                /* This function should not be called by application code hence the\r
                'Restricted' in its name.  It is not part of the public API.  It is\r
                designed for use by kernel code, and has special calling requirements.\r
@@ -1815,11 +2218,15 @@ signed portBASE_TYPE xReturn;
                the queue is locked, and the calling task blocks on the queue, then the\r
                calling task will be immediately unblocked when the queue is unlocked. */\r
                prvLockQueue( pxQueue );\r
-               if( pxQueue->uxMessagesWaiting == ( unsigned portBASE_TYPE ) 0U )\r
+               if( pxQueue->uxMessagesWaiting == ( UBaseType_t ) 0U )\r
                {\r
                        /* There is nothing in the queue, block for the specified period. */\r
                        vTaskPlaceOnEventListRestricted( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait );\r
                }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
                prvUnlockQueue( pxQueue );\r
        }\r
 \r
@@ -1828,13 +2235,13 @@ signed portBASE_TYPE xReturn;
 \r
 #if ( configUSE_QUEUE_SETS == 1 )\r
 \r
-       xQueueSetHandle xQueueCreateSet( unsigned portBASE_TYPE uxEventQueueLength )\r
+       QueueSetHandle_t xQueueCreateSet( const UBaseType_t uxEventQueueLength )\r
        {\r
-       xQUEUE *pxQueue;\r
+       QueueSetHandle_t pxQueue;\r
 \r
-               pxQueue = xQueueGenericCreate( uxEventQueueLength, sizeof( xQUEUE * ), queueQUEUE_TYPE_SET );\r
+               pxQueue = xQueueGenericCreate( uxEventQueueLength, sizeof( Queue_t * ), queueQUEUE_TYPE_SET );\r
 \r
-               return ( xQueueSetHandle ) pxQueue;\r
+               return pxQueue;\r
        }\r
 \r
 #endif /* configUSE_QUEUE_SETS */\r
@@ -1842,23 +2249,30 @@ signed portBASE_TYPE xReturn;
 \r
 #if ( configUSE_QUEUE_SETS == 1 )\r
 \r
-       portBASE_TYPE xQueueAddToSet( xQueueSetMemberHandle xQueueOrSemaphore, xQueueSetHandle xQueueSet )\r
+       BaseType_t xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet )\r
        {\r
-       portBASE_TYPE xReturn;\r
+       BaseType_t xReturn;\r
 \r
-               if( xQueueOrSemaphore->pxQueueSetContainer != NULL )\r
-               {\r
-                       xReturn = pdFAIL;\r
-               }\r
-               else\r
+               taskENTER_CRITICAL();\r
                {\r
-                       taskENTER_CRITICAL();\r
+                       if( ( ( Queue_t * ) xQueueOrSemaphore )->pxQueueSetContainer != NULL )\r
                        {\r
-                               xQueueOrSemaphore->pxQueueSetContainer = xQueueSet;\r
+                               /* Cannot add a queue/semaphore to more than one queue set. */\r
+                               xReturn = pdFAIL;\r
+                       }\r
+                       else if( ( ( Queue_t * ) xQueueOrSemaphore )->uxMessagesWaiting != ( UBaseType_t ) 0 )\r
+                       {\r
+                               /* Cannot add a queue/semaphore to a queue set if there are already\r
+                               items in the queue/semaphore. */\r
+                               xReturn = pdFAIL;\r
+                       }\r
+                       else\r
+                       {\r
+                               ( ( Queue_t * ) xQueueOrSemaphore )->pxQueueSetContainer = xQueueSet;\r
+                               xReturn = pdPASS;\r
                        }\r
-                       taskEXIT_CRITICAL();\r
-                       xReturn = pdPASS;\r
                }\r
+               taskEXIT_CRITICAL();\r
 \r
                return xReturn;\r
        }\r
@@ -1868,16 +2282,17 @@ signed portBASE_TYPE xReturn;
 \r
 #if ( configUSE_QUEUE_SETS == 1 )\r
 \r
-       portBASE_TYPE xQueueRemoveFromSet( xQueueSetMemberHandle xQueueOrSemaphore, xQueueSetHandle xQueueSet )\r
+       BaseType_t xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet )\r
        {\r
-       portBASE_TYPE xReturn;\r
+       BaseType_t xReturn;\r
+       Queue_t * const pxQueueOrSemaphore = ( Queue_t * ) xQueueOrSemaphore;\r
 \r
-               if( xQueueOrSemaphore->pxQueueSetContainer != xQueueSet )\r
+               if( pxQueueOrSemaphore->pxQueueSetContainer != xQueueSet )\r
                {\r
                        /* The queue was not a member of the set. */\r
                        xReturn = pdFAIL;\r
                }\r
-               else if( xQueueOrSemaphore->uxMessagesWaiting != 0 )\r
+               else if( pxQueueOrSemaphore->uxMessagesWaiting != ( UBaseType_t ) 0 )\r
                {\r
                        /* It is dangerous to remove a queue from a set when the queue is\r
                        not empty because the queue set will still hold pending events for\r
@@ -1889,25 +2304,25 @@ signed portBASE_TYPE xReturn;
                        taskENTER_CRITICAL();\r
                        {\r
                                /* The queue is no longer contained in the set. */\r
-                               xQueueOrSemaphore->pxQueueSetContainer = NULL;\r
+                               pxQueueOrSemaphore->pxQueueSetContainer = NULL;\r
                        }\r
                        taskEXIT_CRITICAL();\r
                        xReturn = pdPASS;\r
                }\r
 \r
                return xReturn;\r
-       }\r
+       } /*lint !e818 xQueueSet could not be declared as pointing to const as it is a typedef. */\r
 \r
 #endif /* configUSE_QUEUE_SETS */\r
 /*-----------------------------------------------------------*/\r
 \r
 #if ( configUSE_QUEUE_SETS == 1 )\r
 \r
-       xQueueSetMemberHandle xQueueSelectFromSet( xQueueSetHandle xQueueSet, portTickType xBlockTimeTicks )\r
+       QueueSetMemberHandle_t xQueueSelectFromSet( QueueSetHandle_t xQueueSet, TickType_t const xTicksToWait )\r
        {\r
-       xQueueSetMemberHandle xReturn = NULL;\r
+       QueueSetMemberHandle_t xReturn = NULL;\r
 \r
-               xQueueGenericReceive( ( xQueueHandle ) xQueueSet, &xReturn, xBlockTimeTicks, pdFALSE );\r
+               ( void ) xQueueGenericReceive( ( QueueHandle_t ) xQueueSet, &xReturn, xTicksToWait, pdFALSE ); /*lint !e961 Casting from one typedef to another is not redundant. */\r
                return xReturn;\r
        }\r
 \r
@@ -1916,11 +2331,11 @@ signed portBASE_TYPE xReturn;
 \r
 #if ( configUSE_QUEUE_SETS == 1 )\r
 \r
-       xQueueSetMemberHandle xQueueSelectFromSetFromISR( xQueueSetHandle xQueueSet )\r
+       QueueSetMemberHandle_t xQueueSelectFromSetFromISR( QueueSetHandle_t xQueueSet )\r
        {\r
-       xQueueSetMemberHandle xReturn = NULL;\r
+       QueueSetMemberHandle_t xReturn = NULL;\r
 \r
-               xQueueReceiveFromISR( ( xQueueHandle ) xQueueSet, &xReturn, NULL );\r
+               ( void ) xQueueReceiveFromISR( ( QueueHandle_t ) xQueueSet, &xReturn, NULL ); /*lint !e961 Casting from one typedef to another is not redundant. */\r
                return xReturn;\r
        }\r
 \r
@@ -1929,11 +2344,13 @@ signed portBASE_TYPE xReturn;
 \r
 #if ( configUSE_QUEUE_SETS == 1 )\r
 \r
-       static portBASE_TYPE prvNotifyQueueSetContainer( xQUEUE *pxQueue, portBASE_TYPE xCopyPosition )\r
+       static BaseType_t prvNotifyQueueSetContainer( const Queue_t * const pxQueue, const BaseType_t xCopyPosition )\r
        {\r
-       xQUEUE *pxQueueSetContainer = pxQueue->pxQueueSetContainer;\r
-       portBASE_TYPE xReturn = pdFALSE;\r
+       Queue_t *pxQueueSetContainer = pxQueue->pxQueueSetContainer;\r
+       BaseType_t xReturn = pdFALSE;\r
 \r
+               /* This function must be called form a critical section. */\r
+       \r
                configASSERT( pxQueueSetContainer );\r
                configASSERT( pxQueueSetContainer->uxMessagesWaiting < pxQueueSetContainer->uxLength );\r
 \r
@@ -1949,11 +2366,34 @@ signed portBASE_TYPE xReturn;
                                        /* The task waiting has a higher priority */\r
                                        xReturn = pdTRUE;\r
                                }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
                        }\r
                }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
 \r
                return xReturn;\r
        }\r
 \r
 #endif /* configUSE_QUEUE_SETS */\r
 \r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r