Skip to content

Commit c9d18c2

Browse files
sebromerosoburi
authored andcommitted
cores: arduino: add macro to find pins by node
Add `DIGITAL_PIN_GPIOS_FIND_NODE` helper macro. ------------------------------------------------------------------- Pick: arduino@a60cd82a Co-Authored-by: Sebastian Romero <s.romero@arduino.cc> Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
1 parent a473caa commit c9d18c2

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

cores/arduino/Arduino.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@
3535
#undef DIGITAL_PIN_CHECK_UNIQUE
3636
#endif
3737

38+
// Helper macro to get Arduino pin number from device tree alias
39+
#define DIGITAL_PIN_GPIOS_FIND_NODE(node) \
40+
DIGITAL_PIN_GPIOS_FIND_PIN(DT_REG_ADDR(DT_PHANDLE_BY_IDX(node, gpios, 0)), \
41+
DT_PHA_BY_IDX(node, gpios, 0, pin))
42+
3843
/* Return the index of it if matched, oterwise return 0 */
3944
#define LED_BUILTIN_INDEX_BY_REG_AND_PINNUM(n, p, i, dev, num) \
4045
(DIGITAL_PIN_EXISTS(n, p, i, dev, num) ? i : 0)

0 commit comments

Comments
 (0)