diff --git a/RF24.cpp b/RF24.cpp
index 190e67d..ec6c448 100644
--- a/RF24.cpp
+++ b/RF24.cpp
@@ -448,7 +448,7 @@ void RF24::powerUp(void)
bool RF24::write( const void* buf, uint8_t len )
{
//Start Writing
- startWrite(buf,len);
+ startFastWrite(buf,len);
//Wait until complete or failed
//ACK payloads that are handled improperly will cause this to hang
@@ -487,7 +487,7 @@ bool RF24::writeBlocking( const void* buf, uint8_t len )
}
//Start Writing
- startWrite(buf,len);
+ startFastWrite(buf,len);
return 1;
}
@@ -525,7 +525,7 @@ bool RF24::writeFast( const void* buf, uint8_t len )
}
//Start Writing
- startWrite(buf,len);
+ startFastWrite(buf,len);
return 1;
}
@@ -539,7 +539,7 @@ bool RF24::writeFast( const void* buf, uint8_t len )
//Otherwise we enter Standby-II mode, which is still faster than standby mode
//Also, we remove the need to keep writing the config register over and over and delaying for 150 us each time if sending a stream of data
-void RF24::startWrite( const void* buf, uint8_t len ){ //TMRh20
+void RF24::startFastWrite( const void* buf, uint8_t len ){ //TMRh20
write_payload( buf,len);
ce(HIGH);
@@ -547,6 +547,24 @@ void RF24::startWrite( const void* buf, uint8_t len ){ //TMRh20
}
+//Added the original startWrite back in so users can still use interrupts, ack payloads, etc
+//Allows the library to pass all tests
+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);
+
+ // Send the payload
+ write_payload( buf, len );
+
+ // Allons!
+ ce(HIGH);
+ delayMicroseconds(15);
+ ce(LOW);
+}
+
+
bool RF24::txStandBy(){
if ( (read_register(FIFO_STATUS) & _BV(TX_EMPTY))){
@@ -613,7 +631,7 @@ void RF24::read( void* buf, uint8_t len ){
read_payload( buf, len );
//Clear the two possible interrupt flags with one command
- write_register(STATUS,_BV(RX_DR) | _BV(TX_DS) );
+ write_register(STATUS,_BV(RX_DR) | _BV(MAX_RT) | _BV(TX_DS) );
}
diff --git a/RF24.h b/RF24.h
index 7f242ea..840b26c 100644
--- a/RF24.h
+++ b/RF24.h
@@ -66,6 +66,22 @@ protected:
*/
/**@{*/
+ /**
+ * Non-blocking write to the open writing pipe used for buffered writes
+ *
+ * @note Optimization: This function now leaves the CE pin high, so the radio
+ * will remain in TX or STANDBY-II Mode until a txStandBy() command is issued.
+ * This allows the chip to be used to its full potential in TX mode.
+ *
+ * @see writeFast()
+ * @see writeBlocking()
+ *
+ * @param buf Pointer to the data to be sent
+ * @param len Number of bytes to be sent
+ * @return True if the payload was delivered successfully false if not
+ */
+ void startFastWrite( const void* buf, uint8_t len );
+
/**
* Set chip select pin
*
@@ -692,16 +708,16 @@ public:
* Just like write(), but it returns immediately. To find out what happened
* to the send, catch the IRQ and then call whatHappened().
*
- * @note Optimization: This function now leaves the CE pin high, so the radio
- * will remain in TX or STANDBY-II Mode until a txStandBy() command is issued.
- * This allows the chip to be used to its full potential in TX mode.
+ * @note Optimization: This function again behaves as it did previously.
+ * startFastWrite() has been moved to an internal function
*
* @see write()
+ * @see startFastWrite()
* @see whatHappened()
*
* @param buf Pointer to the data to be sent
* @param len Number of bytes to be sent
- * @return True if the payload was delivered successfully false if not
+ *
*/
void startWrite( const void* buf, uint8_t len );
@@ -934,6 +950,7 @@ public:
*
* @li Project blog:
* @li TMRh20.blogspot.com
+ * @li ManiacBug on GitHub (Original Library Author)
*/
#endif // __RF24_H__