]> git.sur5r.net Git - freertos/commitdiff
Enter sleep mode in the idle task.
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Thu, 23 Dec 2010 11:24:14 +0000 (11:24 +0000)
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Thu, 23 Dec 2010 11:24:14 +0000 (11:24 +0000)
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1183 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

Demo/Cortex_STM32L152_IAR/FreeRTOSConfig.h
Demo/Cortex_STM32L152_IAR/RTOSDemo.ewp
Demo/Cortex_STM32L152_IAR/main.c
Demo/Cortex_STM32L152_IAR/settings/RTOSDemo.dni
Demo/Cortex_STM32L152_IAR/settings/RTOSDemo.wsdt
Demo/Cortex_STM32L152_IAR/system_and_ST_code/STM32L1xx_StdPeriph_Driver/inc/stm32l1xx_pwr.h [new file with mode: 0644]
Demo/Cortex_STM32L152_IAR/system_and_ST_code/STM32L1xx_StdPeriph_Driver/src/stm32l1xx_pwr.c [new file with mode: 0644]
Demo/Cortex_STM32L152_IAR/system_and_ST_code/stm32l1xx_conf.h

index a4aa0374f655c6c0af1002e76963ff32ffb6d363..5c9a376f5902ed34c19fcdccd9c64f930d34b31d 100644 (file)
@@ -67,7 +67,7 @@
  *----------------------------------------------------------*/\r
 \r
 #define configUSE_PREEMPTION                   1\r
-#define configUSE_IDLE_HOOK                            0\r
+#define configUSE_IDLE_HOOK                            1\r
 #define configUSE_TICK_HOOK                            1\r
 #define configCPU_CLOCK_HZ                             ( 32000000UL )  \r
 #define configTICK_RATE_HZ                             ( ( portTickType ) 1000 )\r
index 6f8de65c3034b0653c38200177b85f224ff22b66..bcf5088254823910aec5f8880d157cb686fbcdc6 100644 (file)
       <file>\r
         <name>$PROJ_DIR$\system_and_ST_code\STM32L1xx_StdPeriph_Driver\src\stm32l1xx_gpio.c</name>\r
       </file>\r
+      <file>\r
+        <name>$PROJ_DIR$\system_and_ST_code\STM32L1xx_StdPeriph_Driver\src\stm32l1xx_pwr.c</name>\r
+      </file>\r
       <file>\r
         <name>$PROJ_DIR$\system_and_ST_code\STM32L1xx_StdPeriph_Driver\src\stm32l1xx_rcc.c</name>\r
       </file>\r
index 9329e65281736eea62aafb87ab437f94fd17f319..8dbf6daba66c9e62f020cc1182c2b7177bfa65d4 100644 (file)
@@ -367,5 +367,12 @@ void vApplicationMallocFailedHook( void )
 {\r
        for( ;; );\r
 }\r
+/*-----------------------------------------------------------*/\r
+\r
+void vApplicationIdleHook( void )\r
+{\r
+       PWR_EnterSleepMode( PWR_Regulator_ON, PWR_SLEEPEntry_WFI );\r
+}\r
+\r
 \r
 \r
index 42f771af76ac512ac305b5660a5c9bc3f119090c..fab1365c8f9f04418cd89dcdec693d3751092703 100644 (file)
@@ -1,5 +1,5 @@
 [DebugChecksum]\r
-Checksum=-72575356\r
+Checksum=818382432\r
 [DisAssemblyWindow]\r
 NumStates=_ 1\r
 State 1=_ 1\r
@@ -70,6 +70,10 @@ ShowTimeLog=1
 ShowTimeSum=0\r
 Title0=Power [mA]\r
 Setup0=0 1 0 500 2 0 4 1 0\r
+[Disassemble mode]\r
+mode=0\r
+[Breakpoints]\r
+Count=0\r
 [Log file]\r
 LoggingEnabled=_ 0\r
 LogFile=_ ""\r
@@ -77,6 +81,9 @@ Category=_ 0
 [TermIOLog]\r
 LoggingEnabled=_ 0\r
 LogFile=_ ""\r
+[Aliases]\r
+Count=0\r
+SuppressDialog=0\r
 [SWOTraceWindow]\r
 PcSampling=0\r
 InterruptLogs=0\r
@@ -96,10 +103,3 @@ Enabled=0
 Mode=3\r
 Graph=0\r
 Symbiont=0\r
-[Disassemble mode]\r
-mode=0\r
-[Breakpoints]\r
-Count=0\r
-[Aliases]\r
-Count=0\r
-SuppressDialog=0\r
index 3428edc3d640621217f126a385ccf1bc859ee5fd..0b5da45aba14d506fc72c89787261afe5f1e3366 100644 (file)
           \r
           \r
           \r
-        <Column0>364</Column0><Column1>27</Column1><Column2>27</Column2><Column3>27</Column3></ColumnWidths>\r
+        <Column0>348</Column0><Column1>27</Column1><Column2>27</Column2><Column3>27</Column3></ColumnWidths>\r
       </Workspace>\r
     <Build><ColumnWidth0>20</ColumnWidth0><ColumnWidth1>1216</ColumnWidth1><ColumnWidth2>324</ColumnWidth2><ColumnWidth3>81</ColumnWidth3></Build><TerminalIO/><Debug-Log><ColumnWidth0>20</ColumnWidth0><ColumnWidth1>1622</ColumnWidth1></Debug-Log></Static>\r
     <Windows>\r
       \r
