]> git.sur5r.net Git - freertos/commitdiff
Updated the sleep function to ensure it left interrupts disabled when returning.
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Sun, 7 Apr 2013 19:30:25 +0000 (19:30 +0000)
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Sun, 7 Apr 2013 19:30:25 +0000 (19:30 +0000)
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1851 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

FreeRTOS/Demo/CORTEX_M4_ATSAM4L_Atmel_Studio/FreeRTOS_Demo.cproj
FreeRTOS/Demo/CORTEX_M4_ATSAM4L_Atmel_Studio/src/SAM4L_low_power_tick_management.c
FreeRTOS/Demo/CORTEX_M4_ATSAM4L_Atmel_Studio/src/asf/sam/drivers/bpm/bpm.c
FreeRTOS/Demo/CORTEX_M4_ATSAM4L_Atmel_Studio/src/asf/sam/drivers/bpm/sleep.h
FreeRTOS/Demo/CORTEX_M4_ATSAM4L_Atmel_Studio/src/config/FreeRTOSConfig.h

index c553fcd0c3924b8eb1682388a1156c278436a639..227cab4fd2c6c323c203b637508ef815be620ec6 100644 (file)
     <com_atmel_avrdbg_tool_samice>\r
       <ToolType>com.atmel.avrdbg.tool.samice</ToolType>\r
       <ToolName>J-Link-OB-SAM3U128</ToolName>\r
-      <ToolNumber>000480008423</ToolNumber>\r
+      <ToolNumber>000480008435</ToolNumber>\r
       <KeepTimersRunning>true</KeepTimersRunning>\r
       <OverrideVtor>false</OverrideVtor>\r
       <OverrideVtorValue>\r
       </OverrideVtorValue>\r
       <Channel>\r
         <host>127.0.0.1</host>\r
-        <port>4788</port>\r
+        <port>1882</port>\r
         <ssl>False</ssl>\r
       </Channel>\r
       <ToolOptions>\r
   <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">\r
     <ToolchainSettings>\r
       <ArmGcc>\r
