Added setRetries()

This commit is contained in:
maniacbug 2011-06-28 06:44:41 -07:00
parent 1c6cc96fb7
commit a22906f961
3 changed files with 23 additions and 1 deletions

View File

@ -631,5 +631,12 @@ void RF24::setCRCLength(rf24_crclength_e length)
write_register(CONFIG,config);
}
/******************************************************************/
void RF24::setRetries(uint8_t delay, uint8_t count)
{
write_register(SETUP_RETR,(delay&0xf)<<ARD | (count&0xf)<<ARC);
}
// vim:ai:cin:sts=2 sw=2 ft=cpp

9
RF24.h
View File

@ -332,6 +332,15 @@ public:
*/
/**@{*/
/**
* Set the number and delay of retries upon failed submit
*
* @param delay How long to wait between each retry, in multiples of 250us,
* max is 15. 0 means 250us, 15 means 4000us.
* @param count How many retries before giving up, max 15
*/
void setRetries(uint8_t delay, uint8_t count);
/**
* Set RF communication channel
*

View File

@ -90,6 +90,12 @@ void setup(void)
radio.begin();
// optionally, increase the delay between retries & # of retries
radio.setRetries(15,15);
// optionally, use a high channel to avoid WiFi chatter
radio.setChannel(110);
//
// Open pipes to other nodes for communication
//
@ -201,4 +207,4 @@ void loop(void)
}
}
}
// vim:ci sts=2 sw=2 ft=cpp
// vim:cin:ai:sts=2 sw=2 ft=cpp