]> git.sur5r.net Git - freertos/commitdiff
SmartFusion2 CLI working with polled UART, about to convert to interrupt driven UART.
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Fri, 10 May 2013 18:47:43 +0000 (18:47 +0000)
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Fri, 10 May 2013 18:47:43 +0000 (18:47 +0000)
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1890 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

FreeRTOS/Demo/CORTEX_M2S050_Starter_Kit_SoftConsole/RTOSDemo/FreeRTOSConfig.h
FreeRTOS/Demo/CORTEX_M2S050_Starter_Kit_SoftConsole/RTOSDemo/Full-Demo/File-releated-CLI-commands.c
FreeRTOS/Demo/CORTEX_M2S050_Starter_Kit_SoftConsole/RTOSDemo/Full-Demo/File-system-demo.c
FreeRTOS/Demo/CORTEX_M2S050_Starter_Kit_SoftConsole/RTOSDemo/Full-Demo/UARTCommandConsole.c
FreeRTOS/Demo/CORTEX_M2S050_Starter_Kit_SoftConsole/RTOSDemo/Full-Demo/main_full.c
FreeRTOS/Demo/CORTEX_M2S050_Starter_Kit_SoftConsole/RTOSDemo/main.c
FreeRTOS/Demo/CORTEX_M2S050_Starter_Kit_SoftConsole/RTOSDemo/printf-stdarg.c

index 53e139a625f10350d65a1ecfd0d0e6d0b1e35b63..4b5ec8214f12f3205cbea4a57d4fdc84c052a022 100644 (file)
 #include <stdint.h>\r
 extern uint32_t SystemCoreClock;\r
 \r
+/* Driver includes required for UART IO. */\r
+#include "drivers/mss_uart/mss_uart.h"\r
+extern const mss_uart_instance_t * const pxUART;\r
+\r
 #define configUSE_PREEMPTION                   1\r
-#define configUSE_IDLE_HOOK                            0\r
+#define configUSE_IDLE_HOOK                            1\r
 #define configUSE_TICK_HOOK                            0\r
 #define configCPU_CLOCK_HZ                             ( SystemCoreClock )\r
 #define configTICK_RATE_HZ                             ( ( portTickType ) 1000 )\r
@@ -150,7 +154,7 @@ are multiple command interpreters running at once (for example, one on a UART
 and one on TCP/IP).  This is done to prevent an output buffer being defined by\r
 each implementation - which would waste RAM.  In this case, there is only one\r
 command interpreter running. */\r
-#define configCOMMAND_INT_MAX_OUTPUT_SIZE 128\r
+#define configCOMMAND_INT_MAX_OUTPUT_SIZE 2048\r
 \r
 /* Cortex-M specific definitions. */\r
 #ifdef __NVIC_PRIO_BITS\r
index 87960c4d4a85825495205529019f919d446a4c11..5e7b7a3f7a4eb75d501f91dad3f941909c16cf2c 100644 (file)
@@ -80,6 +80,7 @@
 #include <stdint.h>\r
 #include <stdio.h>\r
 #include <stdlib.h>\r
+#include <string.h>\r
 \r
 /* FreeRTOS+CLI includes. */\r
 #include "FreeRTOS_CLI.h"\r
@@ -570,5 +571,5 @@ const char * pcAttrib;
 \r
        /* Create a string that includes the file name, the file size and the\r
        attributes string. */\r
-       sprintf( ( char * ) pcBuffer, "%s [%s] [size=%d]", pxFindStruct->filename, pcAttrib, pxFindStruct->filesize );\r
+       sprintf( ( char * ) pcBuffer, "%s [%s] [size=%d]", pxFindStruct->filename, pcAttrib, ( int ) pxFindStruct->filesize );\r
 }\r
index 8dd6f0b277ca6196886a9aa667e9ded98085fffc..d7ee184f100619437edc7ee93aa7fc55015e66ae 100644 (file)
@@ -79,6 +79,7 @@
 \r
 /* Standard includes. */\r
 #include <stdio.h>\r
+#include <string.h>\r
 \r
 /* FreeRTOS includes. */\r
 #include "FreeRTOS.h"\r
