i2c: add stubs for targets without i2c

This commit is contained in:
Astro 2020-11-11 14:17:46 +01:00
parent 7c336f7770
commit 9259cffeb2
1 changed files with 80 additions and 47 deletions

View File

@ -1,5 +1,7 @@
use libboard_zynq;
#[cfg(feature = "target_zc706")]
mod i2c {
use crate::artiq_raise;
static mut I2C_BUS: Option<libboard_zynq::i2c::I2c> = None;
@ -66,3 +68,34 @@ pub fn init() {
i2c.init().expect("I2C bus initialization failed");
unsafe { I2C_BUS = Some(i2c) };
}
}
#[cfg(not(feature = "target_zc706"))]
mod i2c {
use crate::artiq_raise;
pub extern fn start(_busno: i32) {
artiq_raise!("I2CError", "No I2C bus");
}
pub extern fn restart(_busno: i32) {
artiq_raise!("I2CError", "No I2C bus");
}
pub extern fn stop(_busno: i32) {
artiq_raise!("I2CError", "No I2C bus");
}
pub extern fn write(_busno: i32, _data: i32) -> bool {
artiq_raise!("I2CError", "No I2C bus");
}
pub extern fn read(_busno: i32, _ack: bool) -> i32 {
artiq_raise!("I2CError", "No I2C bus");
}
pub fn init() {
}
}
pub use i2c::*;