aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpennae <[email protected]>2023-04-25 21:55:33 +0200
committerpennae <[email protected]>2023-05-02 13:44:24 +0200
commit47ae9b79815af97e7e5d8b2f3c94af2326d7fd79 (patch)
tree139a15db23a43ae0f3c67693f0e8bd27b52453c0
parent8e22d574478d7480bc0473ed0ad9dac7d02602a8 (diff)
rp/pio: add funcsel values to PioInstance
makes code setting funcsels easier to read and should make it easier to hook up more pio blocks, should they ever appear
-rw-r--r--embassy-rp/src/pio.rs15
1 files changed, 4 insertions, 11 deletions
diff --git a/embassy-rp/src/pio.rs b/embassy-rp/src/pio.rs
index cab57f765..ecf7c9227 100644
--- a/embassy-rp/src/pio.rs
+++ b/embassy-rp/src/pio.rs
@@ -959,17 +959,7 @@ pub trait PioCommon: sealed::PioCommon + Sized {
959 959
960 fn make_pio_pin(&self, pin: impl Pin) -> PioPin<Self::Pio> { 960 fn make_pio_pin(&self, pin: impl Pin) -> PioPin<Self::Pio> {
961 unsafe { 961 unsafe {
962 pin.io().ctrl().write(|w| { 962 pin.io().ctrl().write(|w| w.set_funcsel(Self::Pio::FUNCSEL.0));
963 w.set_funcsel(
964 if Self::Pio::PIO_NO == 1 {
965 pac::io::vals::Gpio0ctrlFuncsel::PIO1_0
966 } else {
967 // PIO == 0
968 pac::io::vals::Gpio0ctrlFuncsel::PIO0_0
969 }
970 .0,
971 );
972 });
973 } 963 }
974 PioPin { 964 PioPin {
975 pin_bank: pin.pin_bank(), 965 pin_bank: pin.pin_bank(),
@@ -1031,6 +1021,7 @@ mod sealed {
1031 pub trait PioInstance { 1021 pub trait PioInstance {
1032 const PIO_NO: u8; 1022 const PIO_NO: u8;
1033 const PIO: &'static crate::pac::pio::Pio; 1023 const PIO: &'static crate::pac::pio::Pio;
1024 const FUNCSEL: crate::pac::io::vals::Gpio0ctrlFuncsel;
1034 } 1025 }
1035 1026
1036 pub trait PioCommon { 1027 pub trait PioCommon {
@@ -1059,12 +1050,14 @@ pub trait PioInstance: sealed::PioInstance + Unpin {}
1059impl sealed::PioInstance for PioInstanceBase<0> { 1050impl sealed::PioInstance for PioInstanceBase<0> {
1060 const PIO_NO: u8 = 0; 1051 const PIO_NO: u8 = 0;
1061 const PIO: &'static pac::pio::Pio = &pac::PIO0; 1052 const PIO: &'static pac::pio::Pio = &pac::PIO0;
1053 const FUNCSEL: pac::io::vals::Gpio0ctrlFuncsel = pac::io::vals::Gpio0ctrlFuncsel::PIO0_0;
1062} 1054}
1063impl PioInstance for PioInstanceBase<0> {} 1055impl PioInstance for PioInstanceBase<0> {}
1064 1056
1065impl sealed::PioInstance for PioInstanceBase<1> { 1057impl sealed::PioInstance for PioInstanceBase<1> {
1066 const PIO_NO: u8 = 1; 1058 const PIO_NO: u8 = 1;
1067 const PIO: &'static pac::pio::Pio = &pac::PIO1; 1059 const PIO: &'static pac::pio::Pio = &pac::PIO1;
1060 const FUNCSEL: pac::io::vals::Gpio0ctrlFuncsel = pac::io::vals::Gpio0ctrlFuncsel::PIO1_0;
1068} 1061}
1069impl PioInstance for PioInstanceBase<1> {} 1062impl PioInstance for PioInstanceBase<1> {}
1070 1063