1 | /**
|
---|
2 | ******************************************************************************
|
---|
3 | * @file stm32f4xx_hal_pwr_ex.h
|
---|
4 | * @author MCD Application Team
|
---|
5 | * @brief Header file of PWR HAL Extension module.
|
---|
6 | ******************************************************************************
|
---|
7 | * @attention
|
---|
8 | *
|
---|
9 | * <h2><center>© Copyright (c) 2017 STMicroelectronics.
|
---|
10 | * All rights reserved.</center></h2>
|
---|
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 __STM32F4xx_HAL_PWR_EX_H
|
---|
22 | #define __STM32F4xx_HAL_PWR_EX_H
|
---|
23 |
|
---|
24 | #ifdef __cplusplus
|
---|
25 | extern "C" {
|
---|
26 | #endif
|
---|
27 |
|
---|
28 | /* Includes ------------------------------------------------------------------*/
|
---|
29 | #include "stm32f4xx_hal_def.h"
|
---|
30 |
|
---|
31 | /** @addtogroup STM32F4xx_HAL_Driver
|
---|
32 | * @{
|
---|
33 | */
|
---|
34 |
|
---|
35 | /** @addtogroup PWREx
|
---|
36 | * @{
|
---|
37 | */
|
---|
38 |
|
---|
39 | /* Exported types ------------------------------------------------------------*/
|
---|
40 | /* Exported constants --------------------------------------------------------*/
|
---|
41 | /** @defgroup PWREx_Exported_Constants PWREx Exported Constants
|
---|
42 | * @{
|
---|
43 | */
|
---|
44 | #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
|
---|
45 | defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx)
|
---|
46 |
|
---|
47 | /** @defgroup PWREx_Regulator_state_in_UnderDrive_mode PWREx Regulator state in UnderDrive mode
|
---|
48 | * @{
|
---|
49 | */
|
---|
50 | #define PWR_MAINREGULATOR_UNDERDRIVE_ON PWR_CR_MRUDS
|
---|
51 | #define PWR_LOWPOWERREGULATOR_UNDERDRIVE_ON ((uint32_t)(PWR_CR_LPDS | PWR_CR_LPUDS))
|
---|
52 | /**
|
---|
53 | * @}
|
---|
54 | */
|
---|
55 |
|
---|
56 | /** @defgroup PWREx_Over_Under_Drive_Flag PWREx Over Under Drive Flag
|
---|
57 | * @{
|
---|
58 | */
|
---|
59 | #define PWR_FLAG_ODRDY PWR_CSR_ODRDY
|
---|
60 | #define PWR_FLAG_ODSWRDY PWR_CSR_ODSWRDY
|
---|
61 | #define PWR_FLAG_UDRDY PWR_CSR_UDSWRDY
|
---|
62 | /**
|
---|
63 | * @}
|
---|
64 | */
|
---|
65 | #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx */
|
---|
66 |
|
---|
67 | /** @defgroup PWREx_Regulator_Voltage_Scale PWREx Regulator Voltage Scale
|
---|
68 | * @{
|
---|
69 | */
|
---|
70 | #if defined(STM32F405xx) || defined(STM32F407xx) || defined(STM32F415xx) || defined(STM32F417xx)
|
---|
71 | #define PWR_REGULATOR_VOLTAGE_SCALE1 PWR_CR_VOS /* Scale 1 mode(default value at reset): the maximum value of fHCLK = 168 MHz. */
|
---|
72 | #define PWR_REGULATOR_VOLTAGE_SCALE2 0x00000000U /* Scale 2 mode: the maximum value of fHCLK = 144 MHz. */
|
---|
73 | #else
|
---|
74 | #define PWR_REGULATOR_VOLTAGE_SCALE1 PWR_CR_VOS /* Scale 1 mode(default value at reset): the maximum value of fHCLK is 168 MHz. It can be extended to
|
---|
75 | 180 MHz by activating the over-drive mode. */
|
---|
76 | #define PWR_REGULATOR_VOLTAGE_SCALE2 PWR_CR_VOS_1 /* Scale 2 mode: the maximum value of fHCLK is 144 MHz. It can be extended to
|
---|
77 | 168 MHz by activating the over-drive mode. */
|
---|
78 | #define PWR_REGULATOR_VOLTAGE_SCALE3 PWR_CR_VOS_0 /* Scale 3 mode: the maximum value of fHCLK is 120 MHz. */
|
---|
79 | #endif /* STM32F405xx || STM32F407xx || STM32F415xx || STM32F417xx */
|
---|
80 | /**
|
---|
81 | * @}
|
---|
82 | */
|
---|
83 | #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F446xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || \
|
---|
84 | defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx)
|
---|
85 | /** @defgroup PWREx_WakeUp_Pins PWREx WakeUp Pins
|
---|
86 | * @{
|
---|
87 | */
|
---|
88 | #define PWR_WAKEUP_PIN2 0x00000080U
|
---|
89 | #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F412Zx) || defined(STM32F412Vx) || \
|
---|
90 | defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx)
|
---|
91 | #define PWR_WAKEUP_PIN3 0x00000040U
|
---|
92 | #endif /* STM32F410xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Zx || STM32F412Vx || \
|
---|
93 | STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */
|
---|
94 | /**
|
---|
95 | * @}
|
---|
96 | */
|
---|
97 | #endif /* STM32F410xx || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx ||
|
---|
98 | STM32F413xx || STM32F423xx */
|
---|
99 |
|
---|
100 | /**
|
---|
101 | * @}
|
---|
102 | */
|
---|
103 |
|
---|
104 | /* Exported macro ------------------------------------------------------------*/
|
---|
105 | /** @defgroup PWREx_Exported_Constants PWREx Exported Constants
|
---|
106 | * @{
|
---|
107 | */
|
---|
108 |
|
---|
109 | #if defined(STM32F405xx) || defined(STM32F407xx) || defined(STM32F415xx) || defined(STM32F417xx)
|
---|
110 | /** @brief macros configure the main internal regulator output voltage.
|
---|
111 | * @param __REGULATOR__ specifies the regulator output voltage to achieve
|
---|
112 | * a tradeoff between performance and power consumption when the device does
|
---|
113 | * not operate at the maximum frequency (refer to the datasheets for more details).
|
---|
114 | * This parameter can be one of the following values:
|
---|
115 | * @arg PWR_REGULATOR_VOLTAGE_SCALE1: Regulator voltage output Scale 1 mode
|
---|
116 | * @arg PWR_REGULATOR_VOLTAGE_SCALE2: Regulator voltage output Scale 2 mode
|
---|
117 | * @retval None
|
---|
118 | */
|
---|
119 | #define __HAL_PWR_VOLTAGESCALING_CONFIG(__REGULATOR__) do { \
|
---|
120 | __IO uint32_t tmpreg = 0x00U; \
|
---|
121 | MODIFY_REG(PWR->CR, PWR_CR_VOS, (__REGULATOR__)); \
|
---|
122 | /* Delay after an RCC peripheral clock enabling */ \
|
---|
123 | tmpreg = READ_BIT(PWR->CR, PWR_CR_VOS); \
|
---|
124 | UNUSED(tmpreg); \
|
---|
125 | } while(0U)
|
---|
126 | #else
|
---|
127 | /** @brief macros configure the main internal regulator output voltage.
|
---|
128 | * @param __REGULATOR__ specifies the regulator output voltage to achieve
|
---|
129 | * a tradeoff between performance and power consumption when the device does
|
---|
130 | * not operate at the maximum frequency (refer to the datasheets for more details).
|
---|
131 | * This parameter can be one of the following values:
|
---|
132 | * @arg PWR_REGULATOR_VOLTAGE_SCALE1: Regulator voltage output Scale 1 mode
|
---|
133 | * @arg PWR_REGULATOR_VOLTAGE_SCALE2: Regulator voltage output Scale 2 mode
|
---|
134 | * @arg PWR_REGULATOR_VOLTAGE_SCALE3: Regulator voltage output Scale 3 mode
|
---|
135 | * @retval None
|
---|
136 | */
|
---|
137 | #define __HAL_PWR_VOLTAGESCALING_CONFIG(__REGULATOR__) do { \
|
---|
138 | __IO uint32_t tmpreg = 0x00U; \
|
---|
139 | MODIFY_REG(PWR->CR, PWR_CR_VOS, (__REGULATOR__)); \
|
---|
140 | /* Delay after an RCC peripheral clock enabling */ \
|
---|
141 | tmpreg = READ_BIT(PWR->CR, PWR_CR_VOS); \
|
---|
142 | UNUSED(tmpreg); \
|
---|
143 | } while(0U)
|
---|
144 | #endif /* STM32F405xx || STM32F407xx || STM32F415xx || STM32F417xx */
|
---|
145 |
|
---|
146 | #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
|
---|
147 | defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx)
|
---|
148 | /** @brief Macros to enable or disable the Over drive mode.
|
---|
149 | * @note These macros can be used only for STM32F42xx/STM3243xx devices.
|
---|
150 | */
|
---|
151 | #define __HAL_PWR_OVERDRIVE_ENABLE() (*(__IO uint32_t *) CR_ODEN_BB = ENABLE)
|
---|
152 | #define __HAL_PWR_OVERDRIVE_DISABLE() (*(__IO uint32_t *) CR_ODEN_BB = DISABLE)
|
---|
153 |
|
---|
154 | /** @brief Macros to enable or disable the Over drive switching.
|
---|
155 | * @note These macros can be used only for STM32F42xx/STM3243xx devices.
|
---|
156 | */
|
---|
157 | #define __HAL_PWR_OVERDRIVESWITCHING_ENABLE() (*(__IO uint32_t *) CR_ODSWEN_BB = ENABLE)
|
---|
158 | #define __HAL_PWR_OVERDRIVESWITCHING_DISABLE() (*(__IO uint32_t *) CR_ODSWEN_BB = DISABLE)
|
---|
159 |
|
---|
160 | /** @brief Macros to enable or disable the Under drive mode.
|
---|
161 | * @note This mode is enabled only with STOP low power mode.
|
---|
162 | * In this mode, the 1.2V domain is preserved in reduced leakage mode. This
|
---|
163 | * mode is only available when the main regulator or the low power regulator
|
---|
164 | * is in low voltage mode.
|
---|
165 | * @note If the Under-drive mode was enabled, it is automatically disabled after
|
---|
166 | * exiting Stop mode.
|
---|
167 | * When the voltage regulator operates in Under-drive mode, an additional
|
---|
168 | * startup delay is induced when waking up from Stop mode.
|
---|
169 | */
|
---|
170 | #define __HAL_PWR_UNDERDRIVE_ENABLE() (PWR->CR |= (uint32_t)PWR_CR_UDEN)
|
---|
171 | #define __HAL_PWR_UNDERDRIVE_DISABLE() (PWR->CR &= (uint32_t)(~PWR_CR_UDEN))
|
---|
172 |
|
---|
173 | /** @brief Check PWR flag is set or not.
|
---|
174 | * @note These macros can be used only for STM32F42xx/STM3243xx devices.
|
---|
175 | * @param __FLAG__ specifies the flag to check.
|
---|
176 | * This parameter can be one of the following values:
|
---|
177 | * @arg PWR_FLAG_ODRDY: This flag indicates that the Over-drive mode
|
---|
178 | * is ready
|
---|
179 | * @arg PWR_FLAG_ODSWRDY: This flag indicates that the Over-drive mode
|
---|
180 | * switching is ready
|
---|
181 | * @arg PWR_FLAG_UDRDY: This flag indicates that the Under-drive mode
|
---|
182 | * is enabled in Stop mode
|
---|
183 | * @retval The new state of __FLAG__ (TRUE or FALSE).
|
---|
184 | */
|
---|
185 | #define __HAL_PWR_GET_ODRUDR_FLAG(__FLAG__) ((PWR->CSR & (__FLAG__)) == (__FLAG__))
|
---|
186 |
|
---|
187 | /** @brief Clear the Under-Drive Ready flag.
|
---|
188 | * @note These macros can be used only for STM32F42xx/STM3243xx devices.
|
---|
189 | */
|
---|
190 | #define __HAL_PWR_CLEAR_ODRUDR_FLAG() (PWR->CSR |= PWR_FLAG_UDRDY)
|
---|
191 |
|
---|
192 | #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx */
|
---|
193 | /**
|
---|
194 | * @}
|
---|
195 | */
|
---|
196 |
|
---|
197 | /* Exported functions --------------------------------------------------------*/
|
---|
198 | /** @addtogroup PWREx_Exported_Functions PWREx Exported Functions
|
---|
199 | * @{
|
---|
200 | */
|
---|
201 |
|
---|
202 | /** @addtogroup PWREx_Exported_Functions_Group1
|
---|
203 | * @{
|
---|
204 | */
|
---|
205 | void HAL_PWREx_EnableFlashPowerDown(void);
|
---|
206 | void HAL_PWREx_DisableFlashPowerDown(void);
|
---|
207 | HAL_StatusTypeDef HAL_PWREx_EnableBkUpReg(void);
|
---|
208 | HAL_StatusTypeDef HAL_PWREx_DisableBkUpReg(void);
|
---|
209 | uint32_t HAL_PWREx_GetVoltageRange(void);
|
---|
210 | HAL_StatusTypeDef HAL_PWREx_ControlVoltageScaling(uint32_t VoltageScaling);
|
---|
211 |
|
---|
212 | #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F401xC) ||\
|
---|
213 | defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F412Zx) || defined(STM32F412Vx) ||\
|
---|
214 | defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx)
|
---|
215 | void HAL_PWREx_EnableMainRegulatorLowVoltage(void);
|
---|
216 | void HAL_PWREx_DisableMainRegulatorLowVoltage(void);
|
---|
217 | void HAL_PWREx_EnableLowRegulatorLowVoltage(void);
|
---|
218 | void HAL_PWREx_DisableLowRegulatorLowVoltage(void);
|
---|
219 | #endif /* STM32F410xx || STM32F401xC || STM32F401xE || STM32F411xE || STM32F412Zx || STM32F412Vx ||\
|
---|
220 | STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */
|
---|
221 |
|
---|
222 | #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F446xx) ||\
|
---|
223 | defined(STM32F469xx) || defined(STM32F479xx)
|
---|
224 | HAL_StatusTypeDef HAL_PWREx_EnableOverDrive(void);
|
---|
225 | HAL_StatusTypeDef HAL_PWREx_DisableOverDrive(void);
|
---|
226 | HAL_StatusTypeDef HAL_PWREx_EnterUnderDriveSTOPMode(uint32_t Regulator, uint8_t STOPEntry);
|
---|
227 | #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx */
|
---|
228 |
|
---|
229 | /**
|
---|
230 | * @}
|
---|
231 | */
|
---|
232 |
|
---|
233 | /**
|
---|
234 | * @}
|
---|
235 | */
|
---|
236 | /* Private types -------------------------------------------------------------*/
|
---|
237 | /* Private variables ---------------------------------------------------------*/
|
---|
238 | /* Private constants ---------------------------------------------------------*/
|
---|
239 | /** @defgroup PWREx_Private_Constants PWREx Private Constants
|
---|
240 | * @{
|
---|
241 | */
|
---|
242 |
|
---|
243 | /** @defgroup PWREx_register_alias_address PWREx Register alias address
|
---|
244 | * @{
|
---|
245 | */
|
---|
246 | /* ------------- PWR registers bit address in the alias region ---------------*/
|
---|
247 | /* --- CR Register ---*/
|
---|
248 | /* Alias word address of FPDS bit */
|
---|
249 | #define FPDS_BIT_NUMBER PWR_CR_FPDS_Pos
|
---|
250 | #define CR_FPDS_BB (uint32_t)(PERIPH_BB_BASE + (PWR_CR_OFFSET_BB * 32U) + (FPDS_BIT_NUMBER * 4U))
|
---|
251 |
|
---|
252 | /* Alias word address of ODEN bit */
|
---|
253 | #define ODEN_BIT_NUMBER PWR_CR_ODEN_Pos
|
---|
254 | #define CR_ODEN_BB (uint32_t)(PERIPH_BB_BASE + (PWR_CR_OFFSET_BB * 32U) + (ODEN_BIT_NUMBER * 4U))
|
---|
255 |
|
---|
256 | /* Alias word address of ODSWEN bit */
|
---|
257 | #define ODSWEN_BIT_NUMBER PWR_CR_ODSWEN_Pos
|
---|
258 | #define CR_ODSWEN_BB (uint32_t)(PERIPH_BB_BASE + (PWR_CR_OFFSET_BB * 32U) + (ODSWEN_BIT_NUMBER * 4U))
|
---|
259 |
|
---|
260 | /* Alias word address of MRLVDS bit */
|
---|
261 | #define MRLVDS_BIT_NUMBER PWR_CR_MRLVDS_Pos
|
---|
262 | #define CR_MRLVDS_BB (uint32_t)(PERIPH_BB_BASE + (PWR_CR_OFFSET_BB * 32U) + (MRLVDS_BIT_NUMBER * 4U))
|
---|
263 |
|
---|
264 | /* Alias word address of LPLVDS bit */
|
---|
265 | #define LPLVDS_BIT_NUMBER PWR_CR_LPLVDS_Pos
|
---|
266 | #define CR_LPLVDS_BB (uint32_t)(PERIPH_BB_BASE + (PWR_CR_OFFSET_BB * 32U) + (LPLVDS_BIT_NUMBER * 4U))
|
---|
267 |
|
---|
268 | /**
|
---|
269 | * @}
|
---|
270 | */
|
---|
271 |
|
---|
272 | /** @defgroup PWREx_CSR_register_alias PWRx CSR Register alias address
|
---|
273 | * @{
|
---|
274 | */
|
---|
275 | /* --- CSR Register ---*/
|
---|
276 | /* Alias word address of BRE bit */
|
---|
277 | #define BRE_BIT_NUMBER PWR_CSR_BRE_Pos
|
---|
278 | #define CSR_BRE_BB (uint32_t)(PERIPH_BB_BASE + (PWR_CSR_OFFSET_BB * 32U) + (BRE_BIT_NUMBER * 4U))
|
---|
279 |
|
---|
280 | /**
|
---|
281 | * @}
|
---|
282 | */
|
---|
283 |
|
---|
284 | /**
|
---|
285 | * @}
|
---|
286 | */
|
---|
287 |
|
---|
288 | /* Private macros ------------------------------------------------------------*/
|
---|
289 | /** @defgroup PWREx_Private_Macros PWREx Private Macros
|
---|
290 | * @{
|
---|
291 | */
|
---|
292 |
|
---|
293 | /** @defgroup PWREx_IS_PWR_Definitions PWREx Private macros to check input parameters
|
---|
294 | * @{
|
---|
295 | */
|
---|
296 | #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
|
---|
297 | defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx)
|
---|
298 | #define IS_PWR_REGULATOR_UNDERDRIVE(REGULATOR) (((REGULATOR) == PWR_MAINREGULATOR_UNDERDRIVE_ON) || \
|
---|
299 | ((REGULATOR) == PWR_LOWPOWERREGULATOR_UNDERDRIVE_ON))
|
---|
300 | #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx */
|
---|
301 |
|
---|
302 | #if defined(STM32F405xx) || defined(STM32F407xx) || defined(STM32F415xx) || defined(STM32F417xx)
|
---|
303 | #define IS_PWR_VOLTAGE_SCALING_RANGE(VOLTAGE) (((VOLTAGE) == PWR_REGULATOR_VOLTAGE_SCALE1) || \
|
---|
304 | ((VOLTAGE) == PWR_REGULATOR_VOLTAGE_SCALE2))
|
---|
305 | #else
|
---|
306 | #define IS_PWR_VOLTAGE_SCALING_RANGE(VOLTAGE) (((VOLTAGE) == PWR_REGULATOR_VOLTAGE_SCALE1) || \
|
---|
307 | ((VOLTAGE) == PWR_REGULATOR_VOLTAGE_SCALE2) || \
|
---|
308 | ((VOLTAGE) == PWR_REGULATOR_VOLTAGE_SCALE3))
|
---|
309 | #endif /* STM32F405xx || STM32F407xx || STM32F415xx || STM32F417xx */
|
---|
310 |
|
---|
311 | #if defined(STM32F446xx)
|
---|
312 | #define IS_PWR_WAKEUP_PIN(PIN) (((PIN) == PWR_WAKEUP_PIN1) || ((PIN) == PWR_WAKEUP_PIN2))
|
---|
313 | #elif defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F412Zx) ||\
|
---|
314 | defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) ||\
|
---|
315 | defined(STM32F423xx)
|
---|
316 | #define IS_PWR_WAKEUP_PIN(PIN) (((PIN) == PWR_WAKEUP_PIN1) || ((PIN) == PWR_WAKEUP_PIN2) || \
|
---|
317 | ((PIN) == PWR_WAKEUP_PIN3))
|
---|
318 | #else
|
---|
319 | #define IS_PWR_WAKEUP_PIN(PIN) ((PIN) == PWR_WAKEUP_PIN1)
|
---|
320 | #endif /* STM32F446xx */
|
---|
321 | /**
|
---|
322 | * @}
|
---|
323 | */
|
---|
324 |
|
---|
325 | /**
|
---|
326 | * @}
|
---|
327 | */
|
---|
328 |
|
---|
329 | /**
|
---|
330 | * @}
|
---|
331 | */
|
---|
332 |
|
---|
333 | /**
|
---|
334 | * @}
|
---|
335 | */
|
---|
336 |
|
---|
337 | #ifdef __cplusplus
|
---|
338 | }
|
---|
339 | #endif
|
---|
340 |
|
---|
341 |
|
---|
342 | #endif /* __STM32F4xx_HAL_PWR_EX_H */
|
---|
343 |
|
---|
344 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
---|