Struct stm32_hal2::flash::Flash

source ·
pub struct Flash {
    pub regs: FLASH,
}

Fields§

§regs: FLASH

Implementations§

source§

impl Flash

source

pub fn new(regs: FLASH) -> Self

Create a struct used to perform operations on Flash.

source

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

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)

source

pub fn erase_sector(&mut self, bank: Bank, sector: usize) -> Result<(), Error>

Erase a 128kb sector. See H743 RM, section 4.3.10: FLASH erase operations; subsection Flash sector erase sequence. Note that this is similar to the procedure for other families, but has a different name “sector” vice “page”, and the RM instructions are phrased differently.

source

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

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

source

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

Write the contents of a sector. Must be erased first. See H742 or H723-35 RM, section 4.3.9. Make sure the sector is one your MCU has, and isn’t being used for the program itself. Writes a byte array, 256 bits at a time.

source

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

Erase a page, then write to it. Make sure the sector is one your MCU has, and isn’t being used for the program itself.

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 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 Twhere
T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere
U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.