[][src]Trait spi_memory::BlockDevice

pub trait BlockDevice<Addr, SPI: Transfer<u8>, CS: OutputPin> {
    fn erase_sectors(
        &mut self,
        addr: Addr,
        amount: usize
    ) -> Result<(), Error<SPI, CS>>;
fn erase_all(&mut self) -> Result<(), Error<SPI, CS>>;
fn write_bytes(
        &mut self,
        addr: Addr,
        data: &mut [u8]
    ) -> Result<(), Error<SPI, CS>>; }

A trait for writing and erasing operations on a memory chip.

Required methods

fn erase_sectors(
    &mut self,
    addr: Addr,
    amount: usize
) -> Result<(), Error<SPI, CS>>

Erases sectors from the memory chip.

Parameters

  • addr: The address to start erasing at. If the address is not on a sector boundary, the lower bits can be ignored in order to make it fit.

fn erase_all(&mut self) -> Result<(), Error<SPI, CS>>

Erases the memory chip fully.

Warning: Full erase operations can take a significant amount of time. Check your device's datasheet for precise numbers.

fn write_bytes(
    &mut self,
    addr: Addr,
    data: &mut [u8]
) -> Result<(), Error<SPI, CS>>

Writes bytes onto the memory chip. This method is supposed to assume that the sectors it is writing to have already been erased and should not do any erasing themselves.

Parameters

  • addr: The address to write to.
  • data: The bytes to write to addr.
Loading content...

Implementors

impl<SPI: Transfer<u8>, CS: OutputPin> BlockDevice<u32, SPI, CS> for Flash<SPI, CS>[src]

Loading content...