SWI driver

nRF5 SDK v12.2.0

Driver for software interrupts (SWI). More...

Macros

#define EGU_ENABLED 0
#define NRF_SWI_UNALLOCATED (( nrf_swi_t ) 0xFFFFFFFFuL)
Unallocated channel value.
#define SWI_MAX SWI_COUNT
Maximum numbers of SWIs. This number is fixed for a specific chip.
#define SWI_MAX_FLAGS 16
Number of flags per SWI (fixed number).
#define SWI_DEFAULT_PRIORITY APP_IRQ_PRIORITY_LOWEST
Default SWI priority.

Typedefs

typedef uint8_t nrf_swi_t
SWI channel (unsigned integer).
typedef uint16_t nrf_swi_flags_t
SWI user flags (unsigned integer). More...
typedef void(* nrf_swi_handler_t )( nrf_swi_t , nrf_swi_flags_t )
SWI handler function. More...

Functions

ret_code_t nrf_drv_swi_init (void)
Function for initializing the SWI module. More...
void nrf_drv_swi_uninit (void)
Function for uninitializing the SWI module. More...
ret_code_t nrf_drv_swi_alloc ( nrf_swi_t *p_swi, nrf_swi_handler_t event_handler, uint32_t priority)
Function for allocating a first unused SWI instance and setting a handler. More...
void nrf_drv_swi_free ( nrf_swi_t *p_swi)
Function for freeing a previously allocated SWI. More...
void nrf_drv_swi_trigger ( nrf_swi_t swi, uint8_t flag_number)
Function for triggering the SWI. More...
uint32_t nrf_drv_swi_task_trigger_address_get ( nrf_swi_t swi, uint8_t channel)
Function for returning the EGU trigger task address. More...
uint32_t nrf_drv_swi_event_triggered_address_get ( nrf_swi_t swi, uint8_t channel)
Function for returning the EGU triggered event address. More...

Detailed Description

Driver for software interrupts (SWI).

The SWI driver allows the user to allocate SWIs and pass extra flags to interrupt handler functions.

Typedef Documentation

typedef uint16_t nrf_swi_flags_t

SWI user flags (unsigned integer).

User flags are set during the SWI trigger and passed to the callback function as an argument.

typedef void(* nrf_swi_handler_t)( nrf_swi_t , nrf_swi_flags_t )

SWI handler function.

Takes two arguments: SWI number (nrf_swi_t) and flags (nrf_swi_flags_t).

Function Documentation

ret_code_t nrf_drv_swi_alloc ( nrf_swi_t * p_swi ,
nrf_swi_handler_t event_handler ,
uint32_t priority
)

Function for allocating a first unused SWI instance and setting a handler.

The event handler function returns void and takes one uint32_t argument (SWI number).

Parameters
[out] p_swi Pointer to the SWI that has been allocated.
[in] event_handler Event handler function (must not be NULL).
[in] priority Interrupt priority.
Return values
NRF_SUCCESS If the SWI was successfully allocated.
NRF_ERROR_NO_MEM If there is no available SWI to be used.
uint32_t nrf_drv_swi_event_triggered_address_get ( nrf_swi_t swi ,
uint8_t channel
)

Function for returning the EGU triggered event address.

Parameters
[in] swi SWI instance.
[in] channel Number of the EGU channel.
Returns
EGU triggered event address.
void nrf_drv_swi_free ( nrf_swi_t * p_swi )

Function for freeing a previously allocated SWI.

Parameters
[in,out] p_swi SWI to free. The value is changed to NRF_SWI_UNALLOCATED on success.
ret_code_t nrf_drv_swi_init ( void )

Function for initializing the SWI module.

Return values
NRF_SUCCESS If the module was successfully initialized.
NRF_ERROR_MODULE_ALREADY_INITIALIZED If the module has already been initialized.
uint32_t nrf_drv_swi_task_trigger_address_get ( nrf_swi_t swi ,
uint8_t channel
)

Function for returning the EGU trigger task address.

Parameters
[in] swi SWI instance.
[in] channel Number of the EGU channel.
Returns
EGU trigger task address.
void nrf_drv_swi_trigger ( nrf_swi_t swi ,
uint8_t flag_number
)

Function for triggering the SWI.

Parameters
[in] swi SWI to trigger.
[in] flag_number Number of user flag to trigger.
void nrf_drv_swi_uninit ( void )

Function for uninitializing the SWI module.

This function also disables all SWIs.