pub trait Device {
type Error;
// Required methods
fn ce_enable(&mut self);
fn ce_disable(&mut self);
fn send_command<C: Command>(
&mut self,
command: &C,
) -> Result<(Status, C::Response), Self::Error>;
fn write_register<R: Register>(
&mut self,
register: R,
) -> Result<Status, Self::Error>;
fn read_register<R: Register>(&mut self) -> Result<(Status, R), Self::Error>;
fn update_config<F, R>(&mut self, f: F) -> Result<R, Self::Error>
where F: FnOnce(&mut Config) -> R;
// Provided methods
fn with_ce_disabled<F, R>(&mut self, f: F) -> R
where F: FnOnce(&mut Self) -> R { ... }
fn update_register<Reg, F, R>(&mut self, f: F) -> Result<R, Self::Error>
where Reg: Register + PartialEq + Clone,
F: FnOnce(&mut Reg) -> R { ... }
}Expand description
Trait that hides all the GPIO/SPI type parameters for use by the operation modes
Required Associated Types§
Required Methods§
Sourcefn ce_disable(&mut self)
fn ce_disable(&mut self)
Set CE pin low
Sourcefn send_command<C: Command>(
&mut self,
command: &C,
) -> Result<(Status, C::Response), Self::Error>
fn send_command<C: Command>( &mut self, command: &C, ) -> Result<(Status, C::Response), Self::Error>
Send a command via SPI
Sourcefn write_register<R: Register>(
&mut self,
register: R,
) -> Result<Status, Self::Error>
fn write_register<R: Register>( &mut self, register: R, ) -> Result<Status, Self::Error>
Send W_REGISTER command
Sourcefn read_register<R: Register>(&mut self) -> Result<(Status, R), Self::Error>
fn read_register<R: Register>(&mut self) -> Result<(Status, R), Self::Error>
Send R_REGISTER command
Sourcefn update_config<F, R>(&mut self, f: F) -> Result<R, Self::Error>where
F: FnOnce(&mut Config) -> R,
fn update_config<F, R>(&mut self, f: F) -> Result<R, Self::Error>where
F: FnOnce(&mut Config) -> R,
Modify the (cached) CONFIG register and write if it has changed.
Provided Methods§
Sourcefn with_ce_disabled<F, R>(&mut self, f: F) -> Rwhere
F: FnOnce(&mut Self) -> R,
fn with_ce_disabled<F, R>(&mut self, f: F) -> Rwhere
F: FnOnce(&mut Self) -> R,
Helper; the receiving during RX and sending during TX require CE
to be low.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.