Skip to content

Commit ed7eb90

Browse files
committed
variants: Add a check for duplicated pin in digital-pin-gpios
Checking a non-unique pin in digital-pin-gpios to keep consistency of configuration. Signed-off-by: TOKITA Hiroshi <[email protected]>
1 parent 3e1e370 commit ed7eb90

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

variants/variants.h

+18
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,24 @@
1818
#include "arduino_mkrzero_pinmap.h"
1919
#endif // CONFIG_BOARD_ARDUINO_MKRZERO
2020

21+
#define DIGITAL_PIN_EXISTS(n, p, i, dev, num) \
22+
(((dev == DT_REG_ADDR(DT_PHANDLE_BY_IDX(n, p, i))) && \
23+
(num == DT_PHA_BY_IDX(n, p, i, pin))) \
24+
? 1 \
25+
: 0)
26+
27+
#define DIGITAL_PIN_CHECK_UNIQUE(i, _) \
28+
((DT_FOREACH_PROP_ELEM_SEP_VARGS( \
29+
DT_PATH(zephyr_user), digital_pin_gpios, DIGITAL_PIN_EXISTS, (+), \
30+
DT_REG_ADDR(DT_PHANDLE_BY_IDX(DT_PATH(zephyr_user), digital_pin_gpios, i)), \
31+
DT_PHA_BY_IDX(DT_PATH(zephyr_user), digital_pin_gpios, i, pin))) == 1)
32+
33+
#if !LISTIFY(DT_PROP_LEN(DT_PATH(zephyr_user), digital_pin_gpios), DIGITAL_PIN_CHECK_UNIQUE, (&&))
34+
#error "digital_pin_gpios has duplicate definition"
35+
#endif
36+
37+
#undef DIGITAL_PIN_CHECK_UNIQUE
38+
2139
#define DN_ENUMS(n, p, i) D##i = i
2240

2341
/*

0 commit comments

Comments
 (0)