nRF51 SDK v10.0.0
Modules | Data Structures | Macros | Typedefs | Enumerations | Functions

Module which provides low level functionality to store data to flash. More...

Modules

 FStorage configuration
 FStorage configuration.
 

Data Structures

struct  fs_config_t
 Flash storage config variable. More...
 

Macros

#define FS_SECTION_VARS_ADD(type_def)   NRF_SECTION_VARS_ADD(fs_data, type_def)
 Macro for registering of flash storage configuration variable. More...
 

Typedefs

typedef uint16_t fs_length_t
 
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. More...
 

Enumerations

enum  fs_oper_t {
  FS_OP_NONE = 0,
  FS_OP_STORE = 1,
  FS_OP_ERASE = 2
}
 

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. More...
 
ret_code_t fs_init (void)
 Function to initialize FStorage. More...
 
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. More...
 
ret_code_t fs_erase (fs_config_t const *p_config, uint32_t *const p_addr, fs_length_t length_words)
 
void fs_sys_event_handler (uint32_t sys_evt)
 Function to call to handle events from the SoftDevice. More...
 

Detailed Description

Module which provides low level functionality to store data to flash.

Macro Definition Documentation

#define FS_SECTION_VARS_ADD (   type_def)    NRF_SECTION_VARS_ADD(fs_data, type_def)

Macro for registering of flash storage configuration variable.

This macro is expected to be invoked in the code unit that that require flash storage. Invoking this places the registered configuration variable in a section named "fs_data" that the fstorage module uses during initialization and regular operation.

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_codeFlash access operation code.
[in]resultResult of the operation.
[in]dataPointer to resulting data (or NULL if not in use).
[in]length_wordsLength of data in words.

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_codeFlash operation code.
[in]resultResult of the flash operation.
[in]p_dataPointer to the resulting data (or NULL if not in use).
[in]length_wordsLength 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_configPointer to the configuration of the user that requests the operation.
[in]p_addrAddress of page to erase (the same as first word in the page).
[in]length_wordsLength (in 4 byte words) of the area to erase.
Return values
NRF_SUCCESSSuccess. Command queued.
NRF_ERROR_INVALID_STATEError. The module is not initialized.
NRF_ERROR_INVALID_ADDRError. Data is unaligned or invalid configuration.
Anyerror returned by the SoftDevice flash API.
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".

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_configConst pointer to configiguration of module user that requests a store operation.
[in]p_addrWrite address of store operation.
[in]p_dataPointer to the data to store.
[in]length_wordsLength of the data to store.
Return values
NRF_SUCCESSSuccess. Command queued.
NRF_ERROR_INVALID_STATEError. The module is not initialized.
NRF_ERROR_INVALID_ADDRError. Data is unaligned or invalid configuration.
Anyerror returned by the SoftDevice flash API.
void fs_sys_event_handler ( uint32_t  sys_evt)

Function to call to handle events from the SoftDevice.

Parameters
sys_evtSystem event from the SoftDevice

This document was last updated on Mon Nov 9 2015.
Please send us your feedback about the documentation! For technical questions, visit the Nordic Developer Zone.