|
|
@@ -13,8 +13,13 @@ mod assets {
|
|
13
|
13
|
include!(concat!(env!("OUT_DIR"), "/assets.rs"));
|
|
14
|
14
|
}
|
|
15
|
15
|
|
|
|
16
|
+use cortex_m::peripheral::NVIC;
|
|
|
17
|
+use embedded_hal::timer::CountDown;
|
|
16
|
18
|
use mkl25z4_hal::clocks::ClockConfiguration;
|
|
|
19
|
+use mkl25z4_hal::mkl25z4::{Interrupt, LPTMR0};
|
|
17
|
20
|
use mkl25z4_hal::time::{CopyableMonoTimer, NonCopyableMonoTimer, U32Ext};
|
|
|
21
|
+use mkl25z4_hal::timer::Timer;
|
|
|
22
|
+use mkl25z4_hal::timer::TimerInterrupt;
|
|
18
|
23
|
use panic_semihosting as _;
|
|
19
|
24
|
|
|
20
|
25
|
use display::{Display, DisplayState};
|
|
|
@@ -32,6 +37,7 @@ const APP: () = {
|
|
32
|
37
|
bme_pins: Option<BME280Pins>,
|
|
33
|
38
|
radio: Option<Radio>,
|
|
34
|
39
|
time: CopyableMonoTimer,
|
|
|
40
|
+ update_timer: Timer<LPTMR0>,
|
|
35
|
41
|
}
|
|
36
|
42
|
|
|
37
|
43
|
#[init(spawn = [fetch_update])]
|
|
|
@@ -63,6 +69,10 @@ const APP: () = {
|
|
63
|
69
|
|
|
64
|
70
|
let radio = Radio::init(pins.nrf, time);
|
|
65
|
71
|
|
|
|
72
|
+ let update_timer = Timer::lptmr0(ctx.device.LPTMR0, 10.s(), clocks, &mut sim);
|
|
|
73
|
+ update_timer.enable_interrupt();
|
|
|
74
|
+ unsafe { NVIC::unmask(Interrupt::LPTMR0) };
|
|
|
75
|
+
|
|
66
|
76
|
// Fetch the first update.
|
|
67
|
77
|
ctx.spawn.fetch_update().ok();
|
|
68
|
78
|
|
|
|
@@ -83,13 +93,15 @@ const APP: () = {
|
|
83
|
93
|
bme_pins: Some(pins.bme),
|
|
84
|
94
|
radio: Some(radio),
|
|
85
|
95
|
time,
|
|
|
96
|
+ update_timer,
|
|
86
|
97
|
}
|
|
87
|
98
|
}
|
|
88
|
99
|
|
|
89
|
|
- #[task(binds = LPTMR0, priority = 3, spawn = [fetch_update])]
|
|
|
100
|
+ #[task(binds = LPTMR0, priority = 3, spawn = [fetch_update], resources = [update_timer])]
|
|
90
|
101
|
fn lptmr0_interrupt(ctx: lptmr0_interrupt::Context) {
|
|
91
|
102
|
// Restart the timer.
|
|
92
|
|
- // TODO
|
|
|
103
|
+ ctx.resources.update_timer.start(10.s());
|
|
|
104
|
+ ctx.resources.update_timer.enable_interrupt();
|
|
93
|
105
|
|
|
94
|
106
|
// Trigger an update of the displayed values.
|
|
95
|
107
|
ctx.spawn.fetch_update().ok();
|