Commit b1b8cadd authored by TMRh20's avatar TMRh20

Add SPI transaction code from Ralph Doncaster

- Temporarily comment changes to begin() pending further testing/dev
- Maintain backwards compatibility by detecting Arduino IDE version
parent 3cc10bb6
...@@ -367,7 +367,7 @@ void RF24::print_observe_tx(uint8_t value) ...@@ -367,7 +367,7 @@ void RF24::print_observe_tx(uint8_t value)
void RF24::print_byte_register(const char* name, uint8_t reg, uint8_t qty) void RF24::print_byte_register(const char* name, uint8_t reg, uint8_t qty)
{ {
//char extra_tab = strlen_P(name) < 8 ? '\t' : '\a'; //char extra_tab = strlen_P(name) < 8 ? '\t' : 0;
//printf_P(PSTR(PRIPSTR"\t%c ="),name,extra_tab); //printf_P(PSTR(PRIPSTR"\t%c ="),name,extra_tab);
#if defined (RF24_LINUX) #if defined (RF24_LINUX)
char extra_tab = strlen_P(name) < 8 ? '\t' : 0; char extra_tab = strlen_P(name) < 8 ? '\t' : 0;
...@@ -643,11 +643,15 @@ bool RF24::begin(void) ...@@ -643,11 +643,15 @@ bool RF24::begin(void)
// check for connected module and if this is a p nRF24l01 variant // check for connected module and if this is a p nRF24l01 variant
// //
setup = read_register(RF_SETUP); if( setDataRate( RF24_250KBPS ) )
if( setup == 0b00001110 ) // register default for nRF24L01P
{ {
p_variant = true ; p_variant = true ;
} }
/*setup = read_register(RF_SETUP);
if( setup == 0b00001110 ) // register default for nRF24L01P
{
p_variant = true ;
}*/
// Then set the data rate to the slowest (and most reliable) speed supported by all // Then set the data rate to the slowest (and most reliable) speed supported by all
// hardware. // hardware.
......
...@@ -90,13 +90,17 @@ protected: ...@@ -90,13 +90,17 @@ protected:
* *
*/ */
inline void beginTransaction() { inline void beginTransaction() {
#if defined (RF24_SPI_TRANSACTIONS)
_SPI.beginTransaction(SPISettings(RF_SPI_SPEED, MSBFIRST, SPI_MODE0)); _SPI.beginTransaction(SPISettings(RF_SPI_SPEED, MSBFIRST, SPI_MODE0));
#endif
csn(LOW); csn(LOW);
} }
inline void endTransaction() { inline void endTransaction() {
csn(HIGH); csn(HIGH);
#if defined (RF24_SPI_TRANSACTIONS)
_SPI.endTransaction(); _SPI.endTransaction();
#endif
} }
#endif /* ARDUINO */ #endif /* ARDUINO */
......
...@@ -53,6 +53,10 @@ ...@@ -53,6 +53,10 @@
#include <Arduino.h> #include <Arduino.h>
#if ARDUINO > 10600
#define RF24_SPI_TRANSACTIONS
#endif
// RF modules support 10 Mhz SPI bus speed // RF modules support 10 Mhz SPI bus speed
const uint32_t RF_SPI_SPEED = 10000000; const uint32_t RF_SPI_SPEED = 10000000;
......
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