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

NRF_SDH_DISPATCH_MODEL_APPSH and sync access to flash results.

We are using NRF_SDH_DISPATCH_MODEL_APPSH, and are generally very happy with it (especially for BLE events). However, I'm trying to retrofit error handling around complex code that uses iflash_erase_page, iflash_write without ever checking the results (normally delivered via sys events), and which expects flash to be synchronous (our wrapper functions sleep long enough for operations to complete, and just assumes they worked).

Given that we use NRF_SDH_DISPATCH_MODEL_APPSH, is there any way to poll for the system events that deliver flash results in a busy loop? Or to get the flash operation results in an IRQ context that could be used to release a spin lock?

If I could have BLE events delivered via the APPSH model, and system events delivered via the INTERRUPT model, this would be straight forward for me.

Parents
  • Hi,

    The SDH implementation is quite simple and not so flexible, and does not support this. All events are handled the same and must use the same method. On the bright side, the SDH is also quite simple, so if you look at the implementation you can see that the various dispatch models really only impact how nrf_sdh_evts_poll() is called:

    • Using the scheduler dispatch model, it is called by the scheduler.
    • Using interrupt model, it is called by the ISR itself.
    • Using the polling model it is not called by SDH, but instead is called by the application itself.

    If you want to split BLE and system events, you could make a new method, where you check in the ISR if it is a BLE event or a system event. If it is a BLE event, put it in a queue of some sort for later handling. If it is a system event, call the registered event handler immediately (from the ISR).

Reply
  • Hi,

    The SDH implementation is quite simple and not so flexible, and does not support this. All events are handled the same and must use the same method. On the bright side, the SDH is also quite simple, so if you look at the implementation you can see that the various dispatch models really only impact how nrf_sdh_evts_poll() is called:

    • Using the scheduler dispatch model, it is called by the scheduler.
    • Using interrupt model, it is called by the ISR itself.
    • Using the polling model it is not called by SDH, but instead is called by the application itself.

    If you want to split BLE and system events, you could make a new method, where you check in the ISR if it is a BLE event or a system event. If it is a BLE event, put it in a queue of some sort for later handling. If it is a system event, call the registered event handler immediately (from the ISR).

Children
No Data
Related