[SX128x] Added finishTransmit

This commit is contained in:
jgromes 2022-09-18 16:15:07 +02:00
parent 8a81a7c827
commit 0b5cd51828
3 changed files with 22 additions and 10 deletions

View file

@ -110,6 +110,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

@ -300,20 +300,12 @@ int16_t SX128x::transmit(uint8_t* data, size_t len, uint8_t addr) {
while(!_mod->digitalRead(_mod->getIrq())) {
_mod->yield();
if(_mod->micros() - start > timeout) {
clearIrqStatus();
standby();
finishTransmit();
return(RADIOLIB_ERR_TX_TIMEOUT);
}
}
// clear interrupt flags
state = clearIrqStatus();
RADIOLIB_ASSERT(state);
// set mode to standby to disable transmitter
state = standby();
return(state);
return(finishTransmit());
}
int16_t SX128x::receive(uint8_t* data, size_t len) {
@ -522,6 +514,14 @@ int16_t SX128x::startTransmit(uint8_t* data, size_t len, uint8_t addr) {
return(state);
}
int16_t SX128x::finishTransmit() {
// clear interrupt flags
clearIrqStatus();
// set mode to standby to disable transmitter/RF switch
return(standby());
}
int16_t SX128x::startReceive(uint16_t timeout) {
// check active modem
if(getPacketType() == RADIOLIB_SX128X_PACKET_TYPE_RANGING) {

View file

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