nRF51 SDK
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
SoftDevice Manager API

APIs for SoftDevice management. More...

Modules

 SoftDevice Manager Error Codes
 Error definitions for the SDM API.
 

Macros

#define SDM_SVC_BASE   0x10
 SoftDevice Manager SVC Base number.
 

Typedefs

typedef uint32_t nrf_clock_lfclksrc_t
 Type representing lfclk oscillator source.
 
typedef void(* softdevice_assertion_handler_t )(uint32_t pc, uint16_t line_number, const uint8_t *p_file_name)
 SoftDevice Assertion Handler type. More...
 

Enumerations

enum  {
  SD_SOFTDEVICE_ENABLE = SDM_SVC_BASE,
  SD_SOFTDEVICE_DISABLE,
  SD_SOFTDEVICE_IS_ENABLED,
  SD_SOFTDEVICE_FORWARD_TO_APPLICATION,
  SVC_SDM_LAST
}
 nRF SoftDevice Manager API SVC numbers. More...
 
enum  {
  NRF_CLOCK_LFCLKSRC_RC_250_PPM_500MS_CALIBRATION,
  NRF_CLOCK_LFCLKSRC_RC_250_PPM_1000MS_CALIBRATION,
  NRF_CLOCK_LFCLKSRC_RC_250_PPM_2000MS_CALIBRATION,
  NRF_CLOCK_LFCLKSRC_RC_250_PPM_4000MS_CALIBRATION,
  NRF_CLOCK_LFCLKSRC_RC_250_PPM_8000MS_CALIBRATION,
  NRF_CLOCK_LFCLKSRC_SYNTH_250_PPM,
  NRF_CLOCK_LFCLKSRC_XTAL_500_PPM,
  NRF_CLOCK_LFCLKSRC_XTAL_250_PPM,
  NRF_CLOCK_LFCLKSRC_XTAL_150_PPM,
  NRF_CLOCK_LFCLKSRC_XTAL_100_PPM,
  NRF_CLOCK_LFCLKSRC_XTAL_75_PPM,
  NRF_CLOCK_LFCLKSRC_XTAL_50_PPM,
  NRF_CLOCK_LFCLKSRC_XTAL_30_PPM,
  NRF_CLOCK_LFCLKSRC_XTAL_20_PPM
}
 Possible lfclk oscillator sources. More...
 

Functions

uint32_t sd_softdevice_enable (nrf_clock_lfclksrc_t clock_source, softdevice_assertion_handler_t assertion_handler)
 Enables the SoftDevice and by extension the protocol stack. More...
 
uint32_t sd_softdevice_disable (void)
 Disables the SoftDevice and by extension the protocol stack. More...
 
uint32_t sd_softdevice_is_enabled (uint8_t *p_softdevice_enabled)
 Check if the SoftDevice is enabled. More...
 
uint32_t sd_softdevice_forward_to_application (void)
 Start forwarding interrupts to application. More...
 

Detailed Description

Typedef Documentation

typedef void(* softdevice_assertion_handler_t)(uint32_t pc, uint16_t line_number, const uint8_t *p_file_name)

When an unexpected error occurs within the SoftDevice it will call the SoftDevice assertion handler callback. The protocol stack will be in an undefined state when this happens and the only way to recover will be to perform a reset, using e.g. CMSIS NVIC_SystemReset().

Note
This callback is executed in HardFault context, thus SVC functions cannot be called from the SoftDevice assert callback.
Parameters
[in]pcThe program counter of the failed assert.
[in]line_numberLine number where the assert failed.
[in]file_nameFile name where the assert failed.

Enumeration Type Documentation

anonymous enum
Enumerator
SD_SOFTDEVICE_ENABLE 

sd_softdevice_enable

SD_SOFTDEVICE_DISABLE 

sd_softdevice_disable

SD_SOFTDEVICE_IS_ENABLED 

sd_softdevice_is_enabled

SD_SOFTDEVICE_FORWARD_TO_APPLICATION 

sd_softdevice_forward_to_application

SVC_SDM_LAST 

Placeholder for last SDM SVC

anonymous enum
Enumerator
NRF_CLOCK_LFCLKSRC_RC_250_PPM_500MS_CALIBRATION 

LFCLK RC oscillator, 500ms calibration interval.

NRF_CLOCK_LFCLKSRC_RC_250_PPM_1000MS_CALIBRATION 

