]> git.sur5r.net Git - freertos/commitdiff
Test the RTC and BURTC tickless implementations on the Gecko parts, and make correct...
authorrtel <rtel@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Wed, 3 Feb 2016 11:58:30 +0000 (11:58 +0000)
committerrtel <rtel@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Wed, 3 Feb 2016 11:58:30 +0000 (11:58 +0000)
Replace some references to the older portTICK_RATE_MS macro with the newer pdMS_TO_TICKS() macro in the standard demo files.

git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2413 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

FreeRTOS/Demo/CORTEX_EFM32_Gecko_Starter_Kit_Simplicity_Studio/.cproject
FreeRTOS/Demo/CORTEX_EFM32_Gecko_Starter_Kit_Simplicity_Studio/Source/FreeRTOSConfig.h
FreeRTOS/Demo/CORTEX_EFM32_Gecko_Starter_Kit_Simplicity_Studio/Source/Low_Power_Demo/low_power_tick_management_BURTC.c
FreeRTOS/Demo/CORTEX_EFM32_Gecko_Starter_Kit_Simplicity_Studio/Source/Low_Power_Demo/low_power_tick_management_RTC.c
FreeRTOS/Demo/CORTEX_EFM32_Gecko_Starter_Kit_Simplicity_Studio/Source/Low_Power_Demo/main_low_power.c
FreeRTOS/Demo/CORTEX_EFM32_Gecko_Starter_Kit_Simplicity_Studio/Source/main.c
FreeRTOS/Demo/Common/Minimal/BlockQ.c
FreeRTOS/Demo/Common/Minimal/EventGroupsDemo.c
FreeRTOS/Demo/Common/Minimal/PollQ.c
FreeRTOS/Demo/Common/Minimal/QueueSet.c
FreeRTOS/Demo/Common/Minimal/death.c

index 7529f49236caa4b7d492c9402649246779595020..edf15e0bd7f660e287bb3eeef2665d4e22badc30 100644 (file)
                                                        <tool id="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.archiver.base.1920617400" name="GNU ARM Archiver" superClass="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.archiver.base"/>\r
                                                </toolChain>\r
                                        </folderInfo>\r
-                                       <fileInfo id="com.silabs.ide.si32.gcc.debug#com.silabs.ide.si32.gcc:4.8.3.20131129.566130702" name="low_power_tick_management_BURTC.c" rcbsApplicability="disable" resourcePath="Source/Low_Power_Demo/low_power_tick_management_BURTC.c" toolsToInvoke="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.c.compiler.base.1299820402.669016646">\r
-                                               <tool id="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.c.compiler.base.1299820402.669016646" name="GNU ARM C Compiler" superClass="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.c.compiler.base.1299820402"/>\r
-                                       </fileInfo>\r
                                        <sourceEntries>\r
                                                <entry excluding="Source/FreeRTOS_Source/portable/GCC/ARM_CM4F|Source/SilLabs_Code/kits/EFM32WG_STK3800|Source/SilLabs_Code/Device/SiliconLabs/EFM32GG/Source|Source/SilLabs_Code/Device/SiliconLabs/EFM32WG|Source/SilLabs_Code/CMSIS/efm32wg|CMSIS/efm32wg|Source/SilLabs_Code/kits/bsp/bsp_dk_3201.c|Source/SilLabs_Code/kits/bsp/bsp_dk_3200.c|Source/SilLabs_Code/kits/bsp/bsp_dk_leds.c|Source/RTT|Source/SilLabs_Code/kits/bsp/bsp_dk_mcuboard.c|Source/SilLabs_Code/kits/bsp/bsp_bcc.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>\r
                                        </sourceEntries>\r
