Added ethernet module to local hardware instance, since we have to hack it a bit in order to move it to alternative SPI port
Removed Wire and SAMD_AnalogCorrection libraries from HW section, as we didn't change anything in those, so let's keep it to the standard ones Modified SPI library, initializing extra SPI ports, also HW mux changes in the setup of individual SPI ports to match the GW setup Added MyHWSAMD files so they are included in the core headers (MyConfig.h / MySensors.h)
This commit is contained in:
@@ -269,6 +269,8 @@
|
||||
#ifndef MY_RF24_CE_PIN
|
||||
#if defined(ARDUINO_ARCH_ESP8266)
|
||||
#define MY_RF24_CE_PIN 4
|
||||
#elif defined(ARDUINO_ARCH_SAMD)
|
||||
#define MY_RF24_CE_PIN 27
|
||||
#else
|
||||
#define MY_RF24_CE_PIN 9
|
||||
#endif
|
||||
@@ -277,6 +279,8 @@
|
||||
#ifndef MY_RF24_CS_PIN
|
||||
#if defined(ARDUINO_ARCH_ESP8266)
|
||||
#define MY_RF24_CS_PIN 15
|
||||
#elif defined(ARDUINO_ARCH_SAMD)
|
||||
#define MY_RF24_CS_PIN 3
|
||||
#else
|
||||
#define MY_RF24_CS_PIN 10
|
||||
#endif
|
||||
|
||||
@@ -52,6 +52,8 @@
|
||||
#define MY_GATEWAY_ESP8266
|
||||
#elif defined(ARDUINO_ARCH_AVR)
|
||||
#include "core/MyHwATMega328.cpp"
|
||||
#elif defined(ARDUINO_ARCH_SAMD)
|
||||
#include "core/MyHwSAMD.cpp"
|
||||
#endif
|
||||
|
||||
// LEDS
|
||||
|
||||
@@ -40,34 +40,45 @@ ISR (WDT_vect)
|
||||
}
|
||||
*/
|
||||
|
||||
static void hwInitConfigBlock( size_t length = 1024)
|
||||
{
|
||||
static bool initDone = false;
|
||||
if (!initDone)
|
||||
{
|
||||
initDone = true;
|
||||
}
|
||||
|
||||
|
||||
void i2c_eeprom_write_byte(unsigned int eeaddress, byte data ) {
|
||||
int rdata = data;
|
||||
Wire.beginTransmission(I2C_EEP_ADDRESS);
|
||||
Wire.write((int)(eeaddress >> 8)); // MSB
|
||||
Wire.write((int)(eeaddress & 0xFF)); // LSB
|
||||
Wire.write(rdata);
|
||||
Wire.endTransmission();
|
||||
}
|
||||
|
||||
byte i2c_eeprom_read_byte(unsigned int eeaddress ) {
|
||||
byte rdata = 0xFF;
|
||||
Wire.beginTransmission(I2C_EEP_ADDRESS);
|
||||
Wire.write((int)(eeaddress >> 8)); // MSB
|
||||
Wire.write((int)(eeaddress & 0xFF)); // LSB
|
||||
Wire.endTransmission();
|
||||
Wire.requestFrom(I2C_EEP_ADDRESS,1);
|
||||
if (Wire.available()) rdata = Wire.read();
|
||||
return rdata;
|
||||
}
|
||||
|
||||
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++];
|
||||
*dst++ = i2c_eeprom_read_byte(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++;
|
||||
i2c_eeprom_write_byte(offs++, *src++);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "MyConfig.h"
|
||||
|
||||
#include "MyMessage.h"
|
||||
|
||||
#include <Wire.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <Arduino.h>
|
||||
@@ -31,6 +31,7 @@
|
||||
#endif
|
||||
|
||||
#include <avr/dtostrf.h>
|
||||
#define I2C_EEP_ADDRESS 55
|
||||
|
||||
#define min(a,b) ((a)<(b)?(a):(b))
|
||||
#define max(a,b) ((a)>(b)?(a):(b))
|
||||
@@ -59,6 +60,4 @@ uint8_t hwReadConfig(int adr);
|
||||
#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
|
||||
|
||||
Reference in New Issue
Block a user