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.
 
 
 

598 lines
22 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32h7xx_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) 2017 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST under BSD 3-Clause license,
  13. * the "License"; You may not use this file except in compliance with the
  14. * License. You may obtain a copy of the License at:
  15. * opensource.org/licenses/BSD-3-Clause
  16. *
  17. ******************************************************************************
  18. */
  19. /* Define to prevent recursive inclusion -------------------------------------*/
  20. #ifndef STM32H7xx_HAL_PWR_H
  21. #define STM32H7xx_HAL_PWR_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "stm32h7xx_hal_def.h"
  27. /** @addtogroup STM32H7xx_HAL_Driver
  28. * @{
  29. */
  30. /** @addtogroup PWR
  31. * @{
  32. */
  33. /* Exported types ------------------------------------------------------------*/
  34. /** @defgroup PWR_Exported_Types PWR Exported Types
  35. * @{
  36. */
  37. /**
  38. * @brief PWR PVD configuration structure definition
  39. */
  40. typedef struct
  41. {
  42. uint32_t PVDLevel; /*!< PVDLevel: Specifies the PVD detection level.
  43. This parameter can be a value of @ref PWR_PVD_detection_level */
  44. uint32_t Mode; /*!< Mode: Specifies the operating mode for the selected pins.
  45. This parameter can be a value of @ref PWR_PVD_Mode */
  46. }PWR_PVDTypeDef;
  47. /**
  48. * @}
  49. */
  50. /* Exported constants --------------------------------------------------------*/
  51. /** @defgroup PWR_Exported_Constants PWR Exported Constants
  52. * @{
  53. */
  54. /** @defgroup PWR_PVD_detection_level PWR PVD detection level
  55. * @{
  56. */
  57. #define PWR_PVDLEVEL_0 PWR_CR1_PLS_LEV0 /*!< Programmable voltage detector level 0 selection : 1V95 */
  58. #define PWR_PVDLEVEL_1 PWR_CR1_PLS_LEV1 /*!< Programmable voltage detector level 1 selection : 2V1 */
  59. #define PWR_PVDLEVEL_2 PWR_CR1_PLS_LEV2 /*!< Programmable voltage detector level 2 selection : 2V25 */
  60. #define PWR_PVDLEVEL_3 PWR_CR1_PLS_LEV3 /*!< Programmable voltage detector level 3 selection : 2V4 */
  61. #define PWR_PVDLEVEL_4 PWR_CR1_PLS_LEV4 /*!< Programmable voltage detector level 4 selection : 2V55 */
  62. #define PWR_PVDLEVEL_5 PWR_CR1_PLS_LEV5 /*!< Programmable voltage detector level 5 selection : 2V7 */
  63. #define PWR_PVDLEVEL_6 PWR_CR1_PLS_LEV6 /*!< Programmable voltage detector level 6 selection : 2V85 */
  64. #define PWR_PVDLEVEL_7 PWR_CR1_PLS_LEV7 /*!< External input analog voltage (Compare internally to VREFINT) */
  65. /**
  66. * @}
  67. */
  68. /** @defgroup PWR_PVD_Mode PWR PVD Mode
  69. * @{
  70. */
  71. #define PWR_PVD_MODE_NORMAL ((uint32_t)0x00000000U) /*!< Basic mode is used */
  72. #define PWR_PVD_MODE_IT_RISING ((uint32_t)0x00010001U) /*!< External Interrupt Mode with Rising edge trigger detection */
  73. #define PWR_PVD_MODE_IT_FALLING ((uint32_t)0x00010002U) /*!< External Interrupt Mode with Falling edge trigger detection */
  74. #define PWR_PVD_MODE_IT_RISING_FALLING ((uint32_t)0x00010003U) /*!< External Interrupt Mode with Rising/Falling edge trigger detection */
  75. #define PWR_PVD_MODE_EVENT_RISING ((uint32_t)0x00020001U) /*!< Event Mode with Rising edge trigger detection */
  76. #define PWR_PVD_MODE_EVENT_FALLING ((uint32_t)0x00020002U) /*!< Event Mode with Falling edge trigger detection */
  77. #define PWR_PVD_MODE_EVENT_RISING_FALLING ((uint32_t)0x00020003U) /*!< Event Mode with Rising/Falling edge trigger detection */
  78. /**
  79. * @}
  80. */
  81. /** @defgroup PWR_Regulator_state_in_STOP_mode PWR Regulator state in SLEEP/STOP mode
  82. * @{
  83. */
  84. #define PWR_MAINREGULATOR_ON ((uint32_t)0x00000000U)
  85. #define PWR_LOWPOWERREGULATOR_ON PWR_CR1_LPDS
  86. /**
  87. * @}
  88. */
  89. /** @defgroup PWR_SLEEP_mode_entry PWR SLEEP mode entry
  90. * @{
  91. */
  92. #define PWR_SLEEPENTRY_WFI ((uint8_t)0x01U)
  93. #define PWR_SLEEPENTRY_WFE ((uint8_t)0x02U)
  94. /**
  95. * @}
  96. */
  97. /** @defgroup PWR_STOP_mode_entry PWR STOP mode entry
  98. * @{
  99. */
  100. #define PWR_STOPENTRY_WFI ((uint8_t)0x01U)
  101. #define PWR_STOPENTRY_WFE ((uint8_t)0x02U)
  102. /**
  103. * @}
  104. */
  105. /** @defgroup PWR_Regulator_Voltage_Scale PWR Regulator Voltage Scale
  106. * @{
  107. */
  108. #define PWR_REGULATOR_VOLTAGE_SCALE0 ((uint32_t)0x00000000)
  109. #define PWR_REGULATOR_VOLTAGE_SCALE1 (PWR_D3CR_VOS_1 | PWR_D3CR_VOS_0)
  110. #define PWR_REGULATOR_VOLTAGE_SCALE2 (PWR_D3CR_VOS_1)
  111. #define PWR_REGULATOR_VOLTAGE_SCALE3 (PWR_D3CR_VOS_0)
  112. /**
  113. * @}
  114. */
  115. /** @defgroup PWR_Flag PWR Flag
  116. * @{
  117. */
  118. #define PWR_FLAG_STOP ((uint8_t)0x01U)
  119. #define PWR_FLAG_SB_D1 ((uint8_t)0x02U)
  120. #define PWR_FLAG_SB_D2 ((uint8_t)0x03U)
  121. #define PWR_FLAG_SB ((uint8_t)0x04U)
  122. #if defined(DUAL_CORE)
  123. #define PWR_FLAG_CPU_HOLD ((uint8_t)0x05U)
  124. #define PWR_FLAG_CPU2_HOLD ((uint8_t)0x06U)
  125. #define PWR_FLAG2_STOP ((uint8_t)0x07U)
  126. #define PWR_FLAG2_SB_D1 ((uint8_t)0x08U)
  127. #define PWR_FLAG2_SB_D2 ((uint8_t)0x09U)
  128. #define PWR_FLAG2_SB ((uint8_t)0x0AU)
  129. #endif /*DUAL_CORE*/
  130. #define PWR_FLAG_PVDO ((uint8_t)0x0BU)
  131. #define PWR_FLAG_AVDO ((uint8_t)0x0CU)
  132. #define PWR_FLAG_ACTVOSRDY ((uint8_t)0x0DU)
  133. #define PWR_FLAG_ACTVOS ((uint8_t)0x0EU)
  134. #define PWR_FLAG_BRR ((uint8_t)0x0FU)
  135. #define PWR_FLAG_VOSRDY ((uint8_t)0x10U)
  136. #if defined(SMPS)
  137. #define PWR_FLAG_SMPSEXTRDY ((uint8_t)0x11U)
  138. #else
  139. #define PWR_FLAG_SCUEN ((uint8_t)0x11U)
  140. #endif /* SMPS */
  141. /**
  142. * @}
  143. */
  144. /** @defgroup PWR_ENABLE_WUP_Mask PWR Enable WUP Mask
  145. * @{
  146. */
  147. #define PWR_EWUP_MASK ((uint32_t)0x0FFF3F3FU)
  148. /**
  149. * @}
  150. */
  151. /**
  152. * @}
  153. */
  154. /* Exported macro ------------------------------------------------------------*/
  155. /** @defgroup PWR_Exported_Macro PWR Exported Macro
  156. * @{
  157. */
  158. /** @brief macros configure the main internal regulator output voltage.
  159. * @param __REGULATOR__: specifies the regulator output voltage to achieve
  160. * a tradeoff between performance and power consumption when the device does
  161. * not operate at the maximum frequency (refer to the datasheets for more details).
  162. * This parameter can be one of the following values:
  163. * @arg PWR_REGULATOR_VOLTAGE_SCALE0: Regulator voltage output Scale 0 mode
  164. * @arg PWR_REGULATOR_VOLTAGE_SCALE1: Regulator voltage output Scale 1 mode
  165. * @arg PWR_REGULATOR_VOLTAGE_SCALE2: Regulator voltage output Scale 2 mode
  166. * @arg PWR_REGULATOR_VOLTAGE_SCALE3: Regulator voltage output Scale 3 mode
  167. * @note PWR_REGULATOR_VOLTAGE_SCALE0 is only possible when Vcore is supplied from LDO.
  168. * the SYSCFG Clock must be enabled before selecting PWR_REGULATOR_VOLTAGE_SCALE0
  169. * using macro __HAL_RCC_SYSCFG_CLK_ENABLE().
  170. * Transition to PWR_REGULATOR_VOLTAGE_SCALE0 is only possible when the system is already in
  171. * PWR_REGULATOR_VOLTAGE_SCALE1.
  172. * transition from PWR_REGULATOR_VOLTAGE_SCALE0 is only possible to PWR_REGULATOR_VOLTAGE_SCALE1
  173. * then once in PWR_REGULATOR_VOLTAGE_SCALE1 it is possible to switch to another voltage scale.
  174. * After each regulator voltage setting, wait on PWR_FLAG_VOSRDY to be set using macro __HAL_PWR_GET_FLAG
  175. * To enter low power mode , and if current regulator voltage is PWR_REGULATOR_VOLTAGE_SCALE0 then first
  176. * switch to PWR_REGULATOR_VOLTAGE_SCALE1 before entering low power mode.
  177. *
  178. * @retval None
  179. */
  180. #define __HAL_PWR_VOLTAGESCALING_CONFIG(__REGULATOR__) \
  181. do { \
  182. __IO uint32_t tmpreg = 0x00; \
  183. if((__REGULATOR__) == PWR_REGULATOR_VOLTAGE_SCALE0) \
  184. { \
  185. MODIFY_REG(PWR->D3CR, PWR_D3CR_VOS, PWR_REGULATOR_VOLTAGE_SCALE1); \
  186. /* Delay after setting the voltage scaling */ \
  187. tmpreg = READ_BIT(PWR->D3CR, PWR_D3CR_VOS); \
  188. MODIFY_REG(SYSCFG->PWRCR, SYSCFG_PWRCR_ODEN, SYSCFG_PWRCR_ODEN); \
  189. /* Delay after setting the syscfg boost setting */ \
  190. tmpreg = READ_BIT(SYSCFG->PWRCR, SYSCFG_PWRCR_ODEN); \
  191. } \
  192. else \
  193. { \
  194. CLEAR_BIT(SYSCFG->PWRCR, SYSCFG_PWRCR_ODEN); \
  195. /* Delay after setting the syscfg boost setting */ \
  196. tmpreg = READ_BIT(SYSCFG->PWRCR, SYSCFG_PWRCR_ODEN); \
  197. MODIFY_REG(PWR->D3CR, PWR_D3CR_VOS, (__REGULATOR__)); \
  198. tmpreg = READ_BIT(PWR->D3CR, PWR_D3CR_VOS); \
  199. } \
  200. UNUSED(tmpreg); \
  201. } while(0)
  202. #if defined(DUAL_CORE)
  203. /** @brief Check PWR PVD/AVD and VOSflags are set or not.
  204. * @param __FLAG__: specifies the flag to check.
  205. * This parameter can be one of the following values:
  206. * @arg PWR_FLAG_PVDO: PVD Output. This flag is valid only if PVD is enabled
  207. * by the HAL_PWR_EnablePVD() function. The PVD is stopped by Standby mode.
  208. * For this reason, this bit is equal to 0 after Standby or reset
  209. * until the PVDE bit is set.
  210. * @arg PWR_FLAG_AVDO: AVD Output. This flag is valid only if AVD is enabled
  211. * by the HAL_PWREx_EnableAVD() function. The AVD is stopped by Standby mode.
  212. * For this reason, this bit is equal to 0 after Standby or reset
  213. * until the AVDE bit is set.
  214. * @arg PWR_FLAG_ACTVOSRDY: This flag indicates that the Regulator voltage
  215. * scaling output selection is ready.
  216. * @arg PWR_FLAG_VOSRDY: This flag indicates that the Regulator voltage
  217. * scaling output selection is ready.
  218. * @arg PWR_FLAG_SMPSEXTRDY: SMPS External supply ready flag.
  219. * @arg PWR_FLAG_BRR: Backup regulator ready flag. This bit is not reset
  220. * when the device wakes up from Standby mode or by a system reset
  221. * or power reset.
  222. * @arg PWR_FLAG_SB: StandBy flag
  223. * @arg PWR_FLAG_STOP: STOP flag
  224. * @arg PWR_FLAG_SB_D1: StandBy D1 flag
  225. * @arg PWR_FLAG_SB_D2: StandBy D2 flag
  226. * @arg PWR_FLAG_CPU1_HOLD: CPU1 system wake up with hold
  227. * @arg PWR_FLAG_CPU2_HOLD: CPU2 system wake up with hold
  228. * @retval The new state of __FLAG__ (TRUE or FALSE).
  229. */
  230. #define __HAL_PWR_GET_FLAG(__FLAG__) ( \
  231. ((__FLAG__) == PWR_FLAG_PVDO)?((PWR->CSR1 & PWR_CSR1_PVDO) == PWR_CSR1_PVDO) : \
  232. ((__FLAG__) == PWR_FLAG_AVDO)?((PWR->CSR1 & PWR_CSR1_AVDO) == PWR_CSR1_AVDO) : \
  233. ((__FLAG__) == PWR_FLAG_ACTVOSRDY)?((PWR->CSR1 & PWR_CSR1_ACTVOSRDY) == PWR_CSR1_ACTVOSRDY) : \
  234. ((__FLAG__) == PWR_FLAG_VOSRDY)?((PWR->D3CR & PWR_D3CR_VOSRDY) == PWR_D3CR_VOSRDY) : \
  235. ((__FLAG__) == PWR_FLAG_SMPSEXTRDY)?((PWR->CR3 & PWR_CR3_SMPSEXTRDY) == PWR_CR3_SMPSEXTRDY) : \
  236. ((__FLAG__) == PWR_FLAG_BRR)?((PWR->CR2 & PWR_CR2_BRRDY) == PWR_CR2_BRRDY) : \
  237. ((__FLAG__) == PWR_FLAG_CPU_HOLD)?((PWR->CPU2CR & PWR_CPU2CR_HOLD1F) == PWR_CPU2CR_HOLD1F) : \
  238. ((__FLAG__) == PWR_FLAG_CPU2_HOLD)?((PWR->CPUCR & PWR_CPUCR_HOLD2F) == PWR_CPUCR_HOLD2F) : \
  239. ((__FLAG__) == PWR_FLAG_SB)?(READ_BIT(PWR->CPUCR, PWR_CPUCR_SBF) == PWR_CPUCR_SBF) : \
  240. ((__FLAG__) == PWR_FLAG2_SB)?(READ_BIT(PWR->CPU2CR, PWR_CPU2CR_SBF) == PWR_CPU2CR_SBF) : \
  241. ((__FLAG__) == PWR_FLAG_STOP)?(READ_BIT(PWR->CPUCR, PWR_CPUCR_STOPF) == PWR_CPUCR_STOPF) : \
  242. ((__FLAG__) == PWR_FLAG2_STOP)?(READ_BIT(PWR->CPU2CR, PWR_CPU2CR_STOPF) == PWR_CPU2CR_STOPF) : \
  243. ((__FLAG__) == PWR_FLAG_SB_D1)?(READ_BIT(PWR->CPUCR, PWR_CPUCR_SBF_D1) == PWR_CPUCR_SBF_D1) : \
  244. ((__FLAG__) == PWR_FLAG2_SB_D1)?(READ_BIT(PWR->CPU2CR, PWR_CPU2CR_SBF_D1) == PWR_CPU2CR_SBF_D1) : \
  245. ((__FLAG__) == PWR_FLAG_SB_D2)?(READ_BIT(PWR->CPUCR, PWR_CPUCR_SBF_D2) == PWR_CPUCR_SBF_D2) : \
  246. (READ_BIT(PWR->CPU2CR, PWR_CPU2CR_SBF_D2) == PWR_CPU2CR_SBF_D2))
  247. #else
  248. /** @brief Check PWR PVD/AVD and VOSflags are set or not.
  249. * @param __FLAG__: specifies the flag to check.
  250. * This parameter can be one of the following values:
  251. * @arg PWR_FLAG_PVDO: PVD Output. This flag is valid only if PVD is enabled
  252. * by the HAL_PWR_EnablePVD() function. The PVD is stopped by Standby mode.
  253. * For this reason, this bit is equal to 0 after Standby or reset
  254. * until the PVDE bit is set.
  255. * @arg PWR_FLAG_AVDO: AVD Output. This flag is valid only if AVD is enabled
  256. * by the HAL_PWREx_EnableAVD() function. The AVD is stopped by Standby mode.
  257. * For this reason, this bit is equal to 0 after Standby or reset
  258. * until the AVDE bit is set.
  259. * @arg PWR_FLAG_ACTVOSRDY: This flag indicates that the Regulator voltage
  260. * scaling output selection is ready.
  261. * @arg PWR_FLAG_VOSRDY: This flag indicates that the Regulator voltage
  262. * scaling output selection is ready.
  263. * @arg PWR_FLAG_BRR: Backup regulator ready flag. This bit is not reset
  264. * when the device wakes up from Standby mode or by a system reset
  265. * or power reset.
  266. * @arg PWR_FLAG_SB: StandBy flag
  267. * @arg PWR_FLAG_STOP: STOP flag
  268. * @arg PWR_FLAG_SB_D1: StandBy D1 flag
  269. * @arg PWR_FLAG_SB_D2: StandBy D2 flag
  270. * @retval The new state of __FLAG__ (TRUE or FALSE).
  271. */
  272. #define __HAL_PWR_GET_FLAG(__FLAG__) ( \
  273. ((__FLAG__) == PWR_FLAG_PVDO)?((PWR->CSR1 & PWR_CSR1_PVDO) == PWR_CSR1_PVDO) : \
  274. ((__FLAG__) == PWR_FLAG_AVDO)?((PWR->CSR1 & PWR_CSR1_AVDO) == PWR_CSR1_AVDO) : \
  275. ((__FLAG__) == PWR_FLAG_ACTVOSRDY)?((PWR->CSR1 & PWR_CSR1_ACTVOSRDY) == PWR_CSR1_ACTVOSRDY) : \
  276. ((__FLAG__) == PWR_FLAG_VOSRDY)?((PWR->D3CR & PWR_D3CR_VOSRDY) == PWR_D3CR_VOSRDY) : \
  277. ((__FLAG__) == PWR_FLAG_SCUEN)?((PWR->CR3 & PWR_CR3_SCUEN) == PWR_CR3_SCUEN) : \
  278. ((__FLAG__) == PWR_FLAG_BRR)?((PWR->CR2 & PWR_CR2_BRRDY) == PWR_CR2_BRRDY) : \
  279. ((__FLAG__) == PWR_FLAG_SB)?((PWR->CPUCR & PWR_CPUCR_SBF) == PWR_CPUCR_SBF) : \
  280. ((__FLAG__) == PWR_FLAG_STOP)?((PWR->CPUCR & PWR_CPUCR_STOPF) == PWR_CPUCR_STOPF) : \
  281. ((__FLAG__) == PWR_FLAG_SB_D1)?((PWR->CPUCR & PWR_CPUCR_SBF_D1) == PWR_CPUCR_SBF_D1) : \
  282. ((PWR->CPUCR & PWR_CPUCR_SBF_D2) == PWR_CPUCR_SBF_D2))
  283. #endif /*DUAL_CORE*/
  284. #if defined(DUAL_CORE)
  285. /** @brief Clear PWR flags.
  286. * @param __FLAG__: specifies the flag to clear.
  287. * This parameter can be one of the following values:
  288. * @arg PWR_FLAG_SB: Standby flag.
  289. * @arg PWR_CPU_FLAGS: Clear HOLD2F, STOPF, SBF, SBF_D1, and SBF_D2 CPU flags.
  290. * @retval None.
  291. */
  292. #define __HAL_PWR_CLEAR_FLAG(__FLAG__) \
  293. do { \
  294. SET_BIT(PWR->CPUCR, PWR_CPUCR_CSSF); \
  295. SET_BIT(PWR->CPU2CR, PWR_CPU2CR_CSSF); \
  296. } while(0)
  297. #else
  298. /** @brief Clear PWR flags.
  299. * @param __FLAG__: specifies the flag to clear.
  300. * This parameter can be one of the following values:
  301. * @arg PWR_FLAG_SB: Standby flag.
  302. * @arg PWR_CPU_FLAGS: Clear STOPF, SBF, SBF_D1, and SBF_D2 CPU flags.
  303. * @retval None.
  304. */
  305. #define __HAL_PWR_CLEAR_FLAG(__FLAG__) SET_BIT(PWR->CPUCR, PWR_CPUCR_CSSF)
  306. #endif /*DUAL_CORE*/
  307. /**
  308. * @brief Enable the PVD EXTI Line 16.
  309. * @retval None.
  310. */
  311. #define __HAL_PWR_PVD_EXTI_ENABLE_IT() SET_BIT(EXTI->IMR1, PWR_EXTI_LINE_PVD)
  312. #if defined(DUAL_CORE)
  313. /**
  314. * @brief Enable the PVD EXTI D2 Line 16.
  315. * @retval None.
  316. */
  317. #define __HAL_PWR_PVD_EXTID2_ENABLE_IT() SET_BIT(EXTI_D2->IMR1, PWR_EXTI_LINE_PVD)
  318. #endif /*DUAL_CORE*/
  319. /**
  320. * @brief Disable the PVD EXTI Line 16.
  321. * @retval None.
  322. */
  323. #define __HAL_PWR_PVD_EXTI_DISABLE_IT() CLEAR_BIT(EXTI->IMR1, PWR_EXTI_LINE_PVD)
  324. #if defined(DUAL_CORE)
  325. /**
  326. * @brief Disable the PVD EXTI D2 Line 16.
  327. * @retval None.
  328. */
  329. #define __HAL_PWR_PVD_EXTID2_DISABLE_IT() CLEAR_BIT(EXTI_D2->IMR1, PWR_EXTI_LINE_PVD)
  330. #endif /*DUAL_CORE*/
  331. /**
  332. * @brief Enable event on PVD EXTI Line 16.
  333. * @retval None.
  334. */
  335. #define __HAL_PWR_PVD_EXTI_ENABLE_EVENT() SET_BIT(EXTI->EMR1, PWR_EXTI_LINE_PVD)
  336. #if defined(DUAL_CORE)
  337. /**
  338. * @brief Enable event on PVD EXTI D2 Line.
  339. * @retval None.
  340. */
  341. #define __HAL_PWR_PVD_EXTID2_ENABLE_EVENT() SET_BIT(EXTI_D2->EMR1, PWR_EXTI_LINE_PVD)
  342. #endif /*DUAL_CORE*/
  343. /**
  344. * @brief Disable event on PVD EXTI Line 16.
  345. * @retval None.
  346. */
  347. #define __HAL_PWR_PVD_EXTI_DISABLE_EVENT() CLEAR_BIT(EXTI->EMR1, PWR_EXTI_LINE_PVD)
  348. #if defined(DUAL_CORE)
  349. /**
  350. * @brief Disable event on PVD EXTI D2 Line.
  351. * @retval None.
  352. */
  353. #define __HAL_PWR_PVD_EXTID2_DISABLE_EVENT() CLEAR_BIT(EXTI_D2->EMR1, PWR_EXTI_LINE_PVD)
  354. #endif /*DUAL_CORE*/
  355. /**
  356. * @brief Enable the PVD Extended Interrupt Rising Trigger.
  357. * @retval None.
  358. */
  359. #define __HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE() SET_BIT(EXTI->RTSR1, PWR_EXTI_LINE_PVD)
  360. /**
  361. * @brief Disable the PVD Extended Interrupt Rising Trigger.
  362. * @retval None.
  363. */
  364. #define __HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE() CLEAR_BIT(EXTI->RTSR1, PWR_EXTI_LINE_PVD)
  365. /**
  366. * @brief Enable the PVD Extended Interrupt Falling Trigger.
  367. * @retval None.
  368. */
  369. #define __HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE() SET_BIT(EXTI->FTSR1, PWR_EXTI_LINE_PVD)
  370. /**
  371. * @brief Disable the PVD Extended Interrupt Falling Trigger.
  372. * @retval None.
  373. */
  374. #define __HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE() CLEAR_BIT(EXTI->FTSR1, PWR_EXTI_LINE_PVD)
  375. /**
  376. * @brief PVD EXTI line configuration: set rising & falling edge trigger.
  377. * @retval None.
  378. */
  379. #define __HAL_PWR_PVD_EXTI_ENABLE_RISING_FALLING_EDGE() \
  380. do { \
  381. __HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE(); \
  382. __HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE(); \
  383. } while(0);
  384. /**
  385. * @brief Disable the PVD Extended Interrupt Rising & Falling Trigger.
  386. * @retval None.
  387. */
  388. #define __HAL_PWR_PVD_EXTI_DISABLE_RISING_FALLING_EDGE() \
  389. do { \
  390. __HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE(); \
  391. __HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE(); \
  392. } while(0);
  393. /**
  394. * @brief Check whether the specified PVD EXTI interrupt flag is set or not.
  395. * @retval EXTI PVD Line Status.
  396. */
  397. #define __HAL_PWR_PVD_EXTI_GET_FLAG() ((READ_BIT(EXTI->PR1, PWR_EXTI_LINE_PVD) == PWR_EXTI_LINE_PVD) ? SET : RESET)
  398. #if defined(DUAL_CORE)
  399. /**
  400. * @brief checks whether the specified PVD Exti interrupt flag is set or not.
  401. * @retval EXTI D2 PVD Line Status.
  402. */
  403. #define __HAL_PWR_PVD_EXTID2_GET_FLAG() ((READ_BIT(EXTI_D2->PR1, PWR_EXTI_LINE_PVD) == PWR_EXTI_LINE_PVD) ? SET : RESET)
  404. #endif /*DUAL_CORE*/
  405. /**
  406. * @brief Clear the PVD EXTI flag.
  407. * @retval None.
  408. */
  409. #define __HAL_PWR_PVD_EXTI_CLEAR_FLAG() SET_BIT(EXTI->PR1, PWR_EXTI_LINE_PVD)
  410. #if defined(DUAL_CORE)
  411. /**
  412. * @brief Clear the PVD EXTI D2 flag.
  413. * @retval None.
  414. */
  415. #define __HAL_PWR_PVD_EXTID2_CLEAR_FLAG() SET_BIT(EXTI_D2->PR1, PWR_EXTI_LINE_PVD)
  416. #endif /*DUAL_CORE*/
  417. /**
  418. * @brief Generates a Software interrupt on PVD EXTI line.
  419. * @retval None.
  420. */
  421. #define __HAL_PWR_PVD_EXTI_GENERATE_SWIT() SET_BIT(EXTI->SWIER1, PWR_EXTI_LINE_PVD)
  422. /**
  423. * @}
  424. */
  425. /* Include PWR HAL Extension module */
  426. #include "stm32h7xx_hal_pwr_ex.h"
  427. /* Exported functions --------------------------------------------------------*/
  428. /** @addtogroup PWR_Exported_Functions PWR Exported Functions
  429. * @{
  430. */
  431. /** @addtogroup PWR_Exported_Functions_Group1 Initialization and De-Initialization functions
  432. * @{
  433. */
  434. /* Initialization and de-initialization functions *****************************/
  435. void HAL_PWR_DeInit(void);
  436. void HAL_PWR_EnableBkUpAccess(void);
  437. void HAL_PWR_DisableBkUpAccess(void);
  438. /**
  439. * @}
  440. */
  441. /** @addtogroup PWR_Exported_Functions_Group2 Peripheral Control functions
  442. * @{
  443. */
  444. /* Peripheral Control functions **********************************************/
  445. /* PVD configuration */
  446. void HAL_PWR_ConfigPVD(PWR_PVDTypeDef *sConfigPVD);
  447. void HAL_PWR_EnablePVD(void);
  448. void HAL_PWR_DisablePVD(void);
  449. /* WakeUp pins configuration */
  450. void HAL_PWR_EnableWakeUpPin(uint32_t WakeUpPinPolarity);
  451. void HAL_PWR_DisableWakeUpPin(uint32_t WakeUpPinx);
  452. /* Low Power modes entry */
  453. void HAL_PWR_EnterSTOPMode(uint32_t Regulator, uint8_t STOPEntry);
  454. void HAL_PWR_EnterSLEEPMode(uint32_t Regulator, uint8_t SLEEPEntry);
  455. void HAL_PWR_EnterSTANDBYMode(void);
  456. /* Power PVD IRQ Handler */
  457. void HAL_PWR_PVD_IRQHandler(void);
  458. void HAL_PWR_PVDCallback(void);
  459. /* Cortex System Control functions *******************************************/
  460. void HAL_PWR_EnableSleepOnExit(void);
  461. void HAL_PWR_DisableSleepOnExit(void);
  462. void HAL_PWR_EnableSEVOnPend(void);
  463. void HAL_PWR_DisableSEVOnPend(void);
  464. /**
  465. * @}
  466. */
  467. /**
  468. * @}
  469. */
  470. /* Private types -------------------------------------------------------------*/
  471. /* Private variables ---------------------------------------------------------*/
  472. /* Private constants ---------------------------------------------------------*/
  473. /** @defgroup PWR_Private_Constants PWR Private Constants
  474. * @{
  475. */
  476. /** @defgroup PWR_PVD_EXTI_Line PWR PVD EXTI Line
  477. * @{
  478. */
  479. /*!< External interrupt line 16 Connected to the PVD EXTI Line */
  480. #define PWR_EXTI_LINE_PVD ((uint32_t)EXTI_IMR1_IM16)
  481. /**
  482. * @}
  483. */
  484. /**
  485. * @}
  486. */
  487. /* Private macros ------------------------------------------------------------*/
  488. /** @defgroup PWR_Private_Macros PWR Private Macros
  489. * @{
  490. */
  491. /** @defgroup PWR_IS_PWR_Definitions PWR Private macros to check input parameters
  492. * @{
  493. */
  494. #define IS_PWR_PVD_LEVEL(LEVEL) (((LEVEL) == PWR_PVDLEVEL_0) || ((LEVEL) == PWR_PVDLEVEL_1)|| \
  495. ((LEVEL) == PWR_PVDLEVEL_2) || ((LEVEL) == PWR_PVDLEVEL_3)|| \
  496. ((LEVEL) == PWR_PVDLEVEL_4) || ((LEVEL) == PWR_PVDLEVEL_5)|| \
  497. ((LEVEL) == PWR_PVDLEVEL_6) || ((LEVEL) == PWR_PVDLEVEL_7))
  498. #define IS_PWR_PVD_MODE(MODE) (((MODE) == PWR_PVD_MODE_IT_RISING)|| ((MODE) == PWR_PVD_MODE_IT_FALLING) || \
  499. ((MODE) == PWR_PVD_MODE_IT_RISING_FALLING) || ((MODE) == PWR_PVD_MODE_EVENT_RISING) || \
  500. ((MODE) == PWR_PVD_MODE_EVENT_FALLING) || ((MODE) == PWR_PVD_MODE_EVENT_RISING_FALLING) || \
  501. ((MODE) == PWR_PVD_MODE_NORMAL))
  502. #define IS_PWR_REGULATOR(REGULATOR) (((REGULATOR) == PWR_MAINREGULATOR_ON) || \
  503. ((REGULATOR) == PWR_LOWPOWERREGULATOR_ON))
  504. #define IS_PWR_SLEEP_ENTRY(ENTRY) (((ENTRY) == PWR_SLEEPENTRY_WFI) || ((ENTRY) == PWR_SLEEPENTRY_WFE))
  505. #define IS_PWR_STOP_ENTRY(ENTRY) (((ENTRY) == PWR_STOPENTRY_WFI) || ((ENTRY) == PWR_STOPENTRY_WFE))
  506. #define IS_PWR_REGULATOR_VOLTAGE(VOLTAGE) (((VOLTAGE) == PWR_REGULATOR_VOLTAGE_SCALE1) || \
  507. ((VOLTAGE) == PWR_REGULATOR_VOLTAGE_SCALE2) || \
  508. ((VOLTAGE) == PWR_REGULATOR_VOLTAGE_SCALE3))
  509. /**
  510. * @}
  511. */
  512. /**
  513. * @}
  514. */
  515. /**
  516. * @}
  517. */
  518. /**
  519. * @}
  520. */
  521. #ifdef __cplusplus
  522. }
  523. #endif
  524. #endif /* STM32H7xx_HAL_PWR_H */
  525. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/