[SX127x] Implemented generic actions

This commit is contained in:
jgromes 2023-06-21 22:03:07 +02:00
parent be7dc572a6
commit a6ba423c73
4 changed files with 40 additions and 2 deletions

View file

@ -51,7 +51,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.setDio0Action(setFlag, RISING); radio.setPacketReceivedAction(setFlag);
// start listening for LoRa packets // start listening for LoRa packets
Serial.print(F("[SX1278] Starting to listen ... ")); Serial.print(F("[SX1278] Starting to listen ... "));

View file

@ -50,7 +50,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.setDio0Action(setFlag, RISING); radio.setPacketSentAction(setFlag);
// start transmitting the first packet // start transmitting the first packet
Serial.print(F("[SX1278] Sending first packet ... ")); Serial.print(F("[SX1278] Sending first packet ... "));

View file

@ -452,6 +452,22 @@ void SX127x::clearDio1Action() {
this->mod->hal->detachInterrupt(this->mod->hal->pinToInterrupt(this->mod->getGpio())); this->mod->hal->detachInterrupt(this->mod->hal->pinToInterrupt(this->mod->getGpio()));
} }
void SX127x::setPacketReceivedAction(void (*func)(void)) {
this->setDio0Action(func, RISING);
}
void SX127x::clearPacketReceivedAction() {
this->clearDio0Action();
}
void SX127x::setPacketSentAction(void (*func)(void)) {
this->setDio0Action(func, RISING);
}
void SX127x::clearPacketSentAction() {
this->clearDio0Action();
}
void SX127x::setFifoEmptyAction(void (*func)(void)) { void SX127x::setFifoEmptyAction(void (*func)(void)) {
// set DIO1 to the FIFO empty event (the register setting is done in startTransmit) // set DIO1 to the FIFO empty event (the register setting is done in startTransmit)
setDio1Action(func, this->mod->hal->GpioInterruptRising); setDio1Action(func, this->mod->hal->GpioInterruptRising);

View file

@ -716,6 +716,28 @@ class SX127x: 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 Set interrupt service routine function to call when FIFO is empty. \brief Set interrupt service routine function to call when FIFO is empty.
\param func Pointer to interrupt service routine. \param func Pointer to interrupt service routine.