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

SDK12.3 use fs_erase and fs_store

I am using SDK12.3 and the Flash Storage module to store some data in Flash. I frequently need to update some of these data basing on received commands.

When I use "fs_erase", it has been cycling at "power_manage ();"

fs_callback_flag = 1;	        
ret = fs_erase(&fs_config, fs_config.p_start_addr, NUM_PAGES, NULL);
    	if (ret != FS_SUCCESS)
    	{
    		bsp_indication_set(BSP_INDICATE_FATAL_ERROR);
    	}
    	while(fs_callback_flag == 1)
    	{
    		power_manage();
    	}
    
    
        static void fs_evt_handler(fs_evt_t const * const evt, fs_ret_t result)
    {
    	if (result != FS_SUCCESS)
    	{
    		bsp_indication_set(BSP_INDICATE_USER_STATE_1);
    	}
    	else
    	{
    		NRF_LOG_INFO("fstorage command successfully completed\n\r");
    		fs_callback_flag = 0;
    	}
    }
Parents Reply
  • Is the callback triggered by softdevice event ? I don't think it's a good idea to put a loop inside a interrupt handler (callback) to wait for an event. If the event is at the same priority it won't be able to interrupt the loop.

    My suggestion is to set a flag after you erase, and the let the loop inside the main loop to wait for that flag of erasing, then you can continue to do store functions after that.

Children
Related