#[repr(C)]
pub struct spi_flash_guard_funcs_t { pub start: spi_flash_guard_start_func_t, pub end: spi_flash_guard_end_func_t, pub op_lock: spi_flash_op_lock_func_t, pub op_unlock: spi_flash_op_unlock_func_t, pub is_safe_write_address: spi_flash_is_safe_write_address_t, pub yield_: spi_flash_os_yield_t, }
Expand description

Structure holding SPI flash access critical sections management functions.

Flash API uses two types of flash access management functions:

  1. Functions which prepare/restore flash cache and interrupts before calling appropriate ROM functions (SPIWrite, SPIRead and SPIEraseBlock):
  • ‘start’ function should disables flash cache and non-IRAM interrupts and is invoked before the call to one of ROM function above.
  • ‘end’ function should restore state of flash cache and non-IRAM interrupts and is invoked after the call to one of ROM function above. These two functions are not recursive.
  1. Functions which synchronizes access to internal data used by flash API. This functions are mostly intended to synchronize access to flash API internal data in multithreaded environment and use OS primitives:
  • ‘op_lock’ locks access to flash API internal data.
  • ‘op_unlock’ unlocks access to flash API internal data. These two functions are recursive and can be used around the outside of multiple calls to ‘start’ & ‘end’, in order to create atomic multi-part flash operations.
  1. When CONFIG_SPI_FLASH_DANGEROUS_WRITE_ALLOWED is disabled, flash writing/erasing API checks for addresses provided by user to avoid corruption of critical flash regions (bootloader, partition table, running application etc.).

Different versions of the guarding functions should be used depending on the context of execution (with or without functional OS). In normal conditions when flash API is called from task the functions use OS primitives. When there is no OS at all or when it is not guaranteed that OS is functional (accessing flash from exception handler) these functions cannot use OS primitives or even does not need them (multithreaded access is not possible).

@note Structure and corresponding guard functions should not reside in flash. For example structure can be placed in DRAM and functions in IRAM sections.

Fields

start: spi_flash_guard_start_func_t

< critical section start function.

end: spi_flash_guard_end_func_t

< critical section end function.

op_lock: spi_flash_op_lock_func_t

< flash access API lock function.

op_unlock: spi_flash_op_unlock_func_t

< flash access API unlock function.

is_safe_write_address: spi_flash_is_safe_write_address_t

< checks flash write addresses.

yield_: spi_flash_os_yield_t

< yield to the OS during flash erase

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

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 resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

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.