From 9ec32ca0a269954f92eec76fd0da72d4b96312bf Mon Sep 17 00:00:00 2001 From: Astro Date: Mon, 18 Mar 2019 21:17:27 +0100 Subject: [PATCH] main: fix wfi, revise leds, unreachable end --- src/main.rs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/main.rs b/src/main.rs index fb6b58e..c214352 100644 --- a/src/main.rs +++ b/src/main.rs @@ -105,36 +105,39 @@ fn main() -> ! { Server::run(iface, |server| { let mut last_output = 0_u32; loop { - led_green.on(); let now = timer::now().0; let instant = Instant::from_millis(now as i64); - server.poll(instant); - led_green.off(); - 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; if now - last_output >= OUTPUT_INTERVAL { + led_red.on(); let adc_value = adc_input.read(); write!(server, "t={},pa3={}\r\n", now, adc_value).unwrap(); last_output = now; + led_red.off(); } - led_blue.off(); // Update watchdog wd.feed(); - led_red.on(); cortex_m::interrupt::free(|cs| { if !net::is_pending(cs) { + led_green.on(); // Wait for interrupts wfi(); - net::clear_pending(cs); + led_green.off(); } }); - led_red.off(); } }); }); - unimplemented!() + unreachable!() }