@@ -37,21 +37,21 @@ const uint8_t StatusFlags::rx_pipe() const
37
37
38
38
const bool StatusFlags::tx_df () const
39
39
{
40
- return value & _BV (MAX_RT) ;
40
+ return value & RF24_TX_DF ;
41
41
}
42
42
43
43
/* ***************************************************************************/
44
44
45
45
const bool StatusFlags::tx_ds () const
46
46
{
47
- return value & _BV (TX_DS) ;
47
+ return value & RF24_TX_DS ;
48
48
}
49
49
50
50
/* ***************************************************************************/
51
51
52
52
const bool StatusFlags::rx_dr () const
53
53
{
54
- return value & _BV (RX_DR) ;
54
+ return value & RF24_RX_DR ;
55
55
}
56
56
57
57
/* ***************************************************************************/
@@ -527,21 +527,13 @@ uint8_t RF24::flush_tx(void)
527
527
return status;
528
528
}
529
529
530
- /* ***************************************************************************/
531
-
532
- uint8_t RF24::get_status (void )
533
- {
534
- read_register (RF24_NOP, (uint8_t *)nullptr , 0 );
535
- return status;
536
- }
537
-
538
530
/* ***************************************************************************/
539
531
#if !defined(MINIMAL)
540
532
541
- void RF24::print_status (uint8_t _status )
533
+ void RF24::printStatus (uint8_t flags )
542
534
{
543
- 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 ,
544
- (_status & _BV (TX_DS)) ? 1 : 0 , (_status & _BV (MAX_RT)) ? 1 : 0 , ((_status >> RX_P_NO) & 0x07 ), (_status & _BV (TX_FULL)) ? 1 : 0 );
535
+ 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 ,
536
+ (flags & RF24_TX_DS) ? 1 : 0 , (flags & RF24_TX_DF) ? 1 : 0 , ((flags >> RX_P_NO) & 0x07 ), (flags & _BV (TX_FULL)) ? 1 : 0 );
545
537
}
546
538
547
539
/* ***************************************************************************/
@@ -755,7 +747,7 @@ void RF24::printDetails(void)
755
747
printf (" ================ NRF Configuration ================\n " );
756
748
#endif // defined(RF24_LINUX)
757
749
758
- print_status ( get_status ());
750
+ printStatus ( update ());
759
751
760
752
print_address_register (PSTR (" RX_ADDR_P0-1" ), RX_ADDR_P0, 2 );
761
753
print_byte_register (PSTR (" RX_ADDR_P2-5" ), RX_ADDR_P2, 4 );
@@ -1151,7 +1143,7 @@ bool RF24::_init_radio()
1151
1143
1152
1144
// Reset current status
1153
1145
// Notice reset and flush is the last thing we do
1154
- write_register (NRF_STATUS, _BV (RX_DR) | _BV (TX_DS) | _BV (MAX_RT) );
1146
+ write_register (NRF_STATUS, RF24_IRQ_ALL );
1155
1147
1156
1148
// Flush buffers
1157
1149
flush_rx ();
@@ -1196,7 +1188,7 @@ void RF24::startListening(void)
1196
1188
#endif
1197
1189
config_reg |= _BV (PRIM_RX);
1198
1190
write_register (NRF_CONFIG, config_reg);
1199
- write_register (NRF_STATUS, _BV (RX_DR) | _BV (TX_DS) | _BV (MAX_RT) );
1191
+ write_register (NRF_STATUS, RF24_IRQ_ALL );
1200
1192
ce (HIGH);
1201
1193
1202
1194
// Restore the pipe0 address, if exists
@@ -1292,7 +1284,7 @@ bool RF24::write(const void* buf, uint8_t len, const bool multicast)
1292
1284
uint32_t timer = millis ();
1293
1285
#endif // defined(FAILURE_HANDLING) || defined(RF24_LINUX)
1294
1286
1295
- while (!(get_status () & (_BV (TX_DS) | _BV (MAX_RT) ))) {
1287
+ while (!(update () & (RF24_TX_DS | RF24_TX_DF ))) {
1296
1288
#if defined(FAILURE_HANDLING) || defined(RF24_LINUX)
1297
1289
if (millis () - timer > 95 ) {
1298
1290
errNotify ();
@@ -1307,10 +1299,10 @@ bool RF24::write(const void* buf, uint8_t len, const bool multicast)
1307
1299
1308
1300
ce (LOW);
1309
1301
1310
- write_register (NRF_STATUS, _BV (RX_DR) | _BV (TX_DS) | _BV (MAX_RT) );
1302
+ write_register (NRF_STATUS, RF24_IRQ_ALL );
1311
1303
1312
1304
// Max retries exceeded
1313
- if (status & _BV (MAX_RT) ) {
1305
+ if (status & RF24_TX_DF ) {
1314
1306
flush_tx (); // Only going to be 1 packet in the FIFO at a time using this method, so just flush
1315
1307
return 0 ;
1316
1308
}
@@ -1335,10 +1327,10 @@ bool RF24::writeBlocking(const void* buf, uint8_t len, uint32_t timeout)
1335
1327
1336
1328
uint32_t timer = millis (); // Get the time that the payload transmission started
1337
1329
1338
- while ((get_status () & (_BV (TX_FULL)))) { // Blocking only if FIFO is full. This will loop and block until TX is successful or timeout
1330
+ while ((update () & (_BV (TX_FULL)))) { // Blocking only if FIFO is full. This will loop and block until TX is successful or timeout
1339
1331
1340
- if (status & _BV (MAX_RT) ) { // If MAX Retries have been reached
1341
- reUseTX (); // Set re-transmit and clear the MAX_RT interrupt flag
1332
+ if (status & RF24_TX_DF ) { // If MAX Retries have been reached
1333
+ reUseTX (); // Set re-transmit and clear the MAX_RT interrupt flag
1342
1334
if (millis () - timer > timeout) {
1343
1335
return 0 ; // If this payload has exceeded the user-defined timeout, exit and return 0
1344
1336
}
@@ -1364,7 +1356,7 @@ bool RF24::writeBlocking(const void* buf, uint8_t len, uint32_t timeout)
1364
1356
void RF24::reUseTX ()
1365
1357
{
1366
1358
ce (LOW);
1367
- write_register (NRF_STATUS, _BV (MAX_RT) ); // Clear max retry flag
1359
+ write_register (NRF_STATUS, RF24_TX_DF ); // Clear max retry flag
1368
1360
read_register (REUSE_TX_PL, (uint8_t *)nullptr , 0 );
1369
1361
IF_RF24_DEBUG (printf_P (" [Reusing payload in TX FIFO]" ););
1370
1362
ce (HIGH); // Re-Transfer packet
@@ -1384,8 +1376,8 @@ bool RF24::writeFast(const void* buf, uint8_t len, const bool multicast)
1384
1376
#endif
1385
1377
1386
1378
// Blocking only if FIFO is full. This will loop and block until TX is successful or fail
1387
- while ((get_status () & (_BV (TX_FULL)))) {
1388
- if (status & _BV (MAX_RT) ) {
1379
+ while ((update () & (_BV (TX_FULL)))) {
1380
+ if (status & RF24_TX_DF ) {
1389
1381
return 0 ; // Return 0. The previous payload has not been retransmitted
1390
1382
// From the user perspective, if you get a 0, call txStandBy()
1391
1383
}
@@ -1477,8 +1469,8 @@ bool RF24::txStandBy()
1477
1469
uint32_t timeout = millis ();
1478
1470
#endif
1479
1471
while (!(read_register (FIFO_STATUS) & _BV (TX_EMPTY))) {
1480
- if (status & _BV (MAX_RT) ) {
1481
- write_register (NRF_STATUS, _BV (MAX_RT) );
1472
+ if (status & RF24_TX_DF ) {
1473
+ write_register (NRF_STATUS, RF24_TX_DF );
1482
1474
ce (LOW);
1483
1475
flush_tx (); // Non blocking, flush the data
1484
1476
return 0 ;
@@ -1509,8 +1501,8 @@ bool RF24::txStandBy(uint32_t timeout, bool startTx)
1509
1501
uint32_t start = millis ();
1510
1502
1511
1503
while (!(read_register (FIFO_STATUS) & _BV (TX_EMPTY))) {
1512
- if (status & _BV (MAX_RT) ) {
1513
- write_register (NRF_STATUS, _BV (MAX_RT) );
1504
+ if (status & RF24_TX_DF ) {
1505
+ write_register (NRF_STATUS, RF24_TX_DF );
1514
1506
ce (LOW); // Set re-transmit
1515
1507
ce (HIGH);
1516
1508
if (millis () - start >= timeout) {
@@ -1570,7 +1562,7 @@ bool RF24::available(void)
1570
1562
bool RF24::available (uint8_t * pipe_num)
1571
1563
{
1572
1564
if (available ()) { // if RX FIFO is not empty
1573
- *pipe_num = (get_status () >> RX_P_NO) & 0x07 ;
1565
+ *pipe_num = (update () >> RX_P_NO) & 0x07 ;
1574
1566
return 1 ;
1575
1567
}
1576
1568
return 0 ;
@@ -1585,7 +1577,7 @@ void RF24::read(void* buf, uint8_t len)
1585
1577
read_payload (buf, len);
1586
1578
1587
1579
// Clear the only applicable interrupt flags
1588
- write_register (NRF_STATUS, _BV (RX_DR) );
1580
+ write_register (NRF_STATUS, RF24_RX_DR );
1589
1581
}
1590
1582
1591
1583
/* ***************************************************************************/
@@ -1594,12 +1586,12 @@ void RF24::whatHappened(bool& tx_ok, bool& tx_fail, bool& rx_ready)
1594
1586
{
1595
1587
// Read the status & reset the status in one easy call
1596
1588
// Or is that such a good idea?
1597
- write_register (NRF_STATUS, _BV (RX_DR) | _BV (TX_DS) | _BV (MAX_RT) );
1589
+ write_register (NRF_STATUS, RF24_IRQ_ALL );
1598
1590
1599
1591
// Report to the user what happened
1600
- tx_ok = status & _BV (TX_DS) ;
1601
- tx_fail = status & _BV (MAX_RT) ;
1602
- rx_ready = status & _BV (RX_DR) ;
1592
+ tx_ok = status & RF24_TX_DS ;
1593
+ tx_fail = status & RF24_TX_DF ;
1594
+ rx_ready = status & RF24_RX_DR ;
1603
1595
}
1604
1596
1605
1597
/* ***************************************************************************/
0 commit comments