Skip to content

Commit 73665ee

Browse files
committed
x
1 parent ceeb967 commit 73665ee

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

cores/arduino/Arduino.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@
2121
#define ARDUINO_HEADER_LABEL arduino_mkr_header
2222
#endif
2323

24+
#define SUM_NGPIOS(i, n, p) \
25+
DT_PROP(DT_PROP_BY_IDX(n, p, i), ngpios)
26+
27+
#define GPIO_OFFSET_IDX_0 1
28+
29+
#define GPIO_OFFSET(n, p, i) \
30+
int hoge##i = COND_CODE_1(UTIL_CAT(GPIO_OFFSET_IDX_, i), (0), (LISTIFY(i, SUM_NGPIOS, (+), n, p)));
31+
2432
#define DIGITAL_PIN_EXISTS(n, p, i, dev, num) \
2533
(((dev == DT_REG_ADDR(DT_PHANDLE_BY_IDX(n, p, i))) && \
2634
(num == DT_PHA_BY_IDX(n, p, i, pin))) \

cores/arduino/zephyrCommon.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include <Arduino.h>
88
#include "zephyrInternal.h"
99

10+
DT_FOREACH_PROP_ELEM(DT_PATH(zephyr_user), gpios, GPIO_OFFSET)
11+
1012
static const struct gpio_dt_spec arduino_pins[] = {DT_FOREACH_PROP_ELEM_SEP(
1113
DT_PATH(zephyr_user), digital_pin_gpios, GPIO_DT_SPEC_GET_BY_IDX, (, ))};
1214

libraries/SPI/SPI.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
/* Count the number of GPIOs for limit of number of interrupts */
2323
#define INTERRUPT_HELPER(n, p, i) 1
2424
#define INTERRUPT_COUNT \
25-
DT_FOREACH_PROP_ELEM_SEP(DT_PATH(zephyr_user), digital_pin_gpios, \
25+
DT_FOREACH_PROP_ELEM_SEP(DT_NODELABEL(ARDUINO_HEADER_LABEL), gpio_map, \
2626
INTERRUPT_HELPER, (+))
2727

2828
namespace arduino {

variants/arduino_mkrzero/arduino_mkrzero.overlay

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
<&adc 6>,
5555
<&adc 7>;
5656

57+
gpios = <&porta>, <&portb>, <&porta>;
5758
serials = <&sercom5>;
5859
i2cs = <&sercom0>;
5960
};

0 commit comments

Comments
 (0)