2 ******************************************************************************
3 * @file stm32f0xx_hal_pwr_ex.h
4 * @author MCD Application Team
6 * @date 11-December-2014
7 * @brief Header file of PWR HAL Extension module.
8 ******************************************************************************
11 * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
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.
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.
35 ******************************************************************************
38 /* Define to prevent recursive inclusion -------------------------------------*/
39 #ifndef __STM32F0xx_HAL_PWR_EX_H
40 #define __STM32F0xx_HAL_PWR_EX_H
46 /* Includes ------------------------------------------------------------------*/
47 #include "stm32f0xx_hal_def.h"
49 /** @addtogroup STM32F0xx_HAL_Driver
57 /* Exported types ------------------------------------------------------------*/
59 /** @defgroup PWREx_Exported_Types PWREx Exported Types
63 #if defined (STM32F031x6) || defined (STM32F042x6) || defined (STM32F051x8) || \
64 defined (STM32F071xB) || defined (STM32F072xB) || \
68 * @brief PWR PVD configuration structure definition
72 uint32_t PVDLevel; /*!< PVDLevel: Specifies the PVD detection level
73 This parameter can be a value of @ref PWREx_PVD_detection_level */
75 uint32_t Mode; /*!< Mode: Specifies the operating mode for the selected pins.
76 This parameter can be a value of @ref PWREx_PVD_Mode */
79 #endif /* defined (STM32F031x6) || defined (STM32F042x6) || defined (STM32F051x8) || */
80 /* defined (STM32F071xB) || defined (STM32F072xB) || */
81 /* defined (STM32F091xC) */
85 /* Exported constants --------------------------------------------------------*/
87 /** @defgroup PWREx_Exported_Constants PWREx Exported Constants
92 /** @defgroup PWREx_WakeUp_Pins PWREx Wakeup Pins
95 #if defined (STM32F071xB) || defined (STM32F072xB) || defined (STM32F078xx) || defined (STM32F070xB) || \
96 defined (STM32F091xC) || defined (STM32F098xx) || defined (STM32F030xC)
97 #define PWR_WAKEUP_PIN1 ((uint32_t)0x00)
98 #define PWR_WAKEUP_PIN2 ((uint32_t)0x01)
99 #define PWR_WAKEUP_PIN3 ((uint32_t)0x02)
100 #define PWR_WAKEUP_PIN4 ((uint32_t)0x03)
101 #define PWR_WAKEUP_PIN5 ((uint32_t)0x04)
102 #define PWR_WAKEUP_PIN6 ((uint32_t)0x05)
103 #define PWR_WAKEUP_PIN7 ((uint32_t)0x06)
104 #define PWR_WAKEUP_PIN8 ((uint32_t)0x07)
106 #define IS_PWR_WAKEUP_PIN(PIN) (((PIN) == PWR_WAKEUP_PIN1) || \
107 ((PIN) == PWR_WAKEUP_PIN2) || \
108 ((PIN) == PWR_WAKEUP_PIN3) || \
109 ((PIN) == PWR_WAKEUP_PIN4) || \
110 ((PIN) == PWR_WAKEUP_PIN5) || \
111 ((PIN) == PWR_WAKEUP_PIN6) || \
112 ((PIN) == PWR_WAKEUP_PIN7) || \
113 ((PIN) == PWR_WAKEUP_PIN8))
115 #define PWR_WAKEUP_PIN1 ((uint32_t)0x00)
116 #define PWR_WAKEUP_PIN2 ((uint32_t)0x01)
118 #define IS_PWR_WAKEUP_PIN(PIN) (((PIN) == PWR_WAKEUP_PIN1) || \
119 ((PIN) == PWR_WAKEUP_PIN2))
120 #endif /* defined (STM32F071xB) || defined (STM32F072xB) || defined (STM32F078xx) || defined (STM32F070xB) || */
121 /* defined (STM32F091xC) || defined (STM32F098xx) || defined (STM32F030xC) */
126 /** @defgroup PWREx_EXTI_Line PWREx EXTI Line
129 #if defined (STM32F031x6) || defined (STM32F042x6) || defined (STM32F051x8) || \
130 defined (STM32F071xB) || defined (STM32F072xB) || \
131 defined (STM32F091xC)
133 #define PWR_EXTI_LINE_PVD ((uint32_t)0x00010000) /*!< External interrupt line 16 Connected to the PVD EXTI Line */
135 #endif /* defined (STM32F031x6) || defined (STM32F042x6) || defined (STM32F051x8) || */
136 /* defined (STM32F071xB) || defined (STM32F072xB) || */
137 /* defined (STM32F091xC) */
139 #if defined (STM32F042x6) || defined (STM32F048xx) || \
140 defined (STM32F071xB) || defined (STM32F072xB) || defined (STM32F078xx) || \
141 defined (STM32F091xC) || defined (STM32F098xx)
143 #define PWR_EXTI_LINE_VDDIO2 ((uint32_t)0x80000000) /*!< External interrupt line 31 Connected to the Vddio2 Monitor EXTI Line */
145 #endif /* defined (STM32F042x6) || defined (STM32F048xx) ||\
146 defined (STM32F071xB) || defined (STM32F072xB) || defined (STM32F078xx) || \
147 defined (STM32F091xC) || defined (STM32F098xx) ||*/
152 #if defined (STM32F031x6) || defined (STM32F042x6) || defined (STM32F051x8) || \
153 defined (STM32F071xB) || defined (STM32F072xB) || \
154 defined (STM32F091xC)
155 /** @defgroup PWREx_PVD_detection_level PWREx PVD detection level
158 #define PWR_PVDLEVEL_0 PWR_CR_PLS_LEV0
159 #define PWR_PVDLEVEL_1 PWR_CR_PLS_LEV1
160 #define PWR_PVDLEVEL_2 PWR_CR_PLS_LEV2
161 #define PWR_PVDLEVEL_3 PWR_CR_PLS_LEV3
162 #define PWR_PVDLEVEL_4 PWR_CR_PLS_LEV4
163 #define PWR_PVDLEVEL_5 PWR_CR_PLS_LEV5
164 #define PWR_PVDLEVEL_6 PWR_CR_PLS_LEV6
165 #define PWR_PVDLEVEL_7 PWR_CR_PLS_LEV7
166 #define IS_PWR_PVD_LEVEL(LEVEL) (((LEVEL) == PWR_PVDLEVEL_0) || ((LEVEL) == PWR_PVDLEVEL_1)|| \
167 ((LEVEL) == PWR_PVDLEVEL_2) || ((LEVEL) == PWR_PVDLEVEL_3)|| \
168 ((LEVEL) == PWR_PVDLEVEL_4) || ((LEVEL) == PWR_PVDLEVEL_5)|| \
169 ((LEVEL) == PWR_PVDLEVEL_6) || ((LEVEL) == PWR_PVDLEVEL_7))
174 /** @defgroup PWREx_PVD_Mode PWREx PVD Mode
177 #define PWR_PVD_MODE_NORMAL ((uint32_t)0x00000000) /*!< basic mode is used */
178 #define PWR_PVD_MODE_IT_RISING ((uint32_t)0x00010001) /*!< External Interrupt Mode with Rising edge trigger detection */
179 #define PWR_PVD_MODE_IT_FALLING ((uint32_t)0x00010002) /*!< External Interrupt Mode with Falling edge trigger detection */
180 #define PWR_PVD_MODE_IT_RISING_FALLING ((uint32_t)0x00010003) /*!< External Interrupt Mode with Rising/Falling edge trigger detection */
181 #define PWR_PVD_MODE_EVENT_RISING ((uint32_t)0x00020001) /*!< Event Mode with Rising edge trigger detection */
182 #define PWR_PVD_MODE_EVENT_FALLING ((uint32_t)0x00020002) /*!< Event Mode with Falling edge trigger detection */
183 #define PWR_PVD_MODE_EVENT_RISING_FALLING ((uint32_t)0x00020003) /*!< Event Mode with Rising/Falling edge trigger detection */
185 #define IS_PWR_PVD_MODE(MODE) (((MODE) == PWR_PVD_MODE_IT_RISING)|| ((MODE) == PWR_PVD_MODE_IT_FALLING) || \
186 ((MODE) == PWR_PVD_MODE_IT_RISING_FALLING) || ((MODE) == PWR_PVD_MODE_EVENT_RISING) || \
187 ((MODE) == PWR_PVD_MODE_EVENT_FALLING) || ((MODE) == PWR_PVD_MODE_EVENT_RISING_FALLING) || \
188 ((MODE) == PWR_PVD_MODE_NORMAL))
192 #endif /* defined (STM32F031x6) || defined (STM32F042x6) || defined (STM32F051x8) || */
193 /* defined (STM32F071xB) || defined (STM32F072xB) || */
194 /* defined (STM32F091xC) */
196 /** @defgroup PWREx_Flag PWREx Flag
199 #if defined (STM32F031x6) || defined (STM32F042x6) || defined (STM32F051x8) || \
200 defined (STM32F071xB) || defined (STM32F072xB) || \
201 defined (STM32F091xC)
203 #define PWR_FLAG_WU PWR_CSR_WUF
204 #define PWR_FLAG_SB PWR_CSR_SBF
205 #define PWR_FLAG_PVDO PWR_CSR_PVDO
206 #define PWR_FLAG_VREFINTRDY PWR_CSR_VREFINTRDYF
207 #elif defined (STM32F070x6) || defined (STM32F070xB) || defined (STM32F030xC)
208 #define PWR_FLAG_WU PWR_CSR_WUF
209 #define PWR_FLAG_SB PWR_CSR_SBF
210 #define PWR_FLAG_VREFINTRDY PWR_CSR_VREFINTRDYF
212 #define PWR_FLAG_WU PWR_CSR_WUF
213 #define PWR_FLAG_SB PWR_CSR_SBF
215 #endif /* defined (STM32F031x6) || defined (STM32F042x6) || defined (STM32F051x8) || */
216 /* defined (STM32F071xB) || defined (STM32F072xB) || */
217 /* defined (STM32F091xC) */
226 /* Exported macro ------------------------------------------------------------*/
227 /** @defgroup PWREx_Exported_Macros PWREx Exported Macros
230 #if defined (STM32F031x6) || defined (STM32F042x6) || defined (STM32F051x8) || \
231 defined (STM32F071xB) || defined (STM32F072xB) || \
232 defined (STM32F091xC)
234 * @brief Enable interrupt on PVD Exti Line 16.
237 #define __HAL_PWR_PVD_EXTI_ENABLE_IT() (EXTI->IMR |= (PWR_EXTI_LINE_PVD))
240 * @brief Disable interrupt on PVD Exti Line 16.
243 #define __HAL_PWR_PVD_EXTI_DISABLE_IT() (EXTI->IMR &= ~(PWR_EXTI_LINE_PVD))
246 * @brief Enable event on PVD Exti Line 16.
249 #define __HAL_PWR_PVD_EXTI_ENABLE_EVENT() (EXTI->EMR |= (PWR_EXTI_LINE_PVD))
252 * @brief Disable event on PVD Exti Line 16.
255 #define __HAL_PWR_PVD_EXTI_DISABLE_EVENT() (EXTI->EMR &= ~(PWR_EXTI_LINE_PVD))
258 * @brief PVD EXTI line configuration: clear falling edge and rising edge trigger.
261 #define __HAL_PWR_PVD_EXTI_CLEAR_EGDE_TRIGGER() EXTI->FTSR &= ~(PWR_EXTI_LINE_PVD); \
262 EXTI->RTSR &= ~(PWR_EXTI_LINE_PVD)
265 * @brief PVD EXTI line configuration: set falling edge trigger.
268 #define __HAL_PWR_PVD_EXTI_SET_FALLING_EGDE_TRIGGER() EXTI->FTSR |= (PWR_EXTI_LINE_PVD)
271 * @brief PVD EXTI line configuration: set rising edge trigger.
274 #define __HAL_PWR_PVD_EXTI_SET_RISING_EDGE_TRIGGER() EXTI->RTSR |= (PWR_EXTI_LINE_PVD)
277 * @brief Check whether the specified PVD EXTI interrupt flag is set or not.
278 * @retval EXTI PVD Line Status.
280 #define __HAL_PWR_PVD_EXTI_GET_FLAG() (EXTI->PR & (PWR_EXTI_LINE_PVD))
283 * @brief Clear the PVD EXTI flag.
286 #define __HAL_PWR_PVD_EXTI_CLEAR_FLAG() (EXTI->PR = (PWR_EXTI_LINE_PVD))
289 * @brief Generate a Software interrupt on selected EXTI line.
292 #define __HAL_PWR_PVD_EXTI_GENERATE_SWIT() (EXTI->SWIER |= (PWR_EXTI_LINE_PVD))
294 #endif /* defined (STM32F031x6) || defined (STM32F042x6) || defined (STM32F051x8) || */
295 /* defined (STM32F071xB) || defined (STM32F072xB) || */
296 /* defined (STM32F091xC) */
299 #if defined (STM32F042x6) || defined (STM32F048xx) || \
300 defined (STM32F071xB) || defined (STM32F072xB) || defined (STM32F078xx) || \
301 defined (STM32F091xC) || defined (STM32F098xx)
303 * @brief Enable interrupt on Vddio2 Monitor Exti Line 31.
306 #define __HAL_PWR_VDDIO2_EXTI_ENABLE_IT() (EXTI->IMR |= (PWR_EXTI_LINE_VDDIO2))
309 * @brief Disable interrupt on Vddio2 Monitor Exti Line 31.
312 #define __HAL_PWR_VDDIO2_EXTI_DISABLE_IT() (EXTI->IMR &= ~(PWR_EXTI_LINE_VDDIO2))
315 * @brief Vddio2 Monitor EXTI line configuration: clear falling edge and rising edge trigger.
318 #define __HAL_PWR_VDDIO2_EXTI_CLEAR_EGDE_TRIGGER() EXTI->FTSR &= ~(PWR_EXTI_LINE_VDDIO2); \
319 EXTI->RTSR &= ~(PWR_EXTI_LINE_VDDIO2)
322 * @brief Vddio2 Monitor EXTI line configuration: set falling edge trigger.
325 #define __HAL_PWR_VDDIO2_EXTI_SET_FALLING_EGDE_TRIGGER() EXTI->FTSR |= (PWR_EXTI_LINE_VDDIO2)
328 * @brief Check whether the specified VDDIO2 monitor EXTI interrupt flag is set or not.
329 * @retval EXTI VDDIO2 Monitor Line Status.
331 #define __HAL_PWR_VDDIO2_EXTI_GET_FLAG() (EXTI->PR & (PWR_EXTI_LINE_VDDIO2))
334 * @brief Clear the VDDIO2 Monitor EXTI flag.
337 #define __HAL_PWR_VDDIO2_EXTI_CLEAR_FLAG() (EXTI->PR = (PWR_EXTI_LINE_VDDIO2))
340 * @brief Generate a Software interrupt on selected EXTI line.
343 #define __HAL_PWR_VDDIO2_EXTI_GENERATE_SWIT() (EXTI->SWIER |= (PWR_EXTI_LINE_VDDIO2))
346 #endif /* defined (STM32F042x6) || defined (STM32F048xx) ||\
347 defined (STM32F071xB) || defined (STM32F072xB) || defined (STM32F078xx) || \
348 defined (STM32F091xC) || defined (STM32F098xx) */
354 /* Exported functions --------------------------------------------------------*/
356 /** @addtogroup PWREx_Exported_Functions PWREx Exported Functions
360 /** @addtogroup PWREx_Exported_Functions_Group1
363 /* I/O operation functions ***************************************************/
364 #if defined (STM32F031x6) || defined (STM32F042x6) || defined (STM32F051x8) || \
365 defined (STM32F071xB) || defined (STM32F072xB) || \
366 defined (STM32F091xC)
367 void HAL_PWR_PVD_IRQHandler(void);
368 void HAL_PWR_PVDCallback(void);
369 #endif /* defined (STM32F031x6) || defined (STM32F042x6) || defined (STM32F051x8) || */
370 /* defined (STM32F071xB) || defined (STM32F072xB) || */
371 /* defined (STM32F091xC) */
373 #if defined (STM32F042x6) || defined (STM32F048xx) || \
374 defined (STM32F071xB) || defined (STM32F072xB) || defined (STM32F078xx) || \
375 defined (STM32F091xC) || defined (STM32F098xx)
376 void HAL_PWR_Vddio2Monitor_IRQHandler(void);
377 void HAL_PWR_Vddio2MonitorCallback(void);
378 #endif /* defined (STM32F042x6) || defined (STM32F048xx) || \
379 defined (STM32F071xB) || defined (STM32F072xB) || defined (STM32F078xx) || \
380 defined (STM32F091xC) || defined (STM32F098xx) */
382 /* Peripheral Control functions **********************************************/
383 #if defined (STM32F031x6) || defined (STM32F042x6) || defined (STM32F051x8) || \
384 defined (STM32F071xB) || defined (STM32F072xB) || \
385 defined (STM32F091xC)
386 void HAL_PWR_PVDConfig(PWR_PVDTypeDef *sConfigPVD);
387 void HAL_PWR_EnablePVD(void);
388 void HAL_PWR_DisablePVD(void);
389 #endif /* defined (STM32F031x6) || defined (STM32F042x6) || defined (STM32F051x8) || */
390 /* defined (STM32F071xB) || defined (STM32F072xB) || */
391 /* defined (STM32F091xC) */
393 #if defined (STM32F042x6) || defined (STM32F048xx) || \
394 defined (STM32F071xB) || defined (STM32F072xB) || defined (STM32F078xx) || \
395 defined (STM32F091xC) || defined (STM32F098xx)
396 void HAL_PWR_EnableVddio2Monitor(void);
397 void HAL_PWR_DisableVddio2Monitor(void);
398 #endif /* defined (STM32F042x6) || defined (STM32F048xx) || \
399 defined (STM32F071xB) || defined (STM32F072xB) || defined (STM32F078xx) || \
400 defined (STM32F091xC) || defined (STM32F098xx) */
422 #endif /* __STM32F0xx_HAL_PWR_EX_H */
424 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/