From 1e2f41c3f8143c9be0ae4aaa165cf98cb3052d84 Mon Sep 17 00:00:00 2001 From: TMRh20 Date: Wed, 19 Mar 2014 08:26:59 -0600 Subject: [PATCH] Inspired idea to change TX standby code Realised that data would be lost if dropping to standby or power down mode before the FIFO is empty. txStandby now returns a boolean value to indicate whether the transmission is complete. If there is data in the TX FIFO the radio will not drop out of TX mode. eg: while( !txStandBy() ){} --- RF24.cpp | 9 +++++++-- RF24.h | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/RF24.cpp b/RF24.cpp index 0ce3e65..5ef039d 100644 --- a/RF24.cpp +++ b/RF24.cpp @@ -545,8 +545,13 @@ void RF24::startWrite( const void* buf, uint8_t len ){ //TMRh20 } -void RF24::txStandBy(){ - ce(LOW); +bool RF24::txStandBy(){ + + if ( (read_register(FIFO_STATUS) & _BV(TX_EMPTY))){ + ce(LOW); + return 1; + } + return 0; } /****************************************************************************/ diff --git a/RF24.h b/RF24.h index 3190ecd..b666a76 100644 --- a/RF24.h +++ b/RF24.h @@ -222,7 +222,7 @@ protected: public: //TMRh20 - void txStandBy(); + bool txStandBy(); bool writeBlocking( const void* buf, uint8_t len ); void reUseTX(); bool writeFast( const void* buf, uint8_t len ); //Fills FIFO buffer, uses packet re-use function of the chip and returns 0 if packet failed and re-sent