pub unsafe trait PPSPin {
type Output;
fn enable(self) -> Self::Output;
}
#[allow(unused_macros)]
macro_rules! impl_pps_pin {
($([$name:ty, $output:ty]),*) => {
$(
unsafe impl super::PPSPin for $name {
type Output = $output;
fn enable(self) -> Self::Output {
self.into_alternate()
}
}
)*
};
}
#[cfg(feature = "stm32f4xx-hal")]
mod impl_pps_pin {
use crate::hal::gpio::{Alternate, Output, PushPull, PB5, PG8};
impl_pps_pin!([PG8<Output<PushPull>>, PG8<Alternate<11>>], [PB5<Output<PushPull>>, PB5<Alternate<11>>]);
}
#[cfg(feature = "stm32f7xx-hal")]
mod impl_pps_pin {
use crate::hal::gpio::{Alternate, Output, PushPull, PB5, PG8};
impl_pps_pin!([PG8<Output<PushPull>>, PG8<Alternate<11>>], [PB5<Output<PushPull>>, PB5<Alternate<11>>]);
}
#[cfg(feature = "stm32f1xx-hal")]
mod impl_pps_pin {
use crate::hal::gpio::{Alternate, Output, PushPull, PB5};
unsafe impl super::PPSPin for PB5<Output<PushPull>> {
type Output = PB5<Alternate<PushPull>>;
fn enable(self) -> Self::Output {
cortex_m::interrupt::free(|_| {
let cr: &mut _ = &mut unsafe { core::mem::transmute(()) };
self.into_alternate_push_pull(cr)
})
}
}
}