Skip to content

Commit 3168510

Browse files
pillo79soburi
authored andcommitted
Arduino.h: fix DIGITAL_PIN_EXISTS macro to avoid comment expansion issues
The DIGITAL_PIN_EXISTS macro (used e.g. by LED_BUILTIN) was not working properly because the inline comments in devicetree_generated.h were confusing the preprocessor: one internal macro tried to create an unsigned constant by pasting a '*/' comment end marker with the 'U' character. Splitting that macro into two parts, so that the DT_REG_ADDR macro is invoked with an expanded argument, fixes the issue. ------------------------------------------------------------------- Pick: arduino@84651c2c Signed-off-by: Luca Burelli <l.burelli@arduino.cc> Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
1 parent 874bd80 commit 3168510

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

cores/arduino/Arduino.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515
#include <zephyr/drivers/i2c.h>
1616

1717
#if DT_PROP_LEN(DT_PATH(zephyr_user), digital_pin_gpios) > 0
18+
/* Note: DT_REG_ADDR needs an expanded argument or it will not work properly */
19+
#define DIGITAL_PIN_MATCHES(dev_pha, pin, dev, num) \
20+
(((dev == DT_REG_ADDR(dev_pha)) && (num == pin)) ? 1 : 0)
1821
#define DIGITAL_PIN_EXISTS(n, p, i, dev, num) \
19-
(((dev == DT_REG_ADDR(DT_PHANDLE_BY_IDX(n, p, i))) && (num == DT_PHA_BY_IDX(n, p, i, pin))) ? \
20-
1 : \
21-
0)
22+
DIGITAL_PIN_MATCHES(DT_PHANDLE_BY_IDX(n, p, i), DT_PHA_BY_IDX(n, p, i, pin), dev, num)
2223

2324
/* Check all pins are defined only once */
2425
#define DIGITAL_PIN_CHECK_UNIQUE(i, _) \

0 commit comments

Comments
 (0)