Commit a57fafe0 authored by TMRh20's avatar TMRh20

Fixes for last commit

- SPI_HAS_TRANSACTION define was not being picked up properly: add
define to RF24_arch_config.h
- Fix beginTransaction call using RF_SPI_SPEED instead of RF24_SPI_SPEED
- Change beginTransaction to use SPISettings object
-
parent f285fde2
......@@ -67,7 +67,7 @@ void RF24::ce(bool level)
inline void RF24::beginTransaction() {
#if defined (RF24_SPI_TRANSACTIONS)
_SPI.beginTransaction(SPISettings(RF_SPI_SPEED, MSBFIRST, SPI_MODE0));
_SPI.beginTransaction(SPISettings(RF24_SPI_SPEED, MSBFIRST, SPI_MODE0));
#endif
csn(LOW);
}
......
......@@ -14,10 +14,10 @@
#include "bcm2835.h"
#include "spi.h"
#define _SPI spi
#define RF24_BIT_ORDER BCM2835_SPI_BIT_ORDER_MSBFIRST
#define RF24_DATA_MODE BCM2835_SPI_MODE0
#define RF24_SPI_SPEED BCM2835_SPI_SPEED_8MHZ
#if defined SPI_HAS_TRANSACTION && !defined SPI_UART && !defined SOFTSPI
#define RF24_SPI_TRANSACTIONS
#endif
// GCC a Arduino Missing
#define _BV(x) (1<<(x))
#define pgm_read_word(p) (*(p))
......
......@@ -16,12 +16,12 @@ void SPI::begin( int busNo ) {
bcm2835_spi_begin();
}
void SPI::beginTransaction(int clock_divider, uint8_t bitOrder, uint8_t mode) {
void SPI::beginTransaction(SPISettings settings){
pthread_mutex_lock (&spiMutex);
setBitOrder(bitOrder);
setDataMode(mode);
setClockDivider(clock_divider);
setBitOrder(settings.border);
setDataMode(settings.dmode);
setClockDivider(settings.clck);
}
void SPI::endTransaction() {
......
......@@ -15,6 +15,30 @@
#include "interrupt.h"
#define SPI_HAS_TRANSACTION
#define MSBFIRST BCM2835_SPI_BIT_ORDER_MSBFIRST
#define SPI_MODE0 BCM2835_SPI_MODE0
#define RF24_SPI_SPEED BCM2835_SPI_SPEED_8MHZ
class SPISettings {
public:
SPISettings(uint32_t clock, uint8_t bitOrder, uint8_t dataMode) {
init(clock,bitOrder,dataMode);
}
SPISettings() { init(RF24_SPI_SPEED, MSBFIRST, SPI_MODE0); }
uint32_t clck;
uint8_t border;
uint8_t dmode;
private:
void init(uint32_t clock, uint8_t bitOrder, uint8_t dataMode) {
clck = clock;
border = bitOrder;
dmode = dataMode;
}
friend class SPIClass;
};
class SPI {
public:
......@@ -34,8 +58,10 @@ public:
static void setClockDivider(uint16_t spi_speed);
static void chipSelect(int csn_pin);
static void beginTransaction(int clock_divider, uint8_t bitOrder, uint8_t mode);
void beginTransaction(SPISettings settings);
static void endTransaction();
};
......
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