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

nRF52840 DK- Softdevice events handling

Hello :

I come from STM32 programming and I am new to Nordic device programming.

for nRF52840 DK, I am looking at the ble-blinking example and try to understand Softdevice event handling process flow.

I understand when a Softdevice has an event, it will trigger an interrupt and the interrupt service routine will execute the 

 nrf_sdh_evts_poll().

 However,

I am not sure how the above  evts-poll function will call the    -- ble_evt_handler     and the            ble_lbs_on_ble_evt ?  ( LED control) 

How does the nrf_sdh_evts_poll() know the address of  ble_evt_handler          and the             ble_lbs_on_ble_evt ? ( LED control) 

There are some discussion saying the event handles are registered , so nrf_sdh_evts_poll()  will know which handle to execute ?

Could you explain it in details ?  ( event handling registration  process ,  etc?)

I would like to understand how the Softdevice event handling  works.

Thanks a lot !

 

ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)

 ble_lbs_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context)

void nrf_sdh_evts_poll(void)
{
nrf_section_iter_t iter;

// Notify observers about pending SoftDevice event.
for (nrf_section_iter_init(&iter, &sdh_stack_observers);
nrf_section_iter_get(&iter) != NULL;
nrf_section_iter_next(&iter))
{
nrf_sdh_stack_observer_t * p_observer;
nrf_sdh_stack_evt_handler_t handler;

p_observer = (nrf_sdh_stack_observer_t *) nrf_section_iter_get(&iter);
handler = p_observer->handler;

handler(p_observer->p_context);
}
}

Related