Skip to content
This repository was archived by the owner on Apr 16, 2021. It is now read-only.

Commit 49ca91d

Browse files
authoredApr 27, 2020
Merge pull request #69 from f-jiang/master
enable CHANGE mode for attachInterrupt()
2 parents 548a18e + af5d3d4 commit 49ca91d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed
 

‎cores/arduino/Interrupts.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ void detachInterrupt(pin_size_t interruptNum) {
4949
void attachInterruptParam(PinName interruptNum, voidFuncPtrParam func, PinStatus mode, void* param) {
5050
detachInterrupt(interruptNum);
5151
mbed::InterruptIn* irq = new mbed::InterruptIn(interruptNum);
52-
if (mode == FALLING) {
52+
if (mode == CHANGE) {
53+
irq->rise(mbed::callback(func, param));
54+
irq->fall(mbed::callback(func, param));
55+
} else if (mode == FALLING) {
5356
irq->fall(mbed::callback(func, param));
5457
} else {
5558
irq->rise(mbed::callback(func, param));
@@ -66,7 +69,10 @@ void attachInterrupt(PinName interruptNum, voidFuncPtr func, PinStatus mode) {
6669
void attachInterruptParam(pin_size_t interruptNum, voidFuncPtrParam func, PinStatus mode, void* param) {
6770
detachInterrupt(interruptNum);
6871
mbed::InterruptIn* irq = new mbed::InterruptIn(digitalPinToPinName(interruptNum));
69-
if (mode == FALLING) {
72+
if (mode == CHANGE) {
73+
irq->rise(mbed::callback(func, param));
74+
irq->fall(mbed::callback(func, param));
75+
} else if (mode == FALLING) {
7076
irq->fall(mbed::callback(func, param));
7177
} else {
7278
irq->rise(mbed::callback(func, param));

0 commit comments

Comments
 (0)
This repository has been archived.