Skip to content

Commit 7fb5ec2

Browse files
committed
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 3ac4639 commit 7fb5ec2

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
@@ -104,7 +104,7 @@ void setInterruptHandler(pin_size_t pinNumber, voidFuncPtr func) {
104104
struct gpio_port_callback *pcb = find_gpio_port_callback(arduino_pins[pinNumber].port);
105105

106106
if (pcb) {
107-
pcb->handlers[BIT(arduino_pins[pinNumber].pin)].handler = func;
107+
pcb->handlers[arduino_pins[pinNumber].pin].handler = func;
108108
}
109109
}
110110

@@ -113,8 +113,8 @@ void handleGpioCallback(const struct device *port, struct gpio_callback *cb, uin
113113
struct gpio_port_callback *pcb = (struct gpio_port_callback *)cb;
114114

115115
for (uint32_t i = 0; i < max_ngpios; i++) {
116-
if (pins & BIT(i) && pcb->handlers[BIT(i)].enabled) {
117-
pcb->handlers[BIT(i)].handler();
116+
if (pins & BIT(i) && pcb->handlers[i].enabled) {
117+
pcb->handlers[i].handler();
118118
}
119119
}
120120
}
@@ -531,15 +531,15 @@ void enableInterrupt(pin_size_t pinNumber) {
531531
struct gpio_port_callback *pcb = find_gpio_port_callback(arduino_pins[pinNumber].port);
532532

533533
if (pcb) {
534-
pcb->handlers[BIT(arduino_pins[pinNumber].pin)].enabled = true;
534+
pcb->handlers[arduino_pins[pinNumber].pin].enabled = true;
535535
}
536536
}
537537

538538
void disableInterrupt(pin_size_t pinNumber) {
539539
struct gpio_port_callback *pcb = find_gpio_port_callback(arduino_pins[pinNumber].port);
540540

541541
if (pcb) {
542-
pcb->handlers[BIT(arduino_pins[pinNumber].pin)].enabled = false;
542+
pcb->handlers[arduino_pins[pinNumber].pin].enabled = false;
543543
}
544544
}
545545

0 commit comments

Comments
 (0)