Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | mjames | 1 | /** |
2 | ****************************************************************************** |
||
3 | * @file stm32f1xx_hal_pwr.h |
||
4 | * @author MCD Application Team |
||
5 | * @brief Header file of PWR HAL module. |
||
6 | ****************************************************************************** |
||
7 | * @attention |
||
8 | * |
||
9 | mjames | 9 | * <h2><center>© Copyright (c) 2016 STMicroelectronics. |
10 | * All rights reserved.</center></h2> |
||
2 | mjames | 11 | * |
9 | mjames | 12 | * This software component is licensed by ST under BSD 3-Clause license, |
13 | * the "License"; You may not use this file except in compliance with the |
||
14 | * License. You may obtain a copy of the License at: |
||
15 | * opensource.org/licenses/BSD-3-Clause |
||
2 | mjames | 16 | * |
17 | ****************************************************************************** |
||
18 | */ |
||
19 | |||
20 | /* Define to prevent recursive inclusion -------------------------------------*/ |
||
21 | #ifndef __STM32F1xx_HAL_PWR_H |
||
22 | #define __STM32F1xx_HAL_PWR_H |
||
23 | |||
24 | #ifdef __cplusplus |
||
25 | extern "C" { |
||
26 | #endif |
||
27 | |||
28 | /* Includes ------------------------------------------------------------------*/ |
||
29 | #include "stm32f1xx_hal_def.h" |
||
30 | |||
31 | /** @addtogroup STM32F1xx_HAL_Driver |
||
32 | * @{ |
||
33 | */ |
||
34 | |||
35 | /** @addtogroup PWR |
||
36 | * @{ |
||
37 | */ |
||
38 | |||
39 | /* Exported types ------------------------------------------------------------*/ |
||
40 | |||
41 | /** @defgroup PWR_Exported_Types PWR Exported Types |
||
42 | * @{ |
||
43 | */ |
||
44 | |||
45 | /** |
||
46 | * @brief PWR PVD configuration structure definition |
||
47 | */ |
||
48 | typedef struct |
||
49 | { |
||
50 | uint32_t PVDLevel; /*!< PVDLevel: Specifies the PVD detection level. |
||
51 | This parameter can be a value of @ref PWR_PVD_detection_level */ |
||
52 | |||
53 | uint32_t Mode; /*!< Mode: Specifies the operating mode for the selected pins. |
||
54 | This parameter can be a value of @ref PWR_PVD_Mode */ |
||
55 | }PWR_PVDTypeDef; |
||
56 | |||
57 | |||
58 | /** |
||
59 | * @} |
||
60 | */ |
||
61 | |||
62 | |||
63 | /* Internal constants --------------------------------------------------------*/ |
||
64 | |||
65 | /** @addtogroup PWR_Private_Constants |
||
66 | * @{ |
||
67 | */ |
||
68 | |||
69 | #define PWR_EXTI_LINE_PVD ((uint32_t)0x00010000) /*!< External interrupt line 16 Connected to the PVD EXTI Line */ |
||
70 | |||
71 | /** |
||
72 | * @} |
||
73 | */ |
||
74 | |||
75 | |||
76 | /* Exported constants --------------------------------------------------------*/ |
||
77 | |||
78 | /** @defgroup PWR_Exported_Constants PWR Exported Constants |
||
79 | * @{ |
||
80 | */ |
||
81 | |||
82 | /** @defgroup PWR_PVD_detection_level PWR PVD detection level |
||
83 | * @{ |
||
84 | */ |
||
85 | #define PWR_PVDLEVEL_0 PWR_CR_PLS_2V2 |
||
86 | #define PWR_PVDLEVEL_1 PWR_CR_PLS_2V3 |
||
87 | #define PWR_PVDLEVEL_2 PWR_CR_PLS_2V4 |
||
88 | #define PWR_PVDLEVEL_3 PWR_CR_PLS_2V5 |
||
89 | #define PWR_PVDLEVEL_4 PWR_CR_PLS_2V6 |
||
90 | #define PWR_PVDLEVEL_5 PWR_CR_PLS_2V7 |
||
91 | #define PWR_PVDLEVEL_6 PWR_CR_PLS_2V8 |
||
92 | #define PWR_PVDLEVEL_7 PWR_CR_PLS_2V9 |
||
93 | |||
94 | /** |
||
95 | * @} |
||
96 | */ |
||
97 | |||
98 | /** @defgroup PWR_PVD_Mode PWR PVD Mode |
||
99 | * @{ |
||
100 | */ |
||
101 | #define PWR_PVD_MODE_NORMAL 0x00000000U /*!< basic mode is used */ |
||
102 | #define PWR_PVD_MODE_IT_RISING 0x00010001U /*!< External Interrupt Mode with Rising edge trigger detection */ |
||
103 | #define PWR_PVD_MODE_IT_FALLING 0x00010002U /*!< External Interrupt Mode with Falling edge trigger detection */ |
||
104 | #define PWR_PVD_MODE_IT_RISING_FALLING 0x00010003U /*!< External Interrupt Mode with Rising/Falling edge trigger detection */ |
||
105 | #define PWR_PVD_MODE_EVENT_RISING 0x00020001U /*!< Event Mode with Rising edge trigger detection */ |
||
106 | #define PWR_PVD_MODE_EVENT_FALLING 0x00020002U /*!< Event Mode with Falling edge trigger detection */ |
||
107 | #define PWR_PVD_MODE_EVENT_RISING_FALLING 0x00020003U /*!< Event Mode with Rising/Falling edge trigger detection */ |
||
108 | |||
109 | /** |
||
110 | * @} |
||
111 | */ |
||
112 | |||
113 | |||
114 | /** @defgroup PWR_WakeUp_Pins PWR WakeUp Pins |
||
115 | * @{ |
||
116 | */ |
||
117 | |||
118 | #define PWR_WAKEUP_PIN1 PWR_CSR_EWUP |
||
119 | |||
120 | /** |
||
121 | * @} |
||
122 | */ |
||
123 | |||
124 | /** @defgroup PWR_Regulator_state_in_SLEEP_STOP_mode PWR Regulator state in SLEEP/STOP mode |
||
125 | * @{ |
||
126 | */ |
||
127 | #define PWR_MAINREGULATOR_ON 0x00000000U |
||
128 | #define PWR_LOWPOWERREGULATOR_ON PWR_CR_LPDS |
||
129 | |||
130 | /** |
||
131 | * @} |
||
132 | */ |
||
133 | |||
134 | /** @defgroup PWR_SLEEP_mode_entry PWR SLEEP mode entry |
||
135 | * @{ |
||
136 | */ |
||
137 | #define PWR_SLEEPENTRY_WFI ((uint8_t)0x01) |
||
138 | #define PWR_SLEEPENTRY_WFE ((uint8_t)0x02) |
||
139 | |||
140 | /** |
||
141 | * @} |
||
142 | */ |
||
143 | |||
144 | /** @defgroup PWR_STOP_mode_entry PWR STOP mode entry |
||
145 | * @{ |
||
146 | */ |
||
147 | #define PWR_STOPENTRY_WFI ((uint8_t)0x01) |
||
148 | #define PWR_STOPENTRY_WFE ((uint8_t)0x02) |
||
149 | |||
150 | /** |
||
151 | * @} |
||
152 | */ |
||
153 | |||
154 | /** @defgroup PWR_Flag PWR Flag |
||
155 | * @{ |
||
156 | */ |
||
157 | #define PWR_FLAG_WU PWR_CSR_WUF |
||
158 | #define PWR_FLAG_SB PWR_CSR_SBF |
||
159 | #define PWR_FLAG_PVDO PWR_CSR_PVDO |
||
160 | |||
161 | |||
162 | /** |
||
163 | * @} |
||
164 | */ |
||
165 | |||
166 | /** |
||
167 | * @} |
||
168 | */ |
||
169 | |||
170 | /* Exported macro ------------------------------------------------------------*/ |
||
171 | /** @defgroup PWR_Exported_Macros PWR Exported Macros |
||
172 | * @{ |
||
173 | */ |
||
174 | |||
175 | /** @brief Check PWR flag is set or not. |
||
176 | * @param __FLAG__: specifies the flag to check. |
||
177 | * This parameter can be one of the following values: |
||
178 | * @arg PWR_FLAG_WU: Wake Up flag. This flag indicates that a wakeup event |
||
179 | * was received from the WKUP pin or from the RTC alarm |
||
180 | * An additional wakeup event is detected if the WKUP pin is enabled |
||
181 | * (by setting the EWUP bit) when the WKUP pin level is already high. |
||
182 | * @arg PWR_FLAG_SB: StandBy flag. This flag indicates that the system was |
||
183 | * resumed from StandBy mode. |
||
184 | * @arg PWR_FLAG_PVDO: PVD Output. This flag is valid only if PVD is enabled |
||
185 | * by the HAL_PWR_EnablePVD() function. The PVD is stopped by Standby mode |
||
186 | * For this reason, this bit is equal to 0 after Standby or reset |
||
187 | * until the PVDE bit is set. |
||
188 | * @retval The new state of __FLAG__ (TRUE or FALSE). |
||
189 | */ |
||
190 | #define __HAL_PWR_GET_FLAG(__FLAG__) ((PWR->CSR & (__FLAG__)) == (__FLAG__)) |
||
191 | |||
192 | /** @brief Clear the PWR's pending flags. |
||
193 | * @param __FLAG__: specifies the flag to clear. |
||
194 | * This parameter can be one of the following values: |
||
195 | * @arg PWR_FLAG_WU: Wake Up flag |
||
196 | * @arg PWR_FLAG_SB: StandBy flag |
||
197 | */ |
||
198 | #define __HAL_PWR_CLEAR_FLAG(__FLAG__) SET_BIT(PWR->CR, ((__FLAG__) << 2)) |
||
199 | |||
200 | /** |
||
201 | * @brief Enable interrupt on PVD Exti Line 16. |
||
202 | * @retval None. |
||
203 | */ |
||
204 | #define __HAL_PWR_PVD_EXTI_ENABLE_IT() SET_BIT(EXTI->IMR, PWR_EXTI_LINE_PVD) |
||
205 | |||
206 | /** |
||
207 | * @brief Disable interrupt on PVD Exti Line 16. |
||
208 | * @retval None. |
||
209 | */ |
||
210 | #define __HAL_PWR_PVD_EXTI_DISABLE_IT() CLEAR_BIT(EXTI->IMR, PWR_EXTI_LINE_PVD) |
||
211 | |||
212 | /** |
||
213 | * @brief Enable event on PVD Exti Line 16. |
||
214 | * @retval None. |
||
215 | */ |
||
216 | #define __HAL_PWR_PVD_EXTI_ENABLE_EVENT() SET_BIT(EXTI->EMR, PWR_EXTI_LINE_PVD) |
||
217 | |||
218 | /** |
||
219 | * @brief Disable event on PVD Exti Line 16. |
||
220 | * @retval None. |
||
221 | */ |
||
222 | #define __HAL_PWR_PVD_EXTI_DISABLE_EVENT() CLEAR_BIT(EXTI->EMR, PWR_EXTI_LINE_PVD) |
||
223 | |||
224 | |||
225 | /** |
||
226 | * @brief PVD EXTI line configuration: set falling edge trigger. |
||
227 | * @retval None. |
||
228 | */ |
||
229 | #define __HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE() SET_BIT(EXTI->FTSR, PWR_EXTI_LINE_PVD) |
||
230 | |||
231 | |||
232 | /** |
||
233 | * @brief Disable the PVD Extended Interrupt Falling Trigger. |
||
234 | * @retval None. |
||
235 | */ |
||
236 | #define __HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE() CLEAR_BIT(EXTI->FTSR, PWR_EXTI_LINE_PVD) |
||
237 | |||
238 | |||
239 | /** |
||
240 | * @brief PVD EXTI line configuration: set rising edge trigger. |
||
241 | * @retval None. |
||
242 | */ |
||
243 | #define __HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE() SET_BIT(EXTI->RTSR, PWR_EXTI_LINE_PVD) |
||
244 | |||
245 | /** |
||
246 | * @brief Disable the PVD Extended Interrupt Rising Trigger. |
||
247 | * This parameter can be: |
||
248 | * @retval None. |
||
249 | */ |
||
250 | #define __HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE() CLEAR_BIT(EXTI->RTSR, PWR_EXTI_LINE_PVD) |
||
251 | |||
252 | /** |
||
253 | * @brief PVD EXTI line configuration: set rising & falling edge trigger. |
||
254 | * @retval None. |
||
255 | */ |
||
256 | #define __HAL_PWR_PVD_EXTI_ENABLE_RISING_FALLING_EDGE() __HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE();__HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE(); |
||
257 | |||
258 | /** |
||
259 | * @brief Disable the PVD Extended Interrupt Rising & Falling Trigger. |
||
260 | * This parameter can be: |
||
261 | * @retval None. |
||
262 | */ |
||
263 | #define __HAL_PWR_PVD_EXTI_DISABLE_RISING_FALLING_EDGE() __HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE();__HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE(); |
||
264 | |||
265 | |||
266 | |||
267 | /** |
||
268 | * @brief Check whether the specified PVD EXTI interrupt flag is set or not. |
||
269 | * @retval EXTI PVD Line Status. |
||
270 | */ |
||
271 | #define __HAL_PWR_PVD_EXTI_GET_FLAG() (EXTI->PR & (PWR_EXTI_LINE_PVD)) |
||
272 | |||
273 | /** |
||
274 | * @brief Clear the PVD EXTI flag. |
||
275 | * @retval None. |
||
276 | */ |
||
277 | #define __HAL_PWR_PVD_EXTI_CLEAR_FLAG() (EXTI->PR = (PWR_EXTI_LINE_PVD)) |
||
278 | |||
279 | /** |
||
280 | * @brief Generate a Software interrupt on selected EXTI line. |
||
281 | * @retval None. |
||
282 | */ |
||
283 | #define __HAL_PWR_PVD_EXTI_GENERATE_SWIT() SET_BIT(EXTI->SWIER, PWR_EXTI_LINE_PVD) |
||
284 | /** |
||
285 | * @} |
||
286 | */ |
||
287 | |||
288 | /* Private macro -------------------------------------------------------------*/ |
||
289 | /** @defgroup PWR_Private_Macros PWR Private Macros |
||
290 | * @{ |
||
291 | */ |
||
292 | #define IS_PWR_PVD_LEVEL(LEVEL) (((LEVEL) == PWR_PVDLEVEL_0) || ((LEVEL) == PWR_PVDLEVEL_1)|| \ |
||
293 | ((LEVEL) == PWR_PVDLEVEL_2) || ((LEVEL) == PWR_PVDLEVEL_3)|| \ |
||
294 | ((LEVEL) == PWR_PVDLEVEL_4) || ((LEVEL) == PWR_PVDLEVEL_5)|| \ |
||
295 | ((LEVEL) == PWR_PVDLEVEL_6) || ((LEVEL) == PWR_PVDLEVEL_7)) |
||
296 | |||
297 | |||
298 | #define IS_PWR_PVD_MODE(MODE) (((MODE) == PWR_PVD_MODE_IT_RISING)|| ((MODE) == PWR_PVD_MODE_IT_FALLING) || \ |
||
299 | ((MODE) == PWR_PVD_MODE_IT_RISING_FALLING) || ((MODE) == PWR_PVD_MODE_EVENT_RISING) || \ |
||
300 | ((MODE) == PWR_PVD_MODE_EVENT_FALLING) || ((MODE) == PWR_PVD_MODE_EVENT_RISING_FALLING) || \ |
||
301 | ((MODE) == PWR_PVD_MODE_NORMAL)) |
||
302 | |||
303 | #define IS_PWR_WAKEUP_PIN(PIN) (((PIN) == PWR_WAKEUP_PIN1)) |
||
304 | |||
305 | #define IS_PWR_REGULATOR(REGULATOR) (((REGULATOR) == PWR_MAINREGULATOR_ON) || \ |
||
306 | ((REGULATOR) == PWR_LOWPOWERREGULATOR_ON)) |
||
307 | |||
308 | #define IS_PWR_SLEEP_ENTRY(ENTRY) (((ENTRY) == PWR_SLEEPENTRY_WFI) || ((ENTRY) == PWR_SLEEPENTRY_WFE)) |
||
309 | |||
310 | #define IS_PWR_STOP_ENTRY(ENTRY) (((ENTRY) == PWR_STOPENTRY_WFI) || ((ENTRY) == PWR_STOPENTRY_WFE)) |
||
311 | |||
312 | /** |
||
313 | * @} |
||
314 | */ |
||
315 | |||
316 | |||
317 | |||
318 | /* Exported functions --------------------------------------------------------*/ |
||
319 | |||
320 | /** @addtogroup PWR_Exported_Functions PWR Exported Functions |
||
321 | * @{ |
||
322 | */ |
||
323 | |||
324 | /** @addtogroup PWR_Exported_Functions_Group1 Initialization and de-initialization functions |
||
325 | * @{ |
||
326 | */ |
||
327 | |||
328 | /* Initialization and de-initialization functions *******************************/ |
||
329 | void HAL_PWR_DeInit(void); |
||
330 | void HAL_PWR_EnableBkUpAccess(void); |
||
331 | void HAL_PWR_DisableBkUpAccess(void); |
||
332 | |||
333 | /** |
||
334 | * @} |
||
335 | */ |
||
336 | |||
337 | /** @addtogroup PWR_Exported_Functions_Group2 Peripheral Control functions |
||
338 | * @{ |
||
339 | */ |
||
340 | |||
341 | /* Peripheral Control functions ************************************************/ |
||
342 | void HAL_PWR_ConfigPVD(PWR_PVDTypeDef *sConfigPVD); |
||
343 | /* #define HAL_PWR_ConfigPVD 12*/ |
||
344 | void HAL_PWR_EnablePVD(void); |
||
345 | void HAL_PWR_DisablePVD(void); |
||
346 | |||
347 | /* WakeUp pins configuration functions ****************************************/ |
||
348 | void HAL_PWR_EnableWakeUpPin(uint32_t WakeUpPinx); |
||
349 | void HAL_PWR_DisableWakeUpPin(uint32_t WakeUpPinx); |
||
350 | |||
351 | /* Low Power modes configuration functions ************************************/ |
||
352 | void HAL_PWR_EnterSTOPMode(uint32_t Regulator, uint8_t STOPEntry); |
||
353 | void HAL_PWR_EnterSLEEPMode(uint32_t Regulator, uint8_t SLEEPEntry); |
||
354 | void HAL_PWR_EnterSTANDBYMode(void); |
||
355 | |||
356 | void HAL_PWR_EnableSleepOnExit(void); |
||
357 | void HAL_PWR_DisableSleepOnExit(void); |
||
358 | void HAL_PWR_EnableSEVOnPend(void); |
||
359 | void HAL_PWR_DisableSEVOnPend(void); |
||
360 | |||
361 | |||
362 | |||
363 | void HAL_PWR_PVD_IRQHandler(void); |
||
364 | void HAL_PWR_PVDCallback(void); |
||
365 | /** |
||
366 | * @} |
||
367 | */ |
||
368 | |||
369 | /** |
||
370 | * @} |
||
371 | */ |
||
372 | |||
373 | /** |
||
374 | * @} |
||
375 | */ |
||
376 | |||
377 | /** |
||
378 | * @} |
||
379 | */ |
||
380 | |||
381 | #ifdef __cplusplus |
||
382 | } |
||
383 | #endif |
||
384 | |||
385 | |||
386 | #endif /* __STM32F1xx_HAL_PWR_H */ |
||
387 | |||
388 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |