STM32F4xx HAL Documentation
Hardware Abstraction Layer for STM32F4 familiy
Loading...
Searching...
No Matches
stm32f4xx_hal_pwr.h
Go to the documentation of this file.
1
18/* Define to prevent recursive inclusion -------------------------------------*/
19#ifndef __STM32F4xx_HAL_PWR_H
20#define __STM32F4xx_HAL_PWR_H
21
22#ifdef __cplusplus
23 extern "C" {
24#endif
25
26/* Includes ------------------------------------------------------------------*/
27#include "stm32f4xx_hal_def.h"
28
37/* Exported types ------------------------------------------------------------*/
38
46typedef struct
47{
48 uint32_t PVDLevel;
51 uint32_t Mode;
54
59/* Exported constants --------------------------------------------------------*/
67#define PWR_WAKEUP_PIN1 0x00000100U
75#define PWR_PVDLEVEL_0 PWR_CR_PLS_LEV0
76#define PWR_PVDLEVEL_1 PWR_CR_PLS_LEV1
77#define PWR_PVDLEVEL_2 PWR_CR_PLS_LEV2
78#define PWR_PVDLEVEL_3 PWR_CR_PLS_LEV3
79#define PWR_PVDLEVEL_4 PWR_CR_PLS_LEV4
80#define PWR_PVDLEVEL_5 PWR_CR_PLS_LEV5
81#define PWR_PVDLEVEL_6 PWR_CR_PLS_LEV6
82#define PWR_PVDLEVEL_7 PWR_CR_PLS_LEV7/* External input analog voltage
83 (Compare internally to VREFINT) */
91#define PWR_PVD_MODE_NORMAL 0x00000000U
92#define PWR_PVD_MODE_IT_RISING 0x00010001U
93#define PWR_PVD_MODE_IT_FALLING 0x00010002U
94#define PWR_PVD_MODE_IT_RISING_FALLING 0x00010003U
95#define PWR_PVD_MODE_EVENT_RISING 0x00020001U
96#define PWR_PVD_MODE_EVENT_FALLING 0x00020002U
97#define PWR_PVD_MODE_EVENT_RISING_FALLING 0x00020003U
106#define PWR_MAINREGULATOR_ON 0x00000000U
107#define PWR_LOWPOWERREGULATOR_ON PWR_CR_LPDS
115#define PWR_SLEEPENTRY_WFI ((uint8_t)0x01)
116#define PWR_SLEEPENTRY_WFE ((uint8_t)0x02)
117#define PWR_SLEEPENTRY_WFE_NO_EVT_CLEAR ((uint8_t)0x03)
118
126#define PWR_STOPENTRY_WFI ((uint8_t)0x01)
127#define PWR_STOPENTRY_WFE ((uint8_t)0x02)
128#define PWR_STOPENTRY_WFE_NO_EVT_CLEAR ((uint8_t)0x03)
136#define PWR_FLAG_WU PWR_CSR_WUF
137#define PWR_FLAG_SB PWR_CSR_SBF
138#define PWR_FLAG_PVDO PWR_CSR_PVDO
139#define PWR_FLAG_BRR PWR_CSR_BRR
140#define PWR_FLAG_VOSRDY PWR_CSR_VOSRDY
149/* Exported macro ------------------------------------------------------------*/
175#define __HAL_PWR_GET_FLAG(__FLAG__) ((PWR->CSR & (__FLAG__)) == (__FLAG__))
176
183#define __HAL_PWR_CLEAR_FLAG(__FLAG__) (PWR->CR |= (__FLAG__) << 2U)
184
189#define __HAL_PWR_PVD_EXTI_ENABLE_IT() (EXTI->IMR |= (PWR_EXTI_LINE_PVD))
190
195#define __HAL_PWR_PVD_EXTI_DISABLE_IT() (EXTI->IMR &= ~(PWR_EXTI_LINE_PVD))
196
201#define __HAL_PWR_PVD_EXTI_ENABLE_EVENT() (EXTI->EMR |= (PWR_EXTI_LINE_PVD))
202
207#define __HAL_PWR_PVD_EXTI_DISABLE_EVENT() (EXTI->EMR &= ~(PWR_EXTI_LINE_PVD))
208
213#define __HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE() SET_BIT(EXTI->RTSR, PWR_EXTI_LINE_PVD)
214
219#define __HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE() CLEAR_BIT(EXTI->RTSR, PWR_EXTI_LINE_PVD)
220
225#define __HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE() SET_BIT(EXTI->FTSR, PWR_EXTI_LINE_PVD)
226
227
232#define __HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE() CLEAR_BIT(EXTI->FTSR, PWR_EXTI_LINE_PVD)
233
234
239#define __HAL_PWR_PVD_EXTI_ENABLE_RISING_FALLING_EDGE() do{__HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE();\
240 __HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE();\
241 }while(0U)
242
248#define __HAL_PWR_PVD_EXTI_DISABLE_RISING_FALLING_EDGE() do{__HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE();\
249 __HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE();\
250 }while(0U)
251
256#define __HAL_PWR_PVD_EXTI_GET_FLAG() (EXTI->PR & (PWR_EXTI_LINE_PVD))
257
262#define __HAL_PWR_PVD_EXTI_CLEAR_FLAG() (EXTI->PR = (PWR_EXTI_LINE_PVD))
263
268#define __HAL_PWR_PVD_EXTI_GENERATE_SWIT() (EXTI->SWIER |= (PWR_EXTI_LINE_PVD))
269
274/* Include PWR HAL Extension module */
275#include "stm32f4xx_hal_pwr_ex.h"
276
277/* Exported functions --------------------------------------------------------*/
285/* Initialization and de-initialization functions *****************************/
286void HAL_PWR_DeInit(void);
287void HAL_PWR_EnableBkUpAccess(void);
296/* Peripheral Control functions **********************************************/
297/* PVD configuration */
298void HAL_PWR_ConfigPVD(PWR_PVDTypeDef *sConfigPVD);
299void HAL_PWR_EnablePVD(void);
300void HAL_PWR_DisablePVD(void);
301
302/* WakeUp pins configuration */
303void HAL_PWR_EnableWakeUpPin(uint32_t WakeUpPinx);
304void HAL_PWR_DisableWakeUpPin(uint32_t WakeUpPinx);
305
306/* Low Power modes entry */
307void HAL_PWR_EnterSTOPMode(uint32_t Regulator, uint8_t STOPEntry);
308void HAL_PWR_EnterSLEEPMode(uint32_t Regulator, uint8_t SLEEPEntry);
309void HAL_PWR_EnterSTANDBYMode(void);
310
311/* Power PVD IRQ Handler */
312void HAL_PWR_PVD_IRQHandler(void);
313void HAL_PWR_PVDCallback(void);
314
315/* Cortex System Control functions *******************************************/
318void HAL_PWR_EnableSEVOnPend(void);
319void HAL_PWR_DisableSEVOnPend(void);
328/* Private types -------------------------------------------------------------*/
329/* Private variables ---------------------------------------------------------*/
330/* Private constants ---------------------------------------------------------*/
338#define PWR_EXTI_LINE_PVD ((uint32_t)EXTI_IMR_MR16)
346/* ------------- PWR registers bit address in the alias region ---------------*/
347#define PWR_OFFSET (PWR_BASE - PERIPH_BASE)
348#define PWR_CR_OFFSET 0x00U
349#define PWR_CSR_OFFSET 0x04U
350#define PWR_CR_OFFSET_BB (PWR_OFFSET + PWR_CR_OFFSET)
351#define PWR_CSR_OFFSET_BB (PWR_OFFSET + PWR_CSR_OFFSET)
359/* --- CR Register ---*/
360/* Alias word address of DBP bit */
361#define DBP_BIT_NUMBER PWR_CR_DBP_Pos
362#define CR_DBP_BB (uint32_t)(PERIPH_BB_BASE + (PWR_CR_OFFSET_BB * 32U) + (DBP_BIT_NUMBER * 4U))
363
364/* Alias word address of PVDE bit */
365#define PVDE_BIT_NUMBER PWR_CR_PVDE_Pos
366#define CR_PVDE_BB (uint32_t)(PERIPH_BB_BASE + (PWR_CR_OFFSET_BB * 32U) + (PVDE_BIT_NUMBER * 4U))
367
368/* Alias word address of VOS bit */
369#define VOS_BIT_NUMBER PWR_CR_VOS_Pos
370#define CR_VOS_BB (uint32_t)(PERIPH_BB_BASE + (PWR_CR_OFFSET_BB * 32U) + (VOS_BIT_NUMBER * 4U))
378/* --- CSR Register ---*/
379/* Alias word address of EWUP bit */
380#define EWUP_BIT_NUMBER PWR_CSR_EWUP_Pos
381#define CSR_EWUP_BB (PERIPH_BB_BASE + (PWR_CSR_OFFSET_BB * 32U) + (EWUP_BIT_NUMBER * 4U))
389/* Private macros ------------------------------------------------------------*/
397#define IS_PWR_PVD_LEVEL(LEVEL) (((LEVEL) == PWR_PVDLEVEL_0) || ((LEVEL) == PWR_PVDLEVEL_1)|| \
398 ((LEVEL) == PWR_PVDLEVEL_2) || ((LEVEL) == PWR_PVDLEVEL_3)|| \
399 ((LEVEL) == PWR_PVDLEVEL_4) || ((LEVEL) == PWR_PVDLEVEL_5)|| \
400 ((LEVEL) == PWR_PVDLEVEL_6) || ((LEVEL) == PWR_PVDLEVEL_7))
401#define IS_PWR_PVD_MODE(MODE) (((MODE) == PWR_PVD_MODE_IT_RISING)|| ((MODE) == PWR_PVD_MODE_IT_FALLING) || \
402 ((MODE) == PWR_PVD_MODE_IT_RISING_FALLING) || ((MODE) == PWR_PVD_MODE_EVENT_RISING) || \
403 ((MODE) == PWR_PVD_MODE_EVENT_FALLING) || ((MODE) == PWR_PVD_MODE_EVENT_RISING_FALLING) || \
404 ((MODE) == PWR_PVD_MODE_NORMAL))
405#define IS_PWR_REGULATOR(REGULATOR) (((REGULATOR) == PWR_MAINREGULATOR_ON) || \
406 ((REGULATOR) == PWR_LOWPOWERREGULATOR_ON))
408#define IS_PWR_SLEEP_ENTRY(ENTRY) (((ENTRY) == PWR_SLEEPENTRY_WFI) || \
409 ((ENTRY) == PWR_SLEEPENTRY_WFE) || \
410 ((ENTRY) == PWR_SLEEPENTRY_WFE_NO_EVT_CLEAR))
412#define IS_PWR_STOP_ENTRY(ENTRY) (((ENTRY) == PWR_STOPENTRY_WFI) || \
413 ((ENTRY) == PWR_STOPENTRY_WFE) || \
414 ((ENTRY) == PWR_STOPENTRY_WFE_NO_EVT_CLEAR))
431#ifdef __cplusplus
432}
433#endif
434
435
436#endif /* __STM32F4xx_HAL_PWR_H */
void HAL_PWR_DisableBkUpAccess(void)
Disables access to the backup domain (RTC registers, RTC backup data registers and backup SRAM).
void HAL_PWR_EnableBkUpAccess(void)
Enables access to the backup domain (RTC registers, RTC backup data registers and backup SRAM).
void HAL_PWR_DeInit(void)
Deinitializes the HAL PWR peripheral registers to their default reset values.
void HAL_PWR_DisableSleepOnExit(void)
Disables Sleep-On-Exit feature when returning from Handler mode to Thread mode.
void HAL_PWR_DisablePVD(void)
Disables the Power Voltage Detector(PVD).
void HAL_PWR_EnterSTANDBYMode(void)
Enters Standby mode.
void HAL_PWR_EnterSLEEPMode(uint32_t Regulator, uint8_t SLEEPEntry)
Enters Sleep mode.
void HAL_PWR_EnableSEVOnPend(void)
Enables CORTEX M4 SEVONPEND bit.
void HAL_PWR_EnablePVD(void)
Enables the Power Voltage Detector(PVD).
void HAL_PWR_PVDCallback(void)
PWR PVD interrupt callback.
void HAL_PWR_DisableSEVOnPend(void)
Disables CORTEX M4 SEVONPEND bit.
void HAL_PWR_EnableSleepOnExit(void)
Indicates Sleep-On-Exit when returning from Handler mode to Thread mode.
void HAL_PWR_ConfigPVD(PWR_PVDTypeDef *sConfigPVD)
Configures the voltage threshold detected by the Power Voltage Detector(PVD).
void HAL_PWR_EnableWakeUpPin(uint32_t WakeUpPinx)
Enables the Wake-up PINx functionality.
void HAL_PWR_DisableWakeUpPin(uint32_t WakeUpPinx)
Disables the Wake-up PINx functionality.
void HAL_PWR_EnterSTOPMode(uint32_t Regulator, uint8_t STOPEntry)
Enters Stop mode.
void HAL_PWR_PVD_IRQHandler(void)
This function handles the PWR PVD interrupt request.
This file contains HAL common defines, enumeration, macros and structures definitions.
Header file of PWR HAL Extension module.
PWR PVD configuration structure definition.