static void prvSendBuffer( struct usart_module *pxCDCUsart, uint8_t * pcBuffer, size_t xBufferLength );\r
 \r
 /*\r
- * A UART is used for printf() output and CLI input and output.  Configure the\r
- * UART and register prvUARTRxNotificationHandler() to handle UART Rx events.\r
+ * Register the 'standard' sample CLI commands with FreeRTOS+CLI.\r
+ */\r
+extern void vRegisterSampleCLICommands( void );\r
+\r
+/*\r
+ * Configure the UART used for IO.and register prvUARTRxNotificationHandler() \r
+ * to handle UART Rx events.\r
  */\r
 static void prvConfigureUART( struct usart_module *pxCDCUsart );\r
+\r
+/*\r
+ * Callback functions registered with the Atmel UART driver.  Both functions \r
+ * just 'give' a semaphore to unblock a task that may be waiting for a \r
+ * character to be received, or a transmission to complete.\r
+ */\r
 static void prvUARTTxNotificationHandler( const struct usart_module *const pxUSART );\r
 static void prvUARTRxNotificationHandler( const struct usart_module *const pxUSART );\r
 \r
 \r
 void vUARTCommandConsoleStart( uint16_t usStackSize, unsigned portBASE_TYPE uxPriority )\r
 {\r
+       vRegisterSampleCLICommands();\r
+       \r
        /* Create that task that handles the console itself. */\r
        xTaskCreate(    prvUARTCommandConsoleTask,                      /* The task that implements the command console. */\r
                                        ( const int8_t * const ) "CLI",         /* Text name assigned to the task.  This is just to assist debugging.  The kernel does not use this name itself. */\r
 \r
 static void prvSendBuffer( struct usart_module *pxCDCUsart, uint8_t * pcBuffer, size_t xBufferLength )\r
 {\r
-const portTickType xBlockMax50ms = 50 / portTICK_RATE_MS;\r
+const portTickType xBlockMax100ms = 100UL / portTICK_RATE_MS;\r
 \r
        if( xBufferLength > 0 )\r
        {               \r
                \r
                /* Wait for the Tx to complete so the buffer can be reused without\r
                corrupting the data that is being sent. */\r
-               xSemaphoreTake( xTxCompleteSemaphore, xBlockMax50ms );\r
+               xSemaphoreTake( xTxCompleteSemaphore, xBlockMax100ms );\r
        }\r
 }\r
 /*-----------------------------------------------------------*/\r
        configASSERT( xRxCompleteSemaphore );\r
 \r
        /* Take the semaphores so they start in the wanted state.  A block time is\r
-       not necessary, and is therefore set to 0, as it is known that the semaphore s\r
+       not necessary, and is therefore set to 0, as it is known that the semaphores\r
        exists - they have just been created. */\r
        xSemaphoreTake( xTxCompleteSemaphore, 0 );\r
        xSemaphoreTake( xRxCompleteSemaphore, 0 );\r
 
 #define configUSE_MALLOC_FAILED_HOOK   1\r
 #define configUSE_APPLICATION_TASK_TAG 0\r
 #define configUSE_COUNTING_SEMAPHORES  1\r
-#define configGENERATE_RUN_TIME_STATS  0\r
 #define configUSE_QUEUE_SETS                   1\r
 \r
+/* Run time stats related definitions. */\r
+void vMainConfigureTimerForRunTimeStats( void );\r
+unsigned long ulMainGetRunTimeCounterValue( void );\r
+#define configGENERATE_RUN_TIME_STATS  1\r
+#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() vMainConfigureTimerForRunTimeStats()\r
+#define portGET_RUN_TIME_COUNTER_VALUE() ulMainGetRunTimeCounterValue()\r
+\r
 /* Co-routine definitions. */\r
 #define configUSE_CO_ROUTINES                  0\r
 #define configMAX_CO_ROUTINE_PRIORITIES ( 2 )\r
 #define INCLUDE_vTaskDelay                             1\r
 #define INCLUDE_eTaskGetState                  1\r
 \r
+/* This demo makes use of one or more example stats formatting functions.  These\r
+format the raw data provided by the uxTaskGetSystemState() function in to human\r
+readable ASCII form.  See the notes in the implementation of vTaskList() within\r
+FreeRTOS/Source/tasks.c for limitations. */\r
+#define configUSE_STATS_FORMATTING_FUNCTIONS   1\r
+\r
 /* Normal assert() semantics without relying on the provision of an assert.h\r
 header file. */\r
 #define configASSERT( x ) if( ( x ) == 0 ) { taskDISABLE_INTERRUPTS(); for( ;; ); }\r
 
 /* Library includes. */\r
 #include <asf.h>\r
 \r
+/*-----------------------------------------------------------*/\r
+\r
+/*\r
+ * Hardware and driver initialisation can be done in this function.\r
+ */\r
 static void prvSetupHardware( void );\r
+\r
+/* \r
+ * Prototypes for the FreeRTOS hook/callback functions.  See the comments in\r
+ * the implementation of each function for more information.\r
+ */\r
 void vApplicationMallocFailedHook( void );\r
 void vApplicationIdleHook( void );\r
 void vApplicationStackOverflowHook( xTaskHandle pxTask, signed char *pcTaskName );\r
 void vApplicationTickHook( void );\r
 \r
+/*-----------------------------------------------------------*/\r
+\r
+/* Used in the run time stats calculations. */\r
+static unsigned long ulClocksPer10thOfAMilliSecond = 0UL;\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
 int main (void)\r
 {\r
        prvSetupHardware();\r
        code must not attempt to block, and only the interrupt safe FreeRTOS API\r
        functions can be used (those that end in FromISR()). */\r
 }\r
+/*-----------------------------------------------------------*/\r
+\r
+void vMainConfigureTimerForRunTimeStats( void )\r
+{\r
+       /* How many clocks are there per tenth of a millisecond? */\r
+       ulClocksPer10thOfAMilliSecond = configCPU_CLOCK_HZ / 10000UL;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+unsigned long ulMainGetRunTimeCounterValue( void )\r
+{\r
+unsigned long ulSysTickCounts, ulTickCount, ulReturn;\r
+const unsigned long ulSysTickReloadValue = ( configCPU_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL;\r
+volatile unsigned long * const pulCurrentSysTickCount = ( ( volatile unsigned long *) 0xe000e018 );\r
+volatile unsigned long * const pulInterruptCTRLState = ( ( volatile unsigned long *) 0xe000ed04 );\r
+const unsigned long ulSysTickPendingBit = 0x04000000UL;\r
+\r
+       /* NOTE: There are potentially race conditions here.  However, it is used\r
+       anyway to keep the examples simple, and to avoid reliance on a separate\r
+       timer peripheral. */\r
+\r
+\r
+       /* The SysTick is a down counter.  How many clocks have passed since it was\r
+       last reloaded? */\r
+       ulSysTickCounts = ulSysTickReloadValue - *pulCurrentSysTickCount;\r
+       \r
+       /* How many times has it overflowed? */\r
+       ulTickCount = xTaskGetTickCountFromISR();\r
+\r
+       /* This is called from the context switch, so will be called from a\r
+       critical section.  xTaskGetTickCountFromISR() contains its own critical\r
+       section, and the ISR safe critical sections are not designed to nest,\r
+       so reset the critical section. */\r
+       portSET_INTERRUPT_MASK_FROM_ISR();\r
+       \r
+       /* Is there a SysTick interrupt pending? */\r
+       if( ( *pulInterruptCTRLState & ulSysTickPendingBit ) != 0UL )\r
+       {\r
+               /* There is a SysTick interrupt pending, so the SysTick has overflowed\r
+               but the tick count not yet incremented. */\r
+               ulTickCount++;\r
+               \r
+               /* Read the SysTick again, as the overflow might have occurred since\r
+               it was read last. */\r
+               ulSysTickCounts = ulSysTickReloadValue - *pulCurrentSysTickCount;\r
+       }       \r
+       \r
+       /* Convert the tick count into tenths of a millisecond.  THIS ASSUMES\r
+       configTICK_RATE_HZ is 1000! */\r
+       ulReturn = ( ulTickCount * 10UL ) ;\r
+               \r
+       /* Add on the number of tenths of a millisecond that have passed since the\r
+       tick count last got updated. */\r
+       ulReturn += ( ulSysTickCounts / ulClocksPer10thOfAMilliSecond );\r
+       \r
+       return ulReturn;        \r
+}\r
 \r