From 40e7176e13a3166b8f1e01e179ee38efe85bfa71 Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Sat, 31 Jul 2021 16:34:50 -0400 Subject: [PATCH] embassy-stm32: Eliminate use of unwrap --- embassy-stm32/src/time_driver.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/embassy-stm32/src/time_driver.rs b/embassy-stm32/src/time_driver.rs index 3ae4b1c4d..91b8525ae 100644 --- a/embassy-stm32/src/time_driver.rs +++ b/embassy-stm32/src/time_driver.rs @@ -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));