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

Can we call softdevice API before enabling softdevice ?

Please check the answer

  • Not all SDS versions are clear on this. So I decided to make this info visible.

    softdevice API are all the function calls with names starting with prefix sd_which is exposed by softdevice.

    Softdevice is enabled after successful call to sd_softdevice_enable

    Softdevice is disabled after successful call to sd_softdevice_disable

    All the calls from nrf_sdm.h (SoftDevice Manager) are available before and after enabling softdevice.

    if you check nrf_soc.h file. There is an enum that looks like below

    enum NRF_SOC_SVCS 
    {
       XXXX,
       XXXX
    }
    

    All the defines inside this enum are intentionally made to look similar to the actual softdevice API call. for example enum value SD_NVIC_SYSTEMRESET is the SVC number for the softdevice call sd_nvic_systemreset()

    Inside this enum, the SVC calls with numbers from

    SOC_SVC_BASE
    to 
    SOC_SVC_BASE_NOT_AVAILABLE - 1
    

    should be available even though softdevice is not enabled.

    The api calls from

    SOC_SVC_BASE_NOT_AVAILABLE to SVC_SOC_LAST -1

    only work when softdevice is enabled else they will return

    #define NRF_ERROR_SOFTDEVICE_NOT_ENABLED      (NRF_ERROR_BASE_NUM + 2)  ///< SoftDevice has not been enabled
    
Related