From 360e8411e740e369da9bd112104d7b4e977e8c83 Mon Sep 17 00:00:00 2001 From: rtel Date: Tue, 11 Feb 2014 09:24:33 +0000 Subject: [PATCH] Add event groups demo to Zynq demo. Add C implementations of some standard library functions to the Zynq demo to prevent the GCC libraries (which use floating point registers as scratch registers) being linked in. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2199 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- .../RTOSDemo/src/FreeRTOSConfig.h | 4 +- .../RTOSDemo/src/Full_Demo/main_full.c | 7 ++ .../CORTEX_A9_Zynq_ZC702/RTOSDemo/src/main.c | 73 +++++++++++++++++-- 3 files changed, 74 insertions(+), 10 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 acfda1d37..06e049af8 100644 --- a/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/FreeRTOSConfig.h +++ b/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/FreeRTOSConfig.h @@ -116,8 +116,8 @@ #define configUSE_IDLE_HOOK 1 #define configUSE_TICK_HOOK 1 #define configMAX_PRIORITIES ( 7 ) -#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 160 ) -#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 51200 ) ) +#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 200 ) +#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 65536 ) ) #define configMAX_TASK_NAME_LEN ( 10 ) #define configUSE_TRACE_FACILITY 1 #define configUSE_16_BIT_TICKS 0 diff --git a/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/Full_Demo/main_full.c b/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/Full_Demo/main_full.c index 18e359506..7c716b613 100644 --- a/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/Full_Demo/main_full.c +++ b/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/Full_Demo/main_full.c @@ -143,6 +143,7 @@ #include "TimerDemo.h" #include "QueueOverwrite.h" #include "IntQueue.h" +#include "EventGroupsDemo.h" /* Priorities for the demo application tasks. */ #define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1UL ) @@ -243,6 +244,7 @@ void main_full( void ) vStartMathTasks( mainFLOP_TASK_PRIORITY ); vStartTimerDemoTask( mainTIMER_TEST_PERIOD ); vStartQueueOverwriteTask( mainQUEUE_OVERWRITE_PRIORITY ); + vStartEventGroupTasks(); /* Start the tasks that implements the command console on the UART, as described above. */ @@ -366,6 +368,11 @@ unsigned long ulErrorFound = pdFALSE; ulErrorFound = pdTRUE; } + if( xAreEventGroupTasksStillRunning() != pdPASS ) + { + ulErrorFound = pdTRUE; + } + /* Check that the register test 1 task is still running. */ if( ulLastRegTest1Value == ulRegTest1LoopCounter ) { 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 02873160d..29d160a68 100644 --- a/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/main.c +++ b/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/main.c @@ -74,12 +74,15 @@ * This file implements the code that is not demo specific, including the * hardware setup and FreeRTOS hook functions. * - * NOTE: The full demo includes a test that checks the floating point context - * is maintained correctly across task switches. The standard GCC libraries can - * use floating point registers and made this test fail (unless the tasks that - * use the library are given a floating point context as described on the - * documentation page for this demo). printf-stdarg.c is included in this - * project to prevent the standard GCC libraries being linked into the project. + * !!! IMPORTANT NOTE !!! + * The GCC libraries that ship with the Xilinx SDK make use of the floating + * point registers. To avoid this causing corruption it is necessary to avoid + * their use. For this reason main.c contains very basic C implementations of + * the standard C library functions memset(), memcpy() and memcmp(), which are + * are used by FreeRTOS itself. Defining these functions in the project + * prevents the linker pulling them in from the library. Any other standard C + * library functions that are used by the application must likewise be defined + * in C. * * ENSURE TO READ THE DOCUMENTATION PAGE FOR THIS PORT AND DEMO APPLICATION ON * THE http://www.FreeRTOS.org WEB SITE FOR FULL INFORMATION ON USING THIS DEMO @@ -99,6 +102,7 @@ #include "partest.h" #include "TimerDemo.h" #include "QueueOverwrite.h" +#include "EventGroupsDemo.h" /* Xilinx includes. */ #include "platform.h" @@ -109,7 +113,7 @@ /* 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 +#define mainCREATE_SIMPLE_BLINKY_DEMO_ONLY 0 /*-----------------------------------------------------------*/ @@ -158,7 +162,7 @@ int main( void ) /* The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting is described at the top of this file. */ - #if mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 + #if( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 ) { main_blinky(); } @@ -281,6 +285,59 @@ void vApplicationTickHook( void ) /* Call the periodic queue overwrite from ISR demo. */ vQueueOverwritePeriodicISRDemo(); + + /* Call the periodic event group from ISR demo. */ + vPeriodicEventGroupsProcessing(); } #endif } +/*-----------------------------------------------------------*/ + +void *memcpy( void *pvDest, const void *pvSource, size_t ulBytes ) +{ +unsigned char *pcDest = ( unsigned char * ) pvDest, *pcSource = ( unsigned char * ) pvSource; +size_t x; + + for( x = 0; x < ulBytes; x++ ) + { + *pcDest = *pcSource; + pcDest++; + pcSource++; + } + + return pvDest; +} +/*-----------------------------------------------------------*/ + +void *memset( void *pvDest, int iValue, size_t ulBytes ) +{ +unsigned char *pcDest = ( unsigned char * ) pvDest; +size_t x; + + for( x = 0; x < ulBytes; x++ ) + { + *pcDest = ( unsigned char ) c; + pcDest++; + } + + return pvDest; +} +/*-----------------------------------------------------------*/ + +int memcmp( const void *pvMem1, const void *pvMem2 ,size_t ulBytes ) +{ +const unsigned char *pucMem1 = pvMem1, *pucMem2 = pvMem2; +size_t x; + + for( x = 0; x < ulBytes; x++ ) + { + if( pucMem1[ x ] != pucMem2[ x ] ) + { + break; + } + } + + return n - x; +} + + -- 2.39.5