Skip to content

Commit a2dd31a

Browse files
committed
Changed FunctionalInterrupt example
1 parent 4f2b58f commit a2dd31a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

libraries/ESP32/examples/GPIO/FunctionalInterrupt/FunctionalInterrupt.ino

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ struct Button {
77
uint8_t PIN;
88
volatile uint32_t numberKeyPresses;
99
volatile int pressed;
10-
void (*isr)(struct Button*);
1110
};
1211

13-
void isr(struct Button* button) {
12+
void isr(void* param) {
13+
struct Button *button = (struct Button*) param;
1414
button->numberKeyPresses += 1;
1515
button->pressed = 1;
1616
}
@@ -22,15 +22,15 @@ void checkPressed(struct Button* button) {
2222
}
2323
}
2424

25-
struct Button button1 = {BUTTON1, 0, 0, isr};
26-
struct Button button2 = {BUTTON2, 0, 0, isr};
25+
struct Button button1 = {BUTTON1, 0, 0};
26+
struct Button button2 = {BUTTON2, 0, 0};
2727

2828
void setup() {
2929
Serial.begin(115200);
3030
pinMode(button1.PIN, INPUT_PULLUP);
3131
pinMode(button2.PIN, INPUT_PULLUP);
32-
attachInterrupt(button1.PIN, (void ()())isr, FALLING);
33-
attachInterrupt(button2.PIN, (void ()())isr, FALLING);
32+
attachInterruptArg(button1.PIN, isr, (void*)&button1, FALLING);
33+
attachInterruptArg(button2.PIN, isr, (void*)&button2, FALLING);
3434
}
3535

3636
void loop() {

0 commit comments

Comments
 (0)