1 /**
2   ******************************************************************************
3   * @file    stm32u5xx_hal_pwr.h
4   * @author  MCD Application Team
5   * @brief   Header file of PWR HAL module.
6   ******************************************************************************
7   * @attention
8   *
9   * Copyright (c) 2021 STMicroelectronics.
10   * All rights reserved.
11   *
12   * This software component is licensed by ST under BSD 3-Clause license,
13   * the "License"; You may not use this file except in compliance with the
14   * License. You may obtain a copy of the License at:
15   *                        opensource.org/licenses/BSD-3-Clause
16   *
17   ******************************************************************************
18   */
19 
20 /* Define to prevent recursive inclusion -------------------------------------*/
21 #ifndef STM32U5xx_HAL_PWR_H
22 #define STM32U5xx_HAL_PWR_H
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif /* __cplusplus */
27 
28 /* Includes ------------------------------------------------------------------*/
29 #include "stm32u5xx_hal_def.h"
30 
31 /** @addtogroup STM32U5xx_HAL_Driver
32   * @{
33   */
34 
35 /** @addtogroup PWR
36   * @{
37   */
38 
39 /* Exported types ------------------------------------------------------------*/
40 
41 /** @defgroup PWR_Exported_Types PWR Exported Types
42   * @{
43   */
44 
45 /**
46   * @brief  PWR PVD configuration structure definition
47   */
48 typedef struct
49 {
50   uint32_t PVDLevel; /*!< Specifies the PVD detection level.
51                           This parameter can be a value of
52                           @ref PWR_PVD_Detection_Level.                       */
53 
54   uint32_t Mode;     /*!< Specifies the operating mode for the selected pins.
55                           This parameter can be a value of @ref PWR_PVD_Mode. */
56 } PWR_PVDTypeDef;
57 /**
58   * @}
59   */
60 
61 /* Exported constants --------------------------------------------------------*/
62 
63 /** @defgroup PWR_Exported_Constants PWR Exported Constants
64   * @{
65   */
66 
67 /** @defgroup PWR_PVD_Detection_Level Programmable Voltage Detection Level
68   * @{
69   */
70 #define PWR_PVDLEVEL_0 0x00000000UL                            /*!< PVD threshold around 2.0 V       */
71 #define PWR_PVDLEVEL_1 (PWR_SVMCR_PVDLS_0)                     /*!< PVD threshold around 2.2 V       */
72 #define PWR_PVDLEVEL_2 (PWR_SVMCR_PVDLS_1)                     /*!< PVD threshold around 2.4 V       */
73 #define PWR_PVDLEVEL_3 (PWR_SVMCR_PVDLS_0 | PWR_SVMCR_PVDLS_1) /*!< PVD threshold around 2.5 V       */
74 #define PWR_PVDLEVEL_4 (PWR_SVMCR_PVDLS_2)                     /*!< PVD threshold around 2.6 V       */
75 #define PWR_PVDLEVEL_5 (PWR_SVMCR_PVDLS_0 | PWR_SVMCR_PVDLS_2) /*!< PVD threshold around 2.8 V       */
76 #define PWR_PVDLEVEL_6 (PWR_SVMCR_PVDLS_1 | PWR_SVMCR_PVDLS_2) /*!< PVD threshold around 2.9 V       */
77 #define PWR_PVDLEVEL_7 (PWR_SVMCR_PVDLS)                       /*!< External input analog voltage
78                                                                     (compared internally to VREFINT) */
79 /**
80   * @}
81   */
82 
83 /** @defgroup PWR_PVD_Mode PWR PVD Mode
84   * @{
85   */
86 #define PWR_PVD_MODE_NORMAL               (0x00U) /*!< Basic Mode is used                                                 */
87 #define PWR_PVD_MODE_IT_RISING            (0x05U) /*!< External Interrupt Mode with Rising edge trigger detection         */
88 #define PWR_PVD_MODE_IT_FALLING           (0x06U) /*!< External Interrupt Mode with Falling edge trigger detection        */
89 #define PWR_PVD_MODE_IT_RISING_FALLING    (0x07U) /*!< External Interrupt Mode with Rising/Falling edge trigger detection */
90 #define PWR_PVD_MODE_EVENT_RISING         (0x09U) /*!< Event Mode with Rising edge trigger detection                      */
91 #define PWR_PVD_MODE_EVENT_FALLING        (0x0AU) /*!< Event Mode with Falling edge trigger detection                     */
92 #define PWR_PVD_MODE_EVENT_RISING_FALLING (0x0BU) /*!< Event Mode with Rising/Falling edge trigger detection              */
93 /**
94   * @}
95   */
96 
97 /** @defgroup PWR_Regulator_In_LowPower_Mode PWR Regulator State in Sleep/Stop Mode
98   * @{
99   */
100 #define PWR_MAINREGULATOR_ON     (0x00U) /*!< Main Regulator ON in Run Mode       */
101 #define PWR_LOWPOWERREGULATOR_ON (0x00U) /*!< Main Regulator ON in Low Power Mode */
102 /**
103   * @}
104   */
105 
106 /** @defgroup PWR_Sleep_Mode_Entry PWR Sleep Mode Entry
107   * @{
108   */
109 #define PWR_SLEEPENTRY_WFI (0x01U) /*!< Wait For Interruption instruction to enter Sleep mode */
110 #define PWR_SLEEPENTRY_WFE (0x02U) /*!< Wait For Event instruction to enter Sleep mode        */
111 /**
112   * @}
113   */
114 
115 /** @defgroup PWR_Stop_Mode_Entry PWR Stop Mode Entry
116   * @{
117   */
118 #define PWR_STOPENTRY_WFI (0x01U) /*!< Wait For Interruption instruction to enter Stop mode */
119 #define PWR_STOPENTRY_WFE (0x02U) /*!< Wait For Event instruction to enter Stop mode        */
120 /**
121   * @}
122   */
123 
124 /** @defgroup PWR_Flags PWR Flags
125   * @{
126   */
127 #define PWR_FLAG_VOSRDY      (0x01U) /*!< Voltage scaling ready flag                               */
128 #define PWR_FLAG_BOOSTRDY    (0x02U) /*!< EPOD booster ready flag                                  */
129 #define PWR_FLAG_STOPF       (0x03U) /*!< Stop flag                                                */
130 #define PWR_FLAG_SBF         (0x04U) /*!< Standby flag                                             */
131 #define PWR_FLAG_VDDA2RDY    (0x05U) /*!< VDDA ready flag (versus 1.8 V threshold)                 */
132 #define PWR_FLAG_VDDA1RDY    (0x06U) /*!< VDDA ready flag (versus 1.6 V threshold)                 */
133 #define PWR_FLAG_VDDIO2RDY   (0x07U) /*!< VDDIO2 ready flag                                        */
134 #define PWR_FLAG_VDDUSBRDY   (0x08U) /*!< VDDUSB ready flag                                        */
135 #define PWR_FLAG_ACTVOSRDY   (0x09U) /*!< Currently applied VOS ready flag                         */
136 #define PWR_FLAG_PVDO        (0x0AU) /*!< VDD voltage detector output flag                         */
137 #define PWR_FLAG_REGS        (0x0BU) /*!< Regulator selection flag                                 */
138 #define PWR_FLAG_TEMPH       (0x0CU) /*!< Temperature level flag (versus high threshold)           */
139 #define PWR_FLAG_TEMPL       (0x0DU) /*!< Temperature level flag (versus low threshold)            */
140 #define PWR_FLAG_VBATH       (0x0EU) /*!< Backup domain voltage level flag (versus high threshold) */
141 /**
142   * @}
143   */
144 
145 /** @defgroup PWR_WakeUp_Lines_Flags PWR Wakeup Lines Flags
146   * @{
147   */
148 #define PWR_WAKEUP_FLAG1    (0x10U) /*!< Wakeup flag 1   */
149 #define PWR_WAKEUP_FLAG2    (0x20U) /*!< Wakeup flag 2   */
150 #define PWR_WAKEUP_FLAG3    (0x30U) /*!< Wakeup flag 3   */
151 #define PWR_WAKEUP_FLAG4    (0x40U) /*!< Wakeup flag 4   */
152 #define PWR_WAKEUP_FLAG5    (0x50U) /*!< Wakeup flag 5   */
153 #define PWR_WAKEUP_FLAG6    (0x60U) /*!< Wakeup flag 6   */
154 #define PWR_WAKEUP_FLAG7    (0x70U) /*!< Wakeup flag 7   */
155 #define PWR_WAKEUP_FLAG8    (0x80U) /*!< Wakeup flag 8   */
156 #define PWR_WAKEUP_ALL_FLAG (0x90U) /*!< Wakeup flag all */
157 /**
158   * @}
159   */
160 
161 /** @defgroup PWR_WakeUp_Pin_High_Polarity PWR Wake Up Pins High Polarity
162   * @{
163   */
164 #define PWR_WAKEUP_PIN1_HIGH_0 (PWR_WUCR1_WUPEN1 | PWR_WAKEUP1_SOURCE_SELECTION_0) /*!< PA0  : Wakeup pin 1 (high polarity) */
165 #define PWR_WAKEUP_PIN1_HIGH_1 (PWR_WUCR1_WUPEN1 | PWR_WAKEUP1_SOURCE_SELECTION_1) /*!< PB2  : Wakeup pin 1 (high polarity) */
166 #define PWR_WAKEUP_PIN1_HIGH_2 (PWR_WUCR1_WUPEN1 | PWR_WAKEUP1_SOURCE_SELECTION_2) /*!< PE4  : Wakeup pin 1 (high polarity) */
167 
168 #define PWR_WAKEUP_PIN2_HIGH_0 (PWR_WUCR1_WUPEN2 | PWR_WAKEUP2_SOURCE_SELECTION_0) /*!< PA4  : Wakeup pin 2 (high polarity) */
169 #define PWR_WAKEUP_PIN2_HIGH_1 (PWR_WUCR1_WUPEN2 | PWR_WAKEUP2_SOURCE_SELECTION_1) /*!< PC13 : Wakeup pin 2 (high polarity) */
170 #define PWR_WAKEUP_PIN2_HIGH_2 (PWR_WUCR1_WUPEN2 | PWR_WAKEUP2_SOURCE_SELECTION_2) /*!< PE5  : Wakeup pin 2 (high polarity) */
171 
172 #define PWR_WAKEUP_PIN3_HIGH_0 (PWR_WUCR1_WUPEN3 | PWR_WAKEUP3_SOURCE_SELECTION_0) /*!< PE6  : Wakeup pin 3 (high polarity) */
173 #define PWR_WAKEUP_PIN3_HIGH_1 (PWR_WUCR1_WUPEN3 | PWR_WAKEUP3_SOURCE_SELECTION_1) /*!< PA1  : Wakeup pin 3 (high polarity) */
174 #define PWR_WAKEUP_PIN3_HIGH_2 (PWR_WUCR1_WUPEN3 | PWR_WAKEUP3_SOURCE_SELECTION_2) /*!< PB6  : Wakeup pin 3 (high polarity) */
175 
176 #define PWR_WAKEUP_PIN4_HIGH_0 (PWR_WUCR1_WUPEN4 | PWR_WAKEUP4_SOURCE_SELECTION_0) /*!< PA2  : Wakeup pin 4 (high polarity) */
177 #define PWR_WAKEUP_PIN4_HIGH_1 (PWR_WUCR1_WUPEN4 | PWR_WAKEUP4_SOURCE_SELECTION_1) /*!< PB1  : Wakeup pin 4 (high polarity) */
178 #define PWR_WAKEUP_PIN4_HIGH_2 (PWR_WUCR1_WUPEN4 | PWR_WAKEUP4_SOURCE_SELECTION_2) /*!< PB7  : Wakeup pin 4 (high polarity) */
179 
180 #define PWR_WAKEUP_PIN5_HIGH_0 (PWR_WUCR1_WUPEN5 | PWR_WAKEUP5_SOURCE_SELECTION_0) /*!< PC5  : Wakeup pin 5 (high polarity) */
181 #define PWR_WAKEUP_PIN5_HIGH_1 (PWR_WUCR1_WUPEN5 | PWR_WAKEUP5_SOURCE_SELECTION_1) /*!< PA3  : Wakeup pin 5 (high polarity) */
182 #define PWR_WAKEUP_PIN5_HIGH_2 (PWR_WUCR1_WUPEN5 | PWR_WAKEUP5_SOURCE_SELECTION_2) /*!< PB8  : Wakeup pin 5 (high polarity) */
183 
184 #define PWR_WAKEUP_PIN6_HIGH_0 (PWR_WUCR1_WUPEN6 | PWR_WAKEUP6_SOURCE_SELECTION_0) /*!< PB5  : Wakeup pin 6 (high polarity) */
185 #define PWR_WAKEUP_PIN6_HIGH_1 (PWR_WUCR1_WUPEN6 | PWR_WAKEUP6_SOURCE_SELECTION_1) /*!< PA5  : Wakeup pin 6 (high polarity) */
186 #define PWR_WAKEUP_PIN6_HIGH_2 (PWR_WUCR1_WUPEN6 | PWR_WAKEUP6_SOURCE_SELECTION_2) /*!< PE7  : Wakeup pin 6 (high polarity) */
187 #define PWR_WAKEUP_PIN6_HIGH_3 (PWR_WUCR1_WUPEN6 | PWR_WAKEUP6_SOURCE_SELECTION_3) /*!< RTC  : Wakeup pin 6 (high polarity) */
188 
189 #define PWR_WAKEUP_PIN7_HIGH_0 (PWR_WUCR1_WUPEN7 | PWR_WAKEUP7_SOURCE_SELECTION_0) /*!< PB15 : Wakeup pin 7 (high polarity) */
190 #define PWR_WAKEUP_PIN7_HIGH_1 (PWR_WUCR1_WUPEN7 | PWR_WAKEUP7_SOURCE_SELECTION_1) /*!< PA6  : Wakeup pin 7 (high polarity) */
191 #define PWR_WAKEUP_PIN7_HIGH_2 (PWR_WUCR1_WUPEN7 | PWR_WAKEUP7_SOURCE_SELECTION_2) /*!< PE8  : Wakeup pin 7 (high polarity) */
192 #define PWR_WAKEUP_PIN7_HIGH_3 (PWR_WUCR1_WUPEN7 | PWR_WAKEUP7_SOURCE_SELECTION_3) /*!< RTC  : Wakeup pin 7 (high polarity) */
193 
194 #define PWR_WAKEUP_PIN8_HIGH_0 (PWR_WUCR1_WUPEN8 | PWR_WAKEUP8_SOURCE_SELECTION_0) /*!< PF2  : Wakeup pin 8 (high polarity) */
195 #define PWR_WAKEUP_PIN8_HIGH_1 (PWR_WUCR1_WUPEN8 | PWR_WAKEUP8_SOURCE_SELECTION_1) /*!< PA7  : Wakeup pin 8 (high polarity) */
196 #define PWR_WAKEUP_PIN8_HIGH_2 (PWR_WUCR1_WUPEN8 | PWR_WAKEUP8_SOURCE_SELECTION_2) /*!< PB10 : Wakeup pin 8 (high polarity) */
197 #define PWR_WAKEUP_PIN8_HIGH_3 (PWR_WUCR1_WUPEN8 | PWR_WAKEUP8_SOURCE_SELECTION_3) /*!< RTC  : Wakeup pin 8 (high polarity) */
198 /**
199   * @}
200   */
201 
202 /** @defgroup PWR_WakeUp_Pin_Low_Polarity PWR Wake Up Pins Low Polarity
203   * @{
204   */
205 #define PWR_WAKEUP_PIN1_LOW_0 (PWR_WUCR1_WUPEN1 | PWR_WAKEUP1_POLARITY_LOW | PWR_WAKEUP1_SOURCE_SELECTION_0) /*!< PA0  : Wakeup pin 1 (low polarity) */
206 #define PWR_WAKEUP_PIN1_LOW_1 (PWR_WUCR1_WUPEN1 | PWR_WAKEUP1_POLARITY_LOW | PWR_WAKEUP1_SOURCE_SELECTION_1) /*!< PB2  : Wakeup pin 1 (low polarity) */
207 #define PWR_WAKEUP_PIN1_LOW_2 (PWR_WUCR1_WUPEN1 | PWR_WAKEUP1_POLARITY_LOW | PWR_WAKEUP1_SOURCE_SELECTION_2) /*!< PE4  : Wakeup pin 1 (low polarity) */
208 
209 #define PWR_WAKEUP_PIN2_LOW_0 (PWR_WUCR1_WUPEN2 | PWR_WAKEUP2_POLARITY_LOW | PWR_WAKEUP2_SOURCE_SELECTION_0) /*!< PA4  : Wakeup pin 2 (low polarity) */
210 #define PWR_WAKEUP_PIN2_LOW_1 (PWR_WUCR1_WUPEN2 | PWR_WAKEUP2_POLARITY_LOW | PWR_WAKEUP2_SOURCE_SELECTION_1) /*!< PC13 : Wakeup pin 2 (low polarity) */
211 #define PWR_WAKEUP_PIN2_LOW_2 (PWR_WUCR1_WUPEN2 | PWR_WAKEUP2_POLARITY_LOW | PWR_WAKEUP2_SOURCE_SELECTION_2) /*!< PE5  : Wakeup pin 2 (low polarity) */
212 
213 #define PWR_WAKEUP_PIN3_LOW_0 (PWR_WUCR1_WUPEN3 | PWR_WAKEUP3_POLARITY_LOW | PWR_WAKEUP3_SOURCE_SELECTION_0) /*!< PE6  : Wakeup pin 3 (low polarity) */
214 #define PWR_WAKEUP_PIN3_LOW_1 (PWR_WUCR1_WUPEN3 | PWR_WAKEUP3_POLARITY_LOW | PWR_WAKEUP3_SOURCE_SELECTION_1) /*!< PA1  : Wakeup pin 3 (low polarity) */
215 #define PWR_WAKEUP_PIN3_LOW_2 (PWR_WUCR1_WUPEN3 | PWR_WAKEUP3_POLARITY_LOW | PWR_WAKEUP3_SOURCE_SELECTION_2) /*!< PB6  : Wakeup pin 3 (low polarity) */
216 
217 #define PWR_WAKEUP_PIN4_LOW_0 (PWR_WUCR1_WUPEN4 | PWR_WAKEUP4_POLARITY_LOW | PWR_WAKEUP4_SOURCE_SELECTION_0) /*!< PA2  : Wakeup pin 4 (low polarity) */
218 #define PWR_WAKEUP_PIN4_LOW_1 (PWR_WUCR1_WUPEN4 | PWR_WAKEUP4_POLARITY_LOW | PWR_WAKEUP4_SOURCE_SELECTION_1) /*!< PB1  : Wakeup pin 4 (low polarity) */
219 #define PWR_WAKEUP_PIN4_LOW_2 (PWR_WUCR1_WUPEN4 | PWR_WAKEUP4_POLARITY_LOW | PWR_WAKEUP4_SOURCE_SELECTION_2) /*!< PB7  : Wakeup pin 4 (low polarity) */
220 
221 #define PWR_WAKEUP_PIN5_LOW_0 (PWR_WUCR1_WUPEN5 | PWR_WAKEUP5_POLARITY_LOW | PWR_WAKEUP5_SOURCE_SELECTION_0) /*!< PC5  : Wakeup pin 5 (low polarity) */
222 #define PWR_WAKEUP_PIN5_LOW_1 (PWR_WUCR1_WUPEN5 | PWR_WAKEUP5_POLARITY_LOW | PWR_WAKEUP5_SOURCE_SELECTION_1) /*!< PA3  : Wakeup pin 5 (low polarity) */
223 #define PWR_WAKEUP_PIN5_LOW_2 (PWR_WUCR1_WUPEN5 | PWR_WAKEUP5_POLARITY_LOW | PWR_WAKEUP5_SOURCE_SELECTION_2) /*!< PB8  : Wakeup pin 5 (low polarity) */
224 
225 #define PWR_WAKEUP_PIN6_LOW_0 (PWR_WUCR1_WUPEN6 | PWR_WAKEUP6_POLARITY_LOW | PWR_WAKEUP6_SOURCE_SELECTION_0) /*!< PB5  : Wakeup pin 6 (low polarity) */
226 #define PWR_WAKEUP_PIN6_LOW_1 (PWR_WUCR1_WUPEN6 | PWR_WAKEUP6_POLARITY_LOW | PWR_WAKEUP6_SOURCE_SELECTION_1) /*!< PA5  : Wakeup pin 6 (low polarity) */
227 #define PWR_WAKEUP_PIN6_LOW_2 (PWR_WUCR1_WUPEN6 | PWR_WAKEUP6_POLARITY_LOW | PWR_WAKEUP6_SOURCE_SELECTION_2) /*!< PE7  : Wakeup pin 6 (low polarity) */
228 #define PWR_WAKEUP_PIN6_LOW_3 (PWR_WUCR1_WUPEN6 | PWR_WAKEUP6_POLARITY_LOW | PWR_WAKEUP6_SOURCE_SELECTION_3) /*!< RTC  : Wakeup pin 6 (low polarity) */
229 
230 #define PWR_WAKEUP_PIN7_LOW_0 (PWR_WUCR1_WUPEN7 | PWR_WAKEUP7_POLARITY_LOW | PWR_WAKEUP7_SOURCE_SELECTION_0) /*!< PB15 : Wakeup pin 7 (low polarity) */
231 #define PWR_WAKEUP_PIN7_LOW_1 (PWR_WUCR1_WUPEN7 | PWR_WAKEUP7_POLARITY_LOW | PWR_WAKEUP7_SOURCE_SELECTION_1) /*!< PA6  : Wakeup pin 7 (low polarity) */
232 #define PWR_WAKEUP_PIN7_LOW_2 (PWR_WUCR1_WUPEN7 | PWR_WAKEUP7_POLARITY_LOW | PWR_WAKEUP7_SOURCE_SELECTION_2) /*!< PE8  : Wakeup pin 7 (low polarity) */
233 #define PWR_WAKEUP_PIN7_LOW_3 (PWR_WUCR1_WUPEN7 | PWR_WAKEUP7_POLARITY_LOW | PWR_WAKEUP7_SOURCE_SELECTION_3) /*!< RTC  : Wakeup pin 7 (low polarity) */
234 
235 #define PWR_WAKEUP_PIN8_LOW_0 (PWR_WUCR1_WUPEN8 | PWR_WAKEUP8_POLARITY_LOW | PWR_WAKEUP8_SOURCE_SELECTION_0) /*!< PF2  : Wakeup pin 8 (low polarity) */
236 #define PWR_WAKEUP_PIN8_LOW_1 (PWR_WUCR1_WUPEN8 | PWR_WAKEUP8_POLARITY_LOW | PWR_WAKEUP8_SOURCE_SELECTION_1) /*!< PA7  : Wakeup pin 8 (low polarity) */
237 #define PWR_WAKEUP_PIN8_LOW_2 (PWR_WUCR1_WUPEN8 | PWR_WAKEUP8_POLARITY_LOW | PWR_WAKEUP8_SOURCE_SELECTION_2) /*!< PB10 : Wakeup pin 8 (low polarity) */
238 #define PWR_WAKEUP_PIN8_LOW_3 (PWR_WUCR1_WUPEN8 | PWR_WAKEUP8_POLARITY_LOW | PWR_WAKEUP8_SOURCE_SELECTION_3) /*!< RTC  : Wakeup pin 8 (low polarity) */
239 /**
240   * @}
241   */
242 
243 /** @defgroup PWR_WakeUp_Pins PWR Wake Up Pins (Default polarity and default pin selection)
244   * @{
245   */
246 #define PWR_WAKEUP_PIN1 (PWR_WUCR1_WUPEN1) /*!< PA0  : Wakeup pin 1 (high polarity) */
247 #define PWR_WAKEUP_PIN2 (PWR_WUCR1_WUPEN2) /*!< PA4  : Wakeup pin 2 (high polarity) */
248 #define PWR_WAKEUP_PIN3 (PWR_WUCR1_WUPEN3) /*!< PE6  : Wakeup pin 3 (high polarity) */
249 #define PWR_WAKEUP_PIN4 (PWR_WUCR1_WUPEN4) /*!< PA2  : Wakeup pin 4 (high polarity) */
250 #define PWR_WAKEUP_PIN5 (PWR_WUCR1_WUPEN5) /*!< PC5  : Wakeup pin 5 (high polarity) */
251 #define PWR_WAKEUP_PIN6 (PWR_WUCR1_WUPEN6) /*!< PB5  : Wakeup pin 6 (high polarity) */
252 #define PWR_WAKEUP_PIN7 (PWR_WUCR1_WUPEN7) /*!< PB15 : Wakeup pin 7 (high polarity) */
253 #define PWR_WAKEUP_PIN8 (PWR_WUCR1_WUPEN8) /*!< PF2  : Wakeup pin 8 (high polarity) */
254 /**
255   * @}
256   */
257 
258 /** @defgroup PWR_Items PWR Items
259   * @{
260   */
261 #define PWR_WKUP1 (PWR_SECCFGR_WUP1SEC) /*!< WUP1 secure protection                             */
262 #define PWR_WKUP2 (PWR_SECCFGR_WUP2SEC) /*!< WUP2 secure protection                             */
263 #define PWR_WKUP3 (PWR_SECCFGR_WUP3SEC) /*!< WUP3 secure protection                             */
264 #define PWR_WKUP4 (PWR_SECCFGR_WUP4SEC) /*!< WUP4 secure protection                             */
265 #define PWR_WKUP5 (PWR_SECCFGR_WUP5SEC) /*!< WUP5 secure protection                             */
266 #define PWR_WKUP6 (PWR_SECCFGR_WUP6SEC) /*!< WUP6 secure protection                             */
267 #define PWR_WKUP7 (PWR_SECCFGR_WUP7SEC) /*!< WUP7 secure protection                             */
268 #define PWR_WKUP8 (PWR_SECCFGR_WUP8SEC) /*!< WUP8 secure protection                             */
269 #define PWR_LPM   (PWR_SECCFGR_LPMSEC)  /*!< Low power modes secure protection                  */
270 #define PWR_VDM   (PWR_SECCFGR_VDMSEC)  /*!< Voltage detection and monitoring secure protection */
271 #define PWR_VB    (PWR_SECCFGR_VBSEC)   /*!< Backup domain secure protection                    */
272 #define PWR_APC   (PWR_SECCFGR_APCSEC)  /*!< Pull-up/pull-down secure protection                */
273 #define PWR_ALL   (PWR_WKUP1 | PWR_WKUP2 | PWR_WKUP3 | PWR_WKUP4 | \
274                    PWR_WKUP5 | PWR_WKUP7 | PWR_WKUP6 | PWR_WKUP8 | \
275                    PWR_LPM   | PWR_VDM   | PWR_VB    | PWR_APC)
276 /**
277   * @}
278   */
279 
280 /** @defgroup PWR_Attributes PWR Attributes
281   * @brief PWR Privilege/NPrivilege and Secure/NSecure Attributes
282   * @{
283   */
284 #define PWR_NSEC_PRIV  (PWR_ITEM_ATTR_NSEC_PRIV_MASK | 0x01U) /*!< NSecure and Privileged attribute  */
285 #define PWR_NSEC_NPRIV (PWR_ITEM_ATTR_NSEC_PRIV_MASK)         /*!< NSecure and NPrivileged attribute */
286 #define PWR_SEC_PRIV   (PWR_ITEM_ATTR_SEC_PRIV_MASK  | 0x02U) /*!< Secure and Privileged attribute   */
287 #define PWR_SEC_NPRIV  (PWR_ITEM_ATTR_SEC_PRIV_MASK)          /*!< Secure and NPrivileged attribute  */
288 /**
289   * @}
290   */
291 
292 /**
293   * @}
294   */
295 
296 /* Exported macros -----------------------------------------------------------*/
297 
298 /** @defgroup PWR_Exported_Macros PWR Exported Macros
299   * @{
300   */
301 
302 /** @brief  Check PWR flags are set or not.
303   * @param  __FLAG__ : Specifies the flag to check.
304   *                    This parameter can be one of the following values :
305   *                    @arg @ref PWR_FLAG_VOSRDY      : Voltage scaling ready flag.
306   *                                                     Indicates that the Vcore level at or above VOS selected level.
307   *                    @arg @ref PWR_FLAG_BOOSTRDY    : EPOD booster ready flag.
308   *                                                     Indicates that EPOD booster ready,
309   *                                                     frequency could be higher than 50 MHz.
310   *                    @arg @ref PWR_FLAG_STOPF       : Stop flag.
311   *                                                     Indicates that the device was resumed from Stop mode.
312   *                    @arg @ref PWR_FLAG_SBF         : Standby flag.
313   *                                                     Indicates that the device was resumed from Standby mode.
314   *                    @arg @ref PWR_FLAG_VDDA2RDY    : VDDA2 ready flag (versus 1.8 V threshold).
315   *                                                     Indicates that VDDA is equal or above the threshold
316   *                                                     of the VDDA voltage monitor 2 (around 1.8 V).
317   *                    @arg @ref PWR_FLAG_VDDA1RDY    : VDDA1 ready flag (versus 1.6 V threshold).
318   *                                                     Indicates that VDDA is equal or above the threshold
319   *                                                     of the VDDA voltage monitor 1 (around 1.6 V).
320   *                    @arg @ref PWR_FLAG_VDDIO2RDY   : VDDIO2 ready flag (versus 0.9 V threshold).
321   *                                                     Indicates that VDDIO2 is equal or above the threshold
322   *                                                     of the VDDIO2 voltage monitor (around 0.9 V).
323   *                    @arg @ref PWR_FLAG_VDDUSBRDY   : VDDUSB ready flag (versus 1.2 V threshold).
324   *                                                     Indicates that VDDUSB is equal or above the threshold
325   *                                                     of the VDDUSB voltage monitor (around 1.2 V).
326   *                    @arg @ref PWR_FLAG_ACTVOSRDY   : Currently applied VOS ready flag.
327   *                                                     Indicates that Vcore is equal to the current
328   *                                                     voltage scaling provided by ACTVOS.
329   *                    @arg @ref PWR_FLAG_PVDO VDD    : Voltage detector output flag.
330   *                                                     Indicates that Vdd is equal or above
331   *                                                     the PVD threshold selected by PVDLS.
332   *                    @arg @ref PWR_FLAG_REGS        : Regulator selection flag.
333   *                                                     Indicates the regulator selected.
334   *                    @arg @ref PWR_FLAG_TEMPH       : Temperature level flag (versus high threshold).
335   *                                                     Indicates the temperature is equal or above high threshold.
336   *                    @arg @ref PWR_FLAG_TEMPL       : Temperature level flag (versus low threshold).
337   *                                                     Indicates the temperature is equal or above low threshold.
338   *                    @arg @ref PWR_FLAG_VBATH       : Backup domain voltage level flag (versus high threshold).
339   *                                                     Indicates the backup domain voltage
340   *                                                     level is equal or above high threshold.
341   *                    @arg @ref PWR_WAKEUP_FLAG1     : Wakeup flag 1.
342   *                                                     Indicates that a wakeup event was received from the WKUP line 1.
343   *                    @arg @ref PWR_WAKEUP_FLAG2     : Wakeup flag 2.
344   *                                                     Indicates that a wakeup event was received from the WKUP line 2.
345   *                    @arg @ref PWR_WAKEUP_FLAG3     : Wakeup flag 3.
346   *                                                     Indicates that a wakeup event was received from the WKUP line 3.
347   *                    @arg @ref PWR_WAKEUP_FLAG4     : Wakeup flag 4.
348   *                                                     Indicates that a wakeup event was received from the WKUP line 4.
349   *                    @arg @ref PWR_WAKEUP_FLAG5     : Wakeup flag 5.
350   *                                                     Indicates that a wakeup event was received from the WKUP line 5.
351   *                    @arg @ref PWR_WAKEUP_FLAG6     : Wakeup flag 6.
352   *                                                     Indicates that a wakeup event was received from the WKUP line 6.
353   *                    @arg @ref PWR_WAKEUP_FLAG7     : Wakeup flag 7.
354   *                                                     Indicates that a wakeup event was received from the WKUP line 7.
355   *                    @arg @ref PWR_WAKEUP_FLAG8     : Wakeup flag 8.
356   *                                                     Indicates that a wakeup event was received from the WKUP line 8.
357   * @retval The state of __FLAG__ (TRUE or FALSE).
358   */
359 #define __HAL_PWR_GET_FLAG(__FLAG__)                                                                            \
360   (                                                                                                             \
361       ((__FLAG__) == PWR_FLAG_VOSRDY)    ? (READ_BIT(PWR->VOSR, PWR_VOSR_VOSRDY)      == PWR_VOSR_VOSRDY)     : \
362       ((__FLAG__) == PWR_FLAG_BOOSTRDY)  ? (READ_BIT(PWR->VOSR, PWR_VOSR_BOOSTRDY)    == PWR_VOSR_BOOSTRDY)   : \
363       ((__FLAG__) == PWR_FLAG_STOPF)     ? (READ_BIT(PWR->SR, PWR_SR_STOPF)           == PWR_SR_STOPF)        : \
364       ((__FLAG__) == PWR_FLAG_SBF)       ? (READ_BIT(PWR->SR, PWR_SR_SBF)             == PWR_SR_SBF)          : \
365       ((__FLAG__) == PWR_FLAG_VDDA2RDY)  ? (READ_BIT(PWR->SVMSR, PWR_SVMSR_VDDA2RDY)  == PWR_SVMSR_VDDA2RDY)  : \
366       ((__FLAG__) == PWR_FLAG_VDDA1RDY)  ? (READ_BIT(PWR->SVMSR, PWR_SVMSR_VDDA1RDY)  == PWR_SVMSR_VDDA1RDY)  : \
367       ((__FLAG__) == PWR_FLAG_VDDIO2RDY) ? (READ_BIT(PWR->SVMSR, PWR_SVMSR_VDDIO2RDY) == PWR_SVMSR_VDDIO2RDY) : \
368       ((__FLAG__) == PWR_FLAG_VDDUSBRDY) ? (READ_BIT(PWR->SVMSR, PWR_SVMSR_VDDUSBRDY) == PWR_SVMSR_VDDUSBRDY) : \
369       ((__FLAG__) == PWR_FLAG_ACTVOSRDY) ? (READ_BIT(PWR->SVMSR, PWR_SVMSR_ACTVOSRDY) == PWR_SVMSR_ACTVOSRDY) : \
370       ((__FLAG__) == PWR_FLAG_PVDO)      ? (READ_BIT(PWR->SVMSR, PWR_SVMSR_PVDO)      == PWR_SVMSR_PVDO)      : \
371       ((__FLAG__) == PWR_FLAG_REGS)      ? (READ_BIT(PWR->SVMSR, PWR_SVMSR_REGS)      == PWR_SVMSR_REGS)      : \
372       ((__FLAG__) == PWR_FLAG_TEMPH)     ? (READ_BIT(PWR->BDSR, PWR_BDSR_TEMPH)       == PWR_BDSR_TEMPH)      : \
373       ((__FLAG__) == PWR_FLAG_TEMPL)     ? (READ_BIT(PWR->BDSR, PWR_BDSR_TEMPL)       == PWR_BDSR_TEMPL)      : \
374       ((__FLAG__) == PWR_FLAG_VBATH)     ? (READ_BIT(PWR->BDSR, PWR_BDSR_VBATH)       == PWR_BDSR_VBATH)      : \
375       ((__FLAG__) == PWR_WAKEUP_FLAG1)   ? (READ_BIT(PWR->WUSR, PWR_WUSR_WUF1)        == PWR_WUSR_WUF1)       : \
376       ((__FLAG__) == PWR_WAKEUP_FLAG2)   ? (READ_BIT(PWR->WUSR, PWR_WUSR_WUF2)        == PWR_WUSR_WUF2)       : \
377       ((__FLAG__) == PWR_WAKEUP_FLAG3)   ? (READ_BIT(PWR->WUSR, PWR_WUSR_WUF3)        == PWR_WUSR_WUF3)       : \
378       ((__FLAG__) == PWR_WAKEUP_FLAG4)   ? (READ_BIT(PWR->WUSR, PWR_WUSR_WUF4)        == PWR_WUSR_WUF4)       : \
379       ((__FLAG__) == PWR_WAKEUP_FLAG5)   ? (READ_BIT(PWR->WUSR, PWR_WUSR_WUF5)        == PWR_WUSR_WUF5)       : \
380       ((__FLAG__) == PWR_WAKEUP_FLAG6)   ? (READ_BIT(PWR->WUSR, PWR_WUSR_WUF6)        == PWR_WUSR_WUF6)       : \
381       ((__FLAG__) == PWR_WAKEUP_FLAG7)   ? (READ_BIT(PWR->WUSR, PWR_WUSR_WUF7)        == PWR_WUSR_WUF7)       : \
382       (READ_BIT(PWR->WUSR, PWR_WUSR_WUF8) == PWR_WUSR_WUF8))
383 
384 /** @brief  Clear PWR flags.
385   * @param  __FLAG__ : Specifies the flag to clear.
386   *                    This parameter can be one of the following values :
387   *                    @arg @ref PWR_FLAG_STOPF     : Stop flag.
388   *                                                   Indicates that the device was resumed from Stop mode.
389   *                    @arg @ref PWR_FLAG_SBF       : Standby flag.
390   *                                                   Indicates that the device was resumed from Standby mode.
391   *                    @arg @ref PWR_WAKEUP_FLAG1   : Wakeup flag 1.
392   *                                                   Indicates that a wakeup event was received from the WKUP line 1.
393   *                    @arg @ref PWR_WAKEUP_FLAG2   : Wakeup flag 2.
394   *                                                   Indicates that a wakeup event was received from the WKUP line 2.
395   *                    @arg @ref PWR_WAKEUP_FLAG3   : Wakeup flag 3.
396   *                                                   Indicates that a wakeup event was received from the WKUP line 3.
397   *                    @arg @ref PWR_WAKEUP_FLAG4   : Wakeup flag 4.
398   *                                                   Indicates that a wakeup event was received from the WKUP line 4.
399   *                    @arg @ref PWR_WAKEUP_FLAG5   : Wakeup flag 5.
400   *                                                   Indicates that a wakeup event was received from the WKUP line 5.
401   *                    @arg @ref PWR_WAKEUP_FLAG6   : Wakeup flag 6.
402   *                                                   Indicates that a wakeup event was received from the WKUP line 6.
403   *                    @arg @ref PWR_WAKEUP_FLAG7   : Wakeup flag 7.
404   *                                                   Indicates that a wakeup event was received from the WKUP line 7.
405   *                    @arg @ref PWR_WAKEUP_FLAG8   : Wakeup flag 8.
406   *                                                   Indicates that a wakeup event was received from the WKUP line 8.
407   * @retval None.
408   */
409 #define __HAL_PWR_CLEAR_FLAG(__FLAG__)                                               \
410   (                                                                                  \
411       ((__FLAG__) == PWR_FLAG_STOPF)      ? (SET_BIT(PWR->SR, PWR_SR_CSSF))        : \
412       ((__FLAG__) == PWR_FLAG_SBF)        ? (SET_BIT(PWR->SR, PWR_SR_CSSF))        : \
413       ((__FLAG__) == PWR_WAKEUP_FLAG1)    ? (SET_BIT(PWR->WUSCR, PWR_WUSCR_CWUF1)) : \
414       ((__FLAG__) == PWR_WAKEUP_FLAG2)    ? (SET_BIT(PWR->WUSCR, PWR_WUSCR_CWUF2)) : \
415       ((__FLAG__) == PWR_WAKEUP_FLAG3)    ? (SET_BIT(PWR->WUSCR, PWR_WUSCR_CWUF3)) : \
416       ((__FLAG__) == PWR_WAKEUP_FLAG4)    ? (SET_BIT(PWR->WUSCR, PWR_WUSCR_CWUF4)) : \
417       ((__FLAG__) == PWR_WAKEUP_FLAG5)    ? (SET_BIT(PWR->WUSCR, PWR_WUSCR_CWUF5)) : \
418       ((__FLAG__) == PWR_WAKEUP_FLAG6)    ? (SET_BIT(PWR->WUSCR, PWR_WUSCR_CWUF6)) : \
419       ((__FLAG__) == PWR_WAKEUP_FLAG7)    ? (SET_BIT(PWR->WUSCR, PWR_WUSCR_CWUF7)) : \
420       ((__FLAG__) == PWR_WAKEUP_FLAG8)    ? (SET_BIT(PWR->WUSCR, PWR_WUSCR_CWUF8)) : \
421       (SET_BIT(PWR->WUSCR, PWR_WUSCR_CWUF)))
422 
423 /**
424   * @brief  Enable the PVD Extended Interrupt Line.
425   * @retval None.
426   */
427 #define __HAL_PWR_PVD_EXTI_ENABLE_IT() SET_BIT(EXTI->IMR1, PWR_EXTI_LINE_PVD)
428 
429 /**
430   * @brief  Disable the PVD Extended Interrupt Line.
431   * @retval None.
432   */
433 #define __HAL_PWR_PVD_EXTI_DISABLE_IT() CLEAR_BIT(EXTI->IMR1, PWR_EXTI_LINE_PVD)
434 
435 /**
436   * @brief  Enable the PVD Event Line.
437   * @retval None.
438   */
439 #define __HAL_PWR_PVD_EXTI_ENABLE_EVENT() SET_BIT(EXTI->EMR1, PWR_EXTI_LINE_PVD)
440 
441 /**
442   * @brief  Disable the PVD Event Line.
443   * @retval None.
444   */
445 #define __HAL_PWR_PVD_EXTI_DISABLE_EVENT() CLEAR_BIT(EXTI->EMR1, PWR_EXTI_LINE_PVD)
446 
447 /**
448   * @brief  Enable the PVD Extended Interrupt Rising Trigger.
449   * @retval None.
450   */
451 #define __HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE() SET_BIT(EXTI->RTSR1, PWR_EXTI_LINE_PVD)
452 
453 /**
454   * @brief  Disable the PVD Extended Interrupt Rising Trigger.
455   * @retval None.
456   */
457 #define __HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE() CLEAR_BIT(EXTI->RTSR1, PWR_EXTI_LINE_PVD)
458 
459 /**
460   * @brief  Enable the PVD Extended Interrupt Falling Trigger.
461   * @retval None.
462   */
463 #define __HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE() SET_BIT(EXTI->FTSR1, PWR_EXTI_LINE_PVD)
464 
465 /**
466   * @brief  Disable the PVD Extended Interrupt Falling Trigger.
467   * @retval None.
468   */
469 #define __HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE() CLEAR_BIT(EXTI->FTSR1, PWR_EXTI_LINE_PVD)
470 
471 /**
472   * @brief  Enable the PVD Extended Interrupt Rising & Falling Trigger.
473   * @retval None.
474   */
475 #define __HAL_PWR_PVD_EXTI_ENABLE_RISING_FALLING_EDGE() \
476   do                                                    \
477   {                                                     \
478     __HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE();            \
479     __HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE();           \
480   } while(0)
481 
482 /**
483   * @brief  Disable the PVD Extended Interrupt Rising & Falling Trigger.
484   * @retval None.
485   */
486 #define __HAL_PWR_PVD_EXTI_DISABLE_RISING_FALLING_EDGE() \
487   do                                                     \
488   {                                                      \
489     __HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE();            \
490     __HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE();           \
491   } while(0)
492 
493 /**
494   * @brief  Generate a Software Interrupt on selected EXTI line.
495   * @retval None
496   */
497 #define __HAL_PWR_PVD_EXTI_GENERATE_SWIT() SET_BIT(EXTI->SWIER1, PWR_EXTI_LINE_PVD)
498 
499 /**
500   * @brief  Check whether or not the PVD EXTI Interrupt flag is set.
501   * @retval EXTI PVD Line Status.
502   */
503 #define __HAL_PWR_PVD_EXTI_GET_FLAG()  ((EXTI->RPR1 | EXTI->FPR1) & PWR_EXTI_LINE_PVD)
504 
505 /**
506   * @brief  Clear the PVD EXTI Interrupt flag.
507   * @retval None.
508   */
509 #define __HAL_PWR_PVD_EXTI_CLEAR_FLAG()       \
510   do                                          \
511   {                                           \
512     WRITE_REG(EXTI->RPR1, PWR_EXTI_LINE_PVD); \
513     WRITE_REG(EXTI->FPR1, PWR_EXTI_LINE_PVD); \
514   } while(0)
515 /**
516   * @}
517   */
518 
519 /* Private constants ---------------------------------------------------------*/
520 
521 /** @addtogroup PWR_Private_Constants PWR Private Constants
522   * @{
523   */
524 /* Define PVD extended interrupts and event line */
525 #define PWR_EXTI_LINE_PVD (0x00010000UL) /*!< PVD EXTI Line */
526 
527 /* Defines wake up lines shift */
528 #define PWR_WUP_POLARITY_SHIFT      (0x08U) /*!< Internal constant used to retrieve wakeup signal polarity  */
529 #define PWR_WUP_SELECT_SIGNAL_SHIFT (0x10U) /*!< Internal constant used to retrieve wakeup signal selection */
530 
531 /* Defines wake up lines mask */
532 #define PWR_EWUP_MASK         (0x000000FFUL) /*!< Internal constant used to retrieve wakeup signal enable    */
533 #define PWR_WUP_POLARITY_MASK (0x0000FF00UL) /*!< Internal constant used to retrieve wakeup signal polarity  */
534 #define PWR_WUP_SELECT_MASK   (0xFFFF0000UL) /*!< Internal constant used to retrieve wakeup signal selection */
535 
536 /* Defines wake up lines selection */
537 #define PWR_WAKEUP1_SOURCE_SELECTION_0 (0U)
538 #define PWR_WAKEUP1_SOURCE_SELECTION_1 (PWR_WUCR3_WUSEL1_0 << PWR_WUP_SELECT_SIGNAL_SHIFT)                        /*!< Internal constant used to retrieve wakeup signal selection */
539 #define PWR_WAKEUP1_SOURCE_SELECTION_2 (PWR_WUCR3_WUSEL1_1 << PWR_WUP_SELECT_SIGNAL_SHIFT)                        /*!< Internal constant used to retrieve wakeup signal selection */
540 #define PWR_WAKEUP2_SOURCE_SELECTION_0 (0U)                                                                       /*!< Internal constant used to retrieve wakeup signal selection */
541 #define PWR_WAKEUP2_SOURCE_SELECTION_1 (PWR_WUCR3_WUSEL2_0 << PWR_WUP_SELECT_SIGNAL_SHIFT)                        /*!< Internal constant used to retrieve wakeup signal selection */
542 #define PWR_WAKEUP2_SOURCE_SELECTION_2 (PWR_WUCR3_WUSEL2_1 << PWR_WUP_SELECT_SIGNAL_SHIFT)                        /*!< Internal constant used to retrieve wakeup signal selection */
543 #define PWR_WAKEUP3_SOURCE_SELECTION_0 (0U)                                                                       /*!< Internal constant used to retrieve wakeup signal selection */
544 #define PWR_WAKEUP3_SOURCE_SELECTION_1 (PWR_WUCR3_WUSEL3_0 << PWR_WUP_SELECT_SIGNAL_SHIFT)                        /*!< Internal constant used to retrieve wakeup signal selection */
545 #define PWR_WAKEUP3_SOURCE_SELECTION_2 (PWR_WUCR3_WUSEL3_1 << PWR_WUP_SELECT_SIGNAL_SHIFT)                        /*!< Internal constant used to retrieve wakeup signal selection */
546 #define PWR_WAKEUP4_SOURCE_SELECTION_0 (0U)                                                                       /*!< Internal constant used to retrieve wakeup signal selection */
547 #define PWR_WAKEUP4_SOURCE_SELECTION_1 (PWR_WUCR3_WUSEL4_0 << PWR_WUP_SELECT_SIGNAL_SHIFT)                        /*!< Internal constant used to retrieve wakeup signal selection */
548 #define PWR_WAKEUP4_SOURCE_SELECTION_2 (PWR_WUCR3_WUSEL4_1 << PWR_WUP_SELECT_SIGNAL_SHIFT)                        /*!< Internal constant used to retrieve wakeup signal selection */
549 #define PWR_WAKEUP5_SOURCE_SELECTION_0 (0U)                                                                       /*!< Internal constant used to retrieve wakeup signal selection */
550 #define PWR_WAKEUP5_SOURCE_SELECTION_1 (PWR_WUCR3_WUSEL5_0 << PWR_WUP_SELECT_SIGNAL_SHIFT)                        /*!< Internal constant used to retrieve wakeup signal selection */
551 #define PWR_WAKEUP5_SOURCE_SELECTION_2 (PWR_WUCR3_WUSEL5_1 << PWR_WUP_SELECT_SIGNAL_SHIFT)                        /*!< Internal constant used to retrieve wakeup signal selection */
552 #define PWR_WAKEUP6_SOURCE_SELECTION_0 (0U)                                                                       /*!< Internal constant used to retrieve wakeup signal selection */
553 #define PWR_WAKEUP6_SOURCE_SELECTION_1 (PWR_WUCR3_WUSEL6_0 << PWR_WUP_SELECT_SIGNAL_SHIFT)                        /*!< Internal constant used to retrieve wakeup signal selection */
554 #define PWR_WAKEUP6_SOURCE_SELECTION_2 (PWR_WUCR3_WUSEL6_1 << PWR_WUP_SELECT_SIGNAL_SHIFT)                        /*!< Internal constant used to retrieve wakeup signal selection */
555 #define PWR_WAKEUP6_SOURCE_SELECTION_3 ((PWR_WUCR3_WUSEL6_0 | PWR_WUCR3_WUSEL6_1) << PWR_WUP_SELECT_SIGNAL_SHIFT) /*!< Internal constant used to retrieve wakeup signal selection */
556 #define PWR_WAKEUP7_SOURCE_SELECTION_0 (0U)                                                                       /*!< Internal constant used to retrieve wakeup signal selection */
557 #define PWR_WAKEUP7_SOURCE_SELECTION_1 (PWR_WUCR3_WUSEL7_0 << PWR_WUP_SELECT_SIGNAL_SHIFT)                        /*!< Internal constant used to retrieve wakeup signal selection */
558 #define PWR_WAKEUP7_SOURCE_SELECTION_2 (PWR_WUCR3_WUSEL7_1 << PWR_WUP_SELECT_SIGNAL_SHIFT)                        /*!< Internal constant used to retrieve wakeup signal selection */
559 #define PWR_WAKEUP7_SOURCE_SELECTION_3 ((PWR_WUCR3_WUSEL7_0 | PWR_WUCR3_WUSEL7_1) << PWR_WUP_SELECT_SIGNAL_SHIFT) /*!< Internal constant used to retrieve wakeup signal selection */
560 #define PWR_WAKEUP8_SOURCE_SELECTION_0 (0U)                                                                       /*!< Internal constant used to retrieve wakeup signal selection */
561 #define PWR_WAKEUP8_SOURCE_SELECTION_1 (PWR_WUCR3_WUSEL8_0 << PWR_WUP_SELECT_SIGNAL_SHIFT)                        /*!< Internal constant used to retrieve wakeup signal selection */
562 #define PWR_WAKEUP8_SOURCE_SELECTION_2 (PWR_WUCR3_WUSEL8_1 << PWR_WUP_SELECT_SIGNAL_SHIFT)                        /*!< Internal constant used to retrieve wakeup signal selection */
563 #define PWR_WAKEUP8_SOURCE_SELECTION_3 ((PWR_WUCR3_WUSEL8_0 | PWR_WUCR3_WUSEL8_1) << PWR_WUP_SELECT_SIGNAL_SHIFT) /*!< Internal constant used to retrieve wakeup signal selection */
564 
565 /* Defines wake up lines low polarity */
566 #define PWR_WAKEUP1_POLARITY_LOW (PWR_WUCR2_WUPP1 << PWR_WUP_POLARITY_SHIFT) /*!< Internal constant used to retrieve wakeup signal selection */
567 #define PWR_WAKEUP2_POLARITY_LOW (PWR_WUCR2_WUPP2 << PWR_WUP_POLARITY_SHIFT) /*!< Internal constant used to retrieve wakeup signal selection */
568 #define PWR_WAKEUP3_POLARITY_LOW (PWR_WUCR2_WUPP3 << PWR_WUP_POLARITY_SHIFT) /*!< Internal constant used to retrieve wakeup signal selection */
569 #define PWR_WAKEUP4_POLARITY_LOW (PWR_WUCR2_WUPP4 << PWR_WUP_POLARITY_SHIFT) /*!< Internal constant used to retrieve wakeup signal selection */
570 #define PWR_WAKEUP5_POLARITY_LOW (PWR_WUCR2_WUPP5 << PWR_WUP_POLARITY_SHIFT) /*!< Internal constant used to retrieve wakeup signal selection */
571 #define PWR_WAKEUP6_POLARITY_LOW (PWR_WUCR2_WUPP6 << PWR_WUP_POLARITY_SHIFT) /*!< Internal constant used to retrieve wakeup signal selection */
572 #define PWR_WAKEUP7_POLARITY_LOW (PWR_WUCR2_WUPP7 << PWR_WUP_POLARITY_SHIFT) /*!< Internal constant used to retrieve wakeup signal selection */
573 #define PWR_WAKEUP8_POLARITY_LOW (PWR_WUCR2_WUPP8 << PWR_WUP_POLARITY_SHIFT) /*!< Internal constant used to retrieve wakeup signal selection */
574 
575 /* Defines attribute */
576 #define PWR_ITEM_ATTR_NSEC_PRIV_MASK (0x10U) /*!< NSecure Privilege / NPrivilege attribute item mask */
577 #define PWR_ITEM_ATTR_SEC_PRIV_MASK  (0x20U) /*!< Secure Privilege / NPrivilege attribute item mask  */
578 /**
579   * @}
580   */
581 
582 /* Private macros ------------------------------------------------------------*/
583 
584 /** @addtogroup PWR_Private_Macros PWR Private Macros
585   * @{
586   */
587 /* Wake up pins check macro */
588 #define IS_PWR_WAKEUP_PIN(PIN)          \
589   (((PIN) == PWR_WAKEUP_PIN1_HIGH_0)  ||\
590    ((PIN) == PWR_WAKEUP_PIN1_HIGH_1)  ||\
591    ((PIN) == PWR_WAKEUP_PIN1_HIGH_2)  ||\
592    ((PIN) == PWR_WAKEUP_PIN2_HIGH_0)  ||\
593    ((PIN) == PWR_WAKEUP_PIN2_HIGH_1)  ||\
594    ((PIN) == PWR_WAKEUP_PIN2_HIGH_2)  ||\
595    ((PIN) == PWR_WAKEUP_PIN3_HIGH_0)  ||\
596    ((PIN) == PWR_WAKEUP_PIN3_HIGH_1)  ||\
597    ((PIN) == PWR_WAKEUP_PIN3_HIGH_2)  ||\
598    ((PIN) == PWR_WAKEUP_PIN4_HIGH_0)  ||\
599    ((PIN) == PWR_WAKEUP_PIN4_HIGH_1)  ||\
600    ((PIN) == PWR_WAKEUP_PIN4_HIGH_2)  ||\
601    ((PIN) == PWR_WAKEUP_PIN5_HIGH_0)  ||\
602    ((PIN) == PWR_WAKEUP_PIN5_HIGH_1)  ||\
603    ((PIN) == PWR_WAKEUP_PIN5_HIGH_2)  ||\
604    ((PIN) == PWR_WAKEUP_PIN6_HIGH_0)  ||\
605    ((PIN) == PWR_WAKEUP_PIN6_HIGH_1)  ||\
606    ((PIN) == PWR_WAKEUP_PIN6_HIGH_2)  ||\
607    ((PIN) == PWR_WAKEUP_PIN6_HIGH_3)  ||\
608    ((PIN) == PWR_WAKEUP_PIN7_HIGH_0)  ||\
609    ((PIN) == PWR_WAKEUP_PIN7_HIGH_1)  ||\
610    ((PIN) == PWR_WAKEUP_PIN7_HIGH_2)  ||\
611    ((PIN) == PWR_WAKEUP_PIN7_HIGH_3)  ||\
612    ((PIN) == PWR_WAKEUP_PIN8_HIGH_0)  ||\
613    ((PIN) == PWR_WAKEUP_PIN8_HIGH_1)  ||\
614    ((PIN) == PWR_WAKEUP_PIN8_HIGH_2)  ||\
615    ((PIN) == PWR_WAKEUP_PIN8_HIGH_3)  ||\
616    ((PIN) == PWR_WAKEUP_PIN1_LOW_0)   ||\
617    ((PIN) == PWR_WAKEUP_PIN1_LOW_1)   ||\
618    ((PIN) == PWR_WAKEUP_PIN1_LOW_2)   ||\
619    ((PIN) == PWR_WAKEUP_PIN2_LOW_0)   ||\
620    ((PIN) == PWR_WAKEUP_PIN2_LOW_1)   ||\
621    ((PIN) == PWR_WAKEUP_PIN2_LOW_2)   ||\
622    ((PIN) == PWR_WAKEUP_PIN3_LOW_0)   ||\
623    ((PIN) == PWR_WAKEUP_PIN3_LOW_1)   ||\
624    ((PIN) == PWR_WAKEUP_PIN3_LOW_2)   ||\
625    ((PIN) == PWR_WAKEUP_PIN4_LOW_0)   ||\
626    ((PIN) == PWR_WAKEUP_PIN4_LOW_1)   ||\
627    ((PIN) == PWR_WAKEUP_PIN4_LOW_2)   ||\
628    ((PIN) == PWR_WAKEUP_PIN5_LOW_0)   ||\
629    ((PIN) == PWR_WAKEUP_PIN5_LOW_1)   ||\
630    ((PIN) == PWR_WAKEUP_PIN5_LOW_2)   ||\
631    ((PIN) == PWR_WAKEUP_PIN6_LOW_0)   ||\
632    ((PIN) == PWR_WAKEUP_PIN6_LOW_1)   ||\
633    ((PIN) == PWR_WAKEUP_PIN6_LOW_2)   ||\
634    ((PIN) == PWR_WAKEUP_PIN6_LOW_3)   ||\
635    ((PIN) == PWR_WAKEUP_PIN7_LOW_0)   ||\
636    ((PIN) == PWR_WAKEUP_PIN7_LOW_1)   ||\
637    ((PIN) == PWR_WAKEUP_PIN7_LOW_2)   ||\
638    ((PIN) == PWR_WAKEUP_PIN7_LOW_3)   ||\
639    ((PIN) == PWR_WAKEUP_PIN8_LOW_0)   ||\
640    ((PIN) == PWR_WAKEUP_PIN8_LOW_1)   ||\
641    ((PIN) == PWR_WAKEUP_PIN8_LOW_2)   ||\
642    ((PIN) == PWR_WAKEUP_PIN8_LOW_3)   ||\
643    ((PIN) == PWR_WAKEUP_PIN1)         ||\
644    ((PIN) == PWR_WAKEUP_PIN2)         ||\
645    ((PIN) == PWR_WAKEUP_PIN3)         ||\
646    ((PIN) == PWR_WAKEUP_PIN4)         ||\
647    ((PIN) == PWR_WAKEUP_PIN5)         ||\
648    ((PIN) == PWR_WAKEUP_PIN6)         ||\
649    ((PIN) == PWR_WAKEUP_PIN7)         ||\
650    ((PIN) == PWR_WAKEUP_PIN8))
651 
652 /* PVD level check macro */
653 #define IS_PWR_PVD_LEVEL(LEVEL)                                 \
654   (((LEVEL) == PWR_PVDLEVEL_0) || ((LEVEL) == PWR_PVDLEVEL_1) ||\
655    ((LEVEL) == PWR_PVDLEVEL_2) || ((LEVEL) == PWR_PVDLEVEL_3) ||\
656    ((LEVEL) == PWR_PVDLEVEL_4) || ((LEVEL) == PWR_PVDLEVEL_5) ||\
657    ((LEVEL) == PWR_PVDLEVEL_6) || ((LEVEL) == PWR_PVDLEVEL_7))
658 
659 /* PVD mode check macro */
660 #define IS_PWR_PVD_MODE(MODE)                      \
661   (((MODE) == PWR_PVD_MODE_NORMAL)               ||\
662    ((MODE) == PWR_PVD_MODE_IT_RISING)            ||\
663    ((MODE) == PWR_PVD_MODE_IT_FALLING)           ||\
664    ((MODE) == PWR_PVD_MODE_IT_RISING_FALLING)    ||\
665    ((MODE) == PWR_PVD_MODE_EVENT_RISING)         ||\
666    ((MODE) == PWR_PVD_MODE_EVENT_FALLING)        ||\
667    ((MODE) == PWR_PVD_MODE_EVENT_RISING_FALLING))
668 
669 /* Sleep mode entry check macro */
670 #define IS_PWR_SLEEP_ENTRY(ENTRY) \
671   (((ENTRY) == PWR_SLEEPENTRY_WFI) || ((ENTRY) == PWR_SLEEPENTRY_WFE))
672 
673 /* Stop mode entry check macro */
674 #define IS_PWR_STOP_ENTRY(ENTRY) \
675   (((ENTRY) == PWR_STOPENTRY_WFI) || ((ENTRY) == PWR_STOPENTRY_WFE))
676 
677 /* PWR items check macro */
678 #define IS_PWR_ITEMS_ATTRIBUTES(ITEM) \
679   ((((ITEM) & (~PWR_ALL)) == 0U) && ((ITEM) != 0U))
680 
681 #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
682 /* PWR attribute check macro (Secure) */
683 #define IS_PWR_ATTRIBUTES(ATTRIBUTES) \
684   ((((~(((ATTRIBUTES) & 0xF0U) >> 4U)) & ((ATTRIBUTES) & 0x0FU)) == 0U) && (((ATTRIBUTES) & 0xFFFFFFCCU) == 0U))
685 #else
686 /* PWR attribute check macro (NSecure) */
687 #define IS_PWR_ATTRIBUTES(ATTRIBUTES) \
688   (((ATTRIBUTES) == PWR_NSEC_NPRIV) || ((ATTRIBUTES) == PWR_NSEC_PRIV))
689 #endif /* __ARM_FEATURE_CMSE */
690 /**
691   * @}
692   */
693 
694 /* Include PWR HAL Extended module */
695 #include "stm32u5xx_hal_pwr_ex.h"
696 
697 /* Exported functions --------------------------------------------------------*/
698 
699 /** @addtogroup PWR_Exported_Functions PWR Exported Functions
700   * @{
701   */
702 
703 /** @addtogroup PWR_Exported_Functions_Group1
704   * @{
705   */
706 /* Initialization and de-initialization functions *****************************/
707 void HAL_PWR_DeInit(void);
708 void HAL_PWR_EnableBkUpAccess(void);
709 void HAL_PWR_DisableBkUpAccess(void);
710 /**
711   * @}
712   */
713 
714 /** @addtogroup PWR_Exported_Functions_Group2
715   * @{
716   */
717 /* Programmable voltage detector functions ************************************/
718 HAL_StatusTypeDef HAL_PWR_ConfigPVD(PWR_PVDTypeDef *pConfigPVD);
719 void              HAL_PWR_EnablePVD(void);
720 void              HAL_PWR_DisablePVD(void);
721 
722 /* Wake up pins configuration functions ***************************************/
723 void HAL_PWR_EnableWakeUpPin(uint32_t WakeUpPin);
724 void HAL_PWR_DisableWakeUpPin(uint32_t WakeUpPin);
725 
726 /* Low power modes configuration functions ************************************/
727 void HAL_PWR_EnterSLEEPMode(uint32_t Regulator, uint8_t SleepEntry);
728 void HAL_PWR_EnterSTOPMode(uint32_t Regulator, uint8_t StopEntry);
729 void HAL_PWR_EnterSTANDBYMode(void);
730 
731 /* Sleep on exit and sev on pending configuration functions *******************/
732 void HAL_PWR_EnableSleepOnExit(void);
733 void HAL_PWR_DisableSleepOnExit(void);
734 void HAL_PWR_EnableSEVOnPend(void);
735 void HAL_PWR_DisableSEVOnPend(void);
736 
737 /* Interrupt handler functions ************************************************/
738 void HAL_PWR_PVD_IRQHandler(void);
739 void HAL_PWR_PVDCallback(void);
740 /**
741   * @}
742   */
743 
744 /** @addtogroup PWR_Exported_Functions_Group3
745   * @{
746   */
747 /* Privileges and security configuration functions ****************************/
748 void              HAL_PWR_ConfigAttributes(uint32_t Item, uint32_t Attributes);
749 HAL_StatusTypeDef HAL_PWR_GetConfigAttributes(uint32_t Item, uint32_t *pAttributes);
750 /**
751   * @}
752   */
753 
754 /**
755   * @}
756   */
757 
758 /**
759   * @}
760   */
761 
762 /**
763   * @}
764   */
765 
766 /**
767   * @}
768   */
769 
770 #ifdef __cplusplus
771 }
772 #endif /* __cplusplus */
773 
774 #endif /* STM32U5xx_HAL_PWR_H */
775