aboutsummaryrefslogtreecommitdiff
path: root/embassy-rp/src
diff options
context:
space:
mode:
authorAdrian Wowk <[email protected]>2025-08-20 13:44:56 -0500
committerDario Nieuwenhuis <[email protected]>2025-09-05 20:41:07 +0200
commit815ba8aa7507d0aa27dfb3f3823793e3567719f8 (patch)
tree7dfaa5b0435e7210410f7f730d78a774c44707d6 /embassy-rp/src
parent51373065752693c1e49d8d9df7c4452d0f62b7f3 (diff)
rp: read pio gpiobase in set_pins and set_pin_dirs
Diffstat (limited to 'embassy-rp/src')
-rw-r--r--embassy-rp/src/pio/mod.rs19
1 files changed, 17 insertions, 2 deletions
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> {
977 self.set_enable(enabled); 977 self.set_enable(enabled);
978 } 978 }
979 979
980 #[cfg(feature = "rp2040")]
981 fn pin_base() -> u8 {
982 0
983 }
984
985 #[cfg(feature = "_rp235x")]
986 fn pin_base() -> u8 {
987 if PIO::PIO.gpiobase().read().gpiobase() {
988 16
989 } else {
990 0
991 }
992 }
993
980 /// Sets pin directions. This pauses the current state machine to run `SET` commands 994 /// Sets pin directions. This pauses the current state machine to run `SET` commands
981 /// and temporarily unsets the `OUT_STICKY` bit. 995 /// and temporarily unsets the `OUT_STICKY` bit.
982 pub fn set_pin_dirs(&mut self, dir: Direction, pins: &[&Pin<'d, PIO>]) { 996 pub fn set_pin_dirs(&mut self, dir: Direction, pins: &[&Pin<'d, PIO>]) {
983 self.with_paused(|sm| { 997 self.with_paused(|sm| {
984 for pin in pins { 998 for pin in pins {
985 Self::this_sm().pinctrl().write(|w| { 999 Self::this_sm().pinctrl().write(|w| {
986 w.set_set_base(pin.pin()); 1000 w.set_set_base(pin.pin() - Self::pin_base());
987 w.set_set_count(1); 1001 w.set_set_count(1);
988 }); 1002 });
989 // SET PINDIRS, (dir) 1003 // SET PINDIRS, (dir)
@@ -998,7 +1012,7 @@ impl<'d, PIO: Instance + 'd, const SM: usize> StateMachine<'d, PIO, SM> {
998 self.with_paused(|sm| { 1012 self.with_paused(|sm| {
999 for pin in pins { 1013 for pin in pins {
1000 Self::this_sm().pinctrl().write(|w| { 1014 Self::this_sm().pinctrl().write(|w| {
1001 w.set_set_base(pin.pin()); 1015 w.set_set_base(pin.pin() - Self::pin_base());
1002 w.set_set_count(1); 1016 w.set_set_count(1);
1003 }); 1017 });
1004 // SET PINS, (dir) 1018 // SET PINS, (dir)
@@ -1361,6 +1375,7 @@ impl<'d, PIO: Instance> Pio<'d, PIO> {
1361 PIO::state().users.store(5, Ordering::Release); 1375 PIO::state().users.store(5, Ordering::Release);
1362 PIO::state().used_pins.store(0, Ordering::Release); 1376 PIO::state().used_pins.store(0, Ordering::Release);
1363 PIO::Interrupt::unpend(); 1377 PIO::Interrupt::unpend();
1378
1364 unsafe { PIO::Interrupt::enable() }; 1379 unsafe { PIO::Interrupt::enable() };
1365 Self { 1380 Self {
1366 common: Common { 1381 common: Common {