Skip to content

Commit 402a502

Browse files
committed
Conflicts: boards.txt platform.txt variants/arduino_zero/variant.h
2 parents 83834c3 + e7bd6f4 commit 402a502

File tree

22 files changed

+1026
-51
lines changed

22 files changed

+1026
-51
lines changed

CHANGELOG

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
1-
SAMD CORE 1.6.5
1+
SAMD CORE 1.6.6
22

3+
* Fixed digitalPinToInterrupt() macro, now it works as documented.
4+
* Added analogInputToDigitalPin macro
5+
* Fixed NUM_DIGITAL_PINS for Zero Board.
6+
* On-board RX-TX LEDs now blinks when there is activity on the native USB port
7+
* Fixed platform.txt, the core now compiles again with Arduino IDE <=1.6.5. Thanks @per1234
8+
* Fixed Wire.write(0x00) "ambiguos method" error
9+
* String class now supports iterators. Thanks @Chris--A
10+
* Remove enabling bootloader protection when burning bootloader. This enables WDT, so sketches do not work.
11+
12+
SAMD CORE 1.6.5 2016.04.02
13+
14+
* Added Arduino/Genuino MKR1000 board
315
* Set NVMCTRL.MANW bit to 1 (default is 0). This prevents accidental writes on program memory.
416
* Bootloader: Fixed wrong UART speed (regression)
17+
* Fixed incorrect return value from Wire.available() when the receive buffer is not fully read.
18+
* Added DAC0 definition in Arduino/Genuino Zero variant file.
19+
* Enabled bootloader protection after "Burn bootloader".
520

621
SAMD CORE 1.6.4 2016.02.19
722

VARIANT_COMPLIANCE_CHANGELOG

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
SAMD CORE 1.6.6
2+
3+
* digitalPinToInterrupt #define moved to Arduino.h, variant.h must no longer define it
4+
5+
SAMD CORE 1.6.3
6+
7+
* Timer for pin PWM selected based on value of PIN_ATTR_TIMER_ALT or PIN_ATTR_TIMER,
8+
prior to this "pin type" (ulPinType) was used

boards.txt

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -42,30 +42,29 @@ adafruit_feather_m0.build.pid=0x800B
4242
adafruit_feather_m0.bootloader.tool=openocd
4343
adafruit_feather_m0.bootloader.file=feather/samd21_sam_ba.bin
4444

45-
46-
adafruit_metro_m0.name=Adafruit Metro M0 (Native USB Port)
47-
adafruit_metro_m0.vid.0=0x239A
48-
adafruit_metro_m0.pid.0=0x8013
49-
adafruit_metro_m0.vid.1=0x239A
50-
adafruit_metro_m0.pid.1=0x0013
51-
adafruit_metro_m0.upload.tool=bossac
52-
adafruit_metro_m0.upload.protocol=sam-ba
53-
adafruit_metro_m0.upload.maximum_size=262144
54-
adafruit_metro_m0.upload.use_1200bps_touch=true
55-
adafruit_metro_m0.upload.wait_for_upload_port=true
56-
adafruit_metro_m0.upload.native_usb=true
57-
adafruit_metro_m0.build.mcu=cortex-m0plus
58-
adafruit_metro_m0.build.f_cpu=48000000L
59-
adafruit_metro_m0.build.usb_product="Metro M0"
60-
adafruit_metro_m0.build.usb_manufacturer="Adafruit"
61-
adafruit_metro_m0.build.board=SAMD_ZERO
62-
adafruit_metro_m0.build.core=arduino
63-
adafruit_metro_m0.build.extra_flags=-D__SAMD21G18A__ {build.usb_flags}
64-
adafruit_metro_m0.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld
65-
adafruit_metro_m0.build.openocdscript=openocd_scripts/arduino_zero.cfg
66-
adafruit_metro_m0.build.variant=arduino_zero
67-
adafruit_metro_m0.build.variant_system_lib=
68-
adafruit_metro_m0.build.vid=0x239A
69-
adafruit_metro_m0.build.pid=0x8013
70-
adafruit_metro_m0.bootloader.tool=openocd
71-
adafruit_metro_m0.bootloader.file=metro/samd21_sam_ba.bin
45+
#adafruit_metro_m0.name=Adafruit Metro M0 (Native USB Port)
46+
#adafruit_metro_m0.vid.0=0x239A
47+
#adafruit_metro_m0.pid.0=0x8013
48+
#adafruit_metro_m0.vid.1=0x239A
49+
#adafruit_metro_m0.pid.1=0x0013
50+
#adafruit_metro_m0.upload.tool=bossac
51+
#adafruit_metro_m0.upload.protocol=sam-ba
52+
#adafruit_metro_m0.upload.maximum_size=262144
53+
#adafruit_metro_m0.upload.use_1200bps_touch=true
54+
#adafruit_metro_m0.upload.wait_for_upload_port=true
55+
#adafruit_metro_m0.upload.native_usb=true
56+
#adafruit_metro_m0.build.mcu=cortex-m0plus
57+
#adafruit_metro_m0.build.f_cpu=48000000L
58+
#adafruit_metro_m0.build.usb_product="Metro M0"
59+
#adafruit_metro_m0.build.usb_manufacturer="Adafruit"
60+
#adafruit_metro_m0.build.board=SAMD_ZERO
61+
#adafruit_metro_m0.build.core=arduino
62+
#adafruit_metro_m0.build.extra_flags=-D__SAMD21G18A__ {build.usb_flags}
63+
#adafruit_metro_m0.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld
64+
#adafruit_metro_m0.build.openocdscript=openocd_scripts/arduino_zero.cfg
65+
#adafruit_metro_m0.build.variant=arduino_zero
66+
#adafruit_metro_m0.build.variant_system_lib=
67+
#adafruit_metro_m0.build.vid=0x239A
68+
#adafruit_metro_m0.build.pid=0x8013
69+
#adafruit_metro_m0.bootloader.tool=openocd
70+
#adafruit_metro_m0.bootloader.file=metro/samd21_sam_ba.bin

