[nRF24] Added finishTransmit

This commit is contained in:
jgromes 2022-09-18 16:14:19 +02:00
parent 733835e9ba
commit 598982c782
3 changed files with 24 additions and 9 deletions

View file

@ -127,6 +127,11 @@ void loop() {
}
// clean up after transmission is finished
// this will ensure transmitter is disabled,
// RF switch is powered down etc.
radio.finishTransmit();
// wait a second before transmitting again
delay(1000);

View file

@ -93,23 +93,18 @@ int16_t nRF24::transmit(uint8_t* data, size_t len, uint8_t addr) {
// check maximum number of retransmits
if(getStatus(RADIOLIB_NRF24_MAX_RT)) {
standby();
clearIRQ();
finishTransmit();
return(RADIOLIB_ERR_ACK_NOT_RECEIVED);
}
// check timeout: 15 retries * 4ms (max Tx time as per datasheet)
if(_mod->micros() - start >= 60000) {
standby();
clearIRQ();
finishTransmit();
return(RADIOLIB_ERR_TX_TIMEOUT);
}
}
// clear interrupts
clearIRQ();
return(state);
return(finishTransmit());
}
int16_t nRF24::receive(uint8_t* data, size_t len) {
@ -199,6 +194,14 @@ int16_t nRF24::startTransmit(uint8_t* data, size_t len, uint8_t addr) {
return(state);
}
int16_t nRF24::finishTransmit() {
// clear interrupt flags
clearIRQ();
// set mode to standby to disable transmitter/RF switch
return(standby());
}
int16_t nRF24::startReceive() {
// set mode to standby
int16_t state = standby();

View file

@ -289,6 +289,13 @@ class nRF24: public PhysicalLayer {
*/
int16_t startTransmit(uint8_t* data, size_t len, uint8_t addr) override;
/*!
\brief Clean up after transmission is done.
\returns \ref status_codes
*/
int16_t finishTransmit() override;
/*!
\brief Interrupt-driven receive method. IRQ will be activated when full packet is received.