Skip to content

Commit

Permalink
Add changes to stopListening
Browse files Browse the repository at this point in the history
- Speed up Rx->Tx, adjust timing
  • Loading branch information
TMRh20 committed Nov 3, 2020
1 parent 9c94e5d commit a0cd707
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions RF24.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ void RF24::stopListening(void)
}
//flush_rx();
config_reg &= ~_BV(PRIM_RX);
write_register(NRF_CONFIG, (read_register(NRF_CONFIG)) & ~_BV(PRIM_RX));
write_register(NRF_CONFIG,config_reg);

#if defined(RF24_TINY) || defined(LITTLEWIRE)
// for 3 pins solution TX mode is only left with additonal powerDown/powerUp cycle
Expand Down Expand Up @@ -1440,7 +1440,7 @@ bool RF24::setDataRate(rf24_datarate_e speed)
setup &= ~(_BV(RF_DR_LOW) | _BV(RF_DR_HIGH));

#if !defined(F_CPU) || F_CPU > 20000000
txDelay = 250;
txDelay = 280;
#else //16Mhz Arduino
txDelay=85;
#endif
Expand All @@ -1449,7 +1449,7 @@ bool RF24::setDataRate(rf24_datarate_e speed)
// Making it '10'.
setup |= _BV(RF_DR_LOW);
#if !defined(F_CPU) || F_CPU > 20000000
txDelay = 450;
txDelay = 505;
#else //16Mhz Arduino
txDelay = 155;
#endif
Expand All @@ -1459,7 +1459,7 @@ bool RF24::setDataRate(rf24_datarate_e speed)
if (speed == RF24_2MBPS) {
setup |= _BV(RF_DR_HIGH);
#if !defined(F_CPU) || F_CPU > 20000000
txDelay = 190;
txDelay = 240;
#else // 16Mhz Arduino
txDelay = 65;
#endif
Expand Down

4 comments on commit a0cd707

@2bndy5
Copy link
Member

@2bndy5 2bndy5 commented on a0cd707 Nov 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TMRh20 are you calculating the txDelay based on the datasheet formulas or are they trial-n-error estimates? I ask because there is a consideration about the SPI baudrate on the receiving device in those formulas.

@TMRh20
Copy link
Member Author

@TMRh20 TMRh20 commented on a0cd707 Nov 9, 2020 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@2bndy5
Copy link
Member

@2bndy5 2bndy5 commented on a0cd707 Nov 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it ok if I remove this following comment from startListening():

    /* Notes Once ready for next release
     * 1. Can update stopListening() to use config_reg var and ack_payloads_enabled var instead of SPI rx/tx
     * 2. Update txDelay defaults: 240 for 2MBPS, 280 for 1MBPS, 505 for 250KBPS per initial testing
     * 3. Allows time for slower devices to update with the faster startListening() function prior to updating stopListening() & adjusting txDelay
     */

It seems as though this commit satisfies point 2. I've inadvertently addressed point 1 in #654 (please read issue description as it aims to improve the utility of writeAckPayload() before entering RX mode). I think point 3 is just a rationality of points 1 & 2.

BTW, I've rebased my master branch to include the changes from this commit during my testing of the new examples; all is well so far (streamingData & manualAcknowledgements are the last 2 that still need attention). 👍

@TMRh20
Copy link
Member Author

@TMRh20 TMRh20 commented on a0cd707 Nov 15, 2020 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.