[nRF24] Implemented generic actions
This commit is contained in:
parent
8567c77641
commit
291251ea72
4 changed files with 49 additions and 2 deletions
|
@ -61,7 +61,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
|
// start listening
|
||||||
Serial.print(F("[nRF24] Starting to listen ... "));
|
Serial.print(F("[nRF24] Starting to listen ... "));
|
||||||
|
|
|
@ -63,7 +63,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("[nRF24] Sending first packet ... "));
|
Serial.print(F("[nRF24] Sending first packet ... "));
|
||||||
|
|
|
@ -159,6 +159,26 @@ void nRF24::setIrqAction(void (*func)(void)) {
|
||||||
this->mod->hal->attachInterrupt(this->mod->hal->pinToInterrupt(this->mod->getIrq()), func, this->mod->hal->GpioInterruptFalling);
|
this->mod->hal->attachInterrupt(this->mod->hal->pinToInterrupt(this->mod->getIrq()), func, this->mod->hal->GpioInterruptFalling);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void nRF24::clearIrqAction() {
|
||||||
|
this->mod->hal->detachInterrupt(this->mod->hal->pinToInterrupt(this->mod->getIrq()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void nRF24::setPacketReceivedAction(void (*func)(void)) {
|
||||||
|
this->setIrqAction(func);
|
||||||
|
}
|
||||||
|
|
||||||
|
void nRF24::clearPacketReceivedAction() {
|
||||||
|
this->clearIrqAction();
|
||||||
|
}
|
||||||
|
|
||||||
|
void nRF24::setPacketSentAction(void (*func)(void)) {
|
||||||
|
this->setIrqAction(func);
|
||||||
|
}
|
||||||
|
|
||||||
|
void nRF24::clearPacketSentAction() {
|
||||||
|
this->clearIrqAction();
|
||||||
|
}
|
||||||
|
|
||||||
int16_t nRF24::startTransmit(uint8_t* data, size_t len, uint8_t addr) {
|
int16_t nRF24::startTransmit(uint8_t* data, size_t len, uint8_t addr) {
|
||||||
// suppress unused variable warning
|
// suppress unused variable warning
|
||||||
(void)addr;
|
(void)addr;
|
||||||
|
|
|
@ -272,6 +272,33 @@ class nRF24: public PhysicalLayer {
|
||||||
*/
|
*/
|
||||||
void setIrqAction(void (*func)(void));
|
void setIrqAction(void (*func)(void));
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Clears interrupt service routine .
|
||||||
|
*/
|
||||||
|
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. IRQ will be activated when full packet is transmitted.
|
\brief Interrupt-driven binary transmit method. IRQ will be activated when full packet is transmitted.
|
||||||
Overloads for string-based transmissions are implemented in PhysicalLayer.
|
Overloads for string-based transmissions are implemented in PhysicalLayer.
|
||||||
|
|
Loading…
Add table
Reference in a new issue