Skip to content

Commit 8fec86c

Browse files
soburipillo79
authored andcommitted
zephyrCommon: Fixed a bug in the interrupt handler acquisition
Fixed an issue where the reference location for the interrupt handler was a bit mask instead of an index value. Signed-off-by: TOKITA Hiroshi <[email protected]>
1 parent c0718c2 commit 8fec86c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

cores/arduino/zephyrCommon.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ void setInterruptHandler(pin_size_t pinNumber, voidFuncPtr func)
113113
struct gpio_port_callback *pcb = find_gpio_port_callback(arduino_pins[pinNumber].port);
114114

115115
if (pcb) {
116-
pcb->handlers[BIT(arduino_pins[pinNumber].pin)].handler = func;
116+
pcb->handlers[arduino_pins[pinNumber].pin].handler = func;
117117
}
118118
}
119119

@@ -123,8 +123,8 @@ void handleGpioCallback(const struct device *port, struct gpio_callback *cb, uin
123123
struct gpio_port_callback *pcb = (struct gpio_port_callback *)cb;
124124

125125
for (uint32_t i = 0; i < max_ngpios; i++) {
126-
if (pins & BIT(i) && pcb->handlers[BIT(i)].enabled) {
127-
pcb->handlers[BIT(i)].handler();
126+
if (pins & BIT(i) && pcb->handlers[i].enabled) {
127+
pcb->handlers[i].handler();
128128
}
129129
}
130130
}
@@ -538,15 +538,15 @@ void enableInterrupt(pin_size_t pinNumber) {
538538
struct gpio_port_callback *pcb = find_gpio_port_callback(arduino_pins[pinNumber].port);
539539

540540
if (pcb) {
541-
pcb->handlers[BIT(arduino_pins[pinNumber].pin)].enabled = true;
541+
pcb->handlers[arduino_pins[pinNumber].pin].enabled = true;
542542
}
543543
}
544544

545545
void disableInterrupt(pin_size_t pinNumber) {
546546
struct gpio_port_callback *pcb = find_gpio_port_callback(arduino_pins[pinNumber].port);
547547

548548
if (pcb) {
549-
pcb->handlers[BIT(arduino_pins[pinNumber].pin)].enabled = false;
549+
pcb->handlers[arduino_pins[pinNumber].pin].enabled = false;
550550
}
551551
}
552552

0 commit comments

Comments
 (0)