123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917 |
- /**
- ******************************************************************************
- * @file stm32l4xx_ll_rcc.c
- * @author MCD Application Team
- * @brief RCC LL module driver.
- ******************************************************************************
- * @attention
- *
- * <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of STMicroelectronics nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ******************************************************************************
- */
- #if defined(USE_FULL_LL_DRIVER)
- /* Includes ------------------------------------------------------------------*/
- #include "stm32l4xx_ll_rcc.h"
- #ifdef USE_FULL_ASSERT
- #include "stm32_assert.h"
- #else
- #define assert_param(expr) ((void)0U)
- #endif
- /** @addtogroup STM32L4xx_LL_Driver
- * @{
- */
- #if defined(RCC)
- /** @addtogroup RCC_LL
- * @{
- */
- /* Private types -------------------------------------------------------------*/
- /* Private variables ---------------------------------------------------------*/
- /* Private constants ---------------------------------------------------------*/
- /* Private macros ------------------------------------------------------------*/
- /** @addtogroup RCC_LL_Private_Macros
- * @{
- */
- #if defined(RCC_CCIPR_USART3SEL)
- #define IS_LL_RCC_USART_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_USART1_CLKSOURCE) \
- || ((__VALUE__) == LL_RCC_USART2_CLKSOURCE) \
- || ((__VALUE__) == LL_RCC_USART3_CLKSOURCE))
- #else
- #define IS_LL_RCC_USART_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_USART1_CLKSOURCE) \
- || ((__VALUE__) == LL_RCC_USART2_CLKSOURCE))
- #endif /* RCC_CCIPR_USART3SEL */
- #if defined(RCC_CCIPR_UART4SEL) && defined(RCC_CCIPR_UART5SEL)
- #define IS_LL_RCC_UART_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_UART4_CLKSOURCE) \
- || ((__VALUE__) == LL_RCC_UART5_CLKSOURCE))
- #elif defined(RCC_CCIPR_UART4SEL)
- #define IS_LL_RCC_UART_CLKSOURCE(__VALUE__) ((__VALUE__) == LL_RCC_UART4_CLKSOURCE)
- #elif defined(RCC_CCIPR_UART5SEL)
- #define IS_LL_RCC_UART_CLKSOURCE(__VALUE__) ((__VALUE__) == LL_RCC_UART5_CLKSOURCE)
- #endif /* RCC_CCIPR_UART4SEL && RCC_CCIPR_UART5SEL*/
- #define IS_LL_RCC_LPUART_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_LPUART1_CLKSOURCE))
- #if defined(RCC_CCIPR_I2C2SEL) && defined(RCC_CCIPR_I2C3SEL) && defined(RCC_CCIPR2_I2C4SEL)
- #define IS_LL_RCC_I2C_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_I2C1_CLKSOURCE) \
- || ((__VALUE__) == LL_RCC_I2C2_CLKSOURCE) \
- || ((__VALUE__) == LL_RCC_I2C3_CLKSOURCE) \
- || ((__VALUE__) == LL_RCC_I2C4_CLKSOURCE))
- #elif defined(RCC_CCIPR_I2C2SEL) && defined(RCC_CCIPR_I2C3SEL)
- #define IS_LL_RCC_I2C_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_I2C1_CLKSOURCE) \
- || ((__VALUE__) == LL_RCC_I2C2_CLKSOURCE) \
- || ((__VALUE__) == LL_RCC_I2C3_CLKSOURCE))
- #elif !defined(RCC_CCIPR_I2C2SEL) && defined(RCC_CCIPR_I2C3SEL)
- #define IS_LL_RCC_I2C_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_I2C1_CLKSOURCE) \
- || ((__VALUE__) == LL_RCC_I2C3_CLKSOURCE))
- #else
- #define IS_LL_RCC_I2C_CLKSOURCE(__VALUE__) ((__VALUE__) == LL_RCC_I2C1_CLKSOURCE)
- #endif /* RCC_CCIPR_I2C2SEL && RCC_CCIPR_I2C3SEL && RCC_CCIPR2_I2C4SEL */
- #define IS_LL_RCC_LPTIM_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_LPTIM1_CLKSOURCE) \
- || ((__VALUE__) == LL_RCC_LPTIM2_CLKSOURCE))
- #if defined(RCC_CCIPR_SAI2SEL)
- #define IS_LL_RCC_SAI_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_SAI1_CLKSOURCE) \
- || ((__VALUE__) == LL_RCC_SAI2_CLKSOURCE))
- #else
- #define IS_LL_RCC_SAI_CLKSOURCE(__VALUE__) ((__VALUE__) == LL_RCC_SAI1_CLKSOURCE)
- #endif /* RCC_CCIPR_SAI2SEL */
- #if defined(RCC_CCIPR2_SDMMCSEL)
- #define IS_LL_RCC_SDMMC_KERNELCLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_SDMMC1_KERNELCLKSOURCE))
- #endif /* RCC_CCIPR2_SDMMCSEL */
- #define IS_LL_RCC_SDMMC_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_SDMMC1_CLKSOURCE))
- #define IS_LL_RCC_RNG_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_RNG_CLKSOURCE))
- #if defined(USB_OTG_FS) || defined(USB)
- #define IS_LL_RCC_USB_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_USB_CLKSOURCE))
- #endif /* USB_OTG_FS || USB */
- #define IS_LL_RCC_ADC_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_ADC_CLKSOURCE))
- #if defined(SWPMI1)
- #define IS_LL_RCC_SWPMI_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_SWPMI1_CLKSOURCE))
- #endif /* SWPMI1 */
- #if defined(DFSDM1_Channel0)
- #define IS_LL_RCC_DFSDM_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_DFSDM1_CLKSOURCE))
- #if defined(RCC_CCIPR2_DFSDM1SEL)
- #define IS_LL_RCC_DFSDM_AUDIO_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_DFSDM1_AUDIO_CLKSOURCE))
- #endif /* RCC_CCIPR2_DFSDM1SEL */
- #endif /* DFSDM1_Channel0 */
- #if defined(DSI)
- #define IS_LL_RCC_DSI_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_DSI_CLKSOURCE))
- #endif /* DSI */
- #if defined(LTDC)
- #define IS_LL_RCC_LTDC_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_LTDC_CLKSOURCE))
- #endif /* LTDC */
- #if defined(OCTOSPI1)
- #define IS_LL_RCC_OCTOSPI_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_OCTOSPI_CLKSOURCE))
- #endif /* OCTOSPI */
- /**
- * @}
- */
- /* Private function prototypes -----------------------------------------------*/
- /** @defgroup RCC_LL_Private_Functions RCC Private functions
- * @{
- */
- uint32_t RCC_GetSystemClockFreq(void);
- uint32_t RCC_GetHCLKClockFreq(uint32_t SYSCLK_Frequency);
- uint32_t RCC_GetPCLK1ClockFreq(uint32_t HCLK_Frequency);
- uint32_t RCC_GetPCLK2ClockFreq(uint32_t HCLK_Frequency);
- uint32_t RCC_PLL_GetFreqDomain_SYS(void);
- uint32_t RCC_PLL_GetFreqDomain_SAI(void);
- uint32_t RCC_PLL_GetFreqDomain_48M(void);
- uint32_t RCC_PLLSAI1_GetFreqDomain_SAI(void);
- uint32_t RCC_PLLSAI1_GetFreqDomain_48M(void);
- uint32_t RCC_PLLSAI1_GetFreqDomain_ADC(void);
- #if defined(RCC_PLLSAI2_SUPPORT)
- uint32_t RCC_PLLSAI2_GetFreqDomain_SAI(void);
- #if defined(LTDC)
- uint32_t RCC_PLLSAI2_GetFreqDomain_LTDC(void);
- #else
- uint32_t RCC_PLLSAI2_GetFreqDomain_ADC(void);
- #endif /* LTDC */
- #if defined(DSI)
- uint32_t RCC_PLLSAI2_GetFreqDomain_DSI(void);
- #endif /* DSI */
- #endif /*RCC_PLLSAI2_SUPPORT*/
- /**
- * @}
- */
- /* Exported functions --------------------------------------------------------*/
- /** @addtogroup RCC_LL_Exported_Functions
- * @{
- */
- /** @addtogroup RCC_LL_EF_Init
- * @{
- */
- /**
- * @brief Reset the RCC clock configuration to the default reset state.
- * @note The default reset state of the clock configuration is given below:
- * - MSI ON and used as system clock source
- * - HSE, HSI, PLL, PLLSAI1 and PLLSAI2 OFF
- * - AHB, APB1 and APB2 prescaler set to 1.
- * - CSS, MCO OFF
- * - All interrupts disabled
- * @note This function doesn't modify the configuration of the
- * - Peripheral clocks
- * - LSI, LSE and RTC clocks
- * @retval An ErrorStatus enumeration value:
- * - SUCCESS: RCC registers are de-initialized
- * - ERROR: not applicable
- */
- ErrorStatus LL_RCC_DeInit(void)
- {
- uint32_t vl_mask = 0U;
- /* Set MSION bit */
- LL_RCC_MSI_Enable();
- /* Insure MSIRDY bit is set before writing default MSIRANGE value */
- while (LL_RCC_MSI_IsReady() == 0U)
- {
- }
- /* Set MSIRANGE default value */
- LL_RCC_MSI_SetRange(LL_RCC_MSIRANGE_6);
- /* Set MSITRIM bits to the reset value*/
- LL_RCC_MSI_SetCalibTrimming(0);
- /* Set HSITRIM bits to the reset value*/
- LL_RCC_HSI_SetCalibTrimming(0x10U);
- /* Reset CFGR register */
- LL_RCC_WriteReg(CFGR, 0x00000000U);
- vl_mask = 0xFFFFFFFFU;
- /* Reset HSION, HSIKERON, HSIASFS, HSEON, PLLON bits */
- CLEAR_BIT(vl_mask, (RCC_CR_HSION | RCC_CR_HSIASFS | RCC_CR_HSIKERON | RCC_CR_HSEON |
- RCC_CR_PLLON));
- /* Reset PLLSAI1ON bit */
- CLEAR_BIT(vl_mask, RCC_CR_PLLSAI1ON);
- #if defined(RCC_PLLSAI2_SUPPORT)
- /* Reset PLLSAI2ON bit */
- CLEAR_BIT(vl_mask, RCC_CR_PLLSAI2ON);
- #endif /*RCC_PLLSAI2_SUPPORT*/
- /* Write new mask in CR register */
- LL_RCC_WriteReg(CR, vl_mask);
- #if defined(RCC_PLLSAI2_SUPPORT)
- /* Wait for PLLRDY, PLLSAI1RDY and PLLSAI2RDY bits to be reset */
- while(READ_BIT(RCC->CR, RCC_CR_PLLRDY | RCC_CR_PLLSAI1RDY | RCC_CR_PLLSAI2RDY) != 0U)
- {
- }
- #else
- /* Wait for PLLRDY, PLLSAI1RDY bits to be reset */
- while(READ_BIT(RCC->CR, RCC_CR_PLLRDY | RCC_CR_PLLSAI1RDY) != 0U)
- {
- }
- #endif
- /* Reset PLLCFGR register */
- LL_RCC_WriteReg(PLLCFGR, 16U << RCC_PLLCFGR_PLLN_Pos);
- /* Reset PLLSAI1CFGR register */
- LL_RCC_WriteReg(PLLSAI1CFGR, 16U << RCC_PLLSAI1CFGR_PLLSAI1N_Pos);
- #if defined(RCC_PLLSAI2_SUPPORT)
- /* Reset PLLSAI2CFGR register */
- LL_RCC_WriteReg(PLLSAI2CFGR, 16U << RCC_PLLSAI2CFGR_PLLSAI2N_Pos);
- #endif /*RCC_PLLSAI2_SUPPORT*/
- /* Reset HSEBYP bit */
- LL_RCC_HSE_DisableBypass();
- /* Disable all interrupts */
- LL_RCC_WriteReg(CIER, 0x00000000U);
- /* Clear all interrupt flags */
- vl_mask = RCC_CICR_LSIRDYC | RCC_CICR_LSERDYC | RCC_CICR_MSIRDYC | RCC_CICR_HSIRDYC | RCC_CICR_HSERDYC | RCC_CICR_PLLRDYC | \
- RCC_CICR_PLLSAI1RDYC | RCC_CICR_CSSC | RCC_CICR_LSECSSC;
- #if defined(RCC_HSI48_SUPPORT)
- vl_mask |= RCC_CICR_HSI48RDYC;
- #endif
- #if defined(RCC_PLLSAI2_SUPPORT)
- vl_mask |= RCC_CICR_PLLSAI2RDYC;
- #endif
- LL_RCC_WriteReg(CICR, vl_mask);
- /* Clear reset flags */
- LL_RCC_ClearResetFlags();
- return SUCCESS;
- }
- /**
- * @}
- */
- /** @addtogroup RCC_LL_EF_Get_Freq
- * @brief Return the frequencies of different on chip clocks; System, AHB, APB1 and APB2 buses clocks
- * and different peripheral clocks available on the device.
- * @note If SYSCLK source is MSI, function returns values based on MSI_VALUE(*)
- * @note If SYSCLK source is HSI, function returns values based on HSI_VALUE(**)
- * @note If SYSCLK source is HSE, function returns values based on HSE_VALUE(***)
- * @note If SYSCLK source is PLL, function returns values based on HSE_VALUE(***)
- * or HSI_VALUE(**) or MSI_VALUE(*) multiplied/divided by the PLL factors.
- * @note (*) MSI_VALUE is a constant defined in this file (default value
- * 4 MHz) but the real value may vary depending on the variations
- * in voltage and temperature.
- * @note (**) HSI_VALUE is a constant defined in this file (default value
- * 16 MHz) but the real value may vary depending on the variations
- * in voltage and temperature.
- * @note (***) HSE_VALUE is a constant defined in this file (default value
- * 8 MHz), user has to ensure that HSE_VALUE is same as the real
- * frequency of the crystal used. Otherwise, this function may
- * have wrong result.
- * @note The result of this function could be incorrect when using fractional
- * value for HSE crystal.
- * @note This function can be used by the user application to compute the
- * baud-rate for the communication peripherals or configure other parameters.
- * @{
- */
- /**
- * @brief Return the frequencies of different on chip clocks; System, AHB, APB1 and APB2 buses clocks
- * @note Each time SYSCLK, HCLK, PCLK1 and/or PCLK2 clock changes, this function
- * must be called to update structure fields. Otherwise, any
- * configuration based on this function will be incorrect.
- * @param RCC_Clocks pointer to a @ref LL_RCC_ClocksTypeDef structure which will hold the clocks frequencies
- * @retval None
- */
- void LL_RCC_GetSystemClocksFreq(LL_RCC_ClocksTypeDef *RCC_Clocks)
- {
- /* Get SYSCLK frequency */
- RCC_Clocks->SYSCLK_Frequency = RCC_GetSystemClockFreq();
- /* HCLK clock frequency */
- RCC_Clocks->HCLK_Frequency = RCC_GetHCLKClockFreq(RCC_Clocks->SYSCLK_Frequency);
- /* PCLK1 clock frequency */
- RCC_Clocks->PCLK1_Frequency = RCC_GetPCLK1ClockFreq(RCC_Clocks->HCLK_Frequency);
- /* PCLK2 clock frequency */
- RCC_Clocks->PCLK2_Frequency = RCC_GetPCLK2ClockFreq(RCC_Clocks->HCLK_Frequency);
- }
- /**
- * @brief Return USARTx clock frequency
- * @param USARTxSource This parameter can be one of the following values:
- * @arg @ref LL_RCC_USART1_CLKSOURCE
- * @arg @ref LL_RCC_USART2_CLKSOURCE
- * @arg @ref LL_RCC_USART3_CLKSOURCE (*)
- *
- * (*) value not defined in all devices.
- * @retval USART clock frequency (in Hz)
- * - @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillator (HSI or LSE) is not ready
- */
- uint32_t LL_RCC_GetUSARTClockFreq(uint32_t USARTxSource)
- {
- uint32_t usart_frequency = LL_RCC_PERIPH_FREQUENCY_NO;
- /* Check parameter */
- assert_param(IS_LL_RCC_USART_CLKSOURCE(USARTxSource));
- if (USARTxSource == LL_RCC_USART1_CLKSOURCE)
- {
- /* USART1CLK clock frequency */
- switch (LL_RCC_GetUSARTClockSource(USARTxSource))
- {
- case LL_RCC_USART1_CLKSOURCE_SYSCLK: /* USART1 Clock is System Clock */
- usart_frequency = RCC_GetSystemClockFreq();
- break;
- case LL_RCC_USART1_CLKSOURCE_HSI: /* USART1 Clock is HSI Osc. */
- if (LL_RCC_HSI_IsReady())
- {
- usart_frequency = HSI_VALUE;
- }
- break;
- case LL_RCC_USART1_CLKSOURCE_LSE: /* USART1 Clock is LSE Osc. */
- if (LL_RCC_LSE_IsReady())
- {
- usart_frequency = LSE_VALUE;
- }
- break;
- case LL_RCC_USART1_CLKSOURCE_PCLK2: /* USART1 Clock is PCLK2 */
- default:
- usart_frequency = RCC_GetPCLK2ClockFreq(RCC_GetHCLKClockFreq(RCC_GetSystemClockFreq()));
- break;
- }
- }
- else if (USARTxSource == LL_RCC_USART2_CLKSOURCE)
- {
- /* USART2CLK clock frequency */
- switch (LL_RCC_GetUSARTClockSource(USARTxSource))
- {
- case LL_RCC_USART2_CLKSOURCE_SYSCLK: /* USART2 Clock is System Clock */
- usart_frequency = RCC_GetSystemClockFreq();
- break;
- case LL_RCC_USART2_CLKSOURCE_HSI: /* USART2 Clock is HSI Osc. */
- if (LL_RCC_HSI_IsReady())
- {
- usart_frequency = HSI_VALUE;
- }
- break;
- case LL_RCC_USART2_CLKSOURCE_LSE: /* USART2 Clock is LSE Osc. */
- if (LL_RCC_LSE_IsReady())
- {
- usart_frequency = LSE_VALUE;
- }
- break;
- case LL_RCC_USART2_CLKSOURCE_PCLK1: /* USART2 Clock is PCLK1 */
- default:
- usart_frequency = RCC_GetPCLK1ClockFreq(RCC_GetHCLKClockFreq(RCC_GetSystemClockFreq()));
- break;
- }
- }
- else
- {
- #if defined(RCC_CCIPR_USART3SEL)
- if (USARTxSource == LL_RCC_USART3_CLKSOURCE)
- {
- /* USART3CLK clock frequency */
- switch (LL_RCC_GetUSARTClockSource(USARTxSource))
- {
- case LL_RCC_USART3_CLKSOURCE_SYSCLK: /* USART3 Clock is System Clock */
- usart_frequency = RCC_GetSystemClockFreq();
- break;
- case LL_RCC_USART3_CLKSOURCE_HSI: /* USART3 Clock is HSI Osc. */
- if (LL_RCC_HSI_IsReady())
- {
- usart_frequency = HSI_VALUE;
- }
- break;
- case LL_RCC_USART3_CLKSOURCE_LSE: /* USART3 Clock is LSE Osc. */
- if (LL_RCC_LSE_IsReady())
- {
- usart_frequency = LSE_VALUE;
- }
- break;
- case LL_RCC_USART3_CLKSOURCE_PCLK1: /* USART3 Clock is PCLK1 */
- default:
- usart_frequency = RCC_GetPCLK1ClockFreq(RCC_GetHCLKClockFreq(RCC_GetSystemClockFreq()));
- break;
- }
- }
- #endif /* RCC_CCIPR_USART3SEL */
- }
- return usart_frequency;
- }
- #if defined(RCC_CCIPR_UART4SEL) || defined(RCC_CCIPR_UART5SEL)
- /**
- * @brief Return UARTx clock frequency
- * @param UARTxSource This parameter can be one of the following values:
- * @arg @ref LL_RCC_UART4_CLKSOURCE
- * @arg @ref LL_RCC_UART5_CLKSOURCE
- * @retval UART clock frequency (in Hz)
- * - @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillator (HSI or LSE) is not ready
- */
- uint32_t LL_RCC_GetUARTClockFreq(uint32_t UARTxSource)
- {
- uint32_t uart_frequency = LL_RCC_PERIPH_FREQUENCY_NO;
- /* Check parameter */
- assert_param(IS_LL_RCC_UART_CLKSOURCE(UARTxSource));
- #if defined(RCC_CCIPR_UART4SEL)
- if (UARTxSource == LL_RCC_UART4_CLKSOURCE)
- {
- /* UART4CLK clock frequency */
- switch (LL_RCC_GetUARTClockSource(UARTxSource))
- {
- case LL_RCC_UART4_CLKSOURCE_SYSCLK: /* UART4 Clock is System Clock */
- uart_frequency = RCC_GetSystemClockFreq();
- break;
- case LL_RCC_UART4_CLKSOURCE_HSI: /* UART4 Clock is HSI Osc. */
- if (LL_RCC_HSI_IsReady())
- {
- uart_frequency = HSI_VALUE;
- }
- break;
- case LL_RCC_UART4_CLKSOURCE_LSE: /* UART4 Clock is LSE Osc. */
- if (LL_RCC_LSE_IsReady())
- {
- uart_frequency = LSE_VALUE;
- }
- break;
- case LL_RCC_UART4_CLKSOURCE_PCLK1: /* UART4 Clock is PCLK1 */
- default:
- uart_frequency = RCC_GetPCLK1ClockFreq(RCC_GetHCLKClockFreq(RCC_GetSystemClockFreq()));
- break;
- }
- }
- #endif /* RCC_CCIPR_UART4SEL */
- #if defined(RCC_CCIPR_UART5SEL)
- if (UARTxSource == LL_RCC_UART5_CLKSOURCE)
- {
- /* UART5CLK clock frequency */
- switch (LL_RCC_GetUARTClockSource(UARTxSource))
- {
- case LL_RCC_UART5_CLKSOURCE_SYSCLK: /* UART5 Clock is System Clock */
- uart_frequency = RCC_GetSystemClockFreq();
- break;
- case LL_RCC_UART5_CLKSOURCE_HSI: /* UART5 Clock is HSI Osc. */
- if (LL_RCC_HSI_IsReady())
- {
- uart_frequency = HSI_VALUE;
- }
- break;
- case LL_RCC_UART5_CLKSOURCE_LSE: /* UART5 Clock is LSE Osc. */
- if (LL_RCC_LSE_IsReady())
- {
- uart_frequency = LSE_VALUE;
- }
- break;
- case LL_RCC_UART5_CLKSOURCE_PCLK1: /* UART5 Clock is PCLK1 */
- default:
- uart_frequency = RCC_GetPCLK1ClockFreq(RCC_GetHCLKClockFreq(RCC_GetSystemClockFreq()));
- break;
- }
- }
- #endif /* RCC_CCIPR_UART5SEL */
- return uart_frequency;
- }
- #endif /* RCC_CCIPR_UART4SEL || RCC_CCIPR_UART5SEL */
- /**
- * @brief Return I2Cx clock frequency
- * @param I2CxSource This parameter can be one of the following values:
- * @arg @ref LL_RCC_I2C1_CLKSOURCE
- * @arg @ref LL_RCC_I2C2_CLKSOURCE (*)
- * @arg @ref LL_RCC_I2C3_CLKSOURCE
- * @arg @ref LL_RCC_I2C4_CLKSOURCE (*)
- *
- * (*) value not defined in all devices.
- * @retval I2C clock frequency (in Hz)
- * - @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that HSI oscillator is not ready
- */
- uint32_t LL_RCC_GetI2CClockFreq(uint32_t I2CxSource)
- {
- uint32_t i2c_frequency = LL_RCC_PERIPH_FREQUENCY_NO;
- /* Check parameter */
- assert_param(IS_LL_RCC_I2C_CLKSOURCE(I2CxSource));
- if (I2CxSource == LL_RCC_I2C1_CLKSOURCE)
- {
- /* I2C1 CLK clock frequency */
- switch (LL_RCC_GetI2CClockSource(I2CxSource))
- {
- case LL_RCC_I2C1_CLKSOURCE_SYSCLK: /* I2C1 Clock is System Clock */
- i2c_frequency = RCC_GetSystemClockFreq();
- break;
- case LL_RCC_I2C1_CLKSOURCE_HSI: /* I2C1 Clock is HSI Osc. */
- if (LL_RCC_HSI_IsReady())
- {
- i2c_frequency = HSI_VALUE;
- }
- break;
- case LL_RCC_I2C1_CLKSOURCE_PCLK1: /* I2C1 Clock is PCLK1 */
- default:
- i2c_frequency = RCC_GetPCLK1ClockFreq(RCC_GetHCLKClockFreq(RCC_GetSystemClockFreq()));
- break;
- }
- }
- #if defined(RCC_CCIPR_I2C2SEL)
- else if (I2CxSource == LL_RCC_I2C2_CLKSOURCE)
- {
- /* I2C2 CLK clock frequency */
- switch (LL_RCC_GetI2CClockSource(I2CxSource))
- {
- case LL_RCC_I2C2_CLKSOURCE_SYSCLK: /* I2C2 Clock is System Clock */
- i2c_frequency = RCC_GetSystemClockFreq();
- break;
- case LL_RCC_I2C2_CLKSOURCE_HSI: /* I2C2 Clock is HSI Osc. */
- if (LL_RCC_HSI_IsReady())
- {
- i2c_frequency = HSI_VALUE;
- }
- break;
- case LL_RCC_I2C2_CLKSOURCE_PCLK1: /* I2C2 Clock is PCLK1 */
- default:
- i2c_frequency = RCC_GetPCLK1ClockFreq(RCC_GetHCLKClockFreq(RCC_GetSystemClockFreq()));
- break;
- }
- }
- #endif /*RCC_CCIPR_I2C2SEL*/
- else
- {
- if (I2CxSource == LL_RCC_I2C3_CLKSOURCE)
- {
- /* I2C3 CLK clock frequency */
- switch (LL_RCC_GetI2CClockSource(I2CxSource))
- {
- case LL_RCC_I2C3_CLKSOURCE_SYSCLK: /* I2C3 Clock is System Clock */
- i2c_frequency = RCC_GetSystemClockFreq();
- break;
- case LL_RCC_I2C3_CLKSOURCE_HSI: /* I2C3 Clock is HSI Osc. */
- if (LL_RCC_HSI_IsReady())
- {
- i2c_frequency = HSI_VALUE;
- }
- break;
- case LL_RCC_I2C3_CLKSOURCE_PCLK1: /* I2C3 Clock is PCLK1 */
- default:
- i2c_frequency = RCC_GetPCLK1ClockFreq(RCC_GetHCLKClockFreq(RCC_GetSystemClockFreq()));
- break;
- }
- }
- #if defined(RCC_CCIPR2_I2C4SEL)
- else
- {
- if (I2CxSource == LL_RCC_I2C4_CLKSOURCE)
- {
- /* I2C4 CLK clock frequency */
- switch (LL_RCC_GetI2CClockSource(I2CxSource))
- {
- case LL_RCC_I2C4_CLKSOURCE_SYSCLK: /* I2C4 Clock is System Clock */
- i2c_frequency = RCC_GetSystemClockFreq();
- break;
- case LL_RCC_I2C4_CLKSOURCE_HSI: /* I2C4 Clock is HSI Osc. */
- if (LL_RCC_HSI_IsReady())
- {
- i2c_frequency = HSI_VALUE;
- }
- break;
- case LL_RCC_I2C4_CLKSOURCE_PCLK1: /* I2C4 Clock is PCLK1 */
- default:
- i2c_frequency = RCC_GetPCLK1ClockFreq(RCC_GetHCLKClockFreq(RCC_GetSystemClockFreq()));
- break;
- }
- }
- }
- #endif /*RCC_CCIPR2_I2C4SEL*/
- }
- return i2c_frequency;
- }
- /**
- * @brief Return LPUARTx clock frequency
- * @param LPUARTxSource This parameter can be one of the following values:
- * @arg @ref LL_RCC_LPUART1_CLKSOURCE
- * @retval LPUART clock frequency (in Hz)
- * - @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillator (HSI or LSE) is not ready
- */
- uint32_t LL_RCC_GetLPUARTClockFreq(uint32_t LPUARTxSource)
- {
- uint32_t lpuart_frequency = LL_RCC_PERIPH_FREQUENCY_NO;
- /* Check parameter */
- assert_param(IS_LL_RCC_LPUART_CLKSOURCE(LPUARTxSource));
- /* LPUART1CLK clock frequency */
- switch (LL_RCC_GetLPUARTClockSource(LPUARTxSource))
- {
- case LL_RCC_LPUART1_CLKSOURCE_SYSCLK: /* LPUART1 Clock is System Clock */
- lpuart_frequency = RCC_GetSystemClockFreq();
- break;
- case LL_RCC_LPUART1_CLKSOURCE_HSI: /* LPUART1 Clock is HSI Osc. */
- if (LL_RCC_HSI_IsReady())
- {
- lpuart_frequency = HSI_VALUE;
- }
- break;
- case LL_RCC_LPUART1_CLKSOURCE_LSE: /* LPUART1 Clock is LSE Osc. */
- if (LL_RCC_LSE_IsReady())
- {
- lpuart_frequency = LSE_VALUE;
- }
- break;
- case LL_RCC_LPUART1_CLKSOURCE_PCLK1: /* LPUART1 Clock is PCLK1 */
- default:
- lpuart_frequency = RCC_GetPCLK1ClockFreq(RCC_GetHCLKClockFreq(RCC_GetSystemClockFreq()));
- break;
- }
- return lpuart_frequency;
- }
- /**
- * @brief Return LPTIMx clock frequency
- * @param LPTIMxSource This parameter can be one of the following values:
- * @arg @ref LL_RCC_LPTIM1_CLKSOURCE
- * @arg @ref LL_RCC_LPTIM2_CLKSOURCE
- * @retval LPTIM clock frequency (in Hz)
- * - @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillator (HSI, LSI or LSE) is not ready
- */
- uint32_t LL_RCC_GetLPTIMClockFreq(uint32_t LPTIMxSource)
- {
- uint32_t lptim_frequency = LL_RCC_PERIPH_FREQUENCY_NO;
- /* Check parameter */
- assert_param(IS_LL_RCC_LPTIM_CLKSOURCE(LPTIMxSource));
- if (LPTIMxSource == LL_RCC_LPTIM1_CLKSOURCE)
- {
- /* LPTIM1CLK clock frequency */
- switch (LL_RCC_GetLPTIMClockSource(LPTIMxSource))
- {
- case LL_RCC_LPTIM1_CLKSOURCE_LSI: /* LPTIM1 Clock is LSI Osc. */
- if (LL_RCC_LSI_IsReady())
- {
- lptim_frequency = LSI_VALUE;
- }
- break;
- case LL_RCC_LPTIM1_CLKSOURCE_HSI: /* LPTIM1 Clock is HSI Osc. */
- if (LL_RCC_HSI_IsReady())
- {
- lptim_frequency = HSI_VALUE;
- }
- break;
- case LL_RCC_LPTIM1_CLKSOURCE_LSE: /* LPTIM1 Clock is LSE Osc. */
- if (LL_RCC_LSE_IsReady())
- {
- lptim_frequency = LSE_VALUE;
- }
- break;
- case LL_RCC_LPTIM1_CLKSOURCE_PCLK1: /* LPTIM1 Clock is PCLK1 */
- default:
- lptim_frequency = RCC_GetPCLK1ClockFreq(RCC_GetHCLKClockFreq(RCC_GetSystemClockFreq()));
- break;
- }
- }
- else
- {
- if (LPTIMxSource == LL_RCC_LPTIM2_CLKSOURCE)
- {
- /* LPTIM2CLK clock frequency */
- switch (LL_RCC_GetLPTIMClockSource(LPTIMxSource))
- {
- case LL_RCC_LPTIM2_CLKSOURCE_LSI: /* LPTIM2 Clock is LSI Osc. */
- if (LL_RCC_LSI_IsReady())
- {
- lptim_frequency = LSI_VALUE;
- }
- break;
- case LL_RCC_LPTIM2_CLKSOURCE_HSI: /* LPTIM2 Clock is HSI Osc. */
- if (LL_RCC_HSI_IsReady())
- {
- lptim_frequency = HSI_VALUE;
- }
- break;
- case LL_RCC_LPTIM2_CLKSOURCE_LSE: /* LPTIM2 Clock is LSE Osc. */
- if (LL_RCC_LSE_IsReady())
- {
- lptim_frequency = LSE_VALUE;
- }
- break;
- case LL_RCC_LPTIM2_CLKSOURCE_PCLK1: /* LPTIM2 Clock is PCLK1 */
- default:
- lptim_frequency = RCC_GetPCLK1ClockFreq(RCC_GetHCLKClockFreq(RCC_GetSystemClockFreq()));
- break;
- }
- }
- }
- return lptim_frequency;
- }
- /**
- * @brief Return SAIx clock frequency
- * @param SAIxSource This parameter can be one of the following values:
- * @arg @ref LL_RCC_SAI1_CLKSOURCE
- * @arg @ref LL_RCC_SAI2_CLKSOURCE (*)
- *
- * (*) value not defined in all devices.
- * @retval SAI clock frequency (in Hz)
- * - @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that PLL is not ready
- * - @ref LL_RCC_PERIPH_FREQUENCY_NA indicates that external clock is used
- */
- uint32_t LL_RCC_GetSAIClockFreq(uint32_t SAIxSource)
- {
- uint32_t sai_frequency = LL_RCC_PERIPH_FREQUENCY_NO;
- /* Check parameter */
- assert_param(IS_LL_RCC_SAI_CLKSOURCE(SAIxSource));
- if (SAIxSource == LL_RCC_SAI1_CLKSOURCE)
- {
- /* SAI1CLK clock frequency */
- switch (LL_RCC_GetSAIClockSource(SAIxSource))
- {
- case LL_RCC_SAI1_CLKSOURCE_PLLSAI1: /* PLLSAI1 clock used as SAI1 clock source */
- if (LL_RCC_PLLSAI1_IsReady())
- {
- sai_frequency = RCC_PLLSAI1_GetFreqDomain_SAI();
- }
- break;
- #if defined(RCC_PLLSAI2_SUPPORT)
- case LL_RCC_SAI1_CLKSOURCE_PLLSAI2: /* PLLSAI2 clock used as SAI1 clock source */
- if (LL_RCC_PLLSAI2_IsReady())
- {
- sai_frequency = RCC_PLLSAI2_GetFreqDomain_SAI();
- }
- break;
- #endif /* RCC_PLLSAI2_SUPPORT */
- case LL_RCC_SAI1_CLKSOURCE_PLL: /* PLL clock used as SAI1 clock source */
- if (LL_RCC_PLL_IsReady())
- {
- sai_frequency = RCC_PLL_GetFreqDomain_SAI();
- }
- break;
- case LL_RCC_SAI1_CLKSOURCE_PIN: /* External input clock used as SAI1 clock source */
- default:
- sai_frequency = LL_RCC_PERIPH_FREQUENCY_NA;
- break;
- }
- }
- else
- {
- #if defined(RCC_CCIPR_SAI2SEL)
- if (SAIxSource == LL_RCC_SAI2_CLKSOURCE)
- {
- /* SAI2CLK clock frequency */
- switch (LL_RCC_GetSAIClockSource(SAIxSource))
- {
- case LL_RCC_SAI2_CLKSOURCE_PLLSAI1: /* PLLSAI1 clock used as SAI2 clock source */
- if (LL_RCC_PLLSAI1_IsReady())
- {
- sai_frequency = RCC_PLLSAI1_GetFreqDomain_SAI();
- }
- break;
- #if defined(RCC_PLLSAI2_SUPPORT)
- case LL_RCC_SAI2_CLKSOURCE_PLLSAI2: /* PLLSAI2 clock used as SAI2 clock source */
- if (LL_RCC_PLLSAI2_IsReady())
- {
- sai_frequency = RCC_PLLSAI2_GetFreqDomain_SAI();
- }
- break;
- #endif /* RCC_PLLSAI2_SUPPORT */
- case LL_RCC_SAI2_CLKSOURCE_PLL: /* PLL clock used as SAI2 clock source */
- if (LL_RCC_PLL_IsReady())
- {
- sai_frequency = RCC_PLL_GetFreqDomain_SAI();
- }
- break;
- case LL_RCC_SAI2_CLKSOURCE_PIN: /* External input clock used as SAI2 clock source */
- default:
- sai_frequency = LL_RCC_PERIPH_FREQUENCY_NA;
- break;
- }
- }
- #endif /* RCC_CCIPR_SAI2SEL */
- }
- return sai_frequency;
- }
- #if defined(RCC_CCIPR2_SDMMCSEL)
- /**
- * @brief Return SDMMCx kernel clock frequency
- * @param SDMMCxSource This parameter can be one of the following values:
- * @arg @ref LL_RCC_SDMMC1_KERNELCLKSOURCE
- * @retval SDMMC clock frequency (in Hz)
- * - @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillator (MSI) or PLL is not ready
- * - @ref LL_RCC_PERIPH_FREQUENCY_NA indicates that no clock source selected
- */
- uint32_t LL_RCC_GetSDMMCKernelClockFreq(uint32_t SDMMCxSource)
- {
- uint32_t sdmmc_frequency = LL_RCC_PERIPH_FREQUENCY_NO;
- /* Check parameter */
- assert_param(IS_LL_RCC_SDMMC_KERNELCLKSOURCE(SDMMCxSource));
- /* SDMMC1CLK kernel clock frequency */
- switch (LL_RCC_GetSDMMCKernelClockSource(SDMMCxSource))
- {
- case LL_RCC_SDMMC1_KERNELCLKSOURCE_48CLK: /* 48MHz clock from internal multiplexor used as SDMMC1 clock source */
- sdmmc_frequency = LL_RCC_GetSDMMCClockFreq(LL_RCC_SDMMC1_CLKSOURCE);
- break;
- case LL_RCC_SDMMC1_KERNELCLKSOURCE_PLLP: /* PLL "P" output (PLLSAI3CLK) clock used as SDMMC1 clock source */
- if (LL_RCC_PLL_IsReady())
- {
- sdmmc_frequency = RCC_PLL_GetFreqDomain_SAI();
- }
- break;
- default:
- sdmmc_frequency = LL_RCC_PERIPH_FREQUENCY_NA;
- break;
- }
- return sdmmc_frequency;
- }
- #endif
- /**
- * @brief Return SDMMCx clock frequency
- * @param SDMMCxSource This parameter can be one of the following values:
- * @arg @ref LL_RCC_SDMMC1_CLKSOURCE
- * @retval SDMMC clock frequency (in Hz)
- * - @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillator (MSI) or PLL is not ready
- * - @ref LL_RCC_PERIPH_FREQUENCY_NA indicates that no clock source selected
- */
- uint32_t LL_RCC_GetSDMMCClockFreq(uint32_t SDMMCxSource)
- {
- uint32_t sdmmc_frequency = LL_RCC_PERIPH_FREQUENCY_NO;
- /* Check parameter */
- assert_param(IS_LL_RCC_SDMMC_CLKSOURCE(SDMMCxSource));
- /* SDMMC1CLK clock frequency */
- switch (LL_RCC_GetSDMMCClockSource(SDMMCxSource))
- {
- #if defined(LL_RCC_SDMMC1_CLKSOURCE_PLLSAI1)
- case LL_RCC_SDMMC1_CLKSOURCE_PLLSAI1: /* PLLSAI1 clock used as SDMMC1 clock source */
- if (LL_RCC_PLLSAI1_IsReady())
- {
- sdmmc_frequency = RCC_PLLSAI1_GetFreqDomain_48M();
- }
- break;
- #endif
- case LL_RCC_SDMMC1_CLKSOURCE_PLL: /* PLL clock used as SDMMC1 clock source */
- if (LL_RCC_PLL_IsReady())
- {
- sdmmc_frequency = RCC_PLL_GetFreqDomain_48M();
- }
- break;
- #if defined(LL_RCC_SDMMC1_CLKSOURCE_MSI)
- case LL_RCC_SDMMC1_CLKSOURCE_MSI: /* MSI clock used as SDMMC1 clock source */
- if (LL_RCC_MSI_IsReady())
- {
- sdmmc_frequency = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
- (LL_RCC_MSI_IsEnabledRangeSelect() ?
- LL_RCC_MSI_GetRange() :
- LL_RCC_MSI_GetRangeAfterStandby()));
- }
- break;
- #endif
- #if defined(RCC_HSI48_SUPPORT)
- case LL_RCC_SDMMC1_CLKSOURCE_HSI48: /* HSI48 used as SDMMC1 clock source */
- if (LL_RCC_HSI48_IsReady())
- {
- sdmmc_frequency = HSI48_VALUE;
- }
- break;
- #else
- case LL_RCC_SDMMC1_CLKSOURCE_NONE: /* No clock used as SDMMC1 clock source */
- #endif
- default:
- sdmmc_frequency = LL_RCC_PERIPH_FREQUENCY_NA;
- break;
- }
- return sdmmc_frequency;
- }
- /**
- * @brief Return RNGx clock frequency
- * @param RNGxSource This parameter can be one of the following values:
- * @arg @ref LL_RCC_RNG_CLKSOURCE
- * @retval RNG clock frequency (in Hz)
- * - @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillator (MSI) or PLL is not ready
- * - @ref LL_RCC_PERIPH_FREQUENCY_NA indicates that no clock source selected
- */
- uint32_t LL_RCC_GetRNGClockFreq(uint32_t RNGxSource)
- {
- uint32_t rng_frequency = LL_RCC_PERIPH_FREQUENCY_NO;
- /* Check parameter */
- assert_param(IS_LL_RCC_RNG_CLKSOURCE(RNGxSource));
- /* RNGCLK clock frequency */
- switch (LL_RCC_GetRNGClockSource(RNGxSource))
- {
- case LL_RCC_RNG_CLKSOURCE_PLLSAI1: /* PLLSAI1 clock used as RNG clock source */
- if (LL_RCC_PLLSAI1_IsReady())
- {
- rng_frequency = RCC_PLLSAI1_GetFreqDomain_48M();
- }
- break;
- case LL_RCC_RNG_CLKSOURCE_PLL: /* PLL clock used as RNG clock source */
- if (LL_RCC_PLL_IsReady())
- {
- rng_frequency = RCC_PLL_GetFreqDomain_48M();
- }
- break;
- case LL_RCC_RNG_CLKSOURCE_MSI: /* MSI clock used as RNG clock source */
- if (LL_RCC_MSI_IsReady())
- {
- rng_frequency = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
- (LL_RCC_MSI_IsEnabledRangeSelect() ?
- LL_RCC_MSI_GetRange() :
- LL_RCC_MSI_GetRangeAfterStandby()));
- }
- break;
- #if defined(RCC_HSI48_SUPPORT)
- case LL_RCC_RNG_CLKSOURCE_HSI48: /* HSI48 used as SDMMC1 clock source */
- if (LL_RCC_HSI48_IsReady())
- {
- rng_frequency = HSI48_VALUE;
- }
- break;
- #else
- case LL_RCC_RNG_CLKSOURCE_NONE: /* No clock used as SDMMC1 clock source */
- #endif
- default:
- rng_frequency = LL_RCC_PERIPH_FREQUENCY_NA;
- break;
- }
- return rng_frequency;
- }
- #if defined(USB_OTG_FS)||defined(USB)
- /**
- * @brief Return USBx clock frequency
- * @param USBxSource This parameter can be one of the following values:
- * @arg @ref LL_RCC_USB_CLKSOURCE
- * @retval USB clock frequency (in Hz)
- * - @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillator (MSI) or PLL is not ready
- * - @ref LL_RCC_PERIPH_FREQUENCY_NA indicates that no clock source selected
- */
- uint32_t LL_RCC_GetUSBClockFreq(uint32_t USBxSource)
- {
- uint32_t usb_frequency = LL_RCC_PERIPH_FREQUENCY_NO;
- /* Check parameter */
- assert_param(IS_LL_RCC_USB_CLKSOURCE(USBxSource));
- /* USBCLK clock frequency */
- switch (LL_RCC_GetUSBClockSource(USBxSource))
- {
- case LL_RCC_USB_CLKSOURCE_PLLSAI1: /* PLLSAI1 clock used as USB clock source */
- if (LL_RCC_PLLSAI1_IsReady())
- {
- usb_frequency = RCC_PLLSAI1_GetFreqDomain_48M();
- }
- break;
- case LL_RCC_USB_CLKSOURCE_PLL: /* PLL clock used as USB clock source */
- if (LL_RCC_PLL_IsReady())
- {
- usb_frequency = RCC_PLL_GetFreqDomain_48M();
- }
- break;
- case LL_RCC_USB_CLKSOURCE_MSI: /* MSI clock used as USB clock source */
- if (LL_RCC_MSI_IsReady())
- {
- usb_frequency = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
- (LL_RCC_MSI_IsEnabledRangeSelect() ?
- LL_RCC_MSI_GetRange() :
- LL_RCC_MSI_GetRangeAfterStandby()));
- }
- break;
- #if defined(RCC_HSI48_SUPPORT)
- case LL_RCC_USB_CLKSOURCE_HSI48: /* HSI48 used as USB clock source */
- if (LL_RCC_HSI48_IsReady())
- {
- usb_frequency = HSI48_VALUE;
- }
- break;
- #else
- case LL_RCC_USB_CLKSOURCE_NONE: /* No clock used as USB clock source */
- #endif
- default:
- usb_frequency = LL_RCC_PERIPH_FREQUENCY_NA;
- break;
- }
- return usb_frequency;
- }
- #endif /* USB_OTG_FS || USB */
- /**
- * @brief Return ADCx clock frequency
- * @param ADCxSource This parameter can be one of the following values:
- * @arg @ref LL_RCC_ADC_CLKSOURCE
- * @retval ADC clock frequency (in Hz)
- * - @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillator (MSI) or PLL is not ready
- * - @ref LL_RCC_PERIPH_FREQUENCY_NA indicates that no clock source selected
- */
- uint32_t LL_RCC_GetADCClockFreq(uint32_t ADCxSource)
- {
- uint32_t adc_frequency = LL_RCC_PERIPH_FREQUENCY_NO;
- /* Check parameter */
- assert_param(IS_LL_RCC_ADC_CLKSOURCE(ADCxSource));
- /* ADCCLK clock frequency */
- switch (LL_RCC_GetADCClockSource(ADCxSource))
- {
- case LL_RCC_ADC_CLKSOURCE_PLLSAI1: /* PLLSAI1 clock used as ADC clock source */
- if (LL_RCC_PLLSAI1_IsReady())
- {
- adc_frequency = RCC_PLLSAI1_GetFreqDomain_ADC();
- }
- break;
- #if defined(RCC_PLLSAI2_SUPPORT) && defined(LL_RCC_ADC_CLKSOURCE_PLLSAI2)
- case LL_RCC_ADC_CLKSOURCE_PLLSAI2: /* PLLSAI2 clock used as ADC clock source */
- if (LL_RCC_PLLSAI2_IsReady())
- {
- adc_frequency = RCC_PLLSAI2_GetFreqDomain_ADC();
- }
- break;
- #endif /* RCC_PLLSAI2_SUPPORT && LL_RCC_ADC_CLKSOURCE_PLLSAI2 */
- case LL_RCC_ADC_CLKSOURCE_SYSCLK: /* SYSCLK clock used as ADC clock source */
- adc_frequency = RCC_GetSystemClockFreq();
- break;
- case LL_RCC_ADC_CLKSOURCE_NONE: /* No clock used as ADC clock source */
- default:
- adc_frequency = LL_RCC_PERIPH_FREQUENCY_NA;
- break;
- }
- return adc_frequency;
- }
- #if defined(SWPMI1)
- /**
- * @brief Return SWPMIx clock frequency
- * @param SWPMIxSource This parameter can be one of the following values:
- * @arg @ref LL_RCC_SWPMI1_CLKSOURCE
- * @retval SWPMI clock frequency (in Hz)
- * - @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillator (HSI) is not ready
- */
- uint32_t LL_RCC_GetSWPMIClockFreq(uint32_t SWPMIxSource)
- {
- uint32_t swpmi_frequency = LL_RCC_PERIPH_FREQUENCY_NO;
- /* Check parameter */
- assert_param(IS_LL_RCC_SWPMI_CLKSOURCE(SWPMIxSource));
- /* SWPMI1CLK clock frequency */
- switch (LL_RCC_GetSWPMIClockSource(SWPMIxSource))
- {
- case LL_RCC_SWPMI1_CLKSOURCE_HSI: /* SWPMI1 Clock is HSI Osc. */
- if (LL_RCC_HSI_IsReady())
- {
- swpmi_frequency = HSI_VALUE;
- }
- break;
- case LL_RCC_SWPMI1_CLKSOURCE_PCLK1: /* SWPMI1 Clock is PCLK1 */
- default:
- swpmi_frequency = RCC_GetPCLK1ClockFreq(RCC_GetHCLKClockFreq(RCC_GetSystemClockFreq()));
- break;
- }
- return swpmi_frequency;
- }
- #endif /* SWPMI1 */
- #if defined(DFSDM1_Channel0)
- /**
- * @brief Return DFSDMx clock frequency
- * @param DFSDMxSource This parameter can be one of the following values:
- * @arg @ref LL_RCC_DFSDM1_CLKSOURCE
- * @retval DFSDM clock frequency (in Hz)
- */
- uint32_t LL_RCC_GetDFSDMClockFreq(uint32_t DFSDMxSource)
- {
- uint32_t dfsdm_frequency = LL_RCC_PERIPH_FREQUENCY_NO;
- /* Check parameter */
- assert_param(IS_LL_RCC_DFSDM_CLKSOURCE(DFSDMxSource));
- /* DFSDM1CLK clock frequency */
- switch (LL_RCC_GetDFSDMClockSource(DFSDMxSource))
- {
- case LL_RCC_DFSDM1_CLKSOURCE_SYSCLK: /* DFSDM1 Clock is SYSCLK */
- dfsdm_frequency = RCC_GetSystemClockFreq();
- break;
- case LL_RCC_DFSDM1_CLKSOURCE_PCLK2: /* DFSDM1 Clock is PCLK2 */
- default:
- dfsdm_frequency = RCC_GetPCLK2ClockFreq(RCC_GetHCLKClockFreq(RCC_GetSystemClockFreq()));
- break;
- }
- return dfsdm_frequency;
- }
- #if defined(RCC_CCIPR2_DFSDM1SEL)
- /**
- * @brief Return DFSDMx Audio clock frequency
- * @param DFSDMxSource This parameter can be one of the following values:
- * @arg @ref LL_RCC_DFSDM1_AUDIO_CLKSOURCE
- * @retval DFSDM clock frequency (in Hz)
- * - @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillator is not ready
- */
- uint32_t LL_RCC_GetDFSDMAudioClockFreq(uint32_t DFSDMxSource)
- {
- uint32_t dfsdm_frequency = LL_RCC_PERIPH_FREQUENCY_NO;
- /* Check parameter */
- assert_param(IS_LL_RCC_DFSDM_AUDIO_CLKSOURCE(DFSDMxSource));
- /* DFSDM1CLK clock frequency */
- switch (LL_RCC_GetDFSDMAudioClockSource(DFSDMxSource))
- {
- case LL_RCC_DFSDM1_AUDIO_CLKSOURCE_SAI1: /* SAI1 clock used as DFSDM1 audio clock */
- dfsdm_frequency = LL_RCC_GetSAIClockFreq(LL_RCC_SAI1_CLKSOURCE);
- break;
- case LL_RCC_DFSDM1_AUDIO_CLKSOURCE_MSI: /* MSI clock used as DFSDM1 audio clock */
- if (LL_RCC_MSI_IsReady())
- {
- dfsdm_frequency = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
- (LL_RCC_MSI_IsEnabledRangeSelect() ?
- LL_RCC_MSI_GetRange() :
- LL_RCC_MSI_GetRangeAfterStandby()));
- }
- break;
- case LL_RCC_DFSDM1_AUDIO_CLKSOURCE_HSI: /* HSI clock used as DFSDM1 audio clock */
- default:
- if (LL_RCC_HSI_IsReady())
- {
- dfsdm_frequency = HSI_VALUE;
- }
- break;
- }
- return dfsdm_frequency;
- }
- #endif /* RCC_CCIPR2_DFSDM1SEL */
- #endif /* DFSDM1_Channel0 */
- #if defined(DSI)
- /**
- * @brief Return DSI clock frequency
- * @param DSIxSource This parameter can be one of the following values:
- * @arg @ref LL_RCC_DSI_CLKSOURCE
- * @retval DSI clock frequency (in Hz)
- * - @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillator is not ready
- * - @ref LL_RCC_PERIPH_FREQUENCY_NA indicates that external clock is used
- */
- uint32_t LL_RCC_GetDSIClockFreq(uint32_t DSIxSource)
- {
- uint32_t dsi_frequency = LL_RCC_PERIPH_FREQUENCY_NO;
- /* Check parameter */
- assert_param(IS_LL_RCC_DSI_CLKSOURCE(DSIxSource));
- /* DSICLK clock frequency */
- switch (LL_RCC_GetDSIClockSource(DSIxSource))
- {
- case LL_RCC_DSI_CLKSOURCE_PLL: /* DSI Clock is PLLSAI2 Osc. */
- if (LL_RCC_PLLSAI2_IsReady())
- {
- dsi_frequency = RCC_PLLSAI2_GetFreqDomain_DSI();
- }
- break;
- case LL_RCC_DSI_CLKSOURCE_PHY: /* DSI Clock is DSI physical clock. */
- default:
- dsi_frequency = LL_RCC_PERIPH_FREQUENCY_NA;
- break;
- }
- return dsi_frequency;
- }
- #endif /* DSI */
- #if defined(LTDC)
- /**
- * @brief Return LTDC clock frequency
- * @param LTDCxSource This parameter can be one of the following values:
- * @arg @ref LL_RCC_LTDC_CLKSOURCE
- * @retval LTDC clock frequency (in Hz)
- * - @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillator PLLSAI is not ready
- */
- uint32_t LL_RCC_GetLTDCClockFreq(uint32_t LTDCxSource)
- {
- uint32_t ltdc_frequency = LL_RCC_PERIPH_FREQUENCY_NO;
- /* Check parameter */
- assert_param(IS_LL_RCC_LTDC_CLKSOURCE(LTDCxSource));
- if (LL_RCC_PLLSAI2_IsReady())
- {
- ltdc_frequency = RCC_PLLSAI2_GetFreqDomain_LTDC();
- }
- return ltdc_frequency;
- }
- #endif /* LTDC */
- #if defined(OCTOSPI1)
- /**
- * @brief Return OCTOSPI clock frequency
- * @param OCTOSPIxSource This parameter can be one of the following values:
- * @arg @ref LL_RCC_OCTOSPI_CLKSOURCE
- * @retval OCTOSPI clock frequency (in Hz)
- * - @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillator PLLSAI is not ready
- */
- uint32_t LL_RCC_GetOCTOSPIClockFreq(uint32_t OCTOSPIxSource)
- {
- uint32_t octospi_frequency = LL_RCC_PERIPH_FREQUENCY_NO;
- /* Check parameter */
- assert_param(IS_LL_RCC_OCTOSPI_CLKSOURCE(OCTOSPIxSource));
- /* OCTOSPI clock frequency */
- switch (LL_RCC_GetOCTOSPIClockSource(OCTOSPIxSource))
- {
- case LL_RCC_OCTOSPI_CLKSOURCE_SYSCLK: /* OCTOSPI clock is SYSCLK */
- octospi_frequency = RCC_GetSystemClockFreq();
- break;
- case LL_RCC_OCTOSPI_CLKSOURCE_MSI: /* MSI clock used as OCTOSPI clock */
- if (LL_RCC_MSI_IsReady())
- {
- octospi_frequency = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
- (LL_RCC_MSI_IsEnabledRangeSelect() ?
- LL_RCC_MSI_GetRange() :
- LL_RCC_MSI_GetRangeAfterStandby()));
- }
- break;
- case LL_RCC_OCTOSPI_CLKSOURCE_PLL: /* PLL clock used as OCTOSPI source */
- if (LL_RCC_PLL_IsReady())
- {
- octospi_frequency = RCC_PLL_GetFreqDomain_48M();
- }
- break;
- default:
- octospi_frequency = LL_RCC_PERIPH_FREQUENCY_NO;
- break;
- }
- return octospi_frequency;
- }
- #endif /* OCTOSPI1 */
- /**
- * @}
- */
- /**
- * @}
- */
- /** @addtogroup RCC_LL_Private_Functions
- * @{
- */
- /**
- * @brief Return SYSTEM clock frequency
- * @retval SYSTEM clock frequency (in Hz)
- */
- uint32_t RCC_GetSystemClockFreq(void)
- {
- uint32_t frequency = 0U;
- /* Get SYSCLK source -------------------------------------------------------*/
- switch (LL_RCC_GetSysClkSource())
- {
- case LL_RCC_SYS_CLKSOURCE_STATUS_MSI: /* MSI used as system clock source */
- frequency = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
- (LL_RCC_MSI_IsEnabledRangeSelect() ?
- LL_RCC_MSI_GetRange() :
- LL_RCC_MSI_GetRangeAfterStandby()));
- break;
- case LL_RCC_SYS_CLKSOURCE_STATUS_HSI: /* HSI used as system clock source */
- frequency = HSI_VALUE;
- break;
- case LL_RCC_SYS_CLKSOURCE_STATUS_HSE: /* HSE used as system clock source */
- frequency = HSE_VALUE;
- break;
- case LL_RCC_SYS_CLKSOURCE_STATUS_PLL: /* PLL used as system clock source */
- frequency = RCC_PLL_GetFreqDomain_SYS();
- break;
- default:
- frequency = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
- (LL_RCC_MSI_IsEnabledRangeSelect() ?
- LL_RCC_MSI_GetRange() :
- LL_RCC_MSI_GetRangeAfterStandby()));
- break;
- }
- return frequency;
- }
- /**
- * @brief Return HCLK clock frequency
- * @param SYSCLK_Frequency SYSCLK clock frequency
- * @retval HCLK clock frequency (in Hz)
- */
- uint32_t RCC_GetHCLKClockFreq(uint32_t SYSCLK_Frequency)
- {
- /* HCLK clock frequency */
- return __LL_RCC_CALC_HCLK_FREQ(SYSCLK_Frequency, LL_RCC_GetAHBPrescaler());
- }
- /**
- * @brief Return PCLK1 clock frequency
- * @param HCLK_Frequency HCLK clock frequency
- * @retval PCLK1 clock frequency (in Hz)
- */
- uint32_t RCC_GetPCLK1ClockFreq(uint32_t HCLK_Frequency)
- {
- /* PCLK1 clock frequency */
- return __LL_RCC_CALC_PCLK1_FREQ(HCLK_Frequency, LL_RCC_GetAPB1Prescaler());
- }
- /**
- * @brief Return PCLK2 clock frequency
- * @param HCLK_Frequency HCLK clock frequency
- * @retval PCLK2 clock frequency (in Hz)
- */
- uint32_t RCC_GetPCLK2ClockFreq(uint32_t HCLK_Frequency)
- {
- /* PCLK2 clock frequency */
- return __LL_RCC_CALC_PCLK2_FREQ(HCLK_Frequency, LL_RCC_GetAPB2Prescaler());
- }
- /**
- * @brief Return PLL clock frequency used for system domain
- * @retval PLL clock frequency (in Hz)
- */
- uint32_t RCC_PLL_GetFreqDomain_SYS(void)
- {
- uint32_t pllinputfreq = 0U, pllsource = 0U;
- /* PLL_VCO = (HSE_VALUE or HSI_VALUE or MSI_VALUE/ PLLM) * PLLN
- SYSCLK = PLL_VCO / PLLR
- */
- pllsource = LL_RCC_PLL_GetMainSource();
- switch (pllsource)
- {
- case LL_RCC_PLLSOURCE_MSI: /* MSI used as PLL clock source */
- pllinputfreq = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
- (LL_RCC_MSI_IsEnabledRangeSelect() ?
- LL_RCC_MSI_GetRange() :
- LL_RCC_MSI_GetRangeAfterStandby()));
- break;
- case LL_RCC_PLLSOURCE_HSI: /* HSI used as PLL clock source */
- pllinputfreq = HSI_VALUE;
- break;
- case LL_RCC_PLLSOURCE_HSE: /* HSE used as PLL clock source */
- pllinputfreq = HSE_VALUE;
- break;
- default:
- pllinputfreq = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
- (LL_RCC_MSI_IsEnabledRangeSelect() ?
- LL_RCC_MSI_GetRange() :
- LL_RCC_MSI_GetRangeAfterStandby()));
- break;
- }
- return __LL_RCC_CALC_PLLCLK_FREQ(pllinputfreq, LL_RCC_PLL_GetDivider(),
- LL_RCC_PLL_GetN(), LL_RCC_PLL_GetR());
- }
- /**
- * @brief Return PLL clock frequency used for SAI domain
- * @retval PLL clock frequency (in Hz)
- */
- uint32_t RCC_PLL_GetFreqDomain_SAI(void)
- {
- uint32_t pllinputfreq = 0U, pllsource = 0U;
- /* PLL_VCO = (HSE_VALUE or HSI_VALUE or MSI_VALUE / PLLM) * PLLN
- SAI Domain clock = PLL_VCO / PLLP
- */
- pllsource = LL_RCC_PLL_GetMainSource();
- switch (pllsource)
- {
- case LL_RCC_PLLSOURCE_MSI: /* MSI used as PLL clock source */
- pllinputfreq = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
- (LL_RCC_MSI_IsEnabledRangeSelect() ?
- LL_RCC_MSI_GetRange() :
- LL_RCC_MSI_GetRangeAfterStandby()));
- break;
- case LL_RCC_PLLSOURCE_HSI: /* HSI used as PLL clock source */
- pllinputfreq = HSI_VALUE;
- break;
- case LL_RCC_PLLSOURCE_HSE: /* HSE used as PLL clock source */
- pllinputfreq = HSE_VALUE;
- break;
- default:
- pllinputfreq = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
- (LL_RCC_MSI_IsEnabledRangeSelect() ?
- LL_RCC_MSI_GetRange() :
- LL_RCC_MSI_GetRangeAfterStandby()));
- break;
- }
- return __LL_RCC_CALC_PLLCLK_SAI_FREQ(pllinputfreq, LL_RCC_PLL_GetDivider(),
- LL_RCC_PLL_GetN(), LL_RCC_PLL_GetP());
- }
- /**
- * @brief Return PLL clock frequency used for 48 MHz domain
- * @retval PLL clock frequency (in Hz)
- */
- uint32_t RCC_PLL_GetFreqDomain_48M(void)
- {
- uint32_t pllinputfreq = 0U, pllsource = 0U;
- /* PLL_VCO = (HSE_VALUE or HSI_VALUE or MSI_VALUE/ PLLM) * PLLN
- 48M Domain clock = PLL_VCO / PLLQ
- */
- pllsource = LL_RCC_PLL_GetMainSource();
- switch (pllsource)
- {
- case LL_RCC_PLLSOURCE_MSI: /* MSI used as PLL clock source */
- pllinputfreq = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
- (LL_RCC_MSI_IsEnabledRangeSelect() ?
- LL_RCC_MSI_GetRange() :
- LL_RCC_MSI_GetRangeAfterStandby()));
- break;
- case LL_RCC_PLLSOURCE_HSI: /* HSI used as PLL clock source */
- pllinputfreq = HSI_VALUE;
- break;
- case LL_RCC_PLLSOURCE_HSE: /* HSE used as PLL clock source */
- pllinputfreq = HSE_VALUE;
- break;
- default:
- pllinputfreq = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
- (LL_RCC_MSI_IsEnabledRangeSelect() ?
- LL_RCC_MSI_GetRange() :
- LL_RCC_MSI_GetRangeAfterStandby()));
- break;
- }
- return __LL_RCC_CALC_PLLCLK_48M_FREQ(pllinputfreq, LL_RCC_PLL_GetDivider(),
- LL_RCC_PLL_GetN(), LL_RCC_PLL_GetQ());
- }
- #if defined(DSI)
- /**
- * @brief Return PLL clock frequency used for DSI clock
- * @retval PLL clock frequency (in Hz)
- */
- uint32_t RCC_PLLSAI2_GetFreqDomain_DSI(void)
- {
- uint32_t pllinputfreq = 0U, pllsource = 0U;
- /* PLLSAI2_VCO = (HSE_VALUE or HSI_VALUE or MSI_VALUE/ PLLSAI2M) * PLLSAI2N */
- /* DSICLK = PLLSAI2_VCO / PLLSAI2R */
- pllsource = LL_RCC_PLL_GetMainSource();
- switch (pllsource)
- {
- case LL_RCC_PLLSOURCE_MSI: /* MSI used as PLLSAI2 clock source */
- pllinputfreq = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
- (LL_RCC_MSI_IsEnabledRangeSelect() ?
- LL_RCC_MSI_GetRange() :
- LL_RCC_MSI_GetRangeAfterStandby()));
- break;
- case LL_RCC_PLLSOURCE_HSI: /* HSI used as PLLSAI2 clock source */
- pllinputfreq = HSI_VALUE;
- break;
- case LL_RCC_PLLSOURCE_HSE: /* HSE used as PLLSAI2 clock source */
- pllinputfreq = HSE_VALUE;
- break;
- default:
- pllinputfreq = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
- (LL_RCC_MSI_IsEnabledRangeSelect() ?
- LL_RCC_MSI_GetRange() :
- LL_RCC_MSI_GetRangeAfterStandby()));
- break;
- }
- return __LL_RCC_CALC_PLLSAI2_DSI_FREQ(pllinputfreq, LL_RCC_PLLSAI2_GetDivider(),
- LL_RCC_PLLSAI2_GetN(), LL_RCC_PLLSAI2_GetR());
- }
- #endif /* DSI */
- /**
- * @brief Return PLLSAI1 clock frequency used for SAI domain
- * @retval PLLSAI1 clock frequency (in Hz)
- */
- uint32_t RCC_PLLSAI1_GetFreqDomain_SAI(void)
- {
- uint32_t pllinputfreq = 0U, pllsource = 0U;
- #if defined(RCC_PLLSAI2M_DIV_1_16_SUPPORT)
- /* PLLSAI1_VCO = (HSE_VALUE or HSI_VALUE or MSI_VALUE/ PLLSAI1M) * PLLSAI1N */
- #else
- /* PLLSAI1_VCO = (HSE_VALUE or HSI_VALUE or MSI_VALUE/ PLLM) * PLLSAI1N */
- #endif
- /* SAI Domain clock = PLLSAI1_VCO / PLLSAI1P */
- pllsource = LL_RCC_PLL_GetMainSource();
- switch (pllsource)
- {
- case LL_RCC_PLLSOURCE_MSI: /* MSI used as PLLSAI1 clock source */
- pllinputfreq = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
- (LL_RCC_MSI_IsEnabledRangeSelect() ?
- LL_RCC_MSI_GetRange() :
- LL_RCC_MSI_GetRangeAfterStandby()));
- break;
- case LL_RCC_PLLSOURCE_HSI: /* HSI used as PLLSAI1 clock source */
- pllinputfreq = HSI_VALUE;
- break;
- case LL_RCC_PLLSOURCE_HSE: /* HSE used as PLLSAI1 clock source */
- pllinputfreq = HSE_VALUE;
- break;
- default:
- pllinputfreq = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
- (LL_RCC_MSI_IsEnabledRangeSelect() ?
- LL_RCC_MSI_GetRange() :
- LL_RCC_MSI_GetRangeAfterStandby()));
- break;
- }
- return __LL_RCC_CALC_PLLSAI1_SAI_FREQ(pllinputfreq, LL_RCC_PLL_GetDivider(),
- LL_RCC_PLLSAI1_GetN(), LL_RCC_PLLSAI1_GetP());
- }
- /**
- * @brief Return PLLSAI1 clock frequency used for 48Mhz domain
- * @retval PLLSAI1 clock frequency (in Hz)
- */
- uint32_t RCC_PLLSAI1_GetFreqDomain_48M(void)
- {
- uint32_t pllinputfreq = 0U, pllsource = 0U;
- #if defined(RCC_PLLSAI2M_DIV_1_16_SUPPORT)
- /* PLLSAI1_VCO = (HSE_VALUE or HSI_VALUE or MSI_VALUE/ PLLSAI1M) * PLLSAI1N */
- #else
- /* PLLSAI1_VCO = (HSE_VALUE or HSI_VALUE or MSI_VALUE/ PLLM) * PLLSAI1N */
- #endif
- /* 48M Domain clock = PLLSAI1_VCO / PLLSAI1Q */
- pllsource = LL_RCC_PLL_GetMainSource();
- switch (pllsource)
- {
- case LL_RCC_PLLSOURCE_MSI: /* MSI used as PLLSAI1 clock source */
- pllinputfreq = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
- (LL_RCC_MSI_IsEnabledRangeSelect() ?
- LL_RCC_MSI_GetRange() :
- LL_RCC_MSI_GetRangeAfterStandby()));
- break;
- case LL_RCC_PLLSOURCE_HSI: /* HSI used as PLLSAI1 clock source */
- pllinputfreq = HSI_VALUE;
- break;
- case LL_RCC_PLLSOURCE_HSE: /* HSE used as PLLSAI1 clock source */
- pllinputfreq = HSE_VALUE;
- break;
- default:
- pllinputfreq = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
- (LL_RCC_MSI_IsEnabledRangeSelect() ?
- LL_RCC_MSI_GetRange() :
- LL_RCC_MSI_GetRangeAfterStandby()));
- break;
- }
- return __LL_RCC_CALC_PLLSAI1_48M_FREQ(pllinputfreq, LL_RCC_PLL_GetDivider(),
- LL_RCC_PLLSAI1_GetN(), LL_RCC_PLLSAI1_GetQ());
- }
- /**
- * @brief Return PLLSAI1 clock frequency used for ADC domain
- * @retval PLLSAI1 clock frequency (in Hz)
- */
- uint32_t RCC_PLLSAI1_GetFreqDomain_ADC(void)
- {
- uint32_t pllinputfreq = 0U, pllsource = 0U;
- #if defined(RCC_PLLSAI2M_DIV_1_16_SUPPORT)
- /* PLLSAI1_VCO = (HSE_VALUE or HSI_VALUE or MSI_VALUE/ PLLSAI1M) * PLLSAI1N */
- #else
- /* PLLSAI1_VCO = (HSE_VALUE or HSI_VALUE or MSI_VALUE/ PLLM) * PLLSAI1N */
- #endif
- /* 48M Domain clock = PLLSAI1_VCO / PLLSAI1R */
- pllsource = LL_RCC_PLL_GetMainSource();
- switch (pllsource)
- {
- case LL_RCC_PLLSOURCE_MSI: /* MSI used as PLLSAI1 clock source */
- pllinputfreq = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
- (LL_RCC_MSI_IsEnabledRangeSelect() ?
- LL_RCC_MSI_GetRange() :
- LL_RCC_MSI_GetRangeAfterStandby()));
- break;
- case LL_RCC_PLLSOURCE_HSI: /* HSI used as PLLSAI1 clock source */
- pllinputfreq = HSI_VALUE;
- break;
- case LL_RCC_PLLSOURCE_HSE: /* HSE used as PLLSAI1 clock source */
- pllinputfreq = HSE_VALUE;
- break;
- default:
- pllinputfreq = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
- (LL_RCC_MSI_IsEnabledRangeSelect() ?
- LL_RCC_MSI_GetRange() :
- LL_RCC_MSI_GetRangeAfterStandby()));
- break;
- }
- return __LL_RCC_CALC_PLLSAI1_ADC_FREQ(pllinputfreq, LL_RCC_PLL_GetDivider(),
- LL_RCC_PLLSAI1_GetN(), LL_RCC_PLLSAI1_GetR());
- }
- #if defined(RCC_PLLSAI2_SUPPORT)
- /**
- * @brief Return PLLSAI2 clock frequency used for SAI domain
- * @retval PLLSAI2 clock frequency (in Hz)
- */
- uint32_t RCC_PLLSAI2_GetFreqDomain_SAI(void)
- {
- uint32_t pllinputfreq = 0U, pllsource = 0U;
- #if defined(RCC_PLLSAI2M_DIV_1_16_SUPPORT)
- /* PLLSAI2_VCO = (HSE_VALUE or HSI_VALUE or MSI_VALUE/ PLLSAI2M) * PLLSAI2N */
- #else
- /* PLLSAI2_VCO = (HSE_VALUE or HSI_VALUE or MSI_VALUE/ PLLM) * PLLSAI2N */
- #endif
- /* SAI Domain clock = PLLSAI2_VCO / PLLSAI2P */
- pllsource = LL_RCC_PLL_GetMainSource();
- switch (pllsource)
- {
- case LL_RCC_PLLSOURCE_MSI: /* MSI used as PLLSAI2 clock source */
- pllinputfreq = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
- (LL_RCC_MSI_IsEnabledRangeSelect() ?
- LL_RCC_MSI_GetRange() :
- LL_RCC_MSI_GetRangeAfterStandby()));
- break;
- case LL_RCC_PLLSOURCE_HSI: /* HSI used as PLLSAI2 clock source */
- pllinputfreq = HSI_VALUE;
- break;
- case LL_RCC_PLLSOURCE_HSE: /* HSE used as PLLSAI2 clock source */
- pllinputfreq = HSE_VALUE;
- break;
- default:
- pllinputfreq = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
- (LL_RCC_MSI_IsEnabledRangeSelect() ?
- LL_RCC_MSI_GetRange() :
- LL_RCC_MSI_GetRangeAfterStandby()));
- break;
- }
- #if defined(RCC_PLLSAI2M_DIV_1_16_SUPPORT)
- return __LL_RCC_CALC_PLLSAI2_SAI_FREQ(pllinputfreq, LL_RCC_PLLSAI2_GetDivider(),
- LL_RCC_PLLSAI2_GetN(), LL_RCC_PLLSAI2_GetP());
- #else
- return __LL_RCC_CALC_PLLSAI2_SAI_FREQ(pllinputfreq, LL_RCC_PLL_GetDivider(),
- LL_RCC_PLLSAI2_GetN(), LL_RCC_PLLSAI2_GetP());
- #endif
- }
- #if defined(LTDC)
- /**
- * @brief Return PLLSAI2 clock frequency used for LTDC domain
- * @retval PLLSAI2 clock frequency (in Hz)
- */
- uint32_t RCC_PLLSAI2_GetFreqDomain_LTDC(void)
- {
- uint32_t pllinputfreq = 0U, pllsource = 0U;
- /* PLLSAI2_VCO = (HSE_VALUE or HSI_VALUE or MSI_VALUE/ PLLSAI2M) * PLLSAI2N */
- /* LTDC Domain clock = (PLLSAI2_VCO / PLLSAI2R) / PLLSAI2DIVR */
- pllsource = LL_RCC_PLL_GetMainSource();
- switch (pllsource)
- {
- case LL_RCC_PLLSOURCE_MSI: /* MSI used as PLLSAI2 clock source */
- pllinputfreq = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
- (LL_RCC_MSI_IsEnabledRangeSelect() ?
- LL_RCC_MSI_GetRange() :
- LL_RCC_MSI_GetRangeAfterStandby()));
- break;
- case LL_RCC_PLLSOURCE_HSI: /* HSI used as PLLSAI2 clock source */
- pllinputfreq = HSI_VALUE;
- break;
- case LL_RCC_PLLSOURCE_HSE: /* HSE used as PLLSAI2 clock source */
- pllinputfreq = HSE_VALUE;
- break;
- default:
- pllinputfreq = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
- (LL_RCC_MSI_IsEnabledRangeSelect() ?
- LL_RCC_MSI_GetRange() :
- LL_RCC_MSI_GetRangeAfterStandby()));
- break;
- }
- return __LL_RCC_CALC_PLLSAI2_LTDC_FREQ(pllinputfreq, LL_RCC_PLLSAI2_GetDivider(),
- LL_RCC_PLLSAI2_GetN(), LL_RCC_PLLSAI2_GetR(), LL_RCC_PLLSAI2_GetDIVR());
- }
- #else
- /**
- * @brief Return PLLSAI2 clock frequency used for ADC domain
- * @retval PLLSAI2 clock frequency (in Hz)
- */
- uint32_t RCC_PLLSAI2_GetFreqDomain_ADC(void)
- {
- uint32_t pllinputfreq = 0U, pllsource = 0U;
- /* PLLSAI2_VCO = (HSE_VALUE or HSI_VALUE or MSI_VALUE/ PLLM) * PLLSAI2N */
- /* 48M Domain clock = PLLSAI2_VCO / PLLSAI2R */
- pllsource = LL_RCC_PLL_GetMainSource();
- switch (pllsource)
- {
- case LL_RCC_PLLSOURCE_MSI: /* MSI used as PLLSAI2 clock source */
- pllinputfreq = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
- (LL_RCC_MSI_IsEnabledRangeSelect() ?
- LL_RCC_MSI_GetRange() :
- LL_RCC_MSI_GetRangeAfterStandby()));
- break;
- case LL_RCC_PLLSOURCE_HSI: /* HSI used as PLLSAI2 clock source */
- pllinputfreq = HSI_VALUE;
- break;
- case LL_RCC_PLLSOURCE_HSE: /* HSE used as PLLSAI2 clock source */
- pllinputfreq = HSE_VALUE;
- break;
- default:
- pllinputfreq = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
- (LL_RCC_MSI_IsEnabledRangeSelect() ?
- LL_RCC_MSI_GetRange() :
- LL_RCC_MSI_GetRangeAfterStandby()));
- break;
- }
- return __LL_RCC_CALC_PLLSAI2_ADC_FREQ(pllinputfreq, LL_RCC_PLL_GetDivider(),
- LL_RCC_PLLSAI2_GetN(), LL_RCC_PLLSAI2_GetR());
- }
- #endif /* LTDC */
- #endif /*RCC_PLLSAI2_SUPPORT*/
- /**
- * @}
- */
- /**
- * @}
- */
- #endif /* defined(RCC) */
- /**
- * @}
- */
- #endif /* USE_FULL_LL_DRIVER */
- /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|