Skip to content

Commit db95a2f

Browse files
committed
Merge branch 'zero-core' into zero-package
2 parents f4f9849 + ecb4c18 commit db95a2f

File tree

18 files changed

+188
-129
lines changed

18 files changed

+188
-129
lines changed

boards.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
arduino_zero_edbg.name=Arduino Zero (Programming Port)
22
arduino_zero_edbg.vid.0=0x03eb
3-
arduino_zero_edbg.pid.0=0x2111
3+
arduino_zero_edbg.pid.0=0x2157
44
arduino_zero_edbg.upload.tool=openocd
55
arduino_zero_edbg.upload.protocol=sam-ba
66
arduino_zero_edbg.upload.maximum_size=262144
@@ -19,13 +19,15 @@ arduino_zero_edbg.build.openocdscript=openocd_scripts/arduino_zero.cfg
1919
arduino_zero_edbg.build.variant=arduino_zero
2020
arduino_zero_edbg.build.variant_system_lib=
2121
arduino_zero_edbg.build.vid=0x2341
22-
arduino_zero_edbg.build.pid=0x004d
22+
arduino_zero_edbg.build.pid=0x804d
2323
arduino_zero_edbg.bootloader.tool=openocd
2424
arduino_zero_edbg.bootloader.file=zero/samd21_sam_ba.bin
2525

2626
arduino_zero_native.name=Arduino Zero (Native USB Port)
2727
arduino_zero_native.vid.0=0x2341
28-
arduino_zero_native.pid.0=0x004d
28+
arduino_zero_native.pid.0=0x804d
29+
arduino_zero_native.vid.1=0x2341
30+
arduino_zero_native.pid.1=0x004d
2931
arduino_zero_native.upload.tool=bossac
3032
arduino_zero_native.upload.protocol=sam-ba
3133
arduino_zero_native.upload.maximum_size=262144
@@ -44,4 +46,4 @@ arduino_zero_native.build.openocdscript=openocd_scripts/arduino_zero.cfg
4446
arduino_zero_native.build.variant=arduino_zero
4547
arduino_zero_native.build.variant_system_lib=
4648
arduino_zero_native.build.vid=0x2341
47-
arduino_zero_native.build.pid=0x004d
49+
arduino_zero_native.build.pid=0x804d

