From 87894102e504d8cd24f20dde1a1e619d851c42a2 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Thu, 28 Nov 2019 17:49:02 +0800 Subject: [PATCH] si549: use recommended i2c read sequence --- artiq/firmware/libboard_artiq/wrpll.rs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/artiq/firmware/libboard_artiq/wrpll.rs b/artiq/firmware/libboard_artiq/wrpll.rs index 0a075beff..d27b90767 100644 --- a/artiq/firmware/libboard_artiq/wrpll.rs +++ b/artiq/firmware/libboard_artiq/wrpll.rs @@ -105,16 +105,6 @@ mod i2c { half_period(); } - pub fn restart(dcxo: Dcxo) { - // Set SCL low then SDA high */ - scl_o(dcxo, false); - half_period(); - sda_oe(dcxo, false); - half_period(); - // Do a regular start - start(dcxo); - } - pub fn stop(dcxo: Dcxo) { // First, make sure SCL is low, so that the target releases the SDA line scl_o(dcxo, false); @@ -223,12 +213,15 @@ mod si549 { if !i2c::write(dcxo, reg) { return Err("Si549 failed to ack register") } - i2c::restart(dcxo); + i2c::stop(dcxo); + + i2c::start(dcxo); if !i2c::write(dcxo, (ADDRESS << 1) | 1) { return Err("Si549 failed to ack read address") } let val = i2c::read(dcxo, false); i2c::stop(dcxo); + Ok(val) }