LFCLK RC oscillator, 1000ms calibration interval.

NRF_CLOCK_LFCLKSRC_RC_250_PPM_2000MS_CALIBRATION 

LFCLK RC oscillator, 2000ms calibration interval.

NRF_CLOCK_LFCLKSRC_RC_250_PPM_4000MS_CALIBRATION 

LFCLK RC oscillator, 4000ms calibration interval.

NRF_CLOCK_LFCLKSRC_RC_250_PPM_8000MS_CALIBRATION 

LFCLK RC oscillator, 8000ms calibration interval.

NRF_CLOCK_LFCLKSRC_SYNTH_250_PPM 

LFCLK Synthesized from HFCLK.

NRF_CLOCK_LFCLKSRC_XTAL_500_PPM 

LFCLK crystal oscillator 500 PPM accuracy.

NRF_CLOCK_LFCLKSRC_XTAL_250_PPM 

LFCLK crystal oscillator 250 PPM accuracy.

NRF_CLOCK_LFCLKSRC_XTAL_150_PPM 

LFCLK crystal oscillator 150 PPM accuracy.

NRF_CLOCK_LFCLKSRC_XTAL_100_PPM 

LFCLK crystal oscillator 100 PPM accuracy.

NRF_CLOCK_LFCLKSRC_XTAL_75_PPM 

LFCLK crystal oscillator 75 PPM accuracy.

NRF_CLOCK_LFCLKSRC_XTAL_50_PPM 

LFCLK crystal oscillator 50 PPM accuracy.

NRF_CLOCK_LFCLKSRC_XTAL_30_PPM 

LFCLK crystal oscillator 30 PPM accuracy.

NRF_CLOCK_LFCLKSRC_XTAL_20_PPM 

LFCLK crystal oscillator 20 PPM accuracy.

Function Documentation

uint32_t sd_softdevice_enable ( nrf_clock_lfclksrc_t  clock_source,
softdevice_assertion_handler_t  assertion_handler 
)

Idempotent function to enable the SoftDevice.

Note
Some care must be taken if a low frequency clock source is already running when calling this function: If the LF clock has a different source then the one currently running, it will be stopped. Then, the new clock source will be started.
This function has no effect when returning with an error.
Postcondition
If return code is NRF_SUCCESS
  • SoC library and protocol stack APIs are made available
  • A portion of RAM will be unavailable (see relevant SDS documentation)
  • Some peripherals will be unavailable or available only through the SoC API (see relevant SDS documentation)
  • Interrupts will not arrive from protected peripherals or interrupts
  • nrf_nvic_ functions must be used instead of CMSIS NVIC_ functions for reliable usage of the softdevice.
  • Interrupt latency may be affected by the SoftDevice (see relevant SDS documentation)
  • Chosen low frequency clock source will be running
Parameters
clock_sourceLow frequency clock source and accuracy. (Note: In the case of XTAL source, the PPM accuracy of the chosen clock source must be greater than or equal to the actual characteristics of your XTAL clock).
assertion_handlerCallback for SoftDevice assertions.
Returns
NRF_SUCCESS
NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION SoftDeviceinterrupt is already enabled, or an enabled interrupt has an illegal priority level
NRF_ERROR_SDM_LFCLK_SOURCE_UNKNOWN Unknown low frequency clock source selected
uint32_t sd_softdevice_disable ( void  )

Idempotent function to disable the SoftDevice.

Postcondition
SoC library and protocol stack APIs are made unavailable.
All interrupts that was protected by the SoftDevice will be disabled and initialized to priority 0 (highest).
All peripherals used by the SoftDevice will be reset to default values.
All of RAM become available.
All interrupts are forwarded to the application.
LFCLK source chosen in sd_softdevice_enable will be left running.
Returns
NRF_SUCCESS
uint32_t sd_softdevice_is_enabled ( uint8_t *  p_softdevice_enabled)
Parameters
[out]p_softdevice_enabledIf the SoftDevice is enabled: 1 else 0.
Returns
NRF_SUCCESS
uint32_t sd_softdevice_forward_to_application ( void  )

This function is only intended to be called when a bootloader is enabled is used. The bootloader should call this right before it starts the application. It is recommended that all interrupt sources are off when this is called, or you could end up having interrupts in the application being executed before main() of the application.

Returns
NRF_SUCCESS