I intend to check some of the NRF_SOC_EVTS in my application. Where should I register soc_evt_handler(uint32_t sys_evt, void * p_context) function? Will this function be called by SD when one of these event is triggered in the system?
I intend to check some of the NRF_SOC_EVTS in my application. Where should I register soc_evt_handler(uint32_t sys_evt, void * p_context) function? Will this function be called by SD when one of these event is triggered in the system?
Hi Justin,
you can register the soc_evt_handler in any .c file in your project with the NRF_SDH_SOC_OBSERVER macro. The nrf_drv_clock.c driver registers a soc_evt_handler to listen for the NRF_EVT_HFCLKSTARTED event.
// In nrf_drv_clock.c
static void soc_evt_handler(uint32_t evt_id, void * p_context)
{
if (evt_id == NRF_EVT_HFCLKSTARTED)
{
m_clock_cb.hfclk_on = true;
clock_clk_started_notify(NRF_DRV_CLOCK_EVT_HFCLK_STARTED);
}
}
NRF_SDH_SOC_OBSERVER(m_soc_evt_observer, CLOCK_CONFIG_SOC_OBSERVER_PRIO, soc_evt_handler, NULL);
Will this function be called by SD when one of these event is triggered in the system?
Yes, the soc_evt_handler that is registered with the NRF_SDH_SOC_OBSERVER macro will be called when the SD forwards SoC events to the application.
Best regards
Bjørn
Hi Justin,
you can register the soc_evt_handler in any .c file in your project with the NRF_SDH_SOC_OBSERVER macro. The nrf_drv_clock.c driver registers a soc_evt_handler to listen for the NRF_EVT_HFCLKSTARTED event.
// In nrf_drv_clock.c
static void soc_evt_handler(uint32_t evt_id, void * p_context)
{
if (evt_id == NRF_EVT_HFCLKSTARTED)
{
m_clock_cb.hfclk_on = true;
clock_clk_started_notify(NRF_DRV_CLOCK_EVT_HFCLK_STARTED);
}
}
NRF_SDH_SOC_OBSERVER(m_soc_evt_observer, CLOCK_CONFIG_SOC_OBSERVER_PRIO, soc_evt_handler, NULL);
Will this function be called by SD when one of these event is triggered in the system?
Yes, the soc_evt_handler that is registered with the NRF_SDH_SOC_OBSERVER macro will be called when the SD forwards SoC events to the application.
Best regards
Bjørn