use imxrt_hal as hal;
use hal::iomuxc::{self, flexio::Pin};
use paste::paste;
pub trait Pins<const N: u8, const L: usize> {
const PIN_COUNT: u8;
fn configure(&mut self);
const FLEXIO_PIN_OFFSETS: &'static [u8];
}
macro_rules! count {
() => (0u8);
( $x:tt $($xs:tt)* ) => (1u8 + count!($($xs)*));
}
macro_rules! impl_pins {
($($n:literal)+) => {
paste! {
impl<const N: u8, $([<P $n>]: Pin<N>),+> Pins<N, {count!($($n)+) as usize}> for ($([<P $n>]),+,) {
fn configure(&mut self) {
$(
iomuxc::flexio::prepare(&mut self.$n);
)+
}
const PIN_COUNT: u8 = count!($($n)+);
const FLEXIO_PIN_OFFSETS: &'static[u8] = &[$(
[<P $n>]::OFFSET
),+];
}
}
};
}
impl_pins!(0);
impl_pins!(0 1);
impl_pins!(0 1 2);
impl_pins!(0 1 2 3);