pub trait I2cBus {
// Required methods
fn write(&mut self, address: u8, data: &[u8]) -> Result<(), I2cError>;
fn read(&mut self, address: u8, data: &mut [u8]) -> Result<(), I2cError>;
fn write_read(
&mut self,
address: u8,
data: &[u8],
buffer: &mut [u8],
) -> Result<(), I2cError>;
// Provided method
fn set_delay(&mut self, microseconds: u16) { ... }
}Expand description
I2C master the adapter drives.
Implement it around the bus driver at hand — see the usb_i2c_tiny example
for one wrapping a hardware I2C peripheral. The class translates the host’s
i2c_msg flags: a lone message becomes a write or
read, a write followed by a read becomes a
write_read with a repeated START between the phases.
Required Methods§
Sourcefn write(&mut self, address: u8, data: &[u8]) -> Result<(), I2cError>
fn write(&mut self, address: u8, data: &[u8]) -> Result<(), I2cError>
Write data to the 7-bit address, START to STOP.
An empty slice only probes the address, which is how bus scanning works.
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".