You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

206 lines
6.9 KiB

  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. * <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 __STM32F0xx_HAL_PWR_H
  37. #define __STM32F0xx_HAL_PWR_H
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41. /* Includes ------------------------------------------------------------------*/
  42. #include "stm32f0xx_hal_def.h"
  43. /** @addtogroup STM32F0xx_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_Regulator_state_in_STOP_mode PWR Regulator state in STOP mode
  55. * @{
  56. */
  57. #define PWR_MAINREGULATOR_ON (0x00000000U)
  58. #define PWR_LOWPOWERREGULATOR_ON PWR_CR_LPDS
  59. #define IS_PWR_REGULATOR(REGULATOR) (((REGULATOR) == PWR_MAINREGULATOR_ON) || \
  60. ((REGULATOR) == PWR_LOWPOWERREGULATOR_ON))
  61. /**
  62. * @}
  63. */
  64. /** @defgroup PWR_SLEEP_mode_entry PWR SLEEP mode entry
  65. * @{
  66. */
  67. #define PWR_SLEEPENTRY_WFI ((uint8_t)0x01U)
  68. #define PWR_SLEEPENTRY_WFE ((uint8_t)0x02U)
  69. #define IS_PWR_SLEEP_ENTRY(ENTRY) (((ENTRY) == PWR_SLEEPENTRY_WFI) || ((ENTRY) == PWR_SLEEPENTRY_WFE))
  70. /**
  71. * @}
  72. */
  73. /** @defgroup PWR_STOP_mode_entry PWR STOP mode entry
  74. * @{
  75. */
  76. #define PWR_STOPENTRY_WFI ((uint8_t)0x01U)
  77. #define PWR_STOPENTRY_WFE ((uint8_t)0x02U)
  78. #define IS_PWR_STOP_ENTRY(ENTRY) (((ENTRY) == PWR_STOPENTRY_WFI) || ((ENTRY) == PWR_STOPENTRY_WFE))
  79. /**
  80. * @}
  81. */
  82. /**
  83. * @}
  84. */
  85. /* Exported macro ------------------------------------------------------------*/
  86. /** @defgroup PWR_Exported_Macro PWR Exported Macro
  87. * @{
  88. */
  89. /** @brief Check PWR flag is set or not.
  90. * @param __FLAG__ specifies the flag to check.
  91. * This parameter can be one of the following values:
  92. * @arg PWR_FLAG_WU: Wake Up flag. This flag indicates that a wakeup event
  93. * was received from the WKUP pin or from the RTC alarm (Alarm A),
  94. * RTC Tamper event, RTC TimeStamp event or RTC Wakeup.
  95. * An additional wakeup event is detected if the WKUP pin is enabled
  96. * (by setting the EWUP bit) when the WKUP pin level is already high.
  97. * @arg PWR_FLAG_SB: StandBy flag. This flag indicates that the system was
  98. * resumed from StandBy mode.
  99. * @arg PWR_FLAG_PVDO: PVD Output. This flag is valid only if PVD is enabled
  100. * by the HAL_PWR_EnablePVD() function. The PVD is stopped by Standby mode
  101. * For this reason, this bit is equal to 0 after Standby or reset
  102. * until the PVDE bit is set.
  103. * Warning: this Flag is not available on STM32F030x8 products
  104. * @arg PWR_FLAG_VREFINTRDY: This flag indicates that the internal reference
  105. * voltage VREFINT is ready.
  106. * Warning: this Flag is not available on STM32F030x8 products
  107. * @retval The new state of __FLAG__ (TRUE or FALSE).
  108. */
  109. #define __HAL_PWR_GET_FLAG(__FLAG__) ((PWR->CSR & (__FLAG__)) == (__FLAG__))
  110. /** @brief Clear the PWR's pending flags.
  111. * @param __FLAG__ specifies the flag to clear.
  112. * This parameter can be one of the following values:
  113. * @arg PWR_FLAG_WU: Wake Up flag
  114. * @arg PWR_FLAG_SB: StandBy flag
  115. */
  116. #define __HAL_PWR_CLEAR_FLAG(__FLAG__) (PWR->CR |= (__FLAG__) << 2U)
  117. /**
  118. * @}
  119. */
  120. /* Include PWR HAL Extension module */
  121. #include "stm32f0xx_hal_pwr_ex.h"
  122. /* Exported functions --------------------------------------------------------*/
  123. /** @addtogroup PWR_Exported_Functions PWR Exported Functions
  124. * @{
  125. */
  126. /** @addtogroup PWR_Exported_Functions_Group1 Initialization and de-initialization functions
  127. * @{
  128. */
  129. /* Initialization and de-initialization functions *****************************/
  130. void HAL_PWR_DeInit(void);
  131. /**
  132. * @}
  133. */
  134. /** @addtogroup PWR_Exported_Functions_Group2 Peripheral Control functions
  135. * @{
  136. */
  137. /* Peripheral Control functions **********************************************/
  138. void HAL_PWR_EnableBkUpAccess(void);
  139. void HAL_PWR_DisableBkUpAccess(void);
  140. /* WakeUp pins configuration functions ****************************************/
  141. void HAL_PWR_EnableWakeUpPin(uint32_t WakeUpPinx);
  142. void HAL_PWR_DisableWakeUpPin(uint32_t WakeUpPinx);
  143. /* Low Power modes configuration functions ************************************/
  144. void HAL_PWR_EnterSTOPMode(uint32_t Regulator, uint8_t STOPEntry);
  145. void HAL_PWR_EnterSLEEPMode(uint32_t Regulator, uint8_t SLEEPEntry);
  146. void HAL_PWR_EnterSTANDBYMode(void);
  147. void HAL_PWR_EnableSleepOnExit(void);
  148. void HAL_PWR_DisableSleepOnExit(void);
  149. void HAL_PWR_EnableSEVOnPend(void);
  150. void HAL_PWR_DisableSEVOnPend(void);
  151. /**
  152. * @}
  153. */
  154. /**
  155. * @}
  156. */
  157. /**
  158. * @}
  159. */
  160. /**
  161. * @}
  162. */
  163. #ifdef __cplusplus
  164. }
  165. #endif
  166. #endif /* __STM32F0xx_HAL_PWR_H */
  167. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/