pub struct FLASH { /* private fields */ }
Expand description

Entry point to the non-volatile memory (NVM) API

Implementations

Initializes the FLASH peripheral

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.

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 memory
  • address is aligned to a page boundary (32 words, 128 bytes)

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.

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.

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 memory
  • address is aligned to a half-page boundary (16 words, 64 bytes)
  • words has a length of 16

Check for errors.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.