@@ -483,21 +483,13 @@ uint8_t RF24::flush_tx(void)
483483 return status;
484484}
485485
486- /* ***************************************************************************/
487-
488- uint8_t RF24::get_status (void )
489- {
490- read_register (RF24_NOP, (uint8_t *)nullptr , 0 );
491- return status;
492- }
493-
494486/* ***************************************************************************/
495487#if !defined(MINIMAL)
496488
497- void RF24::print_status (uint8_t _status )
489+ void RF24::printStatus (uint8_t flags )
498490{
499- printf_P (PSTR (" STATUS\t\t = 0x%02x RX_DR=%x TX_DS=%x MAX_RT =%x RX_P_NO =%x TX_FULL=%x\r\n " ), _status , (_status & _BV (RX_DR) ) ? 1 : 0 ,
500- (_status & _BV (TX_DS)) ? 1 : 0 , (_status & _BV (MAX_RT)) ? 1 : 0 , ((_status >> RX_P_NO) & 0x07 ), (_status & _BV (TX_FULL)) ? 1 : 0 );
491+ printf_P (PSTR (" STATUS\t\t = 0x%02x RX_DR=%x TX_DS=%x TX_DF =%x RX_PIPE =%x TX_FULL=%x\r\n " ), flags , (flags & RF24_RX_DR ) ? 1 : 0 ,
492+ (flags & RF24_TX_DS) ? 1 : 0 , (flags & RF24_TX_DF) ? 1 : 0 , ((flags >> RX_P_NO) & 0x07 ), (flags & _BV (TX_FULL)) ? 1 : 0 );
501493}
502494
503495/* ***************************************************************************/
@@ -711,7 +703,7 @@ void RF24::printDetails(void)
711703 printf (" ================ NRF Configuration ================\n " );
712704 #endif // defined(RF24_LINUX)
713705
714- print_status ( get_status ());
706+ printStatus ( update ());
715707
716708 print_address_register (PSTR (" RX_ADDR_P0-1" ), RX_ADDR_P0, 2 );
717709 print_byte_register (PSTR (" RX_ADDR_P2-5" ), RX_ADDR_P2, 4 );
@@ -1107,7 +1099,7 @@ bool RF24::_init_radio()
11071099
11081100 // Reset current status
11091101 // Notice reset and flush is the last thing we do
1110- write_register (NRF_STATUS, _BV (RX_DR) | _BV (TX_DS) | _BV (MAX_RT) );
1102+ write_register (NRF_STATUS, RF24_IRQ_ALL );
11111103
11121104 // Flush buffers
11131105 flush_rx ();
@@ -1152,7 +1144,7 @@ void RF24::startListening(void)
11521144#endif
11531145 config_reg |= _BV (PRIM_RX);
11541146 write_register (NRF_CONFIG, config_reg);
1155- write_register (NRF_STATUS, _BV (RX_DR) | _BV (TX_DS) | _BV (MAX_RT) );
1147+ write_register (NRF_STATUS, RF24_IRQ_ALL );
11561148 ce (HIGH);
11571149
11581150 // Restore the pipe0 address, if exists
@@ -1248,7 +1240,7 @@ bool RF24::write(const void* buf, uint8_t len, const bool multicast)
12481240 uint32_t timer = millis ();
12491241#endif // defined(FAILURE_HANDLING) || defined(RF24_LINUX)
12501242
1251- while (!(get_status () & (_BV (TX_DS) | _BV (MAX_RT) ))) {
1243+ while (!(update () & (RF24_TX_DS | RF24_TX_DF ))) {
12521244#if defined(FAILURE_HANDLING) || defined(RF24_LINUX)
12531245 if (millis () - timer > 95 ) {
12541246 errNotify ();
@@ -1263,10 +1255,10 @@ bool RF24::write(const void* buf, uint8_t len, const bool multicast)
12631255
12641256 ce (LOW);
12651257
1266- write_register (NRF_STATUS, _BV (RX_DR) | _BV (TX_DS) | _BV (MAX_RT) );
1258+ write_register (NRF_STATUS, RF24_IRQ_ALL );
12671259
12681260 // Max retries exceeded
1269- if (status & _BV (MAX_RT) ) {
1261+ if (status & RF24_TX_DF ) {
12701262 flush_tx (); // Only going to be 1 packet in the FIFO at a time using this method, so just flush
12711263 return 0 ;
12721264 }
@@ -1291,10 +1283,10 @@ bool RF24::writeBlocking(const void* buf, uint8_t len, uint32_t timeout)
12911283
12921284 uint32_t timer = millis (); // Get the time that the payload transmission started
12931285
1294- while (( get_status ( ) & ( _BV (TX_FULL)) )) { // Blocking only if FIFO is full. This will loop and block until TX is successful or timeout
1286+ while (update ( ) & _BV (TX_FULL)) { // Blocking only if FIFO is full. This will loop and block until TX is successful or timeout
12951287
1296- if (status & _BV (MAX_RT) ) { // If MAX Retries have been reached
1297- reUseTX (); // Set re-transmit and clear the MAX_RT interrupt flag
1288+ if (status & RF24_TX_DF ) { // If MAX Retries have been reached
1289+ reUseTX (); // Set re-transmit and clear the MAX_RT interrupt flag
12981290 if (millis () - timer > timeout) {
12991291 return 0 ; // If this payload has exceeded the user-defined timeout, exit and return 0
13001292 }
@@ -1320,7 +1312,7 @@ bool RF24::writeBlocking(const void* buf, uint8_t len, uint32_t timeout)
13201312void RF24::reUseTX ()
13211313{
13221314 ce (LOW);
1323- write_register (NRF_STATUS, _BV (MAX_RT) ); // Clear max retry flag
1315+ write_register (NRF_STATUS, RF24_TX_DF ); // Clear max retry flag
13241316 read_register (REUSE_TX_PL, (uint8_t *)nullptr , 0 );
13251317 IF_RF24_DEBUG (printf_P (" [Reusing payload in TX FIFO]" ););
13261318 ce (HIGH); // Re-Transfer packet
@@ -1340,8 +1332,8 @@ bool RF24::writeFast(const void* buf, uint8_t len, const bool multicast)
13401332#endif
13411333
13421334 // Blocking only if FIFO is full. This will loop and block until TX is successful or fail
1343- while (( get_status ( ) & ( _BV (TX_FULL)) )) {
1344- if (status & _BV (MAX_RT) ) {
1335+ while (update ( ) & _BV (TX_FULL)) {
1336+ if (status & RF24_TX_DF ) {
13451337 return 0 ; // Return 0. The previous payload has not been retransmitted
13461338 // From the user perspective, if you get a 0, call txStandBy()
13471339 }
@@ -1433,8 +1425,8 @@ bool RF24::txStandBy()
14331425 uint32_t timeout = millis ();
14341426#endif
14351427 while (!(read_register (FIFO_STATUS) & _BV (TX_EMPTY))) {
1436- if (status & _BV (MAX_RT) ) {
1437- write_register (NRF_STATUS, _BV (MAX_RT) );
1428+ if (status & RF24_TX_DF ) {
1429+ write_register (NRF_STATUS, RF24_TX_DF );
14381430 ce (LOW);
14391431 flush_tx (); // Non blocking, flush the data
14401432 return 0 ;
@@ -1465,8 +1457,8 @@ bool RF24::txStandBy(uint32_t timeout, bool startTx)
14651457 uint32_t start = millis ();
14661458
14671459 while (!(read_register (FIFO_STATUS) & _BV (TX_EMPTY))) {
1468- if (status & _BV (MAX_RT) ) {
1469- write_register (NRF_STATUS, _BV (MAX_RT) );
1460+ if (status & RF24_TX_DF ) {
1461+ write_register (NRF_STATUS, RF24_TX_DF );
14701462 ce (LOW); // Set re-transmit
14711463 ce (HIGH);
14721464 if (millis () - start >= timeout) {
@@ -1526,7 +1518,7 @@ bool RF24::available(void)
15261518bool RF24::available (uint8_t * pipe_num)
15271519{
15281520 if (available ()) { // if RX FIFO is not empty
1529- *pipe_num = (get_status () >> RX_P_NO) & 0x07 ;
1521+ *pipe_num = (update () >> RX_P_NO) & 0x07 ;
15301522 return 1 ;
15311523 }
15321524 return 0 ;
@@ -1541,7 +1533,7 @@ void RF24::read(void* buf, uint8_t len)
15411533 read_payload (buf, len);
15421534
15431535 // Clear the only applicable interrupt flags
1544- write_register (NRF_STATUS, _BV (RX_DR) );
1536+ write_register (NRF_STATUS, RF24_RX_DR );
15451537}
15461538
15471539/* ***************************************************************************/
@@ -1550,12 +1542,12 @@ void RF24::whatHappened(bool& tx_ok, bool& tx_fail, bool& rx_ready)
15501542{
15511543 // Read the status & reset the status in one easy call
15521544 // Or is that such a good idea?
1553- write_register (NRF_STATUS, _BV (RX_DR) | _BV (TX_DS) | _BV (MAX_RT) );
1545+ write_register (NRF_STATUS, RF24_IRQ_ALL );
15541546
15551547 // Report to the user what happened
1556- tx_ok = status & _BV (TX_DS) ;
1557- tx_fail = status & _BV (MAX_RT) ;
1558- rx_ready = status & _BV (RX_DR) ;
1548+ tx_ok = status & RF24_TX_DS ;
1549+ tx_fail = status & RF24_TX_DF ;
1550+ rx_ready = status & RF24_RX_DR ;
15591551}
15601552
15611553/* ***************************************************************************/
0 commit comments