123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341 |
- #ifndef NRF_DPPI_H__
- #define NRF_DPPI_H__
- #include <nrfx.h>
- #ifdef __cplusplus
- extern "C" {
- #endif
- typedef enum
- {
- NRF_DPPI_CHANNEL_GROUP0 = 0,
- NRF_DPPI_CHANNEL_GROUP1 = 1,
- NRF_DPPI_CHANNEL_GROUP2 = 2,
- NRF_DPPI_CHANNEL_GROUP3 = 3,
- NRF_DPPI_CHANNEL_GROUP4 = 4,
- NRF_DPPI_CHANNEL_GROUP5 = 5
- } nrf_dppi_channel_group_t;
- typedef enum
- {
- NRF_DPPI_TASK_CHG0_EN = offsetof(NRF_DPPIC_Type, TASKS_CHG[0].EN),
- NRF_DPPI_TASK_CHG0_DIS = offsetof(NRF_DPPIC_Type, TASKS_CHG[0].DIS),
- NRF_DPPI_TASK_CHG1_EN = offsetof(NRF_DPPIC_Type, TASKS_CHG[1].EN),
- NRF_DPPI_TASK_CHG1_DIS = offsetof(NRF_DPPIC_Type, TASKS_CHG[1].DIS),
- NRF_DPPI_TASK_CHG2_EN = offsetof(NRF_DPPIC_Type, TASKS_CHG[2].EN),
- NRF_DPPI_TASK_CHG2_DIS = offsetof(NRF_DPPIC_Type, TASKS_CHG[2].DIS),
- NRF_DPPI_TASK_CHG3_EN = offsetof(NRF_DPPIC_Type, TASKS_CHG[3].EN),
- NRF_DPPI_TASK_CHG3_DIS = offsetof(NRF_DPPIC_Type, TASKS_CHG[3].DIS),
- NRF_DPPI_TASK_CHG4_EN = offsetof(NRF_DPPIC_Type, TASKS_CHG[4].EN),
- NRF_DPPI_TASK_CHG4_DIS = offsetof(NRF_DPPIC_Type, TASKS_CHG[4].DIS),
- NRF_DPPI_TASK_CHG5_EN = offsetof(NRF_DPPIC_Type, TASKS_CHG[5].EN),
- NRF_DPPI_TASK_CHG5_DIS = offsetof(NRF_DPPIC_Type, TASKS_CHG[5].DIS)
- } nrf_dppi_task_t;
- __STATIC_INLINE void nrf_dppi_task_trigger(NRF_DPPIC_Type * p_reg, nrf_dppi_task_t dppi_task);
- __STATIC_INLINE uint32_t nrf_dppi_task_address_get(NRF_DPPIC_Type const * p_reg,
- nrf_dppi_task_t task);
- __STATIC_INLINE bool nrf_dppi_channel_check(NRF_DPPIC_Type const * p_reg, uint8_t channel);
- __STATIC_INLINE void nrf_dppi_channels_enable(NRF_DPPIC_Type * p_reg, uint32_t mask);
- __STATIC_INLINE void nrf_dppi_channels_disable(NRF_DPPIC_Type * p_reg, uint32_t mask);
- __STATIC_INLINE void nrf_dppi_channels_disable_all(NRF_DPPIC_Type * p_reg);
- __STATIC_INLINE void nrf_dppi_subscribe_set(NRF_DPPIC_Type * p_reg,
- nrf_dppi_task_t task,
- uint8_t channel);
- __STATIC_INLINE void nrf_dppi_subscribe_clear(NRF_DPPIC_Type * p_reg, nrf_dppi_task_t task);
- __STATIC_INLINE void nrf_dppi_channels_include_in_group(NRF_DPPIC_Type * p_reg,
- uint32_t channel_mask,
- nrf_dppi_channel_group_t channel_group);
- __STATIC_INLINE void nrf_dppi_channels_remove_from_group(NRF_DPPIC_Type * p_reg,
- uint32_t channel_mask,
- nrf_dppi_channel_group_t channel_group);
- __STATIC_INLINE void nrf_dppi_group_clear(NRF_DPPIC_Type * p_reg,
- nrf_dppi_channel_group_t group);
- __STATIC_INLINE void nrf_dppi_group_enable(NRF_DPPIC_Type * p_reg,
- nrf_dppi_channel_group_t group);
- __STATIC_INLINE void nrf_dppi_group_disable(NRF_DPPIC_Type * p_reg,
- nrf_dppi_channel_group_t group);
- __STATIC_INLINE nrf_dppi_task_t nrf_dppi_group_enable_task_get(uint8_t index);
- __STATIC_INLINE nrf_dppi_task_t nrf_dppi_group_disable_task_get(uint8_t index);
- #ifndef SUPPRESS_INLINE_IMPLEMENTATION
- __STATIC_INLINE void nrf_dppi_task_trigger(NRF_DPPIC_Type * p_reg, nrf_dppi_task_t dppi_task)
- {
- *((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) dppi_task)) = 1;
- }
- __STATIC_INLINE uint32_t nrf_dppi_task_address_get(NRF_DPPIC_Type const * p_reg,
- nrf_dppi_task_t task)
- {
- return (uint32_t) ((uint8_t *) p_reg + (uint32_t ) task);
- }
- __STATIC_INLINE bool nrf_dppi_channel_check(NRF_DPPIC_Type const * p_reg, uint8_t channel)
- {
- return ((p_reg->CHEN & (DPPIC_CHEN_CH0_Enabled << (DPPIC_CHEN_CH0_Pos + channel))) != 0);
- }
- __STATIC_INLINE void nrf_dppi_channels_disable_all(NRF_DPPIC_Type * p_reg)
- {
- p_reg->CHENCLR = 0xFFFFFFFFuL;
- }
- __STATIC_INLINE void nrf_dppi_channels_enable(NRF_DPPIC_Type * p_reg, uint32_t mask)
- {
- p_reg->CHENSET = mask;
- }
- __STATIC_INLINE void nrf_dppi_channels_disable(NRF_DPPIC_Type * p_reg, uint32_t mask)
- {
- p_reg->CHENCLR = mask;
- }
- __STATIC_INLINE void nrf_dppi_subscribe_set(NRF_DPPIC_Type * p_reg,
- nrf_dppi_task_t task,
- uint8_t channel)
- {
- *((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) =
- ((uint32_t)channel | DPPIC_SUBSCRIBE_CHG_EN_EN_Msk);
- }
- __STATIC_INLINE void nrf_dppi_subscribe_clear(NRF_DPPIC_Type * p_reg, nrf_dppi_task_t task)
- {
- *((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) = 0;
- }
- __STATIC_INLINE void nrf_dppi_channels_include_in_group(NRF_DPPIC_Type * p_reg,
- uint32_t channel_mask,
- nrf_dppi_channel_group_t channel_group)
- {
- p_reg->CHG[(uint32_t) channel_group] =
- p_reg->CHG[(uint32_t) channel_group] | (channel_mask);
- }
- __STATIC_INLINE void nrf_dppi_channels_remove_from_group(NRF_DPPIC_Type * p_reg,
- uint32_t channel_mask,
- nrf_dppi_channel_group_t channel_group)
- {
- p_reg->CHG[(uint32_t) channel_group] =
- p_reg->CHG[(uint32_t) channel_group] & ~(channel_mask);
- }
- __STATIC_INLINE void nrf_dppi_group_clear(NRF_DPPIC_Type * p_reg,
- nrf_dppi_channel_group_t group)
- {
- p_reg->CHG[(uint32_t) group] = 0;
- }
- __STATIC_INLINE void nrf_dppi_group_enable(NRF_DPPIC_Type * p_reg, nrf_dppi_channel_group_t group)
- {
- p_reg->TASKS_CHG[(uint32_t) group].EN = 1;
- }
- __STATIC_INLINE void nrf_dppi_group_disable(NRF_DPPIC_Type * p_reg,
- nrf_dppi_channel_group_t group)
- {
- p_reg->TASKS_CHG[(uint32_t) group].DIS = 1;
- }
- __STATIC_INLINE nrf_dppi_task_t nrf_dppi_group_enable_task_get(uint8_t index)
- {
- NRFX_ASSERT(index < NRFX_ARRAY_SIZE(NRF_DPPIC->TASKS_CHG));
- return (nrf_dppi_task_t)NRFX_OFFSETOF(NRF_DPPIC_Type, TASKS_CHG[index].EN);
- }
- __STATIC_INLINE nrf_dppi_task_t nrf_dppi_group_disable_task_get(uint8_t index)
- {
- NRFX_ASSERT(index < NRFX_ARRAY_SIZE(NRF_DPPIC->TASKS_CHG));
- return (nrf_dppi_task_t)NRFX_OFFSETOF(NRF_DPPIC_Type, TASKS_CHG[index].DIS);
- }
- #endif
- #ifdef __cplusplus
- }
- #endif
- #endif
|