1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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)
})
}
}
}