]> git.sur5r.net Git - freertos/commitdiff
Baseline the Giant Gecko demo, which now has the first pass at a low power tickless...
authorrtel <rtel@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Mon, 25 Jan 2016 21:17:47 +0000 (21:17 +0000)
committerrtel <rtel@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Mon, 25 Jan 2016 21:17:47 +0000 (21:17 +0000)
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2409 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

FreeRTOS/Demo/CORTEX_EFM32_Gecko_Starter_Kit_Simplicity_Studio/.cproject
FreeRTOS/Demo/CORTEX_EFM32_Gecko_Starter_Kit_Simplicity_Studio/.project
FreeRTOS/Demo/CORTEX_EFM32_Gecko_Starter_Kit_Simplicity_Studio/Source/FreeRTOSConfig.h
FreeRTOS/Demo/CORTEX_EFM32_Gecko_Starter_Kit_Simplicity_Studio/Source/Full_Demo/main_full.c
FreeRTOS/Demo/CORTEX_EFM32_Gecko_Starter_Kit_Simplicity_Studio/Source/Low_Power_Demo/low_power_tick_management.c [new file with mode: 0644]
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

index e26d77f420058249c1f4c5a2143f15ebe738a2cf..56ac0b4fa6a75a24d2cef06b7646ef4ef2448c71 100644 (file)
@@ -83,7 +83,7 @@
                                                </toolChain>\r
                                        </folderInfo>\r
                                        <sourceEntries>\r
-                                               <entry excluding="Source/low_power_tick_management.c|Source/RTT|Source/SilLabs_Code/kits/bsp/bsp_dk_mcuboard.c|Source/SilLabs_Code/kits/bsp/bsp_dk_leds.c|Source/SilLabs_Code/kits/bsp/bsp_dk_3201.c|Source/SilLabs_Code/kits/bsp/bsp_dk_3200.c|Source/SilLabs_Code/kits/bsp/bsp_bcc.c|Source/SilLabs_Code/Device/SiliconLabs/EFM32GG/Source|CMSIS/efm32gg/startup_iar_efm32gg.s|FreeRTOS/efm32gg/port_iar.c|FreeRTOS/efm32gg/portasm.s" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>\r
+                                               <entry excluding="Source/RTT|Source/SilLabs_Code/kits/bsp/bsp_dk_mcuboard.c|Source/SilLabs_Code/kits/bsp/bsp_dk_leds.c|Source/SilLabs_Code/kits/bsp/bsp_dk_3201.c|Source/SilLabs_Code/kits/bsp/bsp_dk_3200.c|Source/SilLabs_Code/kits/bsp/bsp_bcc.c|Source/SilLabs_Code/Device/SiliconLabs/EFM32GG/Source|CMSIS/efm32gg/startup_iar_efm32gg.s|FreeRTOS/efm32gg/port_iar.c|FreeRTOS/efm32gg/portasm.s" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>\r
                                        </sourceEntries>\r
                                </configuration>\r
                        </storageModule>\r
index fc794563b5a1a3051de8b4beaf5acc76de691d9b..a1f81b665891989c0846f890411e626371ce44cf 100644 (file)
@@ -70,7 +70,7 @@
                        </matcher>\r
                </filter>\r
                <filter>\r
-                       <id>1453031901581</id>\r
+                       <id>1453621082417</id>\r
                        <name>Source/Full_Demo/Standard_Demo_Tasks</name>\r
                        <type>5</type>\r
                        <matcher>\r
@@ -79,7 +79,7 @@
                        </matcher>\r
                </filter>\r
                <filter>\r
-                       <id>1453031901586</id>\r
+                       <id>1453621082420</id>\r
                        <name>Source/Full_Demo/Standard_Demo_Tasks</name>\r
                        <type>5</type>\r
                        <matcher>\r
@@ -88,7 +88,7 @@
                        </matcher>\r
                </filter>\r
                <filter>\r
-                       <id>1453031901590</id>\r
+                       <id>1453621082425</id>\r
                        <name>Source/Full_Demo/Standard_Demo_Tasks</name>\r
                        <type>5</type>\r
                        <matcher>\r
@@ -97,7 +97,7 @@
                        </matcher>\r
                </filter>\r
                <filter>\r
-                       <id>1453031901594</id>\r
+                       <id>1453621082429</id>\r
                        <name>Source/Full_Demo/Standard_Demo_Tasks</name>\r
                        <type>5</type>\r
                        <matcher>\r
                        </matcher>\r
                </filter>\r
                <filter>\r
-                       <id>1453031901598</id>\r
+                       <id>1453621082433</id>\r
                        <name>Source/Full_Demo/Standard_Demo_Tasks</name>\r
                        <type>5</type>\r
                        <matcher>\r
                        </matcher>\r
                </filter>\r
                <filter>\r
-                       <id>1453031901602</id>\r
+                       <id>1453621082437</id>\r
                        <name>Source/Full_Demo/Standard_Demo_Tasks</name>\r
                        <type>5</type>\r
                        <matcher>\r
                        </matcher>\r
                </filter>\r
                <filter>\r
