From 4846f2891b3e4370047f77a14da85bd0bd1cd7b2 Mon Sep 17 00:00:00 2001 From: Astro Date: Wed, 22 Jul 2020 23:58:55 +0200 Subject: [PATCH] use blocking timer api, update microseconds api --- src/runtime/src/logger.rs | 2 +- src/runtime/src/main.rs | 18 +++++++----------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/runtime/src/logger.rs b/src/runtime/src/logger.rs index dc0de14..0a7b97e 100644 --- a/src/runtime/src/logger.rs +++ b/src/runtime/src/logger.rs @@ -90,7 +90,7 @@ impl Log for BufferLogger { if self.enabled(record.metadata()) { let timestamp = unsafe { GlobalTimer::get() - }.get_us(); + }.get_us().0; let seconds = timestamp / 1_000_000; let micros = timestamp % 1_000_000; diff --git a/src/runtime/src/main.rs b/src/runtime/src/main.rs index 62e5cae..06494ca 100644 --- a/src/runtime/src/main.rs +++ b/src/runtime/src/main.rs @@ -10,13 +10,13 @@ extern crate alloc; use core::{cmp, str}; use log::{info, warn, error}; -use libboard_zynq::{timer::GlobalTimer, time::Milliseconds, devc, slcr}; +use libboard_zynq::{timer::GlobalTimer, devc, slcr}; use libasync::{task, block_async}; use libsupport_zynq::ram; use libregister::RegisterW; use nb; use void::Void; -use embedded_hal::timer::CountDown; +use embedded_hal::blocking::delay::DelayMs; mod sd_reader; mod config; @@ -89,7 +89,7 @@ fn identifier_read(buf: &mut [u8]) -> &str { } } -fn init_rtio(timer: GlobalTimer, cfg: &config::Config) { +fn init_rtio(timer: &mut GlobalTimer, cfg: &config::Config) { let clock_sel = if let Ok(rtioclk) = cfg.read_str("rtioclk") { match rtioclk.as_ref() { @@ -117,17 +117,13 @@ fn init_rtio(timer: GlobalTimer, cfg: &config::Config) { pl::csr::rtio_crg::clock_sel_write(clock_sel); } - let mut countdown = timer.countdown(); - countdown.start(Milliseconds(2)); - nb::block!(countdown.wait()).unwrap(); + timer.delay_ms(2); unsafe { pl::csr::rtio_crg::pll_reset_write(0); } - let mut countdown = timer.countdown(); - countdown.start(Milliseconds(2)); - nb::block!(countdown.wait()).unwrap(); + timer.delay_ms(2); let locked = unsafe { pl::csr::rtio_crg::pll_locked_read() != 0 }; if !locked { @@ -175,7 +171,7 @@ static mut LOG_BUFFER: [u8; 1<<17] = [0; 1<<17]; #[no_mangle] pub fn main_core0() { - let timer = GlobalTimer::start(); + let mut timer = GlobalTimer::start(); let buffer_logger = unsafe { logger::BufferLogger::new(&mut LOG_BUFFER[..]) @@ -199,7 +195,7 @@ pub fn main_core0() { } }; - init_rtio(timer, &cfg); + init_rtio(&mut timer, &cfg); task::spawn(report_async_rtio_errors()); comms::main(timer, &cfg);