From 4131420de79456be80e218523bf1c3c0ab36b2a1 Mon Sep 17 00:00:00 2001 From: maniacbug Date: Thu, 26 May 2011 20:48:30 -0700 Subject: [PATCH] Added setDataRate() --- RF24.cpp | 10 ++++++++++ RF24.h | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/RF24.cpp b/RF24.cpp index e0fe3c0..5f89db7 100644 --- a/RF24.cpp +++ b/RF24.cpp @@ -608,5 +608,15 @@ boolean RF24::testCarrier(void) 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 diff --git a/RF24.h b/RF24.h index 14cb59c..53f71ff 100644 --- a/RF24.h +++ b/RF24.h @@ -11,6 +11,8 @@ #include +typedef enum { RF24_1MBPS = 0, RF24_2MBPS } rf24_datarate_e; + /** * Driver for nRF24L01(+) 2.4GHz Wireless Transceiver */ @@ -420,6 +422,13 @@ public: */ 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); /**@}*/ };