Skip to content

Commit 607c419

Browse files
soburiDhruvaG2000
authored andcommitted
zephyrCommon: Fix buggy irq handler acquisition
Fix 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]> [DG: tweaked commit message] Signed-off-by: Dhruva Gole <[email protected]>
1 parent 25d463a commit 607c419

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
}
@@ -453,15 +453,15 @@ void enableInterrupt(pin_size_t pinNumber) {
453453
struct gpio_port_callback *pcb = find_gpio_port_callback(arduino_pins[pinNumber].port);
454454

455455
if (pcb) {
456-
pcb->handlers[BIT(arduino_pins[pinNumber].pin)].enabled = true;
456+
pcb->handlers[arduino_pins[pinNumber].pin].enabled = true;
457457
}
458458
}
459459

460460
void disableInterrupt(pin_size_t pinNumber) {
461461
struct gpio_port_callback *pcb = find_gpio_port_callback(arduino_pins[pinNumber].port);
462462

463463
if (pcb) {
464-
pcb->handlers[BIT(arduino_pins[pinNumber].pin)].enabled = false;
464+
pcb->handlers[arduino_pins[pinNumber].pin].enabled = false;
465465
}
466466
}
467467

0 commit comments

Comments
 (0)