nRF5 SDK v17.1.0
Modules | Macros | Typedefs | Functions
SWI driver

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

Modules

 SWI/EGU peripheral allocator configuration
 

Macros

#define NRFX_SWI_UNALLOCATED   ((nrfx_swi_t)0xFFuL)
 Unallocated instance value.
 
#define NRFX_SWI_DEFAULT_PRIORITY   APP_IRQ_PRIORITY_LOWEST
 Default SWI priority.
 

Typedefs

typedef uint8_t nrfx_swi_t
 SWI instance.
 
typedef uint16_t nrfx_swi_flags_t
 SWI user flags. More...
 
typedef void(* nrfx_swi_handler_t )(nrfx_swi_t swi, nrfx_swi_flags_t flags)
 SWI handler function. More...
 

Functions

nrfx_err_t nrfx_swi_alloc (nrfx_swi_t *p_swi, nrfx_swi_handler_t event_handler, uint32_t irq_priority)
 Function for allocating the first unused SWI instance and setting a handler. More...
 
void nrfx_swi_int_disable (nrfx_swi_t swi)
 Function for disabling an allocated SWI interrupt. More...
 
void nrfx_swi_int_enable (nrfx_swi_t swi)
 Function for enabling an allocated SWI interrupt. More...
 
void nrfx_swi_free (nrfx_swi_t *p_swi)
 Function for freeing a previously allocated SWI. More...
 
void nrfx_swi_all_free (void)
 Function for freeing all allocated SWIs.
 
void nrfx_swi_trigger (nrfx_swi_t swi, uint8_t flag_number)
 Function for triggering the SWI. More...
 
bool nrfx_swi_is_allocated (nrfx_swi_t swi)
 Function for checking if the specified SWI is currently allocated. More...
 
__STATIC_INLINE NRF_EGU_Type * nrfx_swi_egu_instance_get (nrfx_swi_t swi)
 Function for returning the base address of the EGU peripheral associated with the specified SWI instance. More...
 
__STATIC_INLINE uint32_t nrfx_swi_task_trigger_address_get (nrfx_swi_t swi, uint8_t channel)
 Function for returning the EGU trigger task address. More...
 
__STATIC_INLINE uint32_t nrfx_swi_event_triggered_address_get (nrfx_swi_t swi, uint8_t channel)
 Function for returning the EGU-triggered event address. More...
 

Detailed Description

Driver for managing software interrupts (SWI).

Typedef Documentation

typedef uint16_t nrfx_swi_flags_t

SWI user flags.

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

typedef void(* nrfx_swi_handler_t)(nrfx_swi_t swi, nrfx_swi_flags_t flags)

SWI handler function.

Parameters
swiSWI instance.
flagsUser flags.

Function Documentation

nrfx_err_t nrfx_swi_alloc ( nrfx_swi_t p_swi,
nrfx_swi_handler_t  event_handler,
uint32_t  irq_priority 
)

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

If provided handler is not NULL, an allocated SWI has its interrupt enabled by default. The interrupt can be disabled by nrfx_swi_int_disable.

Parameters
[out]p_swiPoints to a place where the allocated SWI instance number is to be stored.
[in]event_handlerEvent handler function. If NULL, no interrupt will be enabled. It can be NULL only if the EGU driver is enabled. For classic SWI, it must be a valid handler pointer.
[in]irq_priorityInterrupt priority.
Return values
NRFX_SUCCESSThe SWI was successfully allocated.
NRFX_ERROR_NO_MEMThere is no available SWI to be used.
__STATIC_INLINE NRF_EGU_Type* nrfx_swi_egu_instance_get ( nrfx_swi_t  swi)

Function for returning the base address of the EGU peripheral associated with the specified SWI instance.

Parameters
[in]swiSWI instance.
Returns
EGU base address or NULL if the specified SWI instance number is too high.
__STATIC_INLINE uint32_t nrfx_swi_event_triggered_address_get ( nrfx_swi_t  swi,
uint8_t  channel 
)

Function for returning the EGU-triggered event address.

Parameters
[in]swiSWI instance.
[in]channelNumber of the EGU channel.
Returns
Address of the EGU-triggered event.
void nrfx_swi_free ( nrfx_swi_t p_swi)

Function for freeing a previously allocated SWI.

Parameters
[in,out]p_swiSWI instance to free. The value is changed to NRFX_SWI_UNALLOCATED on success.
void nrfx_swi_int_disable ( nrfx_swi_t  swi)

Function for disabling an allocated SWI interrupt.

Use nrfx_swi_int_enable to re-enable the interrupt.

Parameters
[in]swiSWI instance.
void nrfx_swi_int_enable ( nrfx_swi_t  swi)

Function for enabling an allocated SWI interrupt.

Parameters
[in]swiSWI instance.
bool nrfx_swi_is_allocated ( nrfx_swi_t  swi)

Function for checking if the specified SWI is currently allocated.

Parameters
[in]swiSWI instance.
Return values
trueThe SWI instance is allocated.
falseThe SWI instance is not allocated.
__STATIC_INLINE uint32_t nrfx_swi_task_trigger_address_get ( nrfx_swi_t  swi,
uint8_t  channel 
)

Function for returning the EGU trigger task address.

Parameters
[in]swiSWI instance.
[in]channelNumber of the EGU channel.
Returns
Address of the EGU trigger task.
void nrfx_swi_trigger ( nrfx_swi_t  swi,
uint8_t  flag_number 
)

Function for triggering the SWI.

Parameters
[in]swiSWI to trigger.
[in]flag_numberNumber of user flag to trigger.

Documentation feedback | Developer Zone | Subscribe | Updated