X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=FreeRTOS%2FDemo%2FCORTEX_M0%2B_Atmel_SAMD20_XPlained%2FRTOSDemo%2Fsrc%2Fmain.c;h=031f0b3b686c6651cf4e78004ef50fd81f296eb0;hb=refs%2Ftags%2FV8.1.2;hp=080586c31086ff5a22e9ff7e7e88a0a18d905fa0;hpb=effd9e575f09c05ffb0817f5cad143dfac8df6c0;p=freertos diff --git a/FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo/src/main.c b/FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo/src/main.c index 080586c31..031f0b3b6 100644 --- a/FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo/src/main.c +++ b/FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo/src/main.c @@ -1,5 +1,6 @@ /* - FreeRTOS V7.5.2 - Copyright (C) 2013 Real Time Engineers Ltd. + FreeRTOS V8.1.2 - Copyright (C) 2014 Real Time Engineers Ltd. + All rights reserved VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. @@ -23,10 +24,10 @@ 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. + >>! 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 @@ -98,8 +99,7 @@ or 0 to run the more comprehensive test and demo application. */ /*-----------------------------------------------------------*/ /* - * Perform any application specific hardware configuration. The clocks, - * memory, etc. are configured before main() is called. + * Perform any application specific hardware configuration. */ static void prvSetupHardware( void ); @@ -109,7 +109,7 @@ static void prvSetupHardware( void ); */ void vApplicationMallocFailedHook( void ); void vApplicationIdleHook( void ); -void vApplicationStackOverflowHook( xTaskHandle pxTask, signed char *pcTaskName ); +void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName ); void vApplicationTickHook( void ); /* @@ -183,7 +183,7 @@ void vApplicationIdleHook( void ) } /*-----------------------------------------------------------*/ -void vApplicationStackOverflowHook( xTaskHandle pxTask, signed char *pcTaskName ) +void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName ) { ( void ) pcTaskName; ( void ) pxTask; @@ -202,12 +202,7 @@ void vApplicationTickHook( void ) configUSE_TICK_HOOK is set to 1 in FreeRTOSConfig.h. User code can be 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 code in this - tick hook implementation is for demonstration only - it has no real - purpose. It just gives a semaphore every 50ms. The semaphore unblocks a - task that then toggles an LED. Additionally, the call to - vQueueSetAccessQueueSetFromISR() is part of the "standard demo tasks" - functionality. */ + functions can be used (those that end in FromISR()). */ /* The semaphore and associated task are not created when the simple blinky demo is used. */ @@ -223,6 +218,8 @@ void vApplicationTickHook( void ) void vMainConfigureTimerForRunTimeStats( void ) { + /* Used by the optional run-time stats gathering functionality. */ + /* How many clocks are there per tenth of a millisecond? */ ulClocksPer10thOfAMilliSecond = configCPU_CLOCK_HZ / 10000UL; } @@ -236,6 +233,9 @@ volatile unsigned long * const pulCurrentSysTickCount = ( ( volatile unsigned lo volatile unsigned long * const pulInterruptCTRLState = ( ( volatile unsigned long *) 0xe000ed04 ); const unsigned long ulSysTickPendingBit = 0x04000000UL; + /* Used by the optional run-time stats gathering functionality. */ + + /* NOTE: There are potentially race conditions here. However, it is used anyway to keep the examples simple, and to avoid reliance on a separate timer peripheral. */ @@ -276,4 +276,33 @@ const unsigned long ulSysTickPendingBit = 0x04000000UL; return ulReturn; } +/*-----------------------------------------------------------*/ + +#ifdef JUST_AN_EXAMPLE_ISR + +void Dummy_IRQHandler(void) +{ +long lHigherPriorityTaskWoken = pdFALSE; + + /* Clear the interrupt if necessary. */ + Dummy_ClearITPendingBit(); + + /* This interrupt does nothing more than demonstrate how to synchronise a + task with an interrupt. A semaphore is used for this purpose. Note + lHigherPriorityTaskWoken is initialised to zero. Only FreeRTOS API functions + that end in "FromISR" can be called from an ISR. */ + xSemaphoreGiveFromISR( xTestSemaphore, &lHigherPriorityTaskWoken ); + + /* If there was a task that was blocked on the semaphore, and giving the + semaphore caused the task to unblock, and the unblocked task has a priority + higher than the current Running state task (the task that this interrupt + interrupted), then lHigherPriorityTaskWoken will have been set to pdTRUE + internally within xSemaphoreGiveFromISR(). Passing pdTRUE into the + portEND_SWITCHING_ISR() macro will result in a context switch being pended to + ensure this interrupt returns directly to the unblocked, higher priority, + task. Passing pdFALSE into portEND_SWITCHING_ISR() has no effect. */ + portEND_SWITCHING_ISR( lHigherPriorityTaskWoken ); +} + +#endif /* JUST_AN_EXAMPLE_ISR */