pub trait Flash<'a> {
// Required methods
fn initialize(
&mut self,
callback: impl FnMut(Event) + 'a,
) -> Result<(), i32>;
fn uninitialize(&mut self) -> Result<(), i32>;
fn read_data(&mut self, addr: u32, data: &mut [u8]) -> Result<(), i32>;
fn program_data(&mut self, addr: u32, data: &[u8]) -> Result<(), i32>;
fn erase_sector(&mut self, addr: u32) -> Result<(), i32>;
fn erase_chip(&mut self) -> Result<(), i32>;
fn get_status(&self) -> Status;
fn get_info(&self) -> &FlashInfo;
}Expand description
A trait that defines a standard interface for a flash memory driver.
Required Methods§
Sourcefn initialize(&mut self, callback: impl FnMut(Event) + 'a) -> Result<(), i32>
fn initialize(&mut self, callback: impl FnMut(Event) + 'a) -> Result<(), i32>
Initializes the flash memory peripheral.
The provided callback will be invoked to signal flash events.
Sourcefn uninitialize(&mut self) -> Result<(), i32>
fn uninitialize(&mut self) -> Result<(), i32>
De-initializes the flash memory peripheral.
Sourcefn read_data(&mut self, addr: u32, data: &mut [u8]) -> Result<(), i32>
fn read_data(&mut self, addr: u32, data: &mut [u8]) -> Result<(), i32>
Reads data from the flash memory.
§Arguments
addr- The starting address to read from.data- A mutable buffer to store the read data.
Sourcefn program_data(&mut self, addr: u32, data: &[u8]) -> Result<(), i32>
fn program_data(&mut self, addr: u32, data: &[u8]) -> Result<(), i32>
Programs data into the flash memory.
§Arguments
addr- The starting address to write to.data- The data to be programmed.
Sourcefn erase_sector(&mut self, addr: u32) -> Result<(), i32>
fn erase_sector(&mut self, addr: u32) -> Result<(), i32>
Erases a single sector of the flash memory.
§Arguments
addr- The address of the sector to be erased. Any address within the sector is usually sufficient.
Sourcefn erase_chip(&mut self) -> Result<(), i32>
fn erase_chip(&mut self) -> Result<(), i32>
Erases the entire flash memory chip.
This is a potentially destructive operation and may not be supported by all devices.
Sourcefn get_status(&self) -> Status
fn get_status(&self) -> Status
Gets the current status of the flash memory device.
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.