stm32f1xx_ll_rcc.h 82 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309
  1. /**
  2. ******************************************************************************
  3. * @file stm32f1xx_ll_rcc.h
  4. * @author MCD Application Team
  5. * @brief Header file of RCC LL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2016 STMicroelectronics.
  10. * All rights reserved.
  11. *
  12. * This software is licensed under terms that can be found in the LICENSE file in
  13. * the root directory of this software component.
  14. * If no LICENSE file comes with this software, it is provided AS-IS.
  15. ******************************************************************************
  16. */
  17. /* Define to prevent recursive inclusion -------------------------------------*/
  18. #ifndef __STM32F1xx_LL_RCC_H
  19. #define __STM32F1xx_LL_RCC_H
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. /* Includes ------------------------------------------------------------------*/
  24. #include "stm32f1xx.h"
  25. /** @addtogroup STM32F1xx_LL_Driver
  26. * @{
  27. */
  28. #if defined(RCC)
  29. /** @defgroup RCC_LL RCC
  30. * @{
  31. */
  32. /* Private types -------------------------------------------------------------*/
  33. /* Private variables ---------------------------------------------------------*/
  34. /* Private constants ---------------------------------------------------------*/
  35. /* Private macros ------------------------------------------------------------*/
  36. #if defined(USE_FULL_LL_DRIVER)
  37. /** @defgroup RCC_LL_Private_Macros RCC Private Macros
  38. * @{
  39. */
  40. /**
  41. * @}
  42. */
  43. #endif /*USE_FULL_LL_DRIVER*/
  44. /* Exported types ------------------------------------------------------------*/
  45. #if defined(USE_FULL_LL_DRIVER)
  46. /** @defgroup RCC_LL_Exported_Types RCC Exported Types
  47. * @{
  48. */
  49. /** @defgroup LL_ES_CLOCK_FREQ Clocks Frequency Structure
  50. * @{
  51. */
  52. /**
  53. * @brief RCC Clocks Frequency Structure
  54. */
  55. typedef struct
  56. {
  57. uint32_t SYSCLK_Frequency; /*!< SYSCLK clock frequency */
  58. uint32_t HCLK_Frequency; /*!< HCLK clock frequency */
  59. uint32_t PCLK1_Frequency; /*!< PCLK1 clock frequency */
  60. uint32_t PCLK2_Frequency; /*!< PCLK2 clock frequency */
  61. } LL_RCC_ClocksTypeDef;
  62. /**
  63. * @}
  64. */
  65. /**
  66. * @}
  67. */
  68. #endif /* USE_FULL_LL_DRIVER */
  69. /* Exported constants --------------------------------------------------------*/
  70. /** @defgroup RCC_LL_Exported_Constants RCC Exported Constants
  71. * @{
  72. */
  73. /** @defgroup RCC_LL_EC_OSC_VALUES Oscillator Values adaptation
  74. * @brief Defines used to adapt values of different oscillators
  75. * @note These values could be modified in the user environment according to
  76. * HW set-up.
  77. * @{
  78. */
  79. #if !defined (HSE_VALUE)
  80. #define HSE_VALUE 8000000U /*!< Value of the HSE oscillator in Hz */
  81. #endif /* HSE_VALUE */
  82. #if !defined (HSI_VALUE)
  83. #define HSI_VALUE 8000000U /*!< Value of the HSI oscillator in Hz */
  84. #endif /* HSI_VALUE */
  85. #if !defined (LSE_VALUE)
  86. #define LSE_VALUE 32768U /*!< Value of the LSE oscillator in Hz */
  87. #endif /* LSE_VALUE */
  88. #if !defined (LSI_VALUE)
  89. #define LSI_VALUE 40000U /*!< Value of the LSI oscillator in Hz */
  90. #endif /* LSI_VALUE */
  91. /**
  92. * @}
  93. */
  94. /** @defgroup RCC_LL_EC_CLEAR_FLAG Clear Flags Defines
  95. * @brief Flags defines which can be used with LL_RCC_WriteReg function
  96. * @{
  97. */
  98. #define LL_RCC_CIR_LSIRDYC RCC_CIR_LSIRDYC /*!< LSI Ready Interrupt Clear */
  99. #define LL_RCC_CIR_LSERDYC RCC_CIR_LSERDYC /*!< LSE Ready Interrupt Clear */
  100. #define LL_RCC_CIR_HSIRDYC RCC_CIR_HSIRDYC /*!< HSI Ready Interrupt Clear */
  101. #define LL_RCC_CIR_HSERDYC RCC_CIR_HSERDYC /*!< HSE Ready Interrupt Clear */
  102. #define LL_RCC_CIR_PLLRDYC RCC_CIR_PLLRDYC /*!< PLL Ready Interrupt Clear */
  103. #define LL_RCC_CIR_PLL3RDYC RCC_CIR_PLL3RDYC /*!< PLL3(PLLI2S) Ready Interrupt Clear */
  104. #define LL_RCC_CIR_PLL2RDYC RCC_CIR_PLL2RDYC /*!< PLL2 Ready Interrupt Clear */
  105. #define LL_RCC_CIR_CSSC RCC_CIR_CSSC /*!< Clock Security System Interrupt Clear */
  106. /**
  107. * @}
  108. */
  109. /** @defgroup RCC_LL_EC_GET_FLAG Get Flags Defines
  110. * @brief Flags defines which can be used with LL_RCC_ReadReg function
  111. * @{
  112. */
  113. #define LL_RCC_CIR_LSIRDYF RCC_CIR_LSIRDYF /*!< LSI Ready Interrupt flag */
  114. #define LL_RCC_CIR_LSERDYF RCC_CIR_LSERDYF /*!< LSE Ready Interrupt flag */
  115. #define LL_RCC_CIR_HSIRDYF RCC_CIR_HSIRDYF /*!< HSI Ready Interrupt flag */
  116. #define LL_RCC_CIR_HSERDYF RCC_CIR_HSERDYF /*!< HSE Ready Interrupt flag */
  117. #define LL_RCC_CIR_PLLRDYF RCC_CIR_PLLRDYF /*!< PLL Ready Interrupt flag */
  118. #define LL_RCC_CIR_PLL3RDYF RCC_CIR_PLL3RDYF /*!< PLL3(PLLI2S) Ready Interrupt flag */
  119. #define LL_RCC_CIR_PLL2RDYF RCC_CIR_PLL2RDYF /*!< PLL2 Ready Interrupt flag */
  120. #define LL_RCC_CIR_CSSF RCC_CIR_CSSF /*!< Clock Security System Interrupt flag */
  121. #define LL_RCC_CSR_PINRSTF RCC_CSR_PINRSTF /*!< PIN reset flag */
  122. #define LL_RCC_CSR_PORRSTF RCC_CSR_PORRSTF /*!< POR/PDR reset flag */
  123. #define LL_RCC_CSR_SFTRSTF RCC_CSR_SFTRSTF /*!< Software Reset flag */
  124. #define LL_RCC_CSR_IWDGRSTF RCC_CSR_IWDGRSTF /*!< Independent Watchdog reset flag */
  125. #define LL_RCC_CSR_WWDGRSTF RCC_CSR_WWDGRSTF /*!< Window watchdog reset flag */
  126. #define LL_RCC_CSR_LPWRRSTF RCC_CSR_LPWRRSTF /*!< Low-Power reset flag */
  127. /**
  128. * @}
  129. */
  130. /** @defgroup RCC_LL_EC_IT IT Defines
  131. * @brief IT defines which can be used with LL_RCC_ReadReg and LL_RCC_WriteReg functions
  132. * @{
  133. */
  134. #define LL_RCC_CIR_LSIRDYIE RCC_CIR_LSIRDYIE /*!< LSI Ready Interrupt Enable */
  135. #define LL_RCC_CIR_LSERDYIE RCC_CIR_LSERDYIE /*!< LSE Ready Interrupt Enable */
  136. #define LL_RCC_CIR_HSIRDYIE RCC_CIR_HSIRDYIE /*!< HSI Ready Interrupt Enable */
  137. #define LL_RCC_CIR_HSERDYIE RCC_CIR_HSERDYIE /*!< HSE Ready Interrupt Enable */
  138. #define LL_RCC_CIR_PLLRDYIE RCC_CIR_PLLRDYIE /*!< PLL Ready Interrupt Enable */
  139. #define LL_RCC_CIR_PLL3RDYIE RCC_CIR_PLL3RDYIE /*!< PLL3(PLLI2S) Ready Interrupt Enable */
  140. #define LL_RCC_CIR_PLL2RDYIE RCC_CIR_PLL2RDYIE /*!< PLL2 Ready Interrupt Enable */
  141. /**
  142. * @}
  143. */
  144. #if defined(RCC_CFGR2_PREDIV2)
  145. /** @defgroup RCC_LL_EC_HSE_PREDIV2_DIV HSE PREDIV2 Division factor
  146. * @{
  147. */
  148. #define LL_RCC_HSE_PREDIV2_DIV_1 RCC_CFGR2_PREDIV2_DIV1 /*!< PREDIV2 input clock not divided */
  149. #define LL_RCC_HSE_PREDIV2_DIV_2 RCC_CFGR2_PREDIV2_DIV2 /*!< PREDIV2 input clock divided by 2 */
  150. #define LL_RCC_HSE_PREDIV2_DIV_3 RCC_CFGR2_PREDIV2_DIV3 /*!< PREDIV2 input clock divided by 3 */
  151. #define LL_RCC_HSE_PREDIV2_DIV_4 RCC_CFGR2_PREDIV2_DIV4 /*!< PREDIV2 input clock divided by 4 */
  152. #define LL_RCC_HSE_PREDIV2_DIV_5 RCC_CFGR2_PREDIV2_DIV5 /*!< PREDIV2 input clock divided by 5 */
  153. #define LL_RCC_HSE_PREDIV2_DIV_6 RCC_CFGR2_PREDIV2_DIV6 /*!< PREDIV2 input clock divided by 6 */
  154. #define LL_RCC_HSE_PREDIV2_DIV_7 RCC_CFGR2_PREDIV2_DIV7 /*!< PREDIV2 input clock divided by 7 */
  155. #define LL_RCC_HSE_PREDIV2_DIV_8 RCC_CFGR2_PREDIV2_DIV8 /*!< PREDIV2 input clock divided by 8 */
  156. #define LL_RCC_HSE_PREDIV2_DIV_9 RCC_CFGR2_PREDIV2_DIV9 /*!< PREDIV2 input clock divided by 9 */
  157. #define LL_RCC_HSE_PREDIV2_DIV_10 RCC_CFGR2_PREDIV2_DIV10 /*!< PREDIV2 input clock divided by 10 */
  158. #define LL_RCC_HSE_PREDIV2_DIV_11 RCC_CFGR2_PREDIV2_DIV11 /*!< PREDIV2 input clock divided by 11 */
  159. #define LL_RCC_HSE_PREDIV2_DIV_12 RCC_CFGR2_PREDIV2_DIV12 /*!< PREDIV2 input clock divided by 12 */
  160. #define LL_RCC_HSE_PREDIV2_DIV_13 RCC_CFGR2_PREDIV2_DIV13 /*!< PREDIV2 input clock divided by 13 */
  161. #define LL_RCC_HSE_PREDIV2_DIV_14 RCC_CFGR2_PREDIV2_DIV14 /*!< PREDIV2 input clock divided by 14 */
  162. #define LL_RCC_HSE_PREDIV2_DIV_15 RCC_CFGR2_PREDIV2_DIV15 /*!< PREDIV2 input clock divided by 15 */
  163. #define LL_RCC_HSE_PREDIV2_DIV_16 RCC_CFGR2_PREDIV2_DIV16 /*!< PREDIV2 input clock divided by 16 */
  164. /**
  165. * @}
  166. */
  167. #endif /* RCC_CFGR2_PREDIV2 */
  168. /** @defgroup RCC_LL_EC_SYS_CLKSOURCE System clock switch
  169. * @{
  170. */
  171. #define LL_RCC_SYS_CLKSOURCE_HSI RCC_CFGR_SW_HSI /*!< HSI selection as system clock */
  172. #define LL_RCC_SYS_CLKSOURCE_HSE RCC_CFGR_SW_HSE /*!< HSE selection as system clock */
  173. #define LL_RCC_SYS_CLKSOURCE_PLL RCC_CFGR_SW_PLL /*!< PLL selection as system clock */
  174. /**
  175. * @}
  176. */
  177. /** @defgroup RCC_LL_EC_SYS_CLKSOURCE_STATUS System clock switch status
  178. * @{
  179. */
  180. #define LL_RCC_SYS_CLKSOURCE_STATUS_HSI RCC_CFGR_SWS_HSI /*!< HSI used as system clock */
  181. #define LL_RCC_SYS_CLKSOURCE_STATUS_HSE RCC_CFGR_SWS_HSE /*!< HSE used as system clock */
  182. #define LL_RCC_SYS_CLKSOURCE_STATUS_PLL RCC_CFGR_SWS_PLL /*!< PLL used as system clock */
  183. /**
  184. * @}
  185. */
  186. /** @defgroup RCC_LL_EC_SYSCLK_DIV AHB prescaler
  187. * @{
  188. */
  189. #define LL_RCC_SYSCLK_DIV_1 RCC_CFGR_HPRE_DIV1 /*!< SYSCLK not divided */
  190. #define LL_RCC_SYSCLK_DIV_2 RCC_CFGR_HPRE_DIV2 /*!< SYSCLK divided by 2 */
  191. #define LL_RCC_SYSCLK_DIV_4 RCC_CFGR_HPRE_DIV4 /*!< SYSCLK divided by 4 */
  192. #define LL_RCC_SYSCLK_DIV_8 RCC_CFGR_HPRE_DIV8 /*!< SYSCLK divided by 8 */
  193. #define LL_RCC_SYSCLK_DIV_16 RCC_CFGR_HPRE_DIV16 /*!< SYSCLK divided by 16 */
  194. #define LL_RCC_SYSCLK_DIV_64 RCC_CFGR_HPRE_DIV64 /*!< SYSCLK divided by 64 */
  195. #define LL_RCC_SYSCLK_DIV_128 RCC_CFGR_HPRE_DIV128 /*!< SYSCLK divided by 128 */
  196. #define LL_RCC_SYSCLK_DIV_256 RCC_CFGR_HPRE_DIV256 /*!< SYSCLK divided by 256 */
  197. #define LL_RCC_SYSCLK_DIV_512 RCC_CFGR_HPRE_DIV512 /*!< SYSCLK divided by 512 */
  198. /**
  199. * @}
  200. */
  201. /** @defgroup RCC_LL_EC_APB1_DIV APB low-speed prescaler (APB1)
  202. * @{
  203. */
  204. #define LL_RCC_APB1_DIV_1 RCC_CFGR_PPRE1_DIV1 /*!< HCLK not divided */
  205. #define LL_RCC_APB1_DIV_2 RCC_CFGR_PPRE1_DIV2 /*!< HCLK divided by 2 */
  206. #define LL_RCC_APB1_DIV_4 RCC_CFGR_PPRE1_DIV4 /*!< HCLK divided by 4 */
  207. #define LL_RCC_APB1_DIV_8 RCC_CFGR_PPRE1_DIV8 /*!< HCLK divided by 8 */
  208. #define LL_RCC_APB1_DIV_16 RCC_CFGR_PPRE1_DIV16 /*!< HCLK divided by 16 */
  209. /**
  210. * @}
  211. */
  212. /** @defgroup RCC_LL_EC_APB2_DIV APB high-speed prescaler (APB2)
  213. * @{
  214. */
  215. #define LL_RCC_APB2_DIV_1 RCC_CFGR_PPRE2_DIV1 /*!< HCLK not divided */
  216. #define LL_RCC_APB2_DIV_2 RCC_CFGR_PPRE2_DIV2 /*!< HCLK divided by 2 */
  217. #define LL_RCC_APB2_DIV_4 RCC_CFGR_PPRE2_DIV4 /*!< HCLK divided by 4 */
  218. #define LL_RCC_APB2_DIV_8 RCC_CFGR_PPRE2_DIV8 /*!< HCLK divided by 8 */
  219. #define LL_RCC_APB2_DIV_16 RCC_CFGR_PPRE2_DIV16 /*!< HCLK divided by 16 */
  220. /**
  221. * @}
  222. */
  223. /** @defgroup RCC_LL_EC_MCO1SOURCE MCO1 SOURCE selection
  224. * @{
  225. */
  226. #define LL_RCC_MCO1SOURCE_NOCLOCK RCC_CFGR_MCO_NOCLOCK /*!< MCO output disabled, no clock on MCO */
  227. #define LL_RCC_MCO1SOURCE_SYSCLK RCC_CFGR_MCO_SYSCLK /*!< SYSCLK selection as MCO source */
  228. #define LL_RCC_MCO1SOURCE_HSI RCC_CFGR_MCO_HSI /*!< HSI selection as MCO source */
  229. #define LL_RCC_MCO1SOURCE_HSE RCC_CFGR_MCO_HSE /*!< HSE selection as MCO source */
  230. #define LL_RCC_MCO1SOURCE_PLLCLK_DIV_2 RCC_CFGR_MCO_PLLCLK_DIV2 /*!< PLL clock divided by 2*/
  231. #if defined(RCC_CFGR_MCO_PLL2CLK)
  232. #define LL_RCC_MCO1SOURCE_PLL2CLK RCC_CFGR_MCO_PLL2CLK /*!< PLL2 clock selected as MCO source*/
  233. #endif /* RCC_CFGR_MCO_PLL2CLK */
  234. #if defined(RCC_CFGR_MCO_PLL3CLK_DIV2)
  235. #define LL_RCC_MCO1SOURCE_PLLI2SCLK_DIV2 RCC_CFGR_MCO_PLL3CLK_DIV2 /*!< PLLI2S clock divided by 2 selected as MCO source*/
  236. #endif /* RCC_CFGR_MCO_PLL3CLK_DIV2 */
  237. #if defined(RCC_CFGR_MCO_EXT_HSE)
  238. #define LL_RCC_MCO1SOURCE_EXT_HSE RCC_CFGR_MCO_EXT_HSE /*!< XT1 external 3-25 MHz oscillator clock selected as MCO source */
  239. #endif /* RCC_CFGR_MCO_EXT_HSE */
  240. #if defined(RCC_CFGR_MCO_PLL3CLK)
  241. #define LL_RCC_MCO1SOURCE_PLLI2SCLK RCC_CFGR_MCO_PLL3CLK /*!< PLLI2S clock selected as MCO source */
  242. #endif /* RCC_CFGR_MCO_PLL3CLK */
  243. /**
  244. * @}
  245. */
  246. #if defined(USE_FULL_LL_DRIVER)
  247. /** @defgroup RCC_LL_EC_PERIPH_FREQUENCY Peripheral clock frequency
  248. * @{
  249. */
  250. #define LL_RCC_PERIPH_FREQUENCY_NO 0x00000000U /*!< No clock enabled for the peripheral */
  251. #define LL_RCC_PERIPH_FREQUENCY_NA 0xFFFFFFFFU /*!< Frequency cannot be provided as external clock */
  252. /**
  253. * @}
  254. */
  255. #endif /* USE_FULL_LL_DRIVER */
  256. #if defined(RCC_CFGR2_I2S2SRC)
  257. /** @defgroup RCC_LL_EC_I2S2CLKSOURCE Peripheral I2S clock source selection
  258. * @{
  259. */
  260. #define LL_RCC_I2S2_CLKSOURCE_SYSCLK RCC_CFGR2_I2S2SRC /*!< System clock (SYSCLK) selected as I2S2 clock entry */
  261. #define LL_RCC_I2S2_CLKSOURCE_PLLI2S_VCO (uint32_t)(RCC_CFGR2_I2S2SRC | (RCC_CFGR2_I2S2SRC >> 16U)) /*!< PLLI2S VCO clock selected as I2S2 clock entry */
  262. #define LL_RCC_I2S3_CLKSOURCE_SYSCLK RCC_CFGR2_I2S3SRC /*!< System clock (SYSCLK) selected as I2S3 clock entry */
  263. #define LL_RCC_I2S3_CLKSOURCE_PLLI2S_VCO (uint32_t)(RCC_CFGR2_I2S3SRC | (RCC_CFGR2_I2S3SRC >> 16U)) /*!< PLLI2S VCO clock selected as I2S3 clock entry */
  264. /**
  265. * @}
  266. */
  267. #endif /* RCC_CFGR2_I2S2SRC */
  268. #if defined(USB_OTG_FS) || defined(USB)
  269. /** @defgroup RCC_LL_EC_USB_CLKSOURCE Peripheral USB clock source selection
  270. * @{
  271. */
  272. #if defined(RCC_CFGR_USBPRE)
  273. #define LL_RCC_USB_CLKSOURCE_PLL RCC_CFGR_USBPRE /*!< PLL clock is not divided */
  274. #define LL_RCC_USB_CLKSOURCE_PLL_DIV_1_5 0x00000000U /*!< PLL clock is divided by 1.5 */
  275. #endif /*RCC_CFGR_USBPRE*/
  276. #if defined(RCC_CFGR_OTGFSPRE)
  277. #define LL_RCC_USB_CLKSOURCE_PLL_DIV_2 RCC_CFGR_OTGFSPRE /*!< PLL clock is divided by 2 */
  278. #define LL_RCC_USB_CLKSOURCE_PLL_DIV_3 0x00000000U /*!< PLL clock is divided by 3 */
  279. #endif /*RCC_CFGR_OTGFSPRE*/
  280. /**
  281. * @}
  282. */
  283. #endif /* USB_OTG_FS || USB */
  284. /** @defgroup RCC_LL_EC_ADC_CLKSOURCE_PCLK2 Peripheral ADC clock source selection
  285. * @{
  286. */
  287. #define LL_RCC_ADC_CLKSRC_PCLK2_DIV_2 RCC_CFGR_ADCPRE_DIV2 /*ADC prescaler PCLK2 divided by 2*/
  288. #define LL_RCC_ADC_CLKSRC_PCLK2_DIV_4 RCC_CFGR_ADCPRE_DIV4 /*ADC prescaler PCLK2 divided by 4*/
  289. #define LL_RCC_ADC_CLKSRC_PCLK2_DIV_6 RCC_CFGR_ADCPRE_DIV6 /*ADC prescaler PCLK2 divided by 6*/
  290. #define LL_RCC_ADC_CLKSRC_PCLK2_DIV_8 RCC_CFGR_ADCPRE_DIV8 /*ADC prescaler PCLK2 divided by 8*/
  291. /**
  292. * @}
  293. */
  294. #if defined(RCC_CFGR2_I2S2SRC)
  295. /** @defgroup RCC_LL_EC_I2S2 Peripheral I2S get clock source
  296. * @{
  297. */
  298. #define LL_RCC_I2S2_CLKSOURCE RCC_CFGR2_I2S2SRC /*!< I2S2 Clock source selection */
  299. #define LL_RCC_I2S3_CLKSOURCE RCC_CFGR2_I2S3SRC /*!< I2S3 Clock source selection */
  300. /**
  301. * @}
  302. */
  303. #endif /* RCC_CFGR2_I2S2SRC */
  304. #if defined(USB_OTG_FS) || defined(USB)
  305. /** @defgroup RCC_LL_EC_USB Peripheral USB get clock source
  306. * @{
  307. */
  308. #define LL_RCC_USB_CLKSOURCE 0x00400000U /*!< USB Clock source selection */
  309. /**
  310. * @}
  311. */
  312. #endif /* USB_OTG_FS || USB */
  313. /** @defgroup RCC_LL_EC_ADC Peripheral ADC get clock source
  314. * @{
  315. */
  316. #define LL_RCC_ADC_CLKSOURCE RCC_CFGR_ADCPRE /*!< ADC Clock source selection */
  317. /**
  318. * @}
  319. */
  320. /** @defgroup RCC_LL_EC_RTC_CLKSOURCE RTC clock source selection
  321. * @{
  322. */
  323. #define LL_RCC_RTC_CLKSOURCE_NONE 0x00000000U /*!< No clock used as RTC clock */
  324. #define LL_RCC_RTC_CLKSOURCE_LSE RCC_BDCR_RTCSEL_0 /*!< LSE oscillator clock used as RTC clock */
  325. #define LL_RCC_RTC_CLKSOURCE_LSI RCC_BDCR_RTCSEL_1 /*!< LSI oscillator clock used as RTC clock */
  326. #define LL_RCC_RTC_CLKSOURCE_HSE_DIV128 RCC_BDCR_RTCSEL /*!< HSE oscillator clock divided by 128 used as RTC clock */
  327. /**
  328. * @}
  329. */
  330. /** @defgroup RCC_LL_EC_PLL_MUL PLL Multiplicator factor
  331. * @{
  332. */
  333. #if defined(RCC_CFGR_PLLMULL2)
  334. #define LL_RCC_PLL_MUL_2 RCC_CFGR_PLLMULL2 /*!< PLL input clock*2 */
  335. #endif /*RCC_CFGR_PLLMULL2*/
  336. #if defined(RCC_CFGR_PLLMULL3)
  337. #define LL_RCC_PLL_MUL_3 RCC_CFGR_PLLMULL3 /*!< PLL input clock*3 */
  338. #endif /*RCC_CFGR_PLLMULL3*/
  339. #define LL_RCC_PLL_MUL_4 RCC_CFGR_PLLMULL4 /*!< PLL input clock*4 */
  340. #define LL_RCC_PLL_MUL_5 RCC_CFGR_PLLMULL5 /*!< PLL input clock*5 */
  341. #define LL_RCC_PLL_MUL_6 RCC_CFGR_PLLMULL6 /*!< PLL input clock*6 */
  342. #define LL_RCC_PLL_MUL_7 RCC_CFGR_PLLMULL7 /*!< PLL input clock*7 */
  343. #define LL_RCC_PLL_MUL_8 RCC_CFGR_PLLMULL8 /*!< PLL input clock*8 */
  344. #define LL_RCC_PLL_MUL_9 RCC_CFGR_PLLMULL9 /*!< PLL input clock*9 */
  345. #if defined(RCC_CFGR_PLLMULL6_5)
  346. #define LL_RCC_PLL_MUL_6_5 RCC_CFGR_PLLMULL6_5 /*!< PLL input clock*6 */
  347. #else
  348. #define LL_RCC_PLL_MUL_10 RCC_CFGR_PLLMULL10 /*!< PLL input clock*10 */
  349. #define LL_RCC_PLL_MUL_11 RCC_CFGR_PLLMULL11 /*!< PLL input clock*11 */
  350. #define LL_RCC_PLL_MUL_12 RCC_CFGR_PLLMULL12 /*!< PLL input clock*12 */
  351. #define LL_RCC_PLL_MUL_13 RCC_CFGR_PLLMULL13 /*!< PLL input clock*13 */
  352. #define LL_RCC_PLL_MUL_14 RCC_CFGR_PLLMULL14 /*!< PLL input clock*14 */
  353. #define LL_RCC_PLL_MUL_15 RCC_CFGR_PLLMULL15 /*!< PLL input clock*15 */
  354. #define LL_RCC_PLL_MUL_16 RCC_CFGR_PLLMULL16 /*!< PLL input clock*16 */
  355. #endif /*RCC_CFGR_PLLMULL6_5*/
  356. /**
  357. * @}
  358. */
  359. /** @defgroup RCC_LL_EC_PLLSOURCE PLL SOURCE
  360. * @{
  361. */
  362. #define LL_RCC_PLLSOURCE_HSI_DIV_2 0x00000000U /*!< HSI clock divided by 2 selected as PLL entry clock source */
  363. #define LL_RCC_PLLSOURCE_HSE RCC_CFGR_PLLSRC /*!< HSE/PREDIV1 clock selected as PLL entry clock source */
  364. #if defined(RCC_CFGR2_PREDIV1SRC)
  365. #define LL_RCC_PLLSOURCE_PLL2 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1SRC << 4U) /*!< PLL2/PREDIV1 clock selected as PLL entry clock source */
  366. #endif /*RCC_CFGR2_PREDIV1SRC*/
  367. #if defined(RCC_CFGR2_PREDIV1)
  368. #define LL_RCC_PLLSOURCE_HSE_DIV_1 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV1) /*!< HSE/1 clock selected as PLL entry clock source */
  369. #define LL_RCC_PLLSOURCE_HSE_DIV_2 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV2) /*!< HSE/2 clock selected as PLL entry clock source */
  370. #define LL_RCC_PLLSOURCE_HSE_DIV_3 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV3) /*!< HSE/3 clock selected as PLL entry clock source */
  371. #define LL_RCC_PLLSOURCE_HSE_DIV_4 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV4) /*!< HSE/4 clock selected as PLL entry clock source */
  372. #define LL_RCC_PLLSOURCE_HSE_DIV_5 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV5) /*!< HSE/5 clock selected as PLL entry clock source */
  373. #define LL_RCC_PLLSOURCE_HSE_DIV_6 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV6) /*!< HSE/6 clock selected as PLL entry clock source */
  374. #define LL_RCC_PLLSOURCE_HSE_DIV_7 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV7) /*!< HSE/7 clock selected as PLL entry clock source */
  375. #define LL_RCC_PLLSOURCE_HSE_DIV_8 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV8) /*!< HSE/8 clock selected as PLL entry clock source */
  376. #define LL_RCC_PLLSOURCE_HSE_DIV_9 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV9) /*!< HSE/9 clock selected as PLL entry clock source */
  377. #define LL_RCC_PLLSOURCE_HSE_DIV_10 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV10) /*!< HSE/10 clock selected as PLL entry clock source */
  378. #define LL_RCC_PLLSOURCE_HSE_DIV_11 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV11) /*!< HSE/11 clock selected as PLL entry clock source */
  379. #define LL_RCC_PLLSOURCE_HSE_DIV_12 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV12) /*!< HSE/12 clock selected as PLL entry clock source */
  380. #define LL_RCC_PLLSOURCE_HSE_DIV_13 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV13) /*!< HSE/13 clock selected as PLL entry clock source */
  381. #define LL_RCC_PLLSOURCE_HSE_DIV_14 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV14) /*!< HSE/14 clock selected as PLL entry clock source */
  382. #define LL_RCC_PLLSOURCE_HSE_DIV_15 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV15) /*!< HSE/15 clock selected as PLL entry clock source */
  383. #define LL_RCC_PLLSOURCE_HSE_DIV_16 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV16) /*!< HSE/16 clock selected as PLL entry clock source */
  384. #if defined(RCC_CFGR2_PREDIV1SRC)
  385. #define LL_RCC_PLLSOURCE_PLL2_DIV_1 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV1 | RCC_CFGR2_PREDIV1SRC << 4U) /*!< PLL2/1 clock selected as PLL entry clock source */
  386. #define LL_RCC_PLLSOURCE_PLL2_DIV_2 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV2 | RCC_CFGR2_PREDIV1SRC << 4U) /*!< PLL2/2 clock selected as PLL entry clock source */
  387. #define LL_RCC_PLLSOURCE_PLL2_DIV_3 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV3 | RCC_CFGR2_PREDIV1SRC << 4U) /*!< PLL2/3 clock selected as PLL entry clock source */
  388. #define LL_RCC_PLLSOURCE_PLL2_DIV_4 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV4 | RCC_CFGR2_PREDIV1SRC << 4U) /*!< PLL2/4 clock selected as PLL entry clock source */
  389. #define LL_RCC_PLLSOURCE_PLL2_DIV_5 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV5 | RCC_CFGR2_PREDIV1SRC << 4U) /*!< PLL2/5 clock selected as PLL entry clock source */
  390. #define LL_RCC_PLLSOURCE_PLL2_DIV_6 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV6 | RCC_CFGR2_PREDIV1SRC << 4U) /*!< PLL2/6 clock selected as PLL entry clock source */
  391. #define LL_RCC_PLLSOURCE_PLL2_DIV_7 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV7 | RCC_CFGR2_PREDIV1SRC << 4U) /*!< PLL2/7 clock selected as PLL entry clock source */
  392. #define LL_RCC_PLLSOURCE_PLL2_DIV_8 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV8 | RCC_CFGR2_PREDIV1SRC << 4U) /*!< PLL2/8 clock selected as PLL entry clock source */
  393. #define LL_RCC_PLLSOURCE_PLL2_DIV_9 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV9 | RCC_CFGR2_PREDIV1SRC << 4U) /*!< PLL2/9 clock selected as PLL entry clock source */
  394. #define LL_RCC_PLLSOURCE_PLL2_DIV_10 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV10 | RCC_CFGR2_PREDIV1SRC << 4U) /*!< PLL2/10 clock selected as PLL entry clock source */
  395. #define LL_RCC_PLLSOURCE_PLL2_DIV_11 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV11 | RCC_CFGR2_PREDIV1SRC << 4U) /*!< PLL2/11 clock selected as PLL entry clock source */
  396. #define LL_RCC_PLLSOURCE_PLL2_DIV_12 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV12 | RCC_CFGR2_PREDIV1SRC << 4U) /*!< PLL2/12 clock selected as PLL entry clock source */
  397. #define LL_RCC_PLLSOURCE_PLL2_DIV_13 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV13 | RCC_CFGR2_PREDIV1SRC << 4U) /*!< PLL2/13 clock selected as PLL entry clock source */
  398. #define LL_RCC_PLLSOURCE_PLL2_DIV_14 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV14 | RCC_CFGR2_PREDIV1SRC << 4U) /*!< PLL2/14 clock selected as PLL entry clock source */
  399. #define LL_RCC_PLLSOURCE_PLL2_DIV_15 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV15 | RCC_CFGR2_PREDIV1SRC << 4U) /*!< PLL2/15 clock selected as PLL entry clock source */
  400. #define LL_RCC_PLLSOURCE_PLL2_DIV_16 (RCC_CFGR_PLLSRC | RCC_CFGR2_PREDIV1_DIV16 | RCC_CFGR2_PREDIV1SRC << 4U) /*!< PLL2/16 clock selected as PLL entry clock source */
  401. #endif /*RCC_CFGR2_PREDIV1SRC*/
  402. #else
  403. #define LL_RCC_PLLSOURCE_HSE_DIV_1 (RCC_CFGR_PLLSRC | 0x00000000U) /*!< HSE/1 clock selected as PLL entry clock source */
  404. #define LL_RCC_PLLSOURCE_HSE_DIV_2 (RCC_CFGR_PLLSRC | RCC_CFGR_PLLXTPRE) /*!< HSE/2 clock selected as PLL entry clock source */
  405. #endif /*RCC_CFGR2_PREDIV1*/
  406. /**
  407. * @}
  408. */
  409. /** @defgroup RCC_LL_EC_PREDIV_DIV PREDIV Division factor
  410. * @{
  411. */
  412. #if defined(RCC_CFGR2_PREDIV1)
  413. #define LL_RCC_PREDIV_DIV_1 RCC_CFGR2_PREDIV1_DIV1 /*!< PREDIV1 input clock not divided */
  414. #define LL_RCC_PREDIV_DIV_2 RCC_CFGR2_PREDIV1_DIV2 /*!< PREDIV1 input clock divided by 2 */
  415. #define LL_RCC_PREDIV_DIV_3 RCC_CFGR2_PREDIV1_DIV3 /*!< PREDIV1 input clock divided by 3 */
  416. #define LL_RCC_PREDIV_DIV_4 RCC_CFGR2_PREDIV1_DIV4 /*!< PREDIV1 input clock divided by 4 */
  417. #define LL_RCC_PREDIV_DIV_5 RCC_CFGR2_PREDIV1_DIV5 /*!< PREDIV1 input clock divided by 5 */
  418. #define LL_RCC_PREDIV_DIV_6 RCC_CFGR2_PREDIV1_DIV6 /*!< PREDIV1 input clock divided by 6 */
  419. #define LL_RCC_PREDIV_DIV_7 RCC_CFGR2_PREDIV1_DIV7 /*!< PREDIV1 input clock divided by 7 */
  420. #define LL_RCC_PREDIV_DIV_8 RCC_CFGR2_PREDIV1_DIV8 /*!< PREDIV1 input clock divided by 8 */
  421. #define LL_RCC_PREDIV_DIV_9 RCC_CFGR2_PREDIV1_DIV9 /*!< PREDIV1 input clock divided by 9 */
  422. #define LL_RCC_PREDIV_DIV_10 RCC_CFGR2_PREDIV1_DIV10 /*!< PREDIV1 input clock divided by 10 */
  423. #define LL_RCC_PREDIV_DIV_11 RCC_CFGR2_PREDIV1_DIV11 /*!< PREDIV1 input clock divided by 11 */
  424. #define LL_RCC_PREDIV_DIV_12 RCC_CFGR2_PREDIV1_DIV12 /*!< PREDIV1 input clock divided by 12 */
  425. #define LL_RCC_PREDIV_DIV_13 RCC_CFGR2_PREDIV1_DIV13 /*!< PREDIV1 input clock divided by 13 */
  426. #define LL_RCC_PREDIV_DIV_14 RCC_CFGR2_PREDIV1_DIV14 /*!< PREDIV1 input clock divided by 14 */
  427. #define LL_RCC_PREDIV_DIV_15 RCC_CFGR2_PREDIV1_DIV15 /*!< PREDIV1 input clock divided by 15 */
  428. #define LL_RCC_PREDIV_DIV_16 RCC_CFGR2_PREDIV1_DIV16 /*!< PREDIV1 input clock divided by 16 */
  429. #else
  430. #define LL_RCC_PREDIV_DIV_1 0x00000000U /*!< HSE divider clock clock not divided */
  431. #define LL_RCC_PREDIV_DIV_2 RCC_CFGR_PLLXTPRE /*!< HSE divider clock divided by 2 for PLL entry */
  432. #endif /*RCC_CFGR2_PREDIV1*/
  433. /**
  434. * @}
  435. */
  436. #if defined(RCC_PLLI2S_SUPPORT)
  437. /** @defgroup RCC_LL_EC_PLLI2S_MUL PLLI2S MUL
  438. * @{
  439. */
  440. #define LL_RCC_PLLI2S_MUL_8 RCC_CFGR2_PLL3MUL8 /*!< PLLI2S input clock * 8 */
  441. #define LL_RCC_PLLI2S_MUL_9 RCC_CFGR2_PLL3MUL9 /*!< PLLI2S input clock * 9 */
  442. #define LL_RCC_PLLI2S_MUL_10 RCC_CFGR2_PLL3MUL10 /*!< PLLI2S input clock * 10 */
  443. #define LL_RCC_PLLI2S_MUL_11 RCC_CFGR2_PLL3MUL11 /*!< PLLI2S input clock * 11 */
  444. #define LL_RCC_PLLI2S_MUL_12 RCC_CFGR2_PLL3MUL12 /*!< PLLI2S input clock * 12 */
  445. #define LL_RCC_PLLI2S_MUL_13 RCC_CFGR2_PLL3MUL13 /*!< PLLI2S input clock * 13 */
  446. #define LL_RCC_PLLI2S_MUL_14 RCC_CFGR2_PLL3MUL14 /*!< PLLI2S input clock * 14 */
  447. #define LL_RCC_PLLI2S_MUL_16 RCC_CFGR2_PLL3MUL16 /*!< PLLI2S input clock * 16 */
  448. #define LL_RCC_PLLI2S_MUL_20 RCC_CFGR2_PLL3MUL20 /*!< PLLI2S input clock * 20 */
  449. /**
  450. * @}
  451. */
  452. #endif /* RCC_PLLI2S_SUPPORT */
  453. #if defined(RCC_PLL2_SUPPORT)
  454. /** @defgroup RCC_LL_EC_PLL2_MUL PLL2 MUL
  455. * @{
  456. */
  457. #define LL_RCC_PLL2_MUL_8 RCC_CFGR2_PLL2MUL8 /*!< PLL2 input clock * 8 */
  458. #define LL_RCC_PLL2_MUL_9 RCC_CFGR2_PLL2MUL9 /*!< PLL2 input clock * 9 */
  459. #define LL_RCC_PLL2_MUL_10 RCC_CFGR2_PLL2MUL10 /*!< PLL2 input clock * 10 */
  460. #define LL_RCC_PLL2_MUL_11 RCC_CFGR2_PLL2MUL11 /*!< PLL2 input clock * 11 */
  461. #define LL_RCC_PLL2_MUL_12 RCC_CFGR2_PLL2MUL12 /*!< PLL2 input clock * 12 */
  462. #define LL_RCC_PLL2_MUL_13 RCC_CFGR2_PLL2MUL13 /*!< PLL2 input clock * 13 */
  463. #define LL_RCC_PLL2_MUL_14 RCC_CFGR2_PLL2MUL14 /*!< PLL2 input clock * 14 */
  464. #define LL_RCC_PLL2_MUL_16 RCC_CFGR2_PLL2MUL16 /*!< PLL2 input clock * 16 */
  465. #define LL_RCC_PLL2_MUL_20 RCC_CFGR2_PLL2MUL20 /*!< PLL2 input clock * 20 */
  466. /**
  467. * @}
  468. */
  469. #endif /* RCC_PLL2_SUPPORT */
  470. /**
  471. * @}
  472. */
  473. /* Exported macro ------------------------------------------------------------*/
  474. /** @defgroup RCC_LL_Exported_Macros RCC Exported Macros
  475. * @{
  476. */
  477. /** @defgroup RCC_LL_EM_WRITE_READ Common Write and read registers Macros
  478. * @{
  479. */
  480. /**
  481. * @brief Write a value in RCC register
  482. * @param __REG__ Register to be written
  483. * @param __VALUE__ Value to be written in the register
  484. * @retval None
  485. */
  486. #define LL_RCC_WriteReg(__REG__, __VALUE__) WRITE_REG(RCC->__REG__, (__VALUE__))
  487. /**
  488. * @brief Read a value in RCC register
  489. * @param __REG__ Register to be read
  490. * @retval Register value
  491. */
  492. #define LL_RCC_ReadReg(__REG__) READ_REG(RCC->__REG__)
  493. /**
  494. * @}
  495. */
  496. /** @defgroup RCC_LL_EM_CALC_FREQ Calculate frequencies
  497. * @{
  498. */
  499. #if defined(RCC_CFGR_PLLMULL6_5)
  500. /**
  501. * @brief Helper macro to calculate the PLLCLK frequency
  502. * @note ex: @ref __LL_RCC_CALC_PLLCLK_FREQ (HSE_VALUE / (@ref LL_RCC_PLL_GetPrediv () + 1), @ref LL_RCC_PLL_GetMultiplicator());
  503. * @param __INPUTFREQ__ PLL Input frequency (based on HSE div Prediv1 / HSI div 2 / PLL2 div Prediv1)
  504. * @param __PLLMUL__: This parameter can be one of the following values:
  505. * @arg @ref LL_RCC_PLL_MUL_4
  506. * @arg @ref LL_RCC_PLL_MUL_5
  507. * @arg @ref LL_RCC_PLL_MUL_6
  508. * @arg @ref LL_RCC_PLL_MUL_7
  509. * @arg @ref LL_RCC_PLL_MUL_8
  510. * @arg @ref LL_RCC_PLL_MUL_9
  511. * @arg @ref LL_RCC_PLL_MUL_6_5
  512. * @retval PLL clock frequency (in Hz)
  513. */
  514. #define __LL_RCC_CALC_PLLCLK_FREQ(__INPUTFREQ__, __PLLMUL__) \
  515. (((__PLLMUL__) != RCC_CFGR_PLLMULL6_5) ? \
  516. ((__INPUTFREQ__) * ((((__PLLMUL__) & RCC_CFGR_PLLMULL) >> RCC_CFGR_PLLMULL_Pos) + 2U)) :\
  517. (((__INPUTFREQ__) * 13U) / 2U))
  518. #else
  519. /**
  520. * @brief Helper macro to calculate the PLLCLK frequency
  521. * @note ex: @ref __LL_RCC_CALC_PLLCLK_FREQ (HSE_VALUE / (@ref LL_RCC_PLL_GetPrediv () + 1), @ref LL_RCC_PLL_GetMultiplicator ());
  522. * @param __INPUTFREQ__ PLL Input frequency (based on HSE div Prediv1 or div 2 / HSI div 2)
  523. * @param __PLLMUL__: This parameter can be one of the following values:
  524. * @arg @ref LL_RCC_PLL_MUL_2
  525. * @arg @ref LL_RCC_PLL_MUL_3
  526. * @arg @ref LL_RCC_PLL_MUL_4
  527. * @arg @ref LL_RCC_PLL_MUL_5
  528. * @arg @ref LL_RCC_PLL_MUL_6
  529. * @arg @ref LL_RCC_PLL_MUL_7
  530. * @arg @ref LL_RCC_PLL_MUL_8
  531. * @arg @ref LL_RCC_PLL_MUL_9
  532. * @arg @ref LL_RCC_PLL_MUL_10
  533. * @arg @ref LL_RCC_PLL_MUL_11
  534. * @arg @ref LL_RCC_PLL_MUL_12
  535. * @arg @ref LL_RCC_PLL_MUL_13
  536. * @arg @ref LL_RCC_PLL_MUL_14
  537. * @arg @ref LL_RCC_PLL_MUL_15
  538. * @arg @ref LL_RCC_PLL_MUL_16
  539. * @retval PLL clock frequency (in Hz)
  540. */
  541. #define __LL_RCC_CALC_PLLCLK_FREQ(__INPUTFREQ__, __PLLMUL__) ((__INPUTFREQ__) * (((__PLLMUL__) >> RCC_CFGR_PLLMULL_Pos) + 2U))
  542. #endif /* RCC_CFGR_PLLMULL6_5 */
  543. #if defined(RCC_PLLI2S_SUPPORT)
  544. /**
  545. * @brief Helper macro to calculate the PLLI2S frequency
  546. * @note ex: @ref __LL_RCC_CALC_PLLI2SCLK_FREQ (HSE_VALUE, @ref LL_RCC_PLLI2S_GetMultiplicator (), @ref LL_RCC_HSE_GetPrediv2 ());
  547. * @param __INPUTFREQ__ PLLI2S Input frequency (based on HSE value)
  548. * @param __PLLI2SMUL__: This parameter can be one of the following values:
  549. * @arg @ref LL_RCC_PLLI2S_MUL_8
  550. * @arg @ref LL_RCC_PLLI2S_MUL_9
  551. * @arg @ref LL_RCC_PLLI2S_MUL_10
  552. * @arg @ref LL_RCC_PLLI2S_MUL_11
  553. * @arg @ref LL_RCC_PLLI2S_MUL_12
  554. * @arg @ref LL_RCC_PLLI2S_MUL_13
  555. * @arg @ref LL_RCC_PLLI2S_MUL_14
  556. * @arg @ref LL_RCC_PLLI2S_MUL_16
  557. * @arg @ref LL_RCC_PLLI2S_MUL_20
  558. * @param __PLLI2SDIV__: This parameter can be one of the following values:
  559. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_1
  560. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_2
  561. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_3
  562. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_4
  563. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_5
  564. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_6
  565. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_7
  566. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_8
  567. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_9
  568. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_10
  569. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_11
  570. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_12
  571. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_13
  572. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_14
  573. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_15
  574. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_16
  575. * @retval PLLI2S clock frequency (in Hz)
  576. */
  577. #define __LL_RCC_CALC_PLLI2SCLK_FREQ(__INPUTFREQ__, __PLLI2SMUL__, __PLLI2SDIV__) (((__INPUTFREQ__) * (((__PLLI2SMUL__) >> RCC_CFGR2_PLL3MUL_Pos) + 2U)) / (((__PLLI2SDIV__) >> RCC_CFGR2_PREDIV2_Pos) + 1U))
  578. #endif /* RCC_PLLI2S_SUPPORT */
  579. #if defined(RCC_PLL2_SUPPORT)
  580. /**
  581. * @brief Helper macro to calculate the PLL2 frequency
  582. * @note ex: @ref __LL_RCC_CALC_PLL2CLK_FREQ (HSE_VALUE, @ref LL_RCC_PLL2_GetMultiplicator (), @ref LL_RCC_HSE_GetPrediv2 ());
  583. * @param __INPUTFREQ__ PLL2 Input frequency (based on HSE value)
  584. * @param __PLL2MUL__: This parameter can be one of the following values:
  585. * @arg @ref LL_RCC_PLL2_MUL_8
  586. * @arg @ref LL_RCC_PLL2_MUL_9
  587. * @arg @ref LL_RCC_PLL2_MUL_10
  588. * @arg @ref LL_RCC_PLL2_MUL_11
  589. * @arg @ref LL_RCC_PLL2_MUL_12
  590. * @arg @ref LL_RCC_PLL2_MUL_13
  591. * @arg @ref LL_RCC_PLL2_MUL_14
  592. * @arg @ref LL_RCC_PLL2_MUL_16
  593. * @arg @ref LL_RCC_PLL2_MUL_20
  594. * @param __PLL2DIV__: This parameter can be one of the following values:
  595. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_1
  596. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_2
  597. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_3
  598. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_4
  599. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_5
  600. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_6
  601. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_7
  602. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_8
  603. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_9
  604. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_10
  605. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_11
  606. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_12
  607. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_13
  608. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_14
  609. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_15
  610. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_16
  611. * @retval PLL2 clock frequency (in Hz)
  612. */
  613. #define __LL_RCC_CALC_PLL2CLK_FREQ(__INPUTFREQ__, __PLL2MUL__, __PLL2DIV__) (((__INPUTFREQ__) * (((__PLL2MUL__) >> RCC_CFGR2_PLL2MUL_Pos) + 2U)) / (((__PLL2DIV__) >> RCC_CFGR2_PREDIV2_Pos) + 1U))
  614. #endif /* RCC_PLL2_SUPPORT */
  615. /**
  616. * @brief Helper macro to calculate the HCLK frequency
  617. * @note: __AHBPRESCALER__ be retrieved by @ref LL_RCC_GetAHBPrescaler
  618. * ex: __LL_RCC_CALC_HCLK_FREQ(LL_RCC_GetAHBPrescaler())
  619. * @param __SYSCLKFREQ__ SYSCLK frequency (based on HSE/HSI/PLLCLK)
  620. * @param __AHBPRESCALER__: This parameter can be one of the following values:
  621. * @arg @ref LL_RCC_SYSCLK_DIV_1
  622. * @arg @ref LL_RCC_SYSCLK_DIV_2
  623. * @arg @ref LL_RCC_SYSCLK_DIV_4
  624. * @arg @ref LL_RCC_SYSCLK_DIV_8
  625. * @arg @ref LL_RCC_SYSCLK_DIV_16
  626. * @arg @ref LL_RCC_SYSCLK_DIV_64
  627. * @arg @ref LL_RCC_SYSCLK_DIV_128
  628. * @arg @ref LL_RCC_SYSCLK_DIV_256
  629. * @arg @ref LL_RCC_SYSCLK_DIV_512
  630. * @retval HCLK clock frequency (in Hz)
  631. */
  632. #define __LL_RCC_CALC_HCLK_FREQ(__SYSCLKFREQ__, __AHBPRESCALER__) ((__SYSCLKFREQ__) >> AHBPrescTable[((__AHBPRESCALER__) & RCC_CFGR_HPRE) >> RCC_CFGR_HPRE_Pos])
  633. /**
  634. * @brief Helper macro to calculate the PCLK1 frequency (ABP1)
  635. * @note: __APB1PRESCALER__ be retrieved by @ref LL_RCC_GetAPB1Prescaler
  636. * ex: __LL_RCC_CALC_PCLK1_FREQ(LL_RCC_GetAPB1Prescaler())
  637. * @param __HCLKFREQ__ HCLK frequency
  638. * @param __APB1PRESCALER__: This parameter can be one of the following values:
  639. * @arg @ref LL_RCC_APB1_DIV_1
  640. * @arg @ref LL_RCC_APB1_DIV_2
  641. * @arg @ref LL_RCC_APB1_DIV_4
  642. * @arg @ref LL_RCC_APB1_DIV_8
  643. * @arg @ref LL_RCC_APB1_DIV_16
  644. * @retval PCLK1 clock frequency (in Hz)
  645. */
  646. #define __LL_RCC_CALC_PCLK1_FREQ(__HCLKFREQ__, __APB1PRESCALER__) ((__HCLKFREQ__) >> APBPrescTable[(__APB1PRESCALER__) >> RCC_CFGR_PPRE1_Pos])
  647. /**
  648. * @brief Helper macro to calculate the PCLK2 frequency (ABP2)
  649. * @note: __APB2PRESCALER__ be retrieved by @ref LL_RCC_GetAPB2Prescaler
  650. * ex: __LL_RCC_CALC_PCLK2_FREQ(LL_RCC_GetAPB2Prescaler())
  651. * @param __HCLKFREQ__ HCLK frequency
  652. * @param __APB2PRESCALER__: This parameter can be one of the following values:
  653. * @arg @ref LL_RCC_APB2_DIV_1
  654. * @arg @ref LL_RCC_APB2_DIV_2
  655. * @arg @ref LL_RCC_APB2_DIV_4
  656. * @arg @ref LL_RCC_APB2_DIV_8
  657. * @arg @ref LL_RCC_APB2_DIV_16
  658. * @retval PCLK2 clock frequency (in Hz)
  659. */
  660. #define __LL_RCC_CALC_PCLK2_FREQ(__HCLKFREQ__, __APB2PRESCALER__) ((__HCLKFREQ__) >> APBPrescTable[(__APB2PRESCALER__) >> RCC_CFGR_PPRE2_Pos])
  661. /**
  662. * @}
  663. */
  664. /**
  665. * @}
  666. */
  667. /* Exported functions --------------------------------------------------------*/
  668. /** @defgroup RCC_LL_Exported_Functions RCC Exported Functions
  669. * @{
  670. */
  671. /** @defgroup RCC_LL_EF_HSE HSE
  672. * @{
  673. */
  674. /**
  675. * @brief Enable the Clock Security System.
  676. * @rmtoll CR CSSON LL_RCC_HSE_EnableCSS
  677. * @retval None
  678. */
  679. __STATIC_INLINE void LL_RCC_HSE_EnableCSS(void)
  680. {
  681. SET_BIT(RCC->CR, RCC_CR_CSSON);
  682. }
  683. /**
  684. * @brief Enable HSE external oscillator (HSE Bypass)
  685. * @rmtoll CR HSEBYP LL_RCC_HSE_EnableBypass
  686. * @retval None
  687. */
  688. __STATIC_INLINE void LL_RCC_HSE_EnableBypass(void)
  689. {
  690. SET_BIT(RCC->CR, RCC_CR_HSEBYP);
  691. }
  692. /**
  693. * @brief Disable HSE external oscillator (HSE Bypass)
  694. * @rmtoll CR HSEBYP LL_RCC_HSE_DisableBypass
  695. * @retval None
  696. */
  697. __STATIC_INLINE void LL_RCC_HSE_DisableBypass(void)
  698. {
  699. CLEAR_BIT(RCC->CR, RCC_CR_HSEBYP);
  700. }
  701. /**
  702. * @brief Enable HSE crystal oscillator (HSE ON)
  703. * @rmtoll CR HSEON LL_RCC_HSE_Enable
  704. * @retval None
  705. */
  706. __STATIC_INLINE void LL_RCC_HSE_Enable(void)
  707. {
  708. SET_BIT(RCC->CR, RCC_CR_HSEON);
  709. }
  710. /**
  711. * @brief Disable HSE crystal oscillator (HSE ON)
  712. * @rmtoll CR HSEON LL_RCC_HSE_Disable
  713. * @retval None
  714. */
  715. __STATIC_INLINE void LL_RCC_HSE_Disable(void)
  716. {
  717. CLEAR_BIT(RCC->CR, RCC_CR_HSEON);
  718. }
  719. /**
  720. * @brief Check if HSE oscillator Ready
  721. * @rmtoll CR HSERDY LL_RCC_HSE_IsReady
  722. * @retval State of bit (1 or 0).
  723. */
  724. __STATIC_INLINE uint32_t LL_RCC_HSE_IsReady(void)
  725. {
  726. return (READ_BIT(RCC->CR, RCC_CR_HSERDY) == (RCC_CR_HSERDY));
  727. }
  728. #if defined(RCC_CFGR2_PREDIV2)
  729. /**
  730. * @brief Get PREDIV2 division factor
  731. * @rmtoll CFGR2 PREDIV2 LL_RCC_HSE_GetPrediv2
  732. * @retval Returned value can be one of the following values:
  733. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_1
  734. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_2
  735. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_3
  736. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_4
  737. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_5
  738. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_6
  739. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_7
  740. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_8
  741. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_9
  742. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_10
  743. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_11
  744. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_12
  745. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_13
  746. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_14
  747. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_15
  748. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_16
  749. */
  750. __STATIC_INLINE uint32_t LL_RCC_HSE_GetPrediv2(void)
  751. {
  752. return (uint32_t)(READ_BIT(RCC->CFGR2, RCC_CFGR2_PREDIV2));
  753. }
  754. #endif /* RCC_CFGR2_PREDIV2 */
  755. /**
  756. * @}
  757. */
  758. /** @defgroup RCC_LL_EF_HSI HSI
  759. * @{
  760. */
  761. /**
  762. * @brief Enable HSI oscillator
  763. * @rmtoll CR HSION LL_RCC_HSI_Enable
  764. * @retval None
  765. */
  766. __STATIC_INLINE void LL_RCC_HSI_Enable(void)
  767. {
  768. SET_BIT(RCC->CR, RCC_CR_HSION);
  769. }
  770. /**
  771. * @brief Disable HSI oscillator
  772. * @rmtoll CR HSION LL_RCC_HSI_Disable
  773. * @retval None
  774. */
  775. __STATIC_INLINE void LL_RCC_HSI_Disable(void)
  776. {
  777. CLEAR_BIT(RCC->CR, RCC_CR_HSION);
  778. }
  779. /**
  780. * @brief Check if HSI clock is ready
  781. * @rmtoll CR HSIRDY LL_RCC_HSI_IsReady
  782. * @retval State of bit (1 or 0).
  783. */
  784. __STATIC_INLINE uint32_t LL_RCC_HSI_IsReady(void)
  785. {
  786. return (READ_BIT(RCC->CR, RCC_CR_HSIRDY) == (RCC_CR_HSIRDY));
  787. }
  788. /**
  789. * @brief Get HSI Calibration value
  790. * @note When HSITRIM is written, HSICAL is updated with the sum of
  791. * HSITRIM and the factory trim value
  792. * @rmtoll CR HSICAL LL_RCC_HSI_GetCalibration
  793. * @retval Between Min_Data = 0x00 and Max_Data = 0xFF
  794. */
  795. __STATIC_INLINE uint32_t LL_RCC_HSI_GetCalibration(void)
  796. {
  797. return (uint32_t)(READ_BIT(RCC->CR, RCC_CR_HSICAL) >> RCC_CR_HSICAL_Pos);
  798. }
  799. /**
  800. * @brief Set HSI Calibration trimming
  801. * @note user-programmable trimming value that is added to the HSICAL
  802. * @note Default value is 16, which, when added to the HSICAL value,
  803. * should trim the HSI to 16 MHz +/- 1 %
  804. * @rmtoll CR HSITRIM LL_RCC_HSI_SetCalibTrimming
  805. * @param Value between Min_Data = 0x00 and Max_Data = 0x1F
  806. * @retval None
  807. */
  808. __STATIC_INLINE void LL_RCC_HSI_SetCalibTrimming(uint32_t Value)
  809. {
  810. MODIFY_REG(RCC->CR, RCC_CR_HSITRIM, Value << RCC_CR_HSITRIM_Pos);
  811. }
  812. /**
  813. * @brief Get HSI Calibration trimming
  814. * @rmtoll CR HSITRIM LL_RCC_HSI_GetCalibTrimming
  815. * @retval Between Min_Data = 0x00 and Max_Data = 0x1F
  816. */
  817. __STATIC_INLINE uint32_t LL_RCC_HSI_GetCalibTrimming(void)
  818. {
  819. return (uint32_t)(READ_BIT(RCC->CR, RCC_CR_HSITRIM) >> RCC_CR_HSITRIM_Pos);
  820. }
  821. /**
  822. * @}
  823. */
  824. /** @defgroup RCC_LL_EF_LSE LSE
  825. * @{
  826. */
  827. /**
  828. * @brief Enable Low Speed External (LSE) crystal.
  829. * @rmtoll BDCR LSEON LL_RCC_LSE_Enable
  830. * @retval None
  831. */
  832. __STATIC_INLINE void LL_RCC_LSE_Enable(void)
  833. {
  834. SET_BIT(RCC->BDCR, RCC_BDCR_LSEON);
  835. }
  836. /**
  837. * @brief Disable Low Speed External (LSE) crystal.
  838. * @rmtoll BDCR LSEON LL_RCC_LSE_Disable
  839. * @retval None
  840. */
  841. __STATIC_INLINE void LL_RCC_LSE_Disable(void)
  842. {
  843. CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSEON);
  844. }
  845. /**
  846. * @brief Enable external clock source (LSE bypass).
  847. * @rmtoll BDCR LSEBYP LL_RCC_LSE_EnableBypass
  848. * @retval None
  849. */
  850. __STATIC_INLINE void LL_RCC_LSE_EnableBypass(void)
  851. {
  852. SET_BIT(RCC->BDCR, RCC_BDCR_LSEBYP);
  853. }
  854. /**
  855. * @brief Disable external clock source (LSE bypass).
  856. * @rmtoll BDCR LSEBYP LL_RCC_LSE_DisableBypass
  857. * @retval None
  858. */
  859. __STATIC_INLINE void LL_RCC_LSE_DisableBypass(void)
  860. {
  861. CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSEBYP);
  862. }
  863. /**
  864. * @brief Check if LSE oscillator Ready
  865. * @rmtoll BDCR LSERDY LL_RCC_LSE_IsReady
  866. * @retval State of bit (1 or 0).
  867. */
  868. __STATIC_INLINE uint32_t LL_RCC_LSE_IsReady(void)
  869. {
  870. return (READ_BIT(RCC->BDCR, RCC_BDCR_LSERDY) == (RCC_BDCR_LSERDY));
  871. }
  872. /**
  873. * @}
  874. */
  875. /** @defgroup RCC_LL_EF_LSI LSI
  876. * @{
  877. */
  878. /**
  879. * @brief Enable LSI Oscillator
  880. * @rmtoll CSR LSION LL_RCC_LSI_Enable
  881. * @retval None
  882. */
  883. __STATIC_INLINE void LL_RCC_LSI_Enable(void)
  884. {
  885. SET_BIT(RCC->CSR, RCC_CSR_LSION);
  886. }
  887. /**
  888. * @brief Disable LSI Oscillator
  889. * @rmtoll CSR LSION LL_RCC_LSI_Disable
  890. * @retval None
  891. */
  892. __STATIC_INLINE void LL_RCC_LSI_Disable(void)
  893. {
  894. CLEAR_BIT(RCC->CSR, RCC_CSR_LSION);
  895. }
  896. /**
  897. * @brief Check if LSI is Ready
  898. * @rmtoll CSR LSIRDY LL_RCC_LSI_IsReady
  899. * @retval State of bit (1 or 0).
  900. */
  901. __STATIC_INLINE uint32_t LL_RCC_LSI_IsReady(void)
  902. {
  903. return (READ_BIT(RCC->CSR, RCC_CSR_LSIRDY) == (RCC_CSR_LSIRDY));
  904. }
  905. /**
  906. * @}
  907. */
  908. /** @defgroup RCC_LL_EF_System System
  909. * @{
  910. */
  911. /**
  912. * @brief Configure the system clock source
  913. * @rmtoll CFGR SW LL_RCC_SetSysClkSource
  914. * @param Source This parameter can be one of the following values:
  915. * @arg @ref LL_RCC_SYS_CLKSOURCE_HSI
  916. * @arg @ref LL_RCC_SYS_CLKSOURCE_HSE
  917. * @arg @ref LL_RCC_SYS_CLKSOURCE_PLL
  918. * @retval None
  919. */
  920. __STATIC_INLINE void LL_RCC_SetSysClkSource(uint32_t Source)
  921. {
  922. MODIFY_REG(RCC->CFGR, RCC_CFGR_SW, Source);
  923. }
  924. /**
  925. * @brief Get the system clock source
  926. * @rmtoll CFGR SWS LL_RCC_GetSysClkSource
  927. * @retval Returned value can be one of the following values:
  928. * @arg @ref LL_RCC_SYS_CLKSOURCE_STATUS_HSI
  929. * @arg @ref LL_RCC_SYS_CLKSOURCE_STATUS_HSE
  930. * @arg @ref LL_RCC_SYS_CLKSOURCE_STATUS_PLL
  931. */
  932. __STATIC_INLINE uint32_t LL_RCC_GetSysClkSource(void)
  933. {
  934. return (uint32_t)(READ_BIT(RCC->CFGR, RCC_CFGR_SWS));
  935. }
  936. /**
  937. * @brief Set AHB prescaler
  938. * @rmtoll CFGR HPRE LL_RCC_SetAHBPrescaler
  939. * @param Prescaler This parameter can be one of the following values:
  940. * @arg @ref LL_RCC_SYSCLK_DIV_1
  941. * @arg @ref LL_RCC_SYSCLK_DIV_2
  942. * @arg @ref LL_RCC_SYSCLK_DIV_4
  943. * @arg @ref LL_RCC_SYSCLK_DIV_8
  944. * @arg @ref LL_RCC_SYSCLK_DIV_16
  945. * @arg @ref LL_RCC_SYSCLK_DIV_64
  946. * @arg @ref LL_RCC_SYSCLK_DIV_128
  947. * @arg @ref LL_RCC_SYSCLK_DIV_256
  948. * @arg @ref LL_RCC_SYSCLK_DIV_512
  949. * @retval None
  950. */
  951. __STATIC_INLINE void LL_RCC_SetAHBPrescaler(uint32_t Prescaler)
  952. {
  953. MODIFY_REG(RCC->CFGR, RCC_CFGR_HPRE, Prescaler);
  954. }
  955. /**
  956. * @brief Set APB1 prescaler
  957. * @rmtoll CFGR PPRE1 LL_RCC_SetAPB1Prescaler
  958. * @param Prescaler This parameter can be one of the following values:
  959. * @arg @ref LL_RCC_APB1_DIV_1
  960. * @arg @ref LL_RCC_APB1_DIV_2
  961. * @arg @ref LL_RCC_APB1_DIV_4
  962. * @arg @ref LL_RCC_APB1_DIV_8
  963. * @arg @ref LL_RCC_APB1_DIV_16
  964. * @retval None
  965. */
  966. __STATIC_INLINE void LL_RCC_SetAPB1Prescaler(uint32_t Prescaler)
  967. {
  968. MODIFY_REG(RCC->CFGR, RCC_CFGR_PPRE1, Prescaler);
  969. }
  970. /**
  971. * @brief Set APB2 prescaler
  972. * @rmtoll CFGR PPRE2 LL_RCC_SetAPB2Prescaler
  973. * @param Prescaler This parameter can be one of the following values:
  974. * @arg @ref LL_RCC_APB2_DIV_1
  975. * @arg @ref LL_RCC_APB2_DIV_2
  976. * @arg @ref LL_RCC_APB2_DIV_4
  977. * @arg @ref LL_RCC_APB2_DIV_8
  978. * @arg @ref LL_RCC_APB2_DIV_16
  979. * @retval None
  980. */
  981. __STATIC_INLINE void LL_RCC_SetAPB2Prescaler(uint32_t Prescaler)
  982. {
  983. MODIFY_REG(RCC->CFGR, RCC_CFGR_PPRE2, Prescaler);
  984. }
  985. /**
  986. * @brief Get AHB prescaler
  987. * @rmtoll CFGR HPRE LL_RCC_GetAHBPrescaler
  988. * @retval Returned value can be one of the following values:
  989. * @arg @ref LL_RCC_SYSCLK_DIV_1
  990. * @arg @ref LL_RCC_SYSCLK_DIV_2
  991. * @arg @ref LL_RCC_SYSCLK_DIV_4
  992. * @arg @ref LL_RCC_SYSCLK_DIV_8
  993. * @arg @ref LL_RCC_SYSCLK_DIV_16
  994. * @arg @ref LL_RCC_SYSCLK_DIV_64
  995. * @arg @ref LL_RCC_SYSCLK_DIV_128
  996. * @arg @ref LL_RCC_SYSCLK_DIV_256
  997. * @arg @ref LL_RCC_SYSCLK_DIV_512
  998. */
  999. __STATIC_INLINE uint32_t LL_RCC_GetAHBPrescaler(void)
  1000. {
  1001. return (uint32_t)(READ_BIT(RCC->CFGR, RCC_CFGR_HPRE));
  1002. }
  1003. /**
  1004. * @brief Get APB1 prescaler
  1005. * @rmtoll CFGR PPRE1 LL_RCC_GetAPB1Prescaler
  1006. * @retval Returned value can be one of the following values:
  1007. * @arg @ref LL_RCC_APB1_DIV_1
  1008. * @arg @ref LL_RCC_APB1_DIV_2
  1009. * @arg @ref LL_RCC_APB1_DIV_4
  1010. * @arg @ref LL_RCC_APB1_DIV_8
  1011. * @arg @ref LL_RCC_APB1_DIV_16
  1012. */
  1013. __STATIC_INLINE uint32_t LL_RCC_GetAPB1Prescaler(void)
  1014. {
  1015. return (uint32_t)(READ_BIT(RCC->CFGR, RCC_CFGR_PPRE1));
  1016. }
  1017. /**
  1018. * @brief Get APB2 prescaler
  1019. * @rmtoll CFGR PPRE2 LL_RCC_GetAPB2Prescaler
  1020. * @retval Returned value can be one of the following values:
  1021. * @arg @ref LL_RCC_APB2_DIV_1
  1022. * @arg @ref LL_RCC_APB2_DIV_2
  1023. * @arg @ref LL_RCC_APB2_DIV_4
  1024. * @arg @ref LL_RCC_APB2_DIV_8
  1025. * @arg @ref LL_RCC_APB2_DIV_16
  1026. */
  1027. __STATIC_INLINE uint32_t LL_RCC_GetAPB2Prescaler(void)
  1028. {
  1029. return (uint32_t)(READ_BIT(RCC->CFGR, RCC_CFGR_PPRE2));
  1030. }
  1031. /**
  1032. * @}
  1033. */
  1034. /** @defgroup RCC_LL_EF_MCO MCO
  1035. * @{
  1036. */
  1037. /**
  1038. * @brief Configure MCOx
  1039. * @rmtoll CFGR MCO LL_RCC_ConfigMCO
  1040. * @param MCOxSource This parameter can be one of the following values:
  1041. * @arg @ref LL_RCC_MCO1SOURCE_NOCLOCK
  1042. * @arg @ref LL_RCC_MCO1SOURCE_SYSCLK
  1043. * @arg @ref LL_RCC_MCO1SOURCE_HSI
  1044. * @arg @ref LL_RCC_MCO1SOURCE_HSE
  1045. * @arg @ref LL_RCC_MCO1SOURCE_PLLCLK_DIV_2
  1046. * @arg @ref LL_RCC_MCO1SOURCE_PLL2CLK (*)
  1047. * @arg @ref LL_RCC_MCO1SOURCE_PLLI2SCLK_DIV2 (*)
  1048. * @arg @ref LL_RCC_MCO1SOURCE_EXT_HSE (*)
  1049. * @arg @ref LL_RCC_MCO1SOURCE_PLLI2SCLK (*)
  1050. *
  1051. * (*) value not defined in all devices
  1052. * @retval None
  1053. */
  1054. __STATIC_INLINE void LL_RCC_ConfigMCO(uint32_t MCOxSource)
  1055. {
  1056. MODIFY_REG(RCC->CFGR, RCC_CFGR_MCOSEL, MCOxSource);
  1057. }
  1058. /**
  1059. * @}
  1060. */
  1061. /** @defgroup RCC_LL_EF_Peripheral_Clock_Source Peripheral Clock Source
  1062. * @{
  1063. */
  1064. #if defined(RCC_CFGR2_I2S2SRC)
  1065. /**
  1066. * @brief Configure I2Sx clock source
  1067. * @rmtoll CFGR2 I2S2SRC LL_RCC_SetI2SClockSource\n
  1068. * CFGR2 I2S3SRC LL_RCC_SetI2SClockSource
  1069. * @param I2SxSource This parameter can be one of the following values:
  1070. * @arg @ref LL_RCC_I2S2_CLKSOURCE_SYSCLK
  1071. * @arg @ref LL_RCC_I2S2_CLKSOURCE_PLLI2S_VCO
  1072. * @arg @ref LL_RCC_I2S3_CLKSOURCE_SYSCLK
  1073. * @arg @ref LL_RCC_I2S3_CLKSOURCE_PLLI2S_VCO
  1074. * @retval None
  1075. */
  1076. __STATIC_INLINE void LL_RCC_SetI2SClockSource(uint32_t I2SxSource)
  1077. {
  1078. MODIFY_REG(RCC->CFGR2, (I2SxSource & 0xFFFF0000U), (I2SxSource << 16U));
  1079. }
  1080. #endif /* RCC_CFGR2_I2S2SRC */
  1081. #if defined(USB_OTG_FS) || defined(USB)
  1082. /**
  1083. * @brief Configure USB clock source
  1084. * @rmtoll CFGR OTGFSPRE LL_RCC_SetUSBClockSource\n
  1085. * CFGR USBPRE LL_RCC_SetUSBClockSource
  1086. * @param USBxSource This parameter can be one of the following values:
  1087. * @arg @ref LL_RCC_USB_CLKSOURCE_PLL (*)
  1088. * @arg @ref LL_RCC_USB_CLKSOURCE_PLL_DIV_1_5 (*)
  1089. * @arg @ref LL_RCC_USB_CLKSOURCE_PLL_DIV_2 (*)
  1090. * @arg @ref LL_RCC_USB_CLKSOURCE_PLL_DIV_3 (*)
  1091. *
  1092. * (*) value not defined in all devices
  1093. * @retval None
  1094. */
  1095. __STATIC_INLINE void LL_RCC_SetUSBClockSource(uint32_t USBxSource)
  1096. {
  1097. #if defined(RCC_CFGR_USBPRE)
  1098. MODIFY_REG(RCC->CFGR, RCC_CFGR_USBPRE, USBxSource);
  1099. #else /*RCC_CFGR_OTGFSPRE*/
  1100. MODIFY_REG(RCC->CFGR, RCC_CFGR_OTGFSPRE, USBxSource);
  1101. #endif /*RCC_CFGR_USBPRE*/
  1102. }
  1103. #endif /* USB_OTG_FS || USB */
  1104. /**
  1105. * @brief Configure ADC clock source
  1106. * @rmtoll CFGR ADCPRE LL_RCC_SetADCClockSource
  1107. * @param ADCxSource This parameter can be one of the following values:
  1108. * @arg @ref LL_RCC_ADC_CLKSRC_PCLK2_DIV_2
  1109. * @arg @ref LL_RCC_ADC_CLKSRC_PCLK2_DIV_4
  1110. * @arg @ref LL_RCC_ADC_CLKSRC_PCLK2_DIV_6
  1111. * @arg @ref LL_RCC_ADC_CLKSRC_PCLK2_DIV_8
  1112. * @retval None
  1113. */
  1114. __STATIC_INLINE void LL_RCC_SetADCClockSource(uint32_t ADCxSource)
  1115. {
  1116. MODIFY_REG(RCC->CFGR, RCC_CFGR_ADCPRE, ADCxSource);
  1117. }
  1118. #if defined(RCC_CFGR2_I2S2SRC)
  1119. /**
  1120. * @brief Get I2Sx clock source
  1121. * @rmtoll CFGR2 I2S2SRC LL_RCC_GetI2SClockSource\n
  1122. * CFGR2 I2S3SRC LL_RCC_GetI2SClockSource
  1123. * @param I2Sx This parameter can be one of the following values:
  1124. * @arg @ref LL_RCC_I2S2_CLKSOURCE
  1125. * @arg @ref LL_RCC_I2S3_CLKSOURCE
  1126. * @retval Returned value can be one of the following values:
  1127. * @arg @ref LL_RCC_I2S2_CLKSOURCE_SYSCLK
  1128. * @arg @ref LL_RCC_I2S2_CLKSOURCE_PLLI2S_VCO
  1129. * @arg @ref LL_RCC_I2S3_CLKSOURCE_SYSCLK
  1130. * @arg @ref LL_RCC_I2S3_CLKSOURCE_PLLI2S_VCO
  1131. */
  1132. __STATIC_INLINE uint32_t LL_RCC_GetI2SClockSource(uint32_t I2Sx)
  1133. {
  1134. return (uint32_t)(READ_BIT(RCC->CFGR2, I2Sx) >> 16U | I2Sx);
  1135. }
  1136. #endif /* RCC_CFGR2_I2S2SRC */
  1137. #if defined(USB_OTG_FS) || defined(USB)
  1138. /**
  1139. * @brief Get USBx clock source
  1140. * @rmtoll CFGR OTGFSPRE LL_RCC_GetUSBClockSource\n
  1141. * CFGR USBPRE LL_RCC_GetUSBClockSource
  1142. * @param USBx This parameter can be one of the following values:
  1143. * @arg @ref LL_RCC_USB_CLKSOURCE
  1144. * @retval Returned value can be one of the following values:
  1145. * @arg @ref LL_RCC_USB_CLKSOURCE_PLL (*)
  1146. * @arg @ref LL_RCC_USB_CLKSOURCE_PLL_DIV_1_5 (*)
  1147. * @arg @ref LL_RCC_USB_CLKSOURCE_PLL_DIV_2 (*)
  1148. * @arg @ref LL_RCC_USB_CLKSOURCE_PLL_DIV_3 (*)
  1149. *
  1150. * (*) value not defined in all devices
  1151. */
  1152. __STATIC_INLINE uint32_t LL_RCC_GetUSBClockSource(uint32_t USBx)
  1153. {
  1154. return (uint32_t)(READ_BIT(RCC->CFGR, USBx));
  1155. }
  1156. #endif /* USB_OTG_FS || USB */
  1157. /**
  1158. * @brief Get ADCx clock source
  1159. * @rmtoll CFGR ADCPRE LL_RCC_GetADCClockSource
  1160. * @param ADCx This parameter can be one of the following values:
  1161. * @arg @ref LL_RCC_ADC_CLKSOURCE
  1162. * @retval Returned value can be one of the following values:
  1163. * @arg @ref LL_RCC_ADC_CLKSRC_PCLK2_DIV_2
  1164. * @arg @ref LL_RCC_ADC_CLKSRC_PCLK2_DIV_4
  1165. * @arg @ref LL_RCC_ADC_CLKSRC_PCLK2_DIV_6
  1166. * @arg @ref LL_RCC_ADC_CLKSRC_PCLK2_DIV_8
  1167. */
  1168. __STATIC_INLINE uint32_t LL_RCC_GetADCClockSource(uint32_t ADCx)
  1169. {
  1170. return (uint32_t)(READ_BIT(RCC->CFGR, ADCx));
  1171. }
  1172. /**
  1173. * @}
  1174. */
  1175. /** @defgroup RCC_LL_EF_RTC RTC
  1176. * @{
  1177. */
  1178. /**
  1179. * @brief Set RTC Clock Source
  1180. * @note Once the RTC clock source has been selected, it cannot be changed any more unless
  1181. * the Backup domain is reset. The BDRST bit can be used to reset them.
  1182. * @rmtoll BDCR RTCSEL LL_RCC_SetRTCClockSource
  1183. * @param Source This parameter can be one of the following values:
  1184. * @arg @ref LL_RCC_RTC_CLKSOURCE_NONE
  1185. * @arg @ref LL_RCC_RTC_CLKSOURCE_LSE
  1186. * @arg @ref LL_RCC_RTC_CLKSOURCE_LSI
  1187. * @arg @ref LL_RCC_RTC_CLKSOURCE_HSE_DIV128
  1188. * @retval None
  1189. */
  1190. __STATIC_INLINE void LL_RCC_SetRTCClockSource(uint32_t Source)
  1191. {
  1192. MODIFY_REG(RCC->BDCR, RCC_BDCR_RTCSEL, Source);
  1193. }
  1194. /**
  1195. * @brief Get RTC Clock Source
  1196. * @rmtoll BDCR RTCSEL LL_RCC_GetRTCClockSource
  1197. * @retval Returned value can be one of the following values:
  1198. * @arg @ref LL_RCC_RTC_CLKSOURCE_NONE
  1199. * @arg @ref LL_RCC_RTC_CLKSOURCE_LSE
  1200. * @arg @ref LL_RCC_RTC_CLKSOURCE_LSI
  1201. * @arg @ref LL_RCC_RTC_CLKSOURCE_HSE_DIV128
  1202. */
  1203. __STATIC_INLINE uint32_t LL_RCC_GetRTCClockSource(void)
  1204. {
  1205. return (uint32_t)(READ_BIT(RCC->BDCR, RCC_BDCR_RTCSEL));
  1206. }
  1207. /**
  1208. * @brief Enable RTC
  1209. * @rmtoll BDCR RTCEN LL_RCC_EnableRTC
  1210. * @retval None
  1211. */
  1212. __STATIC_INLINE void LL_RCC_EnableRTC(void)
  1213. {
  1214. SET_BIT(RCC->BDCR, RCC_BDCR_RTCEN);
  1215. }
  1216. /**
  1217. * @brief Disable RTC
  1218. * @rmtoll BDCR RTCEN LL_RCC_DisableRTC
  1219. * @retval None
  1220. */
  1221. __STATIC_INLINE void LL_RCC_DisableRTC(void)
  1222. {
  1223. CLEAR_BIT(RCC->BDCR, RCC_BDCR_RTCEN);
  1224. }
  1225. /**
  1226. * @brief Check if RTC has been enabled or not
  1227. * @rmtoll BDCR RTCEN LL_RCC_IsEnabledRTC
  1228. * @retval State of bit (1 or 0).
  1229. */
  1230. __STATIC_INLINE uint32_t LL_RCC_IsEnabledRTC(void)
  1231. {
  1232. return (READ_BIT(RCC->BDCR, RCC_BDCR_RTCEN) == (RCC_BDCR_RTCEN));
  1233. }
  1234. /**
  1235. * @brief Force the Backup domain reset
  1236. * @rmtoll BDCR BDRST LL_RCC_ForceBackupDomainReset
  1237. * @retval None
  1238. */
  1239. __STATIC_INLINE void LL_RCC_ForceBackupDomainReset(void)
  1240. {
  1241. SET_BIT(RCC->BDCR, RCC_BDCR_BDRST);
  1242. }
  1243. /**
  1244. * @brief Release the Backup domain reset
  1245. * @rmtoll BDCR BDRST LL_RCC_ReleaseBackupDomainReset
  1246. * @retval None
  1247. */
  1248. __STATIC_INLINE void LL_RCC_ReleaseBackupDomainReset(void)
  1249. {
  1250. CLEAR_BIT(RCC->BDCR, RCC_BDCR_BDRST);
  1251. }
  1252. /**
  1253. * @}
  1254. */
  1255. /** @defgroup RCC_LL_EF_PLL PLL
  1256. * @{
  1257. */
  1258. /**
  1259. * @brief Enable PLL
  1260. * @rmtoll CR PLLON LL_RCC_PLL_Enable
  1261. * @retval None
  1262. */
  1263. __STATIC_INLINE void LL_RCC_PLL_Enable(void)
  1264. {
  1265. SET_BIT(RCC->CR, RCC_CR_PLLON);
  1266. }
  1267. /**
  1268. * @brief Disable PLL
  1269. * @note Cannot be disabled if the PLL clock is used as the system clock
  1270. * @rmtoll CR PLLON LL_RCC_PLL_Disable
  1271. * @retval None
  1272. */
  1273. __STATIC_INLINE void LL_RCC_PLL_Disable(void)
  1274. {
  1275. CLEAR_BIT(RCC->CR, RCC_CR_PLLON);
  1276. }
  1277. /**
  1278. * @brief Check if PLL Ready
  1279. * @rmtoll CR PLLRDY LL_RCC_PLL_IsReady
  1280. * @retval State of bit (1 or 0).
  1281. */
  1282. __STATIC_INLINE uint32_t LL_RCC_PLL_IsReady(void)
  1283. {
  1284. return (READ_BIT(RCC->CR, RCC_CR_PLLRDY) == (RCC_CR_PLLRDY));
  1285. }
  1286. /**
  1287. * @brief Configure PLL used for SYSCLK Domain
  1288. * @rmtoll CFGR PLLSRC LL_RCC_PLL_ConfigDomain_SYS\n
  1289. * CFGR PLLXTPRE LL_RCC_PLL_ConfigDomain_SYS\n
  1290. * CFGR PLLMULL LL_RCC_PLL_ConfigDomain_SYS\n
  1291. * CFGR2 PREDIV1 LL_RCC_PLL_ConfigDomain_SYS\n
  1292. * CFGR2 PREDIV1SRC LL_RCC_PLL_ConfigDomain_SYS
  1293. * @param Source This parameter can be one of the following values:
  1294. * @arg @ref LL_RCC_PLLSOURCE_HSI_DIV_2
  1295. * @arg @ref LL_RCC_PLLSOURCE_HSE_DIV_1
  1296. * @arg @ref LL_RCC_PLLSOURCE_HSE_DIV_2 (*)
  1297. * @arg @ref LL_RCC_PLLSOURCE_HSE_DIV_3 (*)
  1298. * @arg @ref LL_RCC_PLLSOURCE_HSE_DIV_4 (*)
  1299. * @arg @ref LL_RCC_PLLSOURCE_HSE_DIV_5 (*)
  1300. * @arg @ref LL_RCC_PLLSOURCE_HSE_DIV_6 (*)
  1301. * @arg @ref LL_RCC_PLLSOURCE_HSE_DIV_7 (*)
  1302. * @arg @ref LL_RCC_PLLSOURCE_HSE_DIV_8 (*)
  1303. * @arg @ref LL_RCC_PLLSOURCE_HSE_DIV_9 (*)
  1304. * @arg @ref LL_RCC_PLLSOURCE_HSE_DIV_10 (*)
  1305. * @arg @ref LL_RCC_PLLSOURCE_HSE_DIV_11 (*)
  1306. * @arg @ref LL_RCC_PLLSOURCE_HSE_DIV_12 (*)
  1307. * @arg @ref LL_RCC_PLLSOURCE_HSE_DIV_13 (*)
  1308. * @arg @ref LL_RCC_PLLSOURCE_HSE_DIV_14 (*)
  1309. * @arg @ref LL_RCC_PLLSOURCE_HSE_DIV_15 (*)
  1310. * @arg @ref LL_RCC_PLLSOURCE_HSE_DIV_16 (*)
  1311. * @arg @ref LL_RCC_PLLSOURCE_PLL2_DIV_1 (*)
  1312. * @arg @ref LL_RCC_PLLSOURCE_PLL2_DIV_2 (*)
  1313. * @arg @ref LL_RCC_PLLSOURCE_PLL2_DIV_3 (*)
  1314. * @arg @ref LL_RCC_PLLSOURCE_PLL2_DIV_4 (*)
  1315. * @arg @ref LL_RCC_PLLSOURCE_PLL2_DIV_5 (*)
  1316. * @arg @ref LL_RCC_PLLSOURCE_PLL2_DIV_6 (*)
  1317. * @arg @ref LL_RCC_PLLSOURCE_PLL2_DIV_7 (*)
  1318. * @arg @ref LL_RCC_PLLSOURCE_PLL2_DIV_8 (*)
  1319. * @arg @ref LL_RCC_PLLSOURCE_PLL2_DIV_9 (*)
  1320. * @arg @ref LL_RCC_PLLSOURCE_PLL2_DIV_10 (*)
  1321. * @arg @ref LL_RCC_PLLSOURCE_PLL2_DIV_11 (*)
  1322. * @arg @ref LL_RCC_PLLSOURCE_PLL2_DIV_12 (*)
  1323. * @arg @ref LL_RCC_PLLSOURCE_PLL2_DIV_13 (*)
  1324. * @arg @ref LL_RCC_PLLSOURCE_PLL2_DIV_14 (*)
  1325. * @arg @ref LL_RCC_PLLSOURCE_PLL2_DIV_15 (*)
  1326. * @arg @ref LL_RCC_PLLSOURCE_PLL2_DIV_16 (*)
  1327. *
  1328. * (*) value not defined in all devices
  1329. * @param PLLMul This parameter can be one of the following values:
  1330. * @arg @ref LL_RCC_PLL_MUL_2 (*)
  1331. * @arg @ref LL_RCC_PLL_MUL_3 (*)
  1332. * @arg @ref LL_RCC_PLL_MUL_4
  1333. * @arg @ref LL_RCC_PLL_MUL_5
  1334. * @arg @ref LL_RCC_PLL_MUL_6
  1335. * @arg @ref LL_RCC_PLL_MUL_7
  1336. * @arg @ref LL_RCC_PLL_MUL_8
  1337. * @arg @ref LL_RCC_PLL_MUL_9
  1338. * @arg @ref LL_RCC_PLL_MUL_6_5 (*)
  1339. * @arg @ref LL_RCC_PLL_MUL_10 (*)
  1340. * @arg @ref LL_RCC_PLL_MUL_11 (*)
  1341. * @arg @ref LL_RCC_PLL_MUL_12 (*)
  1342. * @arg @ref LL_RCC_PLL_MUL_13 (*)
  1343. * @arg @ref LL_RCC_PLL_MUL_14 (*)
  1344. * @arg @ref LL_RCC_PLL_MUL_15 (*)
  1345. * @arg @ref LL_RCC_PLL_MUL_16 (*)
  1346. *
  1347. * (*) value not defined in all devices
  1348. * @retval None
  1349. */
  1350. __STATIC_INLINE void LL_RCC_PLL_ConfigDomain_SYS(uint32_t Source, uint32_t PLLMul)
  1351. {
  1352. MODIFY_REG(RCC->CFGR, RCC_CFGR_PLLSRC | RCC_CFGR_PLLXTPRE | RCC_CFGR_PLLMULL,
  1353. (Source & (RCC_CFGR_PLLSRC | RCC_CFGR_PLLXTPRE)) | PLLMul);
  1354. #if defined(RCC_CFGR2_PREDIV1)
  1355. #if defined(RCC_CFGR2_PREDIV1SRC)
  1356. MODIFY_REG(RCC->CFGR2, (RCC_CFGR2_PREDIV1 | RCC_CFGR2_PREDIV1SRC),
  1357. (Source & RCC_CFGR2_PREDIV1) | ((Source & (RCC_CFGR2_PREDIV1SRC << 4U)) >> 4U));
  1358. #else
  1359. MODIFY_REG(RCC->CFGR2, RCC_CFGR2_PREDIV1, (Source & RCC_CFGR2_PREDIV1));
  1360. #endif /*RCC_CFGR2_PREDIV1SRC*/
  1361. #endif /*RCC_CFGR2_PREDIV1*/
  1362. }
  1363. /**
  1364. * @brief Configure PLL clock source
  1365. * @rmtoll CFGR PLLSRC LL_RCC_PLL_SetMainSource\n
  1366. * CFGR2 PREDIV1SRC LL_RCC_PLL_SetMainSource
  1367. * @param PLLSource This parameter can be one of the following values:
  1368. * @arg @ref LL_RCC_PLLSOURCE_HSI_DIV_2
  1369. * @arg @ref LL_RCC_PLLSOURCE_HSE
  1370. * @arg @ref LL_RCC_PLLSOURCE_PLL2 (*)
  1371. * @retval None
  1372. */
  1373. __STATIC_INLINE void LL_RCC_PLL_SetMainSource(uint32_t PLLSource)
  1374. {
  1375. #if defined(RCC_CFGR2_PREDIV1SRC)
  1376. MODIFY_REG(RCC->CFGR2, RCC_CFGR2_PREDIV1SRC, ((PLLSource & (RCC_CFGR2_PREDIV1SRC << 4U)) >> 4U));
  1377. #endif /* RCC_CFGR2_PREDIV1SRC */
  1378. MODIFY_REG(RCC->CFGR, RCC_CFGR_PLLSRC, PLLSource);
  1379. }
  1380. /**
  1381. * @brief Get the oscillator used as PLL clock source.
  1382. * @rmtoll CFGR PLLSRC LL_RCC_PLL_GetMainSource\n
  1383. * CFGR2 PREDIV1SRC LL_RCC_PLL_GetMainSource
  1384. * @retval Returned value can be one of the following values:
  1385. * @arg @ref LL_RCC_PLLSOURCE_HSI_DIV_2
  1386. * @arg @ref LL_RCC_PLLSOURCE_HSE
  1387. * @arg @ref LL_RCC_PLLSOURCE_PLL2 (*)
  1388. *
  1389. * (*) value not defined in all devices
  1390. */
  1391. __STATIC_INLINE uint32_t LL_RCC_PLL_GetMainSource(void)
  1392. {
  1393. #if defined(RCC_CFGR2_PREDIV1SRC)
  1394. uint32_t pllsrc = READ_BIT(RCC->CFGR, RCC_CFGR_PLLSRC);
  1395. uint32_t predivsrc = (uint32_t)(READ_BIT(RCC->CFGR2, RCC_CFGR2_PREDIV1SRC) << 4U);
  1396. return (uint32_t)(pllsrc | predivsrc);
  1397. #else
  1398. return (uint32_t)(READ_BIT(RCC->CFGR, RCC_CFGR_PLLSRC));
  1399. #endif /*RCC_CFGR2_PREDIV1SRC*/
  1400. }
  1401. /**
  1402. * @brief Get PLL multiplication Factor
  1403. * @rmtoll CFGR PLLMULL LL_RCC_PLL_GetMultiplicator
  1404. * @retval Returned value can be one of the following values:
  1405. * @arg @ref LL_RCC_PLL_MUL_2 (*)
  1406. * @arg @ref LL_RCC_PLL_MUL_3 (*)
  1407. * @arg @ref LL_RCC_PLL_MUL_4
  1408. * @arg @ref LL_RCC_PLL_MUL_5
  1409. * @arg @ref LL_RCC_PLL_MUL_6
  1410. * @arg @ref LL_RCC_PLL_MUL_7
  1411. * @arg @ref LL_RCC_PLL_MUL_8
  1412. * @arg @ref LL_RCC_PLL_MUL_9
  1413. * @arg @ref LL_RCC_PLL_MUL_6_5 (*)
  1414. * @arg @ref LL_RCC_PLL_MUL_10 (*)
  1415. * @arg @ref LL_RCC_PLL_MUL_11 (*)
  1416. * @arg @ref LL_RCC_PLL_MUL_12 (*)
  1417. * @arg @ref LL_RCC_PLL_MUL_13 (*)
  1418. * @arg @ref LL_RCC_PLL_MUL_14 (*)
  1419. * @arg @ref LL_RCC_PLL_MUL_15 (*)
  1420. * @arg @ref LL_RCC_PLL_MUL_16 (*)
  1421. *
  1422. * (*) value not defined in all devices
  1423. */
  1424. __STATIC_INLINE uint32_t LL_RCC_PLL_GetMultiplicator(void)
  1425. {
  1426. return (uint32_t)(READ_BIT(RCC->CFGR, RCC_CFGR_PLLMULL));
  1427. }
  1428. /**
  1429. * @brief Get PREDIV1 division factor for the main PLL
  1430. * @note They can be written only when the PLL is disabled
  1431. * @rmtoll CFGR2 PREDIV1 LL_RCC_PLL_GetPrediv\n
  1432. * CFGR2 PLLXTPRE LL_RCC_PLL_GetPrediv
  1433. * @retval Returned value can be one of the following values:
  1434. * @arg @ref LL_RCC_PREDIV_DIV_1
  1435. * @arg @ref LL_RCC_PREDIV_DIV_2
  1436. * @arg @ref LL_RCC_PREDIV_DIV_3 (*)
  1437. * @arg @ref LL_RCC_PREDIV_DIV_4 (*)
  1438. * @arg @ref LL_RCC_PREDIV_DIV_5 (*)
  1439. * @arg @ref LL_RCC_PREDIV_DIV_6 (*)
  1440. * @arg @ref LL_RCC_PREDIV_DIV_7 (*)
  1441. * @arg @ref LL_RCC_PREDIV_DIV_8 (*)
  1442. * @arg @ref LL_RCC_PREDIV_DIV_9 (*)
  1443. * @arg @ref LL_RCC_PREDIV_DIV_10 (*)
  1444. * @arg @ref LL_RCC_PREDIV_DIV_11 (*)
  1445. * @arg @ref LL_RCC_PREDIV_DIV_12 (*)
  1446. * @arg @ref LL_RCC_PREDIV_DIV_13 (*)
  1447. * @arg @ref LL_RCC_PREDIV_DIV_14 (*)
  1448. * @arg @ref LL_RCC_PREDIV_DIV_15 (*)
  1449. * @arg @ref LL_RCC_PREDIV_DIV_16 (*)
  1450. *
  1451. * (*) value not defined in all devices
  1452. */
  1453. __STATIC_INLINE uint32_t LL_RCC_PLL_GetPrediv(void)
  1454. {
  1455. #if defined(RCC_CFGR2_PREDIV1)
  1456. return (uint32_t)(READ_BIT(RCC->CFGR2, RCC_CFGR2_PREDIV1));
  1457. #else
  1458. return (uint32_t)(READ_BIT(RCC->CFGR, RCC_CFGR_PLLXTPRE) >> RCC_CFGR_PLLXTPRE_Pos);
  1459. #endif /*RCC_CFGR2_PREDIV1*/
  1460. }
  1461. /**
  1462. * @}
  1463. */
  1464. #if defined(RCC_PLLI2S_SUPPORT)
  1465. /** @defgroup RCC_LL_EF_PLLI2S PLLI2S
  1466. * @{
  1467. */
  1468. /**
  1469. * @brief Enable PLLI2S
  1470. * @rmtoll CR PLL3ON LL_RCC_PLLI2S_Enable
  1471. * @retval None
  1472. */
  1473. __STATIC_INLINE void LL_RCC_PLLI2S_Enable(void)
  1474. {
  1475. SET_BIT(RCC->CR, RCC_CR_PLL3ON);
  1476. }
  1477. /**
  1478. * @brief Disable PLLI2S
  1479. * @rmtoll CR PLL3ON LL_RCC_PLLI2S_Disable
  1480. * @retval None
  1481. */
  1482. __STATIC_INLINE void LL_RCC_PLLI2S_Disable(void)
  1483. {
  1484. CLEAR_BIT(RCC->CR, RCC_CR_PLL3ON);
  1485. }
  1486. /**
  1487. * @brief Check if PLLI2S Ready
  1488. * @rmtoll CR PLL3RDY LL_RCC_PLLI2S_IsReady
  1489. * @retval State of bit (1 or 0).
  1490. */
  1491. __STATIC_INLINE uint32_t LL_RCC_PLLI2S_IsReady(void)
  1492. {
  1493. return (READ_BIT(RCC->CR, RCC_CR_PLL3RDY) == (RCC_CR_PLL3RDY));
  1494. }
  1495. /**
  1496. * @brief Configure PLLI2S used for I2S Domain
  1497. * @rmtoll CFGR2 PREDIV2 LL_RCC_PLL_ConfigDomain_PLLI2S\n
  1498. * CFGR2 PLL3MUL LL_RCC_PLL_ConfigDomain_PLLI2S
  1499. * @param Divider This parameter can be one of the following values:
  1500. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_1
  1501. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_2
  1502. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_3
  1503. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_4
  1504. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_5
  1505. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_6
  1506. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_7
  1507. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_8
  1508. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_9
  1509. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_10
  1510. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_11
  1511. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_12
  1512. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_13
  1513. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_14
  1514. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_15
  1515. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_16
  1516. * @param Multiplicator This parameter can be one of the following values:
  1517. * @arg @ref LL_RCC_PLLI2S_MUL_8
  1518. * @arg @ref LL_RCC_PLLI2S_MUL_9
  1519. * @arg @ref LL_RCC_PLLI2S_MUL_10
  1520. * @arg @ref LL_RCC_PLLI2S_MUL_11
  1521. * @arg @ref LL_RCC_PLLI2S_MUL_12
  1522. * @arg @ref LL_RCC_PLLI2S_MUL_13
  1523. * @arg @ref LL_RCC_PLLI2S_MUL_14
  1524. * @arg @ref LL_RCC_PLLI2S_MUL_16
  1525. * @arg @ref LL_RCC_PLLI2S_MUL_20
  1526. * @retval None
  1527. */
  1528. __STATIC_INLINE void LL_RCC_PLL_ConfigDomain_PLLI2S(uint32_t Divider, uint32_t Multiplicator)
  1529. {
  1530. MODIFY_REG(RCC->CFGR2, RCC_CFGR2_PREDIV2 | RCC_CFGR2_PLL3MUL, Divider | Multiplicator);
  1531. }
  1532. /**
  1533. * @brief Get PLLI2S Multiplication Factor
  1534. * @rmtoll CFGR2 PLL3MUL LL_RCC_PLLI2S_GetMultiplicator
  1535. * @retval Returned value can be one of the following values:
  1536. * @arg @ref LL_RCC_PLLI2S_MUL_8
  1537. * @arg @ref LL_RCC_PLLI2S_MUL_9
  1538. * @arg @ref LL_RCC_PLLI2S_MUL_10
  1539. * @arg @ref LL_RCC_PLLI2S_MUL_11
  1540. * @arg @ref LL_RCC_PLLI2S_MUL_12
  1541. * @arg @ref LL_RCC_PLLI2S_MUL_13
  1542. * @arg @ref LL_RCC_PLLI2S_MUL_14
  1543. * @arg @ref LL_RCC_PLLI2S_MUL_16
  1544. * @arg @ref LL_RCC_PLLI2S_MUL_20
  1545. */
  1546. __STATIC_INLINE uint32_t LL_RCC_PLLI2S_GetMultiplicator(void)
  1547. {
  1548. return (uint32_t)(READ_BIT(RCC->CFGR2, RCC_CFGR2_PLL3MUL));
  1549. }
  1550. /**
  1551. * @}
  1552. */
  1553. #endif /* RCC_PLLI2S_SUPPORT */
  1554. #if defined(RCC_PLL2_SUPPORT)
  1555. /** @defgroup RCC_LL_EF_PLL2 PLL2
  1556. * @{
  1557. */
  1558. /**
  1559. * @brief Enable PLL2
  1560. * @rmtoll CR PLL2ON LL_RCC_PLL2_Enable
  1561. * @retval None
  1562. */
  1563. __STATIC_INLINE void LL_RCC_PLL2_Enable(void)
  1564. {
  1565. SET_BIT(RCC->CR, RCC_CR_PLL2ON);
  1566. }
  1567. /**
  1568. * @brief Disable PLL2
  1569. * @rmtoll CR PLL2ON LL_RCC_PLL2_Disable
  1570. * @retval None
  1571. */
  1572. __STATIC_INLINE void LL_RCC_PLL2_Disable(void)
  1573. {
  1574. CLEAR_BIT(RCC->CR, RCC_CR_PLL2ON);
  1575. }
  1576. /**
  1577. * @brief Check if PLL2 Ready
  1578. * @rmtoll CR PLL2RDY LL_RCC_PLL2_IsReady
  1579. * @retval State of bit (1 or 0).
  1580. */
  1581. __STATIC_INLINE uint32_t LL_RCC_PLL2_IsReady(void)
  1582. {
  1583. return (READ_BIT(RCC->CR, RCC_CR_PLL2RDY) == (RCC_CR_PLL2RDY));
  1584. }
  1585. /**
  1586. * @brief Configure PLL2 used for PLL2 Domain
  1587. * @rmtoll CFGR2 PREDIV2 LL_RCC_PLL_ConfigDomain_PLL2\n
  1588. * CFGR2 PLL2MUL LL_RCC_PLL_ConfigDomain_PLL2
  1589. * @param Divider This parameter can be one of the following values:
  1590. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_1
  1591. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_2
  1592. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_3
  1593. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_4
  1594. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_5
  1595. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_6
  1596. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_7
  1597. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_8
  1598. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_9
  1599. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_10
  1600. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_11
  1601. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_12
  1602. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_13
  1603. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_14
  1604. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_15
  1605. * @arg @ref LL_RCC_HSE_PREDIV2_DIV_16
  1606. * @param Multiplicator This parameter can be one of the following values:
  1607. * @arg @ref LL_RCC_PLL2_MUL_8
  1608. * @arg @ref LL_RCC_PLL2_MUL_9
  1609. * @arg @ref LL_RCC_PLL2_MUL_10
  1610. * @arg @ref LL_RCC_PLL2_MUL_11
  1611. * @arg @ref LL_RCC_PLL2_MUL_12
  1612. * @arg @ref LL_RCC_PLL2_MUL_13
  1613. * @arg @ref LL_RCC_PLL2_MUL_14
  1614. * @arg @ref LL_RCC_PLL2_MUL_16
  1615. * @arg @ref LL_RCC_PLL2_MUL_20
  1616. * @retval None
  1617. */
  1618. __STATIC_INLINE void LL_RCC_PLL_ConfigDomain_PLL2(uint32_t Divider, uint32_t Multiplicator)
  1619. {
  1620. MODIFY_REG(RCC->CFGR2, RCC_CFGR2_PREDIV2 | RCC_CFGR2_PLL2MUL, Divider | Multiplicator);
  1621. }
  1622. /**
  1623. * @brief Get PLL2 Multiplication Factor
  1624. * @rmtoll CFGR2 PLL2MUL LL_RCC_PLL2_GetMultiplicator
  1625. * @retval Returned value can be one of the following values:
  1626. * @arg @ref LL_RCC_PLL2_MUL_8
  1627. * @arg @ref LL_RCC_PLL2_MUL_9
  1628. * @arg @ref LL_RCC_PLL2_MUL_10
  1629. * @arg @ref LL_RCC_PLL2_MUL_11
  1630. * @arg @ref LL_RCC_PLL2_MUL_12
  1631. * @arg @ref LL_RCC_PLL2_MUL_13
  1632. * @arg @ref LL_RCC_PLL2_MUL_14
  1633. * @arg @ref LL_RCC_PLL2_MUL_16
  1634. * @arg @ref LL_RCC_PLL2_MUL_20
  1635. */
  1636. __STATIC_INLINE uint32_t LL_RCC_PLL2_GetMultiplicator(void)
  1637. {
  1638. return (uint32_t)(READ_BIT(RCC->CFGR2, RCC_CFGR2_PLL2MUL));
  1639. }
  1640. /**
  1641. * @}
  1642. */
  1643. #endif /* RCC_PLL2_SUPPORT */
  1644. /** @defgroup RCC_LL_EF_FLAG_Management FLAG Management
  1645. * @{
  1646. */
  1647. /**
  1648. * @brief Clear LSI ready interrupt flag
  1649. * @rmtoll CIR LSIRDYC LL_RCC_ClearFlag_LSIRDY
  1650. * @retval None
  1651. */
  1652. __STATIC_INLINE void LL_RCC_ClearFlag_LSIRDY(void)
  1653. {
  1654. SET_BIT(RCC->CIR, RCC_CIR_LSIRDYC);
  1655. }
  1656. /**
  1657. * @brief Clear LSE ready interrupt flag
  1658. * @rmtoll CIR LSERDYC LL_RCC_ClearFlag_LSERDY
  1659. * @retval None
  1660. */
  1661. __STATIC_INLINE void LL_RCC_ClearFlag_LSERDY(void)
  1662. {
  1663. SET_BIT(RCC->CIR, RCC_CIR_LSERDYC);
  1664. }
  1665. /**
  1666. * @brief Clear HSI ready interrupt flag
  1667. * @rmtoll CIR HSIRDYC LL_RCC_ClearFlag_HSIRDY
  1668. * @retval None
  1669. */
  1670. __STATIC_INLINE void LL_RCC_ClearFlag_HSIRDY(void)
  1671. {
  1672. SET_BIT(RCC->CIR, RCC_CIR_HSIRDYC);
  1673. }
  1674. /**
  1675. * @brief Clear HSE ready interrupt flag
  1676. * @rmtoll CIR HSERDYC LL_RCC_ClearFlag_HSERDY
  1677. * @retval None
  1678. */
  1679. __STATIC_INLINE void LL_RCC_ClearFlag_HSERDY(void)
  1680. {
  1681. SET_BIT(RCC->CIR, RCC_CIR_HSERDYC);
  1682. }
  1683. /**
  1684. * @brief Clear PLL ready interrupt flag
  1685. * @rmtoll CIR PLLRDYC LL_RCC_ClearFlag_PLLRDY
  1686. * @retval None
  1687. */
  1688. __STATIC_INLINE void LL_RCC_ClearFlag_PLLRDY(void)
  1689. {
  1690. SET_BIT(RCC->CIR, RCC_CIR_PLLRDYC);
  1691. }
  1692. #if defined(RCC_PLLI2S_SUPPORT)
  1693. /**
  1694. * @brief Clear PLLI2S ready interrupt flag
  1695. * @rmtoll CIR PLL3RDYC LL_RCC_ClearFlag_PLLI2SRDY
  1696. * @retval None
  1697. */
  1698. __STATIC_INLINE void LL_RCC_ClearFlag_PLLI2SRDY(void)
  1699. {
  1700. SET_BIT(RCC->CIR, RCC_CIR_PLL3RDYC);
  1701. }
  1702. #endif /* RCC_PLLI2S_SUPPORT */
  1703. #if defined(RCC_PLL2_SUPPORT)
  1704. /**
  1705. * @brief Clear PLL2 ready interrupt flag
  1706. * @rmtoll CIR PLL2RDYC LL_RCC_ClearFlag_PLL2RDY
  1707. * @retval None
  1708. */
  1709. __STATIC_INLINE void LL_RCC_ClearFlag_PLL2RDY(void)
  1710. {
  1711. SET_BIT(RCC->CIR, RCC_CIR_PLL2RDYC);
  1712. }
  1713. #endif /* RCC_PLL2_SUPPORT */
  1714. /**
  1715. * @brief Clear Clock security system interrupt flag
  1716. * @rmtoll CIR CSSC LL_RCC_ClearFlag_HSECSS
  1717. * @retval None
  1718. */
  1719. __STATIC_INLINE void LL_RCC_ClearFlag_HSECSS(void)
  1720. {
  1721. SET_BIT(RCC->CIR, RCC_CIR_CSSC);
  1722. }
  1723. /**
  1724. * @brief Check if LSI ready interrupt occurred or not
  1725. * @rmtoll CIR LSIRDYF LL_RCC_IsActiveFlag_LSIRDY
  1726. * @retval State of bit (1 or 0).
  1727. */
  1728. __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_LSIRDY(void)
  1729. {
  1730. return (READ_BIT(RCC->CIR, RCC_CIR_LSIRDYF) == (RCC_CIR_LSIRDYF));
  1731. }
  1732. /**
  1733. * @brief Check if LSE ready interrupt occurred or not
  1734. * @rmtoll CIR LSERDYF LL_RCC_IsActiveFlag_LSERDY
  1735. * @retval State of bit (1 or 0).
  1736. */
  1737. __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_LSERDY(void)
  1738. {
  1739. return (READ_BIT(RCC->CIR, RCC_CIR_LSERDYF) == (RCC_CIR_LSERDYF));
  1740. }
  1741. /**
  1742. * @brief Check if HSI ready interrupt occurred or not
  1743. * @rmtoll CIR HSIRDYF LL_RCC_IsActiveFlag_HSIRDY
  1744. * @retval State of bit (1 or 0).
  1745. */
  1746. __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_HSIRDY(void)
  1747. {
  1748. return (READ_BIT(RCC->CIR, RCC_CIR_HSIRDYF) == (RCC_CIR_HSIRDYF));
  1749. }
  1750. /**
  1751. * @brief Check if HSE ready interrupt occurred or not
  1752. * @rmtoll CIR HSERDYF LL_RCC_IsActiveFlag_HSERDY
  1753. * @retval State of bit (1 or 0).
  1754. */
  1755. __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_HSERDY(void)
  1756. {
  1757. return (READ_BIT(RCC->CIR, RCC_CIR_HSERDYF) == (RCC_CIR_HSERDYF));
  1758. }
  1759. /**
  1760. * @brief Check if PLL ready interrupt occurred or not
  1761. * @rmtoll CIR PLLRDYF LL_RCC_IsActiveFlag_PLLRDY
  1762. * @retval State of bit (1 or 0).
  1763. */
  1764. __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_PLLRDY(void)
  1765. {
  1766. return (READ_BIT(RCC->CIR, RCC_CIR_PLLRDYF) == (RCC_CIR_PLLRDYF));
  1767. }
  1768. #if defined(RCC_PLLI2S_SUPPORT)
  1769. /**
  1770. * @brief Check if PLLI2S ready interrupt occurred or not
  1771. * @rmtoll CIR PLL3RDYF LL_RCC_IsActiveFlag_PLLI2SRDY
  1772. * @retval State of bit (1 or 0).
  1773. */
  1774. __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_PLLI2SRDY(void)
  1775. {
  1776. return (READ_BIT(RCC->CIR, RCC_CIR_PLL3RDYF) == (RCC_CIR_PLL3RDYF));
  1777. }
  1778. #endif /* RCC_PLLI2S_SUPPORT */
  1779. #if defined(RCC_PLL2_SUPPORT)
  1780. /**
  1781. * @brief Check if PLL2 ready interrupt occurred or not
  1782. * @rmtoll CIR PLL2RDYF LL_RCC_IsActiveFlag_PLL2RDY
  1783. * @retval State of bit (1 or 0).
  1784. */
  1785. __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_PLL2RDY(void)
  1786. {
  1787. return (READ_BIT(RCC->CIR, RCC_CIR_PLL2RDYF) == (RCC_CIR_PLL2RDYF));
  1788. }
  1789. #endif /* RCC_PLL2_SUPPORT */
  1790. /**
  1791. * @brief Check if Clock security system interrupt occurred or not
  1792. * @rmtoll CIR CSSF LL_RCC_IsActiveFlag_HSECSS
  1793. * @retval State of bit (1 or 0).
  1794. */
  1795. __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_HSECSS(void)
  1796. {
  1797. return (READ_BIT(RCC->CIR, RCC_CIR_CSSF) == (RCC_CIR_CSSF));
  1798. }
  1799. /**
  1800. * @brief Check if RCC flag Independent Watchdog reset is set or not.
  1801. * @rmtoll CSR IWDGRSTF LL_RCC_IsActiveFlag_IWDGRST
  1802. * @retval State of bit (1 or 0).
  1803. */
  1804. __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_IWDGRST(void)
  1805. {
  1806. return (READ_BIT(RCC->CSR, RCC_CSR_IWDGRSTF) == (RCC_CSR_IWDGRSTF));
  1807. }
  1808. /**
  1809. * @brief Check if RCC flag Low Power reset is set or not.
  1810. * @rmtoll CSR LPWRRSTF LL_RCC_IsActiveFlag_LPWRRST
  1811. * @retval State of bit (1 or 0).
  1812. */
  1813. __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_LPWRRST(void)
  1814. {
  1815. return (READ_BIT(RCC->CSR, RCC_CSR_LPWRRSTF) == (RCC_CSR_LPWRRSTF));
  1816. }
  1817. /**
  1818. * @brief Check if RCC flag Pin reset is set or not.
  1819. * @rmtoll CSR PINRSTF LL_RCC_IsActiveFlag_PINRST
  1820. * @retval State of bit (1 or 0).
  1821. */
  1822. __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_PINRST(void)
  1823. {
  1824. return (READ_BIT(RCC->CSR, RCC_CSR_PINRSTF) == (RCC_CSR_PINRSTF));
  1825. }
  1826. /**
  1827. * @brief Check if RCC flag POR/PDR reset is set or not.
  1828. * @rmtoll CSR PORRSTF LL_RCC_IsActiveFlag_PORRST
  1829. * @retval State of bit (1 or 0).
  1830. */
  1831. __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_PORRST(void)
  1832. {
  1833. return (READ_BIT(RCC->CSR, RCC_CSR_PORRSTF) == (RCC_CSR_PORRSTF));
  1834. }
  1835. /**
  1836. * @brief Check if RCC flag Software reset is set or not.
  1837. * @rmtoll CSR SFTRSTF LL_RCC_IsActiveFlag_SFTRST
  1838. * @retval State of bit (1 or 0).
  1839. */
  1840. __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_SFTRST(void)
  1841. {
  1842. return (READ_BIT(RCC->CSR, RCC_CSR_SFTRSTF) == (RCC_CSR_SFTRSTF));
  1843. }
  1844. /**
  1845. * @brief Check if RCC flag Window Watchdog reset is set or not.
  1846. * @rmtoll CSR WWDGRSTF LL_RCC_IsActiveFlag_WWDGRST
  1847. * @retval State of bit (1 or 0).
  1848. */
  1849. __STATIC_INLINE uint32_t LL_RCC_IsActiveFlag_WWDGRST(void)
  1850. {
  1851. return (READ_BIT(RCC->CSR, RCC_CSR_WWDGRSTF) == (RCC_CSR_WWDGRSTF));
  1852. }
  1853. /**
  1854. * @brief Set RMVF bit to clear the reset flags.
  1855. * @rmtoll CSR RMVF LL_RCC_ClearResetFlags
  1856. * @retval None
  1857. */
  1858. __STATIC_INLINE void LL_RCC_ClearResetFlags(void)
  1859. {
  1860. SET_BIT(RCC->CSR, RCC_CSR_RMVF);
  1861. }
  1862. /**
  1863. * @}
  1864. */
  1865. /** @defgroup RCC_LL_EF_IT_Management IT Management
  1866. * @{
  1867. */
  1868. /**
  1869. * @brief Enable LSI ready interrupt
  1870. * @rmtoll CIR LSIRDYIE LL_RCC_EnableIT_LSIRDY
  1871. * @retval None
  1872. */
  1873. __STATIC_INLINE void LL_RCC_EnableIT_LSIRDY(void)
  1874. {
  1875. SET_BIT(RCC->CIR, RCC_CIR_LSIRDYIE);
  1876. }
  1877. /**
  1878. * @brief Enable LSE ready interrupt
  1879. * @rmtoll CIR LSERDYIE LL_RCC_EnableIT_LSERDY
  1880. * @retval None
  1881. */
  1882. __STATIC_INLINE void LL_RCC_EnableIT_LSERDY(void)
  1883. {
  1884. SET_BIT(RCC->CIR, RCC_CIR_LSERDYIE);
  1885. }
  1886. /**
  1887. * @brief Enable HSI ready interrupt
  1888. * @rmtoll CIR HSIRDYIE LL_RCC_EnableIT_HSIRDY
  1889. * @retval None
  1890. */
  1891. __STATIC_INLINE void LL_RCC_EnableIT_HSIRDY(void)
  1892. {
  1893. SET_BIT(RCC->CIR, RCC_CIR_HSIRDYIE);
  1894. }
  1895. /**
  1896. * @brief Enable HSE ready interrupt
  1897. * @rmtoll CIR HSERDYIE LL_RCC_EnableIT_HSERDY
  1898. * @retval None
  1899. */
  1900. __STATIC_INLINE void LL_RCC_EnableIT_HSERDY(void)
  1901. {
  1902. SET_BIT(RCC->CIR, RCC_CIR_HSERDYIE);
  1903. }
  1904. /**
  1905. * @brief Enable PLL ready interrupt
  1906. * @rmtoll CIR PLLRDYIE LL_RCC_EnableIT_PLLRDY
  1907. * @retval None
  1908. */
  1909. __STATIC_INLINE void LL_RCC_EnableIT_PLLRDY(void)
  1910. {
  1911. SET_BIT(RCC->CIR, RCC_CIR_PLLRDYIE);
  1912. }
  1913. #if defined(RCC_PLLI2S_SUPPORT)
  1914. /**
  1915. * @brief Enable PLLI2S ready interrupt
  1916. * @rmtoll CIR PLL3RDYIE LL_RCC_EnableIT_PLLI2SRDY
  1917. * @retval None
  1918. */
  1919. __STATIC_INLINE void LL_RCC_EnableIT_PLLI2SRDY(void)
  1920. {
  1921. SET_BIT(RCC->CIR, RCC_CIR_PLL3RDYIE);
  1922. }
  1923. #endif /* RCC_PLLI2S_SUPPORT */
  1924. #if defined(RCC_PLL2_SUPPORT)
  1925. /**
  1926. * @brief Enable PLL2 ready interrupt
  1927. * @rmtoll CIR PLL2RDYIE LL_RCC_EnableIT_PLL2RDY
  1928. * @retval None
  1929. */
  1930. __STATIC_INLINE void LL_RCC_EnableIT_PLL2RDY(void)
  1931. {
  1932. SET_BIT(RCC->CIR, RCC_CIR_PLL2RDYIE);
  1933. }
  1934. #endif /* RCC_PLL2_SUPPORT */
  1935. /**
  1936. * @brief Disable LSI ready interrupt
  1937. * @rmtoll CIR LSIRDYIE LL_RCC_DisableIT_LSIRDY
  1938. * @retval None
  1939. */
  1940. __STATIC_INLINE void LL_RCC_DisableIT_LSIRDY(void)
  1941. {
  1942. CLEAR_BIT(RCC->CIR, RCC_CIR_LSIRDYIE);
  1943. }
  1944. /**
  1945. * @brief Disable LSE ready interrupt
  1946. * @rmtoll CIR LSERDYIE LL_RCC_DisableIT_LSERDY
  1947. * @retval None
  1948. */
  1949. __STATIC_INLINE void LL_RCC_DisableIT_LSERDY(void)
  1950. {
  1951. CLEAR_BIT(RCC->CIR, RCC_CIR_LSERDYIE);
  1952. }
  1953. /**
  1954. * @brief Disable HSI ready interrupt
  1955. * @rmtoll CIR HSIRDYIE LL_RCC_DisableIT_HSIRDY
  1956. * @retval None
  1957. */
  1958. __STATIC_INLINE void LL_RCC_DisableIT_HSIRDY(void)
  1959. {
  1960. CLEAR_BIT(RCC->CIR, RCC_CIR_HSIRDYIE);
  1961. }
  1962. /**
  1963. * @brief Disable HSE ready interrupt
  1964. * @rmtoll CIR HSERDYIE LL_RCC_DisableIT_HSERDY
  1965. * @retval None
  1966. */
  1967. __STATIC_INLINE void LL_RCC_DisableIT_HSERDY(void)
  1968. {
  1969. CLEAR_BIT(RCC->CIR, RCC_CIR_HSERDYIE);
  1970. }
  1971. /**
  1972. * @brief Disable PLL ready interrupt
  1973. * @rmtoll CIR PLLRDYIE LL_RCC_DisableIT_PLLRDY
  1974. * @retval None
  1975. */
  1976. __STATIC_INLINE void LL_RCC_DisableIT_PLLRDY(void)
  1977. {
  1978. CLEAR_BIT(RCC->CIR, RCC_CIR_PLLRDYIE);
  1979. }
  1980. #if defined(RCC_PLLI2S_SUPPORT)
  1981. /**
  1982. * @brief Disable PLLI2S ready interrupt
  1983. * @rmtoll CIR PLL3RDYIE LL_RCC_DisableIT_PLLI2SRDY
  1984. * @retval None
  1985. */
  1986. __STATIC_INLINE void LL_RCC_DisableIT_PLLI2SRDY(void)
  1987. {
  1988. CLEAR_BIT(RCC->CIR, RCC_CIR_PLL3RDYIE);
  1989. }
  1990. #endif /* RCC_PLLI2S_SUPPORT */
  1991. #if defined(RCC_PLL2_SUPPORT)
  1992. /**
  1993. * @brief Disable PLL2 ready interrupt
  1994. * @rmtoll CIR PLL2RDYIE LL_RCC_DisableIT_PLL2RDY
  1995. * @retval None
  1996. */
  1997. __STATIC_INLINE void LL_RCC_DisableIT_PLL2RDY(void)
  1998. {
  1999. CLEAR_BIT(RCC->CIR, RCC_CIR_PLL2RDYIE);
  2000. }
  2001. #endif /* RCC_PLL2_SUPPORT */
  2002. /**
  2003. * @brief Checks if LSI ready interrupt source is enabled or disabled.
  2004. * @rmtoll CIR LSIRDYIE LL_RCC_IsEnabledIT_LSIRDY
  2005. * @retval State of bit (1 or 0).
  2006. */
  2007. __STATIC_INLINE uint32_t LL_RCC_IsEnabledIT_LSIRDY(void)
  2008. {
  2009. return (READ_BIT(RCC->CIR, RCC_CIR_LSIRDYIE) == (RCC_CIR_LSIRDYIE));
  2010. }
  2011. /**
  2012. * @brief Checks if LSE ready interrupt source is enabled or disabled.
  2013. * @rmtoll CIR LSERDYIE LL_RCC_IsEnabledIT_LSERDY
  2014. * @retval State of bit (1 or 0).
  2015. */
  2016. __STATIC_INLINE uint32_t LL_RCC_IsEnabledIT_LSERDY(void)
  2017. {
  2018. return (READ_BIT(RCC->CIR, RCC_CIR_LSERDYIE) == (RCC_CIR_LSERDYIE));
  2019. }
  2020. /**
  2021. * @brief Checks if HSI ready interrupt source is enabled or disabled.
  2022. * @rmtoll CIR HSIRDYIE LL_RCC_IsEnabledIT_HSIRDY
  2023. * @retval State of bit (1 or 0).
  2024. */
  2025. __STATIC_INLINE uint32_t LL_RCC_IsEnabledIT_HSIRDY(void)
  2026. {
  2027. return (READ_BIT(RCC->CIR, RCC_CIR_HSIRDYIE) == (RCC_CIR_HSIRDYIE));
  2028. }
  2029. /**
  2030. * @brief Checks if HSE ready interrupt source is enabled or disabled.
  2031. * @rmtoll CIR HSERDYIE LL_RCC_IsEnabledIT_HSERDY
  2032. * @retval State of bit (1 or 0).
  2033. */
  2034. __STATIC_INLINE uint32_t LL_RCC_IsEnabledIT_HSERDY(void)
  2035. {
  2036. return (READ_BIT(RCC->CIR, RCC_CIR_HSERDYIE) == (RCC_CIR_HSERDYIE));
  2037. }
  2038. /**
  2039. * @brief Checks if PLL ready interrupt source is enabled or disabled.
  2040. * @rmtoll CIR PLLRDYIE LL_RCC_IsEnabledIT_PLLRDY
  2041. * @retval State of bit (1 or 0).
  2042. */
  2043. __STATIC_INLINE uint32_t LL_RCC_IsEnabledIT_PLLRDY(void)
  2044. {
  2045. return (READ_BIT(RCC->CIR, RCC_CIR_PLLRDYIE) == (RCC_CIR_PLLRDYIE));
  2046. }
  2047. #if defined(RCC_PLLI2S_SUPPORT)
  2048. /**
  2049. * @brief Checks if PLLI2S ready interrupt source is enabled or disabled.
  2050. * @rmtoll CIR PLL3RDYIE LL_RCC_IsEnabledIT_PLLI2SRDY
  2051. * @retval State of bit (1 or 0).
  2052. */
  2053. __STATIC_INLINE uint32_t LL_RCC_IsEnabledIT_PLLI2SRDY(void)
  2054. {
  2055. return (READ_BIT(RCC->CIR, RCC_CIR_PLL3RDYIE) == (RCC_CIR_PLL3RDYIE));
  2056. }
  2057. #endif /* RCC_PLLI2S_SUPPORT */
  2058. #if defined(RCC_PLL2_SUPPORT)
  2059. /**
  2060. * @brief Checks if PLL2 ready interrupt source is enabled or disabled.
  2061. * @rmtoll CIR PLL2RDYIE LL_RCC_IsEnabledIT_PLL2RDY
  2062. * @retval State of bit (1 or 0).
  2063. */
  2064. __STATIC_INLINE uint32_t LL_RCC_IsEnabledIT_PLL2RDY(void)
  2065. {
  2066. return (READ_BIT(RCC->CIR, RCC_CIR_PLL2RDYIE) == (RCC_CIR_PLL2RDYIE));
  2067. }
  2068. #endif /* RCC_PLL2_SUPPORT */
  2069. /**
  2070. * @}
  2071. */
  2072. #if defined(USE_FULL_LL_DRIVER)
  2073. /** @defgroup RCC_LL_EF_Init De-initialization function
  2074. * @{
  2075. */
  2076. ErrorStatus LL_RCC_DeInit(void);
  2077. /**
  2078. * @}
  2079. */
  2080. /** @defgroup RCC_LL_EF_Get_Freq Get system and peripherals clocks frequency functions
  2081. * @{
  2082. */
  2083. void LL_RCC_GetSystemClocksFreq(LL_RCC_ClocksTypeDef *RCC_Clocks);
  2084. #if defined(RCC_CFGR2_I2S2SRC)
  2085. uint32_t LL_RCC_GetI2SClockFreq(uint32_t I2SxSource);
  2086. #endif /* RCC_CFGR2_I2S2SRC */
  2087. #if defined(USB_OTG_FS) || defined(USB)
  2088. uint32_t LL_RCC_GetUSBClockFreq(uint32_t USBxSource);
  2089. #endif /* USB_OTG_FS || USB */
  2090. uint32_t LL_RCC_GetADCClockFreq(uint32_t ADCxSource);
  2091. /**
  2092. * @}
  2093. */
  2094. #endif /* USE_FULL_LL_DRIVER */
  2095. /**
  2096. * @}
  2097. */
  2098. /**
  2099. * @}
  2100. */
  2101. #endif /* RCC */
  2102. /**
  2103. * @}
  2104. */
  2105. #ifdef __cplusplus
  2106. }
  2107. #endif
  2108. #endif /* __STM32F1xx_LL_RCC_H */