Hi
We are working on a product using NRF-51822 chip. I am new to Nordic SDK and want to know how to use fstorage to save data into flash. Following is code. Sometimes data can be saved into flash and sometimes not. Can you please let me know what is wrong below and show my some examples using fstorage. Thanks.
Typically, in the code, we use the function fstorage_store() to store the m_stored_data.
typedef struct StoredData {
uint8_t address[6];
uint8_t role;
uint8_t uart_baud_rate;
uint8_t name[26];
} stored_data_t;
stored_data_t m_stored_data;
FS_REGISTER_CFG(fs_config_t fs_config) =
{
.callback = fs_evt_handler, // Function for event callbacks.
.num_pages = 1, // Number of physical flash pages required.
.priority = 0xFE // Priority for flash usage.
};
static uint32_t fstorage_store(void)
{
fs_ret_t ret;
fs_callback_flag = 1;
ret = fs_store(&fs_config, fs_config.p_start_addr, (uint32_t *)&m_stored_data, 9);
if (ret != FS_SUCCESS) {
// TODO: handle error.
return NRF_ERROR_INTERNAL;
}
// Doesn't seem to unblock.
// while(fs_callback_flag == 1) { power_manage(); }
return NRF_SUCCESS;
}
Regards,
SL