From 0e78e8d6e7971399c0063eb2bb7d66ad686f89d0 Mon Sep 17 00:00:00 2001 From: richardbarry Date: Wed, 9 Oct 2013 13:26:34 +0000 Subject: [PATCH] Complete tidy up of SAMD20 demo. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2059 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- .../RTOSDemo.atsln | 3 -- .../RTOSDemo.atsuo | Bin 73728 -> 73216 bytes .../RTOSDemo/src/main-full.c | 38 ++++++++++----- .../RTOSDemo/src/main.c | 44 ++++++++++++++---- 4 files changed, 62 insertions(+), 23 deletions(-) diff --git a/FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo.atsln b/FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo.atsln index fabb32ace..961acf633 100644 --- a/FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo.atsln +++ b/FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo.atsln @@ -6,13 +6,10 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|ARM = Debug|ARM - Release|ARM = Release|ARM EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {2A475B6A-78B0-4237-8947-341BD379AB5C}.Debug|ARM.ActiveCfg = Debug|ARM {2A475B6A-78B0-4237-8947-341BD379AB5C}.Debug|ARM.Build.0 = Debug|ARM - {2A475B6A-78B0-4237-8947-341BD379AB5C}.Release|ARM.ActiveCfg = Release|ARM - {2A475B6A-78B0-4237-8947-341BD379AB5C}.Release|ARM.Build.0 = Release|ARM EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo.atsuo b/FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo.atsuo index deb7a887dfad740137ab7e0b6926d6d968b4794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{6@|QR6P(SnhN=rq z+V=tV#X^k4u7XrkEX$M?SVN)I9I$xCtbFc*EWMoeSm5pczrJ}_;qncuHxxB&-%#Aq z(17AOHr$KP#&m859F1O~HmTg*q{7?qoWG&Vu>awbU!SDrDu-H&EM^l`OeX{ehO)C- zwgeHvw{xwGs*GNL>Q9tNuUi;l! zLd{bRQ2(Z)>ZN$Z51RR-gRTnPX7n)JNItd@LDRI{F{Y@>`il5Lc~gSaME zE2jU!rP55IJISq;Xnit(EIm+9?4ZO3N>}t^wR%e(Y%%%5nZ9M&FXagJj2ecHvK)+c z$zoS=4?pHTZ}jv>aW`zEPE4-ei2N&=!us8pT;9VAmmgEtNElyHhS6Jzp7c<@2(9y)Tc?$S*+Z7{J}N z?})5_nK(|Jm?yrtcum6Kon+6?VZ0Z%+b?@!!ub@|?@&a}SD$itpO3*eGw+Lwv>3Rk$efVH${2oac&v5#q*o|f3Kdw ABme*a diff --git a/FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo/src/main-full.c b/FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo/src/main-full.c index 618bd8a83..cebfae121 100644 --- a/FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo/src/main-full.c +++ b/FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo/src/main-full.c @@ -83,6 +83,18 @@ * In addition to the standard demo tasks, the following tasks and timer are * defined and/or created within this file: * + * "Command console task" - This uses the Atmel USART driver to provide the + * input and output to FreeRTOS+CLI - the FreeRTOS Command Line Interface. To + * use the CLI: + * - Power the SAMD20 XPlained board through the USB debugger connector. This + * will create a virtual COM port through the USB. + * - Build and run the demo application. + * - Start a dumb terminal program such as TerraTerm or Hyper Terminal. + * - In the dumb terminal select the UART port associated with the XPlained + * debugger connection, using 19200 baud. + * - Type 'help' in the terminal window to see a lit of command registered by + * the demo. + * * "Reg test" tasks - These fill the registers with known values, then check * that each register maintains its expected value for the lifetime of the * task. Each task uses a different set of values. The reg test tasks execute @@ -144,7 +156,7 @@ extern void vRegTest1Task( void *pvParameters ); extern void vRegTest2Task( void *pvParameters ); /* - * Function that starts the command console. + * Function that starts the command console task. */ extern void vUARTCommandConsoleStart( uint16_t usStackSize, unsigned portBASE_TYPE uxPriority ); @@ -222,6 +234,7 @@ const size_t xRegTestStackSize = 25U; actually start running until the scheduler starts. A block time of zero is used in this call, although any value could be used as the block time will be ignored because the scheduler has not started yet. */ + configASSERT( xTimer ); if( xTimer != NULL ) { xTimerStart( xTimer, mainDONT_BLOCK ); @@ -250,58 +263,59 @@ unsigned long ulErrorFound = pdFALSE; running, and that none have detected an error. */ if( xAreDynamicPriorityTasksStillRunning() != pdPASS ) { - ulErrorFound |= ( 0x01UL << 0UL ); + ulErrorFound = pdTRUE; } if( xAreBlockTimeTestTasksStillRunning() != pdPASS ) { - ulErrorFound |= ( 0x01UL << 1UL ); + ulErrorFound = pdTRUE; } if( xAreCountingSemaphoreTasksStillRunning() != pdPASS ) { - ulErrorFound |= ( 0x01UL << 2UL ); + ulErrorFound = pdTRUE; } if( xAreRecursiveMutexTasksStillRunning() != pdPASS ) { - ulErrorFound |= ( 0x01UL << 3UL ); + ulErrorFound = pdTRUE; } /* Check that the register test 1 task is still running. */ if( ulLastRegTest1Value == ulRegTest1LoopCounter ) { - ulErrorFound |= ( 0x01UL << 4UL ); + ulErrorFound = pdTRUE; } ulLastRegTest1Value = ulRegTest1LoopCounter; /* Check that the register test 2 task is still running. */ if( ulLastRegTest2Value == ulRegTest2LoopCounter ) { - ulErrorFound |= ( 0x01UL << 5UL ); + ulErrorFound = pdTRUE; } ulLastRegTest2Value = ulRegTest2LoopCounter; + if( xAreQueueSetTasksStillRunning() != pdPASS ) { - ulErrorFound |= ( 0x01UL << 6UL ); + ulErrorFound = pdTRUE; } if( xIsQueueOverwriteTaskStillRunning() != pdPASS ) { - ulErrorFound |= ( 0x01UL << 7UL ); + ulErrorFound = pdTRUE; } if( xAreGenericQueueTasksStillRunning() != pdPASS ) { - ulErrorFound |= ( 0x01UL << 8UL ); + ulErrorFound = pdTRUE; } if( xAreQueuePeekTasksStillRunning() != pdPASS ) { - ulErrorFound |= ( 0x01UL << 9UL ); + ulErrorFound = pdTRUE; } - + /* Toggle the check LED to give an indication of the system status. If the LED toggles every mainCHECK_TIMER_PERIOD_MS milliseconds then everything is ok. A faster toggle indicates an error. */ 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..2e26593b9 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 @@ -98,8 +98,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 ); @@ -202,12 +201,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 +217,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 +232,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 +275,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 */ -- 2.39.2