From d772a9426504f1632531850a330605d527f3e080 Mon Sep 17 00:00:00 2001 From: mwojcik Date: Mon, 25 Oct 2021 15:58:28 +0800 Subject: [PATCH] rtio_clocking: fix warnings and bypass --- src/runtime/src/rtio_clocking.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/runtime/src/rtio_clocking.rs b/src/runtime/src/rtio_clocking.rs index db4c2e3..53f2192 100644 --- a/src/runtime/src/rtio_clocking.rs +++ b/src/runtime/src/rtio_clocking.rs @@ -1,14 +1,15 @@ use log::{info, warn}; -use libboard_zynq::{timer::GlobalTimer}; +use libboard_zynq::timer::GlobalTimer; use embedded_hal::blocking::delay::DelayMs; use libconfig::Config; use libboard_artiq::pl; +#[cfg(has_si5324)] +use libboard_zynq::i2c::I2c; +#[cfg(has_si5324)] use crate::i2c; - #[cfg(has_si5324)] use libboard_artiq::si5324; - #[derive(Debug, PartialEq, Copy, Clone)] #[allow(non_camel_case_types)] pub enum RtioClock { @@ -90,7 +91,7 @@ fn init_drtio(timer: &mut GlobalTimer) } #[cfg(has_si5324)] -fn setup_si5324(timer: &mut GlobalTimer, clk: RtioClock) { +fn setup_si5324(i2c: &mut I2c, timer: &mut GlobalTimer, clk: RtioClock) { let mut si5324_settings: Option = None; // 125MHz output, from crystal, 7 Hz if si5324_settings.is_none() || clk == RtioClock::Int_125 { @@ -107,8 +108,7 @@ fn setup_si5324(timer: &mut GlobalTimer, clk: RtioClock) { }); } let si5324_ref_input = si5324::Input::Ckin2; - si5324::setup(unsafe { (&mut i2c::I2C_BUS).as_mut().unwrap() }, - &si5324_settings.unwrap(), si5324_ref_input, timer).expect("cannot initialize Si5324"); + si5324::setup(i2c, &si5324_settings.unwrap(), si5324_ref_input, timer).expect("cannot initialize Si5324"); } pub fn init(timer: &mut GlobalTimer, cfg: &Config) { @@ -116,10 +116,11 @@ pub fn init(timer: &mut GlobalTimer, cfg: &Config) { let clk = get_rtio_clock_cfg(cfg); #[cfg(has_si5324)] { + let i2c = unsafe { (&mut i2c::I2C_BUS).as_mut().unwrap() }; let si5324_ext_input = si5324::Input::Ckin2; match clk { - RtioClock::Ext0_Bypass => si5324::bypass(si5324_ext_input).expect("cannot bypass Si5324"), - _ => setup_si5324(timer, clk), + RtioClock::Ext0_Bypass => si5324::bypass(i2c, si5324_ext_input, timer).expect("cannot bypass Si5324"), + _ => setup_si5324(i2c, timer, clk), } } #[cfg(has_drtio)]