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