txStandby() function modified completely

txStandBy() now either works in two modes. The main mode will block
until success or fail. Using txStandBy(1) will block and retry forever
until succesful. Using a while loop with the function is no longer
required. See the updated class reference at
http://tmrh20.github.io/RF24/class_r_f24.html
This commit is contained in:
TMRh20
2014-03-22 20:32:31 -06:00
parent 4340d9339a
commit 1cc7454d97
2 changed files with 57 additions and 42 deletions
+21 -9
View File
@@ -564,18 +564,30 @@ void RF24::startWrite( const void* buf, uint8_t len )
ce(LOW);
}
bool RF24::txStandBy(){
txStandBy(0);
}
if ( (read_register(FIFO_STATUS) & _BV(TX_EMPTY))){
ce(LOW);
return 1;
bool RF24::txStandBy(bool block){
while( ! (read_register(FIFO_STATUS) & _BV(TX_EMPTY)) ){
if( get_status() & _BV(MAX_RT)){
write_register(STATUS,_BV(MAX_RT) );
if(block){
ce(LOW); //Set re-transmit
ce(HIGH);
delayMicroseconds(15);
}else{
flush_tx(); //Non blocking, flush the data
ce(LOW); //Set STANDBY-I mode
return 0;
}
}
}
if( get_status() & _BV(MAX_RT)){
write_register(STATUS,_BV(MAX_RT) );
return 0;
}
return 0;
ce(LOW); //Set STANDBY-I mode
return 1;
}
/****************************************************************************/