123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467 |
- #ifndef NRF_EGU_H__
- #define NRF_EGU_H__
- #include <nrfx.h>
- #ifdef __cplusplus
- extern "C" {
- #endif
- typedef enum
- {
- NRF_EGU_TASK_TRIGGER0 = offsetof(NRF_EGU_Type, TASKS_TRIGGER[0]),
- NRF_EGU_TASK_TRIGGER1 = offsetof(NRF_EGU_Type, TASKS_TRIGGER[1]),
- NRF_EGU_TASK_TRIGGER2 = offsetof(NRF_EGU_Type, TASKS_TRIGGER[2]),
- NRF_EGU_TASK_TRIGGER3 = offsetof(NRF_EGU_Type, TASKS_TRIGGER[3]),
- NRF_EGU_TASK_TRIGGER4 = offsetof(NRF_EGU_Type, TASKS_TRIGGER[4]),
- NRF_EGU_TASK_TRIGGER5 = offsetof(NRF_EGU_Type, TASKS_TRIGGER[5]),
- NRF_EGU_TASK_TRIGGER6 = offsetof(NRF_EGU_Type, TASKS_TRIGGER[6]),
- NRF_EGU_TASK_TRIGGER7 = offsetof(NRF_EGU_Type, TASKS_TRIGGER[7]),
- NRF_EGU_TASK_TRIGGER8 = offsetof(NRF_EGU_Type, TASKS_TRIGGER[8]),
- NRF_EGU_TASK_TRIGGER9 = offsetof(NRF_EGU_Type, TASKS_TRIGGER[9]),
- NRF_EGU_TASK_TRIGGER10 = offsetof(NRF_EGU_Type, TASKS_TRIGGER[10]),
- NRF_EGU_TASK_TRIGGER11 = offsetof(NRF_EGU_Type, TASKS_TRIGGER[11]),
- NRF_EGU_TASK_TRIGGER12 = offsetof(NRF_EGU_Type, TASKS_TRIGGER[12]),
- NRF_EGU_TASK_TRIGGER13 = offsetof(NRF_EGU_Type, TASKS_TRIGGER[13]),
- NRF_EGU_TASK_TRIGGER14 = offsetof(NRF_EGU_Type, TASKS_TRIGGER[14]),
- NRF_EGU_TASK_TRIGGER15 = offsetof(NRF_EGU_Type, TASKS_TRIGGER[15])
- } nrf_egu_task_t;
- typedef enum
- {
- NRF_EGU_EVENT_TRIGGERED0 = offsetof(NRF_EGU_Type, EVENTS_TRIGGERED[0]),
- NRF_EGU_EVENT_TRIGGERED1 = offsetof(NRF_EGU_Type, EVENTS_TRIGGERED[1]),
- NRF_EGU_EVENT_TRIGGERED2 = offsetof(NRF_EGU_Type, EVENTS_TRIGGERED[2]),
- NRF_EGU_EVENT_TRIGGERED3 = offsetof(NRF_EGU_Type, EVENTS_TRIGGERED[3]),
- NRF_EGU_EVENT_TRIGGERED4 = offsetof(NRF_EGU_Type, EVENTS_TRIGGERED[4]),
- NRF_EGU_EVENT_TRIGGERED5 = offsetof(NRF_EGU_Type, EVENTS_TRIGGERED[5]),
- NRF_EGU_EVENT_TRIGGERED6 = offsetof(NRF_EGU_Type, EVENTS_TRIGGERED[6]),
- NRF_EGU_EVENT_TRIGGERED7 = offsetof(NRF_EGU_Type, EVENTS_TRIGGERED[7]),
- NRF_EGU_EVENT_TRIGGERED8 = offsetof(NRF_EGU_Type, EVENTS_TRIGGERED[8]),
- NRF_EGU_EVENT_TRIGGERED9 = offsetof(NRF_EGU_Type, EVENTS_TRIGGERED[9]),
- NRF_EGU_EVENT_TRIGGERED10 = offsetof(NRF_EGU_Type, EVENTS_TRIGGERED[10]),
- NRF_EGU_EVENT_TRIGGERED11 = offsetof(NRF_EGU_Type, EVENTS_TRIGGERED[11]),
- NRF_EGU_EVENT_TRIGGERED12 = offsetof(NRF_EGU_Type, EVENTS_TRIGGERED[12]),
- NRF_EGU_EVENT_TRIGGERED13 = offsetof(NRF_EGU_Type, EVENTS_TRIGGERED[13]),
- NRF_EGU_EVENT_TRIGGERED14 = offsetof(NRF_EGU_Type, EVENTS_TRIGGERED[14]),
- NRF_EGU_EVENT_TRIGGERED15 = offsetof(NRF_EGU_Type, EVENTS_TRIGGERED[15])
- } nrf_egu_event_t;
- typedef enum
- {
- NRF_EGU_INT_TRIGGERED0 = EGU_INTENSET_TRIGGERED0_Msk,
- NRF_EGU_INT_TRIGGERED1 = EGU_INTENSET_TRIGGERED1_Msk,
- NRF_EGU_INT_TRIGGERED2 = EGU_INTENSET_TRIGGERED2_Msk,
- NRF_EGU_INT_TRIGGERED3 = EGU_INTENSET_TRIGGERED3_Msk,
- NRF_EGU_INT_TRIGGERED4 = EGU_INTENSET_TRIGGERED4_Msk,
- NRF_EGU_INT_TRIGGERED5 = EGU_INTENSET_TRIGGERED5_Msk,
- NRF_EGU_INT_TRIGGERED6 = EGU_INTENSET_TRIGGERED6_Msk,
- NRF_EGU_INT_TRIGGERED7 = EGU_INTENSET_TRIGGERED7_Msk,
- NRF_EGU_INT_TRIGGERED8 = EGU_INTENSET_TRIGGERED8_Msk,
- NRF_EGU_INT_TRIGGERED9 = EGU_INTENSET_TRIGGERED9_Msk,
- NRF_EGU_INT_TRIGGERED10 = EGU_INTENSET_TRIGGERED10_Msk,
- NRF_EGU_INT_TRIGGERED11 = EGU_INTENSET_TRIGGERED11_Msk,
- NRF_EGU_INT_TRIGGERED12 = EGU_INTENSET_TRIGGERED12_Msk,
- NRF_EGU_INT_TRIGGERED13 = EGU_INTENSET_TRIGGERED13_Msk,
- NRF_EGU_INT_TRIGGERED14 = EGU_INTENSET_TRIGGERED14_Msk,
- NRF_EGU_INT_TRIGGERED15 = EGU_INTENSET_TRIGGERED15_Msk,
- NRF_EGU_INT_ALL = 0xFFFFuL
- } nrf_egu_int_mask_t;
- __STATIC_INLINE uint32_t nrf_egu_channel_count(NRF_EGU_Type * NRF_EGUx);
- __STATIC_INLINE void nrf_egu_task_trigger(NRF_EGU_Type * NRF_EGUx, nrf_egu_task_t egu_task);
- __STATIC_INLINE uint32_t * nrf_egu_task_address_get(NRF_EGU_Type * NRF_EGUx,
- nrf_egu_task_t egu_task);
- __STATIC_INLINE uint32_t * nrf_egu_task_trigger_address_get(NRF_EGU_Type * NRF_EGUx,
- uint8_t channel);
- __STATIC_INLINE nrf_egu_task_t nrf_egu_task_trigger_get(NRF_EGU_Type * NRF_EGUx, uint8_t channel);
- __STATIC_INLINE bool nrf_egu_event_check(NRF_EGU_Type * NRF_EGUx,
- nrf_egu_event_t egu_event);
- __STATIC_INLINE void nrf_egu_event_clear(NRF_EGU_Type * NRF_EGUx,
- nrf_egu_event_t egu_event);
- __STATIC_INLINE uint32_t * nrf_egu_event_address_get(NRF_EGU_Type * NRF_EGUx,
- nrf_egu_event_t egu_event);
- __STATIC_INLINE uint32_t * nrf_egu_event_triggered_address_get(NRF_EGU_Type * NRF_EGUx,
- uint8_t channel);
- __STATIC_INLINE nrf_egu_event_t nrf_egu_event_triggered_get(NRF_EGU_Type * NRF_EGUx,
- uint8_t channel);
- __STATIC_INLINE void nrf_egu_int_enable(NRF_EGU_Type * NRF_EGUx, uint32_t mask);
- __STATIC_INLINE bool nrf_egu_int_enable_check(NRF_EGU_Type * NRF_EGUx, uint32_t mask);
- __STATIC_INLINE void nrf_egu_int_disable(NRF_EGU_Type * NRF_EGUx, uint32_t mask);
- __STATIC_INLINE nrf_egu_int_mask_t nrf_egu_int_get(NRF_EGU_Type * NRF_EGUx, uint8_t channel);
- #if defined(DPPI_PRESENT) || defined(__NRFX_DOXYGEN__)
- __STATIC_INLINE void nrf_egu_subscribe_set(NRF_EGU_Type * p_reg,
- nrf_egu_task_t task,
- uint8_t channel);
- __STATIC_INLINE void nrf_egu_subscribe_clear(NRF_EGU_Type * p_reg,
- nrf_egu_task_t task);
- __STATIC_INLINE void nrf_egu_publish_set(NRF_EGU_Type * p_reg,
- nrf_egu_event_t event,
- uint8_t channel);
- __STATIC_INLINE void nrf_egu_publish_clear(NRF_EGU_Type * p_reg,
- nrf_egu_event_t event);
- #endif
- #ifndef SUPPRESS_INLINE_IMPLEMENTATION
- __STATIC_INLINE uint32_t nrf_egu_channel_count(NRF_EGU_Type * NRF_EGUx)
- {
- if (NRF_EGUx == NRF_EGU0){
- return EGU0_CH_NUM;
- }
- if (NRF_EGUx == NRF_EGU1){
- return EGU1_CH_NUM;
- }
- #if EGU_COUNT > 2
- if (NRF_EGUx == NRF_EGU2){
- return EGU2_CH_NUM;
- }
- if (NRF_EGUx == NRF_EGU3){
- return EGU3_CH_NUM;
- }
- if (NRF_EGUx == NRF_EGU4){
- return EGU4_CH_NUM;
- }
- if (NRF_EGUx == NRF_EGU5){
- return EGU5_CH_NUM;
- }
- #endif
- return 0;
- }
- __STATIC_INLINE void nrf_egu_task_trigger(NRF_EGU_Type * NRF_EGUx, nrf_egu_task_t egu_task)
- {
- NRFX_ASSERT(NRF_EGUx);
- *((volatile uint32_t *)((uint8_t *)NRF_EGUx + (uint32_t)egu_task)) = 0x1UL;
- }
- __STATIC_INLINE uint32_t * nrf_egu_task_address_get(NRF_EGU_Type * NRF_EGUx,
- nrf_egu_task_t egu_task)
- {
- NRFX_ASSERT(NRF_EGUx);
- return (uint32_t *)((uint8_t *)NRF_EGUx + (uint32_t)egu_task);
- }
- __STATIC_INLINE uint32_t * nrf_egu_task_trigger_address_get(NRF_EGU_Type * NRF_EGUx,
- uint8_t channel)
- {
- NRFX_ASSERT(NRF_EGUx);
- NRFX_ASSERT(channel < nrf_egu_channel_count(NRF_EGUx));
- return (uint32_t*)&NRF_EGUx->TASKS_TRIGGER[channel];
- }
- __STATIC_INLINE nrf_egu_task_t nrf_egu_task_trigger_get(NRF_EGU_Type * NRF_EGUx, uint8_t channel)
- {
- NRFX_ASSERT(NRF_EGUx);
- NRFX_ASSERT(channel < nrf_egu_channel_count(NRF_EGUx));
- return (nrf_egu_task_t)((uint32_t) NRF_EGU_TASK_TRIGGER0 + (channel * sizeof(uint32_t)));
- }
- __STATIC_INLINE bool nrf_egu_event_check(NRF_EGU_Type * NRF_EGUx,
- nrf_egu_event_t egu_event)
- {
- NRFX_ASSERT(NRF_EGUx);
- return (bool)*(volatile uint32_t *)((uint8_t *)NRF_EGUx + (uint32_t)egu_event);
- }
- __STATIC_INLINE void nrf_egu_event_clear(NRF_EGU_Type * NRF_EGUx,
- nrf_egu_event_t egu_event)
- {
- NRFX_ASSERT(NRF_EGUx);
- *((volatile uint32_t *)((uint8_t *)NRF_EGUx + (uint32_t)egu_event)) = 0x0UL;
- #if __CORTEX_M == 0x04
- volatile uint32_t dummy = *((volatile uint32_t *)((uint8_t *)NRF_EGUx + (uint32_t)egu_event));
- (void)dummy;
- #endif
- }
- __STATIC_INLINE uint32_t * nrf_egu_event_address_get(NRF_EGU_Type * NRF_EGUx,
- nrf_egu_event_t egu_event)
- {
- NRFX_ASSERT(NRF_EGUx);
- return (uint32_t *)((uint8_t *)NRF_EGUx + (uint32_t)egu_event);
- }
- __STATIC_INLINE uint32_t * nrf_egu_event_triggered_address_get(NRF_EGU_Type * NRF_EGUx,
- uint8_t channel)
- {
- NRFX_ASSERT(NRF_EGUx);
- NRFX_ASSERT(channel < nrf_egu_channel_count(NRF_EGUx));
- return (uint32_t*)&NRF_EGUx->EVENTS_TRIGGERED[channel];
- }
- __STATIC_INLINE nrf_egu_event_t nrf_egu_event_triggered_get(NRF_EGU_Type * NRF_EGUx,
- uint8_t channel)
- {
- NRFX_ASSERT(NRF_EGUx);
- NRFX_ASSERT(channel < nrf_egu_channel_count(NRF_EGUx));
- return (nrf_egu_event_t)((uint32_t) NRF_EGU_EVENT_TRIGGERED0 + (channel * sizeof(uint32_t)));
- }
- __STATIC_INLINE void nrf_egu_int_enable(NRF_EGU_Type * NRF_EGUx, uint32_t mask)
- {
- NRFX_ASSERT(NRF_EGUx);
- NRF_EGUx->INTENSET = mask;
- }
- __STATIC_INLINE bool nrf_egu_int_enable_check(NRF_EGU_Type * NRF_EGUx, uint32_t mask)
- {
- NRFX_ASSERT(NRF_EGUx);
- return (bool)(NRF_EGUx->INTENSET & mask);
- }
- __STATIC_INLINE void nrf_egu_int_disable(NRF_EGU_Type * NRF_EGUx, uint32_t mask)
- {
- NRFX_ASSERT(NRF_EGUx);
- NRF_EGUx->INTENCLR = mask;
- }
- __STATIC_INLINE nrf_egu_int_mask_t nrf_egu_int_get(NRF_EGU_Type * NRF_EGUx, uint8_t channel)
- {
- NRFX_ASSERT(NRF_EGUx);
- NRFX_ASSERT(channel < nrf_egu_channel_count(NRF_EGUx));
- return (nrf_egu_int_mask_t)((uint32_t) (EGU_INTENSET_TRIGGERED0_Msk << channel));
- }
- #if defined(DPPI_PRESENT)
- __STATIC_INLINE void nrf_egu_subscribe_set(NRF_EGU_Type * p_reg,
- nrf_egu_task_t task,
- uint8_t channel)
- {
- *((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) =
- ((uint32_t)channel | EGU_SUBSCRIBE_TRIGGER_EN_Msk);
- }
- __STATIC_INLINE void nrf_egu_subscribe_clear(NRF_EGU_Type * p_reg,
- nrf_egu_task_t task)
- {
- *((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) = 0;
- }
- __STATIC_INLINE void nrf_egu_publish_set(NRF_EGU_Type * p_reg,
- nrf_egu_event_t event,
- uint8_t channel)
- {
- *((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) event + 0x80uL)) =
- ((uint32_t)channel | EGU_PUBLISH_TRIGGERED_EN_Msk);
- }
- __STATIC_INLINE void nrf_egu_publish_clear(NRF_EGU_Type * p_reg,
- nrf_egu_event_t event)
- {
- *((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) event + 0x80uL)) = 0;
- }
- #endif
- #endif
- #ifdef __cplusplus
- }
- #endif
- #endif
|