[SX127x] Implemented generic actions
This commit is contained in:
parent
be7dc572a6
commit
a6ba423c73
4 changed files with 40 additions and 2 deletions
|
@ -51,7 +51,7 @@ void setup() {
|
|||
|
||||
// set the function that will be called
|
||||
// when new packet is received
|
||||
radio.setDio0Action(setFlag, RISING);
|
||||
radio.setPacketReceivedAction(setFlag);
|
||||
|
||||
// start listening for LoRa packets
|
||||
Serial.print(F("[SX1278] Starting to listen ... "));
|
||||
|
|
|
@ -50,7 +50,7 @@ void setup() {
|
|||
|
||||
// set the function that will be called
|
||||
// when packet transmission is finished
|
||||
radio.setDio0Action(setFlag, RISING);
|
||||
radio.setPacketSentAction(setFlag);
|
||||
|
||||
// start transmitting the first packet
|
||||
Serial.print(F("[SX1278] Sending first packet ... "));
|
||||
|
|
|
@ -452,6 +452,22 @@ void SX127x::clearDio1Action() {
|
|||
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)) {
|
||||
// set DIO1 to the FIFO empty event (the register setting is done in startTransmit)
|
||||
setDio1Action(func, this->mod->hal->GpioInterruptRising);
|
||||
|
|
|
@ -716,6 +716,28 @@ class SX127x: public PhysicalLayer {
|
|||
*/
|
||||
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.
|
||||
\param func Pointer to interrupt service routine.
|
||||
|
|
Loading…
Add table
Reference in a new issue