stm32f4xx_pwr.h 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. /**
  2. ******************************************************************************
  3. * @file stm32f4xx_pwr.h
  4. * @author MCD Application Team
  5. * @version V1.8.0
  6. * @date 04-November-2016
  7. * @brief This file contains all the functions prototypes for the PWR firmware
  8. * library.
  9. ******************************************************************************
  10. * @attention
  11. *
  12. * <h2><center>&copy; COPYRIGHT 2016 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 __STM32F4xx_PWR_H
  30. #define __STM32F4xx_PWR_H
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34. /* Includes ------------------------------------------------------------------*/
  35. #include "stm32f4xx.h"
  36. /** @addtogroup STM32F4xx_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. * @{
  49. */
  50. #define PWR_PVDLevel_0 PWR_CR_PLS_LEV0
  51. #define PWR_PVDLevel_1 PWR_CR_PLS_LEV1
  52. #define PWR_PVDLevel_2 PWR_CR_PLS_LEV2
  53. #define PWR_PVDLevel_3 PWR_CR_PLS_LEV3
  54. #define PWR_PVDLevel_4 PWR_CR_PLS_LEV4
  55. #define PWR_PVDLevel_5 PWR_CR_PLS_LEV5
  56. #define PWR_PVDLevel_6 PWR_CR_PLS_LEV6
  57. #define PWR_PVDLevel_7 PWR_CR_PLS_LEV7
  58. #define IS_PWR_PVD_LEVEL(LEVEL) (((LEVEL) == PWR_PVDLevel_0) || ((LEVEL) == PWR_PVDLevel_1)|| \
  59. ((LEVEL) == PWR_PVDLevel_2) || ((LEVEL) == PWR_PVDLevel_3)|| \
  60. ((LEVEL) == PWR_PVDLevel_4) || ((LEVEL) == PWR_PVDLevel_5)|| \
  61. ((LEVEL) == PWR_PVDLevel_6) || ((LEVEL) == PWR_PVDLevel_7))
  62. /**
  63. * @}
  64. */
  65. /** @defgroup PWR_Regulator_state_in_STOP_mode
  66. * @{
  67. */
  68. #define PWR_MainRegulator_ON ((uint32_t)0x00000000)
  69. #define PWR_LowPowerRegulator_ON PWR_CR_LPDS
  70. /* --- PWR_Legacy ---*/
  71. #define PWR_Regulator_ON PWR_MainRegulator_ON
  72. #define PWR_Regulator_LowPower PWR_LowPowerRegulator_ON
  73. #define IS_PWR_REGULATOR(REGULATOR) (((REGULATOR) == PWR_MainRegulator_ON) || \
  74. ((REGULATOR) == PWR_LowPowerRegulator_ON))
  75. /**
  76. * @}
  77. */
  78. /** @defgroup PWR_Regulator_state_in_UnderDrive_mode
  79. * @{
  80. */
  81. #define PWR_MainRegulator_UnderDrive_ON PWR_CR_MRUDS
  82. #define PWR_LowPowerRegulator_UnderDrive_ON ((uint32_t)(PWR_CR_LPDS | PWR_CR_LPUDS))
  83. #define IS_PWR_REGULATOR_UNDERDRIVE(REGULATOR) (((REGULATOR) == PWR_MainRegulator_UnderDrive_ON) || \
  84. ((REGULATOR) == PWR_LowPowerRegulator_UnderDrive_ON))
  85. /**
  86. * @}
  87. */
  88. #if defined(STM32F410xx) || defined(STM32F412xG) || defined(STM32F413_423xx) || defined(STM32F446xx)
  89. /** @defgroup PWR_Wake_Up_Pin
  90. * @{
  91. */
  92. #define PWR_WakeUp_Pin1 ((uint32_t)0x00)
  93. #define PWR_WakeUp_Pin2 ((uint32_t)0x01)
  94. #if defined(STM32F410xx) || defined(STM32F412xG) || defined(STM32F413_423xx)
  95. #define PWR_WakeUp_Pin3 ((uint32_t)0x02)
  96. #endif /* STM32F410xx || STM32F412xG || STM32F413_423xx */
  97. #if defined(STM32F446xx)
  98. #define IS_PWR_WAKEUP_PIN(PIN) (((PIN) == PWR_WakeUp_Pin1) || \
  99. ((PIN) == PWR_WakeUp_Pin2))
  100. #else /* STM32F410xx || STM32F412xG */
  101. #define IS_PWR_WAKEUP_PIN(PIN) (((PIN) == PWR_WakeUp_Pin1) || ((PIN) == PWR_WakeUp_Pin2) || \
  102. ((PIN) == PWR_WakeUp_Pin3))
  103. #endif /* STM32F446xx */
  104. /**
  105. * @}
  106. */
  107. #endif /* STM32F410xx || STM32F412xG || STM32F413_423xx || STM32F446xx */
  108. /** @defgroup PWR_STOP_mode_entry
  109. * @{
  110. */
  111. #define PWR_STOPEntry_WFI ((uint8_t)0x01)
  112. #define PWR_STOPEntry_WFE ((uint8_t)0x02)
  113. #define IS_PWR_STOP_ENTRY(ENTRY) (((ENTRY) == PWR_STOPEntry_WFI) || ((ENTRY) == PWR_STOPEntry_WFE))
  114. /**
  115. * @}
  116. */
  117. /** @defgroup PWR_Regulator_Voltage_Scale
  118. * @{
  119. */
  120. #define PWR_Regulator_Voltage_Scale1 ((uint32_t)0x0000C000)
  121. #define PWR_Regulator_Voltage_Scale2 ((uint32_t)0x00008000)
  122. #define PWR_Regulator_Voltage_Scale3 ((uint32_t)0x00004000)
  123. #define IS_PWR_REGULATOR_VOLTAGE(VOLTAGE) (((VOLTAGE) == PWR_Regulator_Voltage_Scale1) || \
  124. ((VOLTAGE) == PWR_Regulator_Voltage_Scale2) || \
  125. ((VOLTAGE) == PWR_Regulator_Voltage_Scale3))
  126. /**
  127. * @}
  128. */
  129. /** @defgroup PWR_Flag
  130. * @{
  131. */
  132. #define PWR_FLAG_WU PWR_CSR_WUF
  133. #define PWR_FLAG_SB PWR_CSR_SBF
  134. #define PWR_FLAG_PVDO PWR_CSR_PVDO
  135. #define PWR_FLAG_BRR PWR_CSR_BRR
  136. #define PWR_FLAG_VOSRDY PWR_CSR_VOSRDY
  137. #define PWR_FLAG_ODRDY PWR_CSR_ODRDY
  138. #define PWR_FLAG_ODSWRDY PWR_CSR_ODSWRDY
  139. #define PWR_FLAG_UDRDY PWR_CSR_UDSWRDY
  140. /* --- FLAG Legacy ---*/
  141. #define PWR_FLAG_REGRDY PWR_FLAG_VOSRDY
  142. #define IS_PWR_GET_FLAG(FLAG) (((FLAG) == PWR_FLAG_WU) || ((FLAG) == PWR_FLAG_SB) || \
  143. ((FLAG) == PWR_FLAG_PVDO) || ((FLAG) == PWR_FLAG_BRR) || \
  144. ((FLAG) == PWR_FLAG_VOSRDY) || ((FLAG) == PWR_FLAG_ODRDY) || \
  145. ((FLAG) == PWR_FLAG_ODSWRDY) || ((FLAG) == PWR_FLAG_UDRDY))
  146. #define IS_PWR_CLEAR_FLAG(FLAG) (((FLAG) == PWR_FLAG_WU) || ((FLAG) == PWR_FLAG_SB) || \
  147. ((FLAG) == PWR_FLAG_UDRDY))
  148. /**
  149. * @}
  150. */
  151. /**
  152. * @}
  153. */
  154. /* Exported macro ------------------------------------------------------------*/
  155. /* Exported functions --------------------------------------------------------*/
  156. /* Function used to set the PWR configuration to the default reset state ******/
  157. void PWR_DeInit(void);
  158. /* Backup Domain Access function **********************************************/
  159. void PWR_BackupAccessCmd(FunctionalState NewState);
  160. /* PVD configuration functions ************************************************/
  161. void PWR_PVDLevelConfig(uint32_t PWR_PVDLevel);
  162. void PWR_PVDCmd(FunctionalState NewState);
  163. /* WakeUp pins configuration functions ****************************************/
  164. #if defined(STM32F40_41xxx) || defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F401xx) || defined(STM32F411xE)
  165. void PWR_WakeUpPinCmd(FunctionalState NewState);
  166. #endif /* STM32F40_41xxx || STM32F427_437xx || STM32F429_439xx || STM32F401xx || STM32F411xE */
  167. #if defined(STM32F410xx) || defined(STM32F412xG) || defined(STM32F413_423xx) ||defined(STM32F446xx)
  168. void PWR_WakeUpPinCmd(uint32_t PWR_WakeUpPinx, FunctionalState NewState);
  169. #endif /* STM32F410xx || STM32F412xG || STM32F413_423xx || STM32F446xx */
  170. /* Main and Backup Regulators configuration functions *************************/
  171. void PWR_BackupRegulatorCmd(FunctionalState NewState);
  172. void PWR_MainRegulatorModeConfig(uint32_t PWR_Regulator_Voltage);
  173. void PWR_OverDriveCmd(FunctionalState NewState);
  174. void PWR_OverDriveSWCmd(FunctionalState NewState);
  175. void PWR_UnderDriveCmd(FunctionalState NewState);
  176. #if defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F446xx)
  177. void PWR_MainRegulatorUnderDriveCmd(FunctionalState NewState);
  178. void PWR_LowRegulatorUnderDriveCmd(FunctionalState NewState);
  179. #endif /* STM32F427_437xx || STM32F429_439xx || STM32F446xx */
  180. #if defined(STM32F401xx) || defined(STM32F410xx) || defined(STM32F411xE) || defined(STM32F412xG) || defined(STM32F413_423xx)
  181. void PWR_MainRegulatorLowVoltageCmd(FunctionalState NewState);
  182. void PWR_LowRegulatorLowVoltageCmd(FunctionalState NewState);
  183. #endif /* STM32F401xx || STM32F410xx || STM32F411xE || STM32F412xG || STM32F413_423xx */
  184. /* FLASH Power Down configuration functions ***********************************/
  185. void PWR_FlashPowerDownCmd(FunctionalState NewState);
  186. /* Low Power modes configuration functions ************************************/
  187. void PWR_EnterSTOPMode(uint32_t PWR_Regulator, uint8_t PWR_STOPEntry);
  188. void PWR_EnterUnderDriveSTOPMode(uint32_t PWR_Regulator, uint8_t PWR_STOPEntry);
  189. void PWR_EnterSTANDBYMode(void);
  190. /* Flags management functions *************************************************/
  191. FlagStatus PWR_GetFlagStatus(uint32_t PWR_FLAG);
  192. void PWR_ClearFlag(uint32_t PWR_FLAG);
  193. #ifdef __cplusplus
  194. }
  195. #endif
  196. #endif /* __STM32F4xx_PWR_H */
  197. /**
  198. * @}
  199. */
  200. /**
  201. * @}
  202. */
  203. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/