Optimization of whatHappened, suggested by Mike Denzien
This commit is contained in:
parent
f8e6984ccc
commit
b000a87aa1
9
RF24.cpp
9
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)
|
void RF24::whatHappened(bool& tx_ok,bool& tx_fail,bool& rx_ready)
|
||||||
{
|
{
|
||||||
// Read the status
|
// Read the status & reset the status in one easy call
|
||||||
uint8_t status = get_status();
|
uint8_t status = write_register(STATUS,_BV(RX_DR) | _BV(TX_DS) | _BV(MAX_RT) );
|
||||||
|
|
||||||
// Reset the status
|
|
||||||
write_register(STATUS,_BV(RX_DR) | _BV(TX_DS) | _BV(MAX_RT) );
|
|
||||||
|
|
||||||
// Report to the user what happened
|
// Report to the user what happened
|
||||||
tx_ok = status & _BV(TX_DS);
|
tx_ok = status & _BV(TX_DS);
|
||||||
tx_fail = status & _BV(MAX_RT);
|
tx_fail = status & _BV(MAX_RT);
|
||||||
rx_ready = status & _BV(RX_DR);
|
rx_ready = status & _BV(RX_DR);
|
||||||
|
|
||||||
//print_status(status);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************/
|
/******************************************************************/
|
||||||
|
|
Loading…
Reference in New Issue