[SX127x] Implemented generic actions

pull/779/head
jgromes 2023-06-21 22:03:07 +02:00
rodzic be7dc572a6
commit a6ba423c73
4 zmienionych plików z 40 dodań i 2 usunięć

Wyświetl plik

@ -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 ... "));

Wyświetl plik

@ -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 ... "));

Wyświetl plik

@ -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);

Wyświetl plik

@ -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.