]> 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 2698099f57842122b9b9c031e6919e959e7b46ef..b571297254f92c1168bfead0d071cdcf8bcfa7c1 100644 (file)
@@ -1,48 +1,38 @@
 /*\r
-    FreeRTOS V7.4.2 - Copyright (C) 2013 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
+    Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
 \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.\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.  See the GNU General Public License for more\r
-    details. You should have received a copy of the GNU General Public License\r
-    and the FreeRTOS license exception along with FreeRTOS; if not it can be\r
-    viewed here: http://www.freertos.org/a00114.html and also obtained by\r
-    writing to Real Time Engineers Ltd., contact details for whom are available\r
-    on the FreeRTOS WEB site.\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, 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, and our new\r
-    fully thread aware and reentrant UDP/IP stack.\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, who sell the code with commercial support,\r
-    indemnification and middleware, under the OpenRTOS brand.\r
+    Integrity Systems to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
+    licenses offer ticketed support, indemnification and middleware.\r
 \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
@@ -88,17 +79,20 @@ task.h is included from an application file. */
        #include "croutine.h"\r
 #endif\r
 \r
-#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE\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
-/* 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
+/* 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 xQUEUE structure is used to represent a base queue its pcHead and\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
-xQUEUE structure is used to represent a mutex pcHead and pcTail pointers are\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
@@ -113,10 +107,16 @@ structure member). */
 \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
+#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
@@ -124,37 +124,36 @@ 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
-\r
-       signed char *pcWriteTo;                                 /*< Points to the free next place in the storage area. */\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
-       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
+       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
-               signed char *pcReadFrom;                        /*< Points to the last place that a queued item was read from when the structure is used as a queue. */\r
-               unsigned portBASE_TYPE uxRecursiveCallCount;/*< Maintains a count of the numebr of times a recursive mutex has been recursively 'taken' when the structure is used as a mutex. */\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
@@ -168,14 +167,14 @@ typedef struct QueueDefinition
        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
 #endif /* configQUEUE_REGISTRY_SIZE */\r
 \r
@@ -187,39 +186,39 @@ typedef struct QueueDefinition
  * 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( xQUEUE *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 xQUEUE *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 xQUEUE *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 ) PRIVILEGED_FUNCTION;\r
+       static BaseType_t prvNotifyQueueSetContainer( const Queue_t * const pxQueue, const BaseType_t xCopyPosition ) PRIVILEGED_FUNCTION;\r
 #endif\r
 \r
 /*-----------------------------------------------------------*/\r
@@ -243,19 +242,18 @@ static void prvCopyDataFromQueue( xQUEUE * const pxQueue, const void *pvBuffer )
        taskEXIT_CRITICAL()\r
 /*-----------------------------------------------------------*/\r
 \r
