|
6 | 6 |
|
7 | 7 | #include <hal/nrf_gpiote.h> |
8 | 8 | #include <nrfx_gpiote.h> |
| 9 | +#include <gpiote_nrfx.h> |
9 | 10 | #include <helpers/nrfx_gppi.h> |
10 | 11 |
|
11 | 12 | #include <debug/ppi_trace.h> |
|
14 | 15 | LOG_MODULE_REGISTER(ppi_trace, CONFIG_PPI_TRACE_LOG_LEVEL); |
15 | 16 |
|
16 | 17 | #define GPIOTE_NODE(gpio_node) DT_PHANDLE(gpio_node, gpiote_instance) |
17 | | -#define INVALID_NRFX_GPIOTE_INSTANCE \ |
18 | | - { .p_reg = NULL } |
19 | | -#define GPIOTE_INST_AND_COMMA(gpio_node) \ |
20 | | - [DT_PROP(gpio_node, port)] = \ |
21 | | - COND_CODE_1(DT_NODE_HAS_PROP(gpio_node, gpiote_instance), \ |
22 | | - (NRFX_GPIOTE_INSTANCE(DT_PROP(GPIOTE_NODE(gpio_node), instance))), \ |
23 | | - (INVALID_NRFX_GPIOTE_INSTANCE)), |
| 18 | +#define GPIOTE_INST_AND_COMMA(gpio_node) [DT_PROP(gpio_node, port)] = \ |
| 19 | + COND_CODE_1(DT_NODE_HAS_PROP(gpio_node, gpiote_instance), \ |
| 20 | + (&GPIOTE_NRFX_INST_BY_NODE(GPIOTE_NODE(gpio_node))), \ |
| 21 | + (NULL)), |
24 | 22 |
|
25 | 23 | typedef struct { |
26 | | - const nrfx_gpiote_t *gpiote; |
27 | | - uint8_t gpiote_channel; |
| 24 | + nrfx_gpiote_t *gpiote; |
| 25 | + uint8_t gpiote_channel; |
28 | 26 | } ppi_trace_gpiote_pin_t; |
29 | 27 |
|
30 | 28 | static atomic_t alloc_cnt; |
31 | 29 | static uint32_t handle_pool[CONFIG_PPI_TRACE_PIN_CNT]; |
32 | 30 |
|
33 | | -static const nrfx_gpiote_t *get_gpiote(nrfx_gpiote_pin_t pin) |
| 31 | +static nrfx_gpiote_t *get_gpiote(nrfx_gpiote_pin_t pin) |
34 | 32 | { |
35 | | - static const nrfx_gpiote_t gpiote[GPIO_COUNT] = { |
| 33 | + static nrfx_gpiote_t * const gpiote_per_port[GPIO_COUNT] = { |
36 | 34 | DT_FOREACH_STATUS_OKAY(nordic_nrf_gpio, GPIOTE_INST_AND_COMMA) |
37 | 35 | }; |
38 | 36 |
|
39 | | - const nrfx_gpiote_t *result = &gpiote[pin >> 5]; |
40 | | - |
41 | | - if (result->p_reg == NULL) { |
42 | | - /* On given pin's port there is no GPIOTE. */ |
43 | | - result = NULL; |
44 | | - } |
45 | | - |
46 | | - return result; |
| 37 | + return gpiote_per_port[NRF_PIN_NUMBER_TO_PORT(pin)]; |
47 | 38 | } |
48 | 39 |
|
49 | 40 | static bool ppi_trace_gpiote_pin_init( |
|
0 commit comments