Skip to content

Commit

Permalink
available() could be slightly faster #631 (#650)
Browse files Browse the repository at this point in the history
  • Loading branch information
jscrane authored Oct 27, 2020
1 parent a3f9ace commit 9c94e5d
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions RF24.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1074,19 +1074,16 @@ bool RF24::available(void)

bool RF24::available(uint8_t* pipe_num)
{
if (!(read_register(FIFO_STATUS) & _BV(RX_EMPTY))) {

// If the caller wants the pipe number, include that
if (pipe_num) {
uint8_t status = get_status();
*pipe_num = (status >> RX_P_NO) & 0x07;
}
return 1;
}

return 0;
// get implied RX FIFO empty flag from status byte
uint8_t pipe = (get_status() >> RX_P_NO) & 0x07;
if (pipe > 5)
return 0;

// If the caller wants the pipe number, include that
if (pipe_num)
*pipe_num = pipe;

return 1;
}

/****************************************************************************/
Expand Down

0 comments on commit 9c94e5d

Please sign in to comment.