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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#![no_std]
pub use atsamd_hal as hal;
pub use hal::common::*;
pub use hal::pac;
#[cfg(feature = "rt")]
use cortex_m_rt;
#[cfg(feature = "rt")]
pub use cortex_m_rt::entry;
use hal::prelude::*;
use hal::*;
use hal::clock::GenericClockController;
use hal::time::Hertz;
use hal::sercom::{PadPin, UART5};
use gpio::{Floating, Input, PfD, Port};
define_pins!(
struct Pins,
pac: pac,
pin rx = b23,
pin tx = b22,
pin d0 = a22,
pin d1 = a23,
pin d2 = a10,
pin d3 = a11,
pin d4 = b10,
pin d5 = b11,
pin d6 = a20,
pin d7 = a21,
pin mosi = a16,
pin sck = a17,
pin miso = a19,
pin sda = a8,
pin scl = a9,
pin a0 = a2,
pin a1 = b2,
pin a2 = b3,
pin a3 = a4,
pin a4 = a5,
pin a5 = a6,
pin a6 = a7,
pin usb_dn = a24,
pin usb_dp = a25,
pin usb_id = a18,
pin aref = a3,
);
pub fn uart<F: Into<Hertz>>(
clocks: &mut GenericClockController,
baud: F,
sercom5: pac::SERCOM5,
pm: &mut pac::PM,
d13: gpio::Pb23<Input<Floating>>,
d14: gpio::Pb22<Input<Floating>>,
port: &mut Port,
) -> UART5<
hal::sercom::Sercom5Pad3<gpio::Pb23<PfD>>,
hal::sercom::Sercom5Pad2<gpio::Pb22<PfD>>,
(),
(),
> {
let gclk0 = clocks.gclk0();
UART5::new(
&clocks.sercom5_core(&gclk0).unwrap(),
baud.into(),
sercom5,
pm,
(d13.into_pad(port), d14.into_pad(port)),
)
}