bootloaders/zero/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ Multi-plaform GCC is provided by ARM here: https://launchpad.net/gcc-arm-embedde
99

1010
Atmel Studio contains both make and ARM GCC toolchain. You don't need to install them in this specific use case.
1111

12+
For all builds and platforms you will need to have the Arduino IDE installed and the board support
13+
package for "Arduino SAMD Boards (32-bits ARM Cortex-M0+)". You can install the latter
14+
from the former's "Boards Manager" UI.
15+
1216
### Windows
1317

1418
* Native command line

bootloaders/zero/samd21_sam_ba.bin

100644100755
0 Bytes
Binary file not shown.

cores/arduino/Arduino.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ void loop( void ) ;
114114

115115
#define bit(b) (1UL << (b))
116116

117+
#if (ARDUINO_SAMD_VARIANT_COMPLIANCE >= 10606)
118+
// Interrupts
119+
#define digitalPinToInterrupt(P) ( P )
120+
#endif
121+
117122
// USB Device
118123
#include "USB/USBDesc.h"
119124
#include "USB/USBCore.h"

cores/arduino/USB/USBCore.cpp

Lines changed: 50 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@
2828

2929
USBDevice_SAMD21G18x usbd;
3030

31+
/** Pulse generation counters to keep track of the number of milliseconds remaining for each pulse type */
32+
#define TX_RX_LED_PULSE_MS 100
33+
#ifdef PIN_LED_TXL
34+
static volatile uint8_t txLEDPulse; /**< Milliseconds remaining for data Tx LED pulse */
35+
#endif
36+
#ifdef PIN_LED_RXL
37+
static volatile uint8_t rxLEDPulse; /**< Milliseconds remaining for data Rx LED pulse */
38+
#endif
3139
static char isRemoteWakeUpEnabled = 0;
3240
static char isEndpointHalt = 0;
3341

@@ -90,18 +98,18 @@ bool USBDeviceClass::sendStringDescriptor(const uint8_t *string, uint8_t maxlen)
9098
if (maxlen < 2)
9199
return false;
92100

93-
uint16_t buff[maxlen/2];
94-
int l = 1;
101+
uint8_t buffer[maxlen];
102+
buffer[0] = strlen((const char*)string) * 2 + 2;
103+
buffer[1] = 0x03;
95104

96-
maxlen -= 2;
97-
while (*string && maxlen>0)
98-
{
99-
buff[l++] = (uint8_t)(*string++);
100-
maxlen -= 2;
105+
uint8_t i;
106+
for (i = 2; i < maxlen && *string; i++) {
107+
buffer[i++] = *string++;
108+
if (i == maxlen) break;
109+
buffer[i] = 0;
101110
}
102-
buff[0] = (3<<8) | (l*2);
103111

104-
return USBDevice.sendControl((uint8_t*)buff, l*2);
112+
return USBDevice.sendControl(buffer, i);
105113
}
106114

107115
bool _dry_run = false;
@@ -273,6 +281,18 @@ void USBDeviceClass::handleEndpoint(uint8_t ep)
273281

274282
void USBDeviceClass::init()
275283
{
284+
#ifdef PIN_LED_TXL
285+
txLEDPulse = 0;
286+
pinMode(PIN_LED_TXL, OUTPUT);
287+
digitalWrite(PIN_LED_TXL, HIGH);
288+
#endif
289+
290+
#ifdef PIN_LED_RXL
291+
rxLEDPulse = 0;
292+
pinMode(PIN_LED_RXL, OUTPUT);
293+
digitalWrite(PIN_LED_RXL, HIGH);
294+
#endif
295+
276296
// Enable USB clock
277297
PM->APBBMASK.reg |= PM_APBBMASK_USB;
278298

@@ -522,6 +542,11 @@ uint32_t USBDeviceClass::recv(uint32_t ep, void *_data, uint32_t len)
522542
if (available(ep) < len)
523543
len = available(ep);
524544

545+
#ifdef PIN_LED_RXL
546+
digitalWrite(PIN_LED_RXL, LOW);
547+
rxLEDPulse = TX_RX_LED_PULSE_MS;
548+
#endif
549+
525550
armRecv(ep);
526551

527552
usbd.epBank0DisableTransferComplete(ep);
@@ -620,6 +645,11 @@ uint32_t USBDeviceClass::send(uint32_t ep, const void *data, uint32_t len)
620645
}
621646
#endif
622647

