Struct stm32_hal2::flash::Flash
source · pub struct Flash {
pub regs: FLASH,
}
Fields§
§regs: FLASH
Implementations§
source§impl Flash
impl Flash
sourcepub fn unlock(&mut self) -> Result<(), Error>
pub fn unlock(&mut self) -> Result<(), Error>
Unlock the flash memory, allowing writes. See L4 Reference manual, section 3.3.5. (G4 RM section 5.3.5) “After reset, write is not allowed in the Flash control register (FLASH_CR) to protect the Flash memory against possible unwanted operations due, for example, to electric disturbances.”
pub fn lock(&mut self)
sourcepub fn erase_sector(&mut self, bank: Bank, sector: usize) -> Result<(), Error>
pub fn erase_sector(&mut self, bank: Bank, sector: usize) -> Result<(), Error>
Erase a 128kb sector. See H743 RM, section 4.3.10: FLASH erase operations; subsection Flash sector erase sequence. Note that this is similar to the procedure for other families, but has a different name “sector” vice “page”, and the RM instructions are phrased differently.
sourcepub fn erase_bank(&mut self, bank: Bank) -> Result<(), Error>
pub fn erase_bank(&mut self, bank: Bank) -> Result<(), Error>
Erase one or both banks. Called “Mass erase” on single-bank variants like G4.
sourcepub fn write_sector(
&mut self,
bank: Bank,
sector: usize,
data: &[u8]
) -> Result<(), Error>
pub fn write_sector(
&mut self,
bank: Bank,
sector: usize,
data: &[u8]
) -> Result<(), Error>
Write the contents of a sector. Must be erased first. See H742 or H723-35 RM, section 4.3.9. Make sure the sector is one your MCU has, and isn’t being used for the program itself. Writes a byte array, 256 bits at a time.