Skip to content

Commit a9e8366

Browse files
committed
Initial commit for SAMD compatability
1 parent 6540bcb commit a9e8366

File tree

5 files changed

+53
-18
lines changed

5 files changed

+53
-18
lines changed

boards.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,6 @@ mysensors_gw_native.build.variant=mysensors_gw
3838
mysensors_gw_native.build.variant_system_lib=
3939
mysensors_gw_native.build.vid=0x2341
4040
mysensors_gw_native.build.pid=0x804d
41+
mysensors_gw_native.build.arch=samd
4142
mysensors_gw_native.bootloader.tool=openocd
4243
mysensors_gw_native.bootloader.file=zero/samd21_sam_ba.bin

libraries/SPI/SPI.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void SPIClass::config(SPISettings settings)
6565
{
6666
_p_sercom->disableSPI();
6767

68-
_p_sercom->initSPI(SPI_PAD_2_SCK_3, SERCOM_RX_PAD_0, SPI_CHAR_SIZE_8_BITS, settings.bitOrder);
68+
_p_sercom->initSPI(SPI_PAD_0_SCK_1, SERCOM_RX_PAD_2, SPI_CHAR_SIZE_8_BITS, settings.bitOrder);
6969
_p_sercom->initSPIClock(settings.dataMode, settings.clockFreq);
7070

7171
_p_sercom->enableSPI();
@@ -197,4 +197,4 @@ void SPIClass::detachInterrupt() {
197197
// Should be disableInterrupt()
198198
}
199199

200-
SPIClass SPI( &sercom4, PIN_SPI_MISO, PIN_SPI_SCK, PIN_SPI_MOSI );
200+
SPIClass SPI( &sercom1, PIN_SPI_MISO, PIN_SPI_SCK, PIN_SPI_MOSI );

platform.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ recipe.size.regex=\.text\s+([0-9]+).*
109109
#
110110
# BOSSA
111111
#
112-
tools.bossac.path={runtime.tools.bossac-1.6-arduino.path}
112+
tools.bossac.path={runtime.tools.bossac-1.6.1-arduino.path}
113113
tools.bossac.cmd=bossac
114114
tools.bossac.cmd.windows=bossac.exe
115115

variants/mysensors_gw/variant.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
* +------------+------------------+--------+-----------------+--------------------------------------------------------------------------------------------------------
4444
* | 14 | A0 | PA02 | A0 | EIC/EXTINT[2] *ADC/AIN[0] DAC/VOUT PTC/Y[0]
4545
* | 15 | A1 | PB08 | A1 | EIC/EXTINT[8] *ADC/AIN[2] PTC/Y[14] SERCOM4/PAD[0] TC4/WO[0]
46+
* | 15 | A1 | PB08 | A1 | EIC/EXTINT[8] *ADC/AIN[2] PTC/Y[14] SERCOM4/PAD[0] TC4/WO[0]
4647
* | 16 | A2 | PB09 | A2 | EIC/EXTINT[9] *ADC/AIN[3] PTC/Y[15] SERCOM4/PAD[1] TC4/WO[1]
4748
* | 17 | A3 | PA04 | A3 | EIC/EXTINT[4] *ADC/AIN[4] AC/AIN[0] PTC/Y[2] SERCOM0/PAD[0] TCC0/WO[0]
4849
* | 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[]=
114115
// 0..13 - Digital pins
115116
// ----------------------
116117
// 0/1 - SERCOM/UART (Serial1)
117-
{ PORTA, 11, PIO_SERCOM, (PIN_ATTR_DIGITAL), No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_11 }, // RX: SERCOM0/PAD[3]
118+
{ PORTA, 8, PIO_SERCOM, (PIN_ATTR_DIGITAL), No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_11 }, // RX: SERCOM0/PAD[3]
118119
{ PORTA, 10, PIO_SERCOM, (PIN_ATTR_DIGITAL), No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_10 }, // TX: SERCOM0/PAD[2]
119120

120121
// 2..12
@@ -195,7 +196,12 @@ const PinDescription g_APinDescription[]=
195196
// ----------------------
196197
// 43 - Alternate use of A0 (DAC output)
197198
{ PORTA, 2, PIO_ANALOG, PIN_ATTR_ANALOG, DAC_Channel0, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_2 }, // DAC/VOUT
198-
} ;
199+
// 44 - LED_4 (yellow led)
200+
{ PORTB, 16, PIO_DIGITAL, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE },
201+
202+
// 45 - CE_NRF
203+
{ PORTA, 28, PIO_DIGITAL, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }
204+
};
199205