index e0f66cd52dd03180cc59905efa2a69ff776088ce..9cf5c44b9d0d306a0c10474d521ca21a789e8d2d 100644 (file)
@@ -99,7 +99,7 @@ extern "C" {
  *  See the comments at the top of main.c, main_full.c and main_low_power.c for\r
  *  more information.\r
  */\r
-#define configCREATE_LOW_POWER_DEMO    2\r
+#define configCREATE_LOW_POWER_DEMO    1\r
 \r
 /* Some configuration is dependent on the demo being built. */\r
 #if( configCREATE_LOW_POWER_DEMO == 0 )\r
@@ -142,7 +142,7 @@ extern "C" {
        #define configUSE_MALLOC_FAILED_HOOK    ( 0 )\r
        #define configUSE_IDLE_HOOK                             ( 0 )\r
 \r
-       #define configENERGY_MODE                               ( sleepEM4 )\r
+       #define configENERGY_MODE                               ( sleepEM3 )\r
 \r
 #elif( configCREATE_LOW_POWER_DEMO == 2 )\r
 \r
@@ -198,9 +198,31 @@ extern "C" {
 #define configTIMER_QUEUE_LENGTH                               ( 10 )\r
 #define configTIMER_TASK_STACK_DEPTH                   ( configMINIMAL_STACK_SIZE )\r
 \r
-/* Interrupt nesting behaviour configuration. */\r
-#define configKERNEL_INTERRUPT_PRIORITY                        ( 255 )\r
-#define configMAX_SYSCALL_INTERRUPT_PRIORITY   ( 191 ) /* equivalent to 0xa0, or priority 5. */\r
+/* Cortex-M specific definitions. */\r
+#ifdef __NVIC_PRIO_BITS\r
+       /* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */\r
+       #define configPRIO_BITS                __NVIC_PRIO_BITS\r
+#else\r
+       #define configPRIO_BITS                3        /* 7 priority levels */\r
+#endif\r
+\r
+/* The lowest interrupt priority that can be used in a call to a "set priority"\r
+function. */\r
+#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY                        0x07\r
+\r
+/* The highest interrupt priority that can be used by any interrupt service\r
+routine that makes calls to interrupt safe FreeRTOS API functions.  DO NOT CALL\r
+INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER\r
+PRIORITY THAN THIS! (higher priorities are lower numeric values. */\r
+#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY   0x05\r
+\r
+/* Interrupt priorities used by the kernel port layer itself.  These are generic\r
+to all Cortex-M ports, and do not rely on any particular library functions. */\r
+#define configKERNEL_INTERRUPT_PRIORITY                 ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )\r
+/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!\r
+See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */\r
+#define configMAX_SYSCALL_INTERRUPT_PRIORITY    ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )\r
+\r
 \r
 /* Optional functions - most linkers will remove unused functions anyway. */\r
 #define INCLUDE_vTaskPrioritySet                               ( 1 )\r
index 6f3e3808547cbfce886682fab2df29e94b275c3b..6f3e51c2d03c7fb4549390f116a0a22e6b4caf55 100644 (file)
@@ -150,7 +150,7 @@ BURTC_Init_TypeDef xBURTCInitStruct = BURTC_INIT_DEFAULT;
        BURTC_Init( &xBURTCInitStruct );\r
 \r
        /* The tick interrupt must be set to the lowest priority possible. */\r
-       NVIC_SetPriority( BURTC_IRQn, configKERNEL_INTERRUPT_PRIORITY );\r
+       NVIC_SetPriority( BURTC_IRQn, configLIBRARY_LOWEST_INTERRUPT_PRIORITY );\r
        NVIC_ClearPendingIRQ( BURTC_IRQn );\r
        NVIC_EnableIRQ( BURTC_IRQn );\r
        BURTC_CompareSet( 0, ulReloadValueForOneTick );\r
@@ -162,7 +162,7 @@ BURTC_Init_TypeDef xBURTCInitStruct = BURTC_INIT_DEFAULT;
 \r
 void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime )\r
 {\r
-uint32_t ulReloadValue, ulCompleteTickPeriods, ulCurrentCount;\r
+uint32_t ulReloadValue, ulCompleteTickPeriods, ulCountBeforeSleep, ulCountAfterSleep;\r
 eSleepModeStatus eSleepAction;\r
 TickType_t xModifiableIdleTime;\r
 \r
@@ -189,12 +189,20 @@ TickType_t xModifiableIdleTime;
        result in some tiny drift of the time maintained by the kernel with respect\r
        to calendar time.  The count is latched before stopping the timer as\r
        stopping the timer appears to clear the count. */\r
-       ulCurrentCount = BURTC_CounterGet();\r
+       ulCountBeforeSleep = BURTC_CounterGet();\r
        BURTC_Enable( false );\r
 \r
+       /* If this function is re-entered before one complete tick period then the\r
+       reload value might be to take into account a partial tick, but just reading\r
+       the count assumes it is counting up to a full ticks worth - so add in the\r
+       different if any. */\r
+       ulCountBeforeSleep += ( ulReloadValueForOneTick - BURTC_CompareGet( 0 ) );\r
+\r
        /* Enter a critical section but don't use the taskENTER_CRITICAL() method as\r
        that will mask interrupts that should exit sleep mode. */\r
        INT_Disable();\r
+       __asm volatile( "dsb" );\r
+       __asm volatile( "isb" );\r
 \r
        /* The tick flag is set to false before sleeping.  If it is true when sleep\r
        mode is exited then sleep mode was probably exited because the tick was\r
@@ -209,7 +217,7 @@ TickType_t xModifiableIdleTime;
        {\r
                /* Restart tick and count up to whatever was left of the current time\r
                slice. */\r
-               BURTC_CompareSet( 0, ulReloadValueForOneTick - ulCurrentCount );\r
+               BURTC_CompareSet( 0, ( ulReloadValueForOneTick - ulCountBeforeSleep ) + ulStoppedTimerCompensation );\r
                BURTC_Enable( true );\r
 \r
                /* Re-enable interrupts - see comments above the cpsid instruction()\r
@@ -220,7 +228,7 @@ TickType_t xModifiableIdleTime;
        {\r
                /* Adjust the reload value to take into account that the current time\r
                slice is already partially complete. */\r
-               ulReloadValue -= ulCurrentCount;\r
+               ulReloadValue -= ulCountBeforeSleep;\r
                BURTC_CompareSet( 0, ulReloadValue );\r
 \r
                /* Restart the BURTC. */\r
@@ -248,12 +256,14 @@ TickType_t xModifiableIdleTime;
                result in some tiny drift of the time maintained by the kernel with\r
                respect to calendar time.  The count value is latched before stopping\r
                the timer as stopping the timer appears to clear the count. */\r
-               ulCurrentCount = BURTC_CounterGet();\r
+               ulCountAfterSleep = BURTC_CounterGet();\r
                BURTC_Enable( false );\r
 \r
                /* Re-enable interrupts - see comments above the cpsid instruction()\r
                above. */\r
                INT_Enable();\r
+               __asm volatile( "dsb" );\r
+               __asm volatile( "isb" );\r
 \r
                if( ulTickFlag != pdFALSE )\r
                {\r
@@ -261,7 +271,7 @@ TickType_t xModifiableIdleTime;
                        function is called with the scheduler suspended the actual tick\r
                        processing will not occur until after this function has exited.\r
                        Reset the reload value with whatever remains of this tick period. */\r
-                       ulReloadValue = ulReloadValueForOneTick - ulCurrentCount;\r
+                       ulReloadValue = ulReloadValueForOneTick - ulCountAfterSleep;\r
                        BURTC_CompareSet( 0, ulReloadValue );\r
 \r
                        /* The tick interrupt handler will already have pended the tick\r
@@ -275,12 +285,17 @@ TickType_t xModifiableIdleTime;
                {\r
                        /* Something other than the tick interrupt ended the sleep.  How\r
                        many complete tick periods passed while the processor was\r
-                       sleeping? */\r
-                       ulCompleteTickPeriods = ulCurrentCount / ulReloadValueForOneTick;\r
+                       sleeping?  Add back in the adjustment that was made to the reload\r
+                       value to account for the fact that a time slice was part way through\r
+                       when this function was called. */\r
+                       ulCountAfterSleep += ulCountBeforeSleep;\r
+                       ulCompleteTickPeriods = ulCountAfterSleep / ulReloadValueForOneTick;\r
 \r
                        /* The reload value is set to whatever fraction of a single tick\r
                        period remains. */\r
-                       ulReloadValue = ulCurrentCount - ( ulCompleteTickPeriods * ulReloadValueForOneTick );\r
+                       ulCountAfterSleep -= ( ulCompleteTickPeriods * ulReloadValueForOneTick );\r
+                       ulReloadValue = ulReloadValueForOneTick - ulCountAfterSleep;\r
+\r
                        if( ulReloadValue == 0 )\r
                        {\r
                                /* There is no fraction remaining. */\r
@@ -305,12 +320,13 @@ TickType_t xModifiableIdleTime;
 \r
 void BURTC_IRQHandler( void )\r
 {\r
-       if( ulTickFlag == pdFALSE )\r
+       ulTickFlag = pdTRUE;\r
+\r
+       if( RTC_CompareGet( 0 ) != ulReloadValueForOneTick )\r
        {\r
-               /* Set BURTC interrupt to one RTOS tick period. */\r
+               /* Set RTC interrupt to one RTOS tick period. */\r
                BURTC_Enable( false );\r
                BURTC_CompareSet( 0, ulReloadValueForOneTick );\r
-               ulTickFlag = pdTRUE;\r
                BURTC_Enable( true );\r
        }\r
 \r
index d736f26705d13badf0fa08f91ee5e21db25ad50d..cadbffb58e546295d8e8e373c9804f764e875769 100644 (file)
 /* SiLabs library includes. */\r
 #include "em_cmu.h"\r
 #include "em_rtc.h"\r
+#include "em_burtc.h"\r
 #include "em_rmu.h"\r
 #include "em_int.h"\r
 #include "sleep.h"\r
 \r
+#define lpINCLUDE_TEST_TIMER   1\r
+\r
 /* SEE THE COMMENTS ABOVE THE DEFINITION OF configCREATE_LOW_POWER_DEMO IN\r
 FreeRTOSConfig.h\r
 This file contains functions that will override the default implementations\r
@@ -103,6 +106,14 @@ void vPortSetupTimerInterrupt( void );
  */\r
 void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime );\r
 \r
+/* If lpINCLUDE_TEST_TIMER is defined then the BURTC is used to generate\r
+interrupts that will wake the processor prior to the expected idle time\r
+completing.  The timer interval can be altered to test different\r
+scenarios. */\r
+#if( lpINCLUDE_TEST_TIMER == 1 )\r
+       static void prvSetupTestTimer( void );\r
+#endif\r
+\r
 /*-----------------------------------------------------------*/\r
 \r
 /* Calculate how many clock increments make up a single tick period. */\r
@@ -155,19 +166,27 @@ const uint32_t ulMAX24BitValue = 0xffffffUL;
        RTC_IntDisable( RTC_IFC_COMP0 );\r
 \r
        /* The tick interrupt must be set to the lowest priority possible. */\r
-       NVIC_SetPriority( RTC_IRQn, configKERNEL_INTERRUPT_PRIORITY );\r
+       NVIC_SetPriority( RTC_IRQn, configLIBRARY_LOWEST_INTERRUPT_PRIORITY );\r
        NVIC_ClearPendingIRQ( RTC_IRQn );\r
        NVIC_EnableIRQ( RTC_IRQn );\r
        RTC_CompareSet( 0, ulReloadValueForOneTick );\r
        RTC_IntClear( RTC_IFC_COMP0 );\r
        RTC_IntEnable( RTC_IF_COMP0 );\r
        RTC_Enable( true );\r
+\r
+       /* If lpINCLUDE_TEST_TIMER is defined then the BURTC is used to generate\r
+       interrupts that will wake the processor prior to the expected idle time\r
+       completing.  The timer interval can be altered to test different\r
+       scenarios. */\r
+       #if( lpINCLUDE_TEST_TIMER == 1 )\r
+               prvSetupTestTimer();\r
+       #endif\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
 void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime )\r
 {\r
-uint32_t ulReloadValue, ulCompleteTickPeriods, ulCurrentCount;\r
+uint32_t ulReloadValue, ulCompleteTickPeriods, ulCountBeforeSleep, ulCountAfterSleep;\r
 eSleepModeStatus eSleepAction;\r
 TickType_t xModifiableIdleTime;\r
 \r
@@ -194,9 +213,15 @@ TickType_t xModifiableIdleTime;
        in some tiny drift of the time maintained by the kernel with respect to\r
        calendar time.  The count is latched before stopping the timer as stopping\r
        the timer appears to clear the count. */\r
-       ulCurrentCount = RTC_CounterGet();\r
+       ulCountBeforeSleep = RTC_CounterGet();\r
        RTC_Enable( false );\r
 \r
+       /* If this function is re-entered before one complete tick period then the\r
+       reload value might be to take into account a partial tick, but just reading\r
+       the count assumes it is counting up to a full ticks worth - so add in the\r
+       different if any. */\r
+       ulCountBeforeSleep += ( ulReloadValueForOneTick - RTC_CompareGet( 0 ) );\r
+\r
        /* Enter a critical section but don't use the taskENTER_CRITICAL() method as\r
        that will mask interrupts that should exit sleep mode. */\r
        INT_Disable();\r
@@ -216,7 +241,7 @@ TickType_t xModifiableIdleTime;
        {\r
                /* Restart tick and count up to whatever was left of the current time\r
                slice. */\r
-               RTC_CompareSet( 0, ulReloadValueForOneTick - ulCurrentCount );\r
+               RTC_CompareSet( 0, ( ulReloadValueForOneTick - ulCountBeforeSleep ) + ulStoppedTimerCompensation );\r
                RTC_Enable( true );\r
 \r
                /* Re-enable interrupts - see comments above the cpsid instruction()\r
@@ -227,7 +252,7 @@ TickType_t xModifiableIdleTime;
        {\r
                /* Adjust the reload value to take into account that the current time\r
                slice is already partially complete. */\r
-               ulReloadValue -= ulCurrentCount;\r
+               ulReloadValue -= ulCountBeforeSleep;\r
                RTC_CompareSet( 0, ulReloadValue );\r
 \r
                /* Restart the RTC. */\r
@@ -255,7 +280,7 @@ TickType_t xModifiableIdleTime;
                result in some tiny drift of the time maintained by the kernel with\r
                respect to calendar time.  The count value is latched before stopping\r
                the timer as stopping the timer appears to clear the count. */\r
-               ulCurrentCount = RTC_CounterGet();\r
+               ulCountAfterSleep = RTC_CounterGet();\r
                RTC_Enable( false );\r
 \r
                /* Re-enable interrupts - see comments above the cpsid instruction()\r
@@ -270,7 +295,7 @@ TickType_t xModifiableIdleTime;
                        function is called with the scheduler suspended the actual tick\r
                        processing will not occur until after this function has exited.\r
                        Reset the reload value with whatever remains of this tick period. */\r
-                       ulReloadValue = ulReloadValueForOneTick - ulCurrentCount;\r
+                       ulReloadValue = ulReloadValueForOneTick - ulCountAfterSleep;\r
                        RTC_CompareSet( 0, ulReloadValue );\r
 \r
                        /* The tick interrupt handler will already have pended the tick\r
@@ -284,12 +309,17 @@ TickType_t xModifiableIdleTime;
                {\r
                        /* Something other than the tick interrupt ended the sleep.  How\r
                        many complete tick periods passed while the processor was\r
-                       sleeping? */\r
-                       ulCompleteTickPeriods = ulCurrentCount / ulReloadValueForOneTick;\r
+                       sleeping?  Add back in the adjustment that was made to the reload\r
+                       value to account for the fact that a time slice was part way through\r
+                       when this function was called. */\r
+                       ulCountAfterSleep += ulCountBeforeSleep;\r
+                       ulCompleteTickPeriods = ulCountAfterSleep / ulReloadValueForOneTick;\r
 \r
                        /* The reload value is set to whatever fraction of a single tick\r
                        period remains. */\r
-                       ulReloadValue = ulCurrentCount - ( ulCompleteTickPeriods * ulReloadValueForOneTick );\r
+                       ulCountAfterSleep -= ( ulCompleteTickPeriods * ulReloadValueForOneTick );\r
+                       ulReloadValue = ulReloadValueForOneTick - ulCountAfterSleep;\r
+\r
                        if( ulReloadValue == 0 )\r
                        {\r
                                /* There is no fraction remaining. */\r
@@ -314,12 +344,13 @@ TickType_t xModifiableIdleTime;
 \r
 void RTC_IRQHandler( void )\r
 {\r
-       if( ulTickFlag == pdFALSE )\r
+       ulTickFlag = pdTRUE;\r
+\r
+       if( RTC_CompareGet( 0 ) != ulReloadValueForOneTick )\r
        {\r
                /* Set RTC interrupt to one RTOS tick period. */\r
                RTC_Enable( false );\r
                RTC_CompareSet( 0, ulReloadValueForOneTick );\r
-               ulTickFlag = pdTRUE;\r
                RTC_Enable( true );\r
        }\r
 \r
@@ -336,6 +367,64 @@ void RTC_IRQHandler( void )
        }\r
        portCLEAR_INTERRUPT_MASK_FROM_ISR( 0 );\r
 }\r
+/*-----------------------------------------------------------*/\r
+\r
+#if( lpINCLUDE_TEST_TIMER == 1 )\r
+\r
+       /* If lpINCLUDE_TEST_TIMER is defined then the BURTC is used to generate\r
+       interrupts that will wake the processor prior to the expected idle time\r
+       completing.  The timer interval can be altered to test different\r
+       scenarios. */\r
+       static void prvSetupTestTimer( void )\r
+       {\r
+       BURTC_Init_TypeDef xBURTCInitStruct = BURTC_INIT_DEFAULT;\r
+       const uint32_t ulBURTClockHz = 2000UL, ulInterruptFrequency = 1000UL;\r
+       const uint32_t ulReload = ( ulBURTClockHz / ulInterruptFrequency );\r
+\r
+               /* Ensure LE modules are accessible. */\r
+               CMU_ClockEnable( cmuClock_CORELE, true );\r
+\r
+               /* Enable access to BURTC registers. */\r
+               RMU_ResetControl( rmuResetBU, false );\r
+\r
+               /* Generate periodic interrupts from BURTC. */\r
+               xBURTCInitStruct.mode   = burtcModeEM3;         /* Operational in EM3. */\r
+               xBURTCInitStruct.clkSel = burtcClkSelULFRCO;/* ULFRCO clock. */\r
+               xBURTCInitStruct.clkDiv = burtcClkDiv_1;        /* 2kHz ULFRCO clock. */\r
+               xBURTCInitStruct.compare0Top = true;            /* Wrap on COMP0. */\r
+               BURTC_IntDisable( BURTC_IF_COMP0 );\r
+               BURTC_Init( &xBURTCInitStruct );\r
+\r
+               NVIC_SetPriority( BURTC_IRQn, configLIBRARY_LOWEST_INTERRUPT_PRIORITY );\r
+               NVIC_ClearPendingIRQ( BURTC_IRQn );\r
+               NVIC_EnableIRQ( BURTC_IRQn );\r
+               BURTC_CompareSet( 0, ulReload );\r
+               BURTC_IntClear( BURTC_IF_COMP0 );\r
+               BURTC_IntEnable( BURTC_IF_COMP0 );\r
+               BURTC_CounterReset();\r
+       }\r
+\r
+#endif\r
+/*-----------------------------------------------------------*/\r
+\r
+#if( lpINCLUDE_TEST_TIMER == 1 )\r
 \r
-#endif /* ( configCREATE_LOW_POWER_DEMO == 1 ) */\r
+       /* If lpINCLUDE_TEST_TIMER is defined then the BURTC is used to generate\r
+       interrupts that will wake the processor prior to the expected idle time\r
+       completing.  The timer interval can be altered to test different\r
+       scenarios. */\r
+       volatile uint32_t ulTestTimerCounts = 0;\r
+\r
+       void BURTC_IRQHandler( void )\r
+       {\r
+               /* Nothing to do here - just testing the code in the scenario where a\r
+               tickless idle period is ended prior to the expected maximum idle time\r
+               expiring. */\r
+               BURTC_IntClear( _RTC_IFC_MASK );\r
+               ulTestTimerCounts++;\r
+       }\r
+\r
+#endif\r
+/*-----------------------------------------------------------*/\r
 \r
+#endif /* ( configCREATE_LOW_POWER_DEMO == 2 ) */\r
index ce30aa2400c1c37e998f17588ede041ffad68604..dbe03a3dc4ef6886705546d664d25008207bb8ac 100644 (file)
  * main_low_power() creates one queue, and two tasks.  It then starts the\r
  * scheduler.\r
  *\r
- * TBD\r
+ * The Queue Send Task:\r
+ * The queue send task is implemented by the prvQueueSendTask() function in\r
+ * this file.  It sends the value 100 to the queue every second.\r
+ *\r
+ * The Queue Receive Task:\r
+ * The queue receive task is implemented by the prvQueueReceiveTask() function\r
+ * in this file.  prvQueueReceiveTask() blocks on the queue, blipping (quickly\r
+ * turn on then off again) the LED each time it received the value 100 from the\r
+ * queue send task.  The queue send task writes to the queue every second, so\r
+ * the LED will blip once a second.\r
+ *\r
+ * The RTOS tick is turned off when the queue send task and queue receive task\r
+ * are both in the Blocked state.\r
+ *\r
  */\r
 \r
-#warning Description of demo in comments above is not correct.\r
 \r
 /* Kernel includes. */\r
 #include "FreeRTOS.h"\r
index fe76f5464c9413a2272ba6068669d3b300461856..7ff047a2d6979e4abcc11816b87c3424b92b1173 100644 (file)
@@ -87,8 +87,6 @@
  *\r
  */\r
 \r
-#warning Check the tick suppression routine in the case where the system unblocks before an entire tick period has expired.\r
-\r
 /* FreeRTOS includes. */\r
 #include "FreeRTOS.h"\r
 #include "task.h"\r
@@ -114,7 +112,7 @@ static void prvSetupHardware( void );
  * main_low_power() is used when configCREATE_LOW_POWER_DEMO is set to 1.\r
  * main_full() is used when configCREATE_LOW_POWER_DEMO is set to 0.\r
  */\r
-#if( configCREATE_LOW_POWER_DEMO == 1 )\r
+#if( configCREATE_LOW_POWER_DEMO != 0 )\r
        extern void main_low_power( void );\r
 #else\r
        extern void main_full( void );\r
index 670183740a7f709ff6d5e99945c3740f4c0ade8a..171cd67d47996d34b0dbf8d3f281285b77b3e011 100644 (file)
@@ -136,7 +136,7 @@ xBlockingQueueParameters *pxQueueParameters1, *pxQueueParameters2;
 xBlockingQueueParameters *pxQueueParameters3, *pxQueueParameters4;\r
 xBlockingQueueParameters *pxQueueParameters5, *pxQueueParameters6;\r
 const UBaseType_t uxQueueSize1 = 1, uxQueueSize5 = 5;\r
-const TickType_t xBlockTime = ( TickType_t ) 1000 / portTICK_PERIOD_MS;\r
+const TickType_t xBlockTime = pdMS_TO_TICKS( ( TickType_t ) 1000 );\r
 const TickType_t xDontBlock = ( TickType_t ) 0;\r
 \r
        /* Create the first two tasks as described at the top of the file. */\r
index 93b6f304a20371f336a8a12321f58b2757ef45dc..af75f5039b8ddc3e35285c0553a8abf978cb9d4f 100644 (file)
@@ -122,7 +122,7 @@ that synchronise with the xEventGroupSync() function. */
 #define ebDONT_BLOCK   ( 0 )\r
 \r
 /* A 5ms delay. */\r
-#define ebSHORT_DELAY  ( 5 / portTICK_PERIOD_MS )\r
+#define ebSHORT_DELAY  pdMS_TO_TICKS( ( TickType_t ) 5 )\r
 \r
 /* Used in the selective bits test which checks no, one or both tasks blocked on\r
 event bits in a group are unblocked as appropriate as different bits get set. */\r
index 699b37fd45183fa13c30eb32bdacb6bd32eaaa85..67ed1f3a5d16f51a613b405e2106b597b4c8d7b2 100644 (file)
@@ -109,7 +109,7 @@ Changes from V2.0.0
 \r
 #define pollqSTACK_SIZE                        configMINIMAL_STACK_SIZE\r
 #define pollqQUEUE_SIZE                        ( 10 )\r
-#define pollqPRODUCER_DELAY            ( ( TickType_t ) 200 / portTICK_PERIOD_MS )\r
+#define pollqPRODUCER_DELAY            ( pdMS_TO_TICKS( ( TickType_t ) 200 ) )\r
 #define pollqCONSUMER_DELAY            ( pollqPRODUCER_DELAY - ( TickType_t ) ( 20 / portTICK_PERIOD_MS ) )\r
 #define pollqNO_DELAY                  ( ( TickType_t ) 0 )\r
 #define pollqVALUES_TO_PRODUCE ( ( BaseType_t ) 3 )\r
@@ -135,10 +135,10 @@ static QueueHandle_t xPolledQueue;
        xPolledQueue = xQueueCreate( pollqQUEUE_SIZE, ( UBaseType_t ) sizeof( uint16_t ) );\r
 \r
        /* vQueueAddToRegistry() adds the queue to the queue registry, if one is\r
-       in use.  The queue registry is provided as a means for kernel aware \r
+       in use.  The queue registry is provided as a means for kernel aware\r
        debuggers to locate queues and has no purpose if a kernel aware debugger\r
        is not being used.  The call to vQueueAddToRegistry() will be removed\r
-       by the pre-processor if configQUEUE_REGISTRY_SIZE is not defined or is \r
+       by the pre-processor if configQUEUE_REGISTRY_SIZE is not defined or is\r
        defined to be less than 1. */\r
        vQueueAddToRegistry( xPolledQueue, "Poll_Test_Queue" );\r
 \r
@@ -154,7 +154,7 @@ uint16_t usValue = ( uint16_t ) 0;
 BaseType_t xError = pdFALSE, xLoop;\r
 \r
        for( ;; )\r
-       {               \r
+       {\r
                for( xLoop = 0; xLoop < pollqVALUES_TO_PRODUCE; xLoop++ )\r
                {\r
                        /* Send an incrementing number on the queue without blocking. */\r
@@ -193,7 +193,7 @@ uint16_t usData, usExpectedValue = ( uint16_t ) 0;
 BaseType_t xError = pdFALSE;\r
 \r
        for( ;; )\r
-       {               \r
+       {\r
                /* Loop until the queue is empty. */\r
                while( uxQueueMessagesWaiting( *( ( QueueHandle_t * ) pvParameters ) ) )\r
                {\r
index 1f74bdcc4769d105e7cb194017971252e5e4cdc7..14534087189a2ac6876278bc7c1047bd493efb13 100644 (file)
@@ -122,7 +122,7 @@ queuesetPRIORITY_CHANGE_LOOPS number of values are sent to a queue. */
 /* A delay inserted when the Tx task changes its priority to be above the idle\r
 task priority to ensure the idle priority tasks get some CPU time before the\r
 next iteration of the queue set Tx task. */\r
-#define queuesetTX_LOOP_DELAY  ( 200 / portTICK_PERIOD_MS )\r
+#define queuesetTX_LOOP_DELAY  pdMS_TO_TICKS( ( TickType_t ) 200 )\r
 \r
 /* The allowable maximum deviation between a received value and the expected\r
 received value.  A deviation will occur when data is received from a queue\r
@@ -420,7 +420,7 @@ TickType_t xBlockTime;
                }\r
 \r
                /* Wait for a message to arrive on one of the queues in the set. */\r
-               xActivatedQueue = xQueueSelectFromSet( xQueueSet, portMAX_DELAY );              \r
+               xActivatedQueue = xQueueSelectFromSet( xQueueSet, portMAX_DELAY );\r
 \r
                if( xActivatedQueue == NULL )\r
                {\r
index 9a258bf38380cf52e787e875505e391ae02ff7ee..3ff1cdf4495efe51544cdd318d6e360f3a53536a 100644 (file)
@@ -115,7 +115,7 @@ task can tell if any of the suicidal tasks have failed to die.
 static volatile UBaseType_t uxTasksRunningAtStart = 0;\r
 \r
 /* When a task deletes itself, it stack and TCB are cleaned up by the Idle task.\r
-Under heavy load the idle task might not get much processing time, so it would \r
+Under heavy load the idle task might not get much processing time, so it would\r
 be legitimate for several tasks to remain undeleted for a short period.  There\r
 may also be a few other unexpected tasks if, for example, the tasks that test\r
 static allocation are also being used. */\r
@@ -141,15 +141,15 @@ UBaseType_t *puxPriority;
        /* Record the number of tasks that are running now so we know if any of the\r
        suicidal tasks have failed to be killed. */\r
        uxTasksRunningAtStart = ( UBaseType_t ) uxTaskGetNumberOfTasks();\r
-       \r
+\r
        /* FreeRTOS.org versions before V3.0 started the idle-task as the very\r
        first task. The idle task was then already included in uxTasksRunningAtStart.\r
        From FreeRTOS V3.0 on, the idle task is started when the scheduler is\r
        started. Therefore the idle task is not yet accounted for. We correct\r
        this by increasing uxTasksRunningAtStart by 1. */\r
        uxTasksRunningAtStart++;\r
-       \r
-       /* From FreeRTOS version 7.0.0 can optionally create a timer service task.  \r
+\r
+       /* From FreeRTOS version 7.0.0 can optionally create a timer service task.\r
        If this is done, then uxTasksRunningAtStart needs incrementing again as that\r
        too is created when the scheduler is started. */\r
        #if configUSE_TIMERS == 1\r
@@ -159,12 +159,12 @@ UBaseType_t *puxPriority;
        #endif\r
 }\r
 /*-----------------------------------------------------------*/\r
-                                       \r
+\r
 static portTASK_FUNCTION( vSuicidalTask, pvParameters )\r
 {\r
 volatile long l1, l2;\r
 TaskHandle_t xTaskToKill;\r
-const TickType_t xDelay = ( TickType_t ) 200 / portTICK_PERIOD_MS;\r
+const TickType_t xDelay = pdMS_TO_TICKS( ( TickType_t ) 200 );\r
 \r
        if( pvParameters != NULL )\r
        {\r
@@ -203,7 +203,7 @@ const TickType_t xDelay = ( TickType_t ) 200 / portTICK_PERIOD_MS;
 \r
 static portTASK_FUNCTION( vCreateTasks, pvParameters )\r
 {\r
-const TickType_t xDelay = ( TickType_t ) 1000 / portTICK_PERIOD_MS;\r
+const TickType_t xDelay = pdMS_TO_TICKS( ( TickType_t ) 1000 );\r
 UBaseType_t uxPriority;\r
 \r
        uxPriority = *( UBaseType_t * ) pvParameters;\r
@@ -240,7 +240,7 @@ static UBaseType_t uxTasksRunningNow;
        {\r
                usLastCreationCount = usCreationCount;\r
        }\r
-       \r
+\r
        uxTasksRunningNow = ( UBaseType_t ) uxTaskGetNumberOfTasks();\r
 \r
        if( uxTasksRunningNow < uxTasksRunningAtStart )\r