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
This commit is contained in:
pennae 2023-04-25 21:55:33 +02:00
parent 8e22d57447
commit 47ae9b7981

View file

@ -959,17 +959,7 @@ pub trait PioCommon: sealed::PioCommon + Sized {
fn make_pio_pin(&self, pin: impl Pin) -> PioPin<Self::Pio> {
unsafe {
pin.io().ctrl().write(|w| {
w.set_funcsel(
if Self::Pio::PIO_NO == 1 {
pac::io::vals::Gpio0ctrlFuncsel::PIO1_0
} else {
// PIO == 0
pac::io::vals::Gpio0ctrlFuncsel::PIO0_0
}
.0,
);
});
pin.io().ctrl().write(|w| w.set_funcsel(Self::Pio::FUNCSEL.0));
}
PioPin {
pin_bank: pin.pin_bank(),
@ -1031,6 +1021,7 @@ mod sealed {
pub trait PioInstance {
const PIO_NO: u8;
const PIO: &'static crate::pac::pio::Pio;
const FUNCSEL: crate::pac::io::vals::Gpio0ctrlFuncsel;
}
pub trait PioCommon {
@ -1059,12 +1050,14 @@ pub trait PioInstance: sealed::PioInstance + Unpin {}
impl sealed::PioInstance for PioInstanceBase<0> {
const PIO_NO: u8 = 0;
const PIO: &'static pac::pio::Pio = &pac::PIO0;
const FUNCSEL: pac::io::vals::Gpio0ctrlFuncsel = pac::io::vals::Gpio0ctrlFuncsel::PIO0_0;
}
impl PioInstance for PioInstanceBase<0> {}
impl sealed::PioInstance for PioInstanceBase<1> {
const PIO_NO: u8 = 1;
const PIO: &'static pac::pio::Pio = &pac::PIO1;
const FUNCSEL: pac::io::vals::Gpio0ctrlFuncsel = pac::io::vals::Gpio0ctrlFuncsel::PIO1_0;
}
impl PioInstance for PioInstanceBase<1> {}