1 /*
2  * Copyright (c) 2023 Nordic Semiconductor ASA
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 /*
8  * The integrator should ensure this header is in
9  * the include path before the real hal/nrf_dppi.h
10  */
11 
12 #ifndef HAL_REPLACEMENTS_HAL_NRF_DPPI_H
13 #define HAL_REPLACEMENTS_HAL_NRF_DPPI_H
14 
15 #include_next "hal/nrf_dppi.h"
16 
17 /*
18  * Special API for the HW models, which allows setting or clearing
19  * any subscribe register based on a pointer to the register
20  *
21  * These calls are experimental and may change at any point
22  */
23 void nrf_dppi_hack_subscribe_set(void *sub_reg, unsigned int channel);
24 void nrf_dppi_hack_subscribe_clear(void *sub_reg);
25 
26 #undef NRF_DPPI_ENDPOINT_SETUP
27 #define NRF_DPPI_ENDPOINT_SETUP(task_or_event, dppi_chan)                            \
28   do {                                                                               \
29     uint32_t tmp = task_or_event + NRF_SUBSCRIBE_PUBLISH_OFFSET(task_or_event);      \
30     *(volatile uint32_t *)tmp = ((uint32_t)dppi_chan | NRF_SUBSCRIBE_PUBLISH_ENABLE);\
31     nrf_dppi_hack_subscribe_set((void *)tmp, dppi_chan);                             \
32   } while(0)
33 
34 #undef NRF_DPPI_ENDPOINT_CLEAR
35 #define NRF_DPPI_ENDPOINT_CLEAR(task_or_event)                                  \
36   do {                                                                          \
37     uint32_t tmp = task_or_event + NRF_SUBSCRIBE_PUBLISH_OFFSET(task_or_event); \
38     *(volatile uint32_t *)tmp = 0;                                              \
39     nrf_dppi_hack_subscribe_clear((void *)tmp);                                 \
40   } while(0)
41 
42 #endif /* HAL_REPLACEMENTS_HAL_NRF_DPPI_H */
43