We have some legacy code ported from other platfrom to nRF51822. The old platform supports blocking flash write, so there will be some readback code after flash write function.
After ported to nRF51822, I am wondering whether there is way that the code can wait or sleep after issue flash write request, and continue the code after received NRF_EVT_FLASH_OPERATION_SUCCESS event.
void sys_evt_dispatch(uint32_t sys_evt)
{
if (sys_evt == NRF_EVT_FLASH_OPERATION_SUCCESS){
// how to trigger/wake up some_way_to_wait()
}else{
LOG_DEBUG(" sys_evt_dispatch code 0x%x", sys_evt);
}
}
func()
{
flash_write(...);
some_way_to_wait();
read_flash_back_do_something1();
flash_write(...);
some_way_to_wait();
read_flash_back_do_something2();
}
Of course I know I could put read_flash_back_do_something() in a callback function but that needs some significant change and we prefer not to do it if we can find a solution for this post.