]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/WIN32-MingW/main_full.c
Ensure both one-shot and auto-reload are written consistently with a hyphen in comments.
[freertos] / FreeRTOS / Demo / WIN32-MingW / main_full.c
index adec022118ce9ddc81d1f5db34160ddc24068920..718c1e1b0a86edcc052fc646f43a7855cdecd2ce 100644 (file)
@@ -1,78 +1,36 @@
 /*\r
-    FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd.\r
-    All rights reserved\r
-\r
-    VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\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
-\r
-    ***************************************************************************\r
-    >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
-    >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
-    >>!   obliged to provide the source code for proprietary components     !<<\r
-    >>!   outside of the FreeRTOS kernel.                                   !<<\r
-    ***************************************************************************\r
-\r
-    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
-    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
-    FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
-    link: http://www.freertos.org/a00114.html\r
-\r
-    ***************************************************************************\r
-     *                                                                       *\r
-     *    FreeRTOS provides completely free yet professionally developed,    *\r
-     *    robust, strictly quality controlled, supported, and cross          *\r
-     *    platform software that is more than just the market leader, it     *\r
-     *    is the industry's de facto standard.                               *\r
-     *                                                                       *\r
-     *    Help yourself get started quickly while simultaneously helping     *\r
-     *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
-     *    tutorial book, reference manual, or both:                          *\r
-     *    http://www.FreeRTOS.org/Documentation                              *\r
-     *                                                                       *\r
-    ***************************************************************************\r
-\r
-    http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
-    the FAQ page "My application does not run, what could be wrong?".  Have you\r
-    defined configASSERT()?\r
-\r
-    http://www.FreeRTOS.org/support - In return for receiving this top quality\r
-    embedded software for free we request you assist our global community by\r
-    participating in the support forum.\r
-\r
-    http://www.FreeRTOS.org/training - Investing in training allows your team to\r
-    be as productive as possible as early as possible.  Now you can receive\r
-    FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
-    Ltd, and the world's leading authority on the world's leading RTOS.\r
-\r
-    http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\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.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
-    Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
-\r
-    http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
-    Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
-    licenses offer ticketed support, indemnification and commercial 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
+ * FreeRTOS Kernel V10.2.1\r
+ * Copyright (C) 2019 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
+ * this software and associated documentation files (the "Software"), to deal in\r
+ * the Software without restriction, including without limitation the rights to\r
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
+ * the Software, and to permit persons to whom the Software is furnished to do so,\r
+ * subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be included in all\r
+ * copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+ *\r
+ * http://www.FreeRTOS.org\r
+ * http://aws.amazon.com/freertos\r
+ *\r
+ * 1 tab == 4 spaces!\r
+ */\r
 \r
 /*\r
  *******************************************************************************\r
  * NOTE 1: The Win32 port is a simulation (or is that emulation?) only!  Do not\r
  * expect to get real time behaviour from the Win32 port or this demo\r
  * application.  It is provided as a convenient development and demonstration\r
- * test bed only.  This was tested using Windows XP on a dual core laptop.\r
+ * test bed only.\r
  *\r
  * Windows will not be running the FreeRTOS simulator threads continuously, so\r
  * the timing information in the FreeRTOS+Trace logs have no meaningful units.\r
@@ -88,7 +46,7 @@
  * in main.c.  This file implements the comprehensive test and demo version.\r
  *\r
  * NOTE 3:  This file only contains the source code that is specific to the\r
- * basic demo.  Generic functions, such FreeRTOS hook functions, are defined in\r
+ * full demo.  Generic functions, such FreeRTOS hook functions, are defined in\r
  * main.c.\r
  *******************************************************************************\r
  *\r
 \r
 /* Kernel includes. */\r
 #include <FreeRTOS.h>\r
