aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--boards.txt772
-rw-r--r--[-rwxr-xr-x]bootloaders/atmega/ATmegaBOOT_168.c0
-rw-r--r--[-rwxr-xr-x]bootloaders/atmega/Makefile0
-rw-r--r--[-rwxr-xr-x]bootloaders/atmega8/ATmegaBOOT.c0
-rw-r--r--[-rwxr-xr-x]bootloaders/bt/Makefile0
-rw-r--r--[-rwxr-xr-x]bootloaders/caterina-LilyPadUSB/Caterina-LilyPadUSB.hex0
-rw-r--r--[-rwxr-xr-x]bootloaders/caterina-LilyPadUSB/Caterina.c0
-rw-r--r--[-rwxr-xr-x]bootloaders/caterina-LilyPadUSB/Caterina.h0
-rw-r--r--[-rwxr-xr-x]bootloaders/caterina-LilyPadUSB/Descriptors.c0
-rw-r--r--[-rwxr-xr-x]bootloaders/caterina-LilyPadUSB/Descriptors.h0
-rw-r--r--[-rwxr-xr-x]bootloaders/caterina-LilyPadUSB/Makefile0
-rw-r--r--[-rwxr-xr-x]bootloaders/caterina-LilyPadUSB/Readme.txt0
-rw-r--r--bootloaders/caterina/Caterina-Yun.hex1025
-rw-r--r--[-rwxr-xr-x]cores/arduino/Arduino.h4
-rw-r--r--cores/arduino/CDC.cpp41
-rw-r--r--cores/arduino/HardwareSerial.cpp123
-rw-r--r--cores/arduino/HardwareSerial.h28
-rw-r--r--cores/arduino/IPAddress.h1
-rw-r--r--[-rwxr-xr-x]cores/arduino/Print.cpp8
-rw-r--r--[-rwxr-xr-x]cores/arduino/Print.h3
-rw-r--r--cores/arduino/Stream.h6
-rw-r--r--[-rwxr-xr-x]cores/arduino/Tone.cpp0
-rw-r--r--cores/arduino/USBAPI.h14
-rw-r--r--cores/arduino/USBCore.cpp70
-rw-r--r--cores/arduino/WString.cpp82
-rw-r--r--cores/arduino/WString.h17
-rw-r--r--cores/arduino/hooks.c31
-rw-r--r--cores/arduino/wiring.c1
-rw-r--r--[-rwxr-xr-x]cores/arduino/wiring_private.h0
-rw-r--r--[-rwxr-xr-x]cores/arduino/wiring_pulse.c0
-rw-r--r--[-rwxr-xr-x]cores/arduino/wiring_shift.c0
-rwxr-xr-xcores/robot/Arduino.h215
-rw-r--r--cores/robot/CDC.cpp239
-rw-r--r--cores/robot/Client.h26
-rw-r--r--cores/robot/HID.cpp520
-rw-r--r--cores/robot/HardwareSerial.cpp508
-rw-r--r--cores/robot/HardwareSerial.h115
-rw-r--r--cores/robot/IPAddress.cpp56
-rw-r--r--cores/robot/IPAddress.h76
-rw-r--r--cores/robot/Platform.h23
-rwxr-xr-xcores/robot/Print.cpp268
-rwxr-xr-xcores/robot/Print.h81
-rw-r--r--cores/robot/Server.h9
-rw-r--r--cores/robot/Stream.cpp270
-rw-r--r--cores/robot/Stream.h96
-rwxr-xr-xcores/robot/Tone.cpp616
-rw-r--r--cores/robot/USBAPI.h196
-rw-r--r--cores/robot/USBCore.cpp684
-rw-r--r--cores/robot/USBCore.h303
-rw-r--r--cores/robot/USBDesc.h63
-rw-r--r--cores/robot/Udp.h88
-rw-r--r--cores/robot/WCharacter.h168
-rw-r--r--cores/robot/WInterrupts.c334
-rw-r--r--cores/robot/WMath.cpp60
-rw-r--r--cores/robot/WString.cpp645
-rw-r--r--cores/robot/WString.h206
-rw-r--r--cores/robot/binary.h515
-rw-r--r--cores/robot/main.cpp20
-rw-r--r--cores/robot/new.cpp28
-rw-r--r--cores/robot/new.h24
-rw-r--r--cores/robot/wiring.c324
-rw-r--r--cores/robot/wiring_analog.c284
-rw-r--r--cores/robot/wiring_digital.c178
-rwxr-xr-xcores/robot/wiring_private.h71
-rwxr-xr-xcores/robot/wiring_pulse.c69
-rwxr-xr-xcores/robot/wiring_shift.c55
-rw-r--r--[-rwxr-xr-x]firmwares/atmegaxxu2/arduino-usbdfu/Arduino-usbdfu.c0
-rw-r--r--[-rwxr-xr-x]firmwares/atmegaxxu2/arduino-usbdfu/Arduino-usbdfu.h0
-rw-r--r--[-rwxr-xr-x]firmwares/atmegaxxu2/arduino-usbdfu/Board/LEDs.h0
-rw-r--r--[-rwxr-xr-x]firmwares/atmegaxxu2/arduino-usbdfu/Descriptors.c0
-rw-r--r--[-rwxr-xr-x]firmwares/atmegaxxu2/arduino-usbdfu/Descriptors.h0
-rw-r--r--[-rwxr-xr-x]firmwares/atmegaxxu2/arduino-usbdfu/makefile0
-rw-r--r--[-rwxr-xr-x]firmwares/atmegaxxu2/arduino-usbserial/Arduino-usbserial.c0
-rw-r--r--[-rwxr-xr-x]firmwares/atmegaxxu2/arduino-usbserial/Arduino-usbserial.h0
-rw-r--r--[-rwxr-xr-x]firmwares/atmegaxxu2/arduino-usbserial/Board/LEDs.h0
-rw-r--r--[-rwxr-xr-x]firmwares/atmegaxxu2/arduino-usbserial/Descriptors.c0
-rw-r--r--[-rwxr-xr-x]firmwares/atmegaxxu2/arduino-usbserial/Descriptors.h0
-rw-r--r--[-rwxr-xr-x]firmwares/atmegaxxu2/arduino-usbserial/Lib/LightweightRingBuff.h0
-rw-r--r--[-rwxr-xr-x]firmwares/atmegaxxu2/arduino-usbserial/makefile0
-rw-r--r--libraries/EEPROM/EEPROM.cpp50
-rw-r--r--libraries/EEPROM/EEPROM.h (renamed from cores/robot/Printable.h)25
-rw-r--r--libraries/EEPROM/examples/eeprom_clear/eeprom_clear.ino23
-rw-r--r--libraries/EEPROM/examples/eeprom_read/eeprom_read.ino43
-rw-r--r--libraries/EEPROM/examples/eeprom_write/eeprom_write.ino38
-rw-r--r--libraries/EEPROM/keywords.txt18
-rw-r--r--libraries/SPI/SPI.cpp66
-rw-r--r--libraries/SPI/SPI.h70
-rw-r--r--libraries/SPI/examples/BarometricPressureSensor/BarometricPressureSensor.ino143
-rw-r--r--libraries/SPI/examples/DigitalPotControl/DigitalPotControl.ino71
-rw-r--r--libraries/SPI/keywords.txt36
-rw-r--r--libraries/SoftwareSerial/SoftwareSerial.cpp518
-rw-r--r--libraries/SoftwareSerial/SoftwareSerial.h112
-rw-r--r--libraries/SoftwareSerial/examples/SoftwareSerialExample/SoftwareSerialExample.ino55
-rw-r--r--libraries/SoftwareSerial/examples/TwoPortReceive/TwoPortReceive.ino93
-rw-r--r--libraries/SoftwareSerial/keywords.txt30
-rw-r--r--libraries/Wire/Wire.cpp298
-rw-r--r--libraries/Wire/Wire.h79
-rw-r--r--libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.ino87
-rw-r--r--libraries/Wire/examples/digital_potentiometer/digital_potentiometer.ino39
-rw-r--r--libraries/Wire/examples/master_reader/master_reader.ino32
-rw-r--r--libraries/Wire/examples/master_writer/master_writer.ino31
-rw-r--r--libraries/Wire/examples/slave_receiver/slave_receiver.ino38
-rw-r--r--libraries/Wire/examples/slave_sender/slave_sender.ino32
-rw-r--r--libraries/Wire/keywords.txt31
-rw-r--r--libraries/Wire/utility/twi.c527
-rw-r--r--libraries/Wire/utility/twi.h53
-rw-r--r--platform.txt94
-rw-r--r--programmers.txt19
-rw-r--r--variants/leonardo/pins_arduino.h2
-rw-r--r--variants/mega/pins_arduino.h2
-rw-r--r--variants/robot_control/pins_arduino.h2
-rw-r--r--variants/robot_motor/pins_arduino.h2
-rw-r--r--variants/standard/pins_arduino.h2
-rw-r--r--variants/yun/pins_arduino.h46
114 files changed, 4535 insertions, 7931 deletions
diff --git a/boards.txt b/boards.txt
index fc29ee4..d4a0def 100644
--- a/boards.txt
+++ b/boards.txt
@@ -1,567 +1,737 @@
# See: http://code.google.com/p/arduino/wiki/Platforms
+menu.cpu=Processor
+
+##############################################################
+
+yun.name=Arduino Yún
+yun.upload.via_ssh=true
+
+yun.vid.0=0x2341
+yun.pid.0=0x0041
+yun.vid.1=0x2341
+yun.pid.1=0x8041
+yun.upload.tool=avrdude
+yun.upload.protocol=avr109
+yun.upload.maximum_size=28672
+yun.upload.maximum_data_size=2560
+yun.upload.speed=57600
+yun.upload.disable_flushing=true
+yun.upload.use_1200bps_touch=true
+yun.upload.wait_for_upload_port=true
+
+yun.bootloader.tool=avrdude
+yun.bootloader.low_fuses=0xff
+yun.bootloader.high_fuses=0xd8
+yun.bootloader.extended_fuses=0xfb
+yun.bootloader.file=caterina/Caterina-Yun.hex
+yun.bootloader.unlock_bits=0x3F
+yun.bootloader.lock_bits=0x2F
+
+yun.build.mcu=atmega32u4
+yun.build.f_cpu=16000000L
+yun.build.vid=0x2341
+yun.build.pid=0x8041
+yun.build.usb_product="Arduino Yun"
+yun.build.board=AVR_YUN
+yun.build.core=arduino
+yun.build.variant=yun
+yun.build.extra_flags={build.usb_flags}
+
##############################################################
uno.name=Arduino Uno
+
+uno.vid.0=0x2341
+uno.pid.0=0x0043
+uno.vid.1=0x2341
+uno.pid.1=0x0001
+
+uno.upload.tool=avrdude
uno.upload.protocol=arduino
uno.upload.maximum_size=32256
+uno.upload.maximum_data_size=2048
uno.upload.speed=115200
-uno.bootloader.low_fuses=0xff
-uno.bootloader.high_fuses=0xde
+
+uno.bootloader.tool=avrdude
+uno.bootloader.low_fuses=0xFF
+uno.bootloader.high_fuses=0xDE
uno.bootloader.extended_fuses=0x05
-uno.bootloader.path=optiboot
-uno.bootloader.file=optiboot_atmega328.hex
uno.bootloader.unlock_bits=0x3F
uno.bootloader.lock_bits=0x0F
+uno.bootloader.file=optiboot/optiboot_atmega328.hex
+
uno.build.mcu=atmega328p
uno.build.f_cpu=16000000L
+uno.build.board=AVR_UNO
uno.build.core=arduino
uno.build.variant=standard
##############################################################
-atmega328.name=Arduino Duemilanove w/ ATmega328
-
-atmega328.upload.protocol=arduino
-atmega328.upload.maximum_size=30720
-atmega328.upload.speed=57600
-
-atmega328.bootloader.low_fuses=0xFF
-atmega328.bootloader.high_fuses=0xDA
-atmega328.bootloader.extended_fuses=0x05
-atmega328.bootloader.path=atmega
-atmega328.bootloader.file=ATmegaBOOT_168_atmega328.hex
-atmega328.bootloader.unlock_bits=0x3F
-atmega328.bootloader.lock_bits=0x0F
-
-atmega328.build.mcu=atmega328p
-atmega328.build.f_cpu=16000000L
-atmega328.build.core=arduino
-atmega328.build.variant=standard
-
-##############################################################
-
-diecimila.name=Arduino Diecimila or Duemilanove w/ ATmega168
+diecimila.name=Arduino Duemilanove or Diecimila
+diecimila.upload.tool=avrdude
diecimila.upload.protocol=arduino
-diecimila.upload.maximum_size=14336
-diecimila.upload.speed=19200
-
-diecimila.bootloader.low_fuses=0xff
-diecimila.bootloader.high_fuses=0xdd
-diecimila.bootloader.extended_fuses=0x00
-diecimila.bootloader.path=atmega
-diecimila.bootloader.file=ATmegaBOOT_168_diecimila.hex
+
+diecimila.bootloader.tool=avrdude
+diecimila.bootloader.low_fuses=0xFF
diecimila.bootloader.unlock_bits=0x3F
diecimila.bootloader.lock_bits=0x0F
-diecimila.build.mcu=atmega168
diecimila.build.f_cpu=16000000L
+diecimila.build.board=AVR_DUEMILANOVE
diecimila.build.core=arduino
diecimila.build.variant=standard
-##############################################################
+## Arduino Duemilanove or Diecimila w/ ATmega328
+## ---------------------------------------------
+diecimila.menu.cpu.atmega328=ATmega328
+
+diecimila.menu.cpu.atmega328.upload.maximum_size=30720
+diecimila.menu.cpu.atmega328.upload.maximum_data_size=2048
+diecimila.menu.cpu.atmega328.upload.speed=57600
-nano328.name=Arduino Nano w/ ATmega328
+diecimila.menu.cpu.atmega328.bootloader.high_fuses=0xDA
+diecimila.menu.cpu.atmega328.bootloader.extended_fuses=0x05
+diecimila.menu.cpu.atmega328.bootloader.file=atmega/ATmegaBOOT_168_atmega328.hex
-nano328.upload.protocol=arduino
-nano328.upload.maximum_size=30720
-nano328.upload.speed=57600
+diecimila.menu.cpu.atmega328.build.mcu=atmega328p
-nano328.bootloader.low_fuses=0xFF
-nano328.bootloader.high_fuses=0xDA
-nano328.bootloader.extended_fuses=0x05
-nano328.bootloader.path=atmega
-nano328.bootloader.file=ATmegaBOOT_168_atmega328.hex
-nano328.bootloader.unlock_bits=0x3F
-nano328.bootloader.lock_bits=0x0F
+## Arduino Duemilanove or Diecimila w/ ATmega168
+## ---------------------------------------------
+diecimila.menu.cpu.atmega168=ATmega168
-nano328.build.mcu=atmega328p
-nano328.build.f_cpu=16000000L
-nano328.build.core=arduino
-nano328.build.variant=eightanaloginputs
+diecimila.menu.cpu.atmega168.upload.maximum_size=14336
+diecimila.menu.cpu.atmega168.upload.maximum_data_size=1024
+diecimila.menu.cpu.atmega168.upload.speed=19200
+
+diecimila.menu.cpu.atmega168.bootloader.high_fuses=0xdd
+diecimila.menu.cpu.atmega168.bootloader.extended_fuses=0x00
+diecimila.menu.cpu.atmega168.bootloader.file=atmega/ATmegaBOOT_168_diecimila.hex
+
+diecimila.menu.cpu.atmega168.build.mcu=atmega168
##############################################################
-nano.name=Arduino Nano w/ ATmega168
+nano.name=Arduino Nano
+nano.upload.tool=avrdude
nano.upload.protocol=arduino
-nano.upload.maximum_size=14336
-nano.upload.speed=19200
-
-nano.bootloader.low_fuses=0xff
-nano.bootloader.high_fuses=0xdd
-nano.bootloader.extended_fuses=0x00
-nano.bootloader.path=atmega
-nano.bootloader.file=ATmegaBOOT_168_diecimila.hex
+
+nano.bootloader.tool=avrdude
nano.bootloader.unlock_bits=0x3F
nano.bootloader.lock_bits=0x0F
-nano.build.mcu=atmega168
nano.build.f_cpu=16000000L
+nano.build.board=AVR_NANO
nano.build.core=arduino
nano.build.variant=eightanaloginputs
-##############################################################
+## Arduino Nano w/ ATmega328
+## -------------------------
+nano.menu.cpu.atmega328=ATmega328
+
+nano.menu.cpu.atmega328.upload.maximum_size=30720
+nano.menu.cpu.atmega328.upload.maximum_data_size=2048
+nano.menu.cpu.atmega328.upload.speed=57600
-mega2560.name=Arduino Mega 2560 or Mega ADK
+nano.menu.cpu.atmega328.bootloader.low_fuses=0xFF
+nano.menu.cpu.atmega328.bootloader.high_fuses=0xDA
+nano.menu.cpu.atmega328.bootloader.extended_fuses=0x05
+nano.menu.cpu.atmega328.bootloader.file=atmega/ATmegaBOOT_168_atmega328.hex
-mega2560.upload.protocol=wiring
-mega2560.upload.maximum_size=258048
-mega2560.upload.speed=115200
+nano.menu.cpu.atmega328.build.mcu=atmega328p
-mega2560.bootloader.low_fuses=0xFF
-mega2560.bootloader.high_fuses=0xD8
-mega2560.bootloader.extended_fuses=0xFD
-mega2560.bootloader.path=stk500v2
-mega2560.bootloader.file=stk500boot_v2_mega2560.hex
-mega2560.bootloader.unlock_bits=0x3F
-mega2560.bootloader.lock_bits=0x0F
+## Arduino Nano w/ ATmega168
+## -------------------------
+nano.menu.cpu.atmega168=ATmega168
-mega2560.build.mcu=atmega2560
-mega2560.build.f_cpu=16000000L
-mega2560.build.core=arduino
-mega2560.build.variant=mega
+nano.menu.cpu.atmega168.upload.maximum_size=14336
+nano.menu.cpu.atmega168.upload.maximum_data_size=1024
+nano.menu.cpu.atmega168.upload.speed=19200
+
+nano.menu.cpu.atmega168.bootloader.low_fuses=0xff
+nano.menu.cpu.atmega168.bootloader.high_fuses=0xdd
+nano.menu.cpu.atmega168.bootloader.extended_fuses=0x00
+nano.menu.cpu.atmega168.bootloader.file=atmega/ATmegaBOOT_168_diecimila.hex
+
+nano.menu.cpu.atmega168.build.mcu=atmega168
##############################################################
-mega.name=Arduino Mega (ATmega1280)
+mega.name=Arduino Mega or Mega 2560
-mega.upload.protocol=arduino
-mega.upload.maximum_size=126976
-mega.upload.speed=57600
+mega.vid.0=0x2341
+mega.pid.0=0x0010
+mega.vid.1=0x2341
+mega.pid.1=0x0042
+mega.upload.tool=avrdude
+mega.upload.maximum_data_size=8192
+
+mega.bootloader.tool=avrdude
mega.bootloader.low_fuses=0xFF
-mega.bootloader.high_fuses=0xDA
-mega.bootloader.extended_fuses=0xF5
-mega.bootloader.path=atmega
-mega.bootloader.file=ATmegaBOOT_168_atmega1280.hex
mega.bootloader.unlock_bits=0x3F
mega.bootloader.lock_bits=0x0F
-mega.build.mcu=atmega1280
mega.build.f_cpu=16000000L
mega.build.core=arduino
mega.build.variant=mega
+# default board may be overridden by the cpu menu
+mega.build.board=AVR_MEGA2560
+
+## Arduino Mega w/ ATmega2560
+## -------------------------
+mega.menu.cpu.atmega2560=ATmega2560 (Mega 2560)
+
+mega.menu.cpu.atmega2560.upload.protocol=wiring
+mega.menu.cpu.atmega2560.upload.maximum_size=258048
+mega.menu.cpu.atmega2560.upload.speed=115200
+
+mega.menu.cpu.atmega2560.bootloader.high_fuses=0xD8
+mega.menu.cpu.atmega2560.bootloader.extended_fuses=0xFD
+mega.menu.cpu.atmega2560.bootloader.file=stk500v2/stk500boot_v2_mega2560.hex
+
+mega.menu.cpu.atmega2560.build.mcu=atmega2560
+mega.menu.cpu.atmega2560.build.board=AVR_MEGA2560
+
+## Arduino Mega w/ ATmega1280
+## -------------------------
+mega.menu.cpu.atmega1280=ATmega1280
+
+mega.menu.cpu.atmega1280.upload.protocol=arduino
+mega.menu.cpu.atmega1280.upload.maximum_size=126976
+mega.menu.cpu.atmega1280.upload.speed=57600
+
+mega.menu.cpu.atmega1280.bootloader.high_fuses=0xDA
+mega.menu.cpu.atmega1280.bootloader.extended_fuses=0xF5
+mega.menu.cpu.atmega1280.bootloader.file=atmega/ATmegaBOOT_168_atmega1280.hex
+
+mega.menu.cpu.atmega1280.build.mcu=atmega1280
+mega.menu.cpu.atmega1280.build.board=AVR_MEGA
+
+##############################################################
+
+megaADK.name=Arduino Mega ADK
+
+megaADK.vid.0=0x2341
+megaADK.pid.0=0x003f
+megaADK.vid.1=0x2341
+megaADK.pid.1=0x0044
+
+megaADK.upload.tool=avrdude
+megaADK.upload.protocol=wiring
+megaADK.upload.maximum_size=258048
+megaADK.upload.maximum_data_size=8192
+megaADK.upload.speed=115200
+
+megaADK.bootloader.tool=avrdude
+megaADK.bootloader.low_fuses=0xFF
+megaADK.bootloader.high_fuses=0xD8
+megaADK.bootloader.extended_fuses=0xFD
+megaADK.bootloader.file=stk500v2/stk500boot_v2_mega2560.hex
+megaADK.bootloader.unlock_bits=0x3F
+megaADK.bootloader.lock_bits=0x0F
+
+megaADK.build.mcu=atmega2560
+megaADK.build.f_cpu=16000000L
+megaADK.build.board=AVR_ADK
+megaADK.build.core=arduino
+megaADK.build.variant=mega
##############################################################
leonardo.name=Arduino Leonardo
+leonardo.vid.0=0x2341
+leonardo.pid.0=0x0036
+leonardo.vid.1=0x2341
+leonardo.pid.1=0x8036
+leonardo.upload.tool=avrdude
leonardo.upload.protocol=avr109
leonardo.upload.maximum_size=28672
+leonardo.upload.maximum_data_size=2560
leonardo.upload.speed=57600
leonardo.upload.disable_flushing=true
+leonardo.upload.use_1200bps_touch=true
+leonardo.upload.wait_for_upload_port=true
+
+leonardo.bootloader.tool=avrdude
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.file=caterina/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.usb_product="Arduino Leonardo"
+leonardo.build.board=AVR_LEONARDO
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
+leonardo.build.extra_flags={build.usb_flags}
##############################################################
micro.name=Arduino Micro
+micro.upload.tool=avrdude
micro.upload.protocol=avr109
micro.upload.maximum_size=28672
+micro.upload.maximum_data_size=2560
micro.upload.speed=57600
micro.upload.disable_flushing=true
+micro.upload.use_1200bps_touch=true
+micro.upload.wait_for_upload_port=true
+
+micro.bootloader.tool=avrdude
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.file=caterina/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.usb_product="Arduino Micro"
+micro.build.board=AVR_MICRO
micro.build.core=arduino
micro.build.variant=micro
+micro.build.extra_flags={build.usb_flags}
##############################################################
-mini328.name=Arduino Mini w/ ATmega328
-
-mini328.upload.protocol=arduino
-mini328.upload.maximum_size=28672
-mini328.upload.speed=115200
+esplora.name=Arduino Esplora
+esplora.vid.0=0x2341
+esplora.pid.0=0x003c
+esplora.vid.1=0x2341
+esplora.pid.1=0x803c
+esplora.upload.tool=avrdude
+esplora.upload.protocol=avr109
+esplora.upload.maximum_size=28672
+esplora.upload.maximum_data_size=2560
+esplora.upload.speed=57600
+esplora.upload.disable_flushing=true
+esplora.upload.use_1200bps_touch=true
+esplora.upload.wait_for_upload_port=true
-mini328.bootloader.low_fuses=0xff
-mini328.bootloader.high_fuses=0xd8
-mini328.bootloader.extended_fuses=0x05
-mini328.bootloader.path=optiboot
-mini328.bootloader.file=optiboot_atmega328-Mini.hex
-mini328.bootloader.unlock_bits=0x3F
-mini328.bootloader.lock_bits=0x0F
+esplora.bootloader.tool=avrdude
+esplora.bootloader.low_fuses=0xff
+esplora.bootloader.high_fuses=0xd8
+esplora.bootloader.extended_fuses=0xcb
+esplora.bootloader.file=caterina/Caterina-Esplora.hex
+esplora.bootloader.unlock_bits=0x3F
+esplora.bootloader.lock_bits=0x2F
-mini328.build.mcu=atmega328p
-mini328.build.f_cpu=16000000L
-mini328.build.core=arduino
-mini328.build.variant=eightanaloginputs
+esplora.build.mcu=atmega32u4
+esplora.build.f_cpu=16000000L
+esplora.build.vid=0x2341
+esplora.build.pid=0x803c
+esplora.build.usb_product="Arduino Esplora"
+esplora.build.board=AVR_ESPLORA
+esplora.build.core=arduino
+esplora.build.variant=leonardo
+esplora.build.extra_flags={build.usb_flags}
##############################################################
-mini.name=Arduino Mini w/ ATmega168
+mini.name=Arduino Mini
+mini.upload.tool=avrdude
mini.upload.protocol=arduino
-mini.upload.maximum_size=14336
-mini.upload.speed=19200
+mini.bootloader.tool=avrdude
mini.bootloader.low_fuses=0xff
-mini.bootloader.high_fuses=0xdd
-mini.bootloader.extended_fuses=0x00
-mini.bootloader.path=atmega
-mini.bootloader.file=ATmegaBOOT_168_ng.hex
mini.bootloader.unlock_bits=0x3F
mini.bootloader.lock_bits=0x0F
-mini.build.mcu=atmega168
mini.build.f_cpu=16000000L
+mini.build.board=AVR_MINI
mini.build.core=arduino
mini.build.variant=eightanaloginputs
+## Arduino Mini w/ ATmega328
+## -------------------------
+mini.menu.cpu.atmega328=ATmega328
+
+mini.menu.cpu.atmega328.upload.maximum_size=28672
+mini.menu.cpu.atmega328.upload.maximum_data_size=2048
+mini.menu.cpu.atmega328.upload.speed=115200
+
+mini.menu.cpu.atmega328.bootloader.high_fuses=0xd8
+mini.menu.cpu.atmega328.bootloader.extended_fuses=0x05
+mini.menu.cpu.atmega328.bootloader.file=optiboot/optiboot_atmega328-Mini.hex
+
+mini.menu.cpu.atmega328.build.mcu=atmega328p
+
+## Arduino Mini w/ ATmega168
+## -------------------------
+mini.menu.cpu.atmega168=ATmega168
+
+mini.menu.cpu.atmega168.upload.maximum_size=14336
+mini.menu.cpu.atmega168.upload.maximum_data_size=1024
+mini.menu.cpu.atmega168.upload.speed=19200
+
+mini.menu.cpu.atmega168.bootloader.high_fuses=0xdd
+mini.menu.cpu.atmega168.bootloader.extended_fuses=0x00
+mini.menu.cpu.atmega168.bootloader.file=atmega/ATmegaBOOT_168_ng.hex
+
+mini.menu.cpu.atmega168.build.mcu=atmega168
+
##############################################################
ethernet.name=Arduino Ethernet
+ethernet.upload.tool=avrdude
ethernet.upload.protocol=arduino
ethernet.upload.maximum_size=32256
+ethernet.upload.maximum_data_size=2048
ethernet.upload.speed=115200
+ethernet.bootloader.tool=avrdude
ethernet.bootloader.low_fuses=0xff
ethernet.bootloader.high_fuses=0xde
ethernet.bootloader.extended_fuses=0x05
-ethernet.bootloader.path=optiboot
-ethernet.bootloader.file=optiboot_atmega328.hex
+ethernet.bootloader.file=optiboot/optiboot_atmega328.hex
ethernet.bootloader.unlock_bits=0x3F
ethernet.bootloader.lock_bits=0x0F
ethernet.build.variant=ethernet
ethernet.build.mcu=atmega328p
ethernet.build.f_cpu=16000000L
+ethernet.build.board=AVR_ETHERNET
ethernet.build.core=arduino
##############################################################
fio.name=Arduino Fio
+fio.upload.tool=avrdude
fio.upload.protocol=arduino
fio.upload.maximum_size=30720
+fio.upload.maximum_data_size=2048
fio.upload.speed=57600
+fio.bootloader.tool=avrdude
fio.bootloader.low_fuses=0xFF
fio.bootloader.high_fuses=0xDA
fio.bootloader.extended_fuses=0x05
-fio.bootloader.path=arduino:atmega
-fio.bootloader.file=ATmegaBOOT_168_atmega328_pro_8MHz.hex
+fio.bootloader.file=atmega/ATmegaBOOT_168_atmega328_pro_8MHz.hex
fio.bootloader.unlock_bits=0x3F
fio.bootloader.lock_bits=0x0F
fio.build.mcu=atmega328p
fio.build.f_cpu=8000000L
+fio.build.board=AVR_FIO
fio.build.core=arduino
fio.build.variant=eightanaloginputs
##############################################################
-bt328.name=Arduino BT w/ ATmega328
-
-bt328.upload.protocol=arduino
-bt328.upload.maximum_size=28672
-bt328.upload.speed=19200
-bt328.upload.disable_flushing=true
-
-bt328.bootloader.low_fuses=0xff
-bt328.bootloader.high_fuses=0xd8
-bt328.bootloader.extended_fuses=0x05
-bt328.bootloader.path=bt
-bt328.bootloader.file=ATmegaBOOT_168_atmega328_bt.hex
-bt328.bootloader.unlock_bits=0x3F
-bt328.bootloader.lock_bits=0x0F
-
-bt328.build.mcu=atmega328p
-bt328.build.f_cpu=16000000L
-bt328.build.core=arduino
-bt328.build.variant=eightanaloginputs
-
-##############################################################
-
-bt.name=Arduino BT w/ ATmega168
+bt.name=Arduino BT
+bt.upload.tool=avrdude
bt.upload.protocol=arduino
-bt.upload.maximum_size=14336
bt.upload.speed=19200
bt.upload.disable_flushing=true
+bt.bootloader.tool=avrdude
bt.bootloader.low_fuses=0xff
-bt.bootloader.high_fuses=0xdd
-bt.bootloader.extended_fuses=0x00
-bt.bootloader.path=bt
-bt.bootloader.file=ATmegaBOOT_168.hex
bt.bootloader.unlock_bits=0x3F
bt.bootloader.lock_bits=0x0F
-bt.build.mcu=atmega168
bt.build.f_cpu=16000000L
+bt.build.board=AVR_BT
bt.build.core=arduino
bt.build.variant=eightanaloginputs
+## Arduino BT w/ ATmega328
+## -----------------------
+bt.menu.cpu.atmega328=ATmega328
+bt.menu.cpu.atmega328.upload.maximum_size=28672
+bt.menu.cpu.atmega328.upload.maximum_data_size=2048
+
+bt.menu.cpu.atmega328.bootloader.high_fuses=0xd8
+bt.menu.cpu.atmega328.bootloader.extended_fuses=0x05
+bt.menu.cpu.atmega328.bootloader.file=bt/ATmegaBOOT_168_atmega328_bt.hex
+
+bt.menu.cpu.atmega328.build.mcu=atmega328p
+
+## Arduino BT w/ ATmega168
+## -----------------------
+bt.menu.cpu.atmega168=ATmega168
+bt.menu.cpu.atmega168.upload.maximum_size=14336
+bt.menu.cpu.atmega168.upload.maximum_data_size=1024
+
+bt.menu.cpu.atmega168.bootloader.high_fuses=0xdd
+bt.menu.cpu.atmega168.bootloader.extended_fuses=0x00
+bt.menu.cpu.atmega168.bootloader.file=bt/ATmegaBOOT_168.hex
+
+bt.menu.cpu.atmega168.build.mcu=atmega168
+
##############################################################
LilyPadUSB.name=LilyPad Arduino USB
+
+LilyPadUSB.upload.tool=avrdude
LilyPadUSB.upload.protocol=avr109
LilyPadUSB.upload.maximum_size=28672
+LilyPadUSB.upload.maximum_data_size=2560
LilyPadUSB.upload.speed=57600
LilyPadUSB.upload.disable_flushing=true
+LilyPadUSB.upload.use_1200bps_touch=true
+LilyPadUSB.upload.wait_for_upload_port=true
+
+LilyPadUSB.bootloader.tool=avrdude
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.file=caterina-LilyPadUSB/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.usb_product="LilyPad USB"
+LilyPadUSB.build.board=AVR_LILYPAD_USB
LilyPadUSB.build.core=arduino
LilyPadUSB.build.variant=leonardo
+LilyPadUSB.build.extra_flags={build.usb_flags}
##############################################################
-lilypad328.name=LilyPad Arduino w/ ATmega328
-
-lilypad328.upload.protocol=arduino
-lilypad328.upload.maximum_size=30720
-lilypad328.upload.speed=57600
-
-lilypad328.bootloader.low_fuses=0xFF
-lilypad328.bootloader.high_fuses=0xDA
-lilypad328.bootloader.extended_fuses=0x05
-lilypad328.bootloader.path=atmega
-lilypad328.bootloader.file=ATmegaBOOT_168_atmega328_pro_8MHz.hex
-lilypad328.bootloader.unlock_bits=0x3F
-lilypad328.bootloader.lock_bits=0x0F
-
-lilypad328.build.mcu=atmega328p
-lilypad328.build.f_cpu=8000000L
-lilypad328.build.core=arduino
-lilypad328.build.variant=standard
-
-##############################################################
-
-lilypad.name=LilyPad Arduino w/ ATmega168
+lilypad.name=LilyPad Arduino
+lilypad.upload.tool=avrdude
lilypad.upload.protocol=arduino
-lilypad.upload.maximum_size=14336
-lilypad.upload.speed=19200
-
-lilypad.bootloader.low_fuses=0xe2
-lilypad.bootloader.high_fuses=0xdd
-lilypad.bootloader.extended_fuses=0x00
-lilypad.bootloader.path=lilypad
-lilypad.bootloader.file=LilyPadBOOT_168.hex
+
+lilypad.bootloader.tool=avrdude
lilypad.bootloader.unlock_bits=0x3F
lilypad.bootloader.lock_bits=0x0F
-lilypad.build.mcu=atmega168
lilypad.build.f_cpu=8000000L
+lilypad.build.board=AVR_LILYPAD
lilypad.build.core=arduino
lilypad.build.variant=standard
-##############################################################
+## LilyPad Arduino w/ ATmega328
+## ----------------------------
+lilypad.menu.cpu.atmega328=ATmega328
+
+lilypad.menu.cpu.atmega328.upload.maximum_size=30720
+lilypad.menu.cpu.atmega328.upload.maximum_data_size=2048
+lilypad.menu.cpu.atmega328.upload.speed=57600
+
+lilypad.menu.cpu.atmega328.bootloader.low_fuses=0xFF
+lilypad.menu.cpu.atmega328.bootloader.high_fuses=0xDA
+lilypad.menu.cpu.atmega328.bootloader.extended_fuses=0x05
+lilypad.menu.cpu.atmega328.bootloader.file=atmega/ATmegaBOOT_168_atmega328_pro_8MHz.hex
-pro5v328.name=Arduino Pro or Pro Mini (5V, 16 MHz) w/ ATmega328
+lilypad.menu.cpu.atmega328.build.mcu=atmega328p
-pro5v328.upload.protocol=arduino
-pro5v328.upload.maximum_size=30720
-pro5v328.upload.speed=57600
+## LilyPad Arduino w/ ATmega168
+## ----------------------------
+lilypad.menu.cpu.atmega168=ATmega168
-pro5v328.bootloader.low_fuses=0xFF
-pro5v328.bootloader.high_fuses=0xDA
-pro5v328.bootloader.extended_fuses=0x05
-pro5v328.bootloader.path=atmega
-pro5v328.bootloader.file=ATmegaBOOT_168_atmega328.hex
-pro5v328.bootloader.unlock_bits=0x3F
-pro5v328.bootloader.lock_bits=0x0F
+lilypad.menu.cpu.atmega168.upload.maximum_size=14336
+lilypad.menu.cpu.atmega168.upload.maximum_data_size=1024
+lilypad.menu.cpu.atmega168.upload.speed=19200
-pro5v328.build.mcu=atmega328p
-pro5v328.build.f_cpu=16000000L
-pro5v328.build.core=arduino
-pro5v328.build.variant=standard
+lilypad.menu.cpu.atmega168.bootloader.low_fuses=0xe2
+lilypad.menu.cpu.atmega168.bootloader.high_fuses=0xdd
+lilypad.menu.cpu.atmega168.bootloader.extended_fuses=0x00
+lilypad.menu.cpu.atmega168.bootloader.file=lilypad/LilyPadBOOT_168.hex
+
+lilypad.menu.cpu.atmega168.build.mcu=atmega168
##############################################################
-pro5v.name=Arduino Pro or Pro Mini (5V, 16 MHz) w/ ATmega168
+pro.name=Arduino Pro or Pro Mini
-pro5v.upload.protocol=arduino
-pro5v.upload.maximum_size=14336
-pro5v.upload.speed=19200
+pro.upload.tool=avrdude
+pro.upload.protocol=arduino
-pro5v.bootloader.low_fuses=0xff
-pro5v.bootloader.high_fuses=0xdd
-pro5v.bootloader.extended_fuses=0x00
-pro5v.bootloader.path=atmega
-pro5v.bootloader.file=ATmegaBOOT_168_diecimila.hex
-pro5v.bootloader.unlock_bits=0x3F
-pro5v.bootloader.lock_bits=0x0F
+pro.bootloader.tool=avrdude
+pro.bootloader.unlock_bits=0x3F
+pro.bootloader.lock_bits=0x0F
-pro5v.build.mcu=atmega168
-pro5v.build.f_cpu=16000000L
-pro5v.build.core=arduino
-pro5v.build.variant=standard
+pro.build.board=AVR_PRO
+pro.build.core=arduino
+pro.build.variant=standard
-##############################################################
+## Arduino Pro or Pro Mini (5V, 16 MHz) w/ ATmega328
+## -------------------------------------------------
+pro.menu.cpu.16MHzatmega328=ATmega328 (5V, 16 MHz)
-pro328.name=Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega328
+pro.menu.cpu.16MHzatmega328.upload.maximum_size=30720
+pro.menu.cpu.16MHzatmega328.upload.maximum_data_size=2048
+pro.menu.cpu.16MHzatmega328.upload.speed=57600
-pro328.upload.protocol=arduino
-pro328.upload.maximum_size=30720
-pro328.upload.speed=57600
+pro.menu.cpu.16MHzatmega328.bootloader.low_fuses=0xFF
+pro.menu.cpu.16MHzatmega328.bootloader.high_fuses=0xDA
+pro.menu.cpu.16MHzatmega328.bootloader.extended_fuses=0x05
+pro.menu.cpu.16MHzatmega328.bootloader.file=atmega/ATmegaBOOT_168_atmega328.hex
-pro328.bootloader.low_fuses=0xFF
-pro328.bootloader.high_fuses=0xDA
-pro328.bootloader.extended_fuses=0x05
-pro328.bootloader.path=atmega
-pro328.bootloader.file=ATmegaBOOT_168_atmega328_pro_8MHz.hex
-pro328.bootloader.unlock_bits=0x3F
-pro328.bootloader.lock_bits=0x0F
+pro.menu.cpu.16MHzatmega328.build.mcu=atmega328p
+pro.menu.cpu.16MHzatmega328.build.f_cpu=16000000L
-pro328.build.mcu=atmega328p
-pro328.build.f_cpu=8000000L
-pro328.build.core=arduino
-pro328.build.variant=standard
+## Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega328
+## --------------------------------------------------
+pro.menu.cpu.8MHzatmega328=ATmega328 (3.3V, 8 MHz)
-##############################################################
+pro.menu.cpu.8MHzatmega328.upload.maximum_size=30720
+pro.menu.cpu.8MHzatmega328.upload.maximum_data_size=2048
+pro.menu.cpu.8MHzatmega328.upload.speed=57600
-pro.name=Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega168
+pro.menu.cpu.8MHzatmega328.bootloader.low_fuses=0xFF
+pro.menu.cpu.8MHzatmega328.bootloader.high_fuses=0xDA
+pro.menu.cpu.8MHzatmega328.bootloader.extended_fuses=0x05
+pro.menu.cpu.8MHzatmega328.bootloader.file=atmega/ATmegaBOOT_168_atmega328_pro_8MHz.hex
-pro.upload.protocol=arduino
-pro.upload.maximum_size=14336
-pro.upload.speed=19200
-
-pro.bootloader.low_fuses=0xc6
-pro.bootloader.high_fuses=0xdd
-pro.bootloader.extended_fuses=0x00
-pro.bootloader.path=atmega
-pro.bootloader.file=ATmegaBOOT_168_pro_8MHz.hex
-pro.bootloader.unlock_bits=0x3F
-pro.bootloader.lock_bits=0x0F
+pro.menu.cpu.8MHzatmega328.build.mcu=atmega328p
+pro.menu.cpu.8MHzatmega328.build.f_cpu=8000000L
-pro.build.mcu=atmega168
-pro.build.f_cpu=8000000L
-pro.build.core=arduino
-pro.build.variant=standard
+## Arduino Pro or Pro Mini (5V, 16 MHz) w/ ATmega168
+## -------------------------------------------------
+pro.menu.cpu.16MHzatmega168=ATmega168 (5V, 16 MHz)
-##############################################################
+pro.menu.cpu.16MHzatmega168.upload.maximum_size=14336
+pro.menu.cpu.16MHzatmega168.upload.maximum_data_size=1024
+pro.menu.cpu.16MHzatmega168.upload.speed=19200
+
+pro.menu.cpu.16MHzatmega168.bootloader.low_fuses=0xff
+pro.menu.cpu.16MHzatmega168.bootloader.high_fuses=0xdd
+pro.menu.cpu.16MHzatmega168.bootloader.extended_fuses=0x00
+pro.menu.cpu.16MHzatmega168.bootloader.file=atmega/ATmegaBOOT_168_diecimila.hex
+
+pro.menu.cpu.16MHzatmega168.build.mcu=atmega168
+pro.menu.cpu.16MHzatmega168.build.f_cpu=16000000L
-atmega168.name=Arduino NG or older w/ ATmega168
+## Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega168
+## --------------------------------------------------
+pro.menu.cpu.8MHzatmega168=ATmega168 (3.3V, 8 MHz)
-atmega168.upload.protocol=arduino
-atmega168.upload.maximum_size=14336
-atmega168.upload.speed=19200
+pro.menu.cpu.8MHzatmega168.upload.maximum_size=14336
+pro.menu.cpu.8MHzatmega168.upload.maximum_data_size=1024
+pro.menu.cpu.8MHzatmega168.upload.speed=19200
-atmega168.bootloader.low_fuses=0xff
-atmega168.bootloader.high_fuses=0xdd
-atmega168.bootloader.extended_fuses=0x00
-atmega168.bootloader.path=atmega
-atmega168.bootloader.file=ATmegaBOOT_168_ng.hex
-atmega168.bootloader.unlock_bits=0x3F
-atmega168.bootloader.lock_bits=0x0F
+pro.menu.cpu.8MHzatmega168.bootloader.low_fuses=0xc6
+pro.menu.cpu.8MHzatmega168.bootloader.high_fuses=0xdd
+pro.menu.cpu.8MHzatmega168.bootloader.extended_fuses=0x00
+pro.menu.cpu.8MHzatmega168.bootloader.file=atmega/ATmegaBOOT_168_pro_8MHz.hex
-atmega168.build.mcu=atmega168
-atmega168.build.f_cpu=16000000L
-atmega168.build.core=arduino
-atmega168.build.variant=standard
+pro.menu.cpu.8MHzatmega168.build.mcu=atmega168
+pro.menu.cpu.8MHzatmega168.build.f_cpu=8000000L
##############################################################
-atmega8.name=Arduino NG or older w/ ATmega8
+atmegang.name=Arduino NG or older
+
+atmegang.upload.tool=avrdude
+atmegang.upload.protocol=arduino
+atmegang.upload.speed=19200
+
+atmegang.bootloader.tool=avrdude
+atmegang.bootloader.unlock_bits=0x3F
+atmegang.bootloader.lock_bits=0x0F
+
+atmegang.build.mcu=atmegang
+atmegang.build.f_cpu=16000000L
+atmegang.build.board=AVR_NG
+atmegang.build.core=arduino
+atmegang.build.variant=standard
+
+## Arduino NG or older w/ ATmega168
+## --------------------------------
+atmegang.menu.cpu.atmega168=ATmega168
-atmega8.upload.protocol=arduino
-atmega8.upload.maximum_size=7168
-atmega8.upload.speed=19200
+atmegang.menu.cpu.atmega168.upload.maximum_size=14336
+atmegang.menu.cpu.atmega168.upload.maximum_data_size=1024
-atmega8.bootloader.low_fuses=0xdf
-atmega8.bootloader.high_fuses=0xca
-atmega8.bootloader.path=atmega8
-atmega8.bootloader.file=ATmegaBOOT-prod-firmware-2009-11-07.hex
-atmega8.bootloader.unlock_bits=0x3F
-atmega8.bootloader.lock_bits=0x0F
+atmegang.menu.cpu.atmega168.bootloader.low_fuses=0xff
+atmegang.menu.cpu.atmega168.bootloader.high_fuses=0xdd
+atmegang.menu.cpu.atmega168.bootloader.extended_fuses=0x00
+atmegang.menu.cpu.atmega168.bootloader.file=atmega/ATmegaBOOT_168_ng.hex
-atmega8.build.mcu=atmega8
-atmega8.build.f_cpu=16000000L
-atmega8.build.core=arduino
-atmega8.build.variant=standard
+atmegang.menu.cpu.atmega168.build.mcu=atmega168
+
+## Arduino NG or older w/ ATmega8
+## ------------------------------
+atmegang.menu.cpu.atmega8=ATmega8
+
+atmegang.menu.cpu.atmega8.upload.maximum_size=7168
+atmegang.menu.cpu.atmega8.upload.maximum_data_size=1024
+
+atmegang.menu.cpu.atmega8.bootloader.low_fuses=0xdf
+atmegang.menu.cpu.atmega8.bootloader.high_fuses=0xca
+atmegang.menu.cpu.atmega8.bootloader.file=atmega8/ATmegaBOOT-prod-firmware-2009-11-07.hex
+
+atmegang.menu.cpu.atmega8.build.mcu=atmega8
##############################################################
robotControl.name=Arduino Robot Control
+robotControl.upload.tool=avrdude
robotControl.upload.protocol=avr109
robotControl.upload.maximum_size=28672
+robotControl.upload.maximum_data_size=2560
robotControl.upload.speed=57600
robotControl.upload.disable_flushing=true
+robotControl.upload.use_1200bps_touch=true
+robotControl.upload.wait_for_upload_port=true
+
+robotControl.bootloader.tool=avrdude
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.file=caterina-Arduino_Robot/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.usb_product="Robot Control"
+robotControl.build.board=AVR_ROBOT_CONTROL
+robotControl.build.core=arduino
robotControl.build.variant=robot_control
+robotControl.build.extra_flags={build.usb_flags}
##############################################################
robotMotor.name=Arduino Robot Motor
+robotMotor.upload.tool=avrdude
robotMotor.upload.protocol=avr109
robotMotor.upload.maximum_size=28672
+robotMotor.upload.maximum_data_size=2560
robotMotor.upload.speed=57600
robotMotor.upload.disable_flushing=true
+robotMotor.upload.use_1200bps_touch=true
+robotMotor.upload.wait_for_upload_port=true
+
+robotMotor.bootloader.tool=avrdude
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.file=caterina-Arduino_Robot/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.usb_product="Robot Motor"
+robotMotor.build.board=AVR_ROBOT_MOTOR
+robotMotor.build.core=arduino
robotMotor.build.variant=robot_motor
+robotMotor.build.extra_flags={build.usb_flags}
diff --git a/bootloaders/atmega/ATmegaBOOT_168.c b/bootloaders/atmega/ATmegaBOOT_168.c
index 880cf9b..880cf9b 100755..100644
--- a/bootloaders/atmega/ATmegaBOOT_168.c
+++ b/bootloaders/atmega/ATmegaBOOT_168.c
diff --git a/bootloaders/atmega/Makefile b/bootloaders/atmega/Makefile
index 0fd54db..0fd54db 100755..100644
--- a/bootloaders/atmega/Makefile
+++ b/bootloaders/atmega/Makefile
diff --git a/bootloaders/atmega8/ATmegaBOOT.c b/bootloaders/atmega8/ATmegaBOOT.c
index 8c8d22a..8c8d22a 100755..100644
--- a/bootloaders/atmega8/ATmegaBOOT.c
+++ b/bootloaders/atmega8/ATmegaBOOT.c
diff --git a/bootloaders/bt/Makefile b/bootloaders/bt/Makefile
index 431f2e7..431f2e7 100755..100644
--- a/bootloaders/bt/Makefile
+++ b/bootloaders/bt/Makefile
diff --git a/bootloaders/caterina-LilyPadUSB/Caterina-LilyPadUSB.hex b/bootloaders/caterina-LilyPadUSB/Caterina-LilyPadUSB.hex
index abc5ca8..abc5ca8 100755..100644
--- a/bootloaders/caterina-LilyPadUSB/Caterina-LilyPadUSB.hex
+++ b/bootloaders/caterina-LilyPadUSB/Caterina-LilyPadUSB.hex
diff --git a/bootloaders/caterina-LilyPadUSB/Caterina.c b/bootloaders/caterina-LilyPadUSB/Caterina.c
index 9a59081..9a59081 100755..100644
--- a/bootloaders/caterina-LilyPadUSB/Caterina.c
+++ b/bootloaders/caterina-LilyPadUSB/Caterina.c
diff --git a/bootloaders/caterina-LilyPadUSB/Caterina.h b/bootloaders/caterina-LilyPadUSB/Caterina.h
index f8251d4..f8251d4 100755..100644
--- a/bootloaders/caterina-LilyPadUSB/Caterina.h
+++ b/bootloaders/caterina-LilyPadUSB/Caterina.h
diff --git a/bootloaders/caterina-LilyPadUSB/Descriptors.c b/bootloaders/caterina-LilyPadUSB/Descriptors.c
index f58519f..f58519f 100755..100644
--- a/bootloaders/caterina-LilyPadUSB/Descriptors.c
+++ b/bootloaders/caterina-LilyPadUSB/Descriptors.c
diff --git a/bootloaders/caterina-LilyPadUSB/Descriptors.h b/bootloaders/caterina-LilyPadUSB/Descriptors.h
index 94091ae..94091ae 100755..100644
--- a/bootloaders/caterina-LilyPadUSB/Descriptors.h
+++ b/bootloaders/caterina-LilyPadUSB/Descriptors.h
diff --git a/bootloaders/caterina-LilyPadUSB/Makefile b/bootloaders/caterina-LilyPadUSB/Makefile
index 8443e14..8443e14 100755..100644
--- a/bootloaders/caterina-LilyPadUSB/Makefile
+++ b/bootloaders/caterina-LilyPadUSB/Makefile
diff --git a/bootloaders/caterina-LilyPadUSB/Readme.txt b/bootloaders/caterina-LilyPadUSB/Readme.txt
index 9656a6e..9656a6e 100755..100644
--- a/bootloaders/caterina-LilyPadUSB/Readme.txt
+++ b/bootloaders/caterina-LilyPadUSB/Readme.txt
diff --git a/bootloaders/caterina/Caterina-Yun.hex b/bootloaders/caterina/Caterina-Yun.hex
new file mode 100644
index 0000000..1d76eb0
--- /dev/null
+++ b/bootloaders/caterina/Caterina-Yun.hex
@@ -0,0 +1,1025 @@
+:200000000C9475010C949D010C949D010C949D010C949D010C949D010C949D010C949D0118
+:200020000C949D010C949D010C940C050C9493050C949D010C949D010C949D010C949D0163
+:200040000C949D010C949D010C949D010C949D010C949D010C949D010C949D010C94BC0191
+:200060000C949D010C949D010C949D010C949D010C949D010C949D010C949D010C949D0190
+:200080000C949D010C949D010C949D010C949D010C949D010C949D010C949D010C949D0170
+:2000A0000C949D010C949D010C949D0100000000240027002A002D0030000000000025008F
+:2000C00028002B002E003100000000002300260029002C002F00040404040403040502027D
+:2000E0000202040302020202060606060606040402020204040802011040804010204080A8
+:200100004080080204018040201002011080102040400000000200080E0000030401000BB2
+:2001200000000000000000000000000000000000070605040100080A0B0C0D090403090455
+:200140002203410072006400750069006E006F002000590075006E002000200020002000CC
+:2001600020001803410072006400750069006E006F0020004C004C00430012010002000062
+:2001800000404123418000010102000112010002020000404123418000010102000100C1B3
+:2001A0008081C1080B000202020100090400000102020000052400100105240101010424C3
+:2001C000020605240600010705810310004009040100020A00000007050202400000070591
+:2001E000830240000005010902A1010901A100850105091901290315002501950375018138
+:200200000295017505810305010930093109381581257F750895038106C0C005010906A182
+:20022000018502050719E029E7150025017501950881029501750881039506750815002567
+:20024000650507190029658100C009040200010300000009210101000122650007058403EB
+:2002600040000100000000000000002A2B28000000000000000000000000000000000000C0
+:200280000000002C9EB4A0A1A2A434A6A7A5AE362D3738271E1F20212223242526B333B6BE
+:2002A0002EB7B89F8485868788898A8B8C8D8E8F909192939495969798999A9B9C9D2F31F5
+:2002C00030A3AD350405060708090A0B0C0D0E0F101112131415161718191A1B1C1DAFB15C
+:2002E000B0B50000480426072B0811241FBECFEFDAE0DEBFCDBF11E0A0E0B1E0EEECF2E18B
+:2003000002C005900D92AC32B107D9F711E0ACE2B1E001C01D92AD39B107E1F712E0CAEEE1
+:20032000D2E004C02297FE010E946109C43ED107C9F70E9482030C9465090C940000809103
+:20034000000161E00E944F0368EE73E080E090E00E945A028091000160E00E944F0368EE54
+:2003600073E080E090E00E945A0208958091000161E00E94C20208951F920F920FB60F92B1
+:2003800011242F933F938F939F93AF93BF938091300190913101A0913201B091330130917D
+:2003A00034010196A11DB11D232F2D5F2D3720F02D570196A11DB11D2093340180933001C0
+:2003C00090933101A0933201B093330180912C0190912D01A0912E01B0912F010196A11D38
+:2003E000B11D80932C0190932D01A0932E01B0932F01BF91AF919F918F913F912F910F90BA
+:200400000FBE0F901F901895789484B5826084BD84B5816084BD85B5826085BD85B58160D8
+:2004200085BDEEE6F0E0808181608083E1E8F0E01082808182608083808181608083E0E833
+:20044000F0E0808181608083E1E9F0E0808182608083808181608083E0E9F0E08081816007
+:200460008083E1ECF0E0808184608083808182608083808181608083E3ECF0E080818160A8
+:200480008083E0ECF0E0808182608083E2ECF0E0808181608083EAE7F0E0808184608083CB
+:2004A0008081826080838081816080838081806880830895EF92FF920F931F93CF93DF93AE
+:2004C0007B018C013FB7F89480912C0190912D01A0912E01B0912F0126B5A89B05C02F3FE2
+:2004E00019F00196A11DB11D3FBFBA2FA92F982F8827820F911DA11DB11D52E0880F991F4F
+:20050000AA1FBB1F5A95D1F7EC0130C00E9434093FB7F89480912C0190912D01A0912E0156
+:20052000B0912F0126B5A89B05C02F3F19F00196A11DB11D3FBFBA2FA92F982F8827820F07
+:20054000911DA11DB11D32E0880F991FAA1FBB1F3A95D1F78C1B9D0B885E9340B8F2089478
+:20056000E108F10801091109C851DC4FE114F1040105110559F6DF91CF911F910F91FF902D
+:20058000EF900895CF93DF93482F50E0CA018C509F4FFC0134914A525F4FFA018491882368
+:2005A00069F190E0880F991FFC01E455FF4FA591B491FC01E654FF4FC591D491662351F415
+:2005C0002FB7F8948C91932F909589238C93888189230BC0623061F42FB7F8948C91932F22
+:2005E000909589238C938881832B88832FBF06C09FB7F8948C91832B8C939FBFDF91CF919B
+:200600000895883071F1893068F4823031F1833020F4813009F042C01DC0833089F084300A
+:20062000E9F512C08B3059F18C3028F48930E9F08A30A1F51EC08C3031F18E3079F529C07A
+:20064000809180008F7703C0809180008F7D80938000089584B58F7702C084B58F7D84BDEC
+:200660000895809190008F7707C0809190008F7D03C080919000877F809390000895809107
+:20068000C0008F7703C08091C0008F7D8093C00008958091C200877F8093C2000895FF92A8
+:2006A0000F931F93F62E482F50E0CA018E5E9E4FFC012491CA018C509F4FFC0114914A52F2
+:2006C0005F4FFA0104910023C9F0222319F0822F0E940103E02FF0E0EE0FFF1FE654FF4FD9
+:2006E000A591B4919FB7F894FF2021F48C911095812302C08C91812B8C939FBF1F910F91AB
+:20070000FF900895CF93DF930E9404028DE391E00E9449040E94B601C0E0D0E00E949F0176
+:200720002097E1F30E940000F9CF282F809137018823C1F057FF1AC015C0289890933601A9
+:200740008091F1008193E217F307B9F74115510539F08091F200882319F48BE68093E800E4
+:20076000AFBF02C04FEF5FEFCA010895AFB7F89427702093E9008091F200282F30E024178B
+:2007800035070CF4A901FB019B01240F311D94E6DACFDF93CF930F92CDB7DEB7BE016F5F1C
+:2007A0007F4F41E050E00E949503019719F02FEF3FEF03C08981282F30E0C9010F90CF91F6
+:2007C000DF910895FF920F931F93F82E142F052F40913A0150913B01212F302FC901DC010B
+:2007E000FB016EEF29C0F7FE02C0949101C09081209138013091390124173507ACF48091FC
+:20080000E8008570E1F38091E80082FF03C02FEF3FEF17C09093F100C90101968F73907050
+:20082000892B11F46093E8002F5F3F4F3093390120933801119731961097A9F6812F902FFB
+:200840009C01C9011F910F91FF9008959C018091E80082FFFCCFF901260F311D03C0809182
+:20086000F1008193E217F307D1F7289884E6809336018BEF8093E800CB0108958093E9006A
+:200880008091F200882319F08AE38093E800089508951092370181E08093D70080EA80935D
+:2008A000D80082E189BD09B400FEFDCF61E070E080E090E00E945A0280E98093D8008CE011
+:2008C0008093E2001092E000559A209A08955F926F927F928F929F92AF92BF92CF92DF92A2
+:2008E000EF92FF920F931F93CF93DF93E82E842E752E80913701882371F18B01242F352FBA
+:20090000C901EC017AEFF72E67E0962E9E2050E4552E8E2D90E040E2A42EB12CA822B92271
+:200920003AE3632E20E4C22ED12CC822D92258C09FB7F8949092E9008091E80085FD02C0F1
+:2009400020E004C08091F200252D281B9FBF222361F4FA9419F42FEF3FEF4DC061E070E0BE
+:2009600080E090E00E945A023BC0822F90E0C817D9070CF42C2FC21BD1094FB7F894909208
+:20098000E900A114B10421F406C01092F10021502223D9F719C0E7FC03C0F801922F10C007
+:2009A000C801322F06C0FC010196E491E093F10031503323C1F706C081918093F10091508E
+:2009C0009923D1F7020F111D8091E80085FF05C0209729F4C114D10411F06092E8004FBFAB
+:2009E000209709F0A5CF5D9884E680933501282D372DC9019C01C901DF91CF911F910F9121
+:200A0000FF90EF90DF90CF90BF90AF909F908F907F906F905F9008951F920F920FB60F92CC
+:200A200011242F933F934F935F936F937F938F939F93AF93BF93EF93FF938091E100109275
+:200A4000E100982F83FF0FC01092E90081E08093EB001092EC0082E38093ED0010923701E6
+:200A600088E08093F00092FF34C083E08093E9008091F200882319F08AE38093E8008FB7C2
+:200A8000F89492E09093E9009091F2008FBF992321F082E891E00E9469078091350188233F
+:200AA00051F08091350181508093350180913501882309F45D9A80913601882351F0809169
+:200AC000360181508093360180913601882309F4289AFF91EF91BF91AF919F918F917F9112
+:200AE0006F915F914F913F912F910F900FBE0F901F9018950F931F93DF93CF930F92CDB7E2
+:200B0000DEB719828E010F5F1F4FC8010E948F07C8010E942809898190E00F90CF91DF91B4
+:200B20001F910F9108951F920F920FB60F921124EF92FF921F932F933F934F935F936F93AD
+:200B40007F938F939F93AF93BF93EF93FF93DF93CF93CDB7DEB76197DEBFCDBF1092E900EE
+:200B60008091E80083FF0FC1FE0131969E01275F3F4F03C08091F1008193E217F307D1F71D
+:200B8000289884E68093360182EF8093E800998197FF05C08091E80080FFFCCF03C08EEF7D
+:200BA0008093E800292F30E0C90180769070892B09F0C2C08A81882329F41092F1001092DB
+:200BC000F100D6C0813009F4D3C0833009F4D0C0853049F48091E80080FFFCCF8B818068E4
+:200BE0008093E300C5C0863009F07CC01C81EF80F8841230C1F51092E90010923901109206
+:200C0000380110923B0110923A010E947A0599E0FE013996DF01292F1D922A95E9F79987D2
+:200C20001A8791E09E8790E8988B9AEF998B2091380130913901275F3F4F3C872B878D87B3
+:200C40001092E9001092390110923801F0923B01E0923A0180E0BF0149E050E00E94E203E7
+:200C60000E947A0585C01092E9001092390110923801F0923B01E0923A01123241F482E284
+:200C800090E00E942009892B09F476C071C0113079F488E0E816F10419F481E080933C013A
+:200CA00080913C01882309F06BC0EAE7F1E013C0133009F061C08B81882319F4ECE3F1E0E1
+:200CC0000AC0823019F4E0E4F1E005C0813009F053C0E2E6F1E0449180E8BF0150E00E940C
+:200CE000E20346C0873009F447C0883021F481E08093F1003DC08930D9F523703070232B17
+:200D0000D9F5EFE9F1E091E031E026E39093E9003093EB0084918093EC002093ED009F5F65
+:200D20003196953099F78EE78093EA001092EA008B81809337011CC08F8198851092E900AE
+:200D4000109239011092380190933B0180933A018D81882329F4CE0101960E949B0706C0E9
+:200D6000823051F4CE0101960E94F107882321F08EEF8093E80007C081E28093EB0003C05D
+:200D8000ECE8F1E0A8CF6196DEBFCDBFCF91DF91FF91EF91BF91AF919F918F917F916F9147
+:200DA0005F914F913F912F911F91FF90EF900F900FBE0F901F90189520917E0130917F013D
+:200DC0008091800190918101281B390B2F733070C901089520917E0130917F0180918001AB
+:200DE000909181012817390719F42FEF3FEF09C0E0918001F0918101E25CFE4F8081282FD7
+:200E000030E0C901089520917E0130917F0180918001909181012817390719F42FEF3FEFDD
+:200E200013C0E0918001F0918101E25CFE4F2081809180019091810101968F7390709093CD
+:200E400081018093800130E0C9010895109285011092840188EE93E0A0E0B0E08093860123
+:200E600090938701A0938801B093890180E191E0909383018093820108950F931F93DF93CC
+:200E8000CF930F92CDB7DEB78C01698380910901882369F083E0BE016F5F7F4F41E050E08F
+:200EA0000E9467041816190614F49C0107C081E090E0F8019383828320E030E0C9010F900E
+:200EC000CF91DF911F910F91089583E00E943E040895CF93DF9312C082E00E94C9032FEFDD
+:200EE0008F3F9207C9F0E0917E01F0917F01E25CFE4F8083D0937F01C0937E01C0917E01CE
+:200F0000D0917F012196CF73D0708091800190918101C817D90701F7DF91CF910895FC0161
+:200F200080818E5F808380E863EA71E042E450E00E94E2030895FC0181819081913A59F418
+:200F4000813209F04CC080E062E071E047E050E00E94E20342C0913209F041C0803239F46A
+:200F600082E091E067E070E00E94260436C0823209F035C08281809309018091020190914E
+:200F80000301A0910401B0910501805B9440A040B04019F58091090180FD12C087E797E7ED
+:200FA00090930108809300082BE088E190E00FB6F894A895809360000FBE209360000DC058
+:200FC00088E10FB6F89480936000109260000FBEA895109201081092000881E0089580E025
+:200FE0000895FC0191818081813A31F4913089F080E0933089F40DC0813269F49B3021F4CD
+:20100000828180930A0105C09A3029F4828180930B0181E0089580E00895EF92FF920F9332
+:201020001F938C01E62EDC01ED91FC910480F581E02D0995F82ED801ED91FC910680F781C8
+:20104000E02DC8016E2D09958F2D90E01F910F91FF90EF900895109290011092940110924E
+:20106000930182E291E090939201809391010895EF92FF920F931F93DF93CF930F92CDB7B0
+:20108000DEB789838B017A0184E0BE016F5F7F4F41E050E00E94670484E4B801A7010E9420
+:2010A00067040F90CF91DF911F910F91FF90EF90089582E048E050E00E9438080895FC0125
+:2010C00016821782108611861286138614823496BF010E9459080895DC01683810F0685884
+:2010E00029C0E62FF0E067FF13C0E058F04081E090E002C0880F991FEA95E2F78095149688
+:201100002C911497282314962C93149760E012C0ED59FD4F6491662319F420E030E01DC0EC
+:2011200067FF08C014968C9114978D7F14968C9314976F77FD0190E0662321F086818617FD
+:2011400009F416829F5F31969630B1F7CD011496BD010E94590821E030E0C9010895CF93B4
+:20116000DF93DC01683810F0685825C0E62FF0E067FF12C0E058F04081E090E002C0880F2C
+:20118000991FEA95E2F714962C911497282B14962C93149760E00FC0ED59FD4F64916623A7
+:2011A000D9F167FF08C014968C911497826014968C9314976F7716968C9116978617A9F1DC
+:2011C00017968C911797861781F118968C911897861759F119968C911997861731F11A963C
+:2011E0008C911A97861709F11B968C911B978617E1F0ED01E0E0F0E09E2F8E81882321F482
+:20120000EA0FFB1F668306C09F5F31962196E630F10591F7963049F481E090E013969C9350
+:201220008E93129720E030E007C0CD011496BD010E94590821E030E0C901DF91CF9108958C
+:2012400080E865EE71E045E650E00E94E2030895FC0180818F5F808380E86AE472E049E1E2
+:2012600050E00E94E20308950895CF92DF92EF92FF920F931F93CF93DF937C016B018A01FD
+:20128000C0E0D0E00FC0D6016D916D01D701ED91FC910190F081E02DC7010995C80FD91FC5
+:2012A000015010400115110571F7CE01DF91CF911F910F91FF90EF90DF90CF900895EE0F94
+:2012C000FF1F0590F491E02D0994F894FFCF0D0000E10000000000000101000000003D079E
+:2012E0003509DC060307EA0665076907000000000D083509AF086C085F08FFFFFFFFFFFF19
+:20130000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFED
+:20132000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFCD
+:20134000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFAD
+:20136000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8D
+:20138000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF6D
+:2013A000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF4D
+:2013C000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF2D
+:2013E000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0D
+:20140000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEC
+:20142000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFCC
+:20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FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF2
+:206EC000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD2
+:206EE000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFB2
+:206F0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF91
+:206F2000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF71
+:206F4000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF51
+:206F6000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF31
+:206F8000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF11
+:206FA000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1
+:206FC000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD1
+:206FE000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFB1
+:2070000055C000006EC000006CC000006AC0000068C0000066C0000064C0000062C0000043
+:2070200060C000005EC00000FCC400005AC0000058C0000056C0000054C0000052C00000E4
+:2070400050C000005DC000004CC000004AC0000048C0000046C0000044C0000042C00000D9
+:2070600040C000003EC000003CC000003AC0000038C0000036C0000034C0000032C0000048
+:2070800030C000002EC000002CC000002AC0000028C0000026C0000024C0000022C00000A8
+:2070A00020C000001EC000001CC0000011241FBECFEFDAE0DEBFCDBF11E0A0E0B1E0E6E4B7
+:2070C000FFE702C005900D92A63AB107D9F711E0A6EAB1E001C01D92AF3BB107E1F74FD34E
+:2070E00030C78ECFF89410926F001092810081E085BF15BE47985D9A289A0C94000008952F
+:207100001F920F920FB60F9211242F938F939F93EF93FF9310928500109284008091A60153
+:207120009091A701009741F001979093A7018093A601892B09F45D9A8091A8019091A90174
+:20714000009741F001979093A9018093A801892B09F4289A8091AC019091AD01019690938C
+:20716000AD018093AC01E0E0F0E0859194918F5F9F4F49F08091AA019091AB01019690937E
+:20718000AB018093AA01FF91EF919F918F912F910F900FBE0F901F90189584E08093E9009E
+:2071A0000DC08091E8008B778093E80003C08EB3882351F08091E80082FFF9CF8091E800E1
+:2071C00085FFEFCF8091F1000895982F83E08093E9008091E80085FD0DC08091E8008E7762
+:2071E0008093E80003C08EB3882369F08091E80080FFF9CF9093F1005D9884E690E0909346
+:20720000A7018093A60108954F925F926F927F928F929F92AF92BF92CF92DF92EF92FF92C3
+:207220000F931F93CF93DF9384E08093E9008091E80082FF57C2289884E690E09093A901CC
+:207240008093A801AADF182F853481F48CE49DE19093AB018093AA0107B600FCFDCFF999E2
+:20726000FECF81E180935700E89503C0843519F494DF8DE00DC28C34E1F38035D1F38437F8
+:2072800021F484E4A2DF80E003C2813611F489E5FFC18134B1F481DF182F7FDF90E0880F7B
+:2072A000991FAA2797FDA095BA2F312F330F20E0442737FD4095542F822B932BA42BB52BE0
+:2072C000B8C1803711F483E5E3C1833549F4C0E0D1E089917ADF21E0C730D207D1F7D9C181
+:2072E000863521F481E371DF80E3D2C1833731F487E86BDF85E969DF8EE1CAC18536B9F464
+:20730000E0E0F0E093E085E090935700E89507B600FCFDCF80935700E89507B600FCFDCF1D
+:20732000E058FF4FA0E7E030FA0771F7A2CF823739F4E1E0F0E089E0809357008491A8C18E
+:20734000863439F4E0E0F0E089E08093570084919FC18E3439F4E3E0F0E089E08093570019
+:20736000849196C1813539F4E2E0F0E089E08093570084918DC1823631F489E526DF80E046
+:2073800024DF80E885C1823419F0873609F0E5C01092AB011092AA0100DF082FFEDEF82E6F
+:2073A000FCDE682E8554823008F071C1902F80E0CF2DD0E0C82BD92B10926F00173609F08F
+:2073C0004BC081E180935700E895DD24CC24C3943FC0E090AF01F090B0010091B1011091DD
+:2073E000B201B6E46B16D9F4ED2DF0E0EE29FF29E4918E2FEADEDD2081F082E090E0A0E00F
+:20740000B0E0E80EF91E0A1F1B1FE092AF01F092B0010093B1011093B201DC2418C0D801CB
+:20742000C701B695A7959795879575D5CEDE82E090E0A0E0B0E0E80EF91E0A1F1B1FE092FB
+:20744000AF01F092B0010093B1011093B2012197209709F0BECF7DC08090AF019090B001EB
+:20746000A090B101B090B20196E4691609F05DC083E0F40180935700E89507B600FCFDCF64
+:2074800054C0F6E46F1661F5772031F1E090AF01F090B0010091B1011091B2017EDED82E20
+:2074A000CC24852D90E08C299D29F7010C0140925700E895112482E090E0A0E0B0E0E80E87
+:2074C000F91E0A1F1B1FE092AF01F092B0010093B1011093B20102C060DE582E742423C041
+:2074E000E090AF01F090B0010091B1011091B20116950795F794E79450DE682FC70113D5E2
+:207500008091AF019091B001A091B101B091B2010296A11DB11D8093AF019093B001A09313
+:20752000B101B093B201219704C05524772444244394209709F0A5CF96E4691641F485E01D
+:20754000F40180935700E89507B600FCFDCF8DE03CDE82E080936F009CC0833471F4009156
+:20756000AF011091B00119DE90E021E0F8010C0120935700E89511247CCE833619F5E0905E
+:20758000AF01F090B0010091B1011091B20105DEF701E16090E021E00C0120935700E89552
+:2075A000112482E090E0A0E0B0E0E80EF91E0A1F1B1FE092AF01F092B0010093B101109307
+:2075C000B20157CE8D3661F4E091AF01F091B00185E080935700E89507B600FCFDCF49CE80
+:2075E000823551F4E091AF01F091B00105911491812FEBDD802F4CC0843421F5E090AF01E0
+:20760000F090B0010091B1011091B20116950795F794E794C2DD682FC70185D48091AF013D
+:207620009091B001A091B101B091B2010296A11DB11D8093AF019093B001A093B101B093BE
+:20764000B20117CE843609F5E090AF01F090B0010091B1011091B201D801C701B695A795CA
+:207660009795879558D4B1DD82E090E0A0E0B0E0E80EF91E0A1F1B1FE092AF01F092B00161
+:207680000093B1011093B20104C08B3111F08FE39CDD83E08093E9009091E8008091E80082
+:2076A0008E778093E80095FF04C010C08EB38823C9F08091E80080FFF9CF8091E8008E77BF
+:2076C0008093E80003C08EB3882361F08091E80080FFF9CF84E08093E9008091E8008B7714
+:2076E0008093E800DF91CF911F910F91FF90EF90DF90CF90BF90AF909F908F907F906F90A9
+:207700005F904F9008959091B701892F8F77813249F58091B8018032A1F0813219F5913ADD
+:2077200009F58091E800877F8093E8008CE091E067E070E027D28091E8008B778093E800EE
+:207740000895913279F48091E800877F8093E8008CE091E067E070E079D28091E8008E77A5
+:207760008093E800089582E061EC42E0D1D083E061E842E1CDD084E060E842E1C9C01F9389
+:20778000209100081092000844B714BE88E10FB6F89480936000109260000FBE80E8E0E095
+:2077A000F0E00FB6F89480936100E09361000FBE31E035BF92E095BF3F9A209A559A809333
+:2077C00061001092610047985D9A289A109289008AEF8093880090936F0083E080938100E5
+:2077E000859194918F5F9F4F11F03093AE01942F41FF19C0809109012817A9F08093000815
+:20780000789480911301882339F08091AC019091AD018F5E9240C8F310920008F89481E0C5
+:20782000809313010CC090FF04C08091AE01882351F493FF09C080910901281729F0809173
+:20784000AE01882309F04EDCD4D078941092AB011092AA011EEF20C0D7DC4BD38091AA01E6
+:207860009091AB0181549F4110F0109213018091B3019091B40101969093B4018093B301FF
+:20788000292F97FF03C0512F591B252F220F281710F4479801C0479A809113018823E1F653
+:2078A0008091E00081608093E0001CDC80E090E01F910895FA01923049F0933061F0913023
+:2078C000F9F484E191E022E130E01EC086E291E02EE330E019C0882329F484E691E024E07A
+:2078E00030E012C0813029F488E691E022E230E00BC0823029F48CE891E028E130E004C089
+:2079000080E090E020E030E091838083C90108958093E9008091EB0081608093EB00109290
+:20792000ED006093EC004093ED008091EE00881F8827881F08958091B70188238CF403C06B
+:207940008EB38823B1F08091E80082FFF9CF8091E8008B778093E80008958EB3882349F0A0
+:207960008091E80080FFF9CF8091E8008E778093E8000895EF92FF920F931F9345D04CD09A
+:2079800008ED10E0F80180818F77808380818068808380818F7D808319BC1EBA1092B501FE
+:2079A00080EEE82EF12CF70180818B7F8083F80180818160808380E060E042E0A9DFE1EE29
+:2079C000F0E080818E7F8083E2EEF0E0808181608083808188608083F70180818E7F80834C
+:2079E000F8018081806180831F910F91FF90EF900895E7EDF0E08081816080838AE482BF76
+:207A000081E08093B601B6CFE8EDF0E080818E7F80831092E20008951092DA001092E100E0
+:207A200008951F920F920FB60F9211242F933F934F935F936F937F938F939F93AF93BF9358
+:207A4000EF93FF938091DA0080FF1BC08091D80080FF17C08091DA008E7F8093DA00809198
+:207A6000D90080FF0BC080E189BD82E189BD09B400FEFDCF81E08EBB3BD203C019BC1EBAE5
+:207A800037D28091E10080FF17C08091E20080FF13C08091E2008E7F8093E2008091E20068
+:207AA00080618093E2008091D80080628093D80019BC85E08EBB1CD28091E10084FF2CC068
+:207AC0008091E20084FF28C080E189BD82E189BD09B400FEFDCF8091D8008F7D8093D80091
+:207AE0008091E1008F7E8093E1008091E2008F7E8093E2008091E20081608093E2008091C4
+:207B0000B501882331F48091E30087FD02C081E001C084E08EBBECD18091E10083FF21C0C4
+:207B20008091E20083FF1DC08091E100877F8093E10082E08EBB1092B5018091E1008E7F05
+:207B40008093E1008091E2008E7F8093E2008091E20080618093E20080E060E042E0D8DEFB
+:207B6000C7D1FF91EF91BF91AF919F918F917F916F915F914F913F912F910F900FBE0F9002
+:207B80001F9018959C014091BD015091BE014617570718F4F90190E044C06115710511F09B
+:207BA000AB01F8CF8091E8008E778093E80040E050E0F0CF8EB3882309F444C0853009F4AB
+:207BC00043C08091E80083FF02C081E008958091E80082FD31C08091E80080FF22C0809193
+:207BE000F3009091F200782F60E0292F30E0262B372B07C081918093F100415050402F5FF1
+:207C00003F4F4115510519F02830310598F390E02830310509F491E08091E8008E7780938B
+:207C2000E8004115510531F6992321F605C08EB3882341F0853041F08091E80082FFF7CFAE
+:207C400080E0089582E0089583E008959C016115710529F48091E8008B778093E800F90192
+:207C600026C08EB3882391F1853091F18091E80083FF02C081E008958091E80082FFF1CF04
+:207C800006C08091F10081936150704059F02091F3008091F200322F20E090E0822B932B7B
+:207CA000892B79F78091E8008B778093E80061157105B9F605C08EB3882341F0853041F047
+:207CC0008091E80080FFF7CF80E0089582E0089583E008950F931F93DF93CF9300D0CDB7EE
+:207CE000DEB7E7EBF1E08091F100819381E0EF3BF807C9F708DD8091E80083FFE4C08091D7
+:207D0000B7019091B801953009F46DC0963040F4913081F1913070F0933009F0D4C02AC05A
+:207D2000983009F4A3C0993009F4B2C0963009F0CAC07CC0803809F4C6C0823809F0C3C0ED
+:207D40008091BB0187708093E9008091EB001092E9002091E800277F2093E80090E025E08D
+:207D6000969587952A95E1F781708093F1001092F10087C0882319F0823009F0A4C08F7193
+:207D8000823009F0A0C08091B901882331F52091BB01277009F497C02093E9008091EB004C
+:207DA00080FF1BC0933021F48091EB00806213C08091EB0080618093EB0081E090E002C072
+:207DC000880F991F2A95E2F78093EA001092EA008091EB0088608093EB001092E9008091B5
+:207DE000E800877F51C0882309F06DC01091B9011F770FB7F8948091E800877F8093E80076
+:207E00009ADD8091E80080FFFCCF8091E3008078812B8093E30080688093E300112311F403
+:207E200082E001C083E08EBB0FBF4DC08058823008F049C08091B9019091BA016091BB01B9
+:207E4000AE014F5F5F4F36DDBC01009709F43BC08091E800877F8093E80089819A8192DE29
+:207E60008091E8008B778093E8002DC0803859F58091E800877F8093E8008091B501809345
+:207E8000F1008091E8008E778093E80054DD1BC08823C9F49091B9019230A8F48091E80052
+:207EA000877F8093E8009093B50145DD8091B501882331F48091E30087FD02C081E001C0D3
+:207EC00084E08EBB50DC8091E80083FF0AC08091EB0080628093EB008091E800877F809396
+:207EE000E8000F900F90CF91DF911F910F91089508951F938EB3882361F01091E9001092E7
+:207F0000E9008091E80083FF01C0E4DE17701093E9001F910895F999FECF92BD81BDF89A9C
+:207F2000992780B50895262FF999FECF1FBA92BD81BD20BD0FB6F894FA9AF99A0FBE0196DC
+:207F40000895F894FFCF4341544552494E4100770008000000000000080112011001020035
+:207F600000084123410001000201000109023E000201008032090400000102020100052415
+:207F8000001001042402040524060001070582030800FF09040100020A00000007050402AE
+:207FA00010000107058302100001040309042203410072006400750069006E006F002000E3
+:207FC000590075006E002000200020002000200000001803410072006400750069006E0047
+:0C7FE0006F0020004C004C00430000002B
+:00000001FF
diff --git a/cores/arduino/Arduino.h b/cores/arduino/Arduino.h
index 3b9ccca..de1886d 100755..100644
--- a/cores/arduino/Arduino.h
+++ b/cores/arduino/Arduino.h
@@ -15,6 +15,8 @@
extern "C"{
#endif
+void yield(void);
+
#define HIGH 0x1
#define LOW 0x0
@@ -149,6 +151,8 @@ extern const uint8_t PROGMEM digital_pin_to_timer_PGM[];
#define NOT_A_PIN 0
#define NOT_A_PORT 0
+#define NOT_AN_INTERRUPT -1
+
#ifdef ARDUINO_MAIN
#define PA 1
#define PB 2
diff --git a/cores/arduino/CDC.cpp b/cores/arduino/CDC.cpp
index e1e859d..a691306 100644
--- a/cores/arduino/CDC.cpp
+++ b/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;
@@ -144,8 +129,7 @@ void Serial_::end(void)
void Serial_::accept(void)
{
- ring_buffer *buffer = &cdc_rx_buffer;
- int i = (unsigned int)(buffer->head+1) % SERIAL_BUFFER_SIZE;
+ int i = (unsigned int)(_rx_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
@@ -153,42 +137,39 @@ void Serial_::accept(void)
// and so we don't write the character or advance the head.
// while we have room to store a byte
- while (i != buffer->tail) {
+ while (i != _rx_buffer_tail) {
int c = USB_Recv(CDC_RX);
if (c == -1)
break; // no more data
- buffer->buffer[buffer->head] = c;
- buffer->head = i;
+ _rx_buffer[_rx_buffer_head] = c;
+ _rx_buffer_head = i;
- i = (unsigned int)(buffer->head+1) % SERIAL_BUFFER_SIZE;
+ i = (unsigned int)(_rx_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;
+ return (unsigned int)(SERIAL_BUFFER_SIZE + _rx_buffer_head - _rx_buffer_tail) % SERIAL_BUFFER_SIZE;
}
int Serial_::peek(void)
{
- ring_buffer *buffer = &cdc_rx_buffer;
- if (buffer->head == buffer->tail) {
+ if (_rx_buffer_head == _rx_buffer_tail) {
return -1;
} else {
- return buffer->buffer[buffer->tail];
+ return _rx_buffer[_rx_buffer_tail];
}
}
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) {
+ if (_rx_buffer_head == _rx_buffer_tail) {
return -1;
} else {
- unsigned char c = buffer->buffer[buffer->tail];
- buffer->tail = (unsigned int)(buffer->tail + 1) % SERIAL_BUFFER_SIZE;
+ unsigned char c = _rx_buffer[_rx_buffer_tail];
+ _rx_buffer_tail = (unsigned int)(_rx_buffer_tail + 1) % SERIAL_BUFFER_SIZE;
return c;
}
}
diff --git a/cores/arduino/HardwareSerial.cpp b/cores/arduino/HardwareSerial.cpp
index eb2365f..9a86fa0 100644
--- a/cores/arduino/HardwareSerial.cpp
+++ b/cores/arduino/HardwareSerial.cpp
@@ -49,55 +49,17 @@
#endif
#endif
-// Define constants and variables for buffering incoming serial data. We're
-// using a ring buffer (I think), in which head is the index of the location
-// to which to write the next incoming character and tail is the index of the
-// location from which to read.
-#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 unsigned int head;
- volatile unsigned int tail;
-};
-
-#if defined(USBCON)
- ring_buffer rx_buffer = { { 0 }, 0, 0};
- ring_buffer tx_buffer = { { 0 }, 0, 0};
-#endif
-#if defined(UBRRH) || defined(UBRR0H)
- ring_buffer rx_buffer = { { 0 }, 0, 0 };
- ring_buffer tx_buffer = { { 0 }, 0, 0 };
-#endif
-#if defined(UBRR1H)
- ring_buffer rx_buffer1 = { { 0 }, 0, 0 };
- ring_buffer tx_buffer1 = { { 0 }, 0, 0 };
-#endif
-#if defined(UBRR2H)
- ring_buffer rx_buffer2 = { { 0 }, 0, 0 };
- ring_buffer tx_buffer2 = { { 0 }, 0, 0 };
-#endif
-#if defined(UBRR3H)
- ring_buffer rx_buffer3 = { { 0 }, 0, 0 };
- ring_buffer tx_buffer3 = { { 0 }, 0, 0 };
-#endif
-
-inline void store_char(unsigned char c, ring_buffer *buffer)
+inline void store_char(unsigned char c, HardwareSerial *s)
{
- int i = (unsigned int)(buffer->head + 1) % SERIAL_BUFFER_SIZE;
+ int i = (unsigned int)(s->_rx_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.
- if (i != buffer->tail) {
- buffer->buffer[buffer->head] = c;
- buffer->head = i;
+ if (i != s->_rx_buffer_tail) {
+ s->_rx_buffer[s->_rx_buffer_head] = c;
+ s->_rx_buffer_head = i;
}
}
@@ -122,14 +84,14 @@ inline void store_char(unsigned char c, ring_buffer *buffer)
#if defined(UDR0)
if (bit_is_clear(UCSR0A, UPE0)) {
unsigned char c = UDR0;
- store_char(c, &rx_buffer);
+ store_char(c, &Serial);
} else {
unsigned char c = UDR0;
};
#elif defined(UDR)
if (bit_is_clear(UCSRA, PE)) {
unsigned char c = UDR;
- store_char(c, &rx_buffer);
+ store_char(c, &Serial);
} else {
unsigned char c = UDR;
};
@@ -148,7 +110,7 @@ inline void store_char(unsigned char c, ring_buffer *buffer)
{
if (bit_is_clear(UCSR1A, UPE1)) {
unsigned char c = UDR1;
- store_char(c, &rx_buffer1);
+ store_char(c, &Serial1);
} else {
unsigned char c = UDR1;
};
@@ -163,7 +125,7 @@ inline void store_char(unsigned char c, ring_buffer *buffer)
{
if (bit_is_clear(UCSR2A, UPE2)) {
unsigned char c = UDR2;
- store_char(c, &rx_buffer2);
+ store_char(c, &Serial2);
} else {
unsigned char c = UDR2;
};
@@ -178,7 +140,7 @@ inline void store_char(unsigned char c, ring_buffer *buffer)
{
if (bit_is_clear(UCSR3A, UPE3)) {
unsigned char c = UDR3;
- store_char(c, &rx_buffer3);
+ store_char(c, &Serial3);
} else {
unsigned char c = UDR3;
};
@@ -218,7 +180,7 @@ ISR(USART0_UDRE_vect)
ISR(USART_UDRE_vect)
#endif
{
- if (tx_buffer.head == tx_buffer.tail) {
+ if (Serial._tx_buffer_head == Serial._tx_buffer_tail) {
// Buffer empty, so disable interrupts
#if defined(UCSR0B)
cbi(UCSR0B, UDRIE0);
@@ -228,8 +190,8 @@ ISR(USART_UDRE_vect)
}
else {
// There is more data in the output buffer. Send the next byte
- unsigned char c = tx_buffer.buffer[tx_buffer.tail];
- tx_buffer.tail = (tx_buffer.tail + 1) % SERIAL_BUFFER_SIZE;
+ unsigned char c = Serial._tx_buffer[Serial._tx_buffer_tail];
+ Serial._tx_buffer_tail = (Serial._tx_buffer_tail + 1) % SERIAL_BUFFER_SIZE;
#if defined(UDR0)
UDR0 = c;
@@ -246,14 +208,14 @@ ISR(USART_UDRE_vect)
#ifdef USART1_UDRE_vect
ISR(USART1_UDRE_vect)
{
- if (tx_buffer1.head == tx_buffer1.tail) {
+ if (Serial1._tx_buffer_head == Serial1._tx_buffer_tail) {
// Buffer empty, so disable interrupts
cbi(UCSR1B, UDRIE1);
}
else {
// There is more data in the output buffer. Send the next byte
- unsigned char c = tx_buffer1.buffer[tx_buffer1.tail];
- tx_buffer1.tail = (tx_buffer1.tail + 1) % SERIAL_BUFFER_SIZE;
+ unsigned char c = Serial1._tx_buffer[Serial1._tx_buffer_tail];
+ Serial1._tx_buffer_tail = (Serial1._tx_buffer_tail + 1) % SERIAL_BUFFER_SIZE;
UDR1 = c;
}
@@ -263,14 +225,14 @@ ISR(USART1_UDRE_vect)
#ifdef USART2_UDRE_vect
ISR(USART2_UDRE_vect)
{
- if (tx_buffer2.head == tx_buffer2.tail) {
+ if (Serial2._tx_buffer_head == Serial2._tx_buffer_tail) {
// Buffer empty, so disable interrupts
cbi(UCSR2B, UDRIE2);
}
else {
// There is more data in the output buffer. Send the next byte
- unsigned char c = tx_buffer2.buffer[tx_buffer2.tail];
- tx_buffer2.tail = (tx_buffer2.tail + 1) % SERIAL_BUFFER_SIZE;
+ unsigned char c = Serial2._tx_buffer[Serial2._tx_buffer_tail];
+ Serial2._tx_buffer_tail = (Serial2._tx_buffer_tail + 1) % SERIAL_BUFFER_SIZE;
UDR2 = c;
}
@@ -280,31 +242,30 @@ ISR(USART2_UDRE_vect)
#ifdef USART3_UDRE_vect
ISR(USART3_UDRE_vect)
{
- if (tx_buffer3.head == tx_buffer3.tail) {
+ if (Serial3._tx_buffer_head == Serial3._tx_buffer_tail) {
// Buffer empty, so disable interrupts
cbi(UCSR3B, UDRIE3);
}
else {
// There is more data in the output buffer. Send the next byte
- unsigned char c = tx_buffer3.buffer[tx_buffer3.tail];
- tx_buffer3.tail = (tx_buffer3.tail + 1) % SERIAL_BUFFER_SIZE;
+ unsigned char c = Serial3._tx_buffer[Serial3._tx_buffer_tail];
+ Serial3._tx_buffer_tail = (Serial3._tx_buffer_tail + 1) % SERIAL_BUFFER_SIZE;
UDR3 = c;
}
}
#endif
-
// Constructors ////////////////////////////////////////////////////////////////
-HardwareSerial::HardwareSerial(ring_buffer *rx_buffer, ring_buffer *tx_buffer,
+HardwareSerial::HardwareSerial(
volatile uint8_t *ubrrh, volatile uint8_t *ubrrl,
volatile uint8_t *ucsra, volatile uint8_t *ucsrb,
volatile uint8_t *ucsrc, volatile uint8_t *udr,
uint8_t rxen, uint8_t txen, uint8_t rxcie, uint8_t udrie, uint8_t u2x)
{
- _rx_buffer = rx_buffer;
- _tx_buffer = tx_buffer;
+ _tx_buffer_head = _tx_buffer_tail = 0;
+ _rx_buffer_head = _rx_buffer_tail = 0;
_ubrrh = ubrrh;
_ubrrl = ubrrl;
_ucsra = ucsra;
@@ -412,7 +373,7 @@ try_again:
void HardwareSerial::end()
{
// wait for transmission of outgoing data
- while (_tx_buffer->head != _tx_buffer->tail)
+ while (_tx_buffer_head != _tx_buffer_tail)
;
cbi(*_ucsrb, _rxen);
@@ -421,31 +382,31 @@ void HardwareSerial::end()
cbi(*_ucsrb, _udrie);
// clear any received data
- _rx_buffer->head = _rx_buffer->tail;
+ _rx_buffer_head = _rx_buffer_tail;
}
int HardwareSerial::available(void)
{
- return (unsigned int)(SERIAL_BUFFER_SIZE + _rx_buffer->head - _rx_buffer->tail) % SERIAL_BUFFER_SIZE;
+ return (unsigned int)(SERIAL_BUFFER_SIZE + _rx_buffer_head - _rx_buffer_tail) % SERIAL_BUFFER_SIZE;
}
int HardwareSerial::peek(void)
{
- if (_rx_buffer->head == _rx_buffer->tail) {
+ if (_rx_buffer_head == _rx_buffer_tail) {
return -1;
} else {
- return _rx_buffer->buffer[_rx_buffer->tail];
+ return _rx_buffer[_rx_buffer_tail];
}
}
int HardwareSerial::read(void)
{
// if the head isn't ahead of the tail, we don't have any characters
- if (_rx_buffer->head == _rx_buffer->tail) {
+ if (_rx_buffer_head == _rx_buffer_tail) {
return -1;
} else {
- unsigned char c = _rx_buffer->buffer[_rx_buffer->tail];
- _rx_buffer->tail = (unsigned int)(_rx_buffer->tail + 1) % SERIAL_BUFFER_SIZE;
+ unsigned char c = _rx_buffer[_rx_buffer_tail];
+ _rx_buffer_tail = (unsigned int)(_rx_buffer_tail + 1) % SERIAL_BUFFER_SIZE;
return c;
}
}
@@ -459,16 +420,16 @@ void HardwareSerial::flush()
size_t HardwareSerial::write(uint8_t c)
{
- int i = (_tx_buffer->head + 1) % SERIAL_BUFFER_SIZE;
+ int i = (_tx_buffer_head + 1) % SERIAL_BUFFER_SIZE;
// If the output buffer is full, there's nothing for it other than to
// wait for the interrupt handler to empty it a bit
// ???: return 0 here instead?
- while (i == _tx_buffer->tail)
+ while (i == _tx_buffer_tail)
;
- _tx_buffer->buffer[_tx_buffer->head] = c;
- _tx_buffer->head = i;
+ _tx_buffer[_tx_buffer_head] = c;
+ _tx_buffer_head = i;
sbi(*_ucsrb, _udrie);
// clear the TXC bit -- "can be cleared by writing a one to its bit location"
@@ -485,9 +446,9 @@ HardwareSerial::operator bool() {
// Preinstantiate Objects //////////////////////////////////////////////////////
#if defined(UBRRH) && defined(UBRRL)
- HardwareSerial Serial(&rx_buffer, &tx_buffer, &UBRRH, &UBRRL, &UCSRA, &UCSRB, &UCSRC, &UDR, RXEN, TXEN, RXCIE, UDRIE, U2X);
+ HardwareSerial Serial(&UBRRH, &UBRRL, &UCSRA, &UCSRB, &UCSRC, &UDR, RXEN, TXEN, RXCIE, UDRIE, U2X);
#elif defined(UBRR0H) && defined(UBRR0L)
- HardwareSerial Serial(&rx_buffer, &tx_buffer, &UBRR0H, &UBRR0L, &UCSR0A, &UCSR0B, &UCSR0C, &UDR0, RXEN0, TXEN0, RXCIE0, UDRIE0, U2X0);
+ HardwareSerial Serial(&UBRR0H, &UBRR0L, &UCSR0A, &UCSR0B, &UCSR0C, &UDR0, RXEN0, TXEN0, RXCIE0, UDRIE0, U2X0);
#elif defined(USBCON)
// do nothing - Serial object and buffers are initialized in CDC code
#else
@@ -495,13 +456,13 @@ HardwareSerial::operator bool() {
#endif
#if defined(UBRR1H)
- HardwareSerial Serial1(&rx_buffer1, &tx_buffer1, &UBRR1H, &UBRR1L, &UCSR1A, &UCSR1B, &UCSR1C, &UDR1, RXEN1, TXEN1, RXCIE1, UDRIE1, U2X1);
+ HardwareSerial Serial1(&UBRR1H, &UBRR1L, &UCSR1A, &UCSR1B, &UCSR1C, &UDR1, RXEN1, TXEN1, RXCIE1, UDRIE1, U2X1);
#endif
#if defined(UBRR2H)
- HardwareSerial Serial2(&rx_buffer2, &tx_buffer2, &UBRR2H, &UBRR2L, &UCSR2A, &UCSR2B, &UCSR2C, &UDR2, RXEN2, TXEN2, RXCIE2, UDRIE2, U2X2);
+ HardwareSerial Serial2(&UBRR2H, &UBRR2L, &UCSR2A, &UCSR2B, &UCSR2C, &UDR2, RXEN2, TXEN2, RXCIE2, UDRIE2, U2X2);
#endif
#if defined(UBRR3H)
- HardwareSerial Serial3(&rx_buffer3, &tx_buffer3, &UBRR3H, &UBRR3L, &UCSR3A, &UCSR3B, &UCSR3C, &UDR3, RXEN3, TXEN3, RXCIE3, UDRIE3, U2X3);
+ HardwareSerial Serial3(&UBRR3H, &UBRR3L, &UCSR3A, &UCSR3B, &UCSR3C, &UDR3, RXEN3, TXEN3, RXCIE3, UDRIE3, U2X3);
#endif
#endif // whole file
diff --git a/cores/arduino/HardwareSerial.h b/cores/arduino/HardwareSerial.h
index a73117f..0f62262 100644
--- a/cores/arduino/HardwareSerial.h
+++ b/cores/arduino/HardwareSerial.h
@@ -27,13 +27,19 @@
#include "Stream.h"
-struct ring_buffer;
+// Define constants and variables for buffering incoming serial data. We're
+// using a ring buffer (I think), in which head is the index of the location
+// to which to write the next incoming character and tail is the index of the
+// location from which to read.
+#if (RAMEND < 1000)
+ #define SERIAL_BUFFER_SIZE 16
+#else
+ #define SERIAL_BUFFER_SIZE 64
+#endif
class HardwareSerial : public Stream
{
- private:
- ring_buffer *_rx_buffer;
- ring_buffer *_tx_buffer;
+ protected:
volatile uint8_t *_ubrrh;
volatile uint8_t *_ubrrl;
volatile uint8_t *_ucsra;
@@ -46,8 +52,20 @@ class HardwareSerial : public Stream
uint8_t _udrie;
uint8_t _u2x;
bool transmitting;
+
public:
- HardwareSerial(ring_buffer *rx_buffer, ring_buffer *tx_buffer,
+ volatile uint8_t _rx_buffer_head;
+ volatile uint8_t _rx_buffer_tail;
+ volatile uint8_t _tx_buffer_head;
+ volatile uint8_t _tx_buffer_tail;
+
+ // Don't put any members after these buffers, since only the first
+ // 32 bytes of this struct can be accessed quickly using the ldd
+ // instruction.
+ unsigned char _rx_buffer[SERIAL_BUFFER_SIZE];
+ unsigned char _tx_buffer[SERIAL_BUFFER_SIZE];
+
+ HardwareSerial(
volatile uint8_t *ubrrh, volatile uint8_t *ubrrl,
volatile uint8_t *ucsra, volatile uint8_t *ucsrb,
volatile uint8_t *ucsrc, volatile uint8_t *udr,
diff --git a/cores/arduino/IPAddress.h b/cores/arduino/IPAddress.h
index 2585aec..078ac97 100644
--- a/cores/arduino/IPAddress.h
+++ b/cores/arduino/IPAddress.h
@@ -26,6 +26,7 @@
#ifndef IPAddress_h
#define IPAddress_h
+#include <stdint.h>
#include <Printable.h>
// A class to make it easier to handle and pass around IP addresses
diff --git a/cores/arduino/Print.cpp b/cores/arduino/Print.cpp
index 53961ec..5df5630 100755..100644
--- a/cores/arduino/Print.cpp
+++ b/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/cores/arduino/Print.h b/cores/arduino/Print.h
index dc76150..7b53aa4 100755..100644
--- a/cores/arduino/Print.h
+++ b/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/cores/arduino/Stream.h b/cores/arduino/Stream.h
index 007b4bc..5cf5ddf 100644
--- a/cores/arduino/Stream.h
+++ b/cores/arduino/Stream.h
@@ -57,14 +57,18 @@ class Stream : public Print
void setTimeout(unsigned long timeout); // sets maximum milliseconds to wait for stream data, default is 1 second
bool find(char *target); // reads data from the stream until the target string is found
+ bool find(uint8_t *target) { return find ((char *)target); }
// returns true if target string is found, false if timed out (see setTimeout)
bool find(char *target, size_t length); // reads data from the stream until the target string of given length is found
+ bool find(uint8_t *target, size_t length) { return find ((char *)target, length); }
// returns true if target string is found, false if timed out
bool findUntil(char *target, char *terminator); // as find but search ends if the terminator string is found
+ bool findUntil(uint8_t *target, char *terminator) { return findUntil((char *)target, terminator); }
bool findUntil(char *target, size_t targetLen, char *terminate, size_t termLen); // as above but search ends if the terminate string is found
+ bool findUntil(uint8_t *target, size_t targetLen, char *terminate, size_t termLen) {return findUntil((char *)target, targetLen, terminate, termLen); }
long parseInt(); // returns the first valid (long) integer value from the current position.
@@ -74,10 +78,12 @@ class Stream : public Print
float parseFloat(); // float version of parseInt
size_t readBytes( char *buffer, size_t length); // read chars from stream into buffer
+ size_t readBytes( uint8_t *buffer, size_t length) { return readBytes((char *)buffer, length); }
// terminates if length characters have been read or timeout (see setTimeout)
// returns the number of characters placed in the buffer (0 means no valid data found)
size_t readBytesUntil( char terminator, char *buffer, size_t length); // as readBytes with terminator character
+ size_t readBytesUntil( char terminator, uint8_t *buffer, size_t length) { return readBytesUntil(terminator, (char *)buffer, length); }
// terminates if length characters have been read, timeout, or if the terminator character detected
// returns the number of characters placed in the buffer (0 means no valid data found)
diff --git a/cores/arduino/Tone.cpp b/cores/arduino/Tone.cpp
index 9bb6fe7..9bb6fe7 100755..100644
--- a/cores/arduino/Tone.cpp
+++ b/cores/arduino/Tone.cpp
diff --git a/cores/arduino/USBAPI.h b/cores/arduino/USBAPI.h
index 7a14285..da2e869 100644
--- a/cores/arduino/USBAPI.h
+++ b/cores/arduino/USBAPI.h
@@ -25,10 +25,16 @@ extern USBDevice_ USBDevice;
//================================================================================
// Serial over CDC (Serial1 is the physical port)
+struct ring_buffer;
+
+#if (RAMEND < 1000)
+#define SERIAL_BUFFER_SIZE 16
+#else
+#define SERIAL_BUFFER_SIZE 64
+#endif
+
class Serial_ : public Stream
{
-private:
- ring_buffer *_cdc_rx_buffer;
public:
void begin(unsigned long);
void begin(unsigned long, uint8_t);
@@ -42,6 +48,10 @@ public:
virtual size_t write(uint8_t);
using Print::write; // pull in write(str) and write(buf, size) from Print
operator bool();
+
+ volatile uint8_t _rx_buffer_head;
+ volatile uint8_t _rx_buffer_tail;
+ unsigned char _rx_buffer[SERIAL_BUFFER_SIZE];
};
extern Serial_ Serial;
diff --git a/cores/arduino/USBCore.cpp b/cores/arduino/USBCore.cpp
index d3e0170..c46c75f 100644
--- a/cores/arduino/USBCore.cpp
+++ b/cores/arduino/USBCore.cpp
@@ -39,8 +39,8 @@ volatile u8 RxLEDPulse; /**< Milliseconds remaining for data Rx LED pulse */
//==================================================================
extern const u16 STRING_LANGUAGE[] PROGMEM;
-extern const u16 STRING_IPRODUCT[] PROGMEM;
-extern const u16 STRING_IMANUFACTURER[] PROGMEM;
+extern const u8 STRING_PRODUCT[] PROGMEM;
+extern const u8 STRING_MANUFACTURER[] PROGMEM;
extern const DeviceDescriptor USB_DeviceDescriptor PROGMEM;
extern const DeviceDescriptor USB_DeviceDescriptorA PROGMEM;
@@ -49,31 +49,24 @@ const u16 STRING_LANGUAGE[2] = {
0x0409 // English
};
-const u16 STRING_IPRODUCT[17] = {
- (3<<8) | (2+2*16),
-#if USB_PID == 0x8036
- 'A','r','d','u','i','n','o',' ','L','e','o','n','a','r','d','o'
-#elif USB_PID == 0x8037
- 'A','r','d','u','i','n','o',' ','M','i','c','r','o',' ',' ',' '
-#elif USB_PID == 0x803C
- 'A','r','d','u','i','n','o',' ','E','s','p','l','o','r','a',' '
-#elif USB_PID == 0x9208
- 'L','i','l','y','P','a','d','U','S','B',' ',' ',' ',' ',' ',' '
-#else
- 'U','S','B',' ','I','O',' ','B','o','a','r','d',' ',' ',' ',' '
+#ifndef USB_PRODUCT
+// If no product is provided, use USB IO Board
+#define USB_PRODUCT "USB IO Board"
#endif
-};
-const u16 STRING_IMANUFACTURER[12] = {
- (3<<8) | (2+2*11),
+const u8 STRING_PRODUCT[] PROGMEM = USB_PRODUCT;
+
#if USB_VID == 0x2341
- 'A','r','d','u','i','n','o',' ','L','L','C'
+#define USB_MANUFACTURER "Arduino LLC"
#elif USB_VID == 0x1b4f
- 'S','p','a','r','k','F','u','n',' ',' ',' '
-#else
- 'U','n','k','n','o','w','n',' ',' ',' ',' '
+#define USB_MANUFACTURER "SparkFun"
+#elif !defined(USB_MANUFACTURER)
+// Fall through to unknown if no manufacturer name was provided in a macro
+#define USB_MANUFACTURER "Unknown"
#endif
-};
+
+const u8 STRING_MANUFACTURER[] PROGMEM = USB_MANUFACTURER;
+
#ifdef CDC_ENABLED
#define DEVICE_CLASS 0x02
@@ -416,6 +409,22 @@ int USB_SendControl(u8 flags, const void* d, int len)
return sent;
}
+// Send a USB descriptor string. The string is stored in PROGMEM as a
+// plain ASCII string but is sent out as UTF-16 with the correct 2-byte
+// prefix
+static bool USB_SendStringDescriptor(const u8*string_P, u8 string_len) {
+ SendControl(2 + string_len * 2);
+ SendControl(3);
+ for(u8 i = 0; i < string_len; i++) {
+ bool r = SendControl(pgm_read_byte(&string_P[i]));
+ r &= SendControl(0); // high byte
+ if(!r) {
+ return false;
+ }
+ }
+ return true;
+}
+
// Does not timeout or cross fifo boundaries
// Will only work for transfers <= 64 bytes
// TODO
@@ -476,7 +485,6 @@ bool SendDescriptor(Setup& setup)
return HID_GetDescriptor(t);
#endif
- u8 desc_length = 0;
const u8* desc_addr = 0;
if (USB_DEVICE_DESCRIPTOR_TYPE == t)
{
@@ -486,20 +494,22 @@ bool SendDescriptor(Setup& setup)
}
else if (USB_STRING_DESCRIPTOR_TYPE == t)
{
- if (setup.wValueL == 0)
+ if (setup.wValueL == 0) {
desc_addr = (const u8*)&STRING_LANGUAGE;
- else if (setup.wValueL == IPRODUCT)
- desc_addr = (const u8*)&STRING_IPRODUCT;
- else if (setup.wValueL == IMANUFACTURER)
- desc_addr = (const u8*)&STRING_IMANUFACTURER;
+ }
+ else if (setup.wValueL == IPRODUCT) {
+ return USB_SendStringDescriptor(STRING_PRODUCT, strlen(USB_PRODUCT));
+ }
+ else if (setup.wValueL == IMANUFACTURER) {
+ return USB_SendStringDescriptor(STRING_MANUFACTURER, strlen(USB_MANUFACTURER));
+ }
else
return false;
}
if (desc_addr == 0)
return false;
- if (desc_length == 0)
- desc_length = pgm_read_byte(desc_addr);
+ u8 desc_length = pgm_read_byte(desc_addr);
USB_SendControl(TRANSFER_PGM,desc_addr,desc_length);
return true;
diff --git a/cores/arduino/WString.cpp b/cores/arduino/WString.cpp
index e19f543..ed880ce 100644
--- a/cores/arduino/WString.cpp
+++ b/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/cores/arduino/WString.h b/cores/arduino/WString.h
index 2d372c5..7402430 100644
--- a/cores/arduino/WString.h
+++ b/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/cores/arduino/hooks.c b/cores/arduino/hooks.c
new file mode 100644
index 0000000..641eabc
--- /dev/null
+++ b/cores/arduino/hooks.c
@@ -0,0 +1,31 @@
+/*
+ Copyright (c) 2012 Arduino. 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
+*/
+
+/**
+ * Empty yield() hook.
+ *
+ * This function is intended to be used by library writers to build
+ * libraries or sketches that supports cooperative threads.
+ *
+ * Its defined as a weak symbol and it can be redefined to implement a
+ * real cooperative scheduler.
+ */
+static void __empty() {
+ // Empty
+}
+void yield(void) __attribute__ ((weak, alias("__empty")));
diff --git a/cores/arduino/wiring.c b/cores/arduino/wiring.c
index a3c4390..5cbe241 100644
--- a/cores/arduino/wiring.c
+++ b/cores/arduino/wiring.c
@@ -111,6 +111,7 @@ void delay(unsigned long ms)
uint16_t start = (uint16_t)micros();
while (ms > 0) {
+ yield();
if (((uint16_t)micros() - start) >= 1000) {
ms--;
start += 1000;
diff --git a/cores/arduino/wiring_private.h b/cores/arduino/wiring_private.h
index c366005..c366005 100755..100644
--- a/cores/arduino/wiring_private.h
+++ b/cores/arduino/wiring_private.h
diff --git a/cores/arduino/wiring_pulse.c b/cores/arduino/wiring_pulse.c
index 0d96886..0d96886 100755..100644
--- a/cores/arduino/wiring_pulse.c
+++ b/cores/arduino/wiring_pulse.c
diff --git a/cores/arduino/wiring_shift.c b/cores/arduino/wiring_shift.c
index cfe7867..cfe7867 100755..100644
--- a/cores/arduino/wiring_shift.c
+++ b/cores/arduino/wiring_shift.c
diff --git a/cores/robot/Arduino.h b/cores/robot/Arduino.h
deleted file mode 100755
index 3b9ccca..0000000
--- a/cores/robot/Arduino.h
+++ /dev/null
@@ -1,215 +0,0 @@
-#ifndef Arduino_h
-#define Arduino_h
-
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-
-#include <avr/pgmspace.h>
-#include <avr/io.h>
-#include <avr/interrupt.h>
-
-#include "binary.h"
-
-#ifdef __cplusplus
-extern "C"{
-#endif
-
-#define HIGH 0x1
-#define LOW 0x0
-
-#define INPUT 0x0
-#define OUTPUT 0x1
-#define INPUT_PULLUP 0x2
-
-#define true 0x1
-#define false 0x0
-
-#define PI 3.1415926535897932384626433832795
-#define HALF_PI 1.5707963267948966192313216916398
-#define TWO_PI 6.283185307179586476925286766559
-#define DEG_TO_RAD 0.017453292519943295769236907684886
-#define RAD_TO_DEG 57.295779513082320876798154814105
-
-#define SERIAL 0x0
-#define DISPLAY 0x1
-
-#define LSBFIRST 0
-#define MSBFIRST 1
-
-#define CHANGE 1
-#define FALLING 2
-#define RISING 3
-
-#if defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
-#define DEFAULT 0
-#define EXTERNAL 1
-#define INTERNAL 2
-#else
-#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__)
-#define INTERNAL1V1 2
-#define INTERNAL2V56 3
-#else
-#define INTERNAL 3
-#endif
-#define DEFAULT 1
-#define EXTERNAL 0
-#endif
-
-// undefine stdlib's abs if encountered
-#ifdef abs
-#undef abs
-#endif
-
-#define min(a,b) ((a)<(b)?(a):(b))
-#define max(a,b) ((a)>(b)?(a):(b))
-#define abs(x) ((x)>0?(x):-(x))
-#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
-#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
-#define radians(deg) ((deg)*DEG_TO_RAD)
-#define degrees(rad) ((rad)*RAD_TO_DEG)
-#define sq(x) ((x)*(x))
-
-#define interrupts() sei()
-#define noInterrupts() cli()
-
-#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L )
-#define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() )
-#define microsecondsToClockCycles(a) ( (a) * clockCyclesPerMicrosecond() )
-
-#define lowByte(w) ((uint8_t) ((w) & 0xff))
-#define highByte(w) ((uint8_t) ((w) >> 8))
-
-#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))
-
-
-typedef unsigned int word;
-
-#define bit(b) (1UL << (b))
-
-typedef uint8_t boolean;
-typedef uint8_t byte;
-
-void init(void);
-
-void pinMode(uint8_t, uint8_t);
-void digitalWrite(uint8_t, uint8_t);
-int digitalRead(uint8_t);
-int analogRead(uint8_t);
-void analogReference(uint8_t mode);
-void analogWrite(uint8_t, int);
-
-unsigned long millis(void);
-unsigned long micros(void);
-void delay(unsigned long);
-void delayMicroseconds(unsigned int us);
-unsigned long pulseIn(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 setup(void);
-void loop(void);
-
-// Get the bit location within the hardware port of the given virtual pin.
-// This comes from the pins_*.c file for the active board configuration.
-
-#define analogInPinToBit(P) (P)
-
-// On the ATmega1280, the addresses of some of the port registers are
-// greater than 255, so we can't store them in uint8_t's.
-extern const uint16_t PROGMEM port_to_mode_PGM[];
-extern const uint16_t PROGMEM port_to_input_PGM[];
-extern const uint16_t PROGMEM port_to_output_PGM[];
-
-extern const uint8_t PROGMEM digital_pin_to_port_PGM[];
-// extern const uint8_t PROGMEM digital_pin_to_bit_PGM[];
-extern const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[];
-extern const uint8_t PROGMEM digital_pin_to_timer_PGM[];
-
-// Get the bit location within the hardware port of the given virtual pin.
-// This comes from the pins_*.c file for the active board configuration.
-//
-// These perform slightly better as macros compared to inline functions
-//
-#define digitalPinToPort(P) ( pgm_read_byte( digital_pin_to_port_PGM + (P) ) )
-#define digitalPinToBitMask(P) ( pgm_read_byte( digital_pin_to_bit_mask_PGM + (P) ) )
-#define digitalPinToTimer(P) ( pgm_read_byte( digital_pin_to_timer_PGM + (P) ) )
-#define analogInPinToBit(P) (P)
-#define portOutputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_output_PGM + (P))) )
-#define portInputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_input_PGM + (P))) )
-#define portModeRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_mode_PGM + (P))) )
-
-#define NOT_A_PIN 0
-#define NOT_A_PORT 0
-
-#ifdef ARDUINO_MAIN
-#define PA 1
-#define PB 2
-#define PC 3
-#define PD 4
-#define PE 5
-#define PF 6
-#define PG 7
-#define PH 8
-#define PJ 10
-#define PK 11
-#define PL 12
-#endif
-
-#define NOT_ON_TIMER 0
-#define TIMER0A 1
-#define TIMER0B 2
-#define TIMER1A 3
-#define TIMER1B 4
-#define TIMER2 5
-#define TIMER2A 6
-#define TIMER2B 7
-
-#define TIMER3A 8
-#define TIMER3B 9
-#define TIMER3C 10
-#define TIMER4A 11
-#define TIMER4B 12
-#define TIMER4C 13
-#define TIMER4D 14
-#define TIMER5A 15
-#define TIMER5B 16
-#define TIMER5C 17
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#ifdef __cplusplus
-#include "WCharacter.h"
-#include "WString.h"
-#include "HardwareSerial.h"
-
-uint16_t makeWord(uint16_t w);
-uint16_t makeWord(byte h, byte l);
-
-#define word(...) makeWord(__VA_ARGS__)
-
-unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L);
-
-void tone(uint8_t _pin, unsigned int frequency, unsigned long duration = 0);
-void noTone(uint8_t _pin);
-
-// WMath prototypes
-long random(long);
-long random(long, long);
-void randomSeed(unsigned int);
-long map(long, long, long, long, long);
-
-#endif
-
-#include "pins_arduino.h"
-
-#endif
diff --git a/cores/robot/CDC.cpp b/cores/robot/CDC.cpp
deleted file mode 100644
index 701e483..0000000
--- a/cores/robot/CDC.cpp
+++ /dev/null
@@ -1,239 +0,0 @@
-
-
-/* Copyright (c) 2011, Peter Barrett
-**
-** Permission to use, copy, modify, and/or distribute this software for
-** any purpose with or without fee is hereby granted, provided that the
-** above copyright notice and this permission notice appear in all copies.
-**
-** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
-** WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
-** WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR
-** BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
-** OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-** WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-** ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-** SOFTWARE.
-*/
-
-#include "Platform.h"
-#include "USBAPI.h"
-#include <avr/wdt.h>
-
-#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;
- u8 bCharFormat;
- u8 bParityType;
- u8 bDataBits;
- u8 lineState;
-} LineInfo;
-
-static volatile LineInfo _usbLineInfo = { 57600, 0x00, 0x00, 0x00, 0x00 };
-
-#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),
-
- // CDC communication interface
- D_INTERFACE(CDC_ACM_INTERFACE,1,CDC_COMMUNICATION_INTERFACE_CLASS,CDC_ABSTRACT_CONTROL_MODEL,0),
- D_CDCCS(CDC_HEADER,0x10,0x01), // Header (1.10 bcd)
- D_CDCCS(CDC_CALL_MANAGEMENT,1,1), // Device handles call management (not)
- D_CDCCS4(CDC_ABSTRACT_CONTROL_MANAGEMENT,6), // SET_LINE_CODING, GET_LINE_CODING, SET_CONTROL_LINE_STATE supported
- D_CDCCS(CDC_UNION,CDC_ACM_INTERFACE,CDC_DATA_INTERFACE), // Communication interface is master, data interface is slave 0
- D_ENDPOINT(USB_ENDPOINT_IN (CDC_ENDPOINT_ACM),USB_ENDPOINT_TYPE_INTERRUPT,0x10,0x40),
-
- // CDC data interface
- D_INTERFACE(CDC_DATA_INTERFACE,2,CDC_DATA_INTERFACE_CLASS,0,0),
- D_ENDPOINT(USB_ENDPOINT_OUT(CDC_ENDPOINT_OUT),USB_ENDPOINT_TYPE_BULK,0x40,0),
- D_ENDPOINT(USB_ENDPOINT_IN (CDC_ENDPOINT_IN ),USB_ENDPOINT_TYPE_BULK,0x40,0)
-};
-
-int WEAK CDC_GetInterface(u8* interfaceNum)
-{
- interfaceNum[0] += 2; // uses 2
- return USB_SendControl(TRANSFER_PGM,&_cdcInterface,sizeof(_cdcInterface));
-}
-
-bool WEAK CDC_Setup(Setup& setup)
-{
- u8 r = setup.bRequest;
- u8 requestType = setup.bmRequestType;
-
- if (REQUEST_DEVICETOHOST_CLASS_INTERFACE == requestType)
- {
- if (CDC_GET_LINE_CODING == r)
- {
- USB_SendControl(0,(void*)&_usbLineInfo,7);
- return true;
- }
- }
-
- if (REQUEST_HOSTTODEVICE_CLASS_INTERFACE == requestType)
- {
- if (CDC_SET_LINE_CODING == r)
- {
- USB_RecvControl((void*)&_usbLineInfo,7);
- return true;
- }
-
- if (CDC_SET_CONTROL_LINE_STATE == r)
- {
- _usbLineInfo.lineState = setup.wValueL;
-
- // 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
- // like servicing endpoints before the sketch ends
- if (1200 == _usbLineInfo.dwDTERate) {
- // We check DTR state to determine if host port is open (bit 0 of lineState).
- if ((_usbLineInfo.lineState & 0x01) == 0) {
- *(uint16_t *)0x0800 = 0x7777;
- wdt_enable(WDTO_120MS);
- } else {
- // 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
- // cancel if DTR goes back high.
-
- wdt_disable();
- wdt_reset();
- *(uint16_t *)0x0800 = 0x0;
- }
- }
- return true;
- }
- }
- return false;
-}
-
-
-int _serialPeek = -1;
-void Serial_::begin(uint16_t baud_count)
-{
-}
-
-void Serial_::end(void)
-{
-}
-
-void Serial_::accept(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;
-}
-
-int Serial_::peek(void)
-{
- ring_buffer *buffer = &cdc_rx_buffer;
- if (buffer->head == buffer->tail) {
- return -1;
- } else {
- return buffer->buffer[buffer->tail];
- }
-}
-
-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;
- return c;
- }
-}
-
-void Serial_::flush(void)
-{
- USB_Flush(CDC_TX);
-}
-
-size_t Serial_::write(uint8_t c)
-{
- /* 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.
- bytes sent before the user opens the connection or after
- the connection is closed are lost - just like with a UART. */
-
- // TODO - ZE - check behavior on different OSes and test what happens if an
- // 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);
- if (r > 0) {
- return r;
- } else {
- setWriteError();
- return 0;
- }
- }
- setWriteError();
- return 0;
-}
-
-// This operator is a convenient way for a sketch to check whether the
-// port has actually been configured and opened by the host (as opposed
-// to just being connected to the host). It can be used, for example, in
-// setup() before printing to ensure that an application on the host is
-// actually ready to receive and display the data.
-// We add a short delay before returning to fix a bug observed by Federico
-// where the port is configured (lineState != 0) but not quite opened.
-Serial_::operator bool() {
- bool result = false;
- if (_usbLineInfo.lineState > 0)
- result = true;
- delay(10);
- return result;
-}
-
-Serial_ Serial;
-
-#endif
-#endif /* if defined(USBCON) */
diff --git a/cores/robot/Client.h b/cores/robot/Client.h
deleted file mode 100644
index ea13483..0000000
--- a/cores/robot/Client.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef client_h
-#define client_h
-#include "Print.h"
-#include "Stream.h"
-#include "IPAddress.h"
-
-class Client : public Stream {
-
-public:
- virtual int connect(IPAddress ip, uint16_t port) =0;
- virtual int connect(const char *host, uint16_t port) =0;
- virtual size_t write(uint8_t) =0;
- virtual size_t write(const uint8_t *buf, size_t size) =0;
- virtual int available() = 0;
- virtual int read() = 0;
- virtual int read(uint8_t *buf, size_t size) = 0;
- virtual int peek() = 0;
- virtual void flush() = 0;
- virtual void stop() = 0;
- virtual uint8_t connected() = 0;
- virtual operator bool() = 0;
-protected:
- uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); };
-};
-
-#endif
diff --git a/cores/robot/HID.cpp b/cores/robot/HID.cpp
deleted file mode 100644
index ac63608..0000000
--- a/cores/robot/HID.cpp
+++ /dev/null
@@ -1,520 +0,0 @@
-
-
-/* Copyright (c) 2011, Peter Barrett
-**
-** Permission to use, copy, modify, and/or distribute this software for
-** any purpose with or without fee is hereby granted, provided that the
-** above copyright notice and this permission notice appear in all copies.
-**
-** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
-** WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
-** WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR
-** BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
-** OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-** WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-** ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-** SOFTWARE.
-*/
-
-#include "Platform.h"
-#include "USBAPI.h"
-#include "USBDesc.h"
-
-#if defined(USBCON)
-#ifdef HID_ENABLED
-
-//#define RAWHID_ENABLED
-
-// Singletons for mouse and keyboard
-
-Mouse_ Mouse;
-Keyboard_ Keyboard;
-
-//================================================================================
-//================================================================================
-
-// HID report descriptor
-
-#define LSB(_x) ((_x) & 0xFF)
-#define MSB(_x) ((_x) >> 8)
-
-#define RAWHID_USAGE_PAGE 0xFFC0
-#define RAWHID_USAGE 0x0C00
-#define RAWHID_TX_SIZE 64
-#define RAWHID_RX_SIZE 64
-
-extern const u8 _hidReportDescriptor[] PROGMEM;
-const u8 _hidReportDescriptor[] = {
-
- // Mouse
- 0x05, 0x01, // USAGE_PAGE (Generic Desktop) // 54
- 0x09, 0x02, // USAGE (Mouse)
- 0xa1, 0x01, // COLLECTION (Application)
- 0x09, 0x01, // USAGE (Pointer)
- 0xa1, 0x00, // COLLECTION (Physical)
- 0x85, 0x01, // REPORT_ID (1)
- 0x05, 0x09, // USAGE_PAGE (Button)
- 0x19, 0x01, // USAGE_MINIMUM (Button 1)
- 0x29, 0x03, // USAGE_MAXIMUM (Button 3)
- 0x15, 0x00, // LOGICAL_MINIMUM (0)
- 0x25, 0x01, // LOGICAL_MAXIMUM (1)
- 0x95, 0x03, // REPORT_COUNT (3)
- 0x75, 0x01, // REPORT_SIZE (1)
- 0x81, 0x02, // INPUT (Data,Var,Abs)
- 0x95, 0x01, // REPORT_COUNT (1)
- 0x75, 0x05, // REPORT_SIZE (5)
- 0x81, 0x03, // INPUT (Cnst,Var,Abs)
- 0x05, 0x01, // USAGE_PAGE (Generic Desktop)
- 0x09, 0x30, // USAGE (X)
- 0x09, 0x31, // USAGE (Y)
- 0x09, 0x38, // USAGE (Wheel)
- 0x15, 0x81, // LOGICAL_MINIMUM (-127)
- 0x25, 0x7f, // LOGICAL_MAXIMUM (127)
- 0x75, 0x08, // REPORT_SIZE (8)
- 0x95, 0x03, // REPORT_COUNT (3)
- 0x81, 0x06, // INPUT (Data,Var,Rel)
- 0xc0, // END_COLLECTION
- 0xc0, // END_COLLECTION
-
- // Keyboard
- 0x05, 0x01, // USAGE_PAGE (Generic Desktop) // 47
- 0x09, 0x06, // USAGE (Keyboard)
- 0xa1, 0x01, // COLLECTION (Application)
- 0x85, 0x02, // REPORT_ID (2)
- 0x05, 0x07, // USAGE_PAGE (Keyboard)
-
- 0x19, 0xe0, // USAGE_MINIMUM (Keyboard LeftControl)
- 0x29, 0xe7, // USAGE_MAXIMUM (Keyboard Right GUI)
- 0x15, 0x00, // LOGICAL_MINIMUM (0)
- 0x25, 0x01, // LOGICAL_MAXIMUM (1)
- 0x75, 0x01, // REPORT_SIZE (1)
-
- 0x95, 0x08, // REPORT_COUNT (8)
- 0x81, 0x02, // INPUT (Data,Var,Abs)
- 0x95, 0x01, // REPORT_COUNT (1)
- 0x75, 0x08, // REPORT_SIZE (8)
- 0x81, 0x03, // INPUT (Cnst,Var,Abs)
-
- 0x95, 0x06, // REPORT_COUNT (6)
- 0x75, 0x08, // REPORT_SIZE (8)
- 0x15, 0x00, // LOGICAL_MINIMUM (0)
- 0x25, 0x65, // LOGICAL_MAXIMUM (101)
- 0x05, 0x07, // USAGE_PAGE (Keyboard)
-
- 0x19, 0x00, // USAGE_MINIMUM (Reserved (no event indicated))
- 0x29, 0x65, // USAGE_MAXIMUM (Keyboard Application)
- 0x81, 0x00, // INPUT (Data,Ary,Abs)
- 0xc0, // END_COLLECTION
-
-#if RAWHID_ENABLED
- // RAW HID
- 0x06, LSB(RAWHID_USAGE_PAGE), MSB(RAWHID_USAGE_PAGE), // 30
- 0x0A, LSB(RAWHID_USAGE), MSB(RAWHID_USAGE),
-
- 0xA1, 0x01, // Collection 0x01
- 0x85, 0x03, // REPORT_ID (3)
- 0x75, 0x08, // report size = 8 bits
- 0x15, 0x00, // logical minimum = 0
- 0x26, 0xFF, 0x00, // logical maximum = 255
-
- 0x95, 64, // report count TX
- 0x09, 0x01, // usage
- 0x81, 0x02, // Input (array)
-
- 0x95, 64, // report count RX
- 0x09, 0x02, // usage
- 0x91, 0x02, // Output (array)
- 0xC0 // end collection
-#endif
-};
-
-extern const HIDDescriptor _hidInterface PROGMEM;
-const HIDDescriptor _hidInterface =
-{
- D_INTERFACE(HID_INTERFACE,1,3,0,0),
- D_HIDREPORT(sizeof(_hidReportDescriptor)),
- D_ENDPOINT(USB_ENDPOINT_IN (HID_ENDPOINT_INT),USB_ENDPOINT_TYPE_INTERRUPT,0x40,0x01)
-};
-
-//================================================================================
-//================================================================================
-// Driver
-
-u8 _hid_protocol = 1;
-u8 _hid_idle = 1;
-
-#define WEAK __attribute__ ((weak))
-
-int WEAK HID_GetInterface(u8* interfaceNum)
-{
- interfaceNum[0] += 1; // uses 1
- return USB_SendControl(TRANSFER_PGM,&_hidInterface,sizeof(_hidInterface));
-}
-
-int WEAK HID_GetDescriptor(int i)
-{
- return USB_SendControl(TRANSFER_PGM,_hidReportDescriptor,sizeof(_hidReportDescriptor));
-}
-
-void WEAK HID_SendReport(u8 id, const void* data, int len)
-{
- USB_Send(HID_TX, &id, 1);
- USB_Send(HID_TX | TRANSFER_RELEASE,data,len);
-}
-
-bool WEAK HID_Setup(Setup& setup)
-{
- u8 r = setup.bRequest;
- u8 requestType = setup.bmRequestType;
- if (REQUEST_DEVICETOHOST_CLASS_INTERFACE == requestType)
- {
- if (HID_GET_REPORT == r)
- {
- //HID_GetReport();
- return true;
- }
- if (HID_GET_PROTOCOL == r)
- {
- //Send8(_hid_protocol); // TODO
- return true;
- }
- }
-
- if (REQUEST_HOSTTODEVICE_CLASS_INTERFACE == requestType)
- {
- if (HID_SET_PROTOCOL == r)
- {
- _hid_protocol = setup.wValueL;
- return true;
- }
-
- if (HID_SET_IDLE == r)
- {
- _hid_idle = setup.wValueL;
- return true;
- }
- }
- return false;
-}
-
-//================================================================================
-//================================================================================
-// Mouse
-
-Mouse_::Mouse_(void) : _buttons(0)
-{
-}
-
-void Mouse_::begin(void)
-{
-}
-
-void Mouse_::end(void)
-{
-}
-
-void Mouse_::click(uint8_t b)
-{
- _buttons = b;
- move(0,0,0);
- _buttons = 0;
- move(0,0,0);
-}
-
-void Mouse_::move(signed char x, signed char y, signed char wheel)
-{
- u8 m[4];
- m[0] = _buttons;
- m[1] = x;
- m[2] = y;
- m[3] = wheel;
- HID_SendReport(1,m,4);
-}
-
-void Mouse_::buttons(uint8_t b)
-{
- if (b != _buttons)
- {
- _buttons = b;
- move(0,0,0);
- }
-}
-
-void Mouse_::press(uint8_t b)
-{
- buttons(_buttons | b);
-}
-
-void Mouse_::release(uint8_t b)
-{
- buttons(_buttons & ~b);
-}
-
-bool Mouse_::isPressed(uint8_t b)
-{
- if ((b & _buttons) > 0)
- return true;
- return false;
-}
-
-//================================================================================
-//================================================================================
-// Keyboard
-
-Keyboard_::Keyboard_(void)
-{
-}
-
-void Keyboard_::begin(void)
-{
-}
-
-void Keyboard_::end(void)
-{
-}
-
-void Keyboard_::sendReport(KeyReport* keys)
-{
- HID_SendReport(2,keys,sizeof(KeyReport));
-}
-
-extern
-const uint8_t _asciimap[128] PROGMEM;
-
-#define SHIFT 0x80
-const uint8_t _asciimap[128] =
-{
- 0x00, // NUL
- 0x00, // SOH
- 0x00, // STX
- 0x00, // ETX
- 0x00, // EOT
- 0x00, // ENQ
- 0x00, // ACK
- 0x00, // BEL
- 0x2a, // BS Backspace
- 0x2b, // TAB Tab
- 0x28, // LF Enter
- 0x00, // VT
- 0x00, // FF
- 0x00, // CR
- 0x00, // SO
- 0x00, // SI
- 0x00, // DEL
- 0x00, // DC1
- 0x00, // DC2
- 0x00, // DC3
- 0x00, // DC4
- 0x00, // NAK
- 0x00, // SYN
- 0x00, // ETB
- 0x00, // CAN
- 0x00, // EM
- 0x00, // SUB
- 0x00, // ESC
- 0x00, // FS
- 0x00, // GS
- 0x00, // RS
- 0x00, // US
-
- 0x2c, // ' '
- 0x1e|SHIFT, // !
- 0x34|SHIFT, // "
- 0x20|SHIFT, // #
- 0x21|SHIFT, // $
- 0x22|SHIFT, // %
- 0x24|SHIFT, // &
- 0x34, // '
- 0x26|SHIFT, // (
- 0x27|SHIFT, // )
- 0x25|SHIFT, // *
- 0x2e|SHIFT, // +
- 0x36, // ,
- 0x2d, // -
- 0x37, // .
- 0x38, // /
- 0x27, // 0
- 0x1e, // 1
- 0x1f, // 2
- 0x20, // 3
- 0x21, // 4
- 0x22, // 5
- 0x23, // 6
- 0x24, // 7
- 0x25, // 8
- 0x26, // 9
- 0x33|SHIFT, // :
- 0x33, // ;
- 0x36|SHIFT, // <
- 0x2e, // =
- 0x37|SHIFT, // >
- 0x38|SHIFT, // ?
- 0x1f|SHIFT, // @
- 0x04|SHIFT, // A
- 0x05|SHIFT, // B
- 0x06|SHIFT, // C
- 0x07|SHIFT, // D
- 0x08|SHIFT, // E
- 0x09|SHIFT, // F
- 0x0a|SHIFT, // G
- 0x0b|SHIFT, // H
- 0x0c|SHIFT, // I
- 0x0d|SHIFT, // J
- 0x0e|SHIFT, // K
- 0x0f|SHIFT, // L
- 0x10|SHIFT, // M
- 0x11|SHIFT, // N
- 0x12|SHIFT, // O
- 0x13|SHIFT, // P
- 0x14|SHIFT, // Q
- 0x15|SHIFT, // R
- 0x16|SHIFT, // S
- 0x17|SHIFT, // T
- 0x18|SHIFT, // U
- 0x19|SHIFT, // V
- 0x1a|SHIFT, // W
- 0x1b|SHIFT, // X
- 0x1c|SHIFT, // Y
- 0x1d|SHIFT, // Z
- 0x2f, // [
- 0x31, // bslash
- 0x30, // ]
- 0x23|SHIFT, // ^
- 0x2d|SHIFT, // _
- 0x35, // `
- 0x04, // a
- 0x05, // b
- 0x06, // c
- 0x07, // d
- 0x08, // e
- 0x09, // f
- 0x0a, // g
- 0x0b, // h
- 0x0c, // i
- 0x0d, // j
- 0x0e, // k
- 0x0f, // l
- 0x10, // m
- 0x11, // n
- 0x12, // o
- 0x13, // p
- 0x14, // q
- 0x15, // r
- 0x16, // s
- 0x17, // t
- 0x18, // u
- 0x19, // v
- 0x1a, // w
- 0x1b, // x
- 0x1c, // y
- 0x1d, // z
- 0x2f|SHIFT, //
- 0x31|SHIFT, // |
- 0x30|SHIFT, // }
- 0x35|SHIFT, // ~
- 0 // DEL
-};
-
-uint8_t USBPutChar(uint8_t c);
-
-// press() adds the specified key (printing, non-printing, or modifier)
-// to the persistent key report and sends the report. Because of the way
-// USB HID works, the host acts like the key remains pressed until we
-// call release(), releaseAll(), or otherwise clear the report and resend.
-size_t Keyboard_::press(uint8_t k)
-{
- uint8_t i;
- if (k >= 136) { // it's a non-printing key (not a modifier)
- k = k - 136;
- } else if (k >= 128) { // it's a modifier key
- _keyReport.modifiers |= (1<<(k-128));
- k = 0;
- } else { // it's a printing key
- k = pgm_read_byte(_asciimap + k);
- if (!k) {
- setWriteError();
- return 0;
- }
- if (k & 0x80) { // it's a capital letter or other character reached with shift
- _keyReport.modifiers |= 0x02; // the left shift modifier
- k &= 0x7F;
- }
- }
-
- // Add k to the key report only if it's not already present
- // and if there is an empty slot.
- if (_keyReport.keys[0] != k && _keyReport.keys[1] != k &&
- _keyReport.keys[2] != k && _keyReport.keys[3] != k &&
- _keyReport.keys[4] != k && _keyReport.keys[5] != k) {
-
- for (i=0; i<6; i++) {
- if (_keyReport.keys[i] == 0x00) {
- _keyReport.keys[i] = k;
- break;
- }
- }
- if (i == 6) {
- setWriteError();
- return 0;
- }
- }
- sendReport(&_keyReport);
- return 1;
-}
-
-// release() takes the specified key out of the persistent key report and
-// sends the report. This tells the OS the key is no longer pressed and that
-// it shouldn't be repeated any more.
-size_t Keyboard_::release(uint8_t k)
-{
- uint8_t i;
- if (k >= 136) { // it's a non-printing key (not a modifier)
- k = k - 136;
- } else if (k >= 128) { // it's a modifier key
- _keyReport.modifiers &= ~(1<<(k-128));
- k = 0;
- } else { // it's a printing key
- k = pgm_read_byte(_asciimap + k);
- if (!k) {
- return 0;
- }
- if (k & 0x80) { // it's a capital letter or other character reached with shift
- _keyReport.modifiers &= ~(0x02); // the left shift modifier
- k &= 0x7F;
- }
- }
-
- // Test the key report to see if k is present. Clear it if it exists.
- // Check all positions in case the key is present more than once (which it shouldn't be)
- for (i=0; i<6; i++) {
- if (0 != k && _keyReport.keys[i] == k) {
- _keyReport.keys[i] = 0x00;
- }
- }
-
- sendReport(&_keyReport);
- return 1;
-}
-
-void Keyboard_::releaseAll(void)
-{
- _keyReport.keys[0] = 0;
- _keyReport.keys[1] = 0;
- _keyReport.keys[2] = 0;
- _keyReport.keys[3] = 0;
- _keyReport.keys[4] = 0;
- _keyReport.keys[5] = 0;
- _keyReport.modifiers = 0;
- sendReport(&_keyReport);
-}
-
-size_t Keyboard_::write(uint8_t c)
-{
- uint8_t p = press(c); // Keydown
- uint8_t r = release(c); // Keyup
- return (p); // just return the result of press() since release() almost always returns 1
-}
-
-#endif
-
-#endif /* if defined(USBCON) */ \ No newline at end of file
diff --git a/cores/robot/HardwareSerial.cpp b/cores/robot/HardwareSerial.cpp
deleted file mode 100644
index eb2365f..0000000
--- a/cores/robot/HardwareSerial.cpp
+++ /dev/null
@@ -1,508 +0,0 @@
-/*
- HardwareSerial.cpp - Hardware serial library for Wiring
- Copyright (c) 2006 Nicholas Zambetti. 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
-
- Modified 23 November 2006 by David A. Mellis
- Modified 28 September 2010 by Mark Sproul
- Modified 14 August 2012 by Alarus
-*/
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <inttypes.h>
-#include "Arduino.h"
-#include "wiring_private.h"
-
-// this next line disables the entire HardwareSerial.cpp,
-// this is so I can support Attiny series and any other chip without a uart
-#if defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H)
-
-#include "HardwareSerial.h"
-
-/*
- * on ATmega8, the uart and its bits are not numbered, so there is no "TXC0"
- * definition.
- */
-#if !defined(TXC0)
-#if defined(TXC)
-#define TXC0 TXC
-#elif defined(TXC1)
-// Some devices have uart1 but no uart0
-#define TXC0 TXC1
-#else
-#error TXC0 not definable in HardwareSerial.h
-#endif
-#endif
-
-// Define constants and variables for buffering incoming serial data. We're
-// using a ring buffer (I think), in which head is the index of the location
-// to which to write the next incoming character and tail is the index of the
-// location from which to read.
-#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 unsigned int head;
- volatile unsigned int tail;
-};
-
-#if defined(USBCON)
- ring_buffer rx_buffer = { { 0 }, 0, 0};
- ring_buffer tx_buffer = { { 0 }, 0, 0};
-#endif
-#if defined(UBRRH) || defined(UBRR0H)
- ring_buffer rx_buffer = { { 0 }, 0, 0 };
- ring_buffer tx_buffer = { { 0 }, 0, 0 };
-#endif
-#if defined(UBRR1H)
- ring_buffer rx_buffer1 = { { 0 }, 0, 0 };
- ring_buffer tx_buffer1 = { { 0 }, 0, 0 };
-#endif
-#if defined(UBRR2H)
- ring_buffer rx_buffer2 = { { 0 }, 0, 0 };
- ring_buffer tx_buffer2 = { { 0 }, 0, 0 };
-#endif
-#if defined(UBRR3H)
- ring_buffer rx_buffer3 = { { 0 }, 0, 0 };
- ring_buffer tx_buffer3 = { { 0 }, 0, 0 };
-#endif
-
-inline void store_char(unsigned char c, ring_buffer *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.
- if (i != buffer->tail) {
- buffer->buffer[buffer->head] = c;
- buffer->head = i;
- }
-}
-
-#if !defined(USART0_RX_vect) && defined(USART1_RX_vect)
-// do nothing - on the 32u4 the first USART is USART1
-#else
-#if !defined(USART_RX_vect) && !defined(USART0_RX_vect) && \
- !defined(USART_RXC_vect)
- #error "Don't know what the Data Received vector is called for the first UART"
-#else
- void serialEvent() __attribute__((weak));
- void serialEvent() {}
- #define serialEvent_implemented
-#if defined(USART_RX_vect)
- ISR(USART_RX_vect)
-#elif defined(USART0_RX_vect)
- ISR(USART0_RX_vect)
-#elif defined(USART_RXC_vect)
- ISR(USART_RXC_vect) // ATmega8
-#endif
- {
- #if defined(UDR0)
- if (bit_is_clear(UCSR0A, UPE0)) {
- unsigned char c = UDR0;
- store_char(c, &rx_buffer);
- } else {
- unsigned char c = UDR0;
- };
- #elif defined(UDR)
- if (bit_is_clear(UCSRA, PE)) {
- unsigned char c = UDR;
- store_char(c, &rx_buffer);
- } else {
- unsigned char c = UDR;
- };
- #else
- #error UDR not defined
- #endif
- }
-#endif
-#endif
-
-#if defined(USART1_RX_vect)
- void serialEvent1() __attribute__((weak));
- void serialEvent1() {}
- #define serialEvent1_implemented
- ISR(USART1_RX_vect)
- {
- if (bit_is_clear(UCSR1A, UPE1)) {
- unsigned char c = UDR1;
- store_char(c, &rx_buffer1);
- } else {
- unsigned char c = UDR1;
- };
- }
-#endif
-
-#if defined(USART2_RX_vect) && defined(UDR2)
- void serialEvent2() __attribute__((weak));
- void serialEvent2() {}
- #define serialEvent2_implemented
- ISR(USART2_RX_vect)
- {
- if (bit_is_clear(UCSR2A, UPE2)) {
- unsigned char c = UDR2;
- store_char(c, &rx_buffer2);
- } else {
- unsigned char c = UDR2;
- };
- }
-#endif
-
-#if defined(USART3_RX_vect) && defined(UDR3)
- void serialEvent3() __attribute__((weak));
- void serialEvent3() {}
- #define serialEvent3_implemented
- ISR(USART3_RX_vect)
- {
- if (bit_is_clear(UCSR3A, UPE3)) {
- unsigned char c = UDR3;
- store_char(c, &rx_buffer3);
- } else {
- unsigned char c = UDR3;
- };
- }
-#endif
-
-void serialEventRun(void)
-{
-#ifdef serialEvent_implemented
- if (Serial.available()) serialEvent();
-#endif
-#ifdef serialEvent1_implemented
- if (Serial1.available()) serialEvent1();
-#endif
-#ifdef serialEvent2_implemented
- if (Serial2.available()) serialEvent2();
-#endif
-#ifdef serialEvent3_implemented
- if (Serial3.available()) serialEvent3();
-#endif
-}
-
-
-#if !defined(USART0_UDRE_vect) && defined(USART1_UDRE_vect)
-// do nothing - on the 32u4 the first USART is USART1
-#else
-#if !defined(UART0_UDRE_vect) && !defined(UART_UDRE_vect) && !defined(USART0_UDRE_vect) && !defined(USART_UDRE_vect)
- #error "Don't know what the Data Register Empty vector is called for the first UART"
-#else
-#if defined(UART0_UDRE_vect)
-ISR(UART0_UDRE_vect)
-#elif defined(UART_UDRE_vect)
-ISR(UART_UDRE_vect)
-#elif defined(USART0_UDRE_vect)
-ISR(USART0_UDRE_vect)
-#elif defined(USART_UDRE_vect)
-ISR(USART_UDRE_vect)
-#endif
-{
- if (tx_buffer.head == tx_buffer.tail) {
- // Buffer empty, so disable interrupts
-#if defined(UCSR0B)
- cbi(UCSR0B, UDRIE0);
-#else
- cbi(UCSRB, UDRIE);
-#endif
- }
- else {
- // There is more data in the output buffer. Send the next byte
- unsigned char c = tx_buffer.buffer[tx_buffer.tail];
- tx_buffer.tail = (tx_buffer.tail + 1) % SERIAL_BUFFER_SIZE;
-
- #if defined(UDR0)
- UDR0 = c;
- #elif defined(UDR)
- UDR = c;
- #else
- #error UDR not defined
- #endif
- }
-}
-#endif
-#endif
-
-#ifdef USART1_UDRE_vect
-ISR(USART1_UDRE_vect)
-{
- if (tx_buffer1.head == tx_buffer1.tail) {
- // Buffer empty, so disable interrupts
- cbi(UCSR1B, UDRIE1);
- }
- else {
- // There is more data in the output buffer. Send the next byte
- unsigned char c = tx_buffer1.buffer[tx_buffer1.tail];
- tx_buffer1.tail = (tx_buffer1.tail + 1) % SERIAL_BUFFER_SIZE;
-
- UDR1 = c;
- }
-}
-#endif
-
-#ifdef USART2_UDRE_vect
-ISR(USART2_UDRE_vect)
-{
- if (tx_buffer2.head == tx_buffer2.tail) {
- // Buffer empty, so disable interrupts
- cbi(UCSR2B, UDRIE2);
- }
- else {
- // There is more data in the output buffer. Send the next byte
- unsigned char c = tx_buffer2.buffer[tx_buffer2.tail];
- tx_buffer2.tail = (tx_buffer2.tail + 1) % SERIAL_BUFFER_SIZE;
-
- UDR2 = c;
- }
-}
-#endif
-
-#ifdef USART3_UDRE_vect
-ISR(USART3_UDRE_vect)
-{
- if (tx_buffer3.head == tx_buffer3.tail) {
- // Buffer empty, so disable interrupts
- cbi(UCSR3B, UDRIE3);
- }
- else {
- // There is more data in the output buffer. Send the next byte
- unsigned char c = tx_buffer3.buffer[tx_buffer3.tail];
- tx_buffer3.tail = (tx_buffer3.tail + 1) % SERIAL_BUFFER_SIZE;
-
- UDR3 = c;
- }
-}
-#endif
-
-
-// Constructors ////////////////////////////////////////////////////////////////
-
-HardwareSerial::HardwareSerial(ring_buffer *rx_buffer, ring_buffer *tx_buffer,
- volatile uint8_t *ubrrh, volatile uint8_t *ubrrl,
- volatile uint8_t *ucsra, volatile uint8_t *ucsrb,
- volatile uint8_t *ucsrc, volatile uint8_t *udr,
- uint8_t rxen, uint8_t txen, uint8_t rxcie, uint8_t udrie, uint8_t u2x)
-{
- _rx_buffer = rx_buffer;
- _tx_buffer = tx_buffer;
- _ubrrh = ubrrh;
- _ubrrl = ubrrl;
- _ucsra = ucsra;
- _ucsrb = ucsrb;
- _ucsrc = ucsrc;
- _udr = udr;
- _rxen = rxen;
- _txen = txen;
- _rxcie = rxcie;
- _udrie = udrie;
- _u2x = u2x;
-}
-
-// Public Methods //////////////////////////////////////////////////////////////
-
-void HardwareSerial::begin(unsigned long baud)
-{
- uint16_t baud_setting;
- bool use_u2x = true;
-
-#if F_CPU == 16000000UL
- // hardcoded exception for compatibility with the bootloader shipped
- // with the Duemilanove and previous boards and the firmware on the 8U2
- // on the Uno and Mega 2560.
- if (baud == 57600) {
- use_u2x = false;
- }
-#endif
-
-try_again:
-
- if (use_u2x) {
- *_ucsra = 1 << _u2x;
- baud_setting = (F_CPU / 4 / baud - 1) / 2;
- } else {
- *_ucsra = 0;
- baud_setting = (F_CPU / 8 / baud - 1) / 2;
- }
-
- if ((baud_setting > 4095) && use_u2x)
- {
- use_u2x = false;
- goto try_again;
- }
-
- // assign the baud_setting, a.k.a. ubbr (USART Baud Rate Register)
- *_ubrrh = baud_setting >> 8;
- *_ubrrl = baud_setting;
-
- transmitting = false;
-
- sbi(*_ucsrb, _rxen);
- sbi(*_ucsrb, _txen);
- sbi(*_ucsrb, _rxcie);
- cbi(*_ucsrb, _udrie);
-}
-
-void HardwareSerial::begin(unsigned long baud, byte config)
-{
- uint16_t baud_setting;
- uint8_t current_config;
- bool use_u2x = true;
-
-#if F_CPU == 16000000UL
- // hardcoded exception for compatibility with the bootloader shipped
- // with the Duemilanove and previous boards and the firmware on the 8U2
- // on the Uno and Mega 2560.
- if (baud == 57600) {
- use_u2x = false;
- }
-#endif
-
-try_again:
-
- if (use_u2x) {
- *_ucsra = 1 << _u2x;
- baud_setting = (F_CPU / 4 / baud - 1) / 2;
- } else {
- *_ucsra = 0;
- baud_setting = (F_CPU / 8 / baud - 1) / 2;
- }
-
- if ((baud_setting > 4095) && use_u2x)
- {
- use_u2x = false;
- goto try_again;
- }
-
- // assign the baud_setting, a.k.a. ubbr (USART Baud Rate Register)
- *_ubrrh = baud_setting >> 8;
- *_ubrrl = baud_setting;
-
- //set the data bits, parity, and stop bits
-#if defined(__AVR_ATmega8__)
- config |= 0x80; // select UCSRC register (shared with UBRRH)
-#endif
- *_ucsrc = config;
-
- sbi(*_ucsrb, _rxen);
- sbi(*_ucsrb, _txen);
- sbi(*_ucsrb, _rxcie);
- cbi(*_ucsrb, _udrie);
-}
-
-void HardwareSerial::end()
-{
- // wait for transmission of outgoing data
- while (_tx_buffer->head != _tx_buffer->tail)
- ;
-
- cbi(*_ucsrb, _rxen);
- cbi(*_ucsrb, _txen);
- cbi(*_ucsrb, _rxcie);
- cbi(*_ucsrb, _udrie);
-
- // clear any received data
- _rx_buffer->head = _rx_buffer->tail;
-}
-
-int HardwareSerial::available(void)
-{
- return (unsigned int)(SERIAL_BUFFER_SIZE + _rx_buffer->head - _rx_buffer->tail) % SERIAL_BUFFER_SIZE;
-}
-
-int HardwareSerial::peek(void)
-{
- if (_rx_buffer->head == _rx_buffer->tail) {
- return -1;
- } else {
- return _rx_buffer->buffer[_rx_buffer->tail];
- }
-}
-
-int HardwareSerial::read(void)
-{
- // if the head isn't ahead of the tail, we don't have any characters
- if (_rx_buffer->head == _rx_buffer->tail) {
- return -1;
- } else {
- unsigned char c = _rx_buffer->buffer[_rx_buffer->tail];
- _rx_buffer->tail = (unsigned int)(_rx_buffer->tail + 1) % SERIAL_BUFFER_SIZE;
- return c;
- }
-}
-
-void HardwareSerial::flush()
-{
- // UDR is kept full while the buffer is not empty, so TXC triggers when EMPTY && SENT
- while (transmitting && ! (*_ucsra & _BV(TXC0)));
- transmitting = false;
-}
-
-size_t HardwareSerial::write(uint8_t c)
-{
- int i = (_tx_buffer->head + 1) % SERIAL_BUFFER_SIZE;
-
- // If the output buffer is full, there's nothing for it other than to
- // wait for the interrupt handler to empty it a bit
- // ???: return 0 here instead?
- while (i == _tx_buffer->tail)
- ;
-
- _tx_buffer->buffer[_tx_buffer->head] = c;
- _tx_buffer->head = i;
-
- sbi(*_ucsrb, _udrie);
- // clear the TXC bit -- "can be cleared by writing a one to its bit location"
- transmitting = true;
- sbi(*_ucsra, TXC0);
-
- return 1;
-}
-
-HardwareSerial::operator bool() {
- return true;
-}
-
-// Preinstantiate Objects //////////////////////////////////////////////////////
-
-#if defined(UBRRH) && defined(UBRRL)
- HardwareSerial Serial(&rx_buffer, &tx_buffer, &UBRRH, &UBRRL, &UCSRA, &UCSRB, &UCSRC, &UDR, RXEN, TXEN, RXCIE, UDRIE, U2X);
-#elif defined(UBRR0H) && defined(UBRR0L)
- HardwareSerial Serial(&rx_buffer, &tx_buffer, &UBRR0H, &UBRR0L, &UCSR0A, &UCSR0B, &UCSR0C, &UDR0, RXEN0, TXEN0, RXCIE0, UDRIE0, U2X0);
-#elif defined(USBCON)
- // do nothing - Serial object and buffers are initialized in CDC code
-#else
- #error no serial port defined (port 0)
-#endif
-
-#if defined(UBRR1H)
- HardwareSerial Serial1(&rx_buffer1, &tx_buffer1, &UBRR1H, &UBRR1L, &UCSR1A, &UCSR1B, &UCSR1C, &UDR1, RXEN1, TXEN1, RXCIE1, UDRIE1, U2X1);
-#endif
-#if defined(UBRR2H)
- HardwareSerial Serial2(&rx_buffer2, &tx_buffer2, &UBRR2H, &UBRR2L, &UCSR2A, &UCSR2B, &UCSR2C, &UDR2, RXEN2, TXEN2, RXCIE2, UDRIE2, U2X2);
-#endif
-#if defined(UBRR3H)
- HardwareSerial Serial3(&rx_buffer3, &tx_buffer3, &UBRR3H, &UBRR3L, &UCSR3A, &UCSR3B, &UCSR3C, &UDR3, RXEN3, TXEN3, RXCIE3, UDRIE3, U2X3);
-#endif
-
-#endif // whole file
-
diff --git a/cores/robot/HardwareSerial.h b/cores/robot/HardwareSerial.h
deleted file mode 100644
index a73117f..0000000
--- a/cores/robot/HardwareSerial.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- HardwareSerial.h - Hardware serial library for Wiring
- Copyright (c) 2006 Nicholas Zambetti. 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
-
- Modified 28 September 2010 by Mark Sproul
- Modified 14 August 2012 by Alarus
-*/
-
-#ifndef HardwareSerial_h
-#define HardwareSerial_h
-
-#include <inttypes.h>
-
-#include "Stream.h"
-
-struct ring_buffer;
-
-class HardwareSerial : public Stream
-{
- private:
- ring_buffer *_rx_buffer;
- ring_buffer *_tx_buffer;
- volatile uint8_t *_ubrrh;
- volatile uint8_t *_ubrrl;
- volatile uint8_t *_ucsra;
- volatile uint8_t *_ucsrb;
- volatile uint8_t *_ucsrc;
- volatile uint8_t *_udr;
- uint8_t _rxen;
- uint8_t _txen;
- uint8_t _rxcie;
- uint8_t _udrie;
- uint8_t _u2x;
- bool transmitting;
- public:
- HardwareSerial(ring_buffer *rx_buffer, ring_buffer *tx_buffer,
- volatile uint8_t *ubrrh, volatile uint8_t *ubrrl,
- volatile uint8_t *ucsra, volatile uint8_t *ucsrb,
- volatile uint8_t *ucsrc, volatile uint8_t *udr,
- uint8_t rxen, uint8_t txen, uint8_t rxcie, uint8_t udrie, uint8_t u2x);
- void begin(unsigned long);
- void begin(unsigned long, uint8_t);
- void end();
- virtual int available(void);
- virtual int peek(void);
- virtual int read(void);
- virtual void flush(void);
- virtual size_t write(uint8_t);
- inline size_t write(unsigned long n) { return write((uint8_t)n); }
- inline size_t write(long n) { return write((uint8_t)n); }
- inline size_t write(unsigned int n) { return write((uint8_t)n); }
- inline size_t write(int n) { return write((uint8_t)n); }
- using Print::write; // pull in write(str) and write(buf, size) from Print
- operator bool();
-};
-
-// Define config for Serial.begin(baud, config);
-#define SERIAL_5N1 0x00
-#define SERIAL_6N1 0x02
-#define SERIAL_7N1 0x04
-#define SERIAL_8N1 0x06
-#define SERIAL_5N2 0x08
-#define SERIAL_6N2 0x0A
-#define SERIAL_7N2 0x0C
-#define SERIAL_8N2 0x0E
-#define SERIAL_5E1 0x20
-#define SERIAL_6E1 0x22
-#define SERIAL_7E1 0x24
-#define SERIAL_8E1 0x26
-#define SERIAL_5E2 0x28
-#define SERIAL_6E2 0x2A
-#define SERIAL_7E2 0x2C
-#define SERIAL_8E2 0x2E
-#define SERIAL_5O1 0x30
-#define SERIAL_6O1 0x32
-#define SERIAL_7O1 0x34
-#define SERIAL_8O1 0x36
-#define SERIAL_5O2 0x38
-#define SERIAL_6O2 0x3A
-#define SERIAL_7O2 0x3C
-#define SERIAL_8O2 0x3E
-
-#if defined(UBRRH) || defined(UBRR0H)
- extern HardwareSerial Serial;
-#elif defined(USBCON)
- #include "USBAPI.h"
-// extern HardwareSerial Serial_;
-#endif
-#if defined(UBRR1H)
- extern HardwareSerial Serial1;
-#endif
-#if defined(UBRR2H)
- extern HardwareSerial Serial2;
-#endif
-#if defined(UBRR3H)
- extern HardwareSerial Serial3;
-#endif
-
-extern void serialEventRun(void) __attribute__((weak));
-
-#endif
diff --git a/cores/robot/IPAddress.cpp b/cores/robot/IPAddress.cpp
deleted file mode 100644
index fe3deb7..0000000
--- a/cores/robot/IPAddress.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-
-#include <Arduino.h>
-#include <IPAddress.h>
-
-IPAddress::IPAddress()
-{
- memset(_address, 0, sizeof(_address));
-}
-
-IPAddress::IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet)
-{
- _address[0] = first_octet;
- _address[1] = second_octet;
- _address[2] = third_octet;
- _address[3] = fourth_octet;
-}
-
-IPAddress::IPAddress(uint32_t address)
-{
- memcpy(_address, &address, sizeof(_address));
-}
-
-IPAddress::IPAddress(const uint8_t *address)
-{
- memcpy(_address, address, sizeof(_address));
-}
-
-IPAddress& IPAddress::operator=(const uint8_t *address)
-{
- memcpy(_address, address, sizeof(_address));
- return *this;
-}
-
-IPAddress& IPAddress::operator=(uint32_t address)
-{
- memcpy(_address, (const uint8_t *)&address, sizeof(_address));
- return *this;
-}
-
-bool IPAddress::operator==(const uint8_t* addr)
-{
- return memcmp(addr, _address, sizeof(_address)) == 0;
-}
-
-size_t IPAddress::printTo(Print& p) const
-{
- size_t n = 0;
- for (int i =0; i < 3; i++)
- {
- n += p.print(_address[i], DEC);
- n += p.print('.');
- }
- n += p.print(_address[3], DEC);
- return n;
-}
-
diff --git a/cores/robot/IPAddress.h b/cores/robot/IPAddress.h
deleted file mode 100644
index 2585aec..0000000
--- a/cores/robot/IPAddress.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- *
- * 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
- */
-
-#ifndef IPAddress_h
-#define IPAddress_h
-
-#include <Printable.h>
-
-// A class to make it easier to handle and pass around IP addresses
-
-class IPAddress : public Printable {
-private:
- uint8_t _address[4]; // IPv4 address
- // Access the raw byte array containing the address. Because this returns a pointer
- // to the internal structure rather than a copy of the address this function should only
- // be used when you know that the usage of the returned uint8_t* will be transient and not
- // stored.
- uint8_t* raw_address() { return _address; };
-
-public:
- // Constructors
- IPAddress();
- IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet);
- IPAddress(uint32_t address);
- IPAddress(const uint8_t *address);
-
- // Overloaded cast operator to allow IPAddress objects to be used where a pointer
- // to a four-byte uint8_t array is expected
- operator uint32_t() { return *((uint32_t*)_address); };
- bool operator==(const IPAddress& addr) { return (*((uint32_t*)_address)) == (*((uint32_t*)addr._address)); };
- bool operator==(const uint8_t* addr);
-
- // Overloaded index operator to allow getting and setting individual octets of the address
- uint8_t operator[](int index) const { return _address[index]; };
- uint8_t& operator[](int index) { return _address[index]; };
-
- // Overloaded copy operators to allow initialisation of IPAddress objects from other types
- IPAddress& operator=(const uint8_t *address);
- IPAddress& operator=(uint32_t address);
-
- virtual size_t printTo(Print& p) const;
-
- friend class EthernetClass;
- friend class UDP;
- friend class Client;
- friend class Server;
- friend class DhcpClass;
- friend class DNSClient;
-};
-
-const IPAddress INADDR_NONE(0,0,0,0);
-
-
-#endif
diff --git a/cores/robot/Platform.h b/cores/robot/Platform.h
deleted file mode 100644
index 8b8f742..0000000
--- a/cores/robot/Platform.h
+++ /dev/null
@@ -1,23 +0,0 @@
-
-#ifndef __PLATFORM_H__
-#define __PLATFORM_H__
-
-#include <inttypes.h>
-#include <avr/pgmspace.h>
-#include <avr/eeprom.h>
-#include <avr/interrupt.h>
-#include <util/delay.h>
-
-typedef unsigned char u8;
-typedef unsigned short u16;
-typedef unsigned long u32;
-
-#include "Arduino.h"
-
-#if defined(USBCON)
- #include "USBDesc.h"
- #include "USBCore.h"
- #include "USBAPI.h"
-#endif /* if defined(USBCON) */
-
-#endif
diff --git a/cores/robot/Print.cpp b/cores/robot/Print.cpp
deleted file mode 100755
index 53961ec..0000000
--- a/cores/robot/Print.cpp
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- Print.cpp - Base class that provides print() and println()
- Copyright (c) 2008 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
-
- Modified 23 November 2006 by David A. Mellis
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <math.h>
-#include "Arduino.h"
-
-#include "Print.h"
-
-// Public Methods //////////////////////////////////////////////////////////////
-
-/* default implementation: may be overridden */
-size_t Print::write(const uint8_t *buffer, size_t size)
-{
- size_t n = 0;
- while (size--) {
- n += write(*buffer++);
- }
- return n;
-}
-
-size_t Print::print(const __FlashStringHelper *ifsh)
-{
- const char PROGMEM *p = (const char PROGMEM *)ifsh;
- size_t n = 0;
- while (1) {
- unsigned char c = pgm_read_byte(p++);
- if (c == 0) break;
- n += write(c);
- }
- return n;
-}
-
-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;
-}
-
-size_t Print::print(const char str[])
-{
- return write(str);
-}
-
-size_t Print::print(char c)
-{
- return write(c);
-}
-
-size_t Print::print(unsigned char b, int base)
-{
- return print((unsigned long) b, base);
-}
-
-size_t Print::print(int n, int base)
-{
- return print((long) n, base);
-}
-
-size_t Print::print(unsigned int n, int base)
-{
- return print((unsigned long) n, base);
-}
-
-size_t Print::print(long n, int base)
-{
- if (base == 0) {
- return write(n);
- } else if (base == 10) {
- if (n < 0) {
- int t = print('-');
- n = -n;
- return printNumber(n, 10) + t;
- }
- return printNumber(n, 10);
- } else {
- return printNumber(n, base);
- }
-}
-
-size_t Print::print(unsigned long n, int base)
-{
- if (base == 0) return write(n);
- else return printNumber(n, base);
-}
-
-size_t Print::print(double n, int digits)
-{
- return printFloat(n, digits);
-}
-
-size_t Print::println(const __FlashStringHelper *ifsh)
-{
- size_t n = print(ifsh);
- n += println();
- return n;
-}
-
-size_t Print::print(const Printable& x)
-{
- return x.printTo(*this);
-}
-
-size_t Print::println(void)
-{
- size_t n = print('\r');
- n += print('\n');
- return n;
-}
-
-size_t Print::println(const String &s)
-{
- size_t n = print(s);
- n += println();
- return n;
-}
-
-size_t Print::println(const char c[])
-{
- size_t n = print(c);
- n += println();
- return n;
-}
-
-size_t Print::println(char c)
-{
- size_t n = print(c);
- n += println();
- return n;
-}
-
-size_t Print::println(unsigned char b, int base)
-{
- size_t n = print(b, base);
- n += println();
- return n;
-}
-
-size_t Print::println(int num, int base)
-{
- size_t n = print(num, base);
- n += println();
- return n;
-}
-
-size_t Print::println(unsigned int num, int base)
-{
- size_t n = print(num, base);
- n += println();
- return n;
-}
-
-size_t Print::println(long num, int base)
-{
- size_t n = print(num, base);
- n += println();
- return n;
-}
-
-size_t Print::println(unsigned long num, int base)
-{
- size_t n = print(num, base);
- n += println();
- return n;
-}
-
-size_t Print::println(double num, int digits)
-{
- size_t n = print(num, digits);
- n += println();
- return n;
-}
-
-size_t Print::println(const Printable& x)
-{
- size_t n = print(x);
- n += println();
- return n;
-}
-
-// Private Methods /////////////////////////////////////////////////////////////
-
-size_t Print::printNumber(unsigned long n, uint8_t base) {
- char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte.
- char *str = &buf[sizeof(buf) - 1];
-
- *str = '\0';
-
- // prevent crash if called with base == 1
- if (base < 2) base = 10;
-
- do {
- unsigned long m = n;
- n /= base;
- char c = m - base * n;
- *--str = c < 10 ? c + '0' : c + 'A' - 10;
- } while(n);
-
- return write(str);
-}
-
-size_t Print::printFloat(double number, uint8_t digits)
-{
- size_t n = 0;
-
- if (isnan(number)) return print("nan");
- if (isinf(number)) return print("inf");
- if (number > 4294967040.0) return print ("ovf"); // constant determined empirically
- if (number <-4294967040.0) return print ("ovf"); // constant determined empirically
-
- // Handle negative numbers
- if (number < 0.0)
- {
- n += print('-');
- number = -number;
- }
-
- // Round correctly so that print(1.999, 2) prints as "2.00"
- double rounding = 0.5;
- for (uint8_t i=0; i<digits; ++i)
- rounding /= 10.0;
-
- number += rounding;
-
- // Extract the integer part of the number and print it
- unsigned long int_part = (unsigned long)number;
- double remainder = number - (double)int_part;
- n += print(int_part);
-
- // Print the decimal point, but only if there are digits beyond
- if (digits > 0) {
- n += print(".");
- }
-
- // Extract digits from the remainder one at a time
- while (digits-- > 0)
- {
- remainder *= 10.0;
- int toPrint = int(remainder);
- n += print(toPrint);
- remainder -= toPrint;
- }
-
- return n;
-}
diff --git a/cores/robot/Print.h b/cores/robot/Print.h
deleted file mode 100755
index dc76150..0000000
--- a/cores/robot/Print.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- Print.h - Base class that provides print() and println()
- Copyright (c) 2008 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 Print_h
-#define Print_h
-
-#include <inttypes.h>
-#include <stdio.h> // for size_t
-
-#include "WString.h"
-#include "Printable.h"
-
-#define DEC 10
-#define HEX 16
-#define OCT 8
-#define BIN 2
-
-class Print
-{
- private:
- int write_error;
- size_t printNumber(unsigned long, uint8_t);
- size_t printFloat(double, uint8_t);
- protected:
- void setWriteError(int err = 1) { write_error = err; }
- public:
- Print() : write_error(0) {}
-
- int getWriteError() { return write_error; }
- void clearWriteError() { setWriteError(0); }
-
- virtual size_t write(uint8_t) = 0;
- size_t write(const char *str) {
- if (str == NULL) return 0;
- return write((const uint8_t *)str, strlen(str));
- }
- virtual size_t write(const uint8_t *buffer, size_t size);
-
- size_t print(const __FlashStringHelper *);
- size_t print(const String &);
- size_t print(const char[]);
- size_t print(char);
- size_t print(unsigned char, int = DEC);
- size_t print(int, int = DEC);
- size_t print(unsigned int, int = DEC);
- size_t print(long, int = DEC);
- size_t print(unsigned long, int = DEC);
- size_t print(double, int = 2);
- size_t print(const Printable&);
-
- size_t println(const __FlashStringHelper *);
- size_t println(const String &s);
- size_t println(const char[]);
- size_t println(char);
- size_t println(unsigned char, int = DEC);
- size_t println(int, int = DEC);
- size_t println(unsigned int, int = DEC);
- size_t println(long, int = DEC);
- size_t println(unsigned long, int = DEC);
- size_t println(double, int = 2);
- size_t println(const Printable&);
- size_t println(void);
-};
-
-#endif
diff --git a/cores/robot/Server.h b/cores/robot/Server.h
deleted file mode 100644
index 9674c76..0000000
--- a/cores/robot/Server.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef server_h
-#define server_h
-
-class Server : public Print {
-public:
- virtual void begin() =0;
-};
-
-#endif
diff --git a/cores/robot/Stream.cpp b/cores/robot/Stream.cpp
deleted file mode 100644
index aafb7fc..0000000
--- a/cores/robot/Stream.cpp
+++ /dev/null
@@ -1,270 +0,0 @@
-/*
- Stream.cpp - adds parsing methods to Stream class
- Copyright (c) 2008 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
-
- Created July 2011
- parsing functions based on TextFinder library by Michael Margolis
- */
-
-#include "Arduino.h"
-#include "Stream.h"
-
-#define PARSE_TIMEOUT 1000 // default number of milli-seconds to wait
-#define NO_SKIP_CHAR 1 // a magic char not found in a valid ASCII numeric field
-
-// private method to read stream with timeout
-int Stream::timedRead()
-{
- int c;
- _startMillis = millis();
- do {
- c = read();
- if (c >= 0) return c;
- } while(millis() - _startMillis < _timeout);
- return -1; // -1 indicates timeout
-}
-
-// private method to peek stream with timeout
-int Stream::timedPeek()
-{
- int c;
- _startMillis = millis();
- do {
- c = peek();
- if (c >= 0) return c;
- } while(millis() - _startMillis < _timeout);
- return -1; // -1 indicates timeout
-}
-
-// returns peek of the next digit in the stream or -1 if timeout
-// discards non-numeric characters
-int Stream::peekNextDigit()
-{
- int c;
- while (1) {
- c = timedPeek();
- if (c < 0) return c; // timeout
- if (c == '-') return c;
- if (c >= '0' && c <= '9') return c;
- read(); // discard non-numeric
- }
-}
-
-// Public Methods
-//////////////////////////////////////////////////////////////
-
-void Stream::setTimeout(unsigned long timeout) // sets the maximum number of milliseconds to wait
-{
- _timeout = timeout;
-}
-
- // find returns true if the target string is found
-bool Stream::find(char *target)
-{
- return findUntil(target, NULL);
-}
-
-// reads data from the stream until the target string of given length is found
-// returns true if target string is found, false if timed out
-bool Stream::find(char *target, size_t length)
-{
- return findUntil(target, length, NULL, 0);
-}
-
-// as find but search ends if the terminator string is found
-bool Stream::findUntil(char *target, char *terminator)
-{
- return findUntil(target, strlen(target), terminator, strlen(terminator));
-}
-
-// reads data from the stream until the target string of the given length is found
-// search terminated if the terminator string is found
-// returns true if target string is found, false if terminated or timed out
-bool Stream::findUntil(char *target, size_t targetLen, char *terminator, size_t termLen)
-{
- size_t index = 0; // maximum target string length is 64k bytes!
- size_t termIndex = 0;
- int c;
-
- if( *target == 0)
- return true; // return true if target is a null string
- while( (c = timedRead()) > 0){
-
- if(c != target[index])
- index = 0; // reset index if any char does not match
-
- if( c == target[index]){
- //////Serial.print("found "); Serial.write(c); Serial.print("index now"); Serial.println(index+1);
- if(++index >= targetLen){ // return true if all chars in the target match
- return true;
- }
- }
-
- if(termLen > 0 && c == terminator[termIndex]){
- if(++termIndex >= termLen)
- return false; // return false if terminate string found before target string
- }
- else
- termIndex = 0;
- }
- return false;
-}
-
-
-// returns the first valid (long) integer value from the current position.
-// initial characters that are not digits (or the minus sign) are skipped
-// function is terminated by the first character that is not a digit.
-long Stream::parseInt()
-{
- return parseInt(NO_SKIP_CHAR); // terminate on first non-digit character (or timeout)
-}
-
-// as above but a given skipChar is ignored
-// this allows format characters (typically commas) in values to be ignored
-long Stream::parseInt(char skipChar)
-{
- boolean isNegative = false;
- long value = 0;
- int c;
-
- c = peekNextDigit();
- // ignore non numeric leading characters
- if(c < 0)
- return 0; // zero returned if timeout
-
- do{
- if(c == skipChar)
- ; // ignore this charactor
- else if(c == '-')
- isNegative = true;
- else if(c >= '0' && c <= '9') // is c a digit?
- value = value * 10 + c - '0';
- read(); // consume the character we got with peek
- c = timedPeek();
- }
- while( (c >= '0' && c <= '9') || c == skipChar );
-
- if(isNegative)
- value = -value;
- return value;
-}
-
-
-// as parseInt but returns a floating point value
-float Stream::parseFloat()
-{
- return parseFloat(NO_SKIP_CHAR);
-}
-
-// as above but the given skipChar is ignored
-// this allows format characters (typically commas) in values to be ignored
-float Stream::parseFloat(char skipChar){
- boolean isNegative = false;
- boolean isFraction = false;
- long value = 0;
- char c;
- float fraction = 1.0;
-
- c = peekNextDigit();
- // ignore non numeric leading characters
- if(c < 0)
- return 0; // zero returned if timeout
-
- do{
- if(c == skipChar)
- ; // ignore
- else if(c == '-')
- isNegative = true;
- else if (c == '.')
- isFraction = true;
- else if(c >= '0' && c <= '9') { // is c a digit?
- value = value * 10 + c - '0';
- if(isFraction)
- fraction *= 0.1;
- }
- read(); // consume the character we got with peek
- c = timedPeek();
- }
- while( (c >= '0' && c <= '9') || c == '.' || c == skipChar );
-
- if(isNegative)
- value = -value;
- if(isFraction)
- return value * fraction;
- else
- return value;
-}
-
-// read characters from stream into buffer
-// terminates if length characters have been read, or timeout (see setTimeout)
-// returns the number of characters placed in the buffer
-// the buffer is NOT null terminated.
-//
-size_t Stream::readBytes(char *buffer, size_t length)
-{
- size_t count = 0;
- while (count < length) {
- int c = timedRead();
- if (c < 0) break;
- *buffer++ = (char)c;
- count++;
- }
- return count;
-}
-
-
-// as readBytes with terminator character
-// terminates if length characters have been read, timeout, or if the terminator character detected
-// returns the number of characters placed in the buffer (0 means no valid data found)
-
-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();
- if (c < 0 || c == terminator) break;
- *buffer++ = (char)c;
- index++;
- }
- return index; // return number of characters, not including null terminator
-}
-
-String Stream::readString()
-{
- String ret;
- int c = timedRead();
- while (c >= 0)
- {
- ret += (char)c;
- c = timedRead();
- }
- return ret;
-}
-
-String Stream::readStringUntil(char terminator)
-{
- String ret;
- int c = timedRead();
- while (c >= 0 && c != terminator)
- {
- ret += (char)c;
- c = timedRead();
- }
- return ret;
-}
-
diff --git a/cores/robot/Stream.h b/cores/robot/Stream.h
deleted file mode 100644
index 007b4bc..0000000
--- a/cores/robot/Stream.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- Stream.h - base class for character-based streams.
- Copyright (c) 2010 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
-
- parsing functions based on TextFinder library by Michael Margolis
-*/
-
-#ifndef Stream_h
-#define Stream_h
-
-#include <inttypes.h>
-#include "Print.h"
-
-// compatability macros for testing
-/*
-#define getInt() parseInt()
-#define getInt(skipChar) parseInt(skipchar)
-#define getFloat() parseFloat()
-#define getFloat(skipChar) parseFloat(skipChar)
-#define getString( pre_string, post_string, buffer, length)
-readBytesBetween( pre_string, terminator, buffer, length)
-*/
-
-class Stream : public Print
-{
- protected:
- unsigned long _timeout; // number of milliseconds to wait for the next char before aborting timed read
- unsigned long _startMillis; // used for timeout measurement
- int timedRead(); // private method to read stream with timeout
- int timedPeek(); // private method to peek stream with timeout
- int peekNextDigit(); // returns the next numeric digit in the stream or -1 if timeout
-
- public:
- virtual int available() = 0;
- virtual int read() = 0;
- virtual int peek() = 0;
- virtual void flush() = 0;
-
- Stream() {_timeout=1000;}
-
-// parsing methods
-
- void setTimeout(unsigned long timeout); // sets maximum milliseconds to wait for stream data, default is 1 second
-
- bool find(char *target); // reads data from the stream until the target string is found
- // returns true if target string is found, false if timed out (see setTimeout)
-
- bool find(char *target, size_t length); // reads data from the stream until the target string of given length is found
- // returns true if target string is found, false if timed out
-
- bool findUntil(char *target, char *terminator); // as find but search ends if the terminator string is found
-
- bool findUntil(char *target, size_t targetLen, char *terminate, size_t termLen); // as above but search ends if the terminate string is found
-
-
- long parseInt(); // returns the first valid (long) integer value from the current position.
- // initial characters that are not digits (or the minus sign) are skipped
- // integer is terminated by the first character that is not a digit.
-
- float parseFloat(); // float version of parseInt
-
- size_t readBytes( char *buffer, size_t length); // read chars from stream into buffer
- // terminates if length characters have been read or timeout (see setTimeout)
- // returns the number of characters placed in the buffer (0 means no valid data found)
-
- size_t readBytesUntil( char terminator, char *buffer, size_t length); // as readBytes with terminator character
- // terminates if length characters have been read, timeout, or if the terminator character detected
- // returns the number of characters placed in the buffer (0 means no valid data found)
-
- // Arduino String functions to be added here
- String readString();
- String readStringUntil(char terminator);
-
- protected:
- long parseInt(char skipChar); // as above but the given skipChar is ignored
- // as above but the given skipChar is ignored
- // this allows format characters (typically commas) in values to be ignored
-
- float parseFloat(char skipChar); // as above but the given skipChar is ignored
-};
-
-#endif
diff --git a/cores/robot/Tone.cpp b/cores/robot/Tone.cpp
deleted file mode 100755
index 9bb6fe7..0000000
--- a/cores/robot/Tone.cpp
+++ /dev/null
@@ -1,616 +0,0 @@
-/* Tone.cpp
-
- A Tone Generator Library
-
- Written by Brett Hagman
-
- 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 Modified By Date Comments
-------- ----------- -------- --------
-0001 B Hagman 09/08/02 Initial coding
-0002 B Hagman 09/08/18 Multiple pins
-0003 B Hagman 09/08/18 Moved initialization from constructor to begin()
-0004 B Hagman 09/09/26 Fixed problems with ATmega8
-0005 B Hagman 09/11/23 Scanned prescalars for best fit on 8 bit timers
- 09/11/25 Changed pin toggle method to XOR
- 09/11/25 Fixed timer0 from being excluded
-0006 D Mellis 09/12/29 Replaced objects with functions
-0007 M Sproul 10/08/29 Changed #ifdefs from cpu to register
-0008 S Kanemoto 12/06/22 Fixed for Leonardo by @maris_HY
-*************************************************/
-
-#include <avr/interrupt.h>
-#include <avr/pgmspace.h>
-#include "Arduino.h"
-#include "pins_arduino.h"
-
-#if defined(__AVR_ATmega8__) || defined(__AVR_ATmega128__)
-#define TCCR2A TCCR2
-#define TCCR2B TCCR2
-#define COM2A1 COM21
-#define COM2A0 COM20
-#define OCR2A OCR2
-#define TIMSK2 TIMSK
-#define OCIE2A OCIE2
-#define TIMER2_COMPA_vect TIMER2_COMP_vect
-#define TIMSK1 TIMSK
-#endif
-
-// timerx_toggle_count:
-// > 0 - duration specified
-// = 0 - stopped
-// < 0 - infinitely (until stop() method called, or new play() called)
-
-#if !defined(__AVR_ATmega8__)
-volatile long timer0_toggle_count;
-volatile uint8_t *timer0_pin_port;
-volatile uint8_t timer0_pin_mask;
-#endif
-
-volatile long timer1_toggle_count;
-volatile uint8_t *timer1_pin_port;
-volatile uint8_t timer1_pin_mask;
-volatile long timer2_toggle_count;
-volatile uint8_t *timer2_pin_port;
-volatile uint8_t timer2_pin_mask;
-
-#if defined(TIMSK3)
-volatile long timer3_toggle_count;
-volatile uint8_t *timer3_pin_port;
-volatile uint8_t timer3_pin_mask;
-#endif
-
-#if defined(TIMSK4)
-volatile long timer4_toggle_count;
-volatile uint8_t *timer4_pin_port;
-volatile uint8_t timer4_pin_mask;
-#endif
-
-#if defined(TIMSK5)
-volatile long timer5_toggle_count;
-volatile uint8_t *timer5_pin_port;
-volatile uint8_t timer5_pin_mask;
-#endif
-
-
-#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
-
-#define AVAILABLE_TONE_PINS 1
-#define USE_TIMER2
-
-const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 3, 4, 5, 1, 0 */ };
-static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255, 255, 255, 255, 255 */ };
-
-#elif defined(__AVR_ATmega8__)
-
-#define AVAILABLE_TONE_PINS 1
-#define USE_TIMER2
-
-const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 1 */ };
-static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255 */ };
-
-#elif defined(__AVR_ATmega32U4__)
-
-#define AVAILABLE_TONE_PINS 1
-#define USE_TIMER3
-
-const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 3 /*, 1 */ };
-static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255 */ };
-
-#else
-
-#define AVAILABLE_TONE_PINS 1
-#define USE_TIMER2
-
-// Leave timer 0 to last.
-const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 1, 0 */ };
-static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255, 255 */ };
-
-#endif
-
-
-
-static int8_t toneBegin(uint8_t _pin)
-{
- int8_t _timer = -1;
-
- // if we're already using the pin, the timer should be configured.
- for (int i = 0; i < AVAILABLE_TONE_PINS; i++) {
- if (tone_pins[i] == _pin) {
- return pgm_read_byte(tone_pin_to_timer_PGM + i);
- }
- }
-
- // search for an unused timer.
- for (int i = 0; i < AVAILABLE_TONE_PINS; i++) {
- if (tone_pins[i] == 255) {
- tone_pins[i] = _pin;
- _timer = pgm_read_byte(tone_pin_to_timer_PGM + i);
- break;
- }
- }
-
- if (_timer != -1)
- {
- // Set timer specific stuff
- // All timers in CTC mode
- // 8 bit timers will require changing prescalar values,
- // whereas 16 bit timers are set to either ck/1 or ck/64 prescalar
- switch (_timer)
- {
- #if defined(TCCR0A) && defined(TCCR0B)
- case 0:
- // 8 bit timer
- TCCR0A = 0;
- TCCR0B = 0;
- bitWrite(TCCR0A, WGM01, 1);
- bitWrite(TCCR0B, CS00, 1);
- timer0_pin_port = portOutputRegister(digitalPinToPort(_pin));
- timer0_pin_mask = digitalPinToBitMask(_pin);
- break;
- #endif
-
- #if defined(TCCR1A) && defined(TCCR1B) && defined(WGM12)
- case 1:
- // 16 bit timer
- TCCR1A = 0;
- TCCR1B = 0;
- bitWrite(TCCR1B, WGM12, 1);
- bitWrite(TCCR1B, CS10, 1);
- timer1_pin_port = portOutputRegister(digitalPinToPort(_pin));
- timer1_pin_mask = digitalPinToBitMask(_pin);
- break;
- #endif
-
- #if defined(TCCR2A) && defined(TCCR2B)
- case 2:
- // 8 bit timer
- TCCR2A = 0;
- TCCR2B = 0;
- bitWrite(TCCR2A, WGM21, 1);
- bitWrite(TCCR2B, CS20, 1);
- timer2_pin_port = portOutputRegister(digitalPinToPort(_pin));
- timer2_pin_mask = digitalPinToBitMask(_pin);
- break;
- #endif
-
- #if defined(TCCR3A) && defined(TCCR3B) && defined(TIMSK3)
- case 3:
- // 16 bit timer
- TCCR3A = 0;
- TCCR3B = 0;
- bitWrite(TCCR3B, WGM32, 1);
- bitWrite(TCCR3B, CS30, 1);
- timer3_pin_port = portOutputRegister(digitalPinToPort(_pin));
- timer3_pin_mask = digitalPinToBitMask(_pin);
- break;
- #endif
-
- #if defined(TCCR4A) && defined(TCCR4B) && defined(TIMSK4)
- case 4:
- // 16 bit timer
- TCCR4A = 0;
- TCCR4B = 0;
- #if defined(WGM42)
- bitWrite(TCCR4B, WGM42, 1);
- #elif defined(CS43)
- #warning this may not be correct
- // atmega32u4
- bitWrite(TCCR4B, CS43, 1);
- #endif
- bitWrite(TCCR4B, CS40, 1);
- timer4_pin_port = portOutputRegister(digitalPinToPort(_pin));
- timer4_pin_mask = digitalPinToBitMask(_pin);
- break;
- #endif
-
- #if defined(TCCR5A) && defined(TCCR5B) && defined(TIMSK5)
- case 5:
- // 16 bit timer
- TCCR5A = 0;
- TCCR5B = 0;
- bitWrite(TCCR5B, WGM52, 1);
- bitWrite(TCCR5B, CS50, 1);
- timer5_pin_port = portOutputRegister(digitalPinToPort(_pin));
- timer5_pin_mask = digitalPinToBitMask(_pin);
- break;
- #endif
- }
- }
-
- return _timer;
-}
-
-
-
-// frequency (in hertz) and duration (in milliseconds).
-
-void tone(uint8_t _pin, unsigned int frequency, unsigned long duration)
-{
- uint8_t prescalarbits = 0b001;
- long toggle_count = 0;
- uint32_t ocr = 0;
- int8_t _timer;
-
- _timer = toneBegin(_pin);
-
- if (_timer >= 0)
- {
- // Set the pinMode as OUTPUT
- pinMode(_pin, OUTPUT);
-
- // if we are using an 8 bit timer, scan through prescalars to find the best fit
- if (_timer == 0 || _timer == 2)
- {
- ocr = F_CPU / frequency / 2 - 1;
- prescalarbits = 0b001; // ck/1: same for both timers
- if (ocr > 255)
- {
- ocr = F_CPU / frequency / 2 / 8 - 1;
- prescalarbits = 0b010; // ck/8: same for both timers
-
- if (_timer == 2 && ocr > 255)
- {
- ocr = F_CPU / frequency / 2 / 32 - 1;
- prescalarbits = 0b011;
- }
-
- if (ocr > 255)
- {
- ocr = F_CPU / frequency / 2 / 64 - 1;
- prescalarbits = _timer == 0 ? 0b011 : 0b100;
-
- if (_timer == 2 && ocr > 255)
- {
- ocr = F_CPU / frequency / 2 / 128 - 1;
- prescalarbits = 0b101;
- }
-
- if (ocr > 255)
- {
- ocr = F_CPU / frequency / 2 / 256 - 1;
- prescalarbits = _timer == 0 ? 0b100 : 0b110;
- if (ocr > 255)
- {
- // can't do any better than /1024
- ocr = F_CPU / frequency / 2 / 1024 - 1;
- prescalarbits = _timer == 0 ? 0b101 : 0b111;
- }
- }
- }
- }
-
-#if defined(TCCR0B)
- if (_timer == 0)
- {
- TCCR0B = prescalarbits;
- }
- else
-#endif
-#if defined(TCCR2B)
- {
- TCCR2B = prescalarbits;
- }
-#else
- {
- // dummy place holder to make the above ifdefs work
- }
-#endif
- }
- else
- {
- // two choices for the 16 bit timers: ck/1 or ck/64
- ocr = F_CPU / frequency / 2 - 1;
-
- prescalarbits = 0b001;
- if (ocr > 0xffff)
- {
- ocr = F_CPU / frequency / 2 / 64 - 1;
- prescalarbits = 0b011;
- }
-
- if (_timer == 1)
- {
-#if defined(TCCR1B)
- TCCR1B = (TCCR1B & 0b11111000) | prescalarbits;
-#endif
- }
-#if defined(TCCR3B)
- else if (_timer == 3)
- TCCR3B = (TCCR3B & 0b11111000) | prescalarbits;
-#endif
-#if defined(TCCR4B)
- else if (_timer == 4)
- TCCR4B = (TCCR4B & 0b11111000) | prescalarbits;
-#endif
-#if defined(TCCR5B)
- else if (_timer == 5)
- TCCR5B = (TCCR5B & 0b11111000) | prescalarbits;
-#endif
-
- }
-
-
- // Calculate the toggle count
- if (duration > 0)
- {
- toggle_count = 2 * frequency * duration / 1000;
- }
- else
- {
- toggle_count = -1;
- }
-
- // Set the OCR for the given timer,
- // set the toggle count,
- // then turn on the interrupts
- switch (_timer)
- {
-
-#if defined(OCR0A) && defined(TIMSK0) && defined(OCIE0A)
- case 0:
- OCR0A = ocr;
- timer0_toggle_count = toggle_count;
- bitWrite(TIMSK0, OCIE0A, 1);
- break;
-#endif
-
- case 1:
-#if defined(OCR1A) && defined(TIMSK1) && defined(OCIE1A)
- OCR1A = ocr;
- timer1_toggle_count = toggle_count;
- bitWrite(TIMSK1, OCIE1A, 1);
-#elif defined(OCR1A) && defined(TIMSK) && defined(OCIE1A)
- // this combination is for at least the ATmega32
- OCR1A = ocr;
- timer1_toggle_count = toggle_count;
- bitWrite(TIMSK, OCIE1A, 1);
-#endif
- break;
-
-#if defined(OCR2A) && defined(TIMSK2) && defined(OCIE2A)
- case 2:
- OCR2A = ocr;
- timer2_toggle_count = toggle_count;
- bitWrite(TIMSK2, OCIE2A, 1);
- break;
-#endif
-
-#if defined(TIMSK3)
- case 3:
- OCR3A = ocr;
- timer3_toggle_count = toggle_count;
- bitWrite(TIMSK3, OCIE3A, 1);
- break;
-#endif
-
-#if defined(TIMSK4)
- case 4:
- OCR4A = ocr;
- timer4_toggle_count = toggle_count;
- bitWrite(TIMSK4, OCIE4A, 1);
- break;
-#endif
-
-#if defined(OCR5A) && defined(TIMSK5) && defined(OCIE5A)
- case 5:
- OCR5A = ocr;
- timer5_toggle_count = toggle_count;
- bitWrite(TIMSK5, OCIE5A, 1);
- break;
-#endif
-
- }
- }
-}
-
-
-// XXX: this function only works properly for timer 2 (the only one we use
-// currently). for the others, it should end the tone, but won't restore
-// proper PWM functionality for the timer.
-void disableTimer(uint8_t _timer)
-{
- switch (_timer)
- {
- case 0:
- #if defined(TIMSK0)
- TIMSK0 = 0;
- #elif defined(TIMSK)
- TIMSK = 0; // atmega32
- #endif
- break;
-
-#if defined(TIMSK1) && defined(OCIE1A)
- case 1:
- bitWrite(TIMSK1, OCIE1A, 0);
- break;
-#endif
-
- case 2:
- #if defined(TIMSK2) && defined(OCIE2A)
- bitWrite(TIMSK2, OCIE2A, 0); // disable interrupt
- #endif
- #if defined(TCCR2A) && defined(WGM20)
- TCCR2A = (1 << WGM20);
- #endif
- #if defined(TCCR2B) && defined(CS22)
- TCCR2B = (TCCR2B & 0b11111000) | (1 << CS22);
- #endif
- #if defined(OCR2A)
- OCR2A = 0;
- #endif
- break;
-
-#if defined(TIMSK3)
- case 3:
- TIMSK3 = 0;
- break;
-#endif
-
-#if defined(TIMSK4)
- case 4:
- TIMSK4 = 0;
- break;
-#endif
-
-#if defined(TIMSK5)
- case 5:
- TIMSK5 = 0;
- break;
-#endif
- }
-}
-
-
-void noTone(uint8_t _pin)
-{
- int8_t _timer = -1;
-
- for (int i = 0; i < AVAILABLE_TONE_PINS; i++) {
- if (tone_pins[i] == _pin) {
- _timer = pgm_read_byte(tone_pin_to_timer_PGM + i);
- tone_pins[i] = 255;
- }
- }
-
- disableTimer(_timer);
-
- digitalWrite(_pin, 0);
-}
-
-#ifdef USE_TIMER0
-ISR(TIMER0_COMPA_vect)
-{
- if (timer0_toggle_count != 0)
- {
- // toggle the pin
- *timer0_pin_port ^= timer0_pin_mask;
-
- if (timer0_toggle_count > 0)
- timer0_toggle_count--;
- }
- else
- {
- disableTimer(0);
- *timer0_pin_port &= ~(timer0_pin_mask); // keep pin low after stop
- }
-}
-#endif
-
-
-#ifdef USE_TIMER1
-ISR(TIMER1_COMPA_vect)
-{
- if (timer1_toggle_count != 0)
- {
- // toggle the pin
- *timer1_pin_port ^= timer1_pin_mask;
-
- if (timer1_toggle_count > 0)
- timer1_toggle_count--;
- }
- else
- {
- disableTimer(1);
- *timer1_pin_port &= ~(timer1_pin_mask); // keep pin low after stop
- }
-}
-#endif
-
-
-#ifdef USE_TIMER2
-ISR(TIMER2_COMPA_vect)
-{
-
- if (timer2_toggle_count != 0)
- {
- // toggle the pin
- *timer2_pin_port ^= timer2_pin_mask;
-
- if (timer2_toggle_count > 0)
- timer2_toggle_count--;
- }
- else
- {
- // need to call noTone() so that the tone_pins[] entry is reset, so the
- // timer gets initialized next time we call tone().
- // XXX: this assumes timer 2 is always the first one used.
- noTone(tone_pins[0]);
-// disableTimer(2);
-// *timer2_pin_port &= ~(timer2_pin_mask); // keep pin low after stop
- }
-}
-#endif
-
-
-#ifdef USE_TIMER3
-ISR(TIMER3_COMPA_vect)
-{
- if (timer3_toggle_count != 0)
- {
- // toggle the pin
- *timer3_pin_port ^= timer3_pin_mask;
-
- if (timer3_toggle_count > 0)
- timer3_toggle_count--;
- }
- else
- {
- disableTimer(3);
- *timer3_pin_port &= ~(timer3_pin_mask); // keep pin low after stop
- }
-}
-#endif
-
-
-#ifdef USE_TIMER4
-ISR(TIMER4_COMPA_vect)
-{
- if (timer4_toggle_count != 0)
- {
- // toggle the pin
- *timer4_pin_port ^= timer4_pin_mask;
-
- if (timer4_toggle_count > 0)
- timer4_toggle_count--;
- }
- else
- {
- disableTimer(4);
- *timer4_pin_port &= ~(timer4_pin_mask); // keep pin low after stop
- }
-}
-#endif
-
-
-#ifdef USE_TIMER5
-ISR(TIMER5_COMPA_vect)
-{
- if (timer5_toggle_count != 0)
- {
- // toggle the pin
- *timer5_pin_port ^= timer5_pin_mask;
-
- if (timer5_toggle_count > 0)
- timer5_toggle_count--;
- }
- else
- {
- disableTimer(5);
- *timer5_pin_port &= ~(timer5_pin_mask); // keep pin low after stop
- }
-}
-#endif
diff --git a/cores/robot/USBAPI.h b/cores/robot/USBAPI.h
deleted file mode 100644
index eb2e593..0000000
--- a/cores/robot/USBAPI.h
+++ /dev/null
@@ -1,196 +0,0 @@
-
-
-#ifndef __USBAPI__
-#define __USBAPI__
-
-#if defined(USBCON)
-
-//================================================================================
-//================================================================================
-// USB
-
-class USBDevice_
-{
-public:
- USBDevice_();
- bool configured();
-
- void attach();
- void detach(); // Serial port goes down too...
- void poll();
-};
-extern USBDevice_ USBDevice;
-
-//================================================================================
-//================================================================================
-// Serial over CDC (Serial1 is the physical port)
-
-class Serial_ : public Stream
-{
-private:
- ring_buffer *_cdc_rx_buffer;
-public:
- void begin(uint16_t baud_count);
- 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);
- using Print::write; // pull in write(str) and write(buf, size) from Print
- operator bool();
-};
-extern Serial_ Serial;
-
-//================================================================================
-//================================================================================
-// Mouse
-
-#define MOUSE_LEFT 1
-#define MOUSE_RIGHT 2
-#define MOUSE_MIDDLE 4
-#define MOUSE_ALL (MOUSE_LEFT | MOUSE_RIGHT | MOUSE_MIDDLE)
-
-class Mouse_
-{
-private:
- uint8_t _buttons;
- void buttons(uint8_t b);
-public:
- Mouse_(void);
- void begin(void);
- void end(void);
- void click(uint8_t b = MOUSE_LEFT);
- void move(signed char x, signed char y, signed char wheel = 0);
- void press(uint8_t b = MOUSE_LEFT); // press LEFT by default
- void release(uint8_t b = MOUSE_LEFT); // release LEFT by default
- bool isPressed(uint8_t b = MOUSE_LEFT); // check LEFT by default
-};
-extern Mouse_ Mouse;
-
-//================================================================================
-//================================================================================
-// Keyboard
-
-#define KEY_LEFT_CTRL 0x80
-#define KEY_LEFT_SHIFT 0x81
-#define KEY_LEFT_ALT 0x82
-#define KEY_LEFT_GUI 0x83
-#define KEY_RIGHT_CTRL 0x84
-#define KEY_RIGHT_SHIFT 0x85
-#define KEY_RIGHT_ALT 0x86
-#define KEY_RIGHT_GUI 0x87
-
-#define KEY_UP_ARROW 0xDA
-#define KEY_DOWN_ARROW 0xD9
-#define KEY_LEFT_ARROW 0xD8
-#define KEY_RIGHT_ARROW 0xD7
-#define KEY_BACKSPACE 0xB2
-#define KEY_TAB 0xB3
-#define KEY_RETURN 0xB0
-#define KEY_ESC 0xB1
-#define KEY_INSERT 0xD1
-#define KEY_DELETE 0xD4
-#define KEY_PAGE_UP 0xD3
-#define KEY_PAGE_DOWN 0xD6
-#define KEY_HOME 0xD2
-#define KEY_END 0xD5
-#define KEY_CAPS_LOCK 0xC1
-#define KEY_F1 0xC2
-#define KEY_F2 0xC3
-#define KEY_F3 0xC4
-#define KEY_F4 0xC5
-#define KEY_F5 0xC6
-#define KEY_F6 0xC7
-#define KEY_F7 0xC8
-#define KEY_F8 0xC9
-#define KEY_F9 0xCA
-#define KEY_F10 0xCB
-#define KEY_F11 0xCC
-#define KEY_F12 0xCD
-
-// Low level key report: up to 6 keys and shift, ctrl etc at once
-typedef struct
-{
- uint8_t modifiers;
- uint8_t reserved;
- uint8_t keys[6];
-} KeyReport;
-
-class Keyboard_ : public Print
-{
-private:
- KeyReport _keyReport;
- void sendReport(KeyReport* keys);
-public:
- Keyboard_(void);
- void begin(void);
- void end(void);
- virtual size_t write(uint8_t k);
- virtual size_t press(uint8_t k);
- virtual size_t release(uint8_t k);
- virtual void releaseAll(void);
-};
-extern Keyboard_ Keyboard;
-
-//================================================================================
-//================================================================================
-// Low level API
-
-typedef struct
-{
- uint8_t bmRequestType;
- uint8_t bRequest;
- uint8_t wValueL;
- uint8_t wValueH;
- uint16_t wIndex;
- uint16_t wLength;
-} Setup;
-
-//================================================================================
-//================================================================================
-// HID 'Driver'
-
-int HID_GetInterface(uint8_t* interfaceNum);
-int HID_GetDescriptor(int i);
-bool HID_Setup(Setup& setup);
-void HID_SendReport(uint8_t id, const void* data, int len);
-
-//================================================================================
-//================================================================================
-// MSC 'Driver'
-
-int MSC_GetInterface(uint8_t* interfaceNum);
-int MSC_GetDescriptor(int i);
-bool MSC_Setup(Setup& setup);
-bool MSC_Data(uint8_t rx,uint8_t tx);
-
-//================================================================================
-//================================================================================
-// CSC 'Driver'
-
-int CDC_GetInterface(uint8_t* interfaceNum);
-int CDC_GetDescriptor(int i);
-bool CDC_Setup(Setup& setup);
-
-//================================================================================
-//================================================================================
-
-#define TRANSFER_PGM 0x80
-#define TRANSFER_RELEASE 0x40
-#define TRANSFER_ZERO 0x20
-
-int USB_SendControl(uint8_t flags, const void* d, int len);
-int USB_RecvControl(void* d, int len);
-
-uint8_t USB_Available(uint8_t ep);
-int USB_Send(uint8_t ep, const void* data, int len); // blocking
-int USB_Recv(uint8_t ep, void* data, int len); // non-blocking
-int USB_Recv(uint8_t ep); // non-blocking
-void USB_Flush(uint8_t ep);
-
-#endif
-
-#endif /* if defined(USBCON) */ \ No newline at end of file
diff --git a/cores/robot/USBCore.cpp b/cores/robot/USBCore.cpp
deleted file mode 100644
index d3e0170..0000000
--- a/cores/robot/USBCore.cpp
+++ /dev/null
@@ -1,684 +0,0 @@
-
-
-/* Copyright (c) 2010, Peter Barrett
-**
-** Permission to use, copy, modify, and/or distribute this software for
-** any purpose with or without fee is hereby granted, provided that the
-** above copyright notice and this permission notice appear in all copies.
-**
-** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
-** WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
-** WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR
-** BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
-** OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-** WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-** ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-** SOFTWARE.
-*/
-
-#include "Platform.h"
-#include "USBAPI.h"
-#include "USBDesc.h"
-
-#if defined(USBCON)
-
-#define EP_TYPE_CONTROL 0x00
-#define EP_TYPE_BULK_IN 0x81
-#define EP_TYPE_BULK_OUT 0x80
-#define EP_TYPE_INTERRUPT_IN 0xC1
-#define EP_TYPE_INTERRUPT_OUT 0xC0
-#define EP_TYPE_ISOCHRONOUS_IN 0x41
-#define EP_TYPE_ISOCHRONOUS_OUT 0x40
-
-/** Pulse generation counters to keep track of the number of milliseconds remaining for each pulse type */
-#define TX_RX_LED_PULSE_MS 100
-volatile u8 TxLEDPulse; /**< Milliseconds remaining for data Tx LED pulse */
-volatile u8 RxLEDPulse; /**< Milliseconds remaining for data Rx LED pulse */
-
-//==================================================================
-//==================================================================
-
-extern const u16 STRING_LANGUAGE[] PROGMEM;
-extern const u16 STRING_IPRODUCT[] PROGMEM;
-extern const u16 STRING_IMANUFACTURER[] PROGMEM;
-extern const DeviceDescriptor USB_DeviceDescriptor PROGMEM;
-extern const DeviceDescriptor USB_DeviceDescriptorA PROGMEM;
-
-const u16 STRING_LANGUAGE[2] = {
- (3<<8) | (2+2),
- 0x0409 // English
-};
-
-const u16 STRING_IPRODUCT[17] = {
- (3<<8) | (2+2*16),
-#if USB_PID == 0x8036
- 'A','r','d','u','i','n','o',' ','L','e','o','n','a','r','d','o'
-#elif USB_PID == 0x8037
- 'A','r','d','u','i','n','o',' ','M','i','c','r','o',' ',' ',' '
-#elif USB_PID == 0x803C
- 'A','r','d','u','i','n','o',' ','E','s','p','l','o','r','a',' '
-#elif USB_PID == 0x9208
- 'L','i','l','y','P','a','d','U','S','B',' ',' ',' ',' ',' ',' '
-#else
- 'U','S','B',' ','I','O',' ','B','o','a','r','d',' ',' ',' ',' '
-#endif
-};
-
-const u16 STRING_IMANUFACTURER[12] = {
- (3<<8) | (2+2*11),
-#if USB_VID == 0x2341
- 'A','r','d','u','i','n','o',' ','L','L','C'
-#elif USB_VID == 0x1b4f
- 'S','p','a','r','k','F','u','n',' ',' ',' '
-#else
- 'U','n','k','n','o','w','n',' ',' ',' ',' '
-#endif
-};
-
-#ifdef CDC_ENABLED
-#define DEVICE_CLASS 0x02
-#else
-#define DEVICE_CLASS 0x00
-#endif
-
-// DEVICE DESCRIPTOR
-const DeviceDescriptor USB_DeviceDescriptor =
- D_DEVICE(0x00,0x00,0x00,64,USB_VID,USB_PID,0x100,IMANUFACTURER,IPRODUCT,0,1);
-
-const DeviceDescriptor USB_DeviceDescriptorA =
- D_DEVICE(DEVICE_CLASS,0x00,0x00,64,USB_VID,USB_PID,0x100,IMANUFACTURER,IPRODUCT,0,1);
-
-//==================================================================
-//==================================================================
-
-volatile u8 _usbConfiguration = 0;
-
-static inline void WaitIN(void)
-{
- while (!(UEINTX & (1<<TXINI)));
-}
-
-static inline void ClearIN(void)
-{
- UEINTX = ~(1<<TXINI);
-}
-
-static inline void WaitOUT(void)
-{
- while (!(UEINTX & (1<<RXOUTI)))
- ;
-}
-
-static inline u8 WaitForINOrOUT()
-{
- while (!(UEINTX & ((1<<TXINI)|(1<<RXOUTI))))
- ;
- return (UEINTX & (1<<RXOUTI)) == 0;
-}
-
-static inline void ClearOUT(void)
-{
- UEINTX = ~(1<<RXOUTI);
-}
-
-void Recv(volatile u8* data, u8 count)
-{
- while (count--)
- *data++ = UEDATX;
-
- RXLED1; // light the RX LED
- RxLEDPulse = TX_RX_LED_PULSE_MS;
-}
-
-static inline u8 Recv8()
-{
- RXLED1; // light the RX LED
- RxLEDPulse = TX_RX_LED_PULSE_MS;
-
- return UEDATX;
-}
-
-static inline void Send8(u8 d)
-{
- UEDATX = d;
-}
-
-static inline void SetEP(u8 ep)
-{
- UENUM = ep;
-}
-
-static inline u8 FifoByteCount()
-{
- return UEBCLX;
-}
-
-static inline u8 ReceivedSetupInt()
-{
- return UEINTX & (1<<RXSTPI);
-}
-
-static inline void ClearSetupInt()
-{
- UEINTX = ~((1<<RXSTPI) | (1<<RXOUTI) | (1<<TXINI));
-}
-
-static inline void Stall()
-{
- UECONX = (1<<STALLRQ) | (1<<EPEN);
-}
-
-static inline u8 ReadWriteAllowed()
-{
- return UEINTX & (1<<RWAL);
-}
-
-static inline u8 Stalled()
-{
- return UEINTX & (1<<STALLEDI);
-}
-
-static inline u8 FifoFree()
-{
- return UEINTX & (1<<FIFOCON);
-}
-
-static inline void ReleaseRX()
-{
- UEINTX = 0x6B; // FIFOCON=0 NAKINI=1 RWAL=1 NAKOUTI=0 RXSTPI=1 RXOUTI=0 STALLEDI=1 TXINI=1
-}
-
-static inline void ReleaseTX()
-{
- UEINTX = 0x3A; // FIFOCON=0 NAKINI=0 RWAL=1 NAKOUTI=1 RXSTPI=1 RXOUTI=0 STALLEDI=1 TXINI=0
-}
-
-static inline u8 FrameNumber()
-{
- return UDFNUML;
-}
-
-//==================================================================
-//==================================================================
-
-u8 USBGetConfiguration(void)
-{
- return _usbConfiguration;
-}
-
-#define USB_RECV_TIMEOUT
-class LockEP
-{
- u8 _sreg;
-public:
- LockEP(u8 ep) : _sreg(SREG)
- {
- cli();
- SetEP(ep & 7);
- }
- ~LockEP()
- {
- SREG = _sreg;
- }
-};
-
-// Number of bytes, assumes a rx endpoint
-u8 USB_Available(u8 ep)
-{
- LockEP lock(ep);
- return FifoByteCount();
-}
-
-// Non Blocking receive
-// Return number of bytes read
-int USB_Recv(u8 ep, void* d, int len)
-{
- if (!_usbConfiguration || len < 0)
- return -1;
-
- LockEP lock(ep);
- u8 n = FifoByteCount();
- len = min(n,len);
- n = len;
- u8* dst = (u8*)d;
- while (n--)
- *dst++ = Recv8();
- if (len && !FifoByteCount()) // release empty buffer
- ReleaseRX();
-
- return len;
-}
-
-// Recv 1 byte if ready
-int USB_Recv(u8 ep)
-{
- u8 c;
- if (USB_Recv(ep,&c,1) != 1)
- return -1;
- return c;
-}
-
-// Space in send EP
-u8 USB_SendSpace(u8 ep)
-{
- LockEP lock(ep);
- if (!ReadWriteAllowed())
- return 0;
- return 64 - FifoByteCount();
-}
-
-// Blocking Send of data to an endpoint
-int USB_Send(u8 ep, const void* d, int len)
-{
- if (!_usbConfiguration)
- return -1;
-
- int r = len;
- const u8* data = (const u8*)d;
- u8 zero = ep & TRANSFER_ZERO;
- u8 timeout = 250; // 250ms timeout on send? TODO
- while (len)
- {
- u8 n = USB_SendSpace(ep);
- if (n == 0)
- {
- if (!(--timeout))
- return -1;
- delay(1);
- continue;
- }
-
- if (n > len)
- n = len;
- len -= n;
- {
- LockEP lock(ep);
- if (ep & TRANSFER_ZERO)
- {
- while (n--)
- Send8(0);
- }
- else if (ep & TRANSFER_PGM)
- {
- while (n--)
- Send8(pgm_read_byte(data++));
- }
- else
- {
- while (n--)
- Send8(*data++);
- }
- if (!ReadWriteAllowed() || ((len == 0) && (ep & TRANSFER_RELEASE))) // Release full buffer
- ReleaseTX();
- }
- }
- TXLED1; // light the TX LED
- TxLEDPulse = TX_RX_LED_PULSE_MS;
- return r;
-}
-
-extern const u8 _initEndpoints[] PROGMEM;
-const u8 _initEndpoints[] =
-{
- 0,
-
-#ifdef CDC_ENABLED
- EP_TYPE_INTERRUPT_IN, // CDC_ENDPOINT_ACM
- EP_TYPE_BULK_OUT, // CDC_ENDPOINT_OUT
- EP_TYPE_BULK_IN, // CDC_ENDPOINT_IN
-#endif
-
-#ifdef HID_ENABLED
- EP_TYPE_INTERRUPT_IN // HID_ENDPOINT_INT
-#endif
-};
-
-#define EP_SINGLE_64 0x32 // EP0
-#define EP_DOUBLE_64 0x36 // Other endpoints
-
-static
-void InitEP(u8 index, u8 type, u8 size)
-{
- UENUM = index;
- UECONX = 1;
- UECFG0X = type;
- UECFG1X = size;
-}
-
-static
-void InitEndpoints()
-{
- for (u8 i = 1; i < sizeof(_initEndpoints); i++)
- {
- UENUM = i;
- UECONX = 1;
- UECFG0X = pgm_read_byte(_initEndpoints+i);
- UECFG1X = EP_DOUBLE_64;
- }
- UERST = 0x7E; // And reset them
- UERST = 0;
-}
-
-// Handle CLASS_INTERFACE requests
-static
-bool ClassInterfaceRequest(Setup& setup)
-{
- u8 i = setup.wIndex;
-
-#ifdef CDC_ENABLED
- if (CDC_ACM_INTERFACE == i)
- return CDC_Setup(setup);
-#endif
-
-#ifdef HID_ENABLED
- if (HID_INTERFACE == i)
- return HID_Setup(setup);
-#endif
- return false;
-}
-
-int _cmark;
-int _cend;
-void InitControl(int end)
-{
- SetEP(0);
- _cmark = 0;
- _cend = end;
-}
-
-static
-bool SendControl(u8 d)
-{
- if (_cmark < _cend)
- {
- if (!WaitForINOrOUT())
- return false;
- Send8(d);
- if (!((_cmark + 1) & 0x3F))
- ClearIN(); // Fifo is full, release this packet
- }
- _cmark++;
- return true;
-};
-
-// Clipped by _cmark/_cend
-int USB_SendControl(u8 flags, const void* d, int len)
-{
- int sent = len;
- const u8* data = (const u8*)d;
- bool pgm = flags & TRANSFER_PGM;
- while (len--)
- {
- u8 c = pgm ? pgm_read_byte(data++) : *data++;
- if (!SendControl(c))
- return -1;
- }
- return sent;
-}
-
-// Does not timeout or cross fifo boundaries
-// Will only work for transfers <= 64 bytes
-// TODO
-int USB_RecvControl(void* d, int len)
-{
- WaitOUT();
- Recv((u8*)d,len);
- ClearOUT();
- return len;
-}
-
-int SendInterfaces()
-{
- int total = 0;
- u8 interfaces = 0;
-
-#ifdef CDC_ENABLED
- total = CDC_GetInterface(&interfaces);
-#endif
-
-#ifdef HID_ENABLED
- total += HID_GetInterface(&interfaces);
-#endif
-
- return interfaces;
-}
-
-// Construct a dynamic configuration descriptor
-// This really needs dynamic endpoint allocation etc
-// TODO
-static
-bool SendConfiguration(int maxlen)
-{
- // Count and measure interfaces
- InitControl(0);
- int interfaces = SendInterfaces();
- ConfigDescriptor config = D_CONFIG(_cmark + sizeof(ConfigDescriptor),interfaces);
-
- // Now send them
- InitControl(maxlen);
- USB_SendControl(0,&config,sizeof(ConfigDescriptor));
- SendInterfaces();
- return true;
-}
-
-u8 _cdcComposite = 0;
-
-static
-bool SendDescriptor(Setup& setup)
-{
- u8 t = setup.wValueH;
- if (USB_CONFIGURATION_DESCRIPTOR_TYPE == t)
- return SendConfiguration(setup.wLength);
-
- InitControl(setup.wLength);
-#ifdef HID_ENABLED
- if (HID_REPORT_DESCRIPTOR_TYPE == t)
- return HID_GetDescriptor(t);
-#endif
-
- u8 desc_length = 0;
- const u8* desc_addr = 0;
- if (USB_DEVICE_DESCRIPTOR_TYPE == t)
- {
- if (setup.wLength == 8)
- _cdcComposite = 1;
- desc_addr = _cdcComposite ? (const u8*)&USB_DeviceDescriptorA : (const u8*)&USB_DeviceDescriptor;
- }
- else if (USB_STRING_DESCRIPTOR_TYPE == t)
- {
- if (setup.wValueL == 0)
- desc_addr = (const u8*)&STRING_LANGUAGE;
- else if (setup.wValueL == IPRODUCT)
- desc_addr = (const u8*)&STRING_IPRODUCT;
- else if (setup.wValueL == IMANUFACTURER)
- desc_addr = (const u8*)&STRING_IMANUFACTURER;
- else
- return false;
- }
-
- if (desc_addr == 0)
- return false;
- if (desc_length == 0)
- desc_length = pgm_read_byte(desc_addr);
-
- USB_SendControl(TRANSFER_PGM,desc_addr,desc_length);
- return true;
-}
-
-// Endpoint 0 interrupt
-ISR(USB_COM_vect)
-{
- SetEP(0);
- if (!ReceivedSetupInt())
- return;
-
- Setup setup;
- Recv((u8*)&setup,8);
- ClearSetupInt();
-
- u8 requestType = setup.bmRequestType;
- if (requestType & REQUEST_DEVICETOHOST)
- WaitIN();
- else
- ClearIN();
-
- bool ok = true;
- if (REQUEST_STANDARD == (requestType & REQUEST_TYPE))
- {
- // Standard Requests
- u8 r = setup.bRequest;
- if (GET_STATUS == r)
- {
- Send8(0); // TODO
- Send8(0);
- }
- else if (CLEAR_FEATURE == r)
- {
- }
- else if (SET_FEATURE == r)
- {
- }
- else if (SET_ADDRESS == r)
- {
- WaitIN();
- UDADDR = setup.wValueL | (1<<ADDEN);
- }
- else if (GET_DESCRIPTOR == r)
- {
- ok = SendDescriptor(setup);
- }
- else if (SET_DESCRIPTOR == r)
- {
- ok = false;
- }
- else if (GET_CONFIGURATION == r)
- {
- Send8(1);
- }
- else if (SET_CONFIGURATION == r)
- {
- if (REQUEST_DEVICE == (requestType & REQUEST_RECIPIENT))
- {
- InitEndpoints();
- _usbConfiguration = setup.wValueL;
- } else
- ok = false;
- }
- else if (GET_INTERFACE == r)
- {
- }
- else if (SET_INTERFACE == r)
- {
- }
- }
- else
- {
- InitControl(setup.wLength); // Max length of transfer
- ok = ClassInterfaceRequest(setup);
- }
-
- if (ok)
- ClearIN();
- else
- {
- Stall();
- }
-}
-
-void USB_Flush(u8 ep)
-{
- SetEP(ep);
- if (FifoByteCount())
- ReleaseTX();
-}
-
-// General interrupt
-ISR(USB_GEN_vect)
-{
- u8 udint = UDINT;
- UDINT = 0;
-
- // End of Reset
- if (udint & (1<<EORSTI))
- {
- InitEP(0,EP_TYPE_CONTROL,EP_SINGLE_64); // init ep0
- _usbConfiguration = 0; // not configured yet
- UEIENX = 1 << RXSTPE; // Enable interrupts for ep0
- }
-
- // Start of Frame - happens every millisecond so we use it for TX and RX LED one-shot timing, too
- if (udint & (1<<SOFI))
- {
-#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
- if (TxLEDPulse && !(--TxLEDPulse))
- TXLED0;
- if (RxLEDPulse && !(--RxLEDPulse))
- RXLED0;
- }
-}
-
-// VBUS or counting frames
-// Any frame counting?
-u8 USBConnected()
-{
- u8 f = UDFNUML;
- delay(3);
- return f != UDFNUML;
-}
-
-//=======================================================================
-//=======================================================================
-
-USBDevice_ USBDevice;
-
-USBDevice_::USBDevice_()
-{
-}
-
-void USBDevice_::attach()
-{
- _usbConfiguration = 0;
- UHWCON = 0x01; // power internal reg
- USBCON = (1<<USBE)|(1<<FRZCLK); // clock frozen, usb enabled
-#if F_CPU == 16000000UL
- PLLCSR = 0x12; // Need 16 MHz xtal
-#elif F_CPU == 8000000UL
- PLLCSR = 0x02; // Need 8 MHz xtal
-#endif
- while (!(PLLCSR & (1<<PLOCK))) // wait for lock pll
- ;
-
- // Some tests on specific versions of macosx (10.7.3), reported some
- // strange behaviuors when the board is reset using the serial
- // port touch at 1200 bps. This delay fixes this behaviour.
- delay(1);
-
- USBCON = ((1<<USBE)|(1<<OTGPADE)); // start USB clock
- UDIEN = (1<<EORSTE)|(1<<SOFE); // Enable interrupts for EOR (End of Reset) and SOF (start of frame)
- UDCON = 0; // enable attach resistor
-
- TX_RX_LED_INIT;
-}
-
-void USBDevice_::detach()
-{
-}
-
-// Check for interrupts
-// TODO: VBUS detection
-bool USBDevice_::configured()
-{
- return _usbConfiguration;
-}
-
-void USBDevice_::poll()
-{
-}
-
-#endif /* if defined(USBCON) */
diff --git a/cores/robot/USBCore.h b/cores/robot/USBCore.h
deleted file mode 100644
index 8d13806..0000000
--- a/cores/robot/USBCore.h
+++ /dev/null
@@ -1,303 +0,0 @@
-
-// Copyright (c) 2010, Peter Barrett
-/*
-** Permission to use, copy, modify, and/or distribute this software for
-** any purpose with or without fee is hereby granted, provided that the
-** above copyright notice and this permission notice appear in all copies.
-**
-** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
-** WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
-** WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR
-** BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
-** OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-** WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-** ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-** SOFTWARE.
-*/
-
-#ifndef __USBCORE_H__
-#define __USBCORE_H__
-
-// Standard requests
-#define GET_STATUS 0
-#define CLEAR_FEATURE 1
-#define SET_FEATURE 3
-#define SET_ADDRESS 5
-#define GET_DESCRIPTOR 6
-#define SET_DESCRIPTOR 7
-#define GET_CONFIGURATION 8
-#define SET_CONFIGURATION 9
-#define GET_INTERFACE 10
-#define SET_INTERFACE 11
-
-
-// bmRequestType
-#define REQUEST_HOSTTODEVICE 0x00
-#define REQUEST_DEVICETOHOST 0x80
-#define REQUEST_DIRECTION 0x80
-
-#define REQUEST_STANDARD 0x00
-#define REQUEST_CLASS 0x20
-#define REQUEST_VENDOR 0x40
-#define REQUEST_TYPE 0x60
-
-#define REQUEST_DEVICE 0x00
-#define REQUEST_INTERFACE 0x01
-#define REQUEST_ENDPOINT 0x02
-#define REQUEST_OTHER 0x03
-#define REQUEST_RECIPIENT 0x03
-
-#define REQUEST_DEVICETOHOST_CLASS_INTERFACE (REQUEST_DEVICETOHOST + REQUEST_CLASS + REQUEST_INTERFACE)
-#define REQUEST_HOSTTODEVICE_CLASS_INTERFACE (REQUEST_HOSTTODEVICE + REQUEST_CLASS + REQUEST_INTERFACE)
-
-// Class requests
-
-#define CDC_SET_LINE_CODING 0x20
-#define CDC_GET_LINE_CODING 0x21
-#define CDC_SET_CONTROL_LINE_STATE 0x22
-
-#define MSC_RESET 0xFF
-#define MSC_GET_MAX_LUN 0xFE
-
-#define HID_GET_REPORT 0x01
-#define HID_GET_IDLE 0x02
-#define HID_GET_PROTOCOL 0x03
-#define HID_SET_REPORT 0x09
-#define HID_SET_IDLE 0x0A
-#define HID_SET_PROTOCOL 0x0B
-
-// Descriptors
-
-#define USB_DEVICE_DESC_SIZE 18
-#define USB_CONFIGUARTION_DESC_SIZE 9
-#define USB_INTERFACE_DESC_SIZE 9
-#define USB_ENDPOINT_DESC_SIZE 7
-
-#define USB_DEVICE_DESCRIPTOR_TYPE 1
-#define USB_CONFIGURATION_DESCRIPTOR_TYPE 2
-#define USB_STRING_DESCRIPTOR_TYPE 3
-#define USB_INTERFACE_DESCRIPTOR_TYPE 4
-#define USB_ENDPOINT_DESCRIPTOR_TYPE 5
-
-#define USB_DEVICE_CLASS_COMMUNICATIONS 0x02
-#define USB_DEVICE_CLASS_HUMAN_INTERFACE 0x03
-#define USB_DEVICE_CLASS_STORAGE 0x08
-#define USB_DEVICE_CLASS_VENDOR_SPECIFIC 0xFF
-
-#define USB_CONFIG_POWERED_MASK 0x40
-#define USB_CONFIG_BUS_POWERED 0x80
-#define USB_CONFIG_SELF_POWERED 0xC0
-#define USB_CONFIG_REMOTE_WAKEUP 0x20
-
-// bMaxPower in Configuration Descriptor
-#define USB_CONFIG_POWER_MA(mA) ((mA)/2)
-
-// bEndpointAddress in Endpoint Descriptor
-#define USB_ENDPOINT_DIRECTION_MASK 0x80
-#define USB_ENDPOINT_OUT(addr) ((addr) | 0x00)
-#define USB_ENDPOINT_IN(addr) ((addr) | 0x80)
-
-#define USB_ENDPOINT_TYPE_MASK 0x03
-#define USB_ENDPOINT_TYPE_CONTROL 0x00
-#define USB_ENDPOINT_TYPE_ISOCHRONOUS 0x01
-#define USB_ENDPOINT_TYPE_BULK 0x02
-#define USB_ENDPOINT_TYPE_INTERRUPT 0x03
-
-#define TOBYTES(x) ((x) & 0xFF),(((x) >> 8) & 0xFF)
-
-#define CDC_V1_10 0x0110
-#define CDC_COMMUNICATION_INTERFACE_CLASS 0x02
-
-#define CDC_CALL_MANAGEMENT 0x01
-#define CDC_ABSTRACT_CONTROL_MODEL 0x02
-#define CDC_HEADER 0x00
-#define CDC_ABSTRACT_CONTROL_MANAGEMENT 0x02
-#define CDC_UNION 0x06
-#define CDC_CS_INTERFACE 0x24
-#define CDC_CS_ENDPOINT 0x25
-#define CDC_DATA_INTERFACE_CLASS 0x0A
-
-#define MSC_SUBCLASS_SCSI 0x06
-#define MSC_PROTOCOL_BULK_ONLY 0x50
-
-#define HID_HID_DESCRIPTOR_TYPE 0x21
-#define HID_REPORT_DESCRIPTOR_TYPE 0x22
-#define HID_PHYSICAL_DESCRIPTOR_TYPE 0x23
-
-
-// Device
-typedef struct {
- u8 len; // 18
- u8 dtype; // 1 USB_DEVICE_DESCRIPTOR_TYPE
- u16 usbVersion; // 0x200
- u8 deviceClass;
- u8 deviceSubClass;
- u8 deviceProtocol;
- u8 packetSize0; // Packet 0
- u16 idVendor;
- u16 idProduct;
- u16 deviceVersion; // 0x100
- u8 iManufacturer;
- u8 iProduct;
- u8 iSerialNumber;
- u8 bNumConfigurations;
-} DeviceDescriptor;
-
-// Config
-typedef struct {
- u8 len; // 9
- u8 dtype; // 2
- u16 clen; // total length
- u8 numInterfaces;
- u8 config;
- u8 iconfig;
- u8 attributes;
- u8 maxPower;
-} ConfigDescriptor;
-
-// String
-
-// Interface
-typedef struct
-{
- u8 len; // 9
- u8 dtype; // 4
- u8 number;
- u8 alternate;
- u8 numEndpoints;
- u8 interfaceClass;
- u8 interfaceSubClass;
- u8 protocol;
- u8 iInterface;
-} InterfaceDescriptor;
-
-// Endpoint
-typedef struct
-{
- u8 len; // 7
- u8 dtype; // 5
- u8 addr;
- u8 attr;
- u16 packetSize;
- u8 interval;
-} EndpointDescriptor;
-
-// Interface Association Descriptor
-// Used to bind 2 interfaces together in CDC compostite device
-typedef struct
-{
- u8 len; // 8
- u8 dtype; // 11
- u8 firstInterface;
- u8 interfaceCount;
- u8 functionClass;
- u8 funtionSubClass;
- u8 functionProtocol;
- u8 iInterface;
-} IADDescriptor;
-
-// CDC CS interface descriptor
-typedef struct
-{
- u8 len; // 5
- u8 dtype; // 0x24
- u8 subtype;
- u8 d0;
- u8 d1;
-} CDCCSInterfaceDescriptor;
-
-typedef struct
-{
- u8 len; // 4
- u8 dtype; // 0x24
- u8 subtype;
- u8 d0;
-} CDCCSInterfaceDescriptor4;
-
-typedef struct
-{
- u8 len;
- u8 dtype; // 0x24
- u8 subtype; // 1
- u8 bmCapabilities;
- u8 bDataInterface;
-} CMFunctionalDescriptor;
-
-typedef struct
-{
- u8 len;
- u8 dtype; // 0x24
- u8 subtype; // 1
- u8 bmCapabilities;
-} ACMFunctionalDescriptor;
-
-typedef struct
-{
- // IAD
- IADDescriptor iad; // Only needed on compound device
-
- // Control
- InterfaceDescriptor cif; //
- CDCCSInterfaceDescriptor header;
- CMFunctionalDescriptor callManagement; // Call Management
- ACMFunctionalDescriptor controlManagement; // ACM
- CDCCSInterfaceDescriptor functionalDescriptor; // CDC_UNION
- EndpointDescriptor cifin;
-
- // Data
- InterfaceDescriptor dif;
- EndpointDescriptor in;
- EndpointDescriptor out;
-} CDCDescriptor;
-
-typedef struct
-{
- InterfaceDescriptor msc;
- EndpointDescriptor in;
- EndpointDescriptor out;
-} MSCDescriptor;
-
-typedef struct
-{
- u8 len; // 9
- u8 dtype; // 0x21
- u8 addr;
- u8 versionL; // 0x101
- u8 versionH; // 0x101
- u8 country;
- u8 desctype; // 0x22 report
- u8 descLenL;
- u8 descLenH;
-} HIDDescDescriptor;
-
-typedef struct
-{
- InterfaceDescriptor hid;
- HIDDescDescriptor desc;
- EndpointDescriptor in;
-} HIDDescriptor;
-
-
-#define D_DEVICE(_class,_subClass,_proto,_packetSize0,_vid,_pid,_version,_im,_ip,_is,_configs) \
- { 18, 1, 0x200, _class,_subClass,_proto,_packetSize0,_vid,_pid,_version,_im,_ip,_is,_configs }
-
-#define D_CONFIG(_totalLength,_interfaces) \
- { 9, 2, _totalLength,_interfaces, 1, 0, USB_CONFIG_BUS_POWERED, USB_CONFIG_POWER_MA(500) }
-
-#define D_INTERFACE(_n,_numEndpoints,_class,_subClass,_protocol) \
- { 9, 4, _n, 0, _numEndpoints, _class,_subClass, _protocol, 0 }
-
-#define D_ENDPOINT(_addr,_attr,_packetSize, _interval) \
- { 7, 5, _addr,_attr,_packetSize, _interval }
-
-#define D_IAD(_firstInterface, _count, _class, _subClass, _protocol) \
- { 8, 11, _firstInterface, _count, _class, _subClass, _protocol, 0 }
-
-#define D_HIDREPORT(_descriptorLength) \
- { 9, 0x21, 0x1, 0x1, 0, 1, 0x22, _descriptorLength, 0 }
-
-#define D_CDCCS(_subtype,_d0,_d1) { 5, 0x24, _subtype, _d0, _d1 }
-#define D_CDCCS4(_subtype,_d0) { 4, 0x24, _subtype, _d0 }
-
-
-#endif \ No newline at end of file
diff --git a/cores/robot/USBDesc.h b/cores/robot/USBDesc.h
deleted file mode 100644
index 900713e..0000000
--- a/cores/robot/USBDesc.h
+++ /dev/null
@@ -1,63 +0,0 @@
-
-
-/* Copyright (c) 2011, Peter Barrett
-**
-** Permission to use, copy, modify, and/or distribute this software for
-** any purpose with or without fee is hereby granted, provided that the
-** above copyright notice and this permission notice appear in all copies.
-**
-** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
-** WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
-** WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR
-** BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
-** OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-** WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-** ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-** SOFTWARE.
-*/
-
-#define CDC_ENABLED
-#define HID_ENABLED
-
-
-#ifdef CDC_ENABLED
-#define CDC_INTERFACE_COUNT 2
-#define CDC_ENPOINT_COUNT 3
-#else
-#define CDC_INTERFACE_COUNT 0
-#define CDC_ENPOINT_COUNT 0
-#endif
-
-#ifdef HID_ENABLED
-#define HID_INTERFACE_COUNT 1
-#define HID_ENPOINT_COUNT 1
-#else
-#define HID_INTERFACE_COUNT 0
-#define HID_ENPOINT_COUNT 0
-#endif
-
-#define CDC_ACM_INTERFACE 0 // CDC ACM
-#define CDC_DATA_INTERFACE 1 // CDC Data
-#define CDC_FIRST_ENDPOINT 1
-#define CDC_ENDPOINT_ACM (CDC_FIRST_ENDPOINT) // CDC First
-#define CDC_ENDPOINT_OUT (CDC_FIRST_ENDPOINT+1)
-#define CDC_ENDPOINT_IN (CDC_FIRST_ENDPOINT+2)
-
-#define HID_INTERFACE (CDC_ACM_INTERFACE + CDC_INTERFACE_COUNT) // HID Interface
-#define HID_FIRST_ENDPOINT (CDC_FIRST_ENDPOINT + CDC_ENPOINT_COUNT)
-#define HID_ENDPOINT_INT (HID_FIRST_ENDPOINT)
-
-#define INTERFACE_COUNT (MSC_INTERFACE + MSC_INTERFACE_COUNT)
-
-#ifdef CDC_ENABLED
-#define CDC_RX CDC_ENDPOINT_OUT
-#define CDC_TX CDC_ENDPOINT_IN
-#endif
-
-#ifdef HID_ENABLED
-#define HID_TX HID_ENDPOINT_INT
-#endif
-
-#define IMANUFACTURER 1
-#define IPRODUCT 2
-
diff --git a/cores/robot/Udp.h b/cores/robot/Udp.h
deleted file mode 100644
index dc5644b..0000000
--- a/cores/robot/Udp.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Udp.cpp: Library to send/receive UDP packets.
- *
- * NOTE: UDP is fast, but has some important limitations (thanks to Warren Gray for mentioning these)
- * 1) UDP does not guarantee the order in which assembled UDP packets are received. This
- * might not happen often in practice, but in larger network topologies, a UDP
- * packet can be received out of sequence.
- * 2) UDP does not guard against lost packets - so packets *can* disappear without the sender being
- * aware of it. Again, this may not be a concern in practice on small local networks.
- * For more information, see http://www.cafeaulait.org/course/week12/35.html
- *
- * MIT License:
- * Copyright (c) 2008 Bjoern Hartmann
- * 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.
- *
- * bjoern@cs.stanford.edu 12/30/2008
- */
-
-#ifndef udp_h
-#define udp_h
-
-#include <Stream.h>
-#include <IPAddress.h>
-
-class UDP : public Stream {
-
-public:
- virtual uint8_t begin(uint16_t) =0; // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use
- virtual void stop() =0; // Finish with the UDP socket
-
- // Sending UDP packets
-
- // Start building up a packet to send to the remote host specific in ip and port
- // Returns 1 if successful, 0 if there was a problem with the supplied IP address or port
- virtual int beginPacket(IPAddress ip, uint16_t port) =0;
- // Start building up a packet to send to the remote host specific in host and port
- // Returns 1 if successful, 0 if there was a problem resolving the hostname or port
- virtual int beginPacket(const char *host, uint16_t port) =0;
- // Finish off this packet and send it
- // Returns 1 if the packet was sent successfully, 0 if there was an error
- virtual int endPacket() =0;
- // Write a single byte into the packet
- virtual size_t write(uint8_t) =0;
- // Write size bytes from buffer into the packet
- virtual size_t write(const uint8_t *buffer, size_t size) =0;
-
- // Start processing the next available incoming packet
- // Returns the size of the packet in bytes, or 0 if no packets are available
- virtual int parsePacket() =0;
- // Number of bytes remaining in the current packet
- virtual int available() =0;
- // Read a single byte from the current packet
- virtual int read() =0;
- // Read up to len bytes from the current packet and place them into buffer
- // Returns the number of bytes read, or 0 if none are available
- virtual int read(unsigned char* buffer, size_t len) =0;
- // Read up to len characters from the current packet and place them into buffer
- // Returns the number of characters read, or 0 if none are available
- virtual int read(char* buffer, size_t len) =0;
- // Return the next byte from the current packet without moving on to the next byte
- virtual int peek() =0;
- virtual void flush() =0; // Finish reading the current packet
-
- // Return the IP address of the host who sent the current incoming packet
- virtual IPAddress remoteIP() =0;
- // Return the port of the host who sent the current incoming packet
- virtual uint16_t remotePort() =0;
-protected:
- uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); };
-};
-
-#endif
diff --git a/cores/robot/WCharacter.h b/cores/robot/WCharacter.h
deleted file mode 100644
index 79733b5..0000000
--- a/cores/robot/WCharacter.h
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- WCharacter.h - Character utility functions for Wiring & Arduino
- Copyright (c) 2010 Hernando Barragan. 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 Character_h
-#define Character_h
-
-#include <ctype.h>
-
-// WCharacter.h prototypes
-inline boolean isAlphaNumeric(int c) __attribute__((always_inline));
-inline boolean isAlpha(int c) __attribute__((always_inline));
-inline boolean isAscii(int c) __attribute__((always_inline));
-inline boolean isWhitespace(int c) __attribute__((always_inline));
-inline boolean isControl(int c) __attribute__((always_inline));
-inline boolean isDigit(int c) __attribute__((always_inline));
-inline boolean isGraph(int c) __attribute__((always_inline));
-inline boolean isLowerCase(int c) __attribute__((always_inline));
-inline boolean isPrintable(int c) __attribute__((always_inline));
-inline boolean isPunct(int c) __attribute__((always_inline));
-inline boolean isSpace(int c) __attribute__((always_inline));
-inline boolean isUpperCase(int c) __attribute__((always_inline));
-inline boolean isHexadecimalDigit(int c) __attribute__((always_inline));
-inline int toAscii(int c) __attribute__((always_inline));
-inline int toLowerCase(int c) __attribute__((always_inline));
-inline int toUpperCase(int c)__attribute__((always_inline));
-
-
-// Checks for an alphanumeric character.
-// It is equivalent to (isalpha(c) || isdigit(c)).
-inline boolean isAlphaNumeric(int c)
-{
- return ( isalnum(c) == 0 ? false : true);
-}
-
-
-// Checks for an alphabetic character.
-// It is equivalent to (isupper(c) || islower(c)).
-inline boolean isAlpha(int c)
-{
- return ( isalpha(c) == 0 ? false : true);
-}
-
-
-// Checks whether c is a 7-bit unsigned char value
-// that fits into the ASCII character set.
-inline boolean isAscii(int c)
-{
- return ( isascii (c) == 0 ? false : true);
-}
-
-
-// Checks for a blank character, that is, a space or a tab.
-inline boolean isWhitespace(int c)
-{
- return ( isblank (c) == 0 ? false : true);
-}
-
-
-// Checks for a control character.
-inline boolean isControl(int c)
-{
- return ( iscntrl (c) == 0 ? false : true);
-}
-
-
-// Checks for a digit (0 through 9).
-inline boolean isDigit(int c)
-{
- return ( isdigit (c) == 0 ? false : true);
-}
-
-
-// Checks for any printable character except space.
-inline boolean isGraph(int c)
-{
- return ( isgraph (c) == 0 ? false : true);
-}
-
-
-// Checks for a lower-case character.
-inline boolean isLowerCase(int c)
-{
- return (islower (c) == 0 ? false : true);
-}
-
-
-// Checks for any printable character including space.
-inline boolean isPrintable(int c)
-{
- return ( isprint (c) == 0 ? false : true);
-}
-
-
-// Checks for any printable character which is not a space
-// or an alphanumeric character.
-inline boolean isPunct(int c)
-{
- return ( ispunct (c) == 0 ? false : true);
-}
-
-
-// Checks for white-space characters. For the avr-libc library,
-// these are: space, formfeed ('\f'), newline ('\n'), carriage
-// return ('\r'), horizontal tab ('\t'), and vertical tab ('\v').
-inline boolean isSpace(int c)
-{
- return ( isspace (c) == 0 ? false : true);
-}
-
-
-// Checks for an uppercase letter.
-inline boolean isUpperCase(int c)
-{
- return ( isupper (c) == 0 ? false : true);
-}
-
-
-// Checks for a hexadecimal digits, i.e. one of 0 1 2 3 4 5 6 7
-// 8 9 a b c d e f A B C D E F.
-inline boolean isHexadecimalDigit(int c)
-{
- return ( isxdigit (c) == 0 ? false : true);
-}
-
-
-// Converts c to a 7-bit unsigned char value that fits into the
-// ASCII character set, by clearing the high-order bits.
-inline int toAscii(int c)
-{
- return toascii (c);
-}
-
-
-// Warning:
-// Many people will be unhappy if you use this function.
-// This function will convert accented letters into random
-// characters.
-
-// Converts the letter c to lower case, if possible.
-inline int toLowerCase(int c)
-{
- return tolower (c);
-}
-
-
-// Converts the letter c to upper case, if possible.
-inline int toUpperCase(int c)
-{
- return toupper (c);
-}
-
-#endif \ No newline at end of file
diff --git a/cores/robot/WInterrupts.c b/cores/robot/WInterrupts.c
deleted file mode 100644
index d3fbf10..0000000
--- a/cores/robot/WInterrupts.c
+++ /dev/null
@@ -1,334 +0,0 @@
-/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
-
-/*
- Part of the Wiring project - http://wiring.uniandes.edu.co
-
- Copyright (c) 2004-05 Hernando Barragan
-
- 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
-
- Modified 24 November 2006 by David A. Mellis
- Modified 1 August 2010 by Mark Sproul
-*/
-
-#include <inttypes.h>
-#include <avr/io.h>
-#include <avr/interrupt.h>
-#include <avr/pgmspace.h>
-#include <stdio.h>
-
-#include "wiring_private.h"
-
-static volatile voidFuncPtr intFunc[EXTERNAL_NUM_INTERRUPTS];
-// volatile static voidFuncPtr twiIntFunc;
-
-void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), int mode) {
- if(interruptNum < EXTERNAL_NUM_INTERRUPTS) {
- intFunc[interruptNum] = userFunc;
-
- // Configure the interrupt mode (trigger on low input, any change, rising
- // edge, or falling edge). The mode constants were chosen to correspond
- // to the configuration bits in the hardware register, so we simply shift
- // the mode into place.
-
- // Enable the interrupt.
-
- switch (interruptNum) {
-#if defined(__AVR_ATmega32U4__)
- // I hate doing this, but the register assignment differs between the 1280/2560
- // and the 32U4. Since avrlib defines registers PCMSK1 and PCMSK2 that aren't
- // even present on the 32U4 this is the only way to distinguish between them.
- case 0:
- EICRA = (EICRA & ~((1<<ISC00) | (1<<ISC01))) | (mode << ISC00);
- EIMSK |= (1<<INT0);
- break;
- case 1:
- EICRA = (EICRA & ~((1<<ISC10) | (1<<ISC11))) | (mode << ISC10);
- EIMSK |= (1<<INT1);
- break;
- case 2:
- EICRA = (EICRA & ~((1<<ISC20) | (1<<ISC21))) | (mode << ISC20);
- EIMSK |= (1<<INT2);
- break;
- case 3:
- EICRA = (EICRA & ~((1<<ISC30) | (1<<ISC31))) | (mode << ISC30);
- EIMSK |= (1<<INT3);
- break;
- case 4:
- EICRB = (EICRB & ~((1<<ISC60) | (1<<ISC61))) | (mode << ISC60);
- EIMSK |= (1<<INT6);
- break;
-#elif defined(EICRA) && defined(EICRB) && defined(EIMSK)
- case 2:
- EICRA = (EICRA & ~((1 << ISC00) | (1 << ISC01))) | (mode << ISC00);
- EIMSK |= (1 << INT0);
- break;
- case 3:
- EICRA = (EICRA & ~((1 << ISC10) | (1 << ISC11))) | (mode << ISC10);
- EIMSK |= (1 << INT1);
- break;
- case 4:
- EICRA = (EICRA & ~((1 << ISC20) | (1 << ISC21))) | (mode << ISC20);
- EIMSK |= (1 << INT2);
- break;
- case 5:
- EICRA = (EICRA & ~((1 << ISC30) | (1 << ISC31))) | (mode << ISC30);
- EIMSK |= (1 << INT3);
- break;
- case 0:
- EICRB = (EICRB & ~((1 << ISC40) | (1 << ISC41))) | (mode << ISC40);
- EIMSK |= (1 << INT4);
- break;
- case 1:
- EICRB = (EICRB & ~((1 << ISC50) | (1 << ISC51))) | (mode << ISC50);
- EIMSK |= (1 << INT5);
- break;
- case 6:
- EICRB = (EICRB & ~((1 << ISC60) | (1 << ISC61))) | (mode << ISC60);
- EIMSK |= (1 << INT6);
- break;
- case 7:
- EICRB = (EICRB & ~((1 << ISC70) | (1 << ISC71))) | (mode << ISC70);
- EIMSK |= (1 << INT7);
- break;
-#else
- case 0:
- #if defined(EICRA) && defined(ISC00) && defined(EIMSK)
- EICRA = (EICRA & ~((1 << ISC00) | (1 << ISC01))) | (mode << ISC00);
- EIMSK |= (1 << INT0);
- #elif defined(MCUCR) && defined(ISC00) && defined(GICR)
- MCUCR = (MCUCR & ~((1 << ISC00) | (1 << ISC01))) | (mode << ISC00);
- GICR |= (1 << INT0);
- #elif defined(MCUCR) && defined(ISC00) && defined(GIMSK)
- MCUCR = (MCUCR & ~((1 << ISC00) | (1 << ISC01))) | (mode << ISC00);
- GIMSK |= (1 << INT0);
- #else
- #error attachInterrupt not finished for this CPU (case 0)
- #endif
- break;
-
- case 1:
- #if defined(EICRA) && defined(ISC10) && defined(ISC11) && defined(EIMSK)
- EICRA = (EICRA & ~((1 << ISC10) | (1 << ISC11))) | (mode << ISC10);
- EIMSK |= (1 << INT1);
- #elif defined(MCUCR) && defined(ISC10) && defined(ISC11) && defined(GICR)
- MCUCR = (MCUCR & ~((1 << ISC10) | (1 << ISC11))) | (mode << ISC10);
- GICR |= (1 << INT1);
- #elif defined(MCUCR) && defined(ISC10) && defined(GIMSK) && defined(GIMSK)
- MCUCR = (MCUCR & ~((1 << ISC10) | (1 << ISC11))) | (mode << ISC10);
- GIMSK |= (1 << INT1);
- #else
- #warning attachInterrupt may need some more work for this cpu (case 1)
- #endif
- break;
-
- case 2:
- #if defined(EICRA) && defined(ISC20) && defined(ISC21) && defined(EIMSK)
- EICRA = (EICRA & ~((1 << ISC20) | (1 << ISC21))) | (mode << ISC20);
- EIMSK |= (1 << INT2);
- #elif defined(MCUCR) && defined(ISC20) && defined(ISC21) && defined(GICR)
- MCUCR = (MCUCR & ~((1 << ISC20) | (1 << ISC21))) | (mode << ISC20);
- GICR |= (1 << INT2);
- #elif defined(MCUCR) && defined(ISC20) && defined(GIMSK) && defined(GIMSK)
- MCUCR = (MCUCR & ~((1 << ISC20) | (1 << ISC21))) | (mode << ISC20);
- GIMSK |= (1 << INT2);
- #endif
- break;
-#endif
- }
- }
-}
-
-void detachInterrupt(uint8_t interruptNum) {
- if(interruptNum < EXTERNAL_NUM_INTERRUPTS) {
- // Disable the interrupt. (We can't assume that interruptNum is equal
- // to the number of the EIMSK bit to clear, as this isn't true on the
- // ATmega8. There, INT0 is 6 and INT1 is 7.)
- switch (interruptNum) {
-#if defined(__AVR_ATmega32U4__)
- case 0:
- EIMSK &= ~(1<<INT0);
- break;
- case 1:
- EIMSK &= ~(1<<INT1);
- break;
- case 2:
- EIMSK &= ~(1<<INT2);
- break;
- case 3:
- EIMSK &= ~(1<<INT3);
- break;
- case 4:
- EIMSK &= ~(1<<INT6);
- break;
-#elif defined(EICRA) && defined(EICRB) && defined(EIMSK)
- case 2:
- EIMSK &= ~(1 << INT0);
- break;
- case 3:
- EIMSK &= ~(1 << INT1);
- break;
- case 4:
- EIMSK &= ~(1 << INT2);
- break;
- case 5:
- EIMSK &= ~(1 << INT3);
- break;
- case 0:
- EIMSK &= ~(1 << INT4);
- break;
- case 1:
- EIMSK &= ~(1 << INT5);
- break;
- case 6:
- EIMSK &= ~(1 << INT6);
- break;
- case 7:
- EIMSK &= ~(1 << INT7);
- break;
-#else
- case 0:
- #if defined(EIMSK) && defined(INT0)
- EIMSK &= ~(1 << INT0);
- #elif defined(GICR) && defined(ISC00)
- GICR &= ~(1 << INT0); // atmega32
- #elif defined(GIMSK) && defined(INT0)
- GIMSK &= ~(1 << INT0);
- #else
- #error detachInterrupt not finished for this cpu
- #endif
- break;
-
- case 1:
- #if defined(EIMSK) && defined(INT1)
- EIMSK &= ~(1 << INT1);
- #elif defined(GICR) && defined(INT1)
- GICR &= ~(1 << INT1); // atmega32
- #elif defined(GIMSK) && defined(INT1)
- GIMSK &= ~(1 << INT1);
- #else
- #warning detachInterrupt may need some more work for this cpu (case 1)
- #endif
- break;
-#endif
- }
-
- intFunc[interruptNum] = 0;
- }
-}
-
-/*
-void attachInterruptTwi(void (*userFunc)(void) ) {
- twiIntFunc = userFunc;
-}
-*/
-
-#if defined(__AVR_ATmega32U4__)
-ISR(INT0_vect) {
- if(intFunc[EXTERNAL_INT_0])
- intFunc[EXTERNAL_INT_0]();
-}
-
-ISR(INT1_vect) {
- if(intFunc[EXTERNAL_INT_1])
- intFunc[EXTERNAL_INT_1]();
-}
-
-ISR(INT2_vect) {
- if(intFunc[EXTERNAL_INT_2])
- intFunc[EXTERNAL_INT_2]();
-}
-
-ISR(INT3_vect) {
- if(intFunc[EXTERNAL_INT_3])
- intFunc[EXTERNAL_INT_3]();
-}
-
-ISR(INT6_vect) {
- if(intFunc[EXTERNAL_INT_4])
- intFunc[EXTERNAL_INT_4]();
-}
-
-#elif defined(EICRA) && defined(EICRB)
-
-ISR(INT0_vect) {
- if(intFunc[EXTERNAL_INT_2])
- intFunc[EXTERNAL_INT_2]();
-}
-
-ISR(INT1_vect) {
- if(intFunc[EXTERNAL_INT_3])
- intFunc[EXTERNAL_INT_3]();
-}
-
-ISR(INT2_vect) {
- if(intFunc[EXTERNAL_INT_4])
- intFunc[EXTERNAL_INT_4]();
-}
-
-ISR(INT3_vect) {
- if(intFunc[EXTERNAL_INT_5])
- intFunc[EXTERNAL_INT_5]();
-}
-
-ISR(INT4_vect) {
- if(intFunc[EXTERNAL_INT_0])
- intFunc[EXTERNAL_INT_0]();
-}
-
-ISR(INT5_vect) {
- if(intFunc[EXTERNAL_INT_1])
- intFunc[EXTERNAL_INT_1]();
-}
-
-ISR(INT6_vect) {
- if(intFunc[EXTERNAL_INT_6])
- intFunc[EXTERNAL_INT_6]();
-}
-
-ISR(INT7_vect) {
- if(intFunc[EXTERNAL_INT_7])
- intFunc[EXTERNAL_INT_7]();
-}
-
-#else
-
-ISR(INT0_vect) {
- if(intFunc[EXTERNAL_INT_0])
- intFunc[EXTERNAL_INT_0]();
-}
-
-ISR(INT1_vect) {
- if(intFunc[EXTERNAL_INT_1])
- intFunc[EXTERNAL_INT_1]();
-}
-
-#if defined(EICRA) && defined(ISC20)
-ISR(INT2_vect) {
- if(intFunc[EXTERNAL_INT_2])
- intFunc[EXTERNAL_INT_2]();
-}
-#endif
-
-#endif
-
-/*
-ISR(TWI_vect) {
- if(twiIntFunc)
- twiIntFunc();
-}
-*/
-
diff --git a/cores/robot/WMath.cpp b/cores/robot/WMath.cpp
deleted file mode 100644
index 2120c4c..0000000
--- a/cores/robot/WMath.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
-
-/*
- Part of the Wiring project - http://wiring.org.co
- Copyright (c) 2004-06 Hernando Barragan
- Modified 13 August 2006, David A. Mellis for Arduino - http://www.arduino.cc/
-
- 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$
-*/
-
-extern "C" {
- #include "stdlib.h"
-}
-
-void randomSeed(unsigned int seed)
-{
- if (seed != 0) {
- srandom(seed);
- }
-}
-
-long random(long howbig)
-{
- if (howbig == 0) {
- return 0;
- }
- return random() % howbig;
-}
-
-long random(long howsmall, long howbig)
-{
- if (howsmall >= howbig) {
- return howsmall;
- }
- long diff = howbig - howsmall;
- return random(diff) + howsmall;
-}
-
-long map(long x, long in_min, long in_max, long out_min, long out_max)
-{
- return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
-}
-
-unsigned int makeWord(unsigned int w) { return w; }
-unsigned int makeWord(unsigned char h, unsigned char l) { return (h << 8) | l; } \ No newline at end of file
diff --git a/cores/robot/WString.cpp b/cores/robot/WString.cpp
deleted file mode 100644
index c6839fc..0000000
--- a/cores/robot/WString.cpp
+++ /dev/null
@@ -1,645 +0,0 @@
-/*
- WString.cpp - String library for Wiring & Arduino
- ...mostly rewritten by Paul Stoffregen...
- Copyright (c) 2009-10 Hernando Barragan. All rights reserved.
- Copyright 2011, Paul Stoffregen, paul@pjrc.com
-
- 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 "WString.h"
-
-
-/*********************************************/
-/* Constructors */
-/*********************************************/
-
-String::String(const char *cstr)
-{
- init();
- if (cstr) copy(cstr, strlen(cstr));
-}
-
-String::String(const String &value)
-{
- init();
- *this = value;
-}
-
-#ifdef __GXX_EXPERIMENTAL_CXX0X__
-String::String(String &&rval)
-{
- init();
- move(rval);
-}
-String::String(StringSumHelper &&rval)
-{
- init();
- move(rval);
-}
-#endif
-
-String::String(char c)
-{
- init();
- char buf[2];
- buf[0] = c;
- buf[1] = 0;
- *this = buf;
-}
-
-String::String(unsigned char value, unsigned char base)
-{
- init();
- char buf[9];
- utoa(value, buf, base);
- *this = buf;
-}
-
-String::String(int value, unsigned char base)
-{
- init();
- char buf[18];
- itoa(value, buf, base);
- *this = buf;
-}
-
-String::String(unsigned int value, unsigned char base)
-{
- init();
- char buf[17];
- utoa(value, buf, base);
- *this = buf;
-}
-
-String::String(long value, unsigned char base)
-{
- init();
- char buf[34];
- ltoa(value, buf, base);
- *this = buf;
-}
-
-String::String(unsigned long value, unsigned char base)
-{
- init();
- char buf[33];
- ultoa(value, buf, base);
- *this = buf;
-}
-
-String::~String()
-{
- free(buffer);
-}
-
-/*********************************************/
-/* Memory Management */
-/*********************************************/
-
-inline void String::init(void)
-{
- buffer = NULL;
- capacity = 0;
- len = 0;
- flags = 0;
-}
-
-void String::invalidate(void)
-{
- if (buffer) free(buffer);
- buffer = NULL;
- capacity = len = 0;
-}
-
-unsigned char String::reserve(unsigned int size)
-{
- if (buffer && capacity >= size) return 1;
- if (changeBuffer(size)) {
- if (len == 0) buffer[0] = 0;
- return 1;
- }
- return 0;
-}
-
-unsigned char String::changeBuffer(unsigned int maxStrLen)
-{
- char *newbuffer = (char *)realloc(buffer, maxStrLen + 1);
- if (newbuffer) {
- buffer = newbuffer;
- capacity = maxStrLen;
- return 1;
- }
- return 0;
-}
-
-/*********************************************/
-/* Copy and Move */
-/*********************************************/
-
-String & String::copy(const char *cstr, unsigned int length)
-{
- if (!reserve(length)) {
- invalidate();
- return *this;
- }
- len = length;
- strcpy(buffer, cstr);
- return *this;
-}
-
-#ifdef __GXX_EXPERIMENTAL_CXX0X__
-void String::move(String &rhs)
-{
- if (buffer) {
- if (capacity >= rhs.len) {
- strcpy(buffer, rhs.buffer);
- len = rhs.len;
- rhs.len = 0;
- return;
- } else {
- free(buffer);
- }
- }
- buffer = rhs.buffer;
- capacity = rhs.capacity;
- len = rhs.len;
- rhs.buffer = NULL;
- rhs.capacity = 0;
- rhs.len = 0;
-}
-#endif
-
-String & String::operator = (const String &rhs)
-{
- if (this == &rhs) return *this;
-
- if (rhs.buffer) copy(rhs.buffer, rhs.len);
- else invalidate();
-
- return *this;
-}
-
-#ifdef __GXX_EXPERIMENTAL_CXX0X__
-String & String::operator = (String &&rval)
-{
- if (this != &rval) move(rval);
- return *this;
-}
-
-String & String::operator = (StringSumHelper &&rval)
-{
- if (this != &rval) move(rval);
- return *this;
-}
-#endif
-
-String & String::operator = (const char *cstr)
-{
- if (cstr) copy(cstr, strlen(cstr));
- else invalidate();
-
- return *this;
-}
-
-/*********************************************/
-/* concat */
-/*********************************************/
-
-unsigned char String::concat(const String &s)
-{
- return concat(s.buffer, s.len);
-}
-
-unsigned char String::concat(const char *cstr, unsigned int length)
-{
- unsigned int newlen = len + length;
- if (!cstr) return 0;
- if (length == 0) return 1;
- if (!reserve(newlen)) return 0;
- strcpy(buffer + len, cstr);
- len = newlen;
- return 1;
-}
-
-unsigned char String::concat(const char *cstr)
-{
- if (!cstr) return 0;
- return concat(cstr, strlen(cstr));
-}
-
-unsigned char String::concat(char c)
-{
- char buf[2];
- buf[0] = c;
- buf[1] = 0;
- return concat(buf, 1);
-}
-
-unsigned char String::concat(unsigned char num)
-{
- char buf[4];
- itoa(num, buf, 10);
- return concat(buf, strlen(buf));
-}
-
-unsigned char String::concat(int num)
-{
- char buf[7];
- itoa(num, buf, 10);
- return concat(buf, strlen(buf));
-}
-
-unsigned char String::concat(unsigned int num)
-{
- char buf[6];
- utoa(num, buf, 10);
- return concat(buf, strlen(buf));
-}
-
-unsigned char String::concat(long num)
-{
- char buf[12];
- ltoa(num, buf, 10);
- return concat(buf, strlen(buf));
-}
-
-unsigned char String::concat(unsigned long num)
-{
- char buf[11];
- ultoa(num, buf, 10);
- return concat(buf, strlen(buf));
-}
-
-/*********************************************/
-/* Concatenate */
-/*********************************************/
-
-StringSumHelper & operator + (const StringSumHelper &lhs, const String &rhs)
-{
- StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
- if (!a.concat(rhs.buffer, rhs.len)) a.invalidate();
- return a;
-}
-
-StringSumHelper & operator + (const StringSumHelper &lhs, const char *cstr)
-{
- StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
- if (!cstr || !a.concat(cstr, strlen(cstr))) a.invalidate();
- return a;
-}
-
-StringSumHelper & operator + (const StringSumHelper &lhs, char c)
-{
- StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
- if (!a.concat(c)) a.invalidate();
- return a;
-}
-
-StringSumHelper & operator + (const StringSumHelper &lhs, unsigned char num)
-{
- StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
- if (!a.concat(num)) a.invalidate();
- return a;
-}
-
-StringSumHelper & operator + (const StringSumHelper &lhs, int num)
-{
- StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
- if (!a.concat(num)) a.invalidate();
- return a;
-}
-
-StringSumHelper & operator + (const StringSumHelper &lhs, unsigned int num)
-{
- StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
- if (!a.concat(num)) a.invalidate();
- return a;
-}
-
-StringSumHelper & operator + (const StringSumHelper &lhs, long num)
-{
- StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
- if (!a.concat(num)) a.invalidate();
- return a;
-}
-
-StringSumHelper & operator + (const StringSumHelper &lhs, unsigned long num)
-{
- StringSumHelper &a = const_cast<StringSumHelper&>(lhs);
- if (!a.concat(num)) a.invalidate();
- return a;
-}
-
-/*********************************************/
-/* Comparison */
-/*********************************************/
-
-int String::compareTo(const String &s) const
-{
- if (!buffer || !s.buffer) {
- if (s.buffer && s.len > 0) return 0 - *(unsigned char *)s.buffer;
- if (buffer && len > 0) return *(unsigned char *)buffer;
- return 0;
- }
- return strcmp(buffer, s.buffer);
-}
-
-unsigned char String::equals(const String &s2) const
-{
- return (len == s2.len && compareTo(s2) == 0);
-}
-
-unsigned char String::equals(const char *cstr) const
-{
- if (len == 0) return (cstr == NULL || *cstr == 0);
- if (cstr == NULL) return buffer[0] == 0;
- return strcmp(buffer, cstr) == 0;
-}
-
-unsigned char String::operator<(const String &rhs) const
-{
- return compareTo(rhs) < 0;
-}
-
-unsigned char String::operator>(const String &rhs) const
-{
- return compareTo(rhs) > 0;
-}
-
-unsigned char String::operator<=(const String &rhs) const
-{
- return compareTo(rhs) <= 0;
-}
-
-unsigned char String::operator>=(const String &rhs) const
-{
- return compareTo(rhs) >= 0;
-}
-
-unsigned char String::equalsIgnoreCase( const String &s2 ) const
-{
- if (this == &s2) return 1;
- if (len != s2.len) return 0;
- if (len == 0) return 1;
- const char *p1 = buffer;
- const char *p2 = s2.buffer;
- while (*p1) {
- if (tolower(*p1++) != tolower(*p2++)) return 0;
- }
- return 1;
-}
-
-unsigned char String::startsWith( const String &s2 ) const
-{
- if (len < s2.len) return 0;
- return startsWith(s2, 0);
-}
-
-unsigned char String::startsWith( const String &s2, unsigned int offset ) const
-{
- if (offset > len - s2.len || !buffer || !s2.buffer) return 0;
- return strncmp( &buffer[offset], s2.buffer, s2.len ) == 0;
-}
-
-unsigned char String::endsWith( const String &s2 ) const
-{
- if ( len < s2.len || !buffer || !s2.buffer) return 0;
- return strcmp(&buffer[len - s2.len], s2.buffer) == 0;
-}
-
-/*********************************************/
-/* Character Access */
-/*********************************************/
-
-char String::charAt(unsigned int loc) const
-{
- return operator[](loc);
-}
-
-void String::setCharAt(unsigned int loc, char c)
-{
- if (loc < len) buffer[loc] = c;
-}
-
-char & String::operator[](unsigned int index)
-{
- static char dummy_writable_char;
- if (index >= len || !buffer) {
- dummy_writable_char = 0;
- return dummy_writable_char;
- }
- return buffer[index];
-}
-
-char String::operator[]( unsigned int index ) const
-{
- if (index >= len || !buffer) return 0;
- return buffer[index];
-}
-
-void String::getBytes(unsigned char *buf, unsigned int bufsize, unsigned int index) const
-{
- if (!bufsize || !buf) return;
- if (index >= len) {
- buf[0] = 0;
- return;
- }
- unsigned int n = bufsize - 1;
- if (n > len - index) n = len - index;
- strncpy((char *)buf, buffer + index, n);
- buf[n] = 0;
-}
-
-/*********************************************/
-/* Search */
-/*********************************************/
-
-int String::indexOf(char c) const
-{
- return indexOf(c, 0);
-}
-
-int String::indexOf( char ch, unsigned int fromIndex ) const
-{
- if (fromIndex >= len) return -1;
- const char* temp = strchr(buffer + fromIndex, ch);
- if (temp == NULL) return -1;
- return temp - buffer;
-}
-
-int String::indexOf(const String &s2) const
-{
- return indexOf(s2, 0);
-}
-
-int String::indexOf(const String &s2, unsigned int fromIndex) const
-{
- if (fromIndex >= len) return -1;
- const char *found = strstr(buffer + fromIndex, s2.buffer);
- if (found == NULL) return -1;
- return found - buffer;
-}
-
-int String::lastIndexOf( char theChar ) const
-{
- return lastIndexOf(theChar, len - 1);
-}
-
-int String::lastIndexOf(char ch, unsigned int fromIndex) const
-{
- if (fromIndex >= len) return -1;
- char tempchar = buffer[fromIndex + 1];
- buffer[fromIndex + 1] = '\0';
- char* temp = strrchr( buffer, ch );
- buffer[fromIndex + 1] = tempchar;
- if (temp == NULL) return -1;
- return temp - buffer;
-}
-
-int String::lastIndexOf(const String &s2) const
-{
- return lastIndexOf(s2, len - s2.len);
-}
-
-int String::lastIndexOf(const String &s2, unsigned int fromIndex) const
-{
- if (s2.len == 0 || len == 0 || s2.len > len) return -1;
- if (fromIndex >= len) fromIndex = len - 1;
- int found = -1;
- for (char *p = buffer; p <= buffer + fromIndex; p++) {
- p = strstr(p, s2.buffer);
- if (!p) break;
- if ((unsigned int)(p - buffer) <= fromIndex) found = p - buffer;
- }
- 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) {
- unsigned int temp = right;
- right = left;
- left = temp;
- }
- String out;
- if (left > len) return out;
- if (right > len) right = len;
- char temp = buffer[right]; // save the replaced character
- buffer[right] = '\0';
- out = buffer + left; // pointer arithmetic
- buffer[right] = temp; //restore character
- return out;
-}
-
-/*********************************************/
-/* Modification */
-/*********************************************/
-
-void String::replace(char find, char replace)
-{
- if (!buffer) return;
- for (char *p = buffer; *p; p++) {
- if (*p == find) *p = replace;
- }
-}
-
-void String::replace(const String& find, const String& replace)
-{
- if (len == 0 || find.len == 0) return;
- int diff = replace.len - find.len;
- char *readFrom = buffer;
- char *foundAt;
- if (diff == 0) {
- while ((foundAt = strstr(readFrom, find.buffer)) != NULL) {
- memcpy(foundAt, replace.buffer, replace.len);
- readFrom = foundAt + replace.len;
- }
- } else if (diff < 0) {
- char *writeTo = buffer;
- while ((foundAt = strstr(readFrom, find.buffer)) != NULL) {
- unsigned int n = foundAt - readFrom;
- memcpy(writeTo, readFrom, n);
- writeTo += n;
- memcpy(writeTo, replace.buffer, replace.len);
- writeTo += replace.len;
- readFrom = foundAt + find.len;
- len += diff;
- }
- strcpy(writeTo, readFrom);
- } else {
- unsigned int size = len; // compute size needed for result
- while ((foundAt = strstr(readFrom, find.buffer)) != NULL) {
- readFrom = foundAt + find.len;
- size += diff;
- }
- if (size == len) return;
- if (size > capacity && !changeBuffer(size)) return; // XXX: tell user!
- int index = len - 1;
- while (index >= 0 && (index = lastIndexOf(find, index)) >= 0) {
- readFrom = buffer + index + find.len;
- memmove(readFrom + diff, readFrom, len - (readFrom - buffer));
- len += diff;
- buffer[len] = 0;
- memcpy(buffer + index, replace.buffer, replace.len);
- index--;
- }
- }
-}
-
-void String::toLowerCase(void)
-{
- if (!buffer) return;
- for (char *p = buffer; *p; p++) {
- *p = tolower(*p);
- }
-}
-
-void String::toUpperCase(void)
-{
- if (!buffer) return;
- for (char *p = buffer; *p; p++) {
- *p = toupper(*p);
- }
-}
-
-void String::trim(void)
-{
- if (!buffer || len == 0) return;
- char *begin = buffer;
- while (isspace(*begin)) begin++;
- char *end = buffer + len - 1;
- while (isspace(*end) && end >= begin) end--;
- len = end + 1 - begin;
- if (begin > buffer) memcpy(buffer, begin, len);
- buffer[len] = 0;
-}
-
-/*********************************************/
-/* Parsing / Conversion */
-/*********************************************/
-
-long String::toInt(void) const
-{
- if (buffer) return atol(buffer);
- return 0;
-}
-
-
diff --git a/cores/robot/WString.h b/cores/robot/WString.h
deleted file mode 100644
index 642b016..0000000
--- a/cores/robot/WString.h
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- WString.h - String library for Wiring & Arduino
- ...mostly rewritten by Paul Stoffregen...
- Copyright (c) 2009-10 Hernando Barragan. All right reserved.
- Copyright 2011, Paul Stoffregen, paul@pjrc.com
-
- 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 String_class_h
-#define String_class_h
-#ifdef __cplusplus
-
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <avr/pgmspace.h>
-
-// When compiling programs with this class, the following gcc parameters
-// dramatically increase performance and memory (RAM) efficiency, typically
-// with little or no increase in code size.
-// -felide-constructors
-// -std=c++0x
-
-class __FlashStringHelper;
-#define F(string_literal) (reinterpret_cast<const __FlashStringHelper *>(PSTR(string_literal)))
-
-// An inherited class for holding the result of a concatenation. These
-// result objects are assumed to be writable by subsequent concatenations.
-class StringSumHelper;
-
-// The string class
-class String
-{
- // use a function pointer to allow for "if (s)" without the
- // complications of an operator bool(). for more information, see:
- // http://www.artima.com/cppsource/safebool.html
- typedef void (String::*StringIfHelperType)() const;
- void StringIfHelper() const {}
-
-public:
- // constructors
- // creates a copy of the initial value.
- // if the initial value is null or invalid, or if memory allocation
- // fails, the string will be marked as invalid (i.e. "if (s)" will
- // be false).
- String(const char *cstr = "");
- String(const String &str);
- #ifdef __GXX_EXPERIMENTAL_CXX0X__
- String(String &&rval);
- String(StringSumHelper &&rval);
- #endif
- explicit String(char c);
- explicit String(unsigned char, unsigned char base=10);
- explicit String(int, unsigned char base=10);
- explicit String(unsigned int, unsigned char base=10);
- explicit String(long, unsigned char base=10);
- explicit String(unsigned long, unsigned char base=10);
- ~String(void);
-
- // memory management
- // return true on success, false on failure (in which case, the string
- // is left unchanged). reserve(0), if successful, will validate an
- // invalid string (i.e., "if (s)" will be true afterwards)
- unsigned char reserve(unsigned int size);
- inline unsigned int length(void) const {return len;}
-
- // creates a copy of the assigned value. if the value is null or
- // invalid, or if the memory allocation fails, the string will be
- // marked as invalid ("if (s)" will be false).
- String & operator = (const String &rhs);
- String & operator = (const char *cstr);
- #ifdef __GXX_EXPERIMENTAL_CXX0X__
- String & operator = (String &&rval);
- String & operator = (StringSumHelper &&rval);
- #endif
-
- // concatenate (works w/ built-in types)
-
- // returns true on success, false on failure (in which case, the string
- // is left unchanged). if the argument is null or invalid, the
- // concatenation is considered unsucessful.
- unsigned char concat(const String &str);
- unsigned char concat(const char *cstr);
- unsigned char concat(char c);
- unsigned char concat(unsigned char c);
- unsigned char concat(int num);
- unsigned char concat(unsigned int num);
- unsigned char concat(long num);
- unsigned char concat(unsigned long num);
-
- // if there's not enough memory for the concatenated value, the string
- // will be left unchanged (but this isn't signalled in any way)
- String & operator += (const String &rhs) {concat(rhs); return (*this);}
- String & operator += (const char *cstr) {concat(cstr); return (*this);}
- String & operator += (char c) {concat(c); return (*this);}
- String & operator += (unsigned char num) {concat(num); return (*this);}
- String & operator += (int num) {concat(num); return (*this);}
- 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);}
-
- friend StringSumHelper & operator + (const StringSumHelper &lhs, const String &rhs);
- friend StringSumHelper & operator + (const StringSumHelper &lhs, const char *cstr);
- friend StringSumHelper & operator + (const StringSumHelper &lhs, char c);
- friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned char num);
- friend StringSumHelper & operator + (const StringSumHelper &lhs, int num);
- friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned int num);
- friend StringSumHelper & operator + (const StringSumHelper &lhs, long num);
- friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned long num);
-
- // comparison (only works w/ Strings and "strings")
- operator StringIfHelperType() const { return buffer ? &String::StringIfHelper : 0; }
- int compareTo(const String &s) const;
- unsigned char equals(const String &s) const;
- unsigned char equals(const char *cstr) const;
- unsigned char operator == (const String &rhs) const {return equals(rhs);}
- unsigned char operator == (const char *cstr) const {return equals(cstr);}
- unsigned char operator != (const String &rhs) const {return !equals(rhs);}
- unsigned char operator != (const char *cstr) const {return !equals(cstr);}
- unsigned char operator < (const String &rhs) const;
- unsigned char operator > (const String &rhs) const;
- unsigned char operator <= (const String &rhs) const;
- unsigned char operator >= (const String &rhs) const;
- unsigned char equalsIgnoreCase(const String &s) const;
- unsigned char startsWith( const String &prefix) const;
- unsigned char startsWith(const String &prefix, unsigned int offset) const;
- unsigned char endsWith(const String &suffix) const;
-
- // character acccess
- char charAt(unsigned int index) const;
- void setCharAt(unsigned int index, char c);
- char operator [] (unsigned int index) const;
- char& operator [] (unsigned int index);
- void getBytes(unsigned char *buf, unsigned int bufsize, unsigned int index=0) const;
- void toCharArray(char *buf, unsigned int bufsize, unsigned int index=0) const
- {getBytes((unsigned char *)buf, bufsize, index);}
- const char * c_str() const { return buffer; }
-
- // search
- int indexOf( char ch ) const;
- int indexOf( char ch, unsigned int fromIndex ) const;
- int indexOf( const String &str ) const;
- int indexOf( const String &str, unsigned int fromIndex ) const;
- int lastIndexOf( char ch ) const;
- 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, unsigned int endIndex ) const;
-
- // modification
- void replace(char find, char replace);
- void replace(const String& find, const String& replace);
- void toLowerCase(void);
- void toUpperCase(void);
- void trim(void);
-
- // parsing/conversion
- long toInt(void) const;
-
-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);
- unsigned char changeBuffer(unsigned int maxStrLen);
- unsigned char concat(const char *cstr, unsigned int length);
-
- // copy and move
- String & copy(const char *cstr, unsigned int length);
- #ifdef __GXX_EXPERIMENTAL_CXX0X__
- void move(String &rhs);
- #endif
-};
-
-class StringSumHelper : public String
-{
-public:
- StringSumHelper(const String &s) : String(s) {}
- StringSumHelper(const char *p) : String(p) {}
- StringSumHelper(char c) : String(c) {}
- StringSumHelper(unsigned char num) : String(num) {}
- StringSumHelper(int num) : String(num) {}
- StringSumHelper(unsigned int num) : String(num) {}
- StringSumHelper(long num) : String(num) {}
- StringSumHelper(unsigned long num) : String(num) {}
-};
-
-#endif // __cplusplus
-#endif // String_class_h
diff --git a/cores/robot/binary.h b/cores/robot/binary.h
deleted file mode 100644
index af14980..0000000
--- a/cores/robot/binary.h
+++ /dev/null
@@ -1,515 +0,0 @@
-#ifndef Binary_h
-#define Binary_h
-
-#define B0 0
-#define B00 0
-#define B000 0
-#define B0000 0
-#define B00000 0
-#define B000000 0
-#define B0000000 0
-#define B00000000 0
-#define B1 1
-#define B01 1
-#define B001 1
-#define B0001 1
-#define B00001 1
-#define B000001 1
-#define B0000001 1
-#define B00000001 1
-#define B10 2
-#define B010 2
-#define B0010 2
-#define B00010 2
-#define B000010 2
-#define B0000010 2
-#define B00000010 2
-#define B11 3
-#define B011 3
-#define B0011 3
-#define B00011 3
-#define B000011 3
-#define B0000011 3
-#define B00000011 3
-#define B100 4
-#define B0100 4
-#define B00100 4
-#define B000100 4
-#define B0000100 4
-#define B00000100 4
-#define B101 5
-#define B0101 5
-#define B00101 5
-#define B000101 5
-#define B0000101 5
-#define B00000101 5
-#define B110 6
-#define B0110 6
-#define B00110 6
-#define B000110 6
-#define B0000110 6
-#define B00000110 6
-#define B111 7
-#define B0111 7
-#define B00111 7
-#define B000111 7
-#define B0000111 7
-#define B00000111 7
-#define B1000 8
-#define B01000 8
-#define B001000 8
-#define B0001000 8
-#define B00001000 8
-#define B1001 9
-#define B01001 9
-#define B001001 9
-#define B0001001 9
-#define B00001001 9
-#define B1010 10
-#define B01010 10
-#define B001010 10
-#define B0001010 10
-#define B00001010 10
-#define B1011 11
-#define B01011 11
-#define B001011 11
-#define B0001011 11
-#define B00001011 11
-#define B1100 12
-#define B01100 12
-#define B001100 12
-#define B0001100 12
-#define B00001100 12
-#define B1101 13
-#define B01101 13
-#define B001101 13
-#define B0001101 13
-#define B00001101 13
-#define B1110 14
-#define B01110 14
-#define B001110 14
-#define B0001110 14
-#define B00001110 14
-#define B1111 15
-#define B01111 15
-#define B001111 15
-#define B0001111 15
-#define B00001111 15
-#define B10000 16
-#define B010000 16
-#define B0010000 16
-#define B00010000 16
-#define B10001 17
-#define B010001 17
-#define B0010001 17
-#define B00010001 17
-#define B10010 18
-#define B010010 18
-#define B0010010 18
-#define B00010010 18
-#define B10011 19
-#define B010011 19
-#define B0010011 19
-#define B00010011 19
-#define B10100 20
-#define B010100 20
-#define B0010100 20
-#define B00010100 20
-#define B10101 21
-#define B010101 21
-#define B0010101 21
-#define B00010101 21
-#define B10110 22
-#define B010110 22
-#define B0010110 22
-#define B00010110 22
-#define B10111 23
-#define B010111 23
-#define B0010111 23
-#define B00010111 23
-#define B11000 24
-#define B011000 24
-#define B0011000 24
-#define B00011000 24
-#define B11001 25
-#define B011001 25
-#define B0011001 25
-#define B00011001 25
-#define B11010 26
-#define B011010 26
-#define B0011010 26
-#define B00011010 26
-#define B11011 27
-#define B011011 27
-#define B0011011 27
-#define B00011011 27
-#define B11100 28
-#define B011100 28
-#define B0011100 28
-#define B00011100 28
-#define B11101 29
-#define B011101 29
-#define B0011101 29
-#define B00011101 29
-#define B11110 30
-#define B011110 30
-#define B0011110 30
-#define B00011110 30
-#define B11111 31
-#define B011111 31
-#define B0011111 31
-#define B00011111 31
-#define B100000 32
-#define B0100000 32
-#define B00100000 32
-#define B100001 33
-#define B0100001 33
-#define B00100001 33
-#define B100010 34
-#define B0100010 34
-#define B00100010 34
-#define B100011 35
-#define B0100011 35
-#define B00100011 35
-#define B100100 36
-#define B0100100 36
-#define B00100100 36
-#define B100101 37
-#define B0100101 37
-#define B00100101 37
-#define B100110 38
-#define B0100110 38
-#define B00100110 38
-#define B100111 39
-#define B0100111 39
-#define B00100111 39
-#define B101000 40
-#define B0101000 40
-#define B00101000 40
-#define B101001 41
-#define B0101001 41
-#define B00101001 41
-#define B101010 42
-#define B0101010 42
-#define B00101010 42
-#define B101011 43
-#define B0101011 43
-#define B00101011 43
-#define B101100 44
-#define B0101100 44
-#define B00101100 44
-#define B101101 45
-#define B0101101 45
-#define B00101101 45
-#define B101110 46
-#define B0101110 46
-#define B00101110 46
-#define B101111 47
-#define B0101111 47
-#define B00101111 47
-#define B110000 48
-#define B0110000 48
-#define B00110000 48
-#define B110001 49
-#define B0110001 49
-#define B00110001 49
-#define B110010 50
-#define B0110010 50
-#define B00110010 50
-#define B110011 51
-#define B0110011 51
-#define B00110011 51
-#define B110100 52
-#define B0110100 52
-#define B00110100 52
-#define B110101 53
-#define B0110101 53
-#define B00110101 53
-#define B110110 54
-#define B0110110 54
-#define B00110110 54
-#define B110111 55
-#define B0110111 55
-#define B00110111 55
-#define B111000 56
-#define B0111000 56
-#define B00111000 56
-#define B111001 57
-#define B0111001 57
-#define B00111001 57
-#define B111010 58
-#define B0111010 58
-#define B00111010 58
-#define B111011 59
-#define B0111011 59
-#define B00111011 59
-#define B111100 60
-#define B0111100 60
-#define B00111100 60
-#define B111101 61
-#define B0111101 61
-#define B00111101 61
-#define B111110 62
-#define B0111110 62
-#define B00111110 62
-#define B111111 63
-#define B0111111 63
-#define B00111111 63
-#define B1000000 64
-#define B01000000 64
-#define B1000001 65
-#define B01000001 65
-#define B1000010 66
-#define B01000010 66
-#define B1000011 67
-#define B01000011 67
-#define B1000100 68
-#define B01000100 68
-#define B1000101 69
-#define B01000101 69
-#define B1000110 70
-#define B01000110 70
-#define B1000111 71
-#define B01000111 71
-#define B1001000 72
-#define B01001000 72
-#define B1001001 73
-#define B01001001 73
-#define B1001010 74
-#define B01001010 74
-#define B1001011 75
-#define B01001011 75
-#define B1001100 76
-#define B01001100 76
-#define B1001101 77
-#define B01001101 77
-#define B1001110 78
-#define B01001110 78
-#define B1001111 79
-#define B01001111 79
-#define B1010000 80
-#define B01010000 80
-#define B1010001 81
-#define B01010001 81
-#define B1010010 82
-#define B01010010 82
-#define B1010011 83
-#define B01010011 83
-#define B1010100 84
-#define B01010100 84
-#define B1010101 85
-#define B01010101 85
-#define B1010110 86
-#define B01010110 86
-#define B1010111 87
-#define B01010111 87
-#define B1011000 88
-#define B01011000 88
-#define B1011001 89
-#define B01011001 89
-#define B1011010 90
-#define B01011010 90
-#define B1011011 91
-#define B01011011 91
-#define B1011100 92
-#define B01011100 92
-#define B1011101 93
-#define B01011101 93
-#define B1011110 94
-#define B01011110 94
-#define B1011111 95
-#define B01011111 95
-#define B1100000 96
-#define B01100000 96
-#define B1100001 97
-#define B01100001 97
-#define B1100010 98
-#define B01100010 98
-#define B1100011 99
-#define B01100011 99
-#define B1100100 100
-#define B01100100 100
-#define B1100101 101
-#define B01100101 101
-#define B1100110 102
-#define B01100110 102
-#define B1100111 103
-#define B01100111 103
-#define B1101000 104
-#define B01101000 104
-#define B1101001 105
-#define B01101001 105
-#define B1101010 106
-#define B01101010 106
-#define B1101011 107
-#define B01101011 107
-#define B1101100 108
-#define B01101100 108
-#define B1101101 109
-#define B01101101 109
-#define B1101110 110
-#define B01101110 110
-#define B1101111 111
-#define B01101111 111
-#define B1110000 112
-#define B01110000 112
-#define B1110001 113
-#define B01110001 113
-#define B1110010 114
-#define B01110010 114
-#define B1110011 115
-#define B01110011 115
-#define B1110100 116
-#define B01110100 116
-#define B1110101 117
-#define B01110101 117
-#define B1110110 118
-#define B01110110 118
-#define B1110111 119
-#define B01110111 119
-#define B1111000 120
-#define B01111000 120
-#define B1111001 121
-#define B01111001 121
-#define B1111010 122
-#define B01111010 122
-#define B1111011 123
-#define B01111011 123
-#define B1111100 124
-#define B01111100 124
-#define B1111101 125
-#define B01111101 125
-#define B1111110 126
-#define B01111110 126
-#define B1111111 127
-#define B01111111 127
-#define B10000000 128
-#define B10000001 129
-#define B10000010 130
-#define B10000011 131
-#define B10000100 132
-#define B10000101 133
-#define B10000110 134
-#define B10000111 135
-#define B10001000 136
-#define B10001001 137
-#define B10001010 138
-#define B10001011 139
-#define B10001100 140
-#define B10001101 141
-#define B10001110 142
-#define B10001111 143
-#define B10010000 144
-#define B10010001 145
-#define B10010010 146
-#define B10010011 147
-#define B10010100 148
-#define B10010101 149
-#define B10010110 150
-#define B10010111 151
-#define B10011000 152
-#define B10011001 153
-#define B10011010 154
-#define B10011011 155
-#define B10011100 156
-#define B10011101 157
-#define B10011110 158
-#define B10011111 159
-#define B10100000 160
-#define B10100001 161
-#define B10100010 162
-#define B10100011 163
-#define B10100100 164
-#define B10100101 165
-#define B10100110 166
-#define B10100111 167
-#define B10101000 168
-#define B10101001 169
-#define B10101010 170
-#define B10101011 171
-#define B10101100 172
-#define B10101101 173
-#define B10101110 174
-#define B10101111 175
-#define B10110000 176
-#define B10110001 177
-#define B10110010 178
-#define B10110011 179
-#define B10110100 180
-#define B10110101 181
-#define B10110110 182
-#define B10110111 183
-#define B10111000 184
-#define B10111001 185
-#define B10111010 186
-#define B10111011 187
-#define B10111100 188
-#define B10111101 189
-#define B10111110 190
-#define B10111111 191
-#define B11000000 192
-#define B11000001 193
-#define B11000010 194
-#define B11000011 195
-#define B11000100 196
-#define B11000101 197
-#define B11000110 198
-#define B11000111 199
-#define B11001000 200
-#define B11001001 201
-#define B11001010 202
-#define B11001011 203
-#define B11001100 204
-#define B11001101 205
-#define B11001110 206
-#define B11001111 207
-#define B11010000 208
-#define B11010001 209
-#define B11010010 210
-#define B11010011 211
-#define B11010100 212
-#define B11010101 213
-#define B11010110 214
-#define B11010111 215
-#define B11011000 216
-#define B11011001 217
-#define B11011010 218
-#define B11011011 219
-#define B11011100 220
-#define B11011101 221
-#define B11011110 222
-#define B11011111 223
-#define B11100000 224
-#define B11100001 225
-#define B11100010 226
-#define B11100011 227
-#define B11100100 228
-#define B11100101 229
-#define B11100110 230
-#define B11100111 231
-#define B11101000 232
-#define B11101001 233
-#define B11101010 234
-#define B11101011 235
-#define B11101100 236
-#define B11101101 237
-#define B11101110 238
-#define B11101111 239
-#define B11110000 240
-#define B11110001 241
-#define B11110010 242
-#define B11110011 243
-#define B11110100 244
-#define B11110101 245
-#define B11110110 246
-#define B11110111 247
-#define B11111000 248
-#define B11111001 249
-#define B11111010 250
-#define B11111011 251
-#define B11111100 252
-#define B11111101 253
-#define B11111110 254
-#define B11111111 255
-
-#endif
diff --git a/cores/robot/main.cpp b/cores/robot/main.cpp
deleted file mode 100644
index 3d4e079..0000000
--- a/cores/robot/main.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-#include <Arduino.h>
-
-int main(void)
-{
- init();
-
-#if defined(USBCON)
- USBDevice.attach();
-#endif
-
- setup();
-
- for (;;) {
- loop();
- if (serialEventRun) serialEventRun();
- }
-
- return 0;
-}
-
diff --git a/cores/robot/new.cpp b/cores/robot/new.cpp
deleted file mode 100644
index b81031e..0000000
--- a/cores/robot/new.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-#include <new.h>
-
-void * operator new(size_t size)
-{
- return malloc(size);
-}
-
-void * operator new[](size_t size)
-{
- return malloc(size);
-}
-
-void operator delete(void * ptr)
-{
- free(ptr);
-}
-
-void operator delete[](void * ptr)
-{
- free(ptr);
-}
-
-int __cxa_guard_acquire(__guard *g) {return !*(char *)(g);};
-void __cxa_guard_release (__guard *g) {*(char *)g = 1;};
-void __cxa_guard_abort (__guard *) {};
-
-void __cxa_pure_virtual(void) {};
-
diff --git a/cores/robot/new.h b/cores/robot/new.h
deleted file mode 100644
index 991c86c..0000000
--- a/cores/robot/new.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/* Header to define new/delete operators as they aren't provided by avr-gcc by default
- Taken from http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=59453
- */
-
-#ifndef NEW_H
-#define NEW_H
-
-#include <stdlib.h>
-
-void * operator new(size_t size);
-void * operator new[](size_t size);
-void operator delete(void * ptr);
-void operator delete[](void * ptr);
-
-__extension__ typedef int __guard __attribute__((mode (__DI__)));
-
-extern "C" int __cxa_guard_acquire(__guard *);
-extern "C" void __cxa_guard_release (__guard *);
-extern "C" void __cxa_guard_abort (__guard *);
-
-extern "C" void __cxa_pure_virtual(void);
-
-#endif
-
diff --git a/cores/robot/wiring.c b/cores/robot/wiring.c
deleted file mode 100644
index a3c4390..0000000
--- a/cores/robot/wiring.c
+++ /dev/null
@@ -1,324 +0,0 @@
-/*
- wiring.c - Partial implementation of the Wiring API for the ATmega8.
- Part of Arduino - http://www.arduino.cc/
-
- Copyright (c) 2005-2006 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$
-*/
-
-#include "wiring_private.h"
-
-// the prescaler is set so that timer0 ticks every 64 clock cycles, and the
-// the overflow handler is called every 256 ticks.
-#define MICROSECONDS_PER_TIMER0_OVERFLOW (clockCyclesToMicroseconds(64 * 256))
-
-// the whole number of milliseconds per timer0 overflow
-#define MILLIS_INC (MICROSECONDS_PER_TIMER0_OVERFLOW / 1000)
-
-// the fractional number of milliseconds per timer0 overflow. we shift right
-// by three to fit these numbers into a byte. (for the clock speeds we care
-// about - 8 and 16 MHz - this doesn't lose precision.)
-#define FRACT_INC ((MICROSECONDS_PER_TIMER0_OVERFLOW % 1000) >> 3)
-#define FRACT_MAX (1000 >> 3)
-
-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__)
-ISR(TIM0_OVF_vect)
-#else
-ISR(TIMER0_OVF_vect)
-#endif
-{
- // copy these to local variables so they can be stored in registers
- // (volatile variables must be read from memory on every access)
- unsigned long m = timer0_millis;
- unsigned char f = timer0_fract;
-
- m += MILLIS_INC;
- f += FRACT_INC;
- if (f >= FRACT_MAX) {
- f -= FRACT_MAX;
- m += 1;
- }
-
- timer0_fract = f;
- timer0_millis = m;
- timer0_overflow_count++;
-}
-
-unsigned long millis()
-{
- unsigned long m;
- uint8_t oldSREG = SREG;
-
- // disable interrupts while we read timer0_millis or we might get an
- // inconsistent value (e.g. in the middle of a write to timer0_millis)
- cli();
- m = timer0_millis;
- SREG = oldSREG;
-
- return m;
-}
-
-unsigned long micros() {
- unsigned long m;
- uint8_t oldSREG = SREG, t;
-
- cli();
- m = timer0_overflow_count;
-#if defined(TCNT0)
- t = TCNT0;
-#elif defined(TCNT0L)
- t = TCNT0L;
-#else
- #error TIMER 0 not defined
-#endif
-
-
-#ifdef TIFR0
- if ((TIFR0 & _BV(TOV0)) && (t < 255))
- m++;
-#else
- if ((TIFR & _BV(TOV0)) && (t < 255))
- m++;
-#endif
-
- SREG = oldSREG;
-
- return ((m << 8) + t) * (64 / clockCyclesPerMicrosecond());
-}
-
-void delay(unsigned long ms)
-{
- uint16_t start = (uint16_t)micros();
-
- while (ms > 0) {
- if (((uint16_t)micros() - start) >= 1000) {
- ms--;
- start += 1000;
- }
- }
-}
-
-/* Delay for the given number of microseconds. Assumes a 8 or 16 MHz clock. */
-void delayMicroseconds(unsigned int us)
-{
- // calling avrlib's delay_us() function with low values (e.g. 1 or
- // 2 microseconds) gives delays longer than desired.
- //delay_us(us);
-#if F_CPU >= 20000000L
- // for the 20 MHz clock on rare Arduino boards
-
- // for a one-microsecond delay, simply wait 2 cycle and return. The overhead
- // of the function call yields a delay of exactly a one microsecond.
- __asm__ __volatile__ (
- "nop" "\n\t"
- "nop"); //just waiting 2 cycle
- if (--us == 0)
- return;
-
- // the following loop takes a 1/5 of a microsecond (4 cycles)
- // per iteration, so execute it five times for each microsecond of
- // delay requested.
- us = (us<<2) + us; // x5 us
-
- // account for the time taken in the preceeding commands.
- us -= 2;
-
-#elif F_CPU >= 16000000L
- // for the 16 MHz clock on most Arduino boards
-
- // for a one-microsecond delay, simply return. the overhead
- // of the function call yields a delay of approximately 1 1/8 us.
- if (--us == 0)
- return;
-
- // the following loop takes a quarter of a microsecond (4 cycles)
- // per iteration, so execute it four times for each microsecond of
- // delay requested.
- us <<= 2;
-
- // account for the time taken in the preceeding commands.
- us -= 2;
-#else
- // for the 8 MHz internal clock on the ATmega168
-
- // for a one- or two-microsecond delay, simply return. the overhead of
- // the function calls takes more than two microseconds. can't just
- // subtract two, since us is unsigned; we'd overflow.
- if (--us == 0)
- return;
- if (--us == 0)
- return;
-
- // the following loop takes half of a microsecond (4 cycles)
- // per iteration, so execute it twice for each microsecond of
- // delay requested.
- us <<= 1;
-
- // partially compensate for the time taken by the preceeding commands.
- // we can't subtract any more than this or we'd overflow w/ small delays.
- us--;
-#endif
-
- // busy wait
- __asm__ __volatile__ (
- "1: sbiw %0,1" "\n\t" // 2 cycles
- "brne 1b" : "=w" (us) : "0" (us) // 2 cycles
- );
-}
-
-void init()
-{
- // this needs to be called before setup() or some functions won't
- // work there
- sei();
-
- // on the ATmega168, timer 0 is also used for fast hardware pwm
- // (using phase-correct PWM would mean that timer 0 overflowed half as often
- // resulting in different millis() behavior on the ATmega8 and ATmega168)
-#if defined(TCCR0A) && defined(WGM01)
- sbi(TCCR0A, WGM01);
- sbi(TCCR0A, WGM00);
-#endif
-
- // set timer 0 prescale factor to 64
-#if defined(__AVR_ATmega128__)
- // CPU specific: different values for the ATmega128
- sbi(TCCR0, CS02);
-#elif defined(TCCR0) && defined(CS01) && defined(CS00)
- // this combination is for the standard atmega8
- sbi(TCCR0, CS01);
- sbi(TCCR0, CS00);
-#elif defined(TCCR0B) && defined(CS01) && defined(CS00)
- // this combination is for the standard 168/328/1280/2560
- sbi(TCCR0B, CS01);
- sbi(TCCR0B, CS00);
-#elif defined(TCCR0A) && defined(CS01) && defined(CS00)
- // this combination is for the __AVR_ATmega645__ series
- sbi(TCCR0A, CS01);
- sbi(TCCR0A, CS00);
-#else
- #error Timer 0 prescale factor 64 not set correctly
-#endif
-
- // enable timer 0 overflow interrupt
-#if defined(TIMSK) && defined(TOIE0)
- sbi(TIMSK, TOIE0);
-#elif defined(TIMSK0) && defined(TOIE0)
- sbi(TIMSK0, TOIE0);
-#else
- #error Timer 0 overflow interrupt not set correctly
-#endif
-
- // timers 1 and 2 are used for phase-correct hardware pwm
- // this is better for motors as it ensures an even waveform
- // note, however, that fast pwm mode can achieve a frequency of up
- // 8 MHz (with a 16 MHz clock) at 50% duty cycle
-
-#if defined(TCCR1B) && defined(CS11) && defined(CS10)
- TCCR1B = 0;
-
- // set timer 1 prescale factor to 64
- sbi(TCCR1B, CS11);
-#if F_CPU >= 8000000L
- sbi(TCCR1B, CS10);
-#endif
-#elif defined(TCCR1) && defined(CS11) && defined(CS10)
- sbi(TCCR1, CS11);
-#if F_CPU >= 8000000L
- sbi(TCCR1, CS10);
-#endif
-#endif
- // put timer 1 in 8-bit phase correct pwm mode
-#if defined(TCCR1A) && defined(WGM10)
- sbi(TCCR1A, WGM10);
-#elif defined(TCCR1)
- #warning this needs to be finished
-#endif
-
- // set timer 2 prescale factor to 64
-#if defined(TCCR2) && defined(CS22)
- sbi(TCCR2, CS22);
-#elif defined(TCCR2B) && defined(CS22)
- sbi(TCCR2B, CS22);
-#else
- #warning Timer 2 not finished (may not be present on this CPU)
-#endif
-
- // configure timer 2 for phase correct pwm (8-bit)
-#if defined(TCCR2) && defined(WGM20)
- sbi(TCCR2, WGM20);
-#elif defined(TCCR2A) && defined(WGM20)
- sbi(TCCR2A, WGM20);
-#else
- #warning Timer 2 not finished (may not be present on this CPU)
-#endif
-
-#if defined(TCCR3B) && defined(CS31) && defined(WGM30)
- sbi(TCCR3B, CS31); // set timer 3 prescale factor to 64
- sbi(TCCR3B, CS30);
- sbi(TCCR3A, WGM30); // put timer 3 in 8-bit phase correct pwm mode
-#endif
-
-#if defined(TCCR4A) && defined(TCCR4B) && defined(TCCR4D) /* beginning of timer4 block for 32U4 and similar */
- sbi(TCCR4B, CS42); // set timer4 prescale factor to 64
- sbi(TCCR4B, CS41);
- sbi(TCCR4B, CS40);
- sbi(TCCR4D, WGM40); // put timer 4 in phase- and frequency-correct PWM mode
- sbi(TCCR4A, PWM4A); // enable PWM mode for comparator OCR4A
- sbi(TCCR4C, PWM4D); // enable PWM mode for comparator OCR4D
-#else /* beginning of timer4 block for ATMEGA1280 and ATMEGA2560 */
-#if defined(TCCR4B) && defined(CS41) && defined(WGM40)
- sbi(TCCR4B, CS41); // set timer 4 prescale factor to 64
- sbi(TCCR4B, CS40);
- sbi(TCCR4A, WGM40); // put timer 4 in 8-bit phase correct pwm mode
-#endif
-#endif /* end timer4 block for ATMEGA1280/2560 and similar */
-
-#if defined(TCCR5B) && defined(CS51) && defined(WGM50)
- sbi(TCCR5B, CS51); // set timer 5 prescale factor to 64
- sbi(TCCR5B, CS50);
- sbi(TCCR5A, WGM50); // put timer 5 in 8-bit phase correct pwm mode
-#endif
-
-#if defined(ADCSRA)
- // set a2d prescale factor to 128
- // 16 MHz / 128 = 125 KHz, inside the desired 50-200 KHz range.
- // XXX: this will not work properly for other clock speeds, and
- // this code should use F_CPU to determine the prescale factor.
- sbi(ADCSRA, ADPS2);
- sbi(ADCSRA, ADPS1);
- sbi(ADCSRA, ADPS0);
-
- // enable a2d conversions
- sbi(ADCSRA, ADEN);
-#endif
-
- // the bootloader connects pins 0 and 1 to the USART; disconnect them
- // here so they can be used as normal digital i/o; they will be
- // reconnected in Serial.begin()
-#if defined(UCSRB)
- UCSRB = 0;
-#elif defined(UCSR0B)
- UCSR0B = 0;
-#endif
-}
diff --git a/cores/robot/wiring_analog.c b/cores/robot/wiring_analog.c
deleted file mode 100644
index 7ed0e4e..0000000
--- a/cores/robot/wiring_analog.c
+++ /dev/null
@@ -1,284 +0,0 @@
-/*
- wiring_analog.c - analog input and output
- Part of Arduino - http://www.arduino.cc/
-
- Copyright (c) 2005-2006 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
-
- Modified 28 September 2010 by Mark Sproul
-
- $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $
-*/
-
-#include "wiring_private.h"
-#include "pins_arduino.h"
-
-uint8_t analog_reference = DEFAULT;
-
-void analogReference(uint8_t mode)
-{
- // can't actually set the register here because the default setting
- // will connect AVCC and the AREF pin, which would cause a short if
- // there's something connected to AREF.
- analog_reference = mode;
-}
-
-int analogRead(uint8_t pin)
-{
- uint8_t low, high;
-
-#if 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)
- // 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);
-#endif
-
- // set the analog reference (high two bits of ADMUX) and select the
- // channel (low 4 bits). this also sets ADLAR (left-adjust result)
- // to 0 (the default).
-#if defined(ADMUX)
- ADMUX = (analog_reference << 6) | (pin & 0x07);
-#endif
-
- // without a delay, we seem to read from the wrong channel
- //delay(1);
-
-#if defined(ADCSRA) && defined(ADCL)
- // start the conversion
- sbi(ADCSRA, ADSC);
-
- // ADSC is cleared when the conversion finishes
- while (bit_is_set(ADCSRA, ADSC));
-
- // we have to read ADCL first; doing so locks both ADCL
- // and ADCH until ADCH is read. reading ADCL second would
- // cause the results of each conversion to be discarded,
- // as ADCL and ADCH would be locked when it completed.
- low = ADCL;
- high = ADCH;
-#else
- // we dont have an ADC, return 0
- low = 0;
- high = 0;
-#endif
-
- // combine the two bytes
- return (high << 8) | low;
-}
-
-// Right now, PWM output only works on the pins with
-// hardware support. These are defined in the appropriate
-// pins_*.c file. For the rest of the pins, we default
-// to digital output.
-void analogWrite(uint8_t pin, int val)
-{
- // We need to make sure the PWM output is enabled for those pins
- // that support it, as we turn it off when digitally reading or
- // writing with them. Also, make sure the pin is in output mode
- // for consistenty with Wiring, which doesn't require a pinMode
- // call for the analog output pins.
- pinMode(pin, OUTPUT);
- if (val == 0)
- {
- digitalWrite(pin, LOW);
- }
- else if (val == 255)
- {
- digitalWrite(pin, HIGH);
- }
- else
- {
- switch(digitalPinToTimer(pin))
- {
- // XXX fix needed for atmega8
- #if defined(TCCR0) && defined(COM00) && !defined(__AVR_ATmega8__)
- case TIMER0A:
- // connect pwm to pin on timer 0
- sbi(TCCR0, COM00);
- OCR0 = val; // set pwm duty
- break;
- #endif
-
- #if defined(TCCR0A) && defined(COM0A1)
- case TIMER0A:
- // connect pwm to pin on timer 0, channel A
- sbi(TCCR0A, COM0A1);
- OCR0A = val; // set pwm duty
- break;
- #endif
-
- #if defined(TCCR0A) && defined(COM0B1)
- case TIMER0B:
- // connect pwm to pin on timer 0, channel B
- sbi(TCCR0A, COM0B1);
- OCR0B = val; // set pwm duty
- break;
- #endif
-
- #if defined(TCCR1A) && defined(COM1A1)
- case TIMER1A:
- // connect pwm to pin on timer 1, channel A
- sbi(TCCR1A, COM1A1);
- OCR1A = val; // set pwm duty
- break;
- #endif
-
- #if defined(TCCR1A) && defined(COM1B1)
- case TIMER1B:
- // connect pwm to pin on timer 1, channel B
- sbi(TCCR1A, COM1B1);
- OCR1B = val; // set pwm duty
- break;
- #endif
-
- #if defined(TCCR2) && defined(COM21)
- case TIMER2:
- // connect pwm to pin on timer 2
- sbi(TCCR2, COM21);
- OCR2 = val; // set pwm duty
- break;
- #endif
-
- #if defined(TCCR2A) && defined(COM2A1)
- case TIMER2A:
- // connect pwm to pin on timer 2, channel A
- sbi(TCCR2A, COM2A1);
- OCR2A = val; // set pwm duty
- break;
- #endif
-
- #if defined(TCCR2A) && defined(COM2B1)
- case TIMER2B:
- // connect pwm to pin on timer 2, channel B
- sbi(TCCR2A, COM2B1);
- OCR2B = val; // set pwm duty
- break;
- #endif
-
- #if defined(TCCR3A) && defined(COM3A1)
- case TIMER3A:
- // connect pwm to pin on timer 3, channel A
- sbi(TCCR3A, COM3A1);
- OCR3A = val; // set pwm duty
- break;
- #endif
-
- #if defined(TCCR3A) && defined(COM3B1)
- case TIMER3B:
- // connect pwm to pin on timer 3, channel B
- sbi(TCCR3A, COM3B1);
- OCR3B = val; // set pwm duty
- break;
- #endif
-
- #if defined(TCCR3A) && defined(COM3C1)
- case TIMER3C:
- // connect pwm to pin on timer 3, channel C
- sbi(TCCR3A, COM3C1);
- OCR3C = val; // set pwm duty
- break;
- #endif
-
- #if defined(TCCR4A)
- case TIMER4A:
- //connect pwm to pin on timer 4, channel A
- sbi(TCCR4A, COM4A1);
- #if defined(COM4A0) // only used on 32U4
- cbi(TCCR4A, COM4A0);
- #endif
- OCR4A = val; // set pwm duty
- break;
- #endif
-
- #if defined(TCCR4A) && defined(COM4B1)
- case TIMER4B:
- // connect pwm to pin on timer 4, channel B
- sbi(TCCR4A, COM4B1);
- OCR4B = val; // set pwm duty
- break;
- #endif
-
- #if defined(TCCR4A) && defined(COM4C1)
- case TIMER4C:
- // connect pwm to pin on timer 4, channel C
- sbi(TCCR4A, COM4C1);
- OCR4C = val; // set pwm duty
- break;
- #endif
-
- #if defined(TCCR4C) && defined(COM4D1)
- case TIMER4D:
- // connect pwm to pin on timer 4, channel D
- sbi(TCCR4C, COM4D1);
- #if defined(COM4D0) // only used on 32U4
- cbi(TCCR4C, COM4D0);
- #endif
- OCR4D = val; // set pwm duty
- break;
- #endif
-
-
- #if defined(TCCR5A) && defined(COM5A1)
- case TIMER5A:
- // connect pwm to pin on timer 5, channel A
- sbi(TCCR5A, COM5A1);
- OCR5A = val; // set pwm duty
- break;
- #endif
-
- #if defined(TCCR5A) && defined(COM5B1)
- case TIMER5B:
- // connect pwm to pin on timer 5, channel B
- sbi(TCCR5A, COM5B1);
- OCR5B = val; // set pwm duty
- break;
- #endif
-
- #if defined(TCCR5A) && defined(COM5C1)
- case TIMER5C:
- // connect pwm to pin on timer 5, channel C
- sbi(TCCR5A, COM5C1);
- OCR5C = val; // set pwm duty
- break;
- #endif
-
- case NOT_ON_TIMER:
- default:
- if (val < 128) {
- digitalWrite(pin, LOW);
- } else {
- digitalWrite(pin, HIGH);
- }
- }
- }
-}
-
diff --git a/cores/robot/wiring_digital.c b/cores/robot/wiring_digital.c
deleted file mode 100644
index be323b1..0000000
--- a/cores/robot/wiring_digital.c
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- wiring_digital.c - digital input and output functions
- Part of Arduino - http://www.arduino.cc/
-
- Copyright (c) 2005-2006 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
-
- Modified 28 September 2010 by Mark Sproul
-
- $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $
-*/
-
-#define ARDUINO_MAIN
-#include "wiring_private.h"
-#include "pins_arduino.h"
-
-void pinMode(uint8_t pin, uint8_t mode)
-{
- uint8_t bit = digitalPinToBitMask(pin);
- uint8_t port = digitalPinToPort(pin);
- volatile uint8_t *reg, *out;
-
- if (port == NOT_A_PIN) return;
-
- // JWS: can I let the optimizer do this?
- reg = portModeRegister(port);
- out = portOutputRegister(port);
-
- if (mode == INPUT) {
- uint8_t oldSREG = SREG;
- cli();
- *reg &= ~bit;
- *out &= ~bit;
- SREG = oldSREG;
- } else if (mode == INPUT_PULLUP) {
- uint8_t oldSREG = SREG;
- cli();
- *reg &= ~bit;
- *out |= bit;
- SREG = oldSREG;
- } else {
- uint8_t oldSREG = SREG;
- cli();
- *reg |= bit;
- SREG = oldSREG;
- }
-}
-
-// Forcing this inline keeps the callers from having to push their own stuff
-// on the stack. It is a good performance win and only takes 1 more byte per
-// user than calling. (It will take more bytes on the 168.)
-//
-// But shouldn't this be moved into pinMode? Seems silly to check and do on
-// each digitalread or write.
-//
-// Mark Sproul:
-// - Removed inline. Save 170 bytes on atmega1280
-// - changed to a switch statment; added 32 bytes but much easier to read and maintain.
-// - Added more #ifdefs, now compiles for atmega645
-//
-//static inline void turnOffPWM(uint8_t timer) __attribute__ ((always_inline));
-//static inline void turnOffPWM(uint8_t timer)
-static void turnOffPWM(uint8_t timer)
-{
- switch (timer)
- {
- #if defined(TCCR1A) && defined(COM1A1)
- case TIMER1A: cbi(TCCR1A, COM1A1); break;
- #endif
- #if defined(TCCR1A) && defined(COM1B1)
- case TIMER1B: cbi(TCCR1A, COM1B1); break;
- #endif
-
- #if defined(TCCR2) && defined(COM21)
- case TIMER2: cbi(TCCR2, COM21); break;
- #endif
-
- #if defined(TCCR0A) && defined(COM0A1)
- case TIMER0A: cbi(TCCR0A, COM0A1); break;
- #endif
-
- #if defined(TIMER0B) && defined(COM0B1)
- case TIMER0B: cbi(TCCR0A, COM0B1); break;
- #endif
- #if defined(TCCR2A) && defined(COM2A1)
- case TIMER2A: cbi(TCCR2A, COM2A1); break;
- #endif
- #if defined(TCCR2A) && defined(COM2B1)
- case TIMER2B: cbi(TCCR2A, COM2B1); break;
- #endif
-
- #if defined(TCCR3A) && defined(COM3A1)
- case TIMER3A: cbi(TCCR3A, COM3A1); break;
- #endif
- #if defined(TCCR3A) && defined(COM3B1)
- case TIMER3B: cbi(TCCR3A, COM3B1); break;
- #endif
- #if defined(TCCR3A) && defined(COM3C1)
- case TIMER3C: cbi(TCCR3A, COM3C1); break;
- #endif
-
- #if defined(TCCR4A) && defined(COM4A1)
- case TIMER4A: cbi(TCCR4A, COM4A1); break;
- #endif
- #if defined(TCCR4A) && defined(COM4B1)
- case TIMER4B: cbi(TCCR4A, COM4B1); break;
- #endif
- #if defined(TCCR4A) && defined(COM4C1)
- case TIMER4C: cbi(TCCR4A, COM4C1); break;
- #endif
- #if defined(TCCR4C) && defined(COM4D1)
- case TIMER4D: cbi(TCCR4C, COM4D1); break;
- #endif
-
- #if defined(TCCR5A)
- case TIMER5A: cbi(TCCR5A, COM5A1); break;
- case TIMER5B: cbi(TCCR5A, COM5B1); break;
- case TIMER5C: cbi(TCCR5A, COM5C1); break;
- #endif
- }
-}
-
-void digitalWrite(uint8_t pin, uint8_t val)
-{
- uint8_t timer = digitalPinToTimer(pin);
- uint8_t bit = digitalPinToBitMask(pin);
- uint8_t port = digitalPinToPort(pin);
- volatile uint8_t *out;
-
- if (port == NOT_A_PIN) return;
-
- // If the pin that support PWM output, we need to turn it off
- // before doing a digital write.
- if (timer != NOT_ON_TIMER) turnOffPWM(timer);
-
- out = portOutputRegister(port);
-
- uint8_t oldSREG = SREG;
- cli();
-
- if (val == LOW) {
- *out &= ~bit;
- } else {
- *out |= bit;
- }
-
- SREG = oldSREG;
-}
-
-int digitalRead(uint8_t pin)
-{
- uint8_t timer = digitalPinToTimer(pin);
- uint8_t bit = digitalPinToBitMask(pin);
- uint8_t port = digitalPinToPort(pin);
-
- if (port == NOT_A_PIN) return LOW;
-
- // If the pin that support PWM output, we need to turn it off
- // before getting a digital reading.
- if (timer != NOT_ON_TIMER) turnOffPWM(timer);
-
- if (*portInputRegister(port) & bit) return HIGH;
- return LOW;
-}
diff --git a/cores/robot/wiring_private.h b/cores/robot/wiring_private.h
deleted file mode 100755
index c366005..0000000
--- a/cores/robot/wiring_private.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- wiring_private.h - Internal header file.
- Part of Arduino - http://www.arduino.cc/
-
- Copyright (c) 2005-2006 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 239 2007-01-12 17:58:39Z mellis $
-*/
-
-#ifndef WiringPrivate_h
-#define WiringPrivate_h
-
-#include <avr/io.h>
-#include <avr/interrupt.h>
-#include <stdio.h>
-#include <stdarg.h>
-
-#include "Arduino.h"
-
-#ifdef __cplusplus
-extern "C"{
-#endif
-
-#ifndef cbi
-#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
-#endif
-#ifndef sbi
-#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
-#endif
-
-#define EXTERNAL_INT_0 0
-#define EXTERNAL_INT_1 1
-#define EXTERNAL_INT_2 2
-#define EXTERNAL_INT_3 3
-#define EXTERNAL_INT_4 4
-#define EXTERNAL_INT_5 5
-#define EXTERNAL_INT_6 6
-#define EXTERNAL_INT_7 7
-
-#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
-#define EXTERNAL_NUM_INTERRUPTS 8
-#elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__)
-#define EXTERNAL_NUM_INTERRUPTS 3
-#elif defined(__AVR_ATmega32U4__)
-#define EXTERNAL_NUM_INTERRUPTS 5
-#else
-#define EXTERNAL_NUM_INTERRUPTS 2
-#endif
-
-typedef void (*voidFuncPtr)(void);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif
diff --git a/cores/robot/wiring_pulse.c b/cores/robot/wiring_pulse.c
deleted file mode 100755
index 0d96886..0000000
--- a/cores/robot/wiring_pulse.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- wiring_pulse.c - pulseIn() function
- Part of Arduino - http://www.arduino.cc/
-
- Copyright (c) 2005-2006 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.c 248 2007-02-03 15:36:30Z mellis $
-*/
-
-#include "wiring_private.h"
-#include "pins_arduino.h"
-
-/* Measures the length (in microseconds) of a pulse on the pin; state is HIGH
- * or LOW, the type of pulse to measure. Works on pulses from 2-3 microseconds
- * to 3 minutes in length, but must be called at least a few dozen microseconds
- * before the start of the pulse. */
-unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout)
-{
- // cache the port and bit of the pin in order to speed up the
- // pulse width measuring loop and achieve finer resolution. calling
- // digitalRead() instead yields much coarser resolution.
- uint8_t bit = digitalPinToBitMask(pin);
- uint8_t port = digitalPinToPort(pin);
- uint8_t stateMask = (state ? bit : 0);
- unsigned long width = 0; // keep initialization out of time critical area
-
- // convert the timeout from microseconds to a number of times through
- // the initial loop; it takes 16 clock cycles per iteration.
- unsigned long numloops = 0;
- unsigned long maxloops = microsecondsToClockCycles(timeout) / 16;
-
- // wait for any previous pulse to end
- while ((*portInputRegister(port) & bit) == stateMask)
- if (numloops++ == maxloops)
- return 0;
-
- // wait for the pulse to start
- while ((*portInputRegister(port) & bit) != stateMask)
- if (numloops++ == maxloops)
- return 0;
-
- // wait for the pulse to stop
- while ((*portInputRegister(port) & bit) == stateMask) {
- if (numloops++ == maxloops)
- return 0;
- width++;
- }
-
- // convert the reading to microseconds. The loop has been determined
- // to be 20 clock cycles long and have about 16 clocks between the edge
- // and the start of the loop. There will be some error introduced by
- // the interrupt handlers.
- return clockCyclesToMicroseconds(width * 21 + 16);
-}
diff --git a/cores/robot/wiring_shift.c b/cores/robot/wiring_shift.c
deleted file mode 100755
index cfe7867..0000000
--- a/cores/robot/wiring_shift.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- wiring_shift.c - shiftOut() function
- Part of Arduino - http://www.arduino.cc/
-
- Copyright (c) 2005-2006 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.c 248 2007-02-03 15:36:30Z mellis $
-*/
-
-#include "wiring_private.h"
-
-uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder) {
- uint8_t value = 0;
- uint8_t i;
-
- for (i = 0; i < 8; ++i) {
- digitalWrite(clockPin, HIGH);
- if (bitOrder == LSBFIRST)
- value |= digitalRead(dataPin) << i;
- else
- value |= digitalRead(dataPin) << (7 - i);
- digitalWrite(clockPin, LOW);
- }
- return value;
-}
-
-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))));
-
- digitalWrite(clockPin, HIGH);
- digitalWrite(clockPin, LOW);
- }
-}
diff --git a/firmwares/atmegaxxu2/arduino-usbdfu/Arduino-usbdfu.c b/firmwares/atmegaxxu2/arduino-usbdfu/Arduino-usbdfu.c
index 7bed831..7bed831 100755..100644
--- a/firmwares/atmegaxxu2/arduino-usbdfu/Arduino-usbdfu.c
+++ b/firmwares/atmegaxxu2/arduino-usbdfu/Arduino-usbdfu.c
diff --git a/firmwares/atmegaxxu2/arduino-usbdfu/Arduino-usbdfu.h b/firmwares/atmegaxxu2/arduino-usbdfu/Arduino-usbdfu.h
index 4fb236e..4fb236e 100755..100644
--- a/firmwares/atmegaxxu2/arduino-usbdfu/Arduino-usbdfu.h
+++ b/firmwares/atmegaxxu2/arduino-usbdfu/Arduino-usbdfu.h
diff --git a/firmwares/atmegaxxu2/arduino-usbdfu/Board/LEDs.h b/firmwares/atmegaxxu2/arduino-usbdfu/Board/LEDs.h
index 152e8f5..152e8f5 100755..100644
--- a/firmwares/atmegaxxu2/arduino-usbdfu/Board/LEDs.h
+++ b/firmwares/atmegaxxu2/arduino-usbdfu/Board/LEDs.h
diff --git a/firmwares/atmegaxxu2/arduino-usbdfu/Descriptors.c b/firmwares/atmegaxxu2/arduino-usbdfu/Descriptors.c
index 4deaa06..4deaa06 100755..100644
--- a/firmwares/atmegaxxu2/arduino-usbdfu/Descriptors.c
+++ b/firmwares/atmegaxxu2/arduino-usbdfu/Descriptors.c
diff --git a/firmwares/atmegaxxu2/arduino-usbdfu/Descriptors.h b/firmwares/atmegaxxu2/arduino-usbdfu/Descriptors.h
index 6c93f20..6c93f20 100755..100644
--- a/firmwares/atmegaxxu2/arduino-usbdfu/Descriptors.h
+++ b/firmwares/atmegaxxu2/arduino-usbdfu/Descriptors.h
diff --git a/firmwares/atmegaxxu2/arduino-usbdfu/makefile b/firmwares/atmegaxxu2/arduino-usbdfu/makefile
index 1fb4ed3..1fb4ed3 100755..100644
--- a/firmwares/atmegaxxu2/arduino-usbdfu/makefile
+++ b/firmwares/atmegaxxu2/arduino-usbdfu/makefile
diff --git a/firmwares/atmegaxxu2/arduino-usbserial/Arduino-usbserial.c b/firmwares/atmegaxxu2/arduino-usbserial/Arduino-usbserial.c
index 4de73c8..4de73c8 100755..100644
--- a/firmwares/atmegaxxu2/arduino-usbserial/Arduino-usbserial.c
+++ b/firmwares/atmegaxxu2/arduino-usbserial/Arduino-usbserial.c
diff --git a/firmwares/atmegaxxu2/arduino-usbserial/Arduino-usbserial.h b/firmwares/atmegaxxu2/arduino-usbserial/Arduino-usbserial.h
index 99fde39..99fde39 100755..100644
--- a/firmwares/atmegaxxu2/arduino-usbserial/Arduino-usbserial.h
+++ b/firmwares/atmegaxxu2/arduino-usbserial/Arduino-usbserial.h
diff --git a/firmwares/atmegaxxu2/arduino-usbserial/Board/LEDs.h b/firmwares/atmegaxxu2/arduino-usbserial/Board/LEDs.h
index 152e8f5..152e8f5 100755..100644
--- a/firmwares/atmegaxxu2/arduino-usbserial/Board/LEDs.h
+++ b/firmwares/atmegaxxu2/arduino-usbserial/Board/LEDs.h
diff --git a/firmwares/atmegaxxu2/arduino-usbserial/Descriptors.c b/firmwares/atmegaxxu2/arduino-usbserial/Descriptors.c
index 705dddf..705dddf 100755..100644
--- a/firmwares/atmegaxxu2/arduino-usbserial/Descriptors.c
+++ b/firmwares/atmegaxxu2/arduino-usbserial/Descriptors.c
diff --git a/firmwares/atmegaxxu2/arduino-usbserial/Descriptors.h b/firmwares/atmegaxxu2/arduino-usbserial/Descriptors.h
index 3ac4e52..3ac4e52 100755..100644
--- a/firmwares/atmegaxxu2/arduino-usbserial/Descriptors.h
+++ b/firmwares/atmegaxxu2/arduino-usbserial/Descriptors.h
diff --git a/firmwares/atmegaxxu2/arduino-usbserial/Lib/LightweightRingBuff.h b/firmwares/atmegaxxu2/arduino-usbserial/Lib/LightweightRingBuff.h
index fb48c1f..fb48c1f 100755..100644
--- a/firmwares/atmegaxxu2/arduino-usbserial/Lib/LightweightRingBuff.h
+++ b/firmwares/atmegaxxu2/arduino-usbserial/Lib/LightweightRingBuff.h
diff --git a/firmwares/atmegaxxu2/arduino-usbserial/makefile b/firmwares/atmegaxxu2/arduino-usbserial/makefile
index 79d6be2..79d6be2 100755..100644
--- a/firmwares/atmegaxxu2/arduino-usbserial/makefile
+++ b/firmwares/atmegaxxu2/arduino-usbserial/makefile
diff --git a/libraries/EEPROM/EEPROM.cpp b/libraries/EEPROM/EEPROM.cpp
new file mode 100644
index 0000000..dfa1deb
--- /dev/null
+++ b/libraries/EEPROM/EEPROM.cpp
@@ -0,0 +1,50 @@
+/*
+ EEPROM.cpp - EEPROM library
+ 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
+*/
+
+/******************************************************************************
+ * Includes
+ ******************************************************************************/
+
+#include <avr/eeprom.h>
+#include "Arduino.h"
+#include "EEPROM.h"
+
+/******************************************************************************
+ * Definitions
+ ******************************************************************************/
+
+/******************************************************************************
+ * Constructors
+ ******************************************************************************/
+
+/******************************************************************************
+ * User API
+ ******************************************************************************/
+
+uint8_t EEPROMClass::read(int address)
+{
+ return eeprom_read_byte((unsigned char *) address);
+}
+
+void EEPROMClass::write(int address, uint8_t value)
+{
+ eeprom_write_byte((unsigned char *) address, value);
+}
+
+EEPROMClass EEPROM;
diff --git a/cores/robot/Printable.h b/libraries/EEPROM/EEPROM.h
index d03c9af..aa2b577 100644
--- a/cores/robot/Printable.h
+++ b/libraries/EEPROM/EEPROM.h
@@ -1,6 +1,6 @@
/*
- Printable.h - Interface class that allows printing of complex types
- Copyright (c) 2011 Adrian McEwen. All right reserved.
+ EEPROM.h - EEPROM library
+ 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
@@ -17,24 +17,19 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef Printable_h
-#define Printable_h
+#ifndef EEPROM_h
+#define EEPROM_h
-#include <new.h>
+#include <inttypes.h>
-class Print;
-
-/** The Printable class provides a way for new classes to allow themselves to be printed.
- By deriving from Printable and implementing the printTo method, it will then be possible
- for users to print out instances of this class by passing them into the usual
- Print::print and Print::println methods.
-*/
-
-class Printable
+class EEPROMClass
{
public:
- virtual size_t printTo(Print& p) const = 0;
+ uint8_t read(int);
+ void write(int, uint8_t);
};
+extern EEPROMClass EEPROM;
+
#endif
diff --git a/libraries/EEPROM/examples/eeprom_clear/eeprom_clear.ino b/libraries/EEPROM/examples/eeprom_clear/eeprom_clear.ino
new file mode 100644
index 0000000..b18ff2c
--- /dev/null
+++ b/libraries/EEPROM/examples/eeprom_clear/eeprom_clear.ino
@@ -0,0 +1,23 @@
+/*
+ * EEPROM Clear
+ *
+ * Sets all of the bytes of the EEPROM to 0.
+ * This example code is in the public domain.
+
+ */
+
+#include <EEPROM.h>
+
+void setup()
+{
+ // write a 0 to all 512 bytes of the EEPROM
+ for (int i = 0; i < 512; i++)
+ EEPROM.write(i, 0);
+
+ // turn the LED on when we're done
+ digitalWrite(13, HIGH);
+}
+
+void loop()
+{
+}
diff --git a/libraries/EEPROM/examples/eeprom_read/eeprom_read.ino b/libraries/EEPROM/examples/eeprom_read/eeprom_read.ino
new file mode 100644
index 0000000..ebf79d6
--- /dev/null
+++ b/libraries/EEPROM/examples/eeprom_read/eeprom_read.ino
@@ -0,0 +1,43 @@
+/*
+ * EEPROM Read
+ *
+ * Reads the value of each byte of the EEPROM and prints it
+ * to the computer.
+ * This example code is in the public domain.
+ */
+
+#include <EEPROM.h>
+
+// start reading from the first byte (address 0) of the EEPROM
+int address = 0;
+byte value;
+
+void setup()
+{
+ // initialize serial and wait for port to open:
+ Serial.begin(9600);
+ while (!Serial) {
+ ; // wait for serial port to connect. Needed for Leonardo only
+ }
+}
+
+void loop()
+{
+ // read a byte from the current address of the EEPROM
+ value = EEPROM.read(address);
+
+ Serial.print(address);
+ Serial.print("\t");
+ Serial.print(value, DEC);
+ Serial.println();
+
+ // advance to the next address of the EEPROM
+ address = address + 1;
+
+ // there are only 512 bytes of EEPROM, from 0 to 511, so if we're
+ // on address 512, wrap around to address 0
+ if (address == 512)
+ address = 0;
+
+ delay(500);
+}
diff --git a/libraries/EEPROM/examples/eeprom_write/eeprom_write.ino b/libraries/EEPROM/examples/eeprom_write/eeprom_write.ino
new file mode 100644
index 0000000..c047887
--- /dev/null
+++ b/libraries/EEPROM/examples/eeprom_write/eeprom_write.ino
@@ -0,0 +1,38 @@
+/*
+ * EEPROM Write
+ *
+ * Stores values read from analog input 0 into the EEPROM.
+ * These values will stay in the EEPROM when the board is
+ * turned off and may be retrieved later by another sketch.
+ */
+
+#include <EEPROM.h>
+
+// the current address in the EEPROM (i.e. which byte
+// we're going to write to next)
+int addr = 0;
+
+void setup()
+{
+}
+
+void loop()
+{
+ // need to divide by 4 because analog inputs range from
+ // 0 to 1023 and each byte of the EEPROM can only hold a
+ // value from 0 to 255.
+ int val = analogRead(0) / 4;
+
+ // write the value to the appropriate byte of the EEPROM.
+ // these values will remain there when the board is
+ // turned off.
+ EEPROM.write(addr, val);
+
+ // advance to the next address. there are 512 bytes in
+ // the EEPROM, so go back to 0 when we hit 512.
+ addr = addr + 1;
+ if (addr == 512)
+ addr = 0;
+
+ delay(100);
+}
diff --git a/libraries/EEPROM/keywords.txt b/libraries/EEPROM/keywords.txt
new file mode 100644
index 0000000..d3218fe
--- /dev/null
+++ b/libraries/EEPROM/keywords.txt
@@ -0,0 +1,18 @@
+#######################################
+# Syntax Coloring Map For Ultrasound
+#######################################
+
+#######################################
+# Datatypes (KEYWORD1)
+#######################################
+
+EEPROM KEYWORD1
+
+#######################################
+# Methods and Functions (KEYWORD2)
+#######################################
+
+#######################################
+# Constants (LITERAL1)
+#######################################
+
diff --git a/libraries/SPI/SPI.cpp b/libraries/SPI/SPI.cpp
new file mode 100644
index 0000000..5e48073
--- /dev/null
+++ b/libraries/SPI/SPI.cpp
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2010 by Cristian Maglie <c.maglie@bug.st>
+ * SPI Master library for arduino.
+ *
+ * This file is free software; you can redistribute it and/or modify
+ * it under the terms of either the GNU General Public License version 2
+ * or the GNU Lesser General Public License version 2.1, both as
+ * published by the Free Software Foundation.
+ */
+
+#include "pins_arduino.h"
+#include "SPI.h"
+
+SPIClass SPI;
+
+void SPIClass::begin() {
+
+ // Set SS to high so a connected chip will be "deselected" by default
+ digitalWrite(SS, HIGH);
+
+ // When the SS pin is set as OUTPUT, it can be used as
+ // a general purpose output port (it doesn't influence
+ // SPI operations).
+ pinMode(SS, OUTPUT);
+
+ // Warning: if the SS pin ever becomes a LOW INPUT then SPI
+ // automatically switches to Slave, so the data direction of
+ // the SS pin MUST be kept as OUTPUT.
+ SPCR |= _BV(MSTR);
+ SPCR |= _BV(SPE);
+
+ // Set direction register for SCK and MOSI pin.
+ // MISO pin automatically overrides to INPUT.
+ // By doing this AFTER enabling SPI, we avoid accidentally
+ // clocking in a single bit since the lines go directly
+ // from "input" to SPI control.
+ // http://code.google.com/p/arduino/issues/detail?id=888
+ pinMode(SCK, OUTPUT);
+ pinMode(MOSI, OUTPUT);
+}
+
+
+void SPIClass::end() {
+ SPCR &= ~_BV(SPE);
+}
+
+void SPIClass::setBitOrder(uint8_t bitOrder)
+{
+ if(bitOrder == LSBFIRST) {
+ SPCR |= _BV(DORD);
+ } else {
+ SPCR &= ~(_BV(DORD));
+ }
+}
+
+void SPIClass::setDataMode(uint8_t mode)
+{
+ SPCR = (SPCR & ~SPI_MODE_MASK) | mode;
+}
+
+void SPIClass::setClockDivider(uint8_t rate)
+{
+ SPCR = (SPCR & ~SPI_CLOCK_MASK) | (rate & SPI_CLOCK_MASK);
+ SPSR = (SPSR & ~SPI_2XCLOCK_MASK) | ((rate >> 2) & SPI_2XCLOCK_MASK);
+}
+
diff --git a/libraries/SPI/SPI.h b/libraries/SPI/SPI.h
new file mode 100644
index 0000000..f647d5c
--- /dev/null
+++ b/libraries/SPI/SPI.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2010 by Cristian Maglie <c.maglie@bug.st>
+ * SPI Master library for arduino.
+ *
+ * This file is free software; you can redistribute it and/or modify
+ * it under the terms of either the GNU General Public License version 2
+ * or the GNU Lesser General Public License version 2.1, both as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef _SPI_H_INCLUDED
+#define _SPI_H_INCLUDED
+
+#include <stdio.h>
+#include <Arduino.h>
+#include <avr/pgmspace.h>
+
+#define SPI_CLOCK_DIV4 0x00
+#define SPI_CLOCK_DIV16 0x01
+#define SPI_CLOCK_DIV64 0x02
+#define SPI_CLOCK_DIV128 0x03
+#define SPI_CLOCK_DIV2 0x04
+#define SPI_CLOCK_DIV8 0x05
+#define SPI_CLOCK_DIV32 0x06
+//#define SPI_CLOCK_DIV64 0x07
+
+#define SPI_MODE0 0x00
+#define SPI_MODE1 0x04
+#define SPI_MODE2 0x08
+#define SPI_MODE3 0x0C
+
+#define SPI_MODE_MASK 0x0C // CPOL = bit 3, CPHA = bit 2 on SPCR
+#define SPI_CLOCK_MASK 0x03 // SPR1 = bit 1, SPR0 = bit 0 on SPCR
+#define SPI_2XCLOCK_MASK 0x01 // SPI2X = bit 0 on SPSR
+
+class SPIClass {
+public:
+ inline static byte transfer(byte _data);
+
+ // SPI Configuration methods
+
+ inline static void attachInterrupt();
+ inline static void detachInterrupt(); // Default
+
+ static void begin(); // Default
+ static void end();
+
+ static void setBitOrder(uint8_t);
+ static void setDataMode(uint8_t);
+ static void setClockDivider(uint8_t);
+};
+
+extern SPIClass SPI;
+
+byte SPIClass::transfer(byte _data) {
+ SPDR = _data;
+ while (!(SPSR & _BV(SPIF)))
+ ;
+ return SPDR;
+}
+
+void SPIClass::attachInterrupt() {
+ SPCR |= _BV(SPIE);
+}
+
+void SPIClass::detachInterrupt() {
+ SPCR &= ~_BV(SPIE);
+}
+
+#endif
diff --git a/libraries/SPI/examples/BarometricPressureSensor/BarometricPressureSensor.ino b/libraries/SPI/examples/BarometricPressureSensor/BarometricPressureSensor.ino
new file mode 100644
index 0000000..8104fcb
--- /dev/null
+++ b/libraries/SPI/examples/BarometricPressureSensor/BarometricPressureSensor.ino
@@ -0,0 +1,143 @@
+/*
+ SCP1000 Barometric Pressure Sensor Display
+
+ Shows the output of a Barometric Pressure Sensor on a
+ Uses the SPI library. For details on the sensor, see:
+ http://www.sparkfun.com/commerce/product_info.php?products_id=8161
+ http://www.vti.fi/en/support/obsolete_products/pressure_sensors/
+
+ This sketch adapted from Nathan Seidle's SCP1000 example for PIC:
+ http://www.sparkfun.com/datasheets/Sensors/SCP1000-Testing.zip
+
+ Circuit:
+ SCP1000 sensor attached to pins 6, 7, 10 - 13:
+ DRDY: pin 6
+ CSB: pin 7
+ MOSI: pin 11
+ MISO: pin 12
+ SCK: pin 13
+
+ created 31 July 2010
+ modified 14 August 2010
+ by Tom Igoe
+ */
+
+// the sensor communicates using SPI, so include the library:
+#include <SPI.h>
+
+//Sensor's memory register addresses:
+const int PRESSURE = 0x1F; //3 most significant bits of pressure
+const int PRESSURE_LSB = 0x20; //16 least significant bits of pressure
+const int TEMPERATURE = 0x21; //16 bit temperature reading
+const byte READ = 0b11111100; // SCP1000's read command
+const byte WRITE = 0b00000010; // SCP1000's write command
+
+// pins used for the connection with the sensor
+// the other you need are controlled by the SPI library):
+const int dataReadyPin = 6;
+const int chipSelectPin = 7;
+
+void setup() {
+ Serial.begin(9600);
+
+ // start the SPI library:
+ SPI.begin();
+
+ // initalize the data ready and chip select pins:
+ pinMode(dataReadyPin, INPUT);
+ pinMode(chipSelectPin, OUTPUT);
+
+ //Configure SCP1000 for low noise configuration:
+ writeRegister(0x02, 0x2D);
+ writeRegister(0x01, 0x03);
+ writeRegister(0x03, 0x02);
+ // give the sensor time to set up:
+ delay(100);
+}
+
+void loop() {
+ //Select High Resolution Mode
+ writeRegister(0x03, 0x0A);
+
+ // don't do anything until the data ready pin is high:
+ if (digitalRead(dataReadyPin) == HIGH) {
+ //Read the temperature data
+ int tempData = readRegister(0x21, 2);
+
+ // convert the temperature to celsius and display it:
+ float realTemp = (float)tempData / 20.0;
+ Serial.print("Temp[C]=");
+ Serial.print(realTemp);
+
+
+ //Read the pressure data highest 3 bits:
+ byte pressure_data_high = readRegister(0x1F, 1);
+ pressure_data_high &= 0b00000111; //you only needs bits 2 to 0
+
+ //Read the pressure data lower 16 bits:
+ unsigned int pressure_data_low = readRegister(0x20, 2);
+ //combine the two parts into one 19-bit number:
+ long pressure = ((pressure_data_high << 16) | pressure_data_low) / 4;
+
+ // display the temperature:
+ Serial.println("\tPressure [Pa]=" + String(pressure));
+ }
+}
+
+//Read from or write to register from the SCP1000:
+unsigned int readRegister(byte thisRegister, int bytesToRead ) {
+ byte inByte = 0; // incoming byte from the SPI
+ unsigned int result = 0; // result to return
+ Serial.print(thisRegister, BIN);
+ Serial.print("\t");
+ // SCP1000 expects the register name in the upper 6 bits
+ // of the byte. So shift the bits left by two bits:
+ thisRegister = thisRegister << 2;
+ // now combine the address and the command into one byte
+ byte dataToSend = thisRegister & READ;
+ Serial.println(thisRegister, BIN);
+ // take the chip select low to select the device:
+ digitalWrite(chipSelectPin, LOW);
+ // send the device the register you want to read:
+ SPI.transfer(dataToSend);
+ // send a value of 0 to read the first byte returned:
+ result = SPI.transfer(0x00);
+ // decrement the number of bytes left to read:
+ bytesToRead--;
+ // if you still have another byte to read:
+ if (bytesToRead > 0) {
+ // shift the first byte left, then get the second byte:
+ result = result << 8;
+ inByte = SPI.transfer(0x00);
+ // combine the byte you just got with the previous one:
+ result = result | inByte;
+ // decrement the number of bytes left to read:
+ bytesToRead--;
+ }
+ // take the chip select high to de-select:
+ digitalWrite(chipSelectPin, HIGH);
+ // return the result:
+ return(result);
+}
+
+
+//Sends a write command to SCP1000
+
+void writeRegister(byte thisRegister, byte thisValue) {
+
+ // SCP1000 expects the register address in the upper 6 bits
+ // of the byte. So shift the bits left by two bits:
+ thisRegister = thisRegister << 2;
+ // now combine the register address and the command into one byte:
+ byte dataToSend = thisRegister | WRITE;
+
+ // take the chip select low to select the device:
+ digitalWrite(chipSelectPin, LOW);
+
+ SPI.transfer(dataToSend); //Send register location
+ SPI.transfer(thisValue); //Send value to record into register
+
+ // take the chip select high to de-select:
+ digitalWrite(chipSelectPin, HIGH);
+}
+
diff --git a/libraries/SPI/examples/DigitalPotControl/DigitalPotControl.ino b/libraries/SPI/examples/DigitalPotControl/DigitalPotControl.ino
new file mode 100644
index 0000000..b135a74
--- /dev/null
+++ b/libraries/SPI/examples/DigitalPotControl/DigitalPotControl.ino
@@ -0,0 +1,71 @@
+/*
+ Digital Pot Control
+
+ This example controls an Analog Devices AD5206 digital potentiometer.
+ The AD5206 has 6 potentiometer channels. Each channel's pins are labeled
+ A - connect this to voltage
+ W - this is the pot's wiper, which changes when you set it
+ B - connect this to ground.
+
+ The AD5206 is SPI-compatible,and to command it, you send two bytes,
+ one with the channel number (0 - 5) and one with the resistance value for the
+ channel (0 - 255).
+
+ The circuit:
+ * All A pins of AD5206 connected to +5V
+ * All B pins of AD5206 connected to ground
+ * An LED and a 220-ohm resisor in series connected from each W pin to ground
+ * CS - to digital pin 10 (SS pin)
+ * SDI - to digital pin 11 (MOSI pin)
+ * CLK - to digital pin 13 (SCK pin)
+
+ created 10 Aug 2010
+ by Tom Igoe
+
+ Thanks to Heather Dewey-Hagborg for the original tutorial, 2005
+
+*/
+
+
+// inslude the SPI library:
+#include <SPI.h>
+
+
+// set pin 10 as the slave select for the digital pot:
+const int slaveSelectPin = 10;
+
+void setup() {
+ // set the slaveSelectPin as an output:
+ pinMode (slaveSelectPin, OUTPUT);
+ // initialize SPI:
+ SPI.begin();
+}
+
+void loop() {
+ // go through the six channels of the digital pot:
+ for (int channel = 0; channel < 6; channel++) {
+ // change the resistance on this channel from min to max:
+ for (int level = 0; level < 255; level++) {
+ digitalPotWrite(channel, level);
+ delay(10);
+ }
+ // wait a second at the top:
+ delay(100);
+ // change the resistance on this channel from max to min:
+ for (int level = 0; level < 255; level++) {
+ digitalPotWrite(channel, 255 - level);
+ delay(10);
+ }
+ }
+
+}
+
+void digitalPotWrite(int address, int value) {
+ // take the SS pin low to select the chip:
+ digitalWrite(slaveSelectPin, LOW);
+ // send in the address and value via SPI:
+ SPI.transfer(address);
+ SPI.transfer(value);
+ // take the SS pin high to de-select the chip:
+ digitalWrite(slaveSelectPin, HIGH);
+}
diff --git a/libraries/SPI/keywords.txt b/libraries/SPI/keywords.txt
new file mode 100644
index 0000000..fa76165
--- /dev/null
+++ b/libraries/SPI/keywords.txt
@@ -0,0 +1,36 @@
+#######################################
+# Syntax Coloring Map SPI
+#######################################
+
+#######################################
+# Datatypes (KEYWORD1)
+#######################################
+
+SPI KEYWORD1
+
+#######################################
+# Methods and Functions (KEYWORD2)
+#######################################
+begin KEYWORD2
+end KEYWORD2
+transfer KEYWORD2
+setBitOrder KEYWORD2
+setDataMode KEYWORD2
+setClockDivider KEYWORD2
+
+
+#######################################
+# Constants (LITERAL1)
+#######################################
+SPI_CLOCK_DIV4 LITERAL1
+SPI_CLOCK_DIV16 LITERAL1
+SPI_CLOCK_DIV64 LITERAL1
+SPI_CLOCK_DIV128 LITERAL1
+SPI_CLOCK_DIV2 LITERAL1
+SPI_CLOCK_DIV8 LITERAL1
+SPI_CLOCK_DIV32 LITERAL1
+SPI_CLOCK_DIV64 LITERAL1
+SPI_MODE0 LITERAL1
+SPI_MODE1 LITERAL1
+SPI_MODE2 LITERAL1
+SPI_MODE3 LITERAL1 \ No newline at end of file
diff --git a/libraries/SoftwareSerial/SoftwareSerial.cpp b/libraries/SoftwareSerial/SoftwareSerial.cpp
new file mode 100644
index 0000000..64496fe
--- /dev/null
+++ b/libraries/SoftwareSerial/SoftwareSerial.cpp
@@ -0,0 +1,518 @@
+/*
+SoftwareSerial.cpp (formerly NewSoftSerial.cpp) -
+Multi-instance software serial library for Arduino/Wiring
+-- Interrupt-driven receive and other improvements by ladyada
+ (http://ladyada.net)
+-- Tuning, circular buffer, derivation from class Print/Stream,
+ multi-instance support, porting to 8MHz processors,
+ various optimizations, PROGMEM delay tables, inverse logic and
+ direct port writing by Mikal Hart (http://www.arduiniana.org)
+-- Pin change interrupt macros by Paul Stoffregen (http://www.pjrc.com)
+-- 20MHz processor support by Garrett Mace (http://www.macetech.com)
+-- ATmega1280/2560 support by Brett Hagman (http://www.roguerobotics.com/)
+
+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
+
+The latest version of this library can always be found at
+http://arduiniana.org.
+*/
+
+// When set, _DEBUG co-opts pins 11 and 13 for debugging with an
+// oscilloscope or logic analyzer. Beware: it also slightly modifies
+// the bit times, so don't rely on it too much at high baud rates
+#define _DEBUG 0
+#define _DEBUG_PIN1 11
+#define _DEBUG_PIN2 13
+//
+// Includes
+//
+#include <avr/interrupt.h>
+#include <avr/pgmspace.h>
+#include <Arduino.h>
+#include <SoftwareSerial.h>
+//
+// Lookup table
+//
+typedef struct _DELAY_TABLE
+{
+ long baud;
+ unsigned short rx_delay_centering;
+ unsigned short rx_delay_intrabit;
+ unsigned short rx_delay_stopbit;
+ unsigned short tx_delay;
+} DELAY_TABLE;
+
+#if F_CPU == 16000000
+
+static const DELAY_TABLE PROGMEM table[] =
+{
+ // baud rxcenter rxintra rxstop tx
+ { 115200, 1, 17, 17, 12, },
+ { 57600, 10, 37, 37, 33, },
+ { 38400, 25, 57, 57, 54, },
+ { 31250, 31, 70, 70, 68, },
+ { 28800, 34, 77, 77, 74, },
+ { 19200, 54, 117, 117, 114, },
+ { 14400, 74, 156, 156, 153, },
+ { 9600, 114, 236, 236, 233, },
+ { 4800, 233, 474, 474, 471, },
+ { 2400, 471, 950, 950, 947, },
+ { 1200, 947, 1902, 1902, 1899, },
+ { 600, 1902, 3804, 3804, 3800, },
+ { 300, 3804, 7617, 7617, 7614, },
+};
+
+const int XMIT_START_ADJUSTMENT = 5;
+
+#elif F_CPU == 8000000
+
+static const DELAY_TABLE table[] PROGMEM =
+{
+ // baud rxcenter rxintra rxstop tx
+ { 115200, 1, 5, 5, 3, },
+ { 57600, 1, 15, 15, 13, },
+ { 38400, 2, 25, 26, 23, },
+ { 31250, 7, 32, 33, 29, },
+ { 28800, 11, 35, 35, 32, },
+ { 19200, 20, 55, 55, 52, },
+ { 14400, 30, 75, 75, 72, },
+ { 9600, 50, 114, 114, 112, },
+ { 4800, 110, 233, 233, 230, },
+ { 2400, 229, 472, 472, 469, },
+ { 1200, 467, 948, 948, 945, },
+ { 600, 948, 1895, 1895, 1890, },
+ { 300, 1895, 3805, 3805, 3802, },
+};
+
+const int XMIT_START_ADJUSTMENT = 4;
+
+#elif F_CPU == 20000000
+
+// 20MHz support courtesy of the good people at macegr.com.
+// Thanks, Garrett!
+
+static const DELAY_TABLE PROGMEM table[] =
+{
+ // baud rxcenter rxintra rxstop tx
+ { 115200, 3, 21, 21, 18, },
+ { 57600, 20, 43, 43, 41, },
+ { 38400, 37, 73, 73, 70, },
+ { 31250, 45, 89, 89, 88, },
+ { 28800, 46, 98, 98, 95, },
+ { 19200, 71, 148, 148, 145, },
+ { 14400, 96, 197, 197, 194, },
+ { 9600, 146, 297, 297, 294, },
+ { 4800, 296, 595, 595, 592, },
+ { 2400, 592, 1189, 1189, 1186, },
+ { 1200, 1187, 2379, 2379, 2376, },
+ { 600, 2379, 4759, 4759, 4755, },
+ { 300, 4759, 9523, 9523, 9520, },
+};
+
+const int XMIT_START_ADJUSTMENT = 6;
+
+#else
+
+#error This version of SoftwareSerial supports only 20, 16 and 8MHz processors
+
+#endif
+
+//
+// Statics
+//
+SoftwareSerial *SoftwareSerial::active_object = 0;
+char SoftwareSerial::_receive_buffer[_SS_MAX_RX_BUFF];
+volatile uint8_t SoftwareSerial::_receive_buffer_tail = 0;
+volatile uint8_t SoftwareSerial::_receive_buffer_head = 0;
+
+//
+// Debugging
+//
+// This function generates a brief pulse
+// for debugging or measuring on an oscilloscope.
+inline void DebugPulse(uint8_t pin, uint8_t count)
+{
+#if _DEBUG
+ volatile uint8_t *pport = portOutputRegister(digitalPinToPort(pin));
+
+ uint8_t val = *pport;
+ while (count--)
+ {
+ *pport = val | digitalPinToBitMask(pin);
+ *pport = val;
+ }
+#endif
+}
+
+//
+// Private methods
+//
+
+/* static */
+inline void SoftwareSerial::tunedDelay(uint16_t delay) {
+ uint8_t tmp=0;
+
+ asm volatile("sbiw %0, 0x01 \n\t"
+ "ldi %1, 0xFF \n\t"
+ "cpi %A0, 0xFF \n\t"
+ "cpc %B0, %1 \n\t"
+ "brne .-10 \n\t"
+ : "+r" (delay), "+a" (tmp)
+ : "0" (delay)
+ );
+}
+
+// This function sets the current object as the "listening"
+// one and returns true if it replaces another
+bool SoftwareSerial::listen()
+{
+ if (active_object != this)
+ {
+ _buffer_overflow = false;
+ uint8_t oldSREG = SREG;
+ cli();
+ _receive_buffer_head = _receive_buffer_tail = 0;
+ active_object = this;
+ SREG = oldSREG;
+ return true;
+ }
+
+ return false;
+}
+
+//
+// The receive routine called by the interrupt handler
+//
+void SoftwareSerial::recv()
+{
+
+#if GCC_VERSION < 40302
+// Work-around for avr-gcc 4.3.0 OSX version bug
+// Preserve the registers that the compiler misses
+// (courtesy of Arduino forum user *etracer*)
+ asm volatile(
+ "push r18 \n\t"
+ "push r19 \n\t"
+ "push r20 \n\t"
+ "push r21 \n\t"
+ "push r22 \n\t"
+ "push r23 \n\t"
+ "push r26 \n\t"
+ "push r27 \n\t"
+ ::);
+#endif
+
+ uint8_t d = 0;
+
+ // If RX line is high, then we don't see any start bit
+ // so interrupt is probably not for us
+ if (_inverse_logic ? rx_pin_read() : !rx_pin_read())
+ {
+ // Wait approximately 1/2 of a bit width to "center" the sample
+ tunedDelay(_rx_delay_centering);
+ DebugPulse(_DEBUG_PIN2, 1);
+
+ // Read each of the 8 bits
+ for (uint8_t i=0x1; i; i <<= 1)
+ {
+ tunedDelay(_rx_delay_intrabit);
+ DebugPulse(_DEBUG_PIN2, 1);
+ uint8_t noti = ~i;
+ if (rx_pin_read())
+ d |= i;
+ else // else clause added to ensure function timing is ~balanced
+ d &= noti;
+ }
+
+ // skip the stop bit
+ tunedDelay(_rx_delay_stopbit);
+ DebugPulse(_DEBUG_PIN2, 1);
+
+ if (_inverse_logic)
+ d = ~d;
+
+ // if buffer full, set the overflow flag and return
+ if ((_receive_buffer_tail + 1) % _SS_MAX_RX_BUFF != _receive_buffer_head)
+ {
+ // save new data in buffer: tail points to where byte goes
+ _receive_buffer[_receive_buffer_tail] = d; // save new byte
+ _receive_buffer_tail = (_receive_buffer_tail + 1) % _SS_MAX_RX_BUFF;
+ }
+ else
+ {
+#if _DEBUG // for scope: pulse pin as overflow indictator
+ DebugPulse(_DEBUG_PIN1, 1);
+#endif
+ _buffer_overflow = true;
+ }
+ }
+
+#if GCC_VERSION < 40302
+// Work-around for avr-gcc 4.3.0 OSX version bug
+// Restore the registers that the compiler misses
+ asm volatile(
+ "pop r27 \n\t"
+ "pop r26 \n\t"
+ "pop r23 \n\t"
+ "pop r22 \n\t"
+ "pop r21 \n\t"
+ "pop r20 \n\t"
+ "pop r19 \n\t"
+ "pop r18 \n\t"
+ ::);
+#endif
+}
+
+void SoftwareSerial::tx_pin_write(uint8_t pin_state)
+{
+ if (pin_state == LOW)
+ *_transmitPortRegister &= ~_transmitBitMask;
+ else
+ *_transmitPortRegister |= _transmitBitMask;
+}
+
+uint8_t SoftwareSerial::rx_pin_read()
+{
+ return *_receivePortRegister & _receiveBitMask;
+}
+
+//
+// Interrupt handling
+//
+
+/* static */
+inline void SoftwareSerial::handle_interrupt()
+{
+ if (active_object)
+ {
+ active_object->recv();
+ }
+}
+
+#if defined(PCINT0_vect)
+ISR(PCINT0_vect)
+{
+ SoftwareSerial::handle_interrupt();
+}
+#endif
+
+#if defined(PCINT1_vect)
+ISR(PCINT1_vect)
+{
+ SoftwareSerial::handle_interrupt();
+}
+#endif
+
+#if defined(PCINT2_vect)
+ISR(PCINT2_vect)
+{
+ SoftwareSerial::handle_interrupt();
+}
+#endif
+
+#if defined(PCINT3_vect)
+ISR(PCINT3_vect)
+{
+ SoftwareSerial::handle_interrupt();
+}
+#endif
+
+//
+// Constructor
+//
+SoftwareSerial::SoftwareSerial(uint8_t receivePin, uint8_t transmitPin, bool inverse_logic /* = false */) :
+ _rx_delay_centering(0),
+ _rx_delay_intrabit(0),
+ _rx_delay_stopbit(0),
+ _tx_delay(0),
+ _buffer_overflow(false),
+ _inverse_logic(inverse_logic)
+{
+ setTX(transmitPin);
+ setRX(receivePin);
+}
+
+//
+// Destructor
+//
+SoftwareSerial::~SoftwareSerial()
+{
+ end();
+}
+
+void SoftwareSerial::setTX(uint8_t tx)
+{
+ pinMode(tx, OUTPUT);
+ digitalWrite(tx, HIGH);
+ _transmitBitMask = digitalPinToBitMask(tx);
+ uint8_t port = digitalPinToPort(tx);
+ _transmitPortRegister = portOutputRegister(port);
+}
+
+void SoftwareSerial::setRX(uint8_t rx)
+{
+ pinMode(rx, INPUT);
+ if (!_inverse_logic)
+ digitalWrite(rx, HIGH); // pullup for normal logic!
+ _receivePin = rx;
+ _receiveBitMask = digitalPinToBitMask(rx);
+ uint8_t port = digitalPinToPort(rx);
+ _receivePortRegister = portInputRegister(port);
+}
+
+//
+// Public methods
+//
+
+void SoftwareSerial::begin(long speed)
+{
+ _rx_delay_centering = _rx_delay_intrabit = _rx_delay_stopbit = _tx_delay = 0;
+
+ for (unsigned i=0; i<sizeof(table)/sizeof(table[0]); ++i)
+ {
+ long baud = pgm_read_dword(&table[i].baud);
+ if (baud == speed)
+ {
+ _rx_delay_centering = pgm_read_word(&table[i].rx_delay_centering);
+ _rx_delay_intrabit = pgm_read_word(&table[i].rx_delay_intrabit);
+ _rx_delay_stopbit = pgm_read_word(&table[i].rx_delay_stopbit);
+ _tx_delay = pgm_read_word(&table[i].tx_delay);
+ break;
+ }
+ }
+
+ // Set up RX interrupts, but only if we have a valid RX baud rate
+ if (_rx_delay_stopbit)
+ {
+ if (digitalPinToPCICR(_receivePin))
+ {
+ *digitalPinToPCICR(_receivePin) |= _BV(digitalPinToPCICRbit(_receivePin));
+ *digitalPinToPCMSK(_receivePin) |= _BV(digitalPinToPCMSKbit(_receivePin));
+ }
+ tunedDelay(_tx_delay); // if we were low this establishes the end
+ }
+
+#if _DEBUG
+ pinMode(_DEBUG_PIN1, OUTPUT);
+ pinMode(_DEBUG_PIN2, OUTPUT);
+#endif
+
+ listen();
+}
+
+void SoftwareSerial::end()
+{
+ if (digitalPinToPCMSK(_receivePin))
+ *digitalPinToPCMSK(_receivePin) &= ~_BV(digitalPinToPCMSKbit(_receivePin));
+}
+
+
+// Read data from buffer
+int SoftwareSerial::read()
+{
+ if (!isListening())
+ return -1;
+
+ // Empty buffer?
+ if (_receive_buffer_head == _receive_buffer_tail)
+ return -1;
+
+ // Read from "head"
+ uint8_t d = _receive_buffer[_receive_buffer_head]; // grab next byte
+ _receive_buffer_head = (_receive_buffer_head + 1) % _SS_MAX_RX_BUFF;
+ return d;
+}
+
+int SoftwareSerial::available()
+{
+ if (!isListening())
+ return 0;
+
+ return (_receive_buffer_tail + _SS_MAX_RX_BUFF - _receive_buffer_head) % _SS_MAX_RX_BUFF;
+}
+
+size_t SoftwareSerial::write(uint8_t b)
+{
+ if (_tx_delay == 0) {
+ setWriteError();
+ return 0;
+ }
+
+ uint8_t oldSREG = SREG;
+ cli(); // turn off interrupts for a clean txmit
+
+ // Write the start bit
+ tx_pin_write(_inverse_logic ? HIGH : LOW);
+ tunedDelay(_tx_delay + XMIT_START_ADJUSTMENT);
+
+ // Write each of the 8 bits
+ if (_inverse_logic)
+ {
+ for (byte mask = 0x01; mask; mask <<= 1)
+ {
+ if (b & mask) // choose bit
+ tx_pin_write(LOW); // send 1
+ else
+ tx_pin_write(HIGH); // send 0
+
+ tunedDelay(_tx_delay);
+ }
+
+ tx_pin_write(LOW); // restore pin to natural state
+ }
+ else
+ {
+ for (byte mask = 0x01; mask; mask <<= 1)
+ {
+ if (b & mask) // choose bit
+ tx_pin_write(HIGH); // send 1
+ else
+ tx_pin_write(LOW); // send 0
+
+ tunedDelay(_tx_delay);
+ }
+
+ tx_pin_write(HIGH); // restore pin to natural state
+ }
+
+ SREG = oldSREG; // turn interrupts back on
+ tunedDelay(_tx_delay);
+
+ return 1;
+}
+
+void SoftwareSerial::flush()
+{
+ if (!isListening())
+ return;
+
+ uint8_t oldSREG = SREG;
+ cli();
+ _receive_buffer_head = _receive_buffer_tail = 0;
+ SREG = oldSREG;
+}
+
+int SoftwareSerial::peek()
+{
+ if (!isListening())
+ return -1;
+
+ // Empty buffer?
+ if (_receive_buffer_head == _receive_buffer_tail)
+ return -1;
+
+ // Read from "head"
+ return _receive_buffer[_receive_buffer_head];
+}
diff --git a/libraries/SoftwareSerial/SoftwareSerial.h b/libraries/SoftwareSerial/SoftwareSerial.h
new file mode 100644
index 0000000..a6a60b5
--- /dev/null
+++ b/libraries/SoftwareSerial/SoftwareSerial.h
@@ -0,0 +1,112 @@
+/*
+SoftwareSerial.h (formerly NewSoftSerial.h) -
+Multi-instance software serial library for Arduino/Wiring
+-- Interrupt-driven receive and other improvements by ladyada
+ (http://ladyada.net)
+-- Tuning, circular buffer, derivation from class Print/Stream,
+ multi-instance support, porting to 8MHz processors,
+ various optimizations, PROGMEM delay tables, inverse logic and
+ direct port writing by Mikal Hart (http://www.arduiniana.org)
+-- Pin change interrupt macros by Paul Stoffregen (http://www.pjrc.com)
+-- 20MHz processor support by Garrett Mace (http://www.macetech.com)
+-- ATmega1280/2560 support by Brett Hagman (http://www.roguerobotics.com/)
+
+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
+
+The latest version of this library can always be found at
+http://arduiniana.org.
+*/
+
+#ifndef SoftwareSerial_h
+#define SoftwareSerial_h
+
+#include <inttypes.h>
+#include <Stream.h>
+
+/******************************************************************************
+* Definitions
+******************************************************************************/
+
+#define _SS_MAX_RX_BUFF 64 // RX buffer size
+#ifndef GCC_VERSION
+#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
+#endif
+
+class SoftwareSerial : public Stream
+{
+private:
+ // per object data
+ uint8_t _receivePin;
+ uint8_t _receiveBitMask;
+ volatile uint8_t *_receivePortRegister;
+ uint8_t _transmitBitMask;
+ volatile uint8_t *_transmitPortRegister;
+
+ uint16_t _rx_delay_centering;
+ uint16_t _rx_delay_intrabit;
+ uint16_t _rx_delay_stopbit;
+ uint16_t _tx_delay;
+
+ uint16_t _buffer_overflow:1;
+ uint16_t _inverse_logic:1;
+
+ // static data
+ static char _receive_buffer[_SS_MAX_RX_BUFF];
+ static volatile uint8_t _receive_buffer_tail;
+ static volatile uint8_t _receive_buffer_head;
+ static SoftwareSerial *active_object;
+
+ // private methods
+ void recv();
+ uint8_t rx_pin_read();
+ void tx_pin_write(uint8_t pin_state);
+ void setTX(uint8_t transmitPin);
+ void setRX(uint8_t receivePin);
+
+ // private static method for timing
+ static inline void tunedDelay(uint16_t delay);
+
+public:
+ // public methods
+ SoftwareSerial(uint8_t receivePin, uint8_t transmitPin, bool inverse_logic = false);
+ ~SoftwareSerial();
+ void begin(long speed);
+ bool listen();
+ void end();
+ bool isListening() { return this == active_object; }
+ bool overflow() { bool ret = _buffer_overflow; _buffer_overflow = false; return ret; }
+ int peek();
+
+ virtual size_t write(uint8_t byte);
+ virtual int read();
+ virtual int available();
+ virtual void flush();
+
+ using Print::write;
+
+ // public only for easy access by interrupt handlers
+ static inline void handle_interrupt();
+};
+
+// Arduino 0012 workaround
+#undef int
+#undef char
+#undef long
+#undef byte
+#undef float
+#undef abs
+#undef round
+
+#endif
diff --git a/libraries/SoftwareSerial/examples/SoftwareSerialExample/SoftwareSerialExample.ino b/libraries/SoftwareSerial/examples/SoftwareSerialExample/SoftwareSerialExample.ino
new file mode 100644
index 0000000..f659133
--- /dev/null
+++ b/libraries/SoftwareSerial/examples/SoftwareSerialExample/SoftwareSerialExample.ino
@@ -0,0 +1,55 @@
+/*
+ Software serial multple serial test
+
+ Receives from the hardware serial, sends to software serial.
+ Receives from software serial, sends to hardware serial.
+
+ The circuit:
+ * RX is digital pin 10 (connect to TX of other device)
+ * TX is digital pin 11 (connect to RX of other device)
+
+ Note:
+ Not all pins on the Mega and Mega 2560 support change interrupts,
+ so only the following can be used for RX:
+ 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69
+
+ Not all pins on the Leonardo support change interrupts,
+ so only the following can be used for RX:
+ 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).
+
+ created back in the mists of time
+ modified 25 May 2012
+ by Tom Igoe
+ based on Mikal Hart's example
+
+ This example code is in the public domain.
+
+ */
+#include <SoftwareSerial.h>
+
+SoftwareSerial mySerial(10, 11); // RX, TX
+
+void setup()
+{
+ // Open serial communications and wait for port to open:
+ Serial.begin(57600);
+ while (!Serial) {
+ ; // wait for serial port to connect. Needed for Leonardo only
+ }
+
+
+ Serial.println("Goodnight moon!");
+
+ // set the data rate for the SoftwareSerial port
+ mySerial.begin(4800);
+ mySerial.println("Hello, world?");
+}
+
+void loop() // run over and over
+{
+ if (mySerial.available())
+ Serial.write(mySerial.read());
+ if (Serial.available())
+ mySerial.write(Serial.read());
+}
+
diff --git a/libraries/SoftwareSerial/examples/TwoPortReceive/TwoPortReceive.ino b/libraries/SoftwareSerial/examples/TwoPortReceive/TwoPortReceive.ino
new file mode 100644
index 0000000..95881a6
--- /dev/null
+++ b/libraries/SoftwareSerial/examples/TwoPortReceive/TwoPortReceive.ino
@@ -0,0 +1,93 @@
+/*
+ Software serial multple serial test
+
+ Receives from the two software serial ports,
+ sends to the hardware serial port.
+
+ In order to listen on a software port, you call port.listen().
+ When using two software serial ports, you have to switch ports
+ by listen()ing on each one in turn. Pick a logical time to switch
+ ports, like the end of an expected transmission, or when the
+ buffer is empty. This example switches ports when there is nothing
+ more to read from a port
+
+ The circuit:
+ Two devices which communicate serially are needed.
+ * First serial device's TX attached to digital pin 2, RX to pin 3
+ * Second serial device's TX attached to digital pin 4, RX to pin 5
+
+ Note:
+ Not all pins on the Mega and Mega 2560 support change interrupts,
+ so only the following can be used for RX:
+ 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69
+
+ Not all pins on the Leonardo support change interrupts,
+ so only the following can be used for RX:
+ 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).
+
+ created 18 Apr. 2011
+ modified 25 May 2012
+ by Tom Igoe
+ based on Mikal Hart's twoPortRXExample
+
+ This example code is in the public domain.
+
+ */
+
+#include <SoftwareSerial.h>
+// software serial #1: TX = digital pin 10, RX = digital pin 11
+SoftwareSerial portOne(10, 11);
+
+// software serial #2: TX = digital pin 8, RX = digital pin 9
+// on the Mega, use other pins instead, since 8 and 9 don't work on the Mega
+SoftwareSerial portTwo(8, 9);
+
+void setup()
+{
+ // Open serial communications and wait for port to open:
+ Serial.begin(9600);
+ while (!Serial) {
+ ; // wait for serial port to connect. Needed for Leonardo only
+ }
+
+
+ // Start each software serial port
+ portOne.begin(9600);
+ portTwo.begin(9600);
+}
+
+void loop()
+{
+ // By default, the last intialized port is listening.
+ // when you want to listen on a port, explicitly select it:
+ portOne.listen();
+ Serial.println("Data from port one:");
+ // while there is data coming in, read it
+ // and send to the hardware serial port:
+ while (portOne.available() > 0) {
+ char inByte = portOne.read();
+ Serial.write(inByte);
+ }
+
+ // blank line to separate data from the two ports:
+ Serial.println();
+
+ // Now listen on the second port
+ portTwo.listen();
+ // while there is data coming in, read it
+ // and send to the hardware serial port:
+ Serial.println("Data from port two:");
+ while (portTwo.available() > 0) {
+ char inByte = portTwo.read();
+ Serial.write(inByte);
+ }
+
+ // blank line to separate data from the two ports:
+ Serial.println();
+}
+
+
+
+
+
+
diff --git a/libraries/SoftwareSerial/keywords.txt b/libraries/SoftwareSerial/keywords.txt
new file mode 100644
index 0000000..aaea17c
--- /dev/null
+++ b/libraries/SoftwareSerial/keywords.txt
@@ -0,0 +1,30 @@
+#######################################
+# Syntax Coloring Map for SoftwareSerial
+# (formerly NewSoftSerial)
+#######################################
+
+#######################################
+# Datatypes (KEYWORD1)
+#######################################
+
+SoftwareSerial KEYWORD1
+
+#######################################
+# Methods and Functions (KEYWORD2)
+#######################################
+
+begin KEYWORD2
+end KEYWORD2
+read KEYWORD2
+write KEYWORD2
+available KEYWORD2
+isListening KEYWORD2
+overflow KEYWORD2
+flush KEYWORD2
+listen KEYWORD2
+peek KEYWORD2
+
+#######################################
+# Constants (LITERAL1)
+#######################################
+
diff --git a/libraries/Wire/Wire.cpp b/libraries/Wire/Wire.cpp
new file mode 100644
index 0000000..4e7a17c
--- /dev/null
+++ b/libraries/Wire/Wire.cpp
@@ -0,0 +1,298 @@
+/*
+ TwoWire.cpp - TWI/I2C library for Wiring & Arduino
+ Copyright (c) 2006 Nicholas Zambetti. 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
+
+ Modified 2012 by Todd Krein (todd@krein.org) to implement repeated starts
+*/
+
+extern "C" {
+ #include <stdlib.h>
+ #include <string.h>
+ #include <inttypes.h>
+ #include "twi.h"
+}
+
+#include "Wire.h"
+
+// Initialize Class Variables //////////////////////////////////////////////////
+
+uint8_t TwoWire::rxBuffer[BUFFER_LENGTH];
+uint8_t TwoWire::rxBufferIndex = 0;
+uint8_t TwoWire::rxBufferLength = 0;
+
+uint8_t TwoWire::txAddress = 0;
+uint8_t TwoWire::txBuffer[BUFFER_LENGTH];
+uint8_t TwoWire::txBufferIndex = 0;
+uint8_t TwoWire::txBufferLength = 0;
+
+uint8_t TwoWire::transmitting = 0;
+void (*TwoWire::user_onRequest)(void);
+void (*TwoWire::user_onReceive)(int);
+
+// Constructors ////////////////////////////////////////////////////////////////
+
+TwoWire::TwoWire()
+{
+}
+
+// Public Methods //////////////////////////////////////////////////////////////
+
+void TwoWire::begin(void)
+{
+ rxBufferIndex = 0;
+ rxBufferLength = 0;
+
+ txBufferIndex = 0;
+ txBufferLength = 0;
+
+ twi_init();
+}
+
+void TwoWire::begin(uint8_t address)
+{
+ twi_setAddress(address);
+ twi_attachSlaveTxEvent(onRequestService);
+ twi_attachSlaveRxEvent(onReceiveService);
+ begin();
+}
+
+void TwoWire::begin(int address)
+{
+ begin((uint8_t)address);
+}
+
+uint8_t TwoWire::requestFrom(uint8_t address, uint8_t quantity, uint8_t sendStop)
+{
+ // clamp to buffer length
+ if(quantity > BUFFER_LENGTH){
+ quantity = BUFFER_LENGTH;
+ }
+ // perform blocking read into buffer
+ uint8_t read = twi_readFrom(address, rxBuffer, quantity, sendStop);
+ // set rx buffer iterator vars
+ rxBufferIndex = 0;
+ rxBufferLength = read;
+
+ return read;
+}
+
+uint8_t TwoWire::requestFrom(uint8_t address, uint8_t quantity)
+{
+ return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)true);
+}
+
+uint8_t TwoWire::requestFrom(int address, int quantity)
+{
+ return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)true);
+}
+
+uint8_t TwoWire::requestFrom(int address, int quantity, int sendStop)
+{
+ return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)sendStop);
+}
+
+void TwoWire::beginTransmission(uint8_t address)
+{
+ // indicate that we are transmitting
+ transmitting = 1;
+ // set address of targeted slave
+ txAddress = address;
+ // reset tx buffer iterator vars
+ txBufferIndex = 0;
+ txBufferLength = 0;
+}
+
+void TwoWire::beginTransmission(int address)
+{
+ beginTransmission((uint8_t)address);
+}
+
+//
+// Originally, 'endTransmission' was an f(void) function.
+// It has been modified to take one parameter indicating
+// whether or not a STOP should be performed on the bus.
+// Calling endTransmission(false) allows a sketch to
+// perform a repeated start.
+//
+// WARNING: Nothing in the library keeps track of whether
+// the bus tenure has been properly ended with a STOP. It
+// is very possible to leave the bus in a hung state if
+// no call to endTransmission(true) is made. Some I2C
+// devices will behave oddly if they do not see a STOP.
+//
+uint8_t TwoWire::endTransmission(uint8_t sendStop)
+{
+ // transmit buffer (blocking)
+ int8_t ret = twi_writeTo(txAddress, txBuffer, txBufferLength, 1, sendStop);
+ // reset tx buffer iterator vars
+ txBufferIndex = 0;
+ txBufferLength = 0;
+ // indicate that we are done transmitting
+ transmitting = 0;
+ return ret;
+}
+
+// This provides backwards compatibility with the original
+// definition, and expected behaviour, of endTransmission
+//
+uint8_t TwoWire::endTransmission(void)
+{
+ return endTransmission(true);
+}
+
+// must be called in:
+// slave tx event callback
+// or after beginTransmission(address)
+size_t TwoWire::write(uint8_t data)
+{
+ if(transmitting){
+ // in master transmitter mode
+ // don't bother if buffer is full
+ if(txBufferLength >= BUFFER_LENGTH){
+ setWriteError();
+ return 0;
+ }
+ // put byte in tx buffer
+ txBuffer[txBufferIndex] = data;
+ ++txBufferIndex;
+ // update amount in buffer
+ txBufferLength = txBufferIndex;
+ }else{
+ // in slave send mode
+ // reply to master
+ twi_transmit(&data, 1);
+ }
+ return 1;
+}
+
+// must be called in:
+// slave tx event callback
+// or after beginTransmission(address)
+size_t TwoWire::write(const uint8_t *data, size_t quantity)
+{
+ if(transmitting){
+ // in master transmitter mode
+ for(size_t i = 0; i < quantity; ++i){
+ write(data[i]);
+ }
+ }else{
+ // in slave send mode
+ // reply to master
+ twi_transmit(data, quantity);
+ }
+ return quantity;
+}
+
+// must be called in:
+// slave rx event callback
+// or after requestFrom(address, numBytes)
+int TwoWire::available(void)
+{
+ return rxBufferLength - rxBufferIndex;
+}
+
+// must be called in:
+// slave rx event callback
+// or after requestFrom(address, numBytes)
+int TwoWire::read(void)
+{
+ int value = -1;
+
+ // get each successive byte on each call
+ if(rxBufferIndex < rxBufferLength){
+ value = rxBuffer[rxBufferIndex];
+ ++rxBufferIndex;
+ }
+
+ return value;
+}
+
+// must be called in:
+// slave rx event callback
+// or after requestFrom(address, numBytes)
+int TwoWire::peek(void)
+{
+ int value = -1;
+
+ if(rxBufferIndex < rxBufferLength){
+ value = rxBuffer[rxBufferIndex];
+ }
+
+ return value;
+}
+
+void TwoWire::flush(void)
+{
+ // XXX: to be implemented.
+}
+
+// behind the scenes function that is called when data is received
+void TwoWire::onReceiveService(uint8_t* inBytes, int numBytes)
+{
+ // don't bother if user hasn't registered a callback
+ if(!user_onReceive){
+ return;
+ }
+ // don't bother if rx buffer is in use by a master requestFrom() op
+ // i know this drops data, but it allows for slight stupidity
+ // meaning, they may not have read all the master requestFrom() data yet
+ if(rxBufferIndex < rxBufferLength){
+ return;
+ }
+ // copy twi rx buffer into local read buffer
+ // this enables new reads to happen in parallel
+ for(uint8_t i = 0; i < numBytes; ++i){
+ rxBuffer[i] = inBytes[i];
+ }
+ // set rx iterator vars
+ rxBufferIndex = 0;
+ rxBufferLength = numBytes;
+ // alert user program
+ user_onReceive(numBytes);
+}
+
+// behind the scenes function that is called when data is requested
+void TwoWire::onRequestService(void)
+{
+ // don't bother if user hasn't registered a callback
+ if(!user_onRequest){
+ return;
+ }
+ // reset tx buffer iterator vars
+ // !!! this will kill any pending pre-master sendTo() activity
+ txBufferIndex = 0;
+ txBufferLength = 0;
+ // alert user program
+ user_onRequest();
+}
+
+// sets function called on slave write
+void TwoWire::onReceive( void (*function)(int) )
+{
+ user_onReceive = function;
+}
+
+// sets function called on slave read
+void TwoWire::onRequest( void (*function)(void) )
+{
+ user_onRequest = function;
+}
+
+// Preinstantiate Objects //////////////////////////////////////////////////////
+
+TwoWire Wire = TwoWire();
+
diff --git a/libraries/Wire/Wire.h b/libraries/Wire/Wire.h
new file mode 100644
index 0000000..a93d0f5
--- /dev/null
+++ b/libraries/Wire/Wire.h
@@ -0,0 +1,79 @@
+/*
+ TwoWire.h - TWI/I2C library for Arduino & Wiring
+ Copyright (c) 2006 Nicholas Zambetti. 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
+
+ Modified 2012 by Todd Krein (todd@krein.org) to implement repeated starts
+*/
+
+#ifndef TwoWire_h
+#define TwoWire_h
+
+#include <inttypes.h>
+#include "Stream.h"
+
+#define BUFFER_LENGTH 32
+
+class TwoWire : public Stream
+{
+ private:
+ static uint8_t rxBuffer[];
+ static uint8_t rxBufferIndex;
+ static uint8_t rxBufferLength;
+
+ static uint8_t txAddress;
+ static uint8_t txBuffer[];
+ static uint8_t txBufferIndex;
+ static uint8_t txBufferLength;
+
+ static uint8_t transmitting;
+ static void (*user_onRequest)(void);
+ static void (*user_onReceive)(int);
+ static void onRequestService(void);
+ static void onReceiveService(uint8_t*, int);
+ public:
+ TwoWire();
+ void begin();
+ void begin(uint8_t);
+ void begin(int);
+ void beginTransmission(uint8_t);
+ void beginTransmission(int);
+ uint8_t endTransmission(void);
+ uint8_t endTransmission(uint8_t);
+ uint8_t requestFrom(uint8_t, uint8_t);
+ uint8_t requestFrom(uint8_t, uint8_t, uint8_t);
+ uint8_t requestFrom(int, int);
+ uint8_t requestFrom(int, int, int);
+ virtual size_t write(uint8_t);
+ virtual size_t write(const uint8_t *, size_t);
+ virtual int available(void);
+ virtual int read(void);
+ virtual int peek(void);
+ virtual void flush(void);
+ void onReceive( void (*)(int) );
+ void onRequest( void (*)(void) );
+
+ inline size_t write(unsigned long n) { return write((uint8_t)n); }
+ inline size_t write(long n) { return write((uint8_t)n); }
+ inline size_t write(unsigned int n) { return write((uint8_t)n); }
+ inline size_t write(int n) { return write((uint8_t)n); }
+ using Print::write;
+};
+
+extern TwoWire Wire;
+
+#endif
+
diff --git a/libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.ino b/libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.ino
new file mode 100644
index 0000000..d97a9e3
--- /dev/null
+++ b/libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.ino
@@ -0,0 +1,87 @@
+// I2C SRF10 or SRF08 Devantech Ultrasonic Ranger Finder
+// by Nicholas Zambetti <http://www.zambetti.com>
+// and James Tichenor <http://www.jamestichenor.net>
+
+// Demonstrates use of the Wire library reading data from the
+// Devantech Utrasonic Rangers SFR08 and SFR10
+
+// Created 29 April 2006
+
+// This example code is in the public domain.
+
+
+#include <Wire.h>
+
+void setup()
+{
+ Wire.begin(); // join i2c bus (address optional for master)
+ Serial.begin(9600); // start serial communication at 9600bps
+}
+
+int reading = 0;
+
+void loop()
+{
+ // step 1: instruct sensor to read echoes
+ Wire.beginTransmission(112); // transmit to device #112 (0x70)
+ // the address specified in the datasheet is 224 (0xE0)
+ // but i2c adressing uses the high 7 bits so it's 112
+ Wire.write(byte(0x00)); // sets register pointer to the command register (0x00)
+ Wire.write(byte(0x50)); // command sensor to measure in "inches" (0x50)
+ // use 0x51 for centimeters
+ // use 0x52 for ping microseconds
+ Wire.endTransmission(); // stop transmitting
+
+ // step 2: wait for readings to happen
+ delay(70); // datasheet suggests at least 65 milliseconds
+
+ // step 3: instruct sensor to return a particular echo reading
+ Wire.beginTransmission(112); // transmit to device #112
+ Wire.write(byte(0x02)); // sets register pointer to echo #1 register (0x02)
+ Wire.endTransmission(); // stop transmitting
+
+ // step 4: request reading from sensor
+ Wire.requestFrom(112, 2); // request 2 bytes from slave device #112
+
+ // step 5: receive reading from sensor
+ if (2 <= Wire.available()) // if two bytes were received
+ {
+ reading = Wire.read(); // receive high byte (overwrites previous reading)
+ reading = reading << 8; // shift high byte to be high 8 bits
+ reading |= Wire.read(); // receive low byte as lower 8 bits
+ Serial.println(reading); // print the reading
+ }
+
+ delay(250); // wait a bit since people have to read the output :)
+}
+
+
+/*
+
+// The following code changes the address of a Devantech Ultrasonic Range Finder (SRF10 or SRF08)
+// usage: changeAddress(0x70, 0xE6);
+
+void changeAddress(byte oldAddress, byte newAddress)
+{
+ Wire.beginTransmission(oldAddress);
+ Wire.write(byte(0x00));
+ Wire.write(byte(0xA0));
+ Wire.endTransmission();
+
+ Wire.beginTransmission(oldAddress);
+ Wire.write(byte(0x00));
+ Wire.write(byte(0xAA));
+ Wire.endTransmission();
+
+ Wire.beginTransmission(oldAddress);
+ Wire.write(byte(0x00));
+ Wire.write(byte(0xA5));
+ Wire.endTransmission();
+
+ Wire.beginTransmission(oldAddress);
+ Wire.write(byte(0x00));
+ Wire.write(newAddress);
+ Wire.endTransmission();
+}
+
+*/
diff --git a/libraries/Wire/examples/digital_potentiometer/digital_potentiometer.ino b/libraries/Wire/examples/digital_potentiometer/digital_potentiometer.ino
new file mode 100644
index 0000000..4d1580a
--- /dev/null
+++ b/libraries/Wire/examples/digital_potentiometer/digital_potentiometer.ino
@@ -0,0 +1,39 @@
+// I2C Digital Potentiometer
+// by Nicholas Zambetti <http://www.zambetti.com>
+// and Shawn Bonkowski <http://people.interaction-ivrea.it/s.bonkowski/>
+
+// Demonstrates use of the Wire library
+// Controls AD5171 digital potentiometer via I2C/TWI
+
+// Created 31 March 2006
+
+// This example code is in the public domain.
+
+// This example code is in the public domain.
+
+
+#include <Wire.h>
+
+void setup()
+{
+ Wire.begin(); // join i2c bus (address optional for master)
+}
+
+byte val = 0;
+
+void loop()
+{
+ Wire.beginTransmission(44); // transmit to device #44 (0x2c)
+ // device address is specified in datasheet
+ Wire.write(byte(0x00)); // sends instruction byte
+ Wire.write(val); // sends potentiometer value byte
+ Wire.endTransmission(); // stop transmitting
+
+ val++; // increment value
+ if (val == 64) // if reached 64th position (max)
+ {
+ val = 0; // start over from lowest value
+ }
+ delay(500);
+}
+
diff --git a/libraries/Wire/examples/master_reader/master_reader.ino b/libraries/Wire/examples/master_reader/master_reader.ino
new file mode 100644
index 0000000..74f0155
--- /dev/null
+++ b/libraries/Wire/examples/master_reader/master_reader.ino
@@ -0,0 +1,32 @@
+// Wire Master Reader
+// by Nicholas Zambetti <http://www.zambetti.com>
+
+// Demonstrates use of the Wire library
+// Reads data from an I2C/TWI slave device
+// Refer to the "Wire Slave Sender" example for use with this
+
+// Created 29 March 2006
+
+// This example code is in the public domain.
+
+
+#include <Wire.h>
+
+void setup()
+{
+ Wire.begin(); // join i2c bus (address optional for master)
+ Serial.begin(9600); // start serial for output
+}
+
+void loop()
+{
+ Wire.requestFrom(2, 6); // request 6 bytes from slave device #2
+
+ while (Wire.available()) // slave may send less than requested
+ {
+ char c = Wire.read(); // receive a byte as character
+ Serial.print(c); // print the character
+ }
+
+ delay(500);
+}
diff --git a/libraries/Wire/examples/master_writer/master_writer.ino b/libraries/Wire/examples/master_writer/master_writer.ino
new file mode 100644
index 0000000..482e922
--- /dev/null
+++ b/libraries/Wire/examples/master_writer/master_writer.ino
@@ -0,0 +1,31 @@
+// Wire Master Writer
+// by Nicholas Zambetti <http://www.zambetti.com>
+
+// Demonstrates use of the Wire library
+// Writes data to an I2C/TWI slave device
+// Refer to the "Wire Slave Receiver" example for use with this
+
+// Created 29 March 2006
+
+// This example code is in the public domain.
+
+
+#include <Wire.h>
+
+void setup()
+{
+ Wire.begin(); // join i2c bus (address optional for master)
+}
+
+byte x = 0;
+
+void loop()
+{
+ Wire.beginTransmission(4); // transmit to device #4
+ Wire.write("x is "); // sends five bytes
+ Wire.write(x); // sends one byte
+ Wire.endTransmission(); // stop transmitting
+
+ x++;
+ delay(500);
+}
diff --git a/libraries/Wire/examples/slave_receiver/slave_receiver.ino b/libraries/Wire/examples/slave_receiver/slave_receiver.ino
new file mode 100644
index 0000000..15eff9a
--- /dev/null
+++ b/libraries/Wire/examples/slave_receiver/slave_receiver.ino
@@ -0,0 +1,38 @@
+// Wire Slave Receiver
+// by Nicholas Zambetti <http://www.zambetti.com>
+
+// Demonstrates use of the Wire library
+// Receives data as an I2C/TWI slave device
+// Refer to the "Wire Master Writer" example for use with this
+
+// Created 29 March 2006
+
+// This example code is in the public domain.
+
+
+#include <Wire.h>
+
+void setup()
+{
+ Wire.begin(4); // join i2c bus with address #4
+ Wire.onReceive(receiveEvent); // register event
+ Serial.begin(9600); // start serial for output
+}
+
+void loop()
+{
+ delay(100);
+}
+
+// function that executes whenever data is received from master
+// this function is registered as an event, see setup()
+void receiveEvent(int howMany)
+{
+ while (1 < Wire.available()) // loop through all but the last
+ {
+ char c = Wire.read(); // receive byte as a character
+ Serial.print(c); // print the character
+ }
+ int x = Wire.read(); // receive byte as an integer
+ Serial.println(x); // print the integer
+}
diff --git a/libraries/Wire/examples/slave_sender/slave_sender.ino b/libraries/Wire/examples/slave_sender/slave_sender.ino
new file mode 100644
index 0000000..4437ab1
--- /dev/null
+++ b/libraries/Wire/examples/slave_sender/slave_sender.ino
@@ -0,0 +1,32 @@
+// Wire Slave Sender
+// by Nicholas Zambetti <http://www.zambetti.com>
+
+// Demonstrates use of the Wire library
+// Sends data as an I2C/TWI slave device
+// Refer to the "Wire Master Reader" example for use with this
+
+// Created 29 March 2006
+
+// This example code is in the public domain.
+
+
+#include <Wire.h>
+
+void setup()
+{
+ Wire.begin(2); // join i2c bus with address #2
+ Wire.onRequest(requestEvent); // register event
+}
+
+void loop()
+{
+ delay(100);
+}
+
+// function that executes whenever data is requested by master
+// this function is registered as an event, see setup()
+void requestEvent()
+{
+ Wire.write("hello "); // respond with message of 6 bytes
+ // as expected by master
+}
diff --git a/libraries/Wire/keywords.txt b/libraries/Wire/keywords.txt
new file mode 100644
index 0000000..12f129b
--- /dev/null
+++ b/libraries/Wire/keywords.txt
@@ -0,0 +1,31 @@
+#######################################
+# Syntax Coloring Map For Wire
+#######################################
+
+#######################################
+# Datatypes (KEYWORD1)
+#######################################
+
+#######################################
+# Methods and Functions (KEYWORD2)
+#######################################
+
+begin KEYWORD2
+beginTransmission KEYWORD2
+endTransmission KEYWORD2
+requestFrom KEYWORD2
+send KEYWORD2
+receive KEYWORD2
+onReceive KEYWORD2
+onRequest KEYWORD2
+
+#######################################
+# Instances (KEYWORD2)
+#######################################
+
+Wire KEYWORD2
+
+#######################################
+# Constants (LITERAL1)
+#######################################
+
diff --git a/libraries/Wire/utility/twi.c b/libraries/Wire/utility/twi.c
new file mode 100644
index 0000000..201d7d1
--- /dev/null
+++ b/libraries/Wire/utility/twi.c
@@ -0,0 +1,527 @@
+/*
+ twi.c - TWI/I2C library for Wiring & Arduino
+ Copyright (c) 2006 Nicholas Zambetti. 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
+
+ Modified 2012 by Todd Krein (todd@krein.org) to implement repeated starts
+*/
+
+#include <math.h>
+#include <stdlib.h>
+#include <inttypes.h>
+#include <avr/io.h>
+#include <avr/interrupt.h>
+#include <compat/twi.h>
+#include "Arduino.h" // for digitalWrite
+
+#ifndef cbi
+#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
+#endif
+
+#ifndef sbi
+#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
+#endif
+
+#include "pins_arduino.h"
+#include "twi.h"
+
+static volatile uint8_t twi_state;
+static volatile uint8_t twi_slarw;
+static volatile uint8_t twi_sendStop; // should the transaction end with a stop
+static volatile uint8_t twi_inRepStart; // in the middle of a repeated start
+
+static void (*twi_onSlaveTransmit)(void);
+static void (*twi_onSlaveReceive)(uint8_t*, int);
+
+static uint8_t twi_masterBuffer[TWI_BUFFER_LENGTH];
+static volatile uint8_t twi_masterBufferIndex;
+static volatile uint8_t twi_masterBufferLength;
+
+static uint8_t twi_txBuffer[TWI_BUFFER_LENGTH];
+static volatile uint8_t twi_txBufferIndex;
+static volatile uint8_t twi_txBufferLength;
+
+static uint8_t twi_rxBuffer[TWI_BUFFER_LENGTH];
+static volatile uint8_t twi_rxBufferIndex;
+
+static volatile uint8_t twi_error;
+
+/*
+ * Function twi_init
+ * Desc readys twi pins and sets twi bitrate
+ * Input none
+ * Output none
+ */
+void twi_init(void)
+{
+ // initialize state
+ twi_state = TWI_READY;
+ twi_sendStop = true; // default value
+ twi_inRepStart = false;
+
+ // activate internal pullups for twi.
+ digitalWrite(SDA, 1);
+ digitalWrite(SCL, 1);
+
+ // initialize twi prescaler and bit rate
+ cbi(TWSR, TWPS0);
+ cbi(TWSR, TWPS1);
+ TWBR = ((F_CPU / TWI_FREQ) - 16) / 2;
+
+ /* twi bit rate formula from atmega128 manual pg 204
+ SCL Frequency = CPU Clock Frequency / (16 + (2 * TWBR))
+ note: TWBR should be 10 or higher for master mode
+ It is 72 for a 16mhz Wiring board with 100kHz TWI */
+
+ // enable twi module, acks, and twi interrupt
+ TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA);
+}
+
+/*
+ * Function twi_slaveInit
+ * Desc sets slave address and enables interrupt
+ * Input none
+ * Output none
+ */
+void twi_setAddress(uint8_t address)
+{
+ // set twi slave address (skip over TWGCE bit)
+ TWAR = address << 1;
+}
+
+/*
+ * Function twi_readFrom
+ * Desc attempts to become twi bus master and read a
+ * series of bytes from a device on the bus
+ * Input address: 7bit i2c device address
+ * data: pointer to byte array
+ * length: number of bytes to read into array
+ * sendStop: Boolean indicating whether to send a stop at the end
+ * Output number of bytes read
+ */
+uint8_t twi_readFrom(uint8_t address, uint8_t* data, uint8_t length, uint8_t sendStop)
+{
+ uint8_t i;
+
+ // ensure data will fit into buffer
+ if(TWI_BUFFER_LENGTH < length){
+ return 0;
+ }
+
+ // wait until twi is ready, become master receiver
+ while(TWI_READY != twi_state){
+ continue;
+ }
+ twi_state = TWI_MRX;
+ twi_sendStop = sendStop;
+ // reset error state (0xFF.. no error occured)
+ twi_error = 0xFF;
+
+ // initialize buffer iteration vars
+ twi_masterBufferIndex = 0;
+ twi_masterBufferLength = length-1; // This is not intuitive, read on...
+ // On receive, the previously configured ACK/NACK setting is transmitted in
+ // response to the received byte before the interrupt is signalled.
+ // Therefor we must actually set NACK when the _next_ to last byte is
+ // received, causing that NACK to be sent in response to receiving the last
+ // expected byte of data.
+
+ // build sla+w, slave device address + w bit
+ twi_slarw = TW_READ;
+ twi_slarw |= address << 1;
+
+ if (true == twi_inRepStart) {
+ // if we're in the repeated start state, then we've already sent the start,
+ // (@@@ we hope), and the TWI statemachine is just waiting for the address byte.
+ // We need to remove ourselves from the repeated start state before we enable interrupts,
+ // since the ISR is ASYNC, and we could get confused if we hit the ISR before cleaning
+ // up. Also, don't enable the START interrupt. There may be one pending from the
+ // repeated start that we sent outselves, and that would really confuse things.
+ twi_inRepStart = false; // remember, we're dealing with an ASYNC ISR
+ TWDR = twi_slarw;
+ TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE); // enable INTs, but not START
+ }
+ else
+ // send start condition
+ TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTA);
+
+ // wait for read operation to complete
+ while(TWI_MRX == twi_state){
+ continue;
+ }
+
+ if (twi_masterBufferIndex < length)
+ length = twi_masterBufferIndex;
+
+ // copy twi buffer to data
+ for(i = 0; i < length; ++i){
+ data[i] = twi_masterBuffer[i];
+ }
+
+ return length;
+}
+
+/*
+ * Function twi_writeTo
+ * Desc attempts to become twi bus master and write a
+ * series of bytes to a device on the bus
+ * Input address: 7bit i2c device address
+ * data: pointer to byte array
+ * length: number of bytes in array
+ * wait: boolean indicating to wait for write or not
+ * sendStop: boolean indicating whether or not to send a stop at the end
+ * Output 0 .. success
+ * 1 .. length to long for buffer
+ * 2 .. address send, NACK received
+ * 3 .. data send, NACK received
+ * 4 .. other twi error (lost bus arbitration, bus error, ..)
+ */
+uint8_t twi_writeTo(uint8_t address, uint8_t* data, uint8_t length, uint8_t wait, uint8_t sendStop)
+{
+ uint8_t i;
+
+ // ensure data will fit into buffer
+ if(TWI_BUFFER_LENGTH < length){
+ return 1;
+ }
+
+ // wait until twi is ready, become master transmitter
+ while(TWI_READY != twi_state){
+ continue;
+ }
+ twi_state = TWI_MTX;
+ twi_sendStop = sendStop;
+ // reset error state (0xFF.. no error occured)
+ twi_error = 0xFF;
+
+ // initialize buffer iteration vars
+ twi_masterBufferIndex = 0;
+ twi_masterBufferLength = length;
+
+ // copy data to twi buffer
+ for(i = 0; i < length; ++i){
+ twi_masterBuffer[i] = data[i];
+ }
+
+ // build sla+w, slave device address + w bit
+ twi_slarw = TW_WRITE;
+ twi_slarw |= address << 1;
+
+ // if we're in a repeated start, then we've already sent the START
+ // in the ISR. Don't do it again.
+ //
+ if (true == twi_inRepStart) {
+ // if we're in the repeated start state, then we've already sent the start,
+ // (@@@ we hope), and the TWI statemachine is just waiting for the address byte.
+ // We need to remove ourselves from the repeated start state before we enable interrupts,
+ // since the ISR is ASYNC, and we could get confused if we hit the ISR before cleaning
+ // up. Also, don't enable the START interrupt. There may be one pending from the
+ // repeated start that we sent outselves, and that would really confuse things.
+ twi_inRepStart = false; // remember, we're dealing with an ASYNC ISR
+ TWDR = twi_slarw;
+ TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE); // enable INTs, but not START
+ }
+ else
+ // send start condition
+ TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE) | _BV(TWSTA); // enable INTs
+
+ // wait for write operation to complete
+ while(wait && (TWI_MTX == twi_state)){
+ continue;
+ }
+
+ if (twi_error == 0xFF)
+ return 0; // success
+ else if (twi_error == TW_MT_SLA_NACK)
+ return 2; // error: address send, nack received
+ else if (twi_error == TW_MT_DATA_NACK)
+ return 3; // error: data send, nack received
+ else
+ return 4; // other twi error
+}
+
+/*
+ * Function twi_transmit
+ * Desc fills slave tx buffer with data
+ * must be called in slave tx event callback
+ * Input data: pointer to byte array
+ * length: number of bytes in array
+ * Output 1 length too long for buffer
+ * 2 not slave transmitter
+ * 0 ok
+ */
+uint8_t twi_transmit(const uint8_t* data, uint8_t length)
+{
+ uint8_t i;
+
+ // ensure data will fit into buffer
+ if(TWI_BUFFER_LENGTH < length){
+ return 1;
+ }
+
+ // ensure we are currently a slave transmitter
+ if(TWI_STX != twi_state){
+ return 2;
+ }
+
+ // set length and copy data into tx buffer
+ twi_txBufferLength = length;
+ for(i = 0; i < length; ++i){
+ twi_txBuffer[i] = data[i];
+ }
+
+ return 0;
+}
+
+/*
+ * Function twi_attachSlaveRxEvent
+ * Desc sets function called before a slave read operation
+ * Input function: callback function to use
+ * Output none
+ */
+void twi_attachSlaveRxEvent( void (*function)(uint8_t*, int) )
+{
+ twi_onSlaveReceive = function;
+}
+
+/*
+ * Function twi_attachSlaveTxEvent
+ * Desc sets function called before a slave write operation
+ * Input function: callback function to use
+ * Output none
+ */
+void twi_attachSlaveTxEvent( void (*function)(void) )
+{
+ twi_onSlaveTransmit = function;
+}
+
+/*
+ * Function twi_reply
+ * Desc sends byte or readys receive line
+ * Input ack: byte indicating to ack or to nack
+ * Output none
+ */
+void twi_reply(uint8_t ack)
+{
+ // transmit master read ready signal, with or without ack
+ if(ack){
+ TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWINT) | _BV(TWEA);
+ }else{
+ TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWINT);
+ }
+}
+
+/*
+ * Function twi_stop
+ * Desc relinquishes bus master status
+ * Input none
+ * Output none
+ */
+void twi_stop(void)
+{
+ // send stop condition
+ TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTO);
+
+ // wait for stop condition to be exectued on bus
+ // TWINT is not set after a stop condition!
+ while(TWCR & _BV(TWSTO)){
+ continue;
+ }
+
+ // update twi state
+ twi_state = TWI_READY;
+}
+
+/*
+ * Function twi_releaseBus
+ * Desc releases bus control
+ * Input none
+ * Output none
+ */
+void twi_releaseBus(void)
+{
+ // release bus
+ TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT);
+
+ // update twi state
+ twi_state = TWI_READY;
+}
+
+ISR(TWI_vect)
+{
+ switch(TW_STATUS){
+ // All Master
+ case TW_START: // sent start condition
+ case TW_REP_START: // sent repeated start condition
+ // copy device address and r/w bit to output register and ack
+ TWDR = twi_slarw;
+ twi_reply(1);
+ break;
+
+ // Master Transmitter
+ case TW_MT_SLA_ACK: // slave receiver acked address
+ case TW_MT_DATA_ACK: // slave receiver acked data
+ // if there is data to send, send it, otherwise stop
+ if(twi_masterBufferIndex < twi_masterBufferLength){
+ // copy data to output register and ack
+ TWDR = twi_masterBuffer[twi_masterBufferIndex++];
+ twi_reply(1);
+ }else{
+ if (twi_sendStop)
+ twi_stop();
+ else {
+ twi_inRepStart = true; // we're gonna send the START
+ // don't enable the interrupt. We'll generate the start, but we
+ // avoid handling the interrupt until we're in the next transaction,
+ // at the point where we would normally issue the start.
+ TWCR = _BV(TWINT) | _BV(TWSTA)| _BV(TWEN) ;
+ twi_state = TWI_READY;
+ }
+ }
+ break;
+ case TW_MT_SLA_NACK: // address sent, nack received
+ twi_error = TW_MT_SLA_NACK;
+ twi_stop();
+ break;
+ case TW_MT_DATA_NACK: // data sent, nack received
+ twi_error = TW_MT_DATA_NACK;
+ twi_stop();
+ break;
+ case TW_MT_ARB_LOST: // lost bus arbitration
+ twi_error = TW_MT_ARB_LOST;
+ twi_releaseBus();
+ break;
+
+ // Master Receiver
+ case TW_MR_DATA_ACK: // data received, ack sent
+ // put byte into buffer
+ twi_masterBuffer[twi_masterBufferIndex++] = TWDR;
+ case TW_MR_SLA_ACK: // address sent, ack received
+ // ack if more bytes are expected, otherwise nack
+ if(twi_masterBufferIndex < twi_masterBufferLength){
+ twi_reply(1);
+ }else{
+ twi_reply(0);
+ }
+ break;
+ case TW_MR_DATA_NACK: // data received, nack sent
+ // put final byte into buffer
+ twi_masterBuffer[twi_masterBufferIndex++] = TWDR;
+ if (twi_sendStop)
+ twi_stop();
+ else {
+ twi_inRepStart = true; // we're gonna send the START
+ // don't enable the interrupt. We'll generate the start, but we
+ // avoid handling the interrupt until we're in the next transaction,
+ // at the point where we would normally issue the start.
+ TWCR = _BV(TWINT) | _BV(TWSTA)| _BV(TWEN) ;
+ twi_state = TWI_READY;
+ }
+ break;
+ case TW_MR_SLA_NACK: // address sent, nack received
+ twi_stop();
+ break;
+ // TW_MR_ARB_LOST handled by TW_MT_ARB_LOST case
+
+ // Slave Receiver
+ case TW_SR_SLA_ACK: // addressed, returned ack
+ case TW_SR_GCALL_ACK: // addressed generally, returned ack
+ case TW_SR_ARB_LOST_SLA_ACK: // lost arbitration, returned ack
+ case TW_SR_ARB_LOST_GCALL_ACK: // lost arbitration, returned ack
+ // enter slave receiver mode
+ twi_state = TWI_SRX;
+ // indicate that rx buffer can be overwritten and ack
+ twi_rxBufferIndex = 0;
+ twi_reply(1);
+ break;
+ case TW_SR_DATA_ACK: // data received, returned ack
+ case TW_SR_GCALL_DATA_ACK: // data received generally, returned ack
+ // if there is still room in the rx buffer
+ if(twi_rxBufferIndex < TWI_BUFFER_LENGTH){
+ // put byte in buffer and ack
+ twi_rxBuffer[twi_rxBufferIndex++] = TWDR;
+ twi_reply(1);
+ }else{
+ // otherwise nack
+ twi_reply(0);
+ }
+ break;
+ case TW_SR_STOP: // stop or repeated start condition received
+ // put a null char after data if there's room
+ if(twi_rxBufferIndex < TWI_BUFFER_LENGTH){
+ twi_rxBuffer[twi_rxBufferIndex] = '\0';
+ }
+ // sends ack and stops interface for clock stretching
+ twi_stop();
+ // callback to user defined callback
+ twi_onSlaveReceive(twi_rxBuffer, twi_rxBufferIndex);
+ // since we submit rx buffer to "wire" library, we can reset it
+ twi_rxBufferIndex = 0;
+ // ack future responses and leave slave receiver state
+ twi_releaseBus();
+ break;
+ case TW_SR_DATA_NACK: // data received, returned nack
+ case TW_SR_GCALL_DATA_NACK: // data received generally, returned nack
+ // nack back at master
+ twi_reply(0);
+ break;
+
+ // Slave Transmitter
+ case TW_ST_SLA_ACK: // addressed, returned ack
+ case TW_ST_ARB_LOST_SLA_ACK: // arbitration lost, returned ack
+ // enter slave transmitter mode
+ twi_state = TWI_STX;
+ // ready the tx buffer index for iteration
+ twi_txBufferIndex = 0;
+ // set tx buffer length to be zero, to verify if user changes it
+ twi_txBufferLength = 0;
+ // request for txBuffer to be filled and length to be set
+ // note: user must call twi_transmit(bytes, length) to do this
+ twi_onSlaveTransmit();
+ // if they didn't change buffer & length, initialize it
+ if(0 == twi_txBufferLength){
+ twi_txBufferLength = 1;
+ twi_txBuffer[0] = 0x00;
+ }
+ // transmit first byte from buffer, fall
+ case TW_ST_DATA_ACK: // byte sent, ack returned
+ // copy data to output register
+ TWDR = twi_txBuffer[twi_txBufferIndex++];
+ // if there is more to send, ack, otherwise nack
+ if(twi_txBufferIndex < twi_txBufferLength){
+ twi_reply(1);
+ }else{
+ twi_reply(0);
+ }
+ break;
+ case TW_ST_DATA_NACK: // received nack, we are done
+ case TW_ST_LAST_DATA: // received ack, but we are done already!
+ // ack future responses
+ twi_reply(1);
+ // leave slave receiver state
+ twi_state = TWI_READY;
+ break;
+
+ // All
+ case TW_NO_INFO: // no state information
+ break;
+ case TW_BUS_ERROR: // bus error, illegal stop/start
+ twi_error = TW_BUS_ERROR;
+ twi_stop();
+ break;
+ }
+}
+
diff --git a/libraries/Wire/utility/twi.h b/libraries/Wire/utility/twi.h
new file mode 100644
index 0000000..6526593
--- /dev/null
+++ b/libraries/Wire/utility/twi.h
@@ -0,0 +1,53 @@
+/*
+ twi.h - TWI/I2C library for Wiring & Arduino
+ Copyright (c) 2006 Nicholas Zambetti. 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 twi_h
+#define twi_h
+
+ #include <inttypes.h>
+
+ //#define ATMEGA8
+
+ #ifndef TWI_FREQ
+ #define TWI_FREQ 100000L
+ #endif
+
+ #ifndef TWI_BUFFER_LENGTH
+ #define TWI_BUFFER_LENGTH 32
+ #endif
+
+ #define TWI_READY 0
+ #define TWI_MRX 1
+ #define TWI_MTX 2
+ #define TWI_SRX 3
+ #define TWI_STX 4
+
+ void twi_init(void);
+ void twi_setAddress(uint8_t);
+ uint8_t twi_readFrom(uint8_t, uint8_t*, uint8_t, uint8_t);
+ uint8_t twi_writeTo(uint8_t, uint8_t*, uint8_t, uint8_t, uint8_t);
+ uint8_t twi_transmit(const uint8_t*, uint8_t);
+ void twi_attachSlaveRxEvent( void (*)(uint8_t*, int) );
+ void twi_attachSlaveTxEvent( void (*)(void) );
+ void twi_reply(uint8_t);
+ void twi_stop(void);
+ void twi_releaseBus(void);
+
+#endif
+
diff --git a/platform.txt b/platform.txt
new file mode 100644
index 0000000..4e28f0a
--- /dev/null
+++ b/platform.txt
@@ -0,0 +1,94 @@
+
+# Arduino AVR Core and platform.
+# ------------------------------
+
+# For more info:
+# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification
+
+name=Arduino AVR Boards
+version=1.5.5
+
+# AVR compile variables
+# ---------------------
+
+# Default "compiler.path" is correct, change only if you want to overidde the initial value
+#compiler.path={ide.path}/tools/avr/bin/..
+compiler.c.cmd=avr-gcc
+compiler.c.flags=-c -g -Os -w -ffunction-sections -fdata-sections -MMD
+compiler.c.elf.flags=-Os -Wl,--gc-sections
+compiler.c.elf.cmd=avr-gcc
+compiler.S.flags=-c -g -assembler-with-cpp
+compiler.cpp.cmd=avr-g++
+compiler.cpp.flags=-c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD
+compiler.ar.cmd=avr-ar
+compiler.ar.flags=rcs
+compiler.objcopy.cmd=avr-objcopy
+compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0
+compiler.elf2hex.flags=-O ihex -R .eeprom
+compiler.elf2hex.cmd=avr-objcopy
+compiler.ldflags=
+compiler.size.cmd=avr-size
+# this can be overriden in boards.txt
+build.extra_flags=
+
+# AVR compile patterns
+# --------------------
+
+## Compile c files
+recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
+
+## Compile c++ files
+recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
+
+## Compile S files
+recipe.S.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.S.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
+
+## Create archives
+recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} "{build.path}/{archive_file}" "{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} -o "{build.path}/{build.project_name}.elf" {object_files} "{build.path}/{archive_file}" "-L{build.path}" -lm
+
+## Create eeprom
+recipe.objcopy.eep.pattern="{compiler.path}{compiler.objcopy.cmd}" {compiler.objcopy.eep.flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.eep"
+
+## Create hex
+recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex"
+
+## Compute size
+recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf"
+recipe.size.regex=^(?:\.text|\.data|\.bootloader)\s+([0-9]+).*
+recipe.size.regex.data=^(?:\.data|\.bss|\.noinit)\s+([0-9]+).*
+recipe.size.regex.eeprom=^(?:\.eeprom)\s+([0-9]+).*
+
+
+# AVR Uploader/Programmers tools
+# ------------------------------
+
+tools.avrdude.cmd.path={runtime.ide.path}/hardware/tools/avr/bin/avrdude
+tools.avrdude.config.path={runtime.ide.path}/hardware/tools/avr/etc/avrdude.conf
+tools.avrdude.cmd.path.linux={runtime.ide.path}/hardware/tools/avrdude
+tools.avrdude.config.path.linux={runtime.ide.path}/hardware/tools/avrdude.conf
+
+tools.avrdude.upload.params.verbose=-v -v -v -v
+tools.avrdude.upload.params.quiet=-q -q
+tools.avrdude.upload.pattern="{cmd.path}" "-C{config.path}" {upload.verbose} -p{build.mcu} -c{upload.protocol} -P{serial.port} -b{upload.speed} -D "-Uflash:w:{build.path}/{build.project_name}.hex:i"
+
+tools.avrdude.program.params.verbose=-v -v -v -v
+tools.avrdude.program.params.quiet=-q -q
+tools.avrdude.program.pattern="{cmd.path}" "-C{config.path}" {program.verbose} -p{build.mcu} -c{protocol} {program.extra_params} "-Uflash:w:{build.path}/{build.project_name}.hex:i"
+
+tools.avrdude.erase.params.verbose=-v -v -v -v
+tools.avrdude.erase.params.quiet=-q -q
+tools.avrdude.erase.pattern="{cmd.path}" "-C{config.path}" {erase.verbose} -p{build.mcu} -c{protocol} {program.extra_params} -e -Ulock:w:{bootloader.unlock_bits}:m -Uefuse:w:{bootloader.extended_fuses}:m -Uhfuse:w:{bootloader.high_fuses}:m -Ulfuse:w:{bootloader.low_fuses}:m
+
+tools.avrdude.bootloader.params.verbose=-v -v -v -v
+tools.avrdude.bootloader.params.quiet=-q -q
+tools.avrdude.bootloader.pattern="{cmd.path}" "-C{config.path}" {bootloader.verbose} -p{build.mcu} -c{protocol} {program.extra_params} "-Uflash:w:{runtime.ide.path}/hardware/arduino/avr/bootloaders/{bootloader.file}:i" -Ulock:w:{bootloader.lock_bits}:m
+
+
+# USB Default Flags
+# Default blank usb manufacturer will be filled it at compile time
+# - from numeric vendor ID, set to Unknown otherwise
+build.usb_manufacturer=
+build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}'
diff --git a/programmers.txt b/programmers.txt
index c34b88c..54c04e7 100644
--- a/programmers.txt
+++ b/programmers.txt
@@ -1,26 +1,41 @@
-# See: http://code.google.com/p/arduino/wiki/Platforms
-
avrisp.name=AVR ISP
avrisp.communication=serial
avrisp.protocol=stk500v1
+avrisp.program.protocol=stk500v1
+avrisp.program.tool=avrdude
+avrisp.program.extra_params=-P{serial.port}
avrispmkii.name=AVRISP mkII
avrispmkii.communication=usb
avrispmkii.protocol=stk500v2
+avrispmkii.program.protocol=stk500v2
+avrispmkii.program.tool=avrdude
+avrispmkii.program.extra_params=-Pusb
usbtinyisp.name=USBtinyISP
usbtinyisp.protocol=usbtiny
+usbtinyisp.program.tool=avrdude
+usbtinyisp.program.extra_params=
usbasp.name=USBasp
usbasp.communication=usb
usbasp.protocol=usbasp
+usbasp.program.protocol=usbasp
+usbasp.program.tool=avrdude
+usbasp.program.extra_params=-Pusb
parallel.name=Parallel Programmer
parallel.protocol=dapa
parallel.force=true
# parallel.delay=200
+parallel.program.tool=avrdude
+parallel.program.extra_params=-F
arduinoisp.name=Arduino as ISP
arduinoisp.communication=serial
arduinoisp.protocol=stk500v1
arduinoisp.speed=19200
+arduinoisp.program.protocol=stk500v1
+arduinoisp.program.speed=19200
+arduinoisp.program.tool=avrdude
+arduinoisp.program.extra_params=-P{serial.port} -b{program.speed}
diff --git a/variants/leonardo/pins_arduino.h b/variants/leonardo/pins_arduino.h
index fe736f5..be9d0f2 100644
--- a/variants/leonardo/pins_arduino.h
+++ b/variants/leonardo/pins_arduino.h
@@ -133,6 +133,8 @@
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
diff --git a/variants/mega/pins_arduino.h b/variants/mega/pins_arduino.h
index 124444f..9b43971 100644
--- a/variants/mega/pins_arduino.h
+++ b/variants/mega/pins_arduino.h
@@ -83,6 +83,8 @@
( (((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[] = {
diff --git a/variants/robot_control/pins_arduino.h b/variants/robot_control/pins_arduino.h
index 545ec3a..04a5dc5 100644
--- a/variants/robot_control/pins_arduino.h
+++ b/variants/robot_control/pins_arduino.h
@@ -94,6 +94,8 @@
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
diff --git a/variants/robot_motor/pins_arduino.h b/variants/robot_motor/pins_arduino.h
index ff7833a..f159f1e 100644
--- a/variants/robot_motor/pins_arduino.h
+++ b/variants/robot_motor/pins_arduino.h
@@ -89,6 +89,8 @@
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
diff --git a/variants/standard/pins_arduino.h b/variants/standard/pins_arduino.h
index 2038cd4..d0eb464 100644
--- a/variants/standard/pins_arduino.h
+++ b/variants/standard/pins_arduino.h
@@ -60,6 +60,8 @@
#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
diff --git a/variants/yun/pins_arduino.h b/variants/yun/pins_arduino.h
new file mode 100644
index 0000000..15f24cd
--- /dev/null
+++ b/variants/yun/pins_arduino.h
@@ -0,0 +1,46 @@
+/*
+ pins_arduino.h - Pin definition functions for Arduino
+ Part of Arduino - http://www.arduino.cc/
+
+ Copyright (c) 2013 Arduino LLC
+
+ 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 $
+*/
+
+#include "../leonardo/pins_arduino.h"
+
+// 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_LINUXBRIDGE Serial1
+
+// defined in the Leonardo variant
+#undef SERIAL_PORT_HARDWARE_OPEN
+