From 7227c7bde24b9ebd1e3fcc355f708690d1724469 Mon Sep 17 00:00:00 2001 From: Eric Seppanen Date: Sat, 13 Dec 2025 15:18:39 -0800 Subject: clock_divider: use core::assert in const fn defmt::assert gives a compile error in const context. --- embassy-rp/src/pio_programs/clock_divider.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/embassy-rp/src/pio_programs/clock_divider.rs b/embassy-rp/src/pio_programs/clock_divider.rs index 28c931ed2..87ba93008 100644 --- a/embassy-rp/src/pio_programs/clock_divider.rs +++ b/embassy-rp/src/pio_programs/clock_divider.rs @@ -29,7 +29,7 @@ pub fn calculate_pio_clock_divider(target_hz: u32) -> fixed::FixedU32 { /// A fixed-point divider value suitable for use in a PIO state machine configuration pub const fn calculate_pio_clock_divider_value(sys_hz: u32, target_hz: u32) -> fixed::FixedU32 { // Requires a non-zero frequency - assert!(target_hz > 0, "PIO clock frequency cannot be zero"); + core::assert!(target_hz > 0); // Compute the integer and fractional part of the divider. // Doing it this way allows us to avoid u64 division while @@ -41,9 +41,9 @@ pub const fn calculate_pio_clock_divider_value(sys_hz: u32, target_hz: u32) -> f let result = integer << 8 | frac; // Ensure the result will fit in 16+8 bits. - assert!(result <= 0xffff_ff, "pio clock divider too big"); + core::assert!(result <= 0xffff_ff); // The clock divider can't be used to go faster than the system clock. - assert!(result >= 0x0001_00, "pio clock divider cannot be less than 1"); + core::assert!(result >= 0x0001_00); fixed::FixedU32::from_bits(result) } -- cgit