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)
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);
#if defined (RF24_LINUX)
char extra_tab = strlen_P(name) < 8 ? '\t' : 0;
......@@ -642,12 +642,16 @@ bool RF24::begin(void)
//setPALevel( RF24_PA_MAX ) ;
// check for connected module and if this is a p nRF24l01 variant
//
setup = read_register(RF_SETUP);
if( setup == 0b00001110 ) // register default for nRF24L01P
//
if( setDataRate( RF24_250KBPS ) )
{
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
// hardware.
......
......@@ -90,13 +90,17 @@ protected:
*
*/
inline void beginTransaction() {
#if defined (RF24_SPI_TRANSACTIONS)
_SPI.beginTransaction(SPISettings(RF_SPI_SPEED, MSBFIRST, SPI_MODE0));
#endif
csn(LOW);
}
inline void endTransaction() {
csn(HIGH);
#if defined (RF24_SPI_TRANSACTIONS)
_SPI.endTransaction();
#endif
}
#endif /* ARDUINO */
......
......@@ -53,6 +53,10 @@
#include <Arduino.h>
#if ARDUINO > 10600
#define RF24_SPI_TRANSACTIONS
#endif
// RF modules support 10 Mhz SPI bus speed
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