This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Is calling Softdevice function from main context safe?

Hello,

my application is using the event scheduler while the softdevice is not. Is it save to call softdevice functions (like sd_ble_gap_scan_stop(), dm_device_delete_all(), ...) directly from the main context?

Parents
  • dm_device_delete_all() is a function that belongs to the Device Manager, which is a software module, it is not part of the SoftDevice.

    sd_ble_gap_scan_stop() is an SVC call and has interrupt priority 2 (0 is the highest, 3 is the lowest)

    There are two application interrupt priorities available, 1 and 3.

    The general answer is yes, it is safe, but it depends on your application, you could get unwanted behavior if you don't keep in mind how the interrupts and the events are handled.

    One difference will be that:

    If you use scheduling on both the application and the SoftDevice, SVC calls and application interrupts will be scheduled and handled in turn.

    If you use scheduling only on the application, the SoftDevice will be able to interrupt the scheduled application events, even the ones with priority 1.

Reply
  • dm_device_delete_all() is a function that belongs to the Device Manager, which is a software module, it is not part of the SoftDevice.

    sd_ble_gap_scan_stop() is an SVC call and has interrupt priority 2 (0 is the highest, 3 is the lowest)

    There are two application interrupt priorities available, 1 and 3.

    The general answer is yes, it is safe, but it depends on your application, you could get unwanted behavior if you don't keep in mind how the interrupts and the events are handled.

    One difference will be that:

    If you use scheduling on both the application and the SoftDevice, SVC calls and application interrupts will be scheduled and handled in turn.

    If you use scheduling only on the application, the SoftDevice will be able to interrupt the scheduled application events, even the ones with priority 1.

Children
  • Thanks Petter! What I'm reading from your reply is that it might be a better idea to use the scheduler for both, the application and the softdevice. I ended up in the constellation I'm currently using because I started from a S120 example that did not use the scheduler for the SD and I did not yet dare to change it. In case I'm using the scheduler for my application anyways, are there any reasons or considerations why I would not use the scheduler also for the softdevice?

  • You would just need to consider that SVC calls and application interrupts will be scheduled and handled in turn. :)

Related