stm32l4xx_ll_rcc.c 64 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917
  1. /**
  2. ******************************************************************************
  3. * @file stm32l4xx_ll_rcc.c
  4. * @author MCD Application Team
  5. * @brief RCC LL module driver.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
  10. *
  11. * Redistribution and use in source and binary forms, with or without modification,
  12. * are permitted provided that the following conditions are met:
  13. * 1. Redistributions of source code must retain the above copyright notice,
  14. * this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  19. * may be used to endorse or promote products derived from this software
  20. * without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  25. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  26. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  28. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  29. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  30. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. *
  33. ******************************************************************************
  34. */
  35. #if defined(USE_FULL_LL_DRIVER)
  36. /* Includes ------------------------------------------------------------------*/
  37. #include "stm32l4xx_ll_rcc.h"
  38. #ifdef USE_FULL_ASSERT
  39. #include "stm32_assert.h"
  40. #else
  41. #define assert_param(expr) ((void)0U)
  42. #endif
  43. /** @addtogroup STM32L4xx_LL_Driver
  44. * @{
  45. */
  46. #if defined(RCC)
  47. /** @addtogroup RCC_LL
  48. * @{
  49. */
  50. /* Private types -------------------------------------------------------------*/
  51. /* Private variables ---------------------------------------------------------*/
  52. /* Private constants ---------------------------------------------------------*/
  53. /* Private macros ------------------------------------------------------------*/
  54. /** @addtogroup RCC_LL_Private_Macros
  55. * @{
  56. */
  57. #if defined(RCC_CCIPR_USART3SEL)
  58. #define IS_LL_RCC_USART_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_USART1_CLKSOURCE) \
  59. || ((__VALUE__) == LL_RCC_USART2_CLKSOURCE) \
  60. || ((__VALUE__) == LL_RCC_USART3_CLKSOURCE))
  61. #else
  62. #define IS_LL_RCC_USART_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_USART1_CLKSOURCE) \
  63. || ((__VALUE__) == LL_RCC_USART2_CLKSOURCE))
  64. #endif /* RCC_CCIPR_USART3SEL */
  65. #if defined(RCC_CCIPR_UART4SEL) && defined(RCC_CCIPR_UART5SEL)
  66. #define IS_LL_RCC_UART_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_UART4_CLKSOURCE) \
  67. || ((__VALUE__) == LL_RCC_UART5_CLKSOURCE))
  68. #elif defined(RCC_CCIPR_UART4SEL)
  69. #define IS_LL_RCC_UART_CLKSOURCE(__VALUE__) ((__VALUE__) == LL_RCC_UART4_CLKSOURCE)
  70. #elif defined(RCC_CCIPR_UART5SEL)
  71. #define IS_LL_RCC_UART_CLKSOURCE(__VALUE__) ((__VALUE__) == LL_RCC_UART5_CLKSOURCE)
  72. #endif /* RCC_CCIPR_UART4SEL && RCC_CCIPR_UART5SEL*/
  73. #define IS_LL_RCC_LPUART_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_LPUART1_CLKSOURCE))
  74. #if defined(RCC_CCIPR_I2C2SEL) && defined(RCC_CCIPR_I2C3SEL) && defined(RCC_CCIPR2_I2C4SEL)
  75. #define IS_LL_RCC_I2C_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_I2C1_CLKSOURCE) \
  76. || ((__VALUE__) == LL_RCC_I2C2_CLKSOURCE) \
  77. || ((__VALUE__) == LL_RCC_I2C3_CLKSOURCE) \
  78. || ((__VALUE__) == LL_RCC_I2C4_CLKSOURCE))
  79. #elif defined(RCC_CCIPR_I2C2SEL) && defined(RCC_CCIPR_I2C3SEL)
  80. #define IS_LL_RCC_I2C_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_I2C1_CLKSOURCE) \
  81. || ((__VALUE__) == LL_RCC_I2C2_CLKSOURCE) \
  82. || ((__VALUE__) == LL_RCC_I2C3_CLKSOURCE))
  83. #elif !defined(RCC_CCIPR_I2C2SEL) && defined(RCC_CCIPR_I2C3SEL)
  84. #define IS_LL_RCC_I2C_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_I2C1_CLKSOURCE) \
  85. || ((__VALUE__) == LL_RCC_I2C3_CLKSOURCE))
  86. #else
  87. #define IS_LL_RCC_I2C_CLKSOURCE(__VALUE__) ((__VALUE__) == LL_RCC_I2C1_CLKSOURCE)
  88. #endif /* RCC_CCIPR_I2C2SEL && RCC_CCIPR_I2C3SEL && RCC_CCIPR2_I2C4SEL */
  89. #define IS_LL_RCC_LPTIM_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_LPTIM1_CLKSOURCE) \
  90. || ((__VALUE__) == LL_RCC_LPTIM2_CLKSOURCE))
  91. #if defined(RCC_CCIPR_SAI2SEL)
  92. #define IS_LL_RCC_SAI_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_SAI1_CLKSOURCE) \
  93. || ((__VALUE__) == LL_RCC_SAI2_CLKSOURCE))
  94. #else
  95. #define IS_LL_RCC_SAI_CLKSOURCE(__VALUE__) ((__VALUE__) == LL_RCC_SAI1_CLKSOURCE)
  96. #endif /* RCC_CCIPR_SAI2SEL */
  97. #if defined(RCC_CCIPR2_SDMMCSEL)
  98. #define IS_LL_RCC_SDMMC_KERNELCLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_SDMMC1_KERNELCLKSOURCE))
  99. #endif /* RCC_CCIPR2_SDMMCSEL */
  100. #define IS_LL_RCC_SDMMC_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_SDMMC1_CLKSOURCE))
  101. #define IS_LL_RCC_RNG_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_RNG_CLKSOURCE))
  102. #if defined(USB_OTG_FS) || defined(USB)
  103. #define IS_LL_RCC_USB_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_USB_CLKSOURCE))
  104. #endif /* USB_OTG_FS || USB */
  105. #define IS_LL_RCC_ADC_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_ADC_CLKSOURCE))
  106. #if defined(SWPMI1)
  107. #define IS_LL_RCC_SWPMI_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_SWPMI1_CLKSOURCE))
  108. #endif /* SWPMI1 */
  109. #if defined(DFSDM1_Channel0)
  110. #define IS_LL_RCC_DFSDM_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_DFSDM1_CLKSOURCE))
  111. #if defined(RCC_CCIPR2_DFSDM1SEL)
  112. #define IS_LL_RCC_DFSDM_AUDIO_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_DFSDM1_AUDIO_CLKSOURCE))
  113. #endif /* RCC_CCIPR2_DFSDM1SEL */
  114. #endif /* DFSDM1_Channel0 */
  115. #if defined(DSI)
  116. #define IS_LL_RCC_DSI_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_DSI_CLKSOURCE))
  117. #endif /* DSI */
  118. #if defined(LTDC)
  119. #define IS_LL_RCC_LTDC_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_LTDC_CLKSOURCE))
  120. #endif /* LTDC */
  121. #if defined(OCTOSPI1)
  122. #define IS_LL_RCC_OCTOSPI_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_OCTOSPI_CLKSOURCE))
  123. #endif /* OCTOSPI */
  124. /**
  125. * @}
  126. */
  127. /* Private function prototypes -----------------------------------------------*/
  128. /** @defgroup RCC_LL_Private_Functions RCC Private functions
  129. * @{
  130. */
  131. uint32_t RCC_GetSystemClockFreq(void);
  132. uint32_t RCC_GetHCLKClockFreq(uint32_t SYSCLK_Frequency);
  133. uint32_t RCC_GetPCLK1ClockFreq(uint32_t HCLK_Frequency);
  134. uint32_t RCC_GetPCLK2ClockFreq(uint32_t HCLK_Frequency);
  135. uint32_t RCC_PLL_GetFreqDomain_SYS(void);
  136. uint32_t RCC_PLL_GetFreqDomain_SAI(void);
  137. uint32_t RCC_PLL_GetFreqDomain_48M(void);
  138. uint32_t RCC_PLLSAI1_GetFreqDomain_SAI(void);
  139. uint32_t RCC_PLLSAI1_GetFreqDomain_48M(void);
  140. uint32_t RCC_PLLSAI1_GetFreqDomain_ADC(void);
  141. #if defined(RCC_PLLSAI2_SUPPORT)
  142. uint32_t RCC_PLLSAI2_GetFreqDomain_SAI(void);
  143. #if defined(LTDC)
  144. uint32_t RCC_PLLSAI2_GetFreqDomain_LTDC(void);
  145. #else
  146. uint32_t RCC_PLLSAI2_GetFreqDomain_ADC(void);
  147. #endif /* LTDC */
  148. #if defined(DSI)
  149. uint32_t RCC_PLLSAI2_GetFreqDomain_DSI(void);
  150. #endif /* DSI */
  151. #endif /*RCC_PLLSAI2_SUPPORT*/
  152. /**
  153. * @}
  154. */
  155. /* Exported functions --------------------------------------------------------*/
  156. /** @addtogroup RCC_LL_Exported_Functions
  157. * @{
  158. */
  159. /** @addtogroup RCC_LL_EF_Init
  160. * @{
  161. */
  162. /**
  163. * @brief Reset the RCC clock configuration to the default reset state.
  164. * @note The default reset state of the clock configuration is given below:
  165. * - MSI ON and used as system clock source
  166. * - HSE, HSI, PLL, PLLSAI1 and PLLSAI2 OFF
  167. * - AHB, APB1 and APB2 prescaler set to 1.
  168. * - CSS, MCO OFF
  169. * - All interrupts disabled
  170. * @note This function doesn't modify the configuration of the
  171. * - Peripheral clocks
  172. * - LSI, LSE and RTC clocks
  173. * @retval An ErrorStatus enumeration value:
  174. * - SUCCESS: RCC registers are de-initialized
  175. * - ERROR: not applicable
  176. */
  177. ErrorStatus LL_RCC_DeInit(void)
  178. {
  179. uint32_t vl_mask = 0U;
  180. /* Set MSION bit */
  181. LL_RCC_MSI_Enable();
  182. /* Insure MSIRDY bit is set before writing default MSIRANGE value */
  183. while (LL_RCC_MSI_IsReady() == 0U)
  184. {
  185. }
  186. /* Set MSIRANGE default value */
  187. LL_RCC_MSI_SetRange(LL_RCC_MSIRANGE_6);
  188. /* Set MSITRIM bits to the reset value*/
  189. LL_RCC_MSI_SetCalibTrimming(0);
  190. /* Set HSITRIM bits to the reset value*/
  191. LL_RCC_HSI_SetCalibTrimming(0x10U);
  192. /* Reset CFGR register */
  193. LL_RCC_WriteReg(CFGR, 0x00000000U);
  194. vl_mask = 0xFFFFFFFFU;
  195. /* Reset HSION, HSIKERON, HSIASFS, HSEON, PLLON bits */
  196. CLEAR_BIT(vl_mask, (RCC_CR_HSION | RCC_CR_HSIASFS | RCC_CR_HSIKERON | RCC_CR_HSEON |
  197. RCC_CR_PLLON));
  198. /* Reset PLLSAI1ON bit */
  199. CLEAR_BIT(vl_mask, RCC_CR_PLLSAI1ON);
  200. #if defined(RCC_PLLSAI2_SUPPORT)
  201. /* Reset PLLSAI2ON bit */
  202. CLEAR_BIT(vl_mask, RCC_CR_PLLSAI2ON);
  203. #endif /*RCC_PLLSAI2_SUPPORT*/
  204. /* Write new mask in CR register */
  205. LL_RCC_WriteReg(CR, vl_mask);
  206. #if defined(RCC_PLLSAI2_SUPPORT)
  207. /* Wait for PLLRDY, PLLSAI1RDY and PLLSAI2RDY bits to be reset */
  208. while(READ_BIT(RCC->CR, RCC_CR_PLLRDY | RCC_CR_PLLSAI1RDY | RCC_CR_PLLSAI2RDY) != 0U)
  209. {
  210. }
  211. #else
  212. /* Wait for PLLRDY, PLLSAI1RDY bits to be reset */
  213. while(READ_BIT(RCC->CR, RCC_CR_PLLRDY | RCC_CR_PLLSAI1RDY) != 0U)
  214. {
  215. }
  216. #endif
  217. /* Reset PLLCFGR register */
  218. LL_RCC_WriteReg(PLLCFGR, 16U << RCC_PLLCFGR_PLLN_Pos);
  219. /* Reset PLLSAI1CFGR register */
  220. LL_RCC_WriteReg(PLLSAI1CFGR, 16U << RCC_PLLSAI1CFGR_PLLSAI1N_Pos);
  221. #if defined(RCC_PLLSAI2_SUPPORT)
  222. /* Reset PLLSAI2CFGR register */
  223. LL_RCC_WriteReg(PLLSAI2CFGR, 16U << RCC_PLLSAI2CFGR_PLLSAI2N_Pos);
  224. #endif /*RCC_PLLSAI2_SUPPORT*/
  225. /* Reset HSEBYP bit */
  226. LL_RCC_HSE_DisableBypass();
  227. /* Disable all interrupts */
  228. LL_RCC_WriteReg(CIER, 0x00000000U);
  229. /* Clear all interrupt flags */
  230. vl_mask = RCC_CICR_LSIRDYC | RCC_CICR_LSERDYC | RCC_CICR_MSIRDYC | RCC_CICR_HSIRDYC | RCC_CICR_HSERDYC | RCC_CICR_PLLRDYC | \
  231. RCC_CICR_PLLSAI1RDYC | RCC_CICR_CSSC | RCC_CICR_LSECSSC;
  232. #if defined(RCC_HSI48_SUPPORT)
  233. vl_mask |= RCC_CICR_HSI48RDYC;
  234. #endif
  235. #if defined(RCC_PLLSAI2_SUPPORT)
  236. vl_mask |= RCC_CICR_PLLSAI2RDYC;
  237. #endif
  238. LL_RCC_WriteReg(CICR, vl_mask);
  239. /* Clear reset flags */
  240. LL_RCC_ClearResetFlags();
  241. return SUCCESS;
  242. }
  243. /**
  244. * @}
  245. */
  246. /** @addtogroup RCC_LL_EF_Get_Freq
  247. * @brief Return the frequencies of different on chip clocks; System, AHB, APB1 and APB2 buses clocks
  248. * and different peripheral clocks available on the device.
  249. * @note If SYSCLK source is MSI, function returns values based on MSI_VALUE(*)
  250. * @note If SYSCLK source is HSI, function returns values based on HSI_VALUE(**)
  251. * @note If SYSCLK source is HSE, function returns values based on HSE_VALUE(***)
  252. * @note If SYSCLK source is PLL, function returns values based on HSE_VALUE(***)
  253. * or HSI_VALUE(**) or MSI_VALUE(*) multiplied/divided by the PLL factors.
  254. * @note (*) MSI_VALUE is a constant defined in this file (default value
  255. * 4 MHz) but the real value may vary depending on the variations
  256. * in voltage and temperature.
  257. * @note (**) HSI_VALUE is a constant defined in this file (default value
  258. * 16 MHz) but the real value may vary depending on the variations
  259. * in voltage and temperature.
  260. * @note (***) HSE_VALUE is a constant defined in this file (default value
  261. * 8 MHz), user has to ensure that HSE_VALUE is same as the real
  262. * frequency of the crystal used. Otherwise, this function may
  263. * have wrong result.
  264. * @note The result of this function could be incorrect when using fractional
  265. * value for HSE crystal.
  266. * @note This function can be used by the user application to compute the
  267. * baud-rate for the communication peripherals or configure other parameters.
  268. * @{
  269. */
  270. /**
  271. * @brief Return the frequencies of different on chip clocks; System, AHB, APB1 and APB2 buses clocks
  272. * @note Each time SYSCLK, HCLK, PCLK1 and/or PCLK2 clock changes, this function
  273. * must be called to update structure fields. Otherwise, any
  274. * configuration based on this function will be incorrect.
  275. * @param RCC_Clocks pointer to a @ref LL_RCC_ClocksTypeDef structure which will hold the clocks frequencies
  276. * @retval None
  277. */
  278. void LL_RCC_GetSystemClocksFreq(LL_RCC_ClocksTypeDef *RCC_Clocks)
  279. {
  280. /* Get SYSCLK frequency */
  281. RCC_Clocks->SYSCLK_Frequency = RCC_GetSystemClockFreq();
  282. /* HCLK clock frequency */
  283. RCC_Clocks->HCLK_Frequency = RCC_GetHCLKClockFreq(RCC_Clocks->SYSCLK_Frequency);
  284. /* PCLK1 clock frequency */
  285. RCC_Clocks->PCLK1_Frequency = RCC_GetPCLK1ClockFreq(RCC_Clocks->HCLK_Frequency);
  286. /* PCLK2 clock frequency */
  287. RCC_Clocks->PCLK2_Frequency = RCC_GetPCLK2ClockFreq(RCC_Clocks->HCLK_Frequency);
  288. }
  289. /**
  290. * @brief Return USARTx clock frequency
  291. * @param USARTxSource This parameter can be one of the following values:
  292. * @arg @ref LL_RCC_USART1_CLKSOURCE
  293. * @arg @ref LL_RCC_USART2_CLKSOURCE
  294. * @arg @ref LL_RCC_USART3_CLKSOURCE (*)
  295. *
  296. * (*) value not defined in all devices.
  297. * @retval USART clock frequency (in Hz)
  298. * - @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillator (HSI or LSE) is not ready
  299. */
  300. uint32_t LL_RCC_GetUSARTClockFreq(uint32_t USARTxSource)
  301. {
  302. uint32_t usart_frequency = LL_RCC_PERIPH_FREQUENCY_NO;
  303. /* Check parameter */
  304. assert_param(IS_LL_RCC_USART_CLKSOURCE(USARTxSource));
  305. if (USARTxSource == LL_RCC_USART1_CLKSOURCE)
  306. {
  307. /* USART1CLK clock frequency */
  308. switch (LL_RCC_GetUSARTClockSource(USARTxSource))
  309. {
  310. case LL_RCC_USART1_CLKSOURCE_SYSCLK: /* USART1 Clock is System Clock */
  311. usart_frequency = RCC_GetSystemClockFreq();
  312. break;
  313. case LL_RCC_USART1_CLKSOURCE_HSI: /* USART1 Clock is HSI Osc. */
  314. if (LL_RCC_HSI_IsReady())
  315. {
  316. usart_frequency = HSI_VALUE;
  317. }
  318. break;
  319. case LL_RCC_USART1_CLKSOURCE_LSE: /* USART1 Clock is LSE Osc. */
  320. if (LL_RCC_LSE_IsReady())
  321. {
  322. usart_frequency = LSE_VALUE;
  323. }
  324. break;
  325. case LL_RCC_USART1_CLKSOURCE_PCLK2: /* USART1 Clock is PCLK2 */
  326. default:
  327. usart_frequency = RCC_GetPCLK2ClockFreq(RCC_GetHCLKClockFreq(RCC_GetSystemClockFreq()));
  328. break;
  329. }
  330. }
  331. else if (USARTxSource == LL_RCC_USART2_CLKSOURCE)
  332. {
  333. /* USART2CLK clock frequency */
  334. switch (LL_RCC_GetUSARTClockSource(USARTxSource))
  335. {
  336. case LL_RCC_USART2_CLKSOURCE_SYSCLK: /* USART2 Clock is System Clock */
  337. usart_frequency = RCC_GetSystemClockFreq();
  338. break;
  339. case LL_RCC_USART2_CLKSOURCE_HSI: /* USART2 Clock is HSI Osc. */
  340. if (LL_RCC_HSI_IsReady())
  341. {
  342. usart_frequency = HSI_VALUE;
  343. }
  344. break;
  345. case LL_RCC_USART2_CLKSOURCE_LSE: /* USART2 Clock is LSE Osc. */
  346. if (LL_RCC_LSE_IsReady())
  347. {
  348. usart_frequency = LSE_VALUE;
  349. }
  350. break;
  351. case LL_RCC_USART2_CLKSOURCE_PCLK1: /* USART2 Clock is PCLK1 */
  352. default:
  353. usart_frequency = RCC_GetPCLK1ClockFreq(RCC_GetHCLKClockFreq(RCC_GetSystemClockFreq()));
  354. break;
  355. }
  356. }
  357. else
  358. {
  359. #if defined(RCC_CCIPR_USART3SEL)
  360. if (USARTxSource == LL_RCC_USART3_CLKSOURCE)
  361. {
  362. /* USART3CLK clock frequency */
  363. switch (LL_RCC_GetUSARTClockSource(USARTxSource))
  364. {
  365. case LL_RCC_USART3_CLKSOURCE_SYSCLK: /* USART3 Clock is System Clock */
  366. usart_frequency = RCC_GetSystemClockFreq();
  367. break;
  368. case LL_RCC_USART3_CLKSOURCE_HSI: /* USART3 Clock is HSI Osc. */
  369. if (LL_RCC_HSI_IsReady())
  370. {
  371. usart_frequency = HSI_VALUE;
  372. }
  373. break;
  374. case LL_RCC_USART3_CLKSOURCE_LSE: /* USART3 Clock is LSE Osc. */
  375. if (LL_RCC_LSE_IsReady())
  376. {
  377. usart_frequency = LSE_VALUE;
  378. }
  379. break;
  380. case LL_RCC_USART3_CLKSOURCE_PCLK1: /* USART3 Clock is PCLK1 */
  381. default:
  382. usart_frequency = RCC_GetPCLK1ClockFreq(RCC_GetHCLKClockFreq(RCC_GetSystemClockFreq()));
  383. break;
  384. }
  385. }
  386. #endif /* RCC_CCIPR_USART3SEL */
  387. }
  388. return usart_frequency;
  389. }
  390. #if defined(RCC_CCIPR_UART4SEL) || defined(RCC_CCIPR_UART5SEL)
  391. /**
  392. * @brief Return UARTx clock frequency
  393. * @param UARTxSource This parameter can be one of the following values:
  394. * @arg @ref LL_RCC_UART4_CLKSOURCE
  395. * @arg @ref LL_RCC_UART5_CLKSOURCE
  396. * @retval UART clock frequency (in Hz)
  397. * - @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillator (HSI or LSE) is not ready
  398. */
  399. uint32_t LL_RCC_GetUARTClockFreq(uint32_t UARTxSource)
  400. {
  401. uint32_t uart_frequency = LL_RCC_PERIPH_FREQUENCY_NO;
  402. /* Check parameter */
  403. assert_param(IS_LL_RCC_UART_CLKSOURCE(UARTxSource));
  404. #if defined(RCC_CCIPR_UART4SEL)
  405. if (UARTxSource == LL_RCC_UART4_CLKSOURCE)
  406. {
  407. /* UART4CLK clock frequency */
  408. switch (LL_RCC_GetUARTClockSource(UARTxSource))
  409. {
  410. case LL_RCC_UART4_CLKSOURCE_SYSCLK: /* UART4 Clock is System Clock */
  411. uart_frequency = RCC_GetSystemClockFreq();
  412. break;
  413. case LL_RCC_UART4_CLKSOURCE_HSI: /* UART4 Clock is HSI Osc. */
  414. if (LL_RCC_HSI_IsReady())
  415. {
  416. uart_frequency = HSI_VALUE;
  417. }
  418. break;
  419. case LL_RCC_UART4_CLKSOURCE_LSE: /* UART4 Clock is LSE Osc. */
  420. if (LL_RCC_LSE_IsReady())
  421. {
  422. uart_frequency = LSE_VALUE;
  423. }
  424. break;
  425. case LL_RCC_UART4_CLKSOURCE_PCLK1: /* UART4 Clock is PCLK1 */
  426. default:
  427. uart_frequency = RCC_GetPCLK1ClockFreq(RCC_GetHCLKClockFreq(RCC_GetSystemClockFreq()));
  428. break;
  429. }
  430. }
  431. #endif /* RCC_CCIPR_UART4SEL */
  432. #if defined(RCC_CCIPR_UART5SEL)
  433. if (UARTxSource == LL_RCC_UART5_CLKSOURCE)
  434. {
  435. /* UART5CLK clock frequency */
  436. switch (LL_RCC_GetUARTClockSource(UARTxSource))
  437. {
  438. case LL_RCC_UART5_CLKSOURCE_SYSCLK: /* UART5 Clock is System Clock */
  439. uart_frequency = RCC_GetSystemClockFreq();
  440. break;
  441. case LL_RCC_UART5_CLKSOURCE_HSI: /* UART5 Clock is HSI Osc. */
  442. if (LL_RCC_HSI_IsReady())
  443. {
  444. uart_frequency = HSI_VALUE;
  445. }
  446. break;
  447. case LL_RCC_UART5_CLKSOURCE_LSE: /* UART5 Clock is LSE Osc. */
  448. if (LL_RCC_LSE_IsReady())
  449. {
  450. uart_frequency = LSE_VALUE;
  451. }
  452. break;
  453. case LL_RCC_UART5_CLKSOURCE_PCLK1: /* UART5 Clock is PCLK1 */
  454. default:
  455. uart_frequency = RCC_GetPCLK1ClockFreq(RCC_GetHCLKClockFreq(RCC_GetSystemClockFreq()));
  456. break;
  457. }
  458. }
  459. #endif /* RCC_CCIPR_UART5SEL */
  460. return uart_frequency;
  461. }
  462. #endif /* RCC_CCIPR_UART4SEL || RCC_CCIPR_UART5SEL */
  463. /**
  464. * @brief Return I2Cx clock frequency
  465. * @param I2CxSource This parameter can be one of the following values:
  466. * @arg @ref LL_RCC_I2C1_CLKSOURCE
  467. * @arg @ref LL_RCC_I2C2_CLKSOURCE (*)
  468. * @arg @ref LL_RCC_I2C3_CLKSOURCE
  469. * @arg @ref LL_RCC_I2C4_CLKSOURCE (*)
  470. *
  471. * (*) value not defined in all devices.
  472. * @retval I2C clock frequency (in Hz)
  473. * - @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that HSI oscillator is not ready
  474. */
  475. uint32_t LL_RCC_GetI2CClockFreq(uint32_t I2CxSource)
  476. {
  477. uint32_t i2c_frequency = LL_RCC_PERIPH_FREQUENCY_NO;
  478. /* Check parameter */
  479. assert_param(IS_LL_RCC_I2C_CLKSOURCE(I2CxSource));
  480. if (I2CxSource == LL_RCC_I2C1_CLKSOURCE)
  481. {
  482. /* I2C1 CLK clock frequency */
  483. switch (LL_RCC_GetI2CClockSource(I2CxSource))
  484. {
  485. case LL_RCC_I2C1_CLKSOURCE_SYSCLK: /* I2C1 Clock is System Clock */
  486. i2c_frequency = RCC_GetSystemClockFreq();
  487. break;
  488. case LL_RCC_I2C1_CLKSOURCE_HSI: /* I2C1 Clock is HSI Osc. */
  489. if (LL_RCC_HSI_IsReady())
  490. {
  491. i2c_frequency = HSI_VALUE;
  492. }
  493. break;
  494. case LL_RCC_I2C1_CLKSOURCE_PCLK1: /* I2C1 Clock is PCLK1 */
  495. default:
  496. i2c_frequency = RCC_GetPCLK1ClockFreq(RCC_GetHCLKClockFreq(RCC_GetSystemClockFreq()));
  497. break;
  498. }
  499. }
  500. #if defined(RCC_CCIPR_I2C2SEL)
  501. else if (I2CxSource == LL_RCC_I2C2_CLKSOURCE)
  502. {
  503. /* I2C2 CLK clock frequency */
  504. switch (LL_RCC_GetI2CClockSource(I2CxSource))
  505. {
  506. case LL_RCC_I2C2_CLKSOURCE_SYSCLK: /* I2C2 Clock is System Clock */
  507. i2c_frequency = RCC_GetSystemClockFreq();
  508. break;
  509. case LL_RCC_I2C2_CLKSOURCE_HSI: /* I2C2 Clock is HSI Osc. */
  510. if (LL_RCC_HSI_IsReady())
  511. {
  512. i2c_frequency = HSI_VALUE;
  513. }
  514. break;
  515. case LL_RCC_I2C2_CLKSOURCE_PCLK1: /* I2C2 Clock is PCLK1 */
  516. default:
  517. i2c_frequency = RCC_GetPCLK1ClockFreq(RCC_GetHCLKClockFreq(RCC_GetSystemClockFreq()));
  518. break;
  519. }
  520. }
  521. #endif /*RCC_CCIPR_I2C2SEL*/
  522. else
  523. {
  524. if (I2CxSource == LL_RCC_I2C3_CLKSOURCE)
  525. {
  526. /* I2C3 CLK clock frequency */
  527. switch (LL_RCC_GetI2CClockSource(I2CxSource))
  528. {
  529. case LL_RCC_I2C3_CLKSOURCE_SYSCLK: /* I2C3 Clock is System Clock */
  530. i2c_frequency = RCC_GetSystemClockFreq();
  531. break;
  532. case LL_RCC_I2C3_CLKSOURCE_HSI: /* I2C3 Clock is HSI Osc. */
  533. if (LL_RCC_HSI_IsReady())
  534. {
  535. i2c_frequency = HSI_VALUE;
  536. }
  537. break;
  538. case LL_RCC_I2C3_CLKSOURCE_PCLK1: /* I2C3 Clock is PCLK1 */
  539. default:
  540. i2c_frequency = RCC_GetPCLK1ClockFreq(RCC_GetHCLKClockFreq(RCC_GetSystemClockFreq()));
  541. break;
  542. }
  543. }
  544. #if defined(RCC_CCIPR2_I2C4SEL)
  545. else
  546. {
  547. if (I2CxSource == LL_RCC_I2C4_CLKSOURCE)
  548. {
  549. /* I2C4 CLK clock frequency */
  550. switch (LL_RCC_GetI2CClockSource(I2CxSource))
  551. {
  552. case LL_RCC_I2C4_CLKSOURCE_SYSCLK: /* I2C4 Clock is System Clock */
  553. i2c_frequency = RCC_GetSystemClockFreq();
  554. break;
  555. case LL_RCC_I2C4_CLKSOURCE_HSI: /* I2C4 Clock is HSI Osc. */
  556. if (LL_RCC_HSI_IsReady())
  557. {
  558. i2c_frequency = HSI_VALUE;
  559. }
  560. break;
  561. case LL_RCC_I2C4_CLKSOURCE_PCLK1: /* I2C4 Clock is PCLK1 */
  562. default:
  563. i2c_frequency = RCC_GetPCLK1ClockFreq(RCC_GetHCLKClockFreq(RCC_GetSystemClockFreq()));
  564. break;
  565. }
  566. }
  567. }
  568. #endif /*RCC_CCIPR2_I2C4SEL*/
  569. }
  570. return i2c_frequency;
  571. }
  572. /**
  573. * @brief Return LPUARTx clock frequency
  574. * @param LPUARTxSource This parameter can be one of the following values:
  575. * @arg @ref LL_RCC_LPUART1_CLKSOURCE
  576. * @retval LPUART clock frequency (in Hz)
  577. * - @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillator (HSI or LSE) is not ready
  578. */
  579. uint32_t LL_RCC_GetLPUARTClockFreq(uint32_t LPUARTxSource)
  580. {
  581. uint32_t lpuart_frequency = LL_RCC_PERIPH_FREQUENCY_NO;
  582. /* Check parameter */
  583. assert_param(IS_LL_RCC_LPUART_CLKSOURCE(LPUARTxSource));
  584. /* LPUART1CLK clock frequency */
  585. switch (LL_RCC_GetLPUARTClockSource(LPUARTxSource))
  586. {
  587. case LL_RCC_LPUART1_CLKSOURCE_SYSCLK: /* LPUART1 Clock is System Clock */
  588. lpuart_frequency = RCC_GetSystemClockFreq();
  589. break;
  590. case LL_RCC_LPUART1_CLKSOURCE_HSI: /* LPUART1 Clock is HSI Osc. */
  591. if (LL_RCC_HSI_IsReady())
  592. {
  593. lpuart_frequency = HSI_VALUE;
  594. }
  595. break;
  596. case LL_RCC_LPUART1_CLKSOURCE_LSE: /* LPUART1 Clock is LSE Osc. */
  597. if (LL_RCC_LSE_IsReady())
  598. {
  599. lpuart_frequency = LSE_VALUE;
  600. }
  601. break;
  602. case LL_RCC_LPUART1_CLKSOURCE_PCLK1: /* LPUART1 Clock is PCLK1 */
  603. default:
  604. lpuart_frequency = RCC_GetPCLK1ClockFreq(RCC_GetHCLKClockFreq(RCC_GetSystemClockFreq()));
  605. break;
  606. }
  607. return lpuart_frequency;
  608. }
  609. /**
  610. * @brief Return LPTIMx clock frequency
  611. * @param LPTIMxSource This parameter can be one of the following values:
  612. * @arg @ref LL_RCC_LPTIM1_CLKSOURCE
  613. * @arg @ref LL_RCC_LPTIM2_CLKSOURCE
  614. * @retval LPTIM clock frequency (in Hz)
  615. * - @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillator (HSI, LSI or LSE) is not ready
  616. */
  617. uint32_t LL_RCC_GetLPTIMClockFreq(uint32_t LPTIMxSource)
  618. {
  619. uint32_t lptim_frequency = LL_RCC_PERIPH_FREQUENCY_NO;
  620. /* Check parameter */
  621. assert_param(IS_LL_RCC_LPTIM_CLKSOURCE(LPTIMxSource));
  622. if (LPTIMxSource == LL_RCC_LPTIM1_CLKSOURCE)
  623. {
  624. /* LPTIM1CLK clock frequency */
  625. switch (LL_RCC_GetLPTIMClockSource(LPTIMxSource))
  626. {
  627. case LL_RCC_LPTIM1_CLKSOURCE_LSI: /* LPTIM1 Clock is LSI Osc. */
  628. if (LL_RCC_LSI_IsReady())
  629. {
  630. lptim_frequency = LSI_VALUE;
  631. }
  632. break;
  633. case LL_RCC_LPTIM1_CLKSOURCE_HSI: /* LPTIM1 Clock is HSI Osc. */
  634. if (LL_RCC_HSI_IsReady())
  635. {
  636. lptim_frequency = HSI_VALUE;
  637. }
  638. break;
  639. case LL_RCC_LPTIM1_CLKSOURCE_LSE: /* LPTIM1 Clock is LSE Osc. */
  640. if (LL_RCC_LSE_IsReady())
  641. {
  642. lptim_frequency = LSE_VALUE;
  643. }
  644. break;
  645. case LL_RCC_LPTIM1_CLKSOURCE_PCLK1: /* LPTIM1 Clock is PCLK1 */
  646. default:
  647. lptim_frequency = RCC_GetPCLK1ClockFreq(RCC_GetHCLKClockFreq(RCC_GetSystemClockFreq()));
  648. break;
  649. }
  650. }
  651. else
  652. {
  653. if (LPTIMxSource == LL_RCC_LPTIM2_CLKSOURCE)
  654. {
  655. /* LPTIM2CLK clock frequency */
  656. switch (LL_RCC_GetLPTIMClockSource(LPTIMxSource))
  657. {
  658. case LL_RCC_LPTIM2_CLKSOURCE_LSI: /* LPTIM2 Clock is LSI Osc. */
  659. if (LL_RCC_LSI_IsReady())
  660. {
  661. lptim_frequency = LSI_VALUE;
  662. }
  663. break;
  664. case LL_RCC_LPTIM2_CLKSOURCE_HSI: /* LPTIM2 Clock is HSI Osc. */
  665. if (LL_RCC_HSI_IsReady())
  666. {
  667. lptim_frequency = HSI_VALUE;
  668. }
  669. break;
  670. case LL_RCC_LPTIM2_CLKSOURCE_LSE: /* LPTIM2 Clock is LSE Osc. */
  671. if (LL_RCC_LSE_IsReady())
  672. {
  673. lptim_frequency = LSE_VALUE;
  674. }
  675. break;
  676. case LL_RCC_LPTIM2_CLKSOURCE_PCLK1: /* LPTIM2 Clock is PCLK1 */
  677. default:
  678. lptim_frequency = RCC_GetPCLK1ClockFreq(RCC_GetHCLKClockFreq(RCC_GetSystemClockFreq()));
  679. break;
  680. }
  681. }
  682. }
  683. return lptim_frequency;
  684. }
  685. /**
  686. * @brief Return SAIx clock frequency
  687. * @param SAIxSource This parameter can be one of the following values:
  688. * @arg @ref LL_RCC_SAI1_CLKSOURCE
  689. * @arg @ref LL_RCC_SAI2_CLKSOURCE (*)
  690. *
  691. * (*) value not defined in all devices.
  692. * @retval SAI clock frequency (in Hz)
  693. * - @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that PLL is not ready
  694. * - @ref LL_RCC_PERIPH_FREQUENCY_NA indicates that external clock is used
  695. */
  696. uint32_t LL_RCC_GetSAIClockFreq(uint32_t SAIxSource)
  697. {
  698. uint32_t sai_frequency = LL_RCC_PERIPH_FREQUENCY_NO;
  699. /* Check parameter */
  700. assert_param(IS_LL_RCC_SAI_CLKSOURCE(SAIxSource));
  701. if (SAIxSource == LL_RCC_SAI1_CLKSOURCE)
  702. {
  703. /* SAI1CLK clock frequency */
  704. switch (LL_RCC_GetSAIClockSource(SAIxSource))
  705. {
  706. case LL_RCC_SAI1_CLKSOURCE_PLLSAI1: /* PLLSAI1 clock used as SAI1 clock source */
  707. if (LL_RCC_PLLSAI1_IsReady())
  708. {
  709. sai_frequency = RCC_PLLSAI1_GetFreqDomain_SAI();
  710. }
  711. break;
  712. #if defined(RCC_PLLSAI2_SUPPORT)
  713. case LL_RCC_SAI1_CLKSOURCE_PLLSAI2: /* PLLSAI2 clock used as SAI1 clock source */
  714. if (LL_RCC_PLLSAI2_IsReady())
  715. {
  716. sai_frequency = RCC_PLLSAI2_GetFreqDomain_SAI();
  717. }
  718. break;
  719. #endif /* RCC_PLLSAI2_SUPPORT */
  720. case LL_RCC_SAI1_CLKSOURCE_PLL: /* PLL clock used as SAI1 clock source */
  721. if (LL_RCC_PLL_IsReady())
  722. {
  723. sai_frequency = RCC_PLL_GetFreqDomain_SAI();
  724. }
  725. break;
  726. case LL_RCC_SAI1_CLKSOURCE_PIN: /* External input clock used as SAI1 clock source */
  727. default:
  728. sai_frequency = LL_RCC_PERIPH_FREQUENCY_NA;
  729. break;
  730. }
  731. }
  732. else
  733. {
  734. #if defined(RCC_CCIPR_SAI2SEL)
  735. if (SAIxSource == LL_RCC_SAI2_CLKSOURCE)
  736. {
  737. /* SAI2CLK clock frequency */
  738. switch (LL_RCC_GetSAIClockSource(SAIxSource))
  739. {
  740. case LL_RCC_SAI2_CLKSOURCE_PLLSAI1: /* PLLSAI1 clock used as SAI2 clock source */
  741. if (LL_RCC_PLLSAI1_IsReady())
  742. {
  743. sai_frequency = RCC_PLLSAI1_GetFreqDomain_SAI();
  744. }
  745. break;
  746. #if defined(RCC_PLLSAI2_SUPPORT)
  747. case LL_RCC_SAI2_CLKSOURCE_PLLSAI2: /* PLLSAI2 clock used as SAI2 clock source */
  748. if (LL_RCC_PLLSAI2_IsReady())
  749. {
  750. sai_frequency = RCC_PLLSAI2_GetFreqDomain_SAI();
  751. }
  752. break;
  753. #endif /* RCC_PLLSAI2_SUPPORT */
  754. case LL_RCC_SAI2_CLKSOURCE_PLL: /* PLL clock used as SAI2 clock source */
  755. if (LL_RCC_PLL_IsReady())
  756. {
  757. sai_frequency = RCC_PLL_GetFreqDomain_SAI();
  758. }
  759. break;
  760. case LL_RCC_SAI2_CLKSOURCE_PIN: /* External input clock used as SAI2 clock source */
  761. default:
  762. sai_frequency = LL_RCC_PERIPH_FREQUENCY_NA;
  763. break;
  764. }
  765. }
  766. #endif /* RCC_CCIPR_SAI2SEL */
  767. }
  768. return sai_frequency;
  769. }
  770. #if defined(RCC_CCIPR2_SDMMCSEL)
  771. /**
  772. * @brief Return SDMMCx kernel clock frequency
  773. * @param SDMMCxSource This parameter can be one of the following values:
  774. * @arg @ref LL_RCC_SDMMC1_KERNELCLKSOURCE
  775. * @retval SDMMC clock frequency (in Hz)
  776. * - @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillator (MSI) or PLL is not ready
  777. * - @ref LL_RCC_PERIPH_FREQUENCY_NA indicates that no clock source selected
  778. */
  779. uint32_t LL_RCC_GetSDMMCKernelClockFreq(uint32_t SDMMCxSource)
  780. {
  781. uint32_t sdmmc_frequency = LL_RCC_PERIPH_FREQUENCY_NO;
  782. /* Check parameter */
  783. assert_param(IS_LL_RCC_SDMMC_KERNELCLKSOURCE(SDMMCxSource));
  784. /* SDMMC1CLK kernel clock frequency */
  785. switch (LL_RCC_GetSDMMCKernelClockSource(SDMMCxSource))
  786. {
  787. case LL_RCC_SDMMC1_KERNELCLKSOURCE_48CLK: /* 48MHz clock from internal multiplexor used as SDMMC1 clock source */
  788. sdmmc_frequency = LL_RCC_GetSDMMCClockFreq(LL_RCC_SDMMC1_CLKSOURCE);
  789. break;
  790. case LL_RCC_SDMMC1_KERNELCLKSOURCE_PLLP: /* PLL "P" output (PLLSAI3CLK) clock used as SDMMC1 clock source */
  791. if (LL_RCC_PLL_IsReady())
  792. {
  793. sdmmc_frequency = RCC_PLL_GetFreqDomain_SAI();
  794. }
  795. break;
  796. default:
  797. sdmmc_frequency = LL_RCC_PERIPH_FREQUENCY_NA;
  798. break;
  799. }
  800. return sdmmc_frequency;
  801. }
  802. #endif
  803. /**
  804. * @brief Return SDMMCx clock frequency
  805. * @param SDMMCxSource This parameter can be one of the following values:
  806. * @arg @ref LL_RCC_SDMMC1_CLKSOURCE
  807. * @retval SDMMC clock frequency (in Hz)
  808. * - @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillator (MSI) or PLL is not ready
  809. * - @ref LL_RCC_PERIPH_FREQUENCY_NA indicates that no clock source selected
  810. */
  811. uint32_t LL_RCC_GetSDMMCClockFreq(uint32_t SDMMCxSource)
  812. {
  813. uint32_t sdmmc_frequency = LL_RCC_PERIPH_FREQUENCY_NO;
  814. /* Check parameter */
  815. assert_param(IS_LL_RCC_SDMMC_CLKSOURCE(SDMMCxSource));
  816. /* SDMMC1CLK clock frequency */
  817. switch (LL_RCC_GetSDMMCClockSource(SDMMCxSource))
  818. {
  819. #if defined(LL_RCC_SDMMC1_CLKSOURCE_PLLSAI1)
  820. case LL_RCC_SDMMC1_CLKSOURCE_PLLSAI1: /* PLLSAI1 clock used as SDMMC1 clock source */
  821. if (LL_RCC_PLLSAI1_IsReady())
  822. {
  823. sdmmc_frequency = RCC_PLLSAI1_GetFreqDomain_48M();
  824. }
  825. break;
  826. #endif
  827. case LL_RCC_SDMMC1_CLKSOURCE_PLL: /* PLL clock used as SDMMC1 clock source */
  828. if (LL_RCC_PLL_IsReady())
  829. {
  830. sdmmc_frequency = RCC_PLL_GetFreqDomain_48M();
  831. }
  832. break;
  833. #if defined(LL_RCC_SDMMC1_CLKSOURCE_MSI)
  834. case LL_RCC_SDMMC1_CLKSOURCE_MSI: /* MSI clock used as SDMMC1 clock source */
  835. if (LL_RCC_MSI_IsReady())
  836. {
  837. sdmmc_frequency = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
  838. (LL_RCC_MSI_IsEnabledRangeSelect() ?
  839. LL_RCC_MSI_GetRange() :
  840. LL_RCC_MSI_GetRangeAfterStandby()));
  841. }
  842. break;
  843. #endif
  844. #if defined(RCC_HSI48_SUPPORT)
  845. case LL_RCC_SDMMC1_CLKSOURCE_HSI48: /* HSI48 used as SDMMC1 clock source */
  846. if (LL_RCC_HSI48_IsReady())
  847. {
  848. sdmmc_frequency = HSI48_VALUE;
  849. }
  850. break;
  851. #else
  852. case LL_RCC_SDMMC1_CLKSOURCE_NONE: /* No clock used as SDMMC1 clock source */
  853. #endif
  854. default:
  855. sdmmc_frequency = LL_RCC_PERIPH_FREQUENCY_NA;
  856. break;
  857. }
  858. return sdmmc_frequency;
  859. }
  860. /**
  861. * @brief Return RNGx clock frequency
  862. * @param RNGxSource This parameter can be one of the following values:
  863. * @arg @ref LL_RCC_RNG_CLKSOURCE
  864. * @retval RNG clock frequency (in Hz)
  865. * - @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillator (MSI) or PLL is not ready
  866. * - @ref LL_RCC_PERIPH_FREQUENCY_NA indicates that no clock source selected
  867. */
  868. uint32_t LL_RCC_GetRNGClockFreq(uint32_t RNGxSource)
  869. {
  870. uint32_t rng_frequency = LL_RCC_PERIPH_FREQUENCY_NO;
  871. /* Check parameter */
  872. assert_param(IS_LL_RCC_RNG_CLKSOURCE(RNGxSource));
  873. /* RNGCLK clock frequency */
  874. switch (LL_RCC_GetRNGClockSource(RNGxSource))
  875. {
  876. case LL_RCC_RNG_CLKSOURCE_PLLSAI1: /* PLLSAI1 clock used as RNG clock source */
  877. if (LL_RCC_PLLSAI1_IsReady())
  878. {
  879. rng_frequency = RCC_PLLSAI1_GetFreqDomain_48M();
  880. }
  881. break;
  882. case LL_RCC_RNG_CLKSOURCE_PLL: /* PLL clock used as RNG clock source */
  883. if (LL_RCC_PLL_IsReady())
  884. {
  885. rng_frequency = RCC_PLL_GetFreqDomain_48M();
  886. }
  887. break;
  888. case LL_RCC_RNG_CLKSOURCE_MSI: /* MSI clock used as RNG clock source */
  889. if (LL_RCC_MSI_IsReady())
  890. {
  891. rng_frequency = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
  892. (LL_RCC_MSI_IsEnabledRangeSelect() ?
  893. LL_RCC_MSI_GetRange() :
  894. LL_RCC_MSI_GetRangeAfterStandby()));
  895. }
  896. break;
  897. #if defined(RCC_HSI48_SUPPORT)
  898. case LL_RCC_RNG_CLKSOURCE_HSI48: /* HSI48 used as SDMMC1 clock source */
  899. if (LL_RCC_HSI48_IsReady())
  900. {
  901. rng_frequency = HSI48_VALUE;
  902. }
  903. break;
  904. #else
  905. case LL_RCC_RNG_CLKSOURCE_NONE: /* No clock used as SDMMC1 clock source */
  906. #endif
  907. default:
  908. rng_frequency = LL_RCC_PERIPH_FREQUENCY_NA;
  909. break;
  910. }
  911. return rng_frequency;
  912. }
  913. #if defined(USB_OTG_FS)||defined(USB)
  914. /**
  915. * @brief Return USBx clock frequency
  916. * @param USBxSource This parameter can be one of the following values:
  917. * @arg @ref LL_RCC_USB_CLKSOURCE
  918. * @retval USB clock frequency (in Hz)
  919. * - @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillator (MSI) or PLL is not ready
  920. * - @ref LL_RCC_PERIPH_FREQUENCY_NA indicates that no clock source selected
  921. */
  922. uint32_t LL_RCC_GetUSBClockFreq(uint32_t USBxSource)
  923. {
  924. uint32_t usb_frequency = LL_RCC_PERIPH_FREQUENCY_NO;
  925. /* Check parameter */
  926. assert_param(IS_LL_RCC_USB_CLKSOURCE(USBxSource));
  927. /* USBCLK clock frequency */
  928. switch (LL_RCC_GetUSBClockSource(USBxSource))
  929. {
  930. case LL_RCC_USB_CLKSOURCE_PLLSAI1: /* PLLSAI1 clock used as USB clock source */
  931. if (LL_RCC_PLLSAI1_IsReady())
  932. {
  933. usb_frequency = RCC_PLLSAI1_GetFreqDomain_48M();
  934. }
  935. break;
  936. case LL_RCC_USB_CLKSOURCE_PLL: /* PLL clock used as USB clock source */
  937. if (LL_RCC_PLL_IsReady())
  938. {
  939. usb_frequency = RCC_PLL_GetFreqDomain_48M();
  940. }
  941. break;
  942. case LL_RCC_USB_CLKSOURCE_MSI: /* MSI clock used as USB clock source */
  943. if (LL_RCC_MSI_IsReady())
  944. {
  945. usb_frequency = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
  946. (LL_RCC_MSI_IsEnabledRangeSelect() ?
  947. LL_RCC_MSI_GetRange() :
  948. LL_RCC_MSI_GetRangeAfterStandby()));
  949. }
  950. break;
  951. #if defined(RCC_HSI48_SUPPORT)
  952. case LL_RCC_USB_CLKSOURCE_HSI48: /* HSI48 used as USB clock source */
  953. if (LL_RCC_HSI48_IsReady())
  954. {
  955. usb_frequency = HSI48_VALUE;
  956. }
  957. break;
  958. #else
  959. case LL_RCC_USB_CLKSOURCE_NONE: /* No clock used as USB clock source */
  960. #endif
  961. default:
  962. usb_frequency = LL_RCC_PERIPH_FREQUENCY_NA;
  963. break;
  964. }
  965. return usb_frequency;
  966. }
  967. #endif /* USB_OTG_FS || USB */
  968. /**
  969. * @brief Return ADCx clock frequency
  970. * @param ADCxSource This parameter can be one of the following values:
  971. * @arg @ref LL_RCC_ADC_CLKSOURCE
  972. * @retval ADC clock frequency (in Hz)
  973. * - @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillator (MSI) or PLL is not ready
  974. * - @ref LL_RCC_PERIPH_FREQUENCY_NA indicates that no clock source selected
  975. */
  976. uint32_t LL_RCC_GetADCClockFreq(uint32_t ADCxSource)
  977. {
  978. uint32_t adc_frequency = LL_RCC_PERIPH_FREQUENCY_NO;
  979. /* Check parameter */
  980. assert_param(IS_LL_RCC_ADC_CLKSOURCE(ADCxSource));
  981. /* ADCCLK clock frequency */
  982. switch (LL_RCC_GetADCClockSource(ADCxSource))
  983. {
  984. case LL_RCC_ADC_CLKSOURCE_PLLSAI1: /* PLLSAI1 clock used as ADC clock source */
  985. if (LL_RCC_PLLSAI1_IsReady())
  986. {
  987. adc_frequency = RCC_PLLSAI1_GetFreqDomain_ADC();
  988. }
  989. break;
  990. #if defined(RCC_PLLSAI2_SUPPORT) && defined(LL_RCC_ADC_CLKSOURCE_PLLSAI2)
  991. case LL_RCC_ADC_CLKSOURCE_PLLSAI2: /* PLLSAI2 clock used as ADC clock source */
  992. if (LL_RCC_PLLSAI2_IsReady())
  993. {
  994. adc_frequency = RCC_PLLSAI2_GetFreqDomain_ADC();
  995. }
  996. break;
  997. #endif /* RCC_PLLSAI2_SUPPORT && LL_RCC_ADC_CLKSOURCE_PLLSAI2 */
  998. case LL_RCC_ADC_CLKSOURCE_SYSCLK: /* SYSCLK clock used as ADC clock source */
  999. adc_frequency = RCC_GetSystemClockFreq();
  1000. break;
  1001. case LL_RCC_ADC_CLKSOURCE_NONE: /* No clock used as ADC clock source */
  1002. default:
  1003. adc_frequency = LL_RCC_PERIPH_FREQUENCY_NA;
  1004. break;
  1005. }
  1006. return adc_frequency;
  1007. }
  1008. #if defined(SWPMI1)
  1009. /**
  1010. * @brief Return SWPMIx clock frequency
  1011. * @param SWPMIxSource This parameter can be one of the following values:
  1012. * @arg @ref LL_RCC_SWPMI1_CLKSOURCE
  1013. * @retval SWPMI clock frequency (in Hz)
  1014. * - @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillator (HSI) is not ready
  1015. */
  1016. uint32_t LL_RCC_GetSWPMIClockFreq(uint32_t SWPMIxSource)
  1017. {
  1018. uint32_t swpmi_frequency = LL_RCC_PERIPH_FREQUENCY_NO;
  1019. /* Check parameter */
  1020. assert_param(IS_LL_RCC_SWPMI_CLKSOURCE(SWPMIxSource));
  1021. /* SWPMI1CLK clock frequency */
  1022. switch (LL_RCC_GetSWPMIClockSource(SWPMIxSource))
  1023. {
  1024. case LL_RCC_SWPMI1_CLKSOURCE_HSI: /* SWPMI1 Clock is HSI Osc. */
  1025. if (LL_RCC_HSI_IsReady())
  1026. {
  1027. swpmi_frequency = HSI_VALUE;
  1028. }
  1029. break;
  1030. case LL_RCC_SWPMI1_CLKSOURCE_PCLK1: /* SWPMI1 Clock is PCLK1 */
  1031. default:
  1032. swpmi_frequency = RCC_GetPCLK1ClockFreq(RCC_GetHCLKClockFreq(RCC_GetSystemClockFreq()));
  1033. break;
  1034. }
  1035. return swpmi_frequency;
  1036. }
  1037. #endif /* SWPMI1 */
  1038. #if defined(DFSDM1_Channel0)
  1039. /**
  1040. * @brief Return DFSDMx clock frequency
  1041. * @param DFSDMxSource This parameter can be one of the following values:
  1042. * @arg @ref LL_RCC_DFSDM1_CLKSOURCE
  1043. * @retval DFSDM clock frequency (in Hz)
  1044. */
  1045. uint32_t LL_RCC_GetDFSDMClockFreq(uint32_t DFSDMxSource)
  1046. {
  1047. uint32_t dfsdm_frequency = LL_RCC_PERIPH_FREQUENCY_NO;
  1048. /* Check parameter */
  1049. assert_param(IS_LL_RCC_DFSDM_CLKSOURCE(DFSDMxSource));
  1050. /* DFSDM1CLK clock frequency */
  1051. switch (LL_RCC_GetDFSDMClockSource(DFSDMxSource))
  1052. {
  1053. case LL_RCC_DFSDM1_CLKSOURCE_SYSCLK: /* DFSDM1 Clock is SYSCLK */
  1054. dfsdm_frequency = RCC_GetSystemClockFreq();
  1055. break;
  1056. case LL_RCC_DFSDM1_CLKSOURCE_PCLK2: /* DFSDM1 Clock is PCLK2 */
  1057. default:
  1058. dfsdm_frequency = RCC_GetPCLK2ClockFreq(RCC_GetHCLKClockFreq(RCC_GetSystemClockFreq()));
  1059. break;
  1060. }
  1061. return dfsdm_frequency;
  1062. }
  1063. #if defined(RCC_CCIPR2_DFSDM1SEL)
  1064. /**
  1065. * @brief Return DFSDMx Audio clock frequency
  1066. * @param DFSDMxSource This parameter can be one of the following values:
  1067. * @arg @ref LL_RCC_DFSDM1_AUDIO_CLKSOURCE
  1068. * @retval DFSDM clock frequency (in Hz)
  1069. * - @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillator is not ready
  1070. */
  1071. uint32_t LL_RCC_GetDFSDMAudioClockFreq(uint32_t DFSDMxSource)
  1072. {
  1073. uint32_t dfsdm_frequency = LL_RCC_PERIPH_FREQUENCY_NO;
  1074. /* Check parameter */
  1075. assert_param(IS_LL_RCC_DFSDM_AUDIO_CLKSOURCE(DFSDMxSource));
  1076. /* DFSDM1CLK clock frequency */
  1077. switch (LL_RCC_GetDFSDMAudioClockSource(DFSDMxSource))
  1078. {
  1079. case LL_RCC_DFSDM1_AUDIO_CLKSOURCE_SAI1: /* SAI1 clock used as DFSDM1 audio clock */
  1080. dfsdm_frequency = LL_RCC_GetSAIClockFreq(LL_RCC_SAI1_CLKSOURCE);
  1081. break;
  1082. case LL_RCC_DFSDM1_AUDIO_CLKSOURCE_MSI: /* MSI clock used as DFSDM1 audio clock */
  1083. if (LL_RCC_MSI_IsReady())
  1084. {
  1085. dfsdm_frequency = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
  1086. (LL_RCC_MSI_IsEnabledRangeSelect() ?
  1087. LL_RCC_MSI_GetRange() :
  1088. LL_RCC_MSI_GetRangeAfterStandby()));
  1089. }
  1090. break;
  1091. case LL_RCC_DFSDM1_AUDIO_CLKSOURCE_HSI: /* HSI clock used as DFSDM1 audio clock */
  1092. default:
  1093. if (LL_RCC_HSI_IsReady())
  1094. {
  1095. dfsdm_frequency = HSI_VALUE;
  1096. }
  1097. break;
  1098. }
  1099. return dfsdm_frequency;
  1100. }
  1101. #endif /* RCC_CCIPR2_DFSDM1SEL */
  1102. #endif /* DFSDM1_Channel0 */
  1103. #if defined(DSI)
  1104. /**
  1105. * @brief Return DSI clock frequency
  1106. * @param DSIxSource This parameter can be one of the following values:
  1107. * @arg @ref LL_RCC_DSI_CLKSOURCE
  1108. * @retval DSI clock frequency (in Hz)
  1109. * - @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillator is not ready
  1110. * - @ref LL_RCC_PERIPH_FREQUENCY_NA indicates that external clock is used
  1111. */
  1112. uint32_t LL_RCC_GetDSIClockFreq(uint32_t DSIxSource)
  1113. {
  1114. uint32_t dsi_frequency = LL_RCC_PERIPH_FREQUENCY_NO;
  1115. /* Check parameter */
  1116. assert_param(IS_LL_RCC_DSI_CLKSOURCE(DSIxSource));
  1117. /* DSICLK clock frequency */
  1118. switch (LL_RCC_GetDSIClockSource(DSIxSource))
  1119. {
  1120. case LL_RCC_DSI_CLKSOURCE_PLL: /* DSI Clock is PLLSAI2 Osc. */
  1121. if (LL_RCC_PLLSAI2_IsReady())
  1122. {
  1123. dsi_frequency = RCC_PLLSAI2_GetFreqDomain_DSI();
  1124. }
  1125. break;
  1126. case LL_RCC_DSI_CLKSOURCE_PHY: /* DSI Clock is DSI physical clock. */
  1127. default:
  1128. dsi_frequency = LL_RCC_PERIPH_FREQUENCY_NA;
  1129. break;
  1130. }
  1131. return dsi_frequency;
  1132. }
  1133. #endif /* DSI */
  1134. #if defined(LTDC)
  1135. /**
  1136. * @brief Return LTDC clock frequency
  1137. * @param LTDCxSource This parameter can be one of the following values:
  1138. * @arg @ref LL_RCC_LTDC_CLKSOURCE
  1139. * @retval LTDC clock frequency (in Hz)
  1140. * - @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillator PLLSAI is not ready
  1141. */
  1142. uint32_t LL_RCC_GetLTDCClockFreq(uint32_t LTDCxSource)
  1143. {
  1144. uint32_t ltdc_frequency = LL_RCC_PERIPH_FREQUENCY_NO;
  1145. /* Check parameter */
  1146. assert_param(IS_LL_RCC_LTDC_CLKSOURCE(LTDCxSource));
  1147. if (LL_RCC_PLLSAI2_IsReady())
  1148. {
  1149. ltdc_frequency = RCC_PLLSAI2_GetFreqDomain_LTDC();
  1150. }
  1151. return ltdc_frequency;
  1152. }
  1153. #endif /* LTDC */
  1154. #if defined(OCTOSPI1)
  1155. /**
  1156. * @brief Return OCTOSPI clock frequency
  1157. * @param OCTOSPIxSource This parameter can be one of the following values:
  1158. * @arg @ref LL_RCC_OCTOSPI_CLKSOURCE
  1159. * @retval OCTOSPI clock frequency (in Hz)
  1160. * - @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillator PLLSAI is not ready
  1161. */
  1162. uint32_t LL_RCC_GetOCTOSPIClockFreq(uint32_t OCTOSPIxSource)
  1163. {
  1164. uint32_t octospi_frequency = LL_RCC_PERIPH_FREQUENCY_NO;
  1165. /* Check parameter */
  1166. assert_param(IS_LL_RCC_OCTOSPI_CLKSOURCE(OCTOSPIxSource));
  1167. /* OCTOSPI clock frequency */
  1168. switch (LL_RCC_GetOCTOSPIClockSource(OCTOSPIxSource))
  1169. {
  1170. case LL_RCC_OCTOSPI_CLKSOURCE_SYSCLK: /* OCTOSPI clock is SYSCLK */
  1171. octospi_frequency = RCC_GetSystemClockFreq();
  1172. break;
  1173. case LL_RCC_OCTOSPI_CLKSOURCE_MSI: /* MSI clock used as OCTOSPI clock */
  1174. if (LL_RCC_MSI_IsReady())
  1175. {
  1176. octospi_frequency = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
  1177. (LL_RCC_MSI_IsEnabledRangeSelect() ?
  1178. LL_RCC_MSI_GetRange() :
  1179. LL_RCC_MSI_GetRangeAfterStandby()));
  1180. }
  1181. break;
  1182. case LL_RCC_OCTOSPI_CLKSOURCE_PLL: /* PLL clock used as OCTOSPI source */
  1183. if (LL_RCC_PLL_IsReady())
  1184. {
  1185. octospi_frequency = RCC_PLL_GetFreqDomain_48M();
  1186. }
  1187. break;
  1188. default:
  1189. octospi_frequency = LL_RCC_PERIPH_FREQUENCY_NO;
  1190. break;
  1191. }
  1192. return octospi_frequency;
  1193. }
  1194. #endif /* OCTOSPI1 */
  1195. /**
  1196. * @}
  1197. */
  1198. /**
  1199. * @}
  1200. */
  1201. /** @addtogroup RCC_LL_Private_Functions
  1202. * @{
  1203. */
  1204. /**
  1205. * @brief Return SYSTEM clock frequency
  1206. * @retval SYSTEM clock frequency (in Hz)
  1207. */
  1208. uint32_t RCC_GetSystemClockFreq(void)
  1209. {
  1210. uint32_t frequency = 0U;
  1211. /* Get SYSCLK source -------------------------------------------------------*/
  1212. switch (LL_RCC_GetSysClkSource())
  1213. {
  1214. case LL_RCC_SYS_CLKSOURCE_STATUS_MSI: /* MSI used as system clock source */
  1215. frequency = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
  1216. (LL_RCC_MSI_IsEnabledRangeSelect() ?
  1217. LL_RCC_MSI_GetRange() :
  1218. LL_RCC_MSI_GetRangeAfterStandby()));
  1219. break;
  1220. case LL_RCC_SYS_CLKSOURCE_STATUS_HSI: /* HSI used as system clock source */
  1221. frequency = HSI_VALUE;
  1222. break;
  1223. case LL_RCC_SYS_CLKSOURCE_STATUS_HSE: /* HSE used as system clock source */
  1224. frequency = HSE_VALUE;
  1225. break;
  1226. case LL_RCC_SYS_CLKSOURCE_STATUS_PLL: /* PLL used as system clock source */
  1227. frequency = RCC_PLL_GetFreqDomain_SYS();
  1228. break;
  1229. default:
  1230. frequency = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
  1231. (LL_RCC_MSI_IsEnabledRangeSelect() ?
  1232. LL_RCC_MSI_GetRange() :
  1233. LL_RCC_MSI_GetRangeAfterStandby()));
  1234. break;
  1235. }
  1236. return frequency;
  1237. }
  1238. /**
  1239. * @brief Return HCLK clock frequency
  1240. * @param SYSCLK_Frequency SYSCLK clock frequency
  1241. * @retval HCLK clock frequency (in Hz)
  1242. */
  1243. uint32_t RCC_GetHCLKClockFreq(uint32_t SYSCLK_Frequency)
  1244. {
  1245. /* HCLK clock frequency */
  1246. return __LL_RCC_CALC_HCLK_FREQ(SYSCLK_Frequency, LL_RCC_GetAHBPrescaler());
  1247. }
  1248. /**
  1249. * @brief Return PCLK1 clock frequency
  1250. * @param HCLK_Frequency HCLK clock frequency
  1251. * @retval PCLK1 clock frequency (in Hz)
  1252. */
  1253. uint32_t RCC_GetPCLK1ClockFreq(uint32_t HCLK_Frequency)
  1254. {
  1255. /* PCLK1 clock frequency */
  1256. return __LL_RCC_CALC_PCLK1_FREQ(HCLK_Frequency, LL_RCC_GetAPB1Prescaler());
  1257. }
  1258. /**
  1259. * @brief Return PCLK2 clock frequency
  1260. * @param HCLK_Frequency HCLK clock frequency
  1261. * @retval PCLK2 clock frequency (in Hz)
  1262. */
  1263. uint32_t RCC_GetPCLK2ClockFreq(uint32_t HCLK_Frequency)
  1264. {
  1265. /* PCLK2 clock frequency */
  1266. return __LL_RCC_CALC_PCLK2_FREQ(HCLK_Frequency, LL_RCC_GetAPB2Prescaler());
  1267. }
  1268. /**
  1269. * @brief Return PLL clock frequency used for system domain
  1270. * @retval PLL clock frequency (in Hz)
  1271. */
  1272. uint32_t RCC_PLL_GetFreqDomain_SYS(void)
  1273. {
  1274. uint32_t pllinputfreq = 0U, pllsource = 0U;
  1275. /* PLL_VCO = (HSE_VALUE or HSI_VALUE or MSI_VALUE/ PLLM) * PLLN
  1276. SYSCLK = PLL_VCO / PLLR
  1277. */
  1278. pllsource = LL_RCC_PLL_GetMainSource();
  1279. switch (pllsource)
  1280. {
  1281. case LL_RCC_PLLSOURCE_MSI: /* MSI used as PLL clock source */
  1282. pllinputfreq = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
  1283. (LL_RCC_MSI_IsEnabledRangeSelect() ?
  1284. LL_RCC_MSI_GetRange() :
  1285. LL_RCC_MSI_GetRangeAfterStandby()));
  1286. break;
  1287. case LL_RCC_PLLSOURCE_HSI: /* HSI used as PLL clock source */
  1288. pllinputfreq = HSI_VALUE;
  1289. break;
  1290. case LL_RCC_PLLSOURCE_HSE: /* HSE used as PLL clock source */
  1291. pllinputfreq = HSE_VALUE;
  1292. break;
  1293. default:
  1294. pllinputfreq = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
  1295. (LL_RCC_MSI_IsEnabledRangeSelect() ?
  1296. LL_RCC_MSI_GetRange() :
  1297. LL_RCC_MSI_GetRangeAfterStandby()));
  1298. break;
  1299. }
  1300. return __LL_RCC_CALC_PLLCLK_FREQ(pllinputfreq, LL_RCC_PLL_GetDivider(),
  1301. LL_RCC_PLL_GetN(), LL_RCC_PLL_GetR());
  1302. }
  1303. /**
  1304. * @brief Return PLL clock frequency used for SAI domain
  1305. * @retval PLL clock frequency (in Hz)
  1306. */
  1307. uint32_t RCC_PLL_GetFreqDomain_SAI(void)
  1308. {
  1309. uint32_t pllinputfreq = 0U, pllsource = 0U;
  1310. /* PLL_VCO = (HSE_VALUE or HSI_VALUE or MSI_VALUE / PLLM) * PLLN
  1311. SAI Domain clock = PLL_VCO / PLLP
  1312. */
  1313. pllsource = LL_RCC_PLL_GetMainSource();
  1314. switch (pllsource)
  1315. {
  1316. case LL_RCC_PLLSOURCE_MSI: /* MSI used as PLL clock source */
  1317. pllinputfreq = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
  1318. (LL_RCC_MSI_IsEnabledRangeSelect() ?
  1319. LL_RCC_MSI_GetRange() :
  1320. LL_RCC_MSI_GetRangeAfterStandby()));
  1321. break;
  1322. case LL_RCC_PLLSOURCE_HSI: /* HSI used as PLL clock source */
  1323. pllinputfreq = HSI_VALUE;
  1324. break;
  1325. case LL_RCC_PLLSOURCE_HSE: /* HSE used as PLL clock source */
  1326. pllinputfreq = HSE_VALUE;
  1327. break;
  1328. default:
  1329. pllinputfreq = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
  1330. (LL_RCC_MSI_IsEnabledRangeSelect() ?
  1331. LL_RCC_MSI_GetRange() :
  1332. LL_RCC_MSI_GetRangeAfterStandby()));
  1333. break;
  1334. }
  1335. return __LL_RCC_CALC_PLLCLK_SAI_FREQ(pllinputfreq, LL_RCC_PLL_GetDivider(),
  1336. LL_RCC_PLL_GetN(), LL_RCC_PLL_GetP());
  1337. }
  1338. /**
  1339. * @brief Return PLL clock frequency used for 48 MHz domain
  1340. * @retval PLL clock frequency (in Hz)
  1341. */
  1342. uint32_t RCC_PLL_GetFreqDomain_48M(void)
  1343. {
  1344. uint32_t pllinputfreq = 0U, pllsource = 0U;
  1345. /* PLL_VCO = (HSE_VALUE or HSI_VALUE or MSI_VALUE/ PLLM) * PLLN
  1346. 48M Domain clock = PLL_VCO / PLLQ
  1347. */
  1348. pllsource = LL_RCC_PLL_GetMainSource();
  1349. switch (pllsource)
  1350. {
  1351. case LL_RCC_PLLSOURCE_MSI: /* MSI used as PLL clock source */
  1352. pllinputfreq = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
  1353. (LL_RCC_MSI_IsEnabledRangeSelect() ?
  1354. LL_RCC_MSI_GetRange() :
  1355. LL_RCC_MSI_GetRangeAfterStandby()));
  1356. break;
  1357. case LL_RCC_PLLSOURCE_HSI: /* HSI used as PLL clock source */
  1358. pllinputfreq = HSI_VALUE;
  1359. break;
  1360. case LL_RCC_PLLSOURCE_HSE: /* HSE used as PLL clock source */
  1361. pllinputfreq = HSE_VALUE;
  1362. break;
  1363. default:
  1364. pllinputfreq = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
  1365. (LL_RCC_MSI_IsEnabledRangeSelect() ?
  1366. LL_RCC_MSI_GetRange() :
  1367. LL_RCC_MSI_GetRangeAfterStandby()));
  1368. break;
  1369. }
  1370. return __LL_RCC_CALC_PLLCLK_48M_FREQ(pllinputfreq, LL_RCC_PLL_GetDivider(),
  1371. LL_RCC_PLL_GetN(), LL_RCC_PLL_GetQ());
  1372. }
  1373. #if defined(DSI)
  1374. /**
  1375. * @brief Return PLL clock frequency used for DSI clock
  1376. * @retval PLL clock frequency (in Hz)
  1377. */
  1378. uint32_t RCC_PLLSAI2_GetFreqDomain_DSI(void)
  1379. {
  1380. uint32_t pllinputfreq = 0U, pllsource = 0U;
  1381. /* PLLSAI2_VCO = (HSE_VALUE or HSI_VALUE or MSI_VALUE/ PLLSAI2M) * PLLSAI2N */
  1382. /* DSICLK = PLLSAI2_VCO / PLLSAI2R */
  1383. pllsource = LL_RCC_PLL_GetMainSource();
  1384. switch (pllsource)
  1385. {
  1386. case LL_RCC_PLLSOURCE_MSI: /* MSI used as PLLSAI2 clock source */
  1387. pllinputfreq = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
  1388. (LL_RCC_MSI_IsEnabledRangeSelect() ?
  1389. LL_RCC_MSI_GetRange() :
  1390. LL_RCC_MSI_GetRangeAfterStandby()));
  1391. break;
  1392. case LL_RCC_PLLSOURCE_HSI: /* HSI used as PLLSAI2 clock source */
  1393. pllinputfreq = HSI_VALUE;
  1394. break;
  1395. case LL_RCC_PLLSOURCE_HSE: /* HSE used as PLLSAI2 clock source */
  1396. pllinputfreq = HSE_VALUE;
  1397. break;
  1398. default:
  1399. pllinputfreq = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
  1400. (LL_RCC_MSI_IsEnabledRangeSelect() ?
  1401. LL_RCC_MSI_GetRange() :
  1402. LL_RCC_MSI_GetRangeAfterStandby()));
  1403. break;
  1404. }
  1405. return __LL_RCC_CALC_PLLSAI2_DSI_FREQ(pllinputfreq, LL_RCC_PLLSAI2_GetDivider(),
  1406. LL_RCC_PLLSAI2_GetN(), LL_RCC_PLLSAI2_GetR());
  1407. }
  1408. #endif /* DSI */
  1409. /**
  1410. * @brief Return PLLSAI1 clock frequency used for SAI domain
  1411. * @retval PLLSAI1 clock frequency (in Hz)
  1412. */
  1413. uint32_t RCC_PLLSAI1_GetFreqDomain_SAI(void)
  1414. {
  1415. uint32_t pllinputfreq = 0U, pllsource = 0U;
  1416. #if defined(RCC_PLLSAI2M_DIV_1_16_SUPPORT)
  1417. /* PLLSAI1_VCO = (HSE_VALUE or HSI_VALUE or MSI_VALUE/ PLLSAI1M) * PLLSAI1N */
  1418. #else
  1419. /* PLLSAI1_VCO = (HSE_VALUE or HSI_VALUE or MSI_VALUE/ PLLM) * PLLSAI1N */
  1420. #endif
  1421. /* SAI Domain clock = PLLSAI1_VCO / PLLSAI1P */
  1422. pllsource = LL_RCC_PLL_GetMainSource();
  1423. switch (pllsource)
  1424. {
  1425. case LL_RCC_PLLSOURCE_MSI: /* MSI used as PLLSAI1 clock source */
  1426. pllinputfreq = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
  1427. (LL_RCC_MSI_IsEnabledRangeSelect() ?
  1428. LL_RCC_MSI_GetRange() :
  1429. LL_RCC_MSI_GetRangeAfterStandby()));
  1430. break;
  1431. case LL_RCC_PLLSOURCE_HSI: /* HSI used as PLLSAI1 clock source */
  1432. pllinputfreq = HSI_VALUE;
  1433. break;
  1434. case LL_RCC_PLLSOURCE_HSE: /* HSE used as PLLSAI1 clock source */
  1435. pllinputfreq = HSE_VALUE;
  1436. break;
  1437. default:
  1438. pllinputfreq = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
  1439. (LL_RCC_MSI_IsEnabledRangeSelect() ?
  1440. LL_RCC_MSI_GetRange() :
  1441. LL_RCC_MSI_GetRangeAfterStandby()));
  1442. break;
  1443. }
  1444. return __LL_RCC_CALC_PLLSAI1_SAI_FREQ(pllinputfreq, LL_RCC_PLL_GetDivider(),
  1445. LL_RCC_PLLSAI1_GetN(), LL_RCC_PLLSAI1_GetP());
  1446. }
  1447. /**
  1448. * @brief Return PLLSAI1 clock frequency used for 48Mhz domain
  1449. * @retval PLLSAI1 clock frequency (in Hz)
  1450. */
  1451. uint32_t RCC_PLLSAI1_GetFreqDomain_48M(void)
  1452. {
  1453. uint32_t pllinputfreq = 0U, pllsource = 0U;
  1454. #if defined(RCC_PLLSAI2M_DIV_1_16_SUPPORT)
  1455. /* PLLSAI1_VCO = (HSE_VALUE or HSI_VALUE or MSI_VALUE/ PLLSAI1M) * PLLSAI1N */
  1456. #else
  1457. /* PLLSAI1_VCO = (HSE_VALUE or HSI_VALUE or MSI_VALUE/ PLLM) * PLLSAI1N */
  1458. #endif
  1459. /* 48M Domain clock = PLLSAI1_VCO / PLLSAI1Q */
  1460. pllsource = LL_RCC_PLL_GetMainSource();
  1461. switch (pllsource)
  1462. {
  1463. case LL_RCC_PLLSOURCE_MSI: /* MSI used as PLLSAI1 clock source */
  1464. pllinputfreq = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
  1465. (LL_RCC_MSI_IsEnabledRangeSelect() ?
  1466. LL_RCC_MSI_GetRange() :
  1467. LL_RCC_MSI_GetRangeAfterStandby()));
  1468. break;
  1469. case LL_RCC_PLLSOURCE_HSI: /* HSI used as PLLSAI1 clock source */
  1470. pllinputfreq = HSI_VALUE;
  1471. break;
  1472. case LL_RCC_PLLSOURCE_HSE: /* HSE used as PLLSAI1 clock source */
  1473. pllinputfreq = HSE_VALUE;
  1474. break;
  1475. default:
  1476. pllinputfreq = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
  1477. (LL_RCC_MSI_IsEnabledRangeSelect() ?
  1478. LL_RCC_MSI_GetRange() :
  1479. LL_RCC_MSI_GetRangeAfterStandby()));
  1480. break;
  1481. }
  1482. return __LL_RCC_CALC_PLLSAI1_48M_FREQ(pllinputfreq, LL_RCC_PLL_GetDivider(),
  1483. LL_RCC_PLLSAI1_GetN(), LL_RCC_PLLSAI1_GetQ());
  1484. }
  1485. /**
  1486. * @brief Return PLLSAI1 clock frequency used for ADC domain
  1487. * @retval PLLSAI1 clock frequency (in Hz)
  1488. */
  1489. uint32_t RCC_PLLSAI1_GetFreqDomain_ADC(void)
  1490. {
  1491. uint32_t pllinputfreq = 0U, pllsource = 0U;
  1492. #if defined(RCC_PLLSAI2M_DIV_1_16_SUPPORT)
  1493. /* PLLSAI1_VCO = (HSE_VALUE or HSI_VALUE or MSI_VALUE/ PLLSAI1M) * PLLSAI1N */
  1494. #else
  1495. /* PLLSAI1_VCO = (HSE_VALUE or HSI_VALUE or MSI_VALUE/ PLLM) * PLLSAI1N */
  1496. #endif
  1497. /* 48M Domain clock = PLLSAI1_VCO / PLLSAI1R */
  1498. pllsource = LL_RCC_PLL_GetMainSource();
  1499. switch (pllsource)
  1500. {
  1501. case LL_RCC_PLLSOURCE_MSI: /* MSI used as PLLSAI1 clock source */
  1502. pllinputfreq = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
  1503. (LL_RCC_MSI_IsEnabledRangeSelect() ?
  1504. LL_RCC_MSI_GetRange() :
  1505. LL_RCC_MSI_GetRangeAfterStandby()));
  1506. break;
  1507. case LL_RCC_PLLSOURCE_HSI: /* HSI used as PLLSAI1 clock source */
  1508. pllinputfreq = HSI_VALUE;
  1509. break;
  1510. case LL_RCC_PLLSOURCE_HSE: /* HSE used as PLLSAI1 clock source */
  1511. pllinputfreq = HSE_VALUE;
  1512. break;
  1513. default:
  1514. pllinputfreq = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
  1515. (LL_RCC_MSI_IsEnabledRangeSelect() ?
  1516. LL_RCC_MSI_GetRange() :
  1517. LL_RCC_MSI_GetRangeAfterStandby()));
  1518. break;
  1519. }
  1520. return __LL_RCC_CALC_PLLSAI1_ADC_FREQ(pllinputfreq, LL_RCC_PLL_GetDivider(),
  1521. LL_RCC_PLLSAI1_GetN(), LL_RCC_PLLSAI1_GetR());
  1522. }
  1523. #if defined(RCC_PLLSAI2_SUPPORT)
  1524. /**
  1525. * @brief Return PLLSAI2 clock frequency used for SAI domain
  1526. * @retval PLLSAI2 clock frequency (in Hz)
  1527. */
  1528. uint32_t RCC_PLLSAI2_GetFreqDomain_SAI(void)
  1529. {
  1530. uint32_t pllinputfreq = 0U, pllsource = 0U;
  1531. #if defined(RCC_PLLSAI2M_DIV_1_16_SUPPORT)
  1532. /* PLLSAI2_VCO = (HSE_VALUE or HSI_VALUE or MSI_VALUE/ PLLSAI2M) * PLLSAI2N */
  1533. #else
  1534. /* PLLSAI2_VCO = (HSE_VALUE or HSI_VALUE or MSI_VALUE/ PLLM) * PLLSAI2N */
  1535. #endif
  1536. /* SAI Domain clock = PLLSAI2_VCO / PLLSAI2P */
  1537. pllsource = LL_RCC_PLL_GetMainSource();
  1538. switch (pllsource)
  1539. {
  1540. case LL_RCC_PLLSOURCE_MSI: /* MSI used as PLLSAI2 clock source */
  1541. pllinputfreq = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
  1542. (LL_RCC_MSI_IsEnabledRangeSelect() ?
  1543. LL_RCC_MSI_GetRange() :
  1544. LL_RCC_MSI_GetRangeAfterStandby()));
  1545. break;
  1546. case LL_RCC_PLLSOURCE_HSI: /* HSI used as PLLSAI2 clock source */
  1547. pllinputfreq = HSI_VALUE;
  1548. break;
  1549. case LL_RCC_PLLSOURCE_HSE: /* HSE used as PLLSAI2 clock source */
  1550. pllinputfreq = HSE_VALUE;
  1551. break;
  1552. default:
  1553. pllinputfreq = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
  1554. (LL_RCC_MSI_IsEnabledRangeSelect() ?
  1555. LL_RCC_MSI_GetRange() :
  1556. LL_RCC_MSI_GetRangeAfterStandby()));
  1557. break;
  1558. }
  1559. #if defined(RCC_PLLSAI2M_DIV_1_16_SUPPORT)
  1560. return __LL_RCC_CALC_PLLSAI2_SAI_FREQ(pllinputfreq, LL_RCC_PLLSAI2_GetDivider(),
  1561. LL_RCC_PLLSAI2_GetN(), LL_RCC_PLLSAI2_GetP());
  1562. #else
  1563. return __LL_RCC_CALC_PLLSAI2_SAI_FREQ(pllinputfreq, LL_RCC_PLL_GetDivider(),
  1564. LL_RCC_PLLSAI2_GetN(), LL_RCC_PLLSAI2_GetP());
  1565. #endif
  1566. }
  1567. #if defined(LTDC)
  1568. /**
  1569. * @brief Return PLLSAI2 clock frequency used for LTDC domain
  1570. * @retval PLLSAI2 clock frequency (in Hz)
  1571. */
  1572. uint32_t RCC_PLLSAI2_GetFreqDomain_LTDC(void)
  1573. {
  1574. uint32_t pllinputfreq = 0U, pllsource = 0U;
  1575. /* PLLSAI2_VCO = (HSE_VALUE or HSI_VALUE or MSI_VALUE/ PLLSAI2M) * PLLSAI2N */
  1576. /* LTDC Domain clock = (PLLSAI2_VCO / PLLSAI2R) / PLLSAI2DIVR */
  1577. pllsource = LL_RCC_PLL_GetMainSource();
  1578. switch (pllsource)
  1579. {
  1580. case LL_RCC_PLLSOURCE_MSI: /* MSI used as PLLSAI2 clock source */
  1581. pllinputfreq = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
  1582. (LL_RCC_MSI_IsEnabledRangeSelect() ?
  1583. LL_RCC_MSI_GetRange() :
  1584. LL_RCC_MSI_GetRangeAfterStandby()));
  1585. break;
  1586. case LL_RCC_PLLSOURCE_HSI: /* HSI used as PLLSAI2 clock source */
  1587. pllinputfreq = HSI_VALUE;
  1588. break;
  1589. case LL_RCC_PLLSOURCE_HSE: /* HSE used as PLLSAI2 clock source */
  1590. pllinputfreq = HSE_VALUE;
  1591. break;
  1592. default:
  1593. pllinputfreq = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
  1594. (LL_RCC_MSI_IsEnabledRangeSelect() ?
  1595. LL_RCC_MSI_GetRange() :
  1596. LL_RCC_MSI_GetRangeAfterStandby()));
  1597. break;
  1598. }
  1599. return __LL_RCC_CALC_PLLSAI2_LTDC_FREQ(pllinputfreq, LL_RCC_PLLSAI2_GetDivider(),
  1600. LL_RCC_PLLSAI2_GetN(), LL_RCC_PLLSAI2_GetR(), LL_RCC_PLLSAI2_GetDIVR());
  1601. }
  1602. #else
  1603. /**
  1604. * @brief Return PLLSAI2 clock frequency used for ADC domain
  1605. * @retval PLLSAI2 clock frequency (in Hz)
  1606. */
  1607. uint32_t RCC_PLLSAI2_GetFreqDomain_ADC(void)
  1608. {
  1609. uint32_t pllinputfreq = 0U, pllsource = 0U;
  1610. /* PLLSAI2_VCO = (HSE_VALUE or HSI_VALUE or MSI_VALUE/ PLLM) * PLLSAI2N */
  1611. /* 48M Domain clock = PLLSAI2_VCO / PLLSAI2R */
  1612. pllsource = LL_RCC_PLL_GetMainSource();
  1613. switch (pllsource)
  1614. {
  1615. case LL_RCC_PLLSOURCE_MSI: /* MSI used as PLLSAI2 clock source */
  1616. pllinputfreq = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
  1617. (LL_RCC_MSI_IsEnabledRangeSelect() ?
  1618. LL_RCC_MSI_GetRange() :
  1619. LL_RCC_MSI_GetRangeAfterStandby()));
  1620. break;
  1621. case LL_RCC_PLLSOURCE_HSI: /* HSI used as PLLSAI2 clock source */
  1622. pllinputfreq = HSI_VALUE;
  1623. break;
  1624. case LL_RCC_PLLSOURCE_HSE: /* HSE used as PLLSAI2 clock source */
  1625. pllinputfreq = HSE_VALUE;
  1626. break;
  1627. default:
  1628. pllinputfreq = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
  1629. (LL_RCC_MSI_IsEnabledRangeSelect() ?
  1630. LL_RCC_MSI_GetRange() :
  1631. LL_RCC_MSI_GetRangeAfterStandby()));
  1632. break;
  1633. }
  1634. return __LL_RCC_CALC_PLLSAI2_ADC_FREQ(pllinputfreq, LL_RCC_PLL_GetDivider(),
  1635. LL_RCC_PLLSAI2_GetN(), LL_RCC_PLLSAI2_GetR());
  1636. }
  1637. #endif /* LTDC */
  1638. #endif /*RCC_PLLSAI2_SUPPORT*/
  1639. /**
  1640. * @}
  1641. */
  1642. /**
  1643. * @}
  1644. */
  1645. #endif /* defined(RCC) */
  1646. /**
  1647. * @}
  1648. */
  1649. #endif /* USE_FULL_LL_DRIVER */
  1650. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/