Merge pull request #93 from zyp/master
[fw/stlink] / example / libs_stm / inc / stm32l1xx / stm32l1xx_pwr.h
1 /**\r
2   ******************************************************************************\r
3   * @file    stm32l1xx_pwr.h\r
4   * @author  MCD Application Team\r
5   * @version V1.0.0\r
6   * @date    31-December-2010\r
7   * @brief   This file contains all the functions prototypes for the PWR firmware \r
8   *          library.\r
9   ******************************************************************************\r
10   * @attention\r
11   *\r
12   * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS\r
13   * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE\r
14   * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY\r
15   * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING\r
16   * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE\r
17   * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.\r
18   *\r
19   * <h2><center>&copy; COPYRIGHT 2010 STMicroelectronics</center></h2>\r
20   ******************************************************************************  \r
21   */ \r
22 \r
23 /* Define to prevent recursive inclusion -------------------------------------*/\r
24 #ifndef __STM32L1xx_PWR_H\r
25 #define __STM32L1xx_PWR_H\r
26 \r
27 #ifdef __cplusplus\r
28  extern "C" {\r
29 #endif\r
30 \r
31 /* Includes ------------------------------------------------------------------*/\r
32 #include "stm32l1xx.h"\r
33 \r
34 /** @addtogroup STM32L1xx_StdPeriph_Driver\r
35   * @{\r
36   */\r
37 \r
38 /** @addtogroup PWR\r
39   * @{\r
40   */ \r
41 \r
42 /* Exported types ------------------------------------------------------------*/\r
43 /* Exported constants --------------------------------------------------------*/\r
44 \r
45 /** @defgroup PWR_Exported_Constants\r
46   * @{\r
47   */ \r
48 \r
49 /** @defgroup PVD_detection_level \r
50   * @{\r
51   */ \r
52 \r
53 #define PWR_PVDLevel_0                  PWR_CR_PLS_LEV0\r
54 #define PWR_PVDLevel_1                  PWR_CR_PLS_LEV1\r
55 #define PWR_PVDLevel_2                  PWR_CR_PLS_LEV2\r
56 #define PWR_PVDLevel_3                  PWR_CR_PLS_LEV3\r
57 #define PWR_PVDLevel_4                  PWR_CR_PLS_LEV4\r
58 #define PWR_PVDLevel_5                  PWR_CR_PLS_LEV5\r
59 #define PWR_PVDLevel_6                  PWR_CR_PLS_LEV6\r
60 #define PWR_PVDLevel_7                  PWR_CR_PLS_LEV7 /* External input analog voltage \r
61                                                           (Compare internally to VREFINT) */\r
62 #define IS_PWR_PVD_LEVEL(LEVEL) (((LEVEL) == PWR_PVDLevel_0) || ((LEVEL) == PWR_PVDLevel_1)|| \\r
63                                  ((LEVEL) == PWR_PVDLevel_2) || ((LEVEL) == PWR_PVDLevel_3)|| \\r
64                                  ((LEVEL) == PWR_PVDLevel_4) || ((LEVEL) == PWR_PVDLevel_5)|| \\r
65                                  ((LEVEL) == PWR_PVDLevel_6) || ((LEVEL) == PWR_PVDLevel_7))\r
66 /**\r
67   * @}\r
68   */\r
69 \r
70 /** @defgroup WakeUp_Pins \r
71   * @{\r
72   */\r
73 \r
74 #define PWR_WakeUpPin_1                 ((uint32_t)0x00000000)\r
75 #define PWR_WakeUpPin_2                 ((uint32_t)0x00000004)\r
76 #define PWR_WakeUpPin_3                 ((uint32_t)0x00000008)\r
77 #define IS_PWR_WAKEUP_PIN(PIN) (((PIN) == PWR_WakeUpPin_1) || \\r
78                                 ((PIN) == PWR_WakeUpPin_2) || \\r
79                                 ((PIN) == PWR_WakeUpPin_3))\r
80 /**\r
81   * @}\r
82   */\r
83 \r
84   \r
85 /** @defgroup Voltage_Scaling_Ranges\r
86   * @{\r
87   */\r
88 \r
89 #define PWR_VoltageScaling_Range1       PWR_CR_VOS_0\r
90 #define PWR_VoltageScaling_Range2       PWR_CR_VOS_1\r
91 #define PWR_VoltageScaling_Range3       PWR_CR_VOS\r
92 \r
93 #define IS_PWR_VOLTAGE_SCALING_RANGE(RANGE) (((RANGE) == PWR_VoltageScaling_Range1) || \\r
94                                              ((RANGE) == PWR_VoltageScaling_Range2) || \\r
95                                              ((RANGE) == PWR_VoltageScaling_Range3))\r
96 /**\r
97   * @}\r
98   */    \r
99   \r
100 /** @defgroup Regulator_state_is_Sleep_STOP_mode \r
101   * @{\r
102   */\r
103 \r
104 #define PWR_Regulator_ON                ((uint32_t)0x00000000)\r
105 #define PWR_Regulator_LowPower          PWR_CR_LPSDSR\r
106 #define IS_PWR_REGULATOR(REGULATOR) (((REGULATOR) == PWR_Regulator_ON) || \\r
107                                      ((REGULATOR) == PWR_Regulator_LowPower))\r
108 /**\r
109   * @}\r
110   */\r
111 \r
112 /** @defgroup SLEEP_mode_entry \r
113   * @{\r
114   */\r
115 \r
116 #define PWR_SLEEPEntry_WFI              ((uint8_t)0x01)\r
117 #define PWR_SLEEPEntry_WFE              ((uint8_t)0x02)\r
118 #define IS_PWR_SLEEP_ENTRY(ENTRY) (((ENTRY) == PWR_SLEEPEntry_WFI) || ((ENTRY) == PWR_SLEEPEntry_WFE))\r
119  \r
120 /**\r
121   * @}\r
122   */\r
123   \r
124 /** @defgroup STOP_mode_entry \r
125   * @{\r
126   */\r
127 \r
128 #define PWR_STOPEntry_WFI               ((uint8_t)0x01)\r
129 #define PWR_STOPEntry_WFE               ((uint8_t)0x02)\r
130 #define IS_PWR_STOP_ENTRY(ENTRY) (((ENTRY) == PWR_STOPEntry_WFI) || ((ENTRY) == PWR_STOPEntry_WFE))\r
131  \r
132 /**\r
133   * @}\r
134   */\r
135 \r
136 /** @defgroup PWR_Flag \r
137   * @{\r
138   */\r
139 \r
140 #define PWR_FLAG_WU                     PWR_CSR_WUF\r
141 #define PWR_FLAG_SB                     PWR_CSR_SBF\r
142 #define PWR_FLAG_PVDO                   PWR_CSR_PVDO\r
143 #define PWR_FLAG_VREFINTRDY             PWR_CSR_VREFINTRDYF\r
144 #define PWR_FLAG_VOS                    PWR_CSR_VOSF\r
145 #define PWR_FLAG_REGLP                  PWR_CSR_REGLPF\r
146 \r
147 #define IS_PWR_GET_FLAG(FLAG) (((FLAG) == PWR_FLAG_WU) || ((FLAG) == PWR_FLAG_SB) || \\r
148                                ((FLAG) == PWR_FLAG_PVDO) || ((FLAG) == PWR_FLAG_VREFINTRDY) || \\r
149                                ((FLAG) == PWR_FLAG_VOS) || ((FLAG) == PWR_FLAG_REGLP))\r
150 \r
151 #define IS_PWR_CLEAR_FLAG(FLAG) (((FLAG) == PWR_FLAG_WU) || ((FLAG) == PWR_FLAG_SB))\r
152 /**\r
153   * @}\r
154   */\r
155 \r
156 /**\r
157   * @}\r
158   */\r
159 \r
160 /* Exported macro ------------------------------------------------------------*/\r
161 /* Exported functions ------------------------------------------------------- */\r
162 \r
163 /* Function used to set the PWR configuration to the default reset state ******/ \r
164 void PWR_DeInit(void);\r
165 \r
166 /* RTC Domain Access function *************************************************/ \r
167 void PWR_RTCAccessCmd(FunctionalState NewState);\r
168 \r
169 /* PVD configuration functions ************************************************/ \r
170 void PWR_PVDLevelConfig(uint32_t PWR_PVDLevel);\r
171 void PWR_PVDCmd(FunctionalState NewState);\r
172 \r
173 /* WakeUp pins configuration functions ****************************************/ \r
174 void PWR_WakeUpPinCmd(uint32_t PWR_WakeUpPin, FunctionalState NewState);\r
175 \r
176 /* Ultra Low Power mode configuration functions *******************************/ \r
177 void PWR_FastWakeUpCmd(FunctionalState NewState);\r
178 void PWR_UltraLowPowerCmd(FunctionalState NewState);\r
179 \r
180 /* Voltage Scaling configuration functions ************************************/ \r
181 void PWR_VoltageScalingConfig(uint32_t PWR_VoltageScaling);\r
182 \r
183 /* Low Power modes configuration functions ************************************/ \r
184 void PWR_EnterLowPowerRunMode(FunctionalState NewState);\r
185 void PWR_EnterSleepMode(uint32_t PWR_Regulator, uint8_t PWR_SLEEPEntry);\r
186 void PWR_EnterSTOPMode(uint32_t PWR_Regulator, uint8_t PWR_STOPEntry);\r
187 void PWR_EnterSTANDBYMode(void);\r
188 \r
189 /* Flags management functions *************************************************/ \r
190 FlagStatus PWR_GetFlagStatus(uint32_t PWR_FLAG);\r
191 void PWR_ClearFlag(uint32_t PWR_FLAG);\r
192 \r
193 #ifdef __cplusplus\r
194 }\r
195 #endif\r
196 \r
197 #endif /* __STM32L1xx_PWR_H */\r
198 \r
199 /**\r
200   * @}\r
201   */\r
202 \r
203 /**\r
204   * @}\r
205   */\r
206 \r
207 /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/\r