Skip to content

Commit

Permalink
make the interrupt handling static because of other architectures whi…
Browse files Browse the repository at this point in the history
…ch didn't have the FunctionalInterrupt-implementation. This should be okay as we support only one Radio.
  • Loading branch information
greenflash1986 committed Aug 23, 2022
1 parent 4da6b60 commit 156cddd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
7 changes: 4 additions & 3 deletions lib/Hoymiles/src/HoymilesRadio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
#include "commands/RequestFrameCommand.h"
#include "crc.h"
#include <Every.h>
#include <FunctionalInterrupt.h>

volatile bool HoymilesRadio::_packetReceived = false;

void HoymilesRadio::init(_SPI* initialisedSpiBus)
{
Expand All @@ -29,7 +30,7 @@ void HoymilesRadio::init(_SPI* initialisedSpiBus)
Serial.println(F("Connection error!!"));
}

attachInterrupt(digitalPinToInterrupt(HOYMILES_PIN_IRQ), std::bind(&HoymilesRadio::handleIntr, this), FALLING);
attachInterrupt(digitalPinToInterrupt(HOYMILES_PIN_IRQ), handleIntr, FALLING);

openReadingPipe();
_radio->startListening();
Expand Down Expand Up @@ -175,7 +176,7 @@ void HoymilesRadio::openWritingPipe(serial_u serial)

void ARDUINO_ISR_ATTR HoymilesRadio::handleIntr()
{
_packetReceived = true;
HoymilesRadio::_packetReceived = true;
}

uint8_t HoymilesRadio::getRxNxtChannel()
Expand Down
10 changes: 7 additions & 3 deletions lib/Hoymiles/src/HoymilesRadio.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@

using namespace std;

#ifdef __AVR__
#define ARDUINO_ISR_ATTR
#endif

// number of fragments hold in buffer
#define FRAGMENT_BUFFER_SIZE 30

Expand Down Expand Up @@ -61,8 +65,10 @@ class HoymilesRadio {
return static_cast<T*>(_commandQueue.back().get());
}

volatile static bool _packetReceived;

private:
void ARDUINO_ISR_ATTR handleIntr();
static void ARDUINO_ISR_ATTR handleIntr();
static serial_u convertSerialToRadioId(serial_u serial);
uint8_t getRxNxtChannel();
uint8_t getTxNxtChannel();
Expand All @@ -80,8 +86,6 @@ class HoymilesRadio {
uint8_t _txChLst[5] = { 3, 23, 40, 61, 75 };
uint8_t _txChIdx;

volatile bool _packetReceived;

CircularBuffer<fragment_t, FRAGMENT_BUFFER_SIZE> _rxBuffer;
TimeoutHelper _rxTimeout;

Expand Down

0 comments on commit 156cddd

Please sign in to comment.