From b690b268612a4dd3dc40d259e23e7842671ec295 Mon Sep 17 00:00:00 2001 From: Richard Barry Date: Sat, 16 Nov 2013 18:06:57 +0000 Subject: [PATCH] Add standard demo tasks to SAM4E demo. --- .../RTOSDemo.atsuo | Bin 84992 -> 93696 bytes .../RTOSDemo.cproj | 45 +++++ .../cmsis/sam4e/source/templates/exceptions.c | 9 +- .../src/ParTest.c | 121 +++++++++++++ .../src/config/FreeRTOSConfig.h | 5 +- .../CORTEX_M4_ATSAM4E_Atmel_Studio/src/main.c | 19 +- .../src/main_blinky.c | 11 +- .../src/main_full.c | 169 ++++++++++++++++-- 8 files changed, 349 insertions(+), 30 deletions(-) create mode 100644 FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/ParTest.c diff --git a/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/RTOSDemo.atsuo b/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/RTOSDemo.atsuo index eb4af88cc4db7cd765769da3e23d868458ecfea0..1c351b4d6d67bddc1d4527c47e30bf0fa0cd282a 100644 GIT binary patch delta 5123 zcmb_g4OCRs7QTDt&Tv5-1{iQuz+pf^5g7@dXr}xLq#y&5Ss^g!sHFUes6AP? zF1CT3bTjHQ8kGkSm$$G*g+^Xr65dX3q^~ zQz}d7qu2%8Nj}3#ju!7qmmC>MsBMPEU-Hwa0I&Fr2M!ndjKm6GKRi2FuxWj0uny~Y zMPaLN3Px^?ky?G-(oqM2I9s;>^mtR3Zd;kgsS+)LMqa@L_T`{8FcmYm&l9WSpdX&QuN7mv z)6sY%G~IhH>z1l%)*SG>{)5z@&N-kuT=~Mw zi{!UQ^m>LD8mca(s6&K24j|o z;_{WRV$Y>sSol2R@ii_|!@_Mqra?`VMpJ2)c^2*zHCSFXe&v!Feg$1$9KIwKI;u?x zcx*`t--iyr+O%EsGu7N9*zP{%9Le!y)d1=A;#z=FG+ww*abaO`QFdBEQ9+?;Ms~(* z^KA1tGaDXe+En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FY@R$O6D`UV%7QoNq5f$ z1I{|-Q1AlQ#+5O9f7l7bBycPSY~R;}#RWQMkAzxm%M7OzB1rHH%xu|%xBqSM=ngly~7tB?*~Y~yPXMA`lGpU>;^^7g^&?wyJ?nN z$o!Yp>!w*Xn;36!=8L-cO$MIT#Nvv(z7asf%G{trbnNrmFJ6_;{Bmw`vgXdom0@#mtfl{HARst25(-NDoN5^^5}m%yDCB)vx}f>uoMGci;qNC@^uQtK=zIo ztV7qNr8EgeaQv6&yVZH$6UKql8V*JPl{-Z=N%15S;M^7gIRL#fH7HHvEQ*AcP_2Pv z9!kun0kdimof}B#`9{hURPIDz2}O{?KA#K|nYoCp=Tudx5shCNRdYx@zt z8m`)6rf?a7X*<@Sxh8~ZQ^Cl#20#fm?n%X?715kaiR^=U7sue2O&RV2z4bjc&cbkI z9ZZeSo_0JC>@b5j%V_G!zt%KYQM+71ox1R4+jQG!BW|&nQ}%d&mSHsAKmB zgNRo@+KkIKYjJJOAbfK8G+Mt+q9Ed99@UtH<3?zQ@%+lQfG$@yx@GYDARm4L&`r(O zJ)vi)%l?91A}prkXkf-EJu@x@A7(9pYtZP9)25+Xui@S6-8&GL1z?M77T#Xq!%T02 zlIMF1oWU#V7`9~zR69GC!gdkMza5QX`;G96dQXv9`@D>ISK*i4Oqz9SG(ZYG25|Y{_7e&*-(}>_~=IkiXuC Il>%z`KarsZ3jhEB diff --git a/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/RTOSDemo.cproj b/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/RTOSDemo.cproj index 62f51e28c..e25100f39 100644 --- a/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/RTOSDemo.cproj +++ b/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/RTOSDemo.cproj @@ -375,6 +375,7 @@ ../../../../FreeRTOS-Plus/Source/FreeRTOS-Plus-CLI ../../../../FreeRTOS-Plus/Source/FreeRTOS-Plus-FAT-SL/api ../../../../FreeRTOS-Plus/Demo/Common/FreeRTOS_Plus_UDP_Demos/CLICommands + ../../Common/include -fdata-sections @@ -516,6 +517,46 @@ compile src\FreeRTOS+\FreeRTOS+FAT SL\PSP\Target\RTC\psp_rtc.c + + compile + src\Common Demo Tasks\blocktim.c + + + compile + src\Common Demo Tasks\countsem.c + + + compile + src\Common Demo Tasks\dynamic.c + + + compile + src\Common Demo Tasks\flash_timer.c + + + compile + src\Common Demo Tasks\GenQTest.c + + + compile + src\Common Demo Tasks\QPeek.c + + + compile + src\Common Demo Tasks\QueueOverwrite.c + + + compile + src\Common Demo Tasks\QueueSet.c + + + compile + src\Common Demo Tasks\recmutex.c + + + compile + src\Common Demo Tasks\semtest.c + compile @@ -534,6 +575,9 @@ compile + + compile + compile @@ -1078,6 +1122,7 @@ + \ No newline at end of file diff --git a/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/ASF/sam/utils/cmsis/sam4e/source/templates/exceptions.c b/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/ASF/sam/utils/cmsis/sam4e/source/templates/exceptions.c index 497cec550..57990ba5a 100644 --- a/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/ASF/sam/utils/cmsis/sam4e/source/templates/exceptions.c +++ b/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/ASF/sam/utils/cmsis/sam4e/source/templates/exceptions.c @@ -62,10 +62,11 @@ extern "C" { /* @endcond */ #ifdef __GNUC__ +void Dummy_Hardfault_Handler( void ); /* Cortex-M4 core handlers */ void Reset_Handler (void ) __attribute__ ((weak, alias("Dummy_Handler"))); void NMI_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler"))); -void HardFault_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler"))); +void HardFault_Handler ( void ) __attribute__ ((weak, alias("Dummy_Hardfault_Handler"))); void MemManage_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler"))); void BusFault_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler"))); void UsageFault_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler"))); @@ -186,6 +187,12 @@ void Dummy_Handler(void) } } +void Dummy_Hardfault_Handler(void) +{ + while (1) { + } +} + /* @cond 0 */ /**INDENT-OFF**/ #ifdef __cplusplus diff --git a/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/ParTest.c b/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/ParTest.c new file mode 100644 index 000000000..7f379f6e6 --- /dev/null +++ b/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/ParTest.c @@ -0,0 +1,121 @@ +/* + FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd. + All rights reserved + + VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. + + *************************************************************************** + * * + * FreeRTOS provides completely free yet professionally developed, * + * robust, strictly quality controlled, supported, and cross * + * platform software that has become a de facto standard. * + * * + * Help yourself get started quickly and support the FreeRTOS * + * project by purchasing a FreeRTOS tutorial book, reference * + * manual, or both from: http://www.FreeRTOS.org/Documentation * + * * + * Thank you! * + * * + *************************************************************************** + + This file is part of the FreeRTOS distribution. + + FreeRTOS is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License (version 2) as published by the + Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. + + >>! NOTE: The modification to the GPL is included to allow you to distribute + >>! a combined work that includes FreeRTOS without being obliged to provide + >>! the source code for proprietary components outside of the FreeRTOS + >>! kernel. + + FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. Full license text is available from the following + link: http://www.freertos.org/a00114.html + + 1 tab == 4 spaces! + + *************************************************************************** + * * + * Having a problem? Start by reading the FAQ "My application does * + * not run, what could be wrong?" * + * * + * http://www.FreeRTOS.org/FAQHelp.html * + * * + *************************************************************************** + + http://www.FreeRTOS.org - Documentation, books, training, latest versions, + license and Real Time Engineers Ltd. contact details. + + http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, + including FreeRTOS+Trace - an indispensable productivity tool, a DOS + compatible FAT file system, and our tiny thread aware UDP/IP stack. + + http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High + Integrity Systems to sell under the OpenRTOS brand. Low cost OpenRTOS + licenses offer ticketed support, indemnification and middleware. + + http://www.SafeRTOS.com - High Integrity Systems also provide a safety + engineered and independently SIL3 certified version for use in safety and + mission critical applications that require provable dependability. + + 1 tab == 4 spaces! +*/ + +/*----------------------------------------------------------- + * Simple IO routines to control the LEDs. + *-----------------------------------------------------------*/ + +/* Scheduler includes. */ +#include "FreeRTOS.h" +#include "task.h" + +/* Demo includes. */ +#include "partest.h" + +/* The number of LEDs available to the user on the evaluation kit. */ +#define partestNUM_LEDS ( 3UL ) + +/* The index of the pins to which the LEDs are connected. The ordering of the +LEDs in this array is intentional and matches the order they appear on the +hardware. */ +static const uint32_t ulLED[] = { LED0_GPIO, LED1_GPIO, LED2_GPIO }; + +/*-----------------------------------------------------------*/ + +void vParTestInitialise( void ) +{ + /* LEDs are initialised in the Atmel provided board initialisation + function. */ +} +/*-----------------------------------------------------------*/ + +void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue ) +{ + if( uxLED < partestNUM_LEDS ) + { + /* Turn the LED off. */ + taskENTER_CRITICAL(); + { + ioport_set_pin_level( ulLED[ uxLED ], !xValue ); + } + taskEXIT_CRITICAL(); + } +} +/*-----------------------------------------------------------*/ + +void vParTestToggleLED( unsigned portBASE_TYPE uxLED ) +{ + if( uxLED < partestNUM_LEDS ) + { + taskENTER_CRITICAL(); + { + ioport_toggle_pin_level( ulLED[ uxLED ] ); + } + taskEXIT_CRITICAL(); + } +} + + + diff --git a/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/config/FreeRTOSConfig.h b/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/config/FreeRTOSConfig.h index da072d87e..8369b918b 100644 --- a/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/config/FreeRTOSConfig.h +++ b/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/config/FreeRTOSConfig.h @@ -84,13 +84,14 @@ #define configUSE_PREEMPTION 1 #define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 +#define configUSE_QUEUE_SETS 1 #define configUSE_IDLE_HOOK 0 -#define configUSE_TICK_HOOK 0 +#define configUSE_TICK_HOOK 1 #define configCPU_CLOCK_HZ ( ( unsigned long ) CHIP_FREQ_CPU_MAX ) #define configTICK_RATE_HZ ( 1000 ) #define configMAX_PRIORITIES ( 5 ) #define configMINIMAL_STACK_SIZE ( ( unsigned short ) 130 ) -#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 22800 ) ) +#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 34 * 1024 ) ) #define configMAX_TASK_NAME_LEN ( 10 ) #define configUSE_TRACE_FACILITY 1 #define configUSE_16_BIT_TICKS 0 diff --git a/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/main.c b/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/main.c index b07ff053c..81582ce0f 100644 --- a/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/main.c +++ b/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/main.c @@ -80,6 +80,9 @@ #include "FreeRTOS.h" #include "task.h" +/* Demo application includes. */ +#include "partest.h" + /* Set mainCREATE_SIMPLE_BLINKY_DEMO_ONLY to one to run the simple blinky demo, or 0 to run the more comprehensive demo application that includes add-on components. */ @@ -128,6 +131,7 @@ static void prvSetupHardware( void ) board_init(); sysclk_init(); pmc_enable_periph_clk( ID_GMAC ); + vParTestInitialise(); } /*-----------------------------------------------------------*/ @@ -143,8 +147,7 @@ void vApplicationMallocFailedHook( void ) FreeRTOSConfig.h, and the xPortGetFreeHeapSize() API function can be used to query the size of free heap space that remains (although it does not provide information on how the remaining heap might be fragmented). */ - taskDISABLE_INTERRUPTS(); - for( ;; ); + vAssertCalled( __LINE__, __FILE__ ); } /*-----------------------------------------------------------*/ @@ -179,8 +182,7 @@ void vApplicationStackOverflowHook( xTaskHandle pxTask, signed char *pcTaskName /* Run time stack overflow checking is performed if configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook function is called if a stack overflow is detected. */ - taskDISABLE_INTERRUPTS(); - for( ;; ); + vAssertCalled( __LINE__, __FILE__ ); } /*-----------------------------------------------------------*/ @@ -191,6 +193,15 @@ void vApplicationTickHook( void ) added here, but the tick hook is called from an interrupt context, so code must not attempt to block, and only the interrupt safe FreeRTOS API functions can be used (those that end in FromISR()). */ + + /* The simple blinky demo does not use the tick hook - the full demo does. */ + #if( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 0 ) + { + extern void vFullDemoTickHook( void ); + + vFullDemoTickHook(); + } + #endif } /*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/main_blinky.c b/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/main_blinky.c index a19957549..1e52ba68a 100644 --- a/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/main_blinky.c +++ b/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/main_blinky.c @@ -100,6 +100,9 @@ #include "queue.h" #include "timers.h" +/* Demo application includes. */ +#include "partest.h" + /* Priorities at which the tasks are created. */ #define mainQUEUE_RECEIVE_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 ) #define mainQUEUE_SEND_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 ) @@ -126,8 +129,8 @@ converted to ticks using the portTICK_RATE_MS constant. */ #define mainDONT_BLOCK ( 0 ) /* The LEDs toggled by the timer and queue receive task respectively. */ -#define mainTIMER_LED LED0_GPIO -#define mainTASK_LED LED1_GPIO +#define mainTIMER_LED 0 +#define mainTASK_LED 1 /*-----------------------------------------------------------*/ @@ -250,7 +253,7 @@ unsigned long ulReceivedValue; is it the expected value? If it is, toggle the LED. */ if( ulReceivedValue == 100UL ) { - ioport_toggle_pin_level( mainTASK_LED ); + vParTestToggleLED( mainTASK_LED ); ulReceivedValue = 0U; } } @@ -265,7 +268,7 @@ static void prvBlinkyTimerCallback( xTimerHandle xTimer ) /* This function is called when the blinky software time expires. All the function does is toggle the LED. LED mainTIMER_LED should therefore toggle with the period set by mainBLINKY_TIMER_PERIOD. */ - ioport_toggle_pin_level( mainTIMER_LED ); + vParTestToggleLED( mainTIMER_LED ); } /*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/main_full.c b/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/main_full.c index 34a0c5f7f..b03439c0f 100644 --- a/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/main_full.c +++ b/FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/main_full.c @@ -73,6 +73,48 @@ /* Demo application includes. */ #include "UDPCommandInterpreter.h" +#include "partest.h" +#include "blocktim.h" +#include "flash_timer.h" +#include "semtest.h" +#include "GenQTest.h" +#include "QPeek.h" +#include "IntQueue.h" +#include "countsem.h" +#include "dynamic.h" +#include "QueueOverwrite.h" +#include "QueueSet.h" +#include "recmutex.h" + +/* The period after which the check timer will expire, in ms, provided no errors +have been reported by any of the standard demo tasks. ms are converted to the +equivalent in ticks using the portTICK_RATE_MS constant. */ +#define mainCHECK_TIMER_PERIOD_MS ( 3000UL / portTICK_RATE_MS ) + +/* The period at which the check timer will expire, in ms, if an error has been +reported in one of the standard demo tasks. ms are converted to the equivalent +in ticks using the portTICK_RATE_MS constant. */ +#define mainERROR_CHECK_TIMER_PERIOD_MS ( 200UL / portTICK_RATE_MS ) + +/* The priorities of the various demo application tasks. */ +#define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 ) +#define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 ) +#define mainCOM_TEST_PRIORITY ( tskIDLE_PRIORITY + 2 ) +#define mainINTEGER_TASK_PRIORITY ( tskIDLE_PRIORITY ) +#define mainGEN_QUEUE_TASK_PRIORITY ( tskIDLE_PRIORITY ) +#define mainQUEUE_OVERWRITE_TASK_PRIORITY ( tskIDLE_PRIORITY ) + +/* The LED controlled by the 'check' software timer. */ +#define mainCHECK_LED ( 2 ) + +/* The number of LEDs that should be controlled by the flash software timer +standard demo. In this case it is only 1 as the starter kit has three LEDs, one +of which is controlled by the check timer and one of which is controlled by the +ISR triggered task. */ +#define mainNUM_FLASH_TIMER_LEDS ( 1 ) + +/* Misc. */ +#define mainDONT_BLOCK ( 0 ) /* Note: If the application is started without the network cable plugged in then ipconfigUDP_TASK_PRIORITY should be set to 0 in FreeRTOSIPConfig.h to @@ -90,10 +132,16 @@ passed into the network event hook is eNetworkUp). */ #define mainUDP_CLI_PORT_NUMBER ( 5001UL ) #define mainUDP_CLI_TASK_STACK_SIZE ( configMINIMAL_STACK_SIZE * 2U ) -/* Simple toggles an LED to show the program is running. */ -static void prvFlashTimerCallback( xTimerHandle xTimer ); +/*-----------------------------------------------------------*/ -/* Creates a set of sample files on a RAM disk. */ +/* + * The check timer callback function, as described at the top of this file. + */ +static void prvCheckTimerCallback( xTimerHandle xTimer ); + +/* + * Creates a set of sample files on a RAM disk. + */ extern void vCreateAndVerifySampleFiles( void ); /* @@ -125,7 +173,7 @@ const uint8_t ucMACAddress[ 6 ] = { configMAC_ADDR0, configMAC_ADDR1, configMAC_ /*-----------------------------------------------------------*/ int main_full( void ) { -xTimerHandle xFlashTimer; +xTimerHandle xTimer = NULL; /* If the file system is only going to be accessed from one task then F_FS_THREAD_AWARE can be set to 0 and the set of example files are created @@ -150,15 +198,6 @@ xTimerHandle xFlashTimer; interpreter. */ vRegisterFileSystemCLICommands(); - /* Create the timer that just toggles an LED to indicate that the - application is running. */ - xFlashTimer = xTimerCreate( ( const signed char * const ) "Flash", 200 / portTICK_RATE_MS, pdTRUE, NULL, prvFlashTimerCallback ); - configASSERT( xFlashTimer ); - - /* Start the timer. As the scheduler is not running a block time cannot be - used and is set to 0. */ - xTimerStart( xFlashTimer, 0 ); - /* Initialise the network interface. Tasks that use the network are created in the network event hook when the network is connected and ready for use. The address values passed in here are used if ipconfigUSE_DHCP is @@ -167,6 +206,31 @@ xTimerHandle xFlashTimer; ipconfigFREERTOS_PLUS_NABTO is set to 1 in FreeRTOSIPConfig.h. */ FreeRTOS_IPInit( ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress ); + /* Create all the other standard demo tasks. */ + vStartLEDFlashTimers( mainNUM_FLASH_TIMER_LEDS ); + vCreateBlockTimeTasks(); + vStartSemaphoreTasks( mainSEM_TEST_PRIORITY ); + vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY ); + vStartQueuePeekTasks(); + vStartCountingSemaphoreTasks(); + vStartDynamicPriorityTasks(); + vStartQueueOverwriteTask( mainQUEUE_OVERWRITE_TASK_PRIORITY ); + vStartQueueSetTasks(); + vStartRecursiveMutexTasks(); + + /* Create the software timer that performs the 'check' functionality, as + described at the top of this file. */ + xTimer = xTimerCreate( ( const signed char * ) "CheckTimer",/* A text name, purely to help debugging. */ + ( mainCHECK_TIMER_PERIOD_MS ), /* The timer period, in this case 3000ms (3s). */ + pdTRUE, /* This is an auto-reload timer, so xAutoReload is set to pdTRUE. */ + ( void * ) 0, /* The ID is not used, so can be set to anything. */ + prvCheckTimerCallback ); /* The callback function that inspects the status of all the other tasks. */ + + if( xTimer != NULL ) + { + xTimerStart( xTimer, mainDONT_BLOCK ); + } + /* Start the scheduler itself. */ vTaskStartScheduler(); @@ -179,14 +243,71 @@ xTimerHandle xFlashTimer; } /*-----------------------------------------------------------*/ -static void prvFlashTimerCallback( xTimerHandle xTimer ) +static void prvCheckTimerCallback( xTimerHandle xTimer ) { - /* The parameter is not used. */ +static long lChangedTimerPeriodAlready = pdFALSE; +unsigned long ulErrorOccurred = pdFALSE; + + /* Avoid compiler warnings. */ ( void ) xTimer; - - /* Timer callback function that does nothing other than toggle an LED to - indicate that the application is still running. */ - ioport_toggle_pin_level( LED0_GPIO ); + + /* Have any of the standard demo tasks detected an error in their + operation? */ + if( xAreGenericQueueTasksStillRunning() != pdTRUE ) + { + ulErrorOccurred |= ( 0x01UL << 3UL ); + } + else if( xAreQueuePeekTasksStillRunning() != pdTRUE ) + { + ulErrorOccurred |= ( 0x01UL << 4UL ); + } + else if( xAreBlockTimeTestTasksStillRunning() != pdTRUE ) + { + ulErrorOccurred |= ( 0x01UL << 5UL ); + } + else if( xAreSemaphoreTasksStillRunning() != pdTRUE ) + { + ulErrorOccurred |= ( 0x01UL << 6UL ); + } + else if( xAreCountingSemaphoreTasksStillRunning() != pdTRUE ) + { + ulErrorOccurred |= ( 0x01UL << 8UL ); + } + else if( xAreDynamicPriorityTasksStillRunning() != pdTRUE ) + { + ulErrorOccurred |= ( 0x01UL << 9UL ); + } + else if( xIsQueueOverwriteTaskStillRunning() != pdTRUE ) + { + ulErrorOccurred |= ( 0x01UL << 10UL ); + } + else if( xAreQueueSetTasksStillRunning() != pdTRUE ) + { + ulErrorOccurred |= ( 0x01UL << 11UL ); + } + else if( xAreRecursiveMutexTasksStillRunning() != pdTRUE ) + { + ulErrorOccurred |= ( 0x01UL << 12UL ); + } + + if( ulErrorOccurred != pdFALSE ) + { + /* An error occurred. Increase the frequency at which the check timer + toggles its LED to give visual feedback of the potential error + condition. */ + if( lChangedTimerPeriodAlready == pdFALSE ) + { + lChangedTimerPeriodAlready = pdTRUE; + + /* This call to xTimerChangePeriod() uses a zero block time. + Functions called from inside of a timer callback function must + *never* attempt to block as to do so could impact other software + timers. */ + xTimerChangePeriod( xTimer, ( mainERROR_CHECK_TIMER_PERIOD_MS ), mainDONT_BLOCK ); + } + } + + vParTestToggleLED( mainCHECK_LED ); } /*-----------------------------------------------------------*/ @@ -245,6 +366,16 @@ void vFullDemoIdleHook( void ) } #endif } +/*-----------------------------------------------------------*/ + +void vFullDemoTickHook( void ) +{ + /* Call the periodic queue overwrite from ISR demo. */ + vQueueOverwritePeriodicISRDemo(); + + /* Call the queue set ISR test function. */ + vQueueSetAccessQueueSetFromISR(); +}