stm32:rcc: update _get_clock (uart/i2c) to handle all cases
Adds handling for missing cases. While i2c only has 3 cases, uarts have
all 4, so make sure they're handled properly.
Removes duplicated/redundant definitions.
Adds doxygen wrappers, even if only for internal use.
Fixes: e41ac6ea71 stm32: added peripheral clock get helpers for all stm32
Signed-of-by: Karl Palsson <karlp@tweak.au>
This commit is contained in:
@@ -277,17 +277,21 @@ uint32_t rcc_get_usart_clk_freq(uint32_t usart)
|
||||
}
|
||||
|
||||
/* Based on extracted clksel value, return the clock. */
|
||||
if (clksel == RCC_D2CCIP2R_USARTSEL_PCLK) {
|
||||
switch(clksel) {
|
||||
case RCC_D2CCIP2R_USARTSEL_PCLK:
|
||||
return pclk;
|
||||
} else if (clksel == RCC_D2CCIP2R_USARTSEL_PLL2Q) {
|
||||
case RCC_D2CCIP2R_USARTSEL_PLL2Q:
|
||||
return rcc_clock_tree.pll2.q_mhz * HZ_PER_MHZ;
|
||||
} else if (clksel == RCC_D2CCIP2R_USARTSEL_PLL3Q) {
|
||||
case RCC_D2CCIP2R_USARTSEL_PLL3Q:
|
||||
return rcc_clock_tree.pll3.q_mhz * HZ_PER_MHZ;
|
||||
} else if (clksel == RCC_D2CCIP2R_USARTSEL_HSI) {
|
||||
case RCC_D2CCIP2R_USARTSEL_HSI:
|
||||
return RCC_HSI_BASE_FREQUENCY;
|
||||
} else {
|
||||
return 0U;
|
||||
case RCC_D2CCIP2R_USARTSEL_CSI:
|
||||
return 4000000;
|
||||
case RCC_D2CCIP2R_USARTSEL_LSE:
|
||||
return 32768;
|
||||
}
|
||||
cm3_assert_not_reached();
|
||||
}
|
||||
|
||||
uint32_t rcc_get_timer_clk_freq(uint32_t timer __attribute__((unused)))
|
||||
|
||||
Reference in New Issue
Block a user