From 5237f7420f55ae38d5aa11e9604f48575bc85248 Mon Sep 17 00:00:00 2001 From: Jonas Scharpf Date: Fri, 6 Nov 2020 21:31:11 +0100 Subject: [PATCH] add function to set the IRQ explicitly --- RFM69.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/RFM69.cpp b/RFM69.cpp index 4fd01e4..a77fe38 100644 --- a/RFM69.cpp +++ b/RFM69.cpp @@ -549,6 +549,23 @@ void RFM69::setCS(uint8_t newSPISlaveSelect) { pinMode(_slaveSelectPin, OUTPUT); } +// set the IRQ pin +bool setIrq(uint8_t newIRQPin) { + uint8_t _newInterruptNum = digitalPinToInterrupt(newIRQPin); + if (_newInterruptNum == NOT_AN_INTERRUPT) return false; +#ifdef RF69_ATTACHINTERRUPT_TAKES_PIN_NUMBER + _newInterruptNum = newIRQPin; +#endif + + // disconnect from existing IRQ pin + detachInterrupt( _interruptNum ); + + _interruptNum = _newInterruptNum; + attachInterrupt(_interruptNum, RFM69::isr0, RISING); + + return true; +} + //for debugging #define REGISTER_DETAIL 0 #if REGISTER_DETAIL