Commit c79ccc70 authored by TMRh20's avatar TMRh20

Fix for SPI transaction code

- Fix for compatibility with SoftSPI and SPI_UART
- I seemed to be running two different versions, fixed for compatibility
between RPi and Arduino
parent a75fd1f4
......@@ -67,6 +67,24 @@ void RF24::ce(bool level)
if (ce_pin != csn_pin) digitalWrite(ce_pin,level);
}
/****************************************************************************/
inline void RF24::beginTransaction() {
#if defined (RF24_SPI_TRANSACTIONS)
_SPI.beginTransaction(SPISettings(RF_SPI_SPEED, MSBFIRST, SPI_MODE0));
#endif
csn(LOW);
}
/****************************************************************************/
inline void RF24::endTransaction() {
csn(HIGH);
#if defined (RF24_SPI_TRANSACTIONS)
_SPI.endTransaction();
#endif
}
/****************************************************************************/
uint8_t RF24::read_register(uint8_t reg, uint8_t* buf, uint8_t len)
......
......@@ -81,7 +81,6 @@ private:
uint32_t txRxDelay; /**< Var for adjusting delays depending on datarate */
#if defined (ARDUINO)
protected:
/**
* SPI transactions
......@@ -89,21 +88,9 @@ protected:
* Common code for SPI transactions including CSN toggle
*
*/
inline void beginTransaction() {
#if defined (SPI_HAS_TRANSACTION)
_SPI.beginTransaction(SPISettings(RF_SPI_SPEED, MSBFIRST, SPI_MODE0));
#endif
csn(LOW);
}
inline void beginTransaction();
inline void endTransaction() {
csn(HIGH);
#if defined (SPI_HAS_TRANSACTION)
_SPI.endTransaction();
#endif
}
#endif /* ARDUINO */
inline void endTransaction();
public:
......
......@@ -20,11 +20,15 @@
//#define MINIMAL
//#define SPI_UART // Requires library from https://github.com/TMRh20/Sketches/tree/master/SPI_UART
//#define SOFTSPI // Requires library from https://github.com/greiman/DigitalIO
/**********************/
#define rf24_max(a,b) (a>b?a:b)
#define rf24_min(a,b) (a<b?a:b)
#if defined SPI_HAS_TRANSACTION && !defined SPI_UART && !defined SOFTSPI
#define RF24_SPI_TRANSACTIONS
#endif
//Generic Linux/ARM and //http://iotdk.intel.com/docs/master/mraa/
#if ( defined (__linux) || defined (LINUX) ) && defined( __arm__ ) || defined(MRAA) // BeagleBone Black running GNU/Linux or any other ARM-based linux device
......
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