pub struct UnlockedFlash<'a> { /* private fields */ }
Expand description

Result of FlashExt::unlocked()

Examples

use stm32f4xx_hal::pac::Peripherals;
use stm32f4xx_hal::flash::{FlashExt, LockedFlash, UnlockedFlash};
use embedded_storage::nor_flash::NorFlash;

let dp = Peripherals::take().unwrap();
let mut flash = LockedFlash::new(dp.FLASH);

// Unlock flash for writing
let mut unlocked_flash = flash.unlocked();

// Erase the second 128 KB sector.
NorFlash::erase(&mut unlocked_flash, 128 * 1024, 256 * 1024).unwrap();

// Write some data at the start of the second 128 KB sector.
let buf = [0u8; 64];
NorFlash::write(&mut unlocked_flash, 128 * 1024, &buf).unwrap();

// Lock flash by dropping
drop(unlocked_flash);

Implementations

Erase a flash sector

Refer to the reference manual to see which sector corresponds to which memory address.

Program bytes with offset into flash memory, aligned to 128-bit rows

Trait Implementations

Automatically lock flash erase/program when leaving scope

Executes the destructor for this type. Read more

The minumum number of bytes the storage peripheral can write

The minumum number of bytes the storage peripheral can erase

Erase the given storage range, clearing all data within [from..to]. The given range will contain all 1s afterwards. Read more

If power is lost during write, the contents of the written words are undefined, but the rest of the page is guaranteed to be unchanged. It is not allowed to write to the same word twice. offset and bytes.len() must both be multiples of WRITE_SIZE. Read more

An enumeration of storage errors

The minumum number of bytes the storage peripheral can read

Read a slice of data from the storage peripheral, starting the read operation at the given address offset, and reading bytes.len() bytes. Read more

The capacity of the peripheral in bytes.

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.

Should always be Self

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.