Added RBL nRF51822 Support

Added support for the nRF51822 Board by RedBearLab.
This commit is contained in:
Matt Sieren 2014-11-21 22:58:54 +01:00
parent eb424a07ac
commit 3646c650b6

View file

@ -27,6 +27,9 @@ e-mail : support@circuitsathome.com
#include <sys/types.h>
#endif
#if defined(RBL_NRF51822)
#include "SPI.H"
#endif
/* SPI initialization */
template< typename SPI_CLK, typename SPI_MOSI, typename SPI_MISO, typename SPI_SS > class SPi {
public:
@ -46,6 +49,13 @@ public:
SPI.begin();
SPI.setClockDivider(4); // Set speed to 84MHz/4=21MHz - the MAX3421E can handle up to 26MHz
}
#elif defined(RBL_NRF51822)
static void init() {
SPI_SS::SetDirWrite();
SPI_SS::Set();
SPI.begin();
// SPI.setFrequency(SPI_FREQUENCY_8M);
}
#else
static void init() {
//uint8_t tmp;
@ -74,6 +84,8 @@ typedef SPi< Pb7, Pb5, Pb6, Pb4 > spi;
typedef SPi< P13, P11, P12, P10 > spi;
#elif defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)
typedef SPi< P76, P75, P74, P10 > spi;
#elif defined(RBL_NRF51822)
typedef SPi< P16, P18, P17, P10 > spi;
#else
#error "No SPI entry in usbhost.h"
#endif
@ -135,7 +147,7 @@ void MAX3421e< SPI_SS, INTR >::regWr(uint8_t reg, uint8_t data) {
c[0] = reg | 0x02;
c[1] = data;
spi4teensy3::send(c, 2);
#elif defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)
#elif (defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)) || defined(RBL_NRF51822)
SPI.transfer(reg | 0x02);
SPI.transfer(data);
#else
@ -159,7 +171,7 @@ uint8_t* MAX3421e< SPI_SS, INTR >::bytesWr(uint8_t reg, uint8_t nbytes, uint8_t*
spi4teensy3::send(reg | 0x02);
spi4teensy3::send(data_p, nbytes);
data_p += nbytes;
#elif defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)
#elif (defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)) || defined(RBL_NRF51822)
SPI.transfer(reg | 0x02);
while(nbytes) {
SPI.transfer(*data_p);
@ -201,7 +213,7 @@ uint8_t MAX3421e< SPI_SS, INTR >::regRd(uint8_t reg) {
spi4teensy3::send(reg);
uint8_t rv = spi4teensy3::receive();
SPI_SS::Set();
#elif defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)
#elif (defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)) || defined(RBL_NRF51822)
SPI.transfer(reg);
uint8_t rv = SPI.transfer(0);
SPI_SS::Set();
@ -227,7 +239,7 @@ uint8_t* MAX3421e< SPI_SS, INTR >::bytesRd(uint8_t reg, uint8_t nbytes, uint8_t*
spi4teensy3::send(reg);
spi4teensy3::receive(data_p, nbytes);
data_p += nbytes;
#elif defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)
#elif (defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)) || defined(RBL_NRF51822)
SPI.transfer(reg);
while(nbytes) {
*data_p++ = SPI.transfer(0);