stm32f7xx_hal_pwr_ex.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. /**
  2. ******************************************************************************
  3. * @file stm32f7xx_hal_pwr_ex.h
  4. * @author MCD Application Team
  5. * @brief Header file of PWR HAL Extension module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2017 STMicroelectronics.
  10. * All rights reserved.
  11. *
  12. * This software is licensed under terms that can be found in the LICENSE file
  13. * in the root directory of this software component.
  14. * If no LICENSE file comes with this software, it is provided AS-IS.
  15. *
  16. ******************************************************************************
  17. */
  18. /* Define to prevent recursive inclusion -------------------------------------*/
  19. #ifndef __STM32F7xx_HAL_PWR_EX_H
  20. #define __STM32F7xx_HAL_PWR_EX_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32f7xx_hal_def.h"
  26. /** @addtogroup STM32F7xx_HAL_Driver
  27. * @{
  28. */
  29. /** @addtogroup PWREx
  30. * @{
  31. */
  32. /* Exported types ------------------------------------------------------------*/
  33. /* Exported constants --------------------------------------------------------*/
  34. /** @defgroup PWREx_Exported_Constants PWREx Exported Constants
  35. * @{
  36. */
  37. /** @defgroup PWREx_WakeUp_Pins PWREx Wake Up Pins
  38. * @{
  39. */
  40. #define PWR_WAKEUP_PIN1 PWR_CSR2_EWUP1
  41. #define PWR_WAKEUP_PIN2 PWR_CSR2_EWUP2
  42. #define PWR_WAKEUP_PIN3 PWR_CSR2_EWUP3
  43. #define PWR_WAKEUP_PIN4 PWR_CSR2_EWUP4
  44. #define PWR_WAKEUP_PIN5 PWR_CSR2_EWUP5
  45. #define PWR_WAKEUP_PIN6 PWR_CSR2_EWUP6
  46. #define PWR_WAKEUP_PIN1_HIGH PWR_CSR2_EWUP1
  47. #define PWR_WAKEUP_PIN2_HIGH PWR_CSR2_EWUP2
  48. #define PWR_WAKEUP_PIN3_HIGH PWR_CSR2_EWUP3
  49. #define PWR_WAKEUP_PIN4_HIGH PWR_CSR2_EWUP4
  50. #define PWR_WAKEUP_PIN5_HIGH PWR_CSR2_EWUP5
  51. #define PWR_WAKEUP_PIN6_HIGH PWR_CSR2_EWUP6
  52. #define PWR_WAKEUP_PIN1_LOW (uint32_t)((PWR_CR2_WUPP1<<6) | PWR_CSR2_EWUP1)
  53. #define PWR_WAKEUP_PIN2_LOW (uint32_t)((PWR_CR2_WUPP2<<6) | PWR_CSR2_EWUP2)
  54. #define PWR_WAKEUP_PIN3_LOW (uint32_t)((PWR_CR2_WUPP3<<6) | PWR_CSR2_EWUP3)
  55. #define PWR_WAKEUP_PIN4_LOW (uint32_t)((PWR_CR2_WUPP4<<6) | PWR_CSR2_EWUP4)
  56. #define PWR_WAKEUP_PIN5_LOW (uint32_t)((PWR_CR2_WUPP5<<6) | PWR_CSR2_EWUP5)
  57. #define PWR_WAKEUP_PIN6_LOW (uint32_t)((PWR_CR2_WUPP6<<6) | PWR_CSR2_EWUP6)
  58. /**
  59. * @}
  60. */
  61. /** @defgroup PWREx_Regulator_state_in_UnderDrive_mode PWREx Regulator state in UnderDrive mode
  62. * @{
  63. */
  64. #define PWR_MAINREGULATOR_UNDERDRIVE_ON PWR_CR1_MRUDS
  65. #define PWR_LOWPOWERREGULATOR_UNDERDRIVE_ON ((uint32_t)(PWR_CR1_LPDS | PWR_CR1_LPUDS))
  66. /**
  67. * @}
  68. */
  69. /** @defgroup PWREx_Over_Under_Drive_Flag PWREx Over Under Drive Flag
  70. * @{
  71. */
  72. #define PWR_FLAG_ODRDY PWR_CSR1_ODRDY
  73. #define PWR_FLAG_ODSWRDY PWR_CSR1_ODSWRDY
  74. #define PWR_FLAG_UDRDY PWR_CSR1_UDRDY
  75. /**
  76. * @}
  77. */
  78. /** @defgroup PWREx_Wakeup_Pins_Flag PWREx Wake Up Pin Flags
  79. * @{
  80. */
  81. #define PWR_WAKEUP_PIN_FLAG1 PWR_CSR2_WUPF1
  82. #define PWR_WAKEUP_PIN_FLAG2 PWR_CSR2_WUPF2
  83. #define PWR_WAKEUP_PIN_FLAG3 PWR_CSR2_WUPF3
  84. #define PWR_WAKEUP_PIN_FLAG4 PWR_CSR2_WUPF4
  85. #define PWR_WAKEUP_PIN_FLAG5 PWR_CSR2_WUPF5
  86. #define PWR_WAKEUP_PIN_FLAG6 PWR_CSR2_WUPF6
  87. /**
  88. * @}
  89. */
  90. /**
  91. * @}
  92. */
  93. /* Exported macro ------------------------------------------------------------*/
  94. /** @defgroup PWREx_Exported_Macro PWREx Exported Macro
  95. * @{
  96. */
  97. /** @brief Macros to enable or disable the Over drive mode.
  98. */
  99. #define __HAL_PWR_OVERDRIVE_ENABLE() (PWR->CR1 |= (uint32_t)PWR_CR1_ODEN)
  100. #define __HAL_PWR_OVERDRIVE_DISABLE() (PWR->CR1 &= (uint32_t)(~PWR_CR1_ODEN))
  101. /** @brief Macros to enable or disable the Over drive switching.
  102. */
  103. #define __HAL_PWR_OVERDRIVESWITCHING_ENABLE() (PWR->CR1 |= (uint32_t)PWR_CR1_ODSWEN)
  104. #define __HAL_PWR_OVERDRIVESWITCHING_DISABLE() (PWR->CR1 &= (uint32_t)(~PWR_CR1_ODSWEN))
  105. /** @brief Macros to enable or disable the Under drive mode.
  106. * @note This mode is enabled only with STOP low power mode.
  107. * In this mode, the 1.2V domain is preserved in reduced leakage mode. This
  108. * mode is only available when the main regulator or the low power regulator
  109. * is in low voltage mode.
  110. * @note If the Under-drive mode was enabled, it is automatically disabled after
  111. * exiting Stop mode.
  112. * When the voltage regulator operates in Under-drive mode, an additional
  113. * startup delay is induced when waking up from Stop mode.
  114. */
  115. #define __HAL_PWR_UNDERDRIVE_ENABLE() (PWR->CR1 |= (uint32_t)PWR_CR1_UDEN)
  116. #define __HAL_PWR_UNDERDRIVE_DISABLE() (PWR->CR1 &= (uint32_t)(~PWR_CR1_UDEN))
  117. /** @brief Check PWR flag is set or not.
  118. * @param __FLAG__ specifies the flag to check.
  119. * This parameter can be one of the following values:
  120. * @arg PWR_FLAG_ODRDY: This flag indicates that the Over-drive mode
  121. * is ready
  122. * @arg PWR_FLAG_ODSWRDY: This flag indicates that the Over-drive mode
  123. * switching is ready
  124. * @arg PWR_FLAG_UDRDY: This flag indicates that the Under-drive mode
  125. * is enabled in Stop mode
  126. * @retval The new state of __FLAG__ (TRUE or FALSE).
  127. */
  128. #define __HAL_PWR_GET_ODRUDR_FLAG(__FLAG__) ((PWR->CSR1 & (__FLAG__)) == (__FLAG__))
  129. /** @brief Clear the Under-Drive Ready flag.
  130. */
  131. #define __HAL_PWR_CLEAR_ODRUDR_FLAG() (PWR->CSR1 |= (PWR_FLAG_UDRDY | PWR_CSR1_EIWUP))
  132. /** @brief Check Wake Up flag is set or not.
  133. * @param __WUFLAG__ specifies the Wake Up flag to check.
  134. * This parameter can be one of the following values:
  135. * @arg PWR_WAKEUP_PIN_FLAG1: Wakeup Pin Flag for PA0
  136. * @arg PWR_WAKEUP_PIN_FLAG2: Wakeup Pin Flag for PA2
  137. * @arg PWR_WAKEUP_PIN_FLAG3: Wakeup Pin Flag for PC1
  138. * @arg PWR_WAKEUP_PIN_FLAG4: Wakeup Pin Flag for PC13
  139. * @arg PWR_WAKEUP_PIN_FLAG5: Wakeup Pin Flag for PI8
  140. * @arg PWR_WAKEUP_PIN_FLAG6: Wakeup Pin Flag for PI11
  141. */
  142. #define __HAL_PWR_GET_WAKEUP_FLAG(__WUFLAG__) (PWR->CSR2 & (__WUFLAG__))
  143. /** @brief Clear the WakeUp pins flags.
  144. * @param __WUFLAG__ specifies the Wake Up pin flag to clear.
  145. * This parameter can be one of the following values:
  146. * @arg PWR_WAKEUP_PIN_FLAG1: Wakeup Pin Flag for PA0
  147. * @arg PWR_WAKEUP_PIN_FLAG2: Wakeup Pin Flag for PA2
  148. * @arg PWR_WAKEUP_PIN_FLAG3: Wakeup Pin Flag for PC1
  149. * @arg PWR_WAKEUP_PIN_FLAG4: Wakeup Pin Flag for PC13
  150. * @arg PWR_WAKEUP_PIN_FLAG5: Wakeup Pin Flag for PI8
  151. * @arg PWR_WAKEUP_PIN_FLAG6: Wakeup Pin Flag for PI11
  152. */
  153. #define __HAL_PWR_CLEAR_WAKEUP_FLAG(__WUFLAG__) (PWR->CR2 |= (__WUFLAG__))
  154. /**
  155. * @}
  156. */
  157. /* Exported functions --------------------------------------------------------*/
  158. /** @addtogroup PWREx_Exported_Functions PWREx Exported Functions
  159. * @{
  160. */
  161. /** @addtogroup PWREx_Exported_Functions_Group1
  162. * @{
  163. */
  164. uint32_t HAL_PWREx_GetVoltageRange(void);
  165. HAL_StatusTypeDef HAL_PWREx_ControlVoltageScaling(uint32_t VoltageScaling);
  166. void HAL_PWREx_EnableFlashPowerDown(void);
  167. void HAL_PWREx_DisableFlashPowerDown(void);
  168. HAL_StatusTypeDef HAL_PWREx_EnableBkUpReg(void);
  169. HAL_StatusTypeDef HAL_PWREx_DisableBkUpReg(void);
  170. void HAL_PWREx_EnableMainRegulatorLowVoltage(void);
  171. void HAL_PWREx_DisableMainRegulatorLowVoltage(void);
  172. void HAL_PWREx_EnableLowRegulatorLowVoltage(void);
  173. void HAL_PWREx_DisableLowRegulatorLowVoltage(void);
  174. HAL_StatusTypeDef HAL_PWREx_EnableOverDrive(void);
  175. HAL_StatusTypeDef HAL_PWREx_DisableOverDrive(void);
  176. HAL_StatusTypeDef HAL_PWREx_EnterUnderDriveSTOPMode(uint32_t Regulator, uint8_t STOPEntry);
  177. /**
  178. * @}
  179. */
  180. /**
  181. * @}
  182. */
  183. /* Private types -------------------------------------------------------------*/
  184. /* Private variables ---------------------------------------------------------*/
  185. /* Private constants ---------------------------------------------------------*/
  186. /* Private macros ------------------------------------------------------------*/
  187. /** @defgroup PWREx_Private_Macros PWREx Private Macros
  188. * @{
  189. */
  190. /** @defgroup PWREx_IS_PWR_Definitions PWREx Private macros to check input parameters
  191. * @{
  192. */
  193. #define IS_PWR_REGULATOR_UNDERDRIVE(REGULATOR) (((REGULATOR) == PWR_MAINREGULATOR_UNDERDRIVE_ON) || \
  194. ((REGULATOR) == PWR_LOWPOWERREGULATOR_UNDERDRIVE_ON))
  195. #define IS_PWR_WAKEUP_PIN(__PIN__) (((__PIN__) == PWR_WAKEUP_PIN1) || \
  196. ((__PIN__) == PWR_WAKEUP_PIN2) || \
  197. ((__PIN__) == PWR_WAKEUP_PIN3) || \
  198. ((__PIN__) == PWR_WAKEUP_PIN4) || \
  199. ((__PIN__) == PWR_WAKEUP_PIN5) || \
  200. ((__PIN__) == PWR_WAKEUP_PIN6) || \
  201. ((__PIN__) == PWR_WAKEUP_PIN1_HIGH) || \
  202. ((__PIN__) == PWR_WAKEUP_PIN2_HIGH) || \
  203. ((__PIN__) == PWR_WAKEUP_PIN3_HIGH) || \
  204. ((__PIN__) == PWR_WAKEUP_PIN4_HIGH) || \
  205. ((__PIN__) == PWR_WAKEUP_PIN5_HIGH) || \
  206. ((__PIN__) == PWR_WAKEUP_PIN6_HIGH) || \
  207. ((__PIN__) == PWR_WAKEUP_PIN1_LOW) || \
  208. ((__PIN__) == PWR_WAKEUP_PIN2_LOW) || \
  209. ((__PIN__) == PWR_WAKEUP_PIN3_LOW) || \
  210. ((__PIN__) == PWR_WAKEUP_PIN4_LOW) || \
  211. ((__PIN__) == PWR_WAKEUP_PIN5_LOW) || \
  212. ((__PIN__) == PWR_WAKEUP_PIN6_LOW))
  213. /**
  214. * @}
  215. */
  216. /**
  217. * @}
  218. */
  219. /**
  220. * @}
  221. */
  222. /**
  223. * @}
  224. */
  225. #ifdef __cplusplus
  226. }
  227. #endif
  228. #endif /* __STM32F7xx_HAL_PWR_EX_H */