]> git.sur5r.net Git - freertos/commitdiff
Add very basic serial CLI to the Zynq demo - needs a lot of tidy up yet!
authorrtel <rtel@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Tue, 28 Jan 2014 17:41:28 +0000 (17:41 +0000)
committerrtel <rtel@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Tue, 28 Jan 2014 17:41:28 +0000 (17:41 +0000)
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2184 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/.cproject
FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/.project
FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/main.c
FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/main_full.c
FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/serial.c

index f3fd43ab257043315e7a73fad2913a98d4c3f5c8..bf4326f6c6d1d590b1f0ad30a61ed449c2ec3d40 100644 (file)
@@ -32,6 +32,7 @@
                                                                </option>\r
                                                                <option id="xilinx.gnu.compiler.dircategory.includes.1516519458" name="Include Paths" superClass="xilinx.gnu.compiler.dircategory.includes" valueType="includePath">\r
                                                                        <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src/FreeRTOS_Source/include}&quot;"/>\r
+                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src/FreeRTOS-Plus-CLI}&quot;"/>\r
                                                                        <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src/Standard_Demo_Tasks/include}&quot;"/>\r
                                                                        <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src}&quot;"/>\r
                                                                        <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src/FreeRTOS_Source/portable/GCC/ARM_CA9}&quot;"/>\r
index dc244b28416b6e43f6f1e2e1d9bc5cf7eaf2c87f..15d9fcbe6ce7091caa46f8ad8572fde20394951a 100644 (file)
                <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>\r
        </natures>\r
        <linkedResources>\r
+               <link>\r
+                       <name>src/FreeRTOS-Plus-CLI</name>\r
+                       <type>2</type>\r
+                       <locationURI>FREERTOS_ROOT/FreeRTOS-Plus/Source/FreeRTOS-Plus-CLI</locationURI>\r
+               </link>\r
                <link>\r
                        <name>src/FreeRTOS_Source</name>\r
                        <type>2</type>\r
                        <type>2</type>\r
                        <locationURI>FREERTOS_ROOT/FreeRTOS/Demo/Common</locationURI>\r
                </link>\r
+               <link>\r
+                       <name>src/UARTCommandConsole.c</name>\r
+                       <type>1</type>\r
+                       <locationURI>FREERTOS_ROOT/FreeRTOS-Plus/Demo/Common/FreeRTOS_Plus_CLI_Demos/UARTCommandConsole.c</locationURI>\r
+               </link>\r
        </linkedResources>\r
        <filteredResources>\r
                <filter>\r
index 68164e7be669fae385a8661662d0f5e716ae3428..f2aff13ab52414382ee2be3f0eb4e666726cdd30 100644 (file)
@@ -128,6 +128,8 @@ void vApplicationIdleHook( void );
 void vApplicationStackOverflowHook( xTaskHandle pxTask, char *pcTaskName );
 void vApplicationTickHook( void );
 
+XScuGic xInterruptController;
+
 /*-----------------------------------------------------------*/
 
 int main( void )
