Commit 4340d933 authored by TMRh20's avatar TMRh20

Lib now passes all tests

Added back original startWrite function for when users want to use
manual methods. The library uses startFastWrite for its internal
functions. Provides compatibility with prev. code while still using the
new methods for everything else.
parent f3b3fb1f
......@@ -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) );
}
......
......@@ -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 <a href="http://TMRh20.blogspot.com"> TMRh20.blogspot.com </a>
* @li <a href="https://github.com/maniacbug/RF24"> ManiacBug on GitHub (Original Library Author)</a>
*/
#endif // __RF24_H__
......
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