[gnoduino] arduino: update hardware to git master sdk (pre 1.0.6)
- From: Lucian Langa <lucilanga src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnoduino] arduino: update hardware to git master sdk (pre 1.0.6)
- Date: Wed, 24 Sep 2014 19:56:26 +0000 (UTC)
commit b045d9ef4191ec8a283254aa2e20bd349f3c735b
Author: Pascal de Bruijn <pmjdebruijn pcode nl>
Date: Thu Jul 17 18:20:22 2014 +0200
arduino: update hardware to git master sdk (pre 1.0.6)
hardware/arduino/boards.txt | 187 ++++++++++------
.../arduino/bootloaders/atmega/ATmegaBOOT_168.c | 20 +-
hardware/arduino/cores/arduino/Arduino.h | 20 ++
hardware/arduino/cores/arduino/CDC.cpp | 77 ++-----
hardware/arduino/cores/arduino/Client.h | 19 ++
hardware/arduino/cores/arduino/HardwareSerial.cpp | 2 +-
hardware/arduino/cores/arduino/IPAddress.cpp | 18 ++
hardware/arduino/cores/arduino/IPAddress.h | 40 ++--
hardware/arduino/cores/arduino/Print.cpp | 8 +-
hardware/arduino/cores/arduino/Print.h | 3 +
hardware/arduino/cores/arduino/Server.h | 19 ++
hardware/arduino/cores/arduino/Stream.cpp | 2 +-
hardware/arduino/cores/arduino/USBAPI.h | 10 +-
hardware/arduino/cores/arduino/USBCore.cpp | 7 +-
hardware/arduino/cores/arduino/WString.cpp | 82 +++++--
hardware/arduino/cores/arduino/WString.h | 17 +-
hardware/arduino/cores/arduino/binary.h | 19 ++
hardware/arduino/cores/arduino/main.cpp | 26 +++
hardware/arduino/cores/arduino/wiring_analog.c | 16 +-
hardware/arduino/programmers.txt | 4 -
hardware/arduino/variants/ethernet/pins_arduino.h | 236 ++++++++++++++++++++
hardware/arduino/variants/leonardo/pins_arduino.h | 24 ++
hardware/arduino/variants/mega/pins_arduino.h | 30 +++-
hardware/arduino/variants/standard/pins_arduino.h | 22 ++-
24 files changed, 692 insertions(+), 216 deletions(-)
---
diff --git a/hardware/arduino/boards.txt b/hardware/arduino/boards.txt
index d15b3ef..fec4655 100644
--- a/hardware/arduino/boards.txt
+++ b/hardware/arduino/boards.txt
@@ -146,66 +146,66 @@ mega.build.variant=mega
##############################################################
-#leonardo.name=Arduino Leonardo
-#leonardo.upload.protocol=avr109
-#leonardo.upload.maximum_size=28672
-#leonardo.upload.speed=57600
-#leonardo.upload.disable_flushing=true
-#leonardo.bootloader.low_fuses=0xff
-#leonardo.bootloader.high_fuses=0xd8
-#leonardo.bootloader.extended_fuses=0xcb
-#leonardo.bootloader.path=caterina
-#leonardo.bootloader.file=Caterina-Leonardo.hex
-#leonardo.bootloader.unlock_bits=0x3F
-#leonardo.bootloader.lock_bits=0x2F
-#leonardo.build.mcu=atmega32u4
-#leonardo.build.f_cpu=16000000L
-#leonardo.build.vid=0x2341
-#leonardo.build.pid=0x8036
-#leonardo.build.core=arduino
-#leonardo.build.variant=leonardo
+leonardo.name=Arduino Leonardo
+leonardo.upload.protocol=avr109
+leonardo.upload.maximum_size=28672
+leonardo.upload.speed=57600
+leonardo.upload.disable_flushing=true
+leonardo.bootloader.low_fuses=0xff
+leonardo.bootloader.high_fuses=0xd8
+leonardo.bootloader.extended_fuses=0xcb
+leonardo.bootloader.path=caterina
+leonardo.bootloader.file=Caterina-Leonardo.hex
+leonardo.bootloader.unlock_bits=0x3F
+leonardo.bootloader.lock_bits=0x2F
+leonardo.build.mcu=atmega32u4
+leonardo.build.f_cpu=16000000L
+leonardo.build.vid=0x2341
+leonardo.build.pid=0x8036
+leonardo.build.core=arduino
+leonardo.build.variant=leonardo
##############################################################
-#esplora.name=Arduino Esplora
-#esplora.upload.protocol=avr109
-#esplora.upload.maximum_size=28672
-#esplora.upload.speed=57600
-#esplora.upload.disable_flushing=true
-#esplora.bootloader.low_fuses=0xff
-#esplora.bootloader.high_fuses=0xd8
-#esplora.bootloader.extended_fuses=0xcb
-#esplora.bootloader.path=caterina
-#esplora.bootloader.file=Caterina-Esplora.hex
-#esplora.bootloader.unlock_bits=0x3F
-#esplora.bootloader.lock_bits=0x2F
-#esplora.build.mcu=atmega32u4
-#esplora.build.f_cpu=16000000L
-#esplora.build.vid=0x2341
-#esplora.build.pid=0x803C
-#esplora.build.core=arduino
-#esplora.build.variant=leonardo
+esplora.name=Arduino Esplora
+esplora.upload.protocol=avr109
+esplora.upload.maximum_size=28672
+esplora.upload.speed=57600
+esplora.upload.disable_flushing=true
+esplora.bootloader.low_fuses=0xff
+esplora.bootloader.high_fuses=0xd8
+esplora.bootloader.extended_fuses=0xcb
+esplora.bootloader.path=caterina
+esplora.bootloader.file=Caterina-Esplora.hex
+esplora.bootloader.unlock_bits=0x3F
+esplora.bootloader.lock_bits=0x2F
+esplora.build.mcu=atmega32u4
+esplora.build.f_cpu=16000000L
+esplora.build.vid=0x2341
+esplora.build.pid=0x803C
+esplora.build.core=arduino
+esplora.build.variant=leonardo
##############################################################
-#micro.name=Arduino Micro
-#micro.upload.protocol=avr109
-#micro.upload.maximum_size=28672
-#micro.upload.speed=57600
-#micro.upload.disable_flushing=true
-#micro.bootloader.low_fuses=0xff
-#micro.bootloader.high_fuses=0xd8
-#micro.bootloader.extended_fuses=0xcb
-#micro.bootloader.path=caterina
-#micro.bootloader.file=Caterina-Micro.hex
-#micro.bootloader.unlock_bits=0x3F
-#micro.bootloader.lock_bits=0x2F
-#micro.build.mcu=atmega32u4
-#micro.build.f_cpu=16000000L
-#micro.build.vid=0x2341
-#micro.build.pid=0x8037
-#micro.build.core=arduino
-#micro.build.variant=micro
+micro.name=Arduino Micro
+micro.upload.protocol=avr109
+micro.upload.maximum_size=28672
+micro.upload.speed=57600
+micro.upload.disable_flushing=true
+micro.bootloader.low_fuses=0xff
+micro.bootloader.high_fuses=0xd8
+micro.bootloader.extended_fuses=0xcb
+micro.bootloader.path=caterina
+micro.bootloader.file=Caterina-Micro.hex
+micro.bootloader.unlock_bits=0x3F
+micro.bootloader.lock_bits=0x2F
+micro.build.mcu=atmega32u4
+micro.build.f_cpu=16000000L
+micro.build.vid=0x2341
+micro.build.pid=0x8037
+micro.build.core=arduino
+micro.build.variant=micro
##############################################################
@@ -265,7 +265,7 @@ ethernet.bootloader.file=optiboot_atmega328.hex
ethernet.bootloader.unlock_bits=0x3F
ethernet.bootloader.lock_bits=0x0F
-ethernet.build.variant=standard
+ethernet.build.variant=ethernet
ethernet.build.mcu=atmega328p
ethernet.build.f_cpu=16000000L
ethernet.build.core=arduino
@@ -337,24 +337,24 @@ bt.build.variant=eightanaloginputs
##############################################################
-#LilyPadUSB.name=LilyPad Arduino USB
-#LilyPadUSB.upload.protocol=avr109
-#LilyPadUSB.upload.maximum_size=28672
-#LilyPadUSB.upload.speed=57600
-#LilyPadUSB.upload.disable_flushing=true
-#LilyPadUSB.bootloader.low_fuses=0xff
-#LilyPadUSB.bootloader.high_fuses=0xd8
-#LilyPadUSB.bootloader.extended_fuses=0xce
-#LilyPadUSB.bootloader.path=caterina-LilyPadUSB
-#LilyPadUSB.bootloader.file=Caterina-LilyPadUSB.hex
-#LilyPadUSB.bootloader.unlock_bits=0x3F
-#LilyPadUSB.bootloader.lock_bits=0x2F
-#LilyPadUSB.build.mcu=atmega32u4
-#LilyPadUSB.build.f_cpu=8000000L
-#LilyPadUSB.build.vid=0x1B4F
-#LilyPadUSB.build.pid=0x9208
-#LilyPadUSB.build.core=arduino
-#LilyPadUSB.build.variant=leonardo
+LilyPadUSB.name=LilyPad Arduino USB
+LilyPadUSB.upload.protocol=avr109
+LilyPadUSB.upload.maximum_size=28672
+LilyPadUSB.upload.speed=57600
+LilyPadUSB.upload.disable_flushing=true
+LilyPadUSB.bootloader.low_fuses=0xff
+LilyPadUSB.bootloader.high_fuses=0xd8
+LilyPadUSB.bootloader.extended_fuses=0xce
+LilyPadUSB.bootloader.path=caterina-LilyPadUSB
+LilyPadUSB.bootloader.file=Caterina-LilyPadUSB.hex
+LilyPadUSB.bootloader.unlock_bits=0x3F
+LilyPadUSB.bootloader.lock_bits=0x2F
+LilyPadUSB.build.mcu=atmega32u4
+LilyPadUSB.build.f_cpu=8000000L
+LilyPadUSB.build.vid=0x1B4F
+LilyPadUSB.build.pid=0x9208
+LilyPadUSB.build.core=arduino
+LilyPadUSB.build.variant=leonardo
##############################################################
@@ -523,3 +523,44 @@ atmega8.build.f_cpu=16000000L
atmega8.build.core=arduino
atmega8.build.variant=standard
+##############################################################
+
+robotControl.name=Arduino Robot Control
+robotControl.upload.protocol=avr109
+robotControl.upload.maximum_size=28672
+robotControl.upload.speed=57600
+robotControl.upload.disable_flushing=true
+robotControl.bootloader.low_fuses=0xff
+robotControl.bootloader.high_fuses=0xd8
+robotControl.bootloader.extended_fuses=0xcb
+robotControl.bootloader.path=caterina-Arduino_Robot
+robotControl.bootloader.file=Caterina-Robot-Control.hex
+robotControl.bootloader.unlock_bits=0x3F
+robotControl.bootloader.lock_bits=0x2F
+robotControl.build.mcu=atmega32u4
+robotControl.build.f_cpu=16000000L
+robotControl.build.vid=0x2341
+robotControl.build.pid=0x8038
+robotControl.build.core=robot
+robotControl.build.variant=robot_control
+
+##############################################################
+
+robotMotor.name=Arduino Robot Motor
+robotMotor.upload.protocol=avr109
+robotMotor.upload.maximum_size=28672
+robotMotor.upload.speed=57600
+robotMotor.upload.disable_flushing=true
+robotMotor.bootloader.low_fuses=0xff
+robotMotor.bootloader.high_fuses=0xd8
+robotMotor.bootloader.extended_fuses=0xcb
+robotMotor.bootloader.path=caterina-Arduino_Robot
+robotMotor.bootloader.file=Caterina-Robot-Motor.hex
+robotMotor.bootloader.unlock_bits=0x3F
+robotMotor.bootloader.lock_bits=0x2F
+robotMotor.build.mcu=atmega32u4
+robotMotor.build.f_cpu=16000000L
+robotMotor.build.vid=0x2341
+robotMotor.build.pid=0x8039
+robotMotor.build.core=robot
+robotMotor.build.variant=robot_motor
diff --git a/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168.c
b/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168.c
index 2b9fefa..721f8ea 100644
--- a/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168.c
+++ b/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168.c
@@ -947,16 +947,16 @@ char getch(void)
while(!(UCSR0A & _BV(RXC0))) {
/* 20060803 DojoCorp:: Addon coming from the previous Bootloader*/
/* HACKME:: here is a good place to count times*/
- count++;
- if (count > MAX_TIME_COUNT)
- app_start();
- }
-
- return UDR0;
- }
- else if(bootuart == 2) {
- while(!(UCSR1A & _BV(RXC1))) {
- /* 20060803 DojoCorp:: Addon coming from the previous Bootloader*/
+ count++;
+ if (count > MAX_TIME_COUNT)
+ app_start();
+ }
+
+ return UDR0;
+ }
+ else if(bootuart == 2) {
+ while(!(UCSR1A & _BV(RXC1))) {
+ /* 20060803 DojoCorp:: Addon coming from the previous Bootloader*/
/* HACKME:: here is a good place to count times*/
count++;
if (count > MAX_TIME_COUNT)
diff --git a/hardware/arduino/cores/arduino/Arduino.h b/hardware/arduino/cores/arduino/Arduino.h
index 3b9ccca..425dfcb 100644
--- a/hardware/arduino/cores/arduino/Arduino.h
+++ b/hardware/arduino/cores/arduino/Arduino.h
@@ -1,3 +1,22 @@
+/*
+ Arduino.h - Main include file for the Arduino SDK
+ Copyright (c) 2005-2013 Arduino Team. 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
+*/
+
#ifndef Arduino_h
#define Arduino_h
@@ -94,6 +113,7 @@ typedef uint8_t boolean;
typedef uint8_t byte;
void init(void);
+void initVariant(void);
void pinMode(uint8_t, uint8_t);
void digitalWrite(uint8_t, uint8_t);
diff --git a/hardware/arduino/cores/arduino/CDC.cpp b/hardware/arduino/cores/arduino/CDC.cpp
index 701e483..aae91c2 100644
--- a/hardware/arduino/cores/arduino/CDC.cpp
+++ b/hardware/arduino/cores/arduino/CDC.cpp
@@ -23,21 +23,6 @@
#if defined(USBCON)
#ifdef CDC_ENABLED
-#if (RAMEND < 1000)
-#define SERIAL_BUFFER_SIZE 16
-#else
-#define SERIAL_BUFFER_SIZE 64
-#endif
-
-struct ring_buffer
-{
- unsigned char buffer[SERIAL_BUFFER_SIZE];
- volatile int head;
- volatile int tail;
-};
-
-ring_buffer cdc_rx_buffer = { { 0 }, 0, 0};
-
typedef struct
{
u32 dwDTERate;
@@ -129,64 +114,43 @@ bool WEAK CDC_Setup(Setup& setup)
}
-int _serialPeek = -1;
-void Serial_::begin(uint16_t baud_count)
+void Serial_::begin(unsigned long baud_count)
{
+ peek_buffer = -1;
}
-void Serial_::end(void)
+void Serial_::begin(unsigned long baud_count, byte config)
{
+ peek_buffer = -1;
}
-void Serial_::accept(void)
+void Serial_::end(void)
{
- ring_buffer *buffer = &cdc_rx_buffer;
- int i = (unsigned int)(buffer->head+1) % SERIAL_BUFFER_SIZE;
-
- // if we should be storing the received character into the location
- // just before the tail (meaning that the head would advance to the
- // current location of the tail), we're about to overflow the buffer
- // and so we don't write the character or advance the head.
-
- // while we have room to store a byte
- while (i != buffer->tail) {
- int c = USB_Recv(CDC_RX);
- if (c == -1)
- break; // no more data
- buffer->buffer[buffer->head] = c;
- buffer->head = i;
-
- i = (unsigned int)(buffer->head+1) % SERIAL_BUFFER_SIZE;
- }
}
int Serial_::available(void)
{
- ring_buffer *buffer = &cdc_rx_buffer;
- return (unsigned int)(SERIAL_BUFFER_SIZE + buffer->head - buffer->tail) % SERIAL_BUFFER_SIZE;
+ if (peek_buffer >= 0) {
+ return 1 + USB_Available(CDC_RX);
+ }
+ return USB_Available(CDC_RX);
}
int Serial_::peek(void)
{
- ring_buffer *buffer = &cdc_rx_buffer;
- if (buffer->head == buffer->tail) {
- return -1;
- } else {
- return buffer->buffer[buffer->tail];
- }
+ if (peek_buffer < 0)
+ peek_buffer = USB_Recv(CDC_RX);
+ return peek_buffer;
}
int Serial_::read(void)
{
- ring_buffer *buffer = &cdc_rx_buffer;
- // if the head isn't ahead of the tail, we don't have any characters
- if (buffer->head == buffer->tail) {
- return -1;
- } else {
- unsigned char c = buffer->buffer[buffer->tail];
- buffer->tail = (unsigned int)(buffer->tail + 1) % SERIAL_BUFFER_SIZE;
+ if (peek_buffer >= 0) {
+ int c = peek_buffer;
+ peek_buffer = -1;
return c;
- }
+ }
+ return USB_Recv(CDC_RX);
}
void Serial_::flush(void)
@@ -196,6 +160,11 @@ void Serial_::flush(void)
size_t Serial_::write(uint8_t c)
{
+ return write(&c, 1);
+}
+
+size_t Serial_::write(const uint8_t *buffer, size_t size)
+{
/* only try to send bytes if the high-level CDC connection itself
is open (not just the pipe) - the OS should set lineState when the port
is opened and clear lineState when the port is closed.
@@ -206,7 +175,7 @@ size_t Serial_::write(uint8_t c)
// open connection isn't broken cleanly (cable is yanked out, host dies
// or locks up, or host virtual serial port hangs)
if (_usbLineInfo.lineState > 0) {
- int r = USB_Send(CDC_TX,&c,1);
+ int r = USB_Send(CDC_TX,buffer,size);
if (r > 0) {
return r;
} else {
diff --git a/hardware/arduino/cores/arduino/Client.h b/hardware/arduino/cores/arduino/Client.h
index ea13483..b8e5d93 100644
--- a/hardware/arduino/cores/arduino/Client.h
+++ b/hardware/arduino/cores/arduino/Client.h
@@ -1,3 +1,22 @@
+/*
+ Client.h - Base class that provides Client
+ Copyright (c) 2011 Adrian McEwen. 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
+*/
+
#ifndef client_h
#define client_h
#include "Print.h"
diff --git a/hardware/arduino/cores/arduino/HardwareSerial.cpp
b/hardware/arduino/cores/arduino/HardwareSerial.cpp
index eb2365f..1a2f8ce 100644
--- a/hardware/arduino/cores/arduino/HardwareSerial.cpp
+++ b/hardware/arduino/cores/arduino/HardwareSerial.cpp
@@ -426,7 +426,7 @@ void HardwareSerial::end()
int HardwareSerial::available(void)
{
- return (unsigned int)(SERIAL_BUFFER_SIZE + _rx_buffer->head - _rx_buffer->tail) % SERIAL_BUFFER_SIZE;
+ return (int)(SERIAL_BUFFER_SIZE + _rx_buffer->head - _rx_buffer->tail) % SERIAL_BUFFER_SIZE;
}
int HardwareSerial::peek(void)
diff --git a/hardware/arduino/cores/arduino/IPAddress.cpp b/hardware/arduino/cores/arduino/IPAddress.cpp
index fe3deb7..3532172 100644
--- a/hardware/arduino/cores/arduino/IPAddress.cpp
+++ b/hardware/arduino/cores/arduino/IPAddress.cpp
@@ -1,3 +1,21 @@
+/*
+ IPAddress.cpp - Base class that provides IPAddress
+ Copyright (c) 2011 Adrian McEwen. 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
+*/
#include <Arduino.h>
#include <IPAddress.h>
diff --git a/hardware/arduino/cores/arduino/IPAddress.h b/hardware/arduino/cores/arduino/IPAddress.h
index 2585aec..c2dd7e5 100644
--- a/hardware/arduino/cores/arduino/IPAddress.h
+++ b/hardware/arduino/cores/arduino/IPAddress.h
@@ -1,27 +1,21 @@
/*
- *
- * MIT License:
- * Copyright (c) 2011 Adrian McEwen
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * adrianm mcqn com 1/1/2011
- */
+ IPAddress.h - Base class that provides IPAddress
+ Copyright (c) 2011 Adrian McEwen. 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
+*/
#ifndef IPAddress_h
#define IPAddress_h
diff --git a/hardware/arduino/cores/arduino/Print.cpp b/hardware/arduino/cores/arduino/Print.cpp
index 53961ec..5df5630 100644
--- a/hardware/arduino/cores/arduino/Print.cpp
+++ b/hardware/arduino/cores/arduino/Print.cpp
@@ -41,7 +41,7 @@ size_t Print::write(const uint8_t *buffer, size_t size)
size_t Print::print(const __FlashStringHelper *ifsh)
{
- const char PROGMEM *p = (const char PROGMEM *)ifsh;
+ PGM_P p = reinterpret_cast<PGM_P>(ifsh);
size_t n = 0;
while (1) {
unsigned char c = pgm_read_byte(p++);
@@ -53,11 +53,7 @@ size_t Print::print(const __FlashStringHelper *ifsh)
size_t Print::print(const String &s)
{
- size_t n = 0;
- for (uint16_t i = 0; i < s.length(); i++) {
- n += write(s[i]);
- }
- return n;
+ return write(s.c_str(), s.length());
}
size_t Print::print(const char str[])
diff --git a/hardware/arduino/cores/arduino/Print.h b/hardware/arduino/cores/arduino/Print.h
index dc76150..7b53aa4 100644
--- a/hardware/arduino/cores/arduino/Print.h
+++ b/hardware/arduino/cores/arduino/Print.h
@@ -51,6 +51,9 @@ class Print
return write((const uint8_t *)str, strlen(str));
}
virtual size_t write(const uint8_t *buffer, size_t size);
+ size_t write(const char *buffer, size_t size) {
+ return write((const uint8_t *)buffer, size);
+ }
size_t print(const __FlashStringHelper *);
size_t print(const String &);
diff --git a/hardware/arduino/cores/arduino/Server.h b/hardware/arduino/cores/arduino/Server.h
index 9674c76..77c415c 100644
--- a/hardware/arduino/cores/arduino/Server.h
+++ b/hardware/arduino/cores/arduino/Server.h
@@ -1,3 +1,22 @@
+/*
+ Server.h - Base class that provides Server
+ Copyright (c) 2011 Adrian McEwen. 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
+*/
+
#ifndef server_h
#define server_h
diff --git a/hardware/arduino/cores/arduino/Stream.cpp b/hardware/arduino/cores/arduino/Stream.cpp
index aafb7fc..f21a411 100644
--- a/hardware/arduino/cores/arduino/Stream.cpp
+++ b/hardware/arduino/cores/arduino/Stream.cpp
@@ -75,7 +75,7 @@ void Stream::setTimeout(unsigned long timeout) // sets the maximum number of mi
// find returns true if the target string is found
bool Stream::find(char *target)
{
- return findUntil(target, NULL);
+ return findUntil(target, "");
}
// reads data from the stream until the target string of given length is found
diff --git a/hardware/arduino/cores/arduino/USBAPI.h b/hardware/arduino/cores/arduino/USBAPI.h
index eb2e593..4846fc2 100644
--- a/hardware/arduino/cores/arduino/USBAPI.h
+++ b/hardware/arduino/cores/arduino/USBAPI.h
@@ -28,17 +28,19 @@ extern USBDevice_ USBDevice;
class Serial_ : public Stream
{
private:
- ring_buffer *_cdc_rx_buffer;
+ int peek_buffer;
public:
- void begin(uint16_t baud_count);
+ Serial_() { peek_buffer = -1; };
+ void begin(unsigned long);
+ void begin(unsigned long, uint8_t);
void end(void);
virtual int available(void);
- virtual void accept(void);
virtual int peek(void);
virtual int read(void);
virtual void flush(void);
virtual size_t write(uint8_t);
+ virtual size_t write(const uint8_t*, size_t);
using Print::write; // pull in write(str) and write(buf, size) from Print
operator bool();
};
@@ -193,4 +195,4 @@ void USB_Flush(uint8_t ep);
#endif
-#endif /* if defined(USBCON) */
\ No newline at end of file
+#endif /* if defined(USBCON) */
diff --git a/hardware/arduino/cores/arduino/USBCore.cpp b/hardware/arduino/cores/arduino/USBCore.cpp
index d3e0170..f8123e5 100644
--- a/hardware/arduino/cores/arduino/USBCore.cpp
+++ b/hardware/arduino/cores/arduino/USBCore.cpp
@@ -290,9 +290,12 @@ int USB_Send(u8 ep, const void* d, int len)
if (n > len)
n = len;
- len -= n;
{
LockEP lock(ep);
+ // Frame may have been released by the SOF interrupt handler
+ if (!ReadWriteAllowed())
+ continue;
+ len -= n;
if (ep & TRANSFER_ZERO)
{
while (n--)
@@ -611,8 +614,6 @@ ISR(USB_GEN_vect)
{
#ifdef CDC_ENABLED
USB_Flush(CDC_TX); // Send a tx frame if found
- if (USB_Available(CDC_RX)) // Handle received bytes (if any)
- Serial.accept();
#endif
// check whether the one-shot period has elapsed. if so, turn off the LED
diff --git a/hardware/arduino/cores/arduino/WString.cpp b/hardware/arduino/cores/arduino/WString.cpp
index e19f543..ed880ce 100644
--- a/hardware/arduino/cores/arduino/WString.cpp
+++ b/hardware/arduino/cores/arduino/WString.cpp
@@ -21,7 +21,6 @@
#include "WString.h"
-
/*********************************************/
/* Constructors */
/*********************************************/
@@ -38,6 +37,12 @@ String::String(const String &value)
*this = value;
}
+String::String(const __FlashStringHelper *pstr)
+{
+ init();
+ *this = pstr;
+}
+
#ifdef __GXX_EXPERIMENTAL_CXX0X__
String::String(String &&rval)
{
@@ -63,7 +68,7 @@ String::String(char c)
String::String(unsigned char value, unsigned char base)
{
init();
- char buf[9];
+ char buf[1 + 8 * sizeof(unsigned char)];
utoa(value, buf, base);
*this = buf;
}
@@ -71,7 +76,7 @@ String::String(unsigned char value, unsigned char base)
String::String(int value, unsigned char base)
{
init();
- char buf[18];
+ char buf[2 + 8 * sizeof(int)];
itoa(value, buf, base);
*this = buf;
}
@@ -79,7 +84,7 @@ String::String(int value, unsigned char base)
String::String(unsigned int value, unsigned char base)
{
init();
- char buf[17];
+ char buf[1 + 8 * sizeof(unsigned int)];
utoa(value, buf, base);
*this = buf;
}
@@ -87,7 +92,7 @@ String::String(unsigned int value, unsigned char base)
String::String(long value, unsigned char base)
{
init();
- char buf[34];
+ char buf[2 + 8 * sizeof(long)];
ltoa(value, buf, base);
*this = buf;
}
@@ -95,24 +100,25 @@ String::String(long value, unsigned char base)
String::String(unsigned long value, unsigned char base)
{
init();
- char buf[33];
+ char buf[1 + 8 * sizeof(unsigned long)];
ultoa(value, buf, base);
*this = buf;
}
-String::String(float value, int decimalPlaces)
+String::String(float value, unsigned char decimalPlaces)
{
init();
char buf[33];
*this = dtostrf(value, (decimalPlaces + 2), decimalPlaces, buf);
}
-String::String(double value, int decimalPlaces)
+String::String(double value, unsigned char decimalPlaces)
{
init();
char buf[33];
*this = dtostrf(value, (decimalPlaces + 2), decimalPlaces, buf);
}
+
String::~String()
{
free(buffer);
@@ -127,7 +133,6 @@ inline void String::init(void)
buffer = NULL;
capacity = 0;
len = 0;
- flags = 0;
}
void String::invalidate(void)
@@ -173,6 +178,17 @@ String & String::copy(const char *cstr, unsigned int length)
return *this;
}
+String & String::copy(const __FlashStringHelper *pstr, unsigned int length)
+{
+ if (!reserve(length)) {
+ invalidate();
+ return *this;
+ }
+ len = length;
+ strcpy_P(buffer, (PGM_P)pstr);
+ return *this;
+}
+
#ifdef __GXX_EXPERIMENTAL_CXX0X__
void String::move(String &rhs)
{
@@ -227,6 +243,14 @@ String & String::operator = (const char *cstr)
return *this;
}
+String & String::operator = (const __FlashStringHelper *pstr)
+{
+ if (pstr) copy(pstr, strlen_P((PGM_P)pstr));
+ else invalidate();
+
+ return *this;
+}
+
/*********************************************/
/* concat */
/*********************************************/
@@ -263,35 +287,35 @@ unsigned char String::concat(char c)
unsigned char String::concat(unsigned char num)
{
- char buf[4];
+ char buf[1 + 3 * sizeof(unsigned char)];
itoa(num, buf, 10);
return concat(buf, strlen(buf));
}
unsigned char String::concat(int num)
{
- char buf[7];
+ char buf[2 + 3 * sizeof(int)];
itoa(num, buf, 10);
return concat(buf, strlen(buf));
}
unsigned char String::concat(unsigned int num)
{
- char buf[6];
+ char buf[1 + 3 * sizeof(unsigned int)];
utoa(num, buf, 10);
return concat(buf, strlen(buf));
}
unsigned char String::concat(long num)
{
- char buf[12];
+ char buf[2 + 3 * sizeof(long)];
ltoa(num, buf, 10);
return concat(buf, strlen(buf));
}
unsigned char String::concat(unsigned long num)
{
- char buf[11];
+ char buf[1 + 3 * sizeof(unsigned long)];
ultoa(num, buf, 10);
return concat(buf, strlen(buf));
}
@@ -299,17 +323,29 @@ unsigned char String::concat(unsigned long num)
unsigned char String::concat(float num)
{
char buf[20];
- char* string = dtostrf(num, 8, 6, buf);
+ char* string = dtostrf(num, 4, 2, buf);
return concat(string, strlen(string));
}
unsigned char String::concat(double num)
{
char buf[20];
- char* string = dtostrf(num, 8, 6, buf);
+ char* string = dtostrf(num, 4, 2, buf);
return concat(string, strlen(string));
}
+unsigned char String::concat(const __FlashStringHelper * str)
+{
+ if (!str) return 0;
+ int length = strlen_P((const char *) str);
+ if (length == 0) return 1;
+ unsigned int newlen = len + length;
+ if (!reserve(newlen)) return 0;
+ strcpy_P(buffer + len, (const char *) str);
+ len = newlen;
+ return 1;
+}
+
/*********************************************/
/* Concatenate */
/*********************************************/
@@ -383,6 +419,14 @@ StringSumHelper & operator + (const StringSumHelper &lhs, double num)
if (!a.concat(num)) a.invalidate();
return a;
}
+
+StringSumHelper & operator + (const StringSumHelper &lhs, const __FlashStringHelper *rhs)
+{
+ StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
+ if (!a.concat(rhs)) a.invalidate();
+ return a;
+}
+
/*********************************************/
/* Comparison */
/*********************************************/
@@ -567,11 +611,6 @@ int String::lastIndexOf(const String &s2, unsigned int fromIndex) const
return found;
}
-String String::substring( unsigned int left ) const
-{
- return substring(left, len);
-}
-
String String::substring(unsigned int left, unsigned int right) const
{
if (left > right) {
@@ -698,7 +737,6 @@ long String::toInt(void) const
return 0;
}
-
float String::toFloat(void) const
{
if (buffer) return float(atof(buffer));
diff --git a/hardware/arduino/cores/arduino/WString.h b/hardware/arduino/cores/arduino/WString.h
index 2d372c5..7402430 100644
--- a/hardware/arduino/cores/arduino/WString.h
+++ b/hardware/arduino/cores/arduino/WString.h
@@ -58,6 +58,7 @@ public:
// be false).
String(const char *cstr = "");
String(const String &str);
+ String(const __FlashStringHelper *str);
#ifdef __GXX_EXPERIMENTAL_CXX0X__
String(String &&rval);
String(StringSumHelper &&rval);
@@ -68,8 +69,8 @@ public:
explicit String(unsigned int, unsigned char base=10);
explicit String(long, unsigned char base=10);
explicit String(unsigned long, unsigned char base=10);
- explicit String(float, int decimalPlaces=6);
- explicit String(double, int decimalPlaces=6);
+ explicit String(float, unsigned char decimalPlaces=2);
+ explicit String(double, unsigned char decimalPlaces=2);
~String(void);
// memory management
@@ -84,6 +85,7 @@ public:
// marked as invalid ("if (s)" will be false).
String & operator = (const String &rhs);
String & operator = (const char *cstr);
+ String & operator = (const __FlashStringHelper *str);
#ifdef __GXX_EXPERIMENTAL_CXX0X__
String & operator = (String &&rval);
String & operator = (StringSumHelper &&rval);
@@ -104,6 +106,7 @@ public:
unsigned char concat(unsigned long num);
unsigned char concat(float num);
unsigned char concat(double num);
+ unsigned char concat(const __FlashStringHelper * str);
// if there's not enough memory for the concatenated value, the string
// will be left unchanged (but this isn't signalled in any way)
@@ -115,6 +118,9 @@ public:
String & operator += (unsigned int num) {concat(num); return (*this);}
String & operator += (long num) {concat(num); return (*this);}
String & operator += (unsigned long num) {concat(num); return (*this);}
+ String & operator += (float num) {concat(num); return (*this);}
+ String & operator += (double num) {concat(num); return (*this);}
+ String & operator += (const __FlashStringHelper *str){concat(str); return (*this);}
friend StringSumHelper & operator + (const StringSumHelper &lhs, const String &rhs);
friend StringSumHelper & operator + (const StringSumHelper &lhs, const char *cstr);
@@ -126,6 +132,7 @@ public:
friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned long num);
friend StringSumHelper & operator + (const StringSumHelper &lhs, float num);
friend StringSumHelper & operator + (const StringSumHelper &lhs, double num);
+ friend StringSumHelper & operator + (const StringSumHelper &lhs, const __FlashStringHelper *rhs);
// comparison (only works w/ Strings and "strings")
operator StringIfHelperType() const { return buffer ? &String::StringIfHelper : 0; }
@@ -164,7 +171,7 @@ public:
int lastIndexOf( char ch, unsigned int fromIndex ) const;
int lastIndexOf( const String &str ) const;
int lastIndexOf( const String &str, unsigned int fromIndex ) const;
- String substring( unsigned int beginIndex ) const;
+ String substring( unsigned int beginIndex ) const { return substring(beginIndex, len); };
String substring( unsigned int beginIndex, unsigned int endIndex ) const;
// modification
@@ -184,7 +191,6 @@ protected:
char *buffer; // the actual char array
unsigned int capacity; // the array length minus one (for the '\0')
unsigned int len; // the String length (not counting the '\0')
- unsigned char flags; // unused, for future features
protected:
void init(void);
void invalidate(void);
@@ -193,6 +199,7 @@ protected:
// copy and move
String & copy(const char *cstr, unsigned int length);
+ String & copy(const __FlashStringHelper *pstr, unsigned int length);
#ifdef __GXX_EXPERIMENTAL_CXX0X__
void move(String &rhs);
#endif
@@ -209,6 +216,8 @@ public:
StringSumHelper(unsigned int num) : String(num) {}
StringSumHelper(long num) : String(num) {}
StringSumHelper(unsigned long num) : String(num) {}
+ StringSumHelper(float num) : String(num) {}
+ StringSumHelper(double num) : String(num) {}
};
#endif // __cplusplus
diff --git a/hardware/arduino/cores/arduino/binary.h b/hardware/arduino/cores/arduino/binary.h
index af14980..aec4c73 100644
--- a/hardware/arduino/cores/arduino/binary.h
+++ b/hardware/arduino/cores/arduino/binary.h
@@ -1,3 +1,22 @@
+/*
+ binary.h - Definitions for binary constants
+ Copyright (c) 2006 David A. Mellis. 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
+*/
+
#ifndef Binary_h
#define Binary_h
diff --git a/hardware/arduino/cores/arduino/main.cpp b/hardware/arduino/cores/arduino/main.cpp
index 3d4e079..091c365 100644
--- a/hardware/arduino/cores/arduino/main.cpp
+++ b/hardware/arduino/cores/arduino/main.cpp
@@ -1,9 +1,35 @@
+/*
+ main.cpp - Main loop for Arduino sketches
+ Copyright (c) 2005-2013 Arduino Team. 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
+*/
+
#include <Arduino.h>
+// Weak empty variant initialization function.
+// May be redefined by variant files.
+void initVariant() __attribute__((weak));
+void initVariant() { }
+
int main(void)
{
init();
+ initVariant();
+
#if defined(USBCON)
USBDevice.attach();
#endif
diff --git a/hardware/arduino/cores/arduino/wiring_analog.c b/hardware/arduino/cores/arduino/wiring_analog.c
index 7ed0e4e..8feead9 100644
--- a/hardware/arduino/cores/arduino/wiring_analog.c
+++ b/hardware/arduino/cores/arduino/wiring_analog.c
@@ -41,22 +41,22 @@ int analogRead(uint8_t pin)
{
uint8_t low, high;
-#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
+#if defined(analogPinToChannel)
+#if defined(__AVR_ATmega32U4__)
+ if (pin >= 18) pin -= 18; // allow for channel or pin numbers
+#endif
+ pin = analogPinToChannel(pin);
+#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
if (pin >= 54) pin -= 54; // allow for channel or pin numbers
#elif defined(__AVR_ATmega32U4__)
if (pin >= 18) pin -= 18; // allow for channel or pin numbers
#elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644__) ||
defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__)
if (pin >= 24) pin -= 24; // allow for channel or pin numbers
-#elif defined(analogPinToChannel) && (defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) ||
defined(__AVR_ATtiny85__))
- pin = analogPinToChannel(pin);
#else
if (pin >= 14) pin -= 14; // allow for channel or pin numbers
#endif
-
-#if defined(__AVR_ATmega32U4__)
- pin = analogPinToChannel(pin);
- ADCSRB = (ADCSRB & ~(1 << MUX5)) | (((pin >> 3) & 0x01) << MUX5);
-#elif defined(ADCSRB) && defined(MUX5)
+
+#if defined(ADCSRB) && defined(MUX5)
// the MUX5 bit of ADCSRB selects whether we're reading from channels
// 0 to 7 (MUX5 low) or 8 to 15 (MUX5 high).
ADCSRB = (ADCSRB & ~(1 << MUX5)) | (((pin >> 3) & 0x01) << MUX5);
diff --git a/hardware/arduino/programmers.txt b/hardware/arduino/programmers.txt
index 2374224..c34b88c 100644
--- a/hardware/arduino/programmers.txt
+++ b/hardware/arduino/programmers.txt
@@ -24,7 +24,3 @@ arduinoisp.name=Arduino as ISP
arduinoisp.communication=serial
arduinoisp.protocol=stk500v1
arduinoisp.speed=19200
-
-mysmartusblight.name=mySmartUSB light
-mysmartusblight.communication=serial
-mysmartusblight.protocol=stk500v2
diff --git a/hardware/arduino/variants/ethernet/pins_arduino.h
b/hardware/arduino/variants/ethernet/pins_arduino.h
new file mode 100644
index 0000000..14e4f90
--- /dev/null
+++ b/hardware/arduino/variants/ethernet/pins_arduino.h
@@ -0,0 +1,236 @@
+/*
+ pins_arduino.h - Pin definition functions for Arduino
+ Part of Arduino - http://www.arduino.cc/
+
+ Copyright (c) 2007 David A. Mellis
+
+ 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., 59 Temple Place, Suite 330,
+ Boston, MA 02111-1307 USA
+
+ $Id: wiring.h 249 2007-02-03 16:52:51Z mellis $
+*/
+
+#ifndef Pins_Arduino_h
+#define Pins_Arduino_h
+
+#include <avr/pgmspace.h>
+
+#define NUM_DIGITAL_PINS 20
+#define NUM_ANALOG_INPUTS 6
+#define analogInputToDigitalPin(p) ((p < 6) ? (p) + 14 : -1)
+
+#if defined(__AVR_ATmega8__)
+#define digitalPinHasPWM(p) ((p) == 9 || (p) == 10 || (p) == 11)
+#else
+#define digitalPinHasPWM(p) ((p) == 3 || (p) == 5 || (p) == 6 || (p) == 9 || (p) == 10 || (p) == 11)
+#endif
+
+static const uint8_t SS = 10;
+static const uint8_t MOSI = 11;
+static const uint8_t MISO = 12;
+static const uint8_t SCK = 13;
+
+static const uint8_t SDA = 18;
+static const uint8_t SCL = 19;
+#define LED_BUILTIN 9
+
+static const uint8_t A0 = 14;
+static const uint8_t A1 = 15;
+static const uint8_t A2 = 16;
+static const uint8_t A3 = 17;
+static const uint8_t A4 = 18;
+static const uint8_t A5 = 19;
+static const uint8_t A6 = 20;
+static const uint8_t A7 = 21;
+
+#define digitalPinToPCICR(p) (((p) >= 0 && (p) <= 21) ? (&PCICR) : ((uint8_t *)0))
+#define digitalPinToPCICRbit(p) (((p) <= 7) ? 2 : (((p) <= 13) ? 0 : 1))
+#define digitalPinToPCMSK(p) (((p) <= 7) ? (&PCMSK2) : (((p) <= 13) ? (&PCMSK0) : (((p) <= 21) ?
(&PCMSK1) : ((uint8_t *)0))))
+#define digitalPinToPCMSKbit(p) (((p) <= 7) ? (p) : (((p) <= 13) ? ((p) - 8) : ((p) - 14)))
+
+#ifdef ARDUINO_MAIN
+
+// On the Arduino board, digital pins are also used
+// for the analog output (software PWM). Analog input
+// pins are a separate set.
+
+// ATMEL ATMEGA8 & 168 / ARDUINO
+//
+// +-\/-+
+// PC6 1| |28 PC5 (AI 5)
+// (D 0) PD0 2| |27 PC4 (AI 4)
+// (D 1) PD1 3| |26 PC3 (AI 3)
+// (D 2) PD2 4| |25 PC2 (AI 2)
+// PWM+ (D 3) PD3 5| |24 PC1 (AI 1)
+// (D 4) PD4 6| |23 PC0 (AI 0)
+// VCC 7| |22 GND
+// GND 8| |21 AREF
+// PB6 9| |20 AVCC
+// PB7 10| |19 PB5 (D 13)
+// PWM+ (D 5) PD5 11| |18 PB4 (D 12)
+// PWM+ (D 6) PD6 12| |17 PB3 (D 11) PWM
+// (D 7) PD7 13| |16 PB2 (D 10) PWM
+// (D 8) PB0 14| |15 PB1 (D 9) PWM
+// +----+
+//
+// (PWM+ indicates the additional PWM pins on the ATmega168.)
+
+// ATMEL ATMEGA1280 / ARDUINO
+//
+// 0-7 PE0-PE7 works
+// 8-13 PB0-PB5 works
+// 14-21 PA0-PA7 works
+// 22-29 PH0-PH7 works
+// 30-35 PG5-PG0 works
+// 36-43 PC7-PC0 works
+// 44-51 PJ7-PJ0 works
+// 52-59 PL7-PL0 works
+// 60-67 PD7-PD0 works
+// A0-A7 PF0-PF7
+// A8-A15 PK0-PK7
+
+
+// these arrays map port names (e.g. port B) to the
+// appropriate addresses for various functions (e.g. reading
+// and writing)
+const uint16_t PROGMEM port_to_mode_PGM[] = {
+ NOT_A_PORT,
+ NOT_A_PORT,
+ (uint16_t) &DDRB,
+ (uint16_t) &DDRC,
+ (uint16_t) &DDRD,
+};
+
+const uint16_t PROGMEM port_to_output_PGM[] = {
+ NOT_A_PORT,
+ NOT_A_PORT,
+ (uint16_t) &PORTB,
+ (uint16_t) &PORTC,
+ (uint16_t) &PORTD,
+};
+
+const uint16_t PROGMEM port_to_input_PGM[] = {
+ NOT_A_PORT,
+ NOT_A_PORT,
+ (uint16_t) &PINB,
+ (uint16_t) &PINC,
+ (uint16_t) &PIND,
+};
+
+const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
+ PD, /* 0 */
+ PD,
+ PD,
+ PD,
+ PD,
+ PD,
+ PD,
+ PD,
+ PB, /* 8 */
+ PB,
+ PB,
+ PB,
+ PB,
+ PB,
+ PC, /* 14 */
+ PC,
+ PC,
+ PC,
+ PC,
+ PC,
+};
+
+const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = {
+ _BV(0), /* 0, port D */
+ _BV(1),
+ _BV(2),
+ _BV(3),
+ _BV(4),
+ _BV(5),
+ _BV(6),
+ _BV(7),
+ _BV(0), /* 8, port B */
+ _BV(1),
+ _BV(2),
+ _BV(3),
+ _BV(4),
+ _BV(5),
+ _BV(0), /* 14, port C */
+ _BV(1),
+ _BV(2),
+ _BV(3),
+ _BV(4),
+ _BV(5),
+};
+
+const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {
+ NOT_ON_TIMER, /* 0 - port D */
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+ // on the ATmega168, digital pin 3 has hardware pwm
+#if defined(__AVR_ATmega8__)
+ NOT_ON_TIMER,
+#else
+ TIMER2B,
+#endif
+ NOT_ON_TIMER,
+ // on the ATmega168, digital pins 5 and 6 have hardware pwm
+#if defined(__AVR_ATmega8__)
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+#else
+ TIMER0B,
+ TIMER0A,
+#endif
+ NOT_ON_TIMER,
+ NOT_ON_TIMER, /* 8 - port B */
+ TIMER1A,
+ TIMER1B,
+#if defined(__AVR_ATmega8__)
+ TIMER2,
+#else
+ TIMER2A,
+#endif
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+ NOT_ON_TIMER, /* 14 - port C */
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+ NOT_ON_TIMER,
+};
+
+#endif
+
+// These serial port names are intended to allow libraries and architecture-neutral
+// sketches to automatically default to the correct port name for a particular type
+// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
+// the first hardware serial port whose RX/TX pins are not dedicated to another use.
+//
+// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor
+//
+// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial
+//
+// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library
+//
+// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins.
+//
+// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX
+// pins are NOT connected to anything by default.
+#define SERIAL_PORT_HARDWARE Serial
+#define SERIAL_PORT_HARDWARE_OPEN Serial
+
+#endif
diff --git a/hardware/arduino/variants/leonardo/pins_arduino.h
b/hardware/arduino/variants/leonardo/pins_arduino.h
index 2c7f837..fd75373 100644
--- a/hardware/arduino/variants/leonardo/pins_arduino.h
+++ b/hardware/arduino/variants/leonardo/pins_arduino.h
@@ -101,6 +101,7 @@
static const uint8_t SDA = 2;
static const uint8_t SCL = 3;
+#define LED_BUILTIN 13
// Map SPI port to 'new' pins D14..D17
static const uint8_t SS = 17;
@@ -132,6 +133,8 @@ static const uint8_t A11 = 29; // D12
extern const uint8_t PROGMEM analog_pin_to_channel_PGM[];
#define analogPinToChannel(P) ( pgm_read_byte( analog_pin_to_channel_PGM + (P) ) )
+#define digitalPinToInterrupt(p) ((p) == 0 ? 2 : ((p) == 1 ? 3 : ((p) == 2 ? 1 : ((p) == 3 ? 0 : ((p) == 7 ?
4 : NOT_AN_INTERRUPT)))))
+
#ifdef ARDUINO_MAIN
// On the Arduino board, digital pins are also used
@@ -334,4 +337,25 @@ const uint8_t PROGMEM analog_pin_to_channel_PGM[] = {
};
#endif /* ARDUINO_MAIN */
+
+// These serial port names are intended to allow libraries and architecture-neutral
+// sketches to automatically default to the correct port name for a particular type
+// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
+// the first hardware serial port whose RX/TX pins are not dedicated to another use.
+//
+// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor
+//
+// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial
+//
+// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library
+//
+// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins.
+//
+// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX
+// pins are NOT connected to anything by default.
+#define SERIAL_PORT_MONITOR Serial
+#define SERIAL_PORT_USBVIRTUAL Serial
+#define SERIAL_PORT_HARDWARE Serial1
+#define SERIAL_PORT_HARDWARE_OPEN Serial1
+
#endif /* Pins_Arduino_h */
diff --git a/hardware/arduino/variants/mega/pins_arduino.h b/hardware/arduino/variants/mega/pins_arduino.h
index 5a9b4cb..a80991b 100644
--- a/hardware/arduino/variants/mega/pins_arduino.h
+++ b/hardware/arduino/variants/mega/pins_arduino.h
@@ -39,7 +39,7 @@ static const uint8_t SCK = 52;
static const uint8_t SDA = 20;
static const uint8_t SCL = 21;
-static const uint8_t LED_BUILTIN = 13;
+#define LED_BUILTIN 13
static const uint8_t A0 = 54;
static const uint8_t A1 = 55;
@@ -83,6 +83,8 @@ static const uint8_t A15 = 69;
( (((p) >= 62) && ((p) <= 69)) ? ((p) - 62) : \
0 ) ) ) ) ) )
+#define digitalPinToInterrupt(p) ((p) == 2 ? 0 : ((p) == 3 ? 1 : ((p) >= 18 && (p) <= 21 ? 23 - (p) :
NOT_AN_INTERRUPT)))
+
#ifdef ARDUINO_MAIN
const uint16_t PROGMEM port_to_mode_PGM[] = {
@@ -360,4 +362,28 @@ const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {
#endif
-#endif
\ No newline at end of file
+// These serial port names are intended to allow libraries and architecture-neutral
+// sketches to automatically default to the correct port name for a particular type
+// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
+// the first hardware serial port whose RX/TX pins are not dedicated to another use.
+//
+// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor
+//
+// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial
+//
+// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library
+//
+// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins.
+//
+// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX
+// pins are NOT connected to anything by default.
+#define SERIAL_PORT_MONITOR Serial
+#define SERIAL_PORT_HARDWARE Serial
+#define SERIAL_PORT_HARDWARE1 Serial1
+#define SERIAL_PORT_HARDWARE2 Serial2
+#define SERIAL_PORT_HARDWARE3 Serial3
+#define SERIAL_PORT_HARDWARE_OPEN Serial1
+#define SERIAL_PORT_HARDWARE_OPEN1 Serial2
+#define SERIAL_PORT_HARDWARE_OPEN2 Serial3
+
+#endif
diff --git a/hardware/arduino/variants/standard/pins_arduino.h
b/hardware/arduino/variants/standard/pins_arduino.h
index 30b4266..3d4a9f6 100644
--- a/hardware/arduino/variants/standard/pins_arduino.h
+++ b/hardware/arduino/variants/standard/pins_arduino.h
@@ -44,7 +44,7 @@ static const uint8_t SCK = 13;
static const uint8_t SDA = 18;
static const uint8_t SCL = 19;
-static const uint8_t LED_BUILTIN = 13;
+#define LED_BUILTIN 13
static const uint8_t A0 = 14;
static const uint8_t A1 = 15;
@@ -60,6 +60,8 @@ static const uint8_t A7 = 21;
#define digitalPinToPCMSK(p) (((p) <= 7) ? (&PCMSK2) : (((p) <= 13) ? (&PCMSK0) : (((p) <= 21) ?
(&PCMSK1) : ((uint8_t *)0))))
#define digitalPinToPCMSKbit(p) (((p) <= 7) ? (p) : (((p) <= 13) ? ((p) - 8) : ((p) - 14)))
+#define digitalPinToInterrupt(p) ((p) == 2 ? 0 : ((p) == 3 ? 1 : NOT_AN_INTERRUPT))
+
#ifdef ARDUINO_MAIN
// On the Arduino board, digital pins are also used
@@ -215,4 +217,22 @@ const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {
#endif
+// These serial port names are intended to allow libraries and architecture-neutral
+// sketches to automatically default to the correct port name for a particular type
+// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
+// the first hardware serial port whose RX/TX pins are not dedicated to another use.
+//
+// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor
+//
+// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial
+//
+// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library
+//
+// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins.
+//
+// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX
+// pins are NOT connected to anything by default.
+#define SERIAL_PORT_MONITOR Serial
+#define SERIAL_PORT_HARDWARE Serial
+
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]