pub struct Edata<'d, M: Mode> { /* private fields */ }Expand description
Driver for the EDATA area of a flash bank.
The EDATA area is flash with 16-bit words, each with its own ECC, and a higher endurance
than the rest of the flash. It’s written in units of EDATA_WRITE_SIZE bytes, and erased
in units of EDATA_ERASE_SIZE bytes. It implements NorFlash, so it can store data with
crates like sequential-storage.
The EDATA area must be enabled in the option bytes:
- C5:
EDATA_ENenables 16 pages in each bank. - H5:
EDATAx_ENenables the lastEDATAx_STRT + 1EDATA sectors of bank x. On the parts with the largest flash of the line, they are the last user flash sectors of the bank, which then can’t be used as user flash: reading them through the user flash is a bus error.
capacity() is the size of the area that is enabled, 0 when it’s
disabled. Offsets are relative to the start of the area.
Locations that were not written since they were erased read as 0xFF. A read with an
uncorrectable ECC error returns Error::Ecc.
The reads are done with the instruction cache (ICACHE) disabled, as the EDATA area must not be cached.
Programming or erasing the bank the code runs from stalls the CPU until it’s done. Use the EDATA area of the other bank to avoid it.
Implementations§
Source§impl<'d, M: Mode> Edata<'d, M>
impl<'d, M: Mode> Edata<'d, M>
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Size in bytes of the EDATA area of the bank enabled in the option bytes. 0 if it’s disabled.
Sourcepub fn blocking_read(
&mut self,
offset: u32,
bytes: &mut [u8],
) -> Result<(), Error>
pub fn blocking_read( &mut self, offset: u32, bytes: &mut [u8], ) -> Result<(), Error>
Blocking read.
NOTE: offset is an offset from the start of the EDATA area of the bank.
An uncorrectable ECC error in the data returns Error::Ecc. The contents of bytes
are then unspecified.
Source§impl<'d> Edata<'d, Blocking>
impl<'d> Edata<'d, Blocking>
Sourcepub fn blocking_write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Error>
pub fn blocking_write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Error>
Blocking write.
NOTE: offset is an offset from the start of the EDATA area of the bank.
offset and the length of bytes must be multiples of EDATA_WRITE_SIZE. The 16-bit
words written must not have been written since they were erased: writing a word twice
would corrupt its ECC. If one was, the write returns Error::NotErased without writing
anything.
Sourcepub fn blocking_erase(&mut self, from: u32, to: u32) -> Result<(), Error>
pub fn blocking_erase(&mut self, from: u32, to: u32) -> Result<(), Error>
Blocking erase.
NOTE: from and to are offsets from the start of the EDATA area of the bank. They
must be multiples of EDATA_ERASE_SIZE.