embassy-stm32: Eliminate use of unwrap

This commit is contained in:
Ben Gamari 2021-07-31 16:34:50 -04:00 committed by Dario Nieuwenhuis
parent 41aaff95f8
commit 40e7176e13

View file

@ -106,7 +106,10 @@ impl State {
r.cnt().write(|w| w.set_cnt(0));
let psc = timer_freq.0 / TICKS_PER_SECOND as u32 - 1;
let psc: u16 = psc.try_into().unwrap();
let psc: u16 = match psc.try_into() {
Err(_) => panic!("psc division overflow: {}", psc),
Ok(n) => n,
};
r.psc().write(|w| w.set_psc(psc));
r.arr().write(|w| w.set_arr(u16::MAX));