-    <Wnd2>\r
+    <Wnd0>\r
         <Tabs>\r
           <Tab>\r
             <Identity>TabID-27630-4718</Identity>\r
             <Factory>Workspace</Factory>\r
             <Session>\r
               \r
-            <NodeDict><ExpandedNode>RTOSDemo</ExpandedNode><ExpandedNode>RTOSDemo/FreeRTOS_Source</ExpandedNode><ExpandedNode>RTOSDemo/FreeRTOS_Source/Portable</ExpandedNode><ExpandedNode>RTOSDemo/Standard_Demo_Code</ExpandedNode></NodeDict></Session>\r
+            <NodeDict><ExpandedNode>RTOSDemo</ExpandedNode><ExpandedNode>RTOSDemo/FreeRTOS_Source</ExpandedNode><ExpandedNode>RTOSDemo/FreeRTOS_Source/Portable</ExpandedNode><ExpandedNode>RTOSDemo/Standard_Demo_Code</ExpandedNode><ExpandedNode>RTOSDemo/System_and_ST_Code</ExpandedNode><ExpandedNode>RTOSDemo/System_and_ST_Code/Peripheral_Library</ExpandedNode><ExpandedNode>RTOSDemo/System_and_ST_Code/Peripheral_Library/stm32l1xx_pwr.c</ExpandedNode></NodeDict></Session>\r
           </Tab>\r
         </Tabs>\r
         \r
-      <SelectedTab>0</SelectedTab></Wnd2><Wnd3><Tabs><Tab><Identity>TabID-10002-7709</Identity><TabName>Build</TabName><Factory>Build</Factory><Session/></Tab><Tab><Identity>TabID-18437-21512</Identity><TabName>Debug Log</TabName><Factory>Debug-Log</Factory><Session/></Tab></Tabs><SelectedTab>0</SelectedTab></Wnd3></Windows>\r
+      <SelectedTab>0</SelectedTab></Wnd0><Wnd1><Tabs><Tab><Identity>TabID-10002-7709</Identity><TabName>Build</TabName><Factory>Build</Factory><Session/></Tab><Tab><Identity>TabID-18437-21512</Identity><TabName>Debug Log</TabName><Factory>Debug-Log</Factory><Session/></Tab></Tabs><SelectedTab>0</SelectedTab></Wnd1></Windows>\r
     <Editor>\r
       \r
       \r
       \r
       \r
-    <Pane><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\main.c</Filename><XPos>0</XPos><YPos>116</YPos><SelStart>4884</SelStart><SelEnd>4884</SelEnd></Tab><ActiveTab>0</ActiveTab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\Common\Minimal\GenQTest.c</Filename><XPos>0</XPos><YPos>531</YPos><SelStart>18205</SelStart><SelEnd>18238</SelEnd></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\FreeRTOSConfig.h</Filename><XPos>0</XPos><YPos>61</YPos><SelStart>4359</SelStart><SelEnd>4359</SelEnd></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\Source\portable\MemMang\heap_2.c</Filename><XPos>0</XPos><YPos>212</YPos><SelStart>9775</SelStart><SelEnd>9817</SelEnd></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\Source\portable\IAR\ARM_CM3\port.c</Filename><XPos>0</XPos><YPos>161</YPos><SelStart>7094</SelStart><SelEnd>7094</SelEnd></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\system_and_ST_code\stm32l1xx_it.c</Filename><XPos>0</XPos><YPos>45</YPos><SelStart>2244</SelStart><SelEnd>2244</SelEnd></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\Source\portable\IAR\ARM_CM3\portasm.s</Filename><XPos>0</XPos><YPos>100</YPos><SelStart>4567</SelStart><SelEnd>4567</SelEnd></Tab></Pane><ActivePane>0</ActivePane><Sizes><Pane><X>1000000</X><Y>1000000</Y></Pane></Sizes><SplitMode>1</SplitMode></Editor>\r
+    <Pane><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\main.c</Filename><XPos>0</XPos><YPos>336</YPos><SelStart>13045</SelStart><SelEnd>13045</SelEnd></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\Common\Minimal\GenQTest.c</Filename><XPos>0</XPos><YPos>531</YPos><SelStart>18205</SelStart><SelEnd>18238</SelEnd></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\FreeRTOSConfig.h</Filename><XPos>0</XPos><YPos>61</YPos><SelStart>3665</SelStart><SelEnd>3665</SelEnd></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\Source\portable\MemMang\heap_2.c</Filename><XPos>0</XPos><YPos>212</YPos><SelStart>9775</SelStart><SelEnd>9817</SelEnd></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\Source\portable\IAR\ARM_CM3\port.c</Filename><XPos>0</XPos><YPos>161</YPos><SelStart>7094</SelStart><SelEnd>7094</SelEnd></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\system_and_ST_code\stm32l1xx_it.c</Filename><XPos>0</XPos><YPos>45</YPos><SelStart>2244</SelStart><SelEnd>2244</SelEnd></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\Source\portable\IAR\ARM_CM3\portasm.s</Filename><XPos>0</XPos><YPos>100</YPos><SelStart>4567</SelStart><SelEnd>4567</SelEnd></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\system_and_ST_code\STM32L1xx_StdPeriph_Driver\src\stm32l1xx_pwr.c</Filename><XPos>0</XPos><YPos>389</YPos><SelStart>8212</SelStart><SelEnd>8230</SelEnd></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\system_and_ST_code\stm32l1xx_conf.h</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>1632</SelStart><SelEnd>1632</SelEnd></Tab><ActiveTab>8</ActiveTab></Pane><ActivePane>0</ActivePane><Sizes><Pane><X>1000000</X><Y>1000000</Y></Pane></Sizes><SplitMode>1</SplitMode></Editor>\r
     <Positions>\r
       \r
       \r
       \r
       \r
       \r
