]> 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 19d758c1fc37a89fb5bedd1264a69c8d5e2157ed..6875add7345839fdc1a01230f1b7f1befd58fb28 100644 (file)
@@ -1,54 +1,70 @@
 /*\r
-    FreeRTOS V7.1.0 - Copyright (C) 2011 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
+    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 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
+     *    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
-     *    Thank you for using FreeRTOS, and thank you for your support!      *\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
-    This file is part of the FreeRTOS distribution.\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
-    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
-    >>>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.  FreeRTOS is distributed in the hope that it will be useful, but\r
-    WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
-    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for\r
-    more details. You should have received a copy of the GNU General Public\r
-    License and the FreeRTOS license exception along with FreeRTOS; if not it\r
-    can be viewed here: http://www.freertos.org/a00114.html and also obtained\r
-    by writing to Richard Barry, contact details for whom are available on the\r
-    FreeRTOS WEB site.\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
-    1 tab == 4 spaces!\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 - Documentation, latest information, license and\r
-    contact details.\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.SafeRTOS.com - A version that is certified for use in safety\r
-    critical systems.\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.OpenRTOS.com - Commercial support, development, porting,\r
-    licensing and training services.\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
@@ -71,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
@@ -87,9 +103,9 @@ static void prvUARTCommandConsoleTask( void *pvParameters );
 \r
 /*\r
  * Ensure a previous interrupt driven Tx has completed before sending the next\r
- * data block to the UART.
+ * 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
@@ -101,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
@@ -117,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
@@ -129,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
@@ -152,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
@@ -160,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
@@ -186,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
@@ -194,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
@@ -236,21 +253,24 @@ 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
-\r
-       MSS_UART_irq_tx( ( mss_uart_instance_t * ) pxUART, pcBuffer, xBufferLength );\r
+const TickType_t xVeryShortDelay = 2UL;\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
-       - this is therefore a crude poll of the Tx end status.  Replacing the\r
-       default UART handler with one that 'gives' a semaphore when the Tx is\r
-       complete would allow this poll loop to be replaced by a simple semaphore\r
-       block. */\r
-       while( MSS_UART_tx_complete( ( mss_uart_instance_t * ) pxUART ) == pdFALSE )\r
+       if( xBufferLength > 0 )\r
        {\r
-               vTaskDelay( xVeryShortDelay );\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
+               - this is therefore a crude poll of the Tx end status.  Replacing the\r
+               default UART handler with one that 'gives' a semaphore when the Tx is\r
+               complete would allow this poll loop to be replaced by a simple semaphore\r
+               block. */\r
+               while( MSS_UART_tx_complete( ( mss_uart_instance_t * ) pxUART ) == pdFALSE )\r
+               {\r
+                       vTaskDelay( xVeryShortDelay );\r
+               }\r
        }\r
 }\r
 /*-----------------------------------------------------------*/\r
@@ -277,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