nRF51 SDK - S110 SoftDevice
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages

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

Macros

#define NRF_SWI_UNALLOCATED   ((nrf_swi_t) 0xFFFFFFFFuL)
 Unallocated channel value.
 
#define SWI_MAX   6
 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_COUNT   4
 Number of software interrupts available. This number can be set in the range from 1 to SWI_MAX.
 
#define SWI_DEFAULT_PRIORITY   APP_IRQ_PRIORITY_LOW
 Default SWI priority.
 

Typedefs

typedef uint32_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. Takes two arguments: SWI number (nrf_swi_t) and flags (nrf_swi_flags_t).
 

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...
 

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.

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_swiPointer to the SWI that has been allocated.
[in]event_handlerEvent handler function (must not be NULL).
[in]priorityInterrupt priority.
Return values
NRF_SUCCESSIf the SWI was successfully allocated.
NRF_ERROR_NO_MEMIf there is no available SWI to be used.
void nrf_drv_swi_free ( nrf_swi_t p_swi)

Function for freeing a previously allocated SWI.

Parameters
[in]p_swiSWI to free.
ret_code_t nrf_drv_swi_init ( void  )

Function for initializing the SWI module.

Return values
NRF_SUCCESSIf the module was successfully initialized.
MODULE_ALREADY_INITIALIZEDIf the module has already been initialized.
void nrf_drv_swi_trigger ( nrf_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.
void nrf_drv_swi_uninit ( void  )

Function for uninitializing the SWI module.

This function also disables all SWIs.

Return values
NRF_SUCCESSIf the module was successfully uninitialized.
NRF_ERROR_INVALID_STATEIf the module has not been initialized yet.