Added setDataRate()

This commit is contained in:
maniacbug 2011-05-26 20:48:30 -07:00
parent a6e7444059
commit 4131420de7
2 changed files with 19 additions and 0 deletions

View File

@ -608,5 +608,15 @@ boolean RF24::testCarrier(void)
return ( read_register(CD) & 1 ); return ( read_register(CD) & 1 );
} }
/******************************************************************/
void RF24::setDataRate(rf24_datarate_e speed)
{
uint8_t setup = read_register(RF_SETUP) & RF_DR;
if (speed == RF24_2MBPS)
setup |= RF_DR;
write_register(RF_SETUP,setup);
}
// vim:ai:cin:sts=2 sw=2 ft=cpp // vim:ai:cin:sts=2 sw=2 ft=cpp

9
RF24.h
View File

@ -11,6 +11,8 @@
#include <inttypes.h> #include <inttypes.h>
typedef enum { RF24_1MBPS = 0, RF24_2MBPS } rf24_datarate_e;
/** /**
* Driver for nRF24L01(+) 2.4GHz Wireless Transceiver * Driver for nRF24L01(+) 2.4GHz Wireless Transceiver
*/ */
@ -420,6 +422,13 @@ public:
*/ */
boolean testCarrier(void); boolean testCarrier(void);
/**
* Set the transmission data rate
*
* @param speed RF24_1MBPS for 1Mbps or RF24_2MBPS for 2Mbps
*/
void setDataRate(rf24_datarate_e speed);
/**@}*/ /**@}*/
}; };