1use imxrt_iomuxc::{self as iomuxc, flexio::Pin};
2
3use paste::paste;
4
5pub trait Pins<const N: u8, const L: usize> {
7 const PIN_COUNT: u8;
9
10 fn configure(&mut self);
15
16 const FLEXIO_PIN_OFFSETS: &'static [u8];
18}
19
20macro_rules! count {
21 () => (0u8);
22 ( $x:tt $($xs:tt)* ) => (1u8 + count!($($xs)*));
23}
24
25macro_rules! impl_pins {
26 ($($n:literal)+) => {
27 paste! {
28 impl<const N: u8, $([<P $n>]: Pin<N>),+> Pins<N, {count!($($n)+) as usize}> for ($([<P $n>]),+,) {
29 fn configure(&mut self) {
30 $(
31 iomuxc::flexio::prepare(&mut self.$n);
32 )+
33 }
34
35 const PIN_COUNT: u8 = count!($($n)+);
36
37 const FLEXIO_PIN_OFFSETS: &'static[u8] = &[$(
38 [<P $n>]::OFFSET
39 ),+];
40 }
41 }
42 };
43}
44
45impl_pins!(0);
46impl_pins!(0 1);
47impl_pins!(0 1 2);
48impl_pins!(0 1 2 3);