jesd204sync: print DDMTD SYSREF final alignment delta

This commit is contained in:
Sebastien Bourdeauducq 2019-01-28 18:39:16 +08:00
parent eebff6d77f
commit 1a42e23fb4
1 changed files with 9 additions and 12 deletions

View File

@ -172,18 +172,15 @@ fn max_phase_deviation(average: i32, phases: &[i32]) -> i32 {
return ret;
}
fn reach_sysref_ddmtd_target(target: i32, tolerance: i32) -> Result<(), &'static str> {
let mut phase = measure_ddmdt_phase();
let mut nslips = 0;
while (phase - target).abs() > tolerance {
fn reach_sysref_ddmtd_target(target: i32, tolerance: i32) -> Result<i32, &'static str> {
for _ in 0..1024 {
let delta = (measure_ddmdt_phase() - target + DDMTD_N) % DDMTD_N;
if delta <= tolerance {
return Ok(delta)
}
hmc7043::sysref_slip();
nslips += 1;
if nslips > 1024 {
return Err("failed to reach SYSREF DDMTD phase target");
}
phase = measure_ddmdt_phase();
}
Ok(())
Err("failed to reach SYSREF DDMTD phase target")
}
fn calibrate_sysref_target(rising_average: i32, falling_average: i32) -> Result<i32, &'static str> {
@ -275,11 +272,11 @@ pub fn sysref_auto_rtio_align() -> Result<(), &'static str> {
};
info!("aligning SYSREF with RTIO clock...");
reach_sysref_ddmtd_target(target_phase, 3)?;
let delta = reach_sysref_ddmtd_target(target_phase, 3)?;
if sysref_sh_error() {
return Err("SYSREF does not meet S/H timing at DDMTD phase target");
}
info!(" ...done");
info!(" ...done, delta={}", delta);
sysref_rtio_align()?;