2 Copyright (C) 2011 J. Coliz <maniacbug@ymail.com>
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 version 2 as published by the Free Software Foundation.
10 #include "RF24_config.h"
13 inline void nrf24_csn(int mode
)
15 // Minimum ideal SPI bus speed is 2x data rate
16 // If we assume 2Mbs data rate and 16Mhz clock, a
17 // divider of 4 is the minimum we want.
18 // CLK:BUS 8Mhz:2Mhz, 16Mhz:4Mhz, or 20Mhz:5Mhz
19 spi_setup(SPI_MSBFIRST
| SPI_MODE0
| SPI_CLOCK_DIV4
);
20 CSN_PORT
&= ~_BV(CSN_PIN
);
21 CSN_PORT
|= mode
<<CSN_PIN
;
24 inline void nrf24_ce(int level
)
26 CE_PORT
&= ~_BV(CE_PIN
);
27 CE_PORT
|= level
<<CE_PIN
;
30 uint8_t nrf24_read_register(uint8_t reg
, uint8_t* buf
, uint8_t len
)
35 status
= spi_transfer( R_REGISTER
| ( REGISTER_MASK
& reg
) );
37 *buf
++ = spi_transfer(0xff);
44 uint8_t nrf24_read_register(uint8_t reg
)
47 spi_transfer( R_REGISTER
| ( REGISTER_MASK
& reg
) );
48 uint8_t result
= spi_transfer(0xff);
54 uint8_t nrf24_write_register(uint8_t reg
, const uint8_t* buf
, uint8_t len
)
59 status
= spi_transfer( W_REGISTER
| ( REGISTER_MASK
& reg
) );
68 uint8_t nrf24_write_register(uint8_t reg
, uint8_t value
)
73 uart_puts_p(PSTR("RF24 write_register("));
82 status
= spi_transfer( W_REGISTER
| ( REGISTER_MASK
& reg
) );
89 uint8_t nrf24_write_payload(const void* buf
, uint8_t len
)
93 const uint8_t* current
= (const uint8_t*)(buf
);
95 uint8_t data_len
= min(len
,payload_size
);
96 uint8_t blank_len
= dynamic_payloads_enabled
? 0 : payload_size
- data_len
;
98 //printf("[Writing %u bytes %u blanks]",data_len,blank_len);
101 status
= spi_transfer( W_TX_PAYLOAD
);
103 spi_transfer(*current
++);
104 while ( blank_len
-- )
111 uint8_t nrf24_read_payload(void* buf
, uint8_t len
)
114 uint8_t* current
= (uint8_t*)(buf
);
116 uint8_t data_len
= min(len
,payload_size
);
117 uint8_t blank_len
= dynamic_payloads_enabled
? 0 : payload_size
- data_len
;
119 //printf("[Reading %u bytes %u blanks]",data_len,blank_len);
122 status
= spi_transfer( R_RX_PAYLOAD
);
124 *current
++ = spi_transfer(0xff);
125 while ( blank_len
-- )
132 uint8_t nrf24_flush_rx(void)
137 status
= spi_transfer( FLUSH_RX
);
143 uint8_t nrf24_flush_tx(void)
148 status
= spi_transfer( FLUSH_TX
);
154 uint8_t nrf24_get_status(void)
159 status
= spi_transfer( NOP
);
165 void nrf24_print_status(uint8_t status
)
167 uart_puts_p(PSTR("RF24 STATUS\t\t = 0x"));
169 uart_puts_p(PSTR("RX_DR="));
170 uart_putc((status
& _BV(RX_DR
))?'1':'0');
171 uart_puts_p(PSTR("TX_DS="));
172 uart_putc((status
& _BV(TX_DS
))?'1':'0');
173 uart_puts_p(PSTR("MAX_RT="));
174 uart_putc((status
& _BV(MAX_RT
))?'1':'0');
175 uart_puts_p(PSTR("RX_P_NO=0x"));
176 uart_puthex((status
>> RX_P_NO
) & 0x7);
177 uart_puts_p(PSTR("TX_FULL="));
178 uart_putc((status
& _BV(TX_FULL
))?'1':'0');
183 void nrf24_print_observe_tx(uint8_t value
)
185 uart_puts_p(PSTR("RF24 OBSERVE_TX="));
187 uart_puts_p(PSTR(": POLS_CNT="));
188 uart_puthex((value
>> PLOS_CNT
) & 0xF);
189 uart_puts_p(PSTR("ARC_CNT="));
190 uart_puthex((value
>> ARC_CNT
) & 0xF);
196 void nrf24_print_byte_register(const char* name
, uint8_t reg
, uint8_t qty
)
198 uart_puts_p("RF24 ");
201 if(strlen_P(name
) < 8){
210 uart_puthex(read_register(reg
++));
217 void nrf24_print_address_register(const char* name
, uint8_t reg
, uint8_t qty
)
219 uart_puts_p("RF24 ");
222 if(strlen_P(name
) < 8){
230 read_register(reg
++,buffer
,sizeof(buffer
));
234 uint8_t* bufptr
= buffer
+ sizeof(buffer
);
235 while( --bufptr
>= buffer
){
236 uart_puthex(*bufptr
);
244 void nrf24_setChannel(uint8_t channel
)
246 // TODO: This method could take advantage of the 'wide_band' calculation
247 // done in setChannel() to require certain channel spacing.
249 const uint8_t max_channel
= 127;
250 write_register(RF_CH
,min(channel
,max_channel
));
255 void nrf24_setPayloadSize(uint8_t size
)
257 const uint8_t max_payload_size
= 32;
258 payload_size
= min(size
,max_payload_size
);
263 uint8_t nrf24_getPayloadSize(void)
270 static const char rf24_datarate_e_str_0
[] PROGMEM
= "1MBPS";
271 static const char rf24_datarate_e_str_1
[] PROGMEM
= "2MBPS";
272 static const char rf24_datarate_e_str_2
[] PROGMEM
= "250KBPS";
273 static const char * const rf24_datarate_e_str_P
[] PROGMEM
= {
274 rf24_datarate_e_str_0
,
275 rf24_datarate_e_str_1
,
276 rf24_datarate_e_str_2
,
278 static const char rf24_model_e_str_0
[] PROGMEM
= "nRF24L01";
279 static const char rf24_model_e_str_1
[] PROGMEM
= "nRF24L01+";
280 static const char * const rf24_model_e_str_P
[] PROGMEM
= {
284 static const char rf24_crclength_e_str_0
[] PROGMEM
= "Disabled";
285 static const char rf24_crclength_e_str_1
[] PROGMEM
= "8 bits";
286 static const char rf24_crclength_e_str_2
[] PROGMEM
= "16 bits" ;
287 static const char * const rf24_crclength_e_str_P
[] PROGMEM
= {
288 rf24_crclength_e_str_0
,
289 rf24_crclength_e_str_1
,
290 rf24_crclength_e_str_2
,
292 static const char rf24_pa_dbm_e_str_0
[] PROGMEM
= "PA_MIN";
293 static const char rf24_pa_dbm_e_str_1
[] PROGMEM
= "PA_LOW";
294 static const char rf24_pa_dbm_e_str_2
[] PROGMEM
= "LA_MED";
295 static const char rf24_pa_dbm_e_str_3
[] PROGMEM
= "PA_HIGH";
296 static const char * const rf24_pa_dbm_e_str_P
[] PROGMEM
= {
303 void nrf24_printDetails(void)
305 print_status(get_status());
307 print_address_register(PSTR("RX_ADDR_P0-1"),RX_ADDR_P0
,2);
308 print_byte_register(PSTR("RX_ADDR_P2-5"),RX_ADDR_P2
,4);
309 print_address_register(PSTR("TX_ADDR"),TX_ADDR
);
311 print_byte_register(PSTR("RX_PW_P0-6"),RX_PW_P0
,6);
312 print_byte_register(PSTR("EN_AA"),EN_AA
);
313 print_byte_register(PSTR("EN_RXADDR"),EN_RXADDR
);
314 print_byte_register(PSTR("RF_CH"),RF_CH
);
315 print_byte_register(PSTR("RF_SETUP"),RF_SETUP
);
316 print_byte_register(PSTR("CONFIG"),CONFIG
);
317 print_byte_register(PSTR("DYNPD/FEATURE"),DYNPD
,2);
319 uart_puts_p(PSTR("RF24 Data Rate\t = "));
320 uart_puts(pgm_read_word(&rf24_datarate_e_str_P
[getDataRate()]));
322 uart_puts_p(PSTR("RF24 Model\t\t = "));
323 uart_puts(pgm_read_word(&rf24_model_e_str_P
[isPVariant()]));
325 uart_puts_p(PSTR("RF24 CRC Length\t = "));
326 uart_puts(pgm_read_word(&rf24_crclength_e_str_P
[getCRCLength()]));
328 uart_puts_p(PSTR("RF24 PA Power\t = "));
329 uart_puts(pgm_read_word(&rf24_pa_dbm_e_str_P
[getPALevel()]));
335 void nrf24_begin(void)
338 CE_DDR
|= _BV(CE_PIN
);
339 CSN_DDR
|= _BV(CSN_PIN
);
341 // Initialize SPI bus
347 // Must allow the radio time to settle else configuration bits will not necessarily stick.
348 // This is actually only required following power up but some settling time also appears to
349 // be required after resets too. For full coverage, we'll always assume the worst.
350 // Enabling 16b CRC is by far the most obvious case if the wrong timing is used - or skipped.
351 // Technically we require 4.5ms + 14us as a worst case. We'll just call it 5ms for good measure.
352 // WARNING: Delay is based on P-variant whereby non-P *may* require different timing.
355 // Set 1500uS (minimum for 32B payload in ESB@250KBPS) timeouts, to make testing a little easier
356 // WARNING: If this is ever lowered, either 250KBS mode with AA is broken or maximum packet
357 // sizes must never be used. See documentation for a more complete explanation.
358 write_register(SETUP_RETR
,(B0100
<< ARD
) | (B1111
<< ARC
));
360 // Restore our default PA level
361 setPALevel( RF24_PA_MAX
) ;
363 // Determine if this is a p or non-p RF24 module and then
364 // reset our data rate back to default value. This works
365 // because a non-P variant won't allow the data rate to
366 // be set to 250Kbps.
367 if( setDataRate( RF24_250KBPS
) )
372 // Then set the data rate to the slowest (and most reliable) speed supported by all
374 setDataRate( RF24_1MBPS
) ;
376 // Initialize CRC and request 2-byte (16bit) CRC
377 setCRCLength( RF24_CRC_16
) ;
379 // Disable dynamic payloads, to match dynamic_payloads_enabled setting
380 write_register(DYNPD
,0);
382 // Reset current status
383 // Notice reset and flush is the last thing we do
384 write_register(STATUS
,_BV(RX_DR
) | _BV(TX_DS
) | _BV(MAX_RT
) );
386 // Set up default configuration. Callers can always change it later.
387 // This channel should be universally safe and not bleed over into adjacent
398 void nrf24_startListening(void)
400 write_register(CONFIG
, read_register(CONFIG
) | _BV(PWR_UP
) | _BV(PRIM_RX
));
401 write_register(STATUS
, _BV(RX_DR
) | _BV(TX_DS
) | _BV(MAX_RT
) );
403 // Restore the pipe0 adddress, if exists
404 if (pipe0_reading_address
)
405 write_register(RX_ADDR_P0
, (const uint8_t*)(pipe0_reading_address
), 5);
414 // wait for the radio to come up (130us actually only needed)
415 delayMicroseconds(130);
420 void nrf24_stopListening(void)
429 void nrf24_powerDown(void)
431 write_register(CONFIG
,read_register(CONFIG
) & ~_BV(PWR_UP
));
436 void nrf24_powerUp(void)
438 write_register(CONFIG
,read_register(CONFIG
) | _BV(PWR_UP
));
443 bool nrf24_write( const void* buf
, uint8_t len
)
451 // At this point we could return from a non-blocking write, and then call
452 // the rest after an interrupt
454 // Instead, we are going to block here until we get TX_DS (transmission completed and ack'd)
455 // or MAX_RT (maximum retries, transmission failed). Also, we'll timeout in case the radio
456 // is flaky and we get neither.
458 // IN the end, the send should be blocking. It comes back in 60ms worst case, or much faster
459 // if I tighted up the retry logic. (Default settings will be 1500us.
463 uint32_t sent_at
= millis();
464 const uint32_t timeout
= 500; //ms to wait for timeout
467 status
= read_register(OBSERVE_TX
,&observe_tx
,1);
468 IF_SERIAL_DEBUG(uart_puthex(observe_tx
));
470 while( ! ( status
& ( _BV(TX_DS
) | _BV(MAX_RT
) ) ) && ( millis() - sent_at
< timeout
) );
472 // The part above is what you could recreate with your own interrupt handler,
473 // and then call this when you got an interrupt
476 // Call this when you get an interrupt
477 // The status tells us three things
478 // * The send was successful (TX_DS)
479 // * The send failed, too many retries (MAX_RT)
480 // * There is an ack packet waiting (RX_DR)
482 whatHappened(tx_ok
,tx_fail
,ack_payload_available
);
484 //printf("%u%u%u\r\n",tx_ok,tx_fail,ack_payload_available);
487 IF_SERIAL_DEBUG(uart_puts(result
?"...OK.":"...Failed"));
489 // Handle the ack packet
490 if ( ack_payload_available
)
492 ack_payload_length
= getDynamicPayloadSize();
494 uart_puts_p(PSTR("RF24 [AckPacket]/"));
495 uart_putdec(uart_ack_payload_length
);
505 // Flush buffers (Is this a relic of past experimentation, and not needed anymore??)
512 void nrf24_startWrite( const void* buf
, uint8_t len
)
514 // Transmitter power-up
515 write_register(CONFIG
, ( read_register(CONFIG
) | _BV(PWR_UP
) ) & ~_BV(PRIM_RX
) );
516 delayMicroseconds(150);
519 write_payload( buf
, len
);
523 delayMicroseconds(15);
529 uint8_t nrf24_getDynamicPayloadSize(void)
534 spi_transfer( R_RX_PL_WID
);
535 result
= spi_transfer(0xff);
543 bool nrf24_available(void)
545 return available(NULL
);
550 bool nrf24_available(uint8_t* pipe_num
)
552 uint8_t status
= get_status();
554 // Too noisy, enable if you really want lots o data!!
555 //IF_SERIAL_DEBUG(print_status(status));
557 bool result
= ( status
& _BV(RX_DR
) );
561 // If the caller wants the pipe number, include that
563 *pipe_num
= ( status
>> RX_P_NO
) & B111
;
565 // Clear the status bit
567 // ??? Should this REALLY be cleared now? Or wait until we
568 // actually READ the payload?
570 write_register(STATUS
,_BV(RX_DR
) );
572 // Handle ack payload receipt
573 if ( status
& _BV(TX_DS
) )
575 write_register(STATUS
,_BV(TX_DS
));
584 bool nrf24_read( void* buf
, uint8_t len
)
587 read_payload( buf
, len
);
589 // was this the last of the data available?
590 return read_register(FIFO_STATUS
) & _BV(RX_EMPTY
);
595 void nrf24_whatHappened(bool& tx_ok
,bool& tx_fail
,bool& rx_ready
)
597 // Read the status & reset the status in one easy call
598 // Or is that such a good idea?
599 uint8_t status
= write_register(STATUS
,_BV(RX_DR
) | _BV(TX_DS
) | _BV(MAX_RT
) );
601 // Report to the user what happened
602 tx_ok
= status
& _BV(TX_DS
);
603 tx_fail
= status
& _BV(MAX_RT
);
604 rx_ready
= status
& _BV(RX_DR
);
609 void nrf24_openWritingPipe(uint64_t value
)
611 // Note that AVR 8-bit uC's store this LSB first, and the NRF24L01(+)
612 // expects it LSB first too, so we're good.
614 write_register(RX_ADDR_P0
, (uint8_t*)(&value
), 5);
615 write_register(TX_ADDR
, (uint8_t*)(&value
), 5);
617 const uint8_t max_payload_size
= 32;
618 write_register(RX_PW_P0
,min(payload_size
,max_payload_size
));
623 static const uint8_t child_pipe
[] PROGMEM
=
625 RX_ADDR_P0
, RX_ADDR_P1
, RX_ADDR_P2
, RX_ADDR_P3
, RX_ADDR_P4
, RX_ADDR_P5
627 static const uint8_t child_payload_size
[] PROGMEM
=
629 RX_PW_P0
, RX_PW_P1
, RX_PW_P2
, RX_PW_P3
, RX_PW_P4
, RX_PW_P5
631 static const uint8_t child_pipe_enable
[] PROGMEM
=
633 ERX_P0
, ERX_P1
, ERX_P2
, ERX_P3
, ERX_P4
, ERX_P5
636 void nrf24_openReadingPipe(uint8_t child
, uint64_t address
)
638 // If this is pipe 0, cache the address. This is needed because
639 // openWritingPipe() will overwrite the pipe 0 address, so
640 // startListening() will have to restore it.
642 pipe0_reading_address
= address
;
646 // For pipes 2-5, only write the LSB
648 write_register(pgm_read_byte(&child_pipe
[child
]), (const uint8_t*)(&address
), 5);
650 write_register(pgm_read_byte(&child_pipe
[child
]), (const uint8_t*)(&address
), 1);
652 write_register(pgm_read_byte(&child_payload_size
[child
]),payload_size
);
654 // Note it would be more efficient to set all of the bits for all open
655 // pipes at once. However, I thought it would make the calling code
656 // more simple to do it this way.
657 write_register(EN_RXADDR
,read_register(EN_RXADDR
) | _BV(pgm_read_byte(&child_pipe_enable
[child
])));
663 void nrf24_toggle_features(void)
666 spi_transfer( ACTIVATE
);
667 spi_transfer( 0x73 );
673 void nrf24_enableDynamicPayloads(void)
675 // Enable dynamic payload throughout the system
676 write_register(FEATURE
,read_register(FEATURE
) | _BV(EN_DPL
) );
678 // If it didn't work, the features are not enabled
679 if ( ! read_register(FEATURE
) )
681 // So enable them and try again
683 write_register(FEATURE
,read_register(FEATURE
) | _BV(EN_DPL
) );
687 uart_puts_p(PSTR("RF24 FEATURE="));
688 uart_putdec(read_register(FEATURE
));
692 // Enable dynamic payload on all pipes
694 // Not sure the use case of only having dynamic payload on certain
695 // pipes, so the library does not support it.
696 write_register(DYNPD
,read_register(DYNPD
) | _BV(DPL_P5
) | _BV(DPL_P4
) | _BV(DPL_P3
) | _BV(DPL_P2
) | _BV(DPL_P1
) | _BV(DPL_P0
));
698 dynamic_payloads_enabled
= true;
703 void nrf24_enableAckPayload(void)
706 // enable ack payload and dynamic payload features
709 write_register(FEATURE
,read_register(FEATURE
) | _BV(EN_ACK_PAY
) | _BV(EN_DPL
) );
711 // If it didn't work, the features are not enabled
712 if ( ! read_register(FEATURE
) )
714 // So enable them and try again
716 write_register(FEATURE
,read_register(FEATURE
) | _BV(EN_ACK_PAY
) | _BV(EN_DPL
) );
720 uart_puts_p(PSTR("RF24 FEATURE="));
721 uart_putdec(read_register(FEATURE
));
726 // Enable dynamic payload on pipes 0 & 1
729 write_register(DYNPD
,read_register(DYNPD
) | _BV(DPL_P1
) | _BV(DPL_P0
));
734 void nrf24_writeAckPayload(uint8_t pipe
, const void* buf
, uint8_t len
)
736 const uint8_t* current
= (const uint8_t*)(buf
);
739 spi_transfer( W_ACK_PAYLOAD
| ( pipe
& B111
) );
740 const uint8_t max_payload_size
= 32;
741 uint8_t data_len
= min(len
,max_payload_size
);
743 spi_transfer(*current
++);
750 bool nrf24_isAckPayloadAvailable(void)
752 bool result
= ack_payload_available
;
753 ack_payload_available
= false;
759 bool nrf24_isPVariant(void)
766 void nrf24_setAutoAck(bool enable
)
769 write_register(EN_AA
, 0x3F);
771 write_register(EN_AA
, 0);
776 void nrf24_setAutoAck( uint8_t pipe
, bool enable
)
780 uint8_t en_aa
= read_register( EN_AA
) ;
787 en_aa
&= ~_BV(pipe
) ;
789 write_register( EN_AA
, en_aa
) ;
795 bool nrf24_testCarrier(void)
797 return ( read_register(CD
) & 1 );
802 bool nrf24_testRPD(void)
804 return ( read_register(RPD
) & 1 ) ;
809 void nrf24_setPALevel(rf24_pa_dbm_e level
)
811 uint8_t setup
= read_register(RF_SETUP
) ;
812 setup
&= ~(_BV(RF_PWR_LOW
) | _BV(RF_PWR_HIGH
)) ;
814 // switch uses RAM (evil!)
815 if ( level
== RF24_PA_MAX
)
817 setup
|= (_BV(RF_PWR_LOW
) | _BV(RF_PWR_HIGH
)) ;
819 else if ( level
== RF24_PA_HIGH
)
821 setup
|= _BV(RF_PWR_HIGH
) ;
823 else if ( level
== RF24_PA_LOW
)
825 setup
|= _BV(RF_PWR_LOW
);
827 else if ( level
== RF24_PA_MIN
)
831 else if ( level
== RF24_PA_ERROR
)
833 // On error, go to maximum PA
834 setup
|= (_BV(RF_PWR_LOW
) | _BV(RF_PWR_HIGH
)) ;
837 write_register( RF_SETUP
, setup
) ;
842 rf24_pa_dbm_e
nrf24_getPALevel(void)
844 rf24_pa_dbm_e result
= RF24_PA_ERROR
;
845 uint8_t power
= read_register(RF_SETUP
) & (_BV(RF_PWR_LOW
) | _BV(RF_PWR_HIGH
)) ;
847 // switch uses RAM (evil!)
848 if ( power
== (_BV(RF_PWR_LOW
) | _BV(RF_PWR_HIGH
)) )
850 result
= RF24_PA_MAX
;
852 else if ( power
== _BV(RF_PWR_HIGH
) )
854 result
= RF24_PA_HIGH
;
856 else if ( power
== _BV(RF_PWR_LOW
) )
858 result
= RF24_PA_LOW
;
862 result
= RF24_PA_MIN
;
870 bool nrf24_setDataRate(rf24_datarate_e speed
)
873 uint8_t setup
= read_register(RF_SETUP
) ;
875 // HIGH and LOW '00' is 1Mbs - our default
877 setup
&= ~(_BV(RF_DR_LOW
) | _BV(RF_DR_HIGH
)) ;
878 if( speed
== RF24_250KBPS
)
880 // Must set the RF_DR_LOW to 1; RF_DR_HIGH (used to be RF_DR) is already 0
883 setup
|= _BV( RF_DR_LOW
) ;
887 // Set 2Mbs, RF_DR (RF_DR_HIGH) is set 1
889 if ( speed
== RF24_2MBPS
)
892 setup
|= _BV(RF_DR_HIGH
);
900 write_register(RF_SETUP
,setup
);
903 if ( read_register(RF_SETUP
) == setup
)
917 rf24_datarate_e
nrf24_getDataRate( void )
919 rf24_datarate_e result
;
920 uint8_t dr
= read_register(RF_SETUP
) & (_BV(RF_DR_LOW
) | _BV(RF_DR_HIGH
));
922 // switch uses RAM (evil!)
923 // Order matters in our case below
924 if ( dr
== _BV(RF_DR_LOW
) )
927 result
= RF24_250KBPS
;
929 else if ( dr
== _BV(RF_DR_HIGH
) )
932 result
= RF24_2MBPS
;
937 result
= RF24_1MBPS
;
944 void nrf24_setCRCLength(rf24_crclength_e length
)
946 uint8_t config
= read_register(CONFIG
) & ~( _BV(CRCO
) | _BV(EN_CRC
)) ;
948 // switch uses RAM (evil!)
949 if ( length
== RF24_CRC_DISABLED
)
951 // Do nothing, we turned it off above.
953 else if ( length
== RF24_CRC_8
)
955 config
|= _BV(EN_CRC
);
959 config
|= _BV(EN_CRC
);
960 config
|= _BV( CRCO
);
962 write_register( CONFIG
, config
) ;
967 rf24_crclength_e
nrf24_getCRCLength(void)
969 rf24_crclength_e result
= RF24_CRC_DISABLED
;
970 uint8_t config
= read_register(CONFIG
) & ( _BV(CRCO
) | _BV(EN_CRC
)) ;
972 if ( config
& _BV(EN_CRC
) )
974 if ( config
& _BV(CRCO
) )
975 result
= RF24_CRC_16
;
985 void nrf24_disableCRC( void )
987 uint8_t disable
= read_register(CONFIG
) & ~_BV(EN_CRC
) ;
988 write_register( CONFIG
, disable
) ;
992 void nrf24_setRetries(uint8_t delay
, uint8_t count
)
994 write_register(SETUP_RETR
,(delay
&0xf)<<ARD
| (count
&0xf)<<ARC
);