-#include "task.h"\r
-#include "queue.h"\r
-#include "timers.h"\r
-#include "semphr.h"\r
+#include <task.h>\r
+#include <queue.h>\r
+#include <timers.h>\r
+#include <semphr.h>\r
 \r
 /* Standard demo includes. */\r
 #include "BlockQ.h"\r
 #include "EventGroupsDemo.h"\r
 #include "IntSemTest.h"\r
 #include "TaskNotify.h"\r
+#include "QueueSetPolling.h"\r
+#include "StaticAllocation.h"\r
+#include "blocktim.h"\r
+#include "AbortDelay.h"\r
+#include "MessageBufferDemo.h"\r
+#include "StreamBufferDemo.h"\r
+#include "StreamBufferInterrupt.h"\r
+#include "MessageBufferAMP.h"\r
 \r
 /* Priorities at which the tasks are created. */\r
 #define mainCHECK_TASK_PRIORITY                        ( configMAX_PRIORITIES - 2 )\r
 \r
 #define mainTIMER_TEST_PERIOD                  ( 50 )\r
 \r
+/*\r
+ * Exercises code that is not otherwise covered by the standard demo/test\r
+ * tasks.\r
+ */\r
+extern BaseType_t xRunCodeCoverageTestAdditions( void );\r
+\r
 /* Task function prototypes. */\r
 static void prvCheckTask( void *pvParameters );\r
 \r
@@ -179,15 +151,37 @@ static void prvDemonstratePendingFunctionCall( void );
  */\r
 static void prvPendedFunction( void *pvParameter1, uint32_t ulParameter2 );\r
 \r
+/*\r
+ * prvDemonstrateTimerQueryFunctions() is called from the idle task hook\r
+ * function to demonstrate the use of functions that query information about a\r
+ * software timer.  prvTestTimerCallback() is the callback function for the\r
+ * timer being queried.\r
+ */\r
+static void prvDemonstrateTimerQueryFunctions( void );\r
+static void prvTestTimerCallback( TimerHandle_t xTimer );\r
+\r
 /*\r
  * A task to demonstrate the use of the xQueueSpacesAvailable() function.\r
  */\r
 static void prvDemoQueueSpaceFunctions( void *pvParameters );\r
 \r
+/*\r
+ * Tasks that ensure indefinite delays are truly indefinite.\r
+ */\r
+static void prvPermanentlyBlockingSemaphoreTask( void *pvParameters );\r
+static void prvPermanentlyBlockingNotificationTask( void *pvParameters );\r
+\r
+/*\r
+ * The test function and callback function used when exercising the timer AP\r
+ * function that changes the timer's auto-reload mode.\r
+ */\r
+static void prvDemonstrateChangingTimerReloadMode( void *pvParameters );\r
+static void prvReloadModeTestTimerCallback( TimerHandle_t xTimer );\r
+\r
 /*-----------------------------------------------------------*/\r
 \r
 /* The variable into which error messages are latched. */\r
-static char *pcStatusMessage = "OK";\r
+static char *pcStatusMessage = "No errors";\r
 \r
 /* This semaphore is created purely to test using the vSemaphoreDelete() and\r
 semaphore tracing API functions.  It has no other purpose. */\r
@@ -214,9 +208,27 @@ int main_full( void )
        vStartDynamicPriorityTasks();\r
        vStartQueueSetTasks();\r
        vStartQueueOverwriteTask( mainQUEUE_OVERWRITE_PRIORITY );\r
-       xTaskCreate( prvDemoQueueSpaceFunctions, "QSpace", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );\r
+       xTaskCreate( prvDemoQueueSpaceFunctions, NULL, configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL ); /* Name is null for code coverage. */\r
        vStartEventGroupTasks();\r
        vStartInterruptSemaphoreTasks();\r
