flash_algorithm

Trait FlashAlgorithm

Source
pub trait FlashAlgorithm: Sized + 'static {
    // Required methods
    fn new(
        address: u32,
        clock: u32,
        function: Function,
    ) -> Result<Self, ErrorCode>;
    fn erase_all(&mut self) -> Result<(), ErrorCode>;
    fn erase_sector(&mut self, address: u32) -> Result<(), ErrorCode>;
    fn program_page(
        &mut self,
        address: u32,
        data: &[u8],
    ) -> Result<(), ErrorCode>;
}

Required Methods§

Source

fn new(address: u32, clock: u32, function: Function) -> Result<Self, ErrorCode>

Initialize the flash algorithm.

It can happen that the flash algorithm does not need any specific initialization for the function to be executed or no initialization at all. It is up to the implementor to decide this.

§Arguments
  • address - The start address of the flash region to program.
  • clock - The clock speed in Hertz for programming the device.
  • function - The function for which this initialization is for.
Source

fn erase_all(&mut self) -> Result<(), ErrorCode>

Erase entire chip. Will only be called after FlashAlgorithm::new() with Function::Erase.

Source

fn erase_sector(&mut self, address: u32) -> Result<(), ErrorCode>

Erase sector. Will only be called after FlashAlgorithm::new() with Function::Erase.

§Arguments
  • address - The start address of the flash sector to erase.
Source

fn program_page(&mut self, address: u32, data: &[u8]) -> Result<(), ErrorCode>

Program bytes. Will only be called after FlashAlgorithm::new() with Function::Program.

§Arguments
  • address - The start address of the flash page to program.
  • data - The data to be written to the page.

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.

Implementors§