X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=FreeRTOS%2FDemo%2FCORTEX_A9_Zynq_ZC702%2FRTOSDemo%2Fsrc%2Fmain.c;h=c09e4056ed09f0e052585463bd901743d2cc2156;hb=14c3bded7a00a2833d54febe3b8442e75e52c89c;hp=d50d31faf6b764d2bc4c5e79c9846916cf28594c;hpb=a682e11ed654f8c2bd8cc76fc4f8177d47212877;p=freertos diff --git a/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/main.c b/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/main.c index d50d31faf..c09e4056e 100644 --- a/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/main.c +++ b/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/main.c @@ -64,12 +64,13 @@ */ /****************************************************************************** - * This project provides two demo applications. A simple blinky style project, - * and a more comprehensive test and demo application. The - * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting (defined in this file) is used to - * select between the two. The simply blinky demo is implemented and described - * in main_blinky.c. The more comprehensive test and demo application is - * implemented and described in main_full.c. + * This project provides three demo applications. A simple blinky style + * project, a more comprehensive test and demo application, and an lwIP example. + * The mainSELECTED_APPLICATION setting (defined in this file) is used to + * select between the three. The simply blinky demo is implemented and + * described in main_blinky.c. The more comprehensive test and demo application + * is implemented and described in main_full.c. The lwIP example is implemented + * and described in main_lwIP.c. * * This file implements the code that is not demo specific, including the * hardware setup and FreeRTOS hook functions. @@ -92,6 +93,7 @@ /* Standard includes. */ #include +#include /* Scheduler include files. */ #include "FreeRTOS.h" @@ -111,9 +113,18 @@ #include "xscugic.h" #include "xil_exception.h" -/* Set mainCREATE_SIMPLE_BLINKY_DEMO_ONLY to one to run the simple blinky demo, -or 0 to run the more comprehensive test and demo application. */ -#define mainCREATE_SIMPLE_BLINKY_DEMO_ONLY 1 +/* mainSELECTED_APPLICATION is used to select between three demo applications, + * as described at the top of this file. + * + * When mainSELECTED_APPLICATION is set to 0 the simple blinky example will + * be run. + * + * When mainSELECTED_APPLICATION is set to 1 the comprehensive test and demo + * application will be run. + * + * When mainSELECTED_APPLICATION is set to 2 the lwIP example will be run. + */ +#define mainSELECTED_APPLICATION 0 /*-----------------------------------------------------------*/ @@ -123,13 +134,17 @@ or 0 to run the more comprehensive test and demo application. */ static void prvSetupHardware( void ); /* - * main_blinky() is used when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 1. - * main_full() is used when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 0. + * See the comments at the top of this file and above the + * mainSELECTED_APPLICATION definition. */ -#if mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 +#if ( mainSELECTED_APPLICATION == 0 ) extern void main_blinky( void ); -#else +#elif ( mainSELECTED_APPLICATION == 1 ) extern void main_full( void ); +#elif ( mainSELECTED_APPLICATION == 2 ) + extern void main_lwIP( void ); +#else + #error Invalid mainSELECTED_APPLICATION setting. See the comments at the top of this file and above the mainSELECTED_APPLICATION definition. #endif /* #if mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 */ /* @@ -147,6 +162,10 @@ void vApplicationIdleHook( void ); void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName ); void vApplicationTickHook( void ); +/* The private watchdog is used as the timer that generates run time +stats. This frequency means it will overflow quite quickly. */ +XScuWdt xWatchDogInstance; + /*-----------------------------------------------------------*/ /* The interrupt controller is initialised in this file, and made available to @@ -162,18 +181,20 @@ extern void main_lwIP( void ); /* Configure the hardware ready to run the demo. */ prvSetupHardware(); -main_lwIP(); - - /* The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting is described at the top + /* The mainSELECTED_APPLICATION setting is described at the top of this file. */ - #if( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 ) + #if( mainSELECTED_APPLICATION == 0 ) { main_blinky(); } - #else + #elif( mainSELECTED_APPLICATION == 1 ) { main_full(); } + #else + { + main_lwIP(); + } #endif /* Don't expect to reach here. */ @@ -281,7 +302,7 @@ volatile unsigned long ul = 0; void vApplicationTickHook( void ) { - #if( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 0 ) + #if( mainSELECTED_APPLICATION == 1 ) { /* The full demo includes a software timer demo/test that requires prodding periodically from the tick interrupt. */ @@ -343,5 +364,25 @@ size_t x; return ulBytes - x; } +/*-----------------------------------------------------------*/ + +void vInitialiseTimerForRunTimeStats( void ) +{ +XScuWdt_Config *pxWatchDogInstance; +uint32_t ulValue; +const uint32_t ulMaxDivisor = 0xff, ulDivisorShift = 0x08; + + pxWatchDogInstance = XScuWdt_LookupConfig( XPAR_SCUWDT_0_DEVICE_ID ); + XScuWdt_CfgInitialize( &xWatchDogInstance, pxWatchDogInstance, pxWatchDogInstance->BaseAddr ); + + ulValue = XScuWdt_GetControlReg( &xWatchDogInstance ); + ulValue |= ulMaxDivisor << ulDivisorShift; + XScuWdt_SetControlReg( &xWatchDogInstance, ulValue ); + + XScuWdt_LoadWdt( &xWatchDogInstance, UINT_MAX ); + XScuWdt_SetTimerMode( &xWatchDogInstance ); + XScuWdt_Start( &xWatchDogInstance ); +} +