2 ******************************************************************************
\r
3 * @file stm32l4xx_hal_pwr_ex.h
\r
4 * @author MCD Application Team
\r
5 * @brief Header file of PWR HAL Extended module.
\r
6 ******************************************************************************
\r
9 * <h2><center>© Copyright (c) 2017 STMicroelectronics.
\r
10 * All rights reserved.</center></h2>
\r
12 * This software component is licensed by ST under BSD 3-Clause license,
\r
13 * the "License"; You may not use this file except in compliance with the
\r
14 * License. You may obtain a copy of the License at:
\r
15 * opensource.org/licenses/BSD-3-Clause
\r
17 ******************************************************************************
\r
20 /* Define to prevent recursive inclusion -------------------------------------*/
\r
21 #ifndef __STM32L4xx_HAL_PWR_EX_H
\r
22 #define __STM32L4xx_HAL_PWR_EX_H
\r
28 /* Includes ------------------------------------------------------------------*/
\r
29 #include "stm32l4xx_hal_def.h"
\r
31 /** @addtogroup STM32L4xx_HAL_Driver
\r
35 /** @addtogroup PWREx
\r
40 /* Exported types ------------------------------------------------------------*/
\r
42 /** @defgroup PWREx_Exported_Types PWR Extended Exported Types
\r
48 * @brief PWR PVM configuration structure definition
\r
52 uint32_t PVMType; /*!< PVMType: Specifies which voltage is monitored and against which threshold.
\r
53 This parameter can be a value of @ref PWREx_PVM_Type.
\r
54 @arg @ref PWR_PVM_1 Peripheral Voltage Monitoring 1 enable: VDDUSB versus 1.2 V (applicable when USB feature is supported).
\r
56 @arg @ref PWR_PVM_2 Peripheral Voltage Monitoring 2 enable: VDDIO2 versus 0.9 V (applicable when VDDIO2 is present on device).
\r
58 @arg @ref PWR_PVM_3 Peripheral Voltage Monitoring 3 enable: VDDA versus 1.62 V.
\r
59 @arg @ref PWR_PVM_4 Peripheral Voltage Monitoring 4 enable: VDDA versus 2.2 V. */
\r
61 uint32_t Mode; /*!< Mode: Specifies the operating mode for the selected pins.
\r
62 This parameter can be a value of @ref PWREx_PVM_Mode. */
\r
69 /* Exported constants --------------------------------------------------------*/
\r
71 /** @defgroup PWREx_Exported_Constants PWR Extended Exported Constants
\r
75 /** @defgroup PWREx_WUP_Polarity Shift to apply to retrieve polarity information from PWR_WAKEUP_PINy_xxx constants
\r
78 #define PWR_WUP_POLARITY_SHIFT 0x05 /*!< Internal constant used to retrieve wakeup pin polariry */
\r
84 /** @defgroup PWREx_WakeUp_Pins PWR wake-up pins
\r
87 #define PWR_WAKEUP_PIN1 PWR_CR3_EWUP1 /*!< Wakeup pin 1 (with high level polarity) */
\r
88 #define PWR_WAKEUP_PIN2 PWR_CR3_EWUP2 /*!< Wakeup pin 2 (with high level polarity) */
\r
89 #define PWR_WAKEUP_PIN3 PWR_CR3_EWUP3 /*!< Wakeup pin 3 (with high level polarity) */
\r
90 #define PWR_WAKEUP_PIN4 PWR_CR3_EWUP4 /*!< Wakeup pin 4 (with high level polarity) */
\r
91 #define PWR_WAKEUP_PIN5 PWR_CR3_EWUP5 /*!< Wakeup pin 5 (with high level polarity) */
\r
92 #define PWR_WAKEUP_PIN1_HIGH PWR_CR3_EWUP1 /*!< Wakeup pin 1 (with high level polarity) */
\r
93 #define PWR_WAKEUP_PIN2_HIGH PWR_CR3_EWUP2 /*!< Wakeup pin 2 (with high level polarity) */
\r
94 #define PWR_WAKEUP_PIN3_HIGH PWR_CR3_EWUP3 /*!< Wakeup pin 3 (with high level polarity) */
\r
95 #define PWR_WAKEUP_PIN4_HIGH PWR_CR3_EWUP4 /*!< Wakeup pin 4 (with high level polarity) */
\r
96 #define PWR_WAKEUP_PIN5_HIGH PWR_CR3_EWUP5 /*!< Wakeup pin 5 (with high level polarity) */
\r
97 #define PWR_WAKEUP_PIN1_LOW (uint32_t)((PWR_CR4_WP1<<PWR_WUP_POLARITY_SHIFT) | PWR_CR3_EWUP1) /*!< Wakeup pin 1 (with low level polarity) */
\r
98 #define PWR_WAKEUP_PIN2_LOW (uint32_t)((PWR_CR4_WP2<<PWR_WUP_POLARITY_SHIFT) | PWR_CR3_EWUP2) /*!< Wakeup pin 2 (with low level polarity) */
\r
99 #define PWR_WAKEUP_PIN3_LOW (uint32_t)((PWR_CR4_WP3<<PWR_WUP_POLARITY_SHIFT) | PWR_CR3_EWUP3) /*!< Wakeup pin 3 (with low level polarity) */
\r
100 #define PWR_WAKEUP_PIN4_LOW (uint32_t)((PWR_CR4_WP4<<PWR_WUP_POLARITY_SHIFT) | PWR_CR3_EWUP4) /*!< Wakeup pin 4 (with low level polarity) */
\r
101 #define PWR_WAKEUP_PIN5_LOW (uint32_t)((PWR_CR4_WP5<<PWR_WUP_POLARITY_SHIFT) | PWR_CR3_EWUP5) /*!< Wakeup pin 5 (with low level polarity) */
\r
106 /** @defgroup PWREx_PVM_Type Peripheral Voltage Monitoring type
\r
109 #if defined(PWR_CR2_PVME1)
\r
110 #define PWR_PVM_1 PWR_CR2_PVME1 /*!< Peripheral Voltage Monitoring 1 enable: VDDUSB versus 1.2 V (applicable when USB feature is supported) */
\r
111 #endif /* PWR_CR2_PVME1 */
\r
112 #if defined(PWR_CR2_PVME2)
\r
113 #define PWR_PVM_2 PWR_CR2_PVME2 /*!< Peripheral Voltage Monitoring 2 enable: VDDIO2 versus 0.9 V (applicable when VDDIO2 is present on device) */
\r
114 #endif /* PWR_CR2_PVME2 */
\r
115 #define PWR_PVM_3 PWR_CR2_PVME3 /*!< Peripheral Voltage Monitoring 3 enable: VDDA versus 1.62 V */
\r
116 #define PWR_PVM_4 PWR_CR2_PVME4 /*!< Peripheral Voltage Monitoring 4 enable: VDDA versus 2.2 V */
\r
121 /** @defgroup PWREx_PVM_Mode PWR PVM interrupt and event mode
\r
124 #define PWR_PVM_MODE_NORMAL ((uint32_t)0x00000000) /*!< basic mode is used */
\r
125 #define PWR_PVM_MODE_IT_RISING ((uint32_t)0x00010001) /*!< External Interrupt Mode with Rising edge trigger detection */
\r
126 #define PWR_PVM_MODE_IT_FALLING ((uint32_t)0x00010002) /*!< External Interrupt Mode with Falling edge trigger detection */
\r
127 #define PWR_PVM_MODE_IT_RISING_FALLING ((uint32_t)0x00010003) /*!< External Interrupt Mode with Rising/Falling edge trigger detection */
\r
128 #define PWR_PVM_MODE_EVENT_RISING ((uint32_t)0x00020001) /*!< Event Mode with Rising edge trigger detection */
\r
129 #define PWR_PVM_MODE_EVENT_FALLING ((uint32_t)0x00020002) /*!< Event Mode with Falling edge trigger detection */
\r
130 #define PWR_PVM_MODE_EVENT_RISING_FALLING ((uint32_t)0x00020003) /*!< Event Mode with Rising/Falling edge trigger detection */
\r
137 /** @defgroup PWREx_Regulator_Voltage_Scale PWR Regulator voltage scale
\r
140 #if defined(PWR_CR5_R1MODE)
\r
141 #define PWR_REGULATOR_VOLTAGE_SCALE1_BOOST ((uint32_t)0x00000000) /*!< Voltage scaling range 1 boost mode */
\r
143 #define PWR_REGULATOR_VOLTAGE_SCALE1 PWR_CR1_VOS_0 /*!< Voltage scaling range 1 normal mode */
\r
144 #define PWR_REGULATOR_VOLTAGE_SCALE2 PWR_CR1_VOS_1 /*!< Voltage scaling range 2 */
\r
150 /** @defgroup PWREx_VBAT_Battery_Charging_Selection PWR battery charging resistor selection
\r
153 #define PWR_BATTERY_CHARGING_RESISTOR_5 ((uint32_t)0x00000000) /*!< VBAT charging through a 5 kOhms resistor */
\r
154 #define PWR_BATTERY_CHARGING_RESISTOR_1_5 PWR_CR4_VBRS /*!< VBAT charging through a 1.5 kOhms resistor */
\r
159 /** @defgroup PWREx_VBAT_Battery_Charging PWR battery charging
\r
162 #define PWR_BATTERY_CHARGING_DISABLE ((uint32_t)0x00000000)
\r
163 #define PWR_BATTERY_CHARGING_ENABLE PWR_CR4_VBE
\r
168 /** @defgroup PWREx_GPIO_Bit_Number GPIO bit number for I/O setting in standby/shutdown mode
\r
171 #define PWR_GPIO_BIT_0 PWR_PUCRA_PA0 /*!< GPIO port I/O pin 0 */
\r
172 #define PWR_GPIO_BIT_1 PWR_PUCRA_PA1 /*!< GPIO port I/O pin 1 */
\r
173 #define PWR_GPIO_BIT_2 PWR_PUCRA_PA2 /*!< GPIO port I/O pin 2 */
\r
174 #define PWR_GPIO_BIT_3 PWR_PUCRA_PA3 /*!< GPIO port I/O pin 3 */
\r
175 #define PWR_GPIO_BIT_4 PWR_PUCRA_PA4 /*!< GPIO port I/O pin 4 */
\r
176 #define PWR_GPIO_BIT_5 PWR_PUCRA_PA5 /*!< GPIO port I/O pin 5 */
\r
177 #define PWR_GPIO_BIT_6 PWR_PUCRA_PA6 /*!< GPIO port I/O pin 6 */
\r
178 #define PWR_GPIO_BIT_7 PWR_PUCRA_PA7 /*!< GPIO port I/O pin 7 */
\r
179 #define PWR_GPIO_BIT_8 PWR_PUCRA_PA8 /*!< GPIO port I/O pin 8 */
\r
180 #define PWR_GPIO_BIT_9 PWR_PUCRA_PA9 /*!< GPIO port I/O pin 9 */
\r
181 #define PWR_GPIO_BIT_10 PWR_PUCRA_PA10 /*!< GPIO port I/O pin 10 */
\r
182 #define PWR_GPIO_BIT_11 PWR_PUCRA_PA11 /*!< GPIO port I/O pin 11 */
\r
183 #define PWR_GPIO_BIT_12 PWR_PUCRA_PA12 /*!< GPIO port I/O pin 12 */
\r
184 #define PWR_GPIO_BIT_13 PWR_PUCRA_PA13 /*!< GPIO port I/O pin 13 */
\r
185 #define PWR_GPIO_BIT_14 PWR_PDCRA_PA14 /*!< GPIO port I/O pin 14 */
\r
186 #define PWR_GPIO_BIT_15 PWR_PUCRA_PA15 /*!< GPIO port I/O pin 15 */
\r
191 /** @defgroup PWREx_GPIO GPIO port
\r
194 #define PWR_GPIO_A 0x00000000U /*!< GPIO port A */
\r
195 #define PWR_GPIO_B 0x00000001U /*!< GPIO port B */
\r
196 #define PWR_GPIO_C 0x00000002U /*!< GPIO port C */
\r
197 #if defined(GPIOD_BASE)
\r
198 #define PWR_GPIO_D 0x00000003U /*!< GPIO port D */
\r
200 #if defined(GPIOE_BASE)
\r
201 #define PWR_GPIO_E 0x00000004U /*!< GPIO port E */
\r
203 #if defined(GPIOF_BASE)
\r
204 #define PWR_GPIO_F 0x00000005U /*!< GPIO port F */
\r
206 #if defined(GPIOG_BASE)
\r
207 #define PWR_GPIO_G 0x00000006U /*!< GPIO port G */
\r
209 #define PWR_GPIO_H 0x00000007U /*!< GPIO port H */
\r
210 #if defined(GPIOI_BASE)
\r
211 #define PWR_GPIO_I 0x00000008U /*!< GPIO port I */
\r
217 /** @defgroup PWREx_PVM_EXTI_LINE PWR PVM external interrupts lines
\r
220 #if defined(PWR_CR2_PVME1)
\r
221 #define PWR_EXTI_LINE_PVM1 ((uint32_t)0x00000008) /*!< External interrupt line 35 Connected to the PVM1 EXTI Line */
\r
222 #endif /* PWR_CR2_PVME1 */
\r
223 #if defined(PWR_CR2_PVME2)
\r
224 #define PWR_EXTI_LINE_PVM2 ((uint32_t)0x00000010) /*!< External interrupt line 36 Connected to the PVM2 EXTI Line */
\r
225 #endif /* PWR_CR2_PVME2 */
\r
226 #define PWR_EXTI_LINE_PVM3 ((uint32_t)0x00000020) /*!< External interrupt line 37 Connected to the PVM3 EXTI Line */
\r
227 #define PWR_EXTI_LINE_PVM4 ((uint32_t)0x00000040) /*!< External interrupt line 38 Connected to the PVM4 EXTI Line */
\r
232 /** @defgroup PWREx_PVM_EVENT_LINE PWR PVM event lines
\r
235 #if defined(PWR_CR2_PVME1)
\r
236 #define PWR_EVENT_LINE_PVM1 ((uint32_t)0x00000008) /*!< Event line 35 Connected to the PVM1 EXTI Line */
\r
237 #endif /* PWR_CR2_PVME1 */
\r
238 #if defined(PWR_CR2_PVME2)
\r
239 #define PWR_EVENT_LINE_PVM2 ((uint32_t)0x00000010) /*!< Event line 36 Connected to the PVM2 EXTI Line */
\r
240 #endif /* PWR_CR2_PVME2 */
\r
241 #define PWR_EVENT_LINE_PVM3 ((uint32_t)0x00000020) /*!< Event line 37 Connected to the PVM3 EXTI Line */
\r
242 #define PWR_EVENT_LINE_PVM4 ((uint32_t)0x00000040) /*!< Event line 38 Connected to the PVM4 EXTI Line */
\r
247 /** @defgroup PWREx_Flag PWR Status Flags
\r
248 * Elements values convention: 0000 0000 0XXY YYYYb
\r
249 * - Y YYYY : Flag position in the XX register (5 bits)
\r
250 * - XX : Status register (2 bits)
\r
251 * - 01: SR1 register
\r
252 * - 10: SR2 register
\r
253 * The only exception is PWR_FLAG_WU, encompassing all
\r
254 * wake-up flags and set to PWR_SR1_WUF.
\r
257 #define PWR_FLAG_WUF1 ((uint32_t)0x0020) /*!< Wakeup event on wakeup pin 1 */
\r
258 #define PWR_FLAG_WUF2 ((uint32_t)0x0021) /*!< Wakeup event on wakeup pin 2 */
\r
259 #define PWR_FLAG_WUF3 ((uint32_t)0x0022) /*!< Wakeup event on wakeup pin 3 */
\r
260 #define PWR_FLAG_WUF4 ((uint32_t)0x0023) /*!< Wakeup event on wakeup pin 4 */
\r
261 #define PWR_FLAG_WUF5 ((uint32_t)0x0024) /*!< Wakeup event on wakeup pin 5 */
\r
262 #define PWR_FLAG_WU PWR_SR1_WUF /*!< Encompass wakeup event on all wakeup pins */
\r
263 #define PWR_FLAG_SB ((uint32_t)0x0028) /*!< Standby flag */
\r
264 #if defined(PWR_SR1_EXT_SMPS_RDY)
\r
265 #define PWR_FLAG_EXT_SMPS ((uint32_t)0x002D) /*!< Switching to external SMPS ready flag */
\r
266 #endif /* PWR_SR1_EXT_SMPS_RDY */
\r
267 #define PWR_FLAG_WUFI ((uint32_t)0x002F) /*!< Wakeup on internal wakeup line */
\r
269 #define PWR_FLAG_REGLPS ((uint32_t)0x0048) /*!< Low-power regulator start flag */
\r
270 #define PWR_FLAG_REGLPF ((uint32_t)0x0049) /*!< Low-power regulator flag */
\r
271 #define PWR_FLAG_VOSF ((uint32_t)0x004A) /*!< Voltage scaling flag */
\r
272 #define PWR_FLAG_PVDO ((uint32_t)0x004B) /*!< Power Voltage Detector output flag */
\r
273 #if defined(PWR_CR2_PVME1)
\r
274 #define PWR_FLAG_PVMO1 ((uint32_t)0x004C) /*!< Power Voltage Monitoring 1 output flag */
\r
275 #endif /* PWR_CR2_PVME1 */
\r
276 #if defined(PWR_CR2_PVME2)
\r
277 #define PWR_FLAG_PVMO2 ((uint32_t)0x004D) /*!< Power Voltage Monitoring 2 output flag */
\r
278 #endif /* PWR_CR2_PVME2 */
\r
279 #define PWR_FLAG_PVMO3 ((uint32_t)0x004E) /*!< Power Voltage Monitoring 3 output flag */
\r
280 #define PWR_FLAG_PVMO4 ((uint32_t)0x004F) /*!< Power Voltage Monitoring 4 output flag */
\r
289 /* Exported macros -----------------------------------------------------------*/
\r
290 /** @defgroup PWREx_Exported_Macros PWR Extended Exported Macros
\r
294 #if defined(PWR_CR2_PVME1)
\r
296 * @brief Enable the PVM1 Extended Interrupt Line.
\r
299 #define __HAL_PWR_PVM1_EXTI_ENABLE_IT() SET_BIT(EXTI->IMR2, PWR_EXTI_LINE_PVM1)
\r
302 * @brief Disable the PVM1 Extended Interrupt Line.
\r
305 #define __HAL_PWR_PVM1_EXTI_DISABLE_IT() CLEAR_BIT(EXTI->IMR2, PWR_EXTI_LINE_PVM1)
\r
308 * @brief Enable the PVM1 Event Line.
\r
311 #define __HAL_PWR_PVM1_EXTI_ENABLE_EVENT() SET_BIT(EXTI->EMR2, PWR_EVENT_LINE_PVM1)
\r
314 * @brief Disable the PVM1 Event Line.
\r
317 #define __HAL_PWR_PVM1_EXTI_DISABLE_EVENT() CLEAR_BIT(EXTI->EMR2, PWR_EVENT_LINE_PVM1)
\r
320 * @brief Enable the PVM1 Extended Interrupt Rising Trigger.
\r
323 #define __HAL_PWR_PVM1_EXTI_ENABLE_RISING_EDGE() SET_BIT(EXTI->RTSR2, PWR_EXTI_LINE_PVM1)
\r
326 * @brief Disable the PVM1 Extended Interrupt Rising Trigger.
\r
329 #define __HAL_PWR_PVM1_EXTI_DISABLE_RISING_EDGE() CLEAR_BIT(EXTI->RTSR2, PWR_EXTI_LINE_PVM1)
\r
332 * @brief Enable the PVM1 Extended Interrupt Falling Trigger.
\r
335 #define __HAL_PWR_PVM1_EXTI_ENABLE_FALLING_EDGE() SET_BIT(EXTI->FTSR2, PWR_EXTI_LINE_PVM1)
\r
339 * @brief Disable the PVM1 Extended Interrupt Falling Trigger.
\r
342 #define __HAL_PWR_PVM1_EXTI_DISABLE_FALLING_EDGE() CLEAR_BIT(EXTI->FTSR2, PWR_EXTI_LINE_PVM1)
\r
346 * @brief PVM1 EXTI line configuration: set rising & falling edge trigger.
\r
349 #define __HAL_PWR_PVM1_EXTI_ENABLE_RISING_FALLING_EDGE() \
\r
351 __HAL_PWR_PVM1_EXTI_ENABLE_RISING_EDGE(); \
\r
352 __HAL_PWR_PVM1_EXTI_ENABLE_FALLING_EDGE(); \
\r
356 * @brief Disable the PVM1 Extended Interrupt Rising & Falling Trigger.
\r
359 #define __HAL_PWR_PVM1_EXTI_DISABLE_RISING_FALLING_EDGE() \
\r
361 __HAL_PWR_PVM1_EXTI_DISABLE_RISING_EDGE(); \
\r
362 __HAL_PWR_PVM1_EXTI_DISABLE_FALLING_EDGE(); \
\r
366 * @brief Generate a Software interrupt on selected EXTI line.
\r
369 #define __HAL_PWR_PVM1_EXTI_GENERATE_SWIT() SET_BIT(EXTI->SWIER2, PWR_EXTI_LINE_PVM1)
\r
372 * @brief Check whether the specified PVM1 EXTI interrupt flag is set or not.
\r
373 * @retval EXTI PVM1 Line Status.
\r
375 #define __HAL_PWR_PVM1_EXTI_GET_FLAG() (EXTI->PR2 & PWR_EXTI_LINE_PVM1)
\r
378 * @brief Clear the PVM1 EXTI flag.
\r
381 #define __HAL_PWR_PVM1_EXTI_CLEAR_FLAG() WRITE_REG(EXTI->PR2, PWR_EXTI_LINE_PVM1)
\r
383 #endif /* PWR_CR2_PVME1 */
\r
386 #if defined(PWR_CR2_PVME2)
\r
388 * @brief Enable the PVM2 Extended Interrupt Line.
\r
391 #define __HAL_PWR_PVM2_EXTI_ENABLE_IT() SET_BIT(EXTI->IMR2, PWR_EXTI_LINE_PVM2)
\r
394 * @brief Disable the PVM2 Extended Interrupt Line.
\r
397 #define __HAL_PWR_PVM2_EXTI_DISABLE_IT() CLEAR_BIT(EXTI->IMR2, PWR_EXTI_LINE_PVM2)
\r
400 * @brief Enable the PVM2 Event Line.
\r
403 #define __HAL_PWR_PVM2_EXTI_ENABLE_EVENT() SET_BIT(EXTI->EMR2, PWR_EVENT_LINE_PVM2)
\r
406 * @brief Disable the PVM2 Event Line.
\r
409 #define __HAL_PWR_PVM2_EXTI_DISABLE_EVENT() CLEAR_BIT(EXTI->EMR2, PWR_EVENT_LINE_PVM2)
\r
412 * @brief Enable the PVM2 Extended Interrupt Rising Trigger.
\r
415 #define __HAL_PWR_PVM2_EXTI_ENABLE_RISING_EDGE() SET_BIT(EXTI->RTSR2, PWR_EXTI_LINE_PVM2)
\r
418 * @brief Disable the PVM2 Extended Interrupt Rising Trigger.
\r
421 #define __HAL_PWR_PVM2_EXTI_DISABLE_RISING_EDGE() CLEAR_BIT(EXTI->RTSR2, PWR_EXTI_LINE_PVM2)
\r
424 * @brief Enable the PVM2 Extended Interrupt Falling Trigger.
\r
427 #define __HAL_PWR_PVM2_EXTI_ENABLE_FALLING_EDGE() SET_BIT(EXTI->FTSR2, PWR_EXTI_LINE_PVM2)
\r
431 * @brief Disable the PVM2 Extended Interrupt Falling Trigger.
\r
434 #define __HAL_PWR_PVM2_EXTI_DISABLE_FALLING_EDGE() CLEAR_BIT(EXTI->FTSR2, PWR_EXTI_LINE_PVM2)
\r
438 * @brief PVM2 EXTI line configuration: set rising & falling edge trigger.
\r
441 #define __HAL_PWR_PVM2_EXTI_ENABLE_RISING_FALLING_EDGE() \
\r
443 __HAL_PWR_PVM2_EXTI_ENABLE_RISING_EDGE(); \
\r
444 __HAL_PWR_PVM2_EXTI_ENABLE_FALLING_EDGE(); \
\r
448 * @brief Disable the PVM2 Extended Interrupt Rising & Falling Trigger.
\r
451 #define __HAL_PWR_PVM2_EXTI_DISABLE_RISING_FALLING_EDGE() \
\r
453 __HAL_PWR_PVM2_EXTI_DISABLE_RISING_EDGE(); \
\r
454 __HAL_PWR_PVM2_EXTI_DISABLE_FALLING_EDGE(); \
\r
458 * @brief Generate a Software interrupt on selected EXTI line.
\r
461 #define __HAL_PWR_PVM2_EXTI_GENERATE_SWIT() SET_BIT(EXTI->SWIER2, PWR_EXTI_LINE_PVM2)
\r
464 * @brief Check whether the specified PVM2 EXTI interrupt flag is set or not.
\r
465 * @retval EXTI PVM2 Line Status.
\r
467 #define __HAL_PWR_PVM2_EXTI_GET_FLAG() (EXTI->PR2 & PWR_EXTI_LINE_PVM2)
\r
470 * @brief Clear the PVM2 EXTI flag.
\r
473 #define __HAL_PWR_PVM2_EXTI_CLEAR_FLAG() WRITE_REG(EXTI->PR2, PWR_EXTI_LINE_PVM2)
\r
475 #endif /* PWR_CR2_PVME2 */
\r
479 * @brief Enable the PVM3 Extended Interrupt Line.
\r
482 #define __HAL_PWR_PVM3_EXTI_ENABLE_IT() SET_BIT(EXTI->IMR2, PWR_EXTI_LINE_PVM3)
\r
485 * @brief Disable the PVM3 Extended Interrupt Line.
\r
488 #define __HAL_PWR_PVM3_EXTI_DISABLE_IT() CLEAR_BIT(EXTI->IMR2, PWR_EXTI_LINE_PVM3)
\r
491 * @brief Enable the PVM3 Event Line.
\r
494 #define __HAL_PWR_PVM3_EXTI_ENABLE_EVENT() SET_BIT(EXTI->EMR2, PWR_EVENT_LINE_PVM3)
\r
497 * @brief Disable the PVM3 Event Line.
\r
500 #define __HAL_PWR_PVM3_EXTI_DISABLE_EVENT() CLEAR_BIT(EXTI->EMR2, PWR_EVENT_LINE_PVM3)
\r
503 * @brief Enable the PVM3 Extended Interrupt Rising Trigger.
\r
506 #define __HAL_PWR_PVM3_EXTI_ENABLE_RISING_EDGE() SET_BIT(EXTI->RTSR2, PWR_EXTI_LINE_PVM3)
\r
509 * @brief Disable the PVM3 Extended Interrupt Rising Trigger.
\r
512 #define __HAL_PWR_PVM3_EXTI_DISABLE_RISING_EDGE() CLEAR_BIT(EXTI->RTSR2, PWR_EXTI_LINE_PVM3)
\r
515 * @brief Enable the PVM3 Extended Interrupt Falling Trigger.
\r
518 #define __HAL_PWR_PVM3_EXTI_ENABLE_FALLING_EDGE() SET_BIT(EXTI->FTSR2, PWR_EXTI_LINE_PVM3)
\r
522 * @brief Disable the PVM3 Extended Interrupt Falling Trigger.
\r
525 #define __HAL_PWR_PVM3_EXTI_DISABLE_FALLING_EDGE() CLEAR_BIT(EXTI->FTSR2, PWR_EXTI_LINE_PVM3)
\r
529 * @brief PVM3 EXTI line configuration: set rising & falling edge trigger.
\r
532 #define __HAL_PWR_PVM3_EXTI_ENABLE_RISING_FALLING_EDGE() \
\r
534 __HAL_PWR_PVM3_EXTI_ENABLE_RISING_EDGE(); \
\r
535 __HAL_PWR_PVM3_EXTI_ENABLE_FALLING_EDGE(); \
\r
539 * @brief Disable the PVM3 Extended Interrupt Rising & Falling Trigger.
\r
542 #define __HAL_PWR_PVM3_EXTI_DISABLE_RISING_FALLING_EDGE() \
\r
544 __HAL_PWR_PVM3_EXTI_DISABLE_RISING_EDGE(); \
\r
545 __HAL_PWR_PVM3_EXTI_DISABLE_FALLING_EDGE(); \
\r
549 * @brief Generate a Software interrupt on selected EXTI line.
\r
552 #define __HAL_PWR_PVM3_EXTI_GENERATE_SWIT() SET_BIT(EXTI->SWIER2, PWR_EXTI_LINE_PVM3)
\r
555 * @brief Check whether the specified PVM3 EXTI interrupt flag is set or not.
\r
556 * @retval EXTI PVM3 Line Status.
\r
558 #define __HAL_PWR_PVM3_EXTI_GET_FLAG() (EXTI->PR2 & PWR_EXTI_LINE_PVM3)
\r
561 * @brief Clear the PVM3 EXTI flag.
\r
564 #define __HAL_PWR_PVM3_EXTI_CLEAR_FLAG() WRITE_REG(EXTI->PR2, PWR_EXTI_LINE_PVM3)
\r
570 * @brief Enable the PVM4 Extended Interrupt Line.
\r
573 #define __HAL_PWR_PVM4_EXTI_ENABLE_IT() SET_BIT(EXTI->IMR2, PWR_EXTI_LINE_PVM4)
\r
576 * @brief Disable the PVM4 Extended Interrupt Line.
\r
579 #define __HAL_PWR_PVM4_EXTI_DISABLE_IT() CLEAR_BIT(EXTI->IMR2, PWR_EXTI_LINE_PVM4)
\r
582 * @brief Enable the PVM4 Event Line.
\r
585 #define __HAL_PWR_PVM4_EXTI_ENABLE_EVENT() SET_BIT(EXTI->EMR2, PWR_EVENT_LINE_PVM4)
\r
588 * @brief Disable the PVM4 Event Line.
\r
591 #define __HAL_PWR_PVM4_EXTI_DISABLE_EVENT() CLEAR_BIT(EXTI->EMR2, PWR_EVENT_LINE_PVM4)
\r
594 * @brief Enable the PVM4 Extended Interrupt Rising Trigger.
\r
597 #define __HAL_PWR_PVM4_EXTI_ENABLE_RISING_EDGE() SET_BIT(EXTI->RTSR2, PWR_EXTI_LINE_PVM4)
\r
600 * @brief Disable the PVM4 Extended Interrupt Rising Trigger.
\r
603 #define __HAL_PWR_PVM4_EXTI_DISABLE_RISING_EDGE() CLEAR_BIT(EXTI->RTSR2, PWR_EXTI_LINE_PVM4)
\r
606 * @brief Enable the PVM4 Extended Interrupt Falling Trigger.
\r
609 #define __HAL_PWR_PVM4_EXTI_ENABLE_FALLING_EDGE() SET_BIT(EXTI->FTSR2, PWR_EXTI_LINE_PVM4)
\r
613 * @brief Disable the PVM4 Extended Interrupt Falling Trigger.
\r
616 #define __HAL_PWR_PVM4_EXTI_DISABLE_FALLING_EDGE() CLEAR_BIT(EXTI->FTSR2, PWR_EXTI_LINE_PVM4)
\r
620 * @brief PVM4 EXTI line configuration: set rising & falling edge trigger.
\r
623 #define __HAL_PWR_PVM4_EXTI_ENABLE_RISING_FALLING_EDGE() \
\r
625 __HAL_PWR_PVM4_EXTI_ENABLE_RISING_EDGE(); \
\r
626 __HAL_PWR_PVM4_EXTI_ENABLE_FALLING_EDGE(); \
\r
630 * @brief Disable the PVM4 Extended Interrupt Rising & Falling Trigger.
\r
633 #define __HAL_PWR_PVM4_EXTI_DISABLE_RISING_FALLING_EDGE() \
\r
635 __HAL_PWR_PVM4_EXTI_DISABLE_RISING_EDGE(); \
\r
636 __HAL_PWR_PVM4_EXTI_DISABLE_FALLING_EDGE(); \
\r
640 * @brief Generate a Software interrupt on selected EXTI line.
\r
643 #define __HAL_PWR_PVM4_EXTI_GENERATE_SWIT() SET_BIT(EXTI->SWIER2, PWR_EXTI_LINE_PVM4)
\r
646 * @brief Check whether or not the specified PVM4 EXTI interrupt flag is set.
\r
647 * @retval EXTI PVM4 Line Status.
\r
649 #define __HAL_PWR_PVM4_EXTI_GET_FLAG() (EXTI->PR2 & PWR_EXTI_LINE_PVM4)
\r
652 * @brief Clear the PVM4 EXTI flag.
\r
655 #define __HAL_PWR_PVM4_EXTI_CLEAR_FLAG() WRITE_REG(EXTI->PR2, PWR_EXTI_LINE_PVM4)
\r
659 * @brief Configure the main internal regulator output voltage.
\r
660 * @param __REGULATOR__: specifies the regulator output voltage to achieve
\r
661 * a tradeoff between performance and power consumption.
\r
662 * This parameter can be one of the following values:
\r
663 * @arg @ref PWR_REGULATOR_VOLTAGE_SCALE1 Regulator voltage output range 1 mode,
\r
664 * typical output voltage at 1.2 V,
\r
665 * system frequency up to 80 MHz.
\r
666 * @arg @ref PWR_REGULATOR_VOLTAGE_SCALE2 Regulator voltage output range 2 mode,
\r
667 * typical output voltage at 1.0 V,
\r
668 * system frequency up to 26 MHz.
\r
669 * @note This macro is similar to HAL_PWREx_ControlVoltageScaling() API but doesn't check
\r
670 * whether or not VOSF flag is cleared when moving from range 2 to range 1. User
\r
671 * may resort to __HAL_PWR_GET_FLAG() macro to check VOSF bit resetting.
\r
674 #define __HAL_PWR_VOLTAGESCALING_CONFIG(__REGULATOR__) do { \
\r
675 __IO uint32_t tmpreg; \
\r
676 MODIFY_REG(PWR->CR1, PWR_CR1_VOS, (__REGULATOR__)); \
\r
677 /* Delay after an RCC peripheral clock enabling */ \
\r
678 tmpreg = READ_BIT(PWR->CR1, PWR_CR1_VOS); \
\r
686 /* Private macros --------------------------------------------------------*/
\r
687 /** @addtogroup PWREx_Private_Macros PWR Extended Private Macros
\r
691 #define IS_PWR_WAKEUP_PIN(PIN) (((PIN) == PWR_WAKEUP_PIN1) || \
\r
692 ((PIN) == PWR_WAKEUP_PIN2) || \
\r
693 ((PIN) == PWR_WAKEUP_PIN3) || \
\r
694 ((PIN) == PWR_WAKEUP_PIN4) || \
\r
695 ((PIN) == PWR_WAKEUP_PIN5) || \
\r
696 ((PIN) == PWR_WAKEUP_PIN1_HIGH) || \
\r
697 ((PIN) == PWR_WAKEUP_PIN2_HIGH) || \
\r
698 ((PIN) == PWR_WAKEUP_PIN3_HIGH) || \
\r
699 ((PIN) == PWR_WAKEUP_PIN4_HIGH) || \
\r
700 ((PIN) == PWR_WAKEUP_PIN5_HIGH) || \
\r
701 ((PIN) == PWR_WAKEUP_PIN1_LOW) || \
\r
702 ((PIN) == PWR_WAKEUP_PIN2_LOW) || \
\r
703 ((PIN) == PWR_WAKEUP_PIN3_LOW) || \
\r
704 ((PIN) == PWR_WAKEUP_PIN4_LOW) || \
\r
705 ((PIN) == PWR_WAKEUP_PIN5_LOW))
\r
707 #if defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) || \
\r
708 defined (STM32L496xx) || defined (STM32L4A6xx) || \
\r
709 defined (STM32L4R5xx) || defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined (STM32L4S9xx)
\r
710 #define IS_PWR_PVM_TYPE(TYPE) (((TYPE) == PWR_PVM_1) ||\
\r
711 ((TYPE) == PWR_PVM_2) ||\
\r
712 ((TYPE) == PWR_PVM_3) ||\
\r
713 ((TYPE) == PWR_PVM_4))
\r
714 #elif defined (STM32L471xx)
\r
715 #define IS_PWR_PVM_TYPE(TYPE) (((TYPE) == PWR_PVM_2) ||\
\r
716 ((TYPE) == PWR_PVM_3) ||\
\r
717 ((TYPE) == PWR_PVM_4))
\r
720 #if defined (STM32L412xx) || defined (STM32L422xx) || defined (STM32L433xx) || defined (STM32L443xx) || defined (STM32L452xx) || defined (STM32L462xx)
\r
721 #define IS_PWR_PVM_TYPE(TYPE) (((TYPE) == PWR_PVM_1) ||\
\r
722 ((TYPE) == PWR_PVM_3) ||\
\r
723 ((TYPE) == PWR_PVM_4))
\r
724 #elif defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L442xx) || defined (STM32L451xx)
\r
725 #define IS_PWR_PVM_TYPE(TYPE) (((TYPE) == PWR_PVM_3) ||\
\r
726 ((TYPE) == PWR_PVM_4))
\r
729 #define IS_PWR_PVM_MODE(MODE) (((MODE) == PWR_PVM_MODE_NORMAL) ||\
\r
730 ((MODE) == PWR_PVM_MODE_IT_RISING) ||\
\r
731 ((MODE) == PWR_PVM_MODE_IT_FALLING) ||\
\r
732 ((MODE) == PWR_PVM_MODE_IT_RISING_FALLING) ||\
\r
733 ((MODE) == PWR_PVM_MODE_EVENT_RISING) ||\
\r
734 ((MODE) == PWR_PVM_MODE_EVENT_FALLING) ||\
\r
735 ((MODE) == PWR_PVM_MODE_EVENT_RISING_FALLING))
\r
737 #if defined(PWR_CR5_R1MODE)
\r
738 #define IS_PWR_VOLTAGE_SCALING_RANGE(RANGE) (((RANGE) == PWR_REGULATOR_VOLTAGE_SCALE1_BOOST) || \
\r
739 ((RANGE) == PWR_REGULATOR_VOLTAGE_SCALE1) || \
\r
740 ((RANGE) == PWR_REGULATOR_VOLTAGE_SCALE2))
\r
742 #define IS_PWR_VOLTAGE_SCALING_RANGE(RANGE) (((RANGE) == PWR_REGULATOR_VOLTAGE_SCALE1) || \
\r
743 ((RANGE) == PWR_REGULATOR_VOLTAGE_SCALE2))
\r
747 #define IS_PWR_BATTERY_RESISTOR_SELECT(RESISTOR) (((RESISTOR) == PWR_BATTERY_CHARGING_RESISTOR_5) ||\
\r
748 ((RESISTOR) == PWR_BATTERY_CHARGING_RESISTOR_1_5))
\r
750 #define IS_PWR_BATTERY_CHARGING(CHARGING) (((CHARGING) == PWR_BATTERY_CHARGING_DISABLE) ||\
\r
751 ((CHARGING) == PWR_BATTERY_CHARGING_ENABLE))
\r
753 #define IS_PWR_GPIO_BIT_NUMBER(BIT_NUMBER) (((BIT_NUMBER) & GPIO_PIN_MASK) != (uint32_t)0x00)
\r
756 #if defined (STM32L412xx) || defined (STM32L422xx)
\r
757 #define IS_PWR_GPIO(GPIO) (((GPIO) == PWR_GPIO_A) ||\
\r
758 ((GPIO) == PWR_GPIO_B) ||\
\r
759 ((GPIO) == PWR_GPIO_C) ||\
\r
760 ((GPIO) == PWR_GPIO_D) ||\
\r
761 ((GPIO) == PWR_GPIO_H))
\r
762 #elif defined (STM32L431xx) || defined (STM32L433xx) || defined (STM32L443xx) || \
\r
763 defined (STM32L451xx) || defined (STM32L452xx) || defined (STM32L462xx)
\r
764 #define IS_PWR_GPIO(GPIO) (((GPIO) == PWR_GPIO_A) ||\
\r
765 ((GPIO) == PWR_GPIO_B) ||\
\r
766 ((GPIO) == PWR_GPIO_C) ||\
\r
767 ((GPIO) == PWR_GPIO_D) ||\
\r
768 ((GPIO) == PWR_GPIO_E) ||\
\r
769 ((GPIO) == PWR_GPIO_H))
\r
770 #elif defined (STM32L432xx) || defined (STM32L442xx)
\r
771 #define IS_PWR_GPIO(GPIO) (((GPIO) == PWR_GPIO_A) ||\
\r
772 ((GPIO) == PWR_GPIO_B) ||\
\r
773 ((GPIO) == PWR_GPIO_C) ||\
\r
774 ((GPIO) == PWR_GPIO_H))
\r
775 #elif defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx)
\r
776 #define IS_PWR_GPIO(GPIO) (((GPIO) == PWR_GPIO_A) ||\
\r
777 ((GPIO) == PWR_GPIO_B) ||\
\r
778 ((GPIO) == PWR_GPIO_C) ||\
\r
779 ((GPIO) == PWR_GPIO_D) ||\
\r
780 ((GPIO) == PWR_GPIO_E) ||\
\r
781 ((GPIO) == PWR_GPIO_F) ||\
\r
782 ((GPIO) == PWR_GPIO_G) ||\
\r
783 ((GPIO) == PWR_GPIO_H))
\r
784 #elif defined (STM32L496xx) || defined (STM32L4A6xx) || \
\r
785 defined (STM32L4R5xx) || defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined (STM32L4S9xx)
\r
786 #define IS_PWR_GPIO(GPIO) (((GPIO) == PWR_GPIO_A) ||\
\r
787 ((GPIO) == PWR_GPIO_B) ||\
\r
788 ((GPIO) == PWR_GPIO_C) ||\
\r
789 ((GPIO) == PWR_GPIO_D) ||\
\r
790 ((GPIO) == PWR_GPIO_E) ||\
\r
791 ((GPIO) == PWR_GPIO_F) ||\
\r
792 ((GPIO) == PWR_GPIO_G) ||\
\r
793 ((GPIO) == PWR_GPIO_H) ||\
\r
794 ((GPIO) == PWR_GPIO_I))
\r
803 /** @addtogroup PWREx_Exported_Functions PWR Extended Exported Functions
\r
807 /** @addtogroup PWREx_Exported_Functions_Group1 Extended Peripheral Control functions
\r
812 /* Peripheral Control functions **********************************************/
\r
813 uint32_t HAL_PWREx_GetVoltageRange(void);
\r
814 HAL_StatusTypeDef HAL_PWREx_ControlVoltageScaling(uint32_t VoltageScaling);
\r
815 void HAL_PWREx_EnableBatteryCharging(uint32_t ResistorSelection);
\r
816 void HAL_PWREx_DisableBatteryCharging(void);
\r
817 #if defined(PWR_CR2_USV)
\r
818 void HAL_PWREx_EnableVddUSB(void);
\r
819 void HAL_PWREx_DisableVddUSB(void);
\r
820 #endif /* PWR_CR2_USV */
\r
821 #if defined(PWR_CR2_IOSV)
\r
822 void HAL_PWREx_EnableVddIO2(void);
\r
823 void HAL_PWREx_DisableVddIO2(void);
\r
824 #endif /* PWR_CR2_IOSV */
\r
825 void HAL_PWREx_EnableInternalWakeUpLine(void);
\r
826 void HAL_PWREx_DisableInternalWakeUpLine(void);
\r
827 HAL_StatusTypeDef HAL_PWREx_EnableGPIOPullUp(uint32_t GPIO, uint32_t GPIONumber);
\r
828 HAL_StatusTypeDef HAL_PWREx_DisableGPIOPullUp(uint32_t GPIO, uint32_t GPIONumber);
\r
829 HAL_StatusTypeDef HAL_PWREx_EnableGPIOPullDown(uint32_t GPIO, uint32_t GPIONumber);
\r
830 HAL_StatusTypeDef HAL_PWREx_DisableGPIOPullDown(uint32_t GPIO, uint32_t GPIONumber);
\r
831 void HAL_PWREx_EnablePullUpPullDownConfig(void);
\r
832 void HAL_PWREx_DisablePullUpPullDownConfig(void);
\r
833 void HAL_PWREx_EnableSRAM2ContentRetention(void);
\r
834 void HAL_PWREx_DisableSRAM2ContentRetention(void);
\r
835 #if defined(PWR_CR1_RRSTP)
\r
836 void HAL_PWREx_EnableSRAM3ContentRetention(void);
\r
837 void HAL_PWREx_DisableSRAM3ContentRetention(void);
\r
838 #endif /* PWR_CR1_RRSTP */
\r
839 #if defined(PWR_CR3_DSIPDEN)
\r
840 void HAL_PWREx_EnableDSIPinsPDActivation(void);
\r
841 void HAL_PWREx_DisableDSIPinsPDActivation(void);
\r
842 #endif /* PWR_CR3_DSIPDEN */
\r
843 #if defined(PWR_CR2_PVME1)
\r
844 void HAL_PWREx_EnablePVM1(void);
\r
845 void HAL_PWREx_DisablePVM1(void);
\r
846 #endif /* PWR_CR2_PVME1 */
\r
847 #if defined(PWR_CR2_PVME2)
\r
848 void HAL_PWREx_EnablePVM2(void);
\r
849 void HAL_PWREx_DisablePVM2(void);
\r
850 #endif /* PWR_CR2_PVME2 */
\r
851 void HAL_PWREx_EnablePVM3(void);
\r
852 void HAL_PWREx_DisablePVM3(void);
\r
853 void HAL_PWREx_EnablePVM4(void);
\r
854 void HAL_PWREx_DisablePVM4(void);
\r
855 HAL_StatusTypeDef HAL_PWREx_ConfigPVM(PWR_PVMTypeDef *sConfigPVM);
\r
856 #if defined(PWR_CR3_ENULP)
\r
857 void HAL_PWREx_EnableBORPVD_ULP(void);
\r
858 void HAL_PWREx_DisableBORPVD_ULP(void);
\r
859 #endif /* PWR_CR3_ENULP */
\r
860 #if defined(PWR_CR4_EXT_SMPS_ON)
\r
861 void HAL_PWREx_EnableExtSMPS_0V95(void);
\r
862 void HAL_PWREx_DisableExtSMPS_0V95(void);
\r
863 #endif /* PWR_CR4_EXT_SMPS_ON */
\r
866 /* Low Power modes configuration functions ************************************/
\r
867 void HAL_PWREx_EnableLowPowerRunMode(void);
\r
868 HAL_StatusTypeDef HAL_PWREx_DisableLowPowerRunMode(void);
\r
869 void HAL_PWREx_EnterSTOP0Mode(uint8_t STOPEntry);
\r
870 void HAL_PWREx_EnterSTOP1Mode(uint8_t STOPEntry);
\r
871 void HAL_PWREx_EnterSTOP2Mode(uint8_t STOPEntry);
\r
872 void HAL_PWREx_EnterSHUTDOWNMode(void);
\r
874 void HAL_PWREx_PVD_PVM_IRQHandler(void);
\r
875 #if defined(PWR_CR2_PVME1)
\r
876 void HAL_PWREx_PVM1Callback(void);
\r
877 #endif /* PWR_CR2_PVME1 */
\r
878 #if defined(PWR_CR2_PVME2)
\r
879 void HAL_PWREx_PVM2Callback(void);
\r
880 #endif /* PWR_CR2_PVME2 */
\r
881 void HAL_PWREx_PVM3Callback(void);
\r
882 void HAL_PWREx_PVM4Callback(void);
\r
905 #endif /* __STM32L4xx_HAL_PWR_EX_H */
\r
907 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
\r