/* Returns the frequency of different on chip clocks.  */
void RCC_GetClocksFreq(RCC_ClocksTypeDef *clk)
/* Returns the frequency of different on chip clocks.  */
void RCC_GetClocksFreq(RCC_ClocksTypeDef *clk)
{
    u8 tbADCPresc[] = {2, 4, 6, 8};
    clk->SYSCLK_Frequency = RCC_GetSysClockFreq();
    clk->HCLK_Frequency   = RCC_GetHCLKFreq();
    clk->PCLK1_Frequency  = RCC_GetPCLK1Freq();
    clk->PCLK2_Frequency  = RCC_GetPCLK2Freq();
    clk->ADCCLK_Frequency = clk->PCLK2_Frequency / tbADCPresc[(RCC->CFGR & ADC_CFGR_PRE) >> ADC_CFGR_PRE_Pos];
}