18#include <zephyr/toolchain.h>
19#include <zephyr/sys/util.h>
20#include <zephyr/sys/iterable_sections.h>
43#define H_NRF_SDH_OBSERVER_PRIO_HIGHEST_HIGHEST 1
44#define H_NRF_SDH_OBSERVER_PRIO_HIGH_HIGH 1
45#define H_NRF_SDH_OBSERVER_PRIO_USER_USER 1
46#define H_NRF_SDH_OBSERVER_PRIO_USER_LOW_USER_LOW 1
47#define H_NRF_SDH_OBSERVER_PRIO_LOWEST_LOWEST 1
53#define PRIO_LEVEL_IS_VALID(level) \
54 COND_CODE_1(H_NRF_SDH_OBSERVER_PRIO_HIGHEST_##level, (), \
55 (COND_CODE_1(H_NRF_SDH_OBSERVER_PRIO_HIGH_##level, (), \
56 (COND_CODE_1(H_NRF_SDH_OBSERVER_PRIO_USER_##level, (), \
57 (COND_CODE_1(H_NRF_SDH_OBSERVER_PRIO_USER_LOW_##level, (), \
58 (COND_CODE_1(H_NRF_SDH_OBSERVER_PRIO_LOWEST_##level, (), \
59 (BUILD_ASSERT(0, "Invalid priority level")))))))))))
65#define PRIO_LEVEL_ORD(level) \
66 COND_CODE_1(H_NRF_SDH_OBSERVER_PRIO_HIGHEST_##level, (0), \
67 (COND_CODE_1(H_NRF_SDH_OBSERVER_PRIO_HIGH_##level, (1), \
68 (COND_CODE_1(H_NRF_SDH_OBSERVER_PRIO_USER_##level, (2), \
69 (COND_CODE_1(H_NRF_SDH_OBSERVER_PRIO_USER_LOW_##level, (3), \
70 (COND_CODE_1(H_NRF_SDH_OBSERVER_PRIO_LOWEST_##level, (4), \
71 (BUILD_ASSERT(0, "Invalid priority level")))))))))))
150#define NRF_SDH_STATE_EVT_OBSERVER(_observer, _handler, _ctx, _prio) \
151 PRIO_LEVEL_IS_VALID(_prio); \
152 static TYPE_SECTION_ITERABLE(struct nrf_sdh_state_evt_observer, _observer, \
153 nrf_sdh_state_evt_observers, PRIO_LEVEL_ORD(_prio)) = { \
154 .handler = _handler, \
190#define NRF_SDH_STACK_EVT_OBSERVER(_observer, _handler, _ctx, _prio) \
191 PRIO_LEVEL_IS_VALID(_prio); \
192 static const TYPE_SECTION_ITERABLE(struct nrf_sdh_stack_evt_observer, _observer, \
193 nrf_sdh_stack_evt_observers, PRIO_LEVEL_ORD(_prio)) = { \
194 .handler = _handler, \
int nrf_sdh_enable_request(void)
Enable the SoftDevice.
int(* nrf_sdh_state_evt_handler_t)(enum nrf_sdh_state_evt state, void *context)
SoftDevice Handler state event handler.
Definition nrf_sdh.h:113
void nrf_sdh_suspend(void)
Stop processing SoftDevice events.
void(* nrf_sdh_stack_evt_handler_t)(void *context)
SoftDevice stack event handler.
Definition nrf_sdh.h:161
nrf_sdh_state_evt
SoftDevice Handler state events.
Definition nrf_sdh.h:80
@ NRF_SDH_STATE_EVT_ENABLE_PREPARE
SoftDevice is going to be enabled.
Definition nrf_sdh.h:86
@ NRF_SDH_STATE_EVT_ENABLED
SoftDevice is enabled.
Definition nrf_sdh.h:90
@ NRF_SDH_STATE_EVT_BLE_ENABLED
Bluetooth enabled.
Definition nrf_sdh.h:94
@ NRF_SDH_STATE_EVT_DISABLE_PREPARE
SoftDevice is going to be disabled.
Definition nrf_sdh.h:100
@ NRF_SDH_STATE_EVT_DISABLED
SoftDevice is disabled.
Definition nrf_sdh.h:104
int nrf_sdh_observer_ready(struct nrf_sdh_state_evt_observer *observer)
Mark an observer ready for a SoftDevice state change.
void nrf_sdh_resume(void)
Resuming processing SoftDevice events.
void nrf_sdh_evts_poll(void)
Poll the SoftDevice for events.
int nrf_sdh_disable_request(void)
Disable the SoftDevice.
bool nrf_sdh_is_suspended(void)
Retrieve the module state.
nrf_sdh_stack_evt_handler_t handler
SoftDevice event handler.
Definition nrf_sdh.h:170
void * context
A context parameter to the event handler.
Definition nrf_sdh.h:174
SoftDevice stack event observer.
Definition nrf_sdh.h:166
nrf_sdh_state_evt_handler_t handler
State event handler.
Definition nrf_sdh.h:122
void * context
A context parameter to the event handler.
Definition nrf_sdh.h:126
bool is_busy
The observer's state during the latest SoftDevice state transistion.
Definition nrf_sdh.h:130
SoftDevice Handler state observer.
Definition nrf_sdh.h:118