Struct stm32l0xx_hal::flash::FLASH
source · [−]pub struct FLASH { /* private fields */ }
Expand description
Entry point to the non-volatile memory (NVM) API
Implementations
sourceimpl FLASH
impl FLASH
sourcepub fn set_wait_states(&mut self, wait_states: LATENCY_A)
pub fn set_wait_states(&mut self, wait_states: LATENCY_A)
Set wait states
By default, the number of wait states is zero. This is not suitable for all configurations. Depending on the processor’s voltage range and frequency, it might be necessary to set the number of wait states to 1.
This is explained, for example, in the STM32L0x2 Reference Manual, section 3.3.3.
sourcepub fn erase_flash_page(&mut self, address: *mut u32) -> Result<(), Error>
pub fn erase_flash_page(&mut self, address: *mut u32) -> Result<(), Error>
Erases a page of flash memory
Attention: You must make sure that your program is not executed from the same Flash bank that the page is being erased in. Either make sure your program is executed from another Flash bank, or run it from main memory.
Panics
This method will panic, unless all of the following is true:
address
points to Flash memoryaddress
is aligned to a page boundary (32 words, 128 bytes)
sourcepub fn write_word(&mut self, address: *mut u32, word: u32) -> Result<(), Error>
pub fn write_word(&mut self, address: *mut u32, word: u32) -> Result<(), Error>
Writes a word to Flash memory or EEPROM
Please note that any access to Flash or EEPROM on the same memory bank will be stalled until this operation completes.
If you use this method to write to Flash memory, the address must have been erased before, otherwise this method will return an error.
Panics
Panics, if address
does not point to Flash memory or EEPROM.
sourcepub fn write_byte(&mut self, address: *mut u8, byte: u8) -> Result<(), Error>
pub fn write_byte(&mut self, address: *mut u8, byte: u8) -> Result<(), Error>
Writes a single byte to EEPROM
Please note that any access to Flash or EEPROM on the same memory bank will be stalled until this operation completes.
Constant Time Writes
Note that the write operation does not complete in constant time. If
all bits of the current value in EEPROM are set to 0, the new value is
written directly in Tprog
(3.2 ms on the STM32L0x1). Otherwise, an
erase operation is executed first, resulting in a total duration of
2xTprog
(6.4 ms on the STM32L0x1).
If constant time writes are important, you could set the FIX bit to force the memory interface to always execute an erase before writing new data. However, this is not currently supported in the HAL.
Panics
Panics, if address
does not point to EEPROM.
sourcepub fn write_flash_half_page(
&mut self,
address: *mut u32,
words: &[u32]
) -> Result<(), Error>
pub fn write_flash_half_page(
&mut self,
address: *mut u32,
words: &[u32]
) -> Result<(), Error>
Writes a half-page (16 words) of Flash memory
The memory written to must have been erased before, otherwise this method will return an error.
Panics
This method will panic, unless all of the following is true:
address
points to Flash memoryaddress
is aligned to a half-page boundary (16 words, 64 bytes)words
has a length of 16
sourcepub fn check_errors(&self) -> Result<(), Error>
pub fn check_errors(&self) -> Result<(), Error>
Check for errors.
Auto Trait Implementations
impl RefUnwindSafe for FLASH
impl Send for FLASH
impl !Sync for FLASH
impl Unpin for FLASH
impl UnwindSafe for FLASH
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more