From b000a87aa1f9582a887569591fbd8edbfacf1f8f Mon Sep 17 00:00:00 2001 From: maniacbug Date: Fri, 8 Jul 2011 22:25:44 -0700 Subject: [PATCH] Optimization of whatHappened, suggested by Mike Denzien --- RF24.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/RF24.cpp b/RF24.cpp index 994d0ee..d0cbe12 100644 --- a/RF24.cpp +++ b/RF24.cpp @@ -504,18 +504,13 @@ boolean RF24::read( void* buf, uint8_t len ) void RF24::whatHappened(bool& tx_ok,bool& tx_fail,bool& rx_ready) { - // Read the status - uint8_t status = get_status(); - - // Reset the status - write_register(STATUS,_BV(RX_DR) | _BV(TX_DS) | _BV(MAX_RT) ); + // Read the status & reset the status in one easy call + uint8_t status = write_register(STATUS,_BV(RX_DR) | _BV(TX_DS) | _BV(MAX_RT) ); // Report to the user what happened tx_ok = status & _BV(TX_DS); tx_fail = status & _BV(MAX_RT); rx_ready = status & _BV(RX_DR); - - //print_status(status); } /******************************************************************/