nrf-softdevice-s132

Crates

git

Versions

default

Flavors

pub unsafe fn sd_app_evt_wait() -> u32
Expand description

@brief Waits for an application event.

An application event is either an application interrupt or a pended interrupt when the interrupt is disabled.

When the application waits for an application event by calling this function, an interrupt that is enabled will be taken immediately on pending since this function will wait in thread mode, then the execution will return in the application’s main thread.

In order to wake up from disabled interrupts, the SEVONPEND flag has to be set in the Cortex-M MCU’s System Control Register (SCR), CMSIS_SCB. In that case, when a disabled interrupt gets pended, this function will return to the application’s main thread.

@note The application must ensure that the pended flag is cleared using ::sd_nvic_ClearPendingIRQ in order to sleep using this function. This is only necessary for disabled interrupts, as the interrupt handler will clear the pending flag automatically for enabled interrupts.

@note If an application interrupt has happened since the last time sd_app_evt_wait was called this function will return immediately and not go to sleep. This is to avoid race conditions that can occur when a flag is updated in the interrupt handler and processed in the main loop.

@post An application interrupt has happened or a interrupt pending flag is set.

@retval ::NRF_SUCCESS