123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586 |
- #ifndef NRFX_GPPI_H
- #define NRFX_GPPI_H
- #include <nrfx.h>
- #ifdef __cplusplus
- extern "C" {
- #endif
- #if defined(PPI_PRESENT)
- #include <hal/nrf_ppi.h>
- typedef enum
- {
- NRFX_GPPI_CHANNEL_GROUP0 = NRF_PPI_CHANNEL_GROUP0,
- NRFX_GPPI_CHANNEL_GROUP1 = NRF_PPI_CHANNEL_GROUP1,
- NRFX_GPPI_CHANNEL_GROUP2 = NRF_PPI_CHANNEL_GROUP2,
- NRFX_GPPI_CHANNEL_GROUP3 = NRF_PPI_CHANNEL_GROUP3,
- #if (PPI_GROUP_NUM > 4)
- NRFX_GPPI_CHANNEL_GROUP4 = NRF_PPI_CHANNEL_GROUP4,
- NRFX_GPPI_CHANNEL_GROUP5 = NRF_PPI_CHANNEL_GROUP5,
- #endif
- } nrfx_gppi_channel_group_t;
- typedef enum
- {
- NRFX_GPPI_TASK_CHG0_EN = NRF_PPI_TASK_CHG0_EN,
- NRFX_GPPI_TASK_CHG0_DIS = NRF_PPI_TASK_CHG0_DIS,
- NRFX_GPPI_TASK_CHG1_EN = NRF_PPI_TASK_CHG1_EN,
- NRFX_GPPI_TASK_CHG1_DIS = NRF_PPI_TASK_CHG1_DIS,
- NRFX_GPPI_TASK_CHG2_EN = NRF_PPI_TASK_CHG2_EN,
- NRFX_GPPI_TASK_CHG2_DIS = NRF_PPI_TASK_CHG2_DIS,
- NRFX_GPPI_TASK_CHG3_EN = NRF_PPI_TASK_CHG3_EN,
- NRFX_GPPI_TASK_CHG3_DIS = NRF_PPI_TASK_CHG3_DIS,
- #if (PPI_GROUP_NUM > 4)
- NRFX_GPPI_TASK_CHG4_EN = NRF_PPI_TASK_CHG4_EN,
- NRFX_GPPI_TASK_CHG4_DIS = NRF_PPI_TASK_CHG4_DIS,
- NRFX_GPPI_TASK_CHG5_EN = NRF_PPI_TASK_CHG5_EN,
- NRFX_GPPI_TASK_CHG5_DIS = NRF_PPI_TASK_CHG5_DIS
- #endif
- } nrfx_gppi_task_t;
- #elif defined(DPPI_PRESENT)
- #include <hal/nrf_dppi.h>
- typedef enum
- {
- NRFX_GPPI_CHANNEL_GROUP0 = NRF_DPPI_CHANNEL_GROUP0,
- NRFX_GPPI_CHANNEL_GROUP1 = NRF_DPPI_CHANNEL_GROUP1,
- NRFX_GPPI_CHANNEL_GROUP2 = NRF_DPPI_CHANNEL_GROUP2,
- NRFX_GPPI_CHANNEL_GROUP3 = NRF_DPPI_CHANNEL_GROUP3,
- NRFX_GPPI_CHANNEL_GROUP4 = NRF_DPPI_CHANNEL_GROUP4,
- NRFX_GPPI_CHANNEL_GROUP5 = NRF_DPPI_CHANNEL_GROUP5,
- } nrfx_gppi_channel_group_t;
- typedef enum
- {
- NRFX_GPPI_TASK_CHG0_EN = NRF_DPPI_TASK_CHG0_EN,
- NRFX_GPPI_TASK_CHG0_DIS = NRF_DPPI_TASK_CHG0_DIS,
- NRFX_GPPI_TASK_CHG1_EN = NRF_DPPI_TASK_CHG1_EN,
- NRFX_GPPI_TASK_CHG1_DIS = NRF_DPPI_TASK_CHG1_DIS,
- NRFX_GPPI_TASK_CHG2_EN = NRF_DPPI_TASK_CHG2_EN,
- NRFX_GPPI_TASK_CHG2_DIS = NRF_DPPI_TASK_CHG2_DIS,
- NRFX_GPPI_TASK_CHG3_EN = NRF_DPPI_TASK_CHG3_EN,
- NRFX_GPPI_TASK_CHG3_DIS = NRF_DPPI_TASK_CHG3_DIS,
- NRFX_GPPI_TASK_CHG4_EN = NRF_DPPI_TASK_CHG4_EN,
- NRFX_GPPI_TASK_CHG4_DIS = NRF_DPPI_TASK_CHG4_DIS,
- NRFX_GPPI_TASK_CHG5_EN = NRF_DPPI_TASK_CHG5_EN,
- NRFX_GPPI_TASK_CHG5_DIS = NRF_DPPI_TASK_CHG5_DIS
- } nrfx_gppi_task_t;
- #elif defined(__NRFX_DOXYGEN__)
- typedef enum
- {
- NRFX_GPPI_CHANNEL_GROUP0,
- NRFX_GPPI_CHANNEL_GROUP1,
- NRFX_GPPI_CHANNEL_GROUP2,
- NRFX_GPPI_CHANNEL_GROUP3,
- NRFX_GPPI_CHANNEL_GROUP4,
- NRFX_GPPI_CHANNEL_GROUP5,
- } nrfx_gppi_channel_group_t;
- typedef enum
- {
- NRFX_GPPI_TASK_CHG0_EN,
- NRFX_GPPI_TASK_CHG0_DIS,
- NRFX_GPPI_TASK_CHG1_EN,
- NRFX_GPPI_TASK_CHG1_DIS,
- NRFX_GPPI_TASK_CHG2_EN,
- NRFX_GPPI_TASK_CHG2_DIS,
- NRFX_GPPI_TASK_CHG3_EN,
- NRFX_GPPI_TASK_CHG3_DIS,
- NRFX_GPPI_TASK_CHG4_EN,
- NRFX_GPPI_TASK_CHG4_DIS,
- NRFX_GPPI_TASK_CHG5_EN,
- NRFX_GPPI_TASK_CHG5_DIS,
- } nrfx_gppi_task_t;
- #endif
- __STATIC_INLINE bool nrfx_gppi_channel_check(uint8_t channel);
- __STATIC_INLINE void nrfx_gppi_channels_disable_all(void);
- __STATIC_INLINE void nrfx_gppi_channels_enable(uint32_t mask);
- __STATIC_INLINE void nrfx_gppi_channels_disable(uint32_t mask);
- __STATIC_INLINE void nrfx_gppi_event_endpoint_setup(uint8_t channel, uint32_t eep);
- __STATIC_INLINE void nrfx_gppi_task_endpoint_setup(uint8_t channel, uint32_t tep);
- __STATIC_INLINE void nrfx_gppi_channel_endpoints_setup(uint8_t channel,
- uint32_t eep,
- uint32_t tep);
- __STATIC_INLINE void nrfx_gppi_event_endpoint_clear(uint8_t channel, uint32_t eep);
- __STATIC_INLINE void nrfx_gppi_task_endpoint_clear(uint8_t channel, uint32_t tep);
- #if defined(PPI_FEATURE_FORKS_PRESENT) || defined(DPPI_PRESENT) || defined(__NRFX_DOXYGEN__)
- __STATIC_INLINE void nrfx_gppi_fork_endpoint_setup(uint8_t channel, uint32_t fork_tep);
- __STATIC_INLINE void nrfx_gppi_fork_endpoint_clear(uint8_t channel, uint32_t fork_tep);
- #endif
- __STATIC_INLINE void nrfx_gppi_channels_include_in_group(uint32_t channel_mask,
- nrfx_gppi_channel_group_t channel_group);
- __STATIC_INLINE void nrfx_gppi_channels_remove_from_group(uint32_t channel_mask,
- nrfx_gppi_channel_group_t channel_group);
- __STATIC_INLINE void nrfx_gppi_group_clear(nrfx_gppi_channel_group_t channel_group);
- __STATIC_INLINE void nrfx_gppi_group_enable(nrfx_gppi_channel_group_t channel_group);
- __STATIC_INLINE void nrfx_gppi_group_disable(nrfx_gppi_channel_group_t channel_group);
- __STATIC_INLINE void nrfx_gppi_task_trigger(nrfx_gppi_task_t task);
- __STATIC_INLINE uint32_t nrfx_gppi_task_address_get(nrfx_gppi_task_t task);
- __STATIC_INLINE nrfx_gppi_task_t nrfx_gppi_group_disable_task_get(nrfx_gppi_channel_group_t group);
- __STATIC_INLINE nrfx_gppi_task_t nrfx_gppi_group_enable_task_get(nrfx_gppi_channel_group_t group);
- #if defined(PPI_PRESENT)
- __STATIC_INLINE bool nrfx_gppi_channel_check(uint8_t channel)
- {
- return (nrf_ppi_channel_enable_get((nrf_ppi_channel_t)channel) == NRF_PPI_CHANNEL_ENABLED);
- }
- __STATIC_INLINE void nrfx_gppi_channels_disable_all(void)
- {
- nrf_ppi_channel_disable_all();
- }
- __STATIC_INLINE void nrfx_gppi_channels_enable(uint32_t mask)
- {
- nrf_ppi_channels_enable(mask);
- }
- __STATIC_INLINE void nrfx_gppi_channels_disable(uint32_t mask)
- {
- nrf_ppi_channels_disable(mask);
- }
- __STATIC_INLINE void nrfx_gppi_event_endpoint_setup(uint8_t channel, uint32_t eep)
- {
- nrf_ppi_event_endpoint_setup((nrf_ppi_channel_t)channel, eep);
- }
- __STATIC_INLINE void nrfx_gppi_task_endpoint_setup(uint8_t channel, uint32_t tep)
- {
- nrf_ppi_task_endpoint_setup((nrf_ppi_channel_t)channel, tep);
- }
- __STATIC_INLINE void nrfx_gppi_channel_endpoints_setup(uint8_t channel,
- uint32_t eep,
- uint32_t tep)
- {
- nrf_ppi_channel_endpoint_setup((nrf_ppi_channel_t)channel, eep, tep);
- }
- __STATIC_INLINE void nrfx_gppi_event_endpoint_clear(uint8_t channel, uint32_t eep)
- {
- (void)eep;
- nrf_ppi_event_endpoint_setup((nrf_ppi_channel_t)channel, 0);
- }
- __STATIC_INLINE void nrfx_gppi_task_endpoint_clear(uint8_t channel, uint32_t tep)
- {
- (void)tep;
- nrf_ppi_task_endpoint_setup((nrf_ppi_channel_t)channel, 0);
- }
- #if defined(PPI_FEATURE_FORKS_PRESENT)
- __STATIC_INLINE void nrfx_gppi_fork_endpoint_setup(uint8_t channel, uint32_t fork_tep)
- {
- nrf_ppi_fork_endpoint_setup((nrf_ppi_channel_t)channel, fork_tep);
- }
- __STATIC_INLINE void nrfx_gppi_fork_endpoint_clear(uint8_t channel, uint32_t fork_tep)
- {
- (void)fork_tep;
- nrf_ppi_fork_endpoint_setup((nrf_ppi_channel_t)channel, 0);
- }
- #endif
- __STATIC_INLINE void nrfx_gppi_channels_include_in_group(uint32_t channel_mask,
- nrfx_gppi_channel_group_t channel_group)
- {
- nrf_ppi_channels_include_in_group(channel_mask, channel_group);
- }
- __STATIC_INLINE void nrfx_gppi_channels_remove_from_group(uint32_t channel_mask,
- nrfx_gppi_channel_group_t channel_group)
- {
- nrf_ppi_channels_remove_from_group(channel_mask, channel_group);
- }
- __STATIC_INLINE void nrfx_gppi_group_clear(nrfx_gppi_channel_group_t channel_group)
- {
- nrf_ppi_channel_group_clear(channel_group);
- }
- __STATIC_INLINE void nrfx_gppi_group_enable(nrfx_gppi_channel_group_t channel_group)
- {
- nrf_ppi_group_enable(channel_group);
- }
- __STATIC_INLINE void nrfx_gppi_group_disable(nrfx_gppi_channel_group_t channel_group)
- {
- nrf_ppi_group_disable(channel_group);
- }
- __STATIC_INLINE void nrfx_gppi_task_trigger(nrfx_gppi_task_t task)
- {
- nrf_ppi_task_trigger(task);
- }
- __STATIC_INLINE uint32_t nrfx_gppi_task_address_get(nrfx_gppi_task_t task)
- {
- return (uint32_t)nrf_ppi_task_address_get(task);
- }
- __STATIC_INLINE nrfx_gppi_task_t nrfx_gppi_group_disable_task_get(nrfx_gppi_channel_group_t group)
- {
- return (nrfx_gppi_task_t)nrf_ppi_group_disable_task_get((uint8_t)group);
- }
- __STATIC_INLINE nrfx_gppi_task_t nrfx_gppi_group_enable_task_get(nrfx_gppi_channel_group_t group)
- {
- return (nrfx_gppi_task_t)nrf_ppi_group_enable_task_get((uint8_t)group);
- }
- #elif defined(DPPI_PRESENT)
- __STATIC_INLINE bool nrfx_gppi_channel_check(uint8_t channel)
- {
- return nrf_dppi_channel_check(NRF_DPPIC, channel);
- }
- __STATIC_INLINE void nrfx_gppi_channels_disable_all(void)
- {
- nrf_dppi_channels_disable_all(NRF_DPPIC);
- }
- __STATIC_INLINE void nrfx_gppi_channels_enable(uint32_t mask)
- {
- nrf_dppi_channels_enable(NRF_DPPIC, mask);
- }
- __STATIC_INLINE void nrfx_gppi_channels_disable(uint32_t mask)
- {
- nrf_dppi_channels_disable(NRF_DPPIC, mask);
- }
- __STATIC_INLINE void nrfx_gppi_task_trigger(nrfx_gppi_task_t task)
- {
- nrf_dppi_task_trigger(NRF_DPPIC, task);
- }
- __STATIC_INLINE void nrfx_gppi_event_endpoint_setup(uint8_t channel, uint32_t eep)
- {
- NRFX_ASSERT(eep);
- *((volatile uint32_t *)(eep + 0x80uL)) = ((uint32_t)channel | DPPIC_SUBSCRIBE_CHG_EN_EN_Msk);
- }
- __STATIC_INLINE void nrfx_gppi_task_endpoint_setup(uint8_t channel, uint32_t tep)
- {
- NRFX_ASSERT(tep);
- *((volatile uint32_t *)(tep + 0x80uL)) = ((uint32_t)channel | DPPIC_SUBSCRIBE_CHG_EN_EN_Msk);
- }
- __STATIC_INLINE void nrfx_gppi_channel_endpoints_setup(uint8_t channel,
- uint32_t eep,
- uint32_t tep)
- {
- nrfx_gppi_event_endpoint_setup(channel, eep);
- nrfx_gppi_task_endpoint_setup(channel, tep);
- }
- __STATIC_INLINE void nrfx_gppi_event_endpoint_clear(uint8_t channel, uint32_t eep)
- {
- NRFX_ASSERT(eep);
- (void)channel;
- *((volatile uint32_t *)(eep + 0x80uL)) = 0;
- }
- __STATIC_INLINE void nrfx_gppi_task_endpoint_clear(uint8_t channel, uint32_t tep)
- {
- NRFX_ASSERT(tep);
- (void)channel;
- *((volatile uint32_t *)(tep + 0x80uL)) = 0;
- }
- __STATIC_INLINE void nrfx_gppi_fork_endpoint_setup(uint8_t channel, uint32_t fork_tep)
- {
- nrfx_gppi_task_endpoint_setup(channel, fork_tep);
- }
- __STATIC_INLINE void nrfx_gppi_fork_endpoint_clear(uint8_t channel, uint32_t fork_tep)
- {
- nrfx_gppi_task_endpoint_clear(channel, fork_tep);
- }
- __STATIC_INLINE void nrfx_gppi_channels_include_in_group(uint32_t channel_mask,
- nrfx_gppi_channel_group_t channel_group)
- {
- nrf_dppi_channels_include_in_group(NRF_DPPIC, channel_mask, channel_group);
- }
- __STATIC_INLINE void nrfx_gppi_channels_remove_from_group(uint32_t channel_mask,
- nrfx_gppi_channel_group_t channel_group)
- {
- nrf_dppi_channels_remove_from_group(NRF_DPPIC, channel_mask, channel_group);
- }
- __STATIC_INLINE void nrfx_gppi_group_clear(nrfx_gppi_channel_group_t channel_group)
- {
- nrf_dppi_group_clear(NRF_DPPIC, channel_group);
- }
- __STATIC_INLINE void nrfx_gppi_group_enable(nrfx_gppi_channel_group_t channel_group)
- {
- nrf_dppi_group_enable(NRF_DPPIC, channel_group);
- }
- __STATIC_INLINE void nrfx_gppi_group_disable(nrfx_gppi_channel_group_t channel_group)
- {
- nrf_dppi_group_disable(NRF_DPPIC, channel_group);
- }
- __STATIC_INLINE uint32_t nrfx_gppi_task_address_get(nrfx_gppi_task_t gppi_task)
- {
- return (uint32_t) ((uint8_t *) NRF_DPPIC + (uint32_t) gppi_task);
- }
- __STATIC_INLINE nrfx_gppi_task_t nrfx_gppi_group_disable_task_get(nrfx_gppi_channel_group_t group)
- {
- return (nrfx_gppi_task_t) nrf_dppi_group_disable_task_get((uint8_t)group);
- }
- __STATIC_INLINE nrfx_gppi_task_t nrfx_gppi_group_enable_task_get(nrfx_gppi_channel_group_t group)
- {
- return (nrfx_gppi_task_t) nrf_dppi_group_enable_task_get((uint8_t)group);
- }
- #else
- #error "Neither PPI nor DPPI is present in the SoC currently in use."
- #endif
- #ifdef __cplusplus
- }
- #endif
- #endif
|