use gpio::{self, IntoFunction, Port};
pub trait PadPin<T> {
fn into_pad(self, port: &mut Port) -> T;
}
macro_rules! pad {
($(pub enum $PadType:ident {
$( $PinType:ident ($new:ident, $Pf:ident),)+
})+
) => {
$(
pub enum $PadType {
$(
$PinType(gpio::$PinType<gpio::$Pf>),
)+
}
impl $PadType {
$(
pub fn $new<MODE>(pin: gpio::$PinType<MODE>, port: &mut Port) -> Self {
$PadType::$PinType(pin.into_function(port))
}
)+
}
$(
impl<MODE> PadPin<$PadType> for gpio::$PinType<MODE> {
fn into_pad(self, port: &mut Port) -> $PadType {
$PadType::$new(self, port)
}
}
)+
)+
};
}
pad!(
pub enum Sercom0Pad0 {
Pa4(pa4, PfD),
Pa8(pa8, PfC),
}
pub enum Sercom0Pad1 {
Pa5(pa5, PfD),
Pa9(pa9, PfC),
}
pub enum Sercom0Pad2 {
Pa6(pa6, PfD),
Pa10(pa10, PfC),
}
pub enum Sercom0Pad3 {
Pa7(pa7, PfD),
Pa11(pa11, PfC),
}
pub enum Sercom1Pad0 {
Pa0(pa0, PfD),
Pa16(pa16, PfC),
}
pub enum Sercom1Pad1 {
Pa1(pa1, PfD),
Pa17(pa17, PfC),
}
pub enum Sercom1Pad2 {
Pa18(pa18, PfC),
Pa30(pa30, PfD),
}
pub enum Sercom1Pad3 {
Pa19(pa19, PfC),
Pa31(pa31, PfD),
}
pub enum Sercom2Pad0 {
Pa8(pa8, PfD),
Pa12(pa12, PfC),
}
pub enum Sercom2Pad1 {
Pa9(pa9, PfD),
Pa13(pa13, PfC),
}
pub enum Sercom2Pad2 {
Pa10(pa10, PfD),
Pa14(pa14, PfC),
}
pub enum Sercom2Pad3 {
Pa11(pa11, PfD),
Pa15(pa15, PfC),
}
pub enum Sercom3Pad0 {
Pa16(pa16, PfD),
Pa22(pa22, PfC),
}
pub enum Sercom3Pad1 {
Pa17(pa17, PfD),
Pa23(pa23, PfC),
}
pub enum Sercom3Pad2 {
Pa18(pa18, PfD),
Pa20(pa20, PfD),
Pa24(pa24, PfC),
}
pub enum Sercom3Pad3 {
Pa19(pa19, PfD),
Pa21(pa21, PfD),
Pa25(pa25, PfC),
}
);
#[cfg(feature = "samd21g18a")]
pad!(
pub enum Sercom4Pad0 {
Pa12(pa12, PfD),
Pb8(pb8, PfD),
Pb12(pb12, PfC),
}
pub enum Sercom4Pad1 {
Pa13(pa13, PfD),
Pb9(pb9, PfD),
Pb13(pb13, PfC),
}
pub enum Sercom4Pad2 {
Pa14(pa14, PfD),
Pb10(pb10, PfD),
Pb14(pb14, PfC),
}
pub enum Sercom4Pad3 {
Pa15(pa15, PfD),
Pb11(pb11, PfD),
Pb15(pb15, PfC),
}
pub enum Sercom5Pad0 {
Pa22(pa22, PfD),
Pb2(pb2, PfD),
Pb16(pb16, PfC),
Pb30(pb30, PfD),
}
pub enum Sercom5Pad1 {
Pa23(pa23, PfD),
Pb3(pb3, PfD),
Pb17(pb17, PfC),
Pb31(pb31, PfD),
}
pub enum Sercom5Pad2 {
Pa24(pa24, PfD),
Pb0(pb0, PfD),
Pa20(pa20, PfC),
Pb22(pb22, PfD),
}
pub enum Sercom5Pad3 {
Pa25(pa25, PfD),
Pb1(pb1, PfD),
Pa21(pa21, PfC),
Pb23(pb23, PfD),
}
);