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 | mjames | 5 | * @version V1.0.4 |
6 | * @date 29-April-2016 |
||
2 | mjames | 7 | * @brief Header file of PWR HAL module. |
8 | ****************************************************************************** |
||
9 | * @attention |
||
10 | * |
||
5 | mjames | 11 | * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
2 | mjames | 12 | * |
13 | * Redistribution and use in source and binary forms, with or without modification, |
||
14 | * are permitted provided that the following conditions are met: |
||
15 | * 1. Redistributions of source code must retain the above copyright notice, |
||
16 | * this list of conditions and the following disclaimer. |
||
17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
||
18 | * this list of conditions and the following disclaimer in the documentation |
||
19 | * and/or other materials provided with the distribution. |
||
20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
||
21 | * may be used to endorse or promote products derived from this software |
||
22 | * without specific prior written permission. |
||
23 | * |
||
24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
||
25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||
26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
||
27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
||
28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
||
29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
||
30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||
31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
||
32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||
33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||
34 | * |
||
35 | ****************************************************************************** |
||
36 | */ |
||
37 | |||
38 | /* Define to prevent recursive inclusion -------------------------------------*/ |
||
39 | #ifndef __STM32F1xx_HAL_PWR_H |
||
40 | #define __STM32F1xx_HAL_PWR_H |
||
41 | |||
42 | #ifdef __cplusplus |
||
43 | extern "C" { |
||
44 | #endif |
||
45 | |||
46 | /* Includes ------------------------------------------------------------------*/ |
||
47 | #include "stm32f1xx_hal_def.h" |
||
48 | |||
49 | /** @addtogroup STM32F1xx_HAL_Driver |
||
50 | * @{ |
||
51 | */ |
||
52 | |||
53 | /** @addtogroup PWR |
||
54 | * @{ |
||
55 | */ |
||
56 | |||
57 | /* Exported types ------------------------------------------------------------*/ |
||
58 | |||
59 | /** @defgroup PWR_Exported_Types PWR Exported Types |
||
60 | * @{ |
||
61 | */ |
||
62 | |||
63 | /** |
||
64 | * @brief PWR PVD configuration structure definition |
||
65 | */ |
||
66 | typedef struct |
||
67 | { |
||
68 | uint32_t PVDLevel; /*!< PVDLevel: Specifies the PVD detection level. |
||
69 | This parameter can be a value of @ref PWR_PVD_detection_level */ |
||
70 | |||
71 | uint32_t Mode; /*!< Mode: Specifies the operating mode for the selected pins. |
||
72 | This parameter can be a value of @ref PWR_PVD_Mode */ |
||
73 | }PWR_PVDTypeDef; |
||
74 | |||
75 | |||
76 | /** |
||
77 | * @} |
||
78 | */ |
||
79 | |||
80 | |||
81 | /* Internal constants --------------------------------------------------------*/ |
||
82 | |||
83 | /** @addtogroup PWR_Private_Constants |
||
84 | * @{ |
||
85 | */ |
||
86 | |||
87 | #define PWR_EXTI_LINE_PVD ((uint32_t)0x00010000) /*!< External interrupt line 16 Connected to the PVD EXTI Line */ |
||
88 | |||
89 | /** |
||
90 | * @} |
||
91 | */ |
||
92 | |||
93 | |||
94 | /* Exported constants --------------------------------------------------------*/ |
||
95 | |||
96 | /** @defgroup PWR_Exported_Constants PWR Exported Constants |
||
97 | * @{ |
||
98 | */ |
||
99 | |||
100 | /** @defgroup PWR_PVD_detection_level PWR PVD detection level |
||
101 | * @{ |
||
102 | */ |
||
103 | #define PWR_PVDLEVEL_0 PWR_CR_PLS_2V2 |
||
104 | #define PWR_PVDLEVEL_1 PWR_CR_PLS_2V3 |
||
105 | #define PWR_PVDLEVEL_2 PWR_CR_PLS_2V4 |
||
106 | #define PWR_PVDLEVEL_3 PWR_CR_PLS_2V5 |
||
107 | #define PWR_PVDLEVEL_4 PWR_CR_PLS_2V6 |
||
108 | #define PWR_PVDLEVEL_5 PWR_CR_PLS_2V7 |
||
109 | #define PWR_PVDLEVEL_6 PWR_CR_PLS_2V8 |
||
110 | #define PWR_PVDLEVEL_7 PWR_CR_PLS_2V9 |
||
111 | |||
112 | /** |
||
113 | * @} |
||
114 | */ |
||
115 | |||
116 | /** @defgroup PWR_PVD_Mode PWR PVD Mode |
||
117 | * @{ |
||
118 | */ |
||
119 | #define PWR_PVD_MODE_NORMAL ((uint32_t)0x00000000) /*!< basic mode is used */ |
||
120 | #define PWR_PVD_MODE_IT_RISING ((uint32_t)0x00010001) /*!< External Interrupt Mode with Rising edge trigger detection */ |
||
121 | #define PWR_PVD_MODE_IT_FALLING ((uint32_t)0x00010002) /*!< External Interrupt Mode with Falling edge trigger detection */ |
||
122 | #define PWR_PVD_MODE_IT_RISING_FALLING ((uint32_t)0x00010003) /*!< External Interrupt Mode with Rising/Falling edge trigger detection */ |
||
123 | #define PWR_PVD_MODE_EVENT_RISING ((uint32_t)0x00020001) /*!< Event Mode with Rising edge trigger detection */ |
||
124 | #define PWR_PVD_MODE_EVENT_FALLING ((uint32_t)0x00020002) /*!< Event Mode with Falling edge trigger detection */ |
||
125 | #define PWR_PVD_MODE_EVENT_RISING_FALLING ((uint32_t)0x00020003) /*!< Event Mode with Rising/Falling edge trigger detection */ |
||
126 | |||
127 | /** |
||
128 | * @} |
||
129 | */ |
||
130 | |||
131 | |||
132 | /** @defgroup PWR_WakeUp_Pins PWR WakeUp Pins |
||
133 | * @{ |
||
134 | */ |
||
135 | |||
136 | #define PWR_WAKEUP_PIN1 PWR_CSR_EWUP |
||
137 | |||
138 | /** |
||
139 | * @} |
||
140 | */ |
||
141 | |||
142 | /** @defgroup PWR_Regulator_state_in_SLEEP_STOP_mode PWR Regulator state in SLEEP/STOP mode |
||
143 | * @{ |
||
144 | */ |
||
145 | #define PWR_MAINREGULATOR_ON ((uint32_t)0x00000000) |
||
146 | #define PWR_LOWPOWERREGULATOR_ON PWR_CR_LPDS |
||
147 | |||
148 | /** |
||
149 | * @} |
||
150 | */ |
||
151 | |||
152 | /** @defgroup PWR_SLEEP_mode_entry PWR SLEEP mode entry |
||
153 | * @{ |
||
154 | */ |
||
155 | #define PWR_SLEEPENTRY_WFI ((uint8_t)0x01) |
||
156 | #define PWR_SLEEPENTRY_WFE ((uint8_t)0x02) |
||
157 | |||
158 | /** |
||
159 | * @} |
||
160 | */ |
||
161 | |||
162 | /** @defgroup PWR_STOP_mode_entry PWR STOP mode entry |
||
163 | * @{ |
||
164 | */ |
||
165 | #define PWR_STOPENTRY_WFI ((uint8_t)0x01) |
||
166 | #define PWR_STOPENTRY_WFE ((uint8_t)0x02) |
||
167 | |||
168 | /** |
||
169 | * @} |
||
170 | */ |
||
171 | |||
172 | /** @defgroup PWR_Flag PWR Flag |
||
173 | * @{ |
||
174 | */ |
||
175 | #define PWR_FLAG_WU PWR_CSR_WUF |
||
176 | #define PWR_FLAG_SB PWR_CSR_SBF |
||
177 | #define PWR_FLAG_PVDO PWR_CSR_PVDO |
||
178 | |||
179 | |||
180 | /** |
||
181 | * @} |
||
182 | */ |
||
183 | |||
184 | /** |
||
185 | * @} |
||
186 | */ |
||
187 | |||
188 | /* Exported macro ------------------------------------------------------------*/ |
||
189 | /** @defgroup PWR_Exported_Macros PWR Exported Macros |
||
190 | * @{ |
||
191 | */ |
||
192 | |||
193 | /** @brief Check PWR flag is set or not. |
||
194 | * @param __FLAG__: specifies the flag to check. |
||
195 | * This parameter can be one of the following values: |
||
196 | * @arg PWR_FLAG_WU: Wake Up flag. This flag indicates that a wakeup event |
||
197 | * was received from the WKUP pin or from the RTC alarm |
||
198 | * An additional wakeup event is detected if the WKUP pin is enabled |
||
199 | * (by setting the EWUP bit) when the WKUP pin level is already high. |
||
200 | * @arg PWR_FLAG_SB: StandBy flag. This flag indicates that the system was |
||
201 | * resumed from StandBy mode. |
||
202 | * @arg PWR_FLAG_PVDO: PVD Output. This flag is valid only if PVD is enabled |
||
203 | * by the HAL_PWR_EnablePVD() function. The PVD is stopped by Standby mode |
||
204 | * For this reason, this bit is equal to 0 after Standby or reset |
||
205 | * until the PVDE bit is set. |
||
206 | * @retval The new state of __FLAG__ (TRUE or FALSE). |
||
207 | */ |
||
208 | #define __HAL_PWR_GET_FLAG(__FLAG__) ((PWR->CSR & (__FLAG__)) == (__FLAG__)) |
||
209 | |||
210 | /** @brief Clear the PWR's pending flags. |
||
211 | * @param __FLAG__: specifies the flag to clear. |
||
212 | * This parameter can be one of the following values: |
||
213 | * @arg PWR_FLAG_WU: Wake Up flag |
||
214 | * @arg PWR_FLAG_SB: StandBy flag |
||
215 | */ |
||
216 | #define __HAL_PWR_CLEAR_FLAG(__FLAG__) SET_BIT(PWR->CR, ((__FLAG__) << 2)) |
||
217 | |||
218 | /** |
||
219 | * @brief Enable interrupt on PVD Exti Line 16. |
||
220 | * @retval None. |
||
221 | */ |
||
222 | #define __HAL_PWR_PVD_EXTI_ENABLE_IT() SET_BIT(EXTI->IMR, PWR_EXTI_LINE_PVD) |
||
223 | |||
224 | /** |
||
225 | * @brief Disable interrupt on PVD Exti Line 16. |
||
226 | * @retval None. |
||
227 | */ |
||
228 | #define __HAL_PWR_PVD_EXTI_DISABLE_IT() CLEAR_BIT(EXTI->IMR, PWR_EXTI_LINE_PVD) |
||
229 | |||
230 | /** |
||
231 | * @brief Enable event on PVD Exti Line 16. |
||
232 | * @retval None. |
||
233 | */ |
||
234 | #define __HAL_PWR_PVD_EXTI_ENABLE_EVENT() SET_BIT(EXTI->EMR, PWR_EXTI_LINE_PVD) |
||
235 | |||
236 | /** |
||
237 | * @brief Disable event on PVD Exti Line 16. |
||
238 | * @retval None. |
||
239 | */ |
||
240 | #define __HAL_PWR_PVD_EXTI_DISABLE_EVENT() CLEAR_BIT(EXTI->EMR, PWR_EXTI_LINE_PVD) |
||
241 | |||
242 | |||
243 | /** |
||
244 | * @brief PVD EXTI line configuration: set falling edge trigger. |
||
245 | * @retval None. |
||
246 | */ |
||
247 | #define __HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE() SET_BIT(EXTI->FTSR, PWR_EXTI_LINE_PVD) |
||
248 | |||
249 | |||
250 | /** |
||
251 | * @brief Disable the PVD Extended Interrupt Falling Trigger. |
||
252 | * @retval None. |
||
253 | */ |
||
254 | #define __HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE() CLEAR_BIT(EXTI->FTSR, PWR_EXTI_LINE_PVD) |
||
255 | |||
256 | |||
257 | /** |
||
258 | * @brief PVD EXTI line configuration: set rising edge trigger. |
||
259 | * @retval None. |
||
260 | */ |
||
261 | #define __HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE() SET_BIT(EXTI->RTSR, PWR_EXTI_LINE_PVD) |
||
262 | |||
263 | /** |
||
264 | * @brief Disable the PVD Extended Interrupt Rising Trigger. |
||
265 | * This parameter can be: |
||
266 | * @retval None. |
||
267 | */ |
||
268 | #define __HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE() CLEAR_BIT(EXTI->RTSR, PWR_EXTI_LINE_PVD) |
||
269 | |||
270 | /** |
||
271 | * @brief PVD EXTI line configuration: set rising & falling edge trigger. |
||
272 | * @retval None. |
||
273 | */ |
||
274 | #define __HAL_PWR_PVD_EXTI_ENABLE_RISING_FALLING_EDGE() __HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE();__HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE(); |
||
275 | |||
276 | /** |
||
277 | * @brief Disable the PVD Extended Interrupt Rising & Falling Trigger. |
||
278 | * This parameter can be: |
||
279 | * @retval None. |
||
280 | */ |
||
281 | #define __HAL_PWR_PVD_EXTI_DISABLE_RISING_FALLING_EDGE() __HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE();__HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE(); |
||
282 | |||
283 | |||
284 | |||
285 | /** |
||
286 | * @brief Check whether the specified PVD EXTI interrupt flag is set or not. |
||
287 | * @retval EXTI PVD Line Status. |
||
288 | */ |
||
289 | #define __HAL_PWR_PVD_EXTI_GET_FLAG() (EXTI->PR & (PWR_EXTI_LINE_PVD)) |
||
290 | |||
291 | /** |
||
292 | * @brief Clear the PVD EXTI flag. |
||
293 | * @retval None. |
||
294 | */ |
||
295 | #define __HAL_PWR_PVD_EXTI_CLEAR_FLAG() (EXTI->PR = (PWR_EXTI_LINE_PVD)) |
||
296 | |||
297 | /** |
||
298 | * @brief Generate a Software interrupt on selected EXTI line. |
||
299 | * @retval None. |
||
300 | */ |
||
301 | #define __HAL_PWR_PVD_EXTI_GENERATE_SWIT() SET_BIT(EXTI->SWIER, PWR_EXTI_LINE_PVD) |
||
302 | /** |
||
303 | * @} |
||
304 | */ |
||
305 | |||
306 | /* Private macro -------------------------------------------------------------*/ |
||
307 | /** @defgroup PWR_Private_Macros PWR Private Macros |
||
308 | * @{ |
||
309 | */ |
||
310 | #define IS_PWR_PVD_LEVEL(LEVEL) (((LEVEL) == PWR_PVDLEVEL_0) || ((LEVEL) == PWR_PVDLEVEL_1)|| \ |
||
311 | ((LEVEL) == PWR_PVDLEVEL_2) || ((LEVEL) == PWR_PVDLEVEL_3)|| \ |
||
312 | ((LEVEL) == PWR_PVDLEVEL_4) || ((LEVEL) == PWR_PVDLEVEL_5)|| \ |
||
313 | ((LEVEL) == PWR_PVDLEVEL_6) || ((LEVEL) == PWR_PVDLEVEL_7)) |
||
314 | |||
315 | |||
316 | #define IS_PWR_PVD_MODE(MODE) (((MODE) == PWR_PVD_MODE_IT_RISING)|| ((MODE) == PWR_PVD_MODE_IT_FALLING) || \ |
||
317 | ((MODE) == PWR_PVD_MODE_IT_RISING_FALLING) || ((MODE) == PWR_PVD_MODE_EVENT_RISING) || \ |
||
318 | ((MODE) == PWR_PVD_MODE_EVENT_FALLING) || ((MODE) == PWR_PVD_MODE_EVENT_RISING_FALLING) || \ |
||
319 | ((MODE) == PWR_PVD_MODE_NORMAL)) |
||
320 | |||
321 | #define IS_PWR_WAKEUP_PIN(PIN) (((PIN) == PWR_WAKEUP_PIN1)) |
||
322 | |||
323 | #define IS_PWR_REGULATOR(REGULATOR) (((REGULATOR) == PWR_MAINREGULATOR_ON) || \ |
||
324 | ((REGULATOR) == PWR_LOWPOWERREGULATOR_ON)) |
||
325 | |||
326 | #define IS_PWR_SLEEP_ENTRY(ENTRY) (((ENTRY) == PWR_SLEEPENTRY_WFI) || ((ENTRY) == PWR_SLEEPENTRY_WFE)) |
||
327 | |||
328 | #define IS_PWR_STOP_ENTRY(ENTRY) (((ENTRY) == PWR_STOPENTRY_WFI) || ((ENTRY) == PWR_STOPENTRY_WFE)) |
||
329 | |||
330 | /** |
||
331 | * @} |
||
332 | */ |
||
333 | |||
334 | |||
335 | |||
336 | /* Exported functions --------------------------------------------------------*/ |
||
337 | |||
338 | /** @addtogroup PWR_Exported_Functions PWR Exported Functions |
||
339 | * @{ |
||
340 | */ |
||
341 | |||
342 | /** @addtogroup PWR_Exported_Functions_Group1 Initialization and de-initialization functions |
||
343 | * @{ |
||
344 | */ |
||
345 | |||
346 | /* Initialization and de-initialization functions *******************************/ |
||
347 | void HAL_PWR_DeInit(void); |
||
348 | void HAL_PWR_EnableBkUpAccess(void); |
||
349 | void HAL_PWR_DisableBkUpAccess(void); |
||
350 | |||
351 | /** |
||
352 | * @} |
||
353 | */ |
||
354 | |||
355 | /** @addtogroup PWR_Exported_Functions_Group2 Peripheral Control functions |
||
356 | * @{ |
||
357 | */ |
||
358 | |||
359 | /* Peripheral Control functions ************************************************/ |
||
360 | void HAL_PWR_ConfigPVD(PWR_PVDTypeDef *sConfigPVD); |
||
361 | /* #define HAL_PWR_ConfigPVD 12*/ |
||
362 | void HAL_PWR_EnablePVD(void); |
||
363 | void HAL_PWR_DisablePVD(void); |
||
364 | |||
365 | /* WakeUp pins configuration functions ****************************************/ |
||
366 | void HAL_PWR_EnableWakeUpPin(uint32_t WakeUpPinx); |
||
367 | void HAL_PWR_DisableWakeUpPin(uint32_t WakeUpPinx); |
||
368 | |||
369 | /* Low Power modes configuration functions ************************************/ |
||
370 | void HAL_PWR_EnterSTOPMode(uint32_t Regulator, uint8_t STOPEntry); |
||
371 | void HAL_PWR_EnterSLEEPMode(uint32_t Regulator, uint8_t SLEEPEntry); |
||
372 | void HAL_PWR_EnterSTANDBYMode(void); |
||
373 | |||
374 | void HAL_PWR_EnableSleepOnExit(void); |
||
375 | void HAL_PWR_DisableSleepOnExit(void); |
||
376 | void HAL_PWR_EnableSEVOnPend(void); |
||
377 | void HAL_PWR_DisableSEVOnPend(void); |
||
378 | |||
379 | |||
380 | |||
381 | void HAL_PWR_PVD_IRQHandler(void); |
||
382 | void HAL_PWR_PVDCallback(void); |
||
383 | /** |
||
384 | * @} |
||
385 | */ |
||
386 | |||
387 | /** |
||
388 | * @} |
||
389 | */ |
||
390 | |||
391 | /** |
||
392 | * @} |
||
393 | */ |
||
394 | |||
395 | /** |
||
396 | * @} |
||
397 | */ |
||
398 | |||
399 | #ifdef __cplusplus |
||
400 | } |
||
401 | #endif |
||
402 | |||
403 | |||
404 | #endif /* __STM32F1xx_HAL_PWR_H */ |
||
405 | |||
406 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |