[Si443x] Added finishTransmit

This commit is contained in:
jgromes 2022-09-18 16:14:04 +02:00
parent 0d72dd2ac3
commit 733835e9ba
3 changed files with 22 additions and 9 deletions

View file

@ -108,6 +108,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);

View file

@ -87,19 +87,12 @@ int16_t Si443x::transmit(uint8_t* data, size_t len, uint8_t addr) {
while(_mod->digitalRead(_mod->getIrq())) { while(_mod->digitalRead(_mod->getIrq())) {
_mod->yield(); _mod->yield();
if(_mod->micros() - start > timeout) { if(_mod->micros() - start > timeout) {
standby(); finishTransmit();
clearIRQFlags();
return(RADIOLIB_ERR_TX_TIMEOUT); return(RADIOLIB_ERR_TX_TIMEOUT);
} }
} }
// clear interrupt flags return(finishTransmit());
clearIRQFlags();
// set mode to standby
standby();
return(state);
} }
int16_t Si443x::receive(uint8_t* data, size_t len) { int16_t Si443x::receive(uint8_t* data, size_t len) {
@ -258,6 +251,14 @@ int16_t Si443x::startTransmit(uint8_t* data, size_t len, uint8_t addr) {
return(state); return(state);
} }
int16_t Si443x::finishTransmit() {
// clear interrupt flags
clearIRQFlags();
// set mode to standby to disable transmitter/RF switch
return(standby());
}
int16_t Si443x::startReceive() { int16_t Si443x::startReceive() {
// set mode to standby // set mode to standby
int16_t state = standby(); int16_t state = standby();

View file

@ -683,6 +683,13 @@ class Si443x: public PhysicalLayer {
*/ */
int16_t startTransmit(uint8_t* data, size_t len, uint8_t addr = 0) override; 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. IRQ will be activated when full valid packet is received. \brief Interrupt-driven receive method. IRQ will be activated when full valid packet is received.