bootloaders/zero/drivers/cdc_enumerate.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ const char devDescriptor[] = {
5050
0x00, // bDeviceSubclass: CDC class sub code
5151
0x00, // bDeviceProtocol: CDC Device protocol
5252
0x40, // bMaxPacketSize0
53-
0xEB, // idVendorL
54-
0x03, //
55-
0x24, // idProductL
56-
0x61, //
53+
0x41, // idVendorL
54+
0x23, //
55+
0x4D, // idProductL
56+
0x00, //
5757
0x10, // bcdDeviceL
5858
0x01, //
5959
0x00, // iManufacturer // 0x01

bootloaders/zero/main.c

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -106,26 +106,22 @@ static void check_start_application(void)
106106
}
107107
else
108108
{
109-
switch (BOOT_DOUBLE_TAP_DATA) {
110-
case 0:
111-
/* First tap */
112-
BOOT_DOUBLE_TAP_DATA = DOUBLE_TAP_MAGIC;
113-
114-
for (uint32_t i=0; i<125000; i++) /* 500ms */
115-
/* force compiler to not optimize this... */
116-
__asm__ __volatile__("");
117-
118-
/* Timeout happened, continue boot... */
119-
BOOT_DOUBLE_TAP_DATA = 0;
120-
break;
121-
case DOUBLE_TAP_MAGIC:
109+
if (BOOT_DOUBLE_TAP_DATA == DOUBLE_TAP_MAGIC) {
122110
/* Second tap, stay in bootloader */
123111
BOOT_DOUBLE_TAP_DATA = 0;
124112
return;
125-
default:
126-
/* Fallback... reset counter and continue boot */
127-
BOOT_DOUBLE_TAP_DATA = 0;
128113
}
114+
115+
/* First tap */
116+
BOOT_DOUBLE_TAP_DATA = DOUBLE_TAP_MAGIC;
117+
118+
/* Wait 0.5sec to see if the user tap reset again */
119+
for (uint32_t i=0; i<125000; i++) /* 500ms */
120+
/* force compiler to not optimize this... */
121+
__asm__ __volatile__("");
122+
123+
/* Timeout happened, continue boot... */
124+
BOOT_DOUBLE_TAP_DATA = 0;
129125
}
130126
#endif
131127

bootloaders/zero/samd21_sam_ba.bin

-4 Bytes
Binary file not shown.

cores/arduino/SERCOM.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,9 @@ typedef enum
7979

8080
typedef enum
8181
{
82-
UART_TX_PAD_0 = 0x0ul, //Only for UART
83-
UART_TX_PAD_2 = 0x1ul, //Only for UART
84-
//UART_TX_PAD_1 = 0x0ul, //DON'T USE
85-
//UART_TX_PAD_3 = 0x1ul //DON'T USE
82+
UART_TX_PAD_0 = 0x0ul, // Only for UART
83+
UART_TX_PAD_2 = 0x1ul, // Only for UART
84+
UART_TX_RTS_CTS_PAD_0_2_3 = 0x2ul, // Only for UART with TX on PAD0, RTS on PAD2 and CTS on PAD3
8685
} SercomUartTXPad;
8786

8887
typedef enum

cores/arduino/Stream.cpp

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -254,59 +254,64 @@ String Stream::readStringUntil(char terminator)
254254
int Stream::findMulti( struct Stream::MultiTarget *targets, int tCount) {
255255
// any zero length target string automatically matches and would make
256256
// a mess of the rest of the algorithm.
257-
for (struct MultiTarget *t = targets; t < targets+tCount; ++t)
257+
for (struct MultiTarget *t = targets; t < targets+tCount; ++t) {
258258
if (t->len <= 0)
259259
return t - targets;
260+
}
260261

261-
while(1) {
262+
while (1) {
262263
int c = timedRead();
263264
if (c < 0)
264265
return -1;
265266

266267
for (struct MultiTarget *t = targets; t < targets+tCount; ++t) {
267268
// the simple case is if we match, deal with that first.
268-
if (c == t->str[t->index])
269-
if (++t->index == t->len)
270-
return t - targets;
271-
else
272-
continue;
269+
if (c == t->str[t->index]) {
270+
if (++t->index == t->len)
271+
return t - targets;
272+
else
273+
continue;
274+
}
273275

274276
// if not we need to walk back and see if we could have matched further
275277
// down the stream (ie '1112' doesn't match the first position in '11112'
276278
// but it will match the second position so we can't just reset the current
277279
// index to 0 when we find a mismatch.
278280
if (t->index == 0)
279-
continue;
281+
continue;
280282

281283
int origIndex = t->index;
282284
do {
283-
--t->index;
284-
// first check if current char works against the new current index
285-
if (c != t->str[t->index])
286-
continue;
287-
288-
// if it's the only char then we're good, nothing more to check
289-
if (t->index == 0) {
290-
t->index++;
291-
break;
292-
}
293-
294-
// otherwise we need to check the rest of the found string
295-
int diff = origIndex - t->index;
296-
int i;
297-
for (i = 0; i < t->index; ++i)
298-
if (t->str[i] != t->str[i + diff])
299-
break;
300-
// if we successfully got through the previous loop then our current
301-
// index is good.
302-
if (i == t->index) {
303-
t->index++;
304-
break;
305-
}
306-
// otherwise we just try the next index
285+
--t->index;
286+
// first check if current char works against the new current index
287+
if (c != t->str[t->index])
288+
continue;
289+
290+
// if it's the only char then we're good, nothing more to check
291+
if (t->index == 0) {
292+
t->index++;
293+
break;
294+
}
295+
296+
// otherwise we need to check the rest of the found string
297+
int diff = origIndex - t->index;
298+
size_t i;
299+
for (i = 0; i < t->index; ++i) {
300+
if (t->str[i] != t->str[i + diff])
301+
break;
302+
}
303+
304+
// if we successfully got through the previous loop then our current
305+
// index is good.
306+
if (i == t->index) {
307+
t->index++;
308+
break;
309+
}
310+
311+
// otherwise we just try the next index
307312
} while (t->index);
308313
}
309314
}
310315
// unreachable
311316
return -1;
312-
}
317+
}

cores/arduino/USB/USBCore.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
//==================================================================
3434

3535
#define USB_PID_DUE 0x003E
36-
#define USB_PID_ZERO 0x004D
36+
#define USB_PID_ZERO 0x804D
3737

3838
// USB Device
3939
#define USB_VID 0x2341 // arduino LLC vid

cores/arduino/Uart.cpp

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@
2020
#include "WVariant.h"
2121
#include "wiring_digital.h"
2222

23-
Uart::Uart(SERCOM *_s, uint8_t _pinRX, uint8_t _pinTX)
23+
Uart::Uart(SERCOM *_s, uint8_t _pinRX, uint8_t _pinTX, SercomRXPad _padRX, SercomUartTXPad _padTX)
2424
{
2525
sercom = _s;
2626
uc_pinRX = _pinRX;
2727
uc_pinTX = _pinTX;
28+
uc_padRX=_padRX ;
29+
uc_padTX=_padTX;
2830
}
2931

3032
void Uart::begin(unsigned long baudrate)
@@ -39,8 +41,7 @@ void Uart::begin(unsigned long baudrate, uint8_t config)
3941

4042
sercom->initUART(UART_INT_CLOCK, SAMPLE_RATE_x16, baudrate);
4143
sercom->initFrame(extractCharSize(config), LSB_FIRST, extractParity(config), extractNbStopBit(config));
42-
sercom->initPads(UART_TX_PAD_2, SERCOM_RX_PAD_3);
43-
44+
sercom->initPads(uc_padTX, uc_padRX);
4445

4546
sercom->enableUART();
4647
}
@@ -140,13 +141,3 @@ SercomParityMode Uart::extractParity(uint8_t config)
140141
return SERCOM_ODD_PARITY;
141142
}
142143
}
143-
144-
void SERCOM0_Handler()
145-
{
146-
Serial1.IrqHandler();
147-
}
148-
149-
void SERCOM5_Handler()
150-
{
151-
Serial.IrqHandler();
152-
}

