1
0
Fork 0

i2c: disable its usage on Cora Z7-10

This commit is contained in:
Harry Ho 2020-08-10 11:49:21 +08:00
parent 4614ed1371
commit 76a4cac873
2 changed files with 31 additions and 27 deletions

View File

@ -205,34 +205,37 @@ pub fn main_core0() {
} }
// Test I2C // Test I2C
let mut i2c = zynq::i2c::I2C::i2c(); #[cfg(feature = "target_zc706")]
i2c.init(); {
println!("I2C bit-banging enabled"); let mut i2c = zynq::i2c::I2C::i2c();
let mut eeprom = zynq::i2c::eeprom::EEPROM::new(&mut i2c, 16); i2c.init();
// Write to 0x00 and 0x08 println!("I2C bit-banging enabled");
let eeprom_buffer: [u8; 22] = [ let mut eeprom = zynq::i2c::eeprom::EEPROM::new(&mut i2c, 16);
0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, // Write to 0x00 and 0x08
0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, let eeprom_buffer: [u8; 22] = [
0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb,
]; 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee,
eeprom.write(0x00, &eeprom_buffer[0..6]); 0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01,
eeprom.write(0x08, &eeprom_buffer[6..22]); ];
println!("Data written to EEPROM"); eeprom.write(0x00, &eeprom_buffer[0..6]);
let mut eeprom_buffer = [0u8; 24]; eeprom.write(0x08, &eeprom_buffer[6..22]);
// Read from 0x00 println!("Data written to EEPROM");
eeprom.read(0x00, &mut eeprom_buffer); let mut eeprom_buffer = [0u8; 24];
print!("Data read from EEPROM @ 0x00: (hex) "); // Read from 0x00
for i in 0..6 { eeprom.read(0x00, &mut eeprom_buffer);
print!("{:02x} ", eeprom_buffer[i]); 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()); let eth = zynq::eth::Eth::default(HWADDR.clone());
println!("Eth on"); println!("Eth on");

View File

@ -20,6 +20,7 @@ pub mod flash;
pub mod time; pub mod time;
pub mod timer; pub mod timer;
pub mod sdio; pub mod sdio;
#[cfg(feature = "target_zc706")]
pub mod i2c; pub mod i2c;
pub mod logger; pub mod logger;
pub mod ps7_init; pub mod ps7_init;