]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/RTOSDemo/src/main.c
Add networking option to the Microblaze Kintex demo.
[freertos] / FreeRTOS / Demo / MicroBlaze_Kintex7_EthernetLite / RTOSDemo / src / main.c
index 858cb15ea252baf8f0b72300352ad1cc0038a030..2b877bbe3e6e22125e85812c7880f7ba71c38ef4 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
 #include "xtmrctr.h"\r
 #include "xil_cache.h"\r
 \r
-/* mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is used to select between the simply\r
- * blinky demo and the comprehensive test and demo application.\r
+/* mainSELECTED_APPLICATION is used to select between three demo applications,\r
+ * as described at the top of this file.\r
  *\r
- * When mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 1 the simple blinky example\r
- * will be run.\r
+ * When mainSELECTED_APPLICATION is set to 0 the simple blinky example will\r
+ * be run.\r
  *\r
- * When mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 0 the comprehensive test\r
- * and demo application will be run.\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 mainCREATE_SIMPLE_BLINKY_DEMO_ONLY     0\r
+#define mainSELECTED_APPLICATION       0\r
 \r
 /*-----------------------------------------------------------*/\r
 \r
 static void prvSetupHardware( void );\r
 \r
 /*\r
- * See the comments at the top of this file and above the\r
- * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY definition.\r
- */\r
-#if ( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 )\r
+* See the comments at the top of this file and above the\r
+* mainSELECTED_APPLICATION definition.\r
+*/\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\r
 \r
 /* Prototypes for the standard FreeRTOS callback/hook functions implemented\r
@@ -139,22 +146,31 @@ for the run time stats. */
 static XTmrCtr xTickTimerInstance;\r
 \r
 /*-----------------------------------------------------------*/\r
+volatile uint32_t ulx = 999;\r
 \r
 int main( void )\r
 {\r
+       /* Check start up code executed correctly. */\r
+       configASSERT( ulx == 999 );\r
+       ulx = 0;\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
@@ -208,14 +224,14 @@ void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName )
        /* Run time stack overflow checking is performed if\r
        configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2.  This hook\r
        function is called if a stack overflow is detected.  Force an assertion\r
-       failuse. */\r
+       failure. */\r
        configASSERT( ( char * ) pxTask == pcTaskName );\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
 void vApplicationIdleHook( void )\r
 {\r
-       #if( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 0 )\r
+       #if( mainSELECTED_APPLICATION == 1 )\r
        {\r
                extern void vFullDemoIdleHook( void );\r
 \r
@@ -249,7 +265,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
                extern void vFullDemoTickHook( void );\r
 \r
@@ -362,10 +378,25 @@ const uint32_t ulPrescale = 10, ulTCR2Offset = 24UL;
 \r
        if( ulTimeNow < ulLastTime )\r
        {\r
-               ulOverflows += ( 1UL << ulPrescale );\r
+               /* 32 as its a 32-bit number. */\r
+               ulOverflows += ( 1UL << ( 32 - ulPrescale ) );\r
        }\r
+       ulLastTime = ulTimeNow;\r
 \r
        ulReturn = ( ulTimeNow >> ulPrescale ) + ulOverflows;\r
 \r
        return ulReturn;\r
 }\r
+/*-----------------------------------------------------------*/\r
+\r
+int outbyte( int c )\r
+{\r
+       return c;\r
+}\r
+\r
+void xil_printf( const char *pc, ... )\r
+{\r
+       ( void ) pc;\r
+}\r
+\r
+\r