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
use stm32f30x::{GPIOE, Gpioe, Rcc};
pub static LEDS: [Led; 8] = [
Led { i: 9 },
Led { i: 10 },
Led { i: 11 },
Led { i: 12 },
Led { i: 13 },
Led { i: 14 },
Led { i: 15 },
Led { i: 8 },
];
pub struct Led {
i: u8,
}
impl Led {
pub fn off(&self) {
unsafe { (*GPIOE.get()).bsrr.write(|w| w.bits(1 << (self.i + 16))) }
}
pub fn on(&self) {
unsafe { (*GPIOE.get()).bsrr.write(|w| w.bits(1 << self.i)) }
}
}
pub fn init(gpioe: &Gpioe, rcc: &Rcc) {
rcc.ahbenr.modify(|_, w| w.iopeen().enabled());
gpioe
.moder
.modify(
|_, w| {
w.moder8()
.output()
.moder9()
.output()
.moder10()
.output()
.moder11()
.output()
.moder12()
.output()
.moder13()
.output()
.moder14()
.output()
.moder15()
.output()
},
);
}