-    <Top><Row0><Sizes><Toolbar-012aae60><key>iaridepm.enu1</key></Toolbar-012aae60></Sizes></Row0><Row1><Sizes/></Row1></Top><Left><Row0><Sizes><Wnd2><Rect><Top>-2</Top><Left>-2</Left><Bottom>740</Bottom><Right>438</Right><x>-2</x><y>-2</y><xscreen>200</xscreen><yscreen>200</yscreen><sizeHorzCX>119048</sizeHorzCX><sizeHorzCY>203666</sizeHorzCY><sizeVertCX>261905</sizeVertCX><sizeVertCY>755601</sizeVertCY></Rect></Wnd2></Sizes></Row0></Left><Right><Row0><Sizes/></Row0></Right><Bottom><Row0><Sizes><Wnd3><Rect><Top>-2</Top><Left>-2</Left><Bottom>198</Bottom><Right>1682</Right><x>-2</x><y>-2</y><xscreen>1684</xscreen><yscreen>200</yscreen><sizeHorzCX>1002381</sizeHorzCX><sizeHorzCY>203666</sizeHorzCY><sizeVertCX>119048</sizeVertCX><sizeVertCY>203666</sizeVertCY></Rect></Wnd3></Sizes></Row0></Bottom><Float><Sizes/></Float></Positions>\r
+    <Top><Row0><Sizes><Toolbar-012aae60><key>iaridepm.enu1</key></Toolbar-012aae60></Sizes></Row0></Top><Left><Row0><Sizes><Wnd0><Rect><Top>-2</Top><Left>-2</Left><Bottom>740</Bottom><Right>438</Right><x>-2</x><y>-2</y><xscreen>200</xscreen><yscreen>200</yscreen><sizeHorzCX>119048</sizeHorzCX><sizeHorzCY>203666</sizeHorzCY><sizeVertCX>261905</sizeVertCX><sizeVertCY>755601</sizeVertCY></Rect></Wnd0></Sizes></Row0></Left><Right><Row0><Sizes/></Row0></Right><Bottom><Row0><Sizes><Wnd1><Rect><Top>-2</Top><Left>-2</Left><Bottom>198</Bottom><Right>1682</Right><x>-2</x><y>-2</y><xscreen>1684</xscreen><yscreen>200</yscreen><sizeHorzCX>1002381</sizeHorzCX><sizeHorzCY>203666</sizeHorzCY><sizeVertCX>119048</sizeVertCX><sizeVertCY>203666</sizeVertCY></Rect></Wnd1></Sizes></Row0></Bottom><Float><Sizes/></Float></Positions>\r
   </Desktop>\r
 </Workspace>\r
 \r
