stm32f0xx_hal_pwr.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /**
  2. ******************************************************************************
  3. * @file stm32f0xx_hal_pwr.h
  4. * @author MCD Application Team
  5. * @brief Header file of PWR HAL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2016 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. /* Define to prevent recursive inclusion -------------------------------------*/
  19. #ifndef __STM32F0xx_HAL_PWR_H
  20. #define __STM32F0xx_HAL_PWR_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32f0xx_hal_def.h"
  26. /** @addtogroup STM32F0xx_HAL_Driver
  27. * @{
  28. */
  29. /** @addtogroup PWR PWR
  30. * @{
  31. */
  32. /* Exported types ------------------------------------------------------------*/
  33. /* Exported constants --------------------------------------------------------*/
  34. /** @defgroup PWR_Exported_Constants PWR Exported Constants
  35. * @{
  36. */
  37. /** @defgroup PWR_Regulator_state_in_STOP_mode PWR Regulator state in STOP mode
  38. * @{
  39. */
  40. #define PWR_MAINREGULATOR_ON (0x00000000U)
  41. #define PWR_LOWPOWERREGULATOR_ON PWR_CR_LPDS
  42. #define IS_PWR_REGULATOR(REGULATOR) (((REGULATOR) == PWR_MAINREGULATOR_ON) || \
  43. ((REGULATOR) == PWR_LOWPOWERREGULATOR_ON))
  44. /**
  45. * @}
  46. */
  47. /** @defgroup PWR_SLEEP_mode_entry PWR SLEEP mode entry
  48. * @{
  49. */
  50. #define PWR_SLEEPENTRY_WFI ((uint8_t)0x01U)
  51. #define PWR_SLEEPENTRY_WFE ((uint8_t)0x02U)
  52. #define IS_PWR_SLEEP_ENTRY(ENTRY) (((ENTRY) == PWR_SLEEPENTRY_WFI) || ((ENTRY) == PWR_SLEEPENTRY_WFE))
  53. /**
  54. * @}
  55. */
  56. /** @defgroup PWR_STOP_mode_entry PWR STOP mode entry
  57. * @{
  58. */
  59. #define PWR_STOPENTRY_WFI ((uint8_t)0x01U)
  60. #define PWR_STOPENTRY_WFE ((uint8_t)0x02U)
  61. #define IS_PWR_STOP_ENTRY(ENTRY) (((ENTRY) == PWR_STOPENTRY_WFI) || ((ENTRY) == PWR_STOPENTRY_WFE))
  62. /**
  63. * @}
  64. */
  65. /**
  66. * @}
  67. */
  68. /* Exported macro ------------------------------------------------------------*/
  69. /** @defgroup PWR_Exported_Macro PWR Exported Macro
  70. * @{
  71. */
  72. /** @brief Check PWR flag is set or not.
  73. * @param __FLAG__ specifies the flag to check.
  74. * This parameter can be one of the following values:
  75. * @arg PWR_FLAG_WU: Wake Up flag. This flag indicates that a wakeup event
  76. * was received from the WKUP pin or from the RTC alarm (Alarm A),
  77. * RTC Tamper event, RTC TimeStamp event or RTC Wakeup.
  78. * An additional wakeup event is detected if the WKUP pin is enabled
  79. * (by setting the EWUP bit) when the WKUP pin level is already high.
  80. * @arg PWR_FLAG_SB: StandBy flag. This flag indicates that the system was
  81. * resumed from StandBy mode.
  82. * @arg PWR_FLAG_PVDO: PVD Output. This flag is valid only if PVD is enabled
  83. * by the HAL_PWR_EnablePVD() function. The PVD is stopped by Standby mode
  84. * For this reason, this bit is equal to 0 after Standby or reset
  85. * until the PVDE bit is set.
  86. * Warning: this Flag is not available on STM32F030x8 products
  87. * @arg PWR_FLAG_VREFINTRDY: This flag indicates that the internal reference
  88. * voltage VREFINT is ready.
  89. * Warning: this Flag is not available on STM32F030x8 products
  90. * @retval The new state of __FLAG__ (TRUE or FALSE).
  91. */
  92. #define __HAL_PWR_GET_FLAG(__FLAG__) ((PWR->CSR & (__FLAG__)) == (__FLAG__))
  93. /** @brief Clear the PWR's pending flags.
  94. * @param __FLAG__ specifies the flag to clear.
  95. * This parameter can be one of the following values:
  96. * @arg PWR_FLAG_WU: Wake Up flag
  97. * @arg PWR_FLAG_SB: StandBy flag
  98. */
  99. #define __HAL_PWR_CLEAR_FLAG(__FLAG__) (PWR->CR |= (__FLAG__) << 2U)
  100. /**
  101. * @}
  102. */
  103. /* Include PWR HAL Extension module */
  104. #include "stm32f0xx_hal_pwr_ex.h"
  105. /* Exported functions --------------------------------------------------------*/
  106. /** @addtogroup PWR_Exported_Functions PWR Exported Functions
  107. * @{
  108. */
  109. /** @addtogroup PWR_Exported_Functions_Group1 Initialization and de-initialization functions
  110. * @{
  111. */
  112. /* Initialization and de-initialization functions *****************************/
  113. void HAL_PWR_DeInit(void);
  114. /**
  115. * @}
  116. */
  117. /** @addtogroup PWR_Exported_Functions_Group2 Peripheral Control functions
  118. * @{
  119. */
  120. /* Peripheral Control functions **********************************************/
  121. void HAL_PWR_EnableBkUpAccess(void);
  122. void HAL_PWR_DisableBkUpAccess(void);
  123. /* WakeUp pins configuration functions ****************************************/
  124. void HAL_PWR_EnableWakeUpPin(uint32_t WakeUpPinx);
  125. void HAL_PWR_DisableWakeUpPin(uint32_t WakeUpPinx);
  126. /* Low Power modes configuration functions ************************************/
  127. void HAL_PWR_EnterSTOPMode(uint32_t Regulator, uint8_t STOPEntry);
  128. void HAL_PWR_EnterSLEEPMode(uint32_t Regulator, uint8_t SLEEPEntry);
  129. void HAL_PWR_EnterSTANDBYMode(void);
  130. void HAL_PWR_EnableSleepOnExit(void);
  131. void HAL_PWR_DisableSleepOnExit(void);
  132. void HAL_PWR_EnableSEVOnPend(void);
  133. void HAL_PWR_DisableSEVOnPend(void);
  134. /**
  135. * @}
  136. */
  137. /**
  138. * @}
  139. */
  140. /**
  141. * @}
  142. */
  143. /**
  144. * @}
  145. */
  146. #ifdef __cplusplus
  147. }
  148. #endif
  149. #endif /* __STM32F0xx_HAL_PWR_H */