]> git.sur5r.net Git - freertos/commitdiff
Get CLI functioning in SAMD20 demo.
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Wed, 2 Oct 2013 14:24:38 +0000 (14:24 +0000)
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Wed, 2 Oct 2013 14:24:38 +0000 (14:24 +0000)
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2047 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo.atsuo
FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo/RTOSDemo.cproj
FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo/src/Sample-CLI-commands.c [new file with mode: 0644]
FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo/src/UARTCommandConsole.c [new file with mode: 0644]
FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo/src/UARTCommandConsole.h [new file with mode: 0644]
FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo/src/main.c

index 3a6238b468f3a01018dae3e6f6be256df2f75ce9..c05015591135a7018cf9d0f1d9c37d13f3b57667 100644 (file)
Binary files a/FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo.atsuo and b/FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo.atsuo differ
index 81fb75d466e57556b1991a65dab4bafb9833a237..e3144d198ff08aa9b75a57fd492629e542cfe350 100644 (file)
       <Value>../../../../../FreeRTOS-Plus/Source/FreeRTOS-Plus-CLI</Value>\r
     </ListValues>\r
   </armgcc.compiler.directories.IncludePaths>\r
-  <armgcc.compiler.optimization.level>Optimize (-O1)</armgcc.compiler.optimization.level>\r
   <armgcc.compiler.optimization.OtherFlags>-fdata-sections</armgcc.compiler.optimization.OtherFlags>\r
   <armgcc.compiler.optimization.PrepareFunctionsForGarbageCollection>True</armgcc.compiler.optimization.PrepareFunctionsForGarbageCollection>\r
   <armgcc.compiler.optimization.DebugLevel>Maximum (-g3)</armgcc.compiler.optimization.DebugLevel>\r
     <GenerateEepFile>True</GenerateEepFile>\r
   </PropertyGroup>\r
   <ItemGroup>\r
+    <Compile Include="src\Sample-CLI-commands.c">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+    <Compile Include="src\UARTCommandConsole.c">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
     <None Include="src\ASF\common\services\serial\sam0_usart\usart_serial.h">\r
       <SubType>compile</SubType>\r
     </None>\r
