Skip to content

Commit

Permalink
fix #913
Browse files Browse the repository at this point in the history
Essentially, this reverts the algorithm used to satisfy #650 as it has proved erroneous on fast MCUs.
  • Loading branch information
2bndy5 committed Aug 14, 2023
1 parent a028813 commit 6db47d6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
17 changes: 8 additions & 9 deletions RF24.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1521,24 +1521,23 @@ uint8_t RF24::getDynamicPayloadSize(void)

bool RF24::available(void)
{
uint8_t pipe = 0;
uint8_t pipe = RF24_NO_FETCH_PIPE;
return available(&pipe);
}

/****************************************************************************/

bool RF24::available(uint8_t* pipe_num)
{
// get implied RX FIFO empty flag from status byte
uint8_t pipe = (get_status() >> RX_P_NO) & 0x07;
if (pipe > 5)
return 0;
if (!isFifo(false, true)) { // if RX FIFO is not empty
// If the caller wants the pipe number, include that
if (*pipe_num != RF24_NO_FETCH_PIPE)
*pipe_num = (get_status() >> RX_P_NO) & 0x07;

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

return 1;
return 0;
}

/****************************************************************************/
Expand Down
3 changes: 3 additions & 0 deletions RF24_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
#define RF24_SPI_SPEED 10000000
#endif

/// A sentinel used to control fetching the pipe info in `RF24::available()`.
#define RF24_NO_FETCH_PIPE 0XFF

//ATXMega
#if defined(__AVR_ATxmega64D3__) || defined(__AVR_ATxmega128D3__) || defined(__AVR_ATxmega192D3__) || defined(__AVR_ATxmega256D3__) || defined(__AVR_ATxmega384D3__)
// In order to be available both in Windows and Linux this should take presence here.
Expand Down

0 comments on commit 6db47d6

Please sign in to comment.