stm32h5xx_ll_pwr.h 70 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077
  1. /**
  2. ******************************************************************************
  3. * @file stm32h5xx_ll_pwr.h
  4. * @author MCD Application Team
  5. * @brief Header file of PWR LL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2023 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 STM32H5xx_LL_PWR_H
  20. #define STM32H5xx_LL_PWR_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif /* __cplusplus */
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32h5xx.h"
  26. /** @addtogroup STM32H5xx_LL_Driver
  27. * @{
  28. */
  29. #if defined (PWR)
  30. /** @defgroup PWR_LL PWR
  31. * @{
  32. */
  33. /* Private types -------------------------------------------------------------*/
  34. /* Private variables ---------------------------------------------------------*/
  35. /* Private constants ---------------------------------------------------------*/
  36. /** @defgroup PWR_LL_Private_Constants PWR Private Constants
  37. * @{
  38. */
  39. /** @defgroup PWR_LL_WAKEUP_PIN_OFFSET Wake-Up Pins register offsets Defines
  40. * @brief Flags defines which can be used with LL_PWR_WriteReg function
  41. * @{
  42. */
  43. /* Wake-Up Pins PWR register offsets */
  44. #define LL_PWR_WAKEUP_PINS_PULL_SHIFT_OFFSET 2UL
  45. #define LL_PWR_WAKEUP_PINS_MAX_SHIFT_MASK 0x7FU
  46. /**
  47. * @}
  48. */
  49. /**
  50. * @}
  51. */
  52. /* Private macros ------------------------------------------------------------*/
  53. /* Exported types ------------------------------------------------------------*/
  54. /* Exported constants --------------------------------------------------------*/
  55. /** @defgroup PWR_LL_Exported_Constants PWR Exported Constants
  56. * @{
  57. */
  58. /** @defgroup PWR_LL_EC_CLEAR_FLAG Clear Flags Defines
  59. * @brief Flags defines which can be used with LL_PWR_WriteReg function
  60. * @{
  61. */
  62. #define LL_PWR_PMCR_CSSF PWR_PMCR_CSSF /*!< Clear STOP and STANDBY flags */
  63. #define LL_PWR_WUSCR_CWUF1 PWR_WUSCR_CWUF1 /*!< Clear Wakeup flag 1 */
  64. #define LL_PWR_WUSCR_CWUF2 PWR_WUSCR_CWUF2 /*!< Clear Wakeup flag 2 */
  65. #define LL_PWR_WUSCR_CWUF3 PWR_WUSCR_CWUF3 /*!< Clear Wakeup flag 3 */
  66. #define LL_PWR_WUSCR_CWUF4 PWR_WUSCR_CWUF4 /*!< Clear Wakeup flag 4 */
  67. #define LL_PWR_WUSCR_CWUF5 PWR_WUSCR_CWUF5 /*!< Clear Wakeup flag 5 */
  68. #define LL_PWR_WUSCR_CWUF6 PWR_WUSCR_CWUF6 /*!< Clear Wakeup flag 6 */
  69. #define LL_PWR_WUSCR_CWUF7 PWR_WUSCR_CWUF7 /*!< Clear Wakeup flag 7 */
  70. #define LL_PWR_WUSCR_CWUF8 PWR_WUSCR_CWUF8 /*!< Clear Wakeup flag 8 */
  71. #define LL_PWR_WUSCR_CWUF_ALL PWR_WUSCR_CWUF /*!< Clear all Wakeup flags */
  72. /**
  73. * @}
  74. */
  75. /** @defgroup PWR_LL_EC_GET_FLAG Get Flags Defines
  76. * @brief Flags defines which can be used with LL_PWR_ReadReg function
  77. * @{
  78. */
  79. #define LL_PWR_FLAG_VOSRDY PWR_VOSR_VOSRDY /*!< Voltage scaling ready flag */
  80. #define LL_PWR_FLAG_ACTVOSRDY PWR_VOSR_ACTOVSRDY /*!< Currently applied VOS ready flag */
  81. #define LL_PWR_FLAG_STOPF PWR_PMSR_STOPF /*!< STOP flag */
  82. #define LL_PWR_FLAG_SBF PWR_PMSR_SBF /*!< STANDBY flag */
  83. #define LL_PWR_FLAG_AVDO PWR_VMSR_AVDO /*!< Analog voltage detector output on VDDA flag */
  84. #define LL_PWR_FLAG_VDDIO2RDY PWR_VMSR_VDDIO2RDY /*!< VDDIO2 ready flag */
  85. #define LL_PWR_FLAG_PVDO PWR_VMSR_PVDO /*!< Programmable voltage detect output flag */
  86. #define LL_PWR_FLAG_USB33RDY PWR_VMSR_USB33RDY /*!< VDDUSB ready flag */
  87. #define LL_PWR_FLAG_TEMPH PWR_BDSR_TEMPH /*!< Temperature level flag (versus high threshold) */
  88. #define LL_PWR_FLAG_TEMPL PWR_BDSR_TEMPL /*!< Temperature level flag (versus low threshold) */
  89. #define LL_PWR_FLAG_VBATH PWR_BDSR_VBATH /*!< VBAT level flag (versus high threshold) */
  90. #define LL_PWR_FLAG_VBATL PWR_BDSR_VBATL /*!< VBAT level flag (versus low threshold) */
  91. #define LL_PWR_WAKEUP_FLAG1 PWR_WUSR_WUF1 /*!< Wakeup flag 1 */
  92. #define LL_PWR_WAKEUP_FLAG2 PWR_WUSR_WUF2 /*!< Wakeup flag 2 */
  93. #define LL_PWR_WAKEUP_FLAG3 PWR_WUSR_WUF3 /*!< Wakeup flag 3 */
  94. #define LL_PWR_WAKEUP_FLAG4 PWR_WUSR_WUF4 /*!< Wakeup flag 4 */
  95. #define LL_PWR_WAKEUP_FLAG5 PWR_WUSR_WUF5 /*!< Wakeup flag 5 */
  96. #define LL_PWR_WAKEUP_FLAG6 PWR_WUSR_WUF6 /*!< Wakeup flag 6 */
  97. #define LL_PWR_WAKEUP_FLAG7 PWR_WUSR_WUF7 /*!< Wakeup flag 7 */
  98. #define LL_PWR_WAKEUP_FLAG8 PWR_WUSR_WUF8 /*!< Wakeup flag 8 */
  99. /**
  100. * @}
  101. */
  102. /** @defgroup PWR_LL_EC_LOW_POWER_MODE_SELCTION Low Power Mode Selection
  103. * @{
  104. */
  105. #define LL_PWR_STOP_MODE (0U) /*!< STOP 0 mode */
  106. #define LL_PWR_STANDBY_MODE PWR_PMCR_LPMS /*!< STANDBY mode */
  107. /**
  108. * @}
  109. */
  110. /** @defgroup PWR_LL_EC_VOLTAGE_SCALING_RANGE_SELECTION PWR Voltage scaling range selection
  111. * @{
  112. */
  113. #define LL_PWR_REGU_VOLTAGE_SCALE0 PWR_VOSCR_VOS /*!< Voltage scaling range 0 */
  114. #define LL_PWR_REGU_VOLTAGE_SCALE1 PWR_VOSCR_VOS_1 /*!< Voltage scaling range 1 */
  115. #define LL_PWR_REGU_VOLTAGE_SCALE2 PWR_VOSCR_VOS_0 /*!< Voltage scaling range 2 */
  116. #define LL_PWR_REGU_VOLTAGE_SCALE3 0x00000000U /*!< Voltage scaling range 3 */
  117. /**
  118. * @}
  119. */
  120. /** @defgroup PWR_LL_EC_STOP_MODE_REGU_VOLTAGE Stop mode Regulator Voltage Scaling
  121. * @{
  122. */
  123. #define LL_PWR_REGU_VOLTAGE_SVOS_SCALE5 PWR_PMCR_SVOS_0 /*!< Select voltage scale 5 when system enters STOP mode */
  124. #define LL_PWR_REGU_VOLTAGE_SVOS_SCALE4 PWR_PMCR_SVOS_1 /*!< Select voltage scale 4 when system enters STOP mode */
  125. #define LL_PWR_REGU_VOLTAGE_SVOS_SCALE3 (PWR_PMCR_SVOS_0 | PWR_PMCR_SVOS_1) /*!< Select voltage scale 3 when system enters STOP mode */
  126. /**
  127. * @}
  128. */
  129. /** @defgroup PWR_LL_EC_PVD_LEVEL_SELECTION PWR Power Voltage Detector Level Selection
  130. * @{
  131. */
  132. #define LL_PWR_PVDLEVEL_0 0U /*!< Voltage threshold detected by PVD 1.95 V */
  133. #define LL_PWR_PVDLEVEL_1 PWR_VMCR_PLS_0 /*!< Voltage threshold detected by PVD 2.10 V */
  134. #define LL_PWR_PVDLEVEL_2 PWR_VMCR_PLS_1 /*!< Voltage threshold detected by PVD 2.25 V */
  135. #define LL_PWR_PVDLEVEL_3 (PWR_VMCR_PLS_0 | PWR_VMCR_PLS_1) /*!< Voltage threshold detected by PVD 2.40 V */
  136. #define LL_PWR_PVDLEVEL_4 PWR_VMCR_PLS_2 /*!< Voltage threshold detected by PVD 2.55 V */
  137. #define LL_PWR_PVDLEVEL_5 (PWR_VMCR_PLS_0 | PWR_VMCR_PLS_2) /*!< Voltage threshold detected by PVD 2.70 V */
  138. #define LL_PWR_PVDLEVEL_6 (PWR_VMCR_PLS_1 | PWR_VMCR_PLS_2) /*!< Voltage threshold detected by PVD 2.85 V */
  139. #define LL_PWR_PVDLEVEL_7 PWR_VMCR_PLS /*!< External input analog voltage on PVD_IN
  140. pin, compared to internal VREFINT level */
  141. /**
  142. * @}
  143. */
  144. /** @defgroup PWR_LL_EC_AVDLEVEL Power Analog Voltage Level Detector
  145. * @{
  146. */
  147. #define LL_PWR_AVDLEVEL_0 0U /*!< Analog Voltage threshold detected by AVD 1.7 V */
  148. #define LL_PWR_AVDLEVEL_1 PWR_VMCR_ALS_0 /*!< Analog Voltage threshold detected by AVD 2.1 V */
  149. #define LL_PWR_AVDLEVEL_2 PWR_VMCR_ALS_1 /*!< Analog Voltage threshold detected by AVD 2.5 V */
  150. #define LL_PWR_AVDLEVEL_3 PWR_VMCR_ALS /*!< Analog Voltage threshold detected by AVD 2.8 V */
  151. /**
  152. * @}
  153. */
  154. /** @defgroup PWR_LL_EC_WAKEUP_PIN PWR Wake Up Pin
  155. * @{
  156. */
  157. #define LL_PWR_WAKEUP_PIN1 PWR_WUCR_WUPEN1 /*!< Wakeup pin 1 enable */
  158. #define LL_PWR_WAKEUP_PIN2 PWR_WUCR_WUPEN2 /*!< Wakeup pin 2 enable */
  159. #define LL_PWR_WAKEUP_PIN3 PWR_WUCR_WUPEN3 /*!< Wakeup pin 3 enable */
  160. #define LL_PWR_WAKEUP_PIN4 PWR_WUCR_WUPEN4 /*!< Wakeup pin 4 enable */
  161. #define LL_PWR_WAKEUP_PIN5 PWR_WUCR_WUPEN5 /*!< Wakeup pin 5 enable */
  162. #define LL_PWR_WAKEUP_PIN6 PWR_WUCR_WUPEN6 /*!< Wakeup pin 6 enable */
  163. #define LL_PWR_WAKEUP_PIN7 PWR_WUCR_WUPEN7 /*!< Wakeup pin 7 enable */
  164. #define LL_PWR_WAKEUP_PIN8 PWR_WUCR_WUPEN8 /*!< Wakeup pin 8 enable */
  165. /**
  166. * @}
  167. */
  168. /** @defgroup PWR_LL_EC_WAKEUP_PIN_PULL Wakeup Pins pull configuration
  169. * @{
  170. */
  171. #define LL_PWR_WAKEUP_PIN_NOPULL 0x00000000UL /*!< Configure Wake-Up pin in no pull */
  172. #define LL_PWR_WAKEUP_PIN_PULLUP 0x00000001UL /*!< Configure Wake-Up pin in pull Up */
  173. #define LL_PWR_WAKEUP_PIN_PULLDOWN 0x00000002UL /*!< Configure Wake-Up pin in pull Down */
  174. /**
  175. * @}
  176. */
  177. /** @defgroup PWR_LL_EC_SUPPLY_PWR Power supply source configuration
  178. * @{
  179. */
  180. #define LL_PWR_EXTERNAL_SOURCE_SUPPLY PWR_SCCR_BYPASS /*!< The SMPS and the LDO are Bypassed.
  181. The Core domains are supplied from an external source */
  182. /**
  183. * @}
  184. */
  185. /** @defgroup PWR_LL_EC_CHARGING_RESISTOR_SELECTION PWR VBAT Charging Resistor Selection
  186. * @{
  187. */
  188. #define LL_PWR_BATT_CHARG_RESISTOR_5K 0U /*!< Charge the battery through a 5 kO resistor */
  189. #define LL_PWR_BATT_CHARG_RESISTOR_1_5K PWR_BDCR_VBRS /*!< Charge the battery through a 1.5 kO resistor */
  190. /**
  191. * @}
  192. */
  193. /** @defgroup PWR_LL_EC_ITEMS_SECURE_ATTRIBUTE PWR Items Secure Attribute
  194. * @{
  195. */
  196. #define LL_PWR_WAKEUP_PIN1_NSEC 0U /* Wake up pin 1 nsecure mode */
  197. #define LL_PWR_WAKEUP_PIN1_SEC PWR_SECCFGR_WUP1SEC /* Wake up pin 1 secure mode */
  198. #define LL_PWR_WAKEUP_PIN2_NSEC 0U /* Wake up pin 2 nsecure mode */
  199. #define LL_PWR_WAKEUP_PIN2_SEC PWR_SECCFGR_WUP2SEC /* Wake up pin 2 secure mode */
  200. #define LL_PWR_WAKEUP_PIN3_NSEC 0U /* Wake up pin 3 nsecure mode */
  201. #define LL_PWR_WAKEUP_PIN3_SEC PWR_SECCFGR_WUP3SEC /* Wake up pin 3 secure mode */
  202. #define LL_PWR_WAKEUP_PIN4_NSEC 0U /* Wake up pin 4 nsecure mode */
  203. #define LL_PWR_WAKEUP_PIN4_SEC PWR_SECCFGR_WUP4SEC /* Wake up pin 4 secure mode */
  204. #define LL_PWR_WAKEUP_PIN5_NSEC 0U /* Wake up pin 5 nsecure mode */
  205. #define LL_PWR_WAKEUP_PIN5_SEC PWR_SECCFGR_WUP5SEC /* Wake up pin 5 secure mode */
  206. #define LL_PWR_WAKEUP_PIN6_NSEC 0U /* Wake up pin 6 nsecure mode */
  207. #define LL_PWR_WAKEUP_PIN6_SEC PWR_SECCFGR_WUP6SEC /* Wake up pin 6 secure mode */
  208. #define LL_PWR_WAKEUP_PIN7_NSEC 0U /* Wake up pin 7 nsecure mode */
  209. #define LL_PWR_WAKEUP_PIN7_SEC PWR_SECCFGR_WUP7SEC /* Wake up pin 7 secure mode */
  210. #define LL_PWR_WAKEUP_PIN8_NSEC 0U /* Wake up pin 8 nsecure mode */
  211. #define LL_PWR_WAKEUP_PIN8_SEC PWR_SECCFGR_WUP8SEC /* Wake up pin 8 secure mode */
  212. #define LL_PWR_RET_NSEC 0U /* Retention nsecure mode */
  213. #define LL_PWR_RET_SEC PWR_SECCFGR_RETSEC /* Retention secure mode */
  214. #define LL_PWR_LPM_NSEC 0U /* Low-power modes nsecure mode */
  215. #define LL_PWR_LPM_SEC PWR_SECCFGR_LPMSEC /* Low-power modes secure mode */
  216. #define LL_PWR_VDM_NSEC 0U /* Voltage detection and monitoring nsecure mode */
  217. #define LL_PWR_VDM_SEC PWR_SECCFGR_SCMSEC /* Voltage detection and monitoring secure mode */
  218. #define LL_PWR_VB_NSEC 0U /* Backup domain nsecure mode */
  219. #define LL_PWR_VB_SEC PWR_SECCFGR_VBSEC /* Backup domain secure mode */
  220. #define LL_PWR_APC_NSEC 0U /* Pull-up/pull-down nsecure mode */
  221. #define LL_PWR_APC_SEC PWR_SECCFGR_VUSBSEC /* Pull-up/pull-down secure mode */
  222. /**
  223. * @}
  224. */
  225. /**
  226. * @}
  227. */
  228. /* Exported macro ------------------------------------------------------------*/
  229. /** @defgroup PWR_LL_Exported_Macros PWR Exported Macros
  230. * @{
  231. */
  232. /** @defgroup PWR_LL_EM_WRITE_READ Common Write and Read Registers Macros
  233. * @{
  234. */
  235. /**
  236. * @brief Write a value in PWR register.
  237. * @param __REG__ Register to be written.
  238. * @param __VALUE__ Value to be written in the register.
  239. * @retval None.
  240. */
  241. #define LL_PWR_WriteReg(__REG__, __VALUE__) WRITE_REG(PWR->__REG__, (__VALUE__))
  242. /**
  243. * @brief Read a value in PWR register.
  244. * @param __REG__ Register to be read.
  245. * @retval Register value.
  246. */
  247. #define LL_PWR_ReadReg(__REG__) READ_REG(PWR->__REG__)
  248. /**
  249. * @}
  250. */
  251. /**
  252. * @}
  253. */
  254. /* Exported functions --------------------------------------------------------*/
  255. /** @defgroup PWR_LL_Exported_Functions PWR Exported Functions
  256. * @{
  257. */
  258. /** @defgroup PWR_LL_EF_CONFIGURATION PWR Configuration
  259. * @{
  260. */
  261. /**
  262. * @brief Set system power mode.
  263. * @rmtoll PMCR LPMS LL_PWR_SetPowerMode
  264. * @param Mode : This parameter can be one of the following values:
  265. * @arg @ref LL_PWR_STOP_MODE
  266. * @arg @ref LL_PWR_STANDBY_MODE
  267. * @retval None
  268. */
  269. __STATIC_INLINE void LL_PWR_SetPowerMode(uint32_t Mode)
  270. {
  271. MODIFY_REG(PWR->PMCR, PWR_PMCR_LPMS, Mode);
  272. }
  273. /**
  274. * @brief Get system power mode.
  275. * @rmtoll PMCR LPMS LL_PWR_GetPowerMode
  276. * @retval Returned value can be one of the following values:
  277. * @arg @ref LL_PWR_STOP_MODE
  278. * @arg @ref LL_PWR_STANDBY_MODE
  279. */
  280. __STATIC_INLINE uint32_t LL_PWR_GetPowerMode(void)
  281. {
  282. return (READ_BIT(PWR->PMCR, PWR_PMCR_LPMS));
  283. }
  284. /**
  285. * @brief Set the internal Regulator output voltage in STOP mode
  286. * @rmtoll PMCR SVOS LL_PWR_SetStopModeRegulVoltageScaling
  287. * @param VoltageScaling This parameter can be one of the following values:
  288. * @arg @ref LL_PWR_REGU_VOLTAGE_SVOS_SCALE3
  289. * @arg @ref LL_PWR_REGU_VOLTAGE_SVOS_SCALE4
  290. * @arg @ref LL_PWR_REGU_VOLTAGE_SVOS_SCALE5
  291. * @retval None
  292. */
  293. __STATIC_INLINE void LL_PWR_SetStopModeRegulVoltageScaling(uint32_t VoltageScaling)
  294. {
  295. MODIFY_REG(PWR->PMCR, PWR_PMCR_SVOS, VoltageScaling);
  296. }
  297. /**
  298. * @brief Get the internal Regulator output voltage in STOP mode
  299. * @rmtoll PMCR SVOS LL_PWR_GetStopModeRegulVoltageScaling
  300. * @retval Returned value can be one of the following values:
  301. * @arg @ref LL_PWR_REGU_VOLTAGE_SVOS_SCALE3
  302. * @arg @ref LL_PWR_REGU_VOLTAGE_SVOS_SCALE4
  303. * @arg @ref LL_PWR_REGU_VOLTAGE_SVOS_SCALE5
  304. */
  305. __STATIC_INLINE uint32_t LL_PWR_GetStopModeRegulVoltageScaling(void)
  306. {
  307. return (uint32_t)(READ_BIT(PWR->PMCR, PWR_PMCR_SVOS));
  308. }
  309. /**
  310. * @brief Enable the Flash Power Down in Stop Mode
  311. * @rmtoll PMCR FLPS LL_PWR_EnableFlashPowerDown
  312. * @retval None
  313. */
  314. __STATIC_INLINE void LL_PWR_EnableFlashPowerDown(void)
  315. {
  316. SET_BIT(PWR->PMCR, PWR_PMCR_FLPS);
  317. }
  318. /**
  319. * @brief Disable the Flash Power Down in Stop Mode
  320. * @rmtoll PMCR FLPS LL_PWR_DisableFlashPowerDown
  321. * @retval None
  322. */
  323. __STATIC_INLINE void LL_PWR_DisableFlashPowerDown(void)
  324. {
  325. CLEAR_BIT(PWR->PMCR, PWR_PMCR_FLPS);
  326. }
  327. /**
  328. * @brief Check if the Flash Power Down in Stop Mode is enabled
  329. * @rmtoll PMCR FLPS LL_PWR_IsEnabledFlashPowerDown
  330. * @retval State of bit (1 or 0).
  331. */
  332. __STATIC_INLINE uint32_t LL_PWR_IsEnabledFlashPowerDown(void)
  333. {
  334. return ((READ_BIT(PWR->PMCR, PWR_PMCR_FLPS) == (PWR_PMCR_FLPS)) ? 1UL : 0UL);
  335. }
  336. /**
  337. * @brief Enable the Analog Voltage Booster (VDDA)
  338. * @rmtoll PMCR BOOSTE LL_PWR_EnableAnalogBooster
  339. * @retval None
  340. */
  341. __STATIC_INLINE void LL_PWR_EnableAnalogBooster(void)
  342. {
  343. SET_BIT(PWR->PMCR, PWR_PMCR_BOOSTE);
  344. }
  345. /**
  346. * @brief Disable the Analog Voltage Booster (VDDA)
  347. * @rmtoll PMCR BOOSTE LL_PWR_DisableAnalogBooster
  348. * @retval None
  349. */
  350. __STATIC_INLINE void LL_PWR_DisableAnalogBooster(void)
  351. {
  352. CLEAR_BIT(PWR->PMCR, PWR_PMCR_BOOSTE);
  353. }
  354. /**
  355. * @brief Check if the Analog Voltage Booster (VDDA) is enabled
  356. * @rmtoll PMCR BOOSTE LL_PWR_IsEnabledAnalogBooster
  357. * @retval State of bit (1 or 0).
  358. */
  359. __STATIC_INLINE uint32_t LL_PWR_IsEnabledAnalogBooster(void)
  360. {
  361. return ((READ_BIT(PWR->PMCR, PWR_PMCR_BOOSTE) == (PWR_PMCR_BOOSTE)) ? 1UL : 0UL);
  362. }
  363. /**
  364. * @brief Enable the Analog Voltage Ready to isolate the BOOST IP until VDDA will be ready
  365. * @rmtoll PMCR AVD_READY LL_PWR_EnableAnalogVoltageReady
  366. * @retval None
  367. */
  368. __STATIC_INLINE void LL_PWR_EnableAnalogVoltageReady(void)
  369. {
  370. SET_BIT(PWR->PMCR, PWR_PMCR_AVD_READY);
  371. }
  372. /**
  373. * @brief Disable the Analog Voltage Ready (VDDA)
  374. * @rmtoll PMCR AVD_READY LL_PWR_DisableAnalogVoltageReady
  375. * @retval None
  376. */
  377. __STATIC_INLINE void LL_PWR_DisableAnalogVoltageReady(void)
  378. {
  379. CLEAR_BIT(PWR->PMCR, PWR_PMCR_AVD_READY);
  380. }
  381. /**
  382. * @brief Check if the Analog Voltage Booster (VDDA) is enabled
  383. * @rmtoll PMCR AVD_READY LL_PWR_IsEnabledAnalogVoltageReady
  384. * @retval State of bit (1 or 0).
  385. */
  386. __STATIC_INLINE uint32_t LL_PWR_IsEnabledAnalogVoltageReady(void)
  387. {
  388. return ((READ_BIT(PWR->PMCR, PWR_PMCR_AVD_READY) == (PWR_PMCR_AVD_READY)) ? 1UL : 0UL);
  389. }
  390. /**
  391. * @brief Enable the AHB RAM1 shut-off in Stop mode
  392. * @rmtoll PMCR SRAM1SO LL_PWR_EnableAHBRAM1ShutOff
  393. * @retval None
  394. */
  395. __STATIC_INLINE void LL_PWR_EnableAHBRAM1ShutOff(void)
  396. {
  397. SET_BIT(PWR->PMCR, PWR_PMCR_SRAM1SO);
  398. }
  399. /**
  400. * @brief Disable the AHB RAM1 shut-off in Stop mode
  401. * @rmtoll PMCR SRAM1SO LL_PWR_DisableAHBRAM1ShutOff
  402. * @retval None
  403. */
  404. __STATIC_INLINE void LL_PWR_DisableAHBRAM1ShutOff(void)
  405. {
  406. CLEAR_BIT(PWR->PMCR, PWR_PMCR_SRAM1SO);
  407. }
  408. /**
  409. * @brief Check if the AHB RAM1 shut-off in Stop mode is enabled
  410. * @rmtoll CR1 SRAM1SO LL_PWR_IsEnabledAHBRAM1ShutOff
  411. * @retval State of bit (1 or 0).
  412. */
  413. __STATIC_INLINE uint32_t LL_PWR_IsEnabledAHBRAM1ShutOff(void)
  414. {
  415. return ((READ_BIT(PWR->PMCR, PWR_PMCR_SRAM1SO) == (PWR_PMCR_SRAM1SO)) ? 1UL : 0UL);
  416. }
  417. #if defined (PWR_PMCR_SRAM2_48SO)
  418. /**
  419. * @brief Enable the AHB RAM2 48K Bytes shut-off in Stop mode
  420. * @rmtoll PMCR SRAM2_48SO LL_PWR_EnableAHBRAM2_48K_ShutOff
  421. * @retval None
  422. */
  423. __STATIC_INLINE void LL_PWR_EnableAHBRAM2_48K_ShutOff(void)
  424. {
  425. SET_BIT(PWR->PMCR, PWR_PMCR_SRAM2_48SO);
  426. }
  427. /**
  428. * @brief Disable the AHB RAM2 48K Bytes shut-off in Stop mode
  429. * @rmtoll PMCR SRAM2_48SO LL_PWR_DisableAHBRAM2_48K_ShutOff
  430. * @retval None
  431. */
  432. __STATIC_INLINE void LL_PWR_DisableAHBRAM2_48K_ShutOff(void)
  433. {
  434. CLEAR_BIT(PWR->PMCR, PWR_PMCR_SRAM2_48SO);
  435. }
  436. /**
  437. * @brief Check if the AHB RAM2 shut-off in Stop mode is enabled
  438. * @rmtoll PMCR SRAM2_48SO LL_PWR_IsEnabledAHBRAM2_48K_ShutOff
  439. * @retval State of bit (1 or 0).
  440. */
  441. __STATIC_INLINE uint32_t LL_PWR_IsEnabledAHBRAM2_48K_ShutOff(void)
  442. {
  443. return ((READ_BIT(PWR->PMCR, PWR_PMCR_SRAM2_48SO) == (PWR_PMCR_SRAM2_48SO)) ? 1UL : 0UL);
  444. }
  445. #endif /* PWR_PMCR_SRAM2_48SO */
  446. #if defined (PWR_PMCR_SRAM2_16SO)
  447. /**
  448. * @brief Enable the AHB RAM2 16K Bytes shut-off in Stop mode
  449. * @rmtoll PMCR SRAM2_16SO LL_PWR_EnableAHBRAM2_16K_ShutOff
  450. * @retval None
  451. */
  452. __STATIC_INLINE void LL_PWR_EnableAHBRAM2_16K_ShutOff(void)
  453. {
  454. SET_BIT(PWR->PMCR, PWR_PMCR_SRAM2_16SO);
  455. }
  456. /**
  457. * @brief Disable the AHB RAM2 16K Bytes shut-off in Stop mode
  458. * @rmtoll PMCR SRAM2_16SO LL_PWR_DisableAHBRAM2_16K_ShutOff
  459. * @retval None
  460. */
  461. __STATIC_INLINE void LL_PWR_DisableAHBRAM2_16K_ShutOff(void)
  462. {
  463. CLEAR_BIT(PWR->PMCR, PWR_PMCR_SRAM2_16SO);
  464. }
  465. /**
  466. * @brief Check if the AHB RAM2 shut-off in Stop mode is enabled
  467. * @rmtoll PMCR SRAM2_16SO LL_PWR_IsEnabledAHBRAM2_16K_ShutOff
  468. * @retval State of bit (1 or 0).
  469. */
  470. __STATIC_INLINE uint32_t LL_PWR_IsEnabledAHBRAM2_16K_ShutOff(void)
  471. {
  472. return ((READ_BIT(PWR->PMCR, PWR_PMCR_SRAM2_16SO) == (PWR_PMCR_SRAM2_16SO)) ? 1UL : 0UL);
  473. }
  474. #endif /* PWR_PMCR_SRAM2_16SO */
  475. #if defined(PWR_PMCR_SRAM2_16HSO)
  476. /**
  477. * @brief Enable the AHB RAM2 high 16K Bytes shut-off in Stop mode
  478. * @rmtoll PMCR SRAM2_16HSO LL_PWR_EnableAHBRAM2_High_16K_ShutOff
  479. * @retval None
  480. */
  481. __STATIC_INLINE void LL_PWR_EnableAHBRAM2_High_16K_ShutOff(void)
  482. {
  483. SET_BIT(PWR->PMCR, PWR_PMCR_SRAM2_16HSO);
  484. }
  485. /**
  486. * @brief Disable the AHB RAM2 high 16K Bytes shut-off in Stop mode
  487. * @rmtoll PMCR SRAM2_16HSO LL_PWR_DisableAHBRAM2_High_16K_ShutOff
  488. * @retval None
  489. */
  490. __STATIC_INLINE void LL_PWR_DisableAHBRAM2_High_16K_ShutOff(void)
  491. {
  492. CLEAR_BIT(PWR->PMCR, PWR_PMCR_SRAM2_16HSO);
  493. }
  494. /**
  495. * @brief Check if the high AHB RAM2 shut-off in Stop mode is enabled
  496. * @rmtoll PMCR SRAM2_16HSO LL_PWR_IsEnabledAHBRAM2_16K_ShutOff
  497. * @retval State of bit (1 or 0).
  498. */
  499. __STATIC_INLINE uint32_t LL_PWR_IsEnabledAHBRAM2_High_16K_ShutOff(void)
  500. {
  501. return ((READ_BIT(PWR->PMCR, PWR_PMCR_SRAM2_16HSO) == (PWR_PMCR_SRAM2_16HSO)) ? 1UL : 0UL);
  502. }
  503. #endif /* PWR_PMCR_SRAM2_16HSO */
  504. #if defined(PWR_PMCR_SRAM2_16LSO)
  505. /**
  506. * @brief Enable the AHB RAM2 low 16K Bytes shut-off in Stop mode
  507. * @rmtoll PMCR SRAM2_16LSO LL_PWR_EnableAHBRAM2_Low_16K_ShutOff
  508. * @retval None
  509. */
  510. __STATIC_INLINE void LL_PWR_EnableAHBRAM2_Low_16K_ShutOff(void)
  511. {
  512. SET_BIT(PWR->PMCR, PWR_PMCR_SRAM2_16LSO);
  513. }
  514. /**
  515. * @brief Disable the AHB RAM2 low 16K Bytes shut-off in Stop mode
  516. * @rmtoll PMCR SRAM2_16LSO LL_PWR_DisableAHBRAM2_Low_16K_ShutOff
  517. * @retval None
  518. */
  519. __STATIC_INLINE void LL_PWR_DisableAHBRAM2_Low_16K_ShutOff(void)
  520. {
  521. CLEAR_BIT(PWR->PMCR, PWR_PMCR_SRAM2_16LSO);
  522. }
  523. /**
  524. * @brief Check if the low 16K AHB RAM2 shut-off in Stop mode is enabled
  525. * @rmtoll PMCR SRAM2_16LSO LL_PWR_IsEnabledAHBRAM2_Low_16K_ShutOff
  526. * @retval State of bit (1 or 0).
  527. */
  528. __STATIC_INLINE uint32_t LL_PWR_IsEnabledAHBRAM2_Low_16K_ShutOff(void)
  529. {
  530. return ((READ_BIT(PWR->PMCR, PWR_PMCR_SRAM2_16LSO) == (PWR_PMCR_SRAM2_16LSO)) ? 1UL : 0UL);
  531. }
  532. #endif /* PWR_PMCR_SRAM2_16LSO */
  533. #if defined (PWR_PMCR_SRAM2SO)
  534. /**
  535. * @brief Enable the AHB RAM2 shut-off in Stop mode
  536. * @rmtoll PMCR SRAM2SO LL_PWR_EnableAHBRAM2ShutOff
  537. * @retval None
  538. */
  539. __STATIC_INLINE void LL_PWR_EnableAHBRAM2ShutOff(void)
  540. {
  541. SET_BIT(PWR->PMCR, PWR_PMCR_SRAM2SO);
  542. }
  543. /**
  544. * @brief Disable the AHB RAM2 shut-off in Stop mode
  545. * @rmtoll PMCR SRAM2SO LL_PWR_DisableAHBRAM2ShutOff
  546. * @retval None
  547. */
  548. __STATIC_INLINE void LL_PWR_DisableAHBRAM2ShutOff(void)
  549. {
  550. CLEAR_BIT(PWR->PMCR, PWR_PMCR_SRAM2SO);
  551. }
  552. /**
  553. * @brief Check if the AHB RAM2 shut-off in Stop mode is enabled
  554. * @rmtoll PMCR SRAM2SO LL_PWR_IsEnabledAHBRAM2ShutOff
  555. * @retval State of bit (1 or 0).
  556. */
  557. __STATIC_INLINE uint32_t LL_PWR_IsEnabledAHBRAM2ShutOff(void)
  558. {
  559. return ((READ_BIT(PWR->PMCR, PWR_PMCR_SRAM2SO) == (PWR_PMCR_SRAM2SO)) ? 1UL : 0UL);
  560. }
  561. #endif /* PWR_PMCR_SRAM2SO */
  562. #if defined (PWR_PMCR_SRAM3SO)
  563. /**
  564. * @brief Enable the AHB RAM3 shut-off in Stop mode
  565. * @rmtoll PMCR SRAM3SO LL_PWR_EnableAHBRAM3ShutOff
  566. * @retval None
  567. */
  568. __STATIC_INLINE void LL_PWR_EnableAHBRAM3ShutOff(void)
  569. {
  570. SET_BIT(PWR->PMCR, PWR_PMCR_SRAM3SO);
  571. }
  572. /**
  573. * @brief Disable the AHB RAM3 shut-off in Stop mode
  574. * @rmtoll PMCR SRAM3SO LL_PWR_DisableAHBRAM3ShutOff
  575. * @retval None
  576. */
  577. __STATIC_INLINE void LL_PWR_DisableAHBRAM3ShutOff(void)
  578. {
  579. CLEAR_BIT(PWR->PMCR, PWR_PMCR_SRAM3SO);
  580. }
  581. /**
  582. * @brief Check if the AHB RAM3 shut-off in Stop mode is enabled
  583. * @rmtoll PMCR SRAM3SO LL_PWR_IsEnabledAHBRAM3ShutOff
  584. * @retval State of bit (1 or 0).
  585. */
  586. __STATIC_INLINE uint32_t LL_PWR_IsEnabledAHBRAM3ShutOff(void)
  587. {
  588. return ((READ_BIT(PWR->PMCR, PWR_PMCR_SRAM3SO) == (PWR_PMCR_SRAM3SO)) ? 1UL : 0UL);
  589. }
  590. #endif /* PWR_PMCR_SRAM3SO */
  591. #if defined (PWR_PMCR_ETHERNETSO)
  592. /**
  593. * @brief Enable the ETHERNET RAM shut-off in Stop mode
  594. * @rmtoll PMCR ETHERNETSO LL_PWR_EnableETHERNETRAMShutOff
  595. * @retval None
  596. */
  597. __STATIC_INLINE void LL_PWR_EnableETHERNETRAMShutOff(void)
  598. {
  599. SET_BIT(PWR->PMCR, PWR_PMCR_ETHERNETSO);
  600. }
  601. /**
  602. * @brief Disable the ETHERNET RAM shut-off in Stop mode
  603. * @rmtoll PMCR ETHERNETSO LL_PWR_DisableETHERNETRAMShutOff
  604. * @retval None
  605. */
  606. __STATIC_INLINE void LL_PWR_DisableETHERNETRAMShutOff(void)
  607. {
  608. CLEAR_BIT(PWR->PMCR, PWR_PMCR_ETHERNETSO);
  609. }
  610. /**
  611. * @brief Check if the ETHERNET RAM shut-off in Stop mode is enabled
  612. * @rmtoll PMCR ETHERNETSO LL_PWR_IsEnabledETHERNETRAMShutOff
  613. * @retval State of bit (1 or 0).
  614. */
  615. __STATIC_INLINE uint32_t LL_PWR_IsEnabledETHERNETRAMShutOff(void)
  616. {
  617. return ((READ_BIT(PWR->PMCR, PWR_PMCR_ETHERNETSO) == (PWR_PMCR_ETHERNETSO)) ? 1UL : 0UL);
  618. }
  619. #endif /* PWR_PMCR_ETHERNETSO */
  620. /**
  621. * @brief Set the regulator supply output voltage.
  622. * @rmtoll VOSCR VOS LL_PWR_SetRegulVoltageScaling
  623. * @param VoltageScaling This parameter can be one of the following values:
  624. * @arg @ref LL_PWR_REGU_VOLTAGE_SCALE0
  625. * @arg @ref LL_PWR_REGU_VOLTAGE_SCALE1
  626. * @arg @ref LL_PWR_REGU_VOLTAGE_SCALE2
  627. * @arg @ref LL_PWR_REGU_VOLTAGE_SCALE3
  628. * @retval None
  629. */
  630. __STATIC_INLINE void LL_PWR_SetRegulVoltageScaling(uint32_t VoltageScaling)
  631. {
  632. MODIFY_REG(PWR->VOSCR, PWR_VOSCR_VOS, VoltageScaling);
  633. }
  634. /**
  635. * @brief Get the regulator supply output voltage.
  636. * @rmtoll VOSCR VOS LL_PWR_GetRegulVoltageScaling
  637. * @retval Returned value can be one of the following values:
  638. * @arg @ref LL_PWR_REGU_VOLTAGE_SCALE0
  639. * @arg @ref LL_PWR_REGU_VOLTAGE_SCALE1
  640. * @arg @ref LL_PWR_REGU_VOLTAGE_SCALE2
  641. * @arg @ref LL_PWR_REGU_VOLTAGE_SCALE3
  642. */
  643. __STATIC_INLINE uint32_t LL_PWR_GetRegulVoltageScaling(void)
  644. {
  645. return (uint32_t)(READ_BIT(PWR->VOSCR, PWR_VOSCR_VOS));
  646. }
  647. /**
  648. * @brief Get currently voltage scaling applied to VCORE.
  649. * @rmtoll VOSSR ACTVOS[1:0] LL_PWR_GetCurrentVOS
  650. * @retval Returned value can be one of the following values:
  651. * @arg @ref LL_PWR_REGU_VOLTAGE_SCALE0
  652. * @arg @ref LL_PWR_REGU_VOLTAGE_SCALE1
  653. * @arg @ref LL_PWR_REGU_VOLTAGE_SCALE2
  654. * @arg @ref LL_PWR_REGU_VOLTAGE_SCALE3
  655. */
  656. __STATIC_INLINE uint32_t LL_PWR_GetCurrentVOS(void)
  657. {
  658. return (READ_BIT(PWR->VOSSR, PWR_VOSSR_ACTVOS));
  659. }
  660. /**
  661. * @brief Enable Backup Regulator
  662. * @rmtoll BDCR BREN LL_PWR_EnableBkUpRegulator
  663. * @note When set, the Backup Regulator (used to maintain backup SRAM content in Standby and
  664. * VBAT modes) is enabled. If BRE is reset, the backup Regulator is switched off. The backup
  665. * SRAM can still be used but its content will be lost in the Standby and VBAT modes. Once set,
  666. * the application must wait that the Backup Regulator Ready flag (BRR) is set to indicate that
  667. * the data written into the RAM will be maintained in the Standby and VBAT modes.
  668. * @retval None
  669. */
  670. __STATIC_INLINE void LL_PWR_EnableBkUpRegulator(void)
  671. {
  672. SET_BIT(PWR->BDCR, PWR_BDCR_BREN);
  673. }
  674. /**
  675. * @brief Disable Backup Regulator
  676. * @rmtoll BDCR BREN LL_PWR_DisableBkUpRegulator
  677. * @retval None
  678. */
  679. __STATIC_INLINE void LL_PWR_DisableBkUpRegulator(void)
  680. {
  681. CLEAR_BIT(PWR->BDCR, PWR_BDCR_BREN);
  682. }
  683. /**
  684. * @brief Check if the backup Regulator is enabled
  685. * @rmtoll BDCR BREN LL_PWR_IsEnabledBkUpRegulator
  686. * @retval State of bit (1 or 0).
  687. */
  688. __STATIC_INLINE uint32_t LL_PWR_IsEnabledBkUpRegulator(void)
  689. {
  690. return ((READ_BIT(PWR->BDCR, PWR_BDCR_BREN) == (PWR_BDCR_BREN)) ? 1UL : 0UL);
  691. }
  692. /**
  693. * @brief Enable VBAT and Temperature monitoring
  694. * @rmtoll BDCR MONEN LL_PWR_EnableMonitoring
  695. * @retval None
  696. */
  697. __STATIC_INLINE void LL_PWR_EnableMonitoring(void)
  698. {
  699. SET_BIT(PWR->BDCR, PWR_BDCR_MONEN);
  700. }
  701. /**
  702. * @brief Disable VBAT and Temperature monitoring
  703. * @rmtoll BDCR MONEN LL_PWR_DisableMonitoring
  704. * @retval None
  705. */
  706. __STATIC_INLINE void LL_PWR_DisableMonitoring(void)
  707. {
  708. CLEAR_BIT(PWR->BDCR, PWR_BDCR_MONEN);
  709. }
  710. /**
  711. * @brief Check if the VBAT and Temperature monitoring is enabled
  712. * @rmtoll BDCR MONEN LL_PWR_IsEnabledMonitoring
  713. * @retval State of bit (1 or 0).
  714. */
  715. __STATIC_INLINE uint32_t LL_PWR_IsEnabledMonitoring(void)
  716. {
  717. return ((READ_BIT(PWR->BDCR, PWR_BDCR_MONEN) == (PWR_BDCR_MONEN)) ? 1UL : 0UL);
  718. }
  719. /**
  720. * @brief Enable battery charging
  721. * @rmtoll BDCR VBE LL_PWR_EnableBatteryCharging
  722. * @retval None
  723. */
  724. __STATIC_INLINE void LL_PWR_EnableBatteryCharging(void)
  725. {
  726. SET_BIT(PWR->BDCR, PWR_BDCR_VBE);
  727. }
  728. /**
  729. * @brief Disable battery charging
  730. * @rmtoll BDCR VBE LL_PWR_DisableBatteryCharging
  731. * @retval None
  732. */
  733. __STATIC_INLINE void LL_PWR_DisableBatteryCharging(void)
  734. {
  735. CLEAR_BIT(PWR->BDCR, PWR_BDCR_VBE);
  736. }
  737. /**
  738. * @brief Check if battery charging is enabled
  739. * @rmtoll BDCR VBE LL_PWR_IsEnabledBatteryCharging
  740. * @retval State of bit (1 or 0).
  741. */
  742. __STATIC_INLINE uint32_t LL_PWR_IsEnabledBatteryCharging(void)
  743. {
  744. return ((READ_BIT(PWR->BDCR, PWR_BDCR_VBE) == (PWR_BDCR_VBE)) ? 1UL : 0UL);
  745. }
  746. /**
  747. * @brief Set the Battery charge resistor impedance
  748. * @rmtoll BDCR VBRS LL_PWR_SetBattChargResistor
  749. * @param Resistor This parameter can be one of the following values:
  750. * @arg @ref LL_PWR_BATT_CHARG_RESISTOR_5K
  751. * @arg @ref LL_PWR_BATT_CHARG_RESISTOR_1_5K
  752. * @retval None
  753. */
  754. __STATIC_INLINE void LL_PWR_SetBattChargResistor(uint32_t Resistor)
  755. {
  756. MODIFY_REG(PWR->BDCR, PWR_BDCR_VBRS, Resistor);
  757. }
  758. /**
  759. * @brief Get the Battery charge resistor impedance
  760. * @rmtoll BDCR VBRS LL_PWR_GetBattChargResistor
  761. * @retval Returned value can be one of the following values:
  762. * @arg @ref LL_PWR_BATT_CHARG_RESISTOR_5K
  763. * @arg @ref LL_PWR_BATT_CHARG_RESISTOR_1_5K
  764. */
  765. __STATIC_INLINE uint32_t LL_PWR_GetBattChargResistor(void)
  766. {
  767. return (uint32_t)(READ_BIT(PWR->BDCR, PWR_BDCR_VBRS));
  768. }
  769. /**
  770. * @brief Enable access to the backup domain
  771. * @rmtoll DBPCR DBP LL_PWR_EnableBkUpAccess
  772. * @retval None
  773. */
  774. __STATIC_INLINE void LL_PWR_EnableBkUpAccess(void)
  775. {
  776. SET_BIT(PWR->DBPCR, PWR_DBPCR_DBP);
  777. }
  778. /**
  779. * @brief Disable access to the backup domain
  780. * @rmtoll DBPCR DBP LL_PWR_DisableBkUpAccess
  781. * @retval None
  782. */
  783. __STATIC_INLINE void LL_PWR_DisableBkUpAccess(void)
  784. {
  785. CLEAR_BIT(PWR->DBPCR, PWR_DBPCR_DBP);
  786. }
  787. /**
  788. * @brief Check if the backup domain is enabled
  789. * @rmtoll DBPCR DBP LL_PWR_IsEnabledBkUpAccess
  790. * @retval State of bit (1 or 0).
  791. */
  792. __STATIC_INLINE uint32_t LL_PWR_IsEnabledBkUpAccess(void)
  793. {
  794. return ((READ_BIT(PWR->DBPCR, PWR_DBPCR_DBP) == (PWR_DBPCR_DBP)) ? 1UL : 0UL);
  795. }
  796. #if defined (PWR_UCPDR_UCPD_STBY)
  797. /**
  798. * @brief Enable the USB type-C and power delivery memorization in Standby
  799. * mode.
  800. * @note This function must be called just before entering Standby mode.
  801. * @rmtoll UCPDR UCPD_STDBY LL_PWR_EnableUCPDStandbyMode
  802. * @retval None
  803. */
  804. __STATIC_INLINE void LL_PWR_EnableUCPDStandbyMode(void)
  805. {
  806. SET_BIT(PWR->UCPDR, PWR_UCPDR_UCPD_STBY);
  807. }
  808. /**
  809. * @brief Disable the USB type-C and power delivery memorization in Standby
  810. * mode.
  811. * @note This function must be called after exiting Standby mode and before
  812. * any UCPD configuration update.
  813. * @rmtoll UCPDR UCPD_STDBY LL_PWR_DisableUCPDStandbyMode
  814. * @retval None
  815. */
  816. __STATIC_INLINE void LL_PWR_DisableUCPDStandbyMode(void)
  817. {
  818. CLEAR_BIT(PWR->UCPDR, PWR_UCPDR_UCPD_STBY);
  819. }
  820. /**
  821. * @brief Check if the USB Type-C and Power Delivery Standby mode memorization
  822. * is enabled.
  823. * @rmtoll UCPDR UCPD_STDBY LL_PWR_IsEnabledUCPDStandbyMode
  824. * @retval State of bit (1 or 0).
  825. */
  826. __STATIC_INLINE uint32_t LL_PWR_IsEnabledUCPDStandbyMode(void)
  827. {
  828. return ((READ_BIT(PWR->UCPDR, PWR_UCPDR_UCPD_STBY) == (PWR_UCPDR_UCPD_STBY)) ? 1UL : 0UL);
  829. }
  830. #endif /* PWR_UCPDR_UCPD_STBY */
  831. #if defined (PWR_UCPDR_UCPD_DBDIS)
  832. /**
  833. * @brief Enable the USB Type-C and power delivery dead battery pull-down behavior
  834. * on UCPD CC1 and CC2 pins.
  835. * @note After exiting reset, the USB Type-C dead battery behavior is enabled,
  836. * which may have a pull-down effect on CC1 and CC2 pins. It is recommended
  837. * to disable it in all cases, either to stop this pull-down or to hand over
  838. * control to the UCPD (which should therefore be initialized before doing the disable).
  839. * @rmtoll UCPDR UCPD_DBDIS LL_PWR_EnableUCPDDeadBattery
  840. * @retval None
  841. */
  842. __STATIC_INLINE void LL_PWR_EnableUCPDDeadBattery(void)
  843. {
  844. CLEAR_BIT(PWR->UCPDR, PWR_UCPDR_UCPD_DBDIS);
  845. }
  846. /**
  847. * @brief Disable the USB Type-C and power delivery dead battery pull-down behavior
  848. * on UCPD CC1 and CC2 pins.
  849. * @note After exiting reset, the USB Type-C dead battery behavior is enabled,
  850. * which may have a pull-down effect on CC1 and CC2 pins. It is recommended
  851. * to disable it in all cases, either to stop this pull-down or to hand over
  852. * control to the UCPD (which should therefore be initialized before doing the disable).
  853. * @rmtoll UCPDR UCPD_DBDIS LL_PWR_DisableUCPDDeadBattery
  854. * @retval None
  855. */
  856. __STATIC_INLINE void LL_PWR_DisableUCPDDeadBattery(void)
  857. {
  858. SET_BIT(PWR->UCPDR, PWR_UCPDR_UCPD_DBDIS);
  859. }
  860. /**
  861. * @brief Check the USB Type-C and power delivery dead battery pull-down behavior
  862. * on UCPD CC1 and CC2 pins.
  863. * @note After exiting reset, the USB Type-C dead battery behavior is enabled,
  864. * which may have a pull-down effect on CC1 and CC2 pins. It is recommended
  865. * to disable it in all cases, either to stop this pull-down or to hand over
  866. * control to the UCPD (which should therefore be initialized before doing the disable).
  867. * @rmtoll UCPDR UCPD_DBDIS LL_PWR_IsEnabledUCPDDeadBattery
  868. * @retval State of feature (1 : enabled; 0 : disabled).
  869. */
  870. __STATIC_INLINE uint32_t LL_PWR_IsEnabledUCPDDeadBattery(void)
  871. {
  872. return ((READ_BIT(PWR->UCPDR, PWR_UCPDR_UCPD_DBDIS) == (PWR_UCPDR_UCPD_DBDIS)) ? 0UL : 1UL);
  873. }
  874. #endif /* PWR_UCPDR_UCPD_DBDIS */
  875. /**
  876. * @brief Configure the PWR supply
  877. * @rmtoll SCCR BYPASS LL_PWR_ConfigSupply
  878. * @param SupplySource This parameter can be one of the following values:
  879. * @arg @ref LL_PWR_EXTERNAL_SOURCE_SUPPLY
  880. * @retval None
  881. */
  882. __STATIC_INLINE void LL_PWR_ConfigSupply(uint32_t SupplySource)
  883. {
  884. /* Set the power supply configuration */
  885. MODIFY_REG(PWR->SCCR, (PWR_SCCR_BYPASS), SupplySource);
  886. }
  887. /**
  888. * @brief Get the PWR supply
  889. * @rmtoll SCCR BYPASS LL_PWR_GetSupply
  890. * @retval The supply configuration.
  891. */
  892. __STATIC_INLINE uint32_t LL_PWR_GetSupply(void)
  893. {
  894. #if defined (PWR_SCCR_SMPSEN)
  895. /* Get the power supply configuration */
  896. return (uint32_t)(READ_BIT(PWR->SCCR, (PWR_SCCR_SMPSEN | PWR_SCCR_LDOEN | PWR_SCCR_BYPASS)));
  897. #else
  898. /* Get the power supply configuration */
  899. return (uint32_t)(READ_BIT(PWR->SCCR, (PWR_SCCR_LDOEN | PWR_SCCR_BYPASS)));
  900. #endif /* PWR_SCCR_SMPSEN */
  901. }
  902. /**
  903. * @brief Enable Power Voltage Detector
  904. * @rmtoll VMCR PVDEN LL_PWR_EnablePVD
  905. * @retval None
  906. */
  907. __STATIC_INLINE void LL_PWR_EnablePVD(void)
  908. {
  909. SET_BIT(PWR->VMCR, PWR_VMCR_PVDEN);
  910. }
  911. /**
  912. * @brief Disable Power Voltage Detector
  913. * @rmtoll VMCR PVDEN LL_PWR_DisablePVD
  914. * @retval None
  915. */
  916. __STATIC_INLINE void LL_PWR_DisablePVD(void)
  917. {
  918. CLEAR_BIT(PWR->VMCR, PWR_VMCR_PVDEN);
  919. }
  920. /**
  921. * @brief Check if Power Voltage Detector is enabled
  922. * @rmtoll VMCR PVDEN LL_PWR_IsEnabledPVD
  923. * @retval State of bit (1 or 0).
  924. */
  925. __STATIC_INLINE uint32_t LL_PWR_IsEnabledPVD(void)
  926. {
  927. return ((READ_BIT(PWR->VMCR, PWR_VMCR_PVDEN) == (PWR_VMCR_PVDEN)) ? 1UL : 0UL);
  928. }
  929. /**
  930. * @brief Configure the voltage threshold detected by the Power Voltage Detector
  931. * @rmtoll VMCR PLS LL_PWR_SetPVDLevel
  932. * @param PVDLevel This parameter can be one of the following values:
  933. * @arg @ref LL_PWR_PVDLEVEL_0
  934. * @arg @ref LL_PWR_PVDLEVEL_1
  935. * @arg @ref LL_PWR_PVDLEVEL_2
  936. * @arg @ref LL_PWR_PVDLEVEL_3
  937. * @arg @ref LL_PWR_PVDLEVEL_4
  938. * @arg @ref LL_PWR_PVDLEVEL_5
  939. * @arg @ref LL_PWR_PVDLEVEL_6
  940. * @arg @ref LL_PWR_PVDLEVEL_7
  941. * @retval None
  942. */
  943. __STATIC_INLINE void LL_PWR_SetPVDLevel(uint32_t PVDLevel)
  944. {
  945. MODIFY_REG(PWR->VMCR, PWR_VMCR_PLS, PVDLevel);
  946. }
  947. /**
  948. * @brief Get the voltage threshold detection
  949. * @rmtoll VMCR PLS LL_PWR_GetPVDLevel
  950. * @retval Returned value can be one of the following values:
  951. * @arg @ref LL_PWR_PVDLEVEL_0
  952. * @arg @ref LL_PWR_PVDLEVEL_1
  953. * @arg @ref LL_PWR_PVDLEVEL_2
  954. * @arg @ref LL_PWR_PVDLEVEL_3
  955. * @arg @ref LL_PWR_PVDLEVEL_4
  956. * @arg @ref LL_PWR_PVDLEVEL_5
  957. * @arg @ref LL_PWR_PVDLEVEL_6
  958. * @arg @ref LL_PWR_PVDLEVEL_7
  959. */
  960. __STATIC_INLINE uint32_t LL_PWR_GetPVDLevel(void)
  961. {
  962. return (uint32_t)(READ_BIT(PWR->VMCR, PWR_VMCR_PLS));
  963. }
  964. /**
  965. * @brief Enable Analog Power Voltage Detector
  966. * @rmtoll VMCR AVDEN LL_PWR_EnableAVD
  967. * @retval None
  968. */
  969. __STATIC_INLINE void LL_PWR_EnableAVD(void)
  970. {
  971. SET_BIT(PWR->VMCR, PWR_VMCR_AVDEN);
  972. }
  973. /**
  974. * @brief Disable Analog Power Voltage Detector
  975. * @rmtoll VMCR AVDEN LL_PWR_DisableAVD
  976. * @retval None
  977. */
  978. __STATIC_INLINE void LL_PWR_DisableAVD(void)
  979. {
  980. CLEAR_BIT(PWR->VMCR, PWR_VMCR_AVDEN);
  981. }
  982. /**
  983. * @brief Check if Analog Power Voltage Detector is enabled
  984. * @rmtoll VMCR AVDEN LL_PWR_IsEnabledAVD
  985. * @retval State of bit (1 or 0).
  986. */
  987. __STATIC_INLINE uint32_t LL_PWR_IsEnabledAVD(void)
  988. {
  989. return ((READ_BIT(PWR->VMCR, PWR_VMCR_AVDEN) == (PWR_VMCR_AVDEN)) ? 1UL : 0UL);
  990. }
  991. /**
  992. * @brief Configure the voltage threshold to be detected by the Analog Power Voltage Detector
  993. * @rmtoll VMCR ALS LL_PWR_SetAVDLevel
  994. * @param AVDLevel This parameter can be one of the following values:
  995. * @arg @ref LL_PWR_AVDLEVEL_0
  996. * @arg @ref LL_PWR_AVDLEVEL_1
  997. * @arg @ref LL_PWR_AVDLEVEL_2
  998. * @arg @ref LL_PWR_AVDLEVEL_3
  999. * @retval None
  1000. */
  1001. __STATIC_INLINE void LL_PWR_SetAVDLevel(uint32_t AVDLevel)
  1002. {
  1003. MODIFY_REG(PWR->VMCR, PWR_VMCR_ALS, AVDLevel);
  1004. }
  1005. /**
  1006. * @brief Get the Analog Voltage threshold to be detected by the Analog Power Voltage Detector
  1007. * @rmtoll CR1 ALS LL_PWR_GetAVDLevel
  1008. * @retval Returned value can be one of the following values:
  1009. * @arg @ref LL_PWR_AVDLEVEL_0
  1010. * @arg @ref LL_PWR_AVDLEVEL_1
  1011. * @arg @ref LL_PWR_AVDLEVEL_2
  1012. * @arg @ref LL_PWR_AVDLEVEL_3
  1013. */
  1014. __STATIC_INLINE uint32_t LL_PWR_GetAVDLevel(void)
  1015. {
  1016. return (uint32_t)(READ_BIT(PWR->VMCR, PWR_VMCR_ALS));
  1017. }
  1018. #if defined (PWR_USBSCR_USB33DEN)
  1019. /**
  1020. * @brief Enable the USB voltage detector
  1021. * @rmtoll USBSCR USB33DEN LL_PWR_EnableUSBVoltageDetector
  1022. * @retval None
  1023. */
  1024. __STATIC_INLINE void LL_PWR_EnableUSBVoltageDetector(void)
  1025. {
  1026. SET_BIT(PWR->USBSCR, PWR_USBSCR_USB33DEN);
  1027. }
  1028. /**
  1029. * @brief Disable the USB voltage detector
  1030. * @rmtoll USBSCR USB33DEN LL_PWR_DisableUSBVoltageDetector
  1031. * @retval None
  1032. */
  1033. __STATIC_INLINE void LL_PWR_DisableUSBVoltageDetector(void)
  1034. {
  1035. CLEAR_BIT(PWR->USBSCR, PWR_USBSCR_USB33DEN);
  1036. }
  1037. /**
  1038. * @brief Check if the USB voltage detector is enabled
  1039. * @rmtoll USBSCR USB33DEN LL_PWR_IsEnabledUSBVoltageDetector
  1040. * @retval State of bit (1 or 0).
  1041. */
  1042. __STATIC_INLINE uint32_t LL_PWR_IsEnabledUSBVoltageDetector(void)
  1043. {
  1044. return ((READ_BIT(PWR->USBSCR, PWR_USBSCR_USB33DEN) == (PWR_USBSCR_USB33DEN)) ? 1UL : 0UL);
  1045. }
  1046. /**
  1047. * @brief Enable the independent USB supply.
  1048. * @rmtoll USBSCR USB33SV LL_PWR_EnableVddUSB
  1049. * @retval None
  1050. */
  1051. __STATIC_INLINE void LL_PWR_EnableVddUSB(void)
  1052. {
  1053. SET_BIT(PWR->USBSCR, PWR_USBSCR_USB33SV);
  1054. }
  1055. #define LL_PWR_EnableVDDUSB LL_PWR_EnableVddUSB /* for API backward compatibility */
  1056. /**
  1057. * @brief Disable the independent USB supply.
  1058. * @rmtoll USBSCR USB33SV LL_PWR_DisableVddUSB
  1059. * @retval None
  1060. */
  1061. __STATIC_INLINE void LL_PWR_DisableVddUSB(void)
  1062. {
  1063. CLEAR_BIT(PWR->USBSCR, PWR_USBSCR_USB33SV);
  1064. }
  1065. #define LL_PWR_DisableVDDUSB LL_PWR_DisableVddUSB /* for API backward compatibility */
  1066. /**
  1067. * @brief Check if the independent USB supply is enabled.
  1068. * @rmtoll USBSCR USB33SV LL_PWR_IsEnabledVddUSB
  1069. * @retval State of bit (1 or 0).
  1070. */
  1071. __STATIC_INLINE uint32_t LL_PWR_IsEnabledVddUSB(void)
  1072. {
  1073. return ((READ_BIT(PWR->USBSCR, PWR_USBSCR_USB33SV) == (PWR_USBSCR_USB33SV)) ? 1UL : 0UL);
  1074. }
  1075. #define LL_PWR_IsEnabledVDDUSB LL_PWR_IsEnabledVddUSB /* for API backward compatibility */
  1076. #endif /* PWR_USBSCR_USB33DEN */
  1077. /**
  1078. * @brief Enable the wake up pin_x.
  1079. * @rmtoll WUCR WUPENx LL_PWR_EnableWakeUpPin
  1080. * @param WakeUpPin This parameter can be a combination of the following values:
  1081. * @arg @ref LL_PWR_WAKEUP_PIN1
  1082. * @arg @ref LL_PWR_WAKEUP_PIN2
  1083. * @arg @ref LL_PWR_WAKEUP_PIN3
  1084. * @arg @ref LL_PWR_WAKEUP_PIN4
  1085. * @arg @ref LL_PWR_WAKEUP_PIN5
  1086. * @arg @ref LL_PWR_WAKEUP_PIN6
  1087. * @arg @ref LL_PWR_WAKEUP_PIN7
  1088. * @arg @ref LL_PWR_WAKEUP_PIN8
  1089. * @retval None
  1090. */
  1091. __STATIC_INLINE void LL_PWR_EnableWakeUpPin(uint32_t WakeUpPin)
  1092. {
  1093. SET_BIT(PWR->WUCR, WakeUpPin);
  1094. }
  1095. /**
  1096. * @brief Disable the wake up pin_x.
  1097. * @rmtoll WUCR WUPENx LL_PWR_DisableWakeUpPin
  1098. * @param WakeUpPin This parameter can be a combination of the following values:
  1099. * @arg @ref LL_PWR_WAKEUP_PIN1
  1100. * @arg @ref LL_PWR_WAKEUP_PIN2
  1101. * @arg @ref LL_PWR_WAKEUP_PIN3
  1102. * @arg @ref LL_PWR_WAKEUP_PIN4
  1103. * @arg @ref LL_PWR_WAKEUP_PIN5
  1104. * @arg @ref LL_PWR_WAKEUP_PIN6
  1105. * @arg @ref LL_PWR_WAKEUP_PIN7
  1106. * @arg @ref LL_PWR_WAKEUP_PIN8
  1107. * @retval None
  1108. */
  1109. __STATIC_INLINE void LL_PWR_DisableWakeUpPin(uint32_t WakeUpPin)
  1110. {
  1111. CLEAR_BIT(PWR->WUCR, WakeUpPin);
  1112. }
  1113. /**
  1114. * @brief Check if the wake up pin_x is enabled.
  1115. * @rmtoll WUCR WUPPx LL_PWR_IsEnabledWakeUpPin
  1116. * @param WakeUpPin This parameter can be one of the following values:
  1117. * @arg @ref LL_PWR_WAKEUP_PIN1
  1118. * @arg @ref LL_PWR_WAKEUP_PIN2
  1119. * @arg @ref LL_PWR_WAKEUP_PIN3
  1120. * @arg @ref LL_PWR_WAKEUP_PIN4
  1121. * @arg @ref LL_PWR_WAKEUP_PIN5
  1122. * @arg @ref LL_PWR_WAKEUP_PIN6
  1123. * @arg @ref LL_PWR_WAKEUP_PIN7
  1124. * @arg @ref LL_PWR_WAKEUP_PIN8
  1125. * @retval State of bit (1 or 0).
  1126. */
  1127. __STATIC_INLINE uint32_t LL_PWR_IsEnabledWakeUpPin(uint32_t WakeUpPin)
  1128. {
  1129. return ((READ_BIT(PWR->WUCR, WakeUpPin) == (WakeUpPin)) ? 1UL : 0UL);
  1130. }
  1131. /**
  1132. * @brief Set the Wake-Up pin polarity low for the event detection
  1133. * @rmtoll WUCR WKUPP1 LL_PWR_SetWakeUpPinPolarityLow\n
  1134. * WUCR WKUPP2 LL_PWR_SetWakeUpPinPolarityLow\n
  1135. * WUCR WKUPP3 LL_PWR_SetWakeUpPinPolarityLow\n
  1136. * WUCR WKUPP4 LL_PWR_SetWakeUpPinPolarityLow\n
  1137. * WUCR WKUPP5 LL_PWR_SetWakeUpPinPolarityLow\n
  1138. * WUCR WKUPP6 LL_PWR_SetWakeUpPinPolarityLow\n
  1139. * WUCR WKUPP7 LL_PWR_SetWakeUpPinPolarityLow\n
  1140. * WUCR WKUPP8 LL_PWR_SetWakeUpPinPolarityLow
  1141. * @param WakeUpPin This parameter can be one of the following values:
  1142. * @arg @ref LL_PWR_WAKEUP_PIN1
  1143. * @arg @ref LL_PWR_WAKEUP_PIN2
  1144. * @arg @ref LL_PWR_WAKEUP_PIN3
  1145. * @arg @ref LL_PWR_WAKEUP_PIN4
  1146. * @arg @ref LL_PWR_WAKEUP_PIN5
  1147. * @arg @ref LL_PWR_WAKEUP_PIN6
  1148. * @arg @ref LL_PWR_WAKEUP_PIN7
  1149. * @arg @ref LL_PWR_WAKEUP_PIN8
  1150. * @retval None
  1151. */
  1152. __STATIC_INLINE void LL_PWR_SetWakeUpPinPolarityLow(uint32_t WakeUpPin)
  1153. {
  1154. SET_BIT(PWR->WUCR, (WakeUpPin << PWR_WUCR_WUPP1_Pos));
  1155. }
  1156. /**
  1157. * @brief Set the Wake-Up pin polarity high for the event detection
  1158. * @rmtoll WUCR WKUPP1 LL_PWR_SetWakeUpPinPolarityHigh\n
  1159. * WUCR WKUPP2 LL_PWR_SetWakeUpPinPolarityHigh\n
  1160. * WUCR WKUPP3 LL_PWR_SetWakeUpPinPolarityHigh\n
  1161. * WUCR WKUPP4 LL_PWR_SetWakeUpPinPolarityHigh\n
  1162. * WUCR WKUPP5 LL_PWR_SetWakeUpPinPolarityHigh\n
  1163. * WUCR WKUPP6 LL_PWR_SetWakeUpPinPolarityHigh\n
  1164. * WUCR WKUPP7 LL_PWR_SetWakeUpPinPolarityHigh\n
  1165. * WUCR WKUPP8 LL_PWR_SetWakeUpPinPolarityHigh
  1166. * @param WakeUpPin This parameter can be one of the following values:
  1167. * @arg @ref LL_PWR_WAKEUP_PIN1
  1168. * @arg @ref LL_PWR_WAKEUP_PIN2
  1169. * @arg @ref LL_PWR_WAKEUP_PIN3
  1170. * @arg @ref LL_PWR_WAKEUP_PIN4
  1171. * @arg @ref LL_PWR_WAKEUP_PIN5
  1172. * @arg @ref LL_PWR_WAKEUP_PIN6
  1173. * @arg @ref LL_PWR_WAKEUP_PIN7
  1174. * @arg @ref LL_PWR_WAKEUP_PIN8
  1175. * @retval None
  1176. */
  1177. __STATIC_INLINE void LL_PWR_SetWakeUpPinPolarityHigh(uint32_t WakeUpPin)
  1178. {
  1179. CLEAR_BIT(PWR->WUCR, (WakeUpPin << PWR_WUCR_WUPP1_Pos));
  1180. }
  1181. /**
  1182. * @brief Get the Wake-Up pin polarity for the event detection
  1183. * @rmtoll WUCR WUPP1 LL_PWR_SetWakeUpPinPolarityLow\n
  1184. * WUCR WUPP2 LL_PWR_SetWakeUpPinPolarityLow\n
  1185. * WUCR WUPP3 LL_PWR_SetWakeUpPinPolarityLow\n
  1186. * WUCR WUPP4 LL_PWR_SetWakeUpPinPolarityLow\n
  1187. * WUCR WUPP5 LL_PWR_SetWakeUpPinPolarityLow\n
  1188. * WUCR WUPP6 LL_PWR_SetWakeUpPinPolarityLow\n
  1189. * WUCR WUPP7 LL_PWR_SetWakeUpPinPolarityLow\n
  1190. * WUCR WUPP8 LL_PWR_SetWakeUpPinPolarityLow
  1191. * @param WakeUpPin This parameter can be one of the following values:
  1192. * @arg @ref LL_PWR_WAKEUP_PIN1
  1193. * @arg @ref LL_PWR_WAKEUP_PIN2
  1194. * @arg @ref LL_PWR_WAKEUP_PIN3
  1195. * @arg @ref LL_PWR_WAKEUP_PIN4
  1196. * @arg @ref LL_PWR_WAKEUP_PIN5
  1197. * @arg @ref LL_PWR_WAKEUP_PIN6
  1198. * @arg @ref LL_PWR_WAKEUP_PIN7
  1199. * @arg @ref LL_PWR_WAKEUP_PIN8
  1200. * @retval State of bit (1 or 0).
  1201. */
  1202. __STATIC_INLINE uint32_t LL_PWR_IsWakeUpPinPolarityLow(uint32_t WakeUpPin)
  1203. {
  1204. return ((READ_BIT(PWR->WUCR, (WakeUpPin << PWR_WUCR_WUPP1_Pos)) == (WakeUpPin << PWR_WUCR_WUPP1_Pos)) ? 1UL : 0UL);
  1205. }
  1206. /**
  1207. * @brief Set the Wake-Up pin Pull None
  1208. * @rmtoll WUCR WUPPUPD1 LL_PWR_SetWakeUpPinPullNone\n
  1209. * WUCR WUPPUPD2 LL_PWR_SetWakeUpPinPullNone\n
  1210. * WUCR WUPPUPD3 LL_PWR_SetWakeUpPinPullNone\n
  1211. * WUCR WUPPUPD4 LL_PWR_SetWakeUpPinPullNone\n
  1212. * WUCR WUPPUPD5 LL_PWR_SetWakeUpPinPullNone\n
  1213. * WUCR WUPPUPD6 LL_PWR_SetWakeUpPinPullNone\n
  1214. * WUCR WUPPUPD7 LL_PWR_SetWakeUpPinPullNone\n
  1215. * WUCR WUPPUPD8 LL_PWR_SetWakeUpPinPullNone
  1216. * @param WakeUpPin This parameter can be one of the following values:
  1217. * @arg @ref LL_PWR_WAKEUP_PIN1
  1218. * @arg @ref LL_PWR_WAKEUP_PIN2
  1219. * @arg @ref LL_PWR_WAKEUP_PIN3
  1220. * @arg @ref LL_PWR_WAKEUP_PIN4
  1221. * @arg @ref LL_PWR_WAKEUP_PIN5
  1222. * @arg @ref LL_PWR_WAKEUP_PIN6
  1223. * @arg @ref LL_PWR_WAKEUP_PIN7
  1224. * @arg @ref LL_PWR_WAKEUP_PIN8
  1225. *
  1226. * @retval None
  1227. */
  1228. __STATIC_INLINE void LL_PWR_SetWakeUpPinPullNone(uint32_t WakeUpPin)
  1229. {
  1230. MODIFY_REG(PWR->WUCR,
  1231. (PWR_WUCR_WUPPUPD1 << ((LL_PWR_WAKEUP_PINS_PULL_SHIFT_OFFSET * (POSITION_VAL(WakeUpPin) & 0xFU)) & \
  1232. LL_PWR_WAKEUP_PINS_MAX_SHIFT_MASK)),
  1233. (LL_PWR_WAKEUP_PIN_NOPULL << ((PWR_WUCR_WUPPUPD1_Pos + ((LL_PWR_WAKEUP_PINS_PULL_SHIFT_OFFSET * \
  1234. POSITION_VAL(WakeUpPin)) & 0xFU)) & \
  1235. LL_PWR_WAKEUP_PINS_MAX_SHIFT_MASK)));
  1236. }
  1237. /**
  1238. * @brief Set the Wake-Up pin Pull Up
  1239. * @rmtoll WUCR WUPPUPD1 LL_PWR_SetWakeUpPinPullUp\n
  1240. * WUCR WUPPUPD2 LL_PWR_SetWakeUpPinPullUp\n
  1241. * WUCR WUPPUPD3 LL_PWR_SetWakeUpPinPullUp\n
  1242. * WUCR WUPPUPD4 LL_PWR_SetWakeUpPinPullUp\n
  1243. * WUCR WUPPUPD5 LL_PWR_SetWakeUpPinPullUp\n
  1244. * WUCR WUPPUPD6 LL_PWR_SetWakeUpPinPullUp\n
  1245. * WUCR WUPPUPD7 LL_PWR_SetWakeUpPinPullUp\n
  1246. * WUCR WUPPUPD8 LL_PWR_SetWakeUpPinPullUp
  1247. * @param WakeUpPin This parameter can be one of the following values:
  1248. * @arg @ref LL_PWR_WAKEUP_PIN1
  1249. * @arg @ref LL_PWR_WAKEUP_PIN2
  1250. * @arg @ref LL_PWR_WAKEUP_PIN3
  1251. * @arg @ref LL_PWR_WAKEUP_PIN4
  1252. * @arg @ref LL_PWR_WAKEUP_PIN5
  1253. * @arg @ref LL_PWR_WAKEUP_PIN6
  1254. * @arg @ref LL_PWR_WAKEUP_PIN7
  1255. * @arg @ref LL_PWR_WAKEUP_PIN8
  1256. *
  1257. *
  1258. * @retval None
  1259. */
  1260. __STATIC_INLINE void LL_PWR_SetWakeUpPinPullUp(uint32_t WakeUpPin)
  1261. {
  1262. MODIFY_REG(PWR->WUCR,
  1263. (PWR_WUCR_WUPPUPD1 << ((LL_PWR_WAKEUP_PINS_PULL_SHIFT_OFFSET * (POSITION_VAL(WakeUpPin) & 0xFU)) & \
  1264. LL_PWR_WAKEUP_PINS_MAX_SHIFT_MASK)),
  1265. (LL_PWR_WAKEUP_PIN_PULLUP << ((PWR_WUCR_WUPPUPD1_Pos + ((LL_PWR_WAKEUP_PINS_PULL_SHIFT_OFFSET * \
  1266. POSITION_VAL(WakeUpPin)) & 0xFU)) & \
  1267. LL_PWR_WAKEUP_PINS_MAX_SHIFT_MASK)));
  1268. }
  1269. /**
  1270. * @brief Set the Wake-Up pin Pull Down
  1271. * @rmtoll WUCR WUPPUPD1 LL_PWR_SetWakeUpPinPullDown\n
  1272. * WUCR WUPPUPD2 LL_PWR_SetWakeUpPinPullDown\n
  1273. * WUCR WUPPUPD3 LL_PWR_SetWakeUpPinPullDown\n
  1274. * WUCR WUPPUPD4 LL_PWR_SetWakeUpPinPullDown\n
  1275. * WUCR WUPPUPD5 LL_PWR_SetWakeUpPinPullDown\n
  1276. * WUCR WUPPUPD6 LL_PWR_SetWakeUpPinPullDown\n
  1277. * WUCR WUPPUPD7 LL_PWR_SetWakeUpPinPullDown\n
  1278. * WUCR WUPPUPD8 LL_PWR_SetWakeUpPinPullDown
  1279. * @param WakeUpPin This parameter can be one of the following values:
  1280. * @arg @ref LL_PWR_WAKEUP_PIN1
  1281. * @arg @ref LL_PWR_WAKEUP_PIN2
  1282. * @arg @ref LL_PWR_WAKEUP_PIN3
  1283. * @arg @ref LL_PWR_WAKEUP_PIN4
  1284. * @arg @ref LL_PWR_WAKEUP_PIN5
  1285. * @arg @ref LL_PWR_WAKEUP_PIN6
  1286. * @arg @ref LL_PWR_WAKEUP_PIN7
  1287. * @arg @ref LL_PWR_WAKEUP_PIN8
  1288. *
  1289. * @retval None
  1290. */
  1291. __STATIC_INLINE void LL_PWR_SetWakeUpPinPullDown(uint32_t WakeUpPin)
  1292. {
  1293. MODIFY_REG(PWR->WUCR,
  1294. (PWR_WUCR_WUPPUPD1 << ((LL_PWR_WAKEUP_PINS_PULL_SHIFT_OFFSET * (POSITION_VAL(WakeUpPin) & 0xFU)) & \
  1295. LL_PWR_WAKEUP_PINS_MAX_SHIFT_MASK)),
  1296. (LL_PWR_WAKEUP_PIN_PULLDOWN << ((PWR_WUCR_WUPPUPD1_Pos + ((LL_PWR_WAKEUP_PINS_PULL_SHIFT_OFFSET * \
  1297. POSITION_VAL(WakeUpPin)) & 0xFU)) & \
  1298. LL_PWR_WAKEUP_PINS_MAX_SHIFT_MASK)));
  1299. }
  1300. /**
  1301. * @brief Get the Wake-Up pin pull
  1302. * @rmtoll WUCR WUPPUPD1 LL_PWR_GetWakeUpPinPull\n
  1303. * WUCR WUPPUPD2 LL_PWR_GetWakeUpPinPull\n
  1304. * WUCR WUPPUPD3 LL_PWR_GetWakeUpPinPull\n
  1305. * WUCR WUPPUPD4 LL_PWR_GetWakeUpPinPull\n
  1306. * WUCR WUPPUPD5 LL_PWR_GetWakeUpPinPull\n
  1307. * WUCR WUPPUPD7 LL_PWR_GetWakeUpPinPull\n
  1308. * WUCR WUPPUPD7 LL_PWR_GetWakeUpPinPull\n
  1309. * WUCR WUPPUPD8 LL_PWR_GetWakeUpPinPull
  1310. * @param WakeUpPin This parameter can be one of the following values:
  1311. * @arg @ref LL_PWR_WAKEUP_PIN1
  1312. * @arg @ref LL_PWR_WAKEUP_PIN2
  1313. * @arg @ref LL_PWR_WAKEUP_PIN3
  1314. * @arg @ref LL_PWR_WAKEUP_PIN4
  1315. * @arg @ref LL_PWR_WAKEUP_PIN5
  1316. * @arg @ref LL_PWR_WAKEUP_PIN6
  1317. * @arg @ref LL_PWR_WAKEUP_PIN7
  1318. * @arg @ref LL_PWR_WAKEUP_PIN8
  1319. *
  1320. * @retval Returned value can be one of the following values:
  1321. * @arg @ref LL_PWR_WAKEUP_PIN_NOPULL
  1322. * @arg @ref LL_PWR_WAKEUP_PIN_PULLUP
  1323. * @arg @ref LL_PWR_WAKEUP_PIN_PULLDOWN
  1324. */
  1325. __STATIC_INLINE uint32_t LL_PWR_GetWakeUpPinPull(uint32_t WakeUpPin)
  1326. {
  1327. uint32_t regValue = READ_BIT(PWR->WUCR, (PWR_WUCR_WUPPUPD1 << ((LL_PWR_WAKEUP_PINS_PULL_SHIFT_OFFSET * \
  1328. (POSITION_VAL(WakeUpPin) & 0xFU)) & \
  1329. LL_PWR_WAKEUP_PINS_MAX_SHIFT_MASK)));
  1330. return (uint32_t)(regValue >> ((PWR_WUCR_WUPPUPD1_Pos + ((LL_PWR_WAKEUP_PINS_PULL_SHIFT_OFFSET * \
  1331. POSITION_VAL(WakeUpPin)) & 0xFU)) & \
  1332. LL_PWR_WAKEUP_PINS_MAX_SHIFT_MASK));
  1333. }
  1334. /**
  1335. * @brief Enable IO Retention
  1336. * @rmtoll IORETR IORETEN LL_PWR_EnableIORetention
  1337. * @retval None
  1338. */
  1339. __STATIC_INLINE void LL_PWR_EnableIORetention(void)
  1340. {
  1341. SET_BIT(PWR->IORETR, PWR_IORETR_IORETEN);
  1342. }
  1343. /**
  1344. * @brief Disable IO Retention
  1345. * @rmtoll IORETR IORETEN LL_PWR_DisableIORetention
  1346. * @retval None
  1347. */
  1348. __STATIC_INLINE void LL_PWR_DisableIORetention(void)
  1349. {
  1350. CLEAR_BIT(PWR->IORETR, PWR_IORETR_IORETEN);
  1351. }
  1352. /**
  1353. * @brief Check if IO Retention is enabled
  1354. * @rmtoll IORETR IORETEN LL_PWR_IsEnabledIORetention
  1355. * @retval State of bit (1 or 0).
  1356. */
  1357. __STATIC_INLINE uint32_t LL_PWR_IsEnabledIORetention(void)
  1358. {
  1359. return ((READ_BIT(PWR->IORETR, PWR_IORETR_IORETEN) == (PWR_IORETR_IORETEN)) ? 1UL : 0UL);
  1360. }
  1361. /**
  1362. * @brief Enable JTAGIO Retention
  1363. * @rmtoll JTAGIORETR JTAGIORETEN LL_PWR_EnableJTAGIORetention
  1364. * @retval None
  1365. */
  1366. __STATIC_INLINE void LL_PWR_EnableJTAGIORetention(void)
  1367. {
  1368. SET_BIT(PWR->IORETR, PWR_IORETR_JTAGIORETEN);
  1369. }
  1370. /**
  1371. * @brief Disable JTAGIO Retention
  1372. * @rmtoll JTAGIORETR JTAGIORETEN LL_PWR_DisableJTAGIORetention
  1373. * @retval None
  1374. */
  1375. __STATIC_INLINE void LL_PWR_DisableJTAGIORetention(void)
  1376. {
  1377. CLEAR_BIT(PWR->IORETR, PWR_IORETR_JTAGIORETEN);
  1378. }
  1379. /**
  1380. * @brief Check if JTAGIO Retention is enabled
  1381. * @rmtoll IORETR JTAGIORETEN LL_PWR_IsEnabledJTAGIORetention
  1382. * @retval State of bit (1 or 0).
  1383. */
  1384. __STATIC_INLINE uint32_t LL_PWR_IsEnabledJTAGIORetention(void)
  1385. {
  1386. return ((READ_BIT(PWR->IORETR, PWR_IORETR_JTAGIORETEN) == (PWR_IORETR_JTAGIORETEN)) ? 1UL : 0UL);
  1387. }
  1388. /**
  1389. * @}
  1390. */
  1391. /** @defgroup PWR_LL_EF_FLAG_MANAGEMENT PWR FLAG Management
  1392. * @{
  1393. */
  1394. /**
  1395. * @brief Indicate whether the regulator voltage output is above voltage
  1396. * scaling range or not.
  1397. * @rmtoll VOSSR VOSRDY LL_PWR_IsActiveFlag_VOS
  1398. * @retval State of bit (1 or 0).
  1399. */
  1400. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_VOS(void)
  1401. {
  1402. return ((READ_BIT(PWR->VOSSR, PWR_VOSSR_VOSRDY) == (PWR_VOSSR_VOSRDY)) ? 1UL : 0UL);
  1403. }
  1404. /**
  1405. * @brief Indicate whether the system was in standby mode or not.
  1406. * @rmtoll PMSR SBF LL_PWR_IsActiveFlag_SB
  1407. * @retval State of bit (1 or 0).
  1408. */
  1409. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_SB(void)
  1410. {
  1411. return ((READ_BIT(PWR->PMSR, PWR_PMSR_SBF) == (PWR_PMSR_SBF)) ? 1UL : 0UL);
  1412. }
  1413. /**
  1414. * @brief Indicate whether the system was in stop mode or not.
  1415. * @rmtoll PMSR STOPF LL_PWR_IsActiveFlag_STOP
  1416. * @retval State of bit (1 or 0).
  1417. */
  1418. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_STOP(void)
  1419. {
  1420. return ((READ_BIT(PWR->PMSR, PWR_PMSR_STOPF) == (PWR_PMSR_STOPF)) ? 1UL : 0UL);
  1421. }
  1422. /**
  1423. * @brief Indicate whether the VDD voltage is below the threshold or not.
  1424. * @rmtoll VMSR PVDO LL_PWR_IsActiveFlag_PVDO
  1425. * @retval State of bit (1 or 0).
  1426. */
  1427. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_PVDO(void)
  1428. {
  1429. return ((READ_BIT(PWR->VMSR, PWR_VMSR_PVDO) == (PWR_VMSR_PVDO)) ? 1UL : 0UL);
  1430. }
  1431. /**
  1432. * @brief Indicate whether the VDDA voltage is below the threshold or not.
  1433. * @rmtoll VMSR AVDO LL_PWR_IsActiveFlag_AVDO
  1434. * @retval State of bit (1 or 0).
  1435. */
  1436. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_AVDO(void)
  1437. {
  1438. return ((READ_BIT(PWR->VMSR, PWR_VMSR_AVDO) == (PWR_VMSR_AVDO)) ? 1UL : 0UL);
  1439. }
  1440. /**
  1441. * @brief Indicate whether the regulator voltage output is equal to current
  1442. * used voltage scaling range or not.
  1443. * @rmtoll VOSSR ACTVOSRDY LL_PWR_IsActiveFlag_ACTVOS
  1444. * @retval State of bit (1 or 0).
  1445. */
  1446. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_ACTVOS(void)
  1447. {
  1448. return ((READ_BIT(PWR->VOSSR, PWR_VOSSR_ACTVOSRDY) == (PWR_VOSSR_ACTVOSRDY)) ? 1UL : 0UL);
  1449. }
  1450. #if defined (PWR_VMSR_USB33RDY)
  1451. /**
  1452. * @brief Indicate whether the VDDUSB is below the threshold of monitor or not.
  1453. * @rmtoll VMSR USB33RDY LL_PWR_IsActiveFlag_VDDUSB
  1454. * @retval State of bit (1 or 0).
  1455. */
  1456. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_VDDUSB(void)
  1457. {
  1458. return ((READ_BIT(PWR->VMSR, PWR_VMSR_USB33RDY) == (PWR_VMSR_USB33RDY)) ? 1UL : 0UL);
  1459. }
  1460. #endif /* PWR_VMSR_USB33RDY */
  1461. /**
  1462. * @brief Indicate whether VDDMMC voltage is below 1V2
  1463. * @rmtoll VMSR VDDIO2RDY LL_PWR_IsActiveFlag_VDDIO2
  1464. * @retval State of bit (1 or 0).
  1465. */
  1466. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_VDDIO2(void)
  1467. {
  1468. return ((READ_BIT(PWR->VMCR, PWR_VMSR_VDDIO2RDY) == (PWR_VMSR_VDDIO2RDY)) ? 1UL : 0UL);
  1469. }
  1470. /**
  1471. * @brief Get Backup Regulator ready Flag
  1472. * @rmtoll BDSR BRRDY LL_PWR_IsActiveFlag_BRR
  1473. * @retval State of bit (1 or 0).
  1474. */
  1475. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_BRR(void)
  1476. {
  1477. return ((READ_BIT(PWR->BDSR, PWR_BDSR_BRRDY) == (PWR_BDSR_BRRDY)) ? 1UL : 0UL);
  1478. }
  1479. /**
  1480. * @brief Indicate whether the VBAT level is below high threshold or not.
  1481. * @rmtoll BDSR VBATL LL_PWR_IsActiveFlag_VBATL
  1482. * @retval State of bit (1 or 0).
  1483. */
  1484. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_VBATL(void)
  1485. {
  1486. return ((READ_BIT(PWR->BDSR, PWR_BDSR_VBATL) == (PWR_BDSR_VBATL)) ? 1UL : 0UL);
  1487. }
  1488. /**
  1489. * @brief Indicate whether the VBAT level is below high threshold or not.
  1490. * @rmtoll BDSR VBATH LL_PWR_IsActiveFlag_VBATH
  1491. * @retval State of bit (1 or 0).
  1492. */
  1493. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_VBATH(void)
  1494. {
  1495. return ((READ_BIT(PWR->BDSR, PWR_BDSR_VBATH) == (PWR_BDSR_VBATH)) ? 1UL : 0UL);
  1496. }
  1497. /**
  1498. * @brief Indicate whether the CPU temperature level is above low threshold or
  1499. * not.
  1500. * @rmtoll BDSR TEMPL LL_PWR_IsActiveFlag_TEMPL
  1501. * @retval State of bit (1 or 0).
  1502. */
  1503. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_TEMPL(void)
  1504. {
  1505. return ((READ_BIT(PWR->BDSR, PWR_BDSR_TEMPL) == (PWR_BDSR_TEMPL)) ? 1UL : 0UL);
  1506. }
  1507. /**
  1508. * @brief Indicate whether the CPU temperature level is below high threshold
  1509. * or not.
  1510. * @rmtoll BDSR TEMPH LL_PWR_IsActiveFlag_TEMPH
  1511. * @retval State of bit (1 or 0).
  1512. */
  1513. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_TEMPH(void)
  1514. {
  1515. return ((READ_BIT(PWR->BDSR, PWR_BDSR_TEMPH) == (PWR_BDSR_TEMPH)) ? 1UL : 0UL);
  1516. }
  1517. /**
  1518. * @brief Indicate whether a wakeup event is detected on wake up pin 1.
  1519. * @rmtoll WUSR WUF1 LL_PWR_IsActiveFlag_WU1
  1520. * @retval State of bit (1 or 0).
  1521. */
  1522. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_WU1(void)
  1523. {
  1524. return ((READ_BIT(PWR->WUSR, PWR_WUSR_WUF1) == (PWR_WUSR_WUF1)) ? 1UL : 0UL);
  1525. }
  1526. /**
  1527. * @brief Indicate whether a wakeup event is detected on wake up pin 2.
  1528. * @rmtoll WUSR WUF2 LL_PWR_IsActiveFlag_WU2
  1529. * @retval State of bit (1 or 0).
  1530. */
  1531. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_WU2(void)
  1532. {
  1533. return ((READ_BIT(PWR->WUSR, PWR_WUSR_WUF2) == (PWR_WUSR_WUF2)) ? 1UL : 0UL);
  1534. }
  1535. /**
  1536. * @brief Indicate whether a wakeup event is detected on wake up pin 3.
  1537. * @rmtoll WUSR WUF3 LL_PWR_IsActiveFlag_WU3
  1538. * @retval State of bit (1 or 0).
  1539. */
  1540. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_WU3(void)
  1541. {
  1542. return ((READ_BIT(PWR->WUSR, PWR_WUSR_WUF3) == (PWR_WUSR_WUF3)) ? 1UL : 0UL);
  1543. }
  1544. /**
  1545. * @brief Indicate whether a wakeup event is detected on wake up pin 4.
  1546. * @rmtoll WUSR WUF4 LL_PWR_IsActiveFlag_WU4
  1547. * @retval State of bit (1 or 0).
  1548. */
  1549. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_WU4(void)
  1550. {
  1551. return ((READ_BIT(PWR->WUSR, PWR_WUSR_WUF4) == (PWR_WUSR_WUF4)) ? 1UL : 0UL);
  1552. }
  1553. /**
  1554. * @brief Indicate whether a wakeup event is detected on wake up pin 5.
  1555. * @rmtoll WUSR WUF5 LL_PWR_IsActiveFlag_WU5
  1556. * @retval State of bit (1 or 0).
  1557. */
  1558. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_WU5(void)
  1559. {
  1560. return ((READ_BIT(PWR->WUSR, PWR_WUSR_WUF5) == (PWR_WUSR_WUF5)) ? 1UL : 0UL);
  1561. }
  1562. #if defined (PWR_WUSR_WUF6)
  1563. /**
  1564. * @brief Indicate whether a wakeup event is detected on wake up pin 6.
  1565. * @rmtoll WUSR WUF6 LL_PWR_IsActiveFlag_WU6
  1566. * @retval State of bit (1 or 0).
  1567. */
  1568. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_WU6(void)
  1569. {
  1570. return ((READ_BIT(PWR->WUSR, PWR_WUSR_WUF6) == (PWR_WUSR_WUF6)) ? 1UL : 0UL);
  1571. }
  1572. #endif /* PWR_WUSR_WUF6 */
  1573. #if defined (PWR_WUSR_WUF7)
  1574. /**
  1575. * @brief Indicate whether a wakeup event is detected on wake up pin 7.
  1576. * @rmtoll WUSR WUF7 LL_PWR_IsActiveFlag_WU7
  1577. * @retval State of bit (1 or 0).
  1578. */
  1579. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_WU7(void)
  1580. {
  1581. return ((READ_BIT(PWR->WUSR, PWR_WUSR_WUF7) == (PWR_WUSR_WUF7)) ? 1UL : 0UL);
  1582. }
  1583. #endif /* PWR_WUSR_WUF7 */
  1584. #if defined (PWR_WUSR_WUF8)
  1585. /**
  1586. * @brief Indicate whether a wakeup event is detected on wake up pin 8.
  1587. * @rmtoll WUSR WUF8 LL_PWR_IsActiveFlag_WU8
  1588. * @retval State of bit (1 or 0).
  1589. */
  1590. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_WU8(void)
  1591. {
  1592. return ((READ_BIT(PWR->WUSR, PWR_WUSR_WUF8) == (PWR_WUSR_WUF8)) ? 1UL : 0UL);
  1593. }
  1594. #endif /* PWR_WUSR_WUF8 */
  1595. /**
  1596. * @brief Clear stop flag.
  1597. * @rmtoll PMCR CSSF LL_PWR_ClearFlag_STOP
  1598. * @retval None
  1599. */
  1600. __STATIC_INLINE void LL_PWR_ClearFlag_STOP(void)
  1601. {
  1602. WRITE_REG(PWR->PMCR, PWR_PMCR_CSSF);
  1603. }
  1604. /**
  1605. * @brief Clear standby flag.
  1606. * @rmtoll PMCR CSSF LL_PWR_ClearFlag_SB
  1607. * @retval None
  1608. */
  1609. __STATIC_INLINE void LL_PWR_ClearFlag_SB(void)
  1610. {
  1611. WRITE_REG(PWR->PMCR, PWR_PMCR_CSSF);
  1612. }
  1613. /**
  1614. * @brief Clear wake up flag 1.
  1615. * @rmtoll WUSCR CWUF1 LL_PWR_ClearFlag_WU1
  1616. * @retval None
  1617. */
  1618. __STATIC_INLINE void LL_PWR_ClearFlag_WU1(void)
  1619. {
  1620. WRITE_REG(PWR->WUSCR, PWR_WUSCR_CWUF1);
  1621. }
  1622. /**
  1623. * @brief Clear wake up flag 2.
  1624. * @rmtoll WUSCR CWUF2 LL_PWR_ClearFlag_WU2
  1625. * @retval None
  1626. */
  1627. __STATIC_INLINE void LL_PWR_ClearFlag_WU2(void)
  1628. {
  1629. WRITE_REG(PWR->WUSCR, PWR_WUSCR_CWUF2);
  1630. }
  1631. /**
  1632. * @brief Clear wake up flag 3.
  1633. * @rmtoll WUSCR CWUF3 LL_PWR_ClearFlag_WU3
  1634. * @retval None
  1635. */
  1636. __STATIC_INLINE void LL_PWR_ClearFlag_WU3(void)
  1637. {
  1638. WRITE_REG(PWR->WUSCR, PWR_WUSCR_CWUF3);
  1639. }
  1640. /**
  1641. * @brief Clear wake up flag 4.
  1642. * @rmtoll WUSCR CWUF4 LL_PWR_ClearFlag_WU4
  1643. * @retval None
  1644. */
  1645. __STATIC_INLINE void LL_PWR_ClearFlag_WU4(void)
  1646. {
  1647. WRITE_REG(PWR->WUSCR, PWR_WUSCR_CWUF4);
  1648. }
  1649. /**
  1650. * @brief Clear wake up flag 5.
  1651. * @rmtoll WUSCR CWUF5 LL_PWR_ClearFlag_WU5
  1652. * @retval None
  1653. */
  1654. __STATIC_INLINE void LL_PWR_ClearFlag_WU5(void)
  1655. {
  1656. WRITE_REG(PWR->WUSCR, PWR_WUSCR_CWUF5);
  1657. }
  1658. #if defined (PWR_WUSCR_CWUF6)
  1659. /**
  1660. * @brief Clear wake up flag 6.
  1661. * @rmtoll WUSCR CWUF6 LL_PWR_ClearFlag_WU6
  1662. * @retval None
  1663. */
  1664. __STATIC_INLINE void LL_PWR_ClearFlag_WU6(void)
  1665. {
  1666. WRITE_REG(PWR->WUSCR, PWR_WUSCR_CWUF6);
  1667. }
  1668. #endif /* PWR_WUSCR_CWUF6 */
  1669. #if defined (PWR_WUSCR_CWUF7)
  1670. /**
  1671. * @brief Clear wake up flag 7.
  1672. * @rmtoll WUSCR CWUF7 LL_PWR_ClearFlag_WU7
  1673. * @retval None
  1674. */
  1675. __STATIC_INLINE void LL_PWR_ClearFlag_WU7(void)
  1676. {
  1677. WRITE_REG(PWR->WUSCR, PWR_WUSCR_CWUF7);
  1678. }
  1679. #endif /* PWR_WUSCR_CWUF7 */
  1680. #if defined (PWR_WUSCR_CWUF8)
  1681. /**
  1682. * @brief Clear wake up flag 8.
  1683. * @rmtoll WUSCR CWUF8 LL_PWR_ClearFlag_WU8
  1684. * @retval None
  1685. */
  1686. __STATIC_INLINE void LL_PWR_ClearFlag_WU8(void)
  1687. {
  1688. WRITE_REG(PWR->WUSCR, PWR_WUSCR_CWUF8);
  1689. }
  1690. #endif /* PWR_WUSCR_CWUF8 */
  1691. /**
  1692. * @brief Clear all wake up flags.
  1693. * @rmtoll WUSCR CWUF LL_PWR_ClearFlag_WU
  1694. * @retval None
  1695. */
  1696. __STATIC_INLINE void LL_PWR_ClearFlag_WU(void)
  1697. {
  1698. WRITE_REG(PWR->WUSCR, PWR_WUSCR_CWUF);
  1699. }
  1700. /**
  1701. * @}
  1702. */
  1703. /** @defgroup PWR_LL_EF_ATTRIBUTE_MANAGEMENT PWR Attribute Management
  1704. * @{
  1705. */
  1706. #if defined(PWR_PRIVCFGR_NSPRIV)
  1707. /**
  1708. * @brief Enable privileged mode for nsecure items.
  1709. * @rmtoll PRIVCFGR NSPRIV LL_PWR_EnableNSecurePrivilege
  1710. * @retval None
  1711. */
  1712. __STATIC_INLINE void LL_PWR_EnableNSecurePrivilege(void)
  1713. {
  1714. SET_BIT(PWR->PRIVCFGR, PWR_PRIVCFGR_NSPRIV);
  1715. }
  1716. /**
  1717. * @brief Disable privileged mode for nsecure items.
  1718. * @rmtoll PRIVCFGR NSPRIV LL_PWR_DisableNSecurePrivilege
  1719. * @retval None
  1720. */
  1721. __STATIC_INLINE void LL_PWR_DisableNSecurePrivilege(void)
  1722. {
  1723. CLEAR_BIT(PWR->PRIVCFGR, PWR_PRIVCFGR_NSPRIV);
  1724. }
  1725. /**
  1726. * @brief Check if privileged mode for nsecure items is enabled.
  1727. * @rmtoll PRIVCFGR NSPRIV LL_PWR_IsEnabledNSecurePrivilege
  1728. * @retval State of bit (1 or 0).
  1729. */
  1730. __STATIC_INLINE uint32_t LL_PWR_IsEnabledNSecurePrivilege(void)
  1731. {
  1732. return ((READ_BIT(PWR->PRIVCFGR, PWR_PRIVCFGR_NSPRIV) == PWR_PRIVCFGR_NSPRIV) ? 1UL : 0UL);
  1733. }
  1734. #else
  1735. /**
  1736. * @brief Enable privileged mode for nsecure items.
  1737. * @rmtoll PRIVCFGR NSPRIV LL_PWR_EnableNSecurePrivilege
  1738. * @retval None
  1739. */
  1740. __STATIC_INLINE void LL_PWR_EnableNSecurePrivilege(void)
  1741. {
  1742. SET_BIT(PWR->PRIVCFGR, PWR_PRIVCFGR_PRIV);
  1743. }
  1744. /**
  1745. * @brief Disable privileged mode for nsecure items.
  1746. * @rmtoll PRIVCFGR NSPRIV LL_PWR_DisableNSecurePrivilege
  1747. * @retval None
  1748. */
  1749. __STATIC_INLINE void LL_PWR_DisableNSecurePrivilege(void)
  1750. {
  1751. CLEAR_BIT(PWR->PRIVCFGR, PWR_PRIVCFGR_PRIV);
  1752. }
  1753. /**
  1754. * @brief Check if privileged mode for nsecure items is enabled.
  1755. * @rmtoll PRIVCFGR NSPRIV LL_PWR_IsEnabledNSecurePrivilege
  1756. * @retval State of bit (1 or 0).
  1757. */
  1758. __STATIC_INLINE uint32_t LL_PWR_IsEnabledNSecurePrivilege(void)
  1759. {
  1760. return ((READ_BIT(PWR->PRIVCFGR, PWR_PRIVCFGR_PRIV) == PWR_PRIVCFGR_PRIV) ? 1UL : 0UL);
  1761. }
  1762. #endif /* RCC_PRIVCFGR_NSPRIV */
  1763. #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
  1764. /**
  1765. * @brief Enable privileged mode for secure items.
  1766. * @rmtoll PRIVCFGR SPRIV LL_PWR_EnableSecurePrivilege
  1767. * @retval None
  1768. */
  1769. __STATIC_INLINE void LL_PWR_EnableSecurePrivilege(void)
  1770. {
  1771. SET_BIT(PWR->PRIVCFGR, PWR_PRIVCFGR_SPRIV);
  1772. }
  1773. /**
  1774. * @brief Disable privileged mode for secure items.
  1775. * @rmtoll PRIVCFGR SPRIV LL_PWR_DisableSecurePrivilege
  1776. * @retval None
  1777. */
  1778. __STATIC_INLINE void LL_PWR_DisableSecurePrivilege(void)
  1779. {
  1780. CLEAR_BIT(PWR->PRIVCFGR, PWR_PRIVCFGR_SPRIV);
  1781. }
  1782. #endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */
  1783. #if defined (PWR_PRIVCFGR_SPRIV)
  1784. /**
  1785. * @brief Check if privileged mode for secure items is enabled.
  1786. * @rmtoll PRIVCFGR SPRIV LL_PWR_IsEnabledSecurePrivilege
  1787. * @retval State of bit (1 or 0).
  1788. */
  1789. __STATIC_INLINE uint32_t LL_PWR_IsEnabledSecurePrivilege(void)
  1790. {
  1791. return ((READ_BIT(PWR->PRIVCFGR, PWR_PRIVCFGR_SPRIV) == PWR_PRIVCFGR_SPRIV) ? 1UL : 0UL);
  1792. }
  1793. #endif /* PWR_PRIVCFGR_SPRIV */
  1794. #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
  1795. /**
  1796. * @brief Configure secure attribute mode.
  1797. * @note This API can be executed only by CPU in secure mode.
  1798. * @rmtoll SECCFGR WUP1SEC LL_PWR_ConfigSecure\n
  1799. * SECCFGR WUP2SEC LL_PWR_ConfigSecure\n
  1800. * SECCFGR WUP3SEC LL_PWR_ConfigSecure\n
  1801. * SECCFGR WUP4SEC LL_PWR_ConfigSecure\n
  1802. * SECCFGR WUP5SEC LL_PWR_ConfigSecure\n
  1803. * SECCFGR WUP6SEC LL_PWR_ConfigSecure\n
  1804. * SECCFGR WUP7SEC LL_PWR_ConfigSecure\n
  1805. * SECCFGR WUP8SEC LL_PWR_ConfigSecure\n
  1806. * SECCFGR RETSEC LL_PWR_ConfigSecure\n
  1807. * SECCFGR LPMSEC LL_PWR_ConfigSecure\n
  1808. * SECCFGR VDMSEC LL_PWR_ConfigSecure\n
  1809. * SECCFGR VBSEC LL_PWR_ConfigSecure\n
  1810. * SECCFGR APCSEC LL_PWR_ConfigSecure
  1811. * @param SecureConfig This parameter can be the full combination
  1812. * of the following values:
  1813. * @arg @ref LL_PWR_WAKEUP_PIN1_NSEC or LL_PWR_WAKEUP_PIN1_SEC
  1814. * @arg @ref LL_PWR_WAKEUP_PIN2_NSEC or LL_PWR_WAKEUP_PIN2_SEC
  1815. * @arg @ref LL_PWR_WAKEUP_PIN3_NSEC or LL_PWR_WAKEUP_PIN3_SEC
  1816. * @arg @ref LL_PWR_WAKEUP_PIN4_NSEC or LL_PWR_WAKEUP_PIN4_SEC
  1817. * @arg @ref LL_PWR_WAKEUP_PIN5_NSEC or LL_PWR_WAKEUP_PIN5_SEC
  1818. * @arg @ref LL_PWR_WAKEUP_PIN6_NSEC or LL_PWR_WAKEUP_PIN6_SEC
  1819. * @arg @ref LL_PWR_WAKEUP_PIN7_NSEC or LL_PWR_WAKEUP_PIN7_SEC
  1820. * @arg @ref LL_PWR_WAKEUP_PIN8_NSEC or LL_PWR_WAKEUP_PIN8_SEC
  1821. * @arg @ref LL_PWR_RET_NSEC or LL_PWR_RET_SEC
  1822. * @arg @ref LL_PWR_LPM_NSEC or LL_PWR_LPM_SEC
  1823. * @arg @ref LL_PWR_VDM_NSEC or LL_PWR_VDM_SEC
  1824. * @arg @ref LL_PWR_VB_NSEC or LL_PWR_VB_SEC
  1825. * @arg @ref LL_PWR_APC_NSEC or LL_PWR_APC_SEC
  1826. * @retval None.
  1827. */
  1828. __STATIC_INLINE void LL_PWR_ConfigSecure(uint32_t SecureConfig)
  1829. {
  1830. WRITE_REG(PWR->SECCFGR, SecureConfig);
  1831. }
  1832. /**
  1833. * @brief Get secure attribute configuration.
  1834. * @note This API can be executed only by CPU in secure mode.
  1835. * @rmtoll SECCFGR WUP1SEC LL_PWR_GetConfigSecure\n
  1836. * SECCFGR WUP2SEC LL_PWR_GetConfigSecure\n
  1837. * SECCFGR WUP3SEC LL_PWR_GetConfigSecure\n
  1838. * SECCFGR WUP4SEC LL_PWR_GetConfigSecure\n
  1839. * SECCFGR WUP5SEC LL_PWR_GetConfigSecure\n
  1840. * SECCFGR WUP6SEC LL_PWR_GetConfigSecure\n
  1841. * SECCFGR WUP7SEC LL_PWR_GetConfigSecure\n
  1842. * SECCFGR WUP8SEC LL_PWR_GetConfigSecure\n
  1843. * SECCFGR RETSEC LL_PWR_ConfigSecure\n
  1844. * SECCFGR LPMSEC LL_PWR_GetConfigSecure\n
  1845. * SECCFGR VDMSEC LL_PWR_GetConfigSecure\n
  1846. * SECCFGR VBSEC LL_PWR_GetConfigSecure\n
  1847. * SECCFGR APCSEC LL_PWR_GetConfigSecure
  1848. * @retval Returned value is the combination of the following values:
  1849. * @arg @ref LL_PWR_WAKEUP_PIN1_NSEC or LL_PWR_WAKEUP_PIN1_SEC
  1850. * @arg @ref LL_PWR_WAKEUP_PIN2_NSEC or LL_PWR_WAKEUP_PIN2_SEC
  1851. * @arg @ref LL_PWR_WAKEUP_PIN3_NSEC or LL_PWR_WAKEUP_PIN3_SEC
  1852. * @arg @ref LL_PWR_WAKEUP_PIN4_NSEC or LL_PWR_WAKEUP_PIN4_SEC
  1853. * @arg @ref LL_PWR_WAKEUP_PIN5_NSEC or LL_PWR_WAKEUP_PIN5_SEC
  1854. * @arg @ref LL_PWR_WAKEUP_PIN6_NSEC or LL_PWR_WAKEUP_PIN6_SEC
  1855. * @arg @ref LL_PWR_WAKEUP_PIN7_NSEC or LL_PWR_WAKEUP_PIN7_SEC
  1856. * @arg @ref LL_PWR_WAKEUP_PIN8_NSEC or LL_PWR_WAKEUP_PIN8_SEC
  1857. * @arg @ref LL_PWR_RET_NSEC or LL_PWR_RET_SEC
  1858. * @arg @ref LL_PWR_LPM_NSEC or LL_PWR_LPM_SEC
  1859. * @arg @ref LL_PWR_VDM_NSEC or LL_PWR_VDM_SEC
  1860. * @arg @ref LL_PWR_VB_NSEC or LL_PWR_VB_SEC
  1861. * @arg @ref LL_PWR_APC_NSEC or LL_PWR_APC_SEC
  1862. */
  1863. __STATIC_INLINE uint32_t LL_PWR_GetConfigSecure(void)
  1864. {
  1865. return (READ_REG(PWR->SECCFGR));
  1866. }
  1867. #endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */
  1868. /**
  1869. * @}
  1870. */
  1871. #if defined (USE_FULL_LL_DRIVER)
  1872. /** @defgroup PWR_LL_EF_Init De-initialization function
  1873. * @{
  1874. */
  1875. ErrorStatus LL_PWR_DeInit(void);
  1876. /**
  1877. * @}
  1878. */
  1879. #endif /* defined (USE_FULL_LL_DRIVER) */
  1880. /**
  1881. * @}
  1882. */
  1883. /**
  1884. * @}
  1885. */
  1886. #endif /* defined (PWR) */
  1887. /**
  1888. * @}
  1889. */
  1890. #ifdef __cplusplus
  1891. }
  1892. #endif /* __cplusplus */
  1893. #endif /* STM32H5xx_LL_PWR_H */