stm32l5xx_ll_pwr.h 58 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725
  1. /**
  2. ******************************************************************************
  3. * @file stm32l5xx_ll_pwr.h
  4. * @author MCD Application Team
  5. * @brief Header file of PWR LL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2019 STMicroelectronics.
  10. * All rights reserved.
  11. *
  12. * This software is licensed under terms that can be found in the LICENSE file in
  13. * the root directory of this software component.
  14. * If no LICENSE file comes with this software, it is provided AS-IS.
  15. ******************************************************************************
  16. */
  17. /* Define to prevent recursive inclusion -------------------------------------*/
  18. #ifndef STM32L5xx_LL_PWR_H
  19. #define STM32L5xx_LL_PWR_H
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. /* Includes ------------------------------------------------------------------*/
  24. #include "stm32l5xx.h"
  25. /** @addtogroup STM32L5xx_LL_Driver
  26. * @{
  27. */
  28. #if defined(PWR)
  29. /** @defgroup PWR_LL PWR
  30. * @{
  31. */
  32. /* Private types -------------------------------------------------------------*/
  33. /* Private variables ---------------------------------------------------------*/
  34. /* Private constants ---------------------------------------------------------*/
  35. /* Private macros ------------------------------------------------------------*/
  36. /* Exported types ------------------------------------------------------------*/
  37. /* Exported constants --------------------------------------------------------*/
  38. /** @defgroup PWR_LL_Exported_Constants PWR Exported Constants
  39. * @{
  40. */
  41. /** @defgroup PWR_LL_EC_CLEAR_FLAG Clear Flags Defines
  42. * @brief Flags defines which can be used with LL_PWR_WriteReg function
  43. * @{
  44. */
  45. #define LL_PWR_SCR_CSBF PWR_SCR_CSBF
  46. #define LL_PWR_SCR_CWUF PWR_SCR_CWUF
  47. #define LL_PWR_SCR_CWUF5 PWR_SCR_CWUF5
  48. #define LL_PWR_SCR_CWUF4 PWR_SCR_CWUF4
  49. #define LL_PWR_SCR_CWUF3 PWR_SCR_CWUF3
  50. #define LL_PWR_SCR_CWUF2 PWR_SCR_CWUF2
  51. #define LL_PWR_SCR_CWUF1 PWR_SCR_CWUF1
  52. /**
  53. * @}
  54. */
  55. /** @defgroup PWR_LL_EC_GET_FLAG Get Flags Defines
  56. * @brief Flags defines which can be used with LL_PWR_ReadReg function
  57. * @{
  58. */
  59. #define LL_PWR_SR1_SMSHPRDY PWR_SR1_SMSHPRDY
  60. #define LL_PWR_SR1_EXTSMSRDY PWR_SR1_EXTSMSRDY
  61. #define LL_PWR_SR1_SMSBYPRDY PWR_SR1_SMSBYPRDYY
  62. #define LL_PWR_SR1_SBF PWR_SR1_SBF
  63. #define LL_PWR_SR1_WUF5 PWR_SR1_WUF5
  64. #define LL_PWR_SR1_WUF4 PWR_SR1_WUF4
  65. #define LL_PWR_SR1_WUF3 PWR_SR1_WUF3
  66. #define LL_PWR_SR1_WUF2 PWR_SR1_WUF2
  67. #define LL_PWR_SR1_WUF1 PWR_SR1_WUF1
  68. #define LL_PWR_SR2_PVMO4 PWR_SR2_PVMO4
  69. #define LL_PWR_SR2_PVMO3 PWR_SR2_PVMO3
  70. #define LL_PWR_SR2_PVMO2 PWR_SR2_PVMO2
  71. #define LL_PWR_SR2_PVMO1 PWR_SR2_PVMO1
  72. #define LL_PWR_SR2_PVDO PWR_SR2_PVDO
  73. #define LL_PWR_SR2_VOSF PWR_SR2_VOSF
  74. #define LL_PWR_SR2_REGLPF PWR_SR2_REGLPF
  75. #define LL_PWR_SR2_REGLPS PWR_SR2_REGLPS
  76. /**
  77. * @}
  78. */
  79. /** @defgroup PWR_LL_EC_REGU_VOLTAGE REGU VOLTAGE
  80. * @{
  81. */
  82. #define LL_PWR_REGU_VOLTAGE_SCALE0 0U
  83. #define LL_PWR_REGU_VOLTAGE_SCALE1 (PWR_CR1_VOS_0)
  84. #define LL_PWR_REGU_VOLTAGE_SCALE2 (PWR_CR1_VOS_1)
  85. /**
  86. * @}
  87. */
  88. /** @defgroup PWR_LL_EC_MODE_PWR MODE PWR
  89. * @{
  90. */
  91. #define LL_PWR_MODE_STOP0 (PWR_CR1_LPMS_STOP0)
  92. #define LL_PWR_MODE_STOP1 (PWR_CR1_LPMS_STOP1)
  93. #define LL_PWR_MODE_STOP2 (PWR_CR1_LPMS_STOP2)
  94. #define LL_PWR_MODE_STANDBY (PWR_CR1_LPMS_STANDBY)
  95. #define LL_PWR_MODE_SHUTDOWN (PWR_CR1_LPMS_SHUTDOWN)
  96. /**
  97. * @}
  98. */
  99. /** @defgroup PWR_LL_EC_PVM_VDDUSB_1 Peripheral voltage monitoring
  100. * @{
  101. */
  102. #define LL_PWR_PVM_VDDUSB_1_2V (PWR_CR2_PVME1) /* Monitoring VDDUSB vs. 1.2 V */
  103. #define LL_PWR_PVM_VDDIO2_0_9V (PWR_CR2_PVME2) /* Monitoring VDDIO2 vs. 0.9 V */
  104. #define LL_PWR_PVM_VDDA_1_62V (PWR_CR2_PVME3) /* Monitoring VDDA vs. 1.62 V */
  105. #define LL_PWR_PVM_VDDA_1_8V (PWR_CR2_PVME4) /* Monitoring VDDA vs. 1.8 V */
  106. /**
  107. * @}
  108. */
  109. /** @defgroup PWR_LL_EC_PVDLEVEL PVDLEVEL
  110. * @{
  111. */
  112. #define LL_PWR_PVDLEVEL_0 (PWR_CR2_PLS_LEV0) /* VPVD0 around 2.0 V */
  113. #define LL_PWR_PVDLEVEL_1 (PWR_CR2_PLS_LEV1) /* VPVD1 around 2.2 V */
  114. #define LL_PWR_PVDLEVEL_2 (PWR_CR2_PLS_LEV2) /* VPVD2 around 2.4 V */
  115. #define LL_PWR_PVDLEVEL_3 (PWR_CR2_PLS_LEV3) /* VPVD3 around 2.5 V */
  116. #define LL_PWR_PVDLEVEL_4 (PWR_CR2_PLS_LEV4) /* VPVD4 around 2.6 V */
  117. #define LL_PWR_PVDLEVEL_5 (PWR_CR2_PLS_LEV5) /* VPVD5 around 2.8 V */
  118. #define LL_PWR_PVDLEVEL_6 (PWR_CR2_PLS_LEV6) /* VPVD6 around 2.9 V */
  119. #define LL_PWR_PVDLEVEL_7 (PWR_CR2_PLS_LEV7) /* External input analog voltage (Compare internally to VREFINT) */
  120. /**
  121. * @}
  122. */
  123. /** @defgroup PWR_LL_EC_WAKEUP WAKEUP
  124. * @{
  125. */
  126. #define LL_PWR_WAKEUP_PIN1 (PWR_CR3_EWUP1)
  127. #define LL_PWR_WAKEUP_PIN2 (PWR_CR3_EWUP2)
  128. #define LL_PWR_WAKEUP_PIN3 (PWR_CR3_EWUP3)
  129. #define LL_PWR_WAKEUP_PIN4 (PWR_CR3_EWUP4)
  130. #define LL_PWR_WAKEUP_PIN5 (PWR_CR3_EWUP5)
  131. /**
  132. * @}
  133. */
  134. /** @defgroup PWR_LL_EC_BATT_CHARG_RESISTOR BATT CHARG RESISTOR
  135. * @{
  136. */
  137. #define LL_PWR_BATT_CHARG_RESISTOR_5K (0x00000000U)
  138. #define LL_PWR_BATT_CHARGRESISTOR_1_5K (PWR_CR4_VBRS)
  139. /**
  140. * @}
  141. */
  142. /** @defgroup PWR_LL_EC_GPIO GPIO
  143. * @{
  144. */
  145. #define LL_PWR_GPIO_A ((uint32_t)(&(PWR->PUCRA)))
  146. #define LL_PWR_GPIO_B ((uint32_t)(&(PWR->PUCRB)))
  147. #define LL_PWR_GPIO_C ((uint32_t)(&(PWR->PUCRC)))
  148. #define LL_PWR_GPIO_D ((uint32_t)(&(PWR->PUCRD)))
  149. #define LL_PWR_GPIO_E ((uint32_t)(&(PWR->PUCRE)))
  150. #define LL_PWR_GPIO_F ((uint32_t)(&(PWR->PUCRF)))
  151. #define LL_PWR_GPIO_G ((uint32_t)(&(PWR->PUCRG)))
  152. #define LL_PWR_GPIO_H ((uint32_t)(&(PWR->PUCRH)))
  153. /**
  154. * @}
  155. */
  156. /** @defgroup PWR_LL_EC_GPIO_BIT GPIO BIT
  157. * @{
  158. */
  159. #define LL_PWR_GPIO_BIT_0 (0x00000001U)
  160. #define LL_PWR_GPIO_BIT_1 (0x00000002U)
  161. #define LL_PWR_GPIO_BIT_2 (0x00000004U)
  162. #define LL_PWR_GPIO_BIT_3 (0x00000008U)
  163. #define LL_PWR_GPIO_BIT_4 (0x00000010U)
  164. #define LL_PWR_GPIO_BIT_5 (0x00000020U)
  165. #define LL_PWR_GPIO_BIT_6 (0x00000040U)
  166. #define LL_PWR_GPIO_BIT_7 (0x00000080U)
  167. #define LL_PWR_GPIO_BIT_8 (0x00000100U)
  168. #define LL_PWR_GPIO_BIT_9 (0x00000200U)
  169. #define LL_PWR_GPIO_BIT_10 (0x00000400U)
  170. #define LL_PWR_GPIO_BIT_11 (0x00000800U)
  171. #define LL_PWR_GPIO_BIT_12 (0x00001000U)
  172. #define LL_PWR_GPIO_BIT_13 (0x00002000U)
  173. #define LL_PWR_GPIO_BIT_14 (0x00004000U)
  174. #define LL_PWR_GPIO_BIT_15 (0x00008000U)
  175. /**
  176. * @}
  177. */
  178. /** @defgroup PWR_LL_EC_SRAM2_STANDBY_RETENTION SRAM2 STANDBY RETENTION
  179. * @{
  180. */
  181. #define LL_PWR_SRAM2_NO_RETENTION 0x00000000U
  182. #define LL_PWR_SRAM2_FULL_RETENTION (PWR_CR3_RRS_0)
  183. #define LL_PWR_SRAM2_4KB_RETENTION (PWR_CR3_RRS_1)
  184. /**
  185. * @}
  186. */
  187. #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
  188. /** @defgroup PWR_LL_EC_SECURE_ATTRIBUTES SECURE ATTRIBUTES
  189. * @{
  190. */
  191. #define LL_PWR_WAKEUP_PINS_SEC PWR_SECCFGR_WUPSEC
  192. #define LL_PWR_WAKEUP_PINS_NSEC 0x00000000U
  193. #define LL_PWR_WAKEUP_PIN1_SEC PWR_SECCFGR_WUP1SEC
  194. #define LL_PWR_WAKEUP_PIN1_NSEC 0x00000000U
  195. #define LL_PWR_WAKEUP_PIN2_SEC PWR_SECCFGR_WUP2SEC
  196. #define LL_PWR_WAKEUP_PIN2_NSEC 0x00000000U
  197. #define LL_PWR_WAKEUP_PIN3_SEC PWR_SECCFGR_WUP3SEC
  198. #define LL_PWR_WAKEUP_PIN3_NSEC 0x00000000U
  199. #define LL_PWR_WAKEUP_PIN4_SEC PWR_SECCFGR_WUP4SEC
  200. #define LL_PWR_WAKEUP_PIN4_NSEC 0x00000000U
  201. #define LL_PWR_WAKEUP_PIN5_SEC PWR_SECCFGR_WUP5SEC
  202. #define LL_PWR_WAKEUP_PIN5_NSEC 0x00000000U
  203. #define LL_PWR_LPM_SEC PWR_SECCFGR_LPMSEC
  204. #define LL_PWR_LPM_NSEC 0x00000000U
  205. #define LL_PWR_VDM_SEC PWR_SECCFGR_VDMSEC
  206. #define LL_PWR_VDM_NSEC 0x00000000U
  207. #define LL_PWR_VB_SEC PWR_SECCFGR_VBSEC
  208. #define LL_PWR_VB_NSEC 0x00000000U
  209. #define LL_PWR_APC_SEC PWR_SECCFGR_APCSEC
  210. #define LL_PWR_APC_NSEC 0x00000000U
  211. /**
  212. * @}
  213. */
  214. #endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */
  215. /**
  216. * @}
  217. */
  218. /* Exported macro ------------------------------------------------------------*/
  219. /** @defgroup PWR_LL_Exported_Macros PWR Exported Macros
  220. * @{
  221. */
  222. /** @defgroup PWR_LL_EM_WRITE_READ Common Write and read registers Macros
  223. * @{
  224. */
  225. /**
  226. * @brief Write a value in PWR register
  227. * @param __REG__ Register to be written
  228. * @param __VALUE__ Value to be written in the register
  229. * @retval None
  230. */
  231. #define LL_PWR_WriteReg(__REG__, __VALUE__) WRITE_REG(PWR->__REG__, (__VALUE__))
  232. /**
  233. * @brief Read a value in PWR register
  234. * @param __REG__ Register to be read
  235. * @retval Register value
  236. */
  237. #define LL_PWR_ReadReg(__REG__) READ_REG(PWR->__REG__)
  238. /**
  239. * @}
  240. */
  241. /**
  242. * @}
  243. */
  244. /* Exported functions --------------------------------------------------------*/
  245. /** @defgroup PWR_LL_Exported_Functions PWR Exported Functions
  246. * @{
  247. */
  248. /** @defgroup PWR_LL_EF_Configuration Configuration
  249. * @{
  250. */
  251. /**
  252. * @brief Switch the regulator from main mode to low-power mode
  253. * @rmtoll CR1 LPR LL_PWR_EnableLowPowerRunMode
  254. * @retval None
  255. */
  256. __STATIC_INLINE void LL_PWR_EnableLowPowerRunMode(void)
  257. {
  258. SET_BIT(PWR->CR1, PWR_CR1_LPR);
  259. }
  260. /**
  261. * @brief Switch the regulator from low-power mode to main mode
  262. * @rmtoll CR1 LPR LL_PWR_DisableLowPowerRunMode
  263. * @retval None
  264. */
  265. __STATIC_INLINE void LL_PWR_DisableLowPowerRunMode(void)
  266. {
  267. CLEAR_BIT(PWR->CR1, PWR_CR1_LPR);
  268. }
  269. /**
  270. * @brief Check if the regulator is in low-power mode
  271. * @rmtoll CR1 LPR LL_PWR_IsEnabledLowPowerRunMode
  272. * @retval State of bit (1 or 0).
  273. */
  274. __STATIC_INLINE uint32_t LL_PWR_IsEnabledLowPowerRunMode(void)
  275. {
  276. return ((READ_BIT(PWR->CR1, PWR_CR1_LPR) == (PWR_CR1_LPR)) ? 1UL : 0UL);
  277. }
  278. /**
  279. * @brief Switch from run main mode to run low-power mode.
  280. * @rmtoll CR1 LPR LL_PWR_EnterLowPowerRunMode
  281. * @retval None
  282. */
  283. __STATIC_INLINE void LL_PWR_EnterLowPowerRunMode(void)
  284. {
  285. LL_PWR_EnableLowPowerRunMode();
  286. }
  287. /**
  288. * @brief Switch from run main mode to low-power mode.
  289. * @rmtoll CR1 LPR LL_PWR_ExitLowPowerRunMode
  290. * @retval None
  291. */
  292. __STATIC_INLINE void LL_PWR_ExitLowPowerRunMode(void)
  293. {
  294. LL_PWR_DisableLowPowerRunMode();
  295. }
  296. /**
  297. * @brief Set the main internal regulator output voltage
  298. * @rmtoll CR1 VOS LL_PWR_SetRegulVoltageScaling
  299. * @param VoltageScaling This parameter can be one of the following values:
  300. * @arg @ref LL_PWR_REGU_VOLTAGE_SCALE0
  301. * @arg @ref LL_PWR_REGU_VOLTAGE_SCALE1
  302. * @arg @ref LL_PWR_REGU_VOLTAGE_SCALE2
  303. * @retval None
  304. */
  305. __STATIC_INLINE void LL_PWR_SetRegulVoltageScaling(uint32_t VoltageScaling)
  306. {
  307. MODIFY_REG(PWR->CR1, PWR_CR1_VOS, VoltageScaling);
  308. }
  309. /**
  310. * @brief Get the main internal regulator output voltage
  311. * @rmtoll CR1 VOS LL_PWR_GetRegulVoltageScaling
  312. * @retval Returned value can be one of the following values:
  313. * @arg @ref LL_PWR_REGU_VOLTAGE_SCALE0
  314. * @arg @ref LL_PWR_REGU_VOLTAGE_SCALE1
  315. * @arg @ref LL_PWR_REGU_VOLTAGE_SCALE2
  316. */
  317. __STATIC_INLINE uint32_t LL_PWR_GetRegulVoltageScaling(void)
  318. {
  319. return (uint32_t)(READ_BIT(PWR->CR1, PWR_CR1_VOS));
  320. }
  321. /**
  322. * @brief Enable access to the backup domain
  323. * @rmtoll CR1 DBP LL_PWR_EnableBkUpAccess
  324. * @retval None
  325. */
  326. __STATIC_INLINE void LL_PWR_EnableBkUpAccess(void)
  327. {
  328. SET_BIT(PWR->CR1, PWR_CR1_DBP);
  329. }
  330. /**
  331. * @brief Disable access to the backup domain
  332. * @rmtoll CR1 DBP LL_PWR_DisableBkUpAccess
  333. * @retval None
  334. */
  335. __STATIC_INLINE void LL_PWR_DisableBkUpAccess(void)
  336. {
  337. CLEAR_BIT(PWR->CR1, PWR_CR1_DBP);
  338. }
  339. /**
  340. * @brief Check if the backup domain is enabled
  341. * @rmtoll CR1 DBP LL_PWR_IsEnabledBkUpAccess
  342. * @retval State of bit (1 or 0).
  343. */
  344. __STATIC_INLINE uint32_t LL_PWR_IsEnabledBkUpAccess(void)
  345. {
  346. return ((READ_BIT(PWR->CR1, PWR_CR1_DBP) == (PWR_CR1_DBP)) ? 1UL : 0UL);
  347. }
  348. /**
  349. * @brief Set Low-Power mode
  350. * @rmtoll CR1 LPMS LL_PWR_SetPowerMode
  351. * @param LowPowerMode This parameter can be one of the following values:
  352. * @arg @ref LL_PWR_MODE_STOP0
  353. * @arg @ref LL_PWR_MODE_STOP1
  354. * @arg @ref LL_PWR_MODE_STOP2
  355. * @arg @ref LL_PWR_MODE_STANDBY
  356. * @arg @ref LL_PWR_MODE_SHUTDOWN
  357. * @retval None
  358. */
  359. __STATIC_INLINE void LL_PWR_SetPowerMode(uint32_t LowPowerMode)
  360. {
  361. MODIFY_REG(PWR->CR1, PWR_CR1_LPMS, LowPowerMode);
  362. }
  363. /**
  364. * @brief Get Low-Power mode
  365. * @rmtoll CR1 LPMS LL_PWR_GetPowerMode
  366. * @retval Returned value can be one of the following values:
  367. * @arg @ref LL_PWR_MODE_STOP0
  368. * @arg @ref LL_PWR_MODE_STOP1
  369. * @arg @ref LL_PWR_MODE_STOP2
  370. * @arg @ref LL_PWR_MODE_STANDBY
  371. * @arg @ref LL_PWR_MODE_SHUTDOWN
  372. */
  373. __STATIC_INLINE uint32_t LL_PWR_GetPowerMode(void)
  374. {
  375. return (uint32_t)(READ_BIT(PWR->CR1, PWR_CR1_LPMS));
  376. }
  377. /**
  378. * @brief Enable the USB Type-C and Power Delivery memorization in Standby mode.
  379. * @note This function must be called just before entering Standby mode.
  380. * @rmtoll CR3 UCPD_STDBY LL_PWR_EnableUCPDStandbyMode
  381. * @retval None
  382. */
  383. __STATIC_INLINE void LL_PWR_EnableUCPDStandbyMode(void)
  384. {
  385. SET_BIT(PWR->CR3, PWR_CR3_UCPD_STDBY);
  386. }
  387. /**
  388. * @brief Disable the USB Type-C and Power Delivery memorization in Standby mode.
  389. * @note This function must be called after exiting Standby mode and before any
  390. * UCPD configuration update.
  391. * @rmtoll CR3 UCPD_STDBY LL_PWR_DisableUCPDStandbyMode
  392. * @retval None
  393. */
  394. __STATIC_INLINE void LL_PWR_DisableUCPDStandbyMode(void)
  395. {
  396. CLEAR_BIT(PWR->CR3, PWR_CR3_UCPD_STDBY);
  397. }
  398. /**
  399. * @brief Check the USB Type-C and Power Delivery Standby mode memorization state.
  400. * @rmtoll CR3 UCPD_STDBY LL_PWR_IsEnabledUCPDStandbyMode
  401. * @retval State of bit (1 or 0).
  402. */
  403. __STATIC_INLINE uint32_t LL_PWR_IsEnabledUCPDStandbyMode(void)
  404. {
  405. return ((READ_BIT(PWR->CR3, PWR_CR3_UCPD_STDBY) == (PWR_CR3_UCPD_STDBY)) ? 1UL : 0UL);
  406. }
  407. /**
  408. * @brief Enable the USB Type-C and power delivery dead battery pull-down behavior
  409. * on UCPD CC1 and CC2 pins.
  410. * @note After exiting reset, the USB Type-C dead battery behavior is enabled,
  411. * which may have a pull-down effect on CC1 and CC2 pins. It is recommended
  412. * to disable it in all cases, either to stop this pull-down or to hand over
  413. * control to the UCPD (which should therefore be initialized before doing the disable).
  414. * @rmtoll CR3 UCPD_DBDIS LL_PWR_EnableUCPDDeadBattery
  415. * @retval None
  416. */
  417. __STATIC_INLINE void LL_PWR_EnableUCPDDeadBattery(void)
  418. {
  419. CLEAR_BIT(PWR->CR3, PWR_CR3_UCPD_DBDIS);
  420. }
  421. /**
  422. * @brief Disable the USB Type-C and power delivery dead battery pull-down behavior
  423. * on UCPD CC1 and CC2 pins.
  424. * @note After exiting reset, the USB Type-C dead battery behavior is enabled,
  425. * which may have a pull-down effect on CC1 and CC2 pins. It is recommended
  426. * to disable it in all cases, either to stop this pull-down or to hand over
  427. * control to the UCPD (which should therefore be initialized before doing the disable).
  428. * @rmtoll CR3 UCPD_DBDIS LL_PWR_DisableUCPDDeadBattery
  429. * @retval None
  430. */
  431. __STATIC_INLINE void LL_PWR_DisableUCPDDeadBattery(void)
  432. {
  433. SET_BIT(PWR->CR3, PWR_CR3_UCPD_DBDIS);
  434. }
  435. /**
  436. * @brief Check the USB Type-C and power delivery dead battery pull-down behavior
  437. * on UCPD CC1 and CC2 pins.
  438. * @note After exiting reset, the USB Type-C dead battery behavior is enabled,
  439. * which may have a pull-down effect on CC1 and CC2 pins. It is recommended
  440. * to disable it in all cases, either to stop this pull-down or to hand over
  441. * control to the UCPD (which should therefore be initialized before doing the disable).
  442. * @rmtoll CR3 UCPD_DBDIS LL_PWR_IsEnabledUCPDDeadBattery
  443. * @retval State of feature (1 : enabled; 0 : disabled).
  444. */
  445. __STATIC_INLINE uint32_t LL_PWR_IsEnabledUCPDDeadBattery(void)
  446. {
  447. return ((READ_BIT(PWR->CR3, PWR_CR3_UCPD_DBDIS) == (PWR_CR3_UCPD_DBDIS)) ? 0UL : 1UL);
  448. }
  449. /**
  450. * @brief Enable VDDUSB supply
  451. * @rmtoll CR2 USV LL_PWR_EnableVddUSB
  452. * @retval None
  453. */
  454. __STATIC_INLINE void LL_PWR_EnableVddUSB(void)
  455. {
  456. SET_BIT(PWR->CR2, PWR_CR2_USV);
  457. }
  458. /**
  459. * @brief Disable VDDUSB supply
  460. * @rmtoll CR2 USV LL_PWR_DisableVddUSB
  461. * @retval None
  462. */
  463. __STATIC_INLINE void LL_PWR_DisableVddUSB(void)
  464. {
  465. CLEAR_BIT(PWR->CR2, PWR_CR2_USV);
  466. }
  467. /**
  468. * @brief Check if VDDUSB supply is enabled
  469. * @rmtoll CR2 USV LL_PWR_IsEnabledVddUSB
  470. * @retval State of bit (1 or 0).
  471. */
  472. __STATIC_INLINE uint32_t LL_PWR_IsEnabledVddUSB(void)
  473. {
  474. return ((READ_BIT(PWR->CR2, PWR_CR2_USV) == (PWR_CR2_USV)) ? 1UL : 0UL);
  475. }
  476. /**
  477. * @brief Enable VDDIO2 supply
  478. * @rmtoll CR2 IOSV LL_PWR_EnableVddIO2
  479. * @retval None
  480. */
  481. __STATIC_INLINE void LL_PWR_EnableVddIO2(void)
  482. {
  483. SET_BIT(PWR->CR2, PWR_CR2_IOSV);
  484. }
  485. /**
  486. * @brief Disable VDDIO2 supply
  487. * @rmtoll CR2 IOSV LL_PWR_DisableVddIO2
  488. * @retval None
  489. */
  490. __STATIC_INLINE void LL_PWR_DisableVddIO2(void)
  491. {
  492. CLEAR_BIT(PWR->CR2, PWR_CR2_IOSV);
  493. }
  494. /**
  495. * @brief Check if VDDIO2 supply is enabled
  496. * @rmtoll CR2 IOSV LL_PWR_IsEnabledVddIO2
  497. * @retval State of bit (1 or 0).
  498. */
  499. __STATIC_INLINE uint32_t LL_PWR_IsEnabledVddIO2(void)
  500. {
  501. return ((READ_BIT(PWR->CR2, PWR_CR2_IOSV) == (PWR_CR2_IOSV)) ? 1UL : 0UL);
  502. }
  503. /**
  504. * @brief Enable the Power Voltage Monitoring on a peripheral
  505. * @rmtoll CR2 PVME1 LL_PWR_EnablePVM\n
  506. * CR2 PVME2 LL_PWR_EnablePVM\n
  507. * CR2 PVME3 LL_PWR_EnablePVM\n
  508. * CR2 PVME4 LL_PWR_EnablePVM
  509. * @param PeriphVoltage This parameter can be one of the following values:
  510. * @arg @ref LL_PWR_PVM_VDDUSB_1_2V
  511. * @arg @ref LL_PWR_PVM_VDDIO2_0_9V
  512. * @arg @ref LL_PWR_PVM_VDDA_1_62V
  513. * @arg @ref LL_PWR_PVM_VDDA_1_8V
  514. * @retval None
  515. */
  516. __STATIC_INLINE void LL_PWR_EnablePVM(uint32_t PeriphVoltage)
  517. {
  518. SET_BIT(PWR->CR2, PeriphVoltage);
  519. }
  520. /**
  521. * @brief Disable the Power Voltage Monitoring on a peripheral
  522. * @rmtoll CR2 PVME1 LL_PWR_DisablePVM\n
  523. * CR2 PVME2 LL_PWR_DisablePVM\n
  524. * CR2 PVME3 LL_PWR_DisablePVM\n
  525. * CR2 PVME4 LL_PWR_DisablePVM
  526. * @param PeriphVoltage This parameter can be one of the following values:
  527. * @arg @ref LL_PWR_PVM_VDDUSB_1_2V
  528. * @arg @ref LL_PWR_PVM_VDDIO2_0_9V
  529. * @arg @ref LL_PWR_PVM_VDDA_1_62V
  530. * @arg @ref LL_PWR_PVM_VDDA_1_8V
  531. * @retval None
  532. */
  533. __STATIC_INLINE void LL_PWR_DisablePVM(uint32_t PeriphVoltage)
  534. {
  535. CLEAR_BIT(PWR->CR2, PeriphVoltage);
  536. }
  537. /**
  538. * @brief Check if Power Voltage Monitoring is enabled on a peripheral
  539. * @rmtoll CR2 PVME1 LL_PWR_IsEnabledPVM\n
  540. * CR2 PVME2 LL_PWR_IsEnabledPVM\n
  541. * CR2 PVME3 LL_PWR_IsEnabledPVM\n
  542. * CR2 PVME4 LL_PWR_IsEnabledPVM
  543. * @param PeriphVoltage This parameter can be one of the following values:
  544. * @arg @ref LL_PWR_PVM_VDDUSB_1_2V
  545. * @arg @ref LL_PWR_PVM_VDDIO2_0_9V
  546. * @arg @ref LL_PWR_PVM_VDDA_1_62V
  547. * @arg @ref LL_PWR_PVM_VDDA_1_8V
  548. * @retval State of bit (1 or 0).
  549. */
  550. __STATIC_INLINE uint32_t LL_PWR_IsEnabledPVM(uint32_t PeriphVoltage)
  551. {
  552. return ((READ_BIT(PWR->CR2, PeriphVoltage) == (PeriphVoltage)) ? 1UL : 0UL);
  553. }
  554. /**
  555. * @brief Configure the voltage threshold detected by the Power Voltage Detector
  556. * @rmtoll CR2 PLS LL_PWR_SetPVDLevel
  557. * @param PVDLevel This parameter can be one of the following values:
  558. * @arg @ref LL_PWR_PVDLEVEL_0
  559. * @arg @ref LL_PWR_PVDLEVEL_1
  560. * @arg @ref LL_PWR_PVDLEVEL_2
  561. * @arg @ref LL_PWR_PVDLEVEL_3
  562. * @arg @ref LL_PWR_PVDLEVEL_4
  563. * @arg @ref LL_PWR_PVDLEVEL_5
  564. * @arg @ref LL_PWR_PVDLEVEL_6
  565. * @arg @ref LL_PWR_PVDLEVEL_7
  566. * @retval None
  567. */
  568. __STATIC_INLINE void LL_PWR_SetPVDLevel(uint32_t PVDLevel)
  569. {
  570. MODIFY_REG(PWR->CR2, PWR_CR2_PLS, PVDLevel);
  571. }
  572. /**
  573. * @brief Get the voltage threshold detection
  574. * @rmtoll CR2 PLS LL_PWR_GetPVDLevel
  575. * @retval Returned value can be one of the following values:
  576. * @arg @ref LL_PWR_PVDLEVEL_0
  577. * @arg @ref LL_PWR_PVDLEVEL_1
  578. * @arg @ref LL_PWR_PVDLEVEL_2
  579. * @arg @ref LL_PWR_PVDLEVEL_3
  580. * @arg @ref LL_PWR_PVDLEVEL_4
  581. * @arg @ref LL_PWR_PVDLEVEL_5
  582. * @arg @ref LL_PWR_PVDLEVEL_6
  583. * @arg @ref LL_PWR_PVDLEVEL_7
  584. */
  585. __STATIC_INLINE uint32_t LL_PWR_GetPVDLevel(void)
  586. {
  587. return (uint32_t)(READ_BIT(PWR->CR2, PWR_CR2_PLS));
  588. }
  589. /**
  590. * @brief Enable Power Voltage Detector
  591. * @rmtoll CR2 PVDE LL_PWR_EnablePVD
  592. * @retval None
  593. */
  594. __STATIC_INLINE void LL_PWR_EnablePVD(void)
  595. {
  596. SET_BIT(PWR->CR2, PWR_CR2_PVDE);
  597. }
  598. /**
  599. * @brief Disable Power Voltage Detector
  600. * @rmtoll CR2 PVDE LL_PWR_DisablePVD
  601. * @retval None
  602. */
  603. __STATIC_INLINE void LL_PWR_DisablePVD(void)
  604. {
  605. CLEAR_BIT(PWR->CR2, PWR_CR2_PVDE);
  606. }
  607. /**
  608. * @brief Check if Power Voltage Detector is enabled
  609. * @rmtoll CR2 PVDE LL_PWR_IsEnabledPVD
  610. * @retval State of bit (1 or 0).
  611. */
  612. __STATIC_INLINE uint32_t LL_PWR_IsEnabledPVD(void)
  613. {
  614. return ((READ_BIT(PWR->CR2, PWR_CR2_PVDE) == (PWR_CR2_PVDE)) ? 1UL : 0UL);
  615. }
  616. /**
  617. * @brief Enable SMPS low-power mode
  618. * @rmtoll CR4 SMPSLPEN LL_PWR_EnableSMPSLowPowerMode
  619. * @retval None
  620. */
  621. __STATIC_INLINE void LL_PWR_EnableSMPSLowPowerMode(void)
  622. {
  623. SET_BIT(PWR->CR4, PWR_CR4_SMPSLPEN);
  624. }
  625. /**
  626. * @brief Disable SMPS low-power mode
  627. * @rmtoll CR4 SMPSLPEN LL_PWR_DisableSMPSLowPowerMode
  628. * @retval None
  629. */
  630. __STATIC_INLINE void LL_PWR_DisableSMPSLowPowerMode(void)
  631. {
  632. CLEAR_BIT(PWR->CR4, PWR_CR4_SMPSLPEN);
  633. }
  634. /**
  635. * @brief Check if SMPS low-power mode is enabled
  636. * @rmtoll CR4 SMPSLPEN LL_PWR_IsEnabledSMPSLowPowerMode
  637. * @retval State of bit (1 or 0).
  638. */
  639. __STATIC_INLINE uint32_t LL_PWR_IsEnabledSMPSLowPowerMode(void)
  640. {
  641. return ((READ_BIT(PWR->CR4, PWR_CR4_SMPSLPEN) == (PWR_CR4_SMPSLPEN)) ? 1UL : 0UL);
  642. }
  643. /**
  644. * @brief Enable SMPS fast start
  645. * @rmtoll CR4 SMPSFSTEN LL_PWR_EnableSMPSFastStart
  646. * @retval None
  647. */
  648. __STATIC_INLINE void LL_PWR_EnableSMPSFastStart(void)
  649. {
  650. SET_BIT(PWR->CR4, PWR_CR4_SMPSFSTEN);
  651. }
  652. /**
  653. * @brief Disable SMPS fast start
  654. * @rmtoll CR4 SMPSFSTEN LL_PWR_DisableSMPSFastStart
  655. * @retval None
  656. */
  657. __STATIC_INLINE void LL_PWR_DisableSMPSFastStart(void)
  658. {
  659. CLEAR_BIT(PWR->CR4, PWR_CR4_SMPSFSTEN);
  660. }
  661. /**
  662. * @brief Check if SMPS fast start is enabled
  663. * @rmtoll CR4 SMPSFSTEN LL_PWR_IsEnabledSMPSFastStart
  664. * @retval State of bit (1 or 0).
  665. */
  666. __STATIC_INLINE uint32_t LL_PWR_IsEnabledSMPSFastStart(void)
  667. {
  668. return ((READ_BIT(PWR->CR4, PWR_CR4_SMPSFSTEN) == (PWR_CR4_SMPSFSTEN)) ? 1UL : 0UL);
  669. }
  670. /**
  671. * @brief Enable SMPS bypass mode
  672. * @rmtoll CR4 SMPSBYP LL_PWR_EnableSMPSBypassMode
  673. * @retval None
  674. */
  675. __STATIC_INLINE void LL_PWR_EnableSMPSBypassMode(void)
  676. {
  677. SET_BIT(PWR->CR4, PWR_CR4_SMPSBYP);
  678. }
  679. /**
  680. * @brief Disable SMPS bypass mode
  681. * @rmtoll CR4 SMPSBYP LL_PWR_DisableSMPSBypassMode
  682. * @retval None
  683. */
  684. __STATIC_INLINE void LL_PWR_DisableSMPSBypassMode(void)
  685. {
  686. CLEAR_BIT(PWR->CR4, PWR_CR4_SMPSBYP);
  687. }
  688. /**
  689. * @brief Check if SMPS bypass mode is enabled
  690. * @rmtoll CR4 SMPSBYP LL_PWR_IsEnabledSMPSBypassMode
  691. * @retval State of bit (1 or 0).
  692. */
  693. __STATIC_INLINE uint32_t LL_PWR_IsEnabledSMPSBypassMode(void)
  694. {
  695. return ((READ_BIT(PWR->CR4, PWR_CR4_SMPSBYP) == (PWR_CR4_SMPSBYP)) ? 1UL : 0UL);
  696. }
  697. /**
  698. * @brief Enable external SMPS
  699. * @rmtoll CR4 EXTSMPSEN LL_PWR_EnableExtSMPS
  700. * @retval None
  701. */
  702. __STATIC_INLINE void LL_PWR_EnableExtSMPS(void)
  703. {
  704. SET_BIT(PWR->CR4, PWR_CR4_EXTSMPSEN);
  705. }
  706. /**
  707. * @brief Disable external SMPS
  708. * @rmtoll CR4 EXTSMPSEN LL_PWR_DisableExtSMPS
  709. * @retval None
  710. */
  711. __STATIC_INLINE void LL_PWR_DisableExtSMPS(void)
  712. {
  713. CLEAR_BIT(PWR->CR4, PWR_CR4_EXTSMPSEN);
  714. }
  715. /**
  716. * @brief Check if external SMPS is enabled
  717. * @rmtoll CR4 EXTSMPSEN LL_PWR_IsEnabledExtSMPS
  718. * @retval State of bit (1 or 0).
  719. */
  720. __STATIC_INLINE uint32_t LL_PWR_IsEnabledExtSMPS(void)
  721. {
  722. return ((READ_BIT(PWR->CR4, PWR_CR4_EXTSMPSEN) == (PWR_CR4_EXTSMPSEN)) ? 1UL : 0UL);
  723. }
  724. /**
  725. * @brief Enable ultra low-power mode
  726. * @rmtoll CR3 UPLMEN LL_PWR_EnableUltraLowPowerMode
  727. * @retval None
  728. */
  729. __STATIC_INLINE void LL_PWR_EnableUltraLowPowerMode(void)
  730. {
  731. SET_BIT(PWR->CR3, PWR_CR3_ULPMEN);
  732. }
  733. /**
  734. * @brief Disable ultra low-power mode
  735. * @rmtoll CR3 UPLMEN LL_PWR_DisableUltraLowPowerMode
  736. * @retval None
  737. */
  738. __STATIC_INLINE void LL_PWR_DisableUltraLowPowerMode(void)
  739. {
  740. CLEAR_BIT(PWR->CR3, PWR_CR3_ULPMEN);
  741. }
  742. /**
  743. * @brief Check if ultra low-power mode is enabled
  744. * @rmtoll CR3 UPLMEN LL_PWR_IsEnabledUltraLowPowerMode
  745. * @retval State of bit (1 or 0).
  746. */
  747. __STATIC_INLINE uint32_t LL_PWR_IsEnabledUltraLowPowerMode(void)
  748. {
  749. return ((READ_BIT(PWR->CR3, PWR_CR3_ULPMEN) == (PWR_CR3_ULPMEN)) ? 1UL : 0UL);
  750. }
  751. /**
  752. * @brief Enable pull-up and pull-down configuration
  753. * @rmtoll CR3 APC LL_PWR_EnablePUPDCfg
  754. * @retval None
  755. */
  756. __STATIC_INLINE void LL_PWR_EnablePUPDCfg(void)
  757. {
  758. SET_BIT(PWR->CR3, PWR_CR3_APC);
  759. }
  760. /**
  761. * @brief Disable pull-up and pull-down configuration
  762. * @rmtoll CR3 APC LL_PWR_DisablePUPDCfg
  763. * @retval None
  764. */
  765. __STATIC_INLINE void LL_PWR_DisablePUPDCfg(void)
  766. {
  767. CLEAR_BIT(PWR->CR3, PWR_CR3_APC);
  768. }
  769. /**
  770. * @brief Check if pull-up and pull-down configuration is enabled
  771. * @rmtoll CR3 APC LL_PWR_IsEnabledPUPDCfg
  772. * @retval State of bit (1 or 0).
  773. */
  774. __STATIC_INLINE uint32_t LL_PWR_IsEnabledPUPDCfg(void)
  775. {
  776. return ((READ_BIT(PWR->CR3, PWR_CR3_APC) == (PWR_CR3_APC)) ? 1UL : 0UL);
  777. }
  778. /**
  779. * @brief Set the SRAM2 retention in Standby mode
  780. * @rmtoll CR3 RRS LL_PWR_SetSRAM2Retention
  781. * @param SRAM2Retention This parameter can be one of the following values:
  782. * @arg @ref LL_PWR_SRAM2_NO_RETENTION
  783. * @arg @ref LL_PWR_SRAM2_FULL_RETENTION
  784. * @arg @ref LL_PWR_SRAM2_4KB_RETENTION
  785. * @retval None
  786. */
  787. __STATIC_INLINE void LL_PWR_SetSRAM2Retention(uint32_t SRAM2Retention)
  788. {
  789. MODIFY_REG(PWR->CR3, PWR_CR3_RRS, SRAM2Retention);
  790. }
  791. /**
  792. * @brief Get the SRAM2 retention in Standby mode
  793. * @rmtoll CR3 RRS LL_PWR_GetSRAM2Retention
  794. * @retval Returned value can be one of the following values:
  795. * @arg @ref LL_PWR_SRAM2_NO_RETENTION
  796. * @arg @ref LL_PWR_SRAM2_FULL_RETENTION
  797. * @arg @ref LL_PWR_SRAM2_4KB_RETENTION
  798. */
  799. __STATIC_INLINE uint32_t LL_PWR_GetSRAM2Retention(void)
  800. {
  801. return (uint32_t)(READ_BIT(PWR->CR3, PWR_CR3_RRS));
  802. }
  803. /**
  804. * @brief Enable the WakeUp PINx functionality
  805. * @rmtoll CR3 EWUP1 LL_PWR_EnableWakeUpPin\n
  806. * CR3 EWUP2 LL_PWR_EnableWakeUpPin\n
  807. * CR3 EWUP3 LL_PWR_EnableWakeUpPin\n
  808. * CR3 EWUP4 LL_PWR_EnableWakeUpPin\n
  809. * CR3 EWUP5 LL_PWR_EnableWakeUpPin\n
  810. * @param WakeUpPin This parameter can be one of the following values:
  811. * @arg @ref LL_PWR_WAKEUP_PIN1
  812. * @arg @ref LL_PWR_WAKEUP_PIN2
  813. * @arg @ref LL_PWR_WAKEUP_PIN3
  814. * @arg @ref LL_PWR_WAKEUP_PIN4
  815. * @arg @ref LL_PWR_WAKEUP_PIN5
  816. * @retval None
  817. */
  818. __STATIC_INLINE void LL_PWR_EnableWakeUpPin(uint32_t WakeUpPin)
  819. {
  820. SET_BIT(PWR->CR3, WakeUpPin);
  821. }
  822. /**
  823. * @brief Disable the WakeUp PINx functionality
  824. * @rmtoll CR3 EWUP1 LL_PWR_DisableWakeUpPin\n
  825. * CR3 EWUP2 LL_PWR_DisableWakeUpPin\n
  826. * CR3 EWUP3 LL_PWR_DisableWakeUpPin\n
  827. * CR3 EWUP4 LL_PWR_DisableWakeUpPin\n
  828. * CR3 EWUP5 LL_PWR_DisableWakeUpPin\n
  829. * @param WakeUpPin This parameter can be one of the following values:
  830. * @arg @ref LL_PWR_WAKEUP_PIN1
  831. * @arg @ref LL_PWR_WAKEUP_PIN2
  832. * @arg @ref LL_PWR_WAKEUP_PIN3
  833. * @arg @ref LL_PWR_WAKEUP_PIN4
  834. * @arg @ref LL_PWR_WAKEUP_PIN5
  835. * @retval None
  836. */
  837. __STATIC_INLINE void LL_PWR_DisableWakeUpPin(uint32_t WakeUpPin)
  838. {
  839. CLEAR_BIT(PWR->CR3, WakeUpPin);
  840. }
  841. /**
  842. * @brief Check if the WakeUp PINx functionality is enabled
  843. * @rmtoll CR3 EWUP1 LL_PWR_IsEnabledWakeUpPin\n
  844. * CR3 EWUP2 LL_PWR_IsEnabledWakeUpPin\n
  845. * CR3 EWUP3 LL_PWR_IsEnabledWakeUpPin\n
  846. * CR3 EWUP4 LL_PWR_IsEnabledWakeUpPin\n
  847. * CR3 EWUP5 LL_PWR_IsEnabledWakeUpPin\n
  848. * @param WakeUpPin This parameter can be one of the following values:
  849. * @arg @ref LL_PWR_WAKEUP_PIN1
  850. * @arg @ref LL_PWR_WAKEUP_PIN2
  851. * @arg @ref LL_PWR_WAKEUP_PIN3
  852. * @arg @ref LL_PWR_WAKEUP_PIN4
  853. * @arg @ref LL_PWR_WAKEUP_PIN5
  854. * @retval State of bit (1 or 0).
  855. */
  856. __STATIC_INLINE uint32_t LL_PWR_IsEnabledWakeUpPin(uint32_t WakeUpPin)
  857. {
  858. return ((READ_BIT(PWR->CR3, WakeUpPin) == (WakeUpPin)) ? 1UL : 0UL);
  859. }
  860. /**
  861. * @brief Set the resistor impedance
  862. * @rmtoll CR4 VBRS LL_PWR_SetBattChargResistor
  863. * @param Resistor This parameter can be one of the following values:
  864. * @arg @ref LL_PWR_BATT_CHARG_RESISTOR_5K
  865. * @arg @ref LL_PWR_BATT_CHARGRESISTOR_1_5K
  866. * @retval None
  867. */
  868. __STATIC_INLINE void LL_PWR_SetBattChargResistor(uint32_t Resistor)
  869. {
  870. MODIFY_REG(PWR->CR4, PWR_CR4_VBRS, Resistor);
  871. }
  872. /**
  873. * @brief Get the resistor impedance
  874. * @rmtoll CR4 VBRS LL_PWR_GetBattChargResistor
  875. * @retval Returned value can be one of the following values:
  876. * @arg @ref LL_PWR_BATT_CHARG_RESISTOR_5K
  877. * @arg @ref LL_PWR_BATT_CHARGRESISTOR_1_5K
  878. */
  879. __STATIC_INLINE uint32_t LL_PWR_GetBattChargResistor(void)
  880. {
  881. return (uint32_t)(READ_BIT(PWR->CR4, PWR_CR4_VBRS));
  882. }
  883. /**
  884. * @brief Enable battery charging
  885. * @rmtoll CR4 VBE LL_PWR_EnableBatteryCharging
  886. * @retval None
  887. */
  888. __STATIC_INLINE void LL_PWR_EnableBatteryCharging(void)
  889. {
  890. SET_BIT(PWR->CR4, PWR_CR4_VBE);
  891. }
  892. /**
  893. * @brief Disable battery charging
  894. * @rmtoll CR4 VBE LL_PWR_DisableBatteryCharging
  895. * @retval None
  896. */
  897. __STATIC_INLINE void LL_PWR_DisableBatteryCharging(void)
  898. {
  899. CLEAR_BIT(PWR->CR4, PWR_CR4_VBE);
  900. }
  901. /**
  902. * @brief Check if battery charging is enabled
  903. * @rmtoll CR4 VBE LL_PWR_IsEnabledBatteryCharging
  904. * @retval State of bit (1 or 0).
  905. */
  906. __STATIC_INLINE uint32_t LL_PWR_IsEnabledBatteryCharging(void)
  907. {
  908. return ((READ_BIT(PWR->CR4, PWR_CR4_VBE) == (PWR_CR4_VBE)) ? 1UL : 0UL);
  909. }
  910. /**
  911. * @brief Set the Wake-Up pin polarity low for the event detection
  912. * @rmtoll CR4 WUPP1 LL_PWR_SetWakeUpPinPolarityLow\n
  913. * CR4 WUPP2 LL_PWR_SetWakeUpPinPolarityLow\n
  914. * CR4 WUPP3 LL_PWR_SetWakeUpPinPolarityLow\n
  915. * CR4 WUPP4 LL_PWR_SetWakeUpPinPolarityLow\n
  916. * CR4 WUPP5 LL_PWR_SetWakeUpPinPolarityLow
  917. * @param WakeUpPin This parameter can be one of the following values:
  918. * @arg @ref LL_PWR_WAKEUP_PIN1
  919. * @arg @ref LL_PWR_WAKEUP_PIN2
  920. * @arg @ref LL_PWR_WAKEUP_PIN3
  921. * @arg @ref LL_PWR_WAKEUP_PIN4
  922. * @arg @ref LL_PWR_WAKEUP_PIN5
  923. * @retval None
  924. */
  925. __STATIC_INLINE void LL_PWR_SetWakeUpPinPolarityLow(uint32_t WakeUpPin)
  926. {
  927. SET_BIT(PWR->CR4, WakeUpPin);
  928. }
  929. /**
  930. * @brief Set the Wake-Up pin polarity high for the event detection
  931. * @rmtoll CR4 WUPP1 LL_PWR_SetWakeUpPinPolarityHigh\n
  932. * CR4 WUPP2 LL_PWR_SetWakeUpPinPolarityHigh\n
  933. * CR4 WUPP3 LL_PWR_SetWakeUpPinPolarityHigh\n
  934. * CR4 WUPP4 LL_PWR_SetWakeUpPinPolarityHigh\n
  935. * CR4 WUPP5 LL_PWR_SetWakeUpPinPolarityHigh
  936. * @param WakeUpPin This parameter can be one of the following values:
  937. * @arg @ref LL_PWR_WAKEUP_PIN1
  938. * @arg @ref LL_PWR_WAKEUP_PIN2
  939. * @arg @ref LL_PWR_WAKEUP_PIN3
  940. * @arg @ref LL_PWR_WAKEUP_PIN4
  941. * @arg @ref LL_PWR_WAKEUP_PIN5
  942. * @retval None
  943. */
  944. __STATIC_INLINE void LL_PWR_SetWakeUpPinPolarityHigh(uint32_t WakeUpPin)
  945. {
  946. CLEAR_BIT(PWR->CR4, WakeUpPin);
  947. }
  948. /**
  949. * @brief Get the Wake-Up pin polarity for the event detection
  950. * @rmtoll CR4 WUPP1 LL_PWR_IsWakeUpPinPolarityLow\n
  951. * CR4 WUPP2 LL_PWR_IsWakeUpPinPolarityLow\n
  952. * CR4 WUPP3 LL_PWR_IsWakeUpPinPolarityLow\n
  953. * CR4 WUPP4 LL_PWR_IsWakeUpPinPolarityLow\n
  954. * CR4 WUPP5 LL_PWR_IsWakeUpPinPolarityLow
  955. * @param WakeUpPin This parameter can be one of the following values:
  956. * @arg @ref LL_PWR_WAKEUP_PIN1
  957. * @arg @ref LL_PWR_WAKEUP_PIN2
  958. * @arg @ref LL_PWR_WAKEUP_PIN3
  959. * @arg @ref LL_PWR_WAKEUP_PIN4
  960. * @arg @ref LL_PWR_WAKEUP_PIN5
  961. * @retval State of bit (1 or 0).
  962. */
  963. __STATIC_INLINE uint32_t LL_PWR_IsWakeUpPinPolarityLow(uint32_t WakeUpPin)
  964. {
  965. return ((READ_BIT(PWR->CR4, WakeUpPin) == (WakeUpPin)) ? 1UL : 0UL);
  966. }
  967. /**
  968. * @brief Enable GPIO pull-up state in Standby and Shutdown modes
  969. * @rmtoll PUCRA PU0-15 LL_PWR_EnableGPIOPullUp\n
  970. * PUCRB PU0-15 LL_PWR_EnableGPIOPullUp\n
  971. * PUCRC PU0-15 LL_PWR_EnableGPIOPullUp\n
  972. * PUCRD PU0-15 LL_PWR_EnableGPIOPullUp\n
  973. * PUCRE PU0-15 LL_PWR_EnableGPIOPullUp\n
  974. * PUCRF PU0-15 LL_PWR_EnableGPIOPullUp\n
  975. * PUCRG PU0-15 LL_PWR_EnableGPIOPullUp\n
  976. * PUCRH PU0-15 LL_PWR_EnableGPIOPullUp
  977. * @param GPIO This parameter can be one of the following values:
  978. * @arg @ref LL_PWR_GPIO_A
  979. * @arg @ref LL_PWR_GPIO_B
  980. * @arg @ref LL_PWR_GPIO_C
  981. * @arg @ref LL_PWR_GPIO_D
  982. * @arg @ref LL_PWR_GPIO_E
  983. * @arg @ref LL_PWR_GPIO_F
  984. * @arg @ref LL_PWR_GPIO_G
  985. * @arg @ref LL_PWR_GPIO_H
  986. * @param GPIONumber This parameter can be one of the following values:
  987. * @arg @ref LL_PWR_GPIO_BIT_0
  988. * @arg @ref LL_PWR_GPIO_BIT_1
  989. * @arg @ref LL_PWR_GPIO_BIT_2
  990. * @arg @ref LL_PWR_GPIO_BIT_3
  991. * @arg @ref LL_PWR_GPIO_BIT_4
  992. * @arg @ref LL_PWR_GPIO_BIT_5
  993. * @arg @ref LL_PWR_GPIO_BIT_6
  994. * @arg @ref LL_PWR_GPIO_BIT_7
  995. * @arg @ref LL_PWR_GPIO_BIT_8
  996. * @arg @ref LL_PWR_GPIO_BIT_9
  997. * @arg @ref LL_PWR_GPIO_BIT_10
  998. * @arg @ref LL_PWR_GPIO_BIT_11
  999. * @arg @ref LL_PWR_GPIO_BIT_12
  1000. * @arg @ref LL_PWR_GPIO_BIT_13
  1001. * @arg @ref LL_PWR_GPIO_BIT_14
  1002. * @arg @ref LL_PWR_GPIO_BIT_15
  1003. * @retval None
  1004. */
  1005. __STATIC_INLINE void LL_PWR_EnableGPIOPullUp(uint32_t GPIO, uint32_t GPIONumber)
  1006. {
  1007. SET_BIT(*((__IO uint32_t *)GPIO), GPIONumber);
  1008. }
  1009. /**
  1010. * @brief Disable GPIO pull-up state in Standby and Shutdown modes
  1011. * @rmtoll PUCRA PU0-15 LL_PWR_DisableGPIOPullUp\n
  1012. * PUCRB PU0-15 LL_PWR_DisableGPIOPullUp\n
  1013. * PUCRC PU0-15 LL_PWR_DisableGPIOPullUp\n
  1014. * PUCRD PU0-15 LL_PWR_DisableGPIOPullUp\n
  1015. * PUCRE PU0-15 LL_PWR_DisableGPIOPullUp\n
  1016. * PUCRF PU0-15 LL_PWR_DisableGPIOPullUp\n
  1017. * PUCRG PU0-15 LL_PWR_DisableGPIOPullUp\n
  1018. * PUCRH PU0-15 LL_PWR_DisableGPIOPullUp
  1019. * @param GPIO This parameter can be one of the following values:
  1020. * @arg @ref LL_PWR_GPIO_A
  1021. * @arg @ref LL_PWR_GPIO_B
  1022. * @arg @ref LL_PWR_GPIO_C
  1023. * @arg @ref LL_PWR_GPIO_D
  1024. * @arg @ref LL_PWR_GPIO_E
  1025. * @arg @ref LL_PWR_GPIO_F
  1026. * @arg @ref LL_PWR_GPIO_G
  1027. * @arg @ref LL_PWR_GPIO_H
  1028. * @param GPIONumber This parameter can be one of the following values:
  1029. * @arg @ref LL_PWR_GPIO_BIT_0
  1030. * @arg @ref LL_PWR_GPIO_BIT_1
  1031. * @arg @ref LL_PWR_GPIO_BIT_2
  1032. * @arg @ref LL_PWR_GPIO_BIT_3
  1033. * @arg @ref LL_PWR_GPIO_BIT_4
  1034. * @arg @ref LL_PWR_GPIO_BIT_5
  1035. * @arg @ref LL_PWR_GPIO_BIT_6
  1036. * @arg @ref LL_PWR_GPIO_BIT_7
  1037. * @arg @ref LL_PWR_GPIO_BIT_8
  1038. * @arg @ref LL_PWR_GPIO_BIT_9
  1039. * @arg @ref LL_PWR_GPIO_BIT_10
  1040. * @arg @ref LL_PWR_GPIO_BIT_11
  1041. * @arg @ref LL_PWR_GPIO_BIT_12
  1042. * @arg @ref LL_PWR_GPIO_BIT_13
  1043. * @arg @ref LL_PWR_GPIO_BIT_14
  1044. * @arg @ref LL_PWR_GPIO_BIT_15
  1045. * @retval None
  1046. */
  1047. __STATIC_INLINE void LL_PWR_DisableGPIOPullUp(uint32_t GPIO, uint32_t GPIONumber)
  1048. {
  1049. CLEAR_BIT(*((__IO uint32_t *)GPIO), GPIONumber);
  1050. }
  1051. /**
  1052. * @brief Check if GPIO pull-up state is enabled
  1053. * @rmtoll PUCRA PU0-15 LL_PWR_IsEnabledGPIOPullUp\n
  1054. * PUCRB PU0-15 LL_PWR_IsEnabledGPIOPullUp\n
  1055. * PUCRC PU0-15 LL_PWR_IsEnabledGPIOPullUp\n
  1056. * PUCRD PU0-15 LL_PWR_IsEnabledGPIOPullUp\n
  1057. * PUCRE PU0-15 LL_PWR_IsEnabledGPIOPullUp\n
  1058. * PUCRF PU0-15 LL_PWR_IsEnabledGPIOPullUp\n
  1059. * PUCRG PU0-15 LL_PWR_IsEnabledGPIOPullUp\n
  1060. * PUCRH PU0-15 LL_PWR_IsEnabledGPIOPullUp
  1061. * @param GPIO This parameter can be one of the following values:
  1062. * @arg @ref LL_PWR_GPIO_A
  1063. * @arg @ref LL_PWR_GPIO_B
  1064. * @arg @ref LL_PWR_GPIO_C
  1065. * @arg @ref LL_PWR_GPIO_D
  1066. * @arg @ref LL_PWR_GPIO_E
  1067. * @arg @ref LL_PWR_GPIO_F
  1068. * @arg @ref LL_PWR_GPIO_G
  1069. * @arg @ref LL_PWR_GPIO_H
  1070. * @param GPIONumber This parameter can be one of the following values:
  1071. * @arg @ref LL_PWR_GPIO_BIT_0
  1072. * @arg @ref LL_PWR_GPIO_BIT_1
  1073. * @arg @ref LL_PWR_GPIO_BIT_2
  1074. * @arg @ref LL_PWR_GPIO_BIT_3
  1075. * @arg @ref LL_PWR_GPIO_BIT_4
  1076. * @arg @ref LL_PWR_GPIO_BIT_5
  1077. * @arg @ref LL_PWR_GPIO_BIT_6
  1078. * @arg @ref LL_PWR_GPIO_BIT_7
  1079. * @arg @ref LL_PWR_GPIO_BIT_8
  1080. * @arg @ref LL_PWR_GPIO_BIT_9
  1081. * @arg @ref LL_PWR_GPIO_BIT_10
  1082. * @arg @ref LL_PWR_GPIO_BIT_11
  1083. * @arg @ref LL_PWR_GPIO_BIT_12
  1084. * @arg @ref LL_PWR_GPIO_BIT_13
  1085. * @arg @ref LL_PWR_GPIO_BIT_14
  1086. * @arg @ref LL_PWR_GPIO_BIT_15
  1087. * @retval State of bit (1 or 0).
  1088. */
  1089. __STATIC_INLINE uint32_t LL_PWR_IsEnabledGPIOPullUp(uint32_t GPIO, uint32_t GPIONumber)
  1090. {
  1091. return ((READ_BIT(*((__IO uint32_t *)GPIO), GPIONumber) == (GPIONumber)) ? 1UL : 0UL);
  1092. }
  1093. /**
  1094. * @brief Enable GPIO pull-down state in Standby and Shutdown modes
  1095. * @rmtoll PDCRA PD0-15 LL_PWR_EnableGPIOPullDown\n
  1096. * PDCRB PD0-15 LL_PWR_EnableGPIOPullDown\n
  1097. * PDCRC PD0-15 LL_PWR_EnableGPIOPullDown\n
  1098. * PDCRD PD0-15 LL_PWR_EnableGPIOPullDown\n
  1099. * PDCRE PD0-15 LL_PWR_EnableGPIOPullDown\n
  1100. * PDCRF PD0-15 LL_PWR_EnableGPIOPullDown\n
  1101. * PDCRG PD0-15 LL_PWR_EnableGPIOPullDown\n
  1102. * PDCRH PD0-15 LL_PWR_EnableGPIOPullDown
  1103. * @param GPIO This parameter can be one of the following values:
  1104. * @arg @ref LL_PWR_GPIO_A
  1105. * @arg @ref LL_PWR_GPIO_B
  1106. * @arg @ref LL_PWR_GPIO_C
  1107. * @arg @ref LL_PWR_GPIO_D
  1108. * @arg @ref LL_PWR_GPIO_E
  1109. * @arg @ref LL_PWR_GPIO_F
  1110. * @arg @ref LL_PWR_GPIO_G
  1111. * @arg @ref LL_PWR_GPIO_H
  1112. * @param GPIONumber This parameter can be one of the following values:
  1113. * @arg @ref LL_PWR_GPIO_BIT_0
  1114. * @arg @ref LL_PWR_GPIO_BIT_1
  1115. * @arg @ref LL_PWR_GPIO_BIT_2
  1116. * @arg @ref LL_PWR_GPIO_BIT_3
  1117. * @arg @ref LL_PWR_GPIO_BIT_4
  1118. * @arg @ref LL_PWR_GPIO_BIT_5
  1119. * @arg @ref LL_PWR_GPIO_BIT_6
  1120. * @arg @ref LL_PWR_GPIO_BIT_7
  1121. * @arg @ref LL_PWR_GPIO_BIT_8
  1122. * @arg @ref LL_PWR_GPIO_BIT_9
  1123. * @arg @ref LL_PWR_GPIO_BIT_10
  1124. * @arg @ref LL_PWR_GPIO_BIT_11
  1125. * @arg @ref LL_PWR_GPIO_BIT_12
  1126. * @arg @ref LL_PWR_GPIO_BIT_13
  1127. * @arg @ref LL_PWR_GPIO_BIT_14
  1128. * @arg @ref LL_PWR_GPIO_BIT_15
  1129. * @retval None
  1130. */
  1131. __STATIC_INLINE void LL_PWR_EnableGPIOPullDown(uint32_t GPIO, uint32_t GPIONumber)
  1132. {
  1133. SET_BIT(*((__IO uint32_t *)(GPIO + 4U)), GPIONumber);
  1134. }
  1135. /**
  1136. * @brief Disable GPIO pull-down state in Standby and Shutdown modes
  1137. * @rmtoll PDCRA PD0-15 LL_PWR_DisableGPIOPullDown\n
  1138. * PDCRB PD0-15 LL_PWR_DisableGPIOPullDown\n
  1139. * PDCRC PD0-15 LL_PWR_DisableGPIOPullDown\n
  1140. * PDCRD PD0-15 LL_PWR_DisableGPIOPullDown\n
  1141. * PDCRE PD0-15 LL_PWR_DisableGPIOPullDown\n
  1142. * PDCRF PD0-15 LL_PWR_DisableGPIOPullDown\n
  1143. * PDCRG PD0-15 LL_PWR_DisableGPIOPullDown\n
  1144. * PDCRH PD0-15 LL_PWR_DisableGPIOPullDown
  1145. * @param GPIO This parameter can be one of the following values:
  1146. * @arg @ref LL_PWR_GPIO_A
  1147. * @arg @ref LL_PWR_GPIO_B
  1148. * @arg @ref LL_PWR_GPIO_C
  1149. * @arg @ref LL_PWR_GPIO_D
  1150. * @arg @ref LL_PWR_GPIO_E
  1151. * @arg @ref LL_PWR_GPIO_F
  1152. * @arg @ref LL_PWR_GPIO_G
  1153. * @arg @ref LL_PWR_GPIO_H
  1154. * @param GPIONumber This parameter can be one of the following values:
  1155. * @arg @ref LL_PWR_GPIO_BIT_0
  1156. * @arg @ref LL_PWR_GPIO_BIT_1
  1157. * @arg @ref LL_PWR_GPIO_BIT_2
  1158. * @arg @ref LL_PWR_GPIO_BIT_3
  1159. * @arg @ref LL_PWR_GPIO_BIT_4
  1160. * @arg @ref LL_PWR_GPIO_BIT_5
  1161. * @arg @ref LL_PWR_GPIO_BIT_6
  1162. * @arg @ref LL_PWR_GPIO_BIT_7
  1163. * @arg @ref LL_PWR_GPIO_BIT_8
  1164. * @arg @ref LL_PWR_GPIO_BIT_9
  1165. * @arg @ref LL_PWR_GPIO_BIT_10
  1166. * @arg @ref LL_PWR_GPIO_BIT_11
  1167. * @arg @ref LL_PWR_GPIO_BIT_12
  1168. * @arg @ref LL_PWR_GPIO_BIT_13
  1169. * @arg @ref LL_PWR_GPIO_BIT_14
  1170. * @arg @ref LL_PWR_GPIO_BIT_15
  1171. * @retval None
  1172. */
  1173. __STATIC_INLINE void LL_PWR_DisableGPIOPullDown(uint32_t GPIO, uint32_t GPIONumber)
  1174. {
  1175. CLEAR_BIT(*((__IO uint32_t *)(GPIO + 4U)), GPIONumber);
  1176. }
  1177. /**
  1178. * @brief Check if GPIO pull-down state is enabled
  1179. * @rmtoll PDCRA PD0-15 LL_PWR_IsEnabledGPIOPullDown\n
  1180. * PDCRB PD0-15 LL_PWR_IsEnabledGPIOPullDown\n
  1181. * PDCRC PD0-15 LL_PWR_IsEnabledGPIOPullDown\n
  1182. * PDCRD PD0-15 LL_PWR_IsEnabledGPIOPullDown\n
  1183. * PDCRE PD0-15 LL_PWR_IsEnabledGPIOPullDown\n
  1184. * PDCRF PD0-15 LL_PWR_IsEnabledGPIOPullDown\n
  1185. * PDCRG PD0-15 LL_PWR_IsEnabledGPIOPullDown\n
  1186. * PDCRH PD0-15 LL_PWR_IsEnabledGPIOPullDown
  1187. * @param GPIO This parameter can be one of the following values:
  1188. * @arg @ref LL_PWR_GPIO_A
  1189. * @arg @ref LL_PWR_GPIO_B
  1190. * @arg @ref LL_PWR_GPIO_C
  1191. * @arg @ref LL_PWR_GPIO_D
  1192. * @arg @ref LL_PWR_GPIO_E
  1193. * @arg @ref LL_PWR_GPIO_F
  1194. * @arg @ref LL_PWR_GPIO_G
  1195. * @arg @ref LL_PWR_GPIO_H
  1196. * @param GPIONumber This parameter can be one of the following values:
  1197. * @arg @ref LL_PWR_GPIO_BIT_0
  1198. * @arg @ref LL_PWR_GPIO_BIT_1
  1199. * @arg @ref LL_PWR_GPIO_BIT_2
  1200. * @arg @ref LL_PWR_GPIO_BIT_3
  1201. * @arg @ref LL_PWR_GPIO_BIT_4
  1202. * @arg @ref LL_PWR_GPIO_BIT_5
  1203. * @arg @ref LL_PWR_GPIO_BIT_6
  1204. * @arg @ref LL_PWR_GPIO_BIT_7
  1205. * @arg @ref LL_PWR_GPIO_BIT_8
  1206. * @arg @ref LL_PWR_GPIO_BIT_9
  1207. * @arg @ref LL_PWR_GPIO_BIT_10
  1208. * @arg @ref LL_PWR_GPIO_BIT_11
  1209. * @arg @ref LL_PWR_GPIO_BIT_12
  1210. * @arg @ref LL_PWR_GPIO_BIT_13
  1211. * @arg @ref LL_PWR_GPIO_BIT_14
  1212. * @arg @ref LL_PWR_GPIO_BIT_15
  1213. * @retval State of bit (1 or 0).
  1214. */
  1215. __STATIC_INLINE uint32_t LL_PWR_IsEnabledGPIOPullDown(uint32_t GPIO, uint32_t GPIONumber)
  1216. {
  1217. return ((READ_BIT(*((__IO uint32_t *)(GPIO + 4U)), GPIONumber) == (GPIONumber)) ? 1UL : 0UL);
  1218. }
  1219. /**
  1220. * @}
  1221. */
  1222. /** @defgroup PWR_LL_EF_FLAG_Management FLAG_Management
  1223. * @{
  1224. */
  1225. /**
  1226. * @brief Get SMPS High-power mode ready Flag
  1227. * @rmtoll SR1 SMPSHPRDY LL_PWR_IsActiveFlag_SMPSHPRDY
  1228. * @retval State of bit (1 or 0).
  1229. */
  1230. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_SMPSHPRDY(void)
  1231. {
  1232. return ((READ_BIT(PWR->SR1, PWR_SR1_SMPSHPRDY) == (PWR_SR1_SMPSHPRDY)) ? 1UL : 0UL);
  1233. }
  1234. /**
  1235. * @brief Get External SMPS mode ready Flag
  1236. * @rmtoll SR1 EXTSMPSRDY LL_PWR_IsActiveFlag_EXTSMPSRDY
  1237. * @retval State of bit (1 or 0).
  1238. */
  1239. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_EXTSMPSRDY(void)
  1240. {
  1241. return ((READ_BIT(PWR->SR1, PWR_SR1_EXTSMPSRDY) == (PWR_SR1_EXTSMPSRDY)) ? 1UL : 0UL);
  1242. }
  1243. /**
  1244. * @brief Get SMPS Bypass mode ready Flag
  1245. * @rmtoll SR1 SMPSBYPRDY LL_PWR_IsActiveFlag_SMPSBYPRDY
  1246. * @retval State of bit (1 or 0).
  1247. */
  1248. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_SMPSBYPRDY(void)
  1249. {
  1250. return ((READ_BIT(PWR->SR1, PWR_SR1_SMPSBYPRDY) == (PWR_SR1_SMPSBYPRDY)) ? 1UL : 0UL);
  1251. }
  1252. /**
  1253. * @brief Get Stand-By Flag
  1254. * @rmtoll SR1 SBF LL_PWR_IsActiveFlag_SB
  1255. * @retval State of bit (1 or 0).
  1256. */
  1257. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_SB(void)
  1258. {
  1259. return ((READ_BIT(PWR->SR1, PWR_SR1_SBF) == (PWR_SR1_SBF)) ? 1UL : 0UL);
  1260. }
  1261. /**
  1262. * @brief Get Wake-up Flag 5
  1263. * @rmtoll SR1 WUF5 LL_PWR_IsActiveFlag_WU5
  1264. * @retval State of bit (1 or 0).
  1265. */
  1266. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_WU5(void)
  1267. {
  1268. return ((READ_BIT(PWR->SR1, PWR_SR1_WUF5) == (PWR_SR1_WUF5)) ? 1UL : 0UL);
  1269. }
  1270. /**
  1271. * @brief Get Wake-up Flag 4
  1272. * @rmtoll SR1 WUF4 LL_PWR_IsActiveFlag_WU4
  1273. * @retval State of bit (1 or 0).
  1274. */
  1275. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_WU4(void)
  1276. {
  1277. return ((READ_BIT(PWR->SR1, PWR_SR1_WUF4) == (PWR_SR1_WUF4)) ? 1UL : 0UL);
  1278. }
  1279. /**
  1280. * @brief Get Wake-up Flag 3
  1281. * @rmtoll SR1 WUF3 LL_PWR_IsActiveFlag_WU3
  1282. * @retval State of bit (1 or 0).
  1283. */
  1284. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_WU3(void)
  1285. {
  1286. return ((READ_BIT(PWR->SR1, PWR_SR1_WUF3) == (PWR_SR1_WUF3)) ? 1UL : 0UL);
  1287. }
  1288. /**
  1289. * @brief Get Wake-up Flag 2
  1290. * @rmtoll SR1 WUF2 LL_PWR_IsActiveFlag_WU2
  1291. * @retval State of bit (1 or 0).
  1292. */
  1293. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_WU2(void)
  1294. {
  1295. return ((READ_BIT(PWR->SR1, PWR_SR1_WUF2) == (PWR_SR1_WUF2)) ? 1UL : 0UL);
  1296. }
  1297. /**
  1298. * @brief Get Wake-up Flag 1
  1299. * @rmtoll SR1 WUF1 LL_PWR_IsActiveFlag_WU1
  1300. * @retval State of bit (1 or 0).
  1301. */
  1302. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_WU1(void)
  1303. {
  1304. return ((READ_BIT(PWR->SR1, PWR_SR1_WUF1) == (PWR_SR1_WUF1)) ? 1UL : 0UL);
  1305. }
  1306. /**
  1307. * @brief Clear Stand-By Flag
  1308. * @rmtoll SCR CSBF LL_PWR_ClearFlag_SB
  1309. * @retval None
  1310. */
  1311. __STATIC_INLINE void LL_PWR_ClearFlag_SB(void)
  1312. {
  1313. WRITE_REG(PWR->SCR, PWR_SCR_CSBF);
  1314. }
  1315. /**
  1316. * @brief Clear Wake-up Flags
  1317. * @rmtoll SCR CWUF LL_PWR_ClearFlag_WU
  1318. * @retval None
  1319. */
  1320. __STATIC_INLINE void LL_PWR_ClearFlag_WU(void)
  1321. {
  1322. WRITE_REG(PWR->SCR, PWR_SCR_CWUF);
  1323. }
  1324. /**
  1325. * @brief Clear Wake-up Flag 5
  1326. * @rmtoll SCR CWUF5 LL_PWR_ClearFlag_WU5
  1327. * @retval None
  1328. */
  1329. __STATIC_INLINE void LL_PWR_ClearFlag_WU5(void)
  1330. {
  1331. WRITE_REG(PWR->SCR, PWR_SCR_CWUF5);
  1332. }
  1333. /**
  1334. * @brief Clear Wake-up Flag 4
  1335. * @rmtoll SCR CWUF4 LL_PWR_ClearFlag_WU4
  1336. * @retval None
  1337. */
  1338. __STATIC_INLINE void LL_PWR_ClearFlag_WU4(void)
  1339. {
  1340. WRITE_REG(PWR->SCR, PWR_SCR_CWUF4);
  1341. }
  1342. /**
  1343. * @brief Clear Wake-up Flag 3
  1344. * @rmtoll SCR CWUF3 LL_PWR_ClearFlag_WU3
  1345. * @retval None
  1346. */
  1347. __STATIC_INLINE void LL_PWR_ClearFlag_WU3(void)
  1348. {
  1349. WRITE_REG(PWR->SCR, PWR_SCR_CWUF3);
  1350. }
  1351. /**
  1352. * @brief Clear Wake-up Flag 2
  1353. * @rmtoll SCR CWUF2 LL_PWR_ClearFlag_WU2
  1354. * @retval None
  1355. */
  1356. __STATIC_INLINE void LL_PWR_ClearFlag_WU2(void)
  1357. {
  1358. WRITE_REG(PWR->SCR, PWR_SCR_CWUF2);
  1359. }
  1360. /**
  1361. * @brief Clear Wake-up Flag 1
  1362. * @rmtoll SCR CWUF1 LL_PWR_ClearFlag_WU1
  1363. * @retval None
  1364. */
  1365. __STATIC_INLINE void LL_PWR_ClearFlag_WU1(void)
  1366. {
  1367. WRITE_REG(PWR->SCR, PWR_SCR_CWUF1);
  1368. }
  1369. /**
  1370. * @brief Indicate whether VDDA voltage is below or above PVM4 threshold
  1371. * @rmtoll SR2 PVMO4 LL_PWR_IsActiveFlag_PVMO4
  1372. * @retval State of bit (1 or 0).
  1373. */
  1374. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_PVMO4(void)
  1375. {
  1376. return ((READ_BIT(PWR->SR2, PWR_SR2_PVMO4) == (PWR_SR2_PVMO4)) ? 1UL : 0UL);
  1377. }
  1378. /**
  1379. * @brief Indicate whether VDDA voltage is below or above PVM3 threshold
  1380. * @rmtoll SR2 PVMO3 LL_PWR_IsActiveFlag_PVMO3
  1381. * @retval State of bit (1 or 0).
  1382. */
  1383. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_PVMO3(void)
  1384. {
  1385. return ((READ_BIT(PWR->SR2, PWR_SR2_PVMO3) == (PWR_SR2_PVMO3)) ? 1UL : 0UL);
  1386. }
  1387. /**
  1388. * @brief Indicate whether VDDIO2 voltage is below or above PVM2 threshold
  1389. * @rmtoll SR2 PVMO2 LL_PWR_IsActiveFlag_PVMO2
  1390. * @retval State of bit (1 or 0).
  1391. */
  1392. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_PVMO2(void)
  1393. {
  1394. return ((READ_BIT(PWR->SR2, PWR_SR2_PVMO2) == (PWR_SR2_PVMO2)) ? 1UL : 0UL);
  1395. }
  1396. /**
  1397. * @brief Indicate whether VDDUSB voltage is below or above PVM1 threshold
  1398. * @rmtoll SR2 PVMO1 LL_PWR_IsActiveFlag_PVMO1
  1399. * @retval State of bit (1 or 0).
  1400. */
  1401. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_PVMO1(void)
  1402. {
  1403. return ((READ_BIT(PWR->SR2, PWR_SR2_PVMO1) == (PWR_SR2_PVMO1)) ? 1UL : 0UL);
  1404. }
  1405. /**
  1406. * @brief Indicate whether VDD voltage is below or above the selected PVD threshold
  1407. * @rmtoll SR2 PVDO LL_PWR_IsActiveFlag_PVDO
  1408. * @retval State of bit (1 or 0).
  1409. */
  1410. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_PVDO(void)
  1411. {
  1412. return ((READ_BIT(PWR->SR2, PWR_SR2_PVDO) == (PWR_SR2_PVDO)) ? 1UL : 0UL);
  1413. }
  1414. /**
  1415. * @brief Indicate whether the regulator is ready in the selected voltage range or if its output voltage is still changing to the required voltage level
  1416. * @rmtoll SR2 VOSF LL_PWR_IsActiveFlag_VOS
  1417. * @retval State of bit (1 or 0).
  1418. */
  1419. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_VOS(void)
  1420. {
  1421. return ((READ_BIT(PWR->SR2, PWR_SR2_VOSF) == (PWR_SR2_VOSF)) ? 1UL : 0UL);
  1422. }
  1423. /**
  1424. * @brief Indicate whether the regulator is ready in main mode or is in low-power mode
  1425. * @note: Take care, return value "0" means the regulator is ready. Return value "1" means the output voltage range is still changing.
  1426. * @rmtoll SR2 REGLPF LL_PWR_IsActiveFlag_REGLPF
  1427. * @retval State of bit (1 or 0).
  1428. */
  1429. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_REGLPF(void)
  1430. {
  1431. return ((READ_BIT(PWR->SR2, PWR_SR2_REGLPF) == (PWR_SR2_REGLPF)) ? 1UL : 0UL);
  1432. }
  1433. /**
  1434. * @brief Indicate whether or not the low-power regulator is ready
  1435. * @rmtoll SR2 REGLPS LL_PWR_IsActiveFlag_REGLPS
  1436. * @retval State of bit (1 or 0).
  1437. */
  1438. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_REGLPS(void)
  1439. {
  1440. return ((READ_BIT(PWR->SR2, PWR_SR2_REGLPS) == (PWR_SR2_REGLPS)) ? 1UL : 0UL);
  1441. }
  1442. /**
  1443. * @}
  1444. */
  1445. /** @defgroup PWR_LL_EF_Privilege_Management Privilege_Management
  1446. * @{
  1447. */
  1448. /**
  1449. * @brief Enable Privileged mode
  1450. * @rmtoll PRIVCFGR PRIV LL_PWR_EnablePrivilege
  1451. * @retval None
  1452. */
  1453. __STATIC_INLINE void LL_PWR_EnablePrivilege(void)
  1454. {
  1455. SET_BIT(PWR->PRIVCFGR, PWR_PRIVCFGR_PRIV);
  1456. }
  1457. /**
  1458. * @brief Disable Privileged mode
  1459. * @rmtoll PRIVCFGR PRIV LL_PWR_DisablePrivilege
  1460. * @retval None
  1461. */
  1462. __STATIC_INLINE void LL_PWR_DisablePrivilege(void)
  1463. {
  1464. CLEAR_BIT(PWR->PRIVCFGR, PWR_PRIVCFGR_PRIV);
  1465. }
  1466. /**
  1467. * @brief Check if Privileged mode has been enabled or not
  1468. * @rmtoll PRIVCFGR PRIV LL_PWR_IsEnabledPrivilege
  1469. * @retval State of bit (1 or 0).
  1470. */
  1471. __STATIC_INLINE uint32_t LL_PWR_IsEnabledPrivilege(void)
  1472. {
  1473. return ((READ_BIT(PWR->PRIVCFGR, PWR_PRIVCFGR_PRIV) == PWR_PRIVCFGR_PRIV) ? 1UL : 0UL);
  1474. }
  1475. /**
  1476. * @}
  1477. */
  1478. #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
  1479. /** @defgroup PWR_LL_EF_Secure_Management Secure_Management
  1480. * @{
  1481. */
  1482. /**
  1483. * @brief Configure Secure mode
  1484. * @note Only available from secure state when system implements security (TZEN=1)
  1485. * @rmtoll SECCFGR WUPSEC LL_PWR_ConfigSecure\n
  1486. * SECCFGR WUP1SEC LL_PWR_ConfigSecure\n
  1487. * SECCFGR WUP2SEC LL_PWR_ConfigSecure\n
  1488. * SECCFGR WUP3SEC LL_PWR_ConfigSecure\n
  1489. * SECCFGR WUP4SEC LL_PWR_ConfigSecure\n
  1490. * SECCFGR WUP5SEC LL_PWR_ConfigSecure\n
  1491. * SECCFGR LPMSEC LL_PWR_ConfigSecure\n
  1492. * SECCFGR VDMSEC LL_PWR_ConfigSecure\n
  1493. * SECCFGR VBSEC LL_PWR_ConfigSecure\n
  1494. * SECCFGR APCSEC LL_PWR_ConfigSecure
  1495. * @param Configuration This parameter shall be the full combination
  1496. * of the following values:
  1497. * @arg @ref LL_PWR_WAKEUP_PINS_SEC or LL_PWR_WAKEUP_PINS_NSEC
  1498. * @arg @ref LL_PWR_WAKEUP_PIN1_SEC or LL_PWR_WAKEUP_PIN1_NSEC
  1499. * @arg @ref LL_PWR_WAKEUP_PIN2_SEC or LL_PWR_WAKEUP_PIN2_NSEC
  1500. * @arg @ref LL_PWR_WAKEUP_PIN3_SEC or LL_PWR_WAKEUP_PIN3_NSEC
  1501. * @arg @ref LL_PWR_WAKEUP_PIN4_SEC or LL_PWR_WAKEUP_PIN4_NSEC
  1502. * @arg @ref LL_PWR_WAKEUP_PIN5_SEC or LL_PWR_WAKEUP_PIN5_NSEC
  1503. * @arg @ref LL_PWR_LPM_SEC or LL_PWR_LPM_NSEC
  1504. * @arg @ref LL_PWR_VDM_SEC or LL_PWR_VDM_NSEC
  1505. * @arg @ref LL_PWR_VB_SEC or LL_PWR_VB_NSEC
  1506. * @arg @ref LL_PWR_APC_SEC or LL_PWR_APC_NSEC
  1507. * @retval None
  1508. */
  1509. __STATIC_INLINE void LL_PWR_ConfigSecure(uint32_t Configuration)
  1510. {
  1511. WRITE_REG(PWR->SECCFGR, Configuration);
  1512. }
  1513. /**
  1514. * @brief Get Secure mode configuration
  1515. * @note Only available from secure state when system implements security (TZEN=1)
  1516. * @rmtoll SECCFGR WUPSEC LL_PWR_GetConfigSecure\n
  1517. * SECCFGR WUP1SEC LL_PWR_GetConfigSecure\n
  1518. * SECCFGR WUP2SEC LL_PWR_GetConfigSecure\n
  1519. * SECCFGR WUP3SEC LL_PWR_GetConfigSecure\n
  1520. * SECCFGR WUP4SEC LL_PWR_GetConfigSecure\n
  1521. * SECCFGR WUP5SEC LL_PWR_GetConfigSecure\n
  1522. * SECCFGR LPMSEC LL_PWR_GetConfigSecure\n
  1523. * SECCFGR VDMSEC LL_PWR_GetConfigSecure\n
  1524. * SECCFGR VBSEC LL_PWR_GetConfigSecure\n
  1525. * SECCFGR APCSEC LL_PWR_GetConfigSecure
  1526. * @retval Returned value is the combination of the following values:
  1527. * @arg @ref LL_PWR_WAKEUP_PINS_SEC or LL_PWR_WAKEUP_PINS_NSEC
  1528. * @arg @ref LL_PWR_WAKEUP_PIN1_SEC or LL_PWR_WAKEUP_PIN1_NSEC
  1529. * @arg @ref LL_PWR_WAKEUP_PIN2_SEC or LL_PWR_WAKEUP_PIN2_NSEC
  1530. * @arg @ref LL_PWR_WAKEUP_PIN3_SEC or LL_PWR_WAKEUP_PIN3_NSEC
  1531. * @arg @ref LL_PWR_WAKEUP_PIN4_SEC or LL_PWR_WAKEUP_PIN4_NSEC
  1532. * @arg @ref LL_PWR_WAKEUP_PIN5_SEC or LL_PWR_WAKEUP_PIN5_NSEC
  1533. * @arg @ref LL_PWR_LPM_SEC or LL_PWR_LPM_NSEC
  1534. * @arg @ref LL_PWR_VDM_SEC or LL_PWR_VDM_NSEC
  1535. * @arg @ref LL_PWR_VB_SEC or LL_PWR_VB_NSEC
  1536. * @arg @ref LL_PWR_APC_SEC or LL_PWR_APC_NSEC
  1537. */
  1538. __STATIC_INLINE uint32_t LL_PWR_GetConfigSecure(void)
  1539. {
  1540. return (uint32_t)(READ_REG(PWR->SECCFGR));
  1541. }
  1542. /**
  1543. * @}
  1544. */
  1545. #endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */
  1546. #if defined(USE_FULL_LL_DRIVER)
  1547. /** @defgroup PWR_LL_EF_Init De-initialization function
  1548. * @{
  1549. */
  1550. ErrorStatus LL_PWR_DeInit(void);
  1551. /**
  1552. * @}
  1553. */
  1554. #endif /* USE_FULL_LL_DRIVER */
  1555. /** @defgroup PWR_LL_EF_Legacy_Functions Legacy functions name
  1556. * @{
  1557. */
  1558. /* Old functions name kept for legacy purpose, to be replaced by the */
  1559. /* current functions name. */
  1560. #define LL_PWR_IsActiveFlag_VOSF LL_PWR_IsActiveFlag_VOS
  1561. /**
  1562. * @}
  1563. */
  1564. /**
  1565. * @}
  1566. */
  1567. /**
  1568. * @}
  1569. */
  1570. #endif /* defined(PWR) */
  1571. /**
  1572. * @}
  1573. */
  1574. #ifdef __cplusplus
  1575. }
  1576. #endif
  1577. #endif /* STM32L5xx_LL_PWR_H */