STM CMSIS
stm32f4xx_hal_pwr_ex.h
Go to the documentation of this file.
1 
38 /* Define to prevent recursive inclusion -------------------------------------*/
39 #ifndef __STM32F4xx_HAL_PWR_EX_H
40 #define __STM32F4xx_HAL_PWR_EX_H
41 
42 #ifdef __cplusplus
43  extern "C" {
44 #endif
45 
46 /* Includes ------------------------------------------------------------------*/
47 #include "stm32f4xx_hal_def.h"
48 
57 /* Exported types ------------------------------------------------------------*/
58 /* Exported constants --------------------------------------------------------*/
62 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
63  defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx)
64 
68 #define PWR_MAINREGULATOR_UNDERDRIVE_ON PWR_CR_MRUDS
69 #define PWR_LOWPOWERREGULATOR_UNDERDRIVE_ON ((uint32_t)(PWR_CR_LPDS | PWR_CR_LPUDS))
70 
77 #define PWR_FLAG_ODRDY PWR_CSR_ODRDY
78 #define PWR_FLAG_ODSWRDY PWR_CSR_ODSWRDY
79 #define PWR_FLAG_UDRDY PWR_CSR_UDSWRDY
80 
83 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx */
84 
88 #if defined(STM32F405xx) || defined(STM32F407xx) || defined(STM32F415xx) || defined(STM32F417xx)
89 #define PWR_REGULATOR_VOLTAGE_SCALE1 PWR_CR_VOS /* Scale 1 mode(default value at reset): the maximum value of fHCLK = 168 MHz. */
90 #define PWR_REGULATOR_VOLTAGE_SCALE2 ((uint32_t)0x00000000U) /* Scale 2 mode: the maximum value of fHCLK = 144 MHz. */
91 #else
92 #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
93  180 MHz by activating the over-drive mode. */
94 #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
95  168 MHz by activating the over-drive mode. */
96 #define PWR_REGULATOR_VOLTAGE_SCALE3 PWR_CR_VOS_0 /* Scale 3 mode: the maximum value of fHCLK is 120 MHz. */
97 #endif /* STM32F405xx || STM32F407xx || STM32F415xx || STM32F417xx */
98 
101 #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F446xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || \
102  defined(STM32F412Rx) || defined(STM32F412Cx)
103 
106 #define PWR_WAKEUP_PIN2 ((uint32_t)0x00000080U)
107 #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F412Zx) || defined(STM32F412Vx) || \
108  defined(STM32F412Rx) || defined(STM32F412Cx)
109 #define PWR_WAKEUP_PIN3 ((uint32_t)0x00000040U)
110 #endif /* STM32F410xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Zx || STM32F412Vx || \
111  STM32F412Rx || STM32F412Cx */
112 
115 #endif /* STM32F410xx || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */
116 
121 /* Exported macro ------------------------------------------------------------*/
126 #if defined(STM32F405xx) || defined(STM32F407xx) || defined(STM32F415xx) || defined(STM32F417xx)
127 
136 #define __HAL_PWR_VOLTAGESCALING_CONFIG(__REGULATOR__) do { \
137  __IO uint32_t tmpreg = 0x00U; \
138  MODIFY_REG(PWR->CR, PWR_CR_VOS, (__REGULATOR__)); \
139  /* Delay after an RCC peripheral clock enabling */ \
140  tmpreg = READ_BIT(PWR->CR, PWR_CR_VOS); \
141  UNUSED(tmpreg); \
142  } while(0)
143 #else
144 
154 #define __HAL_PWR_VOLTAGESCALING_CONFIG(__REGULATOR__) do { \
155  __IO uint32_t tmpreg = 0x00U; \
156  MODIFY_REG(PWR->CR, PWR_CR_VOS, (__REGULATOR__)); \
157  /* Delay after an RCC peripheral clock enabling */ \
158  tmpreg = READ_BIT(PWR->CR, PWR_CR_VOS); \
159  UNUSED(tmpreg); \
160  } while(0)
161 #endif /* STM32F405xx || STM32F407xx || STM32F415xx || STM32F417xx */
162 
163 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
164  defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx)
165 
168 #define __HAL_PWR_OVERDRIVE_ENABLE() (*(__IO uint32_t *) CR_ODEN_BB = ENABLE)
169 #define __HAL_PWR_OVERDRIVE_DISABLE() (*(__IO uint32_t *) CR_ODEN_BB = DISABLE)
170 
174 #define __HAL_PWR_OVERDRIVESWITCHING_ENABLE() (*(__IO uint32_t *) CR_ODSWEN_BB = ENABLE)
175 #define __HAL_PWR_OVERDRIVESWITCHING_DISABLE() (*(__IO uint32_t *) CR_ODSWEN_BB = DISABLE)
176 
187 #define __HAL_PWR_UNDERDRIVE_ENABLE() (PWR->CR |= (uint32_t)PWR_CR_UDEN)
188 #define __HAL_PWR_UNDERDRIVE_DISABLE() (PWR->CR &= (uint32_t)(~PWR_CR_UDEN))
189 
202 #define __HAL_PWR_GET_ODRUDR_FLAG(__FLAG__) ((PWR->CSR & (__FLAG__)) == (__FLAG__))
203 
207 #define __HAL_PWR_CLEAR_ODRUDR_FLAG() (PWR->CSR |= PWR_FLAG_UDRDY)
208 
209 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx */
210 
214 /* Exported functions --------------------------------------------------------*/
222 void HAL_PWREx_EnableFlashPowerDown(void);
223 void HAL_PWREx_DisableFlashPowerDown(void);
224 HAL_StatusTypeDef HAL_PWREx_EnableBkUpReg(void);
225 HAL_StatusTypeDef HAL_PWREx_DisableBkUpReg(void);
226 uint32_t HAL_PWREx_GetVoltageRange(void);
227 HAL_StatusTypeDef HAL_PWREx_ControlVoltageScaling(uint32_t VoltageScaling);
228 
229 #if defined(STM32F469xx) || defined(STM32F479xx)
230 void HAL_PWREx_EnableWakeUpPinPolarityRisingEdge(void);
231 void HAL_PWREx_EnableWakeUpPinPolarityFallingEdge(void);
232 #endif /* STM32F469xx || STM32F479xx */
233 
234 #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F401xC) ||\
235  defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F412Zx) || defined(STM32F412Vx) ||\
236  defined(STM32F412Rx) || defined(STM32F412Cx)
237 void HAL_PWREx_EnableMainRegulatorLowVoltage(void);
238 void HAL_PWREx_DisableMainRegulatorLowVoltage(void);
239 void HAL_PWREx_EnableLowRegulatorLowVoltage(void);
240 void HAL_PWREx_DisableLowRegulatorLowVoltage(void);
241 #endif /* STM32F410xx || STM32F401xC || STM32F401xE || STM32F411xE || STM32F412Zx || STM32F412Vx ||\
242  STM32F412Rx || STM32F412Cx */
243 
244 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F446xx) ||\
245  defined(STM32F469xx) || defined(STM32F479xx)
246 HAL_StatusTypeDef HAL_PWREx_EnableOverDrive(void);
247 HAL_StatusTypeDef HAL_PWREx_DisableOverDrive(void);
248 HAL_StatusTypeDef HAL_PWREx_EnterUnderDriveSTOPMode(uint32_t Regulator, uint8_t STOPEntry);
249 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx */
250 
258 /* Private types -------------------------------------------------------------*/
259 /* Private variables ---------------------------------------------------------*/
260 /* Private constants ---------------------------------------------------------*/
268 /* ------------- PWR registers bit address in the alias region ---------------*/
269 /* --- CR Register ---*/
270 /* Alias word address of FPDS bit */
271 #define FPDS_BIT_NUMBER POSITION_VAL(PWR_CR_FPDS)
272 #define CR_FPDS_BB (uint32_t)(PERIPH_BB_BASE + (PWR_CR_OFFSET_BB * 32U) + (FPDS_BIT_NUMBER * 4U))
273 
274 /* Alias word address of ODEN bit */
275 #define ODEN_BIT_NUMBER POSITION_VAL(PWR_CR_ODEN)
276 #define CR_ODEN_BB (uint32_t)(PERIPH_BB_BASE + (PWR_CR_OFFSET_BB * 32U) + (ODEN_BIT_NUMBER * 4U))
277 
278 /* Alias word address of ODSWEN bit */
279 #define ODSWEN_BIT_NUMBER POSITION_VAL(PWR_CR_ODSWEN)
280 #define CR_ODSWEN_BB (uint32_t)(PERIPH_BB_BASE + (PWR_CR_OFFSET_BB * 32U) + (ODSWEN_BIT_NUMBER * 4U))
281 
282 /* Alias word address of MRLVDS bit */
283 #define MRLVDS_BIT_NUMBER POSITION_VAL(PWR_CR_MRLVDS)
284 #define CR_MRLVDS_BB (uint32_t)(PERIPH_BB_BASE + (PWR_CR_OFFSET_BB * 32U) + (MRLVDS_BIT_NUMBER * 4U))
285 
286 /* Alias word address of LPLVDS bit */
287 #define LPLVDS_BIT_NUMBER POSITION_VAL(PWR_CR_LPLVDS)
288 #define CR_LPLVDS_BB (uint32_t)(PERIPH_BB_BASE + (PWR_CR_OFFSET_BB * 32U) + (LPLVDS_BIT_NUMBER * 4U))
289 
297 /* --- CSR Register ---*/
298 /* Alias word address of BRE bit */
299 #define BRE_BIT_NUMBER POSITION_VAL(PWR_CSR_BRE)
300 #define CSR_BRE_BB (uint32_t)(PERIPH_BB_BASE + (PWR_CSR_OFFSET_BB * 32U) + (BRE_BIT_NUMBER * 4U))
301 
302 #if defined(STM32F469xx) || defined(STM32F479xx)
303 /* Alias word address of WUPP bit */
304 #define WUPP_BIT_NUMBER POSITION_VAL(PWR_CSR_WUPP)
305 #define CSR_WUPP_BB (PERIPH_BB_BASE + (PWR_CSR_OFFSET_BB * 32U) + (WUPP_BIT_NUMBER * 4U))
306 #endif /* STM32F469xx || STM32F479xx */
307 
315 /* Private macros ------------------------------------------------------------*/
323 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
324  defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx)
325 #define IS_PWR_REGULATOR_UNDERDRIVE(REGULATOR) (((REGULATOR) == PWR_MAINREGULATOR_UNDERDRIVE_ON) || \
326  ((REGULATOR) == PWR_LOWPOWERREGULATOR_UNDERDRIVE_ON))
327 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx */
328 
329 #if defined(STM32F405xx) || defined(STM32F407xx) || defined(STM32F415xx) || defined(STM32F417xx)
330 #define IS_PWR_VOLTAGE_SCALING_RANGE(VOLTAGE) (((VOLTAGE) == PWR_REGULATOR_VOLTAGE_SCALE1) || \
331  ((VOLTAGE) == PWR_REGULATOR_VOLTAGE_SCALE2))
332 #else
333 #define IS_PWR_VOLTAGE_SCALING_RANGE(VOLTAGE) (((VOLTAGE) == PWR_REGULATOR_VOLTAGE_SCALE1) || \
334  ((VOLTAGE) == PWR_REGULATOR_VOLTAGE_SCALE2) || \
335  ((VOLTAGE) == PWR_REGULATOR_VOLTAGE_SCALE3))
336 #endif /* STM32F405xx || STM32F407xx || STM32F415xx || STM32F417xx */
337 
338 #if defined(STM32F446xx)
339 #define IS_PWR_WAKEUP_PIN(PIN) (((PIN) == PWR_WAKEUP_PIN1) || ((PIN) == PWR_WAKEUP_PIN2))
340 #elif defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F412Zx) || defined(STM32F412Vx) || \
341  defined(STM32F412Rx) || defined(STM32F412Cx)
342 #define IS_PWR_WAKEUP_PIN(PIN) (((PIN) == PWR_WAKEUP_PIN1) || ((PIN) == PWR_WAKEUP_PIN2) || \
343  ((PIN) == PWR_WAKEUP_PIN3))
344 #else
345 #define IS_PWR_WAKEUP_PIN(PIN) ((PIN) == PWR_WAKEUP_PIN1)
346 #endif /* STM32F446xx */
347 
363 #ifdef __cplusplus
364 }
365 #endif
366 
367 
368 #endif /* __STM32F4xx_HAL_PWR_EX_H */
369 
370 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
This file contains HAL common defines, enumeration, macros and structures definitions.
HAL_StatusTypeDef
HAL Status structures definition.
Definition: stm32f4xx_hal_def.h:57