stm32f0xx_hal_pwr.h 7.2 KB

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