Skip to content

Commit a6a1406

Browse files
committed
accum
1 parent 9790283 commit a6a1406

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

cores/arduino/zephyrCommon.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ constexpr uint32_t pins[] = {
2525

2626
constexpr inline const struct device *local_gpio_port_recursive(pin_size_t pin,
2727
const struct device *const *ctrl,
28-
const uint32_t *end, size_t n)
28+
const uint32_t accum, const uint32_t *end, size_t n)
2929
{
3030
return (n == 0) ? nullptr
31-
: (pin < end[0]) ? ctrl[0]
32-
: local_gpio_port_recursive(pin, ctrl + 1, end + 1, n - 1);
31+
: (pin < accum + end[0]) ? ctrl[0]
32+
: local_gpio_port_recursive(pin, ctrl + 1, accum + end[0], end + 1, n - 1);
3333
}
3434

3535
constexpr inline size_t port_index_recursive(const struct device *target,
@@ -43,7 +43,7 @@ constexpr inline size_t port_index_recursive(const struct device *target,
4343

4444
constexpr inline const struct device *local_gpio_port(pin_size_t gpin)
4545
{
46-
return local_gpio_port_recursive(gpin, gpios, pins, ARRAY_SIZE(gpios));
46+
return local_gpio_port_recursive(gpin, gpios, 0, pins, ARRAY_SIZE(gpios));
4747
}
4848

4949
constexpr inline pin_size_t port_idx(pin_size_t gpin)

0 commit comments

Comments
 (0)