]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/CORTEX_SmartFusion2_M2S050_SoftConsole/RTOSDemo/Full-Demo/UARTCommandConsole.c
Update version number to 9.0.0rc2.
[freertos] / FreeRTOS / Demo / CORTEX_SmartFusion2_M2S050_SoftConsole / RTOSDemo / Full-Demo / UARTCommandConsole.c
index 380215b67aba1aa229f3d2ac37ab5ebdb3d42442..6875add7345839fdc1a01230f1b7f1befd58fb28 100644 (file)
@@ -1,60 +1,64 @@
 /*\r
-    FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd. \r
+    FreeRTOS V9.0.0rc2 - Copyright (C) 2016 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
-    ***************************************************************************\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
+    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
+    >>!   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 from the following\r
+    FOR A PARTICULAR PURPOSE.  Full license text is available on 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
+     *    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
-     *    http://www.FreeRTOS.org/FAQHelp.html                               *\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 - Documentation, books, training, latest versions,\r
-    license and Real Time Engineers Ltd. contact details.\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.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
+    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
@@ -83,7 +87,7 @@
 #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
+#define cmdMAX_MUTEX_WAIT              ( 200 / portTICK_PERIOD_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
@@ -101,7 +105,7 @@ static void prvUARTCommandConsoleTask( void *pvParameters );
  * Ensure a previous interrupt driven Tx has completed before sending the next\r
  * data block to the UART.\r
  */\r
-static void prvSendBuffer( const uint8_t * pcBuffer, size_t xBufferLength );\r
+static void prvSendBuffer( const char * pcBuffer, size_t xBufferLength );\r
 \r
 /*\r
  * A UART is used for printf() output and CLI input and output.  Configure the\r
@@ -113,9 +117,9 @@ static void prvUARTRxNotificationHandler( mss_uart_instance_t * this_uart );
 /*-----------------------------------------------------------*/\r
 \r
 /* Const messages output by the command console. */\r
-static const 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
+static const char * const pcWelcomeMessage = "\r\n\r\nFreeRTOS command server.\r\nType Help to view a list of registered commands.\r\n\r\n>";\r
+static const char * const pcEndOfOutputMessage = "\r\n[Press ENTER to execute the previous command again]\r\n>";\r
+static const char * const pcNewLine = "\r\n";\r
 \r
 /* The UART used by the CLI. */\r
 #if configBUILD_FOR_DEVELOPMENT_KIT == 1\r
@@ -129,7 +133,7 @@ static const uint8_t * const pcNewLine = ( uint8_t * ) "\r\n";
 /* Because characters are received slowly (at the speed somebody can type) then\r
 it is ok to pass received characters from the Rx interrupt to the task on a\r
 queue.  This is the queue used for that purpose. */\r
-static xQueueHandle xRxedChars = NULL;\r
+static QueueHandle_t xRxedChars = NULL;\r
 \r
 /*-----------------------------------------------------------*/\r
 \r
