[nRF24] Added finishTransmit
This commit is contained in:
parent
733835e9ba
commit
598982c782
3 changed files with 24 additions and 9 deletions
|
@ -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
|
// wait a second before transmitting again
|
||||||
delay(1000);
|
delay(1000);
|
||||||
|
|
||||||
|
|
|
@ -93,23 +93,18 @@ int16_t nRF24::transmit(uint8_t* data, size_t len, uint8_t addr) {
|
||||||
|
|
||||||
// check maximum number of retransmits
|
// check maximum number of retransmits
|
||||||
if(getStatus(RADIOLIB_NRF24_MAX_RT)) {
|
if(getStatus(RADIOLIB_NRF24_MAX_RT)) {
|
||||||
standby();
|
finishTransmit();
|
||||||
clearIRQ();
|
|
||||||
return(RADIOLIB_ERR_ACK_NOT_RECEIVED);
|
return(RADIOLIB_ERR_ACK_NOT_RECEIVED);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check timeout: 15 retries * 4ms (max Tx time as per datasheet)
|
// check timeout: 15 retries * 4ms (max Tx time as per datasheet)
|
||||||
if(_mod->micros() - start >= 60000) {
|
if(_mod->micros() - start >= 60000) {
|
||||||
standby();
|
finishTransmit();
|
||||||
clearIRQ();
|
|
||||||
return(RADIOLIB_ERR_TX_TIMEOUT);
|
return(RADIOLIB_ERR_TX_TIMEOUT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear interrupts
|
return(finishTransmit());
|
||||||
clearIRQ();
|
|
||||||
|
|
||||||
return(state);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t nRF24::receive(uint8_t* data, size_t len) {
|
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);
|
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() {
|
int16_t nRF24::startReceive() {
|
||||||
// set mode to standby
|
// set mode to standby
|
||||||
int16_t state = standby();
|
int16_t state = standby();
|
||||||
|
|
|
@ -289,6 +289,13 @@ class nRF24: public PhysicalLayer {
|
||||||
*/
|
*/
|
||||||
int16_t startTransmit(uint8_t* data, size_t len, uint8_t addr) override;
|
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.
|
\brief Interrupt-driven receive method. IRQ will be activated when full packet is received.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue