Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use IRQ as pin #107

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
25 changes: 17 additions & 8 deletions RF12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -88,10 +91,15 @@

#elif defined(__AVR_ATmega32U4__) //Arduino Leonardo

#define RFM_IRQ 0 // PD0, INT0, Digital3
#define RFM_IRQ 0 // PD0, pin 18, 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
Expand All @@ -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
Expand Down Expand Up @@ -294,7 +303,7 @@ uint16_t rf12_control(uint16_t cmd) {
bitClear(PCICR, PCIE2);
#endif
#else
bitClear(EIMSK, INT0);
bitClear(EIMSK, RFM_INT);
#endif
uint16_t r = rf12_xferSlow(cmd);
#if PINCHG_IRQ
Expand All @@ -306,13 +315,13 @@ uint16_t rf12_control(uint16_t cmd) {
bitSet(PCICR, PCIE2);
#endif
#else
bitSet(EIMSK, INT0);
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;
}
Expand Down Expand Up @@ -686,9 +695,9 @@ uint8_t rf12_initialize (uint8_t id, uint8_t band, uint8_t g, uint16_t f) {
#endif
#else
if ((nodeid & NODE_ID) != 0)
attachInterrupt(0, rf12_interrupt, LOW);
attachInterrupt(digitalPinToInterrupt(RFM_IRQ), rf12_interrupt, LOW);
else
detachInterrupt(0);
detachInterrupt(digitalPinToInterrupt(RFM_IRQ));
#endif

return nodeid;
Expand Down