@@ -155,7 +157,6 @@ static void prvSetupHardware( void )
 {
 BaseType_t xStatus;
 XScuGic_Config *pxGICConfig;
-XScuGic xInterruptController;
 
        /* Ensure no interrupts execute while the scheduler is in an inconsistent
        state.  Interrupts are automatically enabled when the scheduler is
index 55464a8c3749a9eb0223ba3e0f33d3536e3047ef..081e0f5a2c28cc2ca3200018aa637e2f16d015d3 100644 (file)
@@ -228,6 +228,11 @@ extern void vRegTest2Implementation( void );
 extern void vRegisterSampleCLICommands( void );\r
 extern void vRegisterFileSystemCLICommands( void );\r
 \r
+/*\r
+ * The task that manages the FreeRTOS+CLI input and output.\r
+ */\r
+extern void vUARTCommandConsoleStart( uint16_t usStackSize, UBaseType_t uxPriority );\r
+\r
 /*-----------------------------------------------------------*/\r
 \r
 /* The following two variables are used to communicate the status of the\r
@@ -240,10 +245,6 @@ volatile unsigned long ulRegTest1LoopCounter = 0UL, ulRegTest2LoopCounter = 0UL;
 \r
 void main_full( void )\r
 {\r
-       /* The baud rate setting here has no effect, hence it is set to 0 to\r
-       make that obvious. */\r
-//     xSerialPortInitMinimal( 0, mainUART_QUEUE_LENGTHS );\r
-\r
        /* Start all the other standard demo/test tasks.  The have not particular\r
        functionality, but do demonstrate how to use the FreeRTOS API and test the\r
        kernel port. */\r
@@ -260,7 +261,7 @@ void main_full( void )
 \r
        /* Start the tasks that implements the command console on the UART, as\r
        described above. */\r
-//     vUARTCommandConsoleStart( mainUART_COMMAND_CONSOLE_STACK_SIZE, mainUART_COMMAND_CONSOLE_TASK_PRIORITY );\r
+       vUARTCommandConsoleStart( mainUART_COMMAND_CONSOLE_STACK_SIZE, mainUART_COMMAND_CONSOLE_TASK_PRIORITY );\r
 \r
        /* Register the standard CLI commands. */\r
 //     vRegisterSampleCLICommands();\r
@@ -294,7 +295,7 @@ void main_full( void )
        for( ;; );\r
 }\r
 /*-----------------------------------------------------------*/\r
