main: fix wfi, revise leds, unreachable end

This commit is contained in:
Astro 2019-03-18 21:17:27 +01:00
parent 9af94e7616
commit 9ec32ca0a2
1 changed files with 12 additions and 9 deletions

View File

@ -105,36 +105,39 @@ fn main() -> ! {
Server::run(iface, |server| { Server::run(iface, |server| {
let mut last_output = 0_u32; let mut last_output = 0_u32;
loop { loop {
led_green.on();
let now = timer::now().0; let now = timer::now().0;
let instant = Instant::from_millis(now as i64); let instant = Instant::from_millis(now as i64);
server.poll(instant);
led_green.off();
led_blue.on(); led_blue.on();
cortex_m::interrupt::free(net::clear_pending);
server.poll(instant)
.unwrap_or_else(|e| {
warn!("poll: {:?}", e);
});
led_blue.off();
let now = timer::now().0; let now = timer::now().0;
if now - last_output >= OUTPUT_INTERVAL { if now - last_output >= OUTPUT_INTERVAL {
led_red.on();
let adc_value = adc_input.read(); let adc_value = adc_input.read();
write!(server, "t={},pa3={}\r\n", now, adc_value).unwrap(); write!(server, "t={},pa3={}\r\n", now, adc_value).unwrap();
last_output = now; last_output = now;
led_red.off();
} }
led_blue.off();
// Update watchdog // Update watchdog
wd.feed(); wd.feed();
led_red.on();
cortex_m::interrupt::free(|cs| { cortex_m::interrupt::free(|cs| {
if !net::is_pending(cs) { if !net::is_pending(cs) {
led_green.on();
// Wait for interrupts // Wait for interrupts
wfi(); wfi();
net::clear_pending(cs); led_green.off();
} }
}); });
led_red.off();
} }
}); });
}); });
unimplemented!() unreachable!()
} }