-                       <id>1453031901606</id>\r
+                       <id>1453621082441</id>\r
                        <name>Source/Full_Demo/Standard_Demo_Tasks</name>\r
                        <type>5</type>\r
                        <matcher>\r
                        </matcher>\r
                </filter>\r
                <filter>\r
-                       <id>1453031901610</id>\r
+                       <id>1453621082445</id>\r
                        <name>Source/Full_Demo/Standard_Demo_Tasks</name>\r
                        <type>5</type>\r
                        <matcher>\r
                        </matcher>\r
                </filter>\r
                <filter>\r
-                       <id>1453031901614</id>\r
+                       <id>1453621082449</id>\r
                        <name>Source/Full_Demo/Standard_Demo_Tasks</name>\r
                        <type>5</type>\r
                        <matcher>\r
                        </matcher>\r
                </filter>\r
                <filter>\r
-                       <id>1453031901618</id>\r
+                       <id>1453621082455</id>\r
                        <name>Source/Full_Demo/Standard_Demo_Tasks</name>\r
                        <type>5</type>\r
                        <matcher>\r
                        </matcher>\r
                </filter>\r
                <filter>\r
-                       <id>1453031901623</id>\r
+                       <id>1453621082460</id>\r
                        <name>Source/Full_Demo/Standard_Demo_Tasks</name>\r
                        <type>5</type>\r
                        <matcher>\r
                                <arguments>1.0-name-matches-false-false-IntSemTest.c</arguments>\r
                        </matcher>\r
                </filter>\r
+               <filter>\r
+                       <id>1453621082465</id>\r
+                       <name>Source/Full_Demo/Standard_Demo_Tasks</name>\r
+                       <type>5</type>\r
+                       <matcher>\r
+                               <id>org.eclipse.ui.ide.multiFilter</id>\r
+                               <arguments>1.0-name-matches-false-false-StaticAllocation.c</arguments>\r
+                       </matcher>\r
+               </filter>\r
                <filter>\r
                        <id>0</id>\r
                        <name>Source/FreeRTOS_Source/portable/GCC</name>\r
