rtio_clocking: soft panic if PLL fails to lock

This commit is contained in:
mwojcik 2022-08-25 16:55:12 +08:00
parent e5158ae9c8
commit 93bd962f9b
1 changed files with 19 additions and 1 deletions

View File

@ -1,6 +1,7 @@
use log::{info, warn, error}; use log::{info, warn, error};
use libboard_zynq::timer::GlobalTimer; use libboard_zynq::timer::GlobalTimer;
use embedded_hal::blocking::delay::DelayMs; use embedded_hal::blocking::delay::DelayMs;
use libasync::task;
use libconfig::Config; use libconfig::Config;
use libboard_artiq::pl; use libboard_artiq::pl;
#[cfg(has_si5324)] #[cfg(has_si5324)]
@ -9,6 +10,7 @@ use libboard_zynq::i2c::I2c;
use crate::i2c; use crate::i2c;
#[cfg(has_si5324)] #[cfg(has_si5324)]
use libboard_artiq::si5324; use libboard_artiq::si5324;
use crate::mgmt;
#[derive(Debug, PartialEq, Copy, Clone)] #[derive(Debug, PartialEq, Copy, Clone)]
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
@ -98,7 +100,10 @@ fn init_rtio(timer: &mut GlobalTimer, _clk: RtioClock) {
error!("RTIO PLL failed to lock"); error!("RTIO PLL failed to lock");
#[cfg(feature = "target_kasli_soc")] #[cfg(feature = "target_kasli_soc")]
{ {
pl::csr::error_led::out_write(1); unsafe {
pl::csr::error_led::out_write(1);
}
soft_panic();
// try "soft" panic // try "soft" panic
} }
} }
@ -257,3 +262,16 @@ pub fn init(timer: &mut GlobalTimer, cfg: &Config) {
init_rtio(timer, clk); init_rtio(timer, clk);
} }
#[cfg(feature = "target_kasli_soc")]
fn soft_panic() {
// start mgmt service but nothing else
let cfg = match Config::new() {
Ok(cfg) => cfg,
Err(_) => Config::new_dummy()
};
mgmt::start(cfg);
loop {
task::block_on(task::r#yield());
}
}