aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaleb Jamison <[email protected]>2024-09-16 12:47:07 -0400
committerCaleb Jamison <[email protected]>2024-09-16 12:47:34 -0400
commit9cfde66446ca5451a6cab80e0f2f783199fbeb62 (patch)
tree7929e365b7ffc8f6c0fc19003500f1893fe3d0d6
parent48fd0550d1569a44a6b58a41423b0f86270fb373 (diff)
Move pin isolation config to make_pio_pin
-rw-r--r--embassy-rp/src/pio/mod.rs31
1 files changed, 5 insertions, 26 deletions
diff --git a/embassy-rp/src/pio/mod.rs b/embassy-rp/src/pio/mod.rs
index ace597f00..b08f2df6b 100644
--- a/embassy-rp/src/pio/mod.rs
+++ b/embassy-rp/src/pio/mod.rs
@@ -655,10 +655,6 @@ impl<'d, PIO: Instance> Config<'d, PIO> {
655 655
656 /// Set pin used to signal jump. 656 /// Set pin used to signal jump.
657 pub fn set_jmp_pin(&mut self, pin: &Pin<'d, PIO>) { 657 pub fn set_jmp_pin(&mut self, pin: &Pin<'d, PIO>) {
658 #[cfg(feature = "_rp235x")]
659 pin.pin.pad_ctrl().modify(|w| {
660 w.set_iso(false);
661 });
662 self.exec.jmp_pin = pin.pin(); 658 self.exec.jmp_pin = pin.pin();
663 } 659 }
664 660
@@ -668,12 +664,6 @@ impl<'d, PIO: Instance> Config<'d, PIO> {
668 pub fn set_set_pins(&mut self, pins: &[&Pin<'d, PIO>]) { 664 pub fn set_set_pins(&mut self, pins: &[&Pin<'d, PIO>]) {
669 assert!(pins.len() <= 5); 665 assert!(pins.len() <= 5);
670 assert_consecutive(pins); 666 assert_consecutive(pins);
671 #[cfg(feature = "_rp235x")]
672 for pin in pins {
673 pin.pin.pad_ctrl().modify(|w| {
674 w.set_iso(false);
675 })
676 }
677 self.pins.set_base = pins.first().map_or(0, |p| p.pin()); 667 self.pins.set_base = pins.first().map_or(0, |p| p.pin());
678 self.pins.set_count = pins.len() as u8; 668 self.pins.set_count = pins.len() as u8;
679 } 669 }
@@ -683,12 +673,6 @@ impl<'d, PIO: Instance> Config<'d, PIO> {
683 /// effective. 673 /// effective.
684 pub fn set_out_pins(&mut self, pins: &[&Pin<'d, PIO>]) { 674 pub fn set_out_pins(&mut self, pins: &[&Pin<'d, PIO>]) {
685 assert_consecutive(pins); 675 assert_consecutive(pins);
686 #[cfg(feature = "_rp235x")]
687 for pin in pins {
688 pin.pin.pad_ctrl().modify(|w| {
689 w.set_iso(false);
690 })
691 }
692 self.pins.out_base = pins.first().map_or(0, |p| p.pin()); 676 self.pins.out_base = pins.first().map_or(0, |p| p.pin());
693 self.pins.out_count = pins.len() as u8; 677 self.pins.out_count = pins.len() as u8;
694 } 678 }
@@ -698,12 +682,6 @@ impl<'d, PIO: Instance> Config<'d, PIO> {
698 /// effective. 682 /// effective.
699 pub fn set_in_pins(&mut self, pins: &[&Pin<'d, PIO>]) { 683 pub fn set_in_pins(&mut self, pins: &[&Pin<'d, PIO>]) {
700 assert_consecutive(pins); 684 assert_consecutive(pins);
701 #[cfg(feature = "_rp235x")]
702 for pin in pins {
703 pin.pin.pad_ctrl().modify(|w| {
704 w.set_iso(false);
705 })
706 }
707 self.pins.in_base = pins.first().map_or(0, |p| p.pin()); 685 self.pins.in_base = pins.first().map_or(0, |p| p.pin());
708 self.in_count = pins.len() as u8; 686 self.in_count = pins.len() as u8;
709 } 687 }
@@ -778,10 +756,7 @@ impl<'d, PIO: Instance + 'd, const SM: usize> StateMachine<'d, PIO, SM> {
778 config.pins.set_base + config.pins.set_count, 756 config.pins.set_base + config.pins.set_count,
779 config.pins.out_base, 757 config.pins.out_base,
780 config.pins.out_base + config.pins.out_count, 758 config.pins.out_base + config.pins.out_count,
781 ] 759 ] {
782 .iter()
783 .flatten()
784 {
785 low_ok &= pin < 32; 760 low_ok &= pin < 32;
786 high_ok &= pin >= 16; 761 high_ok &= pin >= 16;
787 } 762 }
@@ -1080,6 +1055,10 @@ impl<'d, PIO: Instance> Common<'d, PIO> {
1080 pub fn make_pio_pin(&mut self, pin: impl Peripheral<P = impl PioPin + 'd> + 'd) -> Pin<'d, PIO> { 1055 pub fn make_pio_pin(&mut self, pin: impl Peripheral<P = impl PioPin + 'd> + 'd) -> Pin<'d, PIO> {
1081 into_ref!(pin); 1056 into_ref!(pin);
1082 pin.gpio().ctrl().write(|w| w.set_funcsel(PIO::FUNCSEL as _)); 1057 pin.gpio().ctrl().write(|w| w.set_funcsel(PIO::FUNCSEL as _));
1058 #[cfg(feature = "_rp235x")]
1059 pin.pad_ctrl().modify(|w| {
1060 w.set_iso(false);
1061 });
1083 // we can be relaxed about this because we're &mut here and nothing is cached 1062 // we can be relaxed about this because we're &mut here and nothing is cached
1084 PIO::state().used_pins.fetch_or(1 << pin.pin_bank(), Ordering::Relaxed); 1063 PIO::state().used_pins.fetch_or(1 << pin.pin_bank(), Ordering::Relaxed);
1085 Pin { 1064 Pin {