+       vStartQueueSetPollingTask();\r
+       vCreateBlockTimeTasks();\r
+       vCreateAbortDelayTasks();\r
+       xTaskCreate( prvDemoQueueSpaceFunctions, "QSpace", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );\r
+       xTaskCreate( prvPermanentlyBlockingSemaphoreTask, "BlockSem", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );\r
+       xTaskCreate( prvPermanentlyBlockingNotificationTask, "BlockNoti", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );\r
+       xTaskCreate( prvDemonstrateChangingTimerReloadMode, "TimerMode", configMINIMAL_STACK_SIZE, NULL, configMAX_PRIORITIES - 1, NULL );\r
+\r
+       vStartMessageBufferTasks( configMINIMAL_STACK_SIZE );\r
+       vStartStreamBufferTasks();\r
+       vStartStreamBufferInterruptDemo();\r
+       vStartMessageBufferAMPTasks( configMINIMAL_STACK_SIZE );\r
+\r
+       #if( configSUPPORT_STATIC_ALLOCATION == 1 )\r
+       {\r
+               vStartStaticallyAllocatedTasks();\r
+       }\r
+       #endif\r
 \r
        #if( configUSE_PREEMPTION != 0  )\r
        {\r
@@ -238,16 +250,17 @@ int main_full( void )
        /* Start the scheduler itself. */\r
        vTaskStartScheduler();\r
 \r
-    /* Should never get here unless there was not enough heap space to create\r
+       /* Should never get here unless there was not enough heap space to create\r
        the idle and other system tasks. */\r
-    return 0;\r
+       return 0;\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
 static void prvCheckTask( void *pvParameters )\r
 {\r
 TickType_t xNextWakeTime;\r
-const TickType_t xCycleFrequency = 2500 / portTICK_PERIOD_MS;\r
+const TickType_t xCycleFrequency = pdMS_TO_TICKS( 2500UL );\r
+HeapStats_t xHeapStats;\r
 \r
        /* Just to remove compiler warning. */\r
        ( void ) pvParameters;\r
@@ -271,12 +284,19 @@ const TickType_t xCycleFrequency = 2500 / portTICK_PERIOD_MS;
                }\r
                #endif\r
 \r
-               if( xAreTaskNotificationTasksStillRunning() != pdTRUE )\r
+               if( xAreStreamBufferTasksStillRunning() != pdTRUE )\r
+               {\r
+                       pcStatusMessage = "Error:  StreamBuffer";\r
+               }\r
+               else if( xAreMessageBufferTasksStillRunning() != pdTRUE )\r
+               {\r
+                       pcStatusMessage = "Error:  MessageBuffer";\r
+               }\r
+               else if( xAreTaskNotificationTasksStillRunning() != pdTRUE )\r
                {\r
                        pcStatusMessage = "Error:  Notification";\r
                }\r
-\r
-               if( xAreInterruptSemaphoreTasksStillRunning() != pdTRUE )\r
+               else if( xAreInterruptSemaphoreTasksStillRunning() != pdTRUE )\r
                {\r
                        pcStatusMessage = "Error: IntSem";\r
                }\r
@@ -284,10 +304,10 @@ const TickType_t xCycleFrequency = 2500 / portTICK_PERIOD_MS;
                {\r
                        pcStatusMessage = "Error: EventGroup";\r
                }\r
-           else if( xAreIntegerMathsTaskStillRunning() != pdTRUE )\r
-           {\r
+               else if( xAreIntegerMathsTaskStillRunning() != pdTRUE )\r
+               {\r
                        pcStatusMessage = "Error: IntMath";\r
-           }\r
+               }\r
                else if( xAreGenericQueueTasksStillRunning() != pdTRUE )\r
                {\r
                        pcStatusMessage = "Error: GenQueue";\r
@@ -300,20 +320,20 @@ const TickType_t xCycleFrequency = 2500 / portTICK_PERIOD_MS;
                {\r
                        pcStatusMessage = "Error: BlockQueue";\r
                }\r
-           else if( xAreSemaphoreTasksStillRunning() != pdTRUE )\r
-           {\r
+               else if( xAreSemaphoreTasksStillRunning() != pdTRUE )\r
+               {\r
                        pcStatusMessage = "Error: SemTest";\r
-           }\r
-           else if( xArePollingQueuesStillRunning() != pdTRUE )\r
-           {\r
+               }\r
+               else if( xArePollingQueuesStillRunning() != pdTRUE )\r
+               {\r
                        pcStatusMessage = "Error: PollQueue";\r
-           }\r
+               }\r
                else if( xAreMathsTaskStillRunning() != pdPASS )\r
                {\r
                        pcStatusMessage = "Error: Flop";\r
                }\r
-           else if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )\r
-           {\r
+               else if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )\r
+               {\r
                        pcStatusMessage = "Error: RecMutex";\r
                }\r
                else if( xAreCountingSemaphoreTasksStillRunning() != pdTRUE )\r
@@ -336,10 +356,49 @@ const TickType_t xCycleFrequency = 2500 / portTICK_PERIOD_MS;
                {\r
                        pcStatusMessage = "Error: Queue overwrite";\r
                }\r
+               else if( xAreQueueSetPollTasksStillRunning() != pdPASS )\r
+               {\r
+                       pcStatusMessage = "Error: Queue set polling";\r
+               }\r
+               else if( xAreBlockTimeTestTasksStillRunning() != pdPASS )\r
+               {\r
+                       pcStatusMessage = "Error: Block time";\r
+               }\r
+               else if( xAreAbortDelayTestTasksStillRunning() != pdPASS )\r
+               {\r
+                       pcStatusMessage = "Error: Abort delay";\r
+               }\r
+               else if( xIsInterruptStreamBufferDemoStillRunning() != pdPASS )\r
+               {\r
+                       pcStatusMessage = "Error: Stream buffer interrupt";\r
+               }\r
+               else if( xAreMessageBufferAMPTasksStillRunning() != pdPASS )\r
+               {\r
+                       pcStatusMessage = "Error: Message buffer AMP";\r
+               }\r
+\r
+               #if( configSUPPORT_STATIC_ALLOCATION == 1 )\r
+                       else if( xAreStaticAllocationTasksStillRunning() != pdPASS )\r
+                       {\r
+                               pcStatusMessage = "Error: Static allocation";\r
+                       }\r
+               #endif /* configSUPPORT_STATIC_ALLOCATION */\r
 \r
                /* This is the only task that uses stdout so its ok to call printf()\r
                directly. */\r
-               printf( ( char * ) "%s - %u\r\n", pcStatusMessage, ( unsigned int ) xTaskGetTickCount() );\r
+               vPortGetHeapStats( &xHeapStats );\r
+\r
+               configASSERT( xHeapStats.xAvailableHeapSpaceInBytes == xPortGetFreeHeapSize() );\r
+               configASSERT( xHeapStats.xMinimumEverFreeBytesRemaining == xPortGetMinimumEverFreeHeapSize() );\r
+\r
+               printf( "%s - tick count %u - free heap %u - min free heap %u - largest free block %u - number of free blocks %u\r\n",\r
+                                       pcStatusMessage,\r
+                                       xTaskGetTickCount(),\r
+                                       xHeapStats.xAvailableHeapSpaceInBytes,\r
+                                       xHeapStats.xMinimumEverFreeBytesRemaining,\r
+                                       xHeapStats.xSizeOfLargestFreeBlockInBytes,\r
+                                       xHeapStats.xNumberOfFreeBlocks );\r
+\r
                fflush( stdout );\r
        }\r
 }\r
