Skip to content

Commit

Permalink
Merge pull request #106 from sfewings/Support_Moteino_Mega___AVR_ATme…
Browse files Browse the repository at this point in the history
…ga1284P

Add support for Moteino Mega ___AVR_ATmega1284P SPI and interrupt pin
  • Loading branch information
jcw authored Feb 24, 2020
2 parents 59fa1c9 + 0bffe31 commit 635113e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
17 changes: 17 additions & 0 deletions RF69_avr.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,23 @@ static void spiConfigPins () {
DDRB |= _BV(SPI_SS) | _BV(SPI_MOSI) | _BV(SPI_SCK);
}

#elif defined(__AVR_ATmega1284P__) //Moteino mega

#define SS_DDR DDRB
#define SS_PORT PORTB
#define SS_BIT 4 // PB4 D4

#define SPI_SS 4 // PB4 D4
#define SPI_MOSI 5 // PB5 D5
#define SPI_MISO 6 // PB6 D6
#define SPI_SCK 7 // PB7 D7

static void spiConfigPins () {
SS_PORT |= _BV(SS_BIT);
SS_DDR |= _BV(SS_BIT);
PORTB |= _BV(SPI_SS);
DDRB |= _BV(SPI_SS) | _BV(SPI_MOSI) | _BV(SPI_SCK);
}
#else // ATmega168, ATmega328, etc.

// #define RFM_IRQ 2
Expand Down
4 changes: 4 additions & 0 deletions RF69_compat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ uint8_t rf69_initialize (uint8_t id, uint8_t band, uint8_t group, uint16_t off)
RF69::node = id & RF12_HDR_MASK;
delay(20); // needed to make RFM69 work properly on power-up
if (RF69::node != 0)
#if defined(__AVR_ATmega1284P__) //Moteino mega
attachInterrupt(2, RF69::interrupt_compat, RISING);
#else
attachInterrupt(0, RF69::interrupt_compat, RISING);
#endif
else
detachInterrupt(0);
RF69::configure_compat();
Expand Down

0 comments on commit 635113e

Please sign in to comment.