200206
const void* g_apTCInstances[TCC_INST_NUM+TC_INST_NUM]={ TCC0, TCC1, TCC2, TC3, TC4, TC5 } ;
201207

@@ -208,14 +214,15 @@ SERCOM sercom4( SERCOM4 ) ;
208214
SERCOM sercom5( SERCOM5 ) ;
209215

210216
Uart Serial1( &sercom0, PIN_SERIAL1_RX, PIN_SERIAL1_TX, PAD_SERIAL1_RX, PAD_SERIAL1_TX ) ;
211-
Uart Serial( &sercom5, PIN_SERIAL_RX, PIN_SERIAL_TX, PAD_SERIAL_RX, PAD_SERIAL_TX ) ;
217+
//Uart Serial( &sercom5, PIN_SERIAL_RX, PIN_SERIAL_TX, PAD_SERIAL_RX, PAD_SERIAL_TX ) ;
212218
void SERCOM0_Handler()
213219
{
214220
Serial1.IrqHandler();
215221
}
216-
222+
/*
217223
void SERCOM5_Handler()
218224
{
219225
Serial.IrqHandler();
220226
}
221227
228+
*/

variants/mysensors_gw/variant.h

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,18 @@ extern "C"
7676
#define digitalPinToInterrupt(P) ( g_APinDescription[P].ulExtInt )
7777

7878
// LEDs
79-
#define PIN_LED_13 (13u)
80-
#define PIN_LED_RXL (25u)
81-
#define PIN_LED_TXL (26u)
82-
#define PIN_LED PIN_LED_13
83-
#define PIN_LED2 PIN_LED_RXL
84-
#define PIN_LED3 PIN_LED_TXL
85-
#define LED_BUILTIN PIN_LED_13
79+
#define PIN_LED_13 (7u)
80+
#define PIN_LED_RXL (6u)
81+
#define PIN_LED_TXL (12u)
82+
#define PIN_LED LED_BLUE
83+
#define PIN_LED2 LED_RED
84+
#define PIN_LED4 LED_GREEN
85+
#define LED_BUILTIN LED_YELLOW
86+
87+
#define LED_BLUE (12u)
88+
#define LED_RED (6u)
89+
#define LED_GREEN (7u)
90+
#define LED_YELLOW (44u)
8691

8792
/*
8893
* Analog pins
@@ -126,9 +131,9 @@ static const uint8_t ATN = PIN_ATN;
126131
*/
127132
#define SPI_INTERFACES_COUNT 1
128133

129-
#define PIN_SPI_MISO (22u)
130-
#define PIN_SPI_MOSI (23u)
131-
#define PIN_SPI_SCK (24u)
134+
#define PIN_SPI_MISO (36u)
135+
#define PIN_SPI_MOSI (35u)
136+
#define PIN_SPI_SCK (37u)
132137

133138
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.
134139
static const uint8_t MOSI = PIN_SPI_MOSI ;
@@ -154,6 +159,28 @@ static const uint8_t SCK = PIN_SPI_SCK ;
154159
}
155160
#endif
156161

162+
163+
/*
164+
* MYSX pins
165+
*/
166+
167+
#define MYSX_D1_DFM
168+
#define MYSX_D2_DTM
169+
#define MYSX_D3_INT
170+
#define MYSX_D4_INT
171+
#define MYSX_D5_PWM
172+
#define MYSX_D6_PWM
173+
#define MYSX_D7_SCL
174+
#define MYSX_D8_SDA
175+
#define MYSX_D9_A3
176+
#define MYSX_D10_A4
177+
#define MYSX_D11_MOSI
178+
#define MYSX_D12_MISO
179+
#define MYSX_D13_SCK
180+
#define MYSX_D14_CS
181+
#define MYSX_A1
182+
#define MYSX_A2
183+
157184
/*----------------------------------------------------------------------------
158185
* Arduino objects - C++ only
159186
*----------------------------------------------------------------------------*/
@@ -171,7 +198,7 @@ extern SERCOM sercom3;
171198
extern SERCOM sercom4;
172199
extern SERCOM sercom5;
173200

174-
extern Uart Serial;
201+
//extern Uart Serial;
175202
extern Uart Serial1;
176203

177204
#endif

0 commit comments

Comments
 (0)