This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to wait for FDS_EVT_UPDATE success event ? I mean to say, I want to wait for updating the flash storage operation, before performing the flash read operation, how to do that exactly?

As in fds.h, i am using the fds_record_update() function to update a record, and then as soon it is completed, i want to read the updated data from the flash, but how do i wait for the fds_record_update() funtion to return success?

  • Hi,

    The documentation says:

    This function is asynchronous. Completion is reported through the FDS_EVT_UPDATE event that is sent to the registered event handler function.

    Which means that you have to wait for the FDS_EVT_UPDATE event is generated in the callback handler. Easy way to implement is to wait in a loop until the an update flag is set. You'll then set the update flag in the callback handler after the FDS_EVT_UPDATE is generated.. Example:

    int update_flag = 0;
    
    static void fds_evt_handler(fds_evt_t const * p_evt)
    {
            case FDS_EVT_UPDATE:
            {
                flag = 1;
        
            } break;
        
    }
    
    int main(void)
    {
    
        rc = fds_init();
        APP_ERROR_CHECK(rc);
    
        /* Wait for fds to initialize. */
        wait_for_fds_ready();
        
        rc = fds_record_update(&desc, &m_dummy_record);
        APP_ERROR_CHECK(rc);
        
        while(!flag){}
        
        flag = 0;
        
        ....
        ...
        ...
    
    
    
    
    
    }

Related