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
|
use trinket_m0::{
clock::GenericClockController,
gpio::{self, Floating, Input},
prelude::*,
sercom::{self, PadPin, SPIMaster1},
PM, SERCOM1,
};
use apa102_spi::Apa102;
pub fn new(
sercom: SERCOM1,
miso: gpio::Pa31<Input<Floating>>,
mosi: gpio::Pa0<Input<Floating>>,
sck: gpio::Pa1<Input<Floating>>,
port: &mut gpio::Port,
pm: &mut PM,
clocks: &mut GenericClockController,
) -> Apa102<
SPIMaster1<
sercom::Sercom1Pad3<gpio::Pa31<gpio::PfD>>,
sercom::Sercom1Pad0<gpio::Pa0<gpio::PfD>>,
sercom::Sercom1Pad1<gpio::Pa1<gpio::PfD>>,
>,
> {
let gclk = clocks.gclk0();
let miso = miso.into_pad(port);
let mosi = mosi.into_pad(port);
let sck = sck.into_pad(port);
let spi = SPIMaster1::new(
&clocks
.sercom1_core(&gclk)
.expect("setting up sercom1 clock"),
3.mhz(),
apa102_spi::MODE,
sercom,
pm,
(miso, mosi, sck),
);
Apa102::new(spi)
}
|