pub struct Flash { /* private fields */ }Expand description
Flash driver providing safe access to the MCXA276 internal flash via ROM API.
The driver holds an internal FlashConfig that is initialised by the ROM
API’s flash_init function during construction. All subsequent operations
pass this config to the ROM API.
Implementations§
Source§impl Flash
impl Flash
Sourcepub fn new() -> Result<Self, Error>
pub fn new() -> Result<Self, Error>
Create and initialise a new flash driver.
This calls the ROM API flash_init to populate the internal flash
configuration. Returns an error if the ROM API reports failure.
Sourcepub fn blocking_erase(&mut self, address: u32, len: u32) -> Result<(), Error>
pub fn blocking_erase(&mut self, address: u32, len: u32) -> Result<(), Error>
Erase flash sectors encompassing the given absolute address range.
address: absolute start address (must be sector-aligned).len: number of bytes to erase (must be a multiple of sector size).
Runs inside a critical section and clears caches afterwards.
Sourcepub fn blocking_program_phrase(
&mut self,
address: u32,
data: &[u8],
) -> Result<(), Error>
pub fn blocking_program_phrase( &mut self, address: u32, data: &[u8], ) -> Result<(), Error>
Program a phrase (16 bytes) of data at the given absolute address.
address: absolute start address (must be phrase-aligned).data: source buffer whose length must be a multiple ofPHRASE_SIZE.
Runs inside a critical section and clears caches afterwards.
Sourcepub fn blocking_program(
&mut self,
address: u32,
data: &[u8],
) -> Result<(), Error>
pub fn blocking_program( &mut self, address: u32, data: &[u8], ) -> Result<(), Error>
Program a page of data at the given absolute address.
address: absolute start address (must be page-aligned).data: source buffer whose length must be a multiple ofPAGE_SIZE.
Runs inside a critical section and clears caches afterwards.
Sourcepub fn verify_program(
&mut self,
address: u32,
expected: &[u8],
) -> Result<(), Error>
pub fn verify_program( &mut self, address: u32, expected: &[u8], ) -> Result<(), Error>
Verify that the programmed data at address matches expected.
On mismatch, returns Error::RomApi with the ROM status code.
Sourcepub fn verify_erase_sector(
&mut self,
address: u32,
len: u32,
) -> Result<(), Error>
pub fn verify_erase_sector( &mut self, address: u32, len: u32, ) -> Result<(), Error>
Verify that the sector(s) starting at address are erased.
Sourcepub fn blocking_read_rom(
&mut self,
address: u32,
dest: &mut [u8],
) -> Result<(), Error>
pub fn blocking_read_rom( &mut self, address: u32, dest: &mut [u8], ) -> Result<(), Error>
Read flash data using the ROM API.
address: absolute start address.dest: destination buffer.
Sourcepub fn blocking_read(&self, offset: u32, dest: &mut [u8]) -> Result<(), Error>
pub fn blocking_read(&self, offset: u32, dest: &mut [u8]) -> Result<(), Error>
Read flash data by direct memory-mapped access (no ROM API call).
offset: byte offset from flash base (0x0000_0000).dest: destination buffer.
Sourcepub fn rom_api_version(&self) -> u32
pub fn rom_api_version(&self) -> u32
Return the ROM API version.
Sourcepub fn get_property(&mut self, property: FlashProperty) -> Result<u32, Error>
pub fn get_property(&mut self, property: FlashProperty) -> Result<u32, Error>
Get a ROM API flash property value.