From 235ed74ea44c9ed9764ec5633302ea399cb633e9 Mon Sep 17 00:00:00 2001 From: diogo464 Date: Fri, 19 Dec 2025 20:11:10 +0000 Subject: embassy-rp: fix set_input_sync_bypass pin offset currently this function causes a crash in debug mode when used with pins greater than 32 (available on the rp235xb variant) because it overflows when doing the shift. this commit applies the offset to pin value before doing the shift. this assumes that when using a pin greater than 32 the GPIOBASE has already been set to 16. --- embassy-rp/src/pio/mod.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/embassy-rp/src/pio/mod.rs b/embassy-rp/src/pio/mod.rs index 1c370fdfc..4d20dfd81 100644 --- a/embassy-rp/src/pio/mod.rs +++ b/embassy-rp/src/pio/mod.rs @@ -294,7 +294,12 @@ impl<'l, PIO: Instance> Pin<'l, PIO> { /// Set the pin's input sync bypass. pub fn set_input_sync_bypass(&mut self, bypass: bool) { - let mask = 1 << self.pin(); + let offset = match self.pin() { + pin @ 0..32 => 0, + pin @ _ => 16, + }; + let mask = 1 << self.pin() - offset; + if bypass { PIO::PIO.input_sync_bypass().write_set(|w| *w = mask); } else { -- cgit