[Si443x] Implemented generic IRQ actions

pull/779/head
jgromes 2023-06-21 22:17:48 +02:00
rodzic df126c92f9
commit 46e1af764e
4 zmienionych plików z 40 dodań i 2 usunięć

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

@ -214,6 +214,22 @@ void Si443x::clearIrqAction() {
this->mod->hal->detachInterrupt(this->mod->hal->pinToInterrupt(this->mod->getIrq())); 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) { int16_t Si443x::startTransmit(uint8_t* data, size_t len, uint8_t addr) {
// check packet length // check packet length
if(len > RADIOLIB_SI443X_MAX_PACKET_LENGTH) { if(len > RADIOLIB_SI443X_MAX_PACKET_LENGTH) {

Wyświetl plik

@ -656,6 +656,28 @@ class Si443x: public PhysicalLayer {
*/ */
void clearIrqAction(); 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. \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. \param data Binary data that will be transmitted.