index e1591a0f5964e3a87a44fb5b3b5f5a2a41df06d2..f97b23a724e934c981bdac3a13e7bfa975413554 100644 (file)
@@ -86,73 +86,103 @@ extern "C" {
  * See http://www.freertos.org/a00110.html.\r
  *----------------------------------------------------------*/\r
 \r
-/* Available options when configUSE_TICKLESS_IDLE set to 1\r
- * or configUSE_SLEEP_MODE_IN_IDLE set to 1 :\r
- * 1 - EM1, 2 - EM2, 3 - EM3, timer in EM3 is not very accurate*/\r
-#define configSLEEP_MODE                                               ( 2 )\r
+\r
+/* Set configCREATE_LOW_POWER_DEMO to one to run the simple blinky demo low power\r
+example, or 1 to run the more comprehensive test and demo application.  See\r
+the comments at the top of main.c for more information. */\r
+#define configCREATE_LOW_POWER_DEMO    1\r
+\r
+/* Some configuration is dependent on the demo being built. */\r
+#if( configCREATE_LOW_POWER_DEMO == 1 )\r
+\r
+       /* The slow clock used to generate the tick interrupt in the low power demo\r
+       runs at 32768Hz.  Ensure the clock is a multiple of the tick rate. */\r
+       #define configTICK_RATE_HZ                              ( 100 )\r
+\r
+       /* The low power demo uses the tickless idle feature. */\r
+       #define configUSE_TICKLESS_IDLE                 1\r
+\r
+       /* Hook function related definitions. */\r
+       #define configUSE_TICK_HOOK                             ( 0 )\r
+       #define configCHECK_FOR_STACK_OVERFLOW  ( 0 )\r
+       #define configUSE_MALLOC_FAILED_HOOK    ( 0 )\r
+       #define configUSE_IDLE_HOOK                             ( 0 )\r
+\r
+#else\r
+\r
+       /* Some of the standard demo test tasks assume a tick rate of 1KHz, even\r
+       though that is faster than would normally be warranted by a real\r
+       application. */\r
+       #define configTICK_RATE_HZ                              ( 1000 )\r
+\r
+       /* The full demo always has tasks to run so the tick will never be turned\r
+       off.  The blinky demo will use the default tickless idle implementation to\r
+       turn the tick off. */\r
+       #define configUSE_TICKLESS_IDLE                 0\r
+\r
+       /* Hook function related definitions. */\r
+       #define configUSE_TICK_HOOK                             ( 1 )\r
+       #define configCHECK_FOR_STACK_OVERFLOW  ( 1 )\r
+       #define configUSE_MALLOC_FAILED_HOOK    ( 1 )\r
+       #define configUSE_IDLE_HOOK  ( 1 )\r
+\r
+#endif\r
 \r
 /* Main functions*/\r
 #define configUSE_PREEMPTION                                   ( 1 )\r
-#define configUSE_TICKLESS_IDLE                                        ( 1 )\r
 #define configUSE_PORT_OPTIMISED_TASK_SELECTION        ( 1 )\r
+#define configSUPPORT_STATIC_ALLOCATION                        ( 1 )\r
 #define configCPU_CLOCK_HZ                                             (( unsigned long ) 14000000)\r
 #define configMAX_PRIORITIES                                   ( 6 )\r
-#define configTICK_RATE_HZ                                             ( 1000 )\r
-#define configMINIMAL_STACK_SIZE                                 (( unsigned short ) 140)\r
-#define configTOTAL_HEAP_SIZE                                   (( size_t )(40000))\r
+#define configMINIMAL_STACK_SIZE                               (( unsigned short ) 140)\r
+#define configTOTAL_HEAP_SIZE                                  (( size_t )(40000))\r
 #define configMAX_TASK_NAME_LEN                                   ( 10 )\r
-#define configUSE_TRACE_FACILITY                                 ( 0 )\r
+#define configUSE_TRACE_FACILITY                               ( 0 )\r
 #define configUSE_16_BIT_TICKS                                 ( 0 )\r
-#define configIDLE_SHOULD_YIELD                                   ( 0 )\r
-#define configUSE_MUTEXES                                               ( 1 )\r
-#define configUSE_RECURSIVE_MUTEXES                       ( 1 )\r
-#define configUSE_COUNTING_SEMAPHORES                   ( 1 )\r
-#define configUSE_ALTERNATIVE_API                               ( 0 )/* Deprecated! */\r
-#define configQUEUE_REGISTRY_SIZE                               ( 10 )\r
-#define configUSE_QUEUE_SETS                                     ( 0 )\r
-\r
-/* Hook function related definitions. */\r
-#define configUSE_TICK_HOOK                                       ( 1 )\r
-#define configCHECK_FOR_STACK_OVERFLOW                 ( 2 )\r
-#define configUSE_MALLOC_FAILED_HOOK                     ( 1 )\r
-#define configUSE_IDLE_HOOK  ( 1 )\r
+#define configIDLE_SHOULD_YIELD                                        ( 0 )\r
+#define configUSE_MUTEXES                                              ( 1 )\r
+#define configUSE_RECURSIVE_MUTEXES                            ( 1 )\r
+#define configUSE_COUNTING_SEMAPHORES                  ( 1 )\r
+#define configUSE_ALTERNATIVE_API                              ( 0 )/* Deprecated! */\r
+#define configQUEUE_REGISTRY_SIZE                              ( 10 )\r
+#define configUSE_QUEUE_SETS                                    ( 0 )\r
 \r
 /* Run time stats gathering related definitions. */\r
-#define configGENERATE_RUN_TIME_STATS                   ( 0 )\r
+#define configGENERATE_RUN_TIME_STATS                  ( 0 )\r
 \r
 /* Co-routine related definitions. */\r
-#define configUSE_CO_ROUTINES                                   ( 0 )\r
-#define configMAX_CO_ROUTINE_PRIORITIES                   ( 1 )\r
+#define configUSE_CO_ROUTINES                                  ( 0 )\r
+#define configMAX_CO_ROUTINE_PRIORITIES                        ( 1 )\r
 \r
 /* Software timer related definitions. */\r
-#define configUSE_TIMERS                                                 ( 1 )\r
-#define configTIMER_TASK_PRIORITY                               ( configMAX_PRIORITIES - 1 ) /* Highest priority */\r
-#define configTIMER_QUEUE_LENGTH                                 ( 10 )\r
-#define configTIMER_TASK_STACK_DEPTH                     ( configMINIMAL_STACK_SIZE )\r
+#define configUSE_TIMERS                                               ( 1 )\r
+#define configTIMER_TASK_PRIORITY                              ( configMAX_PRIORITIES - 1 ) /* Highest priority */\r
+#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
+#define configKERNEL_INTERRUPT_PRIORITY                        ( 255 )\r
+#define configMAX_SYSCALL_INTERRUPT_PRIORITY   ( 191 ) /* equivalent to 0xa0, or priority 5. */\r
 \r
 /* Optional functions - most linkers will remove unused functions anyway. */\r
-#define INCLUDE_vTaskPrioritySet                                 ( 1 )\r
-#define INCLUDE_uxTaskPriorityGet                               ( 1 )\r
-#define INCLUDE_vTaskDelete                                       ( 1 )\r
-#define INCLUDE_vTaskSuspend                                     ( 1 )\r
+#define INCLUDE_vTaskPrioritySet                               ( 1 )\r
+#define INCLUDE_uxTaskPriorityGet                              ( 1 )\r
+#define INCLUDE_vTaskDelete                                            ( 1 )\r
+#define INCLUDE_vTaskSuspend                                   ( 1 )\r
 #define INCLUDE_xResumeFromISR                                 ( 1 )\r
-#define INCLUDE_vTaskDelayUntil                                   ( 1 )\r
+#define INCLUDE_vTaskDelayUntil                                        ( 1 )\r
 #define INCLUDE_vTaskDelay                                             ( 1 )\r
 #define INCLUDE_xTaskGetSchedulerState                 ( 1 )\r
-#define INCLUDE_xTaskGetCurrentTaskHandle               ( 1 )\r
-#define INCLUDE_uxTaskGetStackHighWaterMark       ( 0 )\r
+#define INCLUDE_xTaskGetCurrentTaskHandle              ( 1 )\r
+#define INCLUDE_uxTaskGetStackHighWaterMark            ( 0 )\r
 #define INCLUDE_xTaskGetIdleTaskHandle                 ( 0 )\r
 #define INCLUDE_xTimerGetTimerDaemonTaskHandle ( 0 )\r
-#define INCLUDE_pcTaskGetTaskName                               ( 0 )\r
-#define INCLUDE_eTaskGetState                                   ( 1 )\r
+#define INCLUDE_pcTaskGetTaskName                              ( 0 )\r
+#define INCLUDE_eTaskGetState                                  ( 1 )\r
 #define INCLUDE_xTimerPendFunctionCall                 ( 1 )\r
 \r
 /* Stop if an assertion fails. */\r
-#define configASSERT( x )         if( ( x ) == 0 ) { taskDISABLE_INTERRUPTS(); for( ;; ); }\r
+#define configASSERT( x )      if( ( x ) == 0 ) { taskDISABLE_INTERRUPTS(); for( ;; ); }\r
 \r
 /* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS\r
 standard names. */\r
index 2c517258460a168e8803968589dafdea6ea8ed56..cb8552289d37d9386ebd6380d1f74fc8d0ac5e5a 100644 (file)
 /******************************************************************************\r
  * NOTE 1:  This project provides two demo applications.  A simple blinky style\r
  * project that demonstrates the tickless low power features of FreeRTOS, and a\r
- * more comprehensive test and demo application.  The mainCREATE_LOW_POWER_DEMO\r
- * setting in main.c is used to select between the two.  See the notes on using\r
- * mainCREATE_LOW_POWER_DEMO in main.c.  This file implements the comprehensive\r
- * test and demo version.\r
+ * more comprehensive test and demo application.  The configCREATE_LOW_POWER_DEMO\r
+ * setting in FreeRTOSConifg.h is used to select between the two.  See the notes\r
+ * on using conifgCREATE_LOW_POWER_DEMO in main.c.  This file implements the \r
+ * comprehensive test and demo version.\r
  *\r
  * NOTE 2:  This file only contains the source code that is specific to the\r
  * full demo.  Generic functions, such FreeRTOS hook functions, and functions\r
 #include "EventGroupsDemo.h"\r
 #include "TaskNotify.h"\r
 #include "IntSemTest.h"\r
+#include "StaticAllocation.h"\r
 \r
 /* Priorities for the demo application tasks. */\r
 #define mainSEM_TEST_PRIORITY                          ( tskIDLE_PRIORITY + 1UL )\r
@@ -227,6 +228,7 @@ void main_full( void )
        vStartEventGroupTasks();\r
        vStartTaskNotifyTask();\r
        vStartInterruptSemaphoreTasks();\r
+       vStartStaticallyAllocatedTasks();\r
 \r
        /* Create the register check tasks, as described at the top of this     file */\r
        xTaskCreate( prvRegTestTaskEntry1, "Reg1", configMINIMAL_STACK_SIZE, mainREG_TEST_TASK_1_PARAMETER, tskIDLE_PRIORITY, NULL );\r
@@ -291,6 +293,11 @@ unsigned long ulErrorFound = pdFALSE;
                        ulErrorFound = 1UL << 2UL;\r
                }\r
 \r