@@ -187,7 +188,7 @@ F_FILE *pxFile;
        for( xFileNumber = 1; xFileNumber <= fsROOT_FILES; xFileNumber++ )\r
        {\r
                /* Generate a file name. */\r
-               sprintf( cFileName, "root%03d.txt", xFileNumber );\r
+               sprintf( cFileName, "root%03d.txt", ( int ) xFileNumber );\r
 \r
                /* Obtain the current working directory and print out the file name and\r
                the     directory into which the file is being written. */\r
@@ -229,7 +230,7 @@ F_FILE *pxFile;
        for( xFileNumber = 1; xFileNumber <= fsROOT_FILES; xFileNumber++ )\r
        {\r
                /* Generate the file name. */\r
-               sprintf( cFileName, "root%03d.txt", xFileNumber );\r
+               sprintf( cFileName, "root%03d.txt", ( int ) xFileNumber );\r
 \r
                /* Obtain the current working directory and print out the file name and\r
                the     directory from which the file is being read. */\r
index 571238e64d16b28ac266875f39a33355dd514ead..a3e5b8961567c2c9003c95629d20c66c29ea9613 100644 (file)
@@ -83,7 +83,7 @@ static void prvUARTCommandConsoleTask( void *pvParameters );
 /*-----------------------------------------------------------*/\r
 \r
 /* Const messages output by the command console. */\r
-static const uint8_t * const pcWelcomeMessage = ( uint8_t * ) "FreeRTOS command server.\r\nType Help to view a list of registered commands.\r\n\r\n>";\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
 \r
@@ -115,9 +115,6 @@ mss_uart_instance_t * const pxUART = &g_mss_uart0;
        interface will be used at any one time. */\r
        pcOutputString = FreeRTOS_CLIGetOutputBuffer();\r
 \r
-       /* Initialise the UART. */\r
-    MSS_UART_init( pxUART, MSS_UART_115200_BAUD, MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT );\r
-\r
        /* Send the welcome message. */\r
     MSS_UART_polled_tx_string( pxUART, ( uint8_t * ) pcWelcomeMessage );\r
 \r
@@ -127,77 +124,78 @@ mss_uart_instance_t * const pxUART = &g_mss_uart0;
                cRxedChar = 0;\r
 \r
                /* Only interested in reading one character at a time. */\r
-               MSS_UART_get_rx( pxUART, &cRxedChar, sizeof( cRxedChar ) );\r
-\r
-               /* Echo the character back. */\r
-               MSS_UART_polled_tx( pxUART, &cRxedChar, sizeof( cRxedChar ) );\r
-\r
-               /* Was it the end of the line? */\r
-               if( cRxedChar == '\n' || cRxedChar == '\r' )\r
+               if( MSS_UART_get_rx( pxUART, ( uint8_t * ) &cRxedChar, sizeof( cRxedChar ) ) > 0 )\r
                {\r
-                       /* Just to space the output from the input. */\r
-                       MSS_UART_polled_tx_string( pxUART, ( uint8_t * ) pcNewLine );\r
+                       /* Echo the character back. */\r
+                       MSS_UART_polled_tx( pxUART, ( uint8_t * ) &cRxedChar, sizeof( cRxedChar ) );\r
 \r
-                       /* See if the command is empty, indicating that the last command is\r
-                       to be executed again. */\r
-                       if( cInputIndex == 0 )\r
+                       /* Was it the end of the line? */\r
+                       if( cRxedChar == '\n' || cRxedChar == '\r' )\r
                        {\r
-                               /* Copy the last command back into the input string. */\r
-                               strcpy( ( char * ) cInputString, ( char * ) cLastInputString );\r
-                       }\r
+                               /* Just to space the output from the input. */\r
+                               MSS_UART_polled_tx_string( pxUART, ( uint8_t * ) pcNewLine );\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, pcOutputString, configCOMMAND_INT_MAX_OUTPUT_SIZE );\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
+                               }\r
 \r
-                               /* Write the generated string to the UART. */\r
-                               MSS_UART_polled_tx_string( pxUART, ( uint8_t * ) pcOutputString );\r
-                               vTaskDelay( 1 );\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, pcOutputString, configCOMMAND_INT_MAX_OUTPUT_SIZE );\r
 \r
-                       } while( xReturned != pdFALSE );\r
+                                       /* Write the generated string to the UART. */\r
+                                       MSS_UART_polled_tx_string( pxUART, ( uint8_t * ) pcOutputString );\r
+                                       vTaskDelay( 1 );\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
-                       cInputIndex = 0;\r
-                       memset( cInputString, 0x00, cmdMAX_INPUT_SIZE );\r
+                               } while( xReturned != pdFALSE );\r
 \r
