[SX126x] Implemented generic IRQ actions (#773)

This commit is contained in:
jgromes 2023-06-21 22:21:55 +02:00
parent 46e1af764e
commit 787ebde43e
4 changed files with 40 additions and 2 deletions

View file

@ -54,7 +54,7 @@ void setup() {
// set the function that will be called // set the function that will be called
// when new packet is received // when new packet is received
radio.setDio1Action(setFlag); radio.setPacketReceivedAction(setFlag);
// start listening for LoRa packets // start listening for LoRa packets
Serial.print(F("[SX1262] Starting to listen ... ")); Serial.print(F("[SX1262] Starting to listen ... "));

View file

@ -53,7 +53,7 @@ void setup() {
// set the function that will be called // set the function that will be called
// when packet transmission is finished // when packet transmission is finished
radio.setDio1Action(setFlag); radio.setPacketSentAction(setFlag);
// start transmitting the first packet // start transmitting the first packet
Serial.print(F("[SX1262] Sending first packet ... ")); Serial.print(F("[SX1262] Sending first packet ... "));

View file

@ -470,6 +470,22 @@ void SX126x::clearDio1Action() {
this->mod->hal->detachInterrupt(this->mod->hal->pinToInterrupt(this->mod->getIrq())); this->mod->hal->detachInterrupt(this->mod->hal->pinToInterrupt(this->mod->getIrq()));
} }
void SX126x::setPacketReceivedAction(void (*func)(void)) {
this->setDio1Action(func);
}
void SX126x::clearPacketReceivedAction() {
this->clearDio1Action();
}
void SX126x::setPacketSentAction(void (*func)(void)) {
this->setDio1Action(func);
}
void SX126x::clearPacketSentAction() {
this->clearDio1Action();
}
int16_t SX126x::startTransmit(uint8_t* data, size_t len, uint8_t addr) { int16_t SX126x::startTransmit(uint8_t* data, size_t len, uint8_t addr) {
// suppress unused variable warning // suppress unused variable warning
(void)addr; (void)addr;

View file

@ -573,6 +573,28 @@ class SX126x: public PhysicalLayer {
*/ */
void clearDio1Action(); void clearDio1Action();
/*!
\brief Sets interrupt service routine to call when a packet is received.
\param func ISR to call.
*/
void setPacketReceivedAction(void (*func)(void));
/*!
\brief Clears interrupt service routine to call when a packet is received.
*/
void clearPacketReceivedAction();
/*!
\brief Sets interrupt service routine to call when a packet is sent.
\param func ISR to call.
*/
void setPacketSentAction(void (*func)(void));
/*!
\brief Clears interrupt service routine to call when a packet is sent.
*/
void clearPacketSentAction();
/*! /*!
\brief Interrupt-driven binary transmit method. \brief Interrupt-driven binary transmit method.
Overloads for string-based transmissions are implemented in PhysicalLayer. Overloads for string-based transmissions are implemented in PhysicalLayer.