From 1903ec497e5de7733d78f5575528e4ba2308c2e3 Mon Sep 17 00:00:00 2001 From: rtel Date: Tue, 10 Jun 2014 16:25:46 +0000 Subject: [PATCH] Switch to using the private watchdog as the run time stats timer in the Zynq demo. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2255 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- .../RTOSDemo/src/FreeRTOSConfig.h | 27 ++++++++++++------- .../RTOSDemo/src/Full_Demo/IntQueueTimer.c | 9 +++---- .../BasicSocketCommandServer.c | 4 +++ .../src/lwIP_Demo/lwIP_Apps/lwIP_Apps.c | 5 ++-- .../src/lwIP_Demo/lwIP_port/netif/xpqueue.c | 2 +- .../RTOSDemo/src/lwIP_Demo/main_lwIP.c | 2 +- .../CORTEX_A9_Zynq_ZC702/RTOSDemo/src/main.c | 27 ++++++++++++++++++- 7 files changed, 56 insertions(+), 20 deletions(-) diff --git a/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/FreeRTOSConfig.h b/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/FreeRTOSConfig.h index c61f9972c..b61a83bb8 100644 --- a/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/FreeRTOSConfig.h +++ b/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/FreeRTOSConfig.h @@ -159,14 +159,13 @@ readable ASCII form. See the notes in the implementation of vTaskList() within FreeRTOS/Source/tasks.c for limitations. */ #define configUSE_STATS_FORMATTING_FUNCTIONS 1 -/* portCONFIGURE_TIMER_FOR_RUN_TIME_STATS is not required because the time base -comes from the ulHighFrequencyTimerCounts variable which is incremented in a -high frequency timer that is already being started as part of the interrupt -nesting test. */ -#define configGENERATE_RUN_TIME_STATS 1 -extern volatile uint32_t ulHighFrequencyTimerCounts; -#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() -#define portGET_RUN_TIME_COUNTER_VALUE() ulHighFrequencyTimerCounts +/* The private watchdog is used to generate run time stats. */ +#include "xscuwdt.h" +extern XScuWdt xWatchDogInstance; +extern void vInitialiseTimerForRunTimeStats( void ); +#define configGENERATE_RUN_TIME_STATS 1 +#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() vInitialiseTimerForRunTimeStats() +#define portGET_RUN_TIME_COUNTER_VALUE() ( 0xffffffffUL - XScuWdt_ReadReg( xWatchDogInstance.Config.BaseAddr, XSCUWDT_COUNTER_OFFSET ) ) /* The size of the global output buffer that is available for use when there are multiple command interpreters running at once (for example, one on a UART @@ -205,11 +204,21 @@ Zynq MPU. */ -/****** Network configuration settings. ***************************************/ +/****** Network configuration settings - only used when the lwIP example is +built. See the page that documents this demo on the http://www.FreeRTOS.org +website for more information. ***********************************************/ +/* The priority for the task that unblocked by the MAC interrupt to process +received packets. */ #define configMAC_INPUT_TASK_PRIORITY ( configMAX_PRIORITIES - 1 ) + +/* The priority of the task that runs the lwIP stack. */ #define configLWIP_TASK_PRIORITY ( configMAX_PRIORITIES - 2 ) +/* The priority of the task that uses lwIP sockets to provide a simple command +line interface. */ +#define configCLI_TASK_PRIORITY ( tskIDLE_PRIORITY ) + /* MAC address configuration. */ #define configMAC_ADDR0 0x00 #define configMAC_ADDR1 0x13 diff --git a/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/Full_Demo/IntQueueTimer.c b/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/Full_Demo/IntQueueTimer.c index 00856d194..c03fd942a 100644 --- a/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/Full_Demo/IntQueueTimer.c +++ b/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/Full_Demo/IntQueueTimer.c @@ -148,9 +148,9 @@ actually being reached. */ extern uint32_t ulPortInterruptNesting; static uint32_t ulMaxRecordedNesting = 0; -/* For convenience the high frequency timer increments a variable that is then -used as the time base for the run time stats. */ -volatile uint32_t ulHighFrequencyTimerCounts = 0; +/* Used to ensure the high frequency timer is running at the expected +frequency. */ +static volatile uint32_t ulHighFrequencyTimerCounts = 0; /*-----------------------------------------------------------*/ @@ -238,8 +238,7 @@ BaseType_t xYieldRequired; } else { - /* The high frequency timer is also used to generate the time base for - the run time state. */ + /* Used to check the timer is running at the expected frequency. */ ulHighFrequencyTimerCounts++; /* Latch the highest interrupt nesting count detected. */ diff --git a/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/lwIP_Demo/lwIP_Apps/apps/BasicSocketCommandServer/BasicSocketCommandServer.c b/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/lwIP_Demo/lwIP_Apps/apps/BasicSocketCommandServer/BasicSocketCommandServer.c index 57f9b5ac4..bf7d1f0bf 100644 --- a/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/lwIP_Demo/lwIP_Apps/apps/BasicSocketCommandServer/BasicSocketCommandServer.c +++ b/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/lwIP_Demo/lwIP_Apps/apps/BasicSocketCommandServer/BasicSocketCommandServer.c @@ -83,9 +83,13 @@ const char *pcWelcomeMessage = "FreeRTOS command server - connection accepted.\r char cInChar; static char cInputString[ cmdMAX_INPUT_SIZE ], cOutputString[ cmdMAX_OUTPUT_SIZE ]; portBASE_TYPE xReturned; +extern void vRegisterSampleCLICommands( void ); ( void ) pvParameters; + /* Register the standard CLI commands. */ + vRegisterSampleCLICommands(); + lSocket = lwip_socket(AF_INET, SOCK_STREAM, 0); if( lSocket >= 0 ) diff --git a/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/lwIP_Demo/lwIP_Apps/lwIP_Apps.c b/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/lwIP_Demo/lwIP_Apps/lwIP_Apps.c index fd2b5f8e5..b298b8dd3 100644 --- a/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/lwIP_Demo/lwIP_Apps/lwIP_Apps.c +++ b/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/lwIP_Demo/lwIP_Apps/lwIP_Apps.c @@ -165,12 +165,11 @@ static struct netif xNetIf; use of the lwIP raw API. */ httpd_init(); - sys_thread_new( "lwIP Input", xemacif_input_thread, &xNetIf, configMINIMAL_STACK_SIZE, configMAC_INPUT_TASK_PRIORITY ); + sys_thread_new( "lwIP_In", xemacif_input_thread, &xNetIf, configMINIMAL_STACK_SIZE, configMAC_INPUT_TASK_PRIORITY ); /* Create the FreeRTOS defined basic command server. This demonstrates use of the lwIP sockets API. */ -#warning Commented out CLI -// xTaskCreate( vBasicSocketsCommandInterpreterTask, "CmdInt", configMINIMAL_STACK_SIZE * 10, NULL, configMAX_PRIORITIES - 2, NULL ); + xTaskCreate( vBasicSocketsCommandInterpreterTask, "CmdInt", configMINIMAL_STACK_SIZE * 5, NULL, configCLI_TASK_PRIORITY, NULL ); } /*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/lwIP_Demo/lwIP_port/netif/xpqueue.c b/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/lwIP_Demo/lwIP_port/netif/xpqueue.c index 02bb68fd6..6802c1310 100644 --- a/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/lwIP_Demo/lwIP_port/netif/xpqueue.c +++ b/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/lwIP_Demo/lwIP_port/netif/xpqueue.c @@ -31,7 +31,7 @@ pq_create_queue() pq_queue_t *q = NULL; if (i >= NUM_QUEUES) { - xil_printf("ERR: Max Queues allocated\n\r"); + //xil_printf("ERR: Max Queues allocated\n\r"); return q; } diff --git a/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/lwIP_Demo/main_lwIP.c b/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/lwIP_Demo/main_lwIP.c index 05942205b..7cd652da6 100644 --- a/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/lwIP_Demo/main_lwIP.c +++ b/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/lwIP_Demo/main_lwIP.c @@ -156,4 +156,4 @@ static void prvLEDToggleTimer( TimerHandle_t pxTimer ) vParTestToggleLED( mainTIMER_LED ); } - +/*-----------------------------------------------------------*/ 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 3738bb75c..425c87ac7 100644 --- a/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/main.c +++ b/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/main.c @@ -93,6 +93,7 @@ /* Standard includes. */ #include +#include /* Scheduler include files. */ #include "FreeRTOS.h" @@ -123,7 +124,7 @@ * * When mainSELECTED_APPLICATION is set to 2 the lwIP example will be run. */ -#define mainSELECTED_APPLICATION 0 +#define mainSELECTED_APPLICATION 2 /*-----------------------------------------------------------*/ @@ -161,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 @@ -359,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 ); +} + -- 2.39.2