diff --git a/FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo/src/Sample-CLI-commands.c b/FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo/src/Sample-CLI-commands.c
new file mode 100644 (file)
index 0000000..6f0b23d
--- /dev/null
@@ -0,0 +1,426 @@
+/*\r
+    FreeRTOS V7.5.2 - Copyright (C) 2013 Real Time Engineers Ltd.\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
+\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
+     *                                                                       *\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
+     *                                                                       *\r
+     *    >>> See http://www.FreeRTOS.org/Documentation for details. <<<     *\r
+     *                                                                       *\r
+     *    Thank you for using FreeRTOS, and thank you for your support!      *\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
+\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
+\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 itcan 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
+\r
+    1 tab == 4 spaces!\r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    Having a problem?  Start by reading the FAQ "My application does   *\r
+     *    not run, what could be wrong?"                                     *\r
+     *                                                                       *\r
+     *    http://www.FreeRTOS.org/FAQHelp.html                               *\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
+\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
+\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
+\r
+ /******************************************************************************\r
+ *\r
+ * See the following URL for information on the commands defined in this file:\r
+ * http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/Embedded_Ethernet_Examples/Ethernet_Related_CLI_Commands.shtml\r
+ *\r
+ ******************************************************************************/\r
+\r
+\r
+/* FreeRTOS includes. */\r
+#include "FreeRTOS.h"\r
+#include "task.h"\r
+\r
+/* Standard includes. */\r
+#include <stdint.h>\r
+#include <stdio.h>\r
+#include <string.h>\r
+\r
+/* FreeRTOS+CLI includes. */\r
+#include "FreeRTOS_CLI.h"\r
+\r
+#ifndef  configINCLUDE_TRACE_RELATED_CLI_COMMANDS\r
+       #define configINCLUDE_TRACE_RELATED_CLI_COMMANDS 0\r
+#endif\r
+\r
+\r
+/*\r
+ * Implements the run-time-stats command.\r
+ */\r
+static portBASE_TYPE prvTaskStatsCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString );\r
+\r
+/*\r
+ * Implements the task-stats command.\r
+ */\r
+static portBASE_TYPE prvRunTimeStatsCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString );\r
+\r
+/*\r
+ * Implements the echo-three-parameters command.\r
+ */\r
+static portBASE_TYPE prvThreeParameterEchoCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString );\r
+\r
+/*\r
+ * Implements the echo-parameters command.\r
+ */\r
+static portBASE_TYPE prvParameterEchoCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString );\r
+\r
+/*\r
+ * Implements the "trace start" and "trace stop" commands;\r
+ */\r
+#if configINCLUDE_TRACE_RELATED_CLI_COMMANDS == 1\r
+       static portBASE_TYPE prvStartStopTraceCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString );\r
+#endif\r
+\r
+/* Structure that defines the "run-time-stats" command line command.   This\r
+generates a table that shows how much run time each task has */\r
+static const CLI_Command_Definition_t xRunTimeStats =\r
+{\r
+       ( const int8_t * const ) "run-time-stats", /* The command string to type. */\r
+       ( const int8_t * const ) "\r\nrun-time-stats:\r\n Displays a table showing how much processing time each FreeRTOS task has used\r\n",\r
+       prvRunTimeStatsCommand, /* The function to run. */\r
+       0 /* No parameters are expected. */\r
+};\r
+\r
+/* Structure that defines the "task-stats" command line command.  This generates\r
+a table that gives information on each task in the system. */\r
+static const CLI_Command_Definition_t xTaskStats =\r
+{\r
+       ( const int8_t * const ) "task-stats", /* The command string to type. */\r
+       ( const int8_t * const ) "\r\ntask-stats:\r\n Displays a table showing the state of each FreeRTOS task\r\n",\r
+       prvTaskStatsCommand, /* The function to run. */\r
+       0 /* No parameters are expected. */\r
+};\r
+\r
+/* Structure that defines the "echo_3_parameters" command line command.  This\r
+takes exactly three parameters that the command simply echos back one at a\r
+time. */\r
+static const CLI_Command_Definition_t xThreeParameterEcho =\r
+{\r
+       ( const int8_t * const ) "echo-3-parameters",\r
+       ( const int8_t * const ) "\r\necho-3-parameters <param1> <param2> <param3>:\r\n Expects three parameters, echos each in turn\r\n",\r
+       prvThreeParameterEchoCommand, /* The function to run. */\r
+       3 /* Three parameters are expected, which can take any value. */\r
+};\r
+\r
+/* Structure that defines the "echo_parameters" command line command.  This\r
+takes a variable number of parameters that the command simply echos back one at\r
+a time. */\r
+static const CLI_Command_Definition_t xParameterEcho =\r
+{\r
+       ( const int8_t * const ) "echo-parameters",\r
+       ( const int8_t * const ) "\r\necho-parameters <...>:\r\n Take variable number of parameters, echos each in turn\r\n",\r
+       prvParameterEchoCommand, /* The function to run. */\r
+       -1 /* The user can enter any number of commands. */\r
+};\r
+\r
+#if configINCLUDE_TRACE_RELATED_CLI_COMMANDS == 1\r
+       /* Structure that defines the "trace" command line command.  This takes a single\r
+       parameter, which can be either "start" or "stop". */\r
+       static const CLI_Command_Definition_t xStartStopTrace =\r
+       {\r
+               ( const int8_t * const ) "trace",\r
+               ( const int8_t * const ) "\r\ntrace [start | stop]:\r\n Starts or stops a trace recording for viewing in FreeRTOS+Trace\r\n",\r
+               prvStartStopTraceCommand, /* The function to run. */\r
+               1 /* One parameter is expected.  Valid values are "start" and "stop". */\r
+       };\r
+#endif /* configINCLUDE_TRACE_RELATED_CLI_COMMANDS */\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+void vRegisterSampleCLICommands( void )\r
+{\r
+       /* Register all the command line commands defined immediately above. */\r
+       FreeRTOS_CLIRegisterCommand( &xTaskStats );\r
+       FreeRTOS_CLIRegisterCommand( &xRunTimeStats );\r
+       FreeRTOS_CLIRegisterCommand( &xThreeParameterEcho );\r
+       FreeRTOS_CLIRegisterCommand( &xParameterEcho );\r
+\r
+       #if( configINCLUDE_TRACE_RELATED_CLI_COMMANDS == 1 )\r
+       {\r
+               FreeRTOS_CLIRegisterCommand( & xStartStopTrace );\r
+       }\r
+       #endif\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static portBASE_TYPE prvTaskStatsCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString )\r
+{\r
+const int8_t *const pcHeader = ( int8_t * ) "Task          State  Priority  Stack      #\r\n************************************************\r\n";\r
+\r
+       /* Remove compile time warnings about unused parameters, and check the\r
+       write buffer is not NULL.  NOTE - for simplicity, this example assumes the\r
+       write buffer length is adequate, so does not check for buffer overflows. */\r
+       ( void ) pcCommandString;\r
+       ( void ) xWriteBufferLen;\r
+       configASSERT( pcWriteBuffer );\r
+\r
+       /* Generate a table of task stats. */\r
+       strcpy( ( char * ) pcWriteBuffer, ( char * ) pcHeader );\r
+       vTaskList( pcWriteBuffer + strlen( ( char * ) pcHeader ) );\r
+\r
+       /* There is no more data to return after this single string, so return\r
+       pdFALSE. */\r
+       return pdFALSE;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static portBASE_TYPE prvRunTimeStatsCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString )\r
+{\r
+const int8_t * const pcHeader = ( int8_t * ) "Task            Abs Time      % Time\r\n****************************************\r\n";\r
+\r
+       /* Remove compile time warnings about unused parameters, and check the\r
+       write buffer is not NULL.  NOTE - for simplicity, this example assumes the\r
+       write buffer length is adequate, so does not check for buffer overflows. */\r
+       ( void ) pcCommandString;\r
+       ( void ) xWriteBufferLen;\r
+       configASSERT( pcWriteBuffer );\r
+\r
+       /* Generate a table of task stats. */\r
+       strcpy( ( char * ) pcWriteBuffer, ( char * ) pcHeader );\r
+       vTaskGetRunTimeStats( pcWriteBuffer + strlen( ( char * ) pcHeader ) );\r
+\r
+       /* There is no more data to return after this single string, so return\r
+       pdFALSE. */\r
+       return pdFALSE;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static portBASE_TYPE prvThreeParameterEchoCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString )\r
+{\r
+int8_t *pcParameter;\r
+portBASE_TYPE xParameterStringLength, xReturn;\r
+static portBASE_TYPE lParameterNumber = 0;\r
+\r
+       /* Remove compile time warnings about unused parameters, and check the\r
+       write buffer is not NULL.  NOTE - for simplicity, this example assumes the\r
+       write buffer length is adequate, so does not check for buffer overflows. */\r
+       ( void ) pcCommandString;\r
+       ( void ) xWriteBufferLen;\r
+       configASSERT( pcWriteBuffer );\r
+\r
+       if( lParameterNumber == 0 )\r
+       {\r
+               /* The first time the function is called after the command has been\r
+               entered just a header string is returned. */\r
+               sprintf( ( char * ) pcWriteBuffer, "The three parameters were:\r\n" );\r
+\r
+               /* Next time the function is called the first parameter will be echoed\r
+               back. */\r
+               lParameterNumber = 1L;\r
+\r
+               /* There is more data to be returned as no parameters have been echoed\r
+               back yet. */\r
+               xReturn = pdPASS;\r
+       }\r
+       else\r
+       {\r
+               /* Obtain the parameter string. */\r
+               pcParameter = ( int8_t * ) FreeRTOS_CLIGetParameter\r
+                                                                       (\r
+                                                                               pcCommandString,                /* The command string itself. */\r
+                                                                               lParameterNumber,               /* Return the next parameter. */\r
+                                                                               &xParameterStringLength /* Store the parameter string length. */\r
+                                                                       );\r
+\r
+               /* Sanity check something was returned. */\r
+               configASSERT( pcParameter );\r
+\r
+               /* Return the parameter string. */\r
+               memset( pcWriteBuffer, 0x00, xWriteBufferLen );\r
+               sprintf( ( char * ) pcWriteBuffer, "%d: ", ( int ) lParameterNumber );\r
+               strncat( ( char * ) pcWriteBuffer, ( const char * ) pcParameter, xParameterStringLength );\r
+               strncat( ( char * ) pcWriteBuffer, "\r\n", strlen( "\r\n" ) );\r
+\r
+               /* If this is the last of the three parameters then there are no more\r
+               strings to return after this one. */\r
+               if( lParameterNumber == 3L )\r
+               {\r
+                       /* If this is the last of the three parameters then there are no more\r
+                       strings to return after this one. */\r
+                       xReturn = pdFALSE;\r
+                       lParameterNumber = 0L;\r
+               }\r
+               else\r
+               {\r
+                       /* There are more parameters to return after this one. */\r
+                       xReturn = pdTRUE;\r
+                       lParameterNumber++;\r
+               }\r
+       }\r
+\r
+       return xReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static portBASE_TYPE prvParameterEchoCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString )\r
+{\r
+int8_t *pcParameter;\r
+portBASE_TYPE xParameterStringLength, xReturn;\r
+static portBASE_TYPE lParameterNumber = 0;\r
+\r
+       /* Remove compile time warnings about unused parameters, and check the\r
+       write buffer is not NULL.  NOTE - for simplicity, this example assumes the\r
+       write buffer length is adequate, so does not check for buffer overflows. */\r
+       ( void ) pcCommandString;\r
+       ( void ) xWriteBufferLen;\r
+       configASSERT( pcWriteBuffer );\r
+\r
+       if( lParameterNumber == 0 )\r
+       {\r
+               /* The first time the function is called after the command has been\r
+               entered just a header string is returned. */\r
+               sprintf( ( char * ) pcWriteBuffer, "The parameters were:\r\n" );\r
+\r
+               /* Next time the function is called the first parameter will be echoed\r
+               back. */\r
+               lParameterNumber = 1L;\r
+\r
+               /* There is more data to be returned as no parameters have been echoed\r
+               back yet. */\r
+               xReturn = pdPASS;\r
+       }\r
+       else\r
+       {\r
+               /* Obtain the parameter string. */\r
+               pcParameter = ( int8_t * ) FreeRTOS_CLIGetParameter\r
+                                                                       (\r
+                                                                               pcCommandString,                /* The command string itself. */\r
+                                                                               lParameterNumber,               /* Return the next parameter. */\r
+                                                                               &xParameterStringLength /* Store the parameter string length. */\r
+                                                                       );\r
+\r
+               if( pcParameter != NULL )\r
+               {\r
+                       /* Return the parameter string. */\r
+                       memset( pcWriteBuffer, 0x00, xWriteBufferLen );\r
+                       sprintf( ( char * ) pcWriteBuffer, "%d: ", ( int ) lParameterNumber );\r
+                       strncat( ( char * ) pcWriteBuffer, ( const char * ) pcParameter, xParameterStringLength );\r
+                       strncat( ( char * ) pcWriteBuffer, "\r\n", strlen( "\r\n" ) );\r
+\r
+                       /* There might be more parameters to return after this one. */\r
+                       xReturn = pdTRUE;\r
+                       lParameterNumber++;\r
+               }\r
+               else\r
+               {\r
+                       /* No more parameters were found.  Make sure the write buffer does\r
+                       not contain a valid string. */\r
+                       pcWriteBuffer[ 0 ] = 0x00;\r
+\r
+                       /* No more data to return. */\r
+                       xReturn = pdFALSE;\r
+\r
+                       /* Start over the next time this command is executed. */\r
+                       lParameterNumber = 0;\r
+               }\r
+       }\r
+\r
+       return xReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+#if configINCLUDE_TRACE_RELATED_CLI_COMMANDS == 1\r
+\r
+       static portBASE_TYPE prvStartStopTraceCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString )\r
+       {\r
+       int8_t *pcParameter;\r
+       portBASE_TYPE lParameterStringLength;\r
+\r
+               /* Remove compile time warnings about unused parameters, and check the\r
+               write buffer is not NULL.  NOTE - for simplicity, this example assumes the\r
+               write buffer length is adequate, so does not check for buffer overflows. */\r
+               ( void ) pcCommandString;\r
+               ( void ) xWriteBufferLen;\r
+               configASSERT( pcWriteBuffer );\r
+\r
+               /* Obtain the parameter string. */\r
+               pcParameter = ( int8_t * ) FreeRTOS_CLIGetParameter\r
+                                                                       (\r
+                                                                               pcCommandString,                /* The command string itself. */\r
+                                                                               1,                                              /* Return the first parameter. */\r
+                                                                               &lParameterStringLength /* Store the parameter string length. */\r
+                                                                       );\r
+\r
+               /* Sanity check something was returned. */\r
+               configASSERT( pcParameter );\r
+\r
+               /* There are only two valid parameter values. */\r
+               if( strncmp( ( const char * ) pcParameter, "start", strlen( "start" ) ) == 0 )\r
+               {\r
+                       /* Start or restart the trace. */\r
+                       vTraceStop();\r
+                       vTraceClear();\r
+                       vTraceStart();\r
+\r
+                       sprintf( ( char * ) pcWriteBuffer, "Trace recording (re)started.\r\n" );\r
+               }\r
+               else if( strncmp( ( const char * ) pcParameter, "stop", strlen( "stop" ) ) == 0 )\r
+               {\r
+                       /* End the trace, if one is running. */\r
+                       vTraceStop();\r
+                       sprintf( ( char * ) pcWriteBuffer, "Stopping trace recording.\r\n" );\r
+               }\r
+               else\r
+               {\r
+                       sprintf( ( char * ) pcWriteBuffer, "Valid parameters are 'start' and 'stop'.\r\n" );\r
+               }\r
+\r
+               /* There is no more data to return after this single string, so return\r
+               pdFALSE. */\r
+               return pdFALSE;\r
+       }\r
+\r
+#endif /* configINCLUDE_TRACE_RELATED_CLI_COMMANDS */\r
diff --git a/FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo/src/UARTCommandConsole.c b/FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo/src/UARTCommandConsole.c
new file mode 100644 (file)
index 0000000..9bbdca2
--- /dev/null
@@ -0,0 +1,345 @@
+/*\r
+    FreeRTOS V7.5.2 - Copyright (C) 2013 Real Time Engineers Ltd.\r
+\r
+    VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
+\r
+    ***************************************************************************\r
+     *                                                                       *\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
+     *    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
+     *    Thank you!                                                         *\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
+\r
+    >>! NOTE: The modification to the GPL is included to allow you to distribute\r
+    >>! a combined work that includes FreeRTOS without being obliged to provide\r
+    >>! the source code for proprietary components outside of the FreeRTOS\r
+    >>! kernel.\r
+\r
+    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
+    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+    FOR A PARTICULAR PURPOSE.  Full license text is available from the following\r
+    link: http://www.freertos.org/a00114.html\r
+\r
+    1 tab == 4 spaces!\r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    Having a problem?  Start by reading the FAQ "My application does   *\r
+     *    not run, what could be wrong?"                                     *\r
+     *                                                                       *\r
+     *    http://www.FreeRTOS.org/FAQHelp.html                               *\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, a DOS\r
+    compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
+\r
+    http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High\r
+    Integrity Systems to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
+    licenses offer ticketed support, indemnification and middleware.\r
+\r
+    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
+/* Standard includes. */\r
+#include "string.h"\r
+#include "stdio.h"\r
+\r
+/* FreeRTOS includes. */\r
+#include "FreeRTOS.h"\r
+#include "task.h"\r
+#include "queue.h"\r
+#include "semphr.h"\r
+\r
+/* Library includes. */\r
+#include "asf.h"\r
+\r
+/* Example includes. */\r
+#include "FreeRTOS_CLI.h"\r
+#include "UARTCommandConsole.h"\r
+\r
+/* Dimensions the buffer into which input characters are placed. */\r
+#define cmdMAX_INPUT_SIZE              50\r
+\r
+/* The maximum time in ticks to wait for the UART access mutex. */\r
+#define cmdMAX_MUTEX_WAIT              ( 200 / portTICK_RATE_MS )\r
+\r
+/* Characters are only ever received slowly on the CLI so it is ok to pass\r
+received characters from the UART interrupt to the task on a queue.  This sets\r
+the length of the queue used for that purpose. */\r
+#define cmdRXED_CHARS_QUEUE_LENGTH                     ( 10 )\r
+\r
+/* DEL acts as a backspace. */\r
+#define cmdASCII_DEL           ( 0x7F )\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/*\r
+ * The task that implements the command console processing.\r
+ */\r
+static void prvUARTCommandConsoleTask( void *pvParameters );\r
+\r
+/*\r
+ * Ensure a previous interrupt driven Tx has completed before sending the next\r
+ * data block to the UART.
+ */\r
+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
+ */\r
+static void prvConfigureUART( struct usart_module *pxCDCUsart );\r
+static void prvUARTTxNotificationHandler( const struct usart_module *const pxUSART );\r
+static void prvUARTRxNotificationHandler( const struct usart_module *const pxUSART );\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/* Const messages output by the command console. */\r
+static uint8_t * const pcWelcomeMessage = ( uint8_t * ) "\r\n\r\nFreeRTOS command server.\r\nType Help to view a list of registered commands.\r\n\r\n>";\r
+static const uint8_t * const pcEndOfOutputMessage = ( uint8_t * ) "\r\n[Press ENTER to execute the previous command again]\r\n>";\r
+static const uint8_t * const pcNewLine = ( uint8_t * ) "\r\n";\r
+\r
+/* This semaphore is used to allow the task to wait for a Tx to complete\r
+without wasting any CPU time. */\r
+static xSemaphoreHandle xTxCompleteSemaphore = NULL;\r
+\r
+/* This semaphore is sued to allow the task to wait for an Rx to complete\r
+without wasting any CPU time. */\r
+static xSemaphoreHandle xRxCompleteSemaphore = NULL;\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+void vUARTCommandConsoleStart( uint16_t usStackSize, unsigned portBASE_TYPE uxPriority )\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
+                                       usStackSize,                                            /* The size of the stack allocated to the task. */\r
+                                       NULL,                                                           /* The parameter is not used, so NULL is passed. */\r
+                                       uxPriority,                                                     /* The priority allocated to the task. */\r
+                                       NULL );                                                         /* A handle is not required, so just pass NULL. */\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvUARTCommandConsoleTask( void *pvParameters )\r
+{\r
+uint8_t ucRxedChar, ucInputIndex = 0, *pucOutputString;\r
+static int8_t cInputString[ cmdMAX_INPUT_SIZE ], cLastInputString[ cmdMAX_INPUT_SIZE ];\r
+portBASE_TYPE xReturned;\r
+static struct usart_module xCDCUsart; /* Static so it doesn't take up too much stack. */\r
+\r
+       ( void ) pvParameters;\r
+\r
+       /* A UART is used for printf() output and CLI input and output.  Note there\r
+       is no mutual exclusion on the UART, but the demo as it stands does not\r
+       require mutual exclusion. */\r
+       prvConfigureUART( &xCDCUsart );\r
+\r
+       /* Obtain the address of the output buffer.  Note there is no mutual\r
+       exclusion on this buffer as it is assumed only one command console\r
+       interface will be used at any one time. */\r
+       pucOutputString = ( uint8_t * ) FreeRTOS_CLIGetOutputBuffer();\r
+\r
+       /* Send the welcome message. */\r
+       prvSendBuffer( &xCDCUsart, pcWelcomeMessage, strlen( ( char * ) pcWelcomeMessage ) );\r
+\r
+       for( ;; )\r
+       {\r
+               /* Wait for the next character to arrive.  A semaphore is used to\r
+               ensure no CPU time is used until data has arrived. */\r
+               usart_read_buffer_job( &xCDCUsart, &ucRxedChar, sizeof( ucRxedChar ) );         \r
+               if( xSemaphoreTake( xRxCompleteSemaphore, portMAX_DELAY ) == pdPASS )\r
+               {\r
+                       /* Echo the character back. */\r
+                       prvSendBuffer( &xCDCUsart, ( uint8_t * ) &ucRxedChar, sizeof( ucRxedChar ) );\r
+\r
+                       /* Was it the end of the line? */\r
+                       if( ucRxedChar == '\n' || ucRxedChar == '\r' )\r
+                       {\r
+                               /* Just to space the output from the input. */\r
+                               prvSendBuffer( &xCDCUsart, ( uint8_t * ) pcNewLine, strlen( ( char * ) pcNewLine ) );\r
+\r
+                               /* See if the command is empty, indicating that the last command is\r
+                               to be executed again. */\r
+                               if( ucInputIndex == 0 )\r
+                               {\r
+                                       /* Copy the last command back into the input string. */\r
+                                       strcpy( ( char * ) cInputString, ( char * ) cLastInputString );\r
+                               }\r
+\r
+                               /* Pass the received command to the command interpreter.  The\r
+                               command interpreter is called repeatedly until it returns pdFALSE\r
+                               (indicating there is no more output) as it might generate more than\r
+                               one string. */\r
+                               do\r
+                               {\r
+                                       /* Get the next output string from the command interpreter. */\r
+                                       xReturned = FreeRTOS_CLIProcessCommand( cInputString, ( int8_t * ) pucOutputString, configCOMMAND_INT_MAX_OUTPUT_SIZE );\r
+\r
+                                       /* Write the generated string to the UART. */\r
+                                       prvSendBuffer( &xCDCUsart, ( uint8_t * ) pucOutputString, strlen( ( char * ) pucOutputString ) );\r
+\r
+                               } while( xReturned != pdFALSE );\r
+\r
+                               /* All the strings generated by the input command have been sent.\r
+                               Clear the input string ready to receive the next command.  Remember\r
+                               the command that was just processed first in case it is to be\r
+                               processed again. */\r
+                               strcpy( ( char * ) cLastInputString, ( char * ) cInputString );\r
+                               ucInputIndex = 0;\r
+                               memset( cInputString, 0x00, cmdMAX_INPUT_SIZE );\r
+\r
+                               prvSendBuffer( &xCDCUsart, ( uint8_t * ) pcEndOfOutputMessage, strlen( ( char * ) pcEndOfOutputMessage ) );\r
+                       }\r
+                       else\r
+                       {\r
+                               if( ucRxedChar == '\r' )\r
+                               {\r
+                                       /* Ignore the character. */\r
+                               }\r
+                               else if( ( ucRxedChar == '\b' ) || ( ucRxedChar == cmdASCII_DEL ) )\r
+                               {\r
+                                       /* Backspace was pressed.  Erase the last character in the\r
+                                       string - if any. */\r
+                                       if( ucInputIndex > 0 )\r
+                                       {\r
+                                               ucInputIndex--;\r
+                                               cInputString[ ucInputIndex ] = '\0';\r
+                                       }\r
+                               }\r
+                               else\r
+                               {\r
+                                       /* A character was entered.  Add it to the string\r
+                                       entered so far.  When a \n is entered the complete\r
+                                       string will be passed to the command interpreter. */\r
+                                       if( ( ucRxedChar >= ' ' ) && ( ucRxedChar <= '~' ) )\r
+                                       {\r
+                                               if( ucInputIndex < cmdMAX_INPUT_SIZE )\r
+                                               {\r
+                                                       cInputString[ ucInputIndex ] = ucRxedChar;\r
+                                                       ucInputIndex++;\r
+                                               }\r
+                                       }\r
+                               }\r
+                       }\r
+               }\r
+       }\r
+}\r
+/*-----------------------------------------------------------*/\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
+\r
+       if( xBufferLength > 0 )\r
+       {               \r
+               usart_write_buffer_job( pxCDCUsart, pcBuffer, xBufferLength );\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
+       }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvConfigureUART( struct usart_module *pxCDCUsart )\r
+{\r
+struct usart_config xUARTConfig;\r
+\r
+       /* This semaphore is used to allow the task to wait for the Tx to complete\r
+       without wasting any CPU time. */\r
+       vSemaphoreCreateBinary( xTxCompleteSemaphore );\r
+       configASSERT( xTxCompleteSemaphore );\r
+       \r
+       /* This semaphore is used to allow the task to block for an Rx to complete\r
+       without wasting any CPU time. */\r
+       vSemaphoreCreateBinary( xRxCompleteSemaphore );\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
+       exists - they have just been created. */\r
+       xSemaphoreTake( xTxCompleteSemaphore, 0 );\r
+       xSemaphoreTake( xRxCompleteSemaphore, 0 );\r
+\r
+       /* Configure the hardware. */\r
+       usart_get_config_defaults( &xUARTConfig );\r
+       xUARTConfig.baudrate    = 115200;\r
+       xUARTConfig.mux_setting = EDBG_CDC_SERCOM_MUX_SETTING;\r
+       xUARTConfig.pinmux_pad0 = EDBG_CDC_SERCOM_PINMUX_PAD0;\r
+       xUARTConfig.pinmux_pad1 = EDBG_CDC_SERCOM_PINMUX_PAD1;\r
+       xUARTConfig.pinmux_pad2 = EDBG_CDC_SERCOM_PINMUX_PAD2;\r
+       xUARTConfig.pinmux_pad3 = EDBG_CDC_SERCOM_PINMUX_PAD3;\r
+       while( usart_init( pxCDCUsart, EDBG_CDC_MODULE, &xUARTConfig ) != STATUS_OK ) \r
+       {\r
+               /* Nothing to do here.  Should include a timeout really but this is\r
+               init code only. */\r
+       }\r
+       usart_enable( pxCDCUsart );\r
+       \r
+       /* Register the driver callbacks. */\r
+       usart_register_callback( pxCDCUsart, prvUARTTxNotificationHandler, USART_CALLBACK_BUFFER_TRANSMITTED );\r
+       usart_register_callback( pxCDCUsart, prvUARTRxNotificationHandler, USART_CALLBACK_BUFFER_RECEIVED );\r
+       usart_enable_callback( pxCDCUsart, USART_CALLBACK_BUFFER_TRANSMITTED );\r
+       usart_enable_callback( pxCDCUsart, USART_CALLBACK_BUFFER_RECEIVED );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvUARTRxNotificationHandler( const struct usart_module *const pxUSART )\r
+{\r
+portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;\r
+\r
+       /* Remove compiler warnings. */\r
+       ( void ) pxUSART;\r
+\r
+       /* Give the semaphore  to unblock any tasks that might be waiting for an Rx\r
+       to complete.  If a task is unblocked, and the unblocked task has a priority\r
+       above the currently running task, then xHigherPriorityTaskWoken will be set\r
+       to pdTRUE inside the xSemaphoreGiveFromISR() function. */\r
+       xSemaphoreGiveFromISR( xRxCompleteSemaphore, &xHigherPriorityTaskWoken );\r
+\r
+       /* portEND_SWITCHING_ISR() or portYIELD_FROM_ISR() can be used here. */\r
+       portYIELD_FROM_ISR( xHigherPriorityTaskWoken );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvUARTTxNotificationHandler( const struct usart_module *const pxUSART )\r
+{\r
+portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;\r
+\r
+       /* Remove compiler warnings. */\r
+       ( void ) pxUSART;\r
+\r
+       /* Give the semaphore  to unblock any tasks that might be waiting for a Tx\r
+       to complete.  If a task is unblocked, and the unblocked task has a priority\r
+       above the currently running task, then xHigherPriorityTaskWoken will be set\r
+       to pdTRUE inside the xSemaphoreGiveFromISR() function. */\r
+       xSemaphoreGiveFromISR( xTxCompleteSemaphore, &xHigherPriorityTaskWoken );\r
+\r
+       /* portEND_SWITCHING_ISR() or portYIELD_FROM_ISR() can be used here. */\r
+       portYIELD_FROM_ISR( xHigherPriorityTaskWoken );\r
+}\r
+\r
+\r
diff --git a/FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo/src/UARTCommandConsole.h b/FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo/src/UARTCommandConsole.h
new file mode 100644 (file)
index 0000000..fe4507d
--- /dev/null
@@ -0,0 +1,77 @@
+/*\r
+    FreeRTOS V7.5.2 - Copyright (C) 2013 Real Time Engineers Ltd.\r
+\r
+    VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
+\r
+    ***************************************************************************\r
+     *                                                                       *\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
+     *    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
+     *    Thank you!                                                         *\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
+\r
+    >>! NOTE: The modification to the GPL is included to allow you to distribute\r
+    >>! a combined work that includes FreeRTOS without being obliged to provide\r
+    >>! the source code for proprietary components outside of the FreeRTOS\r
+    >>! kernel.\r
+\r
+    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
+    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+    FOR A PARTICULAR PURPOSE.  Full license text is available from the following\r
+    link: http://www.freertos.org/a00114.html\r
+\r
+    1 tab == 4 spaces!\r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    Having a problem?  Start by reading the FAQ "My application does   *\r
+     *    not run, what could be wrong?"                                     *\r
+     *                                                                       *\r
+     *    http://www.FreeRTOS.org/FAQHelp.html                               *\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, a DOS\r
+    compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
+\r
+    http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High\r
+    Integrity Systems to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
+    licenses offer ticketed support, indemnification and middleware.\r
+\r
+    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
+#ifndef UART_COMMAND_CONSOLE_H\r
+#define UART_COMMAND_CONSOLE_H\r
+\r
+/*\r
+ * Create the task that implements a command console using the USB virtual com\r
+ * port driver for intput and output.\r
+ */\r
+void vUARTCommandConsoleStart( uint16_t usStackSize, unsigned portBASE_TYPE uxPriority );\r
+\r
+#endif /* UART_COMMAND_CONSOLE_H */\r
+\r
+\r
+\r
index e8f3ba8e99043b3a23922003672e159534d7e57b..c69fc589f8ea647c0a31abceac12c8e6c5dcd6d7 100644 (file)
 #include "FreeRTOS.h"\r
 #include "task.h"\r
 \r
+/* Demo app includes. */\r
+#include "UARTCommandConsole.h"\r
+\r
 /* Library includes. */\r
 #include <asf.h>\r
 \r
-void usart_read_callback(const struct usart_module *const usart_module);\r
-void usart_write_callback(const struct usart_module *const usart_module);\r
 static void prvSetupHardware( void );\r
-void configure_usart(void);\r
-void configure_usart_callbacks(void);\r
 void vApplicationMallocFailedHook( void );\r
 void vApplicationIdleHook( void );\r
 void vApplicationStackOverflowHook( xTaskHandle pxTask, signed char *pcTaskName );\r
 void vApplicationTickHook( void );\r
 \r
-struct usart_module usart_instance;\r
-#define MAX_RX_BUFFER_LENGTH   5\r
-volatile uint8_t rx_buffer[MAX_RX_BUFFER_LENGTH];\r
-#define NUM 1024\r
-char cChars[ NUM ] = { 0 };\r
-\r
-void usart_read_callback(const struct usart_module *const usart_module)\r
-{\r
-       usart_write_buffer_job(&usart_instance, (uint8_t *)rx_buffer, MAX_RX_BUFFER_LENGTH);\r
-}\r
-\r
-void usart_write_callback(const struct usart_module *const usart_module)\r
-{\r
-       port_pin_toggle_output_level(LED_0_PIN);\r
-}\r
-\r
-void configure_usart(void)\r
-{\r
-       struct usart_config config_usart;\r
-       usart_get_config_defaults(&config_usart);\r
-       config_usart.baudrate    = 115200;\r
-       config_usart.mux_setting = EDBG_CDC_SERCOM_MUX_SETTING;\r
-       config_usart.pinmux_pad0 = EDBG_CDC_SERCOM_PINMUX_PAD0;\r
-       config_usart.pinmux_pad1 = EDBG_CDC_SERCOM_PINMUX_PAD1;\r
-       config_usart.pinmux_pad2 = EDBG_CDC_SERCOM_PINMUX_PAD2;\r
-       config_usart.pinmux_pad3 = EDBG_CDC_SERCOM_PINMUX_PAD3;\r
-       while (usart_init(&usart_instance,\r
-       EDBG_CDC_MODULE, &config_usart) != STATUS_OK) {\r
-       }\r
-       usart_enable(&usart_instance);\r
-}\r
-\r
-void configure_usart_callbacks(void)\r
-{\r
-       usart_register_callback(&usart_instance,\r
-       usart_write_callback, USART_CALLBACK_BUFFER_TRANSMITTED);\r
-       usart_register_callback(&usart_instance,\r
-       usart_read_callback, USART_CALLBACK_BUFFER_RECEIVED);\r
-       usart_enable_callback(&usart_instance, USART_CALLBACK_BUFFER_TRANSMITTED);\r
-       usart_enable_callback(&usart_instance, USART_CALLBACK_BUFFER_RECEIVED);\r
-}\r
-\r
-\r
-\r
-\r
 int main (void)\r
 {\r
        prvSetupHardware();\r
-\r
-       configure_usart();\r
-       configure_usart_callbacks();\r
-       system_interrupt_enable_global();\r
-\r
-       uint8_t string[] = "Hello World!\r\n";\r
-       usart_write_buffer_job(&usart_instance, string, sizeof(string));\r
-\r
-\r
-\r
-       while (true) {\r
-               usart_read_buffer_job(&usart_instance,\r
-               (uint8_t *)rx_buffer, MAX_RX_BUFFER_LENGTH);\r
-       }\r
-\r
-       while (1) {\r
-               if (port_pin_get_input_level(BUTTON_0_PIN) == BUTTON_0_ACTIVE) {\r
-                       port_pin_set_output_level(LED_0_PIN, LED_0_ACTIVE);\r
-               } else {\r
-                       port_pin_set_output_level(LED_0_PIN, !LED_0_ACTIVE);\r
-               }\r
-       }\r
+       vUARTCommandConsoleStart( ( configMINIMAL_STACK_SIZE * 3 ), tskIDLE_PRIORITY ); \r
+       \r
+       /* Start the scheduler. */\r
+       vTaskStartScheduler();\r
+\r
+       /* If all is well, the scheduler will now be running, and the following line\r
+       will never be reached.  If the following line does execute, then there was\r
+       insufficient FreeRTOS heap memory available for the idle and/or timer tasks\r
+       to be created.  See the memory management section on the FreeRTOS web site\r
+       for more details. */\r
+       for( ;; );\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r