stm32h7xx_hal_pwr_ex.h 32 KB

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