@@ -381,26 +440,61 @@ void *pvAllocated;
        demonstrated by any of the standard demo tasks. */\r
        prvDemonstratePendingFunctionCall();\r
 \r
+       /* Demonstrate the use of functions that query information about a software\r
+       timer. */\r
+       prvDemonstrateTimerQueryFunctions();\r
+\r
        /* If xMutexToDelete has not already been deleted, then delete it now.\r
        This is done purely to demonstrate the use of, and test, the\r
        vSemaphoreDelete() macro.  Care must be taken not to delete a semaphore\r
        that has tasks blocked on it. */\r
        if( xMutexToDelete != NULL )\r
        {\r
+               /* For test purposes, add the mutex to the registry, then remove it\r
+               again, before it is deleted - checking its name is as expected before\r
+               and after the assertion into the registry and its removal from the\r
+               registry. */\r
+               configASSERT( pcQueueGetName( xMutexToDelete ) == NULL );\r
+               vQueueAddToRegistry( xMutexToDelete, "Test_Mutex" );\r
+               configASSERT( strcmp( pcQueueGetName( xMutexToDelete ), "Test_Mutex" ) == 0 );\r
+               vQueueUnregisterQueue( xMutexToDelete );\r
+               configASSERT( pcQueueGetName( xMutexToDelete ) == NULL );\r
+\r
                vSemaphoreDelete( xMutexToDelete );\r
                xMutexToDelete = NULL;\r
        }\r
 \r
        /* Exercise heap_5 a bit.  The malloc failed hook will trap failed\r
        allocations so there is no need to test here. */\r
