stm32f3xx_hal_pwr.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. /**
  2. ******************************************************************************
  3. * @file stm32f3xx_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 __STM32F3xx_HAL_PWR_H
  20. #define __STM32F3xx_HAL_PWR_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32f3xx_hal_def.h"
  26. /** @addtogroup STM32F3xx_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_WakeUp_Pins PWR WakeUp Pins
  38. * @{
  39. */
  40. #define PWR_WAKEUP_PIN1 ((uint32_t)PWR_CSR_EWUP1) /*!< Wakeup pin 1U */
  41. #define PWR_WAKEUP_PIN2 ((uint32_t)PWR_CSR_EWUP2) /*!< Wakeup pin 2U */
  42. #define PWR_WAKEUP_PIN3 ((uint32_t)PWR_CSR_EWUP3) /*!< Wakeup pin 3U */
  43. /**
  44. * @}
  45. */
  46. /** @defgroup PWR_Regulator_state_in_STOP_mode PWR Regulator state in STOP mode
  47. * @{
  48. */
  49. #define PWR_MAINREGULATOR_ON (0x00000000U) /*!< Voltage regulator on during STOP mode */
  50. #define PWR_LOWPOWERREGULATOR_ON PWR_CR_LPDS /*!< Voltage regulator in low-power mode during STOP mode */
  51. /**
  52. * @}
  53. */
  54. /** @defgroup PWR_SLEEP_mode_entry PWR SLEEP mode entry
  55. * @{
  56. */
  57. #define PWR_SLEEPENTRY_WFI ((uint8_t)0x01U) /*!< Wait For Interruption instruction to enter SLEEP mode */
  58. #define PWR_SLEEPENTRY_WFE ((uint8_t)0x02U) /*!< Wait For Event instruction to enter SLEEP mode */
  59. /**
  60. * @}
  61. */
  62. /** @defgroup PWR_STOP_mode_entry PWR STOP mode entry
  63. * @{
  64. */
  65. #define PWR_STOPENTRY_WFI ((uint8_t)0x01U) /*!< Wait For Interruption instruction to enter STOP mode */
  66. #define PWR_STOPENTRY_WFE ((uint8_t)0x02U) /*!< Wait For Event instruction to enter STOP mode */
  67. /**
  68. * @}
  69. */
  70. /** @defgroup PWR_Flag PWR Flag
  71. * @{
  72. */
  73. #define PWR_FLAG_WU PWR_CSR_WUF /*!< Wakeup event from wakeup pin or RTC alarm */
  74. #define PWR_FLAG_SB PWR_CSR_SBF /*!< Standby flag */
  75. #define PWR_FLAG_PVDO PWR_CSR_PVDO /*!< Power Voltage Detector output flag */
  76. #define PWR_FLAG_VREFINTRDY PWR_CSR_VREFINTRDYF /*!< VREFINT reference voltage ready */
  77. /**
  78. * @}
  79. */
  80. /**
  81. * @}
  82. */
  83. /* Exported macro ------------------------------------------------------------*/
  84. /** @defgroup PWR_Exported_Macro PWR Exported Macro
  85. * @{
  86. */
  87. /** @brief Check PWR flag is set or not.
  88. * @param __FLAG__ specifies the flag to check.
  89. * This parameter can be one of the following values:
  90. * @arg PWR_FLAG_WU: Wake Up flag. This flag indicates that a wakeup event
  91. * was received from the WKUP pin or from the RTC alarm (Alarm A
  92. * or Alarm B), RTC Tamper event, RTC TimeStamp event or RTC Wakeup.
  93. * An additional wakeup event is detected if the WKUP pin is enabled
  94. * (by setting the EWUP bit) when the WKUP pin level is already high.
  95. * @arg PWR_FLAG_SB: StandBy flag. This flag indicates that the system was
  96. * resumed from StandBy mode.
  97. * @arg PWR_FLAG_PVDO: PVD Output. This flag is valid only if PVD is enabled
  98. * by the HAL_PWR_EnablePVD() function. The PVD is stopped by Standby mode
  99. * For this reason, this bit is equal to 0 after Standby or reset
  100. * until the PVDE bit is set.
  101. * @arg PWR_FLAG_VREFINTRDY: This flag indicates that the internal reference
  102. * voltage VREFINT is ready.
  103. * @retval The new state of __FLAG__ (TRUE or FALSE).
  104. */
  105. #define __HAL_PWR_GET_FLAG(__FLAG__) ((PWR->CSR & (__FLAG__)) == (__FLAG__))
  106. /** @brief Clear the PWR's pending flags.
  107. * @param __FLAG__ specifies the flag to clear.
  108. * This parameter can be one of the following values:
  109. * @arg PWR_FLAG_WU: Wake Up flag
  110. * @arg PWR_FLAG_SB: StandBy flag
  111. */
  112. #define __HAL_PWR_CLEAR_FLAG(__FLAG__) (PWR->CR |= (__FLAG__) << 2U)
  113. /**
  114. * @}
  115. */
  116. /* Private macros --------------------------------------------------------*/
  117. /** @addtogroup PWR_Private_Macros PWR Private Macros
  118. * @{
  119. */
  120. #define IS_PWR_WAKEUP_PIN(PIN) (((PIN) == PWR_WAKEUP_PIN1) || \
  121. ((PIN) == PWR_WAKEUP_PIN2) || \
  122. ((PIN) == PWR_WAKEUP_PIN3))
  123. #define IS_PWR_REGULATOR(REGULATOR) (((REGULATOR) == PWR_MAINREGULATOR_ON) || \
  124. ((REGULATOR) == PWR_LOWPOWERREGULATOR_ON))
  125. #define IS_PWR_SLEEP_ENTRY(ENTRY) (((ENTRY) == PWR_SLEEPENTRY_WFI) || ((ENTRY) == PWR_SLEEPENTRY_WFE))
  126. #define IS_PWR_STOP_ENTRY(ENTRY) (((ENTRY) == PWR_STOPENTRY_WFI) || ((ENTRY) == PWR_STOPENTRY_WFE))
  127. /**
  128. * @}
  129. */
  130. /* Include PWR HAL Extended module */
  131. #include "stm32f3xx_hal_pwr_ex.h"
  132. /* Exported functions --------------------------------------------------------*/
  133. /** @addtogroup PWR_Exported_Functions PWR Exported Functions
  134. * @{
  135. */
  136. /** @addtogroup PWR_Exported_Functions_Group1 Initialization and de-initialization functions
  137. * @{
  138. */
  139. /* Initialization and de-initialization functions *****************************/
  140. void HAL_PWR_DeInit(void);
  141. /**
  142. * @}
  143. */
  144. /** @addtogroup PWR_Exported_Functions_Group2 Peripheral Control functions
  145. * @{
  146. */
  147. /* Peripheral Control functions **********************************************/
  148. void HAL_PWR_EnableBkUpAccess(void);
  149. void HAL_PWR_DisableBkUpAccess(void);
  150. /* WakeUp pins configuration functions ****************************************/
  151. void HAL_PWR_EnableWakeUpPin(uint32_t WakeUpPinx);
  152. void HAL_PWR_DisableWakeUpPin(uint32_t WakeUpPinx);
  153. /* Low Power modes configuration functions ************************************/
  154. void HAL_PWR_EnterSTOPMode(uint32_t Regulator, uint8_t STOPEntry);
  155. void HAL_PWR_EnterSLEEPMode(uint32_t Regulator, uint8_t SLEEPEntry);
  156. void HAL_PWR_EnterSTANDBYMode(void);
  157. void HAL_PWR_EnableSleepOnExit(void);
  158. void HAL_PWR_DisableSleepOnExit(void);
  159. void HAL_PWR_EnableSEVOnPend(void);
  160. void HAL_PWR_DisableSEVOnPend(void);
  161. /**
  162. * @}
  163. */
  164. /**
  165. * @}
  166. */
  167. /**
  168. * @}
  169. */
  170. /**
  171. * @}
  172. */
  173. #ifdef __cplusplus
  174. }
  175. #endif
  176. #endif /* __STM32F3xx_HAL_PWR_H */