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 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. More... | |
#define | SWI_DEFAULT_PRIORITY APP_IRQ_PRIORITY_LOW |
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... | |
Driver for software interrupts (SWI).
The SWI driver allows the user to allocate SWIs and pass extra flags to interrupt handler functions.
#define SWI_COUNT 4 |
Number of software interrupts available.
This number can be set in the range from 1 to SWI_MAX.
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).
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).
[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. |
NRF_SUCCESS | If the SWI was successfully allocated. |
NRF_ERROR_NO_MEM | If 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.
[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.
NRF_SUCCESS | If the module was successfully initialized. |
MODULE_ALREADY_INITIALIZED | If the module has already been initialized. |
void nrf_drv_swi_trigger | ( | nrf_swi_t | swi, |
uint8_t | flag_number | ||
) |
Function for triggering the SWI.
[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.