Skip to content

Commit e55978e

Browse files
committed
Assign default pull when using attachInterrupt()
In mbed, every platform is allowed to set the default pull for a pin when unspecified. To overcome this, we assign the reverse pull (RISING -> PULLDOWN, FALLING -> PULLUP) if the pin is previosly unconfigured
1 parent c2513f3 commit e55978e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

cores/arduino/Interrupts.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ void attachInterruptParam(pin_size_t interruptNum, voidFuncPtrParam func, PinSta
6767
irq->rise(mbed::callback(func, param));
6868
}
6969
digitalPinToInterruptObj(interruptNum) = irq;
70+
// Give a default pullup for the pin, since calling InterruptIn with PinMode is impossible
71+
if (digitalPinToGpio(interruptNum) == NULL) {
72+
pinMode(interruptNum, mode == FALLING ? INPUT_PULLUP : INPUT_PULLDOWN);
73+
}
7074
}
7175

7276
void attachInterrupt(pin_size_t interruptNum, voidFuncPtr func, PinStatus mode) {

0 commit comments

Comments
 (0)