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
#![no_std]
pub use atsamd_hal as hal;
pub use hal::common::*;
pub use hal::pac;
#[cfg(feature = "rt")]
extern crate cortex_m_rt;
#[cfg(feature = "rt")]
pub use cortex_m_rt::entry;
use hal::prelude::*;
use hal::*;
use gpio::{Floating, Input, PfD, Port};
use hal::clock::GenericClockController;
use hal::sercom::{PadPin, UART0};
use hal::time::Hertz;
define_pins!(
struct Pins,
pac: pac,
pin d0 = a4,
pin d1 = a2,
pin d2 = a5,
pin d13 = a23,
pin mosi = a0,
pin sck = a1,
);
pub fn uart<F: Into<Hertz>>(
clocks: &mut GenericClockController,
baud: F,
sercom0: pac::SERCOM0,
pm: &mut pac::PM,
d2: gpio::Pa5<Input<Floating>>,
d0: gpio::Pa4<Input<Floating>>,
port: &mut Port,
) -> UART0<hal::sercom::Sercom0Pad1<gpio::Pa5<PfD>>, hal::sercom::Sercom0Pad0<gpio::Pa4<PfD>>, (), ()>
{
let gclk0 = clocks.gclk0();
UART0::new(
&clocks.sercom0_core(&gclk0).unwrap(),
baud.into(),
sercom0,
pm,
(d2.into_pad(port), d0.into_pad(port)),
)
}