Skip to content

Commit 631b0ad

Browse files
ankunsrlubos
authored andcommitted
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 <[email protected]>
1 parent 3d3284b commit 631b0ad

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

subsys/debug/ppi_trace/ppi_trace.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,25 @@ LOG_MODULE_REGISTER(ppi_trace, CONFIG_PPI_TRACE_LOG_LEVEL);
4747
#define GET_STOP_CH(handle) (((uint32_t)handle >> 8) & 0xFF)
4848

4949
#define GPIOTE_NODE(gpio_node) DT_PHANDLE(gpio_node, gpiote_instance)
50+
#define INVALID_NRFX_GPIOTE_INSTANCE \
51+
{ .p_reg = NULL }
5052
#define GPIOTE_INST_AND_COMMA(gpio_node) \
5153
[DT_PROP(gpio_node, port)] = \
52-
NRFX_GPIOTE_INSTANCE(DT_PROP(GPIOTE_NODE(gpio_node), instance)),
54+
COND_CODE_1(DT_NODE_HAS_PROP(gpio_node, gpiote_instance), \
55+
(NRFX_GPIOTE_INSTANCE(DT_PROP(GPIOTE_NODE(gpio_node), instance))), \
56+
(INVALID_NRFX_GPIOTE_INSTANCE)),
5357

5458
static const nrfx_gpiote_t *get_gpiote(nrfx_gpiote_pin_t pin)
5559
{
5660
static const nrfx_gpiote_t gpiote[GPIO_COUNT] = {
5761
DT_FOREACH_STATUS_OKAY(nordic_nrf_gpio, GPIOTE_INST_AND_COMMA)
5862
};
5963

60-
return &gpiote[pin >> 5];
64+
const nrfx_gpiote_t *result = &gpiote[pin >> 5];
65+
66+
__ASSERT(result->p_reg != NULL, "The pin=%u nas no GPIOTE", pin);
67+
68+
return result;
6169
}
6270

6371
/** @brief Allocate (D)PPI channel. */

0 commit comments

Comments
 (0)