I am using Nrf52832 as my main microcontroller and in that, I am using fstorage as well as FDS. I have one structure that has several values in it. I want to store the copies of that structure one by one in FDS and size of one structure is 23 bytes. I want to save min 100 records of that. For one time data, I am using fstorage. I am able to write the data successfully. but when I am reading it nrf hangs and do nothing. There is no NRF_BREAKPOINT_ERROR or such, it just hangs.
Here is my structure for NRF_FSTORAGE_DEF
NRF_FSTORAGE_DEF(nrf_fstorage_t fstorage) = { /* Set a handler for fstorage events. */ .evt_handler = fstorage_evt_handler, /* These below are the boundaries of the flash space assigned to this instance of fstorage. * You must set these manually, even at runtime, before nrf_fstorage_init() is called. * The function nrf5_flash_end_addr_get() can be used to retrieve the last address on the * last page of flash available to write data. */ .start_addr = 0x3e000, .end_addr = 0x80000, };
I am reading the data as follows:
void flash_read(inhaler_params *data) { uint32_t rc; uint32_t size = get_puff_count(); memset(data,NULL,sizeof(inhaler_params)*size); for(int i=0;i<size;i++) { fds_record_desc_t desc = {0}; fds_find_token_t tok = {0}; rc = fds_record_find(CONFIG_FILE, CONFIG_REC_KEY+i, &desc, &tok); //APP_ERROR_CHECK(rc); if (rc == NRF_SUCCESS) { rc = fds_record_open(&desc, &config); APP_ERROR_CHECK(rc); memcpy(data+i, config.p_data, sizeof(inhaler_params)); rc = fds_record_close(&desc); APP_ERROR_CHECK(rc); } //NRF_LOG_INFO("RC : %d",rc); } } NRF_LOG_INFO("Flash read done"); //return data; }
Inhaler_params is a structure pointer in which I am reading the data from flash. is there any efficient way to read the whole data at once?
please help me with that and let me know if you want any additional inputs from my side.