-       pvAllocated = pvPortMalloc( ( rand() % 100 ) + 1 );\r
+       pvAllocated = pvPortMalloc( ( rand() % 500 ) + 1 );\r
        vPortFree( pvAllocated );\r
+\r
+       /* Exit after a fixed time so code coverage results are written to the\r
+       disk. */\r
+       #if( projCOVERAGE_TEST == 1 )\r
+       {\r
+               const TickType_t xMaxRunTime = pdMS_TO_TICKS( 30000UL );\r
+\r
+               /* Exercise code not otherwise executed by standard demo/test tasks. */\r
+               if( xRunCodeCoverageTestAdditions() != pdPASS )\r
+               {\r
+                       pcStatusMessage = "Code coverage additions failed.\r\n";\r
+               }\r
+\r
+               if( ( xTaskGetTickCount() - configINITIAL_TICK_COUNT ) >= xMaxRunTime )\r
+               {\r
+                       vTaskEndScheduler();\r
+               }\r
+       }\r
+       #endif\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
 /* Called by vApplicationTickHook(), which is defined in main.c. */\r
 void vFullDemoTickHookFunction( void )\r
 {\r
+TaskHandle_t xTimerTask;\r
+\r
        /* Call the periodic timer test, which tests the timer API functions that\r
        can be called from an ISR. */\r
        #if( configUSE_PREEMPTION != 0 )\r
@@ -416,6 +510,7 @@ void vFullDemoTickHookFunction( void )
        /* Write to a queue that is in use as part of the queue set demo to\r
        demonstrate using queue sets from an ISR. */\r
        vQueueSetAccessQueueSetFromISR();\r
+       vQueueSetPollingInterruptAccess();\r
 \r
        /* Exercise event groups from interrupts. */\r
        vPeriodicEventGroupsProcessing();\r
@@ -425,6 +520,19 @@ void vFullDemoTickHookFunction( void )
 \r
        /* Exercise using task notifications from an interrupt. */\r
        xNotifyTaskFromISR();\r
+\r
+       /* Writes to stream buffer byte by byte to test the stream buffer trigger\r
+       level functionality. */\r
+       vPeriodicStreamBufferProcessing();\r
+\r
+       /* Writes a string to a string buffer four bytes at a time to demonstrate\r
+       a stream being sent from an interrupt to a task. */\r
+       vBasicStreamBufferSendFromISR();\r
+\r
+       /* For code coverage purposes. */\r
+       xTimerTask = xTimerGetTimerDaemonTaskHandle();\r
+       configASSERT( uxTaskPriorityGetFromISR( xTimerTask ) == configTIMER_TASK_PRIORITY );\r
+       ( void ) xTimerTask; /* In case configASSERT() is not defined. */\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
@@ -442,6 +550,57 @@ uint32_t ulParameter1;
        /* Remember the parameters for the next time the function is called. */\r
        ulLastParameter1 = ulParameter1;\r
        ulLastParameter2 = ulParameter2;\r
+\r
+       /* Remove compiler warnings in case configASSERT() is not defined. */\r
+       ( void ) ulLastParameter1;\r
+       ( void ) ulLastParameter2;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvTestTimerCallback( TimerHandle_t xTimer )\r
+{\r
+       /* This is the callback function for the timer accessed by\r
+       prvDemonstrateTimerQueryFunctions().  The callback does not do anything. */\r
+       ( void ) xTimer;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvDemonstrateTimerQueryFunctions( void )\r
+{\r
+static TimerHandle_t xTimer = NULL;\r
+const char *pcTimerName = "TestTimer";\r
+volatile TickType_t xExpiryTime;\r
+const TickType_t xDontBlock = 0;\r
+\r
+       if( xTimer == NULL )\r
+       {\r
+               xTimer = xTimerCreate( pcTimerName, portMAX_DELAY, pdTRUE, NULL, prvTestTimerCallback );\r
+\r
+               if( xTimer != NULL )\r
+               {\r
+                       /* Called from the idle task so a block time must not be\r
+                       specified. */\r
+                       xTimerStart( xTimer, xDontBlock );\r
+               }\r
+       }\r
+\r
+       if( xTimer != NULL )\r
+       {\r
+               /* Demonstrate querying a timer's name. */\r
+               configASSERT( strcmp( pcTimerGetName( xTimer ), pcTimerName ) == 0 );\r
+\r
+               /* Demonstrate querying a timer's period. */\r
+               configASSERT( xTimerGetPeriod( xTimer ) == portMAX_DELAY );\r
+\r
+               /* Demonstrate querying a timer's next expiry time, although nothing is\r
+               done with the returned value.  Note if the expiry time is less than the\r
+               maximum tick count then the expiry time has overflowed from the current\r
+               time.  In this case the expiry time was set to portMAX_DELAY, so it is\r
+               expected to be less than the current time until the current time has\r
+               itself overflowed. */\r
+               xExpiryTime = xTimerGetExpiryTime( xTimer );\r
+               ( void ) xExpiryTime;\r
+       }\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
@@ -466,6 +625,10 @@ TaskHandle_t xIdleTaskHandle, xTimerTaskHandle;
 char *pcTaskName;\r
 static portBASE_TYPE xPerformedOneShotTests = pdFALSE;\r
 TaskHandle_t xTestTask;\r
+TaskStatus_t xTaskInfo;\r
+extern StackType_t uxTimerTaskStack[];\r
+static TickType_t xLastIdleExecutionTime = 0;\r
+TickType_t xIdleExecutionTime;\r
 \r
        /* Demonstrate the use of the xTimerGetTimerDaemonTaskHandle() and\r
        xTaskGetIdleTaskHandle() functions.  Also try using the function that sets\r
@@ -480,13 +643,30 @@ TaskHandle_t xTestTask;
                pcStatusMessage = "Error:  Returned idle task handle was incorrect";\r
        }\r
 \r
+       /* Check the same handle is obtained using the idle task's name.  First try\r
+       with the wrong name, then the right name. */\r
+       if( xTaskGetHandle( "Idle" ) == xIdleTaskHandle )\r
+       {\r
+               pcStatusMessage = "Error:  Returned handle for name Idle was incorrect";\r
+       }\r
+\r
+       if( xTaskGetHandle( "IDLE" ) != xIdleTaskHandle )\r
+       {\r
+               pcStatusMessage = "Error:  Returned handle for name Idle was incorrect";\r
+       }\r
+\r
        /* Check the timer task handle was returned correctly. */\r
-       pcTaskName = pcTaskGetTaskName( xTimerTaskHandle );\r
+       pcTaskName = pcTaskGetName( xTimerTaskHandle );\r
        if( strcmp( pcTaskName, "Tmr Svc" ) != 0 )\r
        {\r
                pcStatusMessage = "Error:  Returned timer task handle was incorrect";\r
        }\r
 \r
+       if( xTaskGetHandle( "Tmr Svc" ) != xTimerTaskHandle )\r
+       {\r
+               pcStatusMessage = "Error:  Returned handle for name Tmr Svc was incorrect";\r
+       }\r
+\r
        /* This task is running, make sure it's state is returned as running. */\r
        if( eTaskStateGet( xIdleTaskHandle ) != eRunning )\r
        {\r
@@ -499,6 +679,22 @@ TaskHandle_t xTestTask;
                pcStatusMessage = "Error:  Returned timer task state was incorrect";\r
        }\r
 \r
+       /* Also with the vTaskGetInfo() function. */\r
+       vTaskGetInfo( xTimerTaskHandle, /* The task being queried. */\r
+                                         &xTaskInfo,           /* The structure into which information on the task will be written. */\r
+                                         pdTRUE,                       /* Include the task's high watermark in the structure. */\r
+                                         eInvalid );           /* Include the task state in the structure. */\r
+\r
+       /* Check the information returned by vTaskGetInfo() is as expected. */\r
+       if( ( xTaskInfo.eCurrentState != eBlocked )                                              ||\r
+               ( strcmp( xTaskInfo.pcTaskName, "Tmr Svc" ) != 0 )                       ||\r
+               ( xTaskInfo.uxCurrentPriority != configTIMER_TASK_PRIORITY ) ||\r
+               ( xTaskInfo.pxStackBase != uxTimerTaskStack )                            ||\r
+               ( xTaskInfo.xHandle != xTimerTaskHandle ) )\r
+       {\r
+               pcStatusMessage = "Error:  vTaskGetInfo() returned incorrect information about the timer task";\r
+       }\r
+\r
        /* Other tests that should only be performed once follow.  The test task\r
        is not created on each iteration because to do so would cause the death\r
        task to report an error (too many tasks running). */\r
@@ -531,6 +727,13 @@ TaskHandle_t xTestTask;
                        }\r
                }\r
        }\r
