Added ISR callback
This commit is contained in:
parent
b65f6c4eb1
commit
ada0e6abcd
13
RFM69.cpp
13
RFM69.cpp
|
|
@ -37,8 +37,10 @@ uint8_t RFM69::ACK_REQUESTED;
|
|||
uint8_t RFM69::ACK_RECEIVED; // should be polled immediately after sending a packet with ACK request
|
||||
int16_t RFM69::RSSI; // most accurate RSSI during reception (closest to the reception)
|
||||
volatile bool RFM69::_haveData;
|
||||
RFM69 *RFM69::_instance = nullptr;
|
||||
|
||||
RFM69::RFM69(uint8_t slaveSelectPin, uint8_t interruptPin, bool isRFM69HW_HCW, SPIClass *spi) {
|
||||
_instance = this;
|
||||
_slaveSelectPin = slaveSelectPin;
|
||||
_interruptPin = interruptPin;
|
||||
_mode = RF69_MODE_STANDBY;
|
||||
|
|
@ -152,6 +154,11 @@ bool RFM69::initialize(uint8_t freqBand, uint16_t nodeID, uint8_t networkID)
|
|||
return true;
|
||||
}
|
||||
|
||||
void RFM69::setIsrCallback(void (*callback)())
|
||||
{
|
||||
_isrCallback = callback;
|
||||
}
|
||||
|
||||
// return the frequency (in Hz)
|
||||
uint32_t RFM69::getFrequency()
|
||||
{
|
||||
|
|
@ -446,7 +453,11 @@ void RFM69::interruptHandler() {
|
|||
}
|
||||
|
||||
// internal function
|
||||
ISR_PREFIX void RFM69::isr0() { _haveData = true; }
|
||||
ISR_PREFIX void RFM69::isr0() {
|
||||
_haveData = true;
|
||||
if (_instance->_isrCallback)
|
||||
_instance->_isrCallback();
|
||||
}
|
||||
|
||||
// internal function
|
||||
void RFM69::receiveBegin() {
|
||||
|
|
|
|||
3
RFM69.h
3
RFM69.h
|
|
@ -201,6 +201,7 @@ class RFM69 {
|
|||
RFM69(uint8_t slaveSelectPin=RF69_SPI_CS, uint8_t interruptPin=RF69_IRQ_PIN, bool isRFM69HW_HCW=false, SPIClass *spi=nullptr);
|
||||
|
||||
bool initialize(uint8_t freqBand, uint16_t ID, uint8_t networkID=1);
|
||||
void setIsrCallback(void (*callback)());
|
||||
void setAddress(uint16_t addr);
|
||||
void setNetwork(uint8_t networkID);
|
||||
virtual bool canSend();
|
||||
|
|
@ -247,6 +248,8 @@ class RFM69 {
|
|||
void interruptHandler();
|
||||
virtual void interruptHook(uint8_t CTLbyte __attribute__((unused))) {};
|
||||
static volatile bool _haveData;
|
||||
static RFM69 *_instance;
|
||||
void (*_isrCallback)() = nullptr;
|
||||
virtual void sendFrame(uint16_t toAddress, const void* buffer, uint8_t size, bool requestACK=false, bool sendACK=false);
|
||||
|
||||
// for ListenMode sleep/timer
|
||||
|
|
|
|||
Loading…
Reference in New Issue