[Si443x] Implemented generic IRQ actions

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

View file

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

View file

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

View file

@ -214,6 +214,22 @@ void Si443x::clearIrqAction() {
this->mod->hal->detachInterrupt(this->mod->hal->pinToInterrupt(this->mod->getIrq()));
}
void Si443x::setPacketReceivedAction(void (*func)(void)) {
this->setIrqAction(func);
}
void Si443x::clearPacketReceivedAction() {
this->clearIrqAction();
}
void Si443x::setPacketSentAction(void (*func)(void)) {
this->setIrqAction(func);
}
void Si443x::clearPacketSentAction() {
this->clearIrqAction();
}
int16_t Si443x::startTransmit(uint8_t* data, size_t len, uint8_t addr) {
// check packet length
if(len > RADIOLIB_SI443X_MAX_PACKET_LENGTH) {

View file

@ -656,6 +656,28 @@ class Si443x: public PhysicalLayer {
*/
void clearIrqAction();
/*!
\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. Will start transmitting arbitrary binary data up to 64 bytes long.
\param data Binary data that will be transmitted.