Expand description
Flash driver for MCXA276 using ROM API.
This module provides safe access to the MCXA276’s internal flash memory through the ROM-resident flash driver API. The ROM API lives at a fixed address and exposes flash operations (init, erase, program, verify, read) via a function pointer table.
§Flash Geometry (MCXA276)
- Base address:
0x0000_0000 - Total size: 1 MB (
0x10_0000) - Sector size: 8 KB (
0x2000) — erase granularity - Page size: 128 bytes — program granularity
- Phrase size: 16 bytes — minimum program unit
§Safety
All flash-modifying operations (erase, program) run inside a critical section to prevent interrupts from executing code in flash while it is being modified. After each modifying operation, speculation buffers and the LPCAC are cleared to ensure subsequent reads return fresh data.
§Example
use embassy_mcxa::flash::Flash;
use embedded_storage::nor_flash::{NorFlash, ReadNorFlash};
let mut flash = Flash::new();
// Erase a sector at offset 0xFE000 (near the end of 1 MB flash)
flash.erase(0xFE000, 0x10_0000).unwrap();
// Program 128 bytes at that offset (must be a multiple of 16-byte phrase size)
let data = [0xABu8; 128];
flash.write(0xFE000, &data).unwrap();
// Read back
let mut buf = [0u8; 128];
flash.read(0xFE000, &mut buf).unwrap();
assert_eq!(buf, data);Structs§
- Flash
- Flash driver providing safe access to the MCXA276 internal flash via ROM API.
Enums§
- Error
- Errors that can occur during flash operations.
- Flash
Property - Flash property identifiers (ROM API
flash_get_property).
Constants§
- FLASH_
BASE - Base address of the internal program flash.
- FLASH_
SIZE - Total size of the internal program flash in bytes (1 MB).
- PAGE_
SIZE - Page size in bytes (128) — program-page granularity.
- PHRASE_
SIZE - Phrase size in bytes (16) — minimum program unit.
- SECTOR_
SIZE - Sector size in bytes (8 KB) — erase granularity.