1010#include " RF24_config.h"
1111#include " RF24.h"
1212
13+ using namespace nRF24L01 ;
14+
1315/* ***************************************************************************/
1416
1517void RF24::csn (bool mode)
@@ -157,7 +159,7 @@ void RF24::read_register(uint8_t reg, uint8_t* buf, uint8_t len)
157159 *ptx++ = reg;
158160
159161 while (len--) {
160- *ptx++ = RF24_NOP ; // Dummy operation, just for reading
162+ *ptx++ = NOP ; // Dummy operation, just for reading
161163 }
162164
163165 #if defined(RF24_RP2)
@@ -207,7 +209,7 @@ uint8_t RF24::read_register(uint8_t reg)
207209 uint8_t * prx = spi_rxbuff;
208210 uint8_t * ptx = spi_txbuff;
209211 *ptx++ = reg;
210- *ptx++ = RF24_NOP ; // Dummy operation, just for reading
212+ *ptx++ = NOP ; // Dummy operation, just for reading
211213
212214 #if defined(RF24_RP2)
213215 _spi->transfernb ((const uint8_t *)spi_txbuff, spi_rxbuff, 2 );
@@ -413,7 +415,7 @@ void RF24::read_payload(void* buf, uint8_t data_len)
413415
414416 *ptx++ = R_RX_PAYLOAD;
415417 while (--size) {
416- *ptx++ = RF24_NOP ;
418+ *ptx++ = NOP ;
417419 }
418420
419421 size = static_cast <uint8_t >(data_len + blank_len + 1 ); // Size has been lost during while, re affect
@@ -718,7 +720,7 @@ void RF24::printDetails(void)
718720 print_byte_register (PSTR (" EN_RXADDR" ), EN_RXADDR);
719721 print_byte_register (PSTR (" RF_CH\t " ), RF_CH);
720722 print_byte_register (PSTR (" RF_SETUP" ), RF_SETUP);
721- print_byte_register (PSTR (" CONFIG\t " ), NRF_CONFIG );
723+ print_byte_register (PSTR (" CONFIG\t " ), CONFIG );
722724 print_byte_register (PSTR (" DYNPD/FEATURE" ), DYNPD, 2 );
723725
724726 printf_P (PSTR (" Data Rate\t " PRIPSTR
@@ -812,7 +814,7 @@ void RF24::printPrettyDetails(void)
812814 static_cast <char >(static_cast <bool >(autoAck & _BV (ENAA_P0)) + 48 ));
813815 }
814816
815- config_reg = read_register (NRF_CONFIG );
817+ config_reg = read_register (CONFIG );
816818 printf_P (PSTR (" Primary Mode\t\t = %cX\r\n " ), config_reg & _BV (PRIM_RX) ? ' R' : ' T' );
817819 print_address_register (PSTR (" TX address\t " ), TX_ADDR);
818820
@@ -894,7 +896,7 @@ uint16_t RF24::sprintfPrettyDetails(char* debugging_information)
894896 }
895897 offset += sprintf_P (
896898 debugging_information + offset, format_str2,
897- (read_register (NRF_CONFIG ) & _BV (PRIM_RX) ? ' R' : ' T' ));
899+ (read_register (CONFIG ) & _BV (PRIM_RX) ? ' R' : ' T' ));
898900 offset += sprintf_address_register (debugging_information + offset, TX_ADDR);
899901 uint8_t openPipes = read_register (EN_RXADDR);
900902 for (uint8_t i = 0 ; i < 6 ; ++i) {
@@ -919,7 +921,7 @@ uint16_t RF24::sprintfPrettyDetails(char* debugging_information)
919921void RF24::encodeRadioDetails (uint8_t * encoded_details)
920922{
921923 uint8_t end = FEATURE + 1 ;
922- for (uint8_t i = NRF_CONFIG ; i < end; ++i) {
924+ for (uint8_t i = CONFIG ; i < end; ++i) {
923925 if (i == RX_ADDR_P0 || i == RX_ADDR_P1 || i == TX_ADDR) {
924926 // get 40-bit registers
925927 read_register (i, encoded_details, 5 );
@@ -1103,7 +1105,7 @@ bool RF24::_init_radio()
11031105
11041106 // Reset current status
11051107 // Notice reset and flush is the last thing we do
1106- write_register (NRF_STATUS , RF24_IRQ_ALL);
1108+ write_register (STATUS , RF24_IRQ_ALL);
11071109
11081110 // Flush buffers
11091111 flush_rx ();
@@ -1116,8 +1118,8 @@ bool RF24::_init_radio()
11161118 // 16-bit CRC (CRC required by auto-ack)
11171119 // Do not write CE high so radio will remain in standby I mode
11181120 // PTX should use only 22uA of power
1119- write_register (NRF_CONFIG , (_BV (EN_CRC) | _BV (CRCO) | _BV (MASK_RX_DR) | _BV (MASK_TX_DS) | _BV (MASK_MAX_RT)));
1120- config_reg = read_register (NRF_CONFIG );
1121+ write_register (CONFIG , (_BV (EN_CRC) | _BV (CRCO) | _BV (MASK_RX_DR) | _BV (MASK_TX_DS) | _BV (MASK_MAX_RT)));
1122+ config_reg = read_register (CONFIG );
11211123
11221124 powerUp ();
11231125
@@ -1147,8 +1149,8 @@ void RF24::startListening(void)
11471149 powerUp ();
11481150#endif
11491151 config_reg |= _BV (PRIM_RX);
1150- write_register (NRF_CONFIG , config_reg);
1151- write_register (NRF_STATUS , RF24_IRQ_ALL);
1152+ write_register (CONFIG , config_reg);
1153+ write_register (STATUS , RF24_IRQ_ALL);
11521154 ce (HIGH);
11531155
11541156 // Restore the pipe0 address, if exists
@@ -1176,7 +1178,7 @@ void RF24::stopListening(void)
11761178 }
11771179
11781180 config_reg = static_cast <uint8_t >(config_reg & ~_BV (PRIM_RX));
1179- write_register (NRF_CONFIG , config_reg);
1181+ write_register (CONFIG , config_reg);
11801182
11811183#if defined(RF24_TINY) || defined(LITTLEWIRE)
11821184 // for 3 pins solution TX mode is only left with additional powerDown/powerUp cycle
@@ -1213,7 +1215,7 @@ void RF24::powerDown(void)
12131215{
12141216 ce (LOW); // Guarantee CE is low on powerDown
12151217 config_reg = static_cast <uint8_t >(config_reg & ~_BV (PWR_UP));
1216- write_register (NRF_CONFIG , config_reg);
1218+ write_register (CONFIG , config_reg);
12171219}
12181220
12191221/* ***************************************************************************/
@@ -1224,7 +1226,7 @@ void RF24::powerUp(void)
12241226 // if not powered up then power up and wait for the radio to initialize
12251227 if (!(config_reg & _BV (PWR_UP))) {
12261228 config_reg |= _BV (PWR_UP);
1227- write_register (NRF_CONFIG , config_reg);
1229+ write_register (CONFIG , config_reg);
12281230
12291231 // For nRF24L01+ to go from power down mode to TX or RX mode it must first pass through stand-by mode.
12301232 // There must be a delay of Tpd2stby (see Table 16.) after the nRF24L01+ leaves power down mode before
@@ -1323,7 +1325,7 @@ bool RF24::write(const void* buf, uint8_t len, const bool multicast)
13231325
13241326 ce (LOW);
13251327
1326- write_register (NRF_STATUS , RF24_IRQ_ALL);
1328+ write_register (STATUS , RF24_IRQ_ALL);
13271329
13281330 // Max retries exceeded
13291331 if (status & RF24_TX_DF) {
@@ -1397,7 +1399,7 @@ bool RF24::writeBlocking(const void* buf, uint8_t len, uint32_t timeout)
13971399void RF24::reUseTX ()
13981400{
13991401 ce (LOW);
1400- write_register (NRF_STATUS , RF24_TX_DF); // Clear max retry flag
1402+ write_register (STATUS , RF24_TX_DF); // Clear max retry flag
14011403 read_register (REUSE_TX_PL, (uint8_t *)nullptr , 0 );
14021404 IF_RF24_DEBUG (printf_P (" [Reusing payload in TX FIFO]" ););
14031405 ce (HIGH); // Re-Transfer packet
@@ -1524,7 +1526,7 @@ bool RF24::txStandBy()
15241526#endif
15251527 while (!(read_register (FIFO_STATUS) & _BV (TX_EMPTY))) {
15261528 if (status & RF24_TX_DF) {
1527- write_register (NRF_STATUS , RF24_TX_DF);
1529+ write_register (STATUS , RF24_TX_DF);
15281530 ce (LOW);
15291531 flush_tx (); // Non blocking, flush the data
15301532#if defined(FAILURE_HANDLING)
@@ -1560,7 +1562,7 @@ bool RF24::txStandBy(uint32_t timeout, bool startTx)
15601562
15611563 while (!(read_register (FIFO_STATUS) & _BV (TX_EMPTY))) {
15621564 if (status & RF24_TX_DF) {
1563- write_register (NRF_STATUS , RF24_TX_DF);
1565+ write_register (STATUS , RF24_TX_DF);
15641566 ce (LOW); // Set re-transmit
15651567 ce (HIGH);
15661568 if (millis () - start >= timeout) {
@@ -1595,7 +1597,7 @@ void RF24::maskIRQ(bool tx, bool fail, bool rx)
15951597 config_reg = static_cast <uint8_t >(config_reg & ~(1 << MASK_MAX_RT | 1 << MASK_TX_DS | 1 << MASK_RX_DR));
15961598 /* set the specified interrupt flags */
15971599 config_reg = static_cast <uint8_t >(config_reg | fail << MASK_MAX_RT | tx << MASK_TX_DS | rx << MASK_RX_DR);
1598- write_register (NRF_CONFIG , config_reg);
1600+ write_register (CONFIG , config_reg);
15991601}
16001602
16011603/* ***************************************************************************/
@@ -1638,7 +1640,7 @@ void RF24::read(void* buf, uint8_t len)
16381640 read_payload (buf, len);
16391641
16401642 // Clear the only applicable interrupt flags
1641- write_register (NRF_STATUS , RF24_RX_DR);
1643+ write_register (STATUS , RF24_RX_DR);
16421644}
16431645
16441646/* ***************************************************************************/
@@ -1647,7 +1649,7 @@ void RF24::whatHappened(bool& tx_ok, bool& tx_fail, bool& rx_ready)
16471649{
16481650 // Read the status & reset the status in one easy call
16491651 // Or is that such a good idea?
1650- write_register (NRF_STATUS , RF24_IRQ_ALL);
1652+ write_register (STATUS , RF24_IRQ_ALL);
16511653
16521654 // Report to the user what happened
16531655 tx_ok = status & RF24_TX_DS;
@@ -1659,7 +1661,7 @@ void RF24::whatHappened(bool& tx_ok, bool& tx_fail, bool& rx_ready)
16591661
16601662uint8_t RF24::clearStatusFlags (uint8_t flags)
16611663{
1662- write_register (NRF_STATUS , flags & RF24_IRQ_ALL);
1664+ write_register (STATUS , flags & RF24_IRQ_ALL);
16631665 return status;
16641666}
16651667
@@ -1669,7 +1671,7 @@ void RF24::setStatusFlags(uint8_t flags)
16691671{
16701672 // flip the `flags` to translate from "human understanding"
16711673 config_reg = (config_reg & ~RF24_IRQ_ALL) | (~flags & RF24_IRQ_ALL);
1672- write_register (NRF_CONFIG , config_reg);
1674+ write_register (CONFIG , config_reg);
16731675}
16741676
16751677/* ***************************************************************************/
@@ -1683,7 +1685,7 @@ uint8_t RF24::getStatusFlags()
16831685
16841686uint8_t RF24::update ()
16851687{
1686- read_register (RF24_NOP , (uint8_t *)nullptr , 0 );
1688+ read_register (NOP , (uint8_t *)nullptr , 0 );
16871689 return status;
16881690}
16891691
@@ -2059,7 +2061,7 @@ void RF24::setCRCLength(rf24_crclength_e length)
20592061 config_reg |= _BV (EN_CRC);
20602062 config_reg |= _BV (CRCO);
20612063 }
2062- write_register (NRF_CONFIG , config_reg);
2064+ write_register (CONFIG , config_reg);
20632065}
20642066
20652067/* ***************************************************************************/
@@ -2068,7 +2070,7 @@ rf24_crclength_e RF24::getCRCLength(void)
20682070{
20692071 rf24_crclength_e result = RF24_CRC_DISABLED;
20702072 uint8_t AA = read_register (EN_AA);
2071- config_reg = read_register (NRF_CONFIG );
2073+ config_reg = read_register (CONFIG );
20722074
20732075 if (config_reg & _BV (EN_CRC) || AA) {
20742076 if (config_reg & _BV (CRCO)) {
@@ -2087,7 +2089,7 @@ rf24_crclength_e RF24::getCRCLength(void)
20872089void RF24::disableCRC (void )
20882090{
20892091 config_reg = static_cast <uint8_t >(config_reg & ~_BV (EN_CRC));
2090- write_register (NRF_CONFIG , config_reg);
2092+ write_register (CONFIG , config_reg);
20912093}
20922094
20932095/* ***************************************************************************/
0 commit comments