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.
 
 
 

744 lines
29 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32h7xx_hal_pwr_ex.h
  4. * @author MCD Application Team
  5. * @brief Header file of PWR HAL Extension 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_EX_H
  21. #define STM32H7xx_HAL_PWR_EX_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif /* __cplusplus */
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "stm32h7xx_hal_def.h"
  27. /** @addtogroup STM32H7xx_HAL_Driver
  28. * @{
  29. */
  30. /** @addtogroup PWREx
  31. * @{
  32. */
  33. /* Exported types ------------------------------------------------------------*/
  34. /** @defgroup PWREx_Exported_Types PWREx Exported Types
  35. * @{
  36. */
  37. /**
  38. * @brief PWREx AVD configuration structure definition
  39. */
  40. typedef struct
  41. {
  42. uint32_t AVDLevel; /*!< AVDLevel : Specifies the AVD detection level. This
  43. parameter can be a value of @ref
  44. PWREx_AVD_detection_level
  45. */
  46. uint32_t Mode; /*!< Mode : Specifies the EXTI operating mode for the AVD
  47. event. This parameter can be a value of @ref
  48. PWREx_AVD_Mode.
  49. */
  50. }PWREx_AVDTypeDef;
  51. /**
  52. * @brief PWREx Wakeup pin configuration structure definition
  53. */
  54. typedef struct
  55. {
  56. uint32_t WakeUpPin; /*!< WakeUpPin: Specifies the Wake-Up pin to be enabled.
  57. This parameter can be a value of @ref
  58. PWREx_WakeUp_Pins
  59. */
  60. uint32_t PinPolarity; /*!< PinPolarity: Specifies the Wake-Up pin polarity.
  61. This parameter can be a value of @ref
  62. PWREx_PIN_Polarity
  63. */
  64. uint32_t PinPull; /*!< PinPull: Specifies the Wake-Up pin pull. This
  65. parameter can be a value of @ref
  66. PWREx_PIN_Pull
  67. */
  68. }PWREx_WakeupPinTypeDef;
  69. #if defined (PWR_CSR1_MMCVDO)
  70. /**
  71. * @brief PWR VDDMMC voltage level enum definition
  72. */
  73. typedef enum
  74. {
  75. PWR_MMC_VOLTAGE_BELOW_1V2, /*!< VDDMMC is below 1V2 */
  76. PWR_MMC_VOLTAGE_EQUAL_ABOVE_1V2 /*!< VDDMMC is above or equal 1V2 */
  77. } PWREx_MMC_VoltageLevel;
  78. #endif /* defined (PWR_CSR1_MMCVDO) */
  79. /**
  80. * @}
  81. */
  82. /* Exported constants --------------------------------------------------------*/
  83. /** @defgroup PWREx_Exported_Constants PWREx Exported Constants
  84. * @{
  85. */
  86. /** @defgroup PWREx_WakeUp_Pins PWREx Wake-Up Pins
  87. * @{
  88. */
  89. /* High level and No pull (default configuration) */
  90. #define PWR_WAKEUP_PIN6 PWR_WKUPEPR_WKUPEN6
  91. #define PWR_WAKEUP_PIN5 PWR_WKUPEPR_WKUPEN5
  92. #define PWR_WAKEUP_PIN4 PWR_WKUPEPR_WKUPEN4
  93. #define PWR_WAKEUP_PIN3 PWR_WKUPEPR_WKUPEN3
  94. #define PWR_WAKEUP_PIN2 PWR_WKUPEPR_WKUPEN2
  95. #define PWR_WAKEUP_PIN1 PWR_WKUPEPR_WKUPEN1
  96. /* High level and No pull */
  97. #define PWR_WAKEUP_PIN6_HIGH PWR_WKUPEPR_WKUPEN6
  98. #define PWR_WAKEUP_PIN5_HIGH PWR_WKUPEPR_WKUPEN5
  99. #define PWR_WAKEUP_PIN4_HIGH PWR_WKUPEPR_WKUPEN4
  100. #define PWR_WAKEUP_PIN3_HIGH PWR_WKUPEPR_WKUPEN3
  101. #define PWR_WAKEUP_PIN2_HIGH PWR_WKUPEPR_WKUPEN2
  102. #define PWR_WAKEUP_PIN1_HIGH PWR_WKUPEPR_WKUPEN1
  103. /* Low level and No pull */
  104. #define PWR_WAKEUP_PIN6_LOW (PWR_WKUPEPR_WKUPP6 | PWR_WKUPEPR_WKUPEN6)
  105. #define PWR_WAKEUP_PIN5_LOW (PWR_WKUPEPR_WKUPP5 | PWR_WKUPEPR_WKUPEN5)
  106. #define PWR_WAKEUP_PIN4_LOW (PWR_WKUPEPR_WKUPP4 | PWR_WKUPEPR_WKUPEN4)
  107. #define PWR_WAKEUP_PIN3_LOW (PWR_WKUPEPR_WKUPP3 | PWR_WKUPEPR_WKUPEN3)
  108. #define PWR_WAKEUP_PIN2_LOW (PWR_WKUPEPR_WKUPP2 | PWR_WKUPEPR_WKUPEN2)
  109. #define PWR_WAKEUP_PIN1_LOW (PWR_WKUPEPR_WKUPP1 | PWR_WKUPEPR_WKUPEN1)
  110. /**
  111. * @}
  112. */
  113. /** @defgroup PWREx_PIN_Polarity PWREx Pin Polarity configuration
  114. * @{
  115. */
  116. #define PWR_PIN_POLARITY_HIGH (0x00000000U)
  117. #define PWR_PIN_POLARITY_LOW (0x00000001U)
  118. /**
  119. * @}
  120. */
  121. /** @defgroup PWREx_PIN_Pull PWREx Pin Pull configuration
  122. * @{
  123. */
  124. #define PWR_PIN_NO_PULL (0x00000000U)
  125. #define PWR_PIN_PULL_UP (0x00000001U)
  126. #define PWR_PIN_PULL_DOWN (0x00000002U)
  127. /**
  128. * @}
  129. */
  130. /** @defgroup PWREx_Wakeup_Pins_Flags PWREx Wakeup Pins Flags.
  131. * @{
  132. */
  133. #define PWR_WAKEUP_FLAG1 PWR_WKUPFR_WKUPF1 /*!< Wakeup flag on PA0 */
  134. #define PWR_WAKEUP_FLAG2 PWR_WKUPFR_WKUPF2 /*!< Wakeup flag on PA2 */
  135. #define PWR_WAKEUP_FLAG3 PWR_WKUPFR_WKUPF3 /*!< Wakeup flag on PI8 */
  136. #define PWR_WAKEUP_FLAG4 PWR_WKUPFR_WKUPF4 /*!< Wakeup flag on PC13 */
  137. #define PWR_WAKEUP_FLAG5 PWR_WKUPFR_WKUPF5 /*!< Wakeup flag on PI11 */
  138. #define PWR_WAKEUP_FLAG6 PWR_WKUPFR_WKUPF6 /*!< Wakeup flag on PC1 */
  139. #define PWR_WAKEUP_FLAG_ALL (PWR_WKUPFR_WKUPF1 | PWR_WKUPFR_WKUPF2 |\
  140. PWR_WKUPFR_WKUPF3 | PWR_WKUPFR_WKUPF4 |\
  141. PWR_WKUPFR_WKUPF5 | PWR_WKUPFR_WKUPF6)
  142. /**
  143. * @}
  144. */
  145. #if defined (DUAL_CORE)
  146. /** @defgroup PWREx_Core_Select PWREx Core definition
  147. * @{
  148. */
  149. #define PWR_CORE_CPU1 (0x00000000U)
  150. #define PWR_CORE_CPU2 (0x00000001U)
  151. /**
  152. * @}
  153. */
  154. #endif /* defined (DUAL_CORE) */
  155. /** @defgroup PWREx_Domains PWREx Domains definition
  156. * @{
  157. */
  158. #define PWR_D1_DOMAIN (0x00000000U)
  159. #if defined (PWR_CPUCR_PDDS_D2)
  160. #define PWR_D2_DOMAIN (0x00000001U)
  161. #endif /* defined (PWR_CPUCR_PDDS_D2) */
  162. #define PWR_D3_DOMAIN (0x00000002U)
  163. /**
  164. * @}
  165. */
  166. /** @defgroup PWREx_Domain_Flags PWREx Domain Flags definition
  167. * @{
  168. */
  169. #if defined (DUAL_CORE)
  170. #define PWR_D1_DOMAIN_FLAGS (0x00000000U)
  171. #define PWR_D2_DOMAIN_FLAGS (0x00000001U)
  172. #define PWR_ALL_DOMAIN_FLAGS (0x00000002U)
  173. #else
  174. #define PWR_CPU_FLAGS (0x00000000U)
  175. #endif /* defined (DUAL_CORE) */
  176. /**
  177. * @}
  178. */
  179. /** @defgroup PWREx_D3_State PWREx D3 Domain State
  180. * @{
  181. */
  182. #define PWR_D3_DOMAIN_STOP (0x00000000U)
  183. #define PWR_D3_DOMAIN_RUN (0x00000800U)
  184. /**
  185. * @}
  186. */
  187. /** @defgroup PWREx_Supply_configuration PWREx Supply configuration
  188. * @{
  189. */
  190. #define PWR_LDO_SUPPLY PWR_CR3_LDOEN /*!< Core domains are suppplied from the LDO */
  191. #if defined (SMPS)
  192. #define PWR_DIRECT_SMPS_SUPPLY PWR_CR3_SMPSEN /*!< Core domains are suppplied from the SMPS only */
  193. #define PWR_SMPS_1V8_SUPPLIES_LDO (PWR_CR3_SMPSLEVEL_0 | PWR_CR3_SMPSEN | PWR_CR3_LDOEN) /*!< The SMPS 1.8V output supplies the LDO which supplies the Core domains */
  194. #define PWR_SMPS_2V5_SUPPLIES_LDO (PWR_CR3_SMPSLEVEL_1 | PWR_CR3_SMPSEN | PWR_CR3_LDOEN) /*!< The SMPS 2.5V output supplies the LDO which supplies the Core domains */
  195. #define PWR_SMPS_1V8_SUPPLIES_EXT_AND_LDO (PWR_CR3_SMPSLEVEL_0 | PWR_CR3_SMPSEXTHP | PWR_CR3_SMPSEN | PWR_CR3_LDOEN) /*!< The SMPS 1.8V output supplies an external circuits and the LDO. The Core domains are suppplied from the LDO */
  196. #define PWR_SMPS_2V5_SUPPLIES_EXT_AND_LDO (PWR_CR3_SMPSLEVEL_1 | PWR_CR3_SMPSEXTHP | PWR_CR3_SMPSEN | PWR_CR3_LDOEN) /*!< The SMPS 2.5V output supplies an external circuits and the LDO. The Core domains are suppplied from the LDO */
  197. #define PWR_SMPS_1V8_SUPPLIES_EXT (PWR_CR3_SMPSLEVEL_0 | PWR_CR3_SMPSEXTHP | PWR_CR3_SMPSEN | PWR_CR3_BYPASS) /*!< The SMPS 1.8V output supplies an external source which supplies the Core domains */
  198. #define PWR_SMPS_2V5_SUPPLIES_EXT (PWR_CR3_SMPSLEVEL_1 | PWR_CR3_SMPSEXTHP | PWR_CR3_SMPSEN | PWR_CR3_BYPASS) /*!< The SMPS 2.5V output supplies an external source which supplies the Core domains */
  199. #endif /* defined (SMPS) */
  200. #define PWR_EXTERNAL_SOURCE_SUPPLY PWR_CR3_BYPASS /*!< The SMPS disabled and the LDO Bypass. The Core domains are supplied from an external source */
  201. #if defined (SMPS)
  202. #define PWR_SUPPLY_CONFIG_MASK (PWR_CR3_SMPSLEVEL | PWR_CR3_SMPSEXTHP | \
  203. PWR_CR3_SMPSEN | PWR_CR3_LDOEN | PWR_CR3_BYPASS)
  204. #else
  205. #define PWR_SUPPLY_CONFIG_MASK (PWR_CR3_SCUEN | PWR_CR3_LDOEN | PWR_CR3_BYPASS)
  206. #endif /* defined (SMPS) */
  207. /**
  208. * @}
  209. */
  210. /** @defgroup PWREx_AVD_detection_level PWREx AVD detection level
  211. * @{
  212. */
  213. #define PWR_AVDLEVEL_0 PWR_CR1_ALS_LEV0 /*!< Analog voltage detector level 0
  214. selection : 1V7 */
  215. #define PWR_AVDLEVEL_1 PWR_CR1_ALS_LEV1 /*!< Analog voltage detector level 1
  216. selection : 2V1 */
  217. #define PWR_AVDLEVEL_2 PWR_CR1_ALS_LEV2 /*!< Analog voltage detector level 2
  218. selection : 2V5 */
  219. #define PWR_AVDLEVEL_3 PWR_CR1_ALS_LEV3 /*!< Analog voltage detector level 3
  220. selection : 2V8 */
  221. /**
  222. * @}
  223. */
  224. /** @defgroup PWREx_AVD_Mode PWREx AVD Mode
  225. * @{
  226. */
  227. #define PWR_AVD_MODE_NORMAL (0x00000000U) /*!< Basic mode is used */
  228. #define PWR_AVD_MODE_IT_RISING (0x00010001U) /*!< External Interrupt Mode with Rising edge trigger detection */
  229. #define PWR_AVD_MODE_IT_FALLING (0x00010002U) /*!< External Interrupt Mode with Falling edge trigger detection */
  230. #define PWR_AVD_MODE_IT_RISING_FALLING (0x00010003U) /*!< External Interrupt Mode with Rising/Falling edge trigger detection */
  231. #define PWR_AVD_MODE_EVENT_RISING (0x00020001U) /*!< Event Mode with Rising edge trigger detection */
  232. #define PWR_AVD_MODE_EVENT_FALLING (0x00020002U) /*!< Event Mode with Falling edge trigger detection */
  233. #define PWR_AVD_MODE_EVENT_RISING_FALLING (0x00020003U) /*!< Event Mode with Rising/Falling edge trigger detection */
  234. /**
  235. * @}
  236. */
  237. /** @defgroup PWREx_Regulator_Voltage_Scale PWREx Regulator Voltage Scale
  238. * @{
  239. */
  240. #define PWR_REGULATOR_SVOS_SCALE5 (PWR_CR1_SVOS_0)
  241. #define PWR_REGULATOR_SVOS_SCALE4 (PWR_CR1_SVOS_1)
  242. #define PWR_REGULATOR_SVOS_SCALE3 (PWR_CR1_SVOS_0 | PWR_CR1_SVOS_1)
  243. /**
  244. * @}
  245. */
  246. /** @defgroup PWREx_VBAT_Battery_Charging_Resistor PWR battery charging resistor selection
  247. * @{
  248. */
  249. #define PWR_BATTERY_CHARGING_RESISTOR_5 (0x00000000U) /*!< VBAT charging through a 5 kOhms resistor */
  250. #define PWR_BATTERY_CHARGING_RESISTOR_1_5 PWR_CR3_VBRS /*!< VBAT charging through a 1.5 kOhms resistor */
  251. /**
  252. * @}
  253. */
  254. /** @defgroup PWREx_VBAT_Thresholds PWREx VBAT Thresholds
  255. * @{
  256. */
  257. #define PWR_VBAT_BETWEEN_HIGH_LOW_THRESHOLD (0x00000000U)
  258. #define PWR_VBAT_BELOW_LOW_THRESHOLD PWR_CR2_VBATL
  259. #define PWR_VBAT_ABOVE_HIGH_THRESHOLD PWR_CR2_VBATH
  260. /**
  261. * @}
  262. */
  263. /** @defgroup PWREx_TEMP_Thresholds PWREx Temperature Thresholds
  264. * @{
  265. */
  266. #define PWR_TEMP_BETWEEN_HIGH_LOW_THRESHOLD (0x00000000U)
  267. #define PWR_TEMP_BELOW_LOW_THRESHOLD PWR_CR2_TEMPL
  268. #define PWR_TEMP_ABOVE_HIGH_THRESHOLD PWR_CR2_TEMPH
  269. /**
  270. * @}
  271. */
  272. /** @defgroup PWREx_AVD_EXTI_Line PWREx AVD EXTI Line 16
  273. * @{
  274. */
  275. #define PWR_EXTI_LINE_AVD EXTI_IMR1_IM16 /*!< External interrupt line 16
  276. Connected to the AVD EXTI Line */
  277. /**
  278. * @}
  279. */
  280. #if defined (PWR_CR1_SRDRAMSO)
  281. /** @defgroup PWREx_Memory_Shut_Off Memory shut-off block selection
  282. * @{
  283. */
  284. #define PWR_SRD_AHB_MEMORY_BLOCK PWR_CR1_SRDRAMSO /*!< SmartRun domain AHB memory shut-off in DStop/DStop2 low-power mode */
  285. #define PWR_USB_FDCAN_MEMORY_BLOCK PWR_CR1_HSITFSO /*!< High-speed interfaces USB and FDCAN memories shut-off in DStop/DStop2 mode */
  286. #define PWR_GFXMMU_JPEG_MEMORY_BLOCK PWR_CR1_GFXSO /*!< GFXMMU and JPEG memories shut-off in DStop/DStop2 mode */
  287. #define PWR_TCM_ECM_MEMORY_BLOCK PWR_CR1_ITCMSO /*!< Instruction TCM and ETM memories shut-off in DStop/DStop2 mode */
  288. #define PWR_RAM1_AHB_MEMORY_BLOCK PWR_CR1_AHBRAM1SO /*!< AHB RAM1 shut-off in DStop/DStop2 mode */
  289. #define PWR_RAM2_AHB_MEMORY_BLOCK PWR_CR1_AHBRAM2SO /*!< AHB RAM2 shut-off in DStop/DStop2 mode */
  290. #define PWR_RAM1_AXI_MEMORY_BLOCK PWR_CR1_AXIRAM1SO /*!< AXI RAM1 shut-off in DStop/DStop2 mode */
  291. #define PWR_RAM2_AXI_MEMORY_BLOCK PWR_CR1_AXIRAM2SO /*!< AXI RAM2 shut-off in DStop/DStop2 mode */
  292. #define PWR_RAM3_AXI_MEMORY_BLOCK PWR_CR1_AXIRAM3SO /*!< AXI RAM3 shut-off in DStop/DStop2 mode */
  293. #define PWR_MEMORY_BLOCK_KEEP_ON 0U /*!< Memory content is kept in DStop or DStop2 mode */
  294. #define PWR_MEMORY_BLOCK_SHUT_OFF 1U /*!< Memory content is lost in DStop or DStop2 mode */
  295. /**
  296. * @}
  297. */
  298. #endif /* defined (PWR_CR1_SRDRAMSO) */
  299. /**
  300. * @}
  301. */
  302. /* Exported macro ------------------------------------------------------------*/
  303. /** @defgroup PWREx_Exported_Macro PWREx Exported Macro
  304. * @{
  305. */
  306. /**
  307. * @brief Enable the AVD EXTI Line 16.
  308. * @retval None.
  309. */
  310. #define __HAL_PWR_AVD_EXTI_ENABLE_IT() SET_BIT(EXTI->IMR1, PWR_EXTI_LINE_AVD)
  311. #if defined (DUAL_CORE)
  312. /**
  313. * @brief Enable the AVD EXTI D2 Line 16.
  314. * @retval None.
  315. */
  316. #define __HAL_PWR_AVD_EXTID2_ENABLE_IT() SET_BIT(EXTI_D2->IMR1, PWR_EXTI_LINE_AVD)
  317. #endif /* defined (DUAL_CORE) */
  318. /**
  319. * @brief Disable the AVD EXTI Line 16
  320. * @retval None.
  321. */
  322. #define __HAL_PWR_AVD_EXTI_DISABLE_IT() CLEAR_BIT(EXTI->IMR1, PWR_EXTI_LINE_AVD)
  323. #if defined (DUAL_CORE)
  324. /**
  325. * @brief Disable the AVD EXTI D2 Line 16.
  326. * @retval None.
  327. */
  328. #define __HAL_PWR_AVD_EXTID2_DISABLE_IT() CLEAR_BIT(EXTI_D2->IMR1, PWR_EXTI_LINE_AVD)
  329. #endif /* defined (DUAL_CORE) */
  330. /**
  331. * @brief Enable event on AVD EXTI Line 16.
  332. * @retval None.
  333. */
  334. #define __HAL_PWR_AVD_EXTI_ENABLE_EVENT() SET_BIT(EXTI->EMR1, PWR_EXTI_LINE_AVD)
  335. #if defined (DUAL_CORE)
  336. /**
  337. * @brief Enable event on AVD EXTI D2 Line 16.
  338. * @retval None.
  339. */
  340. #define __HAL_PWR_AVD_EXTID2_ENABLE_EVENT() SET_BIT(EXTI_D2->EMR1, PWR_EXTI_LINE_AVD)
  341. #endif /* defined (DUAL_CORE) */
  342. /**
  343. * @brief Disable event on AVD EXTI Line 16.
  344. * @retval None.
  345. */
  346. #define __HAL_PWR_AVD_EXTI_DISABLE_EVENT() CLEAR_BIT(EXTI->EMR1, PWR_EXTI_LINE_AVD)
  347. #if defined (DUAL_CORE)
  348. /**
  349. * @brief Disable event on AVD EXTI D2 Line 16.
  350. * @retval None.
  351. */
  352. #define __HAL_PWR_AVD_EXTID2_DISABLE_EVENT() CLEAR_BIT(EXTI_D2->EMR1, PWR_EXTI_LINE_AVD)
  353. #endif /* defined (DUAL_CORE) */
  354. /**
  355. * @brief Enable the AVD Extended Interrupt Rising Trigger.
  356. * @retval None.
  357. */
  358. #define __HAL_PWR_AVD_EXTI_ENABLE_RISING_EDGE() SET_BIT(EXTI->RTSR1, PWR_EXTI_LINE_AVD)
  359. /**
  360. * @brief Disable the AVD Extended Interrupt Rising Trigger.
  361. * @retval None.
  362. */
  363. #define __HAL_PWR_AVD_EXTI_DISABLE_RISING_EDGE() CLEAR_BIT(EXTI->RTSR1, PWR_EXTI_LINE_AVD)
  364. /**
  365. * @brief Enable the AVD Extended Interrupt Falling Trigger.
  366. * @retval None.
  367. */
  368. #define __HAL_PWR_AVD_EXTI_ENABLE_FALLING_EDGE() SET_BIT(EXTI->FTSR1, PWR_EXTI_LINE_AVD)
  369. /**
  370. * @brief Disable the AVD Extended Interrupt Falling Trigger.
  371. * @retval None.
  372. */
  373. #define __HAL_PWR_AVD_EXTI_DISABLE_FALLING_EDGE() CLEAR_BIT(EXTI->FTSR1, PWR_EXTI_LINE_AVD)
  374. /**
  375. * @brief Enable the AVD Extended Interrupt Rising and Falling Trigger.
  376. * @retval None.
  377. */
  378. #define __HAL_PWR_AVD_EXTI_ENABLE_RISING_FALLING_EDGE() \
  379. do { \
  380. __HAL_PWR_AVD_EXTI_ENABLE_RISING_EDGE(); \
  381. __HAL_PWR_AVD_EXTI_ENABLE_FALLING_EDGE(); \
  382. } while(0);
  383. /**
  384. * @brief Disable the AVD Extended Interrupt Rising & Falling Trigger.
  385. * @retval None.
  386. */
  387. #define __HAL_PWR_AVD_EXTI_DISABLE_RISING_FALLING_EDGE() \
  388. do { \
  389. __HAL_PWR_AVD_EXTI_DISABLE_RISING_EDGE(); \
  390. __HAL_PWR_AVD_EXTI_DISABLE_FALLING_EDGE(); \
  391. } while(0);
  392. /**
  393. * @brief Check whether the specified AVD EXTI interrupt flag is set or not.
  394. * @retval EXTI AVD Line Status.
  395. */
  396. #define __HAL_PWR_AVD_EXTI_GET_FLAG() ((READ_BIT(EXTI->PR1, PWR_EXTI_LINE_AVD) == PWR_EXTI_LINE_AVD) ? 1UL : 0UL)
  397. #if defined (DUAL_CORE)
  398. /**
  399. * @brief Check whether the specified AVD EXTI D2 interrupt flag is set or not.
  400. * @retval EXTI D2 AVD Line Status.
  401. */
  402. #define __HAL_PWR_AVD_EXTID2_GET_FLAG() ((READ_BIT(EXTI_D2->PR1, PWR_EXTI_LINE_AVD) == PWR_EXTI_LINE_AVD) ? 1UL : 0UL)
  403. #endif /* defined (DUAL_CORE) */
  404. /**
  405. * @brief Clear the AVD EXTI flag.
  406. * @retval None.
  407. */
  408. #define __HAL_PWR_AVD_EXTI_CLEAR_FLAG() SET_BIT(EXTI->PR1, PWR_EXTI_LINE_AVD)
  409. #if defined (DUAL_CORE)
  410. /**
  411. * @brief Clear the AVD EXTI D2 flag.
  412. * @retval None.
  413. */
  414. #define __HAL_PWR_AVD_EXTID2_CLEAR_FLAG() SET_BIT(EXTI_D2->PR1, PWR_EXTI_LINE_AVD)
  415. #endif /* defined (DUAL_CORE) */
  416. /**
  417. * @brief Generates a Software interrupt on AVD EXTI line.
  418. * @retval None.
  419. */
  420. #define __HAL_PWR_AVD_EXTI_GENERATE_SWIT() SET_BIT(EXTI->SWIER1, PWR_EXTI_LINE_AVD)
  421. /**
  422. * @}
  423. */
  424. /* Exported functions --------------------------------------------------------*/
  425. /** @addtogroup PWREx_Exported_Functions PWREx Exported Functions
  426. * @{
  427. */
  428. /** @addtogroup PWREx_Exported_Functions_Group1 Power Supply Control Functions
  429. * @{
  430. */
  431. HAL_StatusTypeDef HAL_PWREx_ConfigSupply(uint32_t SupplySource);
  432. uint32_t HAL_PWREx_GetSupplyConfig(void);
  433. HAL_StatusTypeDef HAL_PWREx_ControlVoltageScaling(uint32_t VoltageScaling);
  434. uint32_t HAL_PWREx_GetVoltageRange(void);
  435. HAL_StatusTypeDef HAL_PWREx_ControlStopModeVoltageScaling(uint32_t VoltageScaling);
  436. uint32_t HAL_PWREx_GetStopModeVoltageRange(void);
  437. /**
  438. * @}
  439. */
  440. /** @addtogroup PWREx_Exported_Functions_Group2 Low Power Control Functions
  441. * @{
  442. */
  443. /* System low power control functions */
  444. #if defined (PWR_CPUCR_RETDS_CD)
  445. void HAL_PWREx_EnterSTOP2Mode(uint32_t Regulator, uint8_t STOPEntry);
  446. #endif /* defined (PWR_CPUCR_RETDS_CD) */
  447. void HAL_PWREx_EnterSTOPMode(uint32_t Regulator, uint8_t STOPEntry, uint32_t Domain);
  448. void HAL_PWREx_EnterSTANDBYMode(uint32_t Domain);
  449. void HAL_PWREx_ConfigD3Domain(uint32_t D3State);
  450. /* Clear Cortex-Mx pending flag */
  451. void HAL_PWREx_ClearPendingEvent(void);
  452. #if defined (DUAL_CORE)
  453. /* Clear domain flags */
  454. void HAL_PWREx_ClearDomainFlags(uint32_t DomainFlags);
  455. /* Core Hold/Release functions */
  456. HAL_StatusTypeDef HAL_PWREx_HoldCore(uint32_t CPU);
  457. void HAL_PWREx_ReleaseCore(uint32_t CPU);
  458. #endif /* defined (DUAL_CORE) */
  459. /* Flash low power control functions */
  460. void HAL_PWREx_EnableFlashPowerDown(void);
  461. void HAL_PWREx_DisableFlashPowerDown(void);
  462. #if defined (PWR_CR1_SRDRAMSO)
  463. /* Memory shut-off functions */
  464. void HAL_PWREx_EnableMemoryShutOff(uint32_t MemoryBlock);
  465. void HAL_PWREx_DisableMemoryShutOff(uint32_t MemoryBlock);
  466. #endif /* defined(PWR_CR1_SRDRAMSO) */
  467. /* Wakeup Pins control functions */
  468. void HAL_PWREx_EnableWakeUpPin(PWREx_WakeupPinTypeDef *sPinParams);
  469. void HAL_PWREx_DisableWakeUpPin(uint32_t WakeUpPin);
  470. uint32_t HAL_PWREx_GetWakeupFlag(uint32_t WakeUpFlag);
  471. HAL_StatusTypeDef HAL_PWREx_ClearWakeupFlag(uint32_t WakeUpFlag);
  472. /* Power Wakeup PIN IRQ Handler */
  473. void HAL_PWREx_WAKEUP_PIN_IRQHandler(void);
  474. void HAL_PWREx_WKUP1_Callback(void);
  475. void HAL_PWREx_WKUP2_Callback(void);
  476. void HAL_PWREx_WKUP3_Callback(void);
  477. void HAL_PWREx_WKUP4_Callback(void);
  478. void HAL_PWREx_WKUP5_Callback(void);
  479. void HAL_PWREx_WKUP6_Callback(void);
  480. /**
  481. * @}
  482. */
  483. /** @addtogroup PWREx_Exported_Functions_Group3 Peripherals Control Functions
  484. * @{
  485. */
  486. /* Backup regulator control functions */
  487. HAL_StatusTypeDef HAL_PWREx_EnableBkUpReg(void);
  488. HAL_StatusTypeDef HAL_PWREx_DisableBkUpReg(void);
  489. /* USB regulator control functions */
  490. HAL_StatusTypeDef HAL_PWREx_EnableUSBReg(void);
  491. HAL_StatusTypeDef HAL_PWREx_DisableUSBReg(void);
  492. void HAL_PWREx_EnableUSBVoltageDetector(void);
  493. void HAL_PWREx_DisableUSBVoltageDetector(void);
  494. /* Battery control functions */
  495. void HAL_PWREx_EnableBatteryCharging(uint32_t ResistorValue);
  496. void HAL_PWREx_DisableBatteryCharging(void);
  497. #if defined(PWR_CR1_BOOSTE)
  498. /* Analog Booster functions */
  499. void HAL_PWREx_EnableAnalogBooster(void);
  500. void HAL_PWREx_DisableAnalogBooster(void);
  501. #endif /* PWR_CR1_BOOSTE */
  502. /**
  503. * @}
  504. */
  505. /** @addtogroup PWREx_Exported_Functions_Group4 Power Monitoring functions
  506. * @{
  507. */
  508. /* Power VBAT/Temperature monitoring functions */
  509. void HAL_PWREx_EnableMonitoring(void);
  510. void HAL_PWREx_DisableMonitoring(void);
  511. uint32_t HAL_PWREx_GetTemperatureLevel(void);
  512. uint32_t HAL_PWREx_GetVBATLevel(void);
  513. #if defined(PWR_CSR1_MMCVDO)
  514. PWREx_MMC_VoltageLevel HAL_PWREx_GetMMCVoltage(void);
  515. #endif /* PWR_CSR1_MMCVDO */
  516. /* Power AVD configuration functions */
  517. void HAL_PWREx_ConfigAVD(PWREx_AVDTypeDef *sConfigAVD);
  518. void HAL_PWREx_EnableAVD(void);
  519. void HAL_PWREx_DisableAVD(void);
  520. /* Power PVD/AVD IRQ Handler */
  521. void HAL_PWREx_PVD_AVD_IRQHandler(void);
  522. void HAL_PWREx_AVDCallback(void);
  523. /**
  524. * @}
  525. */
  526. /**
  527. * @}
  528. */
  529. /* Private types -------------------------------------------------------------*/
  530. /* Private variables ---------------------------------------------------------*/
  531. /* Private constants ---------------------------------------------------------*/
  532. /* Private macros ------------------------------------------------------------*/
  533. /** @defgroup PWREx_Private_Macros PWREx Private Macros
  534. * @{
  535. */
  536. /** @defgroup PWREx_IS_PWR_Definitions PWREx Private macros to check input parameters
  537. * @{
  538. */
  539. /* Check PWR regulator configuration parameter */
  540. #if defined (SMPS)
  541. #define IS_PWR_SUPPLY(PWR_SOURCE) (((PWR_SOURCE) == PWR_LDO_SUPPLY) ||\
  542. ((PWR_SOURCE) == PWR_DIRECT_SMPS_SUPPLY) ||\
  543. ((PWR_SOURCE) == PWR_SMPS_1V8_SUPPLIES_LDO) ||\
  544. ((PWR_SOURCE) == PWR_SMPS_2V5_SUPPLIES_LDO) ||\
  545. ((PWR_SOURCE) == PWR_SMPS_1V8_SUPPLIES_EXT_AND_LDO) ||\
  546. ((PWR_SOURCE) == PWR_SMPS_2V5_SUPPLIES_EXT_AND_LDO) ||\
  547. ((PWR_SOURCE) == PWR_SMPS_1V8_SUPPLIES_EXT) ||\
  548. ((PWR_SOURCE) == PWR_SMPS_2V5_SUPPLIES_EXT) ||\
  549. ((PWR_SOURCE) == PWR_EXTERNAL_SOURCE_SUPPLY))
  550. #else
  551. #define IS_PWR_SUPPLY(PWR_SOURCE) (((PWR_SOURCE) == PWR_LDO_SUPPLY) ||\
  552. ((PWR_SOURCE) == PWR_EXTERNAL_SOURCE_SUPPLY))
  553. #endif /* defined (SMPS) */
  554. /* Check PWR regulator configuration in STOP mode parameter */
  555. #define IS_PWR_STOP_MODE_REGULATOR_VOLTAGE(VOLTAGE) (((VOLTAGE) == PWR_REGULATOR_SVOS_SCALE3) ||\
  556. ((VOLTAGE) == PWR_REGULATOR_SVOS_SCALE4) ||\
  557. ((VOLTAGE) == PWR_REGULATOR_SVOS_SCALE5))
  558. /* Check PWR domain parameter */
  559. #if defined (PWR_CPUCR_PDDS_D2)
  560. #define IS_PWR_DOMAIN(DOMAIN) (((DOMAIN) == PWR_D1_DOMAIN) ||\
  561. ((DOMAIN) == PWR_D2_DOMAIN) ||\
  562. ((DOMAIN) == PWR_D3_DOMAIN))
  563. #else
  564. #define IS_PWR_DOMAIN(DOMAIN) (((DOMAIN) == PWR_D1_DOMAIN) ||\
  565. ((DOMAIN) == PWR_D3_DOMAIN))
  566. #endif /* defined (PWR_CPUCR_PDDS_D2) */
  567. /* Check D3/SRD domain state parameter */
  568. #define IS_D3_STATE(STATE) (((STATE) == PWR_D3_DOMAIN_STOP) ||\
  569. ((STATE) == PWR_D3_DOMAIN_RUN))
  570. /* Check wake up pin parameter */
  571. #define IS_PWR_WAKEUP_PIN(PIN) (((PIN) == PWR_WAKEUP_PIN1) ||\
  572. ((PIN) == PWR_WAKEUP_PIN2) ||\
  573. ((PIN) == PWR_WAKEUP_PIN3) ||\
  574. ((PIN) == PWR_WAKEUP_PIN4) ||\
  575. ((PIN) == PWR_WAKEUP_PIN5) ||\
  576. ((PIN) == PWR_WAKEUP_PIN6) ||\
  577. ((PIN) == PWR_WAKEUP_PIN1_HIGH) ||\
  578. ((PIN) == PWR_WAKEUP_PIN2_HIGH) ||\
  579. ((PIN) == PWR_WAKEUP_PIN3_HIGH) ||\
  580. ((PIN) == PWR_WAKEUP_PIN4_HIGH) ||\
  581. ((PIN) == PWR_WAKEUP_PIN5_HIGH) ||\
  582. ((PIN) == PWR_WAKEUP_PIN6_HIGH) ||\
  583. ((PIN) == PWR_WAKEUP_PIN1_LOW) ||\
  584. ((PIN) == PWR_WAKEUP_PIN2_LOW) ||\
  585. ((PIN) == PWR_WAKEUP_PIN3_LOW) ||\
  586. ((PIN) == PWR_WAKEUP_PIN4_LOW) ||\
  587. ((PIN) == PWR_WAKEUP_PIN5_LOW) ||\
  588. ((PIN) == PWR_WAKEUP_PIN6_LOW))
  589. /* Check wake up pin polarity parameter */
  590. #define IS_PWR_WAKEUP_PIN_POLARITY(POLARITY) (((POLARITY) == PWR_PIN_POLARITY_HIGH) ||\
  591. ((POLARITY) == PWR_PIN_POLARITY_LOW))
  592. /* Check wake up pin pull configuration parameter */
  593. #define IS_PWR_WAKEUP_PIN_PULL(PULL) (((PULL) == PWR_PIN_NO_PULL) ||\
  594. ((PULL) == PWR_PIN_PULL_UP) ||\
  595. ((PULL) == PWR_PIN_PULL_DOWN))
  596. /* Check wake up flag parameter */
  597. #define IS_PWR_WAKEUP_FLAG(FLAG) (((FLAG) == PWR_WAKEUP_FLAG1) ||\
  598. ((FLAG) == PWR_WAKEUP_FLAG2) ||\
  599. ((FLAG) == PWR_WAKEUP_FLAG3) ||\
  600. ((FLAG) == PWR_WAKEUP_FLAG4) ||\
  601. ((FLAG) == PWR_WAKEUP_FLAG5) ||\
  602. ((FLAG) == PWR_WAKEUP_FLAG6) ||\
  603. ((FLAG) == PWR_WAKEUP_FLAG_ALL))
  604. /* Check wake up flag parameter */
  605. #define IS_PWR_AVD_LEVEL(LEVEL) (((LEVEL) == PWR_AVDLEVEL_0) ||\
  606. ((LEVEL) == PWR_AVDLEVEL_1) ||\
  607. ((LEVEL) == PWR_AVDLEVEL_2) ||\
  608. ((LEVEL) == PWR_AVDLEVEL_3))
  609. /* Check AVD mode parameter */
  610. #define IS_PWR_AVD_MODE(MODE) (((MODE) == PWR_AVD_MODE_IT_RISING) ||\
  611. ((MODE) == PWR_AVD_MODE_IT_FALLING) ||\
  612. ((MODE) == PWR_AVD_MODE_IT_RISING_FALLING) ||\
  613. ((MODE) == PWR_AVD_MODE_EVENT_RISING) ||\
  614. ((MODE) == PWR_AVD_MODE_EVENT_FALLING) ||\
  615. ((MODE) == PWR_AVD_MODE_NORMAL) ||\
  616. ((MODE) == PWR_AVD_MODE_EVENT_RISING_FALLING))
  617. /* Check resistor battery parameter */
  618. #define IS_PWR_BATTERY_RESISTOR_SELECT(RESISTOR) (((RESISTOR) == PWR_BATTERY_CHARGING_RESISTOR_5) ||\
  619. ((RESISTOR) == PWR_BATTERY_CHARGING_RESISTOR_1_5))
  620. /* Check D1/CD CPU ID parameter */
  621. #define IS_PWR_D1_CPU(CPU) ((CPU) == CM7_CPUID)
  622. #if defined (DUAL_CORE)
  623. /* Check CPU parameter */
  624. #define IS_PWR_CORE(CPU) (((CPU) == PWR_CORE_CPU1) || ((CPU) == PWR_CORE_CPU2))
  625. /* Check D2 CPU ID parameter */
  626. #define IS_PWR_D2_CPU(CPU) ((CPU) == CM4_CPUID)
  627. /* Check PWR domain flag parameter */
  628. #define IS_PWR_DOMAIN_FLAG(FLAG) (((FLAG) == PWR_D1_DOMAIN_FLAGS) || \
  629. ((FLAG) == PWR_D2_DOMAIN_FLAGS) || \
  630. ((FLAG) == PWR_ALL_DOMAIN_FLAGS))
  631. #endif /* defined (DUAL_CORE) */
  632. #if defined (PWR_CR1_SRDRAMSO)
  633. /* Check memory block parameter */
  634. #define IS_PWR_MEMORY_BLOCK(BLOCK) (((BLOCK) == PWR_SRD_AHB_MEMORY_BLOCK) || \
  635. ((BLOCK) == PWR_USB_FDCAN_MEMORY_BLOCK) || \
  636. ((BLOCK) == PWR_GFXMMU_JPEG_MEMORY_BLOCK) || \
  637. ((BLOCK) == PWR_TCM_ECM_MEMORY_BLOCK) || \
  638. ((BLOCK) == PWR_RAM1_AHB_MEMORY_BLOCK) || \
  639. ((BLOCK) == PWR_RAM2_AHB_MEMORY_BLOCK) || \
  640. ((BLOCK) == PWR_RAM1_AXI_MEMORY_BLOCK) || \
  641. ((BLOCK) == PWR_RAM2_AXI_MEMORY_BLOCK) || \
  642. ((BLOCK) == PWR_RAM3_AXI_MEMORY_BLOCK))
  643. #endif /* defined (PWR_CR1_SRDRAMSO) */
  644. /**
  645. * @}
  646. */
  647. /**
  648. * @}
  649. */
  650. /**
  651. * @}
  652. */
  653. /**
  654. * @}
  655. */
  656. #ifdef __cplusplus
  657. }
  658. #endif /* __cplusplus */
  659. #endif /* STM32H7xx_HAL_PWR_EX_H */
  660. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/