1 /**
2   ******************************************************************************
3   * @file    stm32wlxx_hal_pwr.h
4   * @author  MCD Application Team
5   * @brief   Header file of PWR HAL module.
6   ******************************************************************************
7   * @attention
8   *
9   * Copyright (c) 2020 STMicroelectronics.
10   * All rights reserved.
11   *
12   * This software is licensed under terms that can be found in the LICENSE file
13   * in the root directory of this software component.
14   * If no LICENSE file comes with this software, it is provided AS-IS.
15   *
16   ******************************************************************************
17   */
18 
19 /* Define to prevent recursive inclusion -------------------------------------*/
20 #ifndef STM32WLxx_HAL_PWR_H
21 #define STM32WLxx_HAL_PWR_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /* Includes ------------------------------------------------------------------*/
28 #include "stm32wlxx_hal_def.h"
29 
30 /* Include low level driver */
31 #include "stm32wlxx_ll_pwr.h"
32 
33 /** @addtogroup STM32WLxx_HAL_Driver
34   * @{
35   */
36 
37 /** @defgroup PWR PWR
38   * @brief PWR HAL module driver
39   * @{
40   */
41 
42 /* Exported types ------------------------------------------------------------*/
43 /** @defgroup PWR_Exported_Types PWR Exported Types
44   * @{
45   */
46 
47 /**
48   * @brief  PWR PVD configuration structure definition
49   */
50 typedef struct
51 {
52   uint32_t PVDLevel;       /*!< PVDLevel: Specifies the PVD detection level.
53                                 This parameter can be a value of @ref PWR_PVD_detection_level. */
54 
55   uint32_t Mode;           /*!< Mode: Specifies the operating mode for the selected pins.
56                                 This parameter can be a value of @ref PWR_PVD_Mode. */
57 } PWR_PVDTypeDef;
58 
59 /**
60   * @}
61   */
62 
63 /* Exported constants --------------------------------------------------------*/
64 /** @defgroup PWR_Exported_Constants PWR Exported Constants
65   * @{
66   */
67 
68 /** @defgroup PWR_PVD_detection_level  Power Voltage Detector Level selection
69   * @note     Refer datasheet for selection voltage value
70   * @{
71   */
72 #define PWR_PVDLEVEL_0                      (0x00000000UL)                                   /*!< PVD threshold around 2.0 V */
73 #define PWR_PVDLEVEL_1                      (                                PWR_CR2_PLS_0)  /*!< PVD threshold around 2.2 V */
74 #define PWR_PVDLEVEL_2                      (                PWR_CR2_PLS_1                )  /*!< PVD threshold around 2.4 V */
75 #define PWR_PVDLEVEL_3                      (                PWR_CR2_PLS_1 | PWR_CR2_PLS_0)  /*!< PVD threshold around 2.5 V */
76 #define PWR_PVDLEVEL_4                      (PWR_CR2_PLS_2                                )  /*!< PVD threshold around 2.6 V */
77 #define PWR_PVDLEVEL_5                      (PWR_CR2_PLS_2                 | PWR_CR2_PLS_0)  /*!< PVD threshold around 2.8 V */
78 #define PWR_PVDLEVEL_6                      (PWR_CR2_PLS_2 | PWR_CR2_PLS_1                )  /*!< PVD threshold around 2.9 V */
79 #define PWR_PVDLEVEL_7                      (PWR_CR2_PLS_2 | PWR_CR2_PLS_1 | PWR_CR2_PLS_0)  /*!< External input analog voltage (compared internally to VREFINT) */
80 /**
81   * @}
82   */
83 
84 /** @defgroup PWR_PVD_Mode  PWR PVD interrupt and event mode
85   * @{
86   */
87 /* Note: On STM32WL series, power PVD event is not available on EXTI lines     */
88 /*       (only interruption is available through EXTI line 16).               */
89 #define PWR_PVD_MODE_NORMAL                 (0x00000000UL)                          /*!< PVD in polling mode (PVD flag update without interruption) */
90 
91 #define PWR_PVD_MODE_IT_RISING              (PVD_MODE_IT | PVD_RISING_EDGE)         /*!< PVD in interrupt mode with rising edge trigger detection */
92 #define PWR_PVD_MODE_IT_FALLING             (PVD_MODE_IT | PVD_FALLING_EDGE)        /*!< PVD in interrupt mode with falling edge trigger detection */
93 #define PWR_PVD_MODE_IT_RISING_FALLING      (PVD_MODE_IT | PVD_RISING_FALLING_EDGE) /*!< PVD in interrupt mode with rising/falling edge trigger detection */
94 /**
95   * @}
96   */
97 
98 /** @defgroup PWR_Low_Power_Mode_Selection  PWR Low Power Mode Selection
99   * @{
100   */
101 #ifdef CORE_CM0PLUS
102 #define PWR_LOWPOWERMODE_STOP0              (0x00000000UL)                        /*!< Stop 0: Stop mode with main regulator */
103 #define PWR_LOWPOWERMODE_STOP1              (PWR_C2CR1_LPMS_0)                    /*!< Stop 1: Stop mode with low power regulator */
104 #define PWR_LOWPOWERMODE_STOP2              (PWR_C2CR1_LPMS_1)                    /*!< Stop 2: Stop mode with low power regulator and VDD12I interruptible digital core domain supply OFF (less peripherals activated than low power mode stop 1 to reduce power consumption)*/
105 #define PWR_LOWPOWERMODE_STANDBY            (PWR_C2CR1_LPMS_0 | PWR_C2CR1_LPMS_1) /*!< Standby mode */
106 #define PWR_LOWPOWERMODE_SHUTDOWN           (PWR_C2CR1_LPMS_2 | PWR_C2CR1_LPMS_1 | PWR_C2CR1_LPMS_0) /*!< Shutdown mode */
107 #else
108 #define PWR_LOWPOWERMODE_STOP0              (0x00000000UL)                        /*!< Stop 0: Stop mode with main regulator */
109 #define PWR_LOWPOWERMODE_STOP1              (PWR_CR1_LPMS_0)                      /*!< Stop 1: Stop mode with low power regulator */
110 #define PWR_LOWPOWERMODE_STOP2              (PWR_CR1_LPMS_1)                      /*!< Stop 2: Stop mode with low power regulator and VDD12I interruptible digital core domain supply OFF (less peripherals activated than low power mode stop 1 to reduce power consumption)*/
111 #define PWR_LOWPOWERMODE_STANDBY            (PWR_CR1_LPMS_0 | PWR_CR1_LPMS_1)     /*!< Standby mode */
112 #define PWR_LOWPOWERMODE_SHUTDOWN           (PWR_CR1_LPMS_2 | PWR_CR1_LPMS_1 | PWR_CR1_LPMS_0) /*!< Shutdown mode */
113 #endif
114 /**
115   * @}
116   */
117 
118 /** @defgroup PWR_Regulator_state_in_SLEEP_STOP_mode  PWR regulator mode
119   * @{
120   */
121 #define PWR_MAINREGULATOR_ON                (0x00000000UL)              /*!< Regulator in main mode      */
122 #define PWR_LOWPOWERREGULATOR_ON            (PWR_CR1_LPR)               /*!< Regulator in low-power mode */
123 /**
124   * @}
125   */
126 
127 /** @defgroup PWR_SLEEP_mode_entry  PWR SLEEP mode entry
128   * @{
129   */
130 #define PWR_SLEEPENTRY_WFI                  ((uint8_t)0x01)         /*!< Wait For Interruption instruction to enter Sleep mode */
131 #define PWR_SLEEPENTRY_WFE                  ((uint8_t)0x02)         /*!< Wait For Event instruction to enter Sleep mode        */
132 /**
133   * @}
134   */
135 
136 /** @defgroup PWR_STOP_mode_entry  PWR STOP mode entry
137   * @{
138   */
139 #define PWR_STOPENTRY_WFI                   ((uint8_t)0x01)         /*!< Wait For Interruption instruction to enter Stop mode */
140 #define PWR_STOPENTRY_WFE                   ((uint8_t)0x02)         /*!< Wait For Event instruction to enter Stop mode        */
141 /**
142   * @}
143   */
144 
145 /**
146   * @}
147   */
148 
149 /* Private constants ---------------------------------------------------------*/
150 /** @defgroup PWR_Private_Constants PWR Private Constants
151   * @{
152   */
153 
154 /** @defgroup PWR_PVD_EXTI_LINE  PWR PVD external interrupt line
155   * @{
156   */
157 #define PWR_EXTI_LINE_PVD                   (LL_EXTI_LINE_16)   /*!< External interrupt line 16 Connected to the PWR PVD */
158 /**
159   * @}
160   */
161 
162 /** @defgroup PWR_PVD_Mode_Mask PWR PVD Mode Mask
163   * @{
164   */
165 /* Note: On STM32WL series, power PVD event is not available on EXTI lines     */
166 /*       (only interruption is available through EXTI line 16).               */
167 #define PVD_MODE_IT                         (0x00010000UL)  /*!< Mask for interruption yielded by PVD threshold crossing */
168 #define PVD_RISING_EDGE                     (0x00000001UL)  /*!< Mask for rising edge set as PVD trigger                 */
169 #define PVD_FALLING_EDGE                    (0x00000002UL)  /*!< Mask for falling edge set as PVD trigger                */
170 #define PVD_RISING_FALLING_EDGE             (0x00000003UL)  /*!< Mask for rising and falling edges set as PVD trigger    */
171 /**
172   * @}
173   */
174 
175 /**
176   * @}
177   */
178 
179 /* Exported macros -----------------------------------------------------------*/
180 /** @defgroup PWR_Exported_Macros  PWR Exported Macros
181   * @{
182   */
183 #if defined(DUAL_CORE)
184 /** @brief  Check whether or not a specific PWR flag is set.
185   * @param __FLAG__ specifies the flag to check.
186   *           This parameter can be one of the following values:
187   *
188   *            /--------------------------------SR1-------------------------------/
189   *            @arg @ref PWR_FLAG_WUF1  Wake Up Flag 1. Indicates that a wakeup event
190   *                                     was received from the WKUP pin 1.
191   *            @arg @ref PWR_FLAG_WUF2  Wake Up Flag 2. Indicates that a wakeup event
192   *                                     was received from the WKUP pin 2.
193   *            @arg @ref PWR_FLAG_WUF3  Wake Up Flag 3. Indicates that a wakeup event
194   *                                     was received from the WKUP pin 3.
195   *
196   *            @arg @ref PWR_FLAG_WPVD      Wakeup PVD flag
197   *
198   *            @arg @ref PWR_FLAG_HOLDC2I   CPU2 on-Hold Interrupt Flag
199   *            @arg @ref PWR_FLAG_WUFI      Wake-Up Flag Internal. Set when a wakeup is detected on
200   *                                         the internal wakeup line.
201   *
202   *            @arg @ref PWR_FLAG_WRFBUSY   Wake-up radio busy flag (triggered status: wake-up event or interruption occurred at least once. Can be cleared by software)
203   *
204   *            /--------------------------------SR2-------------------------------/
205   *            @arg @ref PWR_FLAG_LDORDY   Main LDO ready flag
206   *            @arg @ref PWR_FLAG_SMPSRDY  SMPS ready Flag
207   *
208   *            @arg @ref PWR_FLAG_REGLPS Low-power Regulator 1 started: Indicates whether the regulator
209   *                                      is ready after a power-on reset or a Standby/Shutdown.
210   *            @arg @ref PWR_FLAG_REGLPF Low-power Regulator 1 flag: Indicates whether the
211   *                                      regulator 1 is in main mode or is in low-power mode.
212   *
213   *            @arg @ref PWR_FLAG_REGMRS Low-power regulator (main regulator or low-power regulator used) flag.
214   *
215   *            @arg @ref PWR_FLAG_FLASHRDY Flash ready flag
216   *
217   *            @arg @ref PWR_FLAG_VOSF   Voltage Scaling Flag. Indicates whether the regulator is ready
218   *                                      in the selected voltage range or is still changing to the required voltage level.
219   *            @arg @ref PWR_FLAG_PVDO   Power Voltage Detector Output. Indicates whether VDD voltage is below
220   *                                      or above the selected PVD threshold.
221   *
222   *            @arg @ref PWR_FLAG_PVMO3 Peripheral Voltage Monitoring Output 3. Indicates whether VDDA voltage is
223   *                                     is below or above PVM3 threshold.
224   *
225   *            @arg @ref PWR_FLAG_RFEOL Indicate whether supply voltage is below radio operating level (radio "end of life").
226   *
227   *            @arg @ref PWR_FLAG_RFBUSYS  Radio busy signal flag (current status).
228   *            @arg @ref PWR_FLAG_RFBUSYMS Radio busy masked signal flag (current status).
229   *
230   *            @arg @ref PWR_FLAG_C2BOOTS  CPU2 boot request source information flag.
231   *
232   *            /----------------------------EXTSCR--------------------------/
233   *            @arg @ref PWR_FLAG_STOP      System Stop 0 or Stop1 Flag for CPU1.
234   *            @arg @ref PWR_FLAG_STOP2     System Stop 2 Flag for CPU1.
235   *            @arg @ref PWR_FLAG_SB        System Standby Flag for CPU1.
236   *
237   *            @arg @ref PWR_FLAG_C2STOP    System Stop 0 or Stop1 Flag for CPU2.
238   *            @arg @ref PWR_FLAG_C2STOP2   System Stop 2 Flag for CPU2.
239   *            @arg @ref PWR_FLAG_C2SB      System Standby Flag for CPU2.
240   *
241   *            @arg @ref PWR_FLAG_C1DEEPSLEEP       CPU1 DeepSleep Flag.
242   *            @arg @ref PWR_FLAG_C2DEEPSLEEP       CPU2 DeepSleep Flag.
243   *
244   * @retval The new state of __FLAG__ (TRUE or FALSE).
245   */
246 #else
247 /** @brief  Check whether or not a specific PWR flag is set.
248   * @param __FLAG__ specifies the flag to check.
249   *           This parameter can be one of the following values:
250   *
251   *            /--------------------------------SR1-------------------------------/
252   *            @arg @ref PWR_FLAG_WUF1  Wake Up Flag 1. Indicates that a wakeup event
253   *                                     was received from the WKUP pin 1.
254   *            @arg @ref PWR_FLAG_WUF2  Wake Up Flag 2. Indicates that a wakeup event
255   *                                     was received from the WKUP pin 2.
256   *            @arg @ref PWR_FLAG_WUF3  Wake Up Flag 3. Indicates that a wakeup event
257   *                                     was received from the WKUP pin 3.
258   *
259   *            @arg @ref PWR_FLAG_WPVD      Wakeup PVD flag
260   *
261   *            @arg @ref PWR_FLAG_WUFI      Wake-Up Flag Internal. Set when a wakeup is detected on
262   *                                         the internal wakeup line.
263   *
264   *            @arg @ref PWR_FLAG_WRFBUSY   Wake-up radio busy flag (triggered status: wake-up event or interruption occurred at least once. Can be cleared by software)
265   *
266   *            /--------------------------------SR2-------------------------------/
267   *            @arg @ref PWR_FLAG_LDORDY   Main LDO ready flag
268   *            @arg @ref PWR_FLAG_SMPSRDY  SMPS ready Flag
269   *
270   *            @arg @ref PWR_FLAG_REGLPS Low-power Regulator 1 started: Indicates whether the regulator
271   *                                      is ready after a power-on reset or a Standby/Shutdown.
272   *            @arg @ref PWR_FLAG_REGLPF Low-power Regulator 1 flag: Indicates whether the
273   *                                      regulator 1 is in main mode or is in low-power mode.
274   *
275   *            @arg @ref PWR_FLAG_REGMRS Low-power regulator (main regulator or low-power regulator used) flag.
276   *
277   *            @arg @ref PWR_FLAG_FLASHRDY Flash ready flag
278   *
279   *            @arg @ref PWR_FLAG_VOSF   Voltage Scaling Flag. Indicates whether the regulator is ready
280   *                                      in the selected voltage range or is still changing to the required voltage level.
281   *            @arg @ref PWR_FLAG_PVDO   Power Voltage Detector Output. Indicates whether VDD voltage is below
282   *                                      or above the selected PVD threshold.
283   *
284   *            @arg @ref PWR_FLAG_PVMO3 Peripheral Voltage Monitoring Output 3. Indicates whether VDDA voltage is
285   *                                     is below or above PVM3 threshold.
286   *
287   *            @arg @ref PWR_FLAG_RFEOL Indicate whether supply voltage is below radio operating level (radio "end of life").
288   *
289   *            @arg @ref PWR_FLAG_RFBUSYS  Radio busy signal flag (current status).
290   *            @arg @ref PWR_FLAG_RFBUSYMS Radio busy masked signal flag (current status).
291   *
292   *            /----------------------------EXTSCR--------------------------/
293   *            @arg @ref PWR_FLAG_STOP      System Stop 0 or Stop1 Flag for CPU1.
294   *            @arg @ref PWR_FLAG_STOP2     System Stop 2 Flag for CPU1.
295   *            @arg @ref PWR_FLAG_SB        System Standby Flag for CPU1.
296   *
297   *            @arg @ref PWR_FLAG_C1DEEPSLEEP       CPU1 DeepSleep Flag.
298   *
299   * @retval The new state of __FLAG__ (TRUE or FALSE).
300   */
301 #endif
302 #define __HAL_PWR_GET_FLAG(__FLAG__)  ((((__FLAG__) & PWR_FLAG_REG_MASK) == PWR_FLAG_REG_SR1) ?   \
303                                        (                                                          \
304                                         PWR->SR1 & (1UL << ((__FLAG__) & 31UL))                   \
305                                        )                                                          \
306                                        :                                                          \
307                                        (                                                          \
308                                         (((__FLAG__) & PWR_FLAG_REG_MASK) == PWR_FLAG_REG_SR2) ? \
309                                         (                                                        \
310                                          PWR->SR2 & (1UL << ((__FLAG__) & 31UL))                 \
311                                         )                                                        \
312                                         :                                                        \
313                                         (                                                        \
314                                          PWR->EXTSCR & (1UL << ((__FLAG__) & 31UL))              \
315                                         )                                                        \
316                                        )                                                          \
317                                       )
318 
319 #if defined(DUAL_CORE)
320 /** @brief  Clear a specific PWR flag.
321   * @note   Clearing of flags {PWR_FLAG_STOP, PWR_FLAG_STOP2, PWR_FLAG_SB}
322   *         and flags {PWR_FLAG_C2STOP, PWR_FLAG_C2SB} are grouped:
323   *         clearing of one flag also clears the other ones.
324   * @param __FLAG__ specifies the flag to clear.
325   *          This parameter can be one of the following values:
326   *
327   *            /--------------------------------SCR (SRR)------------------------------/
328   *            @arg @ref PWR_FLAG_WU    Wake Up Flag of all pins.
329   *            @arg @ref PWR_FLAG_WUF1  Wake Up Flag 1. Indicates that a wakeup event
330   *                                     was received from the WKUP pin 1.
331   *            @arg @ref PWR_FLAG_WUF2  Wake Up Flag 2. Indicates that a wakeup event
332   *                                     was received from the WKUP pin 2.
333   *            @arg @ref PWR_FLAG_WUF3  Wake Up Flag 3. Indicates that a wakeup event
334   *                                     was received from the WKUP pin 3.
335   *
336   *            @arg @ref PWR_FLAG_WPVD      Wakeup PVD flag
337   *
338   *            @arg @ref PWR_FLAG_HOLDC2I   CPU2 on-Hold Interrupt Flag
339   *
340   *            @arg @ref PWR_FLAG_WRFBUSY   Wake-up radio busy flag (triggered status: wake-up event or interruption occurred at least once. Can be cleared by software)
341   *
342   *            /----------------------------EXTSCR--------------------------/
343   *            @arg @ref PWR_FLAG_LPMODES   System Standby Flag for CPU1.
344   *            @arg @ref PWR_FLAG_C2LPMODES System Standby Flag for CPU2.
345   *
346   * @retval None
347   */
348 #else
349 /** @brief  Clear a specific PWR flag.
350   * @note   Clearing of flags {PWR_FLAG_STOP, PWR_FLAG_STOP2, PWR_FLAG_SB}
351   *         are grouped:
352   *         clearing of one flag also clears the other ones.
353   * @param __FLAG__ specifies the flag to clear.
354   *          This parameter can be one of the following values:
355   *
356   *            /--------------------------------SCR (SRR)------------------------------/
357   *            @arg @ref PWR_FLAG_WU    Wake Up Flag of all pins.
358   *            @arg @ref PWR_FLAG_WUF1  Wake Up Flag 1. Indicates that a wakeup event
359   *                                     was received from the WKUP pin 1.
360   *            @arg @ref PWR_FLAG_WUF2  Wake Up Flag 2. Indicates that a wakeup event
361   *                                     was received from the WKUP pin 2.
362   *            @arg @ref PWR_FLAG_WUF3  Wake Up Flag 3. Indicates that a wakeup event
363   *                                     was received from the WKUP pin 3.
364   *
365   *            @arg @ref PWR_FLAG_WPVD      Wakeup PVD flag
366   *
367   *            @arg @ref PWR_FLAG_WRFBUSY   Wake-up radio busy flag (triggered status: wake-up event or interruption occurred at least once. Can be cleared by software)
368   *
369   *            /----------------------------EXTSCR--------------------------/
370   *            @arg @ref PWR_FLAG_LPMODES   System Standby Flag for CPU1.
371   *
372   * @retval None
373   */
374 #endif
375 #define __HAL_PWR_CLEAR_FLAG(__FLAG__)   ((((__FLAG__) & PWR_FLAG_REG_MASK) == PWR_FLAG_REG_EXTSCR) ?                                  \
376                                           (                                                                                            \
377                                            PWR->EXTSCR = (1UL << (((__FLAG__) & PWR_FLAG_EXTSCR_CLR_MASK) >> PWR_FLAG_EXTSCR_CLR_POS)) \
378                                           )                                                                                            \
379                                           :                                                                                            \
380                                           (                                                                                            \
381                                            (((__FLAG__)) == PWR_FLAG_WU) ?                                                             \
382                                            (PWR->SCR = PWR_SCR_CWUF) :                                                                 \
383                                            (PWR->SCR = (1UL << ((__FLAG__) & 31UL)))                                                   \
384                                           )                                                                                            \
385                                          )
386 
387 /**
388   * @brief Enable the PVD Extended Interrupt line.
389   * @retval None
390   */
391 #if defined(CORE_CM0PLUS)
392 #define __HAL_PWR_PVD_EXTI_ENABLE_IT()      LL_C2_EXTI_EnableIT_0_31(PWR_EXTI_LINE_PVD)
393 #else
394 #define __HAL_PWR_PVD_EXTI_ENABLE_IT()      LL_EXTI_EnableIT_0_31(PWR_EXTI_LINE_PVD)
395 #endif
396 
397 /**
398   * @brief Disable the PVD Extended Interrupt line.
399   * @retval None
400   */
401 #if defined(CORE_CM0PLUS)
402 #define __HAL_PWR_PVD_EXTI_DISABLE_IT()     LL_C2_EXTI_DisableIT_0_31(PWR_EXTI_LINE_PVD)
403 #else
404 #define __HAL_PWR_PVD_EXTI_DISABLE_IT()     LL_EXTI_DisableIT_0_31(PWR_EXTI_LINE_PVD)
405 #endif
406 
407 /* Note: On STM32WL series, power PVD event is not available on EXTI lines     */
408 /*       (only interruption is available through EXTI line 16).               */
409 
410 /**
411   * @brief Enable the PVD Extended Interrupt Rising Trigger.
412   * @note  PVD flag polarity is inverted compared to EXTI line, therefore
413   *        EXTI rising and falling logic edges are inverted versus PVD voltage edges.
414   * @retval None
415   */
416 #define __HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE()    LL_EXTI_EnableFallingTrig_0_31(PWR_EXTI_LINE_PVD)
417 
418 /**
419   * @brief Disable the PVD Extended Interrupt Rising Trigger.
420   * @note  PVD flag polarity is inverted compared to EXTI line, therefore
421   *        EXTI rising and falling logic edges are inverted versus PVD voltage edges.
422   * @retval None
423   */
424 #define __HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE()   LL_EXTI_DisableFallingTrig_0_31(PWR_EXTI_LINE_PVD)
425 
426 /**
427   * @brief Enable the PVD Extended Interrupt Falling Trigger.
428   * @note  PVD flag polarity is inverted compared to EXTI line, therefore
429   *        EXTI rising and falling logic edges are inverted versus PVD voltage edges.
430   * @retval None
431   */
432 #define __HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE()   LL_EXTI_EnableRisingTrig_0_31(PWR_EXTI_LINE_PVD)
433 
434 /**
435   * @brief Disable the PVD Extended Interrupt Falling Trigger.
436   * @note  PVD flag polarity is inverted compared to EXTI line, therefore
437   *        EXTI rising and falling logic edges are inverted versus PVD voltage edges.
438   * @retval None
439   */
440 #define __HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE()  LL_EXTI_DisableRisingTrig_0_31(PWR_EXTI_LINE_PVD)
441 
442 /**
443   * @brief  Enable the PVD Extended Interrupt Rising & Falling Trigger.
444   * @retval None
445   */
446 #define __HAL_PWR_PVD_EXTI_ENABLE_RISING_FALLING_EDGE()  \
447   do {                                                   \
448     __HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE();             \
449     __HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE();            \
450   } while(0)
451 
452 /**
453   * @brief Disable the PVD Extended Interrupt Rising & Falling Trigger.
454   * @retval None
455   */
456 #define __HAL_PWR_PVD_EXTI_DISABLE_RISING_FALLING_EDGE()  \
457   do {                                                    \
458     __HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE();             \
459     __HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE();            \
460   } while(0)
461 
462 /**
463   * @brief  Generate a Software interrupt on selected EXTI line.
464   * @retval None
465   */
466 #define __HAL_PWR_PVD_EXTI_GENERATE_SWIT()  LL_EXTI_GenerateSWI_0_31(PWR_EXTI_LINE_PVD)
467 
468 /**
469   * @brief Check whether or not the PVD EXTI interrupt flag is set.
470   * @retval EXTI PVD Line Status.
471   */
472 #define __HAL_PWR_PVD_EXTI_GET_FLAG()       LL_EXTI_ReadFlag_0_31(PWR_EXTI_LINE_PVD)
473 
474 /**
475   * @brief Clear the PVD EXTI interrupt flag.
476   * @retval None
477   */
478 #define __HAL_PWR_PVD_EXTI_CLEAR_FLAG()     LL_EXTI_ClearFlag_0_31(PWR_EXTI_LINE_PVD)
479 
480 /**
481   * @}
482   */
483 
484 
485 /* Private macros --------------------------------------------------------*/
486 /** @defgroup PWR_Private_Macros  PWR Private Macros
487   * @{
488   */
489 #define IS_PWR_PVD_LEVEL(__LEVEL__) (((__LEVEL__) == PWR_PVDLEVEL_0) || ((__LEVEL__) == PWR_PVDLEVEL_1)|| \
490                                      ((__LEVEL__) == PWR_PVDLEVEL_2) || ((__LEVEL__) == PWR_PVDLEVEL_3)|| \
491                                      ((__LEVEL__) == PWR_PVDLEVEL_4) || ((__LEVEL__) == PWR_PVDLEVEL_5)|| \
492                                      ((__LEVEL__) == PWR_PVDLEVEL_6) || ((__LEVEL__) == PWR_PVDLEVEL_7))
493 
494 #define IS_PWR_PVD_MODE(__MODE__)  (((__MODE__) == PWR_PVD_MODE_NORMAL)              ||\
495                                     ((__MODE__) == PWR_PVD_MODE_IT_RISING)           ||\
496                                     ((__MODE__) == PWR_PVD_MODE_IT_FALLING)          ||\
497                                     ((__MODE__) == PWR_PVD_MODE_IT_RISING_FALLING))
498 
499 #define IS_PWR_REGULATOR(__REGULATOR__)           (((__REGULATOR__) == PWR_MAINREGULATOR_ON)    || \
500                                                    ((__REGULATOR__) == PWR_LOWPOWERREGULATOR_ON))
501 
502 #define IS_PWR_SLEEP_ENTRY(__ENTRY__)             (((__ENTRY__) == PWR_SLEEPENTRY_WFI) || \
503                                                    ((__ENTRY__) == PWR_SLEEPENTRY_WFE))
504 
505 #define IS_PWR_STOP_ENTRY(__ENTRY__)              (((__ENTRY__) == PWR_STOPENTRY_WFI) || \
506                                                    ((__ENTRY__) == PWR_STOPENTRY_WFE))
507 /**
508   * @}
509   */
510 
511 /* Include PWR HAL Extended module */
512 #include "stm32wlxx_hal_pwr_ex.h"
513 
514 /* Exported functions --------------------------------------------------------*/
515 /** @defgroup PWR_Exported_Functions  PWR Exported Functions
516   * @{
517   */
518 
519 /** @defgroup PWR_Exported_Functions_Group1  Initialization and de-initialization functions
520   * @{
521   */
522 
523 /* Initialization and de-initialization functions *******************************/
524 void              HAL_PWR_DeInit(void);
525 
526 void              HAL_PWR_EnableBkUpAccess(void);
527 void              HAL_PWR_DisableBkUpAccess(void);
528 /**
529   * @}
530   */
531 
532 /** @defgroup PWR_Exported_Functions_Group2  Peripheral Control functions
533   * @{
534   */
535 /* Peripheral Control functions  ************************************************/
536 HAL_StatusTypeDef HAL_PWR_ConfigPVD(PWR_PVDTypeDef *sConfigPVD);
537 void              HAL_PWR_EnablePVD(void);
538 void              HAL_PWR_DisablePVD(void);
539 
540 /* WakeUp pins configuration functions ****************************************/
541 void              HAL_PWR_EnableWakeUpPin(uint32_t WakeUpPinPolarity);
542 void              HAL_PWR_DisableWakeUpPin(uint32_t WakeUpPinx);
543 
544 /* Low Power modes configuration functions ************************************/
545 void              HAL_PWR_EnterSTOPMode(uint32_t Regulator, uint8_t STOPEntry);
546 void              HAL_PWR_EnterSLEEPMode(uint32_t Regulator, uint8_t SLEEPEntry);
547 void              HAL_PWR_EnterSTANDBYMode(void);
548 
549 void              HAL_PWR_EnableSleepOnExit(void);
550 void              HAL_PWR_DisableSleepOnExit(void);
551 
552 void              HAL_PWR_EnableSEVOnPend(void);
553 void              HAL_PWR_DisableSEVOnPend(void);
554 
555 void              HAL_PWR_PVDCallback(void);
556 
557 /**
558   * @}
559   */
560 
561 /**
562   * @}
563   */
564 
565 /**
566   * @}
567   */
568 
569 /**
570   * @}
571   */
572 
573 /**
574   * @}
575   */
576 
577 #ifdef __cplusplus
578 }
579 #endif
580 
581 
582 #endif /* STM32WLxx_HAL_PWR_H */
583 
584