Skip to content

Commit c3ed208

Browse files
committed
ports
1 parent 730e7c9 commit c3ed208

File tree

11 files changed

+18
-13
lines changed

11 files changed

+18
-13
lines changed

cores/arduino/Arduino.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
COND_CODE_1(DT_SAME_NODE(DT_PROP_BY_IDX(n, p, i), nd), \
2121
(LISTIFY(i, ZARD_ADD_NGPIOS, (), n, p)), ())
2222
#define ZARD_GLOBAL_GPIO_NUM(n, p, i) \
23-
DT_FOREACH_PROP_ELEM_VARGS(DT_PATH(zephyr_user), gpios, ZARD_ACCUM_NGPIOS, \
23+
DT_FOREACH_PROP_ELEM_VARGS(DT_PATH(zephyr_user), gpio_ports, ZARD_ACCUM_NGPIOS, \
2424
DT_PHANDLE_BY_IDX(n, p, i)) \
2525
DT_PHA_BY_IDX(n, p, i, pin)
2626
#define DIGITAL_PIN_EXISTS(n, p, i, dev, num) \

cores/arduino/zephyrCommon.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ namespace {
1515

1616
#define DEVICE_GPIO(n, p, i) DEVICE_DT_GET(DT_PROP_BY_IDX(n, p, i))
1717
constexpr const struct device *gpios[] = {
18-
DT_FOREACH_PROP_ELEM_SEP(DT_PATH(zephyr_user), gpios, DEVICE_GPIO, (,))
18+
DT_FOREACH_PROP_ELEM_SEP(DT_PATH(zephyr_user), gpio_ports, DEVICE_GPIO, (,))
1919
};
2020

2121
#define PROP_NGPIOS(n, p, i) DT_PROP(DT_PROP_BY_IDX(n, p, i), ngpios)
2222
constexpr uint32_t pins[] = {
23-
DT_FOREACH_PROP_ELEM_SEP(DT_PATH(zephyr_user), gpios, PROP_NGPIOS, (,))
23+
DT_FOREACH_PROP_ELEM_SEP(DT_PATH(zephyr_user), gpio_ports, PROP_NGPIOS, (,))
2424
};
2525

2626
constexpr inline const struct device *local_gpio_port_recursive(pin_size_t pin,
@@ -46,9 +46,14 @@ constexpr inline const struct device *local_gpio_port(pin_size_t gpin)
4646
return local_gpio_port_recursive(gpin, gpios, pins, ARRAY_SIZE(gpios));
4747
}
4848

49+
constexpr inline pin_size_t port_idx(pin_size_t gpin)
50+
{
51+
return port_index_recursive(local_gpio_port(gpin), gpios, 0, ARRAY_SIZE(gpios));
52+
}
53+
4954
constexpr inline pin_size_t local_gpio_pin(pin_size_t gpin)
5055
{
51-
return gpin - pins[port_index_recursive(local_gpio_port(gpin), gpios, 0, ARRAY_SIZE(gpios))];
56+
return port_idx(gpin) == pin_size_t(-1) ? pin_size_t(-1) : gpin - pins[port_idx(gpin)];
5257
}
5358

5459
constexpr inline pin_size_t global_gpio_pin_(size_t port_idx, pin_size_t lpin)

variants/arduino_mkrzero/arduino_mkrzero.overlay

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

57-
gpios = <&porta>, <&portb>;
57+
gpio-ports = <&porta>, <&portb>;
5858
serials = <&sercom5>;
5959
i2cs = <&sercom0>;
6060
};

variants/arduino_nano_33_ble/arduino_nano_33_ble.overlay

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
<&adc 4>,
6060
<&adc 1>;
6161

62-
gpios = <&gpio0>, <&gpio1>;
62+
gpio-ports = <&gpio0>, <&gpio1>;
6363
serials = <&uart0>;
6464
i2cs = <&arduino_nano_i2c>;
6565
};

variants/arduino_nano_33_ble_sense/arduino_nano_33_ble_sense.overlay

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
<&adc 4>,
6060
<&adc 1>;
6161

62-
gpios = <&gpio0>, <&gpio1>;
62+
gpio-ports = <&gpio0>, <&gpio1>;
6363
serials = <&uart0>;
6464
i2cs = <&arduino_nano_i2c>;
6565
};

variants/arduino_nano_33_iot/arduino_nano_33_iot.overlay

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
<&adc 6>,
6161
<&adc 7>;
6262

63-
gpios = <&porta>, <&portb>;
63+
gpio-ports = <&porta>, <&portb>;
6464
serials = <&sercom5>;
6565
i2cs = <&arduino_nano_i2c>;
6666
};

variants/beagleconnect_freedom/beagleconnect_freedom.overlay

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959

6060
builtin-led-gpios = <&gpio0 18 GPIO_ACTIVE_HIGH>; /* 2.4GHz TX/RX */
6161

62-
gpios = <&gpio0>;
62+
gpio-ports = <&gpio0>;
6363
serials = <&uart0 &uart1>;
6464
i2cs = <&i2c0>;
6565
spis = <&spi0>;

variants/cc3220sf_launchxl/cc3220sf_launchxl.overlay

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<&boosterpack_header 32 0>; /* GPIO_23 */
3232
builtin-led-gpios = <&boosterpack_header 10 0>; /* GREEN_LED */
3333

34-
gpios = <&gpioa0>, <&gpioa1>, <&gpioa2>, <&gpioa3>;
34+
gpio-ports = <&gpioa0>, <&gpioa1>, <&gpioa2>, <&gpioa3>;
3535
serials = <&boosterpack_serial>;
3636
i2cs = <&boosterpack_i2c>;
3737
};

variants/nrf52840dk_nrf52840/nrf52840dk_nrf52840.overlay

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
<&arduino_adc 4>,
5454
<&arduino_adc 5>;
5555

56-
gpios = <&gpio0>, <&gpio1>;
56+
gpio-ports = <&gpio0>, <&gpio1>;
5757
};
5858
};
5959

variants/nrf9160dk_nrf9160/nrf9160dk_nrf9160.overlay

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
<&arduino_adc 4>,
5959
<&arduino_adc 5>;
6060

61-
gpios = <&gpio0>;
61+
gpio-ports = <&gpio0>;
6262
};
6363
};
6464

0 commit comments

Comments
 (0)