test
Fork of nrf51-sdk by
FStorage
Module which provides low level functionality to store data to flash. More...
Data Structures | |
struct | fs_config_t |
Flash storage config variable. More... | |
Modules | |
FStorage configuration | |
FStorage configuration. | |
Typedefs | |
typedef void(* | fs_cb_t )(uint8_t op_code, uint32_t result, uint32_t const *p_data, fs_length_t length_words) |
Callback for flash operations. | |
Functions | |
static void | fs_callback (uint8_t op_code, uint32_t result, uint32_t const *p_data, fs_length_t length_words) |
Function prototype for a callback handler. | |
ret_code_t | fs_init (void) |
Function to initialize FStorage. | |
ret_code_t | fs_store (fs_config_t const *p_config, uint32_t const *p_addr, uint32_t const *const p_data, fs_length_t length_words) |
Function to store data in flash. | |
ret_code_t | fs_erase (fs_config_t const *p_config, uint32_t *const p_addr, fs_length_t length_words) |
Function to erase a page in flash. | |
void | fs_sys_event_handler (uint32_t sys_evt) |
Function to call to handle events from the SoftDevice. |
Detailed Description
Module which provides low level functionality to store data to flash.
Typedef Documentation
typedef void(* fs_cb_t)(uint8_t op_code, uint32_t result, uint32_t const *p_data, fs_length_t length_words) |
Callback for flash operations.
- Parameters:
-
[in] op_code Flash access operation code. [in] result Result of the operation. [in] data Pointer to resulting data (or NULL if not in use). [in] length_words Length of data in words.
Definition at line 71 of file fstorage.h.
Function Documentation
static void fs_callback | ( | uint8_t | op_code, |
uint32_t | result, | ||
uint32_t const * | p_data, | ||
fs_length_t | length_words | ||
) | [static] |
Function prototype for a callback handler.
This function is expected to be implemented by the module that registers for fstorage usage. Its usage is described in the function pointer type fs_cb_t.
- Parameters:
-
[in] op_code Flash operation code. [in] result Result of the flash operation. [in] p_data Pointer to the resulting data (or NULL if not in use). [in] length_words Length of data in words.
ret_code_t fs_erase | ( | fs_config_t const * | p_config, |
uint32_t *const | p_addr, | ||
fs_length_t | length_words | ||
) |
Function to erase a page in flash.
- Note:
- The erase address must be aligned on a page boundary. The length in words must be equivalent to the page size.
- Parameters:
-
[in] p_config Pointer to the configuration of the user that requests the operation. [in] p_addr Address of page to erase (the same as first word in the page). [in] length_words Length (in 4 byte words) of the area to erase.
- Return values:
-
NRF_SUCCESS Success. Command queued. NRF_ERROR_INVALID_STATE Error. The module is not initialized. NRF_ERROR_INVALID_ADDR Error. Data is unaligned or invalid configuration. Any error returned by the SoftDevice flash API.
Check that the address is aligned on a page boundary and the length to erase is a multiple of the page size.
Definition at line 484 of file fstorage.c.
ret_code_t fs_init | ( | void | ) |
Function to initialize FStorage.
This function allocates flash data pages according to the number requested in the config variable. The data used to initialize. the fstorage is section placed variables in the data section "fs_data".
Assign pages to registered users, beginning with the ones with the lowest order, which will be assigned pages with the lowest memory address.
Definition at line 409 of file fstorage.c.
ret_code_t fs_store | ( | fs_config_t const * | p_config, |
uint32_t const * | p_addr, | ||
uint32_t const *const | p_data, | ||
fs_length_t | length_words | ||
) |
Function to store data in flash.
- Warning:
- The data to be written to flash has to be kept in memory until the operation has terminated, i.e., a callback is received.
- Parameters:
-
[in] p_config Const pointer to configiguration of module user that requests a store operation. [in] p_addr Write address of store operation. [in] p_data Pointer to the data to store. [in] length_words Length of the data to store.
- Return values:
-
NRF_SUCCESS Success. Command queued. NRF_ERROR_INVALID_STATE Error. The module is not initialized. NRF_ERROR_INVALID_ADDR Error. Data is unaligned or invalid configuration. Any error returned by the SoftDevice flash API.
Definition at line 454 of file fstorage.c.
void fs_sys_event_handler | ( | uint32_t | sys_evt ) |
Function to call to handle events from the SoftDevice.
- Parameters:
-
sys_evt System event from the SoftDevice
Function to call to handle events from the SoftDevice.
This function should be dispatched system events if any of the modules used by the application rely on FStorage. Examples include Peer Manager and Flash Data Storage.
- Parameters:
-
[in] sys_evt System Event received.
A flash operation was initiated by this module. Handle its result.
A flash operation was initiated outside this module. We have now receveid a callback which indicates it has finished. Clear the FS_FLAG_FLASH_REQ_PENDING flag.
Definition at line 524 of file fstorage.c.
Generated on Tue Jul 12 2022 15:51:32 by 1.7.2