From b6a383811a775d1cb98b4fb2070c55e95c66a648 Mon Sep 17 00:00:00 2001 From: Dominic Date: Mon, 11 Mar 2024 17:51:53 +0100 Subject: [PATCH] Improve panic message when requesting frequency higher than clock Previously it would panic with message "unreachable", which isn't particularly clear about what the problem is and how to fix it. --- embassy-stm32/src/spi/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/embassy-stm32/src/spi/mod.rs b/embassy-stm32/src/spi/mod.rs index 172bc8112..b517f640a 100644 --- a/embassy-stm32/src/spi/mod.rs +++ b/embassy-stm32/src/spi/mod.rs @@ -700,7 +700,7 @@ use vals::Mbr as Br; fn compute_baud_rate(clocks: Hertz, freq: Hertz) -> Br { let val = match clocks.0 / freq.0 { - 0 => unreachable!(), + 0 => panic!("You are trying to reach a frequency higher than the clock"), 1..=2 => 0b000, 3..=5 => 0b001, 6..=11 => 0b010,