Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 13 additions & 14 deletions RF24.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,26 +549,13 @@ bool RF24::available(uint8_t* pipe_num)
// Too noisy, enable if you really want lots o data!!
//IF_SERIAL_DEBUG(print_status(status));

bool result = ( status & _BV(RX_DR) );
bool result = !(read_register(FIFO_STATUS) & _BV(RX_EMPTY));

if (result)
{
// If the caller wants the pipe number, include that
if ( pipe_num )
*pipe_num = ( status >> RX_P_NO ) & B111;

// Clear the status bit

// ??? Should this REALLY be cleared now? Or wait until we
// actually READ the payload?

write_register(STATUS,_BV(RX_DR) );

// Handle ack payload receipt
if ( status & _BV(TX_DS) )
{
write_register(STATUS,_BV(TX_DS));
}
}

return result;
Expand All @@ -578,9 +565,21 @@ bool RF24::available(uint8_t* pipe_num)

bool RF24::read( void* buf, uint8_t len )
{
uint8_t status = get_status();

// Fetch the payload
read_payload( buf, len );

// Clear the status bit

write_register(STATUS,_BV(RX_DR));

// Handle ack payload receipt
if ( status & _BV(TX_DS) )
{
write_register(STATUS,_BV(TX_DS));
}

// was this the last of the data available?
return read_register(FIFO_STATUS) & _BV(RX_EMPTY);
}
Expand Down