forked from M-Labs/artiq
1
0
Fork 0

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.
This commit is contained in:
Florent Kermarrec 2018-05-12 00:06:49 +02:00
parent cd4477864a
commit 3c49eba0a0
1 changed files with 25 additions and 2 deletions

View File

@ -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()
}