-                       MSS_UART_polled_tx_string( pxUART, ( uint8_t * ) pcEndOfOutputMessage );\r
-               }\r
-               else\r
-               {\r
-                       if( cRxedChar == '\r' )\r
-                       {\r
-                               /* Ignore the character. */\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
+                               cInputIndex = 0;\r
+                               memset( cInputString, 0x00, cmdMAX_INPUT_SIZE );\r
+\r
+                               MSS_UART_polled_tx_string( pxUART, ( uint8_t * ) pcEndOfOutputMessage );\r
                        }\r
-                       else if( cRxedChar == '\b' )\r
+                       else\r
                        {\r
-                               /* Backspace was pressed.  Erase the last character in the\r
-                               string - if any. */\r
-                               if( cInputIndex > 0 )\r
+                               if( cRxedChar == '\r' )\r
                                {\r
-                                       cInputIndex--;\r
-                                       cInputString[ cInputIndex ] = '\0';\r
+                                       /* Ignore the character. */\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( ( cRxedChar >= ' ' ) && ( cRxedChar <= '~' ) )\r
+                               else if( cRxedChar == '\b' )\r
+                               {\r
+                                       /* Backspace was pressed.  Erase the last character in the\r
+                                       string - if any. */\r
+                                       if( cInputIndex > 0 )\r
+                                       {\r
+                                               cInputIndex--;\r
+                                               cInputString[ cInputIndex ] = '\0';\r
+                                       }\r
+                               }\r
+                               else\r
                                {\r
-                                       if( cInputIndex < cmdMAX_INPUT_SIZE )\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( ( cRxedChar >= ' ' ) && ( cRxedChar <= '~' ) )\r
                                        {\r
-                                               cInputString[ cInputIndex ] = cRxedChar;\r
-                                               cInputIndex++;\r
+                                               if( cInputIndex < cmdMAX_INPUT_SIZE )\r
+                                               {\r
+                                                       cInputString[ cInputIndex ] = cRxedChar;\r
+                                                       cInputIndex++;\r
+                                               }\r
                                        }\r
                                }\r
                        }\r
index 05a923a66cb26ac9898db921d2700affb7c25028..1444238f011c82e52cb1f316a87cf0fee23a7de1 100644 (file)
@@ -161,7 +161,7 @@ check timer, only two are used by the flash timers. */
 standard demo flash timers. */\r
 #define mainCHECK_LED                                          ( 1 )\r
 \r
-/* The size of the stack and the priority used by the UART CDC command console\r
+/* The size of the stack and the priority used by the UART command console\r
 task. */\r
 #define mainUART_COMMAND_CONSOLE_STACK_SIZE            ( configMINIMAL_STACK_SIZE * 3 )\r
 #define mainUART_COMMAND_CONSOLE_TASK_PRIORITY ( tskIDLE_PRIORITY )\r
@@ -178,7 +178,7 @@ static void prvCheckTimerCallback( xTimerHandle xTimer );
  * defined in CLI-Commands.c and File-Related-CLI-Command.c respectively.\r
  */\r
 extern void vRegisterSampleCLICommands( void );\r
-extern vRegisterFileSystemCLICommands( void );\r
+extern void vRegisterFileSystemCLICommands( void );\r
 \r
 /*-----------------------------------------------------------*/\r
 \r
index e96a299f32a653a629cb3087d16256e3e681171f..d846b6a389afca82a9a0f83cdfb95c7c17e92197 100644 (file)
@@ -119,6 +119,8 @@ void vApplicationIdleHook( void );
 void vApplicationStackOverflowHook( xTaskHandle pxTask, signed char *pcTaskName );\r
 void vApplicationTickHook( void );\r
 \r
+/* The UART used for printf() and CLI IO. */\r
+const mss_uart_instance_t * const pxUART = &g_mss_uart0;\r
 /*-----------------------------------------------------------*/\r
 /* See the documentation page for this demo on the FreeRTOS.org web site for\r
 full information - including hardware setup requirements. */\r
@@ -150,6 +152,9 @@ static void prvSetupHardware( void )
        functions.  The name ParTest is now somewhat obsolete - originally it\r
        stood for PARallel port Test. */\r
        vParTestInitialise();\r
+\r
+       /* Initialise the UART which is used for printf() and CLI IO. */\r
+    MSS_UART_init( pxUART, MSS_UART_115200_BAUD, MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT );\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
index 9bfc45a5c91a4c43a71a145a2532fba3b9985349..559fd68510f68938019c47d38563188d87b18260 100644 (file)
        replace outbyte(c) by your own function call.\r
 \r
 */\r
-\r
-#define putchar(c) c\r
-\r
+#include "FreeRTOS.h"\r
 #include <stdarg.h>\r
+#include <stdint.h>\r
 \r
 static void printchar(char **str, int c)\r
 {\r
-       //extern int putchar(int c);\r
-       \r
        if (str) {\r
                **str = (char)c;\r
                ++(*str);\r
        }\r
        else\r
-       { \r
-               (void)putchar(c);\r
+       {\r
+               MSS_UART_polled_tx( pxUART, ( uint8_t * ) &c, sizeof( uint8_t ) );\r
        }\r
 }\r
 \r