Initial commit for SAMD compatability

This commit is contained in:
Thomas Mørch
2015-12-06 23:16:44 +01:00
parent 9540cb2b30
commit e229e21d0e
19 changed files with 319 additions and 67 deletions
+1 -1
View File
@@ -62,7 +62,7 @@ recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -m
recipe.S.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.S.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
## Create archives
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{build.path}/{archive_file}" "{object_file}"
#recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{build.path}/{archive_file}" "{object_file}"
## Combine gc-sections, archives, and objects
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} -mmcu={build.mcu} {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" {object_files} "{build.path}/{archive_file}" "-L{build.path}" -lm
+1
View File
@@ -38,5 +38,6 @@ mysensors_gw_native.build.variant=mysensors_gw
mysensors_gw_native.build.variant_system_lib=
mysensors_gw_native.build.vid=0x2341
mysensors_gw_native.build.pid=0x804d
mysensors_gw_native.build.arch=samd
mysensors_gw_native.bootloader.tool=openocd
mysensors_gw_native.bootloader.file=zero/samd21_sam_ba.bin
@@ -65,7 +65,7 @@ void SPIClass::config(SPISettings settings)
{
_p_sercom->disableSPI();
_p_sercom->initSPI(SPI_PAD_2_SCK_3, SERCOM_RX_PAD_0, SPI_CHAR_SIZE_8_BITS, settings.bitOrder);
_p_sercom->initSPI(SPI_PAD_0_SCK_1, SERCOM_RX_PAD_2, SPI_CHAR_SIZE_8_BITS, settings.bitOrder);
_p_sercom->initSPIClock(settings.dataMode, settings.clockFreq);
_p_sercom->enableSPI();
@@ -197,4 +197,4 @@ void SPIClass::detachInterrupt() {
// Should be disableInterrupt()
}
SPIClass SPI( &sercom4, PIN_SPI_MISO, PIN_SPI_SCK, PIN_SPI_MOSI );
SPIClass SPI( &sercom1, PIN_SPI_MISO, PIN_SPI_SCK, PIN_SPI_MOSI );
+1 -1
View File
@@ -109,7 +109,7 @@ recipe.size.regex=\.text\s+([0-9]+).*
#
# BOSSA
#
tools.bossac.path={runtime.tools.bossac-1.6-arduino.path}
tools.bossac.path={runtime.tools.bossac-1.6.1-arduino.path}
tools.bossac.cmd=bossac
tools.bossac.cmd.windows=bossac.exe
@@ -43,6 +43,7 @@
* +------------+------------------+--------+-----------------+--------------------------------------------------------------------------------------------------------
* | 14 | A0 | PA02 | A0 | EIC/EXTINT[2] *ADC/AIN[0] DAC/VOUT PTC/Y[0]
* | 15 | A1 | PB08 | A1 | EIC/EXTINT[8] *ADC/AIN[2] PTC/Y[14] SERCOM4/PAD[0] TC4/WO[0]
* | 15 | A1 | PB08 | A1 | EIC/EXTINT[8] *ADC/AIN[2] PTC/Y[14] SERCOM4/PAD[0] TC4/WO[0]
* | 16 | A2 | PB09 | A2 | EIC/EXTINT[9] *ADC/AIN[3] PTC/Y[15] SERCOM4/PAD[1] TC4/WO[1]
* | 17 | A3 | PA04 | A3 | EIC/EXTINT[4] *ADC/AIN[4] AC/AIN[0] PTC/Y[2] SERCOM0/PAD[0] TCC0/WO[0]
* | 18 | A4 | PA05 | A4 | EIC/EXTINT[5] *ADC/AIN[5] AC/AIN[1] PTC/Y[5] SERCOM0/PAD[1] TCC0/WO[1]
@@ -114,7 +115,7 @@ const PinDescription g_APinDescription[]=
// 0..13 - Digital pins
// ----------------------
// 0/1 - SERCOM/UART (Serial1)
{ PORTA, 11, PIO_SERCOM, (PIN_ATTR_DIGITAL), No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_11 }, // RX: SERCOM0/PAD[3]
{ PORTA, 8, PIO_SERCOM, (PIN_ATTR_DIGITAL), No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_11 }, // RX: SERCOM0/PAD[3]
{ PORTA, 10, PIO_SERCOM, (PIN_ATTR_DIGITAL), No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_10 }, // TX: SERCOM0/PAD[2]
// 2..12
@@ -195,7 +196,12 @@ const PinDescription g_APinDescription[]=
// ----------------------
// 43 - Alternate use of A0 (DAC output)
{ PORTA, 2, PIO_ANALOG, PIN_ATTR_ANALOG, DAC_Channel0, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_2 }, // DAC/VOUT
} ;
// 44 - LED_4 (yellow led)
{ PORTB, 16, PIO_DIGITAL, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE },
// 45 - CE_NRF
{ PORTA, 28, PIO_DIGITAL, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }
};
const void* g_apTCInstances[TCC_INST_NUM+TC_INST_NUM]={ TCC0, TCC1, TCC2, TC3, TC4, TC5 } ;
@@ -208,14 +214,15 @@ SERCOM sercom4( SERCOM4 ) ;
SERCOM sercom5( SERCOM5 ) ;
Uart Serial1( &sercom0, PIN_SERIAL1_RX, PIN_SERIAL1_TX, PAD_SERIAL1_RX, PAD_SERIAL1_TX ) ;
Uart Serial( &sercom5, PIN_SERIAL_RX, PIN_SERIAL_TX, PAD_SERIAL_RX, PAD_SERIAL_TX ) ;
//Uart Serial( &sercom5, PIN_SERIAL_RX, PIN_SERIAL_TX, PAD_SERIAL_RX, PAD_SERIAL_TX ) ;
void SERCOM0_Handler()
{
Serial1.IrqHandler();
}
/*
void SERCOM5_Handler()
{
Serial.IrqHandler();
}
*/
@@ -76,13 +76,18 @@ extern "C"
#define digitalPinToInterrupt(P) ( g_APinDescription[P].ulExtInt )
// LEDs
#define PIN_LED_13 (13u)
#define PIN_LED_RXL (25u)
#define PIN_LED_TXL (26u)
#define PIN_LED PIN_LED_13
#define PIN_LED2 PIN_LED_RXL
#define PIN_LED3 PIN_LED_TXL
#define LED_BUILTIN PIN_LED_13
#define PIN_LED_13 (7u)
#define PIN_LED_RXL (6u)
#define PIN_LED_TXL (12u)
#define PIN_LED LED_BLUE
#define PIN_LED2 LED_RED
#define PIN_LED4 LED_GREEN
#define LED_BUILTIN LED_YELLOW
#define LED_BLUE (12u)
#define LED_RED (6u)
#define LED_GREEN (7u)
#define LED_YELLOW (44u)
/*
* Analog pins
@@ -126,9 +131,9 @@ static const uint8_t ATN = PIN_ATN;
*/
#define SPI_INTERFACES_COUNT 1
#define PIN_SPI_MISO (22u)
#define PIN_SPI_MOSI (23u)
#define PIN_SPI_SCK (24u)
#define PIN_SPI_MISO (36u)
#define PIN_SPI_MOSI (35u)
#define PIN_SPI_SCK (37u)
static const uint8_t SS = PIN_A2 ; // SERCOM4 last PAD is present on A2 but HW SS isn't used. Set here only for reference.
static const uint8_t MOSI = PIN_SPI_MOSI ;
@@ -154,6 +159,28 @@ static const uint8_t SCK = PIN_SPI_SCK ;
}
#endif
/*
* MYSX pins
*/
#define MYSX_D1_DFM
#define MYSX_D2_DTM
#define MYSX_D3_INT
#define MYSX_D4_INT
#define MYSX_D5_PWM
#define MYSX_D6_PWM
#define MYSX_D7_SCL
#define MYSX_D8_SDA
#define MYSX_D9_A3
#define MYSX_D10_A4
#define MYSX_D11_MOSI
#define MYSX_D12_MISO
#define MYSX_D13_SCK
#define MYSX_D14_CS
#define MYSX_A1
#define MYSX_A2
/*----------------------------------------------------------------------------
* Arduino objects - C++ only
*----------------------------------------------------------------------------*/
@@ -171,7 +198,7 @@ extern SERCOM sercom3;
extern SERCOM sercom4;
extern SERCOM sercom5;
extern Uart Serial;
//extern Uart Serial;
extern Uart Serial1;
#endif
@@ -107,22 +107,22 @@ bool gatewayTransportInit() {
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
SERIALDEVICE.print(".");
yield();
}
Serial.print(F("IP: "));
Serial.println(WiFi.localIP());
SERIALDEVICE.print(F("IP: "));
SERIALDEVICE.println(WiFi.localIP());
#else
#ifdef MY_IP_ADDRESS
Ethernet.begin(_ethernetGatewayMAC, _ethernetGatewayIP);
Serial.print(F("IP: "));
Serial.println(Ethernet.localIP());
SERIALDEVICE.print(F("IP: "));
SERIALDEVICE.println(Ethernet.localIP());
#else
// Get IP address from DHCP
Ethernet.begin(_ethernetGatewayMAC);
Serial.print(F("IP: "));
Serial.println(Ethernet.localIP());
SERIALDEVICE.print(F("IP: "));
SERIALDEVICE.println(Ethernet.localIP());
#endif /* IP_ADDRESS_DHCP */
// give the Ethernet interface a second to initialize
// TODO: use HW delay
@@ -144,21 +144,21 @@ bool gatewayTransportInit() {
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
SERIALDEVICE.print(".");
yield();
}
Serial.print(F("IP: "));
Serial.println(WiFi.localIP());
SERIALDEVICE.print(F("IP: "));
SERIALDEVICE.println(WiFi.localIP());
#else
#ifdef MY_IP_ADDRESS
Ethernet.begin(_clientMAC, _clientIp);
Serial.print(F("IP: "));
Serial.println(Ethernet.localIP());
SERIALDEVICE.print(F("IP: "));
SERIALDEVICE.println(Ethernet.localIP());
#else
// Get IP address from DHCP
Ethernet.begin(_clientMAC);
Serial.print(F("IP: "));
Serial.println(Ethernet.localIP());
SERIALDEVICE.print(F("IP: "));
SERIALDEVICE.println(Ethernet.localIP());
#endif /* IP_ADDRESS_DHCP */
// give the Ethernet interface a second to initialize
// TODO: use HW delay
@@ -31,7 +31,7 @@ MyMessage _serialMsg;
bool gatewayTransportSend(MyMessage &message) {
Serial.print(protocolFormat(message));
SERIALDEVICE.print(protocolFormat(message));
// Serial print is always successful
return true;
}
@@ -45,9 +45,9 @@ bool gatewayTransportInit() {
bool gatewayTransportAvailable() {
bool available = false;
while (Serial.available()) {
while (SERIALDEVICE.available()) {
// get the new byte:
char inChar = (char) Serial.read();
char inChar = (char) SERIALDEVICE.read();
// if the incoming character is a newline, set a flag
// so the main loop can do something about it:
if (_serialInputPos < MY_GATEWAY_MAX_RECEIVE_LENGTH - 1 && !available) {
+1
View File
@@ -36,6 +36,7 @@
#include <Arduino.h>
#endif
#define SERIALDEVICE Serial
#if defined __AVR_ATmega328P__
#ifndef sleep_bod_disable
#define sleep_bod_disable() \
+1 -1
View File
@@ -30,7 +30,7 @@
//#include <SPI.h>
#endif
#define SERIALDEVICE Serial
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
+151
View File
@@ -0,0 +1,151 @@
/**
* The MySensors Arduino library handles the wireless radio link and protocol
* between your home built sensors/actuators and HA controller of choice.
* The sensors forms a self healing radio network with optional repeaters. Each
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
* network topology allowing messages to be routed to nodes.
*
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
* Copyright (C) 2013-2015 Sensnology AB
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
*
* Documentation: http://www.mysensors.org
* Support Forum: http://forum.mysensors.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*/
#include "MyHwSAMD.h"
/*
int8_t pinIntTrigger = 0;
void wakeUp() //place to send the interrupts
{
pinIntTrigger = 1;
}
void wakeUp2() //place to send the second interrupts
{
pinIntTrigger = 2;
}
// Watchdog Timer interrupt service routine. This routine is required
// to allow automatic WDIF and WDIE bit clearance in hardware.
ISR (WDT_vect)
{
// WDIE & WDIF is cleared in hardware upon entering this ISR
wdt_disable();
}
*/
static void hwInitConfigBlock( size_t length = 1024)
{
static bool initDone = false;
if (!initDone)
{
initDone = true;
}
}
void hwReadConfigBlock(void* buf, void* adr, size_t length)
{
hwInitConfigBlock();
uint8_t* dst = static_cast<uint8_t*>(buf);
int offs = reinterpret_cast<int>(adr);
while (length-- > 0)
{
*dst++ = configBlock[offs++];
}
}
void hwWriteConfigBlock(void* buf, void* adr, size_t length)
{
hwInitConfigBlock();
uint8_t* src = static_cast<uint8_t*>(buf);
int offs = reinterpret_cast<int>(adr);
while (length-- > 0)
{
configBlock[offs++] = *src++;
}
}
uint8_t hwReadConfig(int adr)
{
uint8_t value;
hwReadConfigBlock(&value, reinterpret_cast<void*>(adr), 1);
return value;
}
void hwWriteConfig(int adr, uint8_t value)
{
uint8_t curr = hwReadConfig(adr);
if (curr != value)
{
hwWriteConfigBlock(&value, reinterpret_cast<void*>(adr), 1);
}
}
void hwInit() {
SERIALDEVICE.begin(MY_BAUD_RATE);
while (!SERIALDEVICE) {}
}
void hwWatchdogReset() {
// TODO: Not supported!
}
void hwReboot() {
// TODO: Not supported!
}
void hwSleep(unsigned long ms) {
// TODO: Not supported!
ms = ms + 1;
}
bool hwSleep(uint8_t interrupt, uint8_t mode, unsigned long ms) {
// TODO: Not supported!
interrupt = interrupt;
mode = mode;
ms = ms;
return false;
}
uint8_t hwSleep(uint8_t interrupt1, uint8_t mode1, uint8_t interrupt2, uint8_t mode2, unsigned long ms) {
// TODO: Not supported!
interrupt1 = interrupt1;
mode1 = mode1;
interrupt2 = interrupt2;
mode2 = mode2;
ms = ms;
return 0;
}
#ifdef MY_DEBUG
void hwDebugPrint(const char *fmt, ... ) {
char fmtBuffer[300];
#ifdef MY_GATEWAY_FEATURE
// prepend debug message to be handled correctly by controller (C_INTERNAL, I_LOG_MESSAGE)
snprintf(fmtBuffer, 299, PSTR("0;0;%d;0;%d;"), C_INTERNAL, I_LOG_MESSAGE);
SERIALDEVICE.print(fmtBuffer);
#endif
va_list args;
va_start (args, fmt );
va_end (args);
#ifdef MY_GATEWAY_FEATURE
// Truncate message if this is gateway node
vsnprintf(fmtBuffer, 60, fmt, args);
fmtBuffer[59] = '\n';
fmtBuffer[60] = '\0';
#else
vsnprintf(fmtBuffer, 299, fmt, args);
#endif
va_end (args);
SERIALDEVICE.print(fmtBuffer);
// SERIALDEVICE.flush();
//Serial.write(freeRam());
}
#endif
+64
View File
@@ -0,0 +1,64 @@
/**
* The MySensors Arduino library handles the wireless radio link and protocol
* between your home built sensors/actuators and HA controller of choice.
* The sensors forms a self healing radio network with optional repeaters. Each
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
* network topology allowing messages to be routed to nodes.
*
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
* Copyright (C) 2013-2015 Sensnology AB
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
*
* Documentation: http://www.mysensors.org
* Support Forum: http://forum.mysensors.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*/
#ifndef MyHwSAMD_h
#define MyHwSAMD_h
#include "MyHw.h"
#include "MyConfig.h"
#include "MyMessage.h"
#ifdef __cplusplus
#include <Arduino.h>
//#include <SPI.h>
#endif
#include <avr/dtostrf.h>
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
// Define these as macros to save valuable space
uint8_t configBlock[1024];
#define hwDigitalWrite(__pin, __value) (digitalWrite(__pin, __value))
void hwInit();
void hwWatchdogReset();
void hwReboot();
#define hwMillis() millis()
void hwReadConfigBlock(void* buf, void* adr, size_t length);
void hwWriteConfigBlock(void* buf, void* adr, size_t length);
void hwWriteConfig(int adr, uint8_t value);
uint8_t hwReadConfig(int adr);
#define SERIALDEVICE SerialUSB
/*
#define hwReadConfigBlock(__buf, __adr, __length) ( __length = __length)
#define hwWriteConfigBlock(__buf, __adr, __length) ( __length = __length)
#define hwWriteConfig(__adr, __value) ( __value = __value)
#define hwReadConfig(__adr) (0)
*/
SPIClass _SPI( &sercom1, PIN_SPI_MISO, PIN_SPI_SCK, PIN_SPI_MOSI );
#define USBCON
#endif // #ifdef ARDUINO_ARCH_SAMD
+1 -1
View File
@@ -37,7 +37,7 @@ void inclusionModeSet(boolean newMode) {
if (newMode != _inclusionMode) {
_inclusionMode = newMode;
// Send back mode change to controller
gatewayTransportSend(buildGw(_msg, I_INCLUSION_MODE).set(_inclusionMode?1:0));
gatewayTransportSend(buildGw(_msg, I_INCLUSION_MODE).set((uint8_t)(_inclusionMode?1:0)));
if (_inclusionMode) {
_inclusionStartTime = hwMillis();
}
+2 -1
View File
@@ -3,7 +3,8 @@
int main(void) {
init();
#if defined(USBCON)
USBDevice.attach();
USBDevice.init();
USBDevice.attach();
#endif
_begin(); // Startup MySensors library
@@ -64,7 +64,7 @@ static void DEBUG_SIGNING_PRINTBUF(const __FlashStringHelper* str, uint8_t* buf,
#ifdef MY_GATEWAY_FEATURE
// prepend debug message to be handled correctly by controller (C_INTERNAL, I_LOG_MESSAGE)
snprintf_P(printBuffer, 299, PSTR("0;0;%d;0;%d;"), C_INTERNAL, I_LOG_MESSAGE);
Serial.print(printBuffer);
SERIALDEVICE.print(printBuffer);
#endif
for (int i=0; i<sz; i++)
{
@@ -76,12 +76,12 @@ static void DEBUG_SIGNING_PRINTBUF(const __FlashStringHelper* str, uint8_t* buf,
// Truncate message if this is gateway node
printBuffer[MY_GATEWAY_MAX_SEND_LENGTH-1-strlen_P((const char*)str)] = '\0';
#endif
Serial.print(str);
SERIALDEVICE.print(str);
if (sz > 0)
{
Serial.print(printBuffer);
SERIALDEVICE.print(printBuffer);
}
Serial.println("");
SERIALDEVICE.println("");
}
#else
#define DEBUG_SIGNING_PRINTBUF(str, buf, sz)
@@ -66,7 +66,7 @@ static void DEBUG_SIGNING_PRINTBUF(const __FlashStringHelper* str, uint8_t* buf,
#ifdef MY_GATEWAY_FEATURE
// prepend debug message to be handled correctly by controller (C_INTERNAL, I_LOG_MESSAGE)
snprintf_P(printBuffer, 299, PSTR("0;0;%d;0;%d;"), C_INTERNAL, I_LOG_MESSAGE);
Serial.print(printBuffer);
SERIALDEVICE.print(printBuffer);
#endif
for (int i=0; i<sz; i++)
{
@@ -78,12 +78,12 @@ static void DEBUG_SIGNING_PRINTBUF(const __FlashStringHelper* str, uint8_t* buf,
// Truncate message if this is gateway node
printBuffer[MY_GATEWAY_MAX_SEND_LENGTH-1-strlen_P((const char*)str)] = '\0';
#endif
Serial.print(str);
SERIALDEVICE.print(str);
if (sz > 0)
{
Serial.print(printBuffer);
SERIALDEVICE.print(printBuffer);
}
Serial.println("");
SERIALDEVICE.println("");
}
#else
#define DEBUG_SIGNING_PRINTBUF(str, buf, sz)
+12 -12
View File
@@ -51,7 +51,7 @@ void RF24::csn(bool mode)
delayMicroseconds(11); // allow csn to settle
}
}
#elif !defined (__arm__) || defined (CORE_TEENSY)
#elif !defined (__arm__) || defined (CORE_TEENSY) || defined(ARDUINO_ARCH_SAMD)
digitalWrite(csn_pin,mode);
#endif
@@ -71,7 +71,7 @@ uint8_t RF24::read_register(uint8_t reg, uint8_t* buf, uint8_t len)
{
uint8_t status;
#if defined (__arm__) && !defined ( CORE_TEENSY )
#if defined (__arm__) && !defined ( CORE_TEENSY ) && !defined (ARDUINO_ARCH_SAMD)
status = _SPI.transfer(csn_pin, R_REGISTER | ( REGISTER_MASK & reg ), SPI_CONTINUE );
while ( len-- > 1 ){
*buf++ = _SPI.transfer(csn_pin,0xff, SPI_CONTINUE);
@@ -96,7 +96,7 @@ uint8_t RF24::read_register(uint8_t reg, uint8_t* buf, uint8_t len)
uint8_t RF24::read_register(uint8_t reg)
{
#if defined (__arm__) && !defined ( CORE_TEENSY )
#if defined (__arm__) && !defined ( CORE_TEENSY ) && !defined (ARDUINO_ARCH_SAMD)
_SPI.transfer(csn_pin, R_REGISTER | ( REGISTER_MASK & reg ) , SPI_CONTINUE);
uint8_t result = _SPI.transfer(csn_pin,0xff);
#else
@@ -116,7 +116,7 @@ uint8_t RF24::write_register(uint8_t reg, const uint8_t* buf, uint8_t len)
{
uint8_t status;
#if defined (__arm__) && !defined ( CORE_TEENSY )
#if defined (__arm__) && !defined ( CORE_TEENSY ) && !defined (ARDUINO_ARCH_SAMD)
status = _SPI.transfer(csn_pin, W_REGISTER | ( REGISTER_MASK & reg ), SPI_CONTINUE );
while ( --len){
_SPI.transfer(csn_pin,*buf++, SPI_CONTINUE);
@@ -146,7 +146,7 @@ uint8_t RF24::write_register(uint8_t reg, uint8_t value)
Serial.print(F("write_register(")); print_hex(reg, true); Serial.print(F(",")); print_hex(value, true); Serial.println(F(")"));
#endif
#if defined (__arm__) && !defined ( CORE_TEENSY )
#if defined (__arm__) && !defined ( CORE_TEENSY ) && !defined (ARDUINO_ARCH_SAMD)
status = _SPI.transfer(csn_pin, W_REGISTER | ( REGISTER_MASK & reg ), SPI_CONTINUE);
_SPI.transfer(csn_pin,value);
#else
@@ -171,7 +171,7 @@ uint8_t RF24::write_payload(const void* buf, uint8_t data_len, const uint8_t wri
//printf("[Writing %u bytes %u blanks]",data_len,blank_len);
#if defined (__arm__) && !defined ( CORE_TEENSY )
#if defined (__arm__) && !defined ( CORE_TEENSY ) && !defined (ARDUINO_ARCH_SAMD)
status = _SPI.transfer(csn_pin, writeType , SPI_CONTINUE);
@@ -220,7 +220,7 @@ uint8_t RF24::read_payload(void* buf, uint8_t data_len)
//printf("[Reading %u bytes %u blanks]",data_len,blank_len);
#if defined (__arm__) && !defined ( CORE_TEENSY )
#if defined (__arm__) && !defined ( CORE_TEENSY ) && !defined (ARDUINO_ARCH_SAMD)
status = _SPI.transfer(csn_pin, R_RX_PAYLOAD, SPI_CONTINUE );
@@ -276,7 +276,7 @@ uint8_t RF24::flush_tx(void)
uint8_t RF24::spiTrans(uint8_t cmd){
uint8_t status;
#if defined (__arm__) && !defined ( CORE_TEENSY )
#if defined (__arm__) && !defined ( CORE_TEENSY ) && !defined (ARDUINO_ARCH_SAMD)
status = _SPI.transfer(csn_pin, cmd );
#else
@@ -481,7 +481,7 @@ void RF24::begin(void)
// Initialize pins
if (ce_pin != csn_pin) pinMode(ce_pin,OUTPUT);
#if defined(__arm__) && ! defined( CORE_TEENSY )
#if defined(__arm__) && ! defined( CORE_TEENSY ) && !defined (ARDUINO_ARCH_SAMD)
_SPI.begin(csn_pin); // Using the extended SPI features of the DUE
_SPI.setClockDivider(csn_pin, 9); // Set the bus speed to 8.4mhz on Due
_SPI.setBitOrder(csn_pin,MSBFIRST); // Set the bit order and mode specific to this device
@@ -888,7 +888,7 @@ uint8_t RF24::getDynamicPayloadSize(void)
{
uint8_t result = 0;
#if defined (__arm__) && ! defined( CORE_TEENSY )
#if defined (__arm__) && ! defined( CORE_TEENSY ) && !defined (ARDUINO_ARCH_SAMD)
_SPI.transfer(csn_pin, R_RX_PL_WID, SPI_CONTINUE );
result = _SPI.transfer(csn_pin,0xff);
#else
@@ -1079,7 +1079,7 @@ void RF24::closeReadingPipe( uint8_t pipe )
void RF24::toggle_features(void)
{
#if defined (__arm__) && ! defined( CORE_TEENSY )
#if defined (__arm__) && ! defined( CORE_TEENSY ) && !defined (ARDUINO_ARCH_SAMD)
_SPI.transfer(csn_pin, ACTIVATE, SPI_CONTINUE );
_SPI.transfer(csn_pin, 0x73 );
#else
@@ -1145,7 +1145,7 @@ void RF24::writeAckPayload(uint8_t pipe, const void* buf, uint8_t len)
uint8_t data_len = min(len,32);
#if defined (__arm__) && ! defined( CORE_TEENSY )
#if defined (__arm__) && ! defined( CORE_TEENSY ) && !defined (ARDUINO_ARCH_SAMD)
_SPI.transfer(csn_pin, W_ACK_PAYLOAD | ( pipe & B111 ), SPI_CONTINUE);
while ( data_len-- > 1 ){
_SPI.transfer(csn_pin,*current++, SPI_CONTINUE);
@@ -28,12 +28,11 @@
/**********************/
// Define _BV for non-Arduino platforms and for Arduino DUE
#if defined (ARDUINO) && !defined (__arm__)
#if defined (ARDUINO) && !defined (__arm__) && !defined(_SPI)
#if defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) || defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
#define RF24_TINY
#define _SPI SPI
#else
#if defined SPI_UART
#elif defined SPI_UART
#include <SPI_UART.h>
#define _SPI uspi
#elif defined MY_SOFTSPI
@@ -46,11 +45,12 @@
const uint8_t SPI_MODE = 0;
#define _SPI spi
#elif defined(ARDUINO_ARCH_SAMD)
#include <SPI.h>
#define _SPI SPI1
#else
#include <SPI.h>
#define _SPI SPI
#endif
#endif
#else
#include <stdint.h>
@@ -70,10 +70,10 @@
#else
#define printf Serial.printf
#endif
#if ! defined(_SPI)
#define _SPI SPI
#endif
#endif
// Avoid spurious warnings
// Arduino DUE is arm and uses traditional PROGMEM constructs
@@ -101,7 +101,7 @@
#endif
#endif
#if !defined ( CORE_TEENSY ) && ! defined(ESP8266)
#if !defined ( CORE_TEENSY ) && ! defined(ESP8266) && ! defined(ARDUINO_ARCH_SAMD)
typedef uint16_t prog_uint16_t;
#define PSTR(x) (x)
#define printf_P printf