Trait BlockDevice

Source
pub trait BlockDevice<Addr, SPI: Transfer<u8>, CS: OutputPin> {
    // Required methods
    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>>;
}
Expand description

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

Required Methods§

Source

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.
Source

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.

Source

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.

Implementors§

Source§

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