-  <armgcc.common.general.symbols>__ATSAM4LC4C__</armgcc.common.general.symbols>\r
-  <armgcc.common.outputfiles.hex>True</armgcc.common.outputfiles.hex>\r
-  <armgcc.common.outputfiles.lss>True</armgcc.common.outputfiles.lss>\r
-  <armgcc.common.outputfiles.eep>True</armgcc.common.outputfiles.eep>\r
-  <armgcc.common.outputfiles.bin>True</armgcc.common.outputfiles.bin>\r
-  <armgcc.common.outputfiles.srec>True</armgcc.common.outputfiles.srec>\r
-  <armgcc.compiler.symbols.DefSymbols>\r
-    <ListValues>\r
-      <Value>BOARD=SAM4L_EK</Value>\r
-      <Value>ARM_MATH_CM4=true</Value>\r
-      <Value>__SAM4LC4C__</Value>\r
-    </ListValues>\r
-  </armgcc.compiler.symbols.DefSymbols>\r
-  <armgcc.compiler.directories.DefaultIncludePath>False</armgcc.compiler.directories.DefaultIncludePath>\r
-  <armgcc.compiler.directories.IncludePaths>\r
-    <ListValues>\r
-      <Value>../src/asf/sam/utils/preprocessor</Value>\r
-      <Value>../src/asf/sam/drivers/lcdca/example/sam4lc4c_sam4l_ek</Value>\r
-      <Value>../src/asf/sam/utils/cmsis/sam4l/include</Value>\r
-      <Value>../src/asf/common/services/sleepmgr</Value>\r
-      <Value>../src/asf/sam/utils</Value>\r
-      <Value>../src/asf/common/boards</Value>\r
-      <Value>../src/asf/sam/drivers/flashcalw</Value>\r
-      <Value>../src/asf/sam/boards</Value>\r
-      <Value>../src/asf/common/services/clock</Value>\r
-      <Value>../src/asf/sam/drivers/bpm</Value>\r
-      <Value>../src/asf/thirdparty/CMSIS/Include</Value>\r
-      <Value>../src/asf/sam/boards/sam4l_ek</Value>\r
-      <Value>../src/asf/sam/utils/header_files</Value>\r
-      <Value>../src/asf/common/services/ioport</Value>\r
-      <Value>../src/asf/sam/utils/cmsis/sam4l/source/templates</Value>\r
-      <Value>../src/asf/common/utils</Value>\r
-      <Value>../src/asf/thirdparty/CMSIS/Lib/GCC</Value>\r
-      <Value>../src</Value>\r
-      <Value>../src/config</Value>\r
-      <Value>../src/asf/sam/drivers/ast</Value>\r
-      <Value>../../../Source/include</Value>\r
-      <Value>../../../Source/portable/GCC/ARM_CM3</Value>\r
-      <Value>../../Common/include</Value>\r
-    </ListValues>\r
-  </armgcc.compiler.directories.IncludePaths>\r
-  <armgcc.compiler.optimization.OtherFlags>-fdata-sections</armgcc.compiler.optimization.OtherFlags>\r
-  <armgcc.compiler.optimization.PrepareFunctionsForGarbageCollection>True</armgcc.compiler.optimization.PrepareFunctionsForGarbageCollection>\r
-  <armgcc.compiler.optimization.DebugLevel>Maximum (-g3)</armgcc.compiler.optimization.DebugLevel>\r
-  <armgcc.compiler.warnings.AllWarnings>True</armgcc.compiler.warnings.AllWarnings>\r
-  <armgcc.compiler.miscellaneous.OtherFlags>-std=gnu99 -Wmissing-field-initializers</armgcc.compiler.miscellaneous.OtherFlags>\r
-  <armgcc.linker.libraries.Libraries>\r
-    <ListValues>\r
-      <Value>arm_cortexM4l_math</Value>\r
-      <Value>m</Value>\r
-    </ListValues>\r
-  </armgcc.linker.libraries.Libraries>\r
-  <armgcc.linker.libraries.LibrarySearchPaths>\r
-    <ListValues>\r
-      <Value>../cmsis/linkerScripts</Value>\r
-      <Value>../src/asf/thirdparty/CMSIS/Lib/GCC</Value>\r
-    </ListValues>\r
-  </armgcc.linker.libraries.LibrarySearchPaths>\r
-  <armgcc.linker.optimization.GarbageCollectUnusedSections>True</armgcc.linker.optimization.GarbageCollectUnusedSections>\r
-  <armgcc.linker.miscellaneous.LinkerFlags>-T../src/asf/sam/utils/linker_scripts/sam4l/sam4l4/gcc/flash.ld -Wl,--cref -Wl,--entry=Reset_Handler -mthumb</armgcc.linker.miscellaneous.LinkerFlags>\r
-  <armgcc.assembler.general.IncludePaths>\r
-    <ListValues>\r
-      <Value>../src/asf/sam/utils/preprocessor</Value>\r
-      <Value>../src/asf/sam/drivers/lcdca/example/sam4lc4c_sam4l_ek</Value>\r
-      <Value>../src/asf/sam/utils/cmsis/sam4l/include</Value>\r
-      <Value>../src/asf/common/services/sleepmgr</Value>\r
-      <Value>../src/asf/sam/utils</Value>\r
-      <Value>../src/asf/common/boards</Value>\r
-      <Value>../src/asf/sam/drivers/flashcalw</Value>\r
-      <Value>../src/asf/sam/boards</Value>\r
-      <Value>../src/asf/common/services/clock</Value>\r
-      <Value>../src/asf/sam/drivers/bpm</Value>\r
-      <Value>../src/asf/thirdparty/CMSIS/Include</Value>\r
-      <Value>../src/asf/sam/boards/sam4l_ek</Value>\r
-      <Value>../src/asf/sam/utils/header_files</Value>\r
-      <Value>../src/asf/common/services/ioport</Value>\r
-      <Value>../src/asf/sam/utils/cmsis/sam4l/source/templates</Value>\r
-      <Value>../src/asf/common/utils</Value>\r
-      <Value>../src/asf/thirdparty/CMSIS/Lib/GCC</Value>\r
-      <Value>../src</Value>\r
-      <Value>../src/config</Value>\r
-      <Value>../src/asf/sam/drivers/ast</Value>\r
-    </ListValues>\r
-  </armgcc.assembler.general.IncludePaths>\r
-  <armgcc.assembler.debugging.DebugLevel>Default (-g)</armgcc.assembler.debugging.DebugLevel>\r
-  <armgcc.preprocessingassembler.general.AssemblerFlags>-DARM_MATH_CM4=true -DBOARD=SAM4L_EK -D__ATSAM4LC4C__</armgcc.preprocessingassembler.general.AssemblerFlags>\r
-  <armgcc.preprocessingassembler.general.IncludePaths>\r
-    <ListValues>\r
-      <Value>../src/asf/sam/utils/preprocessor</Value>\r
-      <Value>../src/asf/sam/drivers/lcdca/example/sam4lc4c_sam4l_ek</Value>\r
-      <Value>../src/asf/sam/utils/cmsis/sam4l/include</Value>\r
-      <Value>../src/asf/common/services/sleepmgr</Value>\r
-      <Value>../src/asf/sam/utils</Value>\r
-      <Value>../src/asf/common/boards</Value>\r
-      <Value>../src/asf/sam/drivers/flashcalw</Value>\r
-      <Value>../src/asf/sam/boards</Value>\r
-      <Value>../src/asf/common/services/clock</Value>\r
-      <Value>../src/asf/sam/drivers/bpm</Value>\r
-      <Value>../src/asf/thirdparty/CMSIS/Include</Value>\r
-      <Value>../src/asf/sam/boards/sam4l_ek</Value>\r
-      <Value>../src/asf/sam/utils/header_files</Value>\r
-      <Value>../src/asf/common/services/ioport</Value>\r
-      <Value>../src/asf/sam/utils/cmsis/sam4l/source/templates</Value>\r
-      <Value>../src/asf/common/utils</Value>\r
-      <Value>../src/asf/thirdparty/CMSIS/Lib/GCC</Value>\r
-      <Value>../src</Value>\r
-      <Value>../src/config</Value>\r
-      <Value>../src/asf/sam/drivers/ast</Value>\r
-    </ListValues>\r
-  </armgcc.preprocessingassembler.general.IncludePaths>\r
-  <armgcc.preprocessingassembler.debugging.DebugLevel>Default (-Wa,-g)</armgcc.preprocessingassembler.debugging.DebugLevel>\r
-</ArmGcc>\r
+        <armgcc.common.general.symbols>__ATSAM4LC4C__</armgcc.common.general.symbols>\r
+        <armgcc.common.outputfiles.hex>True</armgcc.common.outputfiles.hex>\r
+        <armgcc.common.outputfiles.lss>True</armgcc.common.outputfiles.lss>\r
+        <armgcc.common.outputfiles.eep>True</armgcc.common.outputfiles.eep>\r
+        <armgcc.common.outputfiles.bin>True</armgcc.common.outputfiles.bin>\r
+        <armgcc.common.outputfiles.srec>True</armgcc.common.outputfiles.srec>\r
+        <armgcc.compiler.symbols.DefSymbols>\r
+          <ListValues>\r
+            <Value>BOARD=SAM4L_EK</Value>\r
+            <Value>ARM_MATH_CM4=true</Value>\r
+            <Value>__SAM4LC4C__</Value>\r
+          </ListValues>\r
+        </armgcc.compiler.symbols.DefSymbols>\r
+        <armgcc.compiler.directories.DefaultIncludePath>False</armgcc.compiler.directories.DefaultIncludePath>\r
+        <armgcc.compiler.directories.IncludePaths>\r
+          <ListValues>\r
+            <Value>../src/asf/sam/utils/preprocessor</Value>\r
+            <Value>../src/asf/sam/drivers/lcdca/example/sam4lc4c_sam4l_ek</Value>\r
+            <Value>../src/asf/sam/utils/cmsis/sam4l/include</Value>\r
+            <Value>../src/asf/common/services/sleepmgr</Value>\r
+            <Value>../src/asf/sam/utils</Value>\r
+            <Value>../src/asf/common/boards</Value>\r
+            <Value>../src/asf/sam/drivers/flashcalw</Value>\r
+            <Value>../src/asf/sam/boards</Value>\r
+            <Value>../src/asf/common/services/clock</Value>\r
+            <Value>../src/asf/sam/drivers/bpm</Value>\r
+            <Value>../src/asf/thirdparty/CMSIS/Include</Value>\r
+            <Value>../src/asf/sam/boards/sam4l_ek</Value>\r
+            <Value>../src/asf/sam/utils/header_files</Value>\r
+            <Value>../src/asf/common/services/ioport</Value>\r
+            <Value>../src/asf/sam/utils/cmsis/sam4l/source/templates</Value>\r
+            <Value>../src/asf/common/utils</Value>\r
+            <Value>../src/asf/thirdparty/CMSIS/Lib/GCC</Value>\r
+            <Value>../src</Value>\r
+            <Value>../src/config</Value>\r
+            <Value>../src/asf/sam/drivers/ast</Value>\r
+            <Value>../../../Source/include</Value>\r
+            <Value>../../../Source/portable/GCC/ARM_CM3</Value>\r
+            <Value>../../Common/include</Value>\r
+          </ListValues>\r
+        </armgcc.compiler.directories.IncludePaths>\r
+        <armgcc.compiler.optimization.OtherFlags>-fdata-sections</armgcc.compiler.optimization.OtherFlags>\r
+        <armgcc.compiler.optimization.PrepareFunctionsForGarbageCollection>True</armgcc.compiler.optimization.PrepareFunctionsForGarbageCollection>\r
+        <armgcc.compiler.optimization.DebugLevel>Maximum (-g3)</armgcc.compiler.optimization.DebugLevel>\r
+        <armgcc.compiler.warnings.AllWarnings>True</armgcc.compiler.warnings.AllWarnings>\r
+        <armgcc.compiler.miscellaneous.OtherFlags>-std=gnu99 -Wmissing-field-initializers</armgcc.compiler.miscellaneous.OtherFlags>\r
+        <armgcc.linker.libraries.Libraries>\r
+          <ListValues>\r
+            <Value>arm_cortexM4l_math</Value>\r
+            <Value>m</Value>\r
+          </ListValues>\r
+        </armgcc.linker.libraries.Libraries>\r
+        <armgcc.linker.libraries.LibrarySearchPaths>\r
+          <ListValues>\r
+            <Value>../cmsis/linkerScripts</Value>\r
+            <Value>../src/asf/thirdparty/CMSIS/Lib/GCC</Value>\r
+          </ListValues>\r
+        </armgcc.linker.libraries.LibrarySearchPaths>\r
+        <armgcc.linker.optimization.GarbageCollectUnusedSections>True</armgcc.linker.optimization.GarbageCollectUnusedSections>\r
+        <armgcc.linker.miscellaneous.LinkerFlags>-T../src/asf/sam/utils/linker_scripts/sam4l/sam4l4/gcc/flash.ld -Wl,--cref -Wl,--entry=Reset_Handler -mthumb</armgcc.linker.miscellaneous.LinkerFlags>\r
+        <armgcc.assembler.general.IncludePaths>\r
+          <ListValues>\r
+            <Value>../src/asf/sam/utils/preprocessor</Value>\r
+            <Value>../src/asf/sam/drivers/lcdca/example/sam4lc4c_sam4l_ek</Value>\r
+            <Value>../src/asf/sam/utils/cmsis/sam4l/include</Value>\r
+            <Value>../src/asf/common/services/sleepmgr</Value>\r
+            <Value>../src/asf/sam/utils</Value>\r
+            <Value>../src/asf/common/boards</Value>\r
+            <Value>../src/asf/sam/drivers/flashcalw</Value>\r
+            <Value>../src/asf/sam/boards</Value>\r
+            <Value>../src/asf/common/services/clock</Value>\r
+            <Value>../src/asf/sam/drivers/bpm</Value>\r
+            <Value>../src/asf/thirdparty/CMSIS/Include</Value>\r
+            <Value>../src/asf/sam/boards/sam4l_ek</Value>\r
+            <Value>../src/asf/sam/utils/header_files</Value>\r
+            <Value>../src/asf/common/services/ioport</Value>\r
+            <Value>../src/asf/sam/utils/cmsis/sam4l/source/templates</Value>\r
+            <Value>../src/asf/common/utils</Value>\r
+            <Value>../src/asf/thirdparty/CMSIS/Lib/GCC</Value>\r
+            <Value>../src</Value>\r
+            <Value>../src/config</Value>\r
+            <Value>../src/asf/sam/drivers/ast</Value>\r
+          </ListValues>\r
+        </armgcc.assembler.general.IncludePaths>\r
+        <armgcc.assembler.debugging.DebugLevel>Default (-g)</armgcc.assembler.debugging.DebugLevel>\r
+        <armgcc.preprocessingassembler.general.AssemblerFlags>-DARM_MATH_CM4=true -DBOARD=SAM4L_EK -D__ATSAM4LC4C__</armgcc.preprocessingassembler.general.AssemblerFlags>\r
+        <armgcc.preprocessingassembler.general.IncludePaths>\r
+          <ListValues>\r
+            <Value>../src/asf/sam/utils/preprocessor</Value>\r
+            <Value>../src/asf/sam/drivers/lcdca/example/sam4lc4c_sam4l_ek</Value>\r
+            <Value>../src/asf/sam/utils/cmsis/sam4l/include</Value>\r
+            <Value>../src/asf/common/services/sleepmgr</Value>\r
+            <Value>../src/asf/sam/utils</Value>\r
+            <Value>../src/asf/common/boards</Value>\r
+            <Value>../src/asf/sam/drivers/flashcalw</Value>\r
+            <Value>../src/asf/sam/boards</Value>\r
+            <Value>../src/asf/common/services/clock</Value>\r
+            <Value>../src/asf/sam/drivers/bpm</Value>\r
+            <Value>../src/asf/thirdparty/CMSIS/Include</Value>\r
+            <Value>../src/asf/sam/boards/sam4l_ek</Value>\r
+            <Value>../src/asf/sam/utils/header_files</Value>\r
+            <Value>../src/asf/common/services/ioport</Value>\r
+            <Value>../src/asf/sam/utils/cmsis/sam4l/source/templates</Value>\r
+            <Value>../src/asf/common/utils</Value>\r
+            <Value>../src/asf/thirdparty/CMSIS/Lib/GCC</Value>\r
+            <Value>../src</Value>\r
+            <Value>../src/config</Value>\r
+            <Value>../src/asf/sam/drivers/ast</Value>\r
+          </ListValues>\r
+        </armgcc.preprocessingassembler.general.IncludePaths>\r
+        <armgcc.preprocessingassembler.debugging.DebugLevel>Default (-Wa,-g)</armgcc.preprocessingassembler.debugging.DebugLevel>\r
+      </ArmGcc>\r
     </ToolchainSettings>\r
   </PropertyGroup>\r
   <ItemGroup>\r