-portBASE_TYPE xQueueGenericReset( xQueueHandle xQueue, portBASE_TYPE xNewQueue )\r
+BaseType_t xQueueGenericReset( QueueHandle_t xQueue, BaseType_t xNewQueue )\r
 {\r
-xQUEUE *pxQueue;\r
+Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
 \r
-       pxQueue = ( xQUEUE * ) xQueue;\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->u.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
@@ -263,16 +261,24 @@ xQUEUE *pxQueue;
                {\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
@@ -289,34 +295,34 @@ xQUEUE *pxQueue;
 }\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
@@ -339,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
@@ -349,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
@@ -373,9 +387,9 @@ xQueueHandle xReturn = NULL;
                        /* 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
@@ -398,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
@@ -414,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( ( ( xQUEUE * ) xSemaphore )->uxQueueType == queueQUEUE_IS_MUTEX )\r
+                       if( ( ( Queue_t * ) xSemaphore )->uxQueueType == queueQUEUE_IS_MUTEX )\r
                        {\r
-                               pxReturn = ( void * ) ( ( xQUEUE * ) xSemaphore )->pxMutexHolder;\r
+                               pxReturn = ( void * ) ( ( Queue_t * ) xSemaphore )->pxMutexHolder;\r
                        }\r
                        else\r
                        {\r
@@ -444,12 +458,11 @@ xQueueHandle xReturn = NULL;
 \r
 #if ( configUSE_RECURSIVE_MUTEXES == 1 )\r
 \r
-       portBASE_TYPE xQueueGiveMutexRecursive( xQueueHandle xMutex )\r
+       BaseType_t xQueueGiveMutexRecursive( QueueHandle_t xMutex )\r
        {\r
-       portBASE_TYPE xReturn;\r
-       xQUEUE *pxMutex;\r
+       BaseType_t xReturn;\r
+       Queue_t * const pxMutex = ( Queue_t * ) xMutex;\r
 \r
-               pxMutex = ( xQUEUE * ) xMutex;\r
                configASSERT( pxMutex );\r
 \r
                /* If this is the task that holds the mutex then pxMutexHolder will not\r
@@ -458,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 == ( void * ) 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
@@ -470,11 +483,15 @@ xQueueHandle xReturn = NULL;
                        ( pxMutex->u.uxRecursiveCallCount )--;\r
 \r
                        /* Have we unwound the call count? */\r
-                       if( pxMutex->u.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
@@ -495,12 +512,11 @@ xQueueHandle xReturn = NULL;
 \r
 #if ( configUSE_RECURSIVE_MUTEXES == 1 )\r
 \r
-       portBASE_TYPE xQueueTakeMutexRecursive( xQueueHandle xMutex, portTickType xBlockTime )\r
+       BaseType_t xQueueTakeMutexRecursive( QueueHandle_t xMutex, TickType_t xTicksToWait )\r
        {\r
-       portBASE_TYPE xReturn;\r
-       xQUEUE *pxMutex;\r
+       BaseType_t xReturn;\r
+       Queue_t * const pxMutex = ( Queue_t * ) xMutex;\r
 \r
-               pxMutex = ( xQUEUE * ) xMutex;\r
                configASSERT( pxMutex );\r
 \r
                /* Comments regarding mutual exclusion as per those within\r
@@ -508,14 +524,14 @@ xQueueHandle xReturn = NULL;
 \r
                traceTAKE_MUTEX_RECURSIVE( pxMutex );\r
 \r
-               if( pxMutex->pxMutexHolder == ( void * )  xTaskGetCurrentTaskHandle() )\r
+               if( pxMutex->pxMutexHolder == ( void * ) xTaskGetCurrentTaskHandle() ) /*lint !e961 Cast is not redundant as TaskHandle_t is a typedef. */\r
                {\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
@@ -537,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 xHandle;\r
+       QueueHandle_t xHandle;\r
+\r
+               configASSERT( uxMaxCount != 0 );\r
+               configASSERT( uxInitialCount <= uxMaxCount );\r
 \r
-               xHandle = 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( xHandle != NULL )\r
                {\r
-                       ( ( xQUEUE * ) xHandle )->uxMessagesWaiting = uxInitialCount;\r
+                       ( ( Queue_t * ) xHandle )->uxMessagesWaiting = uxInitialCount;\r
 \r
                        traceCREATE_COUNTING_SEMAPHORE();\r
                }\r
@@ -561,15 +580,21 @@ xQueueHandle xReturn = NULL;
 #endif /* configUSE_COUNTING_SEMAPHORES */\r
 /*-----------------------------------------------------------*/\r
 \r
-signed portBASE_TYPE xQueueGenericSend( xQueueHandle xQueue, 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
-xQUEUE *pxQueue;\r
+BaseType_t xEntryTimeSet = pdFALSE;\r
+TimeOut_t xTimeOut;\r
+Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
 \r
-       pxQueue = ( xQUEUE * ) xQueue;\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
@@ -578,9 +603,11 @@ xQUEUE *pxQueue;
        {\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
@@ -594,7 +621,11 @@ xQUEUE *pxQueue;
                                                        /* 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
@@ -609,8 +640,16 @@ xQUEUE *pxQueue;
                                                                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
@@ -626,9 +665,17 @@ xQUEUE *pxQueue;
                                                        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
@@ -640,7 +687,7 @@ xQUEUE *pxQueue;
                        }\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
@@ -658,6 +705,11 @@ xQUEUE *pxQueue;
                                        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
@@ -717,15 +769,14 @@ xQUEUE *pxQueue;
 \r
 #if ( configUSE_ALTERNATIVE_API == 1 )\r
 \r
-       signed portBASE_TYPE xQueueAltGenericSend( xQueueHandle xQueue, 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
-       xQUEUE *pxQueue;\r
+       BaseType_t xEntryTimeSet = pdFALSE;\r
+       TimeOut_t xTimeOut;\r
+       Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
 \r
-               pxQueue = ( xQUEUE * ) xQueue;\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
@@ -748,6 +799,14 @@ xQUEUE *pxQueue;
                                                        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
@@ -755,7 +814,7 @@ xQUEUE *pxQueue;
                                }\r
                                else\r
                                {\r
-                                       if( xTicksToWait == ( portTickType ) 0 )\r
+                                       if( xTicksToWait == ( TickType_t ) 0 )\r
                                        {\r
                                                taskEXIT_CRITICAL();\r
                                                return errQUEUE_FULL;\r
@@ -779,6 +838,10 @@ xQUEUE *pxQueue;
                                                vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToSend ), xTicksToWait );\r
                                                portYIELD_WITHIN_API();\r
                                        }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
                                }\r
                                else\r
                                {\r
@@ -796,22 +859,21 @@ xQUEUE *pxQueue;
 \r
 #if ( configUSE_ALTERNATIVE_API == 1 )\r
 \r
-       signed portBASE_TYPE xQueueAltGenericReceive( xQueueHandle xQueue, 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
-       xQUEUE *pxQueue;\r
+       BaseType_t xEntryTimeSet = pdFALSE;\r
+       TimeOut_t xTimeOut;\r
+       int8_t *pcOriginalReadPosition;\r
+       Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
 \r
-               pxQueue = ( xQUEUE * ) xQueue;\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->u.pcReadFrom;\r
@@ -822,7 +884,7 @@ xQUEUE *pxQueue;
                                        {\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
@@ -831,7 +893,11 @@ xQUEUE *pxQueue;
                                                        {\r
                                                                /* Record the information required to implement\r
                                                                priority inheritance should it become necessary. */\r
-                                                               pxQueue->pxMutexHolder = ( void * ) xTaskGetCurrentTaskHandle();\r
+                                                               pxQueue->pxMutexHolder = ( int8_t * ) xTaskGetCurrentTaskHandle();\r
+                                                       }\r
+                                                       else\r
+                                                       {\r
+                                                               mtCOVERAGE_TEST_MARKER();\r
                                                        }\r
                                                }\r
                                                #endif\r
@@ -842,6 +908,10 @@ xQUEUE *pxQueue;
                                                        {\r
                                                                portYIELD_WITHIN_API();\r
                                                        }\r
+                                                       else\r
+                                                       {\r
+                                                               mtCOVERAGE_TEST_MARKER();\r
+                                                       }\r
                                                }\r
                                        }\r
                                        else\r
@@ -863,8 +933,15 @@ xQUEUE *pxQueue;
                                                                /* 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
@@ -872,7 +949,7 @@ xQUEUE *pxQueue;
                                }\r
                                else\r
                                {\r
-                                       if( xTicksToWait == ( portTickType ) 0 )\r
+                                       if( xTicksToWait == ( TickType_t ) 0 )\r
                                        {\r
                                                taskEXIT_CRITICAL();\r
                                                traceQUEUE_RECEIVE_FAILED( pxQueue );\r
@@ -899,11 +976,15 @@ xQUEUE *pxQueue;
                                                {\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
@@ -911,6 +992,10 @@ xQUEUE *pxQueue;
                                                vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait );\r
                                                portYIELD_WITHIN_API();\r
                                        }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
                                }\r
                                else\r
                                {\r
@@ -927,30 +1012,46 @@ xQUEUE *pxQueue;
 #endif /* configUSE_ALTERNATIVE_API */\r
 /*-----------------------------------------------------------*/\r
 \r
-signed portBASE_TYPE xQueueGenericSendFromISR( xQueueHandle xQueue, 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
-xQUEUE *pxQueue;\r
+BaseType_t xReturn;\r
+UBaseType_t uxSavedInterruptStatus;\r
+Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
 \r
-       pxQueue = ( xQUEUE * ) xQueue;\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
@@ -967,6 +1068,14 @@ xQUEUE *pxQueue;
                                                        {\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
@@ -981,8 +1090,20 @@ xQUEUE *pxQueue;
                                                                {\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
@@ -997,8 +1118,20 @@ xQUEUE *pxQueue;
                                                        {\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
@@ -1023,16 +1156,20 @@ xQUEUE *pxQueue;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-signed portBASE_TYPE xQueueGenericReceive( xQueueHandle xQueue, 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
-xQUEUE *pxQueue;\r
+BaseType_t xEntryTimeSet = pdFALSE;\r
+TimeOut_t xTimeOut;\r
+int8_t *pcOriginalReadPosition;\r
+Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
 \r
-       pxQueue = ( xQUEUE * ) xQueue;\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
@@ -1044,9 +1181,10 @@ xQUEUE *pxQueue;
                {\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
+                               /* Remember the read position in case the queue is only being\r
+                               peeked. */\r
                                pcOriginalReadPosition = pxQueue->u.pcReadFrom;\r
 \r
                                prvCopyDataFromQueue( pxQueue, pvBuffer );\r
@@ -1055,7 +1193,7 @@ xQUEUE *pxQueue;
                                {\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
@@ -1064,7 +1202,11 @@ xQUEUE *pxQueue;
                                                {\r
                                                        /* Record the information required to implement\r
                                                        priority inheritance should it become necessary. */\r
-                                                       pxQueue->pxMutexHolder = ( void * ) 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
@@ -1073,9 +1215,17 @@ xQUEUE *pxQueue;
                                        {\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
@@ -1094,8 +1244,16 @@ xQUEUE *pxQueue;
                                                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
@@ -1104,7 +1262,7 @@ xQUEUE *pxQueue;
                        }\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
@@ -1119,6 +1277,11 @@ xQUEUE *pxQueue;
                                        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
@@ -1140,11 +1303,15 @@ xQUEUE *pxQueue;
                                {\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
@@ -1155,6 +1322,10 @@ xQUEUE *pxQueue;
                                {\r
                                        portYIELD_WITHIN_API();\r
                                }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
                        }\r
                        else\r
                        {\r
@@ -1174,29 +1345,45 @@ xQUEUE *pxQueue;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-signed portBASE_TYPE xQueueReceiveFromISR( xQueueHandle xQueue, 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
-xQUEUE *pxQueue;\r
+BaseType_t xReturn;\r
+UBaseType_t uxSavedInterruptStatus;\r
+Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
 \r
-       pxQueue = ( xQUEUE * ) xQueue;\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
@@ -1209,8 +1396,20 @@ xQUEUE *pxQueue;
                                                {\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
@@ -1233,37 +1432,109 @@ xQUEUE *pxQueue;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-unsigned portBASE_TYPE uxQueueMessagesWaiting( const xQueueHandle xQueue )\r
+BaseType_t xQueuePeekFromISR( QueueHandle_t xQueue,  void * const pvBuffer )\r
+{\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
-unsigned portBASE_TYPE uxReturn;\r
+UBaseType_t uxReturn;\r
 \r
        configASSERT( xQueue );\r
 \r
        taskENTER_CRITICAL();\r
-               uxReturn = ( ( xQUEUE * ) xQueue )->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 xQueue )\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
+       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 = ( ( xQUEUE * ) xQueue )->uxMessagesWaiting;\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 xQueue )\r
+void vQueueDelete( QueueHandle_t xQueue )\r
 {\r
-xQUEUE *pxQueue;\r
+Queue_t * const pxQueue = ( Queue_t * ) xQueue;\r
 \r
-       pxQueue = ( xQUEUE * ) xQueue;\r
        configASSERT( pxQueue );\r
 \r
        traceQUEUE_DELETE( pxQueue );\r
@@ -1272,16 +1543,19 @@ xQUEUE *pxQueue;
                vQueueUnregisterQueue( pxQueue );\r
        }\r
        #endif\r
-       vPortFree( pxQueue->pcHead );\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 xQueue )\r
+       UBaseType_t uxQueueGetQueueNumber( QueueHandle_t xQueue )\r
        {\r
-               return ( ( xQUEUE * ) xQueue )->ucQueueNumber;\r
+               return ( ( Queue_t * ) xQueue )->uxQueueNumber;\r
        }\r
 \r
 #endif /* configUSE_TRACE_FACILITY */\r
@@ -1289,9 +1563,9 @@ xQUEUE *pxQueue;
 \r
 #if ( configUSE_TRACE_FACILITY == 1 )\r
 \r
-       void vQueueSetQueueNumber( xQueueHandle xQueue, unsigned char ucQueueNumber )\r
+       void vQueueSetQueueNumber( QueueHandle_t xQueue, UBaseType_t uxQueueNumber )\r
        {\r
-               ( ( xQUEUE * ) xQueue )->ucQueueNumber = ucQueueNumber;\r
+               ( ( Queue_t * ) xQueue )->uxQueueNumber = uxQueueNumber;\r
        }\r
 \r
 #endif /* configUSE_TRACE_FACILITY */\r
@@ -1299,17 +1573,17 @@ xQUEUE *pxQueue;
 \r
 #if ( configUSE_TRACE_FACILITY == 1 )\r
 \r
-       unsigned char ucQueueGetQueueType( xQueueHandle xQueue )\r
+       uint8_t ucQueueGetQueueType( QueueHandle_t xQueue )\r
        {\r
-               return ( ( xQUEUE * ) xQueue )->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
@@ -1319,47 +1593,87 @@ 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, ( size_t ) 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->u.pcReadFrom, pvItemToQueue, ( size_t ) pxQueue->uxItemSize );\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 )\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
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
        }\r
 \r
        ++( pxQueue->uxMessagesWaiting );\r
 }\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->u.pcReadFrom += pxQueue->uxItemSize;\r
-               if( pxQueue->u.pcReadFrom >= pxQueue->pcTail )\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
-               memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->u.pcReadFrom, ( size_t ) pxQueue->uxItemSize );\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\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( xQUEUE *pxQueue )\r
+static void prvUnlockQueue( Queue_t * const pxQueue )\r
 {\r
        /* THIS FUNCTION MUST BE CALLED WITH THE SCHEDULER SUSPENDED. */\r
 \r
@@ -1385,6 +1699,10 @@ static void prvUnlockQueue( xQUEUE *pxQueue )
                                                A context switch is required. */\r
                                                vTaskMissedYield();\r
                                        }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
                                }\r
                                else\r
                                {\r
@@ -1398,6 +1716,10 @@ static void prvUnlockQueue( xQUEUE *pxQueue )
                                                        context switch is required. */\r
                                                        vTaskMissedYield();\r
                                                }\r
+                                               else\r
+                                               {\r
+                                                       mtCOVERAGE_TEST_MARKER();\r
+                                               }\r
                                        }\r
                                        else\r
                                        {\r
@@ -1417,6 +1739,10 @@ static void prvUnlockQueue( xQUEUE *pxQueue )
                                                context switch is required. */\r
                                                vTaskMissedYield();\r
                                        }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
                                }\r
                                else\r
                                {\r
@@ -1443,6 +1769,10 @@ static void prvUnlockQueue( xQUEUE *pxQueue )
                                {\r
                                        vTaskMissedYield();\r
                                }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
 \r
                                --( pxQueue->xRxLock );\r
                        }\r
@@ -1458,13 +1788,13 @@ static void prvUnlockQueue( xQUEUE *pxQueue )
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-static signed portBASE_TYPE prvIsQueueEmpty( const xQUEUE *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
        {\r
-               if( pxQueue->uxMessagesWaiting == 0 )\r
+               if( pxQueue->uxMessagesWaiting == ( UBaseType_t )  0 )\r
                {\r
                        xReturn = pdTRUE;\r
                }\r
@@ -1479,12 +1809,12 @@ signed portBASE_TYPE xReturn;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-signed portBASE_TYPE xQueueIsQueueEmptyFromISR( const xQueueHandle xQueue )\r
+BaseType_t xQueueIsQueueEmptyFromISR( const QueueHandle_t xQueue )\r
 {\r
-signed portBASE_TYPE xReturn;\r
+BaseType_t xReturn;\r
 \r
        configASSERT( xQueue );\r
-       if( ( ( xQUEUE * ) xQueue )->uxMessagesWaiting == 0 )\r
+       if( ( ( Queue_t * ) xQueue )->uxMessagesWaiting == ( UBaseType_t ) 0 )\r
        {\r
                xReturn = pdTRUE;\r
        }\r
@@ -1494,12 +1824,12 @@ signed portBASE_TYPE xReturn;
        }\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 xQUEUE *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
        {\r
@@ -1518,12 +1848,12 @@ signed portBASE_TYPE xReturn;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-signed portBASE_TYPE xQueueIsQueueFullFromISR( const xQueueHandle xQueue )\r
+BaseType_t xQueueIsQueueFullFromISR( const QueueHandle_t xQueue )\r
 {\r
-signed portBASE_TYPE xReturn;\r
+BaseType_t xReturn;\r
 \r
        configASSERT( xQueue );\r
-       if( ( ( xQUEUE * ) xQueue )->uxMessagesWaiting == ( ( xQUEUE * ) xQueue )->uxLength )\r
+       if( ( ( Queue_t * ) xQueue )->uxMessagesWaiting == ( ( Queue_t * ) xQueue )->uxLength )\r
        {\r
                xReturn = pdTRUE;\r
        }\r
@@ -1533,17 +1863,15 @@ signed portBASE_TYPE xReturn;
        }\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 xQueue, 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
-       xQUEUE *pxQueue;\r
-\r
-               pxQueue = ( xQUEUE * ) xQueue;\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
@@ -1554,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
@@ -1592,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
@@ -1609,23 +1945,21 @@ signed portBASE_TYPE xReturn;
 \r
 #if ( configUSE_CO_ROUTINES == 1 )\r
 \r
-       signed portBASE_TYPE xQueueCRReceive( xQueueHandle xQueue, void *pvBuffer, portTickType xTicksToWait )\r
+       BaseType_t xQueueCRReceive( QueueHandle_t xQueue, void *pvBuffer, TickType_t xTicksToWait )\r
        {\r
-       signed portBASE_TYPE xReturn;\r
-       xQUEUE *pxQueue;\r
-\r
-               pxQueue = ( xQUEUE * ) xQueue;\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
@@ -1639,12 +1973,16 @@ signed portBASE_TYPE xReturn;
                                        return errQUEUE_FULL;\r
                                }\r
                        }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
                }\r
                portENABLE_INTERRUPTS();\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->u.pcReadFrom += pxQueue->uxItemSize;\r
@@ -1652,8 +1990,12 @@ signed portBASE_TYPE xReturn;
                                {\r
                                        pxQueue->u.pcReadFrom = pxQueue->pcHead;\r
                                }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
                                --( pxQueue->uxMessagesWaiting );\r
-                               memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->u.pcReadFrom, ( unsigned ) pxQueue->uxItemSize );\r
+                               ( void ) memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->u.pcReadFrom, ( unsigned ) pxQueue->uxItemSize );\r
 \r
                                xReturn = pdPASS;\r
 \r
@@ -1668,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
@@ -1685,11 +2035,9 @@ signed portBASE_TYPE xReturn;
 \r
 #if ( configUSE_CO_ROUTINES == 1 )\r
 \r
-       signed portBASE_TYPE xQueueCRSendFromISR( xQueueHandle xQueue, const void *pvItemToQueue, signed portBASE_TYPE xCoRoutinePreviouslyWoken )\r
+       BaseType_t xQueueCRSendFromISR( QueueHandle_t xQueue, const void *pvItemToQueue, BaseType_t xCoRoutinePreviouslyWoken )\r
        {\r
-       xQUEUE *pxQueue;\r
-\r
-               pxQueue = ( xQUEUE * ) xQueue;\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
@@ -1707,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
@@ -1719,16 +2083,14 @@ signed portBASE_TYPE xReturn;
 \r
 #if ( configUSE_CO_ROUTINES == 1 )\r
 \r
-       signed portBASE_TYPE xQueueCRReceiveFromISR( xQueueHandle xQueue, 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
-       xQUEUE * pxQueue;\r
-\r
-               pxQueue = ( xQUEUE * ) xQueue;\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->u.pcReadFrom += pxQueue->uxItemSize;\r
@@ -1736,8 +2098,12 @@ signed portBASE_TYPE xReturn;
                        {\r
                                pxQueue->u.pcReadFrom = pxQueue->pcHead;\r
                        }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
                        --( pxQueue->uxMessagesWaiting );\r
-                       memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->u.pcReadFrom, ( unsigned ) pxQueue->uxItemSize );\r
+                       ( void ) memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->u.pcReadFrom, ( unsigned ) pxQueue->uxItemSize );\r
 \r
                        if( ( *pxCoRoutineWoken ) == pdFALSE )\r
                        {\r
@@ -1747,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
@@ -1765,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
@@ -1788,13 +2172,13 @@ signed portBASE_TYPE xReturn;
 \r
 #if ( configQUEUE_REGISTRY_SIZE > 0 )\r
 \r
-       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
@@ -1802,20 +2186,22 @@ 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 xQueue, portTickType xTicksToWait )\r
+       void vQueueWaitForMessageRestricted( QueueHandle_t xQueue, TickType_t xTicksToWait )\r
        {\r
-       xQUEUE *pxQueue;\r
-\r
-               pxQueue = ( xQUEUE * ) xQueue;\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
@@ -1832,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
@@ -1845,11 +2235,11 @@ 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
-       xQueueSetHandle 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 pxQueue;\r
        }\r
@@ -1859,30 +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( ( ( xQUEUE * ) xQueueOrSemaphore )->pxQueueSetContainer != NULL )\r
-               {\r
-                       /* Cannot add a queue/semaphore to more than one queue set. */\r
-                       xReturn = pdFAIL;\r
-               }\r
-               else if( ( ( xQUEUE * ) xQueueOrSemaphore )->uxMessagesWaiting != 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
+               taskENTER_CRITICAL();\r
                {\r
-                       taskENTER_CRITICAL();\r
+                       if( ( ( Queue_t * ) xQueueOrSemaphore )->pxQueueSetContainer != NULL )\r
                        {\r
-                               ( ( xQUEUE * ) 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
@@ -1892,19 +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
-       xQUEUE *pxQueueOrSemaphore;\r
-\r
-               pxQueueOrSemaphore = ( xQUEUE * ) xQueueOrSemaphore;\r
+       BaseType_t xReturn;\r
+       Queue_t * const pxQueueOrSemaphore = ( Queue_t * ) xQueueOrSemaphore;\r
 \r
                if( pxQueueOrSemaphore->pxQueueSetContainer != xQueueSet )\r
                {\r
                        /* The queue was not a member of the set. */\r
                        xReturn = pdFAIL;\r
                }\r
-               else if( pxQueueOrSemaphore->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
@@ -1923,18 +2311,18 @@ signed portBASE_TYPE xReturn;
                }\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
@@ -1943,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
@@ -1956,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
@@ -1976,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