123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245 |
- #ifndef NRFX_SWI_H__
- #define NRFX_SWI_H__
- #include <nrfx.h>
- #if NRFX_CHECK(NRFX_EGU_ENABLED)
- #include <hal/nrf_egu.h>
- #endif
- #ifndef SWI_COUNT
- #define SWI_COUNT EGU_COUNT
- #endif
- #ifdef __cplusplus
- extern "C" {
- #endif
- typedef uint8_t nrfx_swi_t;
- typedef uint16_t nrfx_swi_flags_t;
- #define NRFX_SWI_UNALLOCATED ((nrfx_swi_t)0xFFuL)
- #define NRFX_SWI_DEFAULT_PRIORITY APP_IRQ_PRIORITY_LOWEST
- typedef void (*nrfx_swi_handler_t)(nrfx_swi_t swi, nrfx_swi_flags_t flags);
- nrfx_err_t nrfx_swi_alloc(nrfx_swi_t * p_swi,
- nrfx_swi_handler_t event_handler,
- uint32_t irq_priority);
- void nrfx_swi_int_disable(nrfx_swi_t swi);
- void nrfx_swi_int_enable(nrfx_swi_t swi);
- void nrfx_swi_free(nrfx_swi_t * p_swi);
- void nrfx_swi_all_free(void);
- void nrfx_swi_trigger(nrfx_swi_t swi,
- uint8_t flag_number);
- bool nrfx_swi_is_allocated(nrfx_swi_t swi);
- #if NRFX_CHECK(NRFX_EGU_ENABLED) || defined(__NRFX_DOXYGEN__)
- __STATIC_INLINE NRF_EGU_Type * nrfx_swi_egu_instance_get(nrfx_swi_t swi)
- {
- #if (EGU_COUNT < SWI_COUNT)
- if (swi >= EGU_COUNT)
- {
- return NULL;
- }
- #endif
- uint32_t offset = ((uint32_t)swi) * ((uint32_t)NRF_EGU1 - (uint32_t)NRF_EGU0);
- return (NRF_EGU_Type *)((uint32_t)NRF_EGU0 + offset);
- }
- __STATIC_INLINE uint32_t nrfx_swi_task_trigger_address_get(nrfx_swi_t swi,
- uint8_t channel)
- {
- NRFX_ASSERT(nrfx_swi_is_allocated(swi));
- NRF_EGU_Type * p_egu = nrfx_swi_egu_instance_get(swi);
- #if (EGU_COUNT < SWI_COUNT)
- if (p_egu == NULL)
- {
- return 0;
- }
- #endif
- return (uint32_t)nrf_egu_task_trigger_address_get(p_egu, channel);
- }
- __STATIC_INLINE uint32_t nrfx_swi_event_triggered_address_get(nrfx_swi_t swi,
- uint8_t channel)
- {
- NRFX_ASSERT(nrfx_swi_is_allocated(swi));
- NRF_EGU_Type * p_egu = nrfx_swi_egu_instance_get(swi);
- #if (EGU_COUNT < SWI_COUNT)
- if (p_egu == NULL)
- {
- return 0;
- }
- #endif
- return (uint32_t)nrf_egu_event_triggered_address_get(p_egu, channel);
- }
- #endif
- void nrfx_swi_0_irq_handler(void);
- void nrfx_swi_1_irq_handler(void);
- void nrfx_swi_2_irq_handler(void);
- void nrfx_swi_3_irq_handler(void);
- void nrfx_swi_4_irq_handler(void);
- void nrfx_swi_5_irq_handler(void);
- #ifdef __cplusplus
- }
- #endif
- #endif
|