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

Set default pinMode for CHANGE #84

Merged
merged 2 commits into from
Jun 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions cores/arduino/Interrupts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,16 @@ void attachInterruptParam(pin_size_t interruptNum, voidFuncPtrParam func, PinSta
digitalPinToInterruptObj(interruptNum) = irq;
// Give a default pullup for the pin, since calling InterruptIn with PinMode is impossible
if (digitalPinToGpio(interruptNum) == NULL) {
pinMode(interruptNum, mode == FALLING ? INPUT_PULLUP : INPUT_PULLDOWN);
if (mode == FALLING) {
pinMode(interruptNum, INPUT_PULLUP);
} else if (mode == RISING) {
pinMode(interruptNum, INPUT_PULLDOWN);
} else {
pinMode(interruptNum, INPUT);
}
}
}

void attachInterrupt(pin_size_t interruptNum, voidFuncPtr func, PinStatus mode) {
attachInterruptParam(interruptNum, (voidFuncPtrParam)func, mode, NULL);
}
}