648+
#ifdef PIN_LED_TXL
649+
digitalWrite(PIN_LED_TXL, LOW);
650+
txLEDPulse = TX_RX_LED_PULSE_MS;
651+
#endif
652+
623653
// Flash area
624654
while (len != 0)
625655
{
@@ -826,6 +856,17 @@ void USBDeviceClass::ISRHandler()
826856
if (usbd.isStartOfFrameInterrupt())
827857
{
828858
usbd.ackStartOfFrameInterrupt();
859+
860+
// check whether the one-shot period has elapsed. if so, turn off the LED
861+
#ifdef PIN_LED_TXL
862+
if (txLEDPulse && !(--txLEDPulse))
863+
digitalWrite(PIN_LED_TXL, HIGH);
864+
#endif
865+
866+
#ifdef PIN_LED_RXL
867+
if (rxLEDPulse && !(--rxLEDPulse))
868+
digitalWrite(PIN_LED_RXL, HIGH);
869+
#endif
829870
}
830871

831872
// Endpoint 0 Received Setup interrupt

cores/arduino/WInterrupts.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode)
5757
uint32_t config;
5858
uint32_t pos;
5959

60+
#if ARDUINO_SAMD_VARIANT_COMPLIANCE >= 10606
61+
EExt_Interrupts in = g_APinDescription[pin].ulExtInt;
62+
#else
6063
EExt_Interrupts in = digitalPinToInterrupt(pin);
64+
#endif
6165
if (in == NOT_AN_INTERRUPT || in == EXTERNAL_INT_NMI)
6266
return;
6367

@@ -116,7 +120,11 @@ void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode)
116120
*/
117121
void detachInterrupt(uint32_t pin)
118122
{
123+
#if (ARDUINO_SAMD_VARIANT_COMPLIANCE >= 10606)
124+
EExt_Interrupts in = g_APinDescription[pin].ulExtInt;
125+
#else
119126
EExt_Interrupts in = digitalPinToInterrupt(pin);
127+
#endif
120128
if (in == NOT_AN_INTERRUPT || in == EXTERNAL_INT_NMI)
121129
return;
122130

cores/arduino/WString.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class String
8181
inline unsigned int length(void) const {return len;}
8282

8383
// creates a copy of the assigned value. if the value is null or
84-
// invalid, or if the memory allocation fails, the string will be
84+
// invalid, or if the memory allocation fails, the string will be
8585
// marked as invalid ("if (s)" will be false).
8686
String & operator = (const String &rhs);
8787
String & operator = (const char *cstr);
@@ -92,10 +92,10 @@ class String
9292
#endif
9393

9494
// concatenate (works w/ built-in types)
95-
95+
9696
// returns true on success, false on failure (in which case, the string
97-
// is left unchanged). if the argument is null or invalid, the
98-
// concatenation is considered unsucessful.
97+
// is left unchanged). if the argument is null or invalid, the
98+
// concatenation is considered unsucessful.
9999
unsigned char concat(const String &str);
100100
unsigned char concat(const char *cstr);
101101
unsigned char concat(char c);
@@ -107,7 +107,7 @@ class String
107107
unsigned char concat(float num);
108108
unsigned char concat(double num);
109109
unsigned char concat(const __FlashStringHelper * str);
110-
110+
111111
// if there's not enough memory for the concatenated value, the string
112112
// will be left unchanged (but this isn't signalled in any way)
113113
String & operator += (const String &rhs) {concat(rhs); return (*this);}
@@ -161,6 +161,8 @@ class String
161161
void toCharArray(char *buf, unsigned int bufsize, unsigned int index=0) const
162162
{getBytes((unsigned char *)buf, bufsize, index);}
163163
const char * c_str() const { return buffer; }
164+
const char* begin() { return c_str(); }
165+
const char* end() { return c_str() + length(); }
164166

165167
// search
166168
int indexOf( char ch ) const;

cores/arduino/avr/pgmspace.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ typedef int16_t prog_int16_t;
4444
typedef uint16_t prog_uint16_t;
4545
typedef int32_t prog_int32_t;
4646
typedef uint32_t prog_uint32_t;
47-
typedef int32_t prog_int64_t;
48-
typedef uint32_t prog_uint64_t;
47+
typedef int64_t prog_int64_t;
48+
typedef uint64_t prog_uint64_t;
4949

5050
typedef const void* int_farptr_t;
5151
typedef const void* uint_farptr_t;

0 commit comments

Comments
 (0)