aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--boards.txt21
-rw-r--r--cores/arduino/Arduino.h19
-rw-r--r--cores/arduino/CDC.cpp30
-rw-r--r--cores/arduino/HardwareSerial.cpp63
-rw-r--r--cores/arduino/Stream.cpp1
-rw-r--r--cores/arduino/USBAPI.h2
-rw-r--r--cores/arduino/USBCore.cpp16
-rw-r--r--cores/arduino/USBCore.h3
-rw-r--r--cores/arduino/WInterrupts.c14
-rw-r--r--cores/arduino/WString.cpp2
-rw-r--r--cores/arduino/new.cpp5
-rw-r--r--cores/arduino/new.h1
-rw-r--r--cores/arduino/wiring.c2
-rw-r--r--cores/arduino/wiring_shift.c11
-rwxr-xr-xextras/pack.hourlybuild.bash51
-rwxr-xr-xextras/pack.pullrequest.bash50
-rwxr-xr-xextras/pack.release.bash33
-rw-r--r--extras/package_index.json.Hourly.template72
-rw-r--r--extras/package_index.json.PR.template72
-rw-r--r--libraries/EEPROM/src/EEPROM.h6
-rw-r--r--libraries/SPI/examples/DigitalPotControl/DigitalPotControl.ino2
-rw-r--r--libraries/SoftwareSerial/src/SoftwareSerial.cpp4
-rw-r--r--libraries/SoftwareSerial/src/SoftwareSerial.h9
-rw-r--r--libraries/Wire/examples/digital_potentiometer/digital_potentiometer.ino2
-rw-r--r--libraries/Wire/examples/i2c_scanner/i2c_scanner.ino75
-rw-r--r--libraries/Wire/src/Wire.cpp7
-rw-r--r--libraries/Wire/src/utility/twi.c2
-rw-r--r--platform.txt6
-rw-r--r--programmers.txt9
29 files changed, 497 insertions, 93 deletions
diff --git a/boards.txt b/boards.txt
index 77a062e..b72374d 100644
--- a/boards.txt
+++ b/boards.txt
@@ -144,15 +144,30 @@ nano.menu.cpu.atmega328=ATmega328P
nano.menu.cpu.atmega328.upload.maximum_size=30720
nano.menu.cpu.atmega328.upload.maximum_data_size=2048
-nano.menu.cpu.atmega328.upload.speed=57600
+nano.menu.cpu.atmega328.upload.speed=115200
nano.menu.cpu.atmega328.bootloader.low_fuses=0xFF
nano.menu.cpu.atmega328.bootloader.high_fuses=0xDA
nano.menu.cpu.atmega328.bootloader.extended_fuses=0xFD
-nano.menu.cpu.atmega328.bootloader.file=atmega/ATmegaBOOT_168_atmega328.hex
+nano.menu.cpu.atmega328.bootloader.file=optiboot/optiboot_atmega328.hex
nano.menu.cpu.atmega328.build.mcu=atmega328p
+## Arduino Nano w/ ATmega328P (old bootloader)
+## --------------------------
+nano.menu.cpu.atmega328old=ATmega328P (Old Bootloader)
+
+nano.menu.cpu.atmega328old.upload.maximum_size=30720
+nano.menu.cpu.atmega328old.upload.maximum_data_size=2048
+nano.menu.cpu.atmega328old.upload.speed=57600
+
+nano.menu.cpu.atmega328old.bootloader.low_fuses=0xFF
+nano.menu.cpu.atmega328old.bootloader.high_fuses=0xDA
+nano.menu.cpu.atmega328old.bootloader.extended_fuses=0xFD
+nano.menu.cpu.atmega328old.bootloader.file=atmega/ATmegaBOOT_168_atmega328.hex
+
+nano.menu.cpu.atmega328old.build.mcu=atmega328p
+
## Arduino Nano w/ ATmega168
## -------------------------
nano.menu.cpu.atmega168=ATmega168
@@ -931,7 +946,7 @@ yunmini.bootloader.tool=avrdude
yunmini.bootloader.low_fuses=0xff
yunmini.bootloader.high_fuses=0xd8
yunmini.bootloader.extended_fuses=0xfb
-yunmini.bootloader.file=caterina/Caterina-Yunmini.hex
+yunmini.bootloader.file=caterina/Caterina-YunMini.hex
yunmini.bootloader.unlock_bits=0x3F
yunmini.bootloader.lock_bits=0x2F
diff --git a/cores/arduino/Arduino.h b/cores/arduino/Arduino.h
index 09c1448..91eeb16 100644
--- a/cores/arduino/Arduino.h
+++ b/cores/arduino/Arduino.h
@@ -111,7 +111,8 @@ void yield(void);
#define bitRead(value, bit) (((value) >> (bit)) & 0x01)
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
-#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))
+#define bitToggle(value, bit) ((value) ^= (1UL << (bit)))
+#define bitWrite(value, bit, bitvalue) ((bitvalue) ? bitSet(value, bit) : bitClear(value, bit))
// avr-libc defines _NOP() since 1.6.2
#ifndef _NOP
@@ -130,16 +131,16 @@ void initVariant(void);
int atexit(void (*func)()) __attribute__((weak));
-void pinMode(uint8_t, uint8_t);
-void digitalWrite(uint8_t, uint8_t);
-int digitalRead(uint8_t);
-int analogRead(uint8_t);
+void pinMode(uint8_t pin, uint8_t mode);
+void digitalWrite(uint8_t pin, uint8_t val);
+int digitalRead(uint8_t pin);
+int analogRead(uint8_t pin);
void analogReference(uint8_t mode);
-void analogWrite(uint8_t, int);
+void analogWrite(uint8_t pin, int val);
unsigned long millis(void);
unsigned long micros(void);
-void delay(unsigned long);
+void delay(unsigned long ms);
void delayMicroseconds(unsigned int us);
unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout);
unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout);
@@ -147,8 +148,8 @@ unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout);
void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val);
uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder);
-void attachInterrupt(uint8_t, void (*)(void), int mode);
-void detachInterrupt(uint8_t);
+void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), int mode);
+void detachInterrupt(uint8_t interruptNum);
void setup(void);
void loop(void);
diff --git a/cores/arduino/CDC.cpp b/cores/arduino/CDC.cpp
index 0a743e1..4ff6b9b 100644
--- a/cores/arduino/CDC.cpp
+++ b/cores/arduino/CDC.cpp
@@ -34,14 +34,14 @@ typedef struct
static volatile LineInfo _usbLineInfo = { 57600, 0x00, 0x00, 0x00, 0x00 };
static volatile int32_t breakValue = -1;
-bool _updatedLUFAbootloader = false;
+static u8 wdtcsr_save;
#define WEAK __attribute__ ((weak))
extern const CDCDescriptor _cdcInterface PROGMEM;
const CDCDescriptor _cdcInterface =
{
- D_IAD(0,2,CDC_COMMUNICATION_INTERFACE_CLASS,CDC_ABSTRACT_CONTROL_MODEL,1),
+ D_IAD(0,2,CDC_COMMUNICATION_INTERFACE_CLASS,CDC_ABSTRACT_CONTROL_MODEL,0),
// CDC communication interface
D_INTERFACE(CDC_ACM_INTERFACE,1,CDC_COMMUNICATION_INTERFACE_CLASS,CDC_ABSTRACT_CONTROL_MODEL,0),
@@ -57,6 +57,11 @@ const CDCDescriptor _cdcInterface =
D_ENDPOINT(USB_ENDPOINT_IN (CDC_ENDPOINT_IN ),USB_ENDPOINT_TYPE_BULK,USB_EP_SIZE,0)
};
+bool isLUFAbootloader()
+{
+ return pgm_read_word(FLASHEND - 1) == NEW_LUFA_SIGNATURE;
+}
+
int CDC_GetInterface(u8* interfaceNum)
{
interfaceNum[0] += 2; // uses 2
@@ -92,10 +97,7 @@ bool CDC_Setup(USBSetup& setup)
if (CDC_SET_CONTROL_LINE_STATE == r)
{
_usbLineInfo.lineState = setup.wValueL;
- }
- if (CDC_SET_LINE_CODING == r || CDC_SET_CONTROL_LINE_STATE == r)
- {
// auto-reset into the bootloader is triggered when the port, already
// open at 1200 bps, is closed. this is the signal to start the watchdog
// with a relatively long period so it can finish housekeeping tasks
@@ -109,7 +111,7 @@ bool CDC_Setup(USBSetup& setup)
#if MAGIC_KEY_POS != (RAMEND-1)
// For future boards save the key in the inproblematic RAMEND
// Which is reserved for the main() return value (which will never return)
- if (_updatedLUFAbootloader) {
+ if (isLUFAbootloader()) {
// horray, we got a new bootloader!
magic_key_pos = (RAMEND-1);
}
@@ -119,25 +121,31 @@ bool CDC_Setup(USBSetup& setup)
if (1200 == _usbLineInfo.dwDTERate && (_usbLineInfo.lineState & 0x01) == 0)
{
#if MAGIC_KEY_POS != (RAMEND-1)
- // Backup ram value if its not a newer bootloader.
+ // Backup ram value if its not a newer bootloader and it hasn't already been saved.
// This should avoid memory corruption at least a bit, not fully
- if (magic_key_pos != (RAMEND-1)) {
+ if (magic_key_pos != (RAMEND-1) && *(uint16_t *)magic_key_pos != MAGIC_KEY) {
*(uint16_t *)(RAMEND-1) = *(uint16_t *)magic_key_pos;
}
#endif
// Store boot key
*(uint16_t *)magic_key_pos = MAGIC_KEY;
+ // Save the watchdog state in case the reset is aborted.
+ wdtcsr_save = WDTCSR;
wdt_enable(WDTO_120MS);
}
- else
+ else if (*(uint16_t *)magic_key_pos == MAGIC_KEY)
{
// Most OSs do some intermediate steps when configuring ports and DTR can
// twiggle more than once before stabilizing.
- // To avoid spurious resets we set the watchdog to 250ms and eventually
+ // To avoid spurious resets we set the watchdog to 120ms and eventually
// cancel if DTR goes back high.
+ // Cancellation is only done if an auto-reset was started, which is
+ // indicated by the magic key having been set.
- wdt_disable();
wdt_reset();
+ // Restore the watchdog state in case the sketch was using it.
+ WDTCSR |= (1<<WDCE) | (1<<WDE);
+ WDTCSR = wdtcsr_save;
#if MAGIC_KEY_POS != (RAMEND-1)
// Restore backed up (old bootloader) magic key data
if (magic_key_pos != (RAMEND-1)) {
diff --git a/cores/arduino/HardwareSerial.cpp b/cores/arduino/HardwareSerial.cpp
index 5cd89e5..e99d503 100644
--- a/cores/arduino/HardwareSerial.cpp
+++ b/cores/arduino/HardwareSerial.cpp
@@ -26,6 +26,7 @@
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
+#include <util/atomic.h>
#include "Arduino.h"
#include "HardwareSerial.h"
@@ -76,6 +77,13 @@ void serialEventRun(void)
#endif
}
+// macro to guard critical sections when needed for large TX buffer sizes
+#if (SERIAL_TX_BUFFER_SIZE>256)
+#define TX_BUFFER_ATOMIC ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
+#else
+#define TX_BUFFER_ATOMIC
+#endif
+
// Actual interrupt handlers //////////////////////////////////////////////////////////////
void HardwareSerial::_tx_udr_empty_irq(void)
@@ -89,8 +97,14 @@ void HardwareSerial::_tx_udr_empty_irq(void)
// clear the TXC bit -- "can be cleared by writing a one to its bit
// location". This makes sure flush() won't return until the bytes
- // actually got written
- sbi(*_ucsra, TXC0);
+ // actually got written. Other r/w bits are preserved, and zeroes
+ // written to the rest.
+
+#ifdef MPCM0
+ *_ucsra = ((*_ucsra) & ((1 << U2X0) | (1 << MPCM0))) | (1 << TXC0);
+#else
+ *_ucsra = ((*_ucsra) & ((1 << U2X0) | (1 << TXC0)));
+#endif
if (_tx_buffer_head == _tx_buffer_tail) {
// Buffer empty, so disable interrupts
@@ -177,15 +191,13 @@ int HardwareSerial::read(void)
int HardwareSerial::availableForWrite(void)
{
-#if (SERIAL_TX_BUFFER_SIZE>256)
- uint8_t oldSREG = SREG;
- cli();
-#endif
- tx_buffer_index_t head = _tx_buffer_head;
- tx_buffer_index_t tail = _tx_buffer_tail;
-#if (SERIAL_TX_BUFFER_SIZE>256)
- SREG = oldSREG;
-#endif
+ tx_buffer_index_t head;
+ tx_buffer_index_t tail;
+
+ TX_BUFFER_ATOMIC {
+ head = _tx_buffer_head;
+ tail = _tx_buffer_tail;
+ }
if (head >= tail) return SERIAL_TX_BUFFER_SIZE - 1 - head + tail;
return tail - head - 1;
}
@@ -218,8 +230,22 @@ size_t HardwareSerial::write(uint8_t c)
// significantly improve the effective datarate at high (>
// 500kbit/s) bitrates, where interrupt overhead becomes a slowdown.
if (_tx_buffer_head == _tx_buffer_tail && bit_is_set(*_ucsra, UDRE0)) {
- *_udr = c;
- sbi(*_ucsra, TXC0);
+ // If TXC is cleared before writing UDR and the previous byte
+ // completes before writing to UDR, TXC will be set but a byte
+ // is still being transmitted causing flush() to return too soon.
+ // So writing UDR must happen first.
+ // Writing UDR and clearing TC must be done atomically, otherwise
+ // interrupts might delay the TXC clear so the byte written to UDR
+ // is transmitted (setting TXC) before clearing TXC. Then TXC will
+ // be cleared when no bytes are left, causing flush() to hang
+ ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
+ *_udr = c;
+#ifdef MPCM0
+ *_ucsra = ((*_ucsra) & ((1 << U2X0) | (1 << MPCM0))) | (1 << TXC0);
+#else
+ *_ucsra = ((*_ucsra) & ((1 << U2X0) | (1 << TXC0)));
+#endif
+ }
return 1;
}
tx_buffer_index_t i = (_tx_buffer_head + 1) % SERIAL_TX_BUFFER_SIZE;
@@ -240,9 +266,14 @@ size_t HardwareSerial::write(uint8_t c)
}
_tx_buffer[_tx_buffer_head] = c;
- _tx_buffer_head = i;
-
- sbi(*_ucsrb, UDRIE0);
+
+ // make atomic to prevent execution of ISR between setting the
+ // head pointer and setting the interrupt flag resulting in buffer
+ // retransmission
+ ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
+ _tx_buffer_head = i;
+ sbi(*_ucsrb, UDRIE0);
+ }
return 1;
}
diff --git a/cores/arduino/Stream.cpp b/cores/arduino/Stream.cpp
index d284631..9eff663 100644
--- a/cores/arduino/Stream.cpp
+++ b/cores/arduino/Stream.cpp
@@ -218,7 +218,6 @@ size_t Stream::readBytes(char *buffer, size_t length)
size_t Stream::readBytesUntil(char terminator, char *buffer, size_t length)
{
- if (length < 1) return 0;
size_t index = 0;
while (index < length) {
int c = timedRead();
diff --git a/cores/arduino/USBAPI.h b/cores/arduino/USBAPI.h
index 479ced9..701a14f 100644
--- a/cores/arduino/USBAPI.h
+++ b/cores/arduino/USBAPI.h
@@ -65,6 +65,8 @@ public:
void detach(); // Serial port goes down too...
void poll();
bool wakeupHost(); // returns false, when wakeup cannot be processed
+
+ bool isSuspended();
};
extern USBDevice_ USBDevice;
diff --git a/cores/arduino/USBCore.cpp b/cores/arduino/USBCore.cpp
index e00fb02..dc6bc38 100644
--- a/cores/arduino/USBCore.cpp
+++ b/cores/arduino/USBCore.cpp
@@ -35,7 +35,6 @@ extern const u16 STRING_LANGUAGE[] PROGMEM;
extern const u8 STRING_PRODUCT[] PROGMEM;
extern const u8 STRING_MANUFACTURER[] PROGMEM;
extern const DeviceDescriptor USB_DeviceDescriptorIAD PROGMEM;
-extern bool _updatedLUFAbootloader;
const u16 STRING_LANGUAGE[2] = {
(3<<8) | (2+2),
@@ -497,14 +496,13 @@ bool SendConfiguration(int maxlen)
static
bool SendDescriptor(USBSetup& setup)
{
- int ret;
u8 t = setup.wValueH;
if (USB_CONFIGURATION_DESCRIPTOR_TYPE == t)
return SendConfiguration(setup.wLength);
InitControl(setup.wLength);
#ifdef PLUGGABLE_USB_ENABLED
- ret = PluggableUSB().getDescriptor(setup);
+ int ret = PluggableUSB().getDescriptor(setup);
if (ret != 0) {
return (ret > 0 ? true : false);
}
@@ -819,12 +817,6 @@ void USBDevice_::attach()
UDIEN = (1<<EORSTE) | (1<<SOFE) | (1<<SUSPE); // Enable interrupts for EOR (End of Reset), SOF (start of frame) and SUSPEND
TX_RX_LED_INIT;
-
-#if MAGIC_KEY_POS != (RAMEND-1)
- if (pgm_read_word(FLASHEND - 1) == NEW_LUFA_SIGNATURE) {
- _updatedLUFAbootloader = true;
- }
-#endif
}
void USBDevice_::detach()
@@ -862,4 +854,10 @@ bool USBDevice_::wakeupHost()
return false;
}
+bool USBDevice_::isSuspended()
+{
+ return (_usbSuspendState & (1 << SUSPI));
+}
+
+
#endif /* if defined(USBCON) */
diff --git a/cores/arduino/USBCore.h b/cores/arduino/USBCore.h
index 5e0c7b3..0c63c2b 100644
--- a/cores/arduino/USBCore.h
+++ b/cores/arduino/USBCore.h
@@ -288,8 +288,7 @@ typedef struct
// Old Caterina bootloader places the MAGIC key into unsafe RAM locations (it can be rewritten
// by the running sketch before to actual reboot).
// Newer bootloaders, recognizable by the LUFA "signature" at the end of the flash, can handle both
-// the usafe and the safe location. Check once (in USBCore.cpp) if the bootloader in new, then set the global
-// _updatedLUFAbootloader variable to true/false and place the magic key consequently
+// the usafe and the safe location.
#ifndef MAGIC_KEY
#define MAGIC_KEY 0x7777
#endif
diff --git a/cores/arduino/WInterrupts.c b/cores/arduino/WInterrupts.c
index cef1106..ac72dda 100644
--- a/cores/arduino/WInterrupts.c
+++ b/cores/arduino/WInterrupts.c
@@ -65,7 +65,6 @@ static volatile voidFuncPtr intFunc[EXTERNAL_NUM_INTERRUPTS] = {
nothing,
#endif
};
-// volatile static voidFuncPtr twiIntFunc;
void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), int mode) {
if(interruptNum < EXTERNAL_NUM_INTERRUPTS) {
@@ -274,11 +273,6 @@ void detachInterrupt(uint8_t interruptNum) {
}
}
-/*
-void attachInterruptTwi(void (*userFunc)(void) ) {
- twiIntFunc = userFunc;
-}
-*/
#define IMPLEMENT_ISR(vect, interrupt) \
ISR(vect) { \
@@ -314,11 +308,3 @@ IMPLEMENT_ISR(INT2_vect, EXTERNAL_INT_2)
#endif
#endif
-
-/*
-ISR(TWI_vect) {
- if(twiIntFunc)
- twiIntFunc();
-}
-*/
-
diff --git a/cores/arduino/WString.cpp b/cores/arduino/WString.cpp
index f2572d6..043fda7 100644
--- a/cores/arduino/WString.cpp
+++ b/cores/arduino/WString.cpp
@@ -121,7 +121,7 @@ String::String(double value, unsigned char decimalPlaces)
String::~String()
{
- free(buffer);
+ if (buffer) free(buffer);
}
/*********************************************/
diff --git a/cores/arduino/new.cpp b/cores/arduino/new.cpp
index cf6f89c..fc30cf8 100644
--- a/cores/arduino/new.cpp
+++ b/cores/arduino/new.cpp
@@ -26,6 +26,11 @@ void *operator new[](size_t size) {
return malloc(size);
}
+void * operator new(size_t size, void * ptr) noexcept {
+ (void)size;
+ return ptr;
+}
+
void operator delete(void * ptr) {
free(ptr);
}
diff --git a/cores/arduino/new.h b/cores/arduino/new.h
index 6e1b68f..763f5cc 100644
--- a/cores/arduino/new.h
+++ b/cores/arduino/new.h
@@ -23,6 +23,7 @@
void * operator new(size_t size);
void * operator new[](size_t size);
+void * operator new(size_t size, void * ptr) noexcept;
void operator delete(void * ptr);
void operator delete[](void * ptr);
diff --git a/cores/arduino/wiring.c b/cores/arduino/wiring.c
index b956f78..9727135 100644
--- a/cores/arduino/wiring.c
+++ b/cores/arduino/wiring.c
@@ -39,7 +39,7 @@ volatile unsigned long timer0_overflow_count = 0;
volatile unsigned long timer0_millis = 0;
static unsigned char timer0_fract = 0;
-#if defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
+#if defined(TIM0_OVF_vect)
ISR(TIM0_OVF_vect)
#else
ISR(TIMER0_OVF_vect)
diff --git a/cores/arduino/wiring_shift.c b/cores/arduino/wiring_shift.c
index 2b6f7a8..a9b3be5 100644
--- a/cores/arduino/wiring_shift.c
+++ b/cores/arduino/wiring_shift.c
@@ -42,10 +42,13 @@ void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val)
uint8_t i;
for (i = 0; i < 8; i++) {
- if (bitOrder == LSBFIRST)
- digitalWrite(dataPin, !!(val & (1 << i)));
- else
- digitalWrite(dataPin, !!(val & (1 << (7 - i))));
+ if (bitOrder == LSBFIRST) {
+ digitalWrite(dataPin, val & 1);
+ val >>= 1;
+ } else {
+ digitalWrite(dataPin, (val & 128) != 0);
+ val <<= 1;
+ }
digitalWrite(clockPin, HIGH);
digitalWrite(clockPin, LOW);
diff --git a/extras/pack.hourlybuild.bash b/extras/pack.hourlybuild.bash
new file mode 100755
index 0000000..b3a269f
--- /dev/null
+++ b/extras/pack.hourlybuild.bash
@@ -0,0 +1,51 @@
+#!/bin/bash -ex
+
+# pack.*.bash - Bash script to help packaging avr core releases.
+# Copyright (c) 2015 Arduino LLC. All right reserved.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+BUILD_NUMBER=$1
+CURR_TIME=`date "+%Y-%m-%d %H:%M"`
+CURR_TIME_SED=`date "+%Y\\-%m\\-%d %H:%M"`
+VERSION=9.9.9-Hourly
+
+PWD=`pwd`
+FOLDERNAME=`basename $PWD`
+THIS_SCRIPT_NAME=`basename $0`
+FILENAME=package_avr-hourly-b${BUILD_NUMBER}.tar.bz2
+
+rm -f $FILENAME
+
+# Change name in platform.txt
+sed -i "s/name=.*/name=SAMD Hourly Build ${BUILD_NUMBER} (${CURR_TIME})/" platform.txt
+
+cd ..
+tar --transform "s|$FOLDERNAME|avr-hourly_b${BUILD_NUMBER}|g" --exclude=extras/** --exclude=.git* --exclude=.idea -cjf $FILENAME $FOLDERNAME
+cd -
+
+mv ../$FILENAME .
+
+CHKSUM=`sha256sum $FILENAME | awk '{ print $1 }'`
+SIZE=`wc -c $FILENAME | awk '{ print $1 }'`
+
+cat extras/package_index.json.Hourly.template |
+sed "s/%%BUILD_NUMBER%%/${BUILD_NUMBER}/" |
+sed "s/%%CURR_TIME%%/${CURR_TIME_SED}/" |
+sed "s/%%VERSION%%/${VERSION}/" |
+sed "s/%%FILENAME%%/${FILENAME}/" |
+sed "s/%%CHECKSUM%%/${CHKSUM}/" |
+sed "s/%%SIZE%%/${SIZE}/" > package_avr-hourly-build_index.json
+
diff --git a/extras/pack.pullrequest.bash b/extras/pack.pullrequest.bash
new file mode 100755
index 0000000..64f5b95
--- /dev/null
+++ b/extras/pack.pullrequest.bash
@@ -0,0 +1,50 @@
+#!/bin/bash -ex
+
+# pack.*.bash - Bash script to help packaging avr core releases.
+# Copyright (c) 2015 Arduino LLC. All right reserved.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+PR_NUMBER=$1
+BUILD_NUMBER=$2
+VERSION=`grep version= platform.txt | sed 's/version=//g'`
+
+PWD=`pwd`
+FOLDERNAME=`basename $PWD`
+THIS_SCRIPT_NAME=`basename $0`
+FILENAME=package_avr-b${BUILD_NUMBER}.tar.bz2
+
+rm -f $FILENAME
+
+# Change name in platform.txt
+sed -i "s/name=.*/name=SAMD Pull request #${PR_NUMBER} (Build ${BUILD_NUMBER})/" platform.txt
+
+cd ..
+tar --transform "s|$FOLDERNAME|avr-PR${PR_NUMBER}_b${BUILD_NUMBER}|g" --exclude=extras/** --exclude=.git* --exclude=.idea -cjf $FILENAME $FOLDERNAME
+cd -
+
+mv ../$FILENAME .
+
+CHKSUM=`sha256sum $FILENAME | awk '{ print $1 }'`
+SIZE=`wc -c $FILENAME | awk '{ print $1 }'`
+
+cat extras/package_index.json.PR.template |
+sed s/%%PR_NUMBER%%/${PR_NUMBER}/ |
+sed s/%%BUILD_NUMBER%%/${BUILD_NUMBER}/ |
+sed s/%%VERSION%%/${VERSION}-build-${BUILD_NUMBER}/ |
+sed s/%%FILENAME%%/${FILENAME}/ |
+sed s/%%CHECKSUM%%/${CHKSUM}/ |
+sed s/%%SIZE%%/${SIZE}/ > package_avr-b${BUILD_NUMBER}_index.json
+
diff --git a/extras/pack.release.bash b/extras/pack.release.bash
new file mode 100755
index 0000000..a2999d5
--- /dev/null
+++ b/extras/pack.release.bash
@@ -0,0 +1,33 @@
+#!/bin/bash -ex
+
+# pack.*.bash - Bash script to help packaging avr core releases.
+# Copyright (c) 2015 Arduino LLC. All right reserved.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+VERSION=`grep version= platform.txt | sed 's/version=//g'`
+
+PWD=`pwd`
+FOLDERNAME=`basename $PWD`
+THIS_SCRIPT_NAME=`basename $0`
+
+rm -f avr-$VERSION.tar.bz2
+
+cd ..
+tar --transform "s|$FOLDERNAME|$FOLDERNAME-$VERSION|g" --exclude=extras/** --exclude=.git* --exclude=.idea -cjf avr-$VERSION.tar.bz2 $FOLDERNAME
+cd -
+
+mv ../avr-$VERSION.tar.bz2 .
+
diff --git a/extras/package_index.json.Hourly.template b/extras/package_index.json.Hourly.template
new file mode 100644
index 0000000..49c71dd
--- /dev/null
+++ b/extras/package_index.json.Hourly.template
@@ -0,0 +1,72 @@
+{
+ "packages": [
+ {
+ "name": "arduino-beta",
+ "maintainer": "Arduino Betatesting",
+ "websiteURL": "http://www.arduino.cc/",
+ "email": "packages@arduino.cc",
+ "help": {
+ "online": "http://www.arduino.cc/en/Reference/HomePage"
+ },
+ "platforms": [
+ {
+ "name": "Arduino AVR core - Hourly build",
+ "architecture": "avr",
+ "version": "%%VERSION%%",
+ "category": "Arduino",
+ "url": "http://downloads.arduino.cc/Hourly/avr/%%FILENAME%%",
+ "archiveFileName": "%%FILENAME%%",
+ "checksum": "SHA-256:%%CHECKSUM%%",
+ "size": "%%SIZE%%",
+ "boards": [
+ {"name": "Arduino Yún"},
+ {"name": "Arduino/Genuino Uno"},
+ {"name": "Arduino Uno WiFi"},
+ {"name": "Arduino Diecimila"},
+ {"name": "Arduino Nano"},
+ {"name": "Arduino/Genuino Mega"},
+ {"name": "Arduino MegaADK"},
+ {"name": "Arduino Leonardo"},
+ {"name": "Arduino Leonardo Ethernet"},
+ {"name": "Arduino/Genuino Micro"},
+ {"name": "Arduino Esplora"},
+ {"name": "Arduino Mini"},
+ {"name": "Arduino Ethernet"},
+ {"name": "Arduino Fio"},
+ {"name": "Arduino BT"},
+ {"name": "Arduino LilyPadUSB"},
+ {"name": "Arduino Lilypad"},
+ {"name": "Arduino Pro"},
+ {"name": "Arduino ATMegaNG"},
+ {"name": "Arduino Robot Control"},
+ {"name": "Arduino Robot Motor"},
+ {"name": "Arduino Gemma"},
+ {"name": "Adafruit Circuit Playground"},
+ {"name": "Arduino Yún Mini"},
+ {"name": "Arduino Industrial 101"},
+ {"name": "Linino One"}
+ ],
+ "toolsDependencies": [
+ {
+ "packager": "arduino",
+ "name": "avr-gcc",
+ "version": "4.9.2-atmel3.5.4-arduino2"
+ },
+ {
+ "packager": "arduino",
+ "name": "avrdude",
+ "version": "6.3.0-arduino9"
+ },
+ {
+ "packager": "arduino",
+ "name": "arduinoOTA",
+ "version": "1.1.1"
+ }
+ ]
+ }
+ ],
+ "tools": [
+ ]
+ }
+ ]
+}
diff --git a/extras/package_index.json.PR.template b/extras/package_index.json.PR.template
new file mode 100644
index 0000000..17cfa50
--- /dev/null
+++ b/extras/package_index.json.PR.template
@@ -0,0 +1,72 @@
+{
+ "packages": [
+ {
+ "name": "arduino-beta",
+ "maintainer": "Arduino Betatesting",
+ "websiteURL": "http://www.arduino.cc/",
+ "email": "packages@arduino.cc",
+ "help": {
+ "online": "http://www.arduino.cc/en/Reference/HomePage"
+ },
+ "platforms": [
+ {
+ "name": "Arduino AVR core - Pull request #%%PR_NUMBER%% (build %%BUILD_NUMBER%%)",
+ "architecture": "avr",
+ "version": "%%VERSION%%",
+ "category": "Arduino",
+ "url": "http://downloads.arduino.cc/PR/a/%%FILENAME%%",
+ "archiveFileName": "%%FILENAME%%",
+ "checksum": "SHA-256:%%CHECKSUM%%",
+ "size": "%%SIZE%%",
+ "boards": [
+ {"name": "Arduino Yún"},
+ {"name": "Arduino/Genuino Uno"},
+ {"name": "Arduino Uno WiFi"},
+ {"name": "Arduino Diecimila"},
+ {"name": "Arduino Nano"},
+ {"name": "Arduino/Genuino Mega"},
+ {"name": "Arduino MegaADK"},
+ {"name": "Arduino Leonardo"},
+ {"name": "Arduino Leonardo Ethernet"},
+ {"name": "Arduino/Genuino Micro"},
+ {"name": "Arduino Esplora"},
+ {"name": "Arduino Mini"},
+ {"name": "Arduino Ethernet"},
+ {"name": "Arduino Fio"},
+ {"name": "Arduino BT"},
+ {"name": "Arduino LilyPadUSB"},
+ {"name": "Arduino Lilypad"},
+ {"name": "Arduino Pro"},
+ {"name": "Arduino ATMegaNG"},
+ {"name": "Arduino Robot Control"},
+ {"name": "Arduino Robot Motor"},
+ {"name": "Arduino Gemma"},
+ {"name": "Adafruit Circuit Playground"},
+ {"name": "Arduino Yún Mini"},
+ {"name": "Arduino Industrial 101"},
+ {"name": "Linino One"}
+ ],
+ "toolsDependencies": [
+ {
+ "packager": "arduino",
+ "name": "avr-gcc",
+ "version": "4.9.2-atmel3.5.4-arduino2"
+ },
+ {
+ "packager": "arduino",
+ "name": "avrdude",
+ "version": "6.3.0-arduino9"
+ },
+ {
+ "packager": "arduino",
+ "name": "arduinoOTA",
+ "version": "1.1.1"
+ }
+ ]
+ }
+ ],
+ "tools": [
+ ]
+ }
+ ]
+}
diff --git a/libraries/EEPROM/src/EEPROM.h b/libraries/EEPROM/src/EEPROM.h
index cde75db..c8ec271 100644
--- a/libraries/EEPROM/src/EEPROM.h
+++ b/libraries/EEPROM/src/EEPROM.h
@@ -40,7 +40,7 @@ struct EERef{
//Access/read members.
uint8_t operator*() const { return eeprom_read_byte( (uint8_t*) index ); }
- operator const uint8_t() const { return **this; }
+ operator uint8_t() const { return **this; }
//Assignment/write members.
EERef &operator=( const EERef &ref ) { return *this = *ref; }
@@ -89,7 +89,7 @@ struct EEPtr{
EEPtr( const int index )
: index( index ) {}
- operator const int() const { return index; }
+ operator int() const { return index; }
EEPtr &operator=( int in ) { return index = in, *this; }
//Iterator functionality.
@@ -143,4 +143,4 @@ struct EEPROMClass{
};
static EEPROMClass EEPROM;
-#endif \ No newline at end of file
+#endif
diff --git a/libraries/SPI/examples/DigitalPotControl/DigitalPotControl.ino b/libraries/SPI/examples/DigitalPotControl/DigitalPotControl.ino
index c7afcc0..8719058 100644
--- a/libraries/SPI/examples/DigitalPotControl/DigitalPotControl.ino
+++ b/libraries/SPI/examples/DigitalPotControl/DigitalPotControl.ino
@@ -63,9 +63,11 @@ void loop() {
void digitalPotWrite(int address, int value) {
// take the SS pin low to select the chip:
digitalWrite(slaveSelectPin, LOW);
+ delay(100);
// send in the address and value via SPI:
SPI.transfer(address);
SPI.transfer(value);
+ delay(100);
// take the SS pin high to de-select the chip:
digitalWrite(slaveSelectPin, HIGH);
}
diff --git a/libraries/SoftwareSerial/src/SoftwareSerial.cpp b/libraries/SoftwareSerial/src/SoftwareSerial.cpp
index 474fe4a..3163d7a 100644
--- a/libraries/SoftwareSerial/src/SoftwareSerial.cpp
+++ b/libraries/SoftwareSerial/src/SoftwareSerial.cpp
@@ -316,7 +316,7 @@ void SoftwareSerial::begin(long speed)
_tx_delay = subtract_cap(bit_delay, 15 / 4);
// Only setup rx when we have a valid PCINT for this pin
- if (digitalPinToPCICR(_receivePin)) {
+ if (digitalPinToPCICR((int8_t)_receivePin)) {
#if GCC_VERSION > 40800
// Timings counted from gcc 4.8.2 output. This works up to 115200 on
// 16Mhz and 57600 on 8Mhz.
@@ -357,7 +357,7 @@ void SoftwareSerial::begin(long speed)
// Enable the PCINT for the entire port here, but never disable it
// (others might also need it, so we disable the interrupt by using
// the per-pin PCMSK register).
- *digitalPinToPCICR(_receivePin) |= _BV(digitalPinToPCICRbit(_receivePin));
+ *digitalPinToPCICR((int8_t)_receivePin) |= _BV(digitalPinToPCICRbit(_receivePin));
// Precalculate the pcint mask register and value, so setRxIntMask
// can be used inside the ISR without costing too much time.
_pcint_maskreg = digitalPinToPCMSK(_receivePin);
diff --git a/libraries/SoftwareSerial/src/SoftwareSerial.h b/libraries/SoftwareSerial/src/SoftwareSerial.h
index b1a37c4..d8b88ce 100644
--- a/libraries/SoftwareSerial/src/SoftwareSerial.h
+++ b/libraries/SoftwareSerial/src/SoftwareSerial.h
@@ -111,13 +111,4 @@ public:
static inline void handle_interrupt() __attribute__((__always_inline__));
};
-// Arduino 0012 workaround
-#undef int
-#undef char
-#undef long
-#undef byte
-#undef float
-#undef abs
-#undef round
-
#endif
diff --git a/libraries/Wire/examples/digital_potentiometer/digital_potentiometer.ino b/libraries/Wire/examples/digital_potentiometer/digital_potentiometer.ino
index 5fb91fb..dd40a25 100644
--- a/libraries/Wire/examples/digital_potentiometer/digital_potentiometer.ino
+++ b/libraries/Wire/examples/digital_potentiometer/digital_potentiometer.ino
@@ -9,8 +9,6 @@
// This example code is in the public domain.
-// This example code is in the public domain.
-
#include <Wire.h>
diff --git a/libraries/Wire/examples/i2c_scanner/i2c_scanner.ino b/libraries/Wire/examples/i2c_scanner/i2c_scanner.ino
new file mode 100644
index 0000000..3febbf4
--- /dev/null
+++ b/libraries/Wire/examples/i2c_scanner/i2c_scanner.ino
@@ -0,0 +1,75 @@
+// --------------------------------------
+// i2c_scanner
+//
+// Version 1
+// This program (or code that looks like it)
+// can be found in many places.
+// For example on the Arduino.cc forum.
+// The original author is not know.
+// Version 2, Juni 2012, Using Arduino 1.0.1
+// Adapted to be as simple as possible by Arduino.cc user Krodal
+// Version 3, Feb 26 2013
+// V3 by louarnold
+// Version 4, March 3, 2013, Using Arduino 1.0.3
+// by Arduino.cc user Krodal.
+// Changes by louarnold removed.
+// Scanning addresses changed from 0...127 to 1...119,
+// according to the i2c scanner by Nick Gammon
+// https://www.gammon.com.au/forum/?id=10896
+// Version 5, March 28, 2013
+// As version 4, but address scans now to 127.
+// A sensor seems to use address 120.
+// Version 6, November 27, 2015.
+// Added waiting for the Leonardo serial communication.
+//
+//
+// This sketch tests the standard 7-bit addresses
+// Devices with higher bit address might not be seen properly.
+//
+
+#include <Wire.h>
+
+void setup() {
+ Wire.begin();
+
+ Serial.begin(9600);
+ while (!Serial); // Leonardo: wait for serial monitor
+ Serial.println("\nI2C Scanner");
+}
+
+void loop() {
+ int nDevices = 0;
+
+ Serial.println("Scanning...");
+
+ for (byte address = 1; address < 127; ++address) {
+ // The i2c_scanner uses the return value of
+ // the Write.endTransmisstion to see if
+ // a device did acknowledge to the address.
+ Wire.beginTransmission(address);
+ byte error = Wire.endTransmission();
+
+ if (error == 0) {
+ Serial.print("I2C device found at address 0x");
+ if (address < 16) {
+ Serial.print("0");
+ }
+ Serial.print(address, HEX);
+ Serial.println(" !");
+
+ ++nDevices;
+ } else if (error == 4) {
+ Serial.print("Unknown error at address 0x");
+ if (address < 16) {
+ Serial.print("0");
+ }
+ Serial.println(address, HEX);
+ }
+ }
+ if (nDevices == 0) {
+ Serial.println("No I2C devices found\n");
+ } else {
+ Serial.println("done\n");
+ }
+ delay(5000); // Wait 5 seconds for next scan
+}
diff --git a/libraries/Wire/src/Wire.cpp b/libraries/Wire/src/Wire.cpp
index d2146f7..58916ce 100644
--- a/libraries/Wire/src/Wire.cpp
+++ b/libraries/Wire/src/Wire.cpp
@@ -17,6 +17,7 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Modified 2012 by Todd Krein (todd@krein.org) to implement repeated starts
+ Modified 2017 by Chuck Todd (ctodd@cableone.net) to correct Unconfigured Slave Mode reboot
*/
extern "C" {
@@ -60,14 +61,14 @@ void TwoWire::begin(void)
txBufferLength = 0;
twi_init();
+ twi_attachSlaveTxEvent(onRequestService); // default callback must exist
+ twi_attachSlaveRxEvent(onReceiveService); // default callback must exist
}
void TwoWire::begin(uint8_t address)
{
- twi_setAddress(address);
- twi_attachSlaveTxEvent(onRequestService);
- twi_attachSlaveRxEvent(onReceiveService);
begin();
+ twi_setAddress(address);
}
void TwoWire::begin(int address)
diff --git a/libraries/Wire/src/utility/twi.c b/libraries/Wire/src/utility/twi.c
index 171af73..1a35146 100644
--- a/libraries/Wire/src/utility/twi.c
+++ b/libraries/Wire/src/utility/twi.c
@@ -445,6 +445,7 @@ ISR(TWI_vect)
case TW_MR_DATA_ACK: // data received, ack sent
// put byte into buffer
twi_masterBuffer[twi_masterBufferIndex++] = TWDR;
+ __attribute__ ((fallthrough));
case TW_MR_SLA_ACK: // address sent, ack received
// ack if more bytes are expected, otherwise nack
if(twi_masterBufferIndex < twi_masterBufferLength){
@@ -530,6 +531,7 @@ ISR(TWI_vect)
twi_txBufferLength = 1;
twi_txBuffer[0] = 0x00;
}
+ __attribute__ ((fallthrough));
// transmit first byte from buffer, fall
case TW_ST_DATA_ACK: // byte sent, ack returned
// copy data to output register
diff --git a/platform.txt b/platform.txt
index f7fb447..9d18d7b 100644
--- a/platform.txt
+++ b/platform.txt
@@ -6,7 +6,7 @@
# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5-3rd-party-Hardware-specification
name=Arduino AVR Boards
-version=1.6.20
+version=1.6.23
# AVR compile variables
# ---------------------
@@ -25,7 +25,7 @@ compiler.c.elf.flags={compiler.warning_flags} -Os -g -flto -fuse-linker-plugin -
compiler.c.elf.cmd=avr-gcc
compiler.S.flags=-c -g -x assembler-with-cpp -flto -MMD
compiler.cpp.cmd=avr-g++
-compiler.cpp.flags=-c -g -Os {compiler.warning_flags} -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto
+compiler.cpp.flags=-c -g -Os {compiler.warning_flags} -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto
compiler.ar.cmd=avr-gcc-ar
compiler.ar.flags=rcs
compiler.objcopy.cmd=avr-objcopy
@@ -65,7 +65,7 @@ archive_file_path={build.path}/{archive_file}
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}"
## Combine gc-sections, archives, and objects
-recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} -mmcu={build.mcu} {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" {object_files} "{build.path}/{archive_file}" "-L{build.path}" -lm
+recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} -mmcu={build.mcu} {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} "{build.path}/{archive_file}" "-L{build.path}" -lm
## Create output files (.eep and .hex)
recipe.objcopy.eep.pattern="{compiler.path}{compiler.objcopy.cmd}" {compiler.objcopy.eep.flags} {compiler.objcopy.eep.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.eep"
diff --git a/programmers.txt b/programmers.txt
index c100e84..69ddf69 100644
--- a/programmers.txt
+++ b/programmers.txt
@@ -50,6 +50,15 @@ arduinoasisp.program.speed=19200
arduinoasisp.program.tool=avrdude
arduinoasisp.program.extra_params=-P{serial.port} -b{program.speed}
+arduinoasispatmega32u4.name=Arduino as ISP (ATmega32U4)
+arduinoasispatmega32u4.communication=serial
+arduinoasispatmega32u4.protocol=arduino
+arduinoasispatmega32u4.speed=19200
+arduinoasispatmega32u4.program.protocol=arduino
+arduinoasispatmega32u4.program.speed=19200
+arduinoasispatmega32u4.program.tool=avrdude
+arduinoasispatmega32u4.program.extra_params=-P{serial.port} -b{program.speed}
+
usbGemma.name=Arduino Gemma
usbGemma.protocol=arduinogemma
usbGemma.program.tool=avrdude