py32f0xx_ll_rcc.h 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914
  1. /**
  2. ******************************************************************************
  3. * @file py32f0xx_ll_rcc.h
  4. * @author MCU Application Team
  5. * @brief Header file of RCC 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_RCC_H
  32. #define __PY32F0XX_LL_RCC_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(RCC)
  42. /** @defgroup RCC_LL RCC
  43. * @{
  44. */
  45. /* Private types -------------------------------------------------------------*/
  46. /* Private variables ---------------------------------------------------------*/
  47. /** @defgroup RCC_LL_Private_Variables RCC Private Variables
  48. * @{
  49. */
  50. /**
  51. * @}
  52. */
  53. /* Private constants ---------------------------------------------------------*/
  54. /* Private macros ------------------------------------------------------------*/
  55. #if defined(USE_FULL_LL_DRIVER)
  56. /** @defgroup RCC_LL_Private_Macros RCC Private Macros
  57. * @{
  58. */
  59. /**
  60. * @}
  61. */
  62. #endif /*USE_FULL_LL_DRIVER*/
  63. /* Exported types ------------------------------------------------------------*/
  64. #if defined(USE_FULL_LL_DRIVER)
  65. /** @defgroup RCC_LL_Exported_Types RCC Exported Types
  66. * @{
  67. */
  68. /** @defgroup LL_ES_CLOCK_FREQ Clocks Frequency Structure
  69. * @{
  70. */
  71. /**
  72. * @brief RCC Clocks Frequency Structure
  73. */
  74. typedef struct
  75. {
  76. uint32_t SYSCLK_Frequency; /*!< SYSCLK clock frequency */
  77. uint32_t HCLK_Frequency; /*!< HCLK clock frequency */
  78. uint32_t PCLK1_Frequency; /*!< PCLK1 clock frequency */
  79. } LL_RCC_ClocksTypeDef;
  80. /**
  81. * @}
  82. */
  83. /**
  84. * @}
  85. */
  86. #endif /* USE_FULL_LL_DRIVER */
  87. /* Exported constants --------------------------------------------------------*/
  88. /** @defgroup RCC_LL_Exported_Constants RCC Exported Constants
  89. * @{
  90. */
  91. /** @defgroup RCC_LL_EC_OSC_VALUES Oscillator Values adaptation
  92. * @brief Defines used to adapt values of different oscillators
  93. * @note These values could be modified in the user environment according to
  94. * HW set-up.
  95. * @{
  96. */
  97. #if !defined (HSE_VALUE)
  98. #define HSE_VALUE 24000000U /*!< Value of the HSE oscillator in Hz */
  99. #endif /* HSE_VALUE */
  100. #if !defined (HSI_VALUE)
  101. #define HSI_VALUE 8000000U /*!< Value of the HSI oscillator in Hz */
  102. #endif /* HSI_VALUE */
  103. #if defined(RCC_LSE_SUPPORT)
  104. #if !defined (LSE_VALUE)
  105. #define LSE_VALUE 32768U /*!< Value of the LSE oscillator in Hz */
  106. #endif /* LSE_VALUE */
  107. #endif
  108. #if !defined (LSI_VALUE)
  109. #define LSI_VALUE 32768U /*!< Value of the LSI oscillator in Hz */
  110. #endif /* LSI_VALUE */
  111. /**
  112. * @}
  113. */
  114. /** @defgroup RCC_LL_EC_CLEAR_FLAG Clear Flags Defines
  115. * @brief Flags defines which can be used with LL_RCC_WriteReg function
  116. * @{
  117. */
  118. #define LL_RCC_CICR_LSIRDYC RCC_CICR_LSIRDYC /*!< LSI Ready Interrupt Clear */
  119. #define LL_RCC_CICR_HSIRDYC RCC_CICR_HSIRDYC /*!< HSI Ready Interrupt Clear */
  120. #define LL_RCC_CICR_HSERDYC RCC_CICR_HSERDYC /*!< HSE Ready Interrupt Clear */
  121. #if defined(RCC_PLL_SUPPORT)
  122. #define LL_RCC_CICR_PLLRDYC RCC_CICR_PLLRDYC /*!< PLL Ready Interrupt Clear */
  123. #endif
  124. #if defined(RCC_LSE_SUPPORT)
  125. #define LL_RCC_CICR_LSERDYC RCC_CICR_LSERDYC /*!< LSE Ready Interrupt Clear */
  126. #define LL_RCC_CICR_LSECSSC RCC_CICR_LSECSSC /*!< LSE Clock Security System Interrupt Clear */
  127. #endif
  128. #define LL_RCC_CICR_CSSC RCC_CICR_CSSC /*!< Clock Security System Interrupt Clear */
  129. /**
  130. * @}
  131. */
  132. /** @defgroup RCC_LL_EC_GET_FLAG Get Flags Defines
  133. * @brief Flags defines which can be used with LL_RCC_ReadReg function
  134. * @{
  135. */
  136. #define LL_RCC_CIFR_LSIRDYF RCC_CIFR_LSIRDYF /*!< LSI Ready Interrupt flag */
  137. #define LL_RCC_CIFR_HSIRDYF RCC_CIFR_HSIRDYF /*!< HSI Ready Interrupt flag */
  138. #define LL_RCC_CIFR_HSERDYF RCC_CIFR_HSERDYF /*!< HSE Ready Interrupt flag */
  139. #if defined(RCC_PLL_SUPPORT)
  140. #define LL_RCC_CIFR_PLLRDYF RCC_CIFR_PLLRDYF /*!< PLL Ready Interrupt flag */
  141. #endif
  142. #if defined(RCC_LSE_SUPPORT)
  143. #define LL_RCC_CIFR_LSERDYF RCC_CIFR_LSERDYF /*!< LSE Ready Interrupt flag */
  144. #define LL_RCC_CIFR_LSECSSF RCC_CIFR_LSECSSF /*!< LSE Clock Security System Interrupt flag */
  145. #endif
  146. #define LL_RCC_CIFR_CSSF RCC_CIFR_CSSF /*!< Clock Security System Interrupt flag */
  147. #define LL_RCC_CSR_OBLRSTF RCC_CSR_OBLRSTF /*!< OBL reset flag */
  148. #define LL_RCC_CSR_PINRSTF RCC_CSR_PINRSTF /*!< PIN reset flag */
  149. #define LL_RCC_CSR_SFTRSTF RCC_CSR_SFTRSTF /*!< Software Reset flag */
  150. #define LL_RCC_CSR_IWDGRSTF RCC_CSR_IWDGRSTF /*!< Independent Watchdog reset flag */
  151. #if defined(WWDG)
  152. #define LL_RCC_CSR_WWDGRSTF RCC_CSR_WWDGRSTF /*!< Window watchdog reset flag */
  153. #endif
  154. #define LL_RCC_CSR_PWRRSTF RCC_CSR_PWRRSTF /*!< BOR or POR/PDR reset flag */
  155. /**
  156. * @}
  157. */
  158. /** @defgroup RCC_LL_EC_IT IT Defines
  159. * @brief IT defines which can be used with LL_RCC_ReadReg and LL_RCC_WriteReg functions
  160. * @{
  161. */
  162. #define LL_RCC_CIER_LSIRDYIE RCC_CIER_LSIRDYIE /*!< LSI Ready Interrupt Enable */
  163. #if defined(RCC_LSE_SUPPORT)
  164. #define LL_RCC_CIER_LSERDYIE RCC_CIER_LSERDYIE /*!< LSE Ready Interrupt Enable */
  165. #endif
  166. #define LL_RCC_CIER_HSIRDYIE RCC_CIER_HSIRDYIE /*!< HSI Ready Interrupt Enable */
  167. #define LL_RCC_CIER_HSERDYIE RCC_CIER_HSERDYIE /*!< HSE Ready Interrupt Enable */
  168. #if defined(RCC_PLL_SUPPORT)
  169. #define LL_RCC_CIER_PLLRDYIE RCC_CIER_PLLRDYIE /*!< PLL Ready Interrupt Enable */
  170. #endif
  171. /**
  172. * @}
  173. */
  174. #if defined(RCC_LSE_SUPPORT)
  175. /** @defgroup RCC_LL_EC_LSEDRIVE LSE oscillator drive capability
  176. * @{
  177. */
  178. #define LL_RCC_LSEDRIVE_CLOSE 0x00000000 /*!< Xtal mode driving capability closed */
  179. #define LL_RCC_LSEDRIVE_LOW RCC_ECSCR_LSE_DRIVER_0 /*!< Xtal mode lower driving capability */
  180. #define LL_RCC_LSEDRIVE_MEDIUM RCC_ECSCR_LSE_DRIVER_1 /*!< Xtal mode medium driving capability */
  181. #define LL_RCC_LSEDRIVE_HIGH RCC_ECSCR_LSE_DRIVER /*!< Xtal mode higher driving capability */
  182. /**
  183. * @}
  184. */
  185. #endif
  186. #if defined(RCC_BDCR_LSCOSEL)
  187. /** @defgroup RCC_LL_EC_LSCO_CLKSOURCE LSCO Selection
  188. * @{
  189. */
  190. #define LL_RCC_LSCO_CLKSOURCE_LSI 0x00000000U /*!< LSI selection for low speed clock */
  191. #define LL_RCC_LSCO_CLKSOURCE_LSE RCC_BDCR_LSCOSEL /*!< LSE selection for low speed clock */
  192. /**
  193. * @}
  194. */
  195. #endif
  196. /** @defgroup RCC_LL_EC_SYS_CLKSOURCE System clock switch
  197. * @{
  198. */
  199. #define LL_RCC_SYS_CLKSOURCE_HSISYS 0x00000000U /*!< HSISYS selection as system clock */
  200. #define LL_RCC_SYS_CLKSOURCE_HSE RCC_CFGR_SW_0 /*!< HSE selection as system clock */
  201. #if defined(RCC_PLL_SUPPORT)
  202. #define LL_RCC_SYS_CLKSOURCE_PLL RCC_CFGR_SW_1 /*!< PLL selection as system clock */
  203. #endif
  204. #define LL_RCC_SYS_CLKSOURCE_LSI (RCC_CFGR_SW_1 | RCC_CFGR_SW_0) /*!< LSI selection used as system clock */
  205. #if defined(RCC_LSE_SUPPORT)
  206. #define LL_RCC_SYS_CLKSOURCE_LSE RCC_CFGR_SW_2 /*!< LSE selection used as system clock */
  207. #endif
  208. /**
  209. * @}
  210. */
  211. /** @defgroup RCC_LL_EC_SYS_CLKSOURCE_STATUS System clock switch status
  212. * @{
  213. */
  214. #define LL_RCC_SYS_CLKSOURCE_STATUS_HSISYS 0x00000000U /*!< HSISYS used as system clock */
  215. #define LL_RCC_SYS_CLKSOURCE_STATUS_HSE RCC_CFGR_SWS_0 /*!< HSE used as system clock */
  216. #if defined(RCC_PLL_SUPPORT)
  217. #define LL_RCC_SYS_CLKSOURCE_STATUS_PLL RCC_CFGR_SWS_1 /*!< PLL used as system clock */
  218. #endif
  219. #define LL_RCC_SYS_CLKSOURCE_STATUS_LSI (RCC_CFGR_SWS_1 | RCC_CFGR_SWS_0) /*!< LSI used as system clock */
  220. #if defined(RCC_LSE_SUPPORT)
  221. #define LL_RCC_SYS_CLKSOURCE_STATUS_LSE RCC_CFGR_SWS_2 /*!< LSE used as system clock */
  222. #endif
  223. /**
  224. * @}
  225. */
  226. /** @defgroup RCC_LL_EC_SYSCLK_DIV AHB prescaler
  227. * @{
  228. */
  229. #define LL_RCC_SYSCLK_DIV_1 0x00000000U /*!< SYSCLK not divided */
  230. #define LL_RCC_SYSCLK_DIV_2 RCC_CFGR_HPRE_3 /*!< SYSCLK divided by 2 */
  231. #define LL_RCC_SYSCLK_DIV_4 (RCC_CFGR_HPRE_3 | RCC_CFGR_HPRE_0) /*!< SYSCLK divided by 4 */
  232. #define LL_RCC_SYSCLK_DIV_8 (RCC_CFGR_HPRE_3 | RCC_CFGR_HPRE_1) /*!< SYSCLK divided by 8 */
  233. #define LL_RCC_SYSCLK_DIV_16 (RCC_CFGR_HPRE_3 | RCC_CFGR_HPRE_1 | RCC_CFGR_HPRE_0) /*!< SYSCLK divided by 16 */
  234. #define LL_RCC_SYSCLK_DIV_64 (RCC_CFGR_HPRE_3 | RCC_CFGR_HPRE_2) /*!< SYSCLK divided by 64 */
  235. #define LL_RCC_SYSCLK_DIV_128 (RCC_CFGR_HPRE_3 | RCC_CFGR_HPRE_2 | RCC_CFGR_HPRE_0) /*!< SYSCLK divided by 128 */
  236. #define LL_RCC_SYSCLK_DIV_256 (RCC_CFGR_HPRE_3 | RCC_CFGR_HPRE_2 | RCC_CFGR_HPRE_1) /*!< SYSCLK divided by 256 */
  237. #define LL_RCC_SYSCLK_DIV_512 (RCC_CFGR_HPRE_3 | RCC_CFGR_HPRE_2 | RCC_CFGR_HPRE_1 | RCC_CFGR_HPRE_0) /*!< SYSCLK divided by 512 */
  238. /**
  239. * @}
  240. */
  241. /** @defgroup RCC_LL_EC_APB1_DIV APB1 low-speed prescaler (APB1)
  242. * @{
  243. */
  244. #define LL_RCC_APB1_DIV_1 0x00000000U /*!< HCLK not divided */
  245. #define LL_RCC_APB1_DIV_2 RCC_CFGR_PPRE_2 /*!< HCLK divided by 2 */
  246. #define LL_RCC_APB1_DIV_4 (RCC_CFGR_PPRE_2 | RCC_CFGR_PPRE_0) /*!< HCLK divided by 4 */
  247. #define LL_RCC_APB1_DIV_8 (RCC_CFGR_PPRE_2 | RCC_CFGR_PPRE_1) /*!< HCLK divided by 8 */
  248. #define LL_RCC_APB1_DIV_16 (RCC_CFGR_PPRE_2 | RCC_CFGR_PPRE_1 | RCC_CFGR_PPRE_0) /*!< HCLK divided by 16 */
  249. /**
  250. * @}
  251. */
  252. #if defined(RCC_HSIDIV_SUPPORT)
  253. /** @defgroup RCC_LL_EC_HSI_DIV HSI division factor
  254. * @{
  255. */
  256. #define LL_RCC_HSI_DIV_1 0x00000000U /*!< HSI not divided */
  257. #define LL_RCC_HSI_DIV_2 RCC_CR_HSIDIV_0 /*!< HSI divided by 2 */
  258. #define LL_RCC_HSI_DIV_4 RCC_CR_HSIDIV_1 /*!< HSI divided by 4 */
  259. #define LL_RCC_HSI_DIV_8 (RCC_CR_HSIDIV_1 | RCC_CR_HSIDIV_0) /*!< HSI divided by 8 */
  260. #define LL_RCC_HSI_DIV_16 RCC_CR_HSIDIV_2 /*!< HSI divided by 16 */
  261. #define LL_RCC_HSI_DIV_32 (RCC_CR_HSIDIV_2 | RCC_CR_HSIDIV_0) /*!< HSI divided by 32 */
  262. #define LL_RCC_HSI_DIV_64 (RCC_CR_HSIDIV_2 | RCC_CR_HSIDIV_1) /*!< HSI divided by 64 */
  263. #define LL_RCC_HSI_DIV_128 RCC_CR_HSIDIV /*!< HSI divided by 128 */
  264. /**
  265. * @}
  266. */
  267. #endif
  268. /** @defgroup RCC_LL_EC_MCO1SOURCE MCO1 SOURCE selection
  269. * @{
  270. */
  271. #define LL_RCC_MCO1SOURCE_NOCLOCK 0x00000000U /*!< MCO output disabled, no clock on MCO */
  272. #define LL_RCC_MCO1SOURCE_SYSCLK RCC_CFGR_MCOSEL_0 /*!< SYSCLK selection as MCO1 source */
  273. #define LL_RCC_MCO1SOURCE_HSI (RCC_CFGR_MCOSEL_0| RCC_CFGR_MCOSEL_1) /*!< HSI selection as MCO1 source */
  274. #define LL_RCC_MCO1SOURCE_HSE RCC_CFGR_MCOSEL_2 /*!< HSE selection as MCO1 source */
  275. #if defined(RCC_PLL_SUPPORT)
  276. #define LL_RCC_MCO1SOURCE_PLLCLK (RCC_CFGR_MCOSEL_0|RCC_CFGR_MCOSEL_2) /*!< Main PLL selection as MCO1 source */
  277. #endif
  278. #define LL_RCC_MCO1SOURCE_LSI (RCC_CFGR_MCOSEL_1|RCC_CFGR_MCOSEL_2) /*!< LSI selection as MCO1 source */
  279. #if defined(RCC_LSE_SUPPORT)
  280. #define LL_RCC_MCO1SOURCE_LSE (RCC_CFGR_MCOSEL_0|RCC_CFGR_MCOSEL_1|RCC_CFGR_MCOSEL_2) /*!< LSE selection as MCO1 source */
  281. #endif
  282. /**
  283. * @}
  284. */
  285. /** @defgroup RCC_LL_EC_MCO Peripheral MCO get clock source
  286. * @{
  287. */
  288. #define LL_RCC_MCO1_CLKSOURCE RCC_CFGR_MCOSEL /*!< MCO1 Clock source selection */
  289. /**
  290. * @}
  291. */
  292. /** @defgroup RCC_LL_EC_MCO1_DIV MCO1 prescaler
  293. * @{
  294. */
  295. #define LL_RCC_MCO1_DIV_1 0x00000000U /*!< MCO1 not divided */
  296. #define LL_RCC_MCO1_DIV_2 RCC_CFGR_MCOPRE_0 /*!< MCO1 divided by 2 */
  297. #define LL_RCC_MCO1_DIV_4 RCC_CFGR_MCOPRE_1 /*!< MCO1 divided by 4 */
  298. #define LL_RCC_MCO1_DIV_8 (RCC_CFGR_MCOPRE_1 | RCC_CFGR_MCOPRE_0) /*!< MCO1 divided by 8 */
  299. #define LL_RCC_MCO1_DIV_16 RCC_CFGR_MCOPRE_2 /*!< MCO1 divided by 16 */
  300. #define LL_RCC_MCO1_DIV_32 (RCC_CFGR_MCOPRE_2 | RCC_CFGR_MCOPRE_0) /*!< MCO1 divided by 32 */
  301. #define LL_RCC_MCO1_DIV_64 (RCC_CFGR_MCOPRE_2 | RCC_CFGR_MCOPRE_1) /*!< MCO1 divided by 64 */
  302. #define LL_RCC_MCO1_DIV_128 (RCC_CFGR_MCOPRE_2 | RCC_CFGR_MCOPRE_1 | RCC_CFGR_MCOPRE_0) /*!< MCO1 divided by 128 */
  303. /**
  304. * @}
  305. */
  306. #if defined(USE_FULL_LL_DRIVER)
  307. /** @defgroup RCC_LL_EC_PERIPH_FREQUENCY Peripheral clock frequency
  308. * @{
  309. */
  310. #define LL_RCC_PERIPH_FREQUENCY_NO 0x00000000U /*!< No clock enabled for the peripheral */
  311. #define LL_RCC_PERIPH_FREQUENCY_NA 0xFFFFFFFFU /*!< Frequency cannot be provided as external clock */
  312. /**
  313. * @}
  314. */
  315. #endif /* USE_FULL_LL_DRIVER */
  316. #if defined(RCC_CCIPR_PVDSEL)
  317. /** @defgroup RCC_LL_EC_PVD_CLKSOURCE Peripheral PVD clock source selection
  318. * @{
  319. */
  320. #define LL_RCC_PVD_CLKSOURCE_PCLK1 0x00000000U /*!< PCLK1 selected as PVD clock */
  321. #define LL_RCC_PVD_CLKSOURCE_LSC RCC_CCIPR_PVDSEL /*!< LSC selected as PVD clock */
  322. /**
  323. * @}
  324. */
  325. #endif
  326. #if defined(COMP1)
  327. /** @defgroup RCC_LL_EC_COMPx_CLKSOURCE Peripheral COMP clock source selection
  328. * @{
  329. */
  330. #define LL_RCC_COMP1_CLKSOURCE_PCLK1 (RCC_CCIPR_COMP1SEL | (0x00000000U >> 8U)) /*!< PCLK1 selected as COMP1 clock */
  331. #define LL_RCC_COMP1_CLKSOURCE_LSC (RCC_CCIPR_COMP1SEL | (RCC_CCIPR_COMP1SEL >> 8U)) /*!< LSC selected as COMP1 clock */
  332. #if defined(COMP2)
  333. #define LL_RCC_COMP2_CLKSOURCE_PCLK1 (RCC_CCIPR_COMP2SEL | (0x00000000U >> 8U)) /*!< PCLK1 selected as COMP2 clock */
  334. #define LL_RCC_COMP2_CLKSOURCE_LSC (RCC_CCIPR_COMP2SEL | (RCC_CCIPR_COMP2SEL >> 8U)) /*!< LSC selected as COMP2 clock */
  335. #endif
  336. /**
  337. * @}
  338. */
  339. #endif /* COMP1 && COMP2 */
  340. #if defined(RCC_CCIPR_LPTIMSEL)
  341. /** @defgroup RCC_LL_EC_LPTIMx_CLKSOURCE Peripheral LPTIM clock source selection
  342. * @{
  343. */
  344. #define LL_RCC_LPTIM1_CLKSOURCE_NONE (RCC_CCIPR_LPTIMSEL | (RCC_CCIPR_LPTIMSEL_1 >> 16U)) /*!< No clock used as LPTIM1 clock */
  345. #define LL_RCC_LPTIM1_CLKSOURCE_PCLK1 (RCC_CCIPR_LPTIMSEL | (0x00000000U >> 16U)) /*!< PCLK1 selected as LPTIM1 clock */
  346. #define LL_RCC_LPTIM1_CLKSOURCE_LSI (RCC_CCIPR_LPTIMSEL | (RCC_CCIPR_LPTIMSEL_0 >> 16U)) /*!< LSI selected as LPTIM1 clock */
  347. #if defined(RCC_LSE_SUPPORT)
  348. #define LL_RCC_LPTIM1_CLKSOURCE_LSE (RCC_CCIPR_LPTIMSEL | (RCC_CCIPR_LPTIMSEL >> 16U)) /*!< LSE selected as LPTIM1 clock */
  349. #endif
  350. /**
  351. * @}
  352. */
  353. #endif /* RCC_CCIPR_LPTIMSEL */
  354. #if defined(RCC_BDCR_RTCSEL)
  355. /** @defgroup RCC_LL_EC_RTC_CLKSOURCE RTC clock source selection
  356. * @{
  357. */
  358. #define LL_RCC_RTC_CLKSOURCE_NONE 0x00000000U /*!< No clock used as RTC clock */
  359. #if defined(RCC_LSE_SUPPORT)
  360. #define LL_RCC_RTC_CLKSOURCE_LSE RCC_BDCR_RTCSEL_0 /*!< LSE oscillator clock used as RTC clock */
  361. #endif
  362. #define LL_RCC_RTC_CLKSOURCE_LSI RCC_BDCR_RTCSEL_1 /*!< LSI oscillator clock used as RTC clock */
  363. #define LL_RCC_RTC_CLKSOURCE_HSE_DIV128 RCC_BDCR_RTCSEL /*!< HSE oscillator clock divided by 128 used as RTC clock */
  364. /**
  365. * @}
  366. */
  367. #endif
  368. #if defined(RCC_PLL_SUPPORT)
  369. /** @defgroup RCC_LL_EC_PLLSOURCE PLL entry clock source
  370. * @{
  371. */
  372. #define LL_RCC_PLLSOURCE_HSI RCC_PLLCFGR_PLLSRC_HSI /*!< HSI clock selected as PLL entry clock source */
  373. #define LL_RCC_PLLSOURCE_HSE RCC_PLLCFGR_PLLSRC_HSE /*!< HSE clock selected as PLL entry clock source */
  374. /**
  375. * @}
  376. */
  377. #endif
  378. #if defined(COMP1)
  379. /** @defgroup RCC_LL_EC_COMP Peripheral COMP get clock source
  380. * @{
  381. */
  382. #define LL_RCC_COMP1_CLKSOURCE RCC_CCIPR_COMP1SEL /*!< COMP1 Clock source selection */
  383. #if defined(COMP2)
  384. #define LL_RCC_COMP2_CLKSOURCE RCC_CCIPR_COMP2SEL /*!< COMP2 Clock source selection */
  385. #endif /* COMP2 */
  386. /**
  387. * @}
  388. */
  389. #endif /* COMP1 */
  390. #if defined(RCC_CCIPR_LPTIMSEL)
  391. /** @defgroup RCC_LL_EC_LPTIM Peripheral LPTIM get clock source
  392. * @{
  393. */
  394. #define LL_RCC_LPTIM1_CLKSOURCE RCC_CCIPR_LPTIMSEL /*!< LPTIM1 Clock source selection */
  395. /**
  396. * @}
  397. */
  398. #endif /* RCC_CCIPR_LPTIMSEL */
  399. /** @defgroup RCC_HSE_EC_Freq HSE Config
  400. * @{
  401. */
  402. #define LL_RCC_HSE_STOP 0x00000000U
  403. #define LL_RCC_HSE_4_8MHz RCC_ECSCR_HSE_FREQ_0
  404. #define LL_RCC_HSE_8_16MHz RCC_ECSCR_HSE_FREQ_1
  405. #if defined(PY32F002APRE)
  406. #define LL_RCC_HSE_16_24MHz (RCC_ECSCR_HSE_FREQ_0 | RCC_ECSCR_HSE_FREQ_1)
  407. #else
  408. #define LL_RCC_HSE_16_32MHz (RCC_ECSCR_HSE_FREQ_0 | RCC_ECSCR_HSE_FREQ_1)
  409. #endif
  410. /**
  411. * @}
  412. */
  413. /** @defgroup RCC_HSI_EC_Calibration HSI Calibration
  414. * @{
  415. */
  416. #if defined(PY32F002APRE)
  417. #define LL_RCC_HSICALIBRATION_8MHz ((0x1<<13) | ((*(uint32_t *)(0x1FFF0F04)) & 0x1FFF)) /*!< 8MHz HSI calibration trimming value */
  418. #define LL_RCC_HSICALIBRATION_24MHz ((0x4<<13) | ((*(uint32_t *)(0x1FFF0F10)) & 0x1FFF)) /*!< 24MHz HSI calibration trimming value */
  419. #else
  420. #define LL_RCC_HSICALIBRATION_4MHz ((0x0<<13) | ((*(uint32_t *)(0x1FFF0F00)) & 0x1FFF)) /*!< 4MHz HSI calibration trimming value */
  421. #define LL_RCC_HSICALIBRATION_8MHz ((0x1<<13) | ((*(uint32_t *)(0x1FFF0F04)) & 0x1FFF)) /*!< 8MHz HSI calibration trimming value */
  422. #define LL_RCC_HSICALIBRATION_16MHz ((0x2<<13) | ((*(uint32_t *)(0x1FFF0F08)) & 0x1FFF)) /*!< 16MHz HSI calibration trimming value */
  423. #define LL_RCC_HSICALIBRATION_22p12MHz ((0x3<<13) | ((*(uint32_t *)(0x1FFF0F0C)) & 0x1FFF)) /*!< 22.12MHz HSI calibration trimming value */
  424. #define LL_RCC_HSICALIBRATION_24MHz ((0x4<<13) | ((*(uint32_t *)(0x1FFF0F10)) & 0x1FFF)) /*!< 24MHz HSI calibration trimming value */
  425. #endif
  426. /**
  427. * @}
  428. */
  429. /**
  430. * @}
  431. */
  432. /* Exported macro ------------------------------------------------------------*/
  433. /** @defgroup RCC_LL_Exported_Macros RCC Exported Macros
  434. * @{
  435. */
  436. /** @defgroup RCC_LL_EM_WRITE_READ Common Write and read registers Macros
  437. * @{
  438. */
  439. /**
  440. * @brief Write a value in RCC register
  441. * @param __REG__ Register to be written
  442. * @param __VALUE__ Value to be written in the register
  443. * @retval None
  444. */
  445. #define LL_RCC_WriteReg(__REG__, __VALUE__) WRITE_REG((RCC->__REG__), (__VALUE__))
  446. /**
  447. * @brief Read a value in RCC register
  448. * @param __REG__ Register to be read
  449. * @retval Register value
  450. */
  451. #define LL_RCC_ReadReg(__REG__) READ_REG(RCC->__REG__)
  452. /**
  453. * @}
  454. */
  455. /** @defgroup RCC_LL_EM_CALC_FREQ Calculate frequencies
  456. * @{
  457. */
  458. #if defined(RCC_PLL_SUPPORT)
  459. /**
  460. * @brief Helper macro to calculate the PLLCLK frequency on system domain
  461. * @param __INPUTFREQ__ PLL Input frequency (based on HSE/HSI)
  462. * @retval PLL clock frequency (in Hz)
  463. */
  464. #define __LL_RCC_CALC_PLLCLK_FREQ(__INPUTFREQ__) ((__INPUTFREQ__) * 2)
  465. #endif
  466. /**
  467. * @brief Helper macro to calculate the HCLK frequency
  468. * @param __SYSCLKFREQ__ SYSCLK frequency
  469. * @param __AHBPRESCALER__ This parameter can be one of the following values:
  470. * @arg @ref LL_RCC_SYSCLK_DIV_1
  471. * @arg @ref LL_RCC_SYSCLK_DIV_2
  472. * @arg @ref LL_RCC_SYSCLK_DIV_4
  473. * @arg @ref LL_RCC_SYSCLK_DIV_8
  474. * @arg @ref LL_RCC_SYSCLK_DIV_16
  475. * @arg @ref LL_RCC_SYSCLK_DIV_64
  476. * @arg @ref LL_RCC_SYSCLK_DIV_128
  477. * @arg @ref LL_RCC_SYSCLK_DIV_256
  478. * @arg @ref LL_RCC_SYSCLK_DIV_512
  479. * @retval HCLK clock frequency (in Hz)
  480. */
  481. #define __LL_RCC_CALC_HCLK_FREQ(__SYSCLKFREQ__,__AHBPRESCALER__) \
  482. ((__SYSCLKFREQ__) >> (AHBPrescTable[((__AHBPRESCALER__) & RCC_CFGR_HPRE) >> RCC_CFGR_HPRE_Pos] & 0x1FU))
  483. /**
  484. * @brief Helper macro to calculate the PCLK1 frequency (APB1)
  485. * @param __HCLKFREQ__ HCLK frequency
  486. * @param __APB1PRESCALER__ This parameter can be one of the following values:
  487. * @arg @ref LL_RCC_APB1_DIV_1
  488. * @arg @ref LL_RCC_APB1_DIV_2
  489. * @arg @ref LL_RCC_APB1_DIV_4
  490. * @arg @ref LL_RCC_APB1_DIV_8
  491. * @arg @ref LL_RCC_APB1_DIV_16
  492. * @retval PCLK1 clock frequency (in Hz)
  493. */
  494. #define __LL_RCC_CALC_PCLK1_FREQ(__HCLKFREQ__, __APB1PRESCALER__) \
  495. ((__HCLKFREQ__) >> (APBPrescTable[(__APB1PRESCALER__) >> RCC_CFGR_PPRE_Pos] & 0x1FU))
  496. #if defined(RCC_HSIDIV_SUPPORT)
  497. /**
  498. * @brief Helper macro to calculate the HSISYS frequency
  499. * @param __HSIDIV__ This parameter can be one of the following values:
  500. * @arg @ref LL_RCC_HSI_DIV_1
  501. * @arg @ref LL_RCC_HSI_DIV_2
  502. * @arg @ref LL_RCC_HSI_DIV_4
  503. * @arg @ref LL_RCC_HSI_DIV_8
  504. * @arg @ref LL_RCC_HSI_DIV_16
  505. * @arg @ref LL_RCC_HSI_DIV_32
  506. * @arg @ref LL_RCC_HSI_DIV_64
  507. * @arg @ref LL_RCC_HSI_DIV_128
  508. * @retval HSISYS clock frequency (in Hz)
  509. */
  510. #define __LL_RCC_CALC_HSI_FREQ(__HSIDIV__) \
  511. (HSIFreqTable[(RCC->ICSCR & RCC_ICSCR_HSI_FS) >> RCC_ICSCR_HSI_FS_Pos] / (1U << ((__HSIDIV__)>> RCC_CR_HSIDIV_Pos)))
  512. #else
  513. #define __LL_RCC_CALC_HSI_FREQ() \
  514. (HSIFreqTable[(RCC->ICSCR & RCC_ICSCR_HSI_FS) >> RCC_ICSCR_HSI_FS_Pos])
  515. #endif
  516. /**
  517. * @}
  518. */
  519. /**
  520. * @}
  521. */
  522. /* Exported functions --------------------------------------------------------*/
  523. /** @defgroup RCC_LL_Exported_Functions RCC Exported Functions
  524. * @{
  525. */
  526. /** @defgroup RCC_LL_EF_HSE HSE
  527. * @{
  528. */
  529. /**
  530. * @brief Enable the Clock Security System.
  531. * @rmtoll CR CSSON LL_RCC_HSE_EnableCSS
  532. * @retval None
  533. */
  534. __STATIC_INLINE void LL_RCC_HSE_EnableCSS(void)
  535. {
  536. SET_BIT(RCC->CR, RCC_CR_CSSON);
  537. }
  538. /**
  539. * @brief Enable HSE external oscillator (HSE Bypass)
  540. * @rmtoll CR HSEBYP LL_RCC_HSE_EnableBypass
  541. * @retval None
  542. */
  543. __STATIC_INLINE void LL_RCC_HSE_EnableBypass(void)
  544. {
  545. SET_BIT(RCC->CR, RCC_CR_HSEBYP);
  546. }
  547. /**
  548. * @brief Disable HSE external oscillator (HSE Bypass)
  549. * @rmtoll CR HSEBYP LL_RCC_HSE_DisableBypass
  550. * @retval None
  551. */
  552. __STATIC_INLINE void LL_RCC_HSE_DisableBypass(void)
  553. {
  554. CLEAR_BIT(RCC->CR, RCC_CR_HSEBYP);
  555. }
  556. /**
  557. * @brief Enable HSE crystal oscillator (HSE ON)
  558. * @rmtoll CR HSEON LL_RCC_HSE_Enable
  559. * @retval None
  560. */
  561. __STATIC_INLINE void LL_RCC_HSE_Enable(void)
  562. {
  563. SET_BIT(RCC->CR, RCC_CR_HSEON);
  564. }
  565. /**
  566. * @brief Disable HSE crystal oscillator (HSE ON)
  567. * @rmtoll CR HSEON LL_RCC_HSE_Disable
  568. * @retval None
  569. */
  570. __STATIC_INLINE void LL_RCC_HSE_Disable(void)
  571. {
  572. CLEAR_BIT(RCC->CR, RCC_CR_HSEON);
  573. }
  574. /**
  575. * @brief Check if HSE oscillator Ready
  576. * @rmtoll CR HSERDY LL_RCC_HSE_IsReady
  577. * @retval State of bit (1 or 0).
  578. */
  579. __STATIC_INLINE uint32_t LL_RCC_HSE_IsReady(void)
  580. {
  581. return ((READ_BIT(RCC->CR, RCC_CR_HSERDY) == (RCC_CR_HSERDY)) ? 1UL : 0UL);
  582. }
  583. /**
  584. * @brief Set HSE Crystal working frequency
  585. * @param HSEFreq This parameter can be one of the following values:
  586. * @arg @ref LL_RCC_HSE_STOP
  587. * @arg @ref LL_RCC_HSE_4_8MHz
  588. * @arg @ref LL_RCC_HSE_8_16MHz
  589. * @arg @ref LL_RCC_HSE_16_32MHz or LL_RCC_HSE_16_24MHz
  590. * @note The maximum working frequency varies depending on the devices.
  591. * Refer to the devices data sheet for the maximum working frequency.
  592. * @retval None
  593. */
  594. __STATIC_INLINE void LL_RCC_HSE_SetFreqRegion(uint32_t HSEFreq)
  595. {
  596. MODIFY_REG(RCC->ECSCR, RCC_ECSCR_HSE_FREQ, HSEFreq);
  597. }
  598. /**
  599. * @}
  600. */
  601. /** @defgroup RCC_LL_EF_HSI HSI
  602. * @{
  603. */
  604. /**
  605. * @brief Enable HSI oscillator
  606. * @rmtoll CR HSION LL_RCC_HSI_Enable
  607. * @retval None
  608. */
  609. __STATIC_INLINE void LL_RCC_HSI_Enable(void)
  610. {
  611. SET_BIT(RCC->CR, RCC_CR_HSION);
  612. }
  613. /**
  614. * @brief Disable HSI oscillator
  615. * @rmtoll CR HSION LL_RCC_HSI_Disable
  616. * @retval None
  617. */
  618. __STATIC_INLINE void LL_RCC_HSI_Disable(void)
  619. {
  620. CLEAR_BIT(RCC->CR, RCC_CR_HSION);
  621. }
  622. /**
  623. * @brief Check if HSI clock is ready
  624. * @rmtoll CR HSIRDY LL_RCC_HSI_IsReady
  625. * @retval State of bit (1 or 0).
  626. */
  627. __STATIC_INLINE uint32_t LL_RCC_HSI_IsReady(void)
  628. {
  629. return ((READ_BIT(RCC->CR, RCC_CR_HSIRDY) == (RCC_CR_HSIRDY)) ? 1UL : 0UL);
  630. }
  631. /**
  632. * @brief Set HSI Calibration trimming
  633. * @param Value Between Min_Data = 0 and Max_Data = 0x1FFF
  634. * @retval None
  635. */
  636. __STATIC_INLINE void LL_RCC_HSI_SetCalibTrimming(uint32_t Value)
  637. {
  638. MODIFY_REG(RCC->ICSCR, RCC_ICSCR_HSI_TRIM, Value << RCC_ICSCR_HSI_TRIM_Pos);
  639. }
  640. /**
  641. * @brief Get HSI Calibration trimming
  642. * @rmtoll ICSCR HSITRIM LL_RCC_HSI_GetCalibTrimming
  643. * @retval Between Min_Data = 0 and Max_Data = 0x1FFF
  644. */
  645. __STATIC_INLINE uint32_t LL_RCC_HSI_GetCalibTrimming(void)
  646. {
  647. return (uint32_t)(READ_BIT(RCC->ICSCR, RCC_ICSCR_HSI_TRIM) >> RCC_ICSCR_HSI_TRIM_Pos);
  648. }
  649. /**
  650. * @brief Set HSI Calibration Frequency
  651. * @param Value This parameter can be one of the following values:
  652. * @arg @ref LL_RCC_HSICALIBRATION_4MHz
  653. * @arg @ref LL_RCC_HSICALIBRATION_8MHz
  654. * @arg @ref LL_RCC_HSICALIBRATION_16MHz
  655. * @arg @ref LL_RCC_HSICALIBRATION_22p12MHz
  656. * @arg @ref LL_RCC_HSICALIBRATION_24MHz
  657. * @note Depending on devices and packages, some calibration values may not be available.
  658. * Refer to device datasheet for calibration values availability.
  659. * @retval None
  660. */
  661. __STATIC_INLINE void LL_RCC_HSI_SetCalibFreq(uint32_t Value)
  662. {
  663. MODIFY_REG(RCC->ICSCR, (RCC_ICSCR_HSI_FS | RCC_ICSCR_HSI_TRIM), Value);
  664. }
  665. /**
  666. * @brief Get HSI Frequency
  667. * @retval HSI clock frequency (in Hz)
  668. */
  669. __STATIC_INLINE uint32_t LL_RCC_HSI_GetFreq(void)
  670. {
  671. return (uint32_t)HSIFreqTable[(RCC->ICSCR & RCC_ICSCR_HSI_FS) >> RCC_ICSCR_HSI_FS_Pos];
  672. }
  673. /**
  674. * @}
  675. */
  676. #if defined(RCC_LSE_SUPPORT)
  677. /** @defgroup RCC_LL_EF_LSE LSE
  678. * @{
  679. */
  680. /**
  681. * @brief Enable Low Speed External (LSE) crystal.
  682. * @rmtoll BDCR LSEON LL_RCC_LSE_Enable
  683. * @retval None
  684. */
  685. __STATIC_INLINE void LL_RCC_LSE_Enable(void)
  686. {
  687. SET_BIT(RCC->BDCR, RCC_BDCR_LSEON);
  688. }
  689. /**
  690. * @brief Disable Low Speed External (LSE) crystal.
  691. * @rmtoll BDCR LSEON LL_RCC_LSE_Disable
  692. * @retval None
  693. */
  694. __STATIC_INLINE void LL_RCC_LSE_Disable(void)
  695. {
  696. CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSEON);
  697. }
  698. /**
  699. * @brief Enable external clock source (LSE bypass).
  700. * @rmtoll BDCR LSEBYP LL_RCC_LSE_EnableBypass
  701. * @retval None
  702. */
  703. __STATIC_INLINE void LL_RCC_LSE_EnableBypass(void)
  704. {
  705. SET_BIT(RCC->BDCR, RCC_BDCR_LSEBYP);
  706. }
  707. /**
  708. * @brief Disable external clock source (LSE bypass).
  709. * @rmtoll BDCR LSEBYP LL_RCC_LSE_DisableBypass
  710. * @retval None
  711. */
  712. __STATIC_INLINE void LL_RCC_LSE_DisableBypass(void)
  713. {
  714. CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSEBYP);
  715. }
  716. /**
  717. * @brief Set LSE oscillator drive capability
  718. * @note The oscillator is in Xtal mode when it is not in bypass mode.
  719. * @param LSEDrive This parameter can be one of the following values:
  720. * @arg @ref LL_RCC_LSEDRIVE_CLOSE
  721. * @arg @ref LL_RCC_LSEDRIVE_LOW
  722. * @arg @ref LL_RCC_LSEDRIVE_MEDIUM
  723. * @arg @ref LL_RCC_LSEDRIVE_HIGH
  724. * @retval None
  725. */
  726. __STATIC_INLINE void LL_RCC_LSE_SetDriveCapability(uint32_t LSEDrive)
  727. {
  728. MODIFY_REG(RCC->ECSCR, RCC_ECSCR_LSE_DRIVER, LSEDrive);
  729. }
  730. /**
  731. * @brief Get LSE oscillator drive capability
  732. * @retval Returned value can be one of the following values:
  733. * @arg @ref LL_RCC_LSEDRIVE_CLOSE
  734. * @arg @ref LL_RCC_LSEDRIVE_LOW
  735. * @arg @ref LL_RCC_LSEDRIVE_MEDIUM
  736. * @arg @ref LL_RCC_LSEDRIVE_HIGH
  737. */
  738. __STATIC_INLINE uint32_t LL_RCC_LSE_GetDriveCapability(void)
  739. {
  740. return (uint32_t)(READ_BIT(RCC->ECSCR, RCC_ECSCR_LSE_DRIVER));
  741. }
  742. /**
  743. * @brief Enable Clock security system on LSE.
  744. * @rmtoll BDCR LSECSSON LL_RCC_LSE_EnableCSS
  745. * @retval None
  746. */
  747. __STATIC_INLINE void LL_RCC_LSE_EnableCSS(void)
  748. {
  749. SET_BIT(RCC->BDCR, RCC_BDCR_LSECSSON);
  750. }
  751. /**
  752. * @brief Disable Clock security system on LSE.
  753. * @note Clock security system can be disabled only after a LSE
  754. * failure detection. In that case it MUST be disabled by software.
  755. * @rmtoll BDCR LSECSSON LL_RCC_LSE_DisableCSS
  756. * @retval None
  757. */
  758. __STATIC_INLINE void LL_RCC_LSE_DisableCSS(void)
  759. {
  760. CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSECSSON);
  761. }
  762. /**
  763. * @brief Check if LSE oscillator Ready
  764. * @rmtoll BDCR LSERDY LL_RCC_LSE_IsReady
  765. * @retval State of bit (1 or 0).
  766. */
  767. __STATIC_INLINE uint32_t LL_RCC_LSE_IsReady(void)
  768. {
  769. return ((READ_BIT(RCC->BDCR, RCC_BDCR_LSERDY) == (RCC_BDCR_LSERDY)) ? 1UL : 0UL);
  770. }
  771. /**
  772. * @brief Check if CSS on LSE failure Detection
  773. * @rmtoll BDCR LSECSSD LL_RCC_LSE_IsCSSDetected
  774. * @retval State of bit (1 or 0).
  775. */
  776. __STATIC_INLINE uint32_t LL_RCC_LSE_IsCSSDetected(void)
  777. {
  778. return ((READ_BIT(RCC->BDCR, RCC_BDCR_LSECSSD) == (RCC_BDCR_LSECSSD)) ? 1UL : 0UL);
  779. }
  780. /**
  781. * @}
  782. */
  783. #endif
  784. /** @defgroup RCC_LL_EF_LSI LSI
  785. * @{
  786. */
  787. /**
  788. * @brief Enable LSI Oscillator
  789. * @rmtoll CSR LSION LL_RCC_LSI_Enable
  790. * @retval None
  791. */
  792. __STATIC_INLINE void LL_RCC_LSI_Enable(void)
  793. {
  794. SET_BIT(RCC->CSR, RCC_CSR_LSION);
  795. }
  796. /**
  797. * @brief Disable LSI Oscillator
  798. * @rmtoll CSR LSION LL_RCC_LSI_Disable
  799. * @retval None
  800. */
  801. __STATIC_INLINE void LL_RCC_LSI_Disable(void)
  802. {
  803. CLEAR_BIT(RCC->CSR, RCC_CSR_LSION);
  804. }
  805. /**
  806. * @brief Check if LSI is Ready
  807. * @rmtoll CSR LSIRDY LL_RCC_LSI_IsReady
  808. * @retval State of bit (1 or 0).
  809. */
  810. __STATIC_INLINE uint32_t LL_RCC_LSI_IsReady(void)
  811. {
  812. return ((READ_BIT(RCC->CSR, RCC_CSR_LSIRDY) == (RCC_CSR_LSIRDY)) ? 1UL : 0UL);
  813. }
  814. /**
  815. * @}
  816. */
  817. /** @defgroup RCC_LL_EF_LSCO LSCO
  818. * @{
  819. */
  820. #define LL_RCC_LSCO_Enable()
  821. #define LL_RCC_LSCO_Disable()
  822. #if defined(RCC_BDCR_LSCOSEL)
  823. /**
  824. * @brief Configure Low speed clock selection
  825. * @rmtoll BDCR LSCOSEL LL_RCC_LSCO_SetSource
  826. * @param Source This parameter can be one of the following values:
  827. * @arg @ref LL_RCC_LSCO_CLKSOURCE_LSI
  828. * @arg @ref LL_RCC_LSCO_CLKSOURCE_LSE
  829. * @retval None
  830. */
  831. __STATIC_INLINE void LL_RCC_LSCO_SetSource(uint32_t Source)
  832. {
  833. MODIFY_REG(RCC->BDCR, RCC_BDCR_LSCOSEL, Source);
  834. }
  835. /**
  836. * @brief Get Low speed clock selection
  837. * @rmtoll BDCR LSCOSEL LL_RCC_LSCO_GetSource
  838. * @retval Returned value can be one of the following values:
  839. * @arg @ref LL_RCC_LSCO_CLKSOURCE_LSI
  840. * @arg @ref LL_RCC_LSCO_CLKSOURCE_LSE
  841. */
  842. __STATIC_INLINE uint32_t LL_RCC_LSCO_GetSource(void)
  843. {
  844. return (uint32_t)(READ_BIT(RCC->BDCR, RCC_BDCR_LSCOSEL));
  845. }
  846. #endif
  847. /**
  848. * @}
  849. */
  850. /** @defgroup RCC_LL_EF_System System
  851. * @{
  852. */
  853. /**
  854. * @brief Configure the system clock source
  855. * @rmtoll CFGR SW LL_RCC_SetSysClkSource
  856. * @param Source This parameter can be one of the following values:
  857. * @arg @ref LL_RCC_SYS_CLKSOURCE_HSISYS
  858. * @arg @ref LL_RCC_SYS_CLKSOURCE_HSE
  859. * @arg @ref LL_RCC_SYS_CLKSOURCE_PLL
  860. * @arg @ref LL_RCC_SYS_CLKSOURCE_LSI
  861. * @arg @ref LL_RCC_SYS_CLKSOURCE_LSE
  862. * @note Depending on devices and packages, some clocks may not be available.
  863. * Refer to device datasheet for clocks availability.
  864. * @retval None
  865. */
  866. __STATIC_INLINE void LL_RCC_SetSysClkSource(uint32_t Source)
  867. {
  868. MODIFY_REG(RCC->CFGR, RCC_CFGR_SW, Source);
  869. }
  870. /**
  871. * @brief Get the system clock source
  872. * @rmtoll CFGR SWS LL_RCC_GetSysClkSource
  873. * @retval Returned value can be one of the following values:
  874. * @arg @ref LL_RCC_SYS_CLKSOURCE_STATUS_HSISYS
  875. * @arg @ref LL_RCC_SYS_CLKSOURCE_STATUS_HSE
  876. * @arg @ref LL_RCC_SYS_CLKSOURCE_STATUS_PLL
  877. * @arg @ref LL_RCC_SYS_CLKSOURCE_STATUS_LSI
  878. * @arg @ref LL_RCC_SYS_CLKSOURCE_STATUS_LSE
  879. * @note Depending on devices and packages, some clocks may not be available.
  880. * Refer to device datasheet for clocks availability.
  881. */
  882. __STATIC_INLINE uint32_t LL_RCC_GetSysClkSource(void)
  883. {
  884. return (uint32_t)(READ_BIT(RCC->CFGR, RCC_CFGR_SWS));
  885. }
  886. /**
  887. * @brief Set AHB prescaler
  888. * @rmtoll CFGR HPRE LL_RCC_SetAHBPrescaler
  889. * @param Prescaler This parameter can be one of the following values:
  890. * @arg @ref LL_RCC_SYSCLK_DIV_1
  891. * @arg @ref LL_RCC_SYSCLK_DIV_2
  892. * @arg @ref LL_RCC_SYSCLK_DIV_4
  893. * @arg @ref LL_RCC_SYSCLK_DIV_8
  894. * @arg @ref LL_RCC_SYSCLK_DIV_16
  895. * @arg @ref LL_RCC_SYSCLK_DIV_64
  896. * @arg @ref LL_RCC_SYSCLK_DIV_128
  897. * @arg @ref LL_RCC_SYSCLK_DIV_256
  898. * @arg @ref LL_RCC_SYSCLK_DIV_512
  899. * @retval None
  900. */
  901. __STATIC_INLINE void LL_RCC_SetAHBPrescaler(uint32_t Prescaler)
  902. {
  903. MODIFY_REG(RCC->CFGR, RCC_CFGR_HPRE, Prescaler);
  904. }
  905. /**
  906. * @brief Set APB1 prescaler
  907. * @rmtoll CFGR PPRE LL_RCC_SetAPB1Prescaler
  908. * @param Prescaler This parameter can be one of the following values:
  909. * @arg @ref LL_RCC_APB1_DIV_1
  910. * @arg @ref LL_RCC_APB1_DIV_2
  911. * @arg @ref LL_RCC_APB1_DIV_4
  912. * @arg @ref LL_RCC_APB1_DIV_8
  913. * @arg @ref LL_RCC_APB1_DIV_16
  914. * @retval None
  915. */
  916. __STATIC_INLINE void LL_RCC_SetAPB1Prescaler(uint32_t Prescaler)
  917. {
  918. MODIFY_REG(RCC->CFGR, RCC_CFGR_PPRE, Prescaler);
  919. }
  920. #if defined(RCC_HSIDIV_SUPPORT)
  921. /**
  922. * @brief Set HSI division factor
  923. * @rmtoll CR HSIDIV LL_RCC_SetHSIDiv
  924. * @note HSIDIV parameter is only applied to SYSCLK_Frequency when HSI is used as
  925. * system clock source.
  926. * @param HSIDiv This parameter can be one of the following values:
  927. * @arg @ref LL_RCC_HSI_DIV_1
  928. * @arg @ref LL_RCC_HSI_DIV_2
  929. * @arg @ref LL_RCC_HSI_DIV_4
  930. * @arg @ref LL_RCC_HSI_DIV_8
  931. * @arg @ref LL_RCC_HSI_DIV_16
  932. * @arg @ref LL_RCC_HSI_DIV_32
  933. * @arg @ref LL_RCC_HSI_DIV_64
  934. * @arg @ref LL_RCC_HSI_DIV_128
  935. * @retval None
  936. */
  937. __STATIC_INLINE void LL_RCC_SetHSIDiv(uint32_t HSIDiv)
  938. {
  939. MODIFY_REG(RCC->CR, RCC_CR_HSIDIV, HSIDiv);
  940. }
  941. #endif
  942. /**
  943. * @brief Get AHB prescaler
  944. * @rmtoll CFGR HPRE LL_RCC_GetAHBPrescaler
  945. * @retval Returned value can be one of the following values:
  946. * @arg @ref LL_RCC_SYSCLK_DIV_1
  947. * @arg @ref LL_RCC_SYSCLK_DIV_2
  948. * @arg @ref LL_RCC_SYSCLK_DIV_4
  949. * @arg @ref LL_RCC_SYSCLK_DIV_8
  950. * @arg @ref LL_RCC_SYSCLK_DIV_16
  951. * @arg @ref LL_RCC_SYSCLK_DIV_64
  952. * @arg @ref LL_RCC_SYSCLK_DIV_128
  953. * @arg @ref LL_RCC_SYSCLK_DIV_256
  954. * @arg @ref LL_RCC_SYSCLK_DIV_512
  955. */
  956. __STATIC_INLINE uint32_t LL_RCC_GetAHBPrescaler(void)
  957. {
  958. return (uint32_t)(READ_BIT(RCC->CFGR, RCC_CFGR_HPRE));
  959. }
  960. /**
  961. * @brief Get APB1 prescaler
  962. * @rmtoll CFGR PPRE LL_RCC_GetAPB1Prescaler
  963. * @retval Returned value can be one of the following values:
  964. * @arg @ref LL_RCC_APB1_DIV_1
  965. * @arg @ref LL_RCC_APB1_DIV_2
  966. * @arg @ref LL_RCC_APB1_DIV_4
  967. * @arg @ref LL_RCC_APB1_DIV_8
  968. * @arg @ref LL_RCC_APB1_DIV_16
  969. */
  970. __STATIC_INLINE uint32_t LL_RCC_GetAPB1Prescaler(void)
  971. {
  972. return (uint32_t)(READ_BIT(RCC->CFGR, RCC_CFGR_PPRE));
  973. }
  974. #if defined(RCC_HSIDIV_SUPPORT)
  975. /**
  976. * @brief Get HSI division factor
  977. * @rmtoll CR HSIDIV LL_RCC_GetHSIDiv
  978. * @note HSIDIV parameter is only applied to SYSCLK_Frequency when HSI is used as
  979. * system clock source.
  980. * @retval Returned value can be one of the following values:
  981. * @arg @ref LL_RCC_HSI_DIV_1
  982. * @arg @ref LL_RCC_HSI_DIV_2
  983. * @arg @ref LL_RCC_HSI_DIV_4
  984. * @arg @ref LL_RCC_HSI_DIV_8
  985. * @arg @ref LL_RCC_HSI_DIV_16
  986. * @arg @ref LL_RCC_HSI_DIV_32
  987. * @arg @ref LL_RCC_HSI_DIV_64
  988. * @arg @ref LL_RCC_HSI_DIV_128
  989. */
  990. __STATIC_INLINE uint32_t LL_RCC_GetHSIDiv(void)
  991. {
  992. return (uint32_t)(READ_BIT(RCC->CR, RCC_CR_HSIDIV));
  993. }
  994. #endif
  995. /**
  996. * @}
  997. */
  998. /** @defgroup RCC_LL_EF_MCO MCO
  999. * @{
  1000. */
  1001. /**
  1002. * @brief Configure MCOx
  1003. * @rmtoll CFGR MCOSEL LL_RCC_ConfigMCO\n
  1004. * CFGR MCOPRE LL_RCC_ConfigMCO
  1005. * @param MCOxSource This parameter can be one of the following values:
  1006. * @arg @ref LL_RCC_MCO1SOURCE_NOCLOCK
  1007. * @arg @ref LL_RCC_MCO1SOURCE_SYSCLK
  1008. * @arg @ref LL_RCC_MCO1SOURCE_HSI
  1009. * @arg @ref LL_RCC_MCO1SOURCE_HSE
  1010. * @arg @ref LL_RCC_MCO1SOURCE_PLLCLK
  1011. * @arg @ref LL_RCC_MCO1SOURCE_LSI
  1012. * @arg @ref LL_RCC_MCO1SOURCE_LSE
  1013. * @note Depending on devices and packages, some clocks may not be available.
  1014. * Refer to device datasheet for clocks availability.
  1015. * @param MCOxPrescaler This parameter can be one of the following values:
  1016. * @arg @ref LL_RCC_MCO1_DIV_1
  1017. * @arg @ref LL_RCC_MCO1_DIV_2
  1018. * @arg @ref LL_RCC_MCO1_DIV_4
  1019. * @arg @ref LL_RCC_MCO1_DIV_8
  1020. * @arg @ref LL_RCC_MCO1_DIV_16
  1021. * @arg @ref LL_RCC_MCO1_DIV_32
  1022. * @arg @ref LL_RCC_MCO1_DIV_64
  1023. * @arg @ref LL_RCC_MCO1_DIV_128
  1024. * @retval None
  1025. */
  1026. __STATIC_INLINE void LL_RCC_ConfigMCO(uint32_t MCOxSource, uint32_t MCOxPrescaler)
  1027. {
  1028. MODIFY_REG(RCC->CFGR, RCC_CFGR_MCOSEL | RCC_CFGR_MCOPRE, MCOxSource | MCOxPrescaler);
  1029. }
  1030. /**
  1031. * @brief Get MCO clock source
  1032. * @rmtoll CFGR MCOSEL LL_RCC_GetMCOClockSource
  1033. * @param MCOx This parameter can be one of the following values:
  1034. * @arg @ref LL_RCC_MCO1_CLKSOURCE
  1035. * @retval Returned value can be one of the following values:
  1036. * @arg @ref LL_RCC_MCO1SOURCE_NOCLOCK
  1037. * @arg @ref LL_RCC_MCO1SOURCE_SYSCLK
  1038. * @arg @ref LL_RCC_MCO1SOURCE_HSI
  1039. * @arg @ref LL_RCC_MCO1SOURCE_HSE
  1040. * @arg @ref LL_RCC_MCO1SOURCE_PLLCLK
  1041. * @arg @ref LL_RCC_MCO1SOURCE_LSI
  1042. * @arg @ref LL_RCC_MCO1SOURCE_LSE
  1043. * @note Depending on devices and packages, some clocks may not be available.
  1044. * Refer to device datasheet for clocks availability.
  1045. */
  1046. __STATIC_INLINE uint32_t LL_RCC_GetMCOClockSource(uint32_t MCOx)
  1047. {
  1048. return (uint32_t)(READ_BIT(RCC->CFGR, MCOx));
  1049. }
  1050. /**
  1051. * @brief Get MCO division factor
  1052. * @rmtoll CFGR MCOPRE LL_RCC_GetMCODiv
  1053. * @param MCOx This parameter can be one of the following values:
  1054. * @arg @ref LL_RCC_MCO1_CLKSOURCE
  1055. * @retval Returned value can be one of the following values:
  1056. * @arg @ref LL_RCC_MCO1_DIV_1
  1057. * @arg @ref LL_RCC_MCO1_DIV_2
  1058. * @arg @ref LL_RCC_MCO1_DIV_4
  1059. * @arg @ref LL_RCC_MCO1_DIV_8
  1060. * @arg @ref LL_RCC_MCO1_DIV_16
  1061. * @arg @ref LL_RCC_MCO1_DIV_32
  1062. * @arg @ref LL_RCC_MCO1_DIV_64
  1063. * @arg @ref LL_RCC_MCO1_DIV_128
  1064. */
  1065. __STATIC_INLINE uint32_t LL_RCC_GetMCODiv(uint32_t MCOx)
  1066. {
  1067. return (uint32_t)(READ_BIT(RCC->CFGR, RCC_CFGR_MCOPRE));
  1068. }
  1069. /**
  1070. * @}
  1071. */
  1072. /** @defgroup RCC_LL_EF_Peripheral_Clock_Source Peripheral Clock Source
  1073. * @{
  1074. */
  1075. #if defined(RCC_CCIPR_PVDSEL)
  1076. /**
  1077. * @brief Configure PVD clock source
  1078. * @rmtoll CCIPR PVDSEL LL_RCC_SetCOMPClockSource
  1079. * @param PVDSource This parameter can be one of the following values:
  1080. * @arg @ref LL_RCC_PVD_CLKSOURCE_PCLK1
  1081. * @arg @ref LL_RCC_PVD_CLKSOURCE_LSC
  1082. * @retval None
  1083. */
  1084. __STATIC_INLINE void LL_RCC_SetPVDClockSource(uint32_t PVDSource)
  1085. {
  1086. MODIFY_REG(RCC->CCIPR, RCC_CCIPR_PVDSEL, PVDSource);
  1087. }
  1088. /**
  1089. * @brief Get PVD clock source
  1090. * @rmtoll CCIPR PVDSEL LL_RCC_GetCOMPClockSource
  1091. * @retval Returned value can be one of the following values:
  1092. * @arg @ref LL_RCC_PVD_CLKSOURCE_PCLK1
  1093. * @arg @ref LL_RCC_PVD_CLKSOURCE_LSC
  1094. */
  1095. __STATIC_INLINE uint32_t LL_RCC_GetPVDClockSource(void)
  1096. {
  1097. return (uint32_t)(READ_BIT(RCC->CCIPR, RCC_CCIPR_PVDSEL));
  1098. }
  1099. #endif
  1100. #if defined(COMP1)
  1101. /**
  1102. * @brief Configure COMPx clock source
  1103. * @rmtoll CCIPR COMPxSEL LL_RCC_SetCOMPClockSource
  1104. * @param COMPxSource This parameter can be one of the following values:
  1105. * @arg @ref LL_RCC_COMP1_CLKSOURCE_PCLK1
  1106. * @arg @ref LL_RCC_COMP1_CLKSOURCE_LSC
  1107. * @arg @ref LL_RCC_COMP2_CLKSOURCE_PCLK1
  1108. * @arg @ref LL_RCC_COMP2_CLKSOURCE_LSC
  1109. * @note Depending on devices and packages,some COMP may not be available.
  1110. * Refer to device datasheet for COMP availability.
  1111. * @retval None
  1112. */
  1113. __STATIC_INLINE void LL_RCC_SetCOMPClockSource(uint32_t COMPxSource)
  1114. {
  1115. MODIFY_REG(RCC->CCIPR, (COMPxSource & 0x0000FF00U), ((COMPxSource & 0xFFU) << 8U));
  1116. }
  1117. #endif /* COMP1 */
  1118. #if defined(COMP1)
  1119. /**
  1120. * @brief Get COMPx clock source
  1121. * @rmtoll CCIPR COMPxSEL LL_RCC_GetCOMPClockSource
  1122. * @param COMPx This parameter can be one of the following values:
  1123. * @arg @ref LL_RCC_COMP1_CLKSOURCE
  1124. * @arg @ref LL_RCC_COMP2_CLKSOURCE
  1125. * @retval Returned value can be one of the following values:
  1126. * @arg @ref LL_RCC_COMP1_CLKSOURCE_PCLK1
  1127. * @arg @ref LL_RCC_COMP1_CLKSOURCE_LSC
  1128. * @arg @ref LL_RCC_COMP2_CLKSOURCE_PCLK1
  1129. * @arg @ref LL_RCC_COMP2_CLKSOURCE_LSC
  1130. * @note Depending on devices and packages,some COMP may not be available.
  1131. * Refer to device datasheet for COMP availability.
  1132. */
  1133. __STATIC_INLINE uint32_t LL_RCC_GetCOMPClockSource(uint32_t COMPx)
  1134. {
  1135. return (uint32_t)((READ_BIT(RCC->CCIPR, COMPx) >> 8U) | COMPx);
  1136. }
  1137. #endif /* COMP1 */
  1138. #if defined(RCC_CCIPR_LPTIMSEL)
  1139. /**
  1140. * @brief Configure LPTIMx clock source
  1141. * @rmtoll CCIPR LPTIMxSEL LL_RCC_SetLPTIMClockSource
  1142. * @param LPTIMxSource This parameter can be one of the following values:
  1143. * @arg @ref LL_RCC_LPTIM1_CLKSOURCE_PCLK1
  1144. * @arg @ref LL_RCC_LPTIM1_CLKSOURCE_LSI
  1145. * @arg @ref LL_RCC_LPTIM1_CLKSOURCE_NONE
  1146. * @arg @ref LL_RCC_LPTIM1_CLKSOURCE_LSE
  1147. * @note Depending on devices and packages, some clocks may not be available.
  1148. * Refer to device datasheet for clocks availability.
  1149. * @retval None
  1150. */
  1151. __STATIC_INLINE void LL_RCC_SetLPTIMClockSource(uint32_t LPTIMxSource)
  1152. {
  1153. MODIFY_REG(RCC->CCIPR, (LPTIMxSource & 0xFFFF0000U), (LPTIMxSource << 16U));
  1154. }
  1155. /**
  1156. * @brief Get LPTIMx clock source
  1157. * @rmtoll CCIPR LPTIMxSEL LL_RCC_GetLPTIMClockSource
  1158. * @param LPTIMx This parameter can be one of the following values:
  1159. * @arg @ref LL_RCC_LPTIM1_CLKSOURCE
  1160. * @retval Returned value can be one of the following values:
  1161. * @arg @ref LL_RCC_LPTIM1_CLKSOURCE_PCLK1
  1162. * @arg @ref LL_RCC_LPTIM1_CLKSOURCE_LSI
  1163. * @arg @ref LL_RCC_LPTIM1_CLKSOURCE_NONE
  1164. * @arg @ref LL_RCC_LPTIM1_CLKSOURCE_LSE
  1165. * @note Depending on devices and packages, some clocks may not be available.
  1166. * Refer to device datasheet for clocks availability.
  1167. */
  1168. __STATIC_INLINE uint32_t LL_RCC_GetLPTIMClockSource(uint32_t LPTIMx)
  1169. {
  1170. return (uint32_t)((READ_BIT(RCC->CCIPR, LPTIMx) >> 16U) | LPTIMx);
  1171. }
  1172. #endif /* RCC_CCIPR_LPTIMSEL */
  1173. /**
  1174. * @}
  1175. */
  1176. #if defined(RTC)
  1177. #if defined(RCC_BDCR_RTCSEL)
  1178. /** @defgroup RCC_LL_EF_RTC RTC
  1179. * @{
  1180. */
  1181. /**
  1182. * @brief Set RTC Clock Source
  1183. * @note Once the RTC clock source has been selected, it cannot be changed anymore unless
  1184. * the Backup domain is reset, or unless a failure is detected on LSE (LSECSSD is
  1185. * set). The BDRST bit can be used to reset them.
  1186. * @rmtoll BDCR RTCSEL LL_RCC_SetRTCClockSource
  1187. * @param Source This parameter can be one of the following values:
  1188. * @arg @ref LL_RCC_RTC_CLKSOURCE_NONE
  1189. * @arg @ref LL_RCC_RTC_CLKSOURCE_LSE
  1190. * @arg @ref LL_RCC_RTC_CLKSOURCE_LSI
  1191. * @arg @ref LL_RCC_RTC_CLKSOURCE_HSE_DIV128
  1192. * @retval None
  1193. */
  1194. __STATIC_INLINE void LL_RCC_SetRTCClockSource(uint32_t Source)
  1195. {
  1196. MODIFY_REG(RCC->BDCR, RCC_BDCR_RTCSEL, Source);
  1197. }
  1198. /**
  1199. * @brief Get RTC Clock Source
  1200. * @rmtoll BDCR RTCSEL LL_RCC_GetRTCClockSource
  1201. * @retval Returned value can be one of the following values:
  1202. * @arg @ref LL_RCC_RTC_CLKSOURCE_NONE
  1203. * @arg @ref LL_RCC_RTC_CLKSOURCE_LSE
  1204. * @arg @ref LL_RCC_RTC_CLKSOURCE_LSI
  1205. * @arg @ref LL_RCC_RTC_CLKSOURCE_HSE_DIV128
  1206. */
  1207. __STATIC_INLINE uint32_t LL_RCC_GetRTCClockSource(void)
  1208. {
  1209. return (uint32_t)(READ_BIT(RCC->BDCR, RCC_BDCR_RTCSEL));
  1210. }
  1211. #endif
  1212. /**
  1213. * @brief Enable RTC
  1214. * @rmtoll BDCR RTCEN LL_RCC_EnableRTC
  1215. * @retval None
  1216. */
  1217. __STATIC_INLINE void LL_RCC_EnableRTC(void)
  1218. {
  1219. SET_BIT(RCC->BDCR, RCC_BDCR_RTCEN);
  1220. }
  1221. /**
  1222. * @brief Disable RTC
  1223. * @rmtoll BDCR RTCEN LL_RCC_DisableRTC
  1224. * @retval None
  1225. */
  1226. __STATIC_INLINE void LL_RCC_DisableRTC(void)
  1227. {
  1228. CLEAR_BIT(RCC->BDCR, RCC_BDCR_RTCEN);
  1229. }
  1230. /**
  1231. * @brief Check if RTC has been enabled or not
  1232. * @rmtoll BDCR RTCEN LL_RCC_IsEnabledRTC
  1233. * @retval State of bit (1 or 0).
  1234. */
  1235. __STATIC_INLINE uint32_t LL_RCC_IsEnabledRTC(void)
  1236. {
  1237. return ((READ_BIT(RCC->BDCR, RCC_BDCR_RTCEN) == (RCC_BDCR_RTCEN)) ? 1UL : 0UL);
  1238. }
  1239. /**
  1240. * @brief Force the Backup domain reset
  1241. * @rmtoll BDCR BDRST LL_RCC_ForceBackupDomainReset
  1242. * @retval None
  1243. */
  1244. __STATIC_INLINE void LL_RCC_ForceBackupDomainReset(void)
  1245. {
  1246. SET_BIT(RCC->BDCR, RCC_BDCR_BDRST);
  1247. }
  1248. /**
  1249. * @brief Release the Backup domain reset
  1250. * @rmtoll BDCR BDRST LL_RCC_ReleaseBackupDomainReset
  1251. * @retval None
  1252. */
  1253. __STATIC_INLINE void LL_RCC_ReleaseBackupDomainReset(void)
  1254. {
  1255. CLEAR_BIT(RCC->BDCR, RCC_BDCR_BDRST);
  1256. }
  1257. /**
  1258. * @}
  1259. */
  1260. #endif
  1261. #if defined(RCC_PLL_SUPPORT)
  1262. /** @defgroup RCC_LL_EF_PLL PLL
  1263. * @{
  1264. */
  1265. /**
  1266. * @brief Enable PLL
  1267. * @rmtoll CR PLLON LL_RCC_PLL_Enable
  1268. * @retval None
  1269. */
  1270. __STATIC_INLINE void LL_RCC_PLL_Enable(void)
  1271. {
  1272. SET_BIT(RCC->CR, RCC_CR_PLLON);
  1273. }
  1274. /**
  1275. * @brief Disable PLL
  1276. * @note Cannot be disabled if the PLL clock is used as the system clock
  1277. * @rmtoll CR PLLON LL_RCC_PLL_Disable
  1278. * @retval None
  1279. */
  1280. __STATIC_INLINE void LL_RCC_PLL_Disable(void)
  1281. {
  1282. CLEAR_BIT(RCC->CR, RCC_CR_PLLON);
  1283. }
  1284. /**
  1285. * @brief Check if PLL Ready
  1286. * @rmtoll CR PLLRDY LL_RCC_PLL_IsReady
  1287. * @retval State of bit (1 or 0).
  1288. */
  1289. __STATIC_INLINE uint32_t LL_RCC_PLL_IsReady(void)
  1290. {
  1291. return ((READ_BIT(RCC->CR, RCC_CR_PLLRDY) == (RCC_CR_PLLRDY)) ? 1UL : 0UL);
  1292. }
  1293. /**
  1294. * @brief Configure PLL clock source
  1295. * @rmtoll PLLCFGR PLLSRC LL_RCC_PLL_SetMainSource
  1296. * @param PLLSource This parameter can be one of the following values:
  1297. * @arg @ref LL_RCC_PLLSOURCE_HSI
  1298. * @arg @ref LL_RCC_PLLSOURCE_HSE
  1299. * @retval None
  1300. */
  1301. __STATIC_INLINE void LL_RCC_PLL_SetMainSource(uint32_t PLLSource)
  1302. {
  1303. MODIFY_REG(RCC->PLLCFGR, RCC_PLLCFGR_PLLSRC, PLLSource);
  1304. }
  1305. /**
  1306. * @brief Get the oscillator used as PLL clock source.
  1307. * @rmtoll PLLCFGR PLLSRC LL_RCC_PLL_GetMainSource
  1308. * @retval Returned value can be one of the following values:
  1309. * @arg @ref LL_RCC_PLLSOURCE_HSI
  1310. * @arg @ref LL_RCC_PLLSOURCE_HSE
  1311. */
  1312. __STATIC_INLINE uint32_t LL_RCC_PLL_GetMainSource(void)
  1313. {
  1314. return (uint32_t)(READ_BIT(RCC->PLLCFGR, RCC_PLLCFGR_PLLSRC));
  1315. }
  1316. /**
  1317. * @}
  1318. */
  1319. #endif
  1320. /** @defgroup RCC_LL_EF_FLAG_Management FLAG Management
  1321. * @{
  1322. */
  1323. /**
  1324. * @brief Clear LSI ready interrupt flag
  1325. * @rmtoll CICR LSIRDYC LL_RCC_ClearFlag_LSIRDY
  1326. * @retval None
  1327. */
  1328. __STATIC_INLINE void LL_RCC_ClearFlag_LSIRDY(void)
  1329. {
  1330. SET_BIT(RCC->CICR, RCC_CICR_LSIRDYC);
  1331. }
  1332. #if defined(RCC_LSE_SUPPORT)
  1333. /**
  1334. * @brief Clear LSE ready interrupt flag
  1335. * @rmtoll CICR LSERDYC LL_RCC_ClearFlag_LSERDY
  1336. * @retval None
  1337. */
  1338. __STATIC_INLINE void LL_RCC_ClearFlag_LSERDY(void)
  1339. {
  1340. SET_BIT(RCC->CICR, RCC_CICR_LSERDYC);
  1341. }
  1342. #endif
  1343. /**
  1344. * @brief Clear HSI ready interrupt flag
  1345. * @rmtoll CICR HSIRDYC LL_RCC_ClearFlag_HSIRDY
  1346. * @retval None
  1347. */
  1348. __STATIC_INLINE void LL_RCC_ClearFlag_HSIRDY(void)
  1349. {
  1350. SET_BIT(RCC->CICR, RCC_CICR_HSIRDYC);
  1351. }
  1352. /**
  1353. * @brief Clear HSE ready interrupt flag
  1354. * @rmtoll CICR HSERDYC LL_RCC_ClearFlag_HSERDY
  1355. * @retval None
  1356. */
  1357. __STATIC_INLINE void LL_RCC_ClearFlag_HSERDY(void)
  1358. {
  1359. SET_BIT(RCC->CICR, RCC_CICR_HSERDYC);
  1360. }
  1361. #if defined(RCC_PLL_SUPPORT)
  1362. /**
  1363. * @brief Clear PLL ready interrupt flag
  1364. * @rmtoll CICR PLLRDYC LL_RCC_ClearFlag_PLLRDY
  1365. * @retval None
  1366. */
  1367. __STATIC_INLINE void LL_RCC_ClearFlag_PLLRDY(void)
  1368. {
  1369. SET_BIT(RCC->CICR, RCC_CICR_PLLRDYC);
  1370. }
  1371. #endif
  1372. /**
  1373. * @brief Clear Clock security system interrupt flag
  1374. * @rmtoll CICR CSSC LL_RCC_ClearFlag_HSECSS
  1375. * @retval None
  1376. */
  1377. __STATIC_INLINE void LL_RCC_ClearFlag_HSECSS(void)
  1378. {
  1379. SET_BIT(RCC->CICR, RCC_CICR_CSSC);
  1380. }
  1381. #if defined(RCC_LSE_SUPPORT)
  1382. /**
  1383. * @brief Clear LSE Clock security system interrupt flag
  1384. * @rmtoll CICR LSECSSC LL_RCC_ClearFlag_LSECSS
  1385. * @retval None
  1386. */
  1387. __STATIC_INLINE void LL_RCC_ClearFlag_LSECSS(void)
  1388. {
  1389. SET_BIT(RCC->CICR, RCC_CICR_LSECSSC);
  1390. }
  1391. #endif
  1392. /**
  1393. * @brief Check if LSI ready interrupt occurred or not
  1394. * @rmtoll CIFR LSIRDYF LL_RCC_IsActiveFlag_LSIRDY
  1395. * @retval State of bit (1 or 0).
  1396. */
  1397. __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_LSIRDY(void)
  1398. {
  1399. return ((READ_BIT(RCC->CIFR, RCC_CIFR_LSIRDYF) == (RCC_CIFR_LSIRDYF)) ? 1UL : 0UL);
  1400. }
  1401. #if defined(RCC_LSE_SUPPORT)
  1402. /**
  1403. * @brief Check if LSE ready interrupt occurred or not
  1404. * @rmtoll CIFR LSERDYF LL_RCC_IsActiveFlag_LSERDY
  1405. * @retval State of bit (1 or 0).
  1406. */
  1407. __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_LSERDY(void)
  1408. {
  1409. return ((READ_BIT(RCC->CIFR, RCC_CIFR_LSERDYF) == (RCC_CIFR_LSERDYF)) ? 1UL : 0UL);
  1410. }
  1411. #endif
  1412. /**
  1413. * @brief Check if HSI ready interrupt occurred or not
  1414. * @rmtoll CIFR HSIRDYF LL_RCC_IsActiveFlag_HSIRDY
  1415. * @retval State of bit (1 or 0).
  1416. */
  1417. __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_HSIRDY(void)
  1418. {
  1419. return ((READ_BIT(RCC->CIFR, RCC_CIFR_HSIRDYF) == (RCC_CIFR_HSIRDYF)) ? 1UL : 0UL);
  1420. }
  1421. /**
  1422. * @brief Check if HSE ready interrupt occurred or not
  1423. * @rmtoll CIFR HSERDYF LL_RCC_IsActiveFlag_HSERDY
  1424. * @retval State of bit (1 or 0).
  1425. */
  1426. __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_HSERDY(void)
  1427. {
  1428. return ((READ_BIT(RCC->CIFR, RCC_CIFR_HSERDYF) == (RCC_CIFR_HSERDYF)) ? 1UL : 0UL);
  1429. }
  1430. #if defined(RCC_PLL_SUPPORT)
  1431. /**
  1432. * @brief Check if PLL ready interrupt occurred or not
  1433. * @rmtoll CIFR PLLRDYF LL_RCC_IsActiveFlag_PLLRDY
  1434. * @retval State of bit (1 or 0).
  1435. */
  1436. __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_PLLRDY(void)
  1437. {
  1438. return ((READ_BIT(RCC->CIFR, RCC_CIFR_PLLRDYF) == (RCC_CIFR_PLLRDYF)) ? 1UL : 0UL);
  1439. }
  1440. #endif
  1441. /**
  1442. * @brief Check if Clock security system interrupt occurred or not
  1443. * @rmtoll CIFR CSSF LL_RCC_IsActiveFlag_HSECSS
  1444. * @retval State of bit (1 or 0).
  1445. */
  1446. __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_HSECSS(void)
  1447. {
  1448. return ((READ_BIT(RCC->CIFR, RCC_CIFR_CSSF) == (RCC_CIFR_CSSF)) ? 1UL : 0UL);
  1449. }
  1450. #if defined(RCC_LSE_SUPPORT)
  1451. /**
  1452. * @brief Check if LSE Clock security system interrupt occurred or not
  1453. * @rmtoll CIFR LSECSSF LL_RCC_IsActiveFlag_LSECSS
  1454. * @retval State of bit (1 or 0).
  1455. */
  1456. __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_LSECSS(void)
  1457. {
  1458. return ((READ_BIT(RCC->CIFR, RCC_CIFR_LSECSSF) == (RCC_CIFR_LSECSSF)) ? 1UL : 0UL);
  1459. }
  1460. #endif
  1461. /**
  1462. * @brief Check if RCC flag Independent Watchdog reset is set or not.
  1463. * @rmtoll CSR IWDGRSTF LL_RCC_IsActiveFlag_IWDGRST
  1464. * @retval State of bit (1 or 0).
  1465. */
  1466. __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_IWDGRST(void)
  1467. {
  1468. return ((READ_BIT(RCC->CSR, RCC_CSR_IWDGRSTF) == (RCC_CSR_IWDGRSTF)) ? 1UL : 0UL);
  1469. }
  1470. /**
  1471. * @brief Check if RCC flag Option byte reset is set or not.
  1472. * @rmtoll CSR OBLRSTF LL_RCC_IsActiveFlag_OBLRST
  1473. * @retval State of bit (1 or 0).
  1474. */
  1475. __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_OBLRST(void)
  1476. {
  1477. return ((READ_BIT(RCC->CSR, RCC_CSR_OBLRSTF) == (RCC_CSR_OBLRSTF)) ? 1UL : 0UL);
  1478. }
  1479. /**
  1480. * @brief Check if RCC flag Pin reset is set or not.
  1481. * @rmtoll CSR PINRSTF LL_RCC_IsActiveFlag_PINRST
  1482. * @retval State of bit (1 or 0).
  1483. */
  1484. __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_PINRST(void)
  1485. {
  1486. return ((READ_BIT(RCC->CSR, RCC_CSR_PINRSTF) == (RCC_CSR_PINRSTF)) ? 1UL : 0UL);
  1487. }
  1488. /**
  1489. * @brief Check if RCC flag Software reset is set or not.
  1490. * @rmtoll CSR SFTRSTF LL_RCC_IsActiveFlag_SFTRST
  1491. * @retval State of bit (1 or 0).
  1492. */
  1493. __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_SFTRST(void)
  1494. {
  1495. return ((READ_BIT(RCC->CSR, RCC_CSR_SFTRSTF) == (RCC_CSR_SFTRSTF)) ? 1UL : 0UL);
  1496. }
  1497. #if defined(WWDG)
  1498. /**
  1499. * @brief Check if RCC flag Window Watchdog reset is set or not.
  1500. * @rmtoll CSR WWDGRSTF LL_RCC_IsActiveFlag_WWDGRST
  1501. * @retval State of bit (1 or 0).
  1502. */
  1503. __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_WWDGRST(void)
  1504. {
  1505. return ((READ_BIT(RCC->CSR, RCC_CSR_WWDGRSTF) == (RCC_CSR_WWDGRSTF)) ? 1UL : 0UL);
  1506. }
  1507. #endif
  1508. /**
  1509. * @brief Check if RCC flag BOR or POR/PDR reset is set or not.
  1510. * @rmtoll CSR PWRRSTF LL_RCC_IsActiveFlag_PWRRST
  1511. * @retval State of bit (1 or 0).
  1512. */
  1513. __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_PWRRST(void)
  1514. {
  1515. return ((READ_BIT(RCC->CSR, RCC_CSR_PWRRSTF) == (RCC_CSR_PWRRSTF)) ? 1UL : 0UL);
  1516. }
  1517. /**
  1518. * @brief Set RMVF bit to clear the reset flags.
  1519. * @rmtoll CSR RMVF LL_RCC_ClearResetFlags
  1520. * @retval None
  1521. */
  1522. __STATIC_INLINE void LL_RCC_ClearResetFlags(void)
  1523. {
  1524. SET_BIT(RCC->CSR, RCC_CSR_RMVF);
  1525. }
  1526. /**
  1527. * @brief Enable NRST filter
  1528. * @rmtoll CSR NRST_FLTDIS LL_RCC_EnableNRSTFilter
  1529. * @retval None
  1530. */
  1531. __STATIC_INLINE void LL_RCC_EnableNRSTFilter(void)
  1532. {
  1533. CLEAR_BIT(RCC->CSR, RCC_CSR_NRST_FLTDIS);
  1534. }
  1535. /**
  1536. * @brief Disable NRST filter
  1537. * @rmtoll CSR NRST_FLTDIS LL_RCC_DisableNRSTFilter
  1538. * @retval None
  1539. */
  1540. __STATIC_INLINE void LL_RCC_DisableNRSTFilter(void)
  1541. {
  1542. SET_BIT(RCC->CSR, RCC_CSR_NRST_FLTDIS);
  1543. }
  1544. /**
  1545. * @brief Check if NRST filter is enable
  1546. * @rmtoll CSR NRST_FLTDIS LL_RCC_IsEnableNRSTFilter
  1547. * @retval State of bit (1 or 0).
  1548. */
  1549. __STATIC_INLINE uint32_t LL_RCC_IsEnableNRSTFilter(void)
  1550. {
  1551. return ((READ_BIT(RCC->CSR, RCC_CSR_NRST_FLTDIS) == (RCC_CSR_NRST_FLTDIS)) ? 0UL : 1UL);
  1552. }
  1553. /**
  1554. * @}
  1555. */
  1556. /** @defgroup RCC_LL_EF_IT_Management IT Management
  1557. * @{
  1558. */
  1559. /**
  1560. * @brief Enable LSI ready interrupt
  1561. * @rmtoll CIER LSIRDYIE LL_RCC_EnableIT_LSIRDY
  1562. * @retval None
  1563. */
  1564. __STATIC_INLINE void LL_RCC_EnableIT_LSIRDY(void)
  1565. {
  1566. SET_BIT(RCC->CIER, RCC_CIER_LSIRDYIE);
  1567. }
  1568. #if defined(RCC_LSE_SUPPORT)
  1569. /**
  1570. * @brief Enable LSE ready interrupt
  1571. * @rmtoll CIER LSERDYIE LL_RCC_EnableIT_LSERDY
  1572. * @retval None
  1573. */
  1574. __STATIC_INLINE void LL_RCC_EnableIT_LSERDY(void)
  1575. {
  1576. SET_BIT(RCC->CIER, RCC_CIER_LSERDYIE);
  1577. }
  1578. #endif
  1579. /**
  1580. * @brief Enable HSI ready interrupt
  1581. * @rmtoll CIER HSIRDYIE LL_RCC_EnableIT_HSIRDY
  1582. * @retval None
  1583. */
  1584. __STATIC_INLINE void LL_RCC_EnableIT_HSIRDY(void)
  1585. {
  1586. SET_BIT(RCC->CIER, RCC_CIER_HSIRDYIE);
  1587. }
  1588. /**
  1589. * @brief Enable HSE ready interrupt
  1590. * @rmtoll CIER HSERDYIE LL_RCC_EnableIT_HSERDY
  1591. * @retval None
  1592. */
  1593. __STATIC_INLINE void LL_RCC_EnableIT_HSERDY(void)
  1594. {
  1595. SET_BIT(RCC->CIER, RCC_CIER_HSERDYIE);
  1596. }
  1597. #if defined(RCC_PLL_SUPPORT)
  1598. /**
  1599. * @brief Enable PLL ready interrupt
  1600. * @rmtoll CIER PLLRDYIE LL_RCC_EnableIT_PLLRDY
  1601. * @retval None
  1602. */
  1603. __STATIC_INLINE void LL_RCC_EnableIT_PLLRDY(void)
  1604. {
  1605. SET_BIT(RCC->CIER, RCC_CIER_PLLRDYIE);
  1606. }
  1607. #endif
  1608. /**
  1609. * @brief Disable LSI ready interrupt
  1610. * @rmtoll CIER LSIRDYIE LL_RCC_DisableIT_LSIRDY
  1611. * @retval None
  1612. */
  1613. __STATIC_INLINE void LL_RCC_DisableIT_LSIRDY(void)
  1614. {
  1615. CLEAR_BIT(RCC->CIER, RCC_CIER_LSIRDYIE);
  1616. }
  1617. #if defined(RCC_LSE_SUPPORT)
  1618. /**
  1619. * @brief Disable LSE ready interrupt
  1620. * @rmtoll CIER LSERDYIE LL_RCC_DisableIT_LSERDY
  1621. * @retval None
  1622. */
  1623. __STATIC_INLINE void LL_RCC_DisableIT_LSERDY(void)
  1624. {
  1625. CLEAR_BIT(RCC->CIER, RCC_CIER_LSERDYIE);
  1626. }
  1627. #endif
  1628. /**
  1629. * @brief Disable HSI ready interrupt
  1630. * @rmtoll CIER HSIRDYIE LL_RCC_DisableIT_HSIRDY
  1631. * @retval None
  1632. */
  1633. __STATIC_INLINE void LL_RCC_DisableIT_HSIRDY(void)
  1634. {
  1635. CLEAR_BIT(RCC->CIER, RCC_CIER_HSIRDYIE);
  1636. }
  1637. /**
  1638. * @brief Disable HSE ready interrupt
  1639. * @rmtoll CIER HSERDYIE LL_RCC_DisableIT_HSERDY
  1640. * @retval None
  1641. */
  1642. __STATIC_INLINE void LL_RCC_DisableIT_HSERDY(void)
  1643. {
  1644. CLEAR_BIT(RCC->CIER, RCC_CIER_HSERDYIE);
  1645. }
  1646. #if defined(RCC_PLL_SUPPORT)
  1647. /**
  1648. * @brief Disable PLL ready interrupt
  1649. * @rmtoll CIER PLLRDYIE LL_RCC_DisableIT_PLLRDY
  1650. * @retval None
  1651. */
  1652. __STATIC_INLINE void LL_RCC_DisableIT_PLLRDY(void)
  1653. {
  1654. CLEAR_BIT(RCC->CIER, RCC_CIER_PLLRDYIE);
  1655. }
  1656. #endif
  1657. /**
  1658. * @brief Checks if LSI ready interrupt source is enabled or disabled.
  1659. * @rmtoll CIER LSIRDYIE LL_RCC_IsEnabledIT_LSIRDY
  1660. * @retval State of bit (1 or 0).
  1661. */
  1662. __STATIC_INLINE uint32_t LL_RCC_IsEnabledIT_LSIRDY(void)
  1663. {
  1664. return ((READ_BIT(RCC->CIER, RCC_CIER_LSIRDYIE) == (RCC_CIER_LSIRDYIE)) ? 1UL : 0UL);
  1665. }
  1666. #if defined(RCC_LSE_SUPPORT)
  1667. /**
  1668. * @brief Checks if LSE ready interrupt source is enabled or disabled.
  1669. * @rmtoll CIER LSERDYIE LL_RCC_IsEnabledIT_LSERDY
  1670. * @retval State of bit (1 or 0).
  1671. */
  1672. __STATIC_INLINE uint32_t LL_RCC_IsEnabledIT_LSERDY(void)
  1673. {
  1674. return ((READ_BIT(RCC->CIER, RCC_CIER_LSERDYIE) == (RCC_CIER_LSERDYIE)) ? 1UL : 0UL);
  1675. }
  1676. #endif
  1677. /**
  1678. * @brief Checks if HSI ready interrupt source is enabled or disabled.
  1679. * @rmtoll CIER HSIRDYIE LL_RCC_IsEnabledIT_HSIRDY
  1680. * @retval State of bit (1 or 0).
  1681. */
  1682. __STATIC_INLINE uint32_t LL_RCC_IsEnabledIT_HSIRDY(void)
  1683. {
  1684. return ((READ_BIT(RCC->CIER, RCC_CIER_HSIRDYIE) == (RCC_CIER_HSIRDYIE)) ? 1UL : 0UL);
  1685. }
  1686. /**
  1687. * @brief Checks if HSE ready interrupt source is enabled or disabled.
  1688. * @rmtoll CIER HSERDYIE LL_RCC_IsEnabledIT_HSERDY
  1689. * @retval State of bit (1 or 0).
  1690. */
  1691. __STATIC_INLINE uint32_t LL_RCC_IsEnabledIT_HSERDY(void)
  1692. {
  1693. return ((READ_BIT(RCC->CIER, RCC_CIER_HSERDYIE) == (RCC_CIER_HSERDYIE)) ? 1UL : 0UL);
  1694. }
  1695. #if defined(RCC_PLL_SUPPORT)
  1696. /**
  1697. * @brief Checks if PLL ready interrupt source is enabled or disabled.
  1698. * @rmtoll CIER PLLRDYIE LL_RCC_IsEnabledIT_PLLRDY
  1699. * @retval State of bit (1 or 0).
  1700. */
  1701. __STATIC_INLINE uint32_t LL_RCC_IsEnabledIT_PLLRDY(void)
  1702. {
  1703. return ((READ_BIT(RCC->CIER, RCC_CIER_PLLRDYIE) == (RCC_CIER_PLLRDYIE)) ? 1UL : 0UL);
  1704. }
  1705. #endif
  1706. /**
  1707. * @}
  1708. */
  1709. #if defined(USE_FULL_LL_DRIVER)
  1710. /** @defgroup RCC_LL_EF_Init De-initialization function
  1711. * @{
  1712. */
  1713. ErrorStatus LL_RCC_DeInit(void);
  1714. /**
  1715. * @}
  1716. */
  1717. /** @defgroup RCC_LL_EF_Get_Freq Get system and peripherals clocks frequency functions
  1718. * @{
  1719. */
  1720. void LL_RCC_GetSystemClocksFreq(LL_RCC_ClocksTypeDef *RCC_Clocks);
  1721. uint32_t LL_RCC_GetMCOClockFreq(uint32_t MCOx);
  1722. uint32_t LL_RCC_GetLSCClockFreq(void);
  1723. #if defined(RCC_CCIPR_PVDSEL)
  1724. uint32_t LL_RCC_GetPVDClockFreq(void);
  1725. #endif
  1726. #if defined(COMP1)
  1727. uint32_t LL_RCC_GetCOMPClockFreq(uint32_t COMPx);
  1728. #endif
  1729. #if defined(LPTIM1)
  1730. uint32_t LL_RCC_GetLPTIMClockFreq(uint32_t LPTIMx);
  1731. #endif
  1732. #if defined(RTC)
  1733. uint32_t LL_RCC_GetRTCClockFreq(void);
  1734. #endif
  1735. /**
  1736. * @}
  1737. */
  1738. #endif /* USE_FULL_LL_DRIVER */
  1739. /**
  1740. * @}
  1741. */
  1742. /**
  1743. * @}
  1744. */
  1745. #endif /* defined(RCC) */
  1746. /**
  1747. * @}
  1748. */
  1749. #ifdef __cplusplus
  1750. }
  1751. #endif
  1752. #endif /* __PY32F0XX_LL_RCC_H */
  1753. /************************ (C) COPYRIGHT Puya *****END OF FILE****/