forked from M-Labs/artiq
1
0
Fork 0

hmc7043: check that chip is disabled at startup

This commit is contained in:
Sebastien Bourdeauducq 2018-06-19 23:49:17 +08:00
parent 740e6863c3
commit 3d0e92aefd
1 changed files with 12 additions and 3 deletions

View File

@ -227,10 +227,16 @@ pub mod hmc7043 {
} }
} }
pub fn detect() -> Result<(), &'static str> { pub const CHIP_ID: u32 = 0xf17904;
pub fn get_id() -> u32 {
spi_setup(); spi_setup();
let id = (read(0x78) as u32) << 16 | (read(0x79) as u32) << 8 | read(0x7a) as u32; (read(0x78) as u32) << 16 | (read(0x79) as u32) << 8 | read(0x7a) as u32
if id != 0xf17904 { }
pub fn detect() -> Result<(), &'static str> {
let id = get_id();
if id != CHIP_ID {
error!("invalid HMC7043 ID: 0x{:08x}", id); error!("invalid HMC7043 ID: 0x{:08x}", id);
return Err("invalid HMC7043 identification"); return Err("invalid HMC7043 identification");
} else { } else {
@ -340,6 +346,9 @@ pub fn init() -> Result<(), &'static str> {
hmc830::check_locked()?; hmc830::check_locked()?;
if hmc7043::get_id() == hmc7043::CHIP_ID {
error!("HMC7043 detected while in reset (board rework missing?)");
}
hmc7043::enable(); hmc7043::enable();
hmc7043::detect()?; hmc7043::detect()?;
hmc7043::init(); hmc7043::init();