From 815ba8aa7507d0aa27dfb3f3823793e3567719f8 Mon Sep 17 00:00:00 2001 From: Adrian Wowk Date: Wed, 20 Aug 2025 13:44:56 -0500 Subject: rp: read pio gpiobase in set_pins and set_pin_dirs --- embassy-rp/src/pio/mod.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'embassy-rp') diff --git a/embassy-rp/src/pio/mod.rs b/embassy-rp/src/pio/mod.rs index f46e664e4..5f554dfe3 100644 --- a/embassy-rp/src/pio/mod.rs +++ b/embassy-rp/src/pio/mod.rs @@ -977,13 +977,27 @@ impl<'d, PIO: Instance + 'd, const SM: usize> StateMachine<'d, PIO, SM> { self.set_enable(enabled); } + #[cfg(feature = "rp2040")] + fn pin_base() -> u8 { + 0 + } + + #[cfg(feature = "_rp235x")] + fn pin_base() -> u8 { + if PIO::PIO.gpiobase().read().gpiobase() { + 16 + } else { + 0 + } + } + /// Sets pin directions. This pauses the current state machine to run `SET` commands /// and temporarily unsets the `OUT_STICKY` bit. pub fn set_pin_dirs(&mut self, dir: Direction, pins: &[&Pin<'d, PIO>]) { self.with_paused(|sm| { for pin in pins { Self::this_sm().pinctrl().write(|w| { - w.set_set_base(pin.pin()); + w.set_set_base(pin.pin() - Self::pin_base()); w.set_set_count(1); }); // SET PINDIRS, (dir) @@ -998,7 +1012,7 @@ impl<'d, PIO: Instance + 'd, const SM: usize> StateMachine<'d, PIO, SM> { self.with_paused(|sm| { for pin in pins { Self::this_sm().pinctrl().write(|w| { - w.set_set_base(pin.pin()); + w.set_set_base(pin.pin() - Self::pin_base()); w.set_set_count(1); }); // SET PINS, (dir) @@ -1361,6 +1375,7 @@ impl<'d, PIO: Instance> Pio<'d, PIO> { PIO::state().users.store(5, Ordering::Release); PIO::state().used_pins.store(0, Ordering::Release); PIO::Interrupt::unpend(); + unsafe { PIO::Interrupt::enable() }; Self { common: Common { -- cgit