X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=src%2Fapplication%2Fmain.rs;h=444ffd464da0219263f11038f4abd6df6561704d;hb=2c21f04d5a34595ced62860d8273dec306f6a4d6;hp=3523b885fe9a907b081c9b85da75f9d8b3380643;hpb=aa0f0d612a03799423e87e9137765ecb90146f48;p=gps-watch.git diff --git a/src/application/main.rs b/src/application/main.rs index 3523b88..444ffd4 100644 --- a/src/application/main.rs +++ b/src/application/main.rs @@ -30,6 +30,7 @@ extern crate common; mod uart0; use common::buffer::Buffer; +use common::ringbuf::Ringbuf; use common::clock; use common::systick; use common::port; @@ -122,6 +123,20 @@ fn configure_push_buttons() { port::set_pull(port::PORTE, 31, port::Pull::Up); } +fn uart0_try_read() -> Option { + extern { + static mut uart0_rx_buf: Ringbuf; + } + + unsafe { + if uart0_rx_buf.is_empty() { + None + } else { + Some(uart0_rx_buf.read()) + } + } +} + #[no_mangle] pub unsafe extern "C" fn _start() -> ! { clock::configure(); @@ -207,7 +222,7 @@ pub unsafe extern "C" fn _start() -> ! { let mut show_time = false; let old_gps_has_fix = gps_has_fix; - while gps.update(&mut tap) { + while gps.update(&mut tap, uart0_try_read) { prev_tap = tap; show_time = true;