forked from M-Labs/artiq
firmware: don't unwrap() but propagate pca9548 errors
This commit is contained in:
parent
a8aabd3815
commit
afe162ceca
|
@ -2,10 +2,10 @@ use i2c;
|
||||||
|
|
||||||
pub fn select(busno: u8, address: u8, channels: u8) -> Result<(), &'static str> {
|
pub fn select(busno: u8, address: u8, channels: u8) -> Result<(), &'static str> {
|
||||||
i2c::start(busno).unwrap();
|
i2c::start(busno).unwrap();
|
||||||
if !i2c::write(busno, address << 1).unwrap() {
|
if !i2c::write(busno, address << 1)? {
|
||||||
return Err("PCA9548 failed to ack write address")
|
return Err("PCA9548 failed to ack write address")
|
||||||
}
|
}
|
||||||
if !i2c::write(busno, channels).unwrap() {
|
if !i2c::write(busno, channels)? {
|
||||||
return Err("PCA9548 failed to ack control word")
|
return Err("PCA9548 failed to ack control word")
|
||||||
}
|
}
|
||||||
i2c::stop(busno).unwrap();
|
i2c::stop(busno).unwrap();
|
||||||
|
|
Loading…
Reference in New Issue