+\r
+       xIdleExecutionTime = xTaskGetIdleRunTimeCounter();\r
+       if( xIdleExecutionTime == xLastIdleExecutionTime )\r
+       {\r
+               pcStatusMessage = "Error: Total amount of Idle task execution time did not change";\r
+       }\r
+       xLastIdleExecutionTime = xIdleExecutionTime;\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
@@ -602,5 +805,103 @@ unsigned portBASE_TYPE uxReturn, x;
                #endif\r
        }\r
 }\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvPermanentlyBlockingSemaphoreTask( void *pvParameters )\r
+{\r
+SemaphoreHandle_t xSemaphore;\r
+\r
+       /* Prevent compiler warning about unused parameter in the case that\r
+       configASSERT() is not defined. */\r
+       ( void ) pvParameters;\r
+\r
+       /* This task should block on a semaphore, and never return. */\r
+       xSemaphore = xSemaphoreCreateBinary();\r
+       configASSERT( xSemaphore );\r
+\r
+       xSemaphoreTake( xSemaphore, portMAX_DELAY );\r
+\r
+       /* The above xSemaphoreTake() call should never return, force an assert if\r
+       it does. */\r
+       configASSERT( pvParameters != NULL );\r
+       vTaskDelete( NULL );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvPermanentlyBlockingNotificationTask( void *pvParameters )\r
+{\r
+       /* Prevent compiler warning about unused parameter in the case that\r
+       configASSERT() is not defined. */\r
+       ( void ) pvParameters;\r
+\r
+       /* This task should block on a task notification, and never return. */\r
+       ulTaskNotifyTake( pdTRUE, portMAX_DELAY );\r
+\r
+       /* The above ulTaskNotifyTake() call should never return, force an assert\r
+       if it does. */\r
+       configASSERT( pvParameters != NULL );\r
+       vTaskDelete( NULL );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvReloadModeTestTimerCallback( TimerHandle_t xTimer )\r
+{\r
+uint32_t ulTimerID;\r
+\r
+       /* Increment the timer's ID to show the callback has executed. */\r
+       ulTimerID = ( uint32_t ) pvTimerGetTimerID( xTimer );\r
+       ulTimerID++;\r
+       vTimerSetTimerID( xTimer, ( void * ) ulTimerID );\r
+}\r
+/*-----------------------------------------------------------*/\r
 \r
+static void prvDemonstrateChangingTimerReloadMode( void *pvParameters )\r
+{\r
+TimerHandle_t xTimer;\r
+const char * const pcTimerName = "TestTimer";\r
+const TickType_t x100ms = pdMS_TO_TICKS( 100UL );\r
+\r
+       /* Avoid compiler warnings about unused parameter. */\r
+       ( void ) pvParameters;\r
 \r
+       xTimer = xTimerCreate(  pcTimerName,\r
+                                                       x100ms,\r
+                                                       pdFALSE, /* Created as a one-shot timer. */\r
+                                                       0,\r
+                                                       prvReloadModeTestTimerCallback );\r
+       configASSERT( xTimer );\r
+       configASSERT( xTimerIsTimerActive( xTimer ) == pdFALSE );\r
+       configASSERT( xTimerGetTimerDaemonTaskHandle() != NULL );\r
+       configASSERT( strcmp( pcTimerName, pcTimerGetName( xTimer ) ) == 0 );\r
+       configASSERT( xTimerGetPeriod( xTimer ) == x100ms );\r
+\r
+       /* Timer was created as a one-shot timer.  Its callback just increments the\r
+       timer's ID - so set the ID to 0, let the timer run for a number of timeout\r
+       periods, then check the timer has only executed once. */\r
+       vTimerSetTimerID( xTimer, ( void * ) 0 );\r
+       xTimerStart( xTimer, portMAX_DELAY );\r
+       vTaskDelay( 3UL * x100ms );\r
+       configASSERT( ( ( uint32_t ) ( pvTimerGetTimerID( xTimer ) ) ) == 1UL );\r
+\r
+       /* Now change the timer to be an auto-reload timer and check it executes\r
+       the expected number of times. */\r
+       vTimerSetReloadMode( xTimer, pdTRUE );\r
+       vTimerSetTimerID( xTimer, ( void * ) 0 );\r
+       xTimerStart( xTimer, 0 );\r
+       vTaskDelay( ( 3UL * x100ms ) + ( x100ms / 2UL ) ); /* Three full periods. */\r
+       configASSERT( ( uint32_t ) ( pvTimerGetTimerID( xTimer ) ) == 3UL );\r
+       configASSERT( xTimerStop( xTimer, 0 ) != pdFAIL );\r
+\r
+       /* Now change the timer back to be a one-shot timer and check it only\r
+       executes once. */\r
+       vTimerSetReloadMode( xTimer, pdFALSE );\r
+       vTimerSetTimerID( xTimer, ( void * ) 0 );\r
+       xTimerStart( xTimer, 0 );\r
+       vTaskDelay( 3UL * x100ms );\r
+       configASSERT( xTimerStop( xTimer, 0 ) != pdFAIL );\r
+       configASSERT( ( uint32_t ) ( pvTimerGetTimerID( xTimer ) ) == 1UL );\r
+\r
+       /* Clean up at the end. */\r
+       xTimerDelete( xTimer, portMAX_DELAY );\r
+       vTaskDelete( NULL );\r
+}\r