+               if( xAreStaticAllocationTasksStillRunning() != pdPASS )\r
+               {\r
+                       ulErrorFound = 1UL << 3UL;\r
+               }\r
+\r
                if ( xAreBlockTimeTestTasksStillRunning() != pdTRUE )\r
                {\r
                        ulErrorFound = 1UL << 4UL;\r
diff --git a/FreeRTOS/Demo/CORTEX_EFM32_Gecko_Starter_Kit_Simplicity_Studio/Source/Low_Power_Demo/low_power_tick_management.c b/FreeRTOS/Demo/CORTEX_EFM32_Gecko_Starter_Kit_Simplicity_Studio/Source/Low_Power_Demo/low_power_tick_management.c
new file mode 100644 (file)
index 0000000..fda6e0e
--- /dev/null
@@ -0,0 +1,326 @@
+/*\r
+    FreeRTOS V8.2.3 - Copyright (C) 2015 Real Time Engineers Ltd.\r
+    All rights reserved\r
+\r
+    VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
+\r
+    This file is part of the FreeRTOS distribution.\r
+\r
+    FreeRTOS is free software; you can redistribute it and/or modify it under\r
+    the terms of the GNU General Public License (version 2) as published by the\r
+    Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.\r
+\r
+    ***************************************************************************\r
+    >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
+    >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
+    >>!   obliged to provide the source code for proprietary components     !<<\r
+    >>!   outside of the FreeRTOS kernel.                                   !<<\r
+    ***************************************************************************\r
+\r
+    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
+    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+    FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
+    link: http://www.freertos.org/a00114.html\r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    FreeRTOS provides completely free yet professionally developed,    *\r
+     *    robust, strictly quality controlled, supported, and cross          *\r
+     *    platform software that is more than just the market leader, it     *\r
+     *    is the industry's de facto standard.                               *\r
+     *                                                                       *\r
+     *    Help yourself get started quickly while simultaneously helping     *\r
+     *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
+     *    tutorial book, reference manual, or both:                          *\r
+     *    http://www.FreeRTOS.org/Documentation                              *\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\r
+    http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
+    the FAQ page "My application does not run, what could be wrong?".  Have you\r
+    defined configASSERT()?\r
+\r
+    http://www.FreeRTOS.org/support - In return for receiving this top quality\r
+    embedded software for free we request you assist our global community by\r
+    participating in the support forum.\r
+\r
+    http://www.FreeRTOS.org/training - Investing in training allows your team to\r
+    be as productive as possible as early as possible.  Now you can receive\r
+    FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
+    Ltd, and the world's leading authority on the world's leading RTOS.\r
+\r
+    http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
+    including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
+    compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
+\r
+    http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
+    Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
+\r
+    http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
+    Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
+    licenses offer ticketed support, indemnification and commercial middleware.\r
+\r
+    http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
+    engineered and independently SIL3 certified version for use in safety and\r
+    mission critical applications that require provable dependability.\r
+\r
+    1 tab == 4 spaces!\r
+*/\r
+\r
+/* Standard includes. */\r
+#include "limits.h"\r
+\r
+/* FreeRTOS includes. */\r
+#include "FreeRTOS.h"\r
+#include "task.h"\r
+\r
+/* SiLabs library includes. */\r
+#include "em_cmu.h"\r
+#include "em_burtc.h"\r
+#include "em_rmu.h"\r
+#include "em_int.h"\r
+#include "sleep.h"\r
+\r
+/* This file contains functions that will override the default implementations\r
+in the RTOS port layer.  Therefore only build this file if the low power demo\r
+is being built. */\r
+#if( configCREATE_LOW_POWER_DEMO == 1 )\r
+\r
+#define mainTIMER_FREQUENCY_HZ ( 2000UL )\r
+\r
+/*\r
+ * The low power demo does not use the SysTick, so override the\r
+ * vPortSetupTickInterrupt() function with an implementation that configures\r
+ * a low power clock source.  NOTE:  This function name must not be changed as\r
+ * it is called from the RTOS portable layer.\r
+ */\r
+void vPortSetupTimerInterrupt( void );\r
+\r
+/* Override the default definition of vPortSuppressTicksAndSleep() that is\r
+ * weakly defined in the FreeRTOS Cortex-M port layer with a version that\r
+ * manages the BURTC clock, as the tick is generated from the low power BURTC\r
+ * and not the SysTick as would normally be the case on a Cortex-M.\r
+ */\r
+void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime );\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/* Calculate how many clock increments make up a single tick period. */\r
+static const uint32_t ulReloadValueForOneTick = ( mainTIMER_FREQUENCY_HZ / configTICK_RATE_HZ );\r
+\r
+/* Calculate the maximum number of ticks that can be suppressed when using the\r
+high resolution clock and low resolution clock respectively. */\r
+static uint32_t xMaximumPossibleSuppressedTicks = 0;\r
+\r
+/* Flag set from the tick interrupt to allow the sleep processing to know if\r
+sleep mode was exited because of an timer interrupt or a different interrupt. */\r
+static volatile uint32_t ulTickFlag = pdFALSE;\r
+\r
+/* As the clock is only 2KHz, it is likely a value of 1 will be too much, so\r
+use zero - but leave the value here to assist porting to different clock\r
+speeds. */\r
+static const uint32_t ulStoppedTimerCompensation = 0UL;\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+void vPortSetupTimerInterrupt( void )\r
+{\r
+BURTC_Init_TypeDef xBURTCInitStruct = BURTC_INIT_DEFAULT;\r
+\r
+       xMaximumPossibleSuppressedTicks = ULONG_MAX / ulReloadValueForOneTick;\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 the tick interrupt 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
+       /* The tick interrupt must be set to the lowest possible. */\r
+       NVIC_SetPriority( BURTC_IRQn, configKERNEL_INTERRUPT_PRIORITY );\r
+       NVIC_ClearPendingIRQ( BURTC_IRQn );\r
+       NVIC_EnableIRQ( BURTC_IRQn );\r
+       BURTC_CompareSet( 0, ulReloadValueForOneTick );\r
+       BURTC_IntClear( BURTC_IF_COMP0 );\r
+       BURTC_IntEnable( BURTC_IF_COMP0 );\r
+       BURTC_CounterReset();\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime )\r
+{\r
+uint32_t ulReloadValue, ulCompleteTickPeriods, ulCurrentCount;\r
+eSleepModeStatus eSleepAction;\r
+TickType_t xModifiableIdleTime;\r
+\r
+       /* THIS FUNCTION IS CALLED WITH THE SCHEDULER SUSPENDED. */\r
+\r
+       /* Make sure the BURTC reload value does not overflow the counter. */\r
+       if( xExpectedIdleTime > xMaximumPossibleSuppressedTicks )\r
+       {\r
+               xExpectedIdleTime = xMaximumPossibleSuppressedTicks;\r
+       }\r
+\r
+       /* Calculate the reload value required to wait xExpectedIdleTime tick\r
+       periods. */\r
+       ulReloadValue = ulReloadValueForOneTick * xExpectedIdleTime;\r
+       if( ulReloadValue > ulStoppedTimerCompensation )\r
+       {\r
+               /* Compensate for the fact that the BURTC is going to be stopped\r
+               momentarily. */\r
+               ulReloadValue -= ulStoppedTimerCompensation;\r
+       }\r
+\r
+       /* Stop the BURTC momentarily.  The time the BURTC is stopped for is\r
+       accounted for as best it can be, but using the tickless mode will inevitably\r
+       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
+       BURTC_Enable( false );\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
+\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
+       suppressed for the entire xExpectedIdleTime period. */\r
+       ulTickFlag = pdFALSE;\r
+\r
+       /* If a context switch is pending then abandon the low power entry as the\r
+       context switch might have been pended by an external interrupt that     requires\r
+       processing. */\r
+       eSleepAction = eTaskConfirmSleepModeStatus();\r
+       if( eSleepAction == eAbortSleep )\r
+       {\r
+               /* Restart tick and count up to whatever was left of the current time\r
+               slice. */\r
+               BURTC_CompareSet( 0, ulReloadValueForOneTick - ulCurrentCount );\r
+               BURTC_Enable( true );\r
+\r
+               /* Re-enable interrupts - see comments above the cpsid instruction()\r
+               above. */\r
+               INT_Enable();\r
+       }\r
+       else\r
+       {\r
+               /* Adjust the reload value to take into account that the current time\r
+               slice is already partially complete. */\r
+               ulReloadValue -= ulCurrentCount;\r
+               BURTC_CompareSet( 0, ulReloadValue );\r
+\r
+               /* Restart the BURTC. */\r
+               BURTC_Enable( true );\r
+\r
+               /* Allow the application to define some pre-sleep processing. */\r
+               xModifiableIdleTime = xExpectedIdleTime;\r
+               configPRE_SLEEP_PROCESSING( xModifiableIdleTime );\r
+\r
+               /* xExpectedIdleTime being set to 0 by configPRE_SLEEP_PROCESSING()\r
+               means the application defined code has already executed the WAIT\r
+               instruction. */\r
+               if( xModifiableIdleTime > 0 )\r
+               {\r
+                       __asm volatile( "dsb" );\r
+                       SLEEP_Sleep();\r
+                       __asm volatile( "isb" );\r
+               }\r
+\r
+               /* Allow the application to define some post sleep processing. */\r
+               configPOST_SLEEP_PROCESSING( xModifiableIdleTime );\r
+\r
+               /* Stop BURTC.  Again, the time the SysTick is stopped for is accounted\r
+               for as best it can be, but using the tickless mode will inevitably\r
+               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
+               BURTC_Enable( false );\r
+\r
+               /* Re-enable interrupts - see comments above the cpsid instruction()\r
+               above. */\r
+               INT_Enable();\r
+\r
+               if( ulTickFlag != pdFALSE )\r
+               {\r
+                       /* The tick interrupt has already executed, although because this\r
+                       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
+                       BURTC_CompareSet( 0, ulReloadValue );\r
+\r
+                       /* The tick interrupt handler will already have pended the tick\r
+                       processing in the kernel.  As the pending tick will be processed as\r
+                       soon as this function exits, the tick value     maintained by the tick\r
+                       is stepped forward by one less than the time spent sleeping.  The\r
+                       actual stepping of the tick appears later in this function. */\r
+                       ulCompleteTickPeriods = xExpectedIdleTime - 1UL;\r
+               }\r
+               else\r
+               {\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
+\r
+                       /* The reload value is set to whatever fraction of a single tick\r
+                       period remains. */\r
+                       ulReloadValue = ulCurrentCount - ( ulCompleteTickPeriods * ulReloadValueForOneTick );\r
+                       if( ulReloadValue == 0 )\r
+                       {\r
+                               /* There is no fraction remaining. */\r
+                               ulReloadValue = ulReloadValueForOneTick;\r
+                               ulCompleteTickPeriods++;\r
+                       }\r
+\r
+                       BURTC_CompareSet( 0, ulReloadValue );\r
+               }\r
+\r
+               /* Restart the BURTC so it runs up to the alarm value.  The alarm value\r
+               will get set to the value required to generate exactly one tick period\r
+               the next time the BURTC interrupt executes. */\r
+               BURTC_Enable( true );\r
+\r
+               /* Wind the tick forward by the number of tick periods that the CPU\r
+               remained in a low power state. */\r
+               vTaskStepTick( ulCompleteTickPeriods );\r
+       }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void BURTC_IRQHandler(void)\r
+{\r
+       if( ulTickFlag == pdFALSE )\r
+       {\r
+               /* Set BURTC interrupt to one system tick period*/\r
+               BURTC_Enable( false );\r
+               BURTC_CompareSet( 0, ulReloadValueForOneTick );\r
+               ulTickFlag = pdTRUE;\r
+               BURTC_Enable( true );\r
+       }\r
+\r
+       BURTC_IntClear( _RTC_IFC_MASK );\r
+\r
+       /* Critical section which protect incrementing the tick*/\r
+       ( void ) portSET_INTERRUPT_MASK_FROM_ISR();\r
+       {\r
+               if( xTaskIncrementTick() != pdFALSE )\r
+               {\r
+                       /* Pend a context switch. */\r
+                       portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT;\r
+               }\r
+       }\r
+       portCLEAR_INTERRUPT_MASK_FROM_ISR( 0 );\r
+}\r
+\r
+#endif /* ( configCREATE_LOW_POWER_DEMO == 1 ) */\r
+\r
index f39f9b8e4d483519db49f3f4475e69cd1d3411e6..fe4824d8c6c90bb7dfbddbbe61bc084d4c6f62c4 100644 (file)
 \r
 /******************************************************************************\r
  * NOTE 1:  This project provides two demo applications.  A simple blinky demo\r
- * that demonstrates tickless low power operation, and a more comprehensive test\r
- * and demo application.  The mainCREATE_LOW_POWER_DEMO setting in main.c is\r
- * used to select between the two.  See the notes on using\r
- * mainCREATE_LOW_POWER_DEMO in main.c.  This file implements the low power\r
+ * that demonstrates tickless low power operation, and a more comprehensive\r
+ * test and demo application.  The configCREATE_LOW_POWER_DEMO setting in\r
+ * FreeRTOSConfig.h is used to select between the two.  See the notes on using\r
+ * configCREATE_LOW_POWER_DEMO in main.c.  This file implements the low power\r
  * version.\r
  *\r
  * NOTE 2:  This file only contains the source code that is specific to the\r
  * main_low_power() creates one queue, and two tasks.  It then starts the\r
  * scheduler.\r
  *\r
- * The Queue Send Task:\r
- * The queue send task is implemented by the prvQueueSendTask() function in\r
- * this file.  prvQueueSendTask() sits in a loop that causes it to repeatedly\r
- * block for 200 milliseconds, before sending the value 100 to the queue that\r
- * was created within main_low_power().  Once the value is sent, the task loops\r
- * back around to block for another 200 milliseconds...and so on.\r
- *\r
- * The Queue Receive Task:\r
- * The queue receive task is implemented by the prvQueueReceiveTask() function\r
- * in this file.  prvQueueReceiveTask() sits in a loop where it repeatedly\r
- * blocks on attempts to read data from the queue that was created within\r
- * main_low_power().  When data is received, the task checks the value of the\r
- * data, and if the value equals the expected 100, toggles an LED.  The 'block\r
- * time' parameter passed to the queue receive function specifies that the\r
- * task should be held in the Blocked state indefinitely to wait for data to\r
- * be available on the queue.  The queue receive task will only leave the\r
- * Blocked state when the queue send task writes to the queue.  As the queue\r
- * send task writes to the queue every 200 milliseconds, the queue receive\r
- * task leaves the Blocked state every 200 milliseconds, and therefore toggles\r
- * the LED every 200 milliseconds.\r
+ * TBD\r
  */\r
 \r
 #warning Description of demo in comments above is not correct.\r
 \r
 /* The rate at which data is sent to the queue.  The 200ms value is converted\r
 to ticks using the portTICK_PERIOD_MS constant. */\r
-#define mainQUEUE_SEND_FREQUENCY_MS                    pdMS_TO_TICKS( 500 )\r
+#define mainQUEUE_SEND_FREQUENCY_MS                    pdMS_TO_TICKS( 1000 )\r
 \r
 /* The number of items the queue can hold.  This is 1 as the receive task\r
 will remove items as they are added, meaning the send task should always find\r
index 1f0371876b673ab9643621078a25f6b1aa8eab1e..8bd4c45768c74728478c41e6da7a41cf0e98563a 100644 (file)
 \r
 /******************************************************************************\r
  * This project provides two demo applications.  A simple blinky style project\r
- * that demonstrates tickless low power functionality, and a more comprehensive\r
- * test and demo application.  The mainCREATE_LOW_POWER_DEMO setting (defined in\r
- * this file) is used to select between the two.  The simply blinky low power\r
- * demo is implemented and described in main_low_power.c.  The more\r
- * comprehensive test and demo application is implemented and described in\r
+ * that demonstrates low power tickless functionality, and a more comprehensive\r
+ * test and demo application.  The configCREATE_LOW_POWER_DEMO setting, which is\r
+ * defined in FreeRTOSConfig.h, is used to select between the two.  The simply\r
+ * blinky low power demo is implemented and described in main_low_power.c.  The\r
+ * more comprehensive test and demo application is implemented and described in\r
  * main_full.c.\r
  *\r
  * This file implements the code that is not demo specific, including the\r
@@ -85,8 +85,6 @@
  *\r
  */\r
 \r
-#warning FreeRTOSConfig.h needs formatting.\r
-\r
 /* FreeRTOS includes. */\r
 #include "FreeRTOS.h"\r
 #include "task.h"\r
@@ -109,14 +107,14 @@ run the more comprehensive test and demo application. */
 static void prvSetupHardware( void );\r
 \r
 /*\r
- * main_low_power() is used when mainCREATE_LOW_POWER_DEMO is set to 1.\r
- * main_full() is used when mainCREATE_LOW_POWER_DEMO is set to 0.\r
+ * 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 mainCREATE_LOW_POWER_DEMO == 1\r
+#if( configCREATE_LOW_POWER_DEMO == 1 )\r
        extern void main_low_power( void );\r
 #else\r
        extern void main_full( void );\r
-#endif /* #if mainCREATE_LOW_POWER_DEMO == 1 */\r
+#endif /* #if configCREATE_LOW_POWER_DEMO == 1 */\r
 \r
 /* Prototypes for the standard FreeRTOS callback/hook functions implemented\r
 within this file. */\r
@@ -134,7 +132,7 @@ int main( void )
 \r
        /* The mainCREATE_LOW_POWER_DEMO setting is described at the top\r
        of this file. */\r
-       #if( mainCREATE_LOW_POWER_DEMO == 1 )\r
+       #if( configCREATE_LOW_POWER_DEMO == 1 )\r
        {\r
                main_low_power();\r
        }\r
@@ -144,10 +142,7 @@ int main( void )
        }\r
        #endif\r
 \r