cores/arduino/Uart.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,10 @@
2525

2626
#include <cstddef>
2727

28-
2928
class Uart : public HardwareSerial
3029
{
3130
public:
32-
Uart(SERCOM *_s, uint8_t _pinRX, uint8_t _pinTX);
31+
Uart(SERCOM *_s, uint8_t _pinRX, uint8_t _pinTX, SercomRXPad _padRX, SercomUartTXPad _padTX);
3332
void begin(unsigned long baudRate);
3433
void begin(unsigned long baudrate, uint8_t config);
3534
void end();
@@ -50,14 +49,12 @@ class Uart : public HardwareSerial
5049

5150
uint8_t uc_pinRX;
5251
uint8_t uc_pinTX;
52+
SercomRXPad uc_padRX;
53+
SercomUartTXPad uc_padTX;
5354

5455
SercomNumberStopBit extractNbStopBit(uint8_t config);
5556
SercomUartCharSize extractCharSize(uint8_t config);
5657
SercomParityMode extractParity(uint8_t config);
5758
};
5859

59-
extern Uart Serial;
60-
extern Uart Serial1;
61-
62-
6360
#endif

cores/arduino/WVariant.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ typedef enum _ETCChannel
6464
TCC2_CH1 = (2<<8)|(1),
6565
TC3_CH0 = (3<<8)|(0),
6666
TC3_CH1 = (3<<8)|(1),
67+
TC5_CH0 = (5<<8)|(0),
68+
TC5_CH1 = (5<<8)|(1),
69+
#if defined __SAMD21J18A__
70+
TC7_CH0 = (7<<8)|(0),
71+
TC7_CH1 = (7<<8)|(1)
72+
#endif // __SAMD21J18A__
6773
} ETCChannel ;
6874

6975
extern const void* g_apTCInstances[TCC_INST_NUM+TC_INST_NUM] ;
@@ -90,6 +96,12 @@ typedef enum _EPWMChannel
9096
PWM2_CH1=TCC2_CH1,
9197
PWM3_CH0=TC3_CH0,
9298
PWM3_CH1=TC3_CH1,
99+
PWM5_CH0=TC5_CH0,
100+
PWM5_CH1=TC5_CH1,
101+
#if defined __SAMD21J18A__
102+
PWM7_CH0=TC7_CH0,
103+
PWM7_CH1=TC7_CH1
104+
#endif // __SAMD21J18A__
93105
} EPWMChannel ;
94106

95107
typedef enum _EPortType

0 commit comments

Comments
 (0)