index dcfa8251406e5ec8322df7abee565750a23e4e02..9aa8210c9235f65473ccfeeb3de45993af503840 100644 (file)
@@ -263,6 +263,7 @@ void vPortSuppressTicksAndSleep( portTickType xExpectedIdleTime )
 uint32_t ulAlarmValue, ulCompleteTickPeriods;\r
 eSleepModeStatus eSleepAction;\r
 portTickType xModifiableIdleTime;\r
+enum sleepmgr_mode xSleepMode;\r
 \r
        /* THIS FUNCTION IS CALLED WITH THE SCHEDULER SUSPENDED. */\r
 \r
@@ -332,8 +333,14 @@ portTickType xModifiableIdleTime;
                instruction. */\r
                if( xModifiableIdleTime > 0 )\r
                {\r
-                       /* Sleep until something happens. */\r
-                       sleepmgr_enter_sleep();\r
+                       /* Find the deepest allowable sleep mode. */\r
+                       xSleepMode = sleepmgr_get_sleep_mode();\r
+\r
+                       if( xSleepMode != SLEEPMGR_ACTIVE )\r
+                       {\r
+                               /* Sleep until something happens. */\r
+                               bpm_sleep( BPM, xSleepMode );\r
+                       }\r
                }\r
 \r
                /* Allow the application to define some post sleep processing. */\r
