pub trait Device: Releasable {
type Error;
// Required methods
fn read_many(
&mut self,
reg: Register,
buffer: &mut [u8]
) -> Result<(), Self::Error>;
fn write(&mut self, reg: Register, val: u8) -> Result<(), Self::Error>;
fn write_many(
&mut self,
reg: Register,
buffer: &[u8]
) -> Result<(), Self::Error>;
// Provided methods
fn read(&mut self, reg: Register) -> Result<u8, Self::Error> { ... }
fn modify<F>(&mut self, reg: Register, f: F) -> Result<(), Self::Error>
where F: FnOnce(u8) -> u8 { ... }
}
Expand description
An MPU communication device abstraction
This allows us to generalize the device over either an I2C or SPI peripheral
Required Associated Types§
Required Methods§
sourcefn read_many(
&mut self,
reg: Register,
buffer: &mut [u8]
) -> Result<(), Self::Error>
fn read_many( &mut self, reg: Register, buffer: &mut [u8] ) -> Result<(), Self::Error>
Read many values from register