-       /* Start FreeRTOS Scheduler */\r
-       vTaskStartScheduler();\r
-\r
-       /* Cannot get here. */\r
+       /* Should not get here. */\r
        return 0;\r
 }\r
 /*-----------------------------------------------------------*/\r
@@ -160,11 +155,7 @@ static void prvSetupHardware( void )
        SLEEP_Init( NULL, NULL );\r
        BSP_LedsInit();\r
 \r
-       #if (configSLEEP_MODE < 3)\r
-       {\r
-               SLEEP_SleepBlockBegin((SLEEP_EnergyMode_t)(configSLEEP_MODE+1));\r
-       }\r
-       #endif\r
+//_RB_ SLEEP_SleepBlockBegin( ( SLEEP_EnergyMode_t ) ( configSLEEP_MODE+1 ) );\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
@@ -216,12 +207,41 @@ volatile size_t xFreeHeapSpace;
 void vApplicationTickHook( void )\r
 {\r
        /* The full demo includes tests that run from the tick hook. */\r
-       #if( mainCREATE_LOW_POWER_DEMO == 0 )\r
+       #if( configCREATE_LOW_POWER_DEMO == 0 )\r
        {\r
        extern void vFullDemoTickHook( void );\r
 \r
+               /* Some of the tests and demo tasks executed by the full demo include\r
+               interaction from an interrupt - for which the tick interrupt is used\r
+               via the tick hook function. */\r
                vFullDemoTickHook();\r
        }\r
        #endif\r
 }\r
+/*-----------------------------------------------------------*/\r
+\r
+void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint16_t *pusIdleTaskStackSize )\r
+{\r
+       /* configUSE_STATIC_ALLOCATION is set to 1, so the application has the\r
+       opportunity to supply the buffers that will be used by the Idle task as its\r
+       stack and to hold its TCB.  If these are set to NULL then the buffers will\r
+       be allocated dynamically, just as if xTaskCreate() had been called. */\r
+       *ppxIdleTaskTCBBuffer = NULL;\r
+       *ppxIdleTaskStackBuffer = NULL;\r
+       *pusIdleTaskStackSize = configMINIMAL_STACK_SIZE; /* In words.  NOT in bytes! */\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vApplicationGetTimerTaskMemory( StaticTask_t **ppxTimerTaskTCBBuffer, StackType_t **ppxTimerTaskStackBuffer, uint16_t *pusTimerTaskStackSize )\r
+{\r
+       /* configUSE_STATIC_ALLOCATION is set to 1, so the application has the\r
+       opportunity to supply the buffers that will be used by the Timer/RTOS daemon\r
+       task as its     stack and to hold its TCB.  If these are set to NULL then the\r
+       buffers will be allocated dynamically, just as if xTaskCreate() had been\r
+       called. */\r
+       *ppxTimerTaskTCBBuffer = NULL;\r
+       *ppxTimerTaskStackBuffer = NULL;\r
+       *pusTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; /* In words.  NOT in bytes! */\r
+}\r
+/*-----------------------------------------------------------*/\r
 \r