Hello,
What I want to do is to store custom data to flash using FDS in "disconnected" event.
When I try to write the data in "disconnected" event, the write_flag is never raised. Is there any solutions to help me to solve this problem?
[Updated on 2017/4/25]
After some tests that I found the custom data is written successfully. However, the system does NOT work well because of the "while" function.
static void my_fds_evt_handler(fds_evt_t const * const p_fds_evt)
{
switch (p_fds_evt->id)
{
case FDS_EVT_INIT:
if (p_fds_evt->result != FDS_SUCCESS)
{
// Initialization failed. --> system reset
}
break;
case FDS_EVT_WRITE:
if (p_fds_evt->result == FDS_SUCCESS)
{
write_flag = 1; // << entered!!!!
}
break;
case FDS_EVT_UPDATE:
if (p_fds_evt->result == FDS_SUCCESS)
{
write_flag = 1;
// reset
sd_nvic_SystemReset();
}
break;
default:
break;
}
}
static void fds_write()
{
uint32_t err_code;
err_code =fds_test_write();
APP_ERROR_CHECK(err_code);
//wait until the write is finished.
while (write_flag==0); // <<--------- Never leave this function.
err_code = fds_read();
}
Thanks.
Sara