[CC1101] Implemented generic actions

This commit is contained in:
jgromes 2023-06-21 22:07:24 +02:00
parent a6ba423c73
commit 8567c77641
4 changed files with 40 additions and 5 deletions

View file

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

View file

@ -48,10 +48,7 @@ void setup() {
// set the function that will be called
// when packet transmission is finished
// NOTE: Unlike other modules (such as SX127x),
// different GDOx pins are used for
// transmit and receive interrupts!
radio.setGdo2Action(setFlag, FALLING);
radio.setPacketSentAction(setFlag);
// start transmitting the first packet
Serial.print(F("[CC1101] Sending first packet ... "));

View file

@ -239,6 +239,22 @@ void CC1101::clearGdo0Action() {
this->mod->hal->detachInterrupt(this->mod->hal->pinToInterrupt(this->mod->getIrq()));
}
void CC1101::setPacketReceivedAction(void (*func)(void)) {
this->setGdo0Action(func, RISING);
}
void CC1101::clearPacketReceivedAction() {
this->clearGdo0Action();
}
void CC1101::setPacketSentAction(void (*func)(void)) {
this->setGdo2Action(func, FALLING);
}
void CC1101::clearPacketSentAction() {
this->clearGdo2Action();
}
void CC1101::setGdo2Action(void (*func)(void), uint32_t dir) {
if(this->mod->getGpio() == RADIOLIB_NC) {
return;

View file

@ -659,6 +659,28 @@ class CC1101: public PhysicalLayer {
*/
void clearGdo2Action();
/*!
\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.
Overloads for string-based transmissions are implemented in PhysicalLayer.