Skip to content

Commit 25cd637

Browse files
committed
Merge branch 'master' into atsamr
Conflicts: boards.txt
2 parents 340ad50 + 3277492 commit 25cd637

File tree

23 files changed

+1037
-87
lines changed

23 files changed

+1037
-87
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

README.md

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,51 +3,27 @@
33
This repository containts the source code and configuration files of the Arduino Core
44
for Atmel's SAMD21 processor (used on the Arduino Zero board).
55

6-
## Installation on Arduino IDE
7-
8-
This core is available as a package in the Arduino IDE cores manager.
9-
Just open the "Boards Manager" and install the package called:
10-
11-
"Arduino SAMD Boards (32-bit ARM Cortex-M0+)"
6+
In particular, this adds support for the Adafruit SAMD Boards such as the Feather M0
127

13-
## Support
8+
## Installation on Arduino IDE
149

15-
There is a dedicated section of the Arduino Forum for general discussion and project assistance:
10+
Install the Adafruit Board Support package json and then install the Adafruit SAMD board package
1611

17-
http://forum.arduino.cc/index.php?board=98.0
12+
https://learn.adafruit.com/adafruit-feather-m0-basic-proto/using-with-arduino-ide
1813

1914
## Bugs or Issues
2015

2116
If you find a bug you can submit an issue here on github:
2217

18+
https://github.com/adafruit/ArduinoCore-samd
19+
20+
or if it is an issue with the upstream:
21+
2322
https://github.com/arduino/ArduinoCore-samd/issues
2423

2524
Before posting a new issue, please check if the same problem has been already reported by someone else
2625
to avoid duplicates.
2726

28-
## Contributions
29-
30-
Contributions are always welcome. The preferred way to receive code cotribution is by submitting a
31-
Pull Request on github.
32-
33-
## Hourly builds
34-
35-
This repository is under a Continuos Integration system that every hour checks if there are updates and
36-
builds a release for testing (the so called "Hourly builds").
37-
38-
The hourly builds are available through Boards Manager. If you want to install them:
39-
1. Open the **Preferences** of the Arduino IDE.
40-
2. Add this URL `http://downloads.arduino.cc/Hourly/samd/package_samd-hourly-build_index.json` in the **Additional Boards Manager URLs** field, and click OK.
41-
3. Open the **Boards Manager** (menu Tools->Board->Board Manager...)
42-
4. Install **Arduino SAMD core - Hourly build**
43-
5. Select one of the boards under **SAMD Hourly build XX** in Tools->Board menu
44-
6. Compile/Upload as usual
45-
46-
If you already installed an hourly build and you want to update it with the latest:
47-
1. Open the **Boards Manager** (menu Tools->Board->Board Manager...)
48-
2. Remove **Arduino SAMD core - Hourly build**
49-
3. Install again **Arduino SAMD core - Hourly build**, the Board Manager will download the latest build replacing the old one.
50-
5127
## License and credits
5228

5329
This core has been developed by Arduino LLC in collaboration with Atmel.

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: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -42,35 +42,6 @@ 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=feather/samd21_sam_ba.bin
72-
73-
7445
adafruit_radio_m0.name=Adafruit M0 Radio (Native USB Port)
7546
adafruit_radio_m0.vid.0=0x239A
7647
adafruit_radio_m0.pid.0=0x8014
@@ -97,3 +68,30 @@ adafruit_radio_m0.build.vid=0x239A
9768
adafruit_radio_m0.build.pid=0x8014
9869
adafruit_radio_m0.bootloader.tool=openocd
9970
adafruit_radio_m0.bootloader.file=feather/samr21_sam_ba.bin
71+
72+
#adafruit_metro_m0.name=Adafruit Metro M0 (Native USB Port)
73+
#adafruit_metro_m0.vid.0=0x239A
74+
#adafruit_metro_m0.pid.0=0x8013
75+
#adafruit_metro_m0.vid.1=0x239A
76+
#adafruit_metro_m0.pid.1=0x0013
77+
#adafruit_metro_m0.upload.tool=bossac
78+
#adafruit_metro_m0.upload.protocol=sam-ba
79+
#adafruit_metro_m0.upload.maximum_size=262144
80+
#adafruit_metro_m0.upload.use_1200bps_touch=true
81+
#adafruit_metro_m0.upload.wait_for_upload_port=true
82+
#adafruit_metro_m0.upload.native_usb=true
83+
#adafruit_metro_m0.build.mcu=cortex-m0plus
84+
#adafruit_metro_m0.build.f_cpu=48000000L
85+
#adafruit_metro_m0.build.usb_product="Metro M0"
86+
#adafruit_metro_m0.build.usb_manufacturer="Adafruit"
87+
#adafruit_metro_m0.build.board=SAMD_ZERO
88+
#adafruit_metro_m0.build.core=arduino
89+
#adafruit_metro_m0.build.extra_flags=-D__SAMD21G18A__ {build.usb_flags}
90+
#adafruit_metro_m0.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld
91+
#adafruit_metro_m0.build.openocdscript=openocd_scripts/arduino_zero.cfg
92+
#adafruit_metro_m0.build.variant=arduino_zero
93+
#adafruit_metro_m0.build.variant_system_lib=
94+
#adafruit_metro_m0.build.vid=0x239A
95+
#adafruit_metro_m0.build.pid=0x8013
96+
#adafruit_metro_m0.bootloader.tool=openocd
97+
#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
@@ -37,6 +37,14 @@ USBDevice_SAMR21G18x usbd;
3737
USBDevice_SAMD21G18x usbd;
3838
#endif
3939

