Trait spi_flash::FlashAccess
source · [−]pub trait FlashAccess {
type Error;
fn exchange(&mut self, data: &[u8]) -> Result<Vec<u8>, Self::Error>;
fn write(&mut self, data: &[u8]) -> Result<(), Self::Error> { ... }
fn delay(&mut self, duration: Duration) { ... }
}
Expand description
Trait for objects which provide access to SPI flash.
Providers only need to implement exchange()
, which asserts CS, writes all the bytes
in data
, then returns all the received bytes. If it provides a performance optimisation,
providers may also implement write()
, which does not require the received data.
From<FlashAccess::Error>
must be implemented for spi_flash::Error
; for example in your
implementation code, add:
impl From<MyError> for spi_flash::Error {
fn from(err: MyError) -> spi_flash::Error {
spi_flash::Error::Access(err.into())
}
}
Required Associated Types
Required Methods
Provided Methods
Assert CS, write all bytes in data
to the SPI bus, then de-assert CS.