From 9c94e5dc2cb051469ef42e40a7ab666243495fd9 Mon Sep 17 00:00:00 2001 From: Stephen Crane Date: Tue, 27 Oct 2020 18:48:28 +0000 Subject: [PATCH] available() could be slightly faster #631 (#650) --- RF24.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/RF24.cpp b/RF24.cpp index 09d0ea0a9..64def5001 100644 --- a/RF24.cpp +++ b/RF24.cpp @@ -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; } /****************************************************************************/