diff --git a/Demo/Cortex_STM32L152_IAR/system_and_ST_code/STM32L1xx_StdPeriph_Driver/inc/stm32l1xx_pwr.h b/Demo/Cortex_STM32L152_IAR/system_and_ST_code/STM32L1xx_StdPeriph_Driver/inc/stm32l1xx_pwr.h
new file mode 100644 (file)
index 0000000..d96aa9e
--- /dev/null
@@ -0,0 +1,208 @@
+/**\r
+  ******************************************************************************\r
+  * @file    stm32l1xx_pwr.h\r
+  * @author  MCD Application Team\r
+  * @version V1.0.0RC1\r
+  * @date    07/02/2010\r
+  * @brief   This file contains all the functions prototypes for the PWR firmware \r
+  *          library.\r
+  ******************************************************************************\r
+  * @copy\r
+  *\r
+  * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS\r
+  * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE\r
+  * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY\r
+  * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING\r
+  * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE\r
+  * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.\r
+  *\r
+  * <h2><center>&copy; COPYRIGHT 2010 STMicroelectronics</center></h2>\r
+  */ \r
+\r
+/* Define to prevent recursive inclusion -------------------------------------*/\r
+#ifndef __STM32L1xx_PWR_H\r
+#define __STM32L1xx_PWR_H\r
+\r
+#ifdef __cplusplus\r
+ extern "C" {\r
+#endif\r
+\r
+/* Includes ------------------------------------------------------------------*/\r
+#include "stm32l1xx.h"\r
+\r
+/** @addtogroup STM32L1xx_StdPeriph_Driver\r
+  * @{\r
+  */\r
+\r
+/** @addtogroup PWR\r
+  * @{\r
+  */ \r
+\r
+/** @defgroup PWR_Exported_Types\r
+  * @{\r
+  */ \r
+\r
+/**\r
+  * @}\r
+  */ \r
+\r
+/** @defgroup PWR_Exported_Constants\r
+  * @{\r
+  */ \r
+\r
+/** @defgroup PVD_detection_level \r
+  * @{\r
+  */ \r
+\r
+#define PWR_PVDLevel_0          PWR_CR_PLS_LEV0\r
+#define PWR_PVDLevel_1          PWR_CR_PLS_LEV1\r
+#define PWR_PVDLevel_2          PWR_CR_PLS_LEV2\r
+#define PWR_PVDLevel_3          PWR_CR_PLS_LEV3\r
+#define PWR_PVDLevel_4          PWR_CR_PLS_LEV4\r
+#define PWR_PVDLevel_5          PWR_CR_PLS_LEV5\r
+#define PWR_PVDLevel_6          PWR_CR_PLS_LEV6\r
+#define PWR_PVDLevel_7          PWR_CR_PLS_LEV7 /* External input analog voltage \r
+                                               (Compare internally to VREFINT) */\r
+#define IS_PWR_PVD_LEVEL(LEVEL) (((LEVEL) == PWR_PVDLevel_0) || ((LEVEL) == PWR_PVDLevel_1)|| \\r
+                                 ((LEVEL) == PWR_PVDLevel_2) || ((LEVEL) == PWR_PVDLevel_3)|| \\r
+                                 ((LEVEL) == PWR_PVDLevel_4) || ((LEVEL) == PWR_PVDLevel_5)|| \\r
+                                 ((LEVEL) == PWR_PVDLevel_6) || ((LEVEL) == PWR_PVDLevel_7))\r
+/**\r
+  * @}\r
+  */\r
+\r
+/** @defgroup WakeUp_Pins \r
+  * @{\r
+  */\r
+\r
+#define PWR_WakeUpPin_1           ((uint32_t)0x00000000)\r
+#define PWR_WakeUpPin_2           ((uint32_t)0x00000004)\r
+#define PWR_WakeUpPin_3           ((uint32_t)0x00000008)\r
+#define IS_PWR_WAKEUP_PIN(PIN) (((PIN) == PWR_WakeUpPin_1) || \\r
+                                ((PIN) == PWR_WakeUpPin_2) || \\r
+                                ((PIN) == PWR_WakeUpPin_3))\r
+/**\r
+  * @}\r
+  */\r
+\r
+  \r
+/** @defgroup Voltage_Scaling_Ranges\r
+  * @{\r
+  */\r
+\r
+#define PWR_VoltageScaling_Range1       PWR_CR_VOS_0\r
+#define PWR_VoltageScaling_Range2       PWR_CR_VOS_1\r
+#define PWR_VoltageScaling_Range3       PWR_CR_VOS\r
+\r
+#define IS_PWR_VOLTAGE_SCALING_RANGE(RANGE) (((RANGE) == PWR_VoltageScaling_Range1) || \\r
+                                             ((RANGE) == PWR_VoltageScaling_Range2) || \\r
+                                             ((RANGE) == PWR_VoltageScaling_Range3))\r
+/**\r
+  * @}\r
+  */    \r
+  \r
+/** @defgroup Regulator_state_is_Sleep_STOP_mode \r
+  * @{\r
+  */\r
+\r
+#define PWR_Regulator_ON                ((uint32_t)0x00000000)\r
+#define PWR_Regulator_LowPower          PWR_CR_LPSDSR\r
+#define IS_PWR_REGULATOR(REGULATOR) (((REGULATOR) == PWR_Regulator_ON) || \\r
+                                     ((REGULATOR) == PWR_Regulator_LowPower))\r
+/**\r
+  * @}\r
+  */\r
+\r
+/** @defgroup SLEEP_mode_entry \r
+  * @{\r
+  */\r
+\r
+#define PWR_SLEEPEntry_WFI         ((uint8_t)0x01)\r
+#define PWR_SLEEPEntry_WFE         ((uint8_t)0x02)\r
+#define IS_PWR_SLEEP_ENTRY(ENTRY) (((ENTRY) == PWR_SLEEPEntry_WFI) || ((ENTRY) == PWR_SLEEPEntry_WFE))\r
\r
+/**\r
+  * @}\r
+  */\r
+  \r
+/** @defgroup STOP_mode_entry \r
+  * @{\r
+  */\r
+\r
+#define PWR_STOPEntry_WFI         ((uint8_t)0x01)\r
+#define PWR_STOPEntry_WFE         ((uint8_t)0x02)\r
+#define IS_PWR_STOP_ENTRY(ENTRY) (((ENTRY) == PWR_STOPEntry_WFI) || ((ENTRY) == PWR_STOPEntry_WFE))\r
\r
+/**\r
+  * @}\r
+  */\r
+\r
+/** @defgroup PWR_Flag \r
+  * @{\r
+  */\r
+\r
+#define PWR_FLAG_WU               PWR_CSR_WUF\r
+#define PWR_FLAG_SB               PWR_CSR_SBF\r
+#define PWR_FLAG_PVDO             PWR_CSR_PVDO\r
+#define PWR_FLAG_VREFINTRDY       PWR_CSR_VREFINTRDYF\r
+#define PWR_FLAG_VOS              PWR_CSR_VOSF\r
+#define PWR_FLAG_REGLP            PWR_CSR_REGLPF\r
+\r
+#define IS_PWR_GET_FLAG(FLAG) (((FLAG) == PWR_FLAG_WU) || ((FLAG) == PWR_FLAG_SB) || \\r
+                               ((FLAG) == PWR_FLAG_PVDO) || ((FLAG) == PWR_FLAG_VREFINTRDY) || \\r
+                               ((FLAG) == PWR_FLAG_VOS) || ((FLAG) == PWR_FLAG_REGLP))\r
+\r
+#define IS_PWR_CLEAR_FLAG(FLAG) (((FLAG) == PWR_FLAG_WU) || ((FLAG) == PWR_FLAG_SB))\r
+/**\r
+  * @}\r
+  */\r
+\r
+/**\r
+  * @}\r
+  */\r
+\r
+/** @defgroup PWR_Exported_Macros\r
+  * @{\r
+  */\r
+\r
+/**\r
+  * @}\r
+  */\r
+\r
+/** @defgroup PWR_Exported_Functions\r
+  * @{\r
+  */\r
+\r
+void PWR_DeInit(void);\r
+void PWR_RTCAccessCmd(FunctionalState NewState);\r
+void PWR_PVDCmd(FunctionalState NewState);\r
+void PWR_PVDLevelConfig(uint32_t PWR_PVDLevel);\r
+void PWR_WakeUpPinCmd(uint32_t PWR_WakeUpPin, FunctionalState NewState);\r
+void PWR_FastWakeUpCmd(FunctionalState NewState);\r
+void PWR_UltraLowPowerCmd(FunctionalState NewState);\r
+void PWR_VoltageScalingConfig(uint32_t PWR_VoltageScaling);\r
+void PWR_EnterLowPowerRunMode(FunctionalState NewState);\r
+void PWR_EnterSleepMode(uint32_t PWR_Regulator, uint8_t PWR_SLEEPEntry);\r
+void PWR_EnterSTOPMode(uint32_t PWR_Regulator, uint8_t PWR_STOPEntry);\r
+void PWR_EnterSTANDBYMode(void);\r
+FlagStatus PWR_GetFlagStatus(uint32_t PWR_FLAG);\r
+void PWR_ClearFlag(uint32_t PWR_FLAG);\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif /* __STM32L1xx_PWR_H */\r
+/**\r
+  * @}\r
+  */\r
+\r
+/**\r
+  * @}\r
+  */\r
+\r
+/**\r
+  * @}\r
+  */\r
+\r
+/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/\r
diff --git a/Demo/Cortex_STM32L152_IAR/system_and_ST_code/STM32L1xx_StdPeriph_Driver/src/stm32l1xx_pwr.c b/Demo/Cortex_STM32L152_IAR/system_and_ST_code/STM32L1xx_StdPeriph_Driver/src/stm32l1xx_pwr.c
new file mode 100644 (file)
index 0000000..e6b8716
--- /dev/null
@@ -0,0 +1,464 @@
+/**\r
+  ******************************************************************************\r
+  * @file    stm32l1xx_pwr.c\r
+  * @author  MCD Application Team\r
+  * @version V1.0.0RC1\r
+  * @date    07/02/2010\r
+  * @brief   This file provides all the PWR firmware functions.\r
+  ******************************************************************************\r
+  * @copy\r
+  *\r
+  * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS\r
+  * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE\r
+  * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY\r
+  * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING\r
+  * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE\r
+  * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.\r
+  *\r
+  * <h2><center>&copy; COPYRIGHT 2010 STMicroelectronics</center></h2>\r
+  */ \r
+\r
+/* Includes ------------------------------------------------------------------*/\r
+#include "stm32l1xx_pwr.h"\r
+#include "stm32l1xx_rcc.h"\r
+\r
+/** @addtogroup STM32L1xx_StdPeriph_Driver\r
+  * @{\r
+  */\r
+\r
+/** @defgroup PWR \r
+  * @brief PWR driver modules\r
+  * @{\r
+  */ \r
+\r
+/** @defgroup PWR_Private_TypesDefinitions\r
+  * @{\r
+  */\r
+\r
+/**\r
+  * @}\r
+  */\r
+\r
+/** @defgroup PWR_Private_Defines\r
+  * @{\r
+  */\r
+\r
+/* --------- PWR registers bit address in the alias region ---------- */\r
+#define PWR_OFFSET               (PWR_BASE - PERIPH_BASE)\r
+\r
+/* --- CR Register ---*/\r
+\r
+/* Alias word address of DBP bit */\r
+#define CR_OFFSET                (PWR_OFFSET + 0x00)\r
+#define DBP_BitNumber            0x08\r
+#define CR_DBP_BB                (PERIPH_BB_BASE + (CR_OFFSET * 32) + (DBP_BitNumber * 4))\r
+\r
+/* Alias word address of PVDE bit */\r
+#define PVDE_BitNumber           0x04\r
+#define CR_PVDE_BB               (PERIPH_BB_BASE + (CR_OFFSET * 32) + (PVDE_BitNumber * 4))\r
+\r
+/* Alias word address of ULP bit */\r
+#define ULP_BitNumber           0x09\r
+#define CR_ULP_BB               (PERIPH_BB_BASE + (CR_OFFSET * 32) + (ULP_BitNumber * 4))\r
+\r
+/* Alias word address of FWU bit */\r
+#define FWU_BitNumber           0x0A\r
+#define CR_FWU_BB               (PERIPH_BB_BASE + (CR_OFFSET * 32) + (FWU_BitNumber * 4))\r
+\r
+/* --- CSR Register ---*/\r
+\r
+/* Alias word address of EWUP bit */\r
+#define CSR_OFFSET               (PWR_OFFSET + 0x04)\r
+#define EWUP_BitNumber           0x08\r
+#define CSR_EWUP_BB              (PERIPH_BB_BASE + (CSR_OFFSET * 32) + (EWUP_BitNumber * 4))\r
+\r
+/* ------------------ PWR registers bit mask ------------------------ */\r
+\r
+/* CR register bit mask */\r
+#define CR_DS_MASK               ((uint32_t)0xFFFFFFFC)\r
+#define CR_PLS_MASK              ((uint32_t)0xFFFFFF1F)\r
+#define CR_VOS_MASK              ((uint32_t)0xFFFFE7FF)\r
+\r
+/**\r
+  * @}\r
+  */\r
+\r
+/** @defgroup PWR_Private_Macros\r
+  * @{\r
+  */\r
+\r
+/**\r
+  * @}\r
+  */\r
+\r
+/** @defgroup PWR_Private_Variables\r
+  * @{\r
+  */\r
+\r
+/**\r
+  * @}\r
+  */\r
+\r
+/** @defgroup PWR_Private_FunctionPrototypes\r
+  * @{\r
+  */\r
+\r
+/**\r
+  * @}\r
+  */\r
+\r
+/** @defgroup PWR_Private_Functions\r
+  * @{\r
+  */\r
+\r
+/**\r
+  * @brief  Deinitializes the PWR peripheral registers to their default reset values.\r
+  * @param  None\r
+  * @retval None\r
+  */\r
+void PWR_DeInit(void)\r
+{\r
+  RCC_APB1PeriphResetCmd(RCC_APB1Periph_PWR, ENABLE);\r
+  RCC_APB1PeriphResetCmd(RCC_APB1Periph_PWR, DISABLE);\r
+}\r
+\r
+/**\r
+  * @brief  Enables or disables access to the RTC and backup registers.\r
+  * @param  NewState: new state of the access to the RTC and backup registers.\r
+  *   This parameter can be: ENABLE or DISABLE.\r
+  * @retval None\r
+  */\r
+void PWR_RTCAccessCmd(FunctionalState NewState)\r
+{\r
+  /* Check the parameters */\r
+  assert_param(IS_FUNCTIONAL_STATE(NewState));\r
+  \r
+  *(__IO uint32_t *) CR_DBP_BB = (uint32_t)NewState;\r
+}\r
+\r
+/**\r
+  * @brief  Enables or disables the Power Voltage Detector(PVD).\r
+  * @param  NewState: new state of the PVD.\r
+  *   This parameter can be: ENABLE or DISABLE.\r
+  * @retval None\r
+  */\r
+void PWR_PVDCmd(FunctionalState NewState)\r
+{\r
+  /* Check the parameters */\r
+  assert_param(IS_FUNCTIONAL_STATE(NewState));\r
+  \r
+  *(__IO uint32_t *) CR_PVDE_BB = (uint32_t)NewState;\r
+}\r
+\r
+/**\r
+  * @brief  Configures the voltage threshold detected by the Power Voltage Detector(PVD).\r
+  * @param  PWR_PVDLevel: specifies the PVD detection level\r
+  *   This parameter can be one of the following values:\r
+  *     @arg PWR_PVDLevel_0: PVD detection level set to 1.9V\r
+  *     @arg PWR_PVDLevel_1: PVD detection level set to 2.1V\r
+  *     @arg PWR_PVDLevel_2: PVD detection level set to 2.3V\r
+  *     @arg PWR_PVDLevel_3: PVD detection level set to 2.5V\r
+  *     @arg PWR_PVDLevel_4: PVD detection level set to 2.7V\r
+  *     @arg PWR_PVDLevel_5: PVD detection level set to 2.9V\r
+  *     @arg PWR_PVDLevel_6: PVD detection level set to 3.1V\r
+  *     @arg PWR_PVDLevel_7: External input analog voltage (Compare internally to VREFINT)\r
+  * @retval None\r
+  */\r
+void PWR_PVDLevelConfig(uint32_t PWR_PVDLevel)\r
+{\r
+  uint32_t tmpreg = 0;\r
+  \r
+  /* Check the parameters */\r
+  assert_param(IS_PWR_PVD_LEVEL(PWR_PVDLevel));\r
+  \r
+  tmpreg = PWR->CR;\r
+  \r
+  /* Clear PLS[7:5] bits */\r
+  tmpreg &= CR_PLS_MASK;\r
+  \r
+  /* Set PLS[7:5] bits according to PWR_PVDLevel value */\r
+  tmpreg |= PWR_PVDLevel;\r
+  \r
+  /* Store the new value */\r
+  PWR->CR = tmpreg;\r
+}\r
+\r
+/**\r
+  * @brief  Enables or disables the WakeUp Pin functionality.\r
+  * @param  PWR_WakeUpPin: specifies the WakeUpPin.\r
+  *   This parameter can be: PWR_WakeUpPin_1, PWR_WakeUpPin_2 or PWR_WakeUpPin_3.\r
+  * @param  NewState: new state of the WakeUp Pin functionality.\r
+  *   This parameter can be: ENABLE or DISABLE.\r
+  * @retval None\r
+  */\r
+void PWR_WakeUpPinCmd(uint32_t PWR_WakeUpPin, FunctionalState NewState)\r
+{\r
+  __IO uint32_t tmp = 0;\r
+  \r
+  /* Check the parameters */\r
+  assert_param(IS_PWR_WAKEUP_PIN(PWR_WakeUpPin));\r
+  \r
+  assert_param(IS_FUNCTIONAL_STATE(NewState));\r
+\r
+  tmp = CSR_EWUP_BB + PWR_WakeUpPin;\r
+  \r
+  *(__IO uint32_t *) (tmp) = (uint32_t)NewState;\r
+}\r
+\r
+/**\r
+  * @brief  Enables or disables the Fast WakeUp from Ultra Low Power mode.\r
+  * @param  NewState: new state of the Fast WakeUp  functionality.\r
+  *   This parameter can be: ENABLE or DISABLE.\r
+  * @retval None\r
+  */\r
+void PWR_FastWakeUpCmd(FunctionalState NewState)\r
+{\r
+  /* Check the parameters */\r
+  assert_param(IS_FUNCTIONAL_STATE(NewState));\r
+\r
+  *(__IO uint32_t *) CR_FWU_BB = (uint32_t)NewState;\r
+}\r
+\r
+/**\r
+  * @brief  Enables or disables the Ultra Low Power mode.\r
+  * @param  NewState: new state of the Ultra Low Power mode.\r
+  *   This parameter can be: ENABLE or DISABLE.\r
+  * @retval None\r
+  */\r
+void PWR_UltraLowPowerCmd(FunctionalState NewState)\r
+{\r
+  /* Check the parameters */\r
+  assert_param(IS_FUNCTIONAL_STATE(NewState));\r
+\r
+  *(__IO uint32_t *) CR_ULP_BB = (uint32_t)NewState;\r
+}\r
+\r
+/**\r
+  * @brief  Configures the voltage scaling range.\r
+  * @param  PWR_VoltageScaling: specifies the voltage scaling range.\r
+  *   This parameter can be:\r
+  *     @arg PWR_VoltageScaling_Range1: Voltage Scaling Range 1\r
+  *     @arg PWR_VoltageScaling_Range2: Voltage Scaling Range 2\r
+  *     @arg PWR_VoltageScaling_Range3: Voltage Scaling Range 3      \r
+  * @retval None\r
+  */\r
+void PWR_VoltageScalingConfig(uint32_t PWR_VoltageScaling)\r
+{\r
+  uint32_t tmp = 0;\r
+  \r
+  /* Check the parameters */\r
+  assert_param(IS_PWR_VOLTAGE_SCALING_RANGE(PWR_VoltageScaling));\r
+  \r
+  tmp = PWR->CR;\r
+\r
+  tmp &= CR_VOS_MASK;\r
+  tmp |= PWR_VoltageScaling;\r
+  \r
+  PWR->CR = tmp & 0xFFFFFFF3;\r
+\r
+}\r
+\r
+/**\r
+  * @brief  Enters/Exits the Low Power Run mode.\r
+  * @param  NewState: new state of the Low Power Run mode.\r
+  *   This parameter can be: ENABLE or DISABLE.\r
+  * @retval None\r
+  */\r
+void PWR_EnterLowPowerRunMode(FunctionalState NewState)\r
+{\r
+  /* Check the parameters */\r
+  assert_param(IS_FUNCTIONAL_STATE(NewState));\r
+\r
+  if (NewState != DISABLE)\r
+  {\r
+    PWR->CR |= PWR_CR_LPSDSR;\r
+    PWR->CR |= PWR_CR_LPRUN;     \r
+  }\r
+  else\r
+  {\r
+    PWR->CR &= (uint32_t)~((uint32_t)PWR_CR_LPRUN); \r
+    PWR->CR &= (uint32_t)~((uint32_t)PWR_CR_LPSDSR);  \r
+  }  \r
+}\r
+\r
+/**\r
+  * @brief  Enters Sleep mode.\r
+  * @param  PWR_Regulator: specifies the regulator state in Sleep mode.\r
+  *   This parameter can be one of the following values:\r
+  *     @arg PWR_Regulator_ON: Sleep mode with regulator ON\r
+  *     @arg PWR_Regulator_LowPower: Sleep mode with regulator in low power mode\r
+  * @param  PWR_SLEEPEntry: specifies if SLEEP mode in entered with WFI or WFE instruction.\r
+  *   This parameter can be one of the following values:\r
+  *     @arg PWR_SLEEPEntry_WFI: enter SLEEP mode with WFI instruction\r
+  *     @arg PWR_SLEEPEntry_WFE: enter SLEEP mode with WFE instruction\r
+  * @retval None\r
+  */\r
+void PWR_EnterSleepMode(uint32_t PWR_Regulator, uint8_t PWR_SLEEPEntry)\r
+{\r
+  uint32_t tmpreg = 0;\r
+\r
+  /* Check the parameters */\r
+  assert_param(IS_PWR_REGULATOR(PWR_Regulator));\r
+\r
+  assert_param(IS_PWR_SLEEP_ENTRY(PWR_SLEEPEntry));\r
+  \r
+  /* Select the regulator state in Sleep mode ---------------------------------*/\r
+  tmpreg = PWR->CR;\r
+  \r
+  /* Clear PDDS and LPDSR bits */\r
+  tmpreg &= CR_DS_MASK;\r
+  \r
+  /* Set LPDSR bit according to PWR_Regulator value */\r
+  tmpreg |= PWR_Regulator;\r
+  \r
+  /* Store the new value */\r
+  PWR->CR = tmpreg;\r
+\r
+  /* Clear SLEEPDEEP bit of Cortex System Control Register */\r
+  SCB->SCR &= (uint32_t)~((uint32_t)SCB_SCR_SLEEPDEEP);\r
+  \r
+  /* Select SLEEP mode entry -------------------------------------------------*/\r
+  if(PWR_SLEEPEntry == PWR_SLEEPEntry_WFI)\r
+  {   \r
+    /* Request Wait For Interrupt */\r
+    __WFI();\r
+  }\r
+  else\r
+  {\r
+    /* Request Wait For Event */\r
+    __WFE();\r
+  }\r
+}\r
+\r
+/**\r
+  * @brief  Enters STOP mode.\r
+  * @param  PWR_Regulator: specifies the regulator state in STOP mode.\r
+  *   This parameter can be one of the following values:\r
+  *     @arg PWR_Regulator_ON: STOP mode with regulator ON\r
+  *     @arg PWR_Regulator_LowPower: STOP mode with regulator in low power mode\r
+  * @param  PWR_STOPEntry: specifies if STOP mode in entered with WFI or WFE instruction.\r
+  *   This parameter can be one of the following values:\r
+  *     @arg PWR_STOPEntry_WFI: enter STOP mode with WFI instruction\r
+  *     @arg PWR_STOPEntry_WFE: enter STOP mode with WFE instruction\r
+  * @retval None\r
+  */\r
+void PWR_EnterSTOPMode(uint32_t PWR_Regulator, uint8_t PWR_STOPEntry)\r
+{\r
+  uint32_t tmpreg = 0;\r
+  \r
+  /* Check the parameters */\r
+  assert_param(IS_PWR_REGULATOR(PWR_Regulator));\r
+  assert_param(IS_PWR_STOP_ENTRY(PWR_STOPEntry));\r
+  \r
+  /* Select the regulator state in STOP mode ---------------------------------*/\r
+  tmpreg = PWR->CR;\r
+  /* Clear PDDS and LPDSR bits */\r
+  tmpreg &= CR_DS_MASK;\r
+  \r
+  /* Set LPDSR bit according to PWR_Regulator value */\r
+  tmpreg |= PWR_Regulator;\r
+  \r
+  /* Store the new value */\r
+  PWR->CR = tmpreg;\r
+  \r
+  /* Set SLEEPDEEP bit of Cortex System Control Register */\r
+  SCB->SCR |= SCB_SCR_SLEEPDEEP;\r
+  \r
+  /* Select STOP mode entry --------------------------------------------------*/\r
+  if(PWR_STOPEntry == PWR_STOPEntry_WFI)\r
+  {   \r
+    /* Request Wait For Interrupt */\r
+    __WFI();\r
+  }\r
+  else\r
+  {\r
+    /* Request Wait For Event */\r
+    __WFE();\r
+  }\r
+  /* Reset SLEEPDEEP bit of Cortex System Control Register */\r
+  SCB->SCR &= (uint32_t)~((uint32_t)SCB_SCR_SLEEPDEEP);  \r
+}\r
+\r
+/**\r
+  * @brief  Enters STANDBY mode.\r
+  * @param  None\r
+  * @retval None\r
+  */\r
+void PWR_EnterSTANDBYMode(void)\r
+{\r
+  /* Clear Wake-up flag */\r
+  PWR->CR |= PWR_CR_CWUF;\r
+  \r
+  /* Select STANDBY mode */\r
+  PWR->CR |= PWR_CR_PDDS;\r
+  \r
+  /* Set SLEEPDEEP bit of Cortex System Control Register */\r
+  SCB->SCR |= SCB_SCR_SLEEPDEEP;\r
+  \r
+/* This option is used to ensure that store operations are completed */\r
+#if defined ( __CC_ARM   )\r
+  __force_stores();\r
+#endif\r
+  /* Request Wait For Interrupt */\r
+  __WFI();\r
+}\r
+\r
+/**\r
+  * @brief  Checks whether the specified PWR flag is set or not.\r
+  * @param  PWR_FLAG: specifies the flag to check.\r
+  *   This parameter can be one of the following values:\r
+  *     @arg PWR_FLAG_WU: Wake Up flag\r
+  *     @arg PWR_FLAG_SB: StandBy flag\r
+  *     @arg PWR_FLAG_PVDO: PVD Output\r
+  *     @arg PWR_FLAG_VREFINTRDY: Internal Voltage Reference Ready flag\r
+  *     @arg PWR_FLAG_VOS: Voltage Scaling select flag\r
+  *     @arg PWR_FLAG_REGLP: Regulator LP flag        \r
+  * @retval The new state of PWR_FLAG (SET or RESET).\r
+  */\r
+FlagStatus PWR_GetFlagStatus(uint32_t PWR_FLAG)\r
+{\r
+  FlagStatus bitstatus = RESET;\r
+  /* Check the parameters */\r
+  assert_param(IS_PWR_GET_FLAG(PWR_FLAG));\r
+  \r
+  if ((PWR->CSR & PWR_FLAG) != (uint32_t)RESET)\r
+  {\r
+    bitstatus = SET;\r
+  }\r
+  else\r
+  {\r
+    bitstatus = RESET;\r
+  }\r
+  /* Return the flag status */\r
+  return bitstatus;\r
+}\r
+\r
+/**\r
+  * @brief  Clears the PWR's pending flags.\r
+  * @param  PWR_FLAG: specifies the flag to clear.\r
+  *   This parameter can be one of the following values:\r
+  *     @arg PWR_FLAG_WU: Wake Up flag\r
+  *     @arg PWR_FLAG_SB: StandBy flag\r
+  * @retval None\r
+  */\r
+void PWR_ClearFlag(uint32_t PWR_FLAG)\r
+{\r
+  /* Check the parameters */\r
+  assert_param(IS_PWR_CLEAR_FLAG(PWR_FLAG));\r
+         \r
+  PWR->CR |=  PWR_FLAG << 2;\r
+}\r
+\r
+/**\r
+  * @}\r
+  */\r
+\r
+/**\r
+  * @}\r
+  */\r
+\r
+/**\r
+  * @}\r
+  */\r
+\r
+/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/\r
index aa6693d8b9fab3018fbfa94a78c185417c8fa2d3..cd79da065e4fb40f400af445de02d8267ebea897 100644 (file)
@@ -37,7 +37,7 @@
 /* #include "stm32l1xx_i2c.h" */\r
 /* #include "stm32l1xx_iwdg.h" */\r
 /* #include "stm32l1xx_lcd.h" */\r
-/* #include "stm32l1xx_pwr.h" */\r
+#include "stm32l1xx_pwr.h"\r
 #include "stm32l1xx_rcc.h"\r
 /* #include "stm32l1xx_rtc.h" */\r
 #include "stm32l1xx_spi.h"\r