-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Request] available() could be slightly faster #631
Comments
I forgot about this little note from the datasheet:
This would affect any program that calls This note from the datasheet also negates my suggestion to @SimonMerrett about using FALLING as mode parameter to |
I have decided that my above comment about not using |
* available() could be slightly faster #631 * allow skipping delay(5) in powerUp() * allow skipping delay(5) in powerUp() * Revert "allow skipping delay(5) in powerUp()" This reverts commit ffd7524. * Revert "allow skipping delay(5) in powerUp()" This reverts commit ffd7524. * add RF24_POWERUP_DELAY_MS to RF24_config.h * delayMicroseconds() * update doc comment
Rationality
The current implementation for
available()
is as follows:The nRF24L01's full duplex behavior gives us the status byte for free on every SPI transaction. This means we're fetching the status byte essentially twice. Once during
read_register(FIFO_STATUS)
, and once duringget_status()
. Remember that the status byte holds information about what pipe received the next available payload in the RX FIFO (thus the*pipe_num = (status >> RX_P_NO) & 0x07;
), andget_status()
need only write a single byte (SPI command0xFF
). According to the datasheet, RX_P_NO of the STATUS register will be a number greater than 5 if the RX FIFO is empty.Revision
By cutting out the extra SPI transaction for
read_register(FIFO_STATUS)
, we can maintain the same behavior and save ourselves 5 microseconds (csDelay
value) as well as the extra time spent on MOSI/MISO to complete checking the FIFO_STATUS register.Additional context
RX_P_0 information is consistent between plus and non-plus versions of nRF24L01 according to datasheets (link above goes to nRF24L01+ datasheet). Status byte received over MISO may get outdated until next SPI transaction when reading a payload from RX FIFO, thus using
get_status()
and why we can't use theRF24::status
private member.The text was updated successfully, but these errors were encountered: