embassy-stm32: Eliminate use of unwrap
This commit is contained in:
parent
41aaff95f8
commit
40e7176e13
1 changed files with 4 additions and 1 deletions
|
@ -106,7 +106,10 @@ impl State {
|
||||||
r.cnt().write(|w| w.set_cnt(0));
|
r.cnt().write(|w| w.set_cnt(0));
|
||||||
|
|
||||||
let psc = timer_freq.0 / TICKS_PER_SECOND as u32 - 1;
|
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.psc().write(|w| w.set_psc(psc));
|
||||||
r.arr().write(|w| w.set_arr(u16::MAX));
|
r.arr().write(|w| w.set_arr(u16::MAX));
|
||||||
|
|
Loading…
Reference in a new issue