@@ -141,19 +145,20 @@ void vUARTCommandConsoleStart( uint16_t usStackSize, unsigned portBASE_TYPE uxPr
        prvConfigureUART();\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
+       xTaskCreate(    prvUARTCommandConsoleTask,      /* The task that implements the command console. */\r
+                                       "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
-int8_t cRxedChar, cInputIndex = 0, *pcOutputString;\r
-static int8_t cInputString[ cmdMAX_INPUT_SIZE ], cLastInputString[ cmdMAX_INPUT_SIZE ];\r
+char cRxedChar, *pcOutputString;\r
+unsigned char cInputIndex = 0;\r
+static char cInputString[ cmdMAX_INPUT_SIZE ], cLastInputString[ cmdMAX_INPUT_SIZE ];\r
 portBASE_TYPE xReturned;\r
 \r
        ( void ) pvParameters;\r
@@ -164,7 +169,7 @@ portBASE_TYPE xReturned;
        pcOutputString = FreeRTOS_CLIGetOutputBuffer();\r
 \r
        /* Send the welcome message. */\r
-       prvSendBuffer( pcWelcomeMessage, strlen( ( char * ) pcWelcomeMessage ) );\r
+       prvSendBuffer( pcWelcomeMessage, strlen( pcWelcomeMessage ) );\r
 \r
        for( ;; )\r
        {\r
@@ -172,20 +177,20 @@ portBASE_TYPE xReturned;
                if( xQueueReceive( xRxedChars, &cRxedChar, portMAX_DELAY ) == pdPASS )\r
                {\r
                        /* Echo the character back. */\r
-                       prvSendBuffer( ( uint8_t * ) &cRxedChar, sizeof( cRxedChar ) );\r
+                       prvSendBuffer( &cRxedChar, sizeof( cRxedChar ) );\r
 \r
                        /* Was it the end of the line? */\r
                        if( cRxedChar == '\n' || cRxedChar == '\r' )\r
                        {\r
                                /* Just to space the output from the input. */\r
-                               prvSendBuffer( ( uint8_t * ) pcNewLine, strlen( ( char * ) pcNewLine ) );\r
+                               prvSendBuffer( pcNewLine, strlen( pcNewLine ) );\r
 \r
                                /* See if the command is empty, indicating that the last command is\r
                                to be executed again. */\r
                                if( cInputIndex == 0 )\r
                                {\r
                                        /* Copy the last command back into the input string. */\r
-                                       strcpy( ( char * ) cInputString, ( char * ) cLastInputString );\r
+                                       strcpy( cInputString, cLastInputString );\r
                                }\r
 \r
                                /* Pass the received command to the command interpreter.  The\r
@@ -198,7 +203,7 @@ portBASE_TYPE xReturned;
                                        xReturned = FreeRTOS_CLIProcessCommand( cInputString, pcOutputString, configCOMMAND_INT_MAX_OUTPUT_SIZE );\r
 \r
                                        /* Write the generated string to the UART. */\r
-                                       prvSendBuffer( ( uint8_t * ) pcOutputString, strlen( ( char * ) pcOutputString ) );\r
+                                       prvSendBuffer( pcOutputString, strlen( pcOutputString ) );\r
 \r
                                } while( xReturned != pdFALSE );\r
 \r
@@ -206,11 +211,11 @@ portBASE_TYPE xReturned;
                                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
+                               strcpy( cLastInputString, cInputString );\r
                                cInputIndex = 0;\r
                                memset( cInputString, 0x00, cmdMAX_INPUT_SIZE );\r
 \r
-                               prvSendBuffer( ( uint8_t * ) pcEndOfOutputMessage, strlen( ( char * ) pcEndOfOutputMessage ) );\r
+                               prvSendBuffer( pcEndOfOutputMessage, strlen( pcEndOfOutputMessage ) );\r
                        }\r
                        else\r
                        {\r
@@ -248,13 +253,13 @@ portBASE_TYPE xReturned;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-static void prvSendBuffer( const uint8_t * pcBuffer, size_t xBufferLength )\r
+static void prvSendBuffer( const char * pcBuffer, size_t xBufferLength )\r
 {\r
-const portTickType xVeryShortDelay = 2UL;\r
+const TickType_t xVeryShortDelay = 2UL;\r
 \r
        if( xBufferLength > 0 )\r
        {\r
-               MSS_UART_irq_tx( ( mss_uart_instance_t * ) pxUART, pcBuffer, xBufferLength );\r
+               MSS_UART_irq_tx( ( mss_uart_instance_t * ) pxUART, ( uint8_t * ) pcBuffer, xBufferLength );\r
 \r
                /* Ensure any previous transmissions have completed.  The default UART\r
                interrupt does not provide an event based method of     signally the end of a Tx\r
@@ -292,13 +297,13 @@ static void prvConfigureUART( void )
 \r
 static void prvUARTRxNotificationHandler( mss_uart_instance_t * pxUART )\r
 {\r
-uint8_t cRxed;\r
+char cRxed;\r
 portBASE_TYPE xHigherPriorityTaskWoken;\r
 \r
        /* The command console receives data very slowly (at the speed of somebody\r
        typing), therefore it is ok to just handle one character at a time and use\r
        a queue to send the characters to the task. */\r
-       if( MSS_UART_get_rx( pxUART, &cRxed, sizeof( cRxed ) ) == sizeof( cRxed ) )\r
+       if( MSS_UART_get_rx( pxUART, ( uint8_t * ) &cRxed, sizeof( cRxed ) ) == sizeof( cRxed ) )\r
        {\r
                xHigherPriorityTaskWoken = pdFALSE;\r
                xQueueSendFromISR( xRxedChars, &cRxed, &xHigherPriorityTaskWoken );\r