Fork of nRF24L01P with autoretransmit implemented
Dependents: Saxion_nRF24L01P_Hello_World
Revision 1:44a9897db321, committed 2020-08-25
- Comitter:
- wkleunen
- Date:
- Tue Aug 25 10:17:55 2020 +0000
- Parent:
- 0:8ae48233b4e4
- Commit message:
- Auto retransmit fix
Changed in this revision
nRF24L01P.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 8ae48233b4e4 -r 44a9897db321 nRF24L01P.cpp --- a/nRF24L01P.cpp Wed Jan 19 22:59:48 2011 +0000 +++ b/nRF24L01P.cpp Tue Aug 25 10:17:55 2020 +0000 @@ -870,7 +870,7 @@ wait_us(_NRF24L01P_TIMING_Thce_us); disable(); - while ( !( getStatusRegister() & _NRF24L01P_STATUS_TX_DS ) ) { + while ( !( getStatusRegister() & _NRF24L01P_STATUS_TX_DS ) && !( getStatusRegister() & _NRF24L01P_STATUS_MAX_RT )) { // Wait for the transfer to complete @@ -1027,3 +1027,14 @@ return status; } + +void nRF24L01P::enableAutoRetransmit(int delay, int count) { + if(delay < 250 || delay > 4000) { + printf("Error: delay must be between 250 and 4000 ms"); + } else if(count < 0 || count > 16) { + printf("Error: retransmit count must be between 0 and 15"); + } else { + int setupTr = ((delay / 250) << 4) + count; + setRegister(_NRF24L01P_REG_SETUP_RETR, setupTr); + } +} \ No newline at end of file