]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/main.c
Re-test Zynq demo now it is using the latest tools.
[freertos] / FreeRTOS / Demo / CORTEX_A9_Zynq_ZC702 / RTOSDemo / src / main.c
index 315f824b88d16182e2d6d6ebcdb3fa2d5e2b99d5..c09e4056ed09f0e052585463bd901743d2cc2156 100644 (file)
 */\r
 \r
 /******************************************************************************\r
- * This project provides two demo applications.  A simple blinky style project,\r
- * and a more comprehensive test and demo application.  The\r
- * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting (defined in this file) is used to\r
- * select between the two.  The simply blinky demo is implemented and described\r
- * in main_blinky.c.  The more comprehensive test and demo application is\r
- * implemented and described in main_full.c.\r
+ * This project provides three demo applications.  A simple blinky style\r
+ * project, a more comprehensive test and demo application, and an lwIP example.\r
+ * The mainSELECTED_APPLICATION setting (defined in this file) is used to\r
+ * select between the three.  The simply blinky demo is implemented and\r
+ * described in main_blinky.c.  The more comprehensive test and demo application\r
+ * is implemented and described in main_full.c.  The lwIP example is implemented\r
+ * and described in main_lwIP.c.\r
  *\r
  * This file implements the code that is not demo specific, including the\r
  * hardware setup and FreeRTOS hook functions.\r
@@ -92,6 +93,7 @@
 \r
 /* Standard includes. */\r
 #include <stdio.h>\r
+#include <limits.h>\r
 \r
 /* Scheduler include files. */\r
 #include "FreeRTOS.h"\r
 #include "xscugic.h"\r
 #include "xil_exception.h"\r
 \r
-/* Set mainCREATE_SIMPLE_BLINKY_DEMO_ONLY to one to run the simple blinky demo,\r
-or 0 to run the more comprehensive test and demo application. */\r
-#define mainCREATE_SIMPLE_BLINKY_DEMO_ONLY     0\r
+/* mainSELECTED_APPLICATION is used to select between three demo applications,\r
+ * as described at the top of this file.\r
+ *\r
+ * When mainSELECTED_APPLICATION is set to 0 the simple blinky example will\r
+ * be run.\r
+ *\r
+ * When mainSELECTED_APPLICATION is set to 1 the comprehensive test and demo\r
+ * application will be run.\r
+ *\r
+ * When mainSELECTED_APPLICATION is set to 2 the lwIP example will be run.\r
+ */\r
+#define mainSELECTED_APPLICATION       0\r
 \r
 /*-----------------------------------------------------------*/\r
 \r
@@ -123,13 +134,17 @@ or 0 to run the more comprehensive test and demo application. */
 static void prvSetupHardware( void );\r
 \r
 /*\r
- * main_blinky() is used when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 1.\r
- * main_full() is used when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 0.\r
+ * See the comments at the top of this file and above the\r
+ * mainSELECTED_APPLICATION definition.\r
  */\r
-#if mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1\r
+#if ( mainSELECTED_APPLICATION == 0 )\r
        extern void main_blinky( void );\r
-#else\r
+#elif ( mainSELECTED_APPLICATION == 1 )\r
        extern void main_full( void );\r
+#elif ( mainSELECTED_APPLICATION == 2 )\r
+       extern void main_lwIP( void );\r
+#else\r
+       #error Invalid mainSELECTED_APPLICATION setting.  See the comments at the top of this file and above the mainSELECTED_APPLICATION definition.\r
 #endif /* #if mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 */\r
 \r
 /*\r
@@ -147,6 +162,10 @@ void vApplicationIdleHook( void );
 void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName );\r
 void vApplicationTickHook( void );\r
 \r
+/* The private watchdog is used as the timer that generates run time\r
+stats.  This frequency means it will overflow quite quickly. */\r
+XScuWdt xWatchDogInstance;\r
+\r
 /*-----------------------------------------------------------*/\r
 \r
 /* The interrupt controller is initialised in this file, and made available to\r
@@ -157,19 +176,25 @@ XScuGic xInterruptController;
 \r
 int main( void )\r
 {\r
+extern void main_lwIP( void );\r
+\r
        /* Configure the hardware ready to run the demo. */\r
        prvSetupHardware();\r
 \r
-       /* The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting is described at the top\r
+       /* The mainSELECTED_APPLICATION setting is described at the top\r
        of this file. */\r
-       #if( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 )\r
+       #if( mainSELECTED_APPLICATION == 0 )\r
        {\r
                main_blinky();\r
        }\r
-       #else\r
+       #elif( mainSELECTED_APPLICATION == 1 )\r
        {\r
                main_full();\r
        }\r
+       #else\r
+       {\r
+               main_lwIP();\r
+       }\r
        #endif\r
 \r
        /* Don't expect to reach here. */\r
@@ -277,7 +302,7 @@ volatile unsigned long ul = 0;
 \r
 void vApplicationTickHook( void )\r
 {\r
-       #if( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 0 )\r
+       #if( mainSELECTED_APPLICATION == 1 )\r
        {\r
                /* The full demo includes a software timer demo/test that requires\r
                prodding periodically from the tick interrupt. */\r
@@ -339,5 +364,25 @@ size_t x;
 \r
     return ulBytes - x;\r
 }\r
+/*-----------------------------------------------------------*/\r
+\r
+void vInitialiseTimerForRunTimeStats( void )\r
+{\r
+XScuWdt_Config *pxWatchDogInstance;\r
+uint32_t ulValue;\r
+const uint32_t ulMaxDivisor = 0xff, ulDivisorShift = 0x08;\r
+\r
+        pxWatchDogInstance = XScuWdt_LookupConfig( XPAR_SCUWDT_0_DEVICE_ID );\r
+        XScuWdt_CfgInitialize( &xWatchDogInstance, pxWatchDogInstance, pxWatchDogInstance->BaseAddr );\r
+\r
+        ulValue = XScuWdt_GetControlReg( &xWatchDogInstance );\r
+        ulValue |= ulMaxDivisor << ulDivisorShift;\r
+        XScuWdt_SetControlReg( &xWatchDogInstance, ulValue );\r
+\r
+        XScuWdt_LoadWdt( &xWatchDogInstance, UINT_MAX );\r
+        XScuWdt_SetTimerMode( &xWatchDogInstance );\r
+        XScuWdt_Start( &xWatchDogInstance );\r
+}\r
+\r
 \r
 \r