From 0d2f89db5366ff52f618d9fe1789a6242359a99c Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Thu, 25 Jan 2018 11:06:19 +0800 Subject: [PATCH] si5324: chip does not ack RST_REG write --- artiq/firmware/libboard_artiq/si5324.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/artiq/firmware/libboard_artiq/si5324.rs b/artiq/firmware/libboard_artiq/si5324.rs index 147cb2302..69ed734db 100644 --- a/artiq/firmware/libboard_artiq/si5324.rs +++ b/artiq/firmware/libboard_artiq/si5324.rs @@ -112,6 +112,20 @@ fn write(reg: u8, val: u8) -> Result<()> { Ok(()) } +#[cfg(si5324_soft_reset)] +fn write_no_ack_value(reg: u8, val: u8) -> Result<()> { + i2c::start(BUSNO).unwrap(); + if !i2c::write(BUSNO, (ADDRESS << 1)).unwrap() { + return Err("Si5324 failed to ack write address") + } + if !i2c::write(BUSNO, reg).unwrap() { + return Err("Si5324 failed to ack register") + } + i2c::write(BUSNO, val).unwrap(); + i2c::stop(BUSNO).unwrap(); + Ok(()) +} + fn read(reg: u8) -> Result { i2c::start(BUSNO).unwrap(); if !i2c::write(BUSNO, (ADDRESS << 1)).unwrap() { @@ -135,7 +149,7 @@ fn ident() -> Result { #[cfg(si5324_soft_reset)] fn soft_reset() -> Result<()> { - write(136, read(136)? | 0x80)?; + write_no_ack_value(136, read(136)? | 0x80)?; clock::spin_us(10_000); Ok(()) }