From 2be762511e083ee95ab52c854c7a4ddef82b6845 Mon Sep 17 00:00:00 2001 From: Paul Brook Date: Wed, 16 Oct 2013 16:34:04 +0100 Subject: [PATCH] Fix power-on delay Increase power-on delay to that specified by the device datasheet Skip delay if device is already powered up Signed-off-by: Paul Brook --- RF24.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/RF24.cpp b/RF24.cpp index 9471583d..4a144edc 100644 --- a/RF24.cpp +++ b/RF24.cpp @@ -507,8 +507,10 @@ bool RF24::write( const void* buf, uint8_t len ) void RF24::startWrite( const void* buf, uint8_t len ) { // Transmitter power-up - write_register(CONFIG, ( read_register(CONFIG) | _BV(PWR_UP) ) & ~_BV(PRIM_RX) ); - delayMicroseconds(150); + uint8_t old_config = read_register(CONFIG); + write_register(CONFIG, ( old_config | _BV(PWR_UP) ) & ~_BV(PRIM_RX) ); + if ((old_config & _BV(PWR_UP)) == 0) + delayMicroseconds(1500); // Send the payload write_payload( buf, len );