Module which provides functionality to store data to flash and erase flash pages. More...
Modules | |
fstorage configuration | |
fstorage configuration options. | |
Data Structures | |
struct | fs_evt_t |
An fstorage event. More... | |
struct | fs_config_t |
fstorage application-specific configuration. More... | |
Macros | |
#define | FS_REGISTER_CFG(cfg_var) NRF_SECTION_VARS_ADD(fs_data, cfg_var) |
Macro for registering with an fstorage configuration. Applications which use fstorage must register with the module using this macro. Registering involves defining a variable which holds the configuration of fstorage specific to the application which invokes the macro. More... | |
Typedefs | |
typedef void(* | fs_cb_t )(fs_evt_t const *const evt, fs_ret_t result) |
fstorage event handler function prototype. More... | |
Enumerations | |
enum | fs_ret_t { FS_SUCCESS, FS_ERR_NOT_INITIALIZED, FS_ERR_INVALID_CFG, FS_ERR_NULL_ARG, FS_ERR_INVALID_ARG, FS_ERR_INVALID_ADDR, FS_ERR_UNALIGNED_ADDR, FS_ERR_QUEUE_FULL, FS_ERR_OPERATION_TIMEOUT, FS_ERR_INTERNAL } |
fstorage return values. More... | |
enum | fs_evt_id_t { FS_EVT_STORE, FS_EVT_ERASE } |
fstorage event IDs. More... | |
Functions | |
fs_ret_t | fs_init (void) |
Function for initializing the module. More... | |
fs_ret_t | fs_store (fs_config_t const *const p_config, uint32_t const *const p_dest, uint32_t const *const p_src, uint16_t length_words) |
Function for storing data in flash. More... | |
fs_ret_t | fs_erase (fs_config_t const *const p_config, uint32_t const *const p_page_addr, uint16_t num_pages) |
Function for erasing flash pages. More... | |
fs_ret_t | fs_queued_op_count_get (uint32_t *const p_op_count) |
Function for retrieving the number of queued flash operations. More... | |
void | fs_sys_event_handler (uint32_t sys_evt) |
Function for handling system events from the SoftDevice. More... | |
Module which provides functionality to store data to flash and erase flash pages.
#define FS_REGISTER_CFG | ( | cfg_var | ) | NRF_SECTION_VARS_ADD(fs_data, cfg_var) |
Macro for registering with an fstorage configuration. Applications which use fstorage must register with the module using this macro. Registering involves defining a variable which holds the configuration of fstorage specific to the application which invokes the macro.
This macro places the configuration variable in a section named "fs_data" that fstorage uses during initialization and regular operation.
[in] | cfg_var | A definition of a fs_config_t variable. |
fstorage event handler function prototype.
[in] | evt | The event. |
[in] | result | The result of the operation. |
enum fs_evt_id_t |
enum fs_ret_t |
fstorage return values.
fs_ret_t fs_erase | ( | fs_config_t const *const | p_config, |
uint32_t const *const | p_page_addr, | ||
uint16_t | num_pages | ||
) |
Function for erasing flash pages.
Starting from the page at p_page_addr
, erases num_pages
flash pages. p_page_addr
must be aligned to a page boundary. All pages to be erased must be within the bounds specified in the supplied fstorage configuration. This function is asynchronous. Completion is reported via an event.
[in] | p_config | fstorage configuration registered by the application. |
[in] | p_page_addr | Address of the page to erase. Must be aligned to a page boundary. |
[in] | num_pages | Number of pages to erase. May not be zero. |
FS_SUCCESS | If the operation was queued successfully. |
FS_ERR_NOT_INITIALIZED | If the module is not initialized. |
FS_ERR_INVALID_CFG | If p_config is NULL or contains invalid data. |
FS_ERR_NULL_ARG | If p_page_addr is NULL. |
FS_ERR_INVALID_ARG | If num_pages is zero. |
FS_ERR_INVALID_ADDR | If the operation would go beyond the flash memory boundaries specified in p_config . |
FS_ERR_UNALIGNED_ADDR | If p_page_addr is not aligned to a page boundary. |
FS_ERR_QUEUE_FULL | If the internal operation queue is full. |
fs_ret_t fs_init | ( | void | ) |
Function for initializing the module.
This functions assigns pages in flash according to all registered configurations.
FS_SUCCESS | If the module was successfully initialized. |
fs_ret_t fs_queued_op_count_get | ( | uint32_t *const | p_op_count | ) |
Function for retrieving the number of queued flash operations.
[out] | p_op_count | The number of queued flash operations. |
FS_SUCCESS | If the number of queued operations was retrieved successfully. |
FS_ERR_NULL_ARG | If p_op_count is NULL. |
fs_ret_t fs_store | ( | fs_config_t const *const | p_config, |
uint32_t const *const | p_dest, | ||
uint32_t const *const | p_src, | ||
uint16_t | length_words | ||
) |
Function for storing data in flash.
Copies length_words
words from p_src
to the location pointed by p_dest
. If the length of the data exceeds FS_MAX_WRITE_SIZE_WORDS, the data will be written down in several chunks, as necessary. Only one event will be sent to the application upon completion. Both the source and the destination of the data must be word aligned. This function is asynchronous, completion is reported via an event sent the the callback function specified in the supplied configuration.
[in] | p_config | fstorage configuration registered by the application. |
[in] | p_dest | The address in flash memory where to store the data. |
[in] | p_src | Pointer to the data to store in flash. |
[in] | length_words | Length of the data to store, in words. |
FS_SUCCESS | If the operation was queued successfully. |
FS_ERR_NOT_INITIALIZED | If the module is not initialized. |
FS_ERR_INVALID_CFG | If p_config is NULL or contains invalid data. |
FS_ERR_NULL_ARG | If p_dest or p_src are NULL. |
FS_ERR_INVALID_ARG | If length_words is zero. |
FS_ERR_INVALID_ADDR | If p_dest or p_src are outside of the flash memory boundaries specified in p_config . |
FS_ERR_UNALIGNED_ADDR | If p_dest or p_src are not aligned to a word boundary. |
FS_ERR_QUEUE_FULL | If the internal operation queue is full. |
void fs_sys_event_handler | ( | uint32_t | sys_evt | ) |
Function for handling system events from the SoftDevice.
If any of the modules used by the application rely on fstorage, the application should dispatch system events to fstorage using this function.
[in] | sys_evt | System event from the SoftDevice. |