soc/rtc: round APB clock frequency to nearest MHz
This commit is contained in:
parent
d24e0dcc2c
commit
c743bdac88
1 changed files with 5 additions and 1 deletions
|
@ -500,7 +500,11 @@ void rtc_clk_apb_freq_update(uint32_t apb_freq)
|
|||
|
||||
uint32_t rtc_clk_apb_freq_get()
|
||||
{
|
||||
return reg_val_to_clk_val(READ_PERI_REG(RTC_APB_FREQ_REG)) << 12;
|
||||
uint32_t freq_hz = reg_val_to_clk_val(READ_PERI_REG(RTC_APB_FREQ_REG)) << 12;
|
||||
// round to the nearest MHz
|
||||
freq_hz += MHZ / 2;
|
||||
uint32_t remainder = freq_hz % MHZ;
|
||||
return freq_hz - remainder;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue