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

Fix MY_RF69_IRQ_NUM pin setting for ESP8266 #287

Merged
merged 1 commit into from Dec 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion libraries/MySensors/MyConfig.h
Expand Up @@ -347,7 +347,11 @@
#define MY_RF69_SPI_CS RF69_SPI_CS
#endif
#ifndef MY_RF69_IRQ_NUM
#define MY_RF69_IRQ_NUM RF69_IRQ_NUM
#if defined(ARDUINO_ARCH_ESP8266)
#define MY_RF69_IRQ_NUM MY_RF69_IRQ_PIN
#else
#define MY_RF69_IRQ_NUM RF69_IRQ_NUM
#endif
#endif

// Enable this for encryption of packets
Expand Down
20 changes: 15 additions & 5 deletions libraries/MySensors/drivers/RFM69/RFM69.cpp
Expand Up @@ -44,8 +44,8 @@ volatile byte RFM69::ACK_RECEIVED; /// Should be polled immediately after sendin
volatile int RFM69::RSSI; //most accurate RSSI during reception (closest to the reception)
RFM69* RFM69::selfPointer;

// Set time out to 50ms
#define TIME_OUT 50
// Set time out to 100ms
#define TIME_OUT 100


bool RFM69::initialize(byte freqBand, byte nodeID, byte networkID)
Expand Down Expand Up @@ -97,11 +97,19 @@ bool RFM69::initialize(byte freqBand, byte nodeID, byte networkID)


start_to = millis();
do writeReg(REG_SYNCVALUE1, 0xaa); while (readReg(REG_SYNCVALUE1) != 0xaa && millis()-start_to < TIME_OUT);
do {
writeReg(REG_SYNCVALUE1, 0xaa);
yield();
} while (readReg(REG_SYNCVALUE1) != 0xaa && millis()-start_to < TIME_OUT);

if (millis()-start_to >= TIME_OUT) return (false);

start_to = millis() ;
do writeReg(REG_SYNCVALUE1, 0x55); while (readReg(REG_SYNCVALUE1) != 0x55 && millis()-start_to < TIME_OUT);
do {
writeReg(REG_SYNCVALUE1, 0x55);
yield();
} while (readReg(REG_SYNCVALUE1) != 0x55 && millis()-start_to < TIME_OUT);

if (millis()-start_to >= TIME_OUT) return (false);

for (byte i = 0; CONFIG[i][0] != 255; i++)
Expand All @@ -116,7 +124,9 @@ bool RFM69::initialize(byte freqBand, byte nodeID, byte networkID)


start_to = millis() ;
while (((readReg(REG_IRQFLAGS1) & RF_IRQFLAGS1_MODEREADY) == 0x00) && millis()-start_to < TIME_OUT); // Wait for ModeReady
while (((readReg(REG_IRQFLAGS1) & RF_IRQFLAGS1_MODEREADY) == 0x00) && millis()-start_to < TIME_OUT) {
yield();
} // Wait for ModeReady
if (millis()-start_to >= TIME_OUT) return (false);

attachInterrupt(_interruptNum, RFM69::isr0, RISING);
Expand Down