Struct Flash

Source
pub struct Flash {
    pub regs: FLASH,
}

Fields§

§regs: FLASH

Implementations§

Source§

impl Flash

Source

pub fn unlock(&mut self) -> Result<()>

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.”

Source

pub fn lock(&mut self) -> Result<()>

Source

pub fn erase_page(&mut self, bank: Bank, page: usize) -> Result<()>

Erase an entire page. See L4 Reference manual, section 3.3.5. For why this is required, reference L4 RM, section 3.3.7: “Programming in a previously programmed address is not allowed except if the data to write is full zero, and any attempt will set PROGERR flag in the Flash status register (FLASH_SR).”

Source

pub fn erase_bank(&mut self, bank: Bank) -> Result<()>

Erase one or both banks. Called “Mass erase” on single-bank variants like G4.

Source

pub fn write_page(&mut self, bank: Bank, page: usize, data: &[u8]) -> Result<()>

Write the contents of a page. Must be erased first. See L4 RM, section 3.3.7. Make sure the page is one your MCU has, and isn’t being used for the program itself.

Source

pub fn erase_write_page( &mut self, bank: Bank, page: usize, data: &[u8], ) -> Result<()>

Erase a page, then write to it.

Source§

impl Flash

Contains code common to both modules.

Source

pub fn new(regs: FLASH) -> Self

Create a struct used to perform operations on Flash.

Source

pub fn read(&self, bank: Bank, page: usize, offset: usize, buf: &mut [u8])

Read flash memory at a given page and offset into an 8-bit-dword buffer.

Auto Trait Implementations§

§

impl Freeze for Flash

§

impl !RefUnwindSafe for Flash

§

impl Send for Flash

§

impl !Sync for Flash

§

impl Unpin for Flash

§

impl UnwindSafe for Flash

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>,

Source§

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>,

Source§

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.