Struct esp_idf_sys::spi_flash_guard_funcs_t
source · [−]#[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:
- 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.
- 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.
- 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
sourceimpl Clone for spi_flash_guard_funcs_t
impl Clone for spi_flash_guard_funcs_t
sourcefn clone(&self) -> spi_flash_guard_funcs_t
fn clone(&self) -> spi_flash_guard_funcs_t
Returns a copy of the value. Read more
1.0.0fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for spi_flash_guard_funcs_t
impl Debug for spi_flash_guard_funcs_t
sourceimpl Default for spi_flash_guard_funcs_t
impl Default for spi_flash_guard_funcs_t
sourcefn default() -> spi_flash_guard_funcs_t
fn default() -> spi_flash_guard_funcs_t
Returns the “default value” for a type. Read more
impl Copy for spi_flash_guard_funcs_t
Auto Trait Implementations
impl RefUnwindSafe for spi_flash_guard_funcs_t
impl Send for spi_flash_guard_funcs_t
impl Sync for spi_flash_guard_funcs_t
impl Unpin for spi_flash_guard_funcs_t
impl UnwindSafe for spi_flash_guard_funcs_t
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstablefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
fn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
Uses borrowed data to replace owned data, usually by cloning. Read more