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

Read-only flash

Examples

use stm32f4xx_hal::pac::Peripherals;
use stm32f4xx_hal::flash::LockedFlash;
use embedded_storage::nor_flash::ReadNorFlash;

let dp = Peripherals::take().unwrap();
let mut flash = LockedFlash::new(dp.FLASH);
println!("Flash capacity: {}", ReadNorFlash::capacity(&flash));

let mut buf = [0u8; 64];
ReadNorFlash::read(&mut flash, 0x0, &mut buf).unwrap();
println!("First 64 bytes of flash memory: {:?}", buf);

Implementations§

source§

impl LockedFlash

source

pub fn new(flash: FLASH) -> Self

Trait Implementations§

source§

impl ErrorType for LockedFlash

§

type Error = Error

Errors returned by this NOR flash.
source§

impl FlashExt for LockedFlash

source§

fn address(&self) -> usize

Memory-mapped address
source§

fn len(&self) -> usize

Size in bytes
source§

fn unlocked(&mut self) -> UnlockedFlash<'_>

Unlock flash for erasing/programming until this method’s result is dropped
source§

fn dual_bank(&self) -> bool

source§

fn sector(&self, offset: usize) -> Option<FlashSector>

Returns flash memory sector of a given offset. Returns none if offset is out of range.
source§

fn read(&self) -> &[u8]

Returns a read-only view of flash memory
source§

impl ReadNorFlash for LockedFlash

source§

const READ_SIZE: usize = 1usize

The minumum number of bytes the storage peripheral can read
source§

fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error>

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
source§

fn capacity(&self) -> usize

The capacity of the peripheral in bytes.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.