Commit 1d180150 authored by TMRh20's avatar TMRh20

Modify write,startWrite, remove rx buffer flushes

Modified write() to use startFastWrite, then toggle CE after completion
to remove need for a delay on some boards.
Added delay to startWrite for non-Arduino boards.
Removed receive buffer flushes. This prevents an issue in the
RF24Network library, where payloads would be received, but flushed when
a transmission takes place prior to reading.
Should address issues #7 and #11
parent 2869663f
......@@ -517,7 +517,7 @@ void RF24::startListening(void)
}
// Flush buffers
flush_rx();
//flush_rx();
flush_tx();
// Go!
......@@ -535,7 +535,7 @@ void RF24::stopListening(void)
delayMicroseconds(130);
#endif
flush_tx();
flush_rx();
//flush_rx();
write_register(CONFIG, ( read_register(CONFIG) ) & ~_BV(PRIM_RX) );
delayMicroseconds(130); //Found that adding this delay back actually increases response time
......@@ -574,13 +574,15 @@ void RF24::powerUp(void)
bool RF24::write( const void* buf, uint8_t len, const bool multicast )
{
//Start Writing
startWrite(buf,len,multicast);
startFastWrite(buf,len,multicast);
//Wait until complete or failed
//ACK payloads that are handled improperly will cause this to hang
//If autoAck is ON, a payload has to be written prior to reading a payload, else write after reading a payload
while( ! ( get_status() & ( _BV(TX_DS) | _BV(MAX_RT) ))) { }
ce(LOW);
uint8_t status = write_register(STATUS,_BV(RX_DR) | _BV(TX_DS) | _BV(MAX_RT) );
//Max retries exceeded
......@@ -684,8 +686,10 @@ void RF24::startWrite( const void* buf, uint8_t len, const bool multicast ){
//write_payload( buf, len );
write_payload( buf, len,multicast? W_TX_PAYLOAD_NO_ACK : W_TX_PAYLOAD ) ;
ce(HIGH);
#if defined(CORE_TEENSY) || !defined(ARDUINO)
delayMicroseconds(10);
#endif
ce(LOW);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment