/* Get the peripheral clock speed for the Timer at base specified.  */
uint32_t rcc_get_timer_clk_freq(uint32_t timer)
/* Get the peripheral clock speed for the Timer at base specified.  */
uint32_t rcc_get_timer_clk_freq(uint32_t timer)
{
	if (timer >= TIM2_BASE && timer <= TIM7_BASE) {
		uint8_t ppre1 = (RCC_CFGR >> RCC_CFGR_PPRE1_SHIFT) & RCC_CFGR_PPRE1_MASK;
		return (ppre1 == RCC_CFGR_PPRE1_HCLK_NODIV) ? rcc_apb1_frequency
			: 2 * rcc_apb1_frequency;
	} else {
		uint8_t ppre2 = (RCC_CFGR >> RCC_CFGR_PPRE2_SHIFT) & RCC_CFGR_PPRE2_MASK;
		return (ppre2 == RCC_CFGR_PPRE2_HCLK_NODIV) ? rcc_apb2_frequency
			: 2 * rcc_apb2_frequency;
	}
}