-#error Fails when the tick hook is used\r
+\r
 static void prvCheckTask( void *pvParameters )\r
 {\r
 portTickType xDelayPeriod = mainNO_ERROR_CHECK_TASK_PERIOD;\r
index 371230a7438dcb5fa0e24a1d47e98bb5c85607ec..53e7fcdb16c68e5320d511696f5b0723ee48c0d0 100644 (file)
@@ -1,82 +1,83 @@
 /*\r
   FreeRTOS V8.0.0:rc2 - Copyright (C) 2014 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
-\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
+ FreeRTOS V8.0.0:rc2 - Copyright (C) 2014 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
+\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
 /*\r
      BASIC INTERRUPT DRIVEN SERIAL PORT DRIVER FOR UART2.\r
-\r
      ***Note*** This example uses queues to send each character into an interrupt\r
      service routine and out of an interrupt service routine individually.  This\r
      is done to demonstrate queues being used in an interrupt, and to deliberately\r
      load the system to test the FreeRTOS port.  It is *NOT* meant to be an\r
      example of an efficient implementation.  An efficient implementation should\r
      use the DMA, and only use FreeRTOS API functions when enough has been\r
      received to warrant a task being unblocked to process the data.\r
-*/\r
+ BASIC INTERRUPT DRIVEN SERIAL PORT DRIVER FOR UART2.\r
+\r
+ ***Note*** This example uses queues to send each character into an interrupt\r
+ service routine and out of an interrupt service routine individually.  This\r
+ is done to demonstrate queues being used in an interrupt, and to deliberately\r
+ load the system to test the FreeRTOS port.  It is *NOT* meant to be an\r
+ example of an efficient implementation.  An efficient implementation should\r
+ use the DMA, and only use FreeRTOS API functions when enough has been\r
+ received to warrant a task being unblocked to process the data.\r
+ */\r
 \r
 /* Scheduler includes. */\r
 #include "FreeRTOS.h"\r
+#include "task.h"\r
 #include "queue.h"\r
 #include "semphr.h"\r
 #include "comtest2.h"\r
 /* Demo application includes. */\r
 #include "serial.h"\r
 \r
+/* Xilinx includes. */\r
+#include "xuartps.h"\r
+#include "xscugic.h"\r
+#include "xil_exception.h"\r
+\r
 /*-----------------------------------------------------------*/\r
 \r
+static XUartPs xUARTInstance;\r
+extern XScuGic xInterruptController;\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvISRHandler( void *pvUnused, uint32_t ulEvent, uint32_t ulUnused2 );\r
+\r
 /*\r
  * See the serial2.h header file.\r
  */\r
-xComPortHandle xSerialPortInitMinimal( unsigned long ulWantedBaud, unsigned portBASE_TYPE uxQueueLength )\r
+xComPortHandle xSerialPortInitMinimal( uint32_t ulWantedBaud, UBaseType_t uxQueueLength )\r
 {\r
-       return NULL;\r
+BaseType_t xStatus;\r
+XUartPs_Config *pxConfig;\r
+\r
+       /* Look up the UART configuration then initialise the dirver. */\r
+       pxConfig = XUartPs_LookupConfig( XPAR_XUARTPS_0_DEVICE_ID );\r
+       configASSERT( pxConfig );\r
+\r
+       xStatus = XUartPs_CfgInitialize( &xUARTInstance, pxConfig, pxConfig->BaseAddress );\r
+       configASSERT( xStatus == XST_SUCCESS );\r
+\r
+       XUartPs_SetBaudRate( &xUARTInstance, ulWantedBaud );\r
+\r
+       XUartPs_SetOperMode( &xUARTInstance, XUARTPS_OPER_MODE_NORMAL );\r
+\r
+       return 0;\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-signed portBASE_TYPE xSerialGetChar( xComPortHandle pxPort, signed char *pcRxedChar, portTickType xBlockTime )\r
+BaseType_t xSerialGetChar( xComPortHandle pxPort, signed char *pcRxedChar, portTickType xBlockTime )\r
 {\r
-       return 0;\r
+TickType_t xTimeOnEntering;\r
+const TickType_t xDelay = 10UL / portTICK_PERIOD_MS;\r
+BaseType_t xReturn = 0;\r
+\r
+       xTimeOnEntering = xTaskGetTickCount();\r
+\r
+       do\r
+       {\r
+               /* Only wanting to receive one key press at a time. */\r
+               if( XUartPs_Recv( &xUARTInstance, pcRxedChar, sizeof( pcRxedChar ) ) != 0 )\r
+               {\r
+                       xReturn = 1;\r
+                       break;\r
+               }\r
+               else\r
+               {\r
+                       vTaskDelay( xDelay );\r
+               }\r
+       } while( ( xTaskGetTickCount() - xTimeOnEntering ) <= xBlockTime );\r
+\r
+       return xReturn;\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
 void vSerialPutString( xComPortHandle pxPort, const signed char * const pcString, unsigned short usStringLength )\r
 {\r
+static const xTxDelay = 10UL / portTICK_PERIOD_MS;\r
+uint32_t ulBytesSent = 0UL;\r
+\r
+       ( void ) pxPort;\r
+\r
+       while( ulBytesSent < usStringLength )\r
+       {\r
+               ulBytesSent += XUartPs_Send( &xUARTInstance, pcString + ulBytesSent, usStringLength - ulBytesSent );\r
+\r
+               while( XUartPs_IsSending( &xUARTInstance ) )\r
+               {\r
+                       vTaskDelay( xTxDelay );\r
+               }\r
+       }\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
 signed portBASE_TYPE xSerialPutChar( xComPortHandle pxPort, signed char cOutChar, portTickType xBlockTime )\r
 {\r
+static const xTxDelay = 10UL / portTICK_PERIOD_MS;\r
+\r
+       XUartPs_Send( &xUARTInstance, &cOutChar, sizeof( cOutChar ) );\r
+\r
+       while( XUartPs_IsSending( &xUARTInstance ) )\r
+       {\r
+               vTaskDelay( xTxDelay );\r
+       }\r
+\r
        return 0;\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-void vSerialClose( xComPortHandle xPort )\r
+void vSerialClose(xComPortHandle xPort)\r
 {\r
        /* Not supported as not required by the demo application. */\r
 }\r