stm32f3xx_hal_pwr.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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. * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
  10. *
  11. * Redistribution and use in source and binary forms, with or without modification,
  12. * are permitted provided that the following conditions are met:
  13. * 1. Redistributions of source code must retain the above copyright notice,
  14. * this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  19. * may be used to endorse or promote products derived from this software
  20. * without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  25. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  26. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  28. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  29. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  30. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. *
  33. ******************************************************************************
  34. */
  35. /* Define to prevent recursive inclusion -------------------------------------*/
  36. #ifndef __STM32F3xx_HAL_PWR_H
  37. #define __STM32F3xx_HAL_PWR_H
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41. /* Includes ------------------------------------------------------------------*/
  42. #include "stm32f3xx_hal_def.h"
  43. /** @addtogroup STM32F3xx_HAL_Driver
  44. * @{
  45. */
  46. /** @addtogroup PWR PWR
  47. * @{
  48. */
  49. /* Exported types ------------------------------------------------------------*/
  50. /* Exported constants --------------------------------------------------------*/
  51. /** @defgroup PWR_Exported_Constants PWR Exported Constants
  52. * @{
  53. */
  54. /** @defgroup PWR_WakeUp_Pins PWR WakeUp Pins
  55. * @{
  56. */
  57. #define PWR_WAKEUP_PIN1 ((uint32_t)PWR_CSR_EWUP1) /*!< Wakeup pin 1U */
  58. #define PWR_WAKEUP_PIN2 ((uint32_t)PWR_CSR_EWUP2) /*!< Wakeup pin 2U */
  59. #define PWR_WAKEUP_PIN3 ((uint32_t)PWR_CSR_EWUP3) /*!< Wakeup pin 3U */
  60. /**
  61. * @}
  62. */
  63. /** @defgroup PWR_Regulator_state_in_STOP_mode PWR Regulator state in STOP mode
  64. * @{
  65. */
  66. #define PWR_MAINREGULATOR_ON (0x00000000U) /*!< Voltage regulator on during STOP mode */
  67. #define PWR_LOWPOWERREGULATOR_ON PWR_CR_LPDS /*!< Voltage regulator in low-power mode during STOP mode */
  68. /**
  69. * @}
  70. */
  71. /** @defgroup PWR_SLEEP_mode_entry PWR SLEEP mode entry
  72. * @{
  73. */
  74. #define PWR_SLEEPENTRY_WFI ((uint8_t)0x01U) /*!< Wait For Interruption instruction to enter SLEEP mode */
  75. #define PWR_SLEEPENTRY_WFE ((uint8_t)0x02U) /*!< Wait For Event instruction to enter SLEEP mode */
  76. /**
  77. * @}
  78. */
  79. /** @defgroup PWR_STOP_mode_entry PWR STOP mode entry
  80. * @{
  81. */
  82. #define PWR_STOPENTRY_WFI ((uint8_t)0x01U) /*!< Wait For Interruption instruction to enter STOP mode */
  83. #define PWR_STOPENTRY_WFE ((uint8_t)0x02U) /*!< Wait For Event instruction to enter STOP mode */
  84. /**
  85. * @}
  86. */
  87. /** @defgroup PWR_Flag PWR Flag
  88. * @{
  89. */
  90. #define PWR_FLAG_WU PWR_CSR_WUF /*!< Wakeup event from wakeup pin or RTC alarm */
  91. #define PWR_FLAG_SB PWR_CSR_SBF /*!< Standby flag */
  92. #define PWR_FLAG_PVDO PWR_CSR_PVDO /*!< Power Voltage Detector output flag */
  93. #define PWR_FLAG_VREFINTRDY PWR_CSR_VREFINTRDYF /*!< VREFINT reference voltage ready */
  94. /**
  95. * @}
  96. */
  97. /**
  98. * @}
  99. */
  100. /* Exported macro ------------------------------------------------------------*/
  101. /** @defgroup PWR_Exported_Macro PWR Exported Macro
  102. * @{
  103. */
  104. /** @brief Check PWR flag is set or not.
  105. * @param __FLAG__ specifies the flag to check.
  106. * This parameter can be one of the following values:
  107. * @arg PWR_FLAG_WU: Wake Up flag. This flag indicates that a wakeup event
  108. * was received from the WKUP pin or from the RTC alarm (Alarm A
  109. * or Alarm B), RTC Tamper event, RTC TimeStamp event or RTC Wakeup.
  110. * An additional wakeup event is detected if the WKUP pin is enabled
  111. * (by setting the EWUP bit) when the WKUP pin level is already high.
  112. * @arg PWR_FLAG_SB: StandBy flag. This flag indicates that the system was
  113. * resumed from StandBy mode.
  114. * @arg PWR_FLAG_PVDO: PVD Output. This flag is valid only if PVD is enabled
  115. * by the HAL_PWR_EnablePVD() function. The PVD is stopped by Standby mode
  116. * For this reason, this bit is equal to 0 after Standby or reset
  117. * until the PVDE bit is set.
  118. * @arg PWR_FLAG_VREFINTRDY: This flag indicates that the internal reference
  119. * voltage VREFINT is ready.
  120. * @retval The new state of __FLAG__ (TRUE or FALSE).
  121. */
  122. #define __HAL_PWR_GET_FLAG(__FLAG__) ((PWR->CSR & (__FLAG__)) == (__FLAG__))
  123. /** @brief Clear the PWR's pending flags.
  124. * @param __FLAG__ specifies the flag to clear.
  125. * This parameter can be one of the following values:
  126. * @arg PWR_FLAG_WU: Wake Up flag
  127. * @arg PWR_FLAG_SB: StandBy flag
  128. */
  129. #define __HAL_PWR_CLEAR_FLAG(__FLAG__) (PWR->CR |= (__FLAG__) << 2U)
  130. /**
  131. * @}
  132. */
  133. /* Private macros --------------------------------------------------------*/
  134. /** @addtogroup PWR_Private_Macros PWR Private Macros
  135. * @{
  136. */
  137. #define IS_PWR_WAKEUP_PIN(PIN) (((PIN) == PWR_WAKEUP_PIN1) || \
  138. ((PIN) == PWR_WAKEUP_PIN2) || \
  139. ((PIN) == PWR_WAKEUP_PIN3))
  140. #define IS_PWR_REGULATOR(REGULATOR) (((REGULATOR) == PWR_MAINREGULATOR_ON) || \
  141. ((REGULATOR) == PWR_LOWPOWERREGULATOR_ON))
  142. #define IS_PWR_SLEEP_ENTRY(ENTRY) (((ENTRY) == PWR_SLEEPENTRY_WFI) || ((ENTRY) == PWR_SLEEPENTRY_WFE))
  143. #define IS_PWR_STOP_ENTRY(ENTRY) (((ENTRY) == PWR_STOPENTRY_WFI) || ((ENTRY) == PWR_STOPENTRY_WFE))
  144. /**
  145. * @}
  146. */
  147. /* Include PWR HAL Extended module */
  148. #include "stm32f3xx_hal_pwr_ex.h"
  149. /* Exported functions --------------------------------------------------------*/
  150. /** @addtogroup PWR_Exported_Functions PWR Exported Functions
  151. * @{
  152. */
  153. /** @addtogroup PWR_Exported_Functions_Group1 Initialization and de-initialization functions
  154. * @{
  155. */
  156. /* Initialization and de-initialization functions *****************************/
  157. void HAL_PWR_DeInit(void);
  158. /**
  159. * @}
  160. */
  161. /** @addtogroup PWR_Exported_Functions_Group2 Peripheral Control functions
  162. * @{
  163. */
  164. /* Peripheral Control functions **********************************************/
  165. void HAL_PWR_EnableBkUpAccess(void);
  166. void HAL_PWR_DisableBkUpAccess(void);
  167. /* WakeUp pins configuration functions ****************************************/
  168. void HAL_PWR_EnableWakeUpPin(uint32_t WakeUpPinx);
  169. void HAL_PWR_DisableWakeUpPin(uint32_t WakeUpPinx);
  170. /* Low Power modes configuration functions ************************************/
  171. void HAL_PWR_EnterSTOPMode(uint32_t Regulator, uint8_t STOPEntry);
  172. void HAL_PWR_EnterSLEEPMode(uint32_t Regulator, uint8_t SLEEPEntry);
  173. void HAL_PWR_EnterSTANDBYMode(void);
  174. void HAL_PWR_EnableSleepOnExit(void);
  175. void HAL_PWR_DisableSleepOnExit(void);
  176. void HAL_PWR_EnableSEVOnPend(void);
  177. void HAL_PWR_DisableSEVOnPend(void);
  178. /**
  179. * @}
  180. */
  181. /**
  182. * @}
  183. */
  184. /**
  185. * @}
  186. */
  187. /**
  188. * @}
  189. */
  190. #ifdef __cplusplus
  191. }
  192. #endif
  193. #endif /* __STM32F3xx_HAL_PWR_H */
  194. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/