From 631b0addeaf5d216bfbbd15d67032f2f2607a997 Mon Sep 17 00:00:00 2001 From: Andrzej Kuros Date: Mon, 26 Aug 2024 12:52:20 +0200 Subject: [PATCH] debug: ppi_trace: handle pins of gpio ports with no gpiote-instance 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 --- subsys/debug/ppi_trace/ppi_trace.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/subsys/debug/ppi_trace/ppi_trace.c b/subsys/debug/ppi_trace/ppi_trace.c index ee787bac9480..6ac5c178c2b7 100644 --- a/subsys/debug/ppi_trace/ppi_trace.c +++ b/subsys/debug/ppi_trace/ppi_trace.c @@ -47,9 +47,13 @@ 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) { @@ -57,7 +61,11 @@ static const nrfx_gpiote_t *get_gpiote(nrfx_gpiote_pin_t pin) 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. */