@@ -347,7 +354,6 @@ portTickType xModifiableIdleTime;
 \r
                /* Re-enable interrupts - see comments above the cpsid instruction()\r
                above. */\r
-#warning The sleep manager will have re-enabled interrupts already, does this matter?\r
                __asm volatile( "cpsie i" );\r
 \r
                if( ulTickFlag != pdFALSE )\r
index 407034ec339c0f3841ce9baa655f9b95e6ee7b40..5124955dbecb43a75ff08b471d8c4d9f2d136507 100644 (file)
@@ -294,5 +294,7 @@ void bpm_sleep(Bpm *bpm, uint32_t sleep_mode)
         * Please note that we should probably use something like\r
         * cpu_leave_critical(), using set_pri_mask(0)\r
         */\r
-       cpu_irq_enable();\r
+       /* In this demo interrupts are managed by the FreeRTOS kernel and must not\r
+       be altered here so the following line has been removed _RB_\r
+       cpu_irq_enable(); */\r
 }\r
index 168ac7c93e5b68155d3e157b4a09b93524c2954e..b6108c7dfefe7b86f490b295d65be1fcc18c8f11 100644 (file)
@@ -127,7 +127,9 @@ static inline void bpm_sleep(Bpm *bpm, uint32_t sleep_mode)
         * Please note that we should probably use something like\r
         * cpu_leave_critical(), using set_pri_mask(0)\r
         */\r
