Skip to content

Commit 23c6f26

Browse files
committed
fix gpio numbering for disabled controllers and align docs
1 parent 74d6469 commit 23c6f26

3 files changed

Lines changed: 12 additions & 4 deletions

File tree

cores/arduino/Arduino.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,11 @@
127127
UTIL_CAT(UTIL_CAT(ZARD_, UTIL_CAT(DT_STRING_UPPER_TOKEN_BY_IDX(node, compatible, 0), _DIGITAL_MAP_)), num)
128128

129129
#define ZARD_CHECK_GPIO_CTLR_OKAY(node_id) \
130-
COND_CODE_1(DT_NODE_HAS_PROP(node_id, gpio_controller), (node_id,), ())
130+
COND_CODE_1(DT_NODE_HAS_PROP(node_id, gpio_controller), \
131+
(COND_CODE_1(DT_NODE_HAS_STATUS_OKAY(node_id), \
132+
(node_id,), \
133+
())), \
134+
())
131135

132136
#define ZARD_ALL_OKAY_GPIO_CTLR DT_FOREACH_NODE(ZARD_CHECK_GPIO_CTLR_OKAY)
133137

cores/arduino/zephyrCommon.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ static constexpr struct gpio_dt_spec arduino_pins[] = {DT_FOREACH_PROP_ELEM_SEP(
2323

2424
#define GET_GPIO_NGPIOS(node_id) \
2525
COND_CODE_1(DT_NODE_HAS_PROP(node_id, gpio_controller), \
26-
(DT_PROP_OR(node_id, ngpios, 0),), ())
26+
(COND_CODE_1(DT_NODE_HAS_STATUS_OKAY(node_id), \
27+
(DT_PROP_OR(node_id, ngpios, 0),), \
28+
(0,))), \
29+
())
2730

2831
static constexpr const struct device *gpio_ports[] = {DT_FOREACH_NODE(GET_GPIO_DEVICES)};
2932
static constexpr uint32_t gpio_ngpios[] = {DT_FOREACH_NODE(GET_GPIO_NGPIOS)};

documentation/configuration-reference.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,8 @@ B. Board devicetree constructs (board-provided defaults)
215215
- **Precedence:**
216216
- Lower than `/zephyr,user/adc-pin-gpios` (association)
217217
- Lower than `/zephyr,user/io-channels` (provisioning)
218-
- **Notes:** `io-channel-map`: left = connector pin id, right = target ADC controller/channel; ADC still needs per-channel config under the ADC device node.
218+
- **Notes:**
219+
- `io-channel-map`: left = connector pin id, right = target ADC controller/channel.
219220
- ADC still requires per-channel configuration under the ADC device node,
220221
regardless of how the channel list is obtained.
221222
- **Example:**
@@ -353,7 +354,7 @@ B. Board devicetree constructs (board-provided defaults)
353354
For example, if you have gpio0, gpio1 which has 16 ports,
354355
then pin0 of gpio0 will be 0, pin1 will be 1, ...
355356
pin0 of gpio1 will be 16, pin1 will be 17, ... etc.
356-
- The numbers will be counted even if the gpio device is disabled.
357+
- Only GPIO controllers with `status = "okay"` are counted.
357358
- The order of GPIOs depends on their appearance in the device tree.
358359
359360
### Dx availability (`D0`, `D1`, …)

0 commit comments

Comments
 (0)