stm32f0xx_pwr.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. /**
  2. ******************************************************************************
  3. * @file stm32f0xx_pwr.h
  4. * @author MCD Application Team
  5. * @version V1.5.0
  6. * @date 05-December-2014
  7. * @brief This file contains all the functions prototypes for the PWR firmware
  8. * library.
  9. ******************************************************************************
  10. * @attention
  11. *
  12. * <h2><center>&copy; COPYRIGHT 2014 STMicroelectronics</center></h2>
  13. *
  14. * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  15. * You may not use this file except in compliance with the License.
  16. * You may obtain a copy of the License at:
  17. *
  18. * http://www.st.com/software_license_agreement_liberty_v2
  19. *
  20. * Unless required by applicable law or agreed to in writing, software
  21. * distributed under the License is distributed on an "AS IS" BASIS,
  22. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  23. * See the License for the specific language governing permissions and
  24. * limitations under the License.
  25. *
  26. ******************************************************************************
  27. */
  28. /* Define to prevent recursive inclusion -------------------------------------*/
  29. #ifndef __STM32F0XX_PWR_H
  30. #define __STM32F0XX_PWR_H
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34. /* Includes ------------------------------------------------------------------*/
  35. #include "stm32f0xx.h"
  36. /** @addtogroup STM32F0xx_StdPeriph_Driver
  37. * @{
  38. */
  39. /** @addtogroup PWR
  40. * @{
  41. */
  42. /* Exported types ------------------------------------------------------------*/
  43. /* Exported constants --------------------------------------------------------*/
  44. /** @defgroup PWR_Exported_Constants
  45. * @{
  46. */
  47. /** @defgroup PWR_PVD_detection_level
  48. * @brief This parameters are only applicable for STM32F051 and STM32F072 devices
  49. * @{
  50. */
  51. #define PWR_PVDLevel_0 PWR_CR_PLS_LEV0
  52. #define PWR_PVDLevel_1 PWR_CR_PLS_LEV1
  53. #define PWR_PVDLevel_2 PWR_CR_PLS_LEV2
  54. #define PWR_PVDLevel_3 PWR_CR_PLS_LEV3
  55. #define PWR_PVDLevel_4 PWR_CR_PLS_LEV4
  56. #define PWR_PVDLevel_5 PWR_CR_PLS_LEV5
  57. #define PWR_PVDLevel_6 PWR_CR_PLS_LEV6
  58. #define PWR_PVDLevel_7 PWR_CR_PLS_LEV7
  59. #define IS_PWR_PVD_LEVEL(LEVEL) (((LEVEL) == PWR_PVDLevel_0) || ((LEVEL) == PWR_PVDLevel_1)|| \
  60. ((LEVEL) == PWR_PVDLevel_2) || ((LEVEL) == PWR_PVDLevel_3)|| \
  61. ((LEVEL) == PWR_PVDLevel_4) || ((LEVEL) == PWR_PVDLevel_5)|| \
  62. ((LEVEL) == PWR_PVDLevel_6) || ((LEVEL) == PWR_PVDLevel_7))
  63. /**
  64. * @}
  65. */
  66. /** @defgroup PWR_WakeUp_Pins
  67. * @{
  68. */
  69. #define PWR_WakeUpPin_1 PWR_CSR_EWUP1
  70. #define PWR_WakeUpPin_2 PWR_CSR_EWUP2
  71. #define PWR_WakeUpPin_3 PWR_CSR_EWUP3 /*!< only applicable for STM32F072 devices */
  72. #define PWR_WakeUpPin_4 PWR_CSR_EWUP4 /*!< only applicable for STM32F072 devices */
  73. #define PWR_WakeUpPin_5 PWR_CSR_EWUP5 /*!< only applicable for STM32F072 devices */
  74. #define PWR_WakeUpPin_6 PWR_CSR_EWUP6 /*!< only applicable for STM32F072 devices */
  75. #define PWR_WakeUpPin_7 PWR_CSR_EWUP7 /*!< only applicable for STM32F072 devices */
  76. #define PWR_WakeUpPin_8 PWR_CSR_EWUP8 /*!< only applicable for STM32F072 devices */
  77. #define IS_PWR_WAKEUP_PIN(PIN) (((PIN) == PWR_WakeUpPin_1) || ((PIN) == PWR_WakeUpPin_2) || \
  78. ((PIN) == PWR_WakeUpPin_3) || ((PIN) == PWR_WakeUpPin_4) || \
  79. ((PIN) == PWR_WakeUpPin_5) || ((PIN) == PWR_WakeUpPin_6) || \
  80. ((PIN) == PWR_WakeUpPin_7) || ((PIN) == PWR_WakeUpPin_8))
  81. /**
  82. * @}
  83. */
  84. /** @defgroup PWR_Regulator_state_is_Sleep_STOP_mode
  85. * @{
  86. */
  87. #define PWR_Regulator_ON ((uint32_t)0x00000000)
  88. #define PWR_Regulator_LowPower PWR_CR_LPSDSR
  89. #define IS_PWR_REGULATOR(REGULATOR) (((REGULATOR) == PWR_Regulator_ON) || \
  90. ((REGULATOR) == PWR_Regulator_LowPower))
  91. /**
  92. * @}
  93. */
  94. /** @defgroup PWR_SLEEP_mode_entry
  95. * @{
  96. */
  97. #define PWR_SLEEPEntry_WFI ((uint8_t)0x01)
  98. #define PWR_SLEEPEntry_WFE ((uint8_t)0x02)
  99. #define IS_PWR_SLEEP_ENTRY(ENTRY) (((ENTRY) == PWR_SLEEPEntry_WFI) || ((ENTRY) == PWR_SLEEPEntry_WFE))
  100. /**
  101. * @}
  102. */
  103. /** @defgroup PWR_STOP_mode_entry
  104. * @{
  105. */
  106. #define PWR_STOPEntry_WFI ((uint8_t)0x01)
  107. #define PWR_STOPEntry_WFE ((uint8_t)0x02)
  108. #define PWR_STOPEntry_SLEEPONEXIT ((uint8_t)0x03)
  109. #define IS_PWR_STOP_ENTRY(ENTRY) (((ENTRY) == PWR_STOPEntry_WFI) || ((ENTRY) == PWR_STOPEntry_WFE) ||\
  110. ((ENTRY) == PWR_STOPEntry_SLEEPONEXIT))
  111. /**
  112. * @}
  113. */
  114. /** @defgroup PWR_Flag
  115. * @{
  116. */
  117. #define PWR_FLAG_WU PWR_CSR_WUF
  118. #define PWR_FLAG_SB PWR_CSR_SBF
  119. #define PWR_FLAG_PVDO PWR_CSR_PVDO /*!< Not applicable for STM32F030 devices */
  120. #define PWR_FLAG_VREFINTRDY PWR_CSR_VREFINTRDYF
  121. #define IS_PWR_GET_FLAG(FLAG) (((FLAG) == PWR_FLAG_WU) || ((FLAG) == PWR_FLAG_SB) || \
  122. ((FLAG) == PWR_FLAG_PVDO) || ((FLAG) == PWR_FLAG_VREFINTRDY))
  123. #define IS_PWR_CLEAR_FLAG(FLAG) (((FLAG) == PWR_FLAG_WU) || ((FLAG) == PWR_FLAG_SB))
  124. /**
  125. * @}
  126. */
  127. /**
  128. * @}
  129. */
  130. /* Exported macro ------------------------------------------------------------*/
  131. /* Exported functions ------------------------------------------------------- */
  132. /* Function used to set the PWR configuration to the default reset state ******/
  133. void PWR_DeInit(void);
  134. /* Backup Domain Access function **********************************************/
  135. void PWR_BackupAccessCmd(FunctionalState NewState);
  136. /* PVD configuration functions ************************************************/
  137. void PWR_PVDLevelConfig(uint32_t PWR_PVDLevel); /*!< only applicable for STM32F051 and STM32F072 devices */
  138. void PWR_PVDCmd(FunctionalState NewState); /*!< only applicable for STM32F051 and STM32F072 devices */
  139. /* WakeUp pins configuration functions ****************************************/
  140. void PWR_WakeUpPinCmd(uint32_t PWR_WakeUpPin, FunctionalState NewState);
  141. /* Low Power modes configuration functions ************************************/
  142. void PWR_EnterSleepMode(uint8_t PWR_SLEEPEntry);
  143. void PWR_EnterSTOPMode(uint32_t PWR_Regulator, uint8_t PWR_STOPEntry);
  144. void PWR_EnterSTANDBYMode(void);
  145. /* Flags management functions *************************************************/
  146. FlagStatus PWR_GetFlagStatus(uint32_t PWR_FLAG);
  147. void PWR_ClearFlag(uint32_t PWR_FLAG);
  148. #ifdef __cplusplus
  149. }
  150. #endif
  151. #endif /* __STM32F0XX_PWR_H */
  152. /**
  153. * @}
  154. */
  155. /**
  156. * @}
  157. */
  158. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/