py32f0xx_ll_pwr.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  1. /**
  2. ******************************************************************************
  3. * @file py32f0xx_ll_pwr.h
  4. * @author MCU Application Team
  5. * @brief Header file of PWR LL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2023 Puya Semiconductor Co.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by Puya under BSD 3-Clause license,
  13. * the "License"; You may not use this file except in compliance with the
  14. * License. You may obtain a copy of the License at:
  15. * opensource.org/licenses/BSD-3-Clause
  16. *
  17. ******************************************************************************
  18. * @attention
  19. *
  20. * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
  21. * All rights reserved.</center></h2>
  22. *
  23. * This software component is licensed by ST under BSD 3-Clause license,
  24. * the "License"; You may not use this file except in compliance with the
  25. * License. You may obtain a copy of the License at:
  26. * opensource.org/licenses/BSD-3-Clause
  27. *
  28. ******************************************************************************
  29. */
  30. /* Define to prevent recursive inclusion -------------------------------------*/
  31. #ifndef PY32F0XX_LL_PWR_H
  32. #define PY32F0XX_LL_PWR_H
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. /* Includes ------------------------------------------------------------------*/
  37. #include "py32f0xx.h"
  38. /** @addtogroup PY32F0xx_LL_Driver
  39. * @{
  40. */
  41. #if defined(PWR)
  42. /** @defgroup PWR_LL PWR
  43. * @{
  44. */
  45. /* Private types -------------------------------------------------------------*/
  46. /* Private variables ---------------------------------------------------------*/
  47. /* Private constants ---------------------------------------------------------*/
  48. /* Private macros ------------------------------------------------------------*/
  49. /* Exported types ------------------------------------------------------------*/
  50. /* Exported constants --------------------------------------------------------*/
  51. /** @defgroup PWR_LL_Exported_Constants PWR Exported Constants
  52. * @{
  53. */
  54. /** @defgroup PWR_LL_EC_REGU_VOLTAGE REGU VOLTAGE
  55. * @{
  56. */
  57. #define LL_PWR_REGU_VOLTAGE_SCALE1 0x0 /* After entering stop mode, VDD=1.2V */
  58. #define LL_PWR_REGU_VOLTAGE_SCALE2 PWR_CR1_VOS /* After entering stop mode, VDD=1.0V */
  59. /**
  60. * @}
  61. */
  62. /** @defgroup PWR_LL_EC_SRAM_RETENTION_VOLTAGE SRAM RETENTION VOLTAGE
  63. * @{
  64. */
  65. #define LL_PWR_SRAM_RETENTION_VOLT_0p9 ( PWR_CR1_SRAM_RETV_1 | PWR_CR1_SRAM_RETV_0) /* Set SRAM to 0.9V voltage in stop mode */
  66. #define LL_PWR_SRAM_RETENTION_VOLT_VOS (PWR_CR1_SRAM_RETV_2 ) /* Set SRAM voltage as set by bit VOS in stop mode */
  67. /**
  68. * @}
  69. */
  70. /** @defgroup PWR_LL_EC_WAKEUP_HSION_MODE WAKEUP HSI ON MODE
  71. * @{
  72. */
  73. #define LL_PWR_WAKEUP_HSION_AFTER_MR 0x00000000U /* Wake up from the STOP mode, After the MR becomes stable, enable HSI */
  74. #define LL_PWR_WAKEUP_HSION_IMMEDIATE PWR_CR1_HSION_CTRL /* Wake up from the STOP mode, Enable HSI immediately */
  75. /**
  76. * @}
  77. */
  78. /** @defgroup PWR_LL_EC_WAKEUP_FLASH_DELAY WAKEUP FLASH DELAY
  79. * @{
  80. */
  81. #define LL_PWR_WAKEUP_FLASH_DELAY_0US (PWR_CR1_FLS_SLPTIME_1 | PWR_CR1_FLS_SLPTIME_0) /* Wake up from the STOP mode, Enable falsh immediately*/
  82. #define LL_PWR_WAKEUP_FLASH_DELAY_2US ( PWR_CR1_FLS_SLPTIME_0) /* Wake up from the STOP mode, Delay 2us enable falsh*/
  83. #define LL_PWR_WAKEUP_FLASH_DELAY_3US (PWR_CR1_FLS_SLPTIME_1 ) /* Wake up from the STOP mode, Delay 3us enable falsh*/
  84. #define LL_PWR_WAKEUP_FLASH_DELAY_5US 0x00000000U /* Wake up from the STOP mode, Delay 5us enable falsh*/
  85. /**
  86. * @}
  87. */
  88. /** @defgroup PWR_LL_EC_WAKEUP_LP_TO_VR_READY_TIME WAKEUP LP TO VR READY TIME
  89. * @{
  90. */
  91. #define LL_PWR_WAKEUP_LP_TO_VR_READY_2US 0x00000000U /* Wake up from the STOP mode, LP to VR ready time 2us */
  92. #define LL_PWR_WAKEUP_LP_TO_VR_READY_3US ( PWR_CR1_MRRDY_TIME_0) /* Wake up from the STOP mode, LP to VR ready time 3us */
  93. #define LL_PWR_WAKEUP_LP_TO_VR_READY_4US (PWR_CR1_MRRDY_TIME_1 ) /* Wake up from the STOP mode, LP to VR ready time 4us */
  94. #define LL_PWR_WAKEUP_LP_TO_VR_READY_5US (PWR_CR1_MRRDY_TIME_1 | PWR_CR1_MRRDY_TIME_0) /* Wake up from the STOP mode, LP to VR ready time 5us */
  95. /**
  96. * @}
  97. */
  98. /** @defgroup PWR_LL_EC_BIAS_CURRENTS_SOURCE BIAS CURRENTS SOURCE
  99. * @{
  100. */
  101. #define LL_PWR_BIAS_CURRENTS_FROM_FACTORY_BYTES 0x00000000U /* MR bias currents source load from Factory config bytes */
  102. #define LL_PWR_BIAS_CURRENTS_FROM_BIAS_CR (PWR_CR1_BIAS_CR_SEL) /* MR bias currents source load from BIAS_CR */
  103. /**
  104. * @}
  105. */
  106. #if defined(PWR_CR2_PVDE)
  107. /** @defgroup PWR_LL_EC_PVDLEVEL PVDLEVEL
  108. * @{
  109. */
  110. #define LL_PWR_PVDLEVEL_0 0x000000000u /* VPVD0 (around 1.8V) */
  111. #define LL_PWR_PVDLEVEL_1 (PWR_CR2_PVDT_0) /* VPVD1 (around 2.0V) */
  112. #define LL_PWR_PVDLEVEL_2 (PWR_CR2_PVDT_1) /* VPVD2 (around 2.2V) */
  113. #define LL_PWR_PVDLEVEL_3 (PWR_CR2_PVDT_1 | PWR_CR2_PVDT_0) /* VPVD3 (around 2.4V) */
  114. #define LL_PWR_PVDLEVEL_4 (PWR_CR2_PVDT_2) /* VPVD4 (around 2.6V) */
  115. #define LL_PWR_PVDLEVEL_5 (PWR_CR2_PVDT_2 | PWR_CR2_PVDT_0) /* VPVD5 (around 2. 8V) */
  116. #define LL_PWR_PVDLEVEL_6 (PWR_CR2_PVDT_2 | PWR_CR2_PVDT_1) /* VPVD6 (around 3.0V) */
  117. #define LL_PWR_PVDLEVEL_7 (PWR_CR2_PVDT_2 | PWR_CR2_PVDT_1 | PWR_CR2_PVDT_0) /* VPVD7 (around 3.2V) */
  118. /**
  119. * @}
  120. */
  121. /** @defgroup PWR_LL_EC_PVDSOURCE PVDSOURCE
  122. * @{
  123. */
  124. #define LL_PWR_PVD_SOURCE_VCC 0
  125. #define LL_PWR_PVD_SOURCE_PB7 PWR_CR2_SRCSEL
  126. /**
  127. * @}
  128. */
  129. /** @defgroup PWR_LL_EC_PVDFILTER PVDFILTER
  130. * @{
  131. */
  132. #define LL_PWR_PVD_FILTER_1CLOCK (0x00000000u) /*!< PVD filter 1 clock */
  133. #define LL_PWR_PVD_FILTER_2CLOCK ( PWR_CR2_FLT_TIME_0) /*!< PVD filter 2 clock */
  134. #define LL_PWR_PVD_FILTER_4CLOCK ( PWR_CR2_FLT_TIME_1 ) /*!< PVD filter 2 clock */
  135. #define LL_PWR_PVD_FILTER_16CLOCK ( PWR_CR2_FLT_TIME_1 | PWR_CR2_FLT_TIME_0) /*!< PVD filter 4 clock */
  136. #define LL_PWR_PVD_FILTER_64CLOCK (PWR_CR2_FLT_TIME_2 ) /*!< PVD filter 16 clock */
  137. #define LL_PWR_PVD_FILTER_128CLOCK (PWR_CR2_FLT_TIME_2 | PWR_CR2_FLT_TIME_0) /*!< PVD filter 128 clock */
  138. #define LL_PWR_PVD_FILTER_1024CLOCK (PWR_CR2_FLT_TIME_2 | PWR_CR2_FLT_TIME_1 ) /*!< PVD filter 1024 clock */
  139. /**
  140. * @}
  141. */
  142. #endif /* PWR_CR2_PVDE */
  143. /** @defgroup PWR_LL_EC_GPIO_BIT GPIO BIT
  144. * @{
  145. */
  146. /**
  147. * @}
  148. */
  149. /**
  150. * @}
  151. */
  152. /* Exported macro ------------------------------------------------------------*/
  153. /** @defgroup PWR_LL_Exported_Macros PWR Exported Macros
  154. * @{
  155. */
  156. /** @defgroup PWR_LL_EM_WRITE_READ Common Write and read registers Macros
  157. * @{
  158. */
  159. /**
  160. * @brief Write a value in PWR register
  161. * @param __REG__ Register to be written
  162. * @param __VALUE__ Value to be written in the register
  163. * @retval None
  164. */
  165. #define LL_PWR_WriteReg(__REG__, __VALUE__) WRITE_REG(PWR->__REG__, (__VALUE__))
  166. /**
  167. * @brief Read a value in PWR register
  168. * @param __REG__ Register to be read
  169. * @retval Register value
  170. */
  171. #define LL_PWR_ReadReg(__REG__) READ_REG(PWR->__REG__)
  172. /**
  173. * @}
  174. */
  175. /**
  176. * @}
  177. */
  178. /* Exported functions --------------------------------------------------------*/
  179. /** @defgroup PWR_LL_Exported_Functions PWR Exported Functions
  180. * @{
  181. */
  182. /** @defgroup PWR_LL_EF_Configuration Configuration
  183. * @{
  184. */
  185. /**
  186. * @brief Set the main internal regulator output voltage
  187. * @rmtoll CR1 VOS LL_PWR_SetRegulVoltageScaling
  188. * @param VoltageScaling This parameter can be one of the following values:
  189. * @arg @ref LL_PWR_REGU_VOLTAGE_SCALE1
  190. * @arg @ref LL_PWR_REGU_VOLTAGE_SCALE2
  191. * @retval None
  192. */
  193. __STATIC_INLINE void LL_PWR_SetRegulVoltageScaling(uint32_t VoltageScaling)
  194. {
  195. MODIFY_REG(PWR->CR1, PWR_CR1_VOS, VoltageScaling);
  196. }
  197. /**
  198. * @brief Get the main internal regulator output voltage
  199. * @rmtoll CR1 VOS LL_PWR_GetRegulVoltageScaling
  200. * @retval Returned value can be one of the following values:
  201. * @arg @ref LL_PWR_REGU_VOLTAGE_SCALE1
  202. * @arg @ref LL_PWR_REGU_VOLTAGE_SCALE2
  203. */
  204. __STATIC_INLINE uint32_t LL_PWR_GetRegulVoltageScaling(void)
  205. {
  206. return (READ_BIT(PWR->CR1, PWR_CR1_VOS));
  207. }
  208. /**
  209. * @brief Switch the regulator from main mode to low-power mode
  210. * @rmtoll CR1 LPR LL_PWR_EnableLowPowerRunMode
  211. * @retval None
  212. */
  213. __STATIC_INLINE void LL_PWR_EnableLowPowerRunMode(void)
  214. {
  215. SET_BIT(PWR->CR1, PWR_CR1_LPR);
  216. }
  217. /**
  218. * @brief Switch the regulator from low-power mode to main mode
  219. * @rmtoll CR1 LPR LL_PWR_DisableLowPowerRunMode
  220. * @retval None
  221. */
  222. __STATIC_INLINE void LL_PWR_DisableLowPowerRunMode(void)
  223. {
  224. CLEAR_BIT(PWR->CR1, PWR_CR1_LPR);
  225. }
  226. /**
  227. * @brief Check if the regulator is in low-power mode
  228. * @rmtoll CR1 LPR LL_PWR_IsEnabledLowPowerRunMode
  229. * @retval State of bit (1 or 0).
  230. */
  231. __STATIC_INLINE uint32_t LL_PWR_IsEnabledLowPowerRunMode(void)
  232. {
  233. return (READ_BIT(PWR->CR1, PWR_CR1_LPR) == (PWR_CR1_LPR));
  234. }
  235. /**
  236. * @brief Switch the regulator from main mode to low-power mode.
  237. * @rmtoll CR1 LPR LL_PWR_EnterLowPowerRunMode
  238. * @retval None
  239. */
  240. __STATIC_INLINE void LL_PWR_EnterLowPowerRunMode(void)
  241. {
  242. LL_PWR_EnableLowPowerRunMode();
  243. }
  244. /**
  245. * @brief Switch the regulator from low-power mode to main mode.
  246. * @rmtoll CR1 LPR LL_PWR_ExitLowPowerRunMode
  247. * @retval None
  248. */
  249. __STATIC_INLINE void LL_PWR_ExitLowPowerRunMode(void)
  250. {
  251. LL_PWR_DisableLowPowerRunMode();
  252. }
  253. /**
  254. * @brief Enable access to the backup domain
  255. * @rmtoll CR1 DBP LL_PWR_EnableBkUpAccess
  256. * @retval None
  257. */
  258. __STATIC_INLINE void LL_PWR_EnableBkUpAccess(void)
  259. {
  260. SET_BIT(PWR->CR1, PWR_CR1_DBP);
  261. }
  262. /**
  263. * @brief Disable access to the backup domain
  264. * @rmtoll CR1 DBP LL_PWR_DisableBkUpAccess
  265. * @retval None
  266. */
  267. __STATIC_INLINE void LL_PWR_DisableBkUpAccess(void)
  268. {
  269. CLEAR_BIT(PWR->CR1, PWR_CR1_DBP);
  270. }
  271. /**
  272. * @brief Check if the backup domain is enabled
  273. * @rmtoll CR1 DBP LL_PWR_IsEnabledBkUpAccess
  274. * @retval State of bit (1 or 0).
  275. */
  276. __STATIC_INLINE uint32_t LL_PWR_IsEnabledBkUpAccess(void)
  277. {
  278. return (READ_BIT(PWR->CR1, PWR_CR1_DBP) == (PWR_CR1_DBP));
  279. }
  280. /**
  281. * @brief Set the HSI turn on mode after wake up
  282. * @rmtoll CR1 HSION_CTRL LL_PWR_SetWakeUpHSIOnMode
  283. * @param HsiOnMode This parameter can be one of the following values:
  284. * @arg @ref LL_PWR_WAKEUP_HSION_AFTER_MR
  285. * @arg @ref LL_PWR_WAKEUP_HSION_IMMEDIATE
  286. * @retval None
  287. */
  288. __STATIC_INLINE void LL_PWR_SetWakeUpHSIOnMode(uint32_t HsiOnMode)
  289. {
  290. MODIFY_REG(PWR->CR1, PWR_CR1_HSION_CTRL, HsiOnMode);
  291. }
  292. /**
  293. * @brief Get the HSI turn on mode after wake up
  294. * @rmtoll CR1 HSION_CTRL LL_PWR_GetWakeUpHSIOnMode
  295. * @retval Returned value can be one of the following values:
  296. * @arg @ref LL_PWR_WAKEUP_HSION_AFTER_MR
  297. * @arg @ref LL_PWR_WAKEUP_HSION_IMMEDIATE
  298. */
  299. __STATIC_INLINE uint32_t LL_PWR_GetWakeUpHSIOnMode(void)
  300. {
  301. return (uint32_t)(READ_BIT(PWR->CR1, PWR_CR1_HSION_CTRL));
  302. }
  303. /**
  304. * @brief Set the SRAM retention voltage in stop mode
  305. * @rmtoll CR1 SRAM_RETV LL_PWR_SetSramRetentionVolt
  306. * @param RetentionVolt This parameter can be one of the following values:
  307. * @arg @ref LL_PWR_SRAM_RETENTION_VOLT_0p9
  308. * @arg @ref LL_PWR_SRAM_RETENTION_VOLT_VOS
  309. * @retval None
  310. */
  311. __STATIC_INLINE void LL_PWR_SetSramRetentionVolt(uint32_t RetentionVolt)
  312. {
  313. MODIFY_REG(PWR->CR1, PWR_CR1_SRAM_RETV, RetentionVolt);
  314. }
  315. /**
  316. * @brief Get the SRAM retention voltage in stop mode
  317. * @rmtoll CR1 SRAM_RETV LL_PWR_GetSramRetentionVolt
  318. * @retval Returned value can be one of the following values:
  319. * @arg @ref LL_PWR_SRAM_RETENTION_VOLT_0p9
  320. * @arg @ref LL_PWR_SRAM_RETENTION_VOLT_VOS
  321. */
  322. __STATIC_INLINE uint32_t LL_PWR_GetSramRetentionVolt(void)
  323. {
  324. return (uint32_t)(READ_BIT(PWR->CR1, PWR_CR1_SRAM_RETV));
  325. }
  326. /**
  327. * @brief Set the flash delay time after wake up
  328. * @rmtoll CR1 FLS_SLPTIME LL_PWR_SetWakeUpFlashDelay
  329. * @param FlashDelay This parameter can be one of the following values:
  330. * @arg @ref LL_PWR_WAKEUP_FLASH_DELAY_0US
  331. * @arg @ref LL_PWR_WAKEUP_FLASH_DELAY_2US
  332. * @arg @ref LL_PWR_WAKEUP_FLASH_DELAY_3US
  333. * @arg @ref LL_PWR_WAKEUP_FLASH_DELAY_5US
  334. * @retval None
  335. */
  336. __STATIC_INLINE void LL_PWR_SetWakeUpFlashDelay(uint32_t FlashDelay)
  337. {
  338. MODIFY_REG(PWR->CR1, PWR_CR1_FLS_SLPTIME, FlashDelay);
  339. }
  340. /**
  341. * @brief Get the flash delay time after wake up
  342. * @rmtoll CR1 FLS_SLPTIME LL_PWR_GetWakeUpFlashDelay
  343. * @retval Returned value can be one of the following values:
  344. * @arg @ref LL_PWR_WAKEUP_FLASH_DELAY_0US
  345. * @arg @ref LL_PWR_WAKEUP_FLASH_DELAY_2US
  346. * @arg @ref LL_PWR_WAKEUP_FLASH_DELAY_3US
  347. * @arg @ref LL_PWR_WAKEUP_FLASH_DELAY_5US
  348. */
  349. __STATIC_INLINE uint32_t LL_PWR_GetWakeUpFlashDelay(void)
  350. {
  351. return (uint32_t)(READ_BIT(PWR->CR1, PWR_CR1_FLS_SLPTIME));
  352. }
  353. /**
  354. * @brief Set VDD voltage from LP to VR ready time after wake up
  355. * @rmtoll CR1 MRRDY_TIME LL_PWR_SetWakeUpLPToVRReadyTime
  356. * @param ReadyTime This parameter can be one of the following values:
  357. * @arg @ref LL_PWR_WAKEUP_LP_TO_VR_READY_2US
  358. * @arg @ref LL_PWR_WAKEUP_LP_TO_VR_READY_3US
  359. * @arg @ref LL_PWR_WAKEUP_LP_TO_VR_READY_4US
  360. * @arg @ref LL_PWR_WAKEUP_LP_TO_VR_READY_5US
  361. * @retval None
  362. */
  363. __STATIC_INLINE void LL_PWR_SetWakeUpLPToVRReadyTime(uint32_t ReadyTime)
  364. {
  365. MODIFY_REG(PWR->CR1, PWR_CR1_MRRDY_TIME, ReadyTime);
  366. }
  367. /**
  368. * @brief Get the LP to VR ready time after wake up
  369. * @rmtoll CR1 MRRDY_TIME LL_PWR_GetWakeUpLPToVRReadyTime
  370. * @retval Returned value can be one of the following values:
  371. * @arg @ref LL_PWR_WAKEUP_LP_TO_VR_READY_2US
  372. * @arg @ref LL_PWR_WAKEUP_LP_TO_VR_READY_3US
  373. * @arg @ref LL_PWR_WAKEUP_LP_TO_VR_READY_4US
  374. * @arg @ref LL_PWR_WAKEUP_LP_TO_VR_READY_5US
  375. */
  376. __STATIC_INLINE uint32_t LL_PWR_GetWakeUpLPToVRReadyTime(void)
  377. {
  378. return (uint32_t)(READ_BIT(PWR->CR1, PWR_CR1_MRRDY_TIME));
  379. }
  380. /**
  381. * @brief Set the bias currents load source and bias currents config value.
  382. * @rmtoll CR1 BIAS_CR_SEL | BIAS_CR LL_PWR_SetBiasCurrents
  383. * @param BiasCurSel This parameter can be one of the following values:
  384. * @arg @ref LL_PWR_BIAS_CURRENTS_FROM_FACTORY_BYTES
  385. * @arg @ref LL_PWR_BIAS_CURRENTS_FROM_BIAS_CR
  386. * @param BiasCur This parameter must be a number between 0x0000 and 0xFFFF
  387. * @retval None
  388. */
  389. __STATIC_INLINE void LL_PWR_SetBiasCurrents(uint32_t BiasCurSel, uint32_t BiasCur)
  390. {
  391. MODIFY_REG(PWR->CR1, (PWR_CR1_BIAS_CR_SEL | PWR_CR1_BIAS_CR), (BiasCurSel | BiasCur));
  392. }
  393. /**
  394. * @brief Get the bias currents load source
  395. * @rmtoll CR1 BIAS_CR_SEL LL_PWR_GetBiasCurrentsLoadSource
  396. * @retval Returned value can be one of the following values:
  397. * @arg @ref LL_PWR_BIAS_CURRENTS_FROM_FACTORY_BYTES
  398. * @arg @ref LL_PWR_BIAS_CURRENTS_FROM_BIAS_CR
  399. */
  400. __STATIC_INLINE uint32_t LL_PWR_GetBiasCurrentsLoadSource(void)
  401. {
  402. return (uint32_t)(READ_BIT(PWR->CR1, PWR_CR1_BIAS_CR_SEL));
  403. }
  404. /**
  405. * @brief Get the bias currents config value
  406. * @rmtoll CR1 BIAS_CR LL_PWR_GetBiasCRValue
  407. * @retval Returned value can be number between 0x00 and 0x0F
  408. */
  409. __STATIC_INLINE uint32_t LL_PWR_GetBiasCRValue(void)
  410. {
  411. return (uint32_t)(READ_BIT(PWR->CR1, PWR_CR1_BIAS_CR));
  412. }
  413. #if defined (PWR_CR2_PVDE)
  414. /**
  415. * @brief Configure the voltage threshold detected by the Power Voltage Detector
  416. * @param PVDLevel This parameter can be one of the following values:
  417. * @arg @ref LL_PWR_PVDLEVEL_0
  418. * @arg @ref LL_PWR_PVDLEVEL_1
  419. * @arg @ref LL_PWR_PVDLEVEL_2
  420. * @arg @ref LL_PWR_PVDLEVEL_3
  421. * @arg @ref LL_PWR_PVDLEVEL_4
  422. * @arg @ref LL_PWR_PVDLEVEL_5
  423. * @arg @ref LL_PWR_PVDLEVEL_6
  424. * @arg @ref LL_PWR_PVDLEVEL_7
  425. * @retval None
  426. */
  427. __STATIC_INLINE void LL_PWR_SetPVDLevel(uint32_t PVDLevel)
  428. {
  429. MODIFY_REG(PWR->CR2, PWR_CR2_PVDT, PVDLevel);
  430. }
  431. /**
  432. * @brief Get the voltage threshold detection
  433. * @retval Returned value can be one of the following values:
  434. * @arg @ref LL_PWR_PVDLEVEL_0
  435. * @arg @ref LL_PWR_PVDLEVEL_1
  436. * @arg @ref LL_PWR_PVDLEVEL_2
  437. * @arg @ref LL_PWR_PVDLEVEL_3
  438. * @arg @ref LL_PWR_PVDLEVEL_4
  439. * @arg @ref LL_PWR_PVDLEVEL_5
  440. * @arg @ref LL_PWR_PVDLEVEL_6
  441. * @arg @ref LL_PWR_PVDLEVEL_7
  442. */
  443. __STATIC_INLINE uint32_t LL_PWR_GetPVDLevel(void)
  444. {
  445. return (uint32_t)(READ_BIT(PWR->CR2, PWR_CR2_PVDT));
  446. }
  447. /**
  448. * @brief Enable Power Voltage Detector
  449. * @rmtoll CR2 PVDE LL_PWR_EnablePVD
  450. * @retval None
  451. */
  452. __STATIC_INLINE void LL_PWR_EnablePVD(void)
  453. {
  454. SET_BIT(PWR->CR2, PWR_CR2_PVDE);
  455. }
  456. /**
  457. * @brief Disable Power Voltage Detector
  458. * @rmtoll CR2 PVDE LL_PWR_DisablePVD
  459. * @retval None
  460. */
  461. __STATIC_INLINE void LL_PWR_DisablePVD(void)
  462. {
  463. CLEAR_BIT(PWR->CR2, PWR_CR2_PVDE);
  464. }
  465. /**
  466. * @brief Check if Power Voltage Detector is enabled
  467. * @rmtoll CR2 PVDE LL_PWR_IsEnabledPVD
  468. * @retval State of bit (1 or 0).
  469. */
  470. __STATIC_INLINE uint32_t LL_PWR_IsEnabledPVD(void)
  471. {
  472. return (READ_BIT(PWR->CR2, PWR_CR2_PVDE) == (PWR_CR2_PVDE));
  473. }
  474. /**
  475. * @brief PVD detection power supply selection
  476. * @rmtoll CR2 PWR_CR2_SRCSEL LL_PWR_SetPVDSource
  477. * @param PVDSrc This parameter can be one of the following values:
  478. * @arg @ref LL_PWR_PVD_SOURCE_VCC
  479. * @arg @ref LL_PWR_PVD_SOURCE_PB7
  480. * @retval None
  481. */
  482. __STATIC_INLINE void LL_PWR_SetPVDSource(uint32_t PVDSrc)
  483. {
  484. MODIFY_REG(PWR->CR2, PWR_CR2_SRCSEL, PVDSrc);
  485. }
  486. /**
  487. * @brief Get PVD detection power supply
  488. * @rmtoll CR2 PWR_CR2_SRCSEL LL_PWR_GetPVDSource
  489. * @retval Returned value can be one of the following values:
  490. * @arg @ref LL_PWR_PVD_SOURCE_VCC
  491. * @arg @ref LL_PWR_PVD_SOURCE_PB7
  492. */
  493. __STATIC_INLINE uint32_t LL_PWR_GetPVDSource(void)
  494. {
  495. return (uint32_t)(READ_BIT(PWR->CR2, PWR_CR2_SRCSEL));
  496. }
  497. /**
  498. * @brief Enable PVD Filter
  499. * @rmtoll CR2 FLTEN LL_PWR_EnablePVDFilter
  500. * @retval None
  501. */
  502. __STATIC_INLINE void LL_PWR_EnablePVDFilter(void)
  503. {
  504. SET_BIT(PWR->CR2, PWR_CR2_FLTEN);
  505. }
  506. /**
  507. * @brief Disable PVD Filter
  508. * @rmtoll CR2 FLTEN LL_PWR_DisablePVDFilter
  509. * @retval None
  510. */
  511. __STATIC_INLINE void LL_PWR_DisablePVDFilter(void)
  512. {
  513. CLEAR_BIT(PWR->CR2, PWR_CR2_FLTEN);
  514. }
  515. /**
  516. * @brief Check if PVD Filter is enabled
  517. * @rmtoll CR2 FLTEN LL_PWR_IsEnabledPVDFilter
  518. * @retval State of bit (1 or 0).
  519. */
  520. __STATIC_INLINE uint32_t LL_PWR_IsEnabledPVDFilter(void)
  521. {
  522. return (READ_BIT(PWR->CR2, PWR_CR2_FLTEN) == (PWR_CR2_FLTEN));
  523. }
  524. /**
  525. * @brief PVD detection power supply selection
  526. * @rmtoll CR2 PWR_CR2_FLT_TIME LL_PWR_SetPVDFilter
  527. * @param PVDFilter This parameter can be one of the following values:
  528. * @arg @ref LL_PWR_PVD_FILTER_1CLOCK
  529. * @arg @ref LL_PWR_PVD_FILTER_2CLOCK
  530. * @arg @ref LL_PWR_PVD_FILTER_4CLOCK
  531. * @arg @ref LL_PWR_PVD_FILTER_16CLOCK
  532. * @arg @ref LL_PWR_PVD_FILTER_64CLOCK
  533. * @arg @ref LL_PWR_PVD_FILTER_128CLOCK
  534. * @arg @ref LL_PWR_PVD_FILTER_1024CLOCK
  535. * @retval None
  536. */
  537. __STATIC_INLINE void LL_PWR_SetPVDFilter(uint32_t PVDFilter)
  538. {
  539. MODIFY_REG(PWR->CR2, PWR_CR2_FLT_TIME, PVDFilter);
  540. }
  541. /**
  542. * @brief Get PVD detection power supply
  543. * @rmtoll CR2 PWR_CR2_FLT_TIME LL_PWR_GetPVDFilter
  544. * @retval Returned value can be one of the following values:
  545. * @arg @ref LL_PWR_PVD_FILTER_1CLOCK
  546. * @arg @ref LL_PWR_PVD_FILTER_2CLOCK
  547. * @arg @ref LL_PWR_PVD_FILTER_4CLOCK
  548. * @arg @ref LL_PWR_PVD_FILTER_16CLOCK
  549. * @arg @ref LL_PWR_PVD_FILTER_64CLOCK
  550. * @arg @ref LL_PWR_PVD_FILTER_128CLOCK
  551. * @arg @ref LL_PWR_PVD_FILTER_1024CLOCK
  552. */
  553. __STATIC_INLINE uint32_t LL_PWR_GetPVDFilter(void)
  554. {
  555. return (uint32_t)(READ_BIT(PWR->CR2, PWR_CR2_FLT_TIME));
  556. }
  557. /**
  558. * @}
  559. */
  560. /** @defgroup PWR_LL_EF_FLAG_Management FLAG Management
  561. * @{
  562. */
  563. /**
  564. * @brief Indicate whether Detected voltage is below or above the selected PVD
  565. * threshold
  566. * @retval State of bit (1 or 0).
  567. */
  568. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_PVDO(void)
  569. {
  570. return (READ_BIT(PWR->SR, PWR_SR_PVDO) == (PWR_SR_PVDO));
  571. }
  572. #endif /* PWR_CR2_PVDE */
  573. /**
  574. * @}
  575. */
  576. #if defined(USE_FULL_LL_DRIVER)
  577. /** @defgroup PWR_LL_EF_Init De-initialization function
  578. * @{
  579. */
  580. ErrorStatus LL_PWR_DeInit(void);
  581. /**
  582. * @}
  583. */
  584. #endif /* USE_FULL_LL_DRIVER */
  585. /**
  586. * @}
  587. */
  588. /**
  589. * @}
  590. */
  591. #endif /* defined(PWR) */
  592. /**
  593. * @}
  594. */
  595. #ifdef __cplusplus
  596. }
  597. #endif
  598. #endif /* PY32F0XX_LL_PWR_H */
  599. /************************ (C) COPYRIGHT Puya *****END OF FILE****/