From 76a4cac87307b2acba3c4bab2084db54988832cf Mon Sep 17 00:00:00 2001 From: Harry Ho Date: Mon, 10 Aug 2020 11:49:21 +0800 Subject: [PATCH] i2c: disable its usage on Cora Z7-10 --- experiments/src/main.rs | 57 +++++++++++++++++++++------------------- libboard_zynq/src/lib.rs | 1 + 2 files changed, 31 insertions(+), 27 deletions(-) diff --git a/experiments/src/main.rs b/experiments/src/main.rs index 91bea19..17b12ff 100644 --- a/experiments/src/main.rs +++ b/experiments/src/main.rs @@ -205,34 +205,37 @@ pub fn main_core0() { } // Test I2C - let mut i2c = zynq::i2c::I2C::i2c(); - i2c.init(); - println!("I2C bit-banging enabled"); - let mut eeprom = zynq::i2c::eeprom::EEPROM::new(&mut i2c, 16); - // Write to 0x00 and 0x08 - let eeprom_buffer: [u8; 22] = [ - 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, - 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, - 0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01, - ]; - eeprom.write(0x00, &eeprom_buffer[0..6]); - eeprom.write(0x08, &eeprom_buffer[6..22]); - println!("Data written to EEPROM"); - let mut eeprom_buffer = [0u8; 24]; - // Read from 0x00 - eeprom.read(0x00, &mut eeprom_buffer); - print!("Data read from EEPROM @ 0x00: (hex) "); - for i in 0..6 { - print!("{:02x} ", eeprom_buffer[i]); + #[cfg(feature = "target_zc706")] + { + let mut i2c = zynq::i2c::I2C::i2c(); + i2c.init(); + println!("I2C bit-banging enabled"); + let mut eeprom = zynq::i2c::eeprom::EEPROM::new(&mut i2c, 16); + // Write to 0x00 and 0x08 + let eeprom_buffer: [u8; 22] = [ + 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, + 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, + 0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01, + ]; + eeprom.write(0x00, &eeprom_buffer[0..6]); + eeprom.write(0x08, &eeprom_buffer[6..22]); + println!("Data written to EEPROM"); + let mut eeprom_buffer = [0u8; 24]; + // Read from 0x00 + eeprom.read(0x00, &mut eeprom_buffer); + print!("Data read from EEPROM @ 0x00: (hex) "); + for i in 0..6 { + print!("{:02x} ", eeprom_buffer[i]); + } + println!(""); + // Read from 0x08 + eeprom.read(0x08, &mut eeprom_buffer); + print!("Data read from EEPROM @ 0x08: (hex) "); + for i in 0..16 { + print!("{:02x} ", eeprom_buffer[i]); + } + println!(""); } - println!(""); - // Read from 0x08 - eeprom.read(0x08, &mut eeprom_buffer); - print!("Data read from EEPROM @ 0x08: (hex) "); - for i in 0..16 { - print!("{:02x} ", eeprom_buffer[i]); - } - println!(""); let eth = zynq::eth::Eth::default(HWADDR.clone()); println!("Eth on"); diff --git a/libboard_zynq/src/lib.rs b/libboard_zynq/src/lib.rs index 8c6daf4..12343b2 100644 --- a/libboard_zynq/src/lib.rs +++ b/libboard_zynq/src/lib.rs @@ -20,6 +20,7 @@ pub mod flash; pub mod time; pub mod timer; pub mod sdio; +#[cfg(feature = "target_zc706")] pub mod i2c; pub mod logger; pub mod ps7_init;