diff --git a/src/libboard_artiq/src/drtioaux_proto.rs b/src/libboard_artiq/src/drtioaux_proto.rs index c83da1d..e2fee29 100644 --- a/src/libboard_artiq/src/drtioaux_proto.rs +++ b/src/libboard_artiq/src/drtioaux_proto.rs @@ -308,7 +308,7 @@ impl Packet { writer.write_u8(0x87)?; writer.write_bool(succeeded)?; }, - Packet::I2cPca954xSelectRequest { destination, busno, address, mask } => { + Packet::I2cSwitchSelectRequest { destination, busno, address, mask } => { writer.write_u8(0x88)?; writer.write_u8(destination)?; writer.write_u8(busno)?; diff --git a/src/runtime/src/i2c.rs b/src/runtime/src/i2c.rs index b2c166f..de908f3 100644 --- a/src/runtime/src/i2c.rs +++ b/src/runtime/src/i2c.rs @@ -64,19 +64,19 @@ pub extern fn switch_select(busno: i32, address: i32, mask: i32) { if busno > 0 { artiq_raise!("I2CError", "I2C bus could not be accessed"); } + let ch = match mask { //decode from mainline, PCA9548-centric API + 0x00 => None, + 0x01 => Some(0), + 0x02 => Some(1), + 0x04 => Some(2), + 0x08 => Some(3), + 0x10 => Some(4), + 0x20 => Some(5), + 0x40 => Some(6), + 0x80 => Some(7), + _ => artiq_raise!("I2CError", "switch select supports only one channel") + }; unsafe { - let ch = match mask { //decode from mainline, PCA9548-centric API - 0x00 => None, - 0x01 => Some(0), - 0x02 => Some(1), - 0x04 => Some(2), - 0x08 => Some(3), - 0x10 => Some(4), - 0x20 => Some(5), - 0x40 => Some(6), - 0x80 => Some(7), - _ => { artiq_raise!("I2CError", "switch select supports only one channel"); return } - }; if (&mut I2C_BUS).as_mut().unwrap().pca954x_select(address as u8, ch).is_err() { artiq_raise!("I2CError", "switch select failed"); }