Skip to content

Commit

Permalink
debug: ppi_trace: handle pins of gpio ports with no gpiote-instance
Browse files Browse the repository at this point in the history
Some instances with compatible `nordic,nrf_gpio` might have no
`gpiote-instance` property set. For example nRF54L15 port P2 has no
GPIOTE at all. The code didn't compile in such cases because
NRFX_GPIOTE_INSTANCE macro was still requested.

Now, when given gpio port has no `gpiote-instance` property, the
nrfx_gpiote_t entry with p_reg = NULL is emitted.

Signed-off-by: Andrzej Kuros <[email protected]>
  • Loading branch information
ankuns committed Dec 3, 2024
1 parent ea19874 commit 16880dd
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions subsys/debug/ppi_trace/ppi_trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,25 @@ LOG_MODULE_REGISTER(ppi_trace, CONFIG_PPI_TRACE_LOG_LEVEL);
#define GET_STOP_CH(handle) (((uint32_t)handle >> 8) & 0xFF)

#define GPIOTE_NODE(gpio_node) DT_PHANDLE(gpio_node, gpiote_instance)
#define INVALID_NRFX_GPIOTE_INSTANCE \
{ .p_reg = NULL }
#define GPIOTE_INST_AND_COMMA(gpio_node) \
[DT_PROP(gpio_node, port)] = \
NRFX_GPIOTE_INSTANCE(DT_PROP(GPIOTE_NODE(gpio_node), instance)),
COND_CODE_1(DT_NODE_HAS_PROP(gpio_node, gpiote_instance), \
(NRFX_GPIOTE_INSTANCE(DT_PROP(GPIOTE_NODE(gpio_node), instance))), \
(INVALID_NRFX_GPIOTE_INSTANCE)),

static const nrfx_gpiote_t *get_gpiote(nrfx_gpiote_pin_t pin)
{
static const nrfx_gpiote_t gpiote[GPIO_COUNT] = {
DT_FOREACH_STATUS_OKAY(nordic_nrf_gpio, GPIOTE_INST_AND_COMMA)
};

return &gpiote[pin >> 5];
const nrfx_gpiote_t *result = &gpiote[pin >> 5];

__ASSERT(result->p_reg != NULL, "The pin=%u nas no GPIOTE", pin);

return result;
}

/** @brief Allocate (D)PPI channel. */
Expand Down

0 comments on commit 16880dd

Please sign in to comment.