add function to set the IRQ explicitly

This commit is contained in:
Jonas Scharpf 2020-11-06 21:31:11 +01:00
parent 561995be16
commit 5237f7420f
1 changed files with 17 additions and 0 deletions

View File

@ -549,6 +549,23 @@ void RFM69::setCS(uint8_t newSPISlaveSelect) {
pinMode(_slaveSelectPin, OUTPUT); 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 //for debugging
#define REGISTER_DETAIL 0 #define REGISTER_DETAIL 0
#if REGISTER_DETAIL #if REGISTER_DETAIL