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
pub enum Tx {}
pub enum Rx {}
pub trait Direction: private::Sealed {}
impl Direction for Tx {}
impl Direction for Rx {}
mod private {
pub trait Sealed {}
impl Sealed for super::Tx {}
impl Sealed for super::Rx {}
}
pub trait Pin: super::Iomuxc {
const ALT: u32;
const DAISY: Option<super::Daisy>;
type Direction: Direction;
type Module: super::consts::Unsigned;
}
pub fn prepare<P: Pin>(pin: &mut P) {
super::alternate(pin, P::ALT);
super::clear_sion(pin);
if let Some(daisy) = P::DAISY {
unsafe { daisy.write() };
}
}
#[allow(unused)] macro_rules! uart {
(module: $module:ty, alt: $alt:expr, pad: $pad:ty, direction: $direction:ty, daisy: $daisy:expr) => {
impl Pin for $pad {
const ALT: u32 = $alt;
const DAISY: Option<Daisy> = $daisy;
type Direction = $direction;
type Module = $module;
}
};
}