Flash operations

nRF5 SDK v15.0.0

Typedefs

typedef void(* nrf_dfu_flash_callback_t )(void *p_buf)
nrf_fstorage event handler function for DFU fstorage operations. More...

Functions

ret_code_t nrf_dfu_flash_init (bool sd_irq_initialized)
Function for initializing the flash module. More...
ret_code_t nrf_dfu_flash_store (uint32_t dest, void const *p_src, uint32_t len, nrf_dfu_flash_callback_t callback)
Function for storing data to flash. More...
ret_code_t nrf_dfu_flash_erase (uint32_t page_addr, uint32_t num_pages, nrf_dfu_flash_callback_t callback)
Function for erasing data from flash. More...

Detailed Description

Typedef Documentation

typedef void(* nrf_dfu_flash_callback_t)(void *p_buf)

nrf_fstorage event handler function for DFU fstorage operations.

This function will be called after a flash operation has completed.

Function Documentation

ret_code_t nrf_dfu_flash_erase ( uint32_t page_addr ,
uint32_t num_pages ,
nrf_dfu_flash_callback_t callback
)

Function for erasing data from flash.

This functions is asynchronous when the SoftDevice is enabled and synchronous when the SoftDevice is not present or disabled. In both cases, if a callback function is provided, it will be called when the operation has completed.

Parameters
[in] page_addr The address of the first flash page to be deleted.
[in] num_pages The number of flash pages to be deleted.
[in] callback Callback function.
Return values
NRF_SUCCESS If the operation was successful.
NRF_ERROR_INVALID_STATE If nrf_dfu_flash is not initialized.
NRF_ERROR_INVALID_ADDR If page_addr is not aligned to a page boundary or the operation would go beyond the flash memory boundaries.
NRF_ERROR_INVALID_LENGTH If num_pages is zero.
NRF_ERROR_NULL If page_addr is NULL.
NRF_ERROR_NO_MEM If the queue of nrf_fstorage is full.
ret_code_t nrf_dfu_flash_init ( bool sd_irq_initialized )

Function for initializing the flash module.

Depending on whether or not the SoftDevice is present and its IRQ have been initialized, this function initializes the correct Flash storage (fstorage) backend.

Parameters
[in] sd_irq_initialized Whether or not the SoftDevice IRQ have been initialized.
Return values
NRF_SUCCESS If the operation was successful.
ret_code_t nrf_dfu_flash_store ( uint32_t dest ,
void const * p_src ,
uint32_t len ,
nrf_dfu_flash_callback_t callback
)

Function for storing data to flash.

This functions is asynchronous when the SoftDevice is enabled and synchronous when the SoftDevice is not present or disabled. In both cases, if a callback function is provided, it will be called when the operation has completed.

Note
The content of p_src should be kept in memory until the operation has completed.
Parameters
[in] dest The address where the data should be stored.
[in] p_src Pointer to the address where the data should be copied from. This address can be in flash or RAM.
[in] len The number of bytes to be copied from p_src to dest .
[in] callback Callback function.
Return values
NRF_SUCCESS If the operation was successful.
NRF_ERROR_INVALID_STATE If nrf_dfu_flash is not initialized.
NRF_ERROR_INVALID_ADDR If p_src or dest is not word-aligned.
NRF_ERROR_INVALID_LENGTH If len is zero.
NRF_ERROR_NULL If p_src is NULL.
NRF_ERROR_NO_MEM If nrf_fstorage is out of memory.