fix timer crash, cant divide by 0

This commit is contained in:
lilian 2017-11-20 21:36:33 +01:00
parent c50201ee43
commit 1cf766f1b5

View file

@ -83,6 +83,11 @@ int timer_set_frequency(const timer_frc_t frc, uint32_t freq)
uint32_t counts = 0;
timer_clkdiv_t div = timer_freq_to_div(freq);
if(freq == 0) //can't divide by 0
{
return -EINVAL;
}
counts = timer_freq_to_count(frc, freq, div);
if(counts == 0)
{