-       cpu_irq_enable();\r
+       /* In this demo interrupts are managed by the FreeRTOS kernel and must not\r
+       be altered here so the following line has been removed _RB_\r
+       cpu_irq_enable(); */\r
 }\r
 \r
 \r
index 44976b5c3a1bf0098a531d6191626648b6de75f4..4e23adaa8817a24b6249248f9cd8b8037cebb424 100644 (file)
@@ -140,19 +140,6 @@ to exclude the API function. */
 #define INCLUDE_vTaskDelayUntil                        1\r
 #define INCLUDE_vTaskDelay                             1\r
 \r
-/* FreeRTOS+CLI definitions. */\r
-\r
-/* Dimensions a buffer into which command outputs can be written.  The buffer\r
-can be declared in the CLI code itself, to allow multiple command consoles to\r
-share the same buffer.  For example, an application may allow access to the\r
-command interpreter by UART and by Ethernet.  Sharing a buffer is done purely\r
-to save RAM.  Note, however, that the command console itself is not re-entrant,\r
-so only one command interpreter interface can be used at any one time.  For\r
-that reason, no attempt at providing mutual exclusion to the buffer is\r
-attempted. */\r
-#define configCOMMAND_INT_MAX_OUTPUT_SIZE 400\r
-\r
-\r
 /* Cortex-M specific definitions. */\r
 \r
 #ifdef __NVIC_PRIO_BITS\r
@@ -192,5 +179,11 @@ void vPostSleepProcessing( unsigned long xExpectedIdleTime );
 #define configPRE_SLEEP_PROCESSING( xExpectedIdleTime ) vPreSleepProcessing( xExpectedIdleTime );\r
 #define configPOST_SLEEP_PROCESSING( xExpectedIdleTime ) vPostSleepProcessing( xExpectedIdleTime );\r
 \r
+/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS\r
+standard names. */\r
+#define vPortSVCHandler SVC_Handler\r
+#define xPortPendSVHandler PendSV_Handler\r
+#define xPortSysTickHandler SysTick_Handler\r
+\r
 #endif /* FREERTOS_CONFIG_H */\r
 \r