40+
/** Pulse generation counters to keep track of the number of milliseconds remaining for each pulse type */
41+
#define TX_RX_LED_PULSE_MS 100
42+
#ifdef PIN_LED_TXL
43+
static volatile uint8_t txLEDPulse; /**< Milliseconds remaining for data Tx LED pulse */
44+
#endif
45+
#ifdef PIN_LED_RXL
46+
static volatile uint8_t rxLEDPulse; /**< Milliseconds remaining for data Rx LED pulse */
47+
#endif
4048
static char isRemoteWakeUpEnabled = 0;
4149
static char isEndpointHalt = 0;
4250

@@ -99,18 +107,18 @@ bool USBDeviceClass::sendStringDescriptor(const uint8_t *string, uint8_t maxlen)
99107
if (maxlen < 2)
100108
return false;
101109

102-
uint16_t buff[maxlen/2];
103-
int l = 1;
110+
uint8_t buffer[maxlen];
111+
buffer[0] = strlen((const char*)string) * 2 + 2;
112+
buffer[1] = 0x03;
104113

105-
maxlen -= 2;
106-
while (*string && maxlen>0)
107-
{
108-
buff[l++] = (uint8_t)(*string++);
109-
maxlen -= 2;
114+
uint8_t i;
115+
for (i = 2; i < maxlen && *string; i++) {
116+
buffer[i++] = *string++;
117+
if (i == maxlen) break;
118+
buffer[i] = 0;
110119
}
111-
buff[0] = (3<<8) | (l*2);
112120

113-
return USBDevice.sendControl((uint8_t*)buff, l*2);
121+
return USBDevice.sendControl(buffer, i);
114122
}
115123

116124
bool _dry_run = false;
@@ -282,6 +290,18 @@ void USBDeviceClass::handleEndpoint(uint8_t ep)
282290

283291
void USBDeviceClass::init()
284292
{
293+
#ifdef PIN_LED_TXL
294+
txLEDPulse = 0;
295+
pinMode(PIN_LED_TXL, OUTPUT);
296+
digitalWrite(PIN_LED_TXL, HIGH);
297+
#endif
298+
299+
#ifdef PIN_LED_RXL
300+
rxLEDPulse = 0;
301+
pinMode(PIN_LED_RXL, OUTPUT);
302+
digitalWrite(PIN_LED_RXL, HIGH);
303+
#endif
304+
285305
// Enable USB clock
286306
PM->APBBMASK.reg |= PM_APBBMASK_USB;
287307

@@ -531,6 +551,11 @@ uint32_t USBDeviceClass::recv(uint32_t ep, void *_data, uint32_t len)
531551
if (available(ep) < len)
532552
len = available(ep);
533553

554+
#ifdef PIN_LED_RXL
555+
digitalWrite(PIN_LED_RXL, LOW);
556+
rxLEDPulse = TX_RX_LED_PULSE_MS;
557+
#endif
558+
534559
armRecv(ep);
535560

536561
usbd.epBank0DisableTransferComplete(ep);
@@ -629,6 +654,11 @@ uint32_t USBDeviceClass::send(uint32_t ep, const void *data, uint32_t len)
629654
}
630655
#endif
631656

657+
#ifdef PIN_LED_TXL
658+
digitalWrite(PIN_LED_TXL, LOW);
659+
txLEDPulse = TX_RX_LED_PULSE_MS;
660+
#endif
661+
632662
// Flash area
633663
while (len != 0)
634664
{
@@ -835,6 +865,17 @@ void USBDeviceClass::ISRHandler()
835865
if (usbd.isStartOfFrameInterrupt())
836866
{
837867
usbd.ackStartOfFrameInterrupt();
868+
869+
// check whether the one-shot period has elapsed. if so, turn off the LED
870+
#ifdef PIN_LED_TXL
871+
if (txLEDPulse && !(--txLEDPulse))
872+
digitalWrite(PIN_LED_TXL, HIGH);
873+
#endif
874+
875+
#ifdef PIN_LED_RXL
876+
if (rxLEDPulse && !(--rxLEDPulse))
877+
digitalWrite(PIN_LED_RXL, HIGH);
878+
#endif
838879
}
839880

840881
// 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;

0 commit comments

Comments
 (0)