From 5c3e834c4d1c6bbede94c2a5bf7b993733edd438 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Fri, 17 Aug 2018 20:52:05 +0800 Subject: [PATCH] ad9154: retry DAC initialization on STPL or PRBS failure Works around #1127 --- artiq/firmware/libboard_artiq/ad9154.rs | 26 +++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/artiq/firmware/libboard_artiq/ad9154.rs b/artiq/firmware/libboard_artiq/ad9154.rs index c210301fd..29e1a901e 100644 --- a/artiq/firmware/libboard_artiq/ad9154.rs +++ b/artiq/firmware/libboard_artiq/ad9154.rs @@ -653,12 +653,25 @@ fn dac_cfg(dacno: u8) -> Result<(), &'static str> { Ok(()) } -fn dac_cfg_retry(dacno: u8) -> Result<(), &'static str> { +fn dac_cfg_and_test(dacno: u8) -> Result<(), &'static str> { + dac_cfg(dacno)?; + dac_prbs(dacno)?; + dac_stpl(dacno, 4, 2)?; + dac_cfg(dacno)?; + Ok(()) +} + +/* + * work around for: + * https://github.com/m-labs/artiq/issues/727 + * https://github.com/m-labs/artiq/issues/1127 + */ +fn dac_cfg_and_test_retry(dacno: u8) -> Result<(), &'static str> { let mut attempt = 0; loop { attempt += 1; dac_reset(dacno); - let outcome = dac_cfg(dacno); + let outcome = dac_cfg_and_test(dacno); match outcome { Ok(_) => return outcome, Err(e) => { @@ -695,16 +708,9 @@ pub fn dac_sync(dacno: u8) -> Result { fn init_dac(dacno: u8) -> Result<(), &'static str> { let dacno = dacno as u8; - dac_reset(dacno); dac_detect(dacno)?; - dac_cfg_retry(dacno)?; - - dac_prbs(dacno)?; - dac_stpl(dacno, 4, 2)?; - - dac_cfg_retry(dacno)?; - + dac_cfg_and_test_retry(dacno)?; Ok(()) }