pub struct Flash<SPI: Transfer<u8>, CS: OutputPin> { /* private fields */ }
Expand description
Driver for 25-series SPI Flash chips.
§Type Parameters
SPI
: The SPI master to which the flash chip is attached.CS
: The Chip-Select line attached to the\CS
/\CE
pin of the flash chip.
Implementations§
Source§impl<SPI: Transfer<u8>, CS: OutputPin> Flash<SPI, CS>
impl<SPI: Transfer<u8>, CS: OutputPin> Flash<SPI, CS>
Sourcepub fn init(spi: SPI, cs: CS) -> Result<Self, Error<SPI, CS>>
pub fn init(spi: SPI, cs: CS) -> Result<Self, Error<SPI, CS>>
Creates a new 25-series flash driver.
§Parameters
spi
: An SPI master. Must be configured to operate in the correct mode for the device.cs
: The Chip-Select Pin connected to the\CS
/\CE
pin of the flash chip. Will be driven low when accessing the device.
Sourcepub fn read_jedec_id(&mut self) -> Result<Identification, Error<SPI, CS>>
pub fn read_jedec_id(&mut self) -> Result<Identification, Error<SPI, CS>>
Reads the JEDEC manufacturer/device identification.
Sourcepub fn read_status(&mut self) -> Result<Status, Error<SPI, CS>>
pub fn read_status(&mut self) -> Result<Status, Error<SPI, CS>>
Reads the status register.
Trait Implementations§
Source§impl<SPI: Transfer<u8>, CS: OutputPin> BlockDevice<u32, SPI, CS> for Flash<SPI, CS>
impl<SPI: Transfer<u8>, CS: OutputPin> BlockDevice<u32, SPI, CS> for Flash<SPI, CS>
Source§fn erase_sectors(
&mut self,
addr: u32,
amount: usize,
) -> Result<(), Error<SPI, CS>>
fn erase_sectors( &mut self, addr: u32, amount: usize, ) -> Result<(), Error<SPI, CS>>
Erases sectors from the memory chip. Read more
Source§impl<SPI: Transfer<u8>, CS: OutputPin> Read<u32, SPI, CS> for Flash<SPI, CS>
impl<SPI: Transfer<u8>, CS: OutputPin> Read<u32, SPI, CS> for Flash<SPI, CS>
Source§fn read(&mut self, addr: u32, buf: &mut [u8]) -> Result<(), Error<SPI, CS>>
fn read(&mut self, addr: u32, buf: &mut [u8]) -> Result<(), Error<SPI, CS>>
Reads flash contents into buf
, starting at addr
.
Note that addr
is not fully decoded: Flash chips will typically only
look at the lowest N
bits needed to encode their size, which means
that the contents are “mirrored” to addresses that are a multiple of the
flash size. Only 24 bits of addr
are transferred to the device in any
case, limiting the maximum size of 25-series SPI flash chips to 16 MiB.
§Parameters
addr
: 24-bit address to start reading at.buf
: Destination buffer to fill.
Auto Trait Implementations§
impl<SPI, CS> Freeze for Flash<SPI, CS>
impl<SPI, CS> RefUnwindSafe for Flash<SPI, CS>where
SPI: RefUnwindSafe,
CS: RefUnwindSafe,
impl<SPI, CS> Send for Flash<SPI, CS>
impl<SPI, CS> Sync for Flash<SPI, CS>
impl<SPI, CS> Unpin for Flash<SPI, CS>
impl<SPI, CS> UnwindSafe for Flash<SPI, CS>where
SPI: UnwindSafe,
CS: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more