From 3c49eba0a0e3ff684da91ce5bb00c9ad126b8157 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Sat, 12 May 2018 00:06:49 +0200 Subject: [PATCH] firmware/hmc830_7043: put hmc7043 in sleep mode before hmc830 initialization hmc7043 seems to generate broadband noise when not initialized. This allows isolating issues. If hmc830 still does not always lock correctly, then this is not related to hmc7043 broadband noise. --- artiq/firmware/libboard_artiq/hmc830_7043.rs | 27 ++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/artiq/firmware/libboard_artiq/hmc830_7043.rs b/artiq/firmware/libboard_artiq/hmc830_7043.rs index fef3c8236..710bdeb03 100644 --- a/artiq/firmware/libboard_artiq/hmc830_7043.rs +++ b/artiq/firmware/libboard_artiq/hmc830_7043.rs @@ -92,7 +92,7 @@ mod hmc830 { } } - pub fn init() -> Result<(), &'static str> { + pub fn detect() -> Result<(), &'static str> { spi_setup(); let id = read(0x00); if id != 0xa7975 { @@ -101,6 +101,12 @@ mod hmc830 { } else { info!("HMC830 found"); } + + Ok(()) + } + + pub fn init() -> Result<(), &'static str> { + spi_setup(); info!("HMC830 configuration..."); for &(addr, data) in HMC830_WRITES.iter() { write(addr, data); @@ -196,7 +202,7 @@ pub mod hmc7043 { } } - pub fn init() -> Result<(), &'static str> { + pub fn detect() -> Result<(), &'static str> { spi_setup(); let id = (read(0x78) as u32) << 16 | (read(0x79) as u32) << 8 | read(0x7a) as u32; if id != 0xf17904 { @@ -205,6 +211,20 @@ pub mod hmc7043 { } else { info!("HMC7043 found"); } + + Ok(()) + } + + pub fn shutdown() -> Result<(), &'static str> { + spi_setup(); + info!("HMC7043 shutdown..."); + write(0x1, 0x1); // Sleep mode + + Ok(()) + } + + pub fn init() -> Result<(), &'static str> { + spi_setup(); info!("HMC7043 configuration..."); write(0x0, 0x1); // Software reset @@ -272,6 +292,9 @@ pub mod hmc7043 { pub fn init() -> Result<(), &'static str> { clock_mux::init(); /* must be the first SPI init because of HMC830 SPI mode selection */ + hmc830::detect()?; + hmc7043::detect()?; + hmc7043::shutdown()?; hmc830::init()?; hmc7043::init() }