LL_RCC_GetSystemClocksFreq API migration ¶
In HAL1, the function void
LL_RCC_GetSystemClocksFreq(LL_RCC_ClocksTypeDef
*RCC_Clocks)
is called to update the structure fields for retrieving the frequencies
of different on-chip clocks, including System, AHB, APB1, and APB2 bus clocks. In HAL2, we must use the unitary LL APIs for each clock selected, as demonstrated in the table below
|
HAL1 |
HAL2 |
|---|---|
/* Declare a variable of type LL_RCC_ClocksTypeDef */
LL_RCC_ClocksTypeDef RCC_Clocks;
/* Call the function to get the clock frequencies */
LL_RCC_GetSystemClocksFreq(&RCC_Clocks);
|
uint32_t source;
uint32_t system_frequency;
uint32_t hclk_frequency;
uint32_t pclk1_frequency;
uint32_t pclk2_frequency;
uint32_t pclk3_frequency;
/* In the first step get the system clock source */
source = LL_RCC_GetSysClkSource();
// After determining the source, call one of the following functions, which depend on the source found
/* MSIS used as system clock source */
system_frequency = LL_RCC_CALC_MSIS_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
((LL_RCC_MSI_IsEnabledRangeSelect() == 1U) ?
LL_RCC_MSIS_GetRange() :
LL_RCC_MSIS_GetRangeAfterStandby()));
/* HSI used as system clock source */
system_frequency = HSI_VALUE;
/* HSE used as system clock source */
system_frequency = HSE_VALUE;
/* PLL1 used as system clock source */
/* get the pll clock source */
uint32_t pllinputfreq;
uint32_t pllsource;
pllsource = LL_RCC_PLL1_GetMainSource();
/* Based on the source found, perform one of the following steps for determinete pllinputfreq */
/* MSIS used as PLL1 clock source */
pllinputfreq = LL_RCC_CALC_MSIS_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(),
((LL_RCC_MSI_IsEnabledRangeSelect() == 1U) ?
LL_RCC_MSIS_GetRange() :
LL_RCC_MSIS_GetRangeAfterStandby()));
/* HSI used as PLL1 clock source */
pllinputfreq = HSI_VALUE;
/* HSE used as PLL1 clock source */
pllinputfreq = HSE_VALUE;
/* Get SYSCLK frequency */
system_frequency = LL_RCC_CALC_PLL1CLK_FREQ(pllinputfreq, LL_RCC_PLL1_GetDivider(),
LL_RCC_PLL1_GetN(), LL_RCC_PLL1_GetR());
/* HCLK clock frequency */
hclk_frequency = LL_RCC_CALC_HCLK_FREQ(system_frequency, LL_RCC_GetAHBPrescaler());
/* PCLK1 clock frequency */
pclk1_frequency = LL_RCC_CALC_PCLK1_FREQ(hclk_frequency, LL_RCC_GetAPB1Prescaler());
/* PCLK2 clock frequency */
pclk2_frequency = LL_RCC_CALC_PCLK2_FREQ(hclk_frequency, LL_RCC_GetAPB2Prescaler());
/* PCLK3 clock frequency */
pclk3_frequency = LL_RCC_CALC_PCLK3_FREQ(hclk_frequency, LL_RCC_GetAPB3Prescaler());
|
Note
Note1: For all LL_RCC_GetPPPClockFreq() calls, follow the same sequence detailed in the previous section to obtain the pclk1_frequency, pclk2_frequency, pclk4_frequency, or system_frequency.
Note
Note2: If the peripheral’s clock source is unknown, call the LL_RCC_GetPPPClockSource() functions.
LL_RCC_GetPPPClockFreq APIs migration ¶
LL_RCC_GetUSARTClockFreq ¶
|
HAL1 |
HAL2 |
|---|---|
|
In HAL2 according to USARTx_CLKSOURCE this function is replaced by the following:
|
LL_RCC_GetUARTClockFreq ¶
|
HAL1 |
HAL2 |
|---|---|
|
|
LL_RCC_GetSPIClockFreq ¶
|
HAL1 |
HAL2 |
|---|---|
|
|
LL_RCC_GetI2CClockFreq ¶
|
HAL1 |
HAL2 |
|---|---|
|
|
LL_RCC_GetLPUARTClockFreq ¶
|
HAL1 |
HAL2 |
|---|---|
|
In HAL2 according to LPUARTx_CLKSOURCE this function is replaced by the following:
|
LL_RCC_GetLPTIMClockFreq ¶
|
HAL1 |
HAL2 |
|---|---|
|
In HAL2 according to LPTIMx_CLKSOURCE this function is replaced by the following:
|
LL_RCC_GetSAIClockFreq ¶
|
HAL1 |
HAL2 |
|---|---|
|
In HAL2 according to SAIx_CLKSOURCE this function is replaced by the following sequences:
|
LL_RCC_GetSDMMCKernelClockFreq ¶
|
HAL1 |
HAL2 |
|---|---|
|
In HAL2 according to LPTIMx_CLKSOURCE this function is replaced by the following sequence:
|
LL_RCC_GetSDMMCClockFreq ¶
|
HAL1 |
HAL2 |
|---|---|
|
In HAL2 according to LPTIMx_CLKSOURCE this function is replaced by the following:
|
LL_RCC_GetRNGClockFreq ¶
|
HAL1 |
HAL2 |
|---|---|
|
In HAL2 according to LPTIMx_CLKSOURCE this function is replaced by the following:
|
LL_RCC_GetUSBClockFreq ¶
|
HAL1 |
HAL2 |
|---|---|
|
In HAL2 this function is replaced by the following implementation:
|
LL_RCC_GetADCDACClockFreq ¶
|
HAL1 |
HAL2 |
|---|---|
|
In HAL2 this function is replaced by the following implementation:
|
LL_RCC_GetLTDCClockFreq ¶
|
HAL1 |
HAL2 |
|---|---|
|
In HAL2 according this function is replaced by the following sequence:
|
LL_RCC_GetHSPIClockFreq ¶
|
HAL1 |
HAL2 |
|---|---|
|
In HAL2 this function is replaced by the following implementation:
|
LL_RCC_GetFDCANClockFreq ¶
|
HAL1 |
HAL2 |
|---|---|
|
In HAL2 this function is replaced by the following implementation:
|
LL_RCC_GetMDF1ClockFreq ¶
|
HAL1 |
HAL2 |
|---|---|
|
In HAL2 this function is replaced by the following implementation:
|
LL_RCC_GetADF1ClockFreq ¶
|
HAL1 |
HAL2 |
|---|---|
|
In HAL2 this function is replaced by the following implementation:
|
LL_RCC_GetDSIClockFreq ¶
|
HAL1 |
HAL2 |
|---|---|
|
In HAL2 this function is replaced by the following sequences:
|
LL_RCC_GetSAESClockFreq ¶
|
HAL1 |
HAL2 |
|---|---|
|
In HAL2 this function is replaced by the following implementation:
|
LL_RCC_GetOCTOSPIClockFreq ¶
|
HAL1 |
HAL2 |
|---|---|
|
In HAL2 this function is replaced by the following sequences:
|
LL_RCC_GetDAC1ClockFreq ¶
|
HAL1 |
HAL2 |
|---|---|
|
In HAL2 this function is replaced by the following implementation:
|