From d27e4cb4ec0e00228eaa66732ab35fe0a4aa9d6d Mon Sep 17 00:00:00 2001 From: Federico Briata Date: Fri, 15 Nov 2024 19:31:13 +0100 Subject: [PATCH] RF12.cpp - make external interrupt configurable --- RF12.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/RF12.cpp b/RF12.cpp index 4996a827..6c3bb2a2 100644 --- a/RF12.cpp +++ b/RF12.cpp @@ -53,6 +53,7 @@ #if defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__) #define RFM_IRQ 2 +#define RFM_INT INT0 #define SS_DDR DDRB #define SS_PORT PORTB #define SS_BIT 0 @@ -65,6 +66,7 @@ #elif defined(__AVR_ATmega644P__) #define RFM_IRQ 10 +#define RFM_INT INT0 #define SS_DDR DDRB #define SS_PORT PORTB #define SS_BIT 4 @@ -77,6 +79,7 @@ #elif defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny44__) #define RFM_IRQ 2 +#define RFM_INT INT0 #define SS_DDR DDRB #define SS_PORT PORTB #define SS_BIT 1 @@ -86,12 +89,17 @@ #define SPI_MOSI 5 // PA5, pin 8 #define SPI_SCK 6 // PA4, pin 9 -#elif defined(__AVR_ATmega32U4__) //Arduino Leonardo, YUN +#elif defined(__AVR_ATmega32U4__) //Arduino Leonardo -#define RFM_IRQ 2 // PD1, pin 19, INT1, Digital2 +#define RFM_IRQ 0 // PD0, pin 19, INT0, Digital3 +#define RFM_INT INT0 +//#define RFM_IRQ 2 // PD1, pin 19, INT1, Digital2 +//#define RFM_INT INT1 +//#define RFM_IRQ 7 // PE6, INT4, Digital7 - Adafruit Feather M0 RFM96 +//#define RFM_INT INT4 #define SS_DDR DDRB #define SS_PORT PORTB -#define SS_BIT 6 // Dig10, PB6 +#define SS_BIT 6 // PB6, pin 30, Digital10 #define SPI_SS 10 // PB6, pin 30, Digital10 #define SPI_MISO 14 // PB3, pin 11, Digital14 @@ -102,6 +110,7 @@ // ATmega168, ATmega328, etc. #define RFM_IRQ 2 // 2=JeeNode, 18=JeeNode pin change +#define RFM_INT INT0 //#define RFM_IRQ 1 // PCINT1=JeeNode Block pin change #define SS_DDR DDRB #define SS_PORT PORTB @@ -294,7 +303,7 @@ uint16_t rf12_control(uint16_t cmd) { bitClear(PCICR, PCIE2); #endif #else - bitClear(EIMSK, INT1); + bitClear(EIMSK, RFM_INT); #endif uint16_t r = rf12_xferSlow(cmd); #if PINCHG_IRQ @@ -306,13 +315,13 @@ uint16_t rf12_control(uint16_t cmd) { bitSet(PCICR, PCIE2); #endif #else - bitSet(EIMSK, INT1); + bitSet(EIMSK, RFM_INT); #endif #else // ATtiny - bitClear(GIMSK, INT0); + bitClear(GIMSK, RFM_INT); uint16_t r = rf12_xferSlow(cmd); - bitSet(GIMSK, INT0); + bitSet(GIMSK, RFM_INT); #endif return r; }