R1 code for micro:bit based train controller code, requires second micro:bit running rx code to operate - see https://meanderingpi.wordpress.com/ for more information

Fork of nrf51-sdk by Lancaster University

Embed: (wiki syntax)

« Back to documentation index

SoftDevice Event Handler

SoftDevice Event Handler

API for initializing and disabling the SoftDevice. More...

Modules

 Types definitions for ANT support in SoftDevice handler.
 

This file contains the declarations of types required for ANT stack support.


 Types definitions for BLE support in SoftDevice handler.
 

This file contains the declarations of types required for BLE stack support.


Typedefs

typedef uint32_t(* softdevice_evt_schedule_func_t )(void)
 Type of function for passing events from the stack handler module to the scheduler.
typedef void(* sys_evt_handler_t )(uint32_t evt_id)
 Application System (SOC) event handler type.

Functions

bool softdevice_handler_isEnabled (void)
 Function for retrieving the information about SD state.
uint32_t softdevice_handler_init (nrf_clock_lfclksrc_t clock_source, void *p_ble_evt_buffer, uint16_t ble_evt_buffer_size, softdevice_evt_schedule_func_t evt_schedule_func)
 Function for initializing the stack handler module.
uint32_t softdevice_handler_sd_disable (void)
 Function for disabling the SoftDevice.
uint32_t softdevice_sys_evt_handler_set (sys_evt_handler_t sys_evt_handler)
 Function for registering for System (SOC) events.

Detailed Description

API for initializing and disabling the SoftDevice.

This API contains the functions and defines exposed by the lib_softdevice_handler. For more information on the library and how the application should use it, please refer lib_softdevice_handler.

Note:
Use the USE_SCHEDULER parameter of the SOFTDEVICE_HANDLER_INIT() macro to select if the Scheduler is to be used or not.
Even if the scheduler is not used, softdevice_handler.h will include app_scheduler.h. So when compiling, app_scheduler.h must be available in one of the compiler include paths.

Typedef Documentation

typedef uint32_t(* softdevice_evt_schedule_func_t)(void)

Type of function for passing events from the stack handler module to the scheduler.

Definition at line 67 of file softdevice_handler.h.

typedef void(* sys_evt_handler_t)(uint32_t evt_id)

Application System (SOC) event handler type.

Definition at line 70 of file softdevice_handler.h.


Function Documentation

uint32_t softdevice_handler_init ( nrf_clock_lfclksrc_t  clock_source,
void *  p_ble_evt_buffer,
uint16_t  ble_evt_buffer_size,
softdevice_evt_schedule_func_t  evt_schedule_func 
)

Function for initializing the stack handler module.

Enables the SoftDevice and the stack event interrupt handler.

Note:
This function must be called before calling any function in the SoftDevice API.
Normally initialization should be done using the SOFTDEVICE_HANDLER_INIT() macro, as that will both allocate the event buffer, and also align the buffer correctly.
Parameters:
[in]clock_sourceLow frequency clock source to be used by the SoftDevice.
[in]p_ble_evt_bufferBuffer for holding one BLE stack event. Since heap is not being used, this buffer must be provided by the application. The buffer must be large enough to hold the biggest stack event the application is supposed to handle. The buffer must be aligned to a 4 byte boundary. This parameter is unused if BLE stack support is not required.
[in]ble_evt_buffer_sizeSize of SoftDevice BLE event buffer. This parameter is unused if BLE stack support is not required.
[in]evt_schedule_funcFunction for passing events to the scheduler. Point to ble_ant_stack_evt_schedule() to connect to the scheduler. Set to NULL to make the stack handler module call the event handler directly from the stack event interrupt handler.
Return values:
NRF_SUCCESSSuccessful initialization.
NRF_ERROR_INVALID_PARAMInvalid parameter (buffer not aligned to a 4 byte boundary) or NULL.

Definition at line 221 of file softdevice_handler.c.

bool softdevice_handler_isEnabled ( void   )

Function for retrieving the information about SD state.

The information about current state of softdevice.

Return values:
falseSD is not initialized and SD commands should not be called.
trueSD is already initialized

Definition at line 216 of file softdevice_handler.c.

uint32_t softdevice_handler_sd_disable ( void   )

Function for disabling the SoftDevice.

This function will disable the SoftDevice. It will also update the internal state of this module.

Definition at line 278 of file softdevice_handler.c.

uint32_t softdevice_sys_evt_handler_set ( sys_evt_handler_t  sys_evt_handler )

Function for registering for System (SOC) events.

The application should use this function to register for receiving System (SOC) events from the SoftDevice. If the application does not call this function, then any System (SOC) events that may be generated by the SoftDevice will NOT be fetched. Once the application has registered for the events, it is not possible to possible to cancel the registration. However, it is possible to register a different function for handling the events at any point of time.

Parameters:
[in]sys_evt_handlerFunction to be called for each received System (SOC) event.
Return values:
NRF_SUCCESSSuccessful registration.
NRF_ERROR_NULLNull pointer provided as input.

Definition at line 318 of file softdevice_handler.c.