diff --git a/arduino-0018-linux-x64/examples/Analog/AnalogInSerial/AnalogInSerial.pde b/arduino-0018-linux-x64/examples/Analog/AnalogInSerial/AnalogInSerial.pde deleted file mode 100644 index c8fa158..0000000 --- a/arduino-0018-linux-x64/examples/Analog/AnalogInSerial/AnalogInSerial.pde +++ /dev/null @@ -1,29 +0,0 @@ -/* - Analog input, serial output - - Reads an analog input pin, prints the results to the serial monitor. - - The circuit: - - * potentiometer connected to analog pin 0. - Center pin of the potentiometer goes to the analog pin. - side pins of the potentiometer go to +5V and ground - - created over and over again - by Tom Igoe and everyone who's ever used Arduino - - */ - - void setup() { - Serial.begin(9600); - } - - void loop() { - // read the analog input into a variable: - int analogValue = analogRead(0); - // print the result: - Serial.println(analogValue); - // wait 10 milliseconds for the analog-to-digital converter - // to settle after the last reading: - delay(10); - } diff --git a/arduino-0018-linux-x64/examples/Digital/Blink/Blink.pde b/arduino-0018-linux-x64/examples/Digital/Blink/Blink.pde deleted file mode 100644 index 5d27483..0000000 --- a/arduino-0018-linux-x64/examples/Digital/Blink/Blink.pde +++ /dev/null @@ -1,40 +0,0 @@ -/* - Blink - - Turns on an LED on for one second, then off for one second, repeatedly. - - The circuit: - * LED connected from digital pin 13 to ground. - - * Note: On most Arduino boards, there is already an LED on the board - connected to pin 13, so you don't need any extra components for this example. - - - Created 1 June 2005 - By David Cuartielles - - http://arduino.cc/en/Tutorial/Blink - - based on an orginal by H. Barragan for the Wiring i/o board - - */ - -int ledPin = 13; // LED connected to digital pin 13 - -// The setup() method runs once, when the sketch starts - -void setup() { - // initialize the digital pin as an output: - pinMode(ledPin, OUTPUT); -} - -// the loop() method runs over and over again, -// as long as the Arduino has power - -void loop() -{ - digitalWrite(ledPin, HIGH); // set the LED on - delay(1000); // wait for a second - digitalWrite(ledPin, LOW); // set the LED off - delay(1000); // wait for a second -} diff --git a/arduino-0018-linux-x64/examples/Stubs/AnalogReadSerial/AnalogReadSerial.pde b/arduino-0018-linux-x64/examples/Stubs/AnalogReadSerial/AnalogReadSerial.pde deleted file mode 100644 index f0ce8f4..0000000 --- a/arduino-0018-linux-x64/examples/Stubs/AnalogReadSerial/AnalogReadSerial.pde +++ /dev/null @@ -1,12 +0,0 @@ - -void setup() { - Serial.begin(9600); -} - -void loop() { - int sensorValue = analogRead(0); - Serial.println(sensorValue, DEC); -} - - - diff --git a/arduino-0018-linux-x64/examples/Stubs/AnalogReadWrite/AnalogReadWrite.pde b/arduino-0018-linux-x64/examples/Stubs/AnalogReadWrite/AnalogReadWrite.pde deleted file mode 100644 index 3dc8052..0000000 --- a/arduino-0018-linux-x64/examples/Stubs/AnalogReadWrite/AnalogReadWrite.pde +++ /dev/null @@ -1,13 +0,0 @@ - -void setup() { - pinMode(6, OUTPUT); -} - -void loop() { - int sensorValue = analogRead(2); - int ledFadeValue = map(sensorValue, 0, 1023, 0, 255); - analogWrite(6, ledFadeValue); -} - - - diff --git a/arduino-0018-linux-x64/examples/Stubs/BareMinumum/BareMinumum.pde b/arduino-0018-linux-x64/examples/Stubs/BareMinumum/BareMinumum.pde deleted file mode 100644 index b1a29e5..0000000 --- a/arduino-0018-linux-x64/examples/Stubs/BareMinumum/BareMinumum.pde +++ /dev/null @@ -1,9 +0,0 @@ -void setup() { - -} - -void loop() { - -} - - diff --git a/arduino-0018-linux-x64/examples/Stubs/DigitalReadWrite/DigitalReadWrite.pde b/arduino-0018-linux-x64/examples/Stubs/DigitalReadWrite/DigitalReadWrite.pde deleted file mode 100644 index f4ca3c5..0000000 --- a/arduino-0018-linux-x64/examples/Stubs/DigitalReadWrite/DigitalReadWrite.pde +++ /dev/null @@ -1,12 +0,0 @@ - -void setup() { - pinMode(13, OUTPUT); -} - -void loop() { - int switchValue = digitalRead(2); - digitalWrite(13, switchValue); -} - - - diff --git a/arduino-0018-linux-x64/examples/Stubs/HelloWorld/HelloWorld.pde b/arduino-0018-linux-x64/examples/Stubs/HelloWorld/HelloWorld.pde deleted file mode 100644 index 628a9f3..0000000 --- a/arduino-0018-linux-x64/examples/Stubs/HelloWorld/HelloWorld.pde +++ /dev/null @@ -1,9 +0,0 @@ -void setup() { - Serial.begin(9600); -} - -void loop() { - Serial.println("Hello World!"); -} - - diff --git a/arduino-0018-linux-x64/hardware/arduino/cores/arduino/WProgram.h b/arduino-0018-linux-x64/hardware/arduino/cores/arduino/WProgram.h deleted file mode 100755 index f5d3e29..0000000 --- a/arduino-0018-linux-x64/hardware/arduino/cores/arduino/WProgram.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef WProgram_h -#define WProgram_h - -#include -#include -#include - -#include - -#include "wiring.h" - -#ifdef __cplusplus -#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 - -#endif \ No newline at end of file diff --git a/arduino-0018-linux-x64/hardware/arduino/cores/arduino/wiring_analog.c b/arduino-0018-linux-x64/hardware/arduino/cores/arduino/wiring_analog.c deleted file mode 100755 index 529ad52..0000000 --- a/arduino-0018-linux-x64/hardware/arduino/cores/arduino/wiring_analog.c +++ /dev/null @@ -1,179 +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 - - $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; - - // 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). - ADMUX = (analog_reference << 6) | (pin & 0x07); - -#if defined(__AVR_ATmega1280__) - // 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 - - // without a delay, we seem to read from the wrong channel - //delay(1); - - // 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; - - // 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 (digitalPinToTimer(pin) == TIMER1A) { - // connect pwm to pin on timer 1, channel A - sbi(TCCR1A, COM1A1); - // set pwm duty - OCR1A = val; - } else if (digitalPinToTimer(pin) == TIMER1B) { - // connect pwm to pin on timer 1, channel B - sbi(TCCR1A, COM1B1); - // set pwm duty - OCR1B = val; -#if defined(__AVR_ATmega8__) - } else if (digitalPinToTimer(pin) == TIMER2) { - // connect pwm to pin on timer 2, channel B - sbi(TCCR2, COM21); - // set pwm duty - OCR2 = val; -#else - } else if (digitalPinToTimer(pin) == TIMER0A) { - if (val == 0) { - digitalWrite(pin, LOW); - } else { - // connect pwm to pin on timer 0, channel A - sbi(TCCR0A, COM0A1); - // set pwm duty - OCR0A = val; - } - } else if (digitalPinToTimer(pin) == TIMER0B) { - if (val == 0) { - digitalWrite(pin, LOW); - } else { - // connect pwm to pin on timer 0, channel B - sbi(TCCR0A, COM0B1); - // set pwm duty - OCR0B = val; - } - } else if (digitalPinToTimer(pin) == TIMER2A) { - // connect pwm to pin on timer 2, channel A - sbi(TCCR2A, COM2A1); - // set pwm duty - OCR2A = val; - } else if (digitalPinToTimer(pin) == TIMER2B) { - // connect pwm to pin on timer 2, channel B - sbi(TCCR2A, COM2B1); - // set pwm duty - OCR2B = val; -#endif -#if defined(__AVR_ATmega1280__) - // XXX: need to handle other timers here - } else if (digitalPinToTimer(pin) == TIMER3A) { - // connect pwm to pin on timer 3, channel A - sbi(TCCR3A, COM3A1); - // set pwm duty - OCR3A = val; - } else if (digitalPinToTimer(pin) == TIMER3B) { - // connect pwm to pin on timer 3, channel B - sbi(TCCR3A, COM3B1); - // set pwm duty - OCR3B = val; - } else if (digitalPinToTimer(pin) == TIMER3C) { - // connect pwm to pin on timer 3, channel C - sbi(TCCR3A, COM3C1); - // set pwm duty - OCR3C = val; - } else if (digitalPinToTimer(pin) == TIMER4A) { - // connect pwm to pin on timer 4, channel A - sbi(TCCR4A, COM4A1); - // set pwm duty - OCR4A = val; - } else if (digitalPinToTimer(pin) == TIMER4B) { - // connect pwm to pin on timer 4, channel B - sbi(TCCR4A, COM4B1); - // set pwm duty - OCR4B = val; - } else if (digitalPinToTimer(pin) == TIMER4C) { - // connect pwm to pin on timer 4, channel C - sbi(TCCR4A, COM4C1); - // set pwm duty - OCR4C = val; - } else if (digitalPinToTimer(pin) == TIMER5A) { - // connect pwm to pin on timer 5, channel A - sbi(TCCR5A, COM5A1); - // set pwm duty - OCR5A = val; - } else if (digitalPinToTimer(pin) == TIMER5B) { - // connect pwm to pin on timer 5, channel B - sbi(TCCR5A, COM5B1); - // set pwm duty - OCR5B = val; -#endif - } else if (val < 128) - digitalWrite(pin, LOW); - else - digitalWrite(pin, HIGH); -} diff --git a/arduino-0018-linux-x64/hardware/tools/avrdude b/arduino-0018-linux-x64/hardware/tools/avrdude deleted file mode 100755 index 8892ba5..0000000 Binary files a/arduino-0018-linux-x64/hardware/tools/avrdude and /dev/null differ diff --git a/arduino-0018-linux-x64/hardware/tools/avrdude.conf b/arduino-0018-linux-x64/hardware/tools/avrdude.conf deleted file mode 100644 index 9c2eb9e..0000000 --- a/arduino-0018-linux-x64/hardware/tools/avrdude.conf +++ /dev/null @@ -1,11914 +0,0 @@ -# $Id: avrdude.conf.in,v 1.122 2007/05/16 21:29:36 joerg_wunsch Exp $ -# -# AVRDUDE Configuration File -# -# This file contains configuration data used by AVRDUDE which describes -# the programming hardware pinouts and also provides part definitions. -# AVRDUDE's "-C" command line option specifies the location of the -# configuration file. The "-c" option names the programmer configuration -# which must match one of the entry's "id" parameter. The "-p" option -# identifies which part AVRDUDE is going to be programming and must match -# one of the parts' "id" parameter. -# -# Possible entry formats are: -# -# programmer -# id = [, [, ] ...] ; # are quoted strings -# desc = ; # quoted string -# type = par | stk500 | stk500v2 | stk500pp | stk500hvsp | stk500generic | -# avr910 | butterfly | usbasp | -# jtagmki | jtagmkii | jtagmkii_isp | jtagmkii_dw | -# dragon_dw | dragon_jtag | dragon_isp | dragon_pp | -# dragon_hvsp; # programmer type -# baudrate = ; # baudrate for avr910-programmer -# vcc = [, ... ] ; # pin number(s) -# reset = ; # pin number -# sck = ; # pin number -# mosi = ; # pin number -# miso = ; # pin number -# errled = ; # pin number -# rdyled = ; # pin number -# pgmled = ; # pin number -# vfyled = ; # pin number -# ; -# -# part -# id = ; # quoted string -# desc = ; # quoted string -# has_jtag = ; # part has JTAG i/f -# has_debugwire = ; # part has debugWire i/f -# devicecode = ; # deprecated, use stk500_devcode -# stk500_devcode = ; # numeric -# avr910_devcode = ; # numeric -# signature = ; # signature bytes -# chip_erase_delay = ; # micro-seconds -# reset = dedicated | io; -# retry_pulse = reset | sck; -# pgm_enable = ; -# chip_erase = ; -# chip_erase_delay = ; # chip erase delay (us) -# # STK500 parameters (parallel programming IO lines) -# pagel = ; # pin name in hex, i.e., 0xD7 -# bs2 = ; # pin name in hex, i.e., 0xA0 -# serial = ; # can use serial downloading -# parallel = ; # can use par. programming -# # STK500v2 parameters, to be taken from Atmel's XML files -# timeout = ; -# stabdelay = ; -# cmdexedelay = ; -# synchloops = ; -# bytedelay = ; -# pollvalue = ; -# pollindex = ; -# predelay = ; -# postdelay = ; -# pollmethod = ; -# mode = ; -# delay = ; -# blocksize = ; -# readsize = ; -# hvspcmdexedelay = ; -# # STK500v2 HV programming parameters, from XML -# pp_controlstack = , , ...; # PP only -# hvsp_controlstack = , , ...; # HVSP only -# hventerstabdelay = ; -# progmodedelay = ; # PP only -# latchcycles = ; -# togglevtg = ; -# poweroffdelay = ; -# resetdelayms = ; -# resetdelayus = ; -# hvleavestabdelay = ; -# resetdelay = ; -# synchcycles = ; # HVSP only -# chiperasepulsewidth = ; # PP only -# chiperasepolltimeout = ; -# chiperasetime = ; # HVSP only -# programfusepulsewidth = ; # PP only -# programfusepolltimeout = ; -# programlockpulsewidth = ; # PP only -# programlockpolltimeout = ; -# # JTAG ICE mkII parameters, also from XML files -# allowfullpagebitstream = ; -# enablepageprogramming = ; -# idr = ; # IO addr of IDR (OCD) reg. -# rampz = ; # IO addr of RAMPZ reg. -# spmcr = ; # mem addr of SPMC[S]R reg. -# eecr = ; # mem addr of EECR reg. -# # (only when != 0x3c) -# -# memory -# paged = ; # yes / no -# size = ; # bytes -# page_size = ; # bytes -# num_pages = ; # numeric -# min_write_delay = ; # micro-seconds -# max_write_delay = ; # micro-seconds -# readback_p1 = ; # byte value -# readback_p2 = ; # byte value -# pwroff_after_write = ; # yes / no -# read = ; -# write = ; -# read_lo = ; -# read_hi = ; -# write_lo = ; -# write_hi = ; -# loadpage_lo = ; -# loadpage_hi = ; -# writepage = ; -# ; -# ; -# -# If any of the above parameters are not specified, the default value -# of 0 is used for numerics or the empty string ("") for string -# values. If a required parameter is left empty, AVRDUDE will -# complain. -# -# NOTES: -# * 'devicecode' is the device code used by the STK500 (see codes -# listed below) -# * Not all memory types will implement all instructions. -# * AVR Fuse bits and Lock bits are implemented as a type of memory. -# * Example memory types are: -# "flash", "eeprom", "fuse", "lfuse" (low fuse), "hfuse" (high -# fuse), "signature", "calibration", "lock" -# * The memory type specified on the avrdude command line must match -# one of the memory types defined for the specified chip. -# * The pwroff_after_write flag causes avrdude to attempt to -# power the device off and back on after an unsuccessful write to -# the affected memory area if VCC programmer pins are defined. If -# VCC pins are not defined for the programmer, a message -# indicating that the device needs a power-cycle is printed out. -# This flag was added to work around a problem with the -# at90s4433/2333's; see the at90s4433 errata at: -# -# http://www.atmel.com/atmel/acrobat/doc1280.pdf -# -# INSTRUCTION FORMATS -# -# Instruction formats are specified as a comma seperated list of -# string values containing information (bit specifiers) about each -# of the 32 bits of the instruction. Bit specifiers may be one of -# the following formats: -# -# '1' = the bit is always set on input as well as output -# -# '0' = the bit is always clear on input as well as output -# -# 'x' = the bit is ignored on input and output -# -# 'a' = the bit is an address bit, the bit-number matches this bit -# specifier's position within the current instruction byte -# -# 'aN' = the bit is the Nth address bit, bit-number = N, i.e., a12 -# is address bit 12 on input, a0 is address bit 0. -# -# 'i' = the bit is an input data bit -# -# 'o' = the bit is an output data bit -# -# Each instruction must be composed of 32 bit specifiers. The -# instruction specification closely follows the instruction data -# provided in Atmel's data sheets for their parts. -# -# See below for some examples. -# -# -# The following are STK500 part device codes to use for the -# "devicecode" field of the part. These came from Atmel's software -# section avr061.zip which accompanies the application note -# AVR061 available from: -# -# http://www.atmel.com/atmel/acrobat/doc2525.pdf -# - -#define ATTINY10 0x10 -#define ATTINY11 0x11 -#define ATTINY12 0x12 -#define ATTINY15 0x13 -#define ATTINY13 0x14 - -#define ATTINY22 0x20 -#define ATTINY26 0x21 -#define ATTINY28 0x22 -#define ATTINY2313 0x23 - -#define AT90S1200 0x33 - -#define AT90S2313 0x40 -#define AT90S2323 0x41 -#define AT90S2333 0x42 -#define AT90S2343 0x43 - -#define AT90S4414 0x50 -#define AT90S4433 0x51 -#define AT90S4434 0x52 -#define ATMEGA48 0x59 - -#define AT90S8515 0x60 -#define AT90S8535 0x61 -#define AT90C8534 0x62 -#define ATMEGA8515 0x63 -#define ATMEGA8535 0x64 - -#define ATMEGA8 0x70 -#define ATMEGA88 0x73 -#define ATMEGA168 0x86 - -#define ATMEGA161 0x80 -#define ATMEGA163 0x81 -#define ATMEGA16 0x82 -#define ATMEGA162 0x83 -#define ATMEGA169 0x84 - -#define ATMEGA323 0x90 -#define ATMEGA32 0x91 - -#define ATMEGA64 0xA0 - -#define ATMEGA103 0xB1 -#define ATMEGA128 0xB2 -#define AT90CAN128 0xB3 - -#define AT86RF401 0xD0 - -#define AT89START 0xE0 -#define AT89S51 0xE0 -#define AT89S52 0xE1 - -# The following table lists the devices in the original AVR910 -# appnote: -# |Device |Signature | Code | -# +-------+----------+------+ -# |tiny12 | 1E 90 05 | 0x55 | -# |tiny15 | 1E 90 06 | 0x56 | -# | | | | -# | S1200 | 1E 90 01 | 0x13 | -# | | | | -# | S2313 | 1E 91 01 | 0x20 | -# | S2323 | 1E 91 02 | 0x48 | -# | S2333 | 1E 91 05 | 0x34 | -# | S2343 | 1E 91 03 | 0x4C | -# | | | | -# | S4414 | 1E 92 01 | 0x28 | -# | S4433 | 1E 92 03 | 0x30 | -# | S4434 | 1E 92 02 | 0x6C | -# | | | | -# | S8515 | 1E 93 01 | 0x38 | -# | S8535 | 1E 93 03 | 0x68 | -# | | | | -# |mega32 | 1E 95 01 | 0x72 | -# |mega83 | 1E 93 05 | 0x65 | -# |mega103| 1E 97 01 | 0x41 | -# |mega161| 1E 94 01 | 0x60 | -# |mega163| 1E 94 02 | 0x64 | - -# Appnote AVR109 also has a table of AVR910 device codes, which -# lists: -# dev avr910 signature -# ATmega8 0x77 0x1E 0x93 0x07 -# ATmega8515 0x3B 0x1E 0x93 0x06 -# ATmega8535 0x6A 0x1E 0x93 0x08 -# ATmega16 0x75 0x1E 0x94 0x03 -# ATmega162 0x63 0x1E 0x94 0x04 -# ATmega163 0x66 0x1E 0x94 0x02 -# ATmega169 0x79 0x1E 0x94 0x05 -# ATmega32 0x7F 0x1E 0x95 0x02 -# ATmega323 0x73 0x1E 0x95 0x01 -# ATmega64 0x46 0x1E 0x96 0x02 -# ATmega128 0x44 0x1E 0x97 0x02 -# -# These codes refer to "BOOT" device codes which are apparently -# different than standard device codes, for whatever reasons -# (often one above the standard code). - -# There are several extended versions of AVR910 implementations around -# in the Internet. These add the following codes (only devices that -# actually exist are listed): - -# ATmega8515 0x3A -# ATmega128 0x43 -# ATmega64 0x45 -# ATtiny26 0x5E -# ATmega8535 0x69 -# ATmega32 0x72 -# ATmega16 0x74 -# ATmega8 0x76 -# ATmega169 0x78 - -# -# Overall avrdude defaults -# -default_parallel = "/dev/parport0"; -default_serial = "/dev/ttyS0"; - - -# -# PROGRAMMER DEFINITIONS -# - -programmer - id = "avrisp"; - desc = "Atmel AVR ISP"; - type = stk500; -; - -programmer - id = "avrispv2"; - desc = "Atmel AVR ISP V2"; - type = stk500v2; -; - -programmer - id = "avrispmkII"; - desc = "Atmel AVR ISP mkII"; - type = stk500v2; -; - -programmer - id = "avrisp2"; - desc = "Atmel AVR ISP mkII"; - type = stk500v2; -; - -# This is supposed to be the "default" STK500 entry. -# Attempts to select the correct firmware version -# by probing for it. Better use one of the entries -# below instead. -programmer - id = "stk500"; - desc = "Atmel STK500"; - type = stk500generic; -; - -programmer - id = "stk500v1"; - desc = "Atmel STK500 Version 1.x firmware"; - type = stk500; -; - -programmer - id = "stk500v2"; - desc = "Atmel STK500 Version 2.x firmware"; - type = stk500v2; -; - -programmer - id = "stk500pp"; - desc = "Atmel STK500 V2 in parallel programming mode"; - type = stk500pp; -; - -programmer - id = "stk500hvsp"; - desc = "Atmel STK500 V2 in high-voltage serial programming mode"; - type = stk500hvsp; -; - -programmer - id = "avr910"; - desc = "Atmel Low Cost Serial Programmer"; - type = avr910; -; - -programmer - id = "usbasp"; - desc = "USBasp, http://www.fischl.de/usbasp/"; - type = usbasp; -; - -#programmer -# id = "usbtiny"; -# desc = "USBtiny simple USB programmer"; -# type = usbtiny; -#; - -programmer - id = "butterfly"; - desc = "Atmel Butterfly Development Board"; - type = butterfly; -; - -programmer - id = "avr109"; - desc = "Atmel AppNote AVR109 Boot Loader"; - type = butterfly; -; - -programmer - id = "avr911"; - desc = "Atmel AppNote AVR911 AVROSP"; - type = butterfly; -; - -programmer - id = "jtagmkI"; - desc = "Atmel JTAG ICE (mkI)"; - baudrate = 115200; # default is 115200 - type = jtagmki; -; - -# easier to type -programmer - id = "jtag1"; - desc = "Atmel JTAG ICE (mkI)"; - baudrate = 115200; # default is 115200 - type = jtagmki; -; - -# easier to type -programmer - id = "jtag1slow"; - desc = "Atmel JTAG ICE (mkI)"; - baudrate = 19200; - type = jtagmki; -; - -programmer - id = "jtagmkII"; - desc = "Atmel JTAG ICE mkII"; - baudrate = 19200; # default is 19200 - type = jtagmkii; -; - -# easier to type -programmer - id = "jtag2slow"; - desc = "Atmel JTAG ICE mkII"; - baudrate = 19200; # default is 19200 - type = jtagmkii; -; - -# JTAG ICE mkII @ 115200 Bd -programmer - id = "jtag2fast"; - desc = "Atmel JTAG ICE mkII"; - baudrate = 115200; - type = jtagmkii; -; - -# make the fast one the default, people will love that -programmer - id = "jtag2"; - desc = "Atmel JTAG ICE mkII"; - baudrate = 115200; - type = jtagmkii; -; - -# JTAG ICE mkII in ISP mode -programmer - id = "jtag2isp"; - desc = "Atmel JTAG ICE mkII in ISP mode"; - baudrate = 115200; - type = jtagmkii_isp; -; - -# JTAG ICE mkII in debugWire mode -programmer - id = "jtag2dw"; - desc = "Atmel JTAG ICE mkII in debugWire mode"; - baudrate = 115200; - type = jtagmkii_dw; -; - -# AVR Dragon in JTAG mode -programmer - id = "dragon_jtag"; - desc = "Atmel AVR Dragon in JTAG mode"; - baudrate = 115200; - type = dragon_jtag; -; - -# AVR Dragon in ISP mode -programmer - id = "dragon_isp"; - desc = "Atmel AVR Dragon in ISP mode"; - baudrate = 115200; - type = dragon_isp; -; - -# AVR Dragon in PP mode -programmer - id = "dragon_pp"; - desc = "Atmel AVR Dragon in PP mode"; - baudrate = 115200; - type = dragon_pp; -; - -# AVR Dragon in HVSP mode -programmer - id = "dragon_hvsp"; - desc = "Atmel AVR Dragon in HVSP mode"; - baudrate = 115200; - type = dragon_hvsp; -; - -# AVR Dragon in debugWire mode -programmer - id = "dragon_dw"; - desc = "Atmel AVR Dragon in debugWire mode"; - baudrate = 115200; - type = dragon_dw; -; - -programmer - id = "pavr"; - desc = "Jason Kyle's pAVR Serial Programmer"; - type = avr910; -; - -# Parallel port programmers. - -programmer - id = "bsd"; - desc = "Brian Dean's Programmer, http://www.bsdhome.com/avrdude/"; - type = par; - vcc = 2, 3, 4, 5; - reset = 7; - sck = 8; - mosi = 9; - miso = 10; -; - -programmer - id = "stk200"; - desc = "STK200"; - type = par; - buff = 4, 5; - sck = 6; - mosi = 7; - reset = 9; - miso = 10; -; - -# The programming dongle used by the popular Ponyprog -# utility. It is almost similar to the STK200 one, -# except that there is a LED indicating that the -# programming is currently in progress. - -programmer - id = "pony-stk200"; - desc = "Pony Prog STK200"; - type = par; - buff = 4, 5; - sck = 6; - mosi = 7; - reset = 9; - miso = 10; - pgmled = 8; -; - -programmer - id = "dt006"; - desc = "Dontronics DT006"; - type = par; - reset = 4; - sck = 5; - mosi = 2; - miso = 11; -; - -programmer - id = "bascom"; - desc = "Bascom SAMPLE programming cable"; - type = par; - reset = 4; - sck = 5; - mosi = 2; - miso = 11; -; - -programmer - id = "alf"; - desc = "Nightshade ALF-PgmAVR, http://nightshade.homeip.net/"; - type = par; - vcc = 2, 3, 4, 5; - buff = 6; - reset = 7; - sck = 8; - mosi = 9; - miso = 10; - errled = 1; - rdyled = 14; - pgmled = 16; - vfyled = 17; -; - -programmer - id = "sp12"; - desc = "Steve Bolt's Programmer"; - type = par; - vcc = 4,5,6,7,8; - reset = 3; - sck = 2; - mosi = 9; - miso = 11; -; - -programmer - id = "picoweb"; - desc = "Picoweb Programming Cable, http://www.picoweb.net/"; - type = par; - reset = 2; - sck = 3; - mosi = 4; - miso = 13; -; - -programmer - id = "abcmini"; - desc = "ABCmini Board, aka Dick Smith HOTCHIP"; - type = par; - reset = 4; - sck = 3; - mosi = 2; - miso = 10; -; - -programmer - id = "futurlec"; - desc = "Futurlec.com programming cable."; - type = par; - reset = 3; - sck = 2; - mosi = 1; - miso = 10; -; - - -# From the contributor of the "xil" jtag cable: -# The "vcc" definition isn't really vcc (the cable gets its power from -# the programming circuit) but is necessary to switch one of the -# buffer lines (trying to add it to the "buff" lines doesn't work). -# With this, TMS connects to RESET, TDI to MOSI, TDO to MISO and TCK -# to SCK (plus vcc/gnd of course) -programmer - id = "xil"; - desc = "Xilinx JTAG cable"; - type = par; - mosi = 2; - sck = 3; - reset = 4; - buff = 5; - miso = 13; - vcc = 6; -; - - -programmer - id = "dapa"; - desc = "Direct AVR Parallel Access cable"; - type = par; - vcc = 3; - reset = 16; - sck = 1; - mosi = 2; - miso = 11; -; - -programmer - id = "atisp"; - desc = "AT-ISP V1.1 programming cable for AVR-SDK1 from micro-research.co.th"; - type = par; - reset = ~6; - sck = ~8; - mosi = ~7; - miso = ~10; -; - -programmer - id = "ere-isp-avr"; - desc = "ERE ISP-AVR "; - type = par; - reset = ~4; - sck = 3; - mosi = 2; - miso = 10; -; - -programmer - id = "blaster"; - desc = "Altera ByteBlaster"; - type = par; - sck = 2; - miso = 11; - reset = 3; - mosi = 8; - buff = 14; -; - -# It is almost same as pony-stk200, except vcc on pin 5 to auto -# disconnect port (download on http://electropol.free.fr) -programmer - id = "frank-stk200"; - desc = "Frank STK200"; - type = par; - vcc = 5; - sck = 6; - mosi = 7; - reset = 9; - miso = 10; - pgmled = 8; -; - - -# -# some ultra cheap programmers use bitbanging on the -# serialport. -# -# PC - DB9 - Pins for RS232: -# -# GND 5 -- |O -# | O| <- 9 RI -# DTR 4 <- |O | -# | O| <- 8 CTS -# TXD 3 <- |O | -# | O| -> 7 RTS -# RXD 2 -> |O | -# | O| <- 6 DSR -# DCD 1 -> |O -# -# Using RXD is currently not supported. -# Using RI is not supported under Win32 but is supported under Posix. - -# serial ponyprog design (dasa2 in uisp) -# reset=!txd sck=rts mosi=dtr miso=cts - -programmer - id = "ponyser"; - desc = "design ponyprog serial, reset=!txd sck=rts mosi=dtr miso=cts"; - type = serbb; - reset = ~3; - sck = 7; - mosi = 4; - miso = 8; -; - -# Same as above, different name -# reset=!txd sck=rts mosi=dtr miso=cts - -programmer - id = "siprog"; - desc = "Lancos SI-Prog "; - type = serbb; - reset = ~3; - sck = 7; - mosi = 4; - miso = 8; -; - -# unknown (dasa in uisp) -# reset=rts sck=dtr mosi=txd miso=cts - -programmer - id = "dasa"; - desc = "serial port banging, reset=rts sck=dtr mosi=txd miso=cts"; - type = serbb; - reset = 7; - sck = 4; - mosi = 3; - miso = 8; -; - -# unknown (dasa3 in uisp) -# reset=!dtr sck=rts mosi=txd miso=cts - -programmer - id = "dasa3"; - desc = "serial port banging, reset=!dtr sck=rts mosi=txd miso=cts"; - type = serbb; - reset = ~4; - sck = 7; - mosi = 3; - miso = 8; -; - -# -# PART DEFINITIONS -# - -#------------------------------------------------------------ -# ATtiny11 -#------------------------------------------------------------ - -# This is an HVSP-only device. - -part - id = "t11"; - desc = "ATtiny11"; - stk500_devcode = 0x11; - signature = 0x1e 0x90 0x04; - chip_erase_delay = 20000; - - timeout = 200; - hvsp_controlstack = - 0x4C, 0x0C, 0x1C, 0x2C, 0x3C, 0x64, 0x74, 0x00, - 0x68, 0x78, 0x68, 0x68, 0x00, 0x00, 0x68, 0x78, - 0x78, 0x00, 0x6D, 0x0C, 0x80, 0x40, 0x20, 0x10, - 0x11, 0x08, 0x04, 0x02, 0x03, 0x08, 0x04, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - hvspcmdexedelay = 0; - synchcycles = 6; - latchcycles = 1; - togglevtg = 1; - poweroffdelay = 25; - resetdelayms = 0; - resetdelayus = 50; - hvleavestabdelay = 100; - resetdelay = 25; - chiperasepolltimeout = 40; - chiperasetime = 0; - programfusepolltimeout = 25; - programlockpolltimeout = 25; - - memory "eeprom" - size = 64; - blocksize = 64; - readsize = 256; - delay = 5; - ; - - memory "flash" - size = 1024; - blocksize = 128; - readsize = 256; - delay = 3; - ; - - memory "signature" - size = 3; - ; - - memory "lock" - size = 1; - ; - - memory "calibration" - size = 1; - ; - - memory "fuse" - size = 1; - ; -; - -#------------------------------------------------------------ -# ATtiny12 -#------------------------------------------------------------ - -part - id = "t12"; - desc = "ATtiny12"; - stk500_devcode = 0x12; - avr910_devcode = 0x55; - signature = 0x1e 0x90 0x05; - chip_erase_delay = 20000; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 0; - - hvsp_controlstack = - 0x4C, 0x0C, 0x1C, 0x2C, 0x3C, 0x64, 0x74, 0x00, - 0x68, 0x78, 0x68, 0x68, 0x00, 0x00, 0x68, 0x78, - 0x78, 0x00, 0x6D, 0x0C, 0x80, 0x40, 0x20, 0x10, - 0x11, 0x08, 0x04, 0x02, 0x03, 0x08, 0x04, 0x00; - hventerstabdelay = 100; - hvspcmdexedelay = 0; - synchcycles = 6; - latchcycles = 1; - togglevtg = 1; - poweroffdelay = 25; - resetdelayms = 0; - resetdelayus = 50; - hvleavestabdelay = 100; - resetdelay = 25; - chiperasepolltimeout = 40; - chiperasetime = 0; - programfusepolltimeout = 25; - programlockpolltimeout = 25; - - memory "eeprom" - size = 64; - min_write_delay = 9000; - max_write_delay = 20000; - readback_p1 = 0xff; - readback_p2 = 0xff; - read = "1 0 1 0 0 0 0 0 x x x x x x x x", - "x x a5 a4 a3 a2 a1 a0 o o o o o o o o"; - - write = "1 1 0 0 0 0 0 0 x x x x x x x x", - "x x a5 a4 a3 a2 a1 a0 i i i i i i i i"; - - mode = 0x04; - delay = 8; - blocksize = 64; - readsize = 256; - ; - - memory "flash" - size = 1024; - min_write_delay = 4500; - max_write_delay = 20000; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - " x x x x x x x a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " x x x x x x x a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write_lo = " 0 1 0 0 0 0 0 0", - " x x x x x x x a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - write_hi = " 0 1 0 0 1 0 0 0", - " x x x x x x x a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - mode = 0x04; - delay = 5; - blocksize = 128; - readsize = 256; - ; - - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 x x x x x x x x", - "0 0 0 0 0 0 a1 a0 o o o o o o o o"; - ; - - memory "lock" - size = 1; - read = "0 1 0 1 1 0 0 0 x x x x x x x x", - "x x x x x x x x x x x x x o o x"; - - write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", - "x x x x x x x x x x x x x x x x"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "calibration" - size = 1; - read = "0 0 1 1 1 0 0 0 x x x x x x x x", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - ; - - memory "fuse" - size = 1; - read = "0 1 0 1 0 0 0 0 x x x x x x x x", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 x x x x x", - "x x x x x x x x i i i i i i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; -; - -#------------------------------------------------------------ -# ATtiny13 -#------------------------------------------------------------ - -part - id = "t13"; - desc = "ATtiny13"; - has_debugwire = yes; - flash_instr = 0xB4, 0x0E, 0x1E; - eeprom_instr = 0xBB, 0xFE, 0xBB, 0xEE, 0xBB, 0xCC, 0xB2, 0x0D, - 0xBC, 0x0E, 0xB4, 0x0E, 0xBA, 0x0D, 0xBB, 0xBC, - 0x99, 0xE1, 0xBB, 0xAC; - stk500_devcode = 0x14; - signature = 0x1e 0x90 0x07; - chip_erase_delay = 4000; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - - hvsp_controlstack = - 0x4C, 0x0C, 0x1C, 0x2C, 0x3C, 0x64, 0x74, 0x66, - 0x68, 0x78, 0x68, 0x68, 0x7A, 0x6A, 0x68, 0x78, - 0x78, 0x7D, 0x6D, 0x0C, 0x80, 0x40, 0x20, 0x10, - 0x11, 0x08, 0x04, 0x02, 0x03, 0x08, 0x04, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - hvspcmdexedelay = 0; - synchcycles = 6; - latchcycles = 1; - togglevtg = 1; - poweroffdelay = 25; - resetdelayms = 0; - resetdelayus = 90; - hvleavestabdelay = 100; - resetdelay = 25; - chiperasepolltimeout = 40; - chiperasetime = 0; - programfusepolltimeout = 25; - programlockpolltimeout = 25; - - memory "eeprom" - size = 64; - page_size = 4; - min_write_delay = 4000; - max_write_delay = 4000; - readback_p1 = 0xff; - readback_p2 = 0xff; - read = "1 0 1 0 0 0 0 0 0 0 0 x x x x x", - "x x a5 a4 a3 a2 a1 a0 o o o o o o o o"; - - write = "1 1 0 0 0 0 0 0 0 0 0 x x x x x", - "x x a5 a4 a3 a2 a1 a0 i i i i i i i i"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 0 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 x x x x x x", - " x x a5 a4 a3 a2 0 0", - " x x x x x x x x"; - - mode = 0x41; - delay = 5; - blocksize = 4; - readsize = 256; - ; - - memory "flash" - paged = yes; - size = 1024; - page_size = 32; - num_pages = 32; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - " 0 0 0 0 0 0 0 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " 0 0 0 0 0 0 0 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " 0 0 0 x x x x x", - " x x x x a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " 0 0 0 x x x x x", - " x x x x a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - " 0 0 0 0 0 0 0 a8", - " a7 a6 a5 a4 x x x x", - " x x x x x x x x"; - - mode = 0x41; - delay = 6; - blocksize = 32; - readsize = 256; - ; - - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - - memory "lock" - size = 1; - min_write_delay = 4500; - max_write_delay = 4500; - - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x x x o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", - "x x x x x x x x 1 1 i i i i i i"; - ; - - memory "calibration" - size = 2; - read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", - "0 0 0 0 0 0 0 a0 o o o o o o o o"; - ; - - memory "lfuse" - size = 1; - min_write_delay = 4500; - max_write_delay = 4500; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - ; - - memory "hfuse" - size = 1; - min_write_delay = 4500; - max_write_delay = 4500; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - ; - -; - - -#------------------------------------------------------------ -# ATtiny15 -#------------------------------------------------------------ - -part - id = "t15"; - desc = "ATtiny15"; - stk500_devcode = 0x13; - avr910_devcode = 0x56; - signature = 0x1e 0x90 0x06; - chip_erase_delay = 8200; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 0; - - hvsp_controlstack = - 0x4C, 0x0C, 0x1C, 0x2C, 0x3C, 0x64, 0x74, 0x00, - 0x68, 0x78, 0x68, 0x68, 0x00, 0x00, 0x68, 0x78, - 0x78, 0x00, 0x6D, 0x0C, 0x80, 0x40, 0x20, 0x10, - 0x11, 0x08, 0x04, 0x02, 0x03, 0x08, 0x04, 0x00; - hventerstabdelay = 100; - hvspcmdexedelay = 5; - synchcycles = 6; - latchcycles = 16; - togglevtg = 1; - poweroffdelay = 25; - resetdelayms = 0; - resetdelayus = 50; - hvleavestabdelay = 100; - resetdelay = 25; - chiperasepolltimeout = 40; - chiperasetime = 0; - programfusepolltimeout = 25; - programlockpolltimeout = 25; - - memory "eeprom" - size = 64; - min_write_delay = 8200; - max_write_delay = 8200; - readback_p1 = 0xff; - readback_p2 = 0xff; - read = "1 0 1 0 0 0 0 0 x x x x x x x x", - "x x a5 a4 a3 a2 a1 a0 o o o o o o o o"; - - write = "1 1 0 0 0 0 0 0 x x x x x x x x", - "x x a5 a4 a3 a2 a1 a0 i i i i i i i i"; - - mode = 0x04; - delay = 10; - blocksize = 64; - readsize = 256; - ; - - memory "flash" - size = 1024; - min_write_delay = 4100; - max_write_delay = 4100; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - " x x x x x x x a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " x x x x x x x a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write_lo = " 0 1 0 0 0 0 0 0", - " x x x x x x x a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - write_hi = " 0 1 0 0 1 0 0 0", - " x x x x x x x a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - mode = 0x04; - delay = 5; - blocksize = 128; - readsize = 256; - ; - - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 x x x x x x x x", - "0 0 0 0 0 0 a1 a0 o o o o o o o o"; - ; - - memory "lock" - size = 1; - read = "0 1 0 1 1 0 0 0 x x x x x x x x", - "x x x x x x x x x x x x x o o x"; - - write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", - "x x x x x x x x x x x x x x x x"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "calibration" - size = 1; - read = "0 0 1 1 1 0 0 0 x x x x x x x x", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - ; - - memory "fuse" - size = 1; - read = "0 1 0 1 0 0 0 0 x x x x x x x x", - "x x x x x x x x o o o o x x o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 x x x x x", - "x x x x x x x x i i i i 1 1 i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; -; - -#------------------------------------------------------------ -# AT90s1200 -#------------------------------------------------------------ - -part - id = "1200"; - desc = "AT90S1200"; - stk500_devcode = 0x33; - avr910_devcode = 0x13; - signature = 0x1e 0x90 0x01; - pagel = 0xd7; - bs2 = 0xa0; - chip_erase_delay = 20000; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 1; - bytedelay = 0; - pollindex = 0; - pollvalue = 0xFF; - predelay = 1; - postdelay = 1; - pollmethod = 0; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 0; - togglevtg = 0; - poweroffdelay = 0; - resetdelayms = 0; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 15; - chiperasepolltimeout = 0; - programfusepulsewidth = 2; - programfusepolltimeout = 0; - programlockpulsewidth = 0; - programlockpolltimeout = 1; - - memory "eeprom" - size = 64; - min_write_delay = 4000; - max_write_delay = 9000; - readback_p1 = 0x00; - readback_p2 = 0xff; - read = "1 0 1 0 0 0 0 0 x x x x x x x x", - "x x a5 a4 a3 a2 a1 a0 o o o o o o o o"; - - write = "1 1 0 0 0 0 0 0 x x x x x x x x", - "x x a5 a4 a3 a2 a1 a0 i i i i i i i i"; - - mode = 0x04; - delay = 20; - blocksize = 32; - readsize = 256; - ; - memory "flash" - size = 1024; - min_write_delay = 4000; - max_write_delay = 9000; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - " x x x x x x x a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " x x x x x x x a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write_lo = " 0 1 0 0 0 0 0 0", - " x x x x x x x a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - write_hi = " 0 1 0 0 1 0 0 0", - " x x x x x x x a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - mode = 0x02; - delay = 15; - blocksize = 128; - readsize = 256; - ; - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 x x x x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - memory "fuse" - size = 1; - ; - memory "lock" - size = 1; - min_write_delay = 9000; - max_write_delay = 20000; - write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", - "x x x x x x x x x x x x x x x x"; - ; - ; - -#------------------------------------------------------------ -# AT90s4414 -#------------------------------------------------------------ - -part - id = "4414"; - desc = "AT90S4414"; - stk500_devcode = 0x50; - avr910_devcode = 0x28; - signature = 0x1e 0x92 0x01; - chip_erase_delay = 20000; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 0; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 0; - togglevtg = 0; - poweroffdelay = 0; - resetdelayms = 0; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 15; - chiperasepolltimeout = 0; - programfusepulsewidth = 2; - programfusepolltimeout = 0; - programlockpulsewidth = 0; - programlockpolltimeout = 1; - - memory "eeprom" - size = 256; - min_write_delay = 9000; - max_write_delay = 20000; - readback_p1 = 0x80; - readback_p2 = 0x7f; - read = " 1 0 1 0 0 0 0 0 x x x x x x x a8", - "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; - - write = " 1 1 0 0 0 0 0 0 x x x x x x x a8", - "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; - - mode = 0x04; - delay = 12; - blocksize = 64; - readsize = 256; - ; - memory "flash" - size = 4096; - min_write_delay = 9000; - max_write_delay = 20000; - readback_p1 = 0x7f; - readback_p2 = 0x7f; - read_lo = " 0 0 1 0 0 0 0 0", - " x x x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " x x x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write_lo = " 0 1 0 0 0 0 0 0", - " x x x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - write_hi = " 0 1 0 0 1 0 0 0", - " x x x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - mode = 0x04; - delay = 12; - blocksize = 64; - readsize = 256; - ; - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 x x x x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - memory "fuse" - size = 1; - ; - memory "lock" - size = 1; - write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", - "x x x x x x x x x x x x x x x x"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - ; - -#------------------------------------------------------------ -# AT90s2313 -#------------------------------------------------------------ - -part - id = "2313"; - desc = "AT90S2313"; - stk500_devcode = 0x40; - avr910_devcode = 0x20; - signature = 0x1e 0x91 0x01; - chip_erase_delay = 20000; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 0; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 0; - togglevtg = 0; - poweroffdelay = 0; - resetdelayms = 0; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 15; - chiperasepolltimeout = 0; - programfusepulsewidth = 2; - programfusepolltimeout = 0; - programlockpulsewidth = 0; - programlockpolltimeout = 1; - - memory "eeprom" - size = 128; - min_write_delay = 4000; - max_write_delay = 9000; - readback_p1 = 0x80; - readback_p2 = 0x7f; - read = "1 0 1 0 0 0 0 0 x x x x x x x x", - "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; - - write = "1 1 0 0 0 0 0 0 x x x x x x x x", - "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; - - mode = 0x04; - delay = 12; - blocksize = 64; - readsize = 256; - ; - memory "flash" - size = 2048; - min_write_delay = 4000; - max_write_delay = 9000; - readback_p1 = 0x7f; - readback_p2 = 0x7f; - read_lo = " 0 0 1 0 0 0 0 0", - " x x x x x x a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " x x x x x x a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write_lo = " 0 1 0 0 0 0 0 0", - " x x x x x x a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - write_hi = " 0 1 0 0 1 0 0 0", - " x x x x x x a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - mode = 0x04; - delay = 12; - blocksize = 128; - readsize = 256; - ; - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 x x x x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - memory "fuse" - size = 1; - ; - memory "lock" - size = 1; - write = "1 0 1 0 1 1 0 0 1 1 1 x x i i x", - "x x x x x x x x x x x x x x x x"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - ; - -#------------------------------------------------------------ -# AT90s2333 -#------------------------------------------------------------ - -part - id = "2333"; -##### WARNING: No XML file for device 'AT90S2333'! ##### - desc = "AT90S2333"; - stk500_devcode = 0x42; - avr910_devcode = 0x34; - signature = 0x1e 0x91 0x05; - chip_erase_delay = 20000; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", - "x x x x x x x x x x x x x x x x"; - - memory "eeprom" - size = 128; - min_write_delay = 9000; - max_write_delay = 20000; - readback_p1 = 0x00; - readback_p2 = 0xff; - read = "1 0 1 0 0 0 0 0 x x x x x x x x", - "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; - - write = "1 1 0 0 0 0 0 0 x x x x x x x x", - "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; - ; - memory "flash" - size = 2048; - min_write_delay = 9000; - max_write_delay = 20000; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - " x x x x x x a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " x x x x x x a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write_lo = " 0 1 0 0 0 0 0 0", - " x x x x x x a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - write_hi = " 0 1 0 0 1 0 0 0", - " x x x x x x a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - ; - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 x x x x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - memory "fuse" - size = 1; - min_write_delay = 9000; - max_write_delay = 20000; - pwroff_after_write = yes; - read = "0 1 0 1 0 0 0 0 x x x x x x x x", - "x x x x x x x x x x o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 i i i i i", - "x x x x x x x x x x x x x x x x"; - ; - memory "lock" - size = 1; - min_write_delay = 9000; - max_write_delay = 20000; - read = "0 1 0 1 1 0 0 0 x x x x x x x x", - "x x x x x x x x x x x x x o o x"; - - write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", - "x x x x x x x x x x x x x x x x"; - ; - ; - - -#------------------------------------------------------------ -# AT90s2343 (also AT90s2323 and ATtiny22) -#------------------------------------------------------------ - -part - id = "2343"; - desc = "AT90S2343"; - stk500_devcode = 0x43; - avr910_devcode = 0x4c; - signature = 0x1e 0x91 0x03; - chip_erase_delay = 18000; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 0; - - hvsp_controlstack = - 0x4C, 0x0C, 0x1C, 0x2C, 0x3C, 0x64, 0x74, 0x00, - 0x68, 0x78, 0x68, 0x68, 0x00, 0x00, 0x68, 0x78, - 0x78, 0x00, 0x6D, 0x0C, 0x80, 0x40, 0x20, 0x10, - 0x11, 0x08, 0x04, 0x02, 0x03, 0x08, 0x04, 0x00; - hventerstabdelay = 100; - hvspcmdexedelay = 0; - synchcycles = 6; - latchcycles = 1; - togglevtg = 0; - poweroffdelay = 25; - resetdelayms = 0; - resetdelayus = 50; - hvleavestabdelay = 100; - resetdelay = 25; - chiperasepolltimeout = 40; - chiperasetime = 0; - programfusepolltimeout = 25; - programlockpolltimeout = 25; - - memory "eeprom" - size = 128; - min_write_delay = 9000; - max_write_delay = 20000; - readback_p1 = 0x00; - readback_p2 = 0xff; - read = "1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0", - "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; - - write = "1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0", - "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; - - mode = 0x04; - delay = 12; - blocksize = 64; - readsize = 256; - ; - memory "flash" - size = 2048; - min_write_delay = 9000; - max_write_delay = 20000; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - " x x x x x x a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " x x x x x x a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write_lo = " 0 1 0 0 0 0 0 0", - " x x x x x x a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - write_hi = " 0 1 0 0 1 0 0 0", - " x x x x x x a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - mode = 0x04; - delay = 12; - blocksize = 128; - readsize = 128; - ; - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 x x x x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - memory "fuse" - size = 1; - min_write_delay = 9000; - max_write_delay = 20000; - read = "0 1 0 1 1 0 0 0 x x x x x x x x", - "x x x x x x x x o o o x x x x o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 1 1 1 1 i", - "x x x x x x x x x x x x x x x x"; - ; - memory "lock" - size = 1; - min_write_delay = 9000; - max_write_delay = 20000; - read = "0 1 0 1 1 0 0 0 x x x x x x x x", - "x x x x x x x x o o o x x x x o"; - - write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", - "x x x x x x x x x x x x x x x x"; - ; - ; - - -#------------------------------------------------------------ -# AT90s4433 -#------------------------------------------------------------ - -part - id = "4433"; - desc = "AT90S4433"; - stk500_devcode = 0x51; - avr910_devcode = 0x30; - signature = 0x1e 0x92 0x03; - chip_erase_delay = 20000; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 0; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 0; - togglevtg = 0; - poweroffdelay = 0; - resetdelayms = 0; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 15; - chiperasepolltimeout = 0; - programfusepulsewidth = 2; - programfusepolltimeout = 0; - programlockpulsewidth = 0; - programlockpolltimeout = 1; - - memory "eeprom" - size = 256; - min_write_delay = 9000; - max_write_delay = 20000; - readback_p1 = 0x00; - readback_p2 = 0xff; - read = " 1 0 1 0 0 0 0 0 x x x x x x x x", - "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; - - write = " 1 1 0 0 0 0 0 0 x x x x x x x x", - "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; - - mode = 0x04; - delay = 12; - blocksize = 128; - readsize = 256; - ; - memory "flash" - size = 4096; - min_write_delay = 9000; - max_write_delay = 20000; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - " x x x x x a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " x x x x x a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write_lo = " 0 1 0 0 0 0 0 0", - " x x x x x a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - write_hi = " 0 1 0 0 1 0 0 0", - " x x x x x a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - mode = 0x04; - delay = 12; - blocksize = 128; - readsize = 256; - ; - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 x x x x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - memory "fuse" - size = 1; - min_write_delay = 9000; - max_write_delay = 20000; - pwroff_after_write = yes; - read = "0 1 0 1 0 0 0 0 x x x x x x x x", - "x x x x x x x x x x o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 i i i i i", - "x x x x x x x x x x x x x x x x"; - ; - memory "lock" - size = 1; - min_write_delay = 9000; - max_write_delay = 20000; - read = "0 1 0 1 1 0 0 0 x x x x x x x x", - "x x x x x x x x x x x x x o o x"; - - write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", - "x x x x x x x x x x x x x x x x"; - ; - ; - -#------------------------------------------------------------ -# AT90s4434 -#------------------------------------------------------------ - -part - id = "4434"; -##### WARNING: No XML file for device 'AT90S4434'! ##### - desc = "AT90S4434"; - stk500_devcode = 0x52; - avr910_devcode = 0x6c; - signature = 0x1e 0x92 0x02; - chip_erase_delay = 20000; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", - "x x x x x x x x x x x x x x x x"; - - memory "eeprom" - size = 256; - min_write_delay = 9000; - max_write_delay = 20000; - readback_p1 = 0x00; - readback_p2 = 0xff; - read = " 1 0 1 0 0 0 0 0 x x x x x x x x", - "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; - - write = " 1 1 0 0 0 0 0 0 x x x x x x x x", - "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; - ; - memory "flash" - size = 4096; - min_write_delay = 9000; - max_write_delay = 20000; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - " x x x x x a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " x x x x x a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write_lo = " 0 1 0 0 0 0 0 0", - " x x x x x a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - write_hi = " 0 1 0 0 1 0 0 0", - " x x x x x a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - ; - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 x x x x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - memory "fuse" - size = 1; - min_write_delay = 9000; - max_write_delay = 20000; - read = "0 1 0 1 0 0 0 0 x x x x x x x x", - "x x x x x x x x x x o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 i i i i i", - "x x x x x x x x x x x x x x x x"; - ; - memory "lock" - size = 1; - min_write_delay = 9000; - max_write_delay = 20000; - read = "0 1 0 1 1 0 0 0 x x x x x x x x", - "x x x x x x x x x x x x x o o x"; - - write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", - "x x x x x x x x x x x x x x x x"; - ; - ; - -#------------------------------------------------------------ -# AT90s8515 -#------------------------------------------------------------ - -part - id = "8515"; - desc = "AT90S8515"; - stk500_devcode = 0x60; - avr910_devcode = 0x38; - signature = 0x1e 0x93 0x01; - chip_erase_delay = 20000; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 0; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 0; - togglevtg = 0; - poweroffdelay = 0; - resetdelayms = 0; - resetdelayus = 0; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepulsewidth = 15; - chiperasepolltimeout = 0; - programfusepulsewidth = 2; - programfusepolltimeout = 0; - programlockpulsewidth = 0; - programlockpolltimeout = 1; - - memory "eeprom" - size = 512; - min_write_delay = 4000; - max_write_delay = 9000; - readback_p1 = 0x80; - readback_p2 = 0x7f; - read = " 1 0 1 0 0 0 0 0 x x x x x x x a8", - "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; - - write = " 1 1 0 0 0 0 0 0 x x x x x x x a8", - "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; - - mode = 0x04; - delay = 12; - blocksize = 128; - readsize = 256; - ; - memory "flash" - size = 8192; - min_write_delay = 4000; - max_write_delay = 9000; - readback_p1 = 0x7f; - readback_p2 = 0x7f; - read_lo = " 0 0 1 0 0 0 0 0", - " x x x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " x x x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write_lo = " 0 1 0 0 0 0 0 0", - " x x x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - write_hi = " 0 1 0 0 1 0 0 0", - " x x x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - mode = 0x04; - delay = 12; - blocksize = 128; - readsize = 256; - ; - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 x x x x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - memory "fuse" - size = 1; - ; - memory "lock" - size = 1; - write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", - "x x x x x x x x x x x x x x x x"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - ; - -#------------------------------------------------------------ -# AT90s8535 -#------------------------------------------------------------ - -part - id = "8535"; - desc = "AT90S8535"; - stk500_devcode = 0x61; - avr910_devcode = 0x68; - signature = 0x1e 0x93 0x03; - chip_erase_delay = 20000; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 0; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 0; - togglevtg = 0; - poweroffdelay = 0; - resetdelayms = 0; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 15; - chiperasepolltimeout = 0; - programfusepulsewidth = 2; - programfusepolltimeout = 0; - programlockpulsewidth = 0; - programlockpolltimeout = 1; - - memory "eeprom" - size = 512; - min_write_delay = 9000; - max_write_delay = 20000; - readback_p1 = 0x00; - readback_p2 = 0xff; - read = " 1 0 1 0 0 0 0 0 x x x x x x x a8", - "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; - - write = " 1 1 0 0 0 0 0 0 x x x x x x x a8", - "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; - - mode = 0x04; - delay = 12; - blocksize = 128; - readsize = 256; - ; - memory "flash" - size = 8192; - min_write_delay = 9000; - max_write_delay = 20000; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - " x x x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " x x x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write_lo = " 0 1 0 0 0 0 0 0", - " x x x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - write_hi = " 0 1 0 0 1 0 0 0", - " x x x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - mode = 0x04; - delay = 12; - blocksize = 128; - readsize = 256; - ; - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 x x x x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - memory "fuse" - size = 1; - read = "0 1 0 1 1 0 0 0 x x x x x x x x", - "x x x x x x x x x x x x x x x o"; - write = "1 0 1 0 1 1 0 0 1 0 1 1 1 1 1 i", - "x x x x x x x x x x x x x x x x"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - memory "lock" - size = 1; - read = "0 1 0 1 1 0 0 0 x x x x x x x x", - "x x x x x x x x o o x x x x x x"; - write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", - "x x x x x x x x x x x x x x x x"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - ; - -#------------------------------------------------------------ -# ATmega103 -#------------------------------------------------------------ - -part - id = "m103"; - desc = "ATMEGA103"; - stk500_devcode = 0xB1; - avr910_devcode = 0x41; - signature = 0x1e 0x97 0x01; - chip_erase_delay = 112000; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 0; - - pp_controlstack = - 0x0E, 0x1E, 0x8E, 0x9E, 0x2E, 0x3E, 0xAE, 0xBE, - 0x4E, 0x5E, 0xCE, 0xDE, 0x6E, 0x7E, 0xEE, 0xDE, - 0x66, 0x76, 0xE6, 0xF6, 0x6A, 0x7A, 0xEA, 0x7A, - 0x7F, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 0; - togglevtg = 0; - poweroffdelay = 0; - resetdelayms = 0; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 15; - chiperasepolltimeout = 0; - programfusepulsewidth = 2; - programfusepolltimeout = 0; - programlockpulsewidth = 0; - programlockpolltimeout = 10; - - memory "eeprom" - size = 4096; - min_write_delay = 4000; - max_write_delay = 9000; - readback_p1 = 0x80; - readback_p2 = 0x7f; - read = " 1 0 1 0 0 0 0 0", - " x x x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write = " 1 1 0 0 0 0 0 0", - " x x x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - mode = 0x04; - delay = 12; - blocksize = 64; - readsize = 256; - ; - - memory "flash" - paged = yes; - size = 131072; - page_size = 256; - num_pages = 512; - min_write_delay = 22000; - max_write_delay = 56000; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - "a15 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - "a15 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " x x x x x x x x", - " x a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " x x x x x x x x", - " x a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - "a15 a14 a13 a12 a11 a10 a9 a8", - " a7 x x x x x x x", - " x x x x x x x x"; - - mode = 0x11; - delay = 70; - blocksize = 256; - readsize = 256; - ; - - memory "fuse" - size = 1; - read = "0 1 0 1 0 0 0 0 x x x x x x x x", - "x x x x x x x x x x o x o 1 o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 1 i 1 i i", - "x x x x x x x x x x x x x x x x"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "lock" - size = 1; - read = "0 1 0 1 1 0 0 0 x x x x x x x x", - "x x x x x x x x x x x x x o o x"; - - write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1", - "x x x x x x x x x x x x x x x x"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 x x x x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - ; - - -#------------------------------------------------------------ -# ATmega64 -#------------------------------------------------------------ - -part - id = "m64"; - desc = "ATMEGA64"; - has_jtag = yes; - stk500_devcode = 0xA0; - avr910_devcode = 0x45; - signature = 0x1e 0x96 0x02; - chip_erase_delay = 9000; - pagel = 0xD7; - bs2 = 0xA0; - reset = dedicated; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 0; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 6; - togglevtg = 0; - poweroffdelay = 0; - resetdelayms = 0; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 10; - programfusepulsewidth = 0; - programfusepolltimeout = 5; - programlockpulsewidth = 0; - programlockpolltimeout = 5; - - idr = 0x22; - spmcr = 0x68; - allowfullpagebitstream = yes; - - memory "eeprom" - paged = no; /* leave this "no" */ - page_size = 8; /* for parallel programming */ - size = 2048; - min_write_delay = 9000; - max_write_delay = 9000; - readback_p1 = 0xff; - readback_p2 = 0xff; - read = " 1 0 1 0 0 0 0 0", - " x x x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write = " 1 1 0 0 0 0 0 0", - " x x x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - mode = 0x04; - delay = 20; - blocksize = 64; - readsize = 256; - ; - - memory "flash" - paged = yes; - size = 65536; - page_size = 256; - num_pages = 256; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - " x a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " x a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " x x x x x x x x", - " x a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " x x x x x x x x", - " x a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - " x a14 a13 a12 a11 a10 a9 a8", - " a7 x x x x x x x", - " x x x x x x x x"; - - mode = 0x21; - delay = 6; - blocksize = 128; - readsize = 256; - ; - - memory "lfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "hfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "efuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", - "x x x x x x x x x x x x x x i i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "lock" - size = 1; - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x x x o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", - "x x x x x x x x 1 1 i i i i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "calibration" - size = 4; - read = "0 0 1 1 1 0 0 0 x x x x x x x x", - "0 0 0 0 0 0 a1 a0 o o o o o o o o"; - ; - - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 x x x x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - ; - - - - -#------------------------------------------------------------ -# ATmega128 -#------------------------------------------------------------ - -part - id = "m128"; - desc = "ATMEGA128"; - has_jtag = yes; - stk500_devcode = 0xB2; - avr910_devcode = 0x43; - signature = 0x1e 0x97 0x02; - chip_erase_delay = 9000; - pagel = 0xD7; - bs2 = 0xA0; - reset = dedicated; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 0; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 6; - togglevtg = 0; - poweroffdelay = 0; - resetdelayms = 0; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 10; - programfusepulsewidth = 0; - programfusepolltimeout = 5; - programlockpulsewidth = 0; - programlockpolltimeout = 5; - - idr = 0x22; - spmcr = 0x68; - rampz = 0x3b; - allowfullpagebitstream = yes; - - memory "eeprom" - paged = no; /* leave this "no" */ - page_size = 8; /* for parallel programming */ - size = 4096; - min_write_delay = 9000; - max_write_delay = 9000; - readback_p1 = 0xff; - readback_p2 = 0xff; - read = " 1 0 1 0 0 0 0 0", - " x x x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write = " 1 1 0 0 0 0 0 0", - " x x x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - mode = 0x04; - delay = 12; - blocksize = 64; - readsize = 256; - ; - - memory "flash" - paged = yes; - size = 131072; - page_size = 256; - num_pages = 512; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - "a15 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - "a15 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " x x x x x x x x", - " x a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " x x x x x x x x", - " x a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - "a15 a14 a13 a12 a11 a10 a9 a8", - " a7 x x x x x x x", - " x x x x x x x x"; - - mode = 0x21; - delay = 6; - blocksize = 128; - readsize = 256; - ; - - memory "lfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "hfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "efuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", - "x x x x x x x x x x x x x x i i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "lock" - size = 1; - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x x x o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", - "x x x x x x x x 1 1 i i i i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "calibration" - size = 4; - read = "0 0 1 1 1 0 0 0 x x x x x x x x", - "0 0 0 0 0 0 a1 a0 o o o o o o o o"; - ; - - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 x x x x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - ; - -#------------------------------------------------------------ -# AT90CAN128 -#------------------------------------------------------------ - -part - id = "c128"; - desc = "AT90CAN128"; - has_jtag = yes; - stk500_devcode = 0xB3; -# avr910_devcode = 0x43; - signature = 0x1e 0x97 0x81; - chip_erase_delay = 9000; - pagel = 0xD7; - bs2 = 0xA0; - reset = dedicated; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 6; - togglevtg = 0; - poweroffdelay = 0; - resetdelayms = 0; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 10; - programfusepulsewidth = 0; - programfusepolltimeout = 5; - programlockpulsewidth = 0; - programlockpolltimeout = 5; - - idr = 0x31; - spmcr = 0x57; - rampz = 0x3b; - eecr = 0x3f; - allowfullpagebitstream = no; - - memory "eeprom" - paged = no; /* leave this "no" */ - page_size = 8; /* for parallel programming */ - size = 4096; - min_write_delay = 9000; - max_write_delay = 9000; - readback_p1 = 0xff; - readback_p2 = 0xff; - read = " 1 0 1 0 0 0 0 0", - " 0 0 0 x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write = " 1 1 0 0 0 0 0 0", - " 0 0 0 x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 0 0 0", - " x x x x x x x x"; - - - mode = 0x41; - delay = 20; - blocksize = 8; - readsize = 256; - ; - - memory "flash" - paged = yes; - size = 131072; - page_size = 256; - num_pages = 512; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - "a15 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - "a15 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " 0 0 0 x x x x x", - " x a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " 0 0 0 x x x x x", - " x a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - "a15 a14 a13 a12 a11 a10 a9 a8", - " a7 x x x x x x x", - " x x x x x x x x"; - - mode = 0x41; - delay = 6; - blocksize = 256; - readsize = 256; - ; - - memory "lfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "hfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "efuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", - "x x x x x x x x x x x x i i i i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "lock" - size = 1; - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x x x o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", - "x x x x x x x x 1 1 i i i i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "calibration" - size = 1; - read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - ; - - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 x x x x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - ; - - -#------------------------------------------------------------ -# ATmega16 -#------------------------------------------------------------ - -part - id = "m16"; - desc = "ATMEGA16"; - has_jtag = yes; - stk500_devcode = 0x82; - avr910_devcode = 0x74; - signature = 0x1e 0x94 0x03; - pagel = 0xd7; - bs2 = 0xa0; - chip_erase_delay = 9000; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 0; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 100; - latchcycles = 6; - togglevtg = 0; - poweroffdelay = 0; - resetdelayms = 0; - resetdelayus = 0; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 10; - programfusepulsewidth = 0; - programfusepolltimeout = 5; - programlockpulsewidth = 0; - programlockpolltimeout = 5; - - idr = 0x31; - spmcr = 0x57; - allowfullpagebitstream = yes; - - memory "eeprom" - paged = no; /* leave this "no" */ - page_size = 4; /* for parallel programming */ - size = 512; - min_write_delay = 9000; - max_write_delay = 9000; - readback_p1 = 0xff; - readback_p2 = 0xff; - read = " 1 0 1 0 0 0 0 0", - " 0 0 x x x x a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write = " 1 1 0 0 0 0 0 0", - " 0 0 x x x x a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 0 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 x x x x a9 a8", - " a7 a6 a5 a4 a3 a2 0 0", - " x x x x x x x x"; - - mode = 0x04; - delay = 10; - blocksize = 128; - readsize = 256; - ; - - memory "flash" - paged = yes; - size = 16384; - page_size = 128; - num_pages = 128; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - " 0 0 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " 0 0 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " 0 0 x x x x x x", - " x x a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " 0 0 x x x x x x", - " x x a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - " 0 0 a13 a12 a11 a10 a9 a8", - " a7 a6 x x x x x x", - " x x x x x x x x"; - - mode = 0x21; - delay = 6; - blocksize = 128; - readsize = 256; - ; - - memory "lock" - size = 1; - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x x x o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", - "x x x x x x x x 1 1 i i i i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "lfuse" - size = 1; - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "hfuse" - size = 1; - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 x x x x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - memory "calibration" - size = 4; - - read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", - "0 0 0 0 0 0 a1 a0 o o o o o o o o"; - ; - ; - - -#------------------------------------------------------------ -# ATmega164P -#------------------------------------------------------------ - -# close to ATmega16 - -part - id = "m164p"; - desc = "ATMEGA164P"; - has_jtag = yes; -# stk500_devcode = 0x82; # no STK500v1 support -# avr910_devcode = 0x?; # try the ATmega16 one:^ - avr910_devcode = 0x74; - signature = 0x1e 0x94 0x0a; - pagel = 0xd7; - bs2 = 0xa0; - chip_erase_delay = 9000; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 0; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 10; - programfusepulsewidth = 0; - programfusepolltimeout = 5; - programlockpulsewidth = 0; - programlockpolltimeout = 5; - - idr = 0x31; - spmcr = 0x57; - allowfullpagebitstream = no; - - memory "eeprom" - paged = no; /* leave this "no" */ - page_size = 4; /* for parallel programming */ - size = 512; - min_write_delay = 9000; - max_write_delay = 9000; - readback_p1 = 0xff; - readback_p2 = 0xff; - read = " 1 0 1 0 0 0 0 0", - " 0 0 x x x x a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write = " 1 1 0 0 0 0 0 0", - " 0 0 x x x x a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 0 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 x x x x a9 a8", - " a7 a6 a5 a4 a3 a2 0 0", - " x x x x x x x x"; - - mode = 0x41; - delay = 10; - blocksize = 128; - readsize = 256; - ; - - memory "flash" - paged = yes; - size = 16384; - page_size = 128; - num_pages = 128; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - " 0 0 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " 0 0 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " 0 0 x x x x x x", - " x x a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " 0 0 x x x x x x", - " x x a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - " 0 0 a13 a12 a11 a10 a9 a8", - " a7 a6 x x x x x x", - " x x x x x x x x"; - - mode = 0x21; - delay = 6; - blocksize = 128; - readsize = 256; - ; - - memory "lock" - size = 1; - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x x x o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", - "x x x x x x x x 1 1 i i i i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "lfuse" - size = 1; - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "hfuse" - size = 1; - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "efuse" - size = 1; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", - "x x x x x x x x 1 1 1 1 1 i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 x x x x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - - memory "calibration" - size = 1; - - read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - ; - ; - - -#------------------------------------------------------------ -# ATmega324P -#------------------------------------------------------------ - -# similar to ATmega164P - -part - id = "m324p"; - desc = "ATMEGA324P"; - has_jtag = yes; -# stk500_devcode = 0x82; # no STK500v1 support -# avr910_devcode = 0x?; # try the ATmega16 one:^ - avr910_devcode = 0x74; - signature = 0x1e 0x95 0x08; - pagel = 0xd7; - bs2 = 0xa0; - chip_erase_delay = 9000; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 0; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 10; - programfusepulsewidth = 0; - programfusepolltimeout = 5; - programlockpulsewidth = 0; - programlockpolltimeout = 5; - - idr = 0x31; - spmcr = 0x57; - allowfullpagebitstream = no; - - memory "eeprom" - paged = no; /* leave this "no" */ - page_size = 4; /* for parallel programming */ - size = 1024; - min_write_delay = 9000; - max_write_delay = 9000; - readback_p1 = 0xff; - readback_p2 = 0xff; - read = " 1 0 1 0 0 0 0 0", - " 0 0 x x x a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write = " 1 1 0 0 0 0 0 0", - " 0 0 x x x a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 0 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 x x x a10 a9 a8", - " a7 a6 a5 a4 a3 a2 0 0", - " x x x x x x x x"; - - mode = 0x41; - delay = 10; - blocksize = 128; - readsize = 256; - ; - - memory "flash" - paged = yes; - size = 32768; - page_size = 128; - num_pages = 256; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - " 0 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " 0 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " 0 0 x x x x x x", - " x x a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " 0 0 x x x x x x", - " x x a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - " 0 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 x x x x x x", - " x x x x x x x x"; - - mode = 0x21; - delay = 6; - blocksize = 256; - readsize = 256; - ; - - memory "lock" - size = 1; - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x x x o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", - "x x x x x x x x 1 1 i i i i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "lfuse" - size = 1; - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "hfuse" - size = 1; - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "efuse" - size = 1; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", - "x x x x x x x x 1 1 1 1 1 i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 x x x x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - - memory "calibration" - size = 1; - - read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - ; - ; - - -#------------------------------------------------------------ -# ATmega644 -#------------------------------------------------------------ - -# similar to ATmega164 - -part - id = "m644"; - desc = "ATMEGA644"; - has_jtag = yes; -# stk500_devcode = 0x82; # no STK500v1 support -# avr910_devcode = 0x?; # try the ATmega16 one:^ - avr910_devcode = 0x74; - signature = 0x1e 0x96 0x09; - pagel = 0xd7; - bs2 = 0xa0; - chip_erase_delay = 9000; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 0; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 6; - togglevtg = 0; - poweroffdelay = 0; - resetdelayms = 0; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 10; - programfusepulsewidth = 0; - programfusepolltimeout = 5; - programlockpulsewidth = 0; - programlockpolltimeout = 5; - - idr = 0x31; - spmcr = 0x57; - allowfullpagebitstream = no; - - memory "eeprom" - paged = no; /* leave this "no" */ - page_size = 8; /* for parallel programming */ - size = 2048; - min_write_delay = 9000; - max_write_delay = 9000; - readback_p1 = 0xff; - readback_p2 = 0xff; - read = " 1 0 1 0 0 0 0 0", - " 0 0 x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write = " 1 1 0 0 0 0 0 0", - " 0 0 x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 0 0 0", - " x x x x x x x x"; - - mode = 0x41; - delay = 10; - blocksize = 128; - readsize = 256; - ; - - memory "flash" - paged = yes; - size = 65536; - page_size = 256; - num_pages = 256; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - "a15 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - "a15 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " 0 0 x x x x x x", - " x a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " 0 0 x x x x x x", - " x a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - "a15 a14 a13 a12 a11 a10 a9 a8", - " a7 x x x x x x x", - " x x x x x x x x"; - - mode = 0x21; - delay = 6; - blocksize = 256; - readsize = 256; - ; - - memory "lock" - size = 1; - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x x x o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", - "x x x x x x x x 1 1 i i i i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "lfuse" - size = 1; - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "hfuse" - size = 1; - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "efuse" - size = 1; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", - "x x x x x x x x 1 1 1 1 1 i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 x x x x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - - memory "calibration" - size = 1; - - read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - ; - ; - -#------------------------------------------------------------ -# ATmega644P -#------------------------------------------------------------ - -# similar to ATmega164p - -part - id = "m644p"; - desc = "ATMEGA644P"; - has_jtag = yes; -# stk500_devcode = 0x82; # no STK500v1 support -# avr910_devcode = 0x?; # try the ATmega16 one:^ - avr910_devcode = 0x74; - signature = 0x1e 0x96 0x0a; - pagel = 0xd7; - bs2 = 0xa0; - chip_erase_delay = 9000; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 0; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 6; - togglevtg = 0; - poweroffdelay = 0; - resetdelayms = 0; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 10; - programfusepulsewidth = 0; - programfusepolltimeout = 5; - programlockpulsewidth = 0; - programlockpolltimeout = 5; - - idr = 0x31; - spmcr = 0x57; - allowfullpagebitstream = no; - - memory "eeprom" - paged = no; /* leave this "no" */ - page_size = 8; /* for parallel programming */ - size = 2048; - min_write_delay = 9000; - max_write_delay = 9000; - readback_p1 = 0xff; - readback_p2 = 0xff; - read = " 1 0 1 0 0 0 0 0", - " 0 0 x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write = " 1 1 0 0 0 0 0 0", - " 0 0 x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 0 0 0", - " x x x x x x x x"; - - mode = 0x41; - delay = 10; - blocksize = 128; - readsize = 256; - ; - - memory "flash" - paged = yes; - size = 65536; - page_size = 256; - num_pages = 256; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - "a15 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - "a15 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " 0 0 x x x x x x", - " x a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " 0 0 x x x x x x", - " x a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - "a15 a14 a13 a12 a11 a10 a9 a8", - " a7 x x x x x x x", - " x x x x x x x x"; - - mode = 0x21; - delay = 6; - blocksize = 256; - readsize = 256; - ; - - memory "lock" - size = 1; - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x x x o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", - "x x x x x x x x 1 1 i i i i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "lfuse" - size = 1; - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "hfuse" - size = 1; - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "efuse" - size = 1; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", - "x x x x x x x x 1 1 1 1 1 i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 x x x x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - - memory "calibration" - size = 1; - - read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - ; - ; - - - -#------------------------------------------------------------ -# ATmega162 -#------------------------------------------------------------ - -part - id = "m162"; - desc = "ATMEGA162"; - has_jtag = yes; - stk500_devcode = 0x83; - avr910_devcode = 0x63; - signature = 0x1e 0x94 0x04; - chip_erase_delay = 9000; - pagel = 0xd7; - bs2 = 0xa0; - - idr = 0x04; - spmcr = 0x57; - allowfullpagebitstream = yes; - - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", - "x x x x x x x x x x x x x x x x"; - - memory "flash" - paged = yes; - size = 16384; - page_size = 128; - num_pages = 128; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - - read_lo = " 0 0 1 0 0 0 0 0", - " 0 0 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " 0 0 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " 0 0 x x x x x x", - " x x a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " 0 0 x x x x x x", - " x x a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - " 0 0 a13 a12 a11 a10 a9 a8", - " a7 a6 x x x x x x", - " x x x x x x x x"; - mode = 0x41; - delay = 10; - blocksize = 128; - readsize = 256; - - ; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 0; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 6; - togglevtg = 0; - poweroffdelay = 0; - resetdelayms = 0; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 10; - programfusepulsewidth = 0; - programfusepolltimeout = 5; - programlockpulsewidth = 0; - programlockpolltimeout = 5; - - memory "eeprom" - paged = no; /* leave this "no" */ - page_size = 4; /* for parallel programming */ - size = 512; - min_write_delay = 9000; - max_write_delay = 9000; - readback_p1 = 0xff; - readback_p2 = 0xff; - - read = " 1 0 1 0 0 0 0 0", - " 0 0 x x x x a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write = " 1 1 0 0 0 0 0 0", - " 0 0 x x x x a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 0 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 x x x x a9 a8", - " a7 a6 a5 a4 a3 a2 0 0", - " x x x x x x x x"; - - mode = 0x41; - delay = 20; - blocksize = 4; - readsize = 256; - ; - - memory "lfuse" - size = 1; - min_write_delay = 16000; - max_write_delay = 16000; - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - ; - - memory "hfuse" - size = 1; - min_write_delay = 16000; - max_write_delay = 16000; - - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - ; - - memory "efuse" - size = 1; - min_write_delay = 16000; - max_write_delay = 16000; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", - "x x x x x x x x 1 1 1 1 1 i i i"; - ; - - memory "lock" - size = 1; - min_write_delay = 16000; - max_write_delay = 16000; - - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x x x o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", - "x x x x x x x x 1 1 i i i i i i"; - ; - - memory "signature" - size = 3; - - read = "0 0 1 1 0 0 0 0 0 0 x x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - - memory "calibration" - size = 1; - - read = "0 0 1 1 1 0 0 0 0 0 x x x x x x", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - ; -; - - - -#------------------------------------------------------------ -# ATmega163 -#------------------------------------------------------------ - -part - id = "m163"; - desc = "ATMEGA163"; - stk500_devcode = 0x81; - avr910_devcode = 0x64; - signature = 0x1e 0x94 0x02; - chip_erase_delay = 32000; - pagel = 0xd7; - bs2 = 0xa0; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", - "x x x x x x x x x x x x x x x x"; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 0; - togglevtg = 0; - poweroffdelay = 0; - resetdelayms = 0; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 30; - programfusepulsewidth = 0; - programfusepolltimeout = 2; - programlockpulsewidth = 0; - programlockpolltimeout = 2; - - - memory "eeprom" - size = 512; - min_write_delay = 4000; - max_write_delay = 4000; - readback_p1 = 0xff; - readback_p2 = 0xff; - read = " 1 0 1 0 0 0 0 0", - " x x x x x x x a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write = " 1 1 0 0 0 0 0 0", - " x x x x x x x a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - ; - - memory "flash" - paged = yes; - size = 16384; - page_size = 128; - num_pages = 128; - min_write_delay = 16000; - max_write_delay = 16000; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - " x x x a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " x x x a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " x x x x x x x x", - " x x a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " x x x x x x x x", - " x x a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - " x x x a12 a11 a10 a9 a8", - " a7 a6 x x x x x x", - " x x x x x x x x"; - - mode = 0x41; - delay = 6; - blocksize = 128; - readsize = 256; - ; - - memory "lfuse" - size = 1; - min_write_delay = 2000; - max_write_delay = 2000; - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o x x o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i 1 1 i i i i"; - ; - - memory "hfuse" - size = 1; - min_write_delay = 2000; - max_write_delay = 2000; - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x x x x x 1 o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x 1 1 1 1 1 i i i"; - ; - - memory "lock" - size = 1; - min_write_delay = 2000; - max_write_delay = 2000; - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "x x x x 0 x x x x x o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", - "x x x x x x x x 1 1 i i i i i i"; - ; - - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 x x x x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - - memory "calibration" - size = 1; - read = "0 0 1 1 1 0 0 0 x x x x x x x x", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - ; - ; - -#------------------------------------------------------------ -# ATmega169 -#------------------------------------------------------------ - -part - id = "m169"; - desc = "ATMEGA169"; - has_jtag = yes; - stk500_devcode = 0x85; - avr910_devcode = 0x78; - signature = 0x1e 0x94 0x05; - chip_erase_delay = 9000; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", - "x x x x x x x x x x x x x x x x"; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 10; - programfusepulsewidth = 0; - programfusepolltimeout = 5; - programlockpulsewidth = 0; - programlockpolltimeout = 5; - - idr = 0x31; - spmcr = 0x57; - - memory "eeprom" - paged = no; /* leave this "no" */ - page_size = 4; /* for parallel programming */ - size = 512; - min_write_delay = 9000; - max_write_delay = 9000; - readback_p1 = 0xff; - readback_p2 = 0xff; - read = " 1 0 1 0 0 0 0 0", - " x x x x x x x a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write = " 1 1 0 0 0 0 0 0", - " x x x x x x x a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 0 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 x x x x x a8", - " a7 a6 a5 a4 a3 a2 0 0", - " x x x x x x x x"; - - mode = 0x41; - delay = 20; - blocksize = 4; - readsize = 256; - ; - - memory "flash" - paged = yes; - size = 16384; - page_size = 128; - num_pages = 128; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - " x x x a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " x x x a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " x x x x x x x x", - " x x a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " x x x x x x x x", - " x x a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - " x x x a12 a11 a10 a9 a8", - " a7 a6 x x x x x x", - " x x x x x x x x"; - - mode = 0x41; - delay = 6; - blocksize = 128; - readsize = 256; - ; - - memory "lfuse" - size = 1; - min_write_delay = 2000; - max_write_delay = 2000; - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - ; - - memory "hfuse" - size = 1; - min_write_delay = 2000; - max_write_delay = 2000; - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - ; - - memory "efuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", - "x x x x x x x x x x x x i i i i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - ; - - memory "lock" - size = 1; - min_write_delay = 2000; - max_write_delay = 2000; - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x x x o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", - "x x x x x x x x 1 1 i i i i i i"; - ; - - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - - memory "calibration" - size = 1; - read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - ; - ; - -#------------------------------------------------------------ -# ATmega329 -#------------------------------------------------------------ - -part - id = "m329"; - desc = "ATMEGA329"; - has_jtag = yes; -# stk500_devcode = 0x85; # no STK500 support, only STK500v2 -# avr910_devcode = 0x?; # try the ATmega169 one: - avr910_devcode = 0x75; - signature = 0x1e 0x95 0x03; - chip_erase_delay = 9000; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", - "x x x x x x x x x x x x x x x x"; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 10; - programfusepulsewidth = 0; - programfusepolltimeout = 5; - programlockpulsewidth = 0; - programlockpolltimeout = 5; - - idr = 0x31; - spmcr = 0x57; - - memory "eeprom" - paged = no; /* leave this "no" */ - page_size = 4; /* for parallel programming */ - size = 1024; - min_write_delay = 9000; - max_write_delay = 9000; - readback_p1 = 0xff; - readback_p2 = 0xff; - read = " 1 0 1 0 0 0 0 0", - " x x x x x x a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write = " 1 1 0 0 0 0 0 0", - " x x x x x x a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 0 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 x x x x a9 a8", - " a7 a6 a5 a4 a3 a2 0 0", - " x x x x x x x x"; - - mode = 0x41; - delay = 20; - blocksize = 8; - readsize = 256; - ; - - memory "flash" - paged = yes; - size = 32768; - page_size = 128; - num_pages = 256; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - " x a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " x a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " x x x x x x x x", - " x x a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " x x x x x x x x", - " x x a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - " x x x a12 a11 a10 a9 a8", - " a7 a6 x x x x x x", - " x x x x x x x x"; - - mode = 0x41; - delay = 6; - blocksize = 256; - readsize = 256; - ; - - memory "lfuse" - size = 1; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - ; - - memory "hfuse" - size = 1; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - ; - - memory "efuse" - size = 1; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", - "x x x x x x x x x x x x x i i i"; - ; - - memory "lock" - size = 1; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x x x o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", - "x x x x x x x x 1 1 i i i i i i"; - ; - - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - - memory "calibration" - size = 1; - read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - ; - ; - -#------------------------------------------------------------ -# ATmega3290 -#------------------------------------------------------------ - -# identical to ATmega329 - -part - id = "m3290"; - desc = "ATMEGA3290"; - has_jtag = yes; -# stk500_devcode = 0x85; # no STK500 support, only STK500v2 -# avr910_devcode = 0x?; # try the ATmega169 one: - avr910_devcode = 0x75; - signature = 0x1e 0x95 0x04; - chip_erase_delay = 9000; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", - "x x x x x x x x x x x x x x x x"; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 10; - programfusepulsewidth = 0; - programfusepolltimeout = 5; - programlockpulsewidth = 0; - programlockpolltimeout = 5; - - idr = 0x31; - spmcr = 0x57; - - memory "eeprom" - paged = no; /* leave this "no" */ - page_size = 4; /* for parallel programming */ - size = 1024; - min_write_delay = 9000; - max_write_delay = 9000; - readback_p1 = 0xff; - readback_p2 = 0xff; - read = " 1 0 1 0 0 0 0 0", - " x x x x x x a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write = " 1 1 0 0 0 0 0 0", - " x x x x x x a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 0 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 x x x x a9 a8", - " a7 a6 a5 a4 a3 a3 0 0", - " x x x x x x x x"; - - mode = 0x41; - delay = 20; - blocksize = 8; - readsize = 256; - ; - - memory "flash" - paged = yes; - size = 32768; - page_size = 128; - num_pages = 256; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - " x a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " x a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " x x x x x x x x", - " x x a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " x x x x x x x x", - " x x a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - " x x x a12 a11 a10 a9 a8", - " a7 a6 x x x x x x", - " x x x x x x x x"; - - mode = 0x41; - delay = 6; - blocksize = 256; - readsize = 256; - ; - - memory "lfuse" - size = 1; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - ; - - memory "hfuse" - size = 1; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - ; - - memory "efuse" - size = 1; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", - "x x x x x x x x x x x x x i i i"; - ; - - memory "lock" - size = 1; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x x x o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", - "x x x x x x x x 1 1 i i i i i i"; - ; - - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - - memory "calibration" - size = 1; - read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - ; - ; - -#------------------------------------------------------------ -# ATmega649 -#------------------------------------------------------------ - -part - id = "m649"; - desc = "ATMEGA649"; - has_jtag = yes; -# stk500_devcode = 0x85; # no STK500 support, only STK500v2 -# avr910_devcode = 0x?; # try the ATmega169 one: - avr910_devcode = 0x75; - signature = 0x1e 0x96 0x03; - chip_erase_delay = 9000; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", - "x x x x x x x x x x x x x x x x"; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 10; - programfusepulsewidth = 0; - programfusepolltimeout = 5; - programlockpulsewidth = 0; - programlockpolltimeout = 5; - - idr = 0x31; - spmcr = 0x57; - - memory "eeprom" - paged = no; /* leave this "no" */ - page_size = 8; /* for parallel programming */ - size = 2048; - min_write_delay = 9000; - max_write_delay = 9000; - readback_p1 = 0xff; - readback_p2 = 0xff; - read = " 1 0 1 0 0 0 0 0", - " x x x x x a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write = " 1 1 0 0 0 0 0 0", - " x x x x x a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 x x x a10 a9 a8", - " a7 a6 a5 a4 a3 0 0 0", - " x x x x x x x x"; - - mode = 0x41; - delay = 20; - blocksize = 8; - readsize = 256; - ; - - memory "flash" - paged = yes; - size = 65536; - page_size = 256; - num_pages = 256; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - "a15 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - "a15 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " x x x x x x x x", - " x a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " x x x x x x x x", - " x a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - " x x x a12 a11 a10 a9 a8", - " a7 x x x x x x x", - " x x x x x x x x"; - - mode = 0x41; - delay = 6; - blocksize = 256; - readsize = 256; - ; - - memory "lfuse" - size = 1; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - ; - - memory "hfuse" - size = 1; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - ; - - memory "efuse" - size = 1; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", - "x x x x x x x x x x x x x i i i"; - ; - - memory "lock" - size = 1; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x x x o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", - "x x x x x x x x 1 1 i i i i i i"; - ; - - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - - memory "calibration" - size = 1; - read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - ; - ; - -#------------------------------------------------------------ -# ATmega6490 -#------------------------------------------------------------ - -# identical to ATmega649 - -part - id = "m6490"; - desc = "ATMEGA6490"; - has_jtag = yes; -# stk500_devcode = 0x85; # no STK500 support, only STK500v2 -# avr910_devcode = 0x?; # try the ATmega169 one: - avr910_devcode = 0x75; - signature = 0x1e 0x96 0x04; - chip_erase_delay = 9000; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", - "x x x x x x x x x x x x x x x x"; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 10; - programfusepulsewidth = 0; - programfusepolltimeout = 5; - programlockpulsewidth = 0; - programlockpolltimeout = 5; - - idr = 0x31; - spmcr = 0x57; - - memory "eeprom" - paged = no; /* leave this "no" */ - page_size = 8; /* for parallel programming */ - size = 2048; - min_write_delay = 9000; - max_write_delay = 9000; - readback_p1 = 0xff; - readback_p2 = 0xff; - read = " 1 0 1 0 0 0 0 0", - " x x x x x a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write = " 1 1 0 0 0 0 0 0", - " x x x x x a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 x x x x x a8", - " a7 a6 a5 a4 a3 0 0 0", - " x x x x x x x x"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 x x x a10 a9 a8", - " a7 a6 a5 a4 a3 0 0 0", - " x x x x x x x x"; - - mode = 0x41; - delay = 20; - blocksize = 8; - readsize = 256; - ; - - memory "flash" - paged = yes; - size = 65536; - page_size = 256; - num_pages = 256; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - "a15 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - "a15 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " x x x x x x x x", - " x a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " x x x x x x x x", - " x a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - " x x x a12 a11 a10 a9 a8", - " a7 x x x x x x x", - " x x x x x x x x"; - - mode = 0x41; - delay = 6; - blocksize = 256; - readsize = 256; - ; - - memory "lfuse" - size = 1; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - ; - - memory "hfuse" - size = 1; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - ; - - memory "efuse" - size = 1; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", - "x x x x x x x x x x x x x i i i"; - ; - - memory "lock" - size = 1; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x x x o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", - "x x x x x x x x 1 1 i i i i i i"; - ; - - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - - memory "calibration" - size = 1; - read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - ; - ; - -#------------------------------------------------------------ -# ATmega32 -#------------------------------------------------------------ - -part - id = "m32"; - desc = "ATMEGA32"; - has_jtag = yes; - stk500_devcode = 0x91; - avr910_devcode = 0x72; - signature = 0x1e 0x95 0x02; - chip_erase_delay = 9000; - pagel = 0xd7; - bs2 = 0xa0; - reset = dedicated; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", - "x x x x x x x x x x x x x x x x"; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 0; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 6; - togglevtg = 0; - poweroffdelay = 0; - resetdelayms = 0; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 10; - programfusepulsewidth = 0; - programfusepolltimeout = 5; - programlockpulsewidth = 0; - programlockpolltimeout = 5; - - idr = 0x31; - spmcr = 0x57; - allowfullpagebitstream = yes; - - memory "eeprom" - paged = no; /* leave this "no" */ - page_size = 4; /* for parallel programming */ - size = 1024; - min_write_delay = 9000; - max_write_delay = 9000; - readback_p1 = 0xff; - readback_p2 = 0xff; - read = " 1 0 1 0 0 0 0 0", - " 0 0 x x x x a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write = " 1 1 0 0 0 0 0 0", - " 0 0 x x x x a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 0 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 x x x x a9 a8", - " a7 a6 a5 a4 a3 a2 0 0", - " x x x x x x x x"; - - mode = 0x04; - delay = 10; - blocksize = 64; - readsize = 256; - ; - - memory "flash" - paged = yes; - size = 32768; - page_size = 128; - num_pages = 256; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - " 0 0 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " 0 0 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " 0 0 x x x x x x", - " x x a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " 0 0 x x x x x x", - " x x a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - " 0 0 a13 a12 a11 a10 a9 a8", - " a7 a6 x x x x x x", - " x x x x x x x x"; - - mode = 0x21; - delay = 6; - blocksize = 64; - readsize = 256; - ; - - memory "lfuse" - size = 1; - min_write_delay = 2000; - max_write_delay = 2000; - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - ; - - memory "hfuse" - size = 1; - min_write_delay = 2000; - max_write_delay = 2000; - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - ; - - memory "lock" - size = 1; - min_write_delay = 2000; - max_write_delay = 2000; - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x x x o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", - "x x x x x x x x 1 1 i i i i i i"; - ; - - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 x x x x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - - memory "calibration" - size = 4; - read = "0 0 1 1 1 0 0 0 0 0 x x x x x x", - "0 0 0 0 0 0 a1 a0 o o o o o o o o"; - ; - ; - -#------------------------------------------------------------ -# ATmega161 -#------------------------------------------------------------ - -part - id = "m161"; - desc = "ATMEGA161"; - stk500_devcode = 0x80; - avr910_devcode = 0x60; - signature = 0x1e 0x94 0x01; - chip_erase_delay = 28000; - pagel = 0xd7; - bs2 = 0xa0; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", - "x x x x x x x x x x x x x x x x"; - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 0; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 0; - togglevtg = 0; - poweroffdelay = 0; - resetdelayms = 0; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 30; - programfusepulsewidth = 0; - programfusepolltimeout = 2; - programlockpulsewidth = 0; - programlockpolltimeout = 2; - - memory "eeprom" - size = 512; - min_write_delay = 3400; - max_write_delay = 3400; - readback_p1 = 0xff; - readback_p2 = 0xff; - read = " 1 0 1 0 0 0 0 0", - " x x x x x x x a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write = " 1 1 0 0 0 0 0 0", - " x x x x x x x a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - mode = 0x04; - delay = 5; - blocksize = 128; - readsize = 256; - ; - - memory "flash" - paged = yes; - size = 16384; - page_size = 128; - num_pages = 128; - min_write_delay = 14000; - max_write_delay = 14000; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - " x x x a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " x x x a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " x x x x x x x x", - " x x a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " x x x x x x x x", - " x x a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - " x x x a12 a11 a10 a9 a8", - " a7 a6 x x x x x x", - " x x x x x x x x"; - - mode = 0x21; - delay = 16; - blocksize = 128; - readsize = 256; - ; - - memory "fuse" - size = 1; - min_write_delay = 2000; - max_write_delay = 2000; - read = "0 1 0 1 0 0 0 0 x x x x x x x x", - "x x x x x x x x x o x o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 x x x x x", - "x x x x x x x x 1 i 1 i i i i i"; - ; - - memory "lock" - size = 1; - min_write_delay = 2000; - max_write_delay = 2000; - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x x x o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", - "x x x x x x x x 1 1 i i i i i i"; - ; - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 x x x x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - ; - - -#------------------------------------------------------------ -# ATmega8 -#------------------------------------------------------------ - -part - id = "m8"; - desc = "ATMEGA8"; - stk500_devcode = 0x70; - avr910_devcode = 0x76; - signature = 0x1e 0x93 0x07; - pagel = 0xd7; - bs2 = 0xc2; - chip_erase_delay = 10000; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 0; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 2; - resetdelayus = 0; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 10; - programfusepulsewidth = 0; - programfusepolltimeout = 5; - programlockpulsewidth = 0; - programlockpolltimeout = 5; - - memory "eeprom" - size = 512; - min_write_delay = 9000; - max_write_delay = 9000; - readback_p1 = 0xff; - readback_p2 = 0xff; - read = " 1 0 1 0 0 0 0 0", - " 0 0 x x x x x a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write = " 1 1 0 0 0 0 0 0", - " 0 0 x x x x x a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - mode = 0x04; - delay = 20; - blocksize = 128; - readsize = 256; - ; - memory "flash" - paged = yes; - size = 8192; - page_size = 64; - num_pages = 128; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0x00; - read_lo = " 0 0 1 0 0 0 0 0", - " 0 0 0 0 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " 0 0 0 0 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " 0 0 0 0 x x x x", - " x x x a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " 0 0 0 0 x x x x", - " x x x a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - " 0 0 0 0 a11 a10 a9 a8", - " a7 a6 a5 x x x x x", - " x x x x x x x x"; - - mode = 0x21; - delay = 10; - blocksize = 64; - readsize = 256; - ; - - memory "lfuse" - size = 1; - min_write_delay = 2000; - max_write_delay = 2000; - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - ; - - memory "hfuse" - size = 1; - min_write_delay = 2000; - max_write_delay = 2000; - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - ; - - memory "lock" - size = 1; - min_write_delay = 2000; - max_write_delay = 2000; - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x x x o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", - "x x x x x x x x 1 1 i i i i i i"; - ; - - memory "calibration" - size = 4; - read = "0 0 1 1 1 0 0 0 0 0 x x x x x x", - "0 0 0 0 0 0 a1 a0 o o o o o o o o"; - ; - - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 x x x x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - ; - - - -#------------------------------------------------------------ -# ATmega8515 -#------------------------------------------------------------ - -part - id = "m8515"; - desc = "ATMEGA8515"; - stk500_devcode = 0x63; - avr910_devcode = 0x3A; - signature = 0x1e 0x93 0x06; - chip_erase_delay = 9000; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 0; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 6; - togglevtg = 0; - poweroffdelay = 0; - resetdelayms = 0; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 10; - programfusepulsewidth = 0; - programfusepolltimeout = 5; - programlockpulsewidth = 0; - programlockpolltimeout = 5; - - memory "eeprom" - size = 512; - min_write_delay = 9000; - max_write_delay = 9000; - readback_p1 = 0xff; - readback_p2 = 0xff; - read = " 1 0 1 0 0 0 0 0", - " 0 0 x x x x x a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write = " 1 1 0 0 0 0 0 0", - " 0 0 x x x x x a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - mode = 0x04; - delay = 10; - blocksize = 128; - readsize = 256; - ; - memory "flash" - paged = yes; - size = 8192; - page_size = 64; - num_pages = 128; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - " 0 0 0 0 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " 0 0 0 0 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " 0 0 0 0 x x x x", - " x x x a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " 0 0 0 0 x x x x", - " x x x a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - " 0 0 0 0 a11 a10 a9 a8", - " a7 a6 a5 x x x x x", - " x x x x x x x x"; - - mode = 0x21; - delay = 6; - blocksize = 64; - readsize = 256; - ; - - memory "lfuse" - size = 1; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - ; - - memory "hfuse" - size = 1; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - ; - - memory "lock" - size = 1; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x x x o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", - "x x x x x x x x 1 1 i i i i i i"; - ; - - memory "calibration" - size = 4; - read = "0 0 1 1 1 0 0 0 0 0 x x x x x x", - "0 0 0 0 0 0 a1 a0 o o o o o o o o"; - ; - - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 x x x x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - ; - - - - -#------------------------------------------------------------ -# ATmega8535 -#------------------------------------------------------------ - -part - id = "m8535"; - desc = "ATMEGA8535"; - stk500_devcode = 0x64; - avr910_devcode = 0x69; - signature = 0x1e 0x93 0x08; - pagel = 0xd7; - bs2 = 0xa0; - chip_erase_delay = 9000; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 0; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 6; - togglevtg = 0; - poweroffdelay = 0; - resetdelayms = 0; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 10; - programfusepulsewidth = 0; - programfusepolltimeout = 5; - programlockpulsewidth = 0; - programlockpolltimeout = 5; - - memory "eeprom" - size = 512; - min_write_delay = 9000; - max_write_delay = 9000; - readback_p1 = 0xff; - readback_p2 = 0xff; - read = " 1 0 1 0 0 0 0 0", - " 0 0 x x x x x a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write = " 1 1 0 0 0 0 0 0", - " 0 0 x x x x x a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - mode = 0x04; - delay = 10; - blocksize = 128; - readsize = 256; - ; - memory "flash" - paged = yes; - size = 8192; - page_size = 64; - num_pages = 128; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - " 0 0 0 0 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " 0 0 0 0 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " 0 0 0 0 x x x x", - " x x x a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " 0 0 0 0 x x x x", - " x x x a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - " 0 0 0 0 a11 a10 a9 a8", - " a7 a6 a5 x x x x x", - " x x x x x x x x"; - - mode = 0x21; - delay = 6; - blocksize = 64; - readsize = 256; - ; - - memory "lfuse" - size = 1; - min_write_delay = 2000; - max_write_delay = 2000; - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - ; - - memory "hfuse" - size = 1; - min_write_delay = 2000; - max_write_delay = 2000; - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - ; - - memory "lock" - size = 1; - min_write_delay = 2000; - max_write_delay = 2000; - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x x x o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", - "x x x x x x x x 1 1 i i i i i i"; - ; - - memory "calibration" - size = 4; - read = "0 0 1 1 1 0 0 0 0 0 x x x x x x", - "0 0 0 0 0 0 a1 a0 o o o o o o o o"; - ; - - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 x x x x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - ; - - -#------------------------------------------------------------ -# ATtiny26 -#------------------------------------------------------------ - -part - id = "t26"; - desc = "ATTINY26"; - stk500_devcode = 0x21; - avr910_devcode = 0x5e; - signature = 0x1e 0x91 0x09; - pagel = 0xb3; - bs2 = 0xb2; - chip_erase_delay = 9000; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 0; - - pp_controlstack = - 0xC4, 0xE4, 0xC4, 0xE4, 0xCC, 0xEC, 0xCC, 0xEC, - 0xD4, 0xF4, 0xD4, 0xF4, 0xDC, 0xFC, 0xDC, 0xFC, - 0xC8, 0xE8, 0xD8, 0xF8, 0x4C, 0x6C, 0x5C, 0x7C, - 0xEC, 0xBC, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 2; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 10; - programfusepulsewidth = 0; - programfusepolltimeout = 5; - programlockpulsewidth = 0; - programlockpolltimeout = 5; - - memory "eeprom" - size = 128; - min_write_delay = 9000; - max_write_delay = 9000; - readback_p1 = 0xff; - readback_p2 = 0xff; - read = "1 0 1 0 0 0 0 0 x x x x x x x x", - "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; - - write = "1 1 0 0 0 0 0 0 x x x x x x x x", - "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; - - mode = 0x04; - delay = 10; - blocksize = 64; - readsize = 256; - ; - - memory "flash" - paged = yes; - size = 2048; - page_size = 32; - num_pages = 64; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - " x x x x x x a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " x x x x x x a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " x x x x x x x x", - " x x x x a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " x x x x x x x x", - " x x x x a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - " x x x x x x a9 a8", - " a7 a6 a5 a4 x x x x", - " x x x x x x x x"; - - mode = 0x21; - delay = 6; - blocksize = 16; - readsize = 256; - ; - - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 x x x x x x x x", - "0 0 0 0 0 0 a1 a0 o o o o o o o o"; - ; - - memory "lock" - size = 1; - read = "0 1 0 1 1 0 0 0 x x x x x x x x", - "x x x x x x x x x x x x x x o o"; - - write = "1 0 1 0 1 1 0 0 1 1 1 1 1 1 i i", - "x x x x x x x x x x x x x x x x"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "lfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "hfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x x x x i i i i i"; - - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x x x x o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "calibration" - size = 4; - read = "0 0 1 1 1 0 0 0 x x x x x x x x", - "0 0 0 0 0 0 a1 a0 o o o o o o o o"; - ; - -; - - -#------------------------------------------------------------ -# ATtiny261 -#------------------------------------------------------------ -# Close to ATtiny26 - -part - id = "t261"; - desc = "ATTINY261"; - has_debugwire = yes; - flash_instr = 0xB4, 0x00, 0x10; - eeprom_instr = 0xBB, 0xFF, 0xBB, 0xEE, 0xBB, 0xCC, 0xB2, 0x0D, - 0xBC, 0x00, 0xB4, 0x00, 0xBA, 0x0D, 0xBB, 0xBC, - 0x99, 0xE1, 0xBB, 0xAC; -# stk500_devcode = 0x21; -# avr910_devcode = 0x5e; - signature = 0x1e 0x91 0x0c; - pagel = 0xb3; - bs2 = 0xb2; - chip_erase_delay = 4000; - - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 0; - - pp_controlstack = - 0xC4, 0xE4, 0xC4, 0xE4, 0xCC, 0xEC, 0xCC, 0xEC, - 0xD4, 0xF4, 0xD4, 0xF4, 0xDC, 0xFC, 0xDC, 0xFC, - 0xC8, 0xE8, 0xD8, 0xF8, 0x4C, 0x6C, 0x5C, 0x7C, - 0xEC, 0xBC, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 2; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 10; - programfusepulsewidth = 0; - programfusepolltimeout = 5; - programlockpulsewidth = 0; - programlockpolltimeout = 5; - - memory "eeprom" - paged = no; - size = 128; - page_size = 4; - num_pages = 32; - min_write_delay = 4000; - max_write_delay = 4000; - readback_p1 = 0xff; - readback_p2 = 0xff; - - read = "1 0 1 0 0 0 0 0 x x x x x x x x", - "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; - - write = "1 1 0 0 0 0 0 0 x x x x x x x x", - "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 0 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 x x x x x x", - " x a6 a5 a4 a3 a2 0 0", - " x x x x x x x x"; - - mode = 0x41; - delay = 10; - blocksize = 4; - readsize = 256; - ; - - memory "flash" - paged = yes; - size = 2048; - page_size = 32; - num_pages = 64; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - - read_lo = " 0 0 1 0 0 0 0 0", - " x x x x x x a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " x x x x x x a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " x x x x x x x x", - " x x x x a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " x x x x x x x x", - " x x x x a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - " x x x x x x a9 a8", - " a7 a6 a5 a4 x x x x", - " x x x x x x x x"; - - mode = 0x41; - delay = 6; - blocksize = 32; - readsize = 256; - ; - - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 x x x x x x x x", - "0 0 0 0 0 0 a1 a0 o o o o o o o o"; - ; - - memory "lock" - size = 1; - read = "0 1 0 1 1 0 0 0 x x x x x x x x", - "x x x x x x x x x x x x x x o o"; - - write = "1 0 1 0 1 1 0 0 1 1 1 1 1 1 i i", - "x x x x x x x x x x x x x x x x"; - min_write_delay = 4500; - max_write_delay = 4500; - ; - - memory "lfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 4500; - max_write_delay = 4500; - ; - - memory "hfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 4500; - max_write_delay = 4500; - ; - - memory "efuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", - "x x x x x x x x x x x x x x x i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x x x x x x x x o"; - min_write_delay = 4500; - max_write_delay = 4500; - ; - - memory "calibration" - size = 1; - read = "0 0 1 1 1 0 0 0 x x x x x x x x", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - ; - -; - - -#------------------------------------------------------------ -# ATtiny461 -#------------------------------------------------------------ -# Close to ATtiny261 - -part - id = "t461"; - desc = "ATTINY461"; - has_debugwire = yes; - flash_instr = 0xB4, 0x00, 0x10; - eeprom_instr = 0xBB, 0xFF, 0xBB, 0xEE, 0xBB, 0xCC, 0xB2, 0x0D, - 0xBC, 0x00, 0xB4, 0x00, 0xBA, 0x0D, 0xBB, 0xBC, - 0x99, 0xE1, 0xBB, 0xAC; -# stk500_devcode = 0x21; -# avr910_devcode = 0x5e; - signature = 0x1e 0x92 0x08; - pagel = 0xb3; - bs2 = 0xb2; - chip_erase_delay = 4000; - - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 0; - - pp_controlstack = - 0xC4, 0xE4, 0xC4, 0xE4, 0xCC, 0xEC, 0xCC, 0xEC, - 0xD4, 0xF4, 0xD4, 0xF4, 0xDC, 0xFC, 0xDC, 0xFC, - 0xC8, 0xE8, 0xD8, 0xF8, 0x4C, 0x6C, 0x5C, 0x7C, - 0xEC, 0xBC, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 2; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 10; - programfusepulsewidth = 0; - programfusepolltimeout = 5; - programlockpulsewidth = 0; - programlockpolltimeout = 5; - - memory "eeprom" - paged = no; - size = 256; - page_size = 4; - num_pages = 64; - min_write_delay = 4000; - max_write_delay = 4000; - readback_p1 = 0xff; - readback_p2 = 0xff; - - read = " 1 0 1 0 0 0 0 0 x x x x x x x x", - "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; - - write = " 1 1 0 0 0 0 0 0 x x x x x x x x", - "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 0 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 x x x x x x", - " a7 a6 a5 a4 a3 a2 0 0", - " x x x x x x x x"; - - mode = 0x41; - delay = 10; - blocksize = 4; - readsize = 256; - ; - - memory "flash" - paged = yes; - size = 4096; - page_size = 64; - num_pages = 64; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - - read_lo = " 0 0 1 0 0 0 0 0", - " x x x x x a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " x x x x x a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " x x x x x x x x", - " x x x a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " x x x x x x x x", - " x x x a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - " x x x x x a10 a9 a8", - " a7 a6 a5 x x x x x", - " x x x x x x x x"; - - mode = 0x41; - delay = 6; - blocksize = 64; - readsize = 256; - ; - - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 x x x x x x x x", - "0 0 0 0 0 0 a1 a0 o o o o o o o o"; - ; - - memory "lock" - size = 1; - read = "0 1 0 1 1 0 0 0 x x x x x x x x", - "x x x x x x x x x x x x x x o o"; - - write = "1 0 1 0 1 1 0 0 1 1 1 1 1 1 i i", - "x x x x x x x x x x x x x x x x"; - min_write_delay = 4500; - max_write_delay = 4500; - ; - - memory "lfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 4500; - max_write_delay = 4500; - ; - - memory "hfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 4500; - max_write_delay = 4500; - ; - - memory "efuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", - "x x x x x x x x x x x x x x x i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x x x x x x x x o"; - min_write_delay = 4500; - max_write_delay = 4500; - ; - - memory "calibration" - size = 1; - read = "0 0 1 1 1 0 0 0 x x x x x x x x", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - ; - -; - - -#------------------------------------------------------------ -# ATtiny861 -#------------------------------------------------------------ -# Close to ATtiny461 - -part - id = "t861"; - desc = "ATTINY861"; - has_debugwire = yes; - flash_instr = 0xB4, 0x00, 0x10; - eeprom_instr = 0xBB, 0xFF, 0xBB, 0xEE, 0xBB, 0xCC, 0xB2, 0x0D, - 0xBC, 0x00, 0xB4, 0x00, 0xBA, 0x0D, 0xBB, 0xBC, - 0x99, 0xE1, 0xBB, 0xAC; -# stk500_devcode = 0x21; -# avr910_devcode = 0x5e; - signature = 0x1e 0x93 0x0d; - pagel = 0xb3; - bs2 = 0xb2; - chip_erase_delay = 4000; - - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 0; - - pp_controlstack = - 0xC4, 0xE4, 0xC4, 0xE4, 0xCC, 0xEC, 0xCC, 0xEC, - 0xD4, 0xF4, 0xD4, 0xF4, 0xDC, 0xFC, 0xDC, 0xFC, - 0xC8, 0xE8, 0xD8, 0xF8, 0x4C, 0x6C, 0x5C, 0x7C, - 0xEC, 0xBC, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 2; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 10; - programfusepulsewidth = 0; - programfusepolltimeout = 5; - programlockpulsewidth = 0; - programlockpolltimeout = 5; - - memory "eeprom" - paged = no; - size = 512; - num_pages = 128; - page_size = 4; - min_write_delay = 4000; - max_write_delay = 4000; - readback_p1 = 0xff; - readback_p2 = 0xff; - - read = " 1 0 1 0 0 0 0 0 x x x x x x x a8", - "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; - - write = " 1 1 0 0 0 0 0 0 x x x x x x x a8", - "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 0 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 x x x x x a8", - " a7 a6 a5 a4 a3 a2 0 0", - " x x x x x x x x"; - - mode = 0x41; - delay = 10; - blocksize = 4; - readsize = 256; - ; - - memory "flash" - paged = yes; - size = 8192; - page_size = 64; - num_pages = 128; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - - read_lo = " 0 0 1 0 0 0 0 0", - " x x x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " x x x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " x x x x x x x x", - " x x x a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " x x x x x x x x", - " x x x a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - " x x x x a11 a10 a9 a8", - " a7 a6 a5 x x x x x", - " x x x x x x x x"; - - mode = 0x41; - delay = 6; - blocksize = 64; - readsize = 256; - ; - - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 x x x x x x x x", - "0 0 0 0 0 0 a1 a0 o o o o o o o o"; - ; - - memory "lock" - size = 1; - read = "0 1 0 1 1 0 0 0 x x x x x x x x", - "x x x x x x x x x x x x x x o o"; - - write = "1 0 1 0 1 1 0 0 1 1 1 1 1 1 i i", - "x x x x x x x x x x x x x x x x"; - min_write_delay = 4500; - max_write_delay = 4500; - ; - - memory "lfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 4500; - max_write_delay = 4500; - ; - - memory "hfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 4500; - max_write_delay = 4500; - ; - - memory "efuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", - "x x x x x x x x x x x x x x x i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x x x x x x x x o"; - min_write_delay = 4500; - max_write_delay = 4500; - ; - - memory "calibration" - size = 1; - read = "0 0 1 1 1 0 0 0 x x x x x x x x", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - ; - -; - - -#------------------------------------------------------------ -# ATmega48 -#------------------------------------------------------------ - -part - id = "m48"; - desc = "ATMEGA48"; - has_debugwire = yes; - flash_instr = 0xB6, 0x01, 0x11; - eeprom_instr = 0xBD, 0xF2, 0xBD, 0xE1, 0xBB, 0xCF, 0xB4, 0x00, - 0xBE, 0x01, 0xB6, 0x01, 0xBC, 0x00, 0xBB, 0xBF, - 0x99, 0xF9, 0xBB, 0xAF; - stk500_devcode = 0x59; -# avr910_devcode = 0x; - signature = 0x1e 0x92 0x05; - pagel = 0xd7; - bs2 = 0xc2; - chip_erase_delay = 45000; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - resetdelayus = 0; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 10; - programfusepulsewidth = 0; - programfusepolltimeout = 5; - programlockpulsewidth = 0; - programlockpolltimeout = 5; - - memory "eeprom" - paged = no; - page_size = 4; - size = 256; - min_write_delay = 3600; - max_write_delay = 3600; - readback_p1 = 0xff; - readback_p2 = 0xff; - read = " 1 0 1 0 0 0 0 0", - " 0 0 0 x x x x x", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write = " 1 1 0 0 0 0 0 0", - " 0 0 0 x x x x x", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 0 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 x x x x x x", - " a7 a6 a5 a4 a3 a2 0 0", - " x x x x x x x x"; - - mode = 0x41; - delay = 5; - blocksize = 4; - readsize = 256; - ; - memory "flash" - paged = yes; - size = 4096; - page_size = 64; - num_pages = 64; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0x00; - readback_p2 = 0x00; - read_lo = " 0 0 1 0 0 0 0 0", - " 0 0 0 0 0 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " 0 0 0 0 0 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " 0 0 0 x x x x x", - " x x x a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " 0 0 0 x x x x x", - " x x x a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - " 0 0 0 0 0 a10 a9 a8", - " a7 a6 a5 x x x x x", - " x x x x x x x x"; - - mode = 0x41; - delay = 6; - blocksize = 64; - readsize = 256; - ; - - memory "lfuse" - size = 1; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - ; - - memory "hfuse" - size = 1; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - ; - - memory "efuse" - size = 1; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x x x x x x x x o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", - "x x x x x x x x x x x x x x x i"; - ; - - memory "lock" - size = 1; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x x x o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", - "x x x x x x x x 1 1 i i i i i i"; - ; - - memory "calibration" - size = 1; - read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - ; - - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - ; - - -#------------------------------------------------------------ -# ATmega88 -#------------------------------------------------------------ - -part - id = "m88"; - desc = "ATMEGA88"; - has_debugwire = yes; - flash_instr = 0xB6, 0x01, 0x11; - eeprom_instr = 0xBD, 0xF2, 0xBD, 0xE1, 0xBB, 0xCF, 0xB4, 0x00, - 0xBE, 0x01, 0xB6, 0x01, 0xBC, 0x00, 0xBB, 0xBF, - 0x99, 0xF9, 0xBB, 0xAF; - stk500_devcode = 0x73; -# avr910_devcode = 0x; - signature = 0x1e 0x93 0x0a; - pagel = 0xd7; - bs2 = 0xc2; - chip_erase_delay = 9000; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - resetdelayus = 0; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 10; - programfusepulsewidth = 0; - programfusepolltimeout = 5; - programlockpulsewidth = 0; - programlockpolltimeout = 5; - - memory "eeprom" - paged = no; - page_size = 4; - size = 512; - min_write_delay = 3600; - max_write_delay = 3600; - readback_p1 = 0xff; - readback_p2 = 0xff; - read = " 1 0 1 0 0 0 0 0", - " 0 0 0 x x x x a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write = " 1 1 0 0 0 0 0 0", - " 0 0 0 x x x x a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 0 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 x x x x x a8", - " a7 a6 a5 a4 a3 a2 0 0", - " x x x x x x x x"; - - mode = 0x41; - delay = 5; - blocksize = 4; - readsize = 256; - ; - memory "flash" - paged = yes; - size = 8192; - page_size = 64; - num_pages = 128; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - " 0 0 0 0 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " 0 0 0 0 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " 0 0 0 x x x x x", - " x x x a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " 0 0 0 x x x x x", - " x x x a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - " 0 0 0 0 a11 a10 a9 a8", - " a7 a6 a5 x x x x x", - " x x x x x x x x"; - - mode = 0x41; - delay = 6; - blocksize = 64; - readsize = 256; - ; - - memory "lfuse" - size = 1; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - ; - - memory "hfuse" - size = 1; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - ; - - memory "efuse" - size = 1; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x x x x x x o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", - "x x x x x x x x x x x x x i i i"; - ; - - memory "lock" - size = 1; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x x x o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", - "x x x x x x x x 1 1 i i i i i i"; - ; - - memory "calibration" - size = 1; - read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - ; - - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - ; - -#------------------------------------------------------------ -# ATmega168 -#------------------------------------------------------------ - -part - id = "m168"; - desc = "ATMEGA168"; - has_debugwire = yes; - flash_instr = 0xB6, 0x01, 0x11; - eeprom_instr = 0xBD, 0xF2, 0xBD, 0xE1, 0xBB, 0xCF, 0xB4, 0x00, - 0xBE, 0x01, 0xB6, 0x01, 0xBC, 0x00, 0xBB, 0xBF, - 0x99, 0xF9, 0xBB, 0xAF; - stk500_devcode = 0x86; - # avr910_devcode = 0x; - signature = 0x1e 0x94 0x06; - pagel = 0xd7; - bs2 = 0xc2; - chip_erase_delay = 9000; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - resetdelayus = 0; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 10; - programfusepulsewidth = 0; - programfusepolltimeout = 5; - programlockpulsewidth = 0; - programlockpolltimeout = 5; - - memory "eeprom" - paged = no; - page_size = 4; - size = 512; - min_write_delay = 3600; - max_write_delay = 3600; - readback_p1 = 0xff; - readback_p2 = 0xff; - read = " 1 0 1 0 0 0 0 0", - " 0 0 0 x x x x a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write = " 1 1 0 0 0 0 0 0", - " 0 0 0 x x x x a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 0 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 x x x x x a8", - " a7 a6 a5 a4 a3 a2 0 0", - " x x x x x x x x"; - - mode = 0x41; - delay = 5; - blocksize = 4; - readsize = 256; - ; - - memory "flash" - paged = yes; - size = 16384; - page_size = 128; - num_pages = 128; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - " 0 0 0 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " 0 0 0 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " 0 0 0 x x x x x", - " x x a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " 0 0 0 x x x x x", - " x x a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - " 0 0 0 a12 a11 a10 a9 a8", - " a7 a6 x x x x x x", - " x x x x x x x x"; - - mode = 0x41; - delay = 6; - blocksize = 128; - readsize = 256; - - ; - - memory "lfuse" - size = 1; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - ; - - memory "hfuse" - size = 1; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - ; - - memory "efuse" - size = 1; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x x x x x x o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", - "x x x x x x x x x x x x x i i i"; - ; - - memory "lock" - size = 1; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x x x o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", - "x x x x x x x x 1 1 i i i i i i"; - ; - - memory "calibration" - size = 1; - read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - ; - - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; -; - -#------------------------------------------------------------ -# ATmega328 -#------------------------------------------------------------ - -part - id = "m328p"; - desc = "ATMEGA328P"; - has_debugwire = yes; - flash_instr = 0xB6, 0x01, 0x11; - eeprom_instr = 0xBD, 0xF2, 0xBD, 0xE1, 0xBB, 0xCF, 0xB4, 0x00, - 0xBE, 0x01, 0xB6, 0x01, 0xBC, 0x00, 0xBB, 0xBF, - 0x99, 0xF9, 0xBB, 0xAF; - stk500_devcode = 0x86; - # avr910_devcode = 0x; - signature = 0x1e 0x95 0x0F; - pagel = 0xd7; - bs2 = 0xc2; - chip_erase_delay = 9000; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - resetdelayus = 0; - hvleavestabdelay = 15; - resetdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 10; - programfusepulsewidth = 0; - programfusepolltimeout = 5; - programlockpulsewidth = 0; - programlockpolltimeout = 5; - - memory "eeprom" - paged = no; - page_size = 4; - size = 1024; - min_write_delay = 3600; - max_write_delay = 3600; - readback_p1 = 0xff; - readback_p2 = 0xff; - read = " 1 0 1 0 0 0 0 0", - " 0 0 0 x x x a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write = " 1 1 0 0 0 0 0 0", - " 0 0 0 x x x a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 0 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 x x x x a9 a8", - " a7 a6 a5 a4 a3 a2 0 0", - " x x x x x x x x"; - - mode = 0x41; - delay = 5; - blocksize = 4; - readsize = 256; - ; - - memory "flash" - paged = yes; - size = 32768; - page_size = 128; - num_pages = 256; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - " 0 0 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " 0 0 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " 0 0 0 x x x x x", - " x x a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " 0 0 0 x x x x x", - " x x a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - " 0 0 a13 a12 a11 a10 a9 a8", - " a7 a6 x x x x x x", - " x x x x x x x x"; - - mode = 0x41; - delay = 6; - blocksize = 128; - readsize = 256; - - ; - - memory "lfuse" - size = 1; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - ; - - memory "hfuse" - size = 1; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - ; - - memory "efuse" - size = 1; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x x x x x x o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", - "x x x x x x x x x x x x x i i i"; - ; - - memory "lock" - size = 1; - min_write_delay = 4500; - max_write_delay = 4500; - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x x x o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", - "x x x x x x x x 1 1 i i i i i i"; - ; - - memory "calibration" - size = 1; - read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - ; - - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; -; - #------------------------------------------------------------ -# ATtiny2313 -#------------------------------------------------------------ - -part - id = "t2313"; - desc = "ATtiny2313"; - has_debugwire = yes; - flash_instr = 0xB2, 0x0F, 0x1F; - eeprom_instr = 0xBB, 0xFE, 0xBB, 0xEE, 0xBB, 0xCC, 0xB2, 0x0D, - 0xBA, 0x0F, 0xB2, 0x0F, 0xBA, 0x0D, 0xBB, 0xBC, - 0x99, 0xE1, 0xBB, 0xAC; - stk500_devcode = 0x23; -## Use the ATtiny26 devcode: - avr910_devcode = 0x5e; - signature = 0x1e 0x91 0x0a; - pagel = 0xD4; - bs2 = 0xD6; - reset = io; - chip_erase_delay = 9000; - - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - - pp_controlstack = - 0x0E, 0x1E, 0x0E, 0x1E, 0x2E, 0x3E, 0x2E, 0x3E, - 0x4E, 0x5E, 0x4E, 0x5E, 0x6E, 0x7E, 0x6E, 0x7E, - 0x26, 0x36, 0x66, 0x76, 0x2A, 0x3A, 0x6A, 0x7A, - 0x2E, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 10; - programfusepulsewidth = 0; - programfusepolltimeout = 5; - programlockpulsewidth = 0; - programlockpolltimeout = 5; - - memory "eeprom" - size = 128; - paged = no; - page_size = 4; - min_write_delay = 4000; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read = "1 0 1 0 0 0 0 0 0 0 0 x x x x x", - "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; - - write = "1 1 0 0 0 0 0 0 0 0 0 x x x x x", - "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 0 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 x x x x x x", - " x a6 a5 a4 a3 a2 0 0", - " x x x x x x x x"; - - mode = 0x41; - delay = 6; - blocksize = 4; - readsize = 256; - ; - memory "flash" - paged = yes; - size = 2048; - page_size = 32; - num_pages = 64; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - " 0 0 0 0 0 0 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " 0 0 0 0 0 0 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - -# The information in the data sheet of April/2004 is wrong, this works: - loadpage_lo = " 0 1 0 0 0 0 0 0", - " 0 0 0 x x x x x", - " x x x x a3 a2 a1 a0", - " i i i i i i i i"; - -# The information in the data sheet of April/2004 is wrong, this works: - loadpage_hi = " 0 1 0 0 1 0 0 0", - " 0 0 0 x x x x x", - " x x x x a3 a2 a1 a0", - " i i i i i i i i"; - -# The information in the data sheet of April/2004 is wrong, this works: - writepage = " 0 1 0 0 1 1 0 0", - " 0 0 0 0 0 0 a9 a8", - " a7 a6 a5 a4 x x x x", - " x x x x x x x x"; - - mode = 0x41; - delay = 6; - blocksize = 32; - readsize = 256; - ; -# ATtiny2313 has Signature Bytes: 0x1E 0x91 0x0A. - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - memory "lock" - size = 1; - write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", - "x x x x x x x x 1 1 i i i i i i"; - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x x x o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "lfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "hfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "efuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", - "x x x x x x x x x x x x x x x i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; -# The Tiny2313 has calibration data for both 4 MHz and 8 MHz. -# The information in the data sheet of April/2004 is wrong, this works: - - memory "calibration" - size = 2; - read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", - "0 0 0 0 0 0 0 a0 o o o o o o o o"; - ; - ; - -#------------------------------------------------------------ -# AT90PWM2 -#------------------------------------------------------------ - -part - id = "pwm2"; - desc = "AT90PWM2"; - has_debugwire = yes; - flash_instr = 0xB6, 0x01, 0x11; - eeprom_instr = 0xBD, 0xF2, 0xBD, 0xE1, 0xBB, 0xCF, 0xB4, 0x00, - 0xBE, 0x01, 0xB6, 0x01, 0xBC, 0x00, 0xBB, 0xBF, - 0x99, 0xF9, 0xBB, 0xAF; - stk500_devcode = 0x65; -## avr910_devcode = ?; - signature = 0x1e 0x93 0x81; - pagel = 0xD8; - bs2 = 0xE2; - reset = io; - chip_erase_delay = 9000; - - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 10; - programfusepulsewidth = 0; - programfusepolltimeout = 5; - programlockpulsewidth = 0; - programlockpolltimeout = 5; - - memory "eeprom" - size = 512; - paged = no; - page_size = 4; - min_write_delay = 4000; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read = "1 0 1 0 0 0 0 0 0 0 0 x x x x a8", - "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; - - write = "1 1 0 0 0 0 0 0 0 0 0 x x x x a8", - "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 0 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 x x x x x x", - " a7 a6 a5 a4 a3 a2 0 0", - " x x x x x x x x"; - - mode = 0x41; - delay = 6; - blocksize = 4; - readsize = 256; - ; - memory "flash" - paged = yes; - size = 8192; - page_size = 64; - num_pages = 128; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - " 0 0 0 0 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " 0 0 0 0 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " 0 0 0 x x x x x", - " x x x a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " 0 0 0 x x x x x", - " x x x a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - " 0 0 0 0 a11 a10 a9 a8", - " a7 a6 a5 x x x x x", - " x x x x x x x x"; - - mode = 0x41; - delay = 6; - blocksize = 64; - readsize = 256; - ; -# AT90PWM2 has Signature Bytes: 0x1E 0x93 0x81. - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 0 0 x x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - memory "lock" - size = 1; - write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", - "x x x x x x x x 1 1 i i i i i i"; - - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x x x o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "lfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "hfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "efuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", - "x x x x x x x x x x x x x x x i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "calibration" - size = 1; - read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - ; - ; - -#------------------------------------------------------------ -# AT90PWM3 -#------------------------------------------------------------ - -# Completely identical to AT90PWM2 (including the signature!) - -part - id = "pwm3"; - desc = "AT90PWM3"; - has_debugwire = yes; - flash_instr = 0xB6, 0x01, 0x11; - eeprom_instr = 0xBD, 0xF2, 0xBD, 0xE1, 0xBB, 0xCF, 0xB4, 0x00, - 0xBE, 0x01, 0xB6, 0x01, 0xBC, 0x00, 0xBB, 0xBF, - 0x99, 0xF9, 0xBB, 0xAF; - stk500_devcode = 0x65; -## avr910_devcode = ?; - signature = 0x1e 0x93 0x81; - pagel = 0xD8; - bs2 = 0xE2; - reset = io; - chip_erase_delay = 9000; - - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 10; - programfusepulsewidth = 0; - programfusepolltimeout = 5; - programlockpulsewidth = 0; - programlockpolltimeout = 5; - - memory "eeprom" - size = 512; - paged = no; - page_size = 4; - min_write_delay = 4000; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read = "1 0 1 0 0 0 0 0 0 0 0 x x x x a8", - "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; - - write = "1 1 0 0 0 0 0 0 0 0 0 x x x x a8", - "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 0 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 x x x x x x", - " a7 a6 a5 a4 a3 a2 0 0", - " x x x x x x x x"; - - mode = 0x41; - delay = 6; - blocksize = 4; - readsize = 256; - ; - memory "flash" - paged = yes; - size = 8192; - page_size = 64; - num_pages = 128; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - " 0 0 0 0 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " 0 0 0 0 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " 0 0 0 x x x x x", - " x x x a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " 0 0 0 x x x x x", - " x x x a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - " 0 0 0 0 a11 a10 a9 a8", - " a7 a6 a5 x x x x x", - " x x x x x x x x"; - - mode = 0x41; - delay = 6; - blocksize = 64; - readsize = 256; - ; -# AT90PWM2 has Signature Bytes: 0x1E 0x93 0x81. - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 0 0 x x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - memory "lock" - size = 1; - write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", - "x x x x x x x x 1 1 i i i i i i"; - - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x x x o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "lfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "hfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "efuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", - "x x x x x x x x x x x x x x x i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "calibration" - size = 1; - read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - ; - ; - -#------------------------------------------------------------ -# AT90PWM2B -#------------------------------------------------------------ -# Same as AT90PWM2 but different signature. - -part - id = "pwm2b"; - desc = "AT90PWM2B"; - has_debugwire = yes; - flash_instr = 0xB6, 0x01, 0x11; - eeprom_instr = 0xBD, 0xF2, 0xBD, 0xE1, 0xBB, 0xCF, 0xB4, 0x00, - 0xBE, 0x01, 0xB6, 0x01, 0xBC, 0x00, 0xBB, 0xBF, - 0x99, 0xF9, 0xBB, 0xAF; - stk500_devcode = 0x65; -## avr910_devcode = ?; - signature = 0x1e 0x93 0x83; - pagel = 0xD8; - bs2 = 0xE2; - reset = io; - chip_erase_delay = 9000; - - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 10; - programfusepulsewidth = 0; - programfusepolltimeout = 5; - programlockpulsewidth = 0; - programlockpolltimeout = 5; - - memory "eeprom" - size = 512; - paged = no; - page_size = 4; - min_write_delay = 4000; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read = "1 0 1 0 0 0 0 0 0 0 0 x x x x a8", - "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; - - write = "1 1 0 0 0 0 0 0 0 0 0 x x x x a8", - "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 0 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 x x x x x x", - " a7 a6 a5 a4 a3 a2 0 0", - " x x x x x x x x"; - - mode = 0x41; - delay = 6; - blocksize = 4; - readsize = 256; - ; - memory "flash" - paged = yes; - size = 8192; - page_size = 64; - num_pages = 128; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - " 0 0 0 0 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " 0 0 0 0 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " 0 0 0 x x x x x", - " x x x a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " 0 0 0 x x x x x", - " x x x a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - " 0 0 0 0 a11 a10 a9 a8", - " a7 a6 a5 x x x x x", - " x x x x x x x x"; - - mode = 0x41; - delay = 6; - blocksize = 64; - readsize = 256; - ; - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 0 0 x x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - memory "lock" - size = 1; - write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", - "x x x x x x x x 1 1 i i i i i i"; - - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x x x o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "lfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "hfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "efuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", - "x x x x x x x x x x x x x x x i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "calibration" - size = 1; - read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - ; - ; - -#------------------------------------------------------------ -# AT90PWM3B -#------------------------------------------------------------ - -# Completely identical to AT90PWM2B (including the signature!) - -part - id = "pwm3b"; - desc = "AT90PWM3B"; - has_debugwire = yes; - flash_instr = 0xB6, 0x01, 0x11; - eeprom_instr = 0xBD, 0xF2, 0xBD, 0xE1, 0xBB, 0xCF, 0xB4, 0x00, - 0xBE, 0x01, 0xB6, 0x01, 0xBC, 0x00, 0xBB, 0xBF, - 0x99, 0xF9, 0xBB, 0xAF; - stk500_devcode = 0x65; -## avr910_devcode = ?; - signature = 0x1e 0x93 0x83; - pagel = 0xD8; - bs2 = 0xE2; - reset = io; - chip_erase_delay = 9000; - - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 10; - programfusepulsewidth = 0; - programfusepolltimeout = 5; - programlockpulsewidth = 0; - programlockpolltimeout = 5; - - memory "eeprom" - size = 512; - paged = no; - page_size = 4; - min_write_delay = 4000; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read = "1 0 1 0 0 0 0 0 0 0 0 x x x x a8", - "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; - - write = "1 1 0 0 0 0 0 0 0 0 0 x x x x a8", - "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 0 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 x x x x x x", - " a7 a6 a5 a4 a3 a2 0 0", - " x x x x x x x x"; - - mode = 0x41; - delay = 6; - blocksize = 4; - readsize = 256; - ; - memory "flash" - paged = yes; - size = 8192; - page_size = 64; - num_pages = 128; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - " 0 0 0 0 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " 0 0 0 0 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " 0 0 0 x x x x x", - " x x x a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " 0 0 0 x x x x x", - " x x x a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - " 0 0 0 0 a11 a10 a9 a8", - " a7 a6 a5 x x x x x", - " x x x x x x x x"; - - mode = 0x41; - delay = 6; - blocksize = 64; - readsize = 256; - ; - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 0 0 x x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - memory "lock" - size = 1; - write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", - "x x x x x x x x 1 1 i i i i i i"; - - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x x x o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "lfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "hfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "efuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", - "x x x x x x x x x x x x x x x i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "calibration" - size = 1; - read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - ; - ; - -#------------------------------------------------------------ -# ATtiny25 -#------------------------------------------------------------ - -part - id = "t25"; - desc = "ATtiny25"; - has_debugwire = yes; - flash_instr = 0xB4, 0x02, 0x12; - eeprom_instr = 0xBB, 0xFF, 0xBB, 0xEE, 0xBB, 0xCC, 0xB2, 0x0D, - 0xBC, 0x02, 0xB4, 0x02, 0xBA, 0x0D, 0xBB, 0xBC, - 0x99, 0xE1, 0xBB, 0xAC; -## no STK500 devcode in XML file, use the ATtiny45 one - stk500_devcode = 0x14; -## avr910_devcode = ?; -## Try the AT90S2313 devcode: - avr910_devcode = 0x20; - signature = 0x1e 0x91 0x08; - reset = io; - chip_erase_delay = 4500; - - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - - hvsp_controlstack = - 0x4C, 0x0C, 0x1C, 0x2C, 0x3C, 0x64, 0x74, 0x66, - 0x68, 0x78, 0x68, 0x68, 0x7A, 0x6A, 0x68, 0x78, - 0x78, 0x7D, 0x6D, 0x0C, 0x80, 0x40, 0x20, 0x10, - 0x11, 0x08, 0x04, 0x02, 0x03, 0x08, 0x04, 0x00; - hventerstabdelay = 100; - hvspcmdexedelay = 0; - synchcycles = 6; - latchcycles = 1; - togglevtg = 1; - poweroffdelay = 25; - resetdelayms = 1; - resetdelayus = 0; - hvleavestabdelay = 100; - resetdelay = 25; - chiperasepolltimeout = 40; - chiperasetime = 0; - programfusepolltimeout = 25; - programlockpolltimeout = 25; - - memory "eeprom" - size = 128; - paged = no; - page_size = 4; - min_write_delay = 4000; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read = "1 0 1 0 0 0 0 0 0 0 0 x x x x x", - "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; - - write = "1 1 0 0 0 0 0 0 0 0 0 x x x x x", - "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 0 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 x x x x x x", - " x a6 a5 a4 a3 a2 0 0", - " x x x x x x x x"; - - mode = 0x41; - delay = 6; - blocksize = 4; - readsize = 256; - ; - memory "flash" - paged = yes; - size = 2048; - page_size = 32; - num_pages = 64; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - " 0 0 0 0 0 0 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " 0 0 0 0 0 0 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " 0 0 0 x x x x x", - " x x x x a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " 0 0 0 x x x x x", - " x x x x a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - " 0 0 0 0 0 0 a9 a8", - " a7 a6 a5 a4 x x x x", - " x x x x x x x x"; - - mode = 0x41; - delay = 6; - blocksize = 32; - readsize = 256; - ; -# ATtiny25 has Signature Bytes: 0x1E 0x91 0x08. - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - memory "lock" - size = 1; - write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", - "x x x x x x x x 1 1 i i i i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "lfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "hfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "efuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", - "x x x x x x x x x x x x x x x i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "calibration" - size = 2; - read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", - "0 0 0 0 0 0 0 a0 o o o o o o o o"; - ; - ; - -#------------------------------------------------------------ -# ATtiny45 -#------------------------------------------------------------ - -part - id = "t45"; - desc = "ATtiny45"; - has_debugwire = yes; - flash_instr = 0xB4, 0x02, 0x12; - eeprom_instr = 0xBB, 0xFF, 0xBB, 0xEE, 0xBB, 0xCC, 0xB2, 0x0D, - 0xBC, 0x02, 0xB4, 0x02, 0xBA, 0x0D, 0xBB, 0xBC, - 0x99, 0xE1, 0xBB, 0xAC; - stk500_devcode = 0x14; -## avr910_devcode = ?; -## Try the AT90S2313 devcode: - avr910_devcode = 0x20; - signature = 0x1e 0x92 0x06; - reset = io; - chip_erase_delay = 4500; - - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - - hvsp_controlstack = - 0x4C, 0x0C, 0x1C, 0x2C, 0x3C, 0x64, 0x74, 0x66, - 0x68, 0x78, 0x68, 0x68, 0x7A, 0x6A, 0x68, 0x78, - 0x78, 0x7D, 0x6D, 0x0C, 0x80, 0x40, 0x20, 0x10, - 0x11, 0x08, 0x04, 0x02, 0x03, 0x08, 0x04, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - hvspcmdexedelay = 0; - synchcycles = 6; - latchcycles = 1; - togglevtg = 1; - poweroffdelay = 25; - resetdelayms = 1; - resetdelayus = 0; - hvleavestabdelay = 100; - resetdelay = 25; - chiperasepolltimeout = 40; - chiperasetime = 0; - programfusepolltimeout = 25; - programlockpolltimeout = 25; - - memory "eeprom" - size = 256; - page_size = 4; - min_write_delay = 4000; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read = "1 0 1 0 0 0 0 0 0 0 0 x x x x x", - "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; - - write = "1 1 0 0 0 0 0 0 0 0 0 x x x x x", - "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 0 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 x x x x x x", - " a7 a6 a5 a4 a3 a2 0 0", - " x x x x x x x x"; - - mode = 0x41; - delay = 6; - blocksize = 4; - readsize = 256; - ; - memory "flash" - paged = yes; - size = 4096; - page_size = 64; - num_pages = 64; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - " 0 0 0 0 0 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " 0 0 0 0 0 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " 0 0 0 x x x x x", - " x x x a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " 0 0 0 x x x x x", - " x x x a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - " 0 0 0 0 0 a10 a9 a8", - " a7 a6 a5 x x x x x", - " x x x x x x x x"; - - mode = 0x41; - delay = 6; - blocksize = 32; - readsize = 256; - ; -# ATtiny45 has Signature Bytes: 0x1E 0x92 0x08. (Data sheet 2586C-AVR-06/05 (doc2586.pdf) indicates otherwise!) - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - memory "lock" - size = 1; - write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", - "x x x x x x x x 1 1 i i i i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "lfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "hfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "efuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", - "x x x x x x x x x x x x x x x i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "calibration" - size = 2; - read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", - "0 0 0 0 0 0 0 a0 o o o o o o o o"; - ; - ; - -#------------------------------------------------------------ -# ATtiny85 -#------------------------------------------------------------ - -part - id = "t85"; - desc = "ATtiny85"; - has_debugwire = yes; - flash_instr = 0xB4, 0x02, 0x12; - eeprom_instr = 0xBB, 0xFF, 0xBB, 0xEE, 0xBB, 0xCC, 0xB2, 0x0D, - 0xBC, 0x02, 0xB4, 0x02, 0xBA, 0x0D, 0xBB, 0xBC, - 0x99, 0xE1, 0xBB, 0xAC; -## no STK500 devcode in XML file, use the ATtiny45 one - stk500_devcode = 0x14; -## avr910_devcode = ?; -## Try the AT90S2313 devcode: - avr910_devcode = 0x20; - signature = 0x1e 0x93 0x0b; - reset = io; - chip_erase_delay = 4500; - - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - - hvsp_controlstack = - 0x4C, 0x0C, 0x1C, 0x2C, 0x3C, 0x64, 0x74, 0x66, - 0x68, 0x78, 0x68, 0x68, 0x7A, 0x6A, 0x68, 0x78, - 0x78, 0x7D, 0x6D, 0x0C, 0x80, 0x40, 0x20, 0x10, - 0x11, 0x08, 0x04, 0x02, 0x03, 0x08, 0x04, 0x00; - hventerstabdelay = 100; - hvspcmdexedelay = 0; - synchcycles = 6; - latchcycles = 1; - togglevtg = 1; - poweroffdelay = 25; - resetdelayms = 1; - resetdelayus = 0; - hvleavestabdelay = 100; - resetdelay = 25; - chiperasepolltimeout = 40; - chiperasetime = 0; - programfusepolltimeout = 25; - programlockpolltimeout = 25; - - memory "eeprom" - size = 512; - paged = no; - page_size = 4; - min_write_delay = 4000; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read = "1 0 1 0 0 0 0 0 0 0 0 x x x x a8", - "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; - - write = "1 1 0 0 0 0 0 0 0 0 0 x x x x a8", - "a8 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 0 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 x x x x x a8", - " a7 a6 a5 a4 a3 a2 0 0", - " x x x x x x x x"; - - mode = 0x41; - delay = 6; - blocksize = 4; - readsize = 256; - ; - memory "flash" - paged = yes; - size = 8192; - page_size = 64; - num_pages = 128; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - " 0 0 0 0 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " 0 0 0 0 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " 0 0 0 x x x x x", - " x x x a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " 0 0 0 x x x x x", - " x x x a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - " 0 0 0 0 a11 a10 a9 a8", - " a7 a6 a5 x x x x x", - " x x x x x x x x"; - - mode = 0x41; - delay = 6; - blocksize = 32; - readsize = 256; - ; -# ATtiny85 has Signature Bytes: 0x1E 0x93 0x08. - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - memory "lock" - size = 1; - write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", - "x x x x x x x x 1 1 i i i i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "lfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "hfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "efuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", - "x x x x x x x x x x x x x x x i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "calibration" - size = 2; - read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", - "0 0 0 0 0 0 0 a0 o o o o o o o o"; - ; - ; - -#------------------------------------------------------------ -# ATmega640 -#------------------------------------------------------------ -# Almost same as ATmega1280, except for different memory sizes - -part - id = "m640"; - desc = "ATMEGA640"; - signature = 0x1e 0x96 0x08; - has_jtag = yes; -# stk500_devcode = 0xB2; -# avr910_devcode = 0x43; - chip_erase_delay = 9000; - pagel = 0xD7; - bs2 = 0xA0; - reset = dedicated; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 10; - programfusepulsewidth = 0; - programfusepolltimeout = 5; - programlockpulsewidth = 0; - programlockpolltimeout = 5; - - idr = 0x31; - spmcr = 0x57; - rampz = 0x3b; - allowfullpagebitstream = no; - - memory "eeprom" - paged = no; /* leave this "no" */ - page_size = 8; /* for parallel programming */ - size = 4096; - min_write_delay = 9000; - max_write_delay = 9000; - readback_p1 = 0x00; - readback_p2 = 0x00; - read = " 1 0 1 0 0 0 0 0", - " x x x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write = " 1 1 0 0 0 0 0 0", - " x x x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 0 0 0", - " x x x x x x x x"; - - mode = 0x41; - delay = 10; - blocksize = 8; - readsize = 256; - ; - - memory "flash" - paged = yes; - size = 65536; - page_size = 256; - num_pages = 256; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0x00; - readback_p2 = 0x00; - read_lo = " 0 0 1 0 0 0 0 0", - " 0 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " 0 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " x x x x x x x x", - " x a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " x x x x x x x x", - " x a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - " 0 a14 a13 a12 a11 a10 a9 a8", - " a7 x x x x x x x", - " x x x x x x x x"; - - mode = 0x41; - delay = 10; - blocksize = 256; - readsize = 256; - ; - - memory "lfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "hfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "efuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", - "x x x x x x x x x x x x x i i i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "lock" - size = 1; - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x x x o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", - "x x x x x x x x 1 1 i i i i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "calibration" - size = 1; - read = "0 0 1 1 1 0 0 0 x x x x x x x x", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - ; - - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 x x x x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - ; - -#------------------------------------------------------------ -# ATmega1280 -#------------------------------------------------------------ - -part - id = "m1280"; - desc = "ATMEGA1280"; - signature = 0x1e 0x97 0x03; - has_jtag = yes; -# stk500_devcode = 0xB2; -# avr910_devcode = 0x43; - chip_erase_delay = 9000; - pagel = 0xD7; - bs2 = 0xA0; - reset = dedicated; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 10; - programfusepulsewidth = 0; - programfusepolltimeout = 5; - programlockpulsewidth = 0; - programlockpolltimeout = 5; - - idr = 0x31; - spmcr = 0x57; - rampz = 0x3b; - allowfullpagebitstream = no; - - memory "eeprom" - paged = no; /* leave this "no" */ - page_size = 8; /* for parallel programming */ - size = 4096; - min_write_delay = 9000; - max_write_delay = 9000; - readback_p1 = 0x00; - readback_p2 = 0x00; - read = " 1 0 1 0 0 0 0 0", - " x x x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write = " 1 1 0 0 0 0 0 0", - " x x x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 0 0 0", - " x x x x x x x x"; - - mode = 0x41; - delay = 10; - blocksize = 8; - readsize = 256; - ; - - memory "flash" - paged = yes; - size = 131072; - page_size = 256; - num_pages = 512; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0x00; - readback_p2 = 0x00; - read_lo = " 0 0 1 0 0 0 0 0", - "a15 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - "a15 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " x x x x x x x x", - " x a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " x x x x x x x x", - " x a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - "a15 a14 a13 a12 a11 a10 a9 a8", - " a7 x x x x x x x", - " x x x x x x x x"; - - mode = 0x41; - delay = 10; - blocksize = 256; - readsize = 256; - ; - - memory "lfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "hfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "efuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", - "x x x x x x x x x x x x x i i i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "lock" - size = 1; - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x x x o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", - "x x x x x x x x 1 1 i i i i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "calibration" - size = 1; - read = "0 0 1 1 1 0 0 0 x x x x x x x x", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - ; - - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 x x x x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - ; - -#------------------------------------------------------------ -# ATmega1281 -#------------------------------------------------------------ -# Identical to ATmega1280 - -part - id = "m1281"; - desc = "ATMEGA1281"; - signature = 0x1e 0x97 0x04; - has_jtag = yes; -# stk500_devcode = 0xB2; -# avr910_devcode = 0x43; - chip_erase_delay = 9000; - pagel = 0xD7; - bs2 = 0xA0; - reset = dedicated; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 10; - programfusepulsewidth = 0; - programfusepolltimeout = 5; - programlockpulsewidth = 0; - programlockpolltimeout = 5; - - idr = 0x31; - spmcr = 0x57; - rampz = 0x3b; - allowfullpagebitstream = no; - - memory "eeprom" - paged = no; /* leave this "no" */ - page_size = 8; /* for parallel programming */ - size = 4096; - min_write_delay = 9000; - max_write_delay = 9000; - readback_p1 = 0x00; - readback_p2 = 0x00; - read = " 1 0 1 0 0 0 0 0", - " x x x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write = " 1 1 0 0 0 0 0 0", - " x x x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 0 0 0", - " x x x x x x x x"; - - mode = 0x41; - delay = 10; - blocksize = 8; - readsize = 256; - ; - - memory "flash" - paged = yes; - size = 131072; - page_size = 256; - num_pages = 512; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0x00; - readback_p2 = 0x00; - read_lo = " 0 0 1 0 0 0 0 0", - "a15 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - "a15 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " x x x x x x x x", - " x a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " x x x x x x x x", - " x a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - "a15 a14 a13 a12 a11 a10 a9 a8", - " a7 x x x x x x x", - " x x x x x x x x"; - - mode = 0x41; - delay = 10; - blocksize = 256; - readsize = 256; - ; - - memory "lfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "hfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "efuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", - "x x x x x x x x x x x x x i i i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "lock" - size = 1; - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x x x o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", - "x x x x x x x x 1 1 i i i i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "calibration" - size = 1; - read = "0 0 1 1 1 0 0 0 x x x x x x x x", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - ; - - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 x x x x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - ; - -#------------------------------------------------------------ -# ATmega2560 -#------------------------------------------------------------ - -part - id = "m2560"; - desc = "ATMEGA2560"; - signature = 0x1e 0x98 0x01; - has_jtag = yes; -# stk500_devcode = 0xB2; -# avr910_devcode = 0x43; - chip_erase_delay = 9000; - pagel = 0xD7; - bs2 = 0xA0; - reset = dedicated; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 10; - programfusepulsewidth = 0; - programfusepolltimeout = 5; - programlockpulsewidth = 0; - programlockpolltimeout = 5; - - idr = 0x31; - spmcr = 0x57; - rampz = 0x3b; - allowfullpagebitstream = no; - - memory "eeprom" - paged = no; /* leave this "no" */ - page_size = 8; /* for parallel programming */ - size = 4096; - min_write_delay = 9000; - max_write_delay = 9000; - readback_p1 = 0x00; - readback_p2 = 0x00; - read = " 1 0 1 0 0 0 0 0", - " x x x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write = " 1 1 0 0 0 0 0 0", - " x x x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 0 0 0", - " x x x x x x x x"; - - mode = 0x41; - delay = 10; - blocksize = 8; - readsize = 256; - ; - - memory "flash" - paged = yes; - size = 262144; - page_size = 256; - num_pages = 1024; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0x00; - readback_p2 = 0x00; - read_lo = " 0 0 1 0 0 0 0 0", - "a15 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - "a15 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " x x x x x x x x", - " x a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " x x x x x x x x", - " x a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - "a15 a14 a13 a12 a11 a10 a9 a8", - " a7 x x x x x x x", - " x x x x x x x x"; - - load_ext_addr = " 0 1 0 0 1 1 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 0 0 a16", - " 0 0 0 0 0 0 0 0"; - - mode = 0x41; - delay = 10; - blocksize = 256; - readsize = 256; - ; - - memory "lfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "hfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "efuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", - "x x x x x x x x x x x x x i i i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "lock" - size = 1; - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x x x o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", - "x x x x x x x x 1 1 i i i i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "calibration" - size = 1; - read = "0 0 1 1 1 0 0 0 x x x x x x x x", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - ; - - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 x x x x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - ; - -#------------------------------------------------------------ -# ATmega2561 -#------------------------------------------------------------ - -part - id = "m2561"; - desc = "ATMEGA2561"; - signature = 0x1e 0x98 0x02; - has_jtag = yes; -# stk500_devcode = 0xB2; -# avr910_devcode = 0x43; - chip_erase_delay = 9000; - pagel = 0xD7; - bs2 = 0xA0; - reset = dedicated; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 10; - programfusepulsewidth = 0; - programfusepolltimeout = 5; - programlockpulsewidth = 0; - programlockpolltimeout = 5; - - idr = 0x31; - spmcr = 0x57; - rampz = 0x3b; - allowfullpagebitstream = no; - - memory "eeprom" - paged = no; /* leave this "no" */ - page_size = 8; /* for parallel programming */ - size = 4096; - min_write_delay = 9000; - max_write_delay = 9000; - readback_p1 = 0x00; - readback_p2 = 0x00; - read = " 1 0 1 0 0 0 0 0", - " x x x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write = " 1 1 0 0 0 0 0 0", - " x x x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 0 0 0", - " x x x x x x x x"; - - mode = 0x41; - delay = 10; - blocksize = 8; - readsize = 256; - ; - - memory "flash" - paged = yes; - size = 262144; - page_size = 256; - num_pages = 1024; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0x00; - readback_p2 = 0x00; - read_lo = " 0 0 1 0 0 0 0 0", - "a15 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - "a15 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " x x x x x x x x", - " x a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " x x x x x x x x", - " x a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - "a15 a14 a13 a12 a11 a10 a9 a8", - " a7 x x x x x x x", - " x x x x x x x x"; - - load_ext_addr = " 0 1 0 0 1 1 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 0 0 a16", - " 0 0 0 0 0 0 0 0"; - - mode = 0x41; - delay = 10; - blocksize = 256; - readsize = 256; - ; - - memory "lfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "hfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "efuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", - "x x x x x x x x x x x x x i i i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "lock" - size = 1; - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x x x o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", - "x x x x x x x x 1 1 i i i i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "calibration" - size = 1; - read = "0 0 1 1 1 0 0 0 x x x x x x x x", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - ; - - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 x x x x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - ; - -#------------------------------------------------------------ -# ATtiny24 -#------------------------------------------------------------ - -part - id = "t24"; - desc = "ATtiny24"; - has_debugwire = yes; - flash_instr = 0xB4, 0x07, 0x17; - eeprom_instr = 0xBB, 0xFF, 0xBB, 0xEE, 0xBB, 0xCC, 0xB2, 0x0D, - 0xBC, 0x07, 0xB4, 0x07, 0xBA, 0x0D, 0xBB, 0xBC, - 0x99, 0xE1, 0xBB, 0xAC; -## no STK500 devcode in XML file, use the ATtiny45 one - stk500_devcode = 0x14; -## avr910_devcode = ?; -## Try the AT90S2313 devcode: - avr910_devcode = 0x20; - signature = 0x1e 0x91 0x0b; - reset = io; - chip_erase_delay = 4500; - - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - - hvsp_controlstack = - 0x4C, 0x0C, 0x1C, 0x2C, 0x3C, 0x64, 0x74, 0x66, - 0x68, 0x78, 0x68, 0x68, 0x7A, 0x6A, 0x68, 0x78, - 0x78, 0x7D, 0x6D, 0x0C, 0x80, 0x40, 0x20, 0x10, - 0x11, 0x08, 0x04, 0x02, 0x03, 0x08, 0x04, 0x0F; - hventerstabdelay = 100; - hvspcmdexedelay = 0; - synchcycles = 6; - latchcycles = 1; - togglevtg = 1; - poweroffdelay = 25; - resetdelayms = 0; - resetdelayus = 70; - hvleavestabdelay = 100; - resetdelay = 25; - chiperasepolltimeout = 40; - chiperasetime = 0; - programfusepolltimeout = 25; - programlockpolltimeout = 25; - - memory "eeprom" - size = 128; - paged = no; - page_size = 4; - min_write_delay = 4000; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read = "1 0 1 0 0 0 0 0 0 0 0 x x x x x", - "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; - - write = "1 1 0 0 0 0 0 0 0 0 0 x x x x x", - "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 0 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 x x x x x x", - " x a6 a5 a4 a3 a2 0 0", - " x x x x x x x x"; - - mode = 0x41; - delay = 6; - blocksize = 4; - readsize = 256; - ; - memory "flash" - paged = yes; - size = 2048; - page_size = 32; - num_pages = 64; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - " 0 0 0 0 0 0 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " 0 0 0 0 0 0 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " 0 0 0 x x x x x", - " x x x x a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " 0 0 0 x x x x x", - " x x x x a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - " 0 0 0 0 0 0 a9 a8", - " a7 a6 a5 a4 x x x x", - " x x x x x x x x"; - - mode = 0x41; - delay = 6; - blocksize = 32; - readsize = 256; - ; -# ATtiny24 has Signature Bytes: 0x1E 0x91 0x0B. - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - memory "lock" - size = 1; - write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", - "x x x x x x x x x x x x x x i i"; - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "lfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "hfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "efuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", - "x x x x x x x x x x x x x x x i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "calibration" - size = 1; - read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", - "0 0 0 0 0 0 0 a0 o o o o o o o o"; - ; - ; - -#------------------------------------------------------------ -# ATtiny44 -#------------------------------------------------------------ - -part - id = "t44"; - desc = "ATtiny44"; - has_debugwire = yes; - flash_instr = 0xB4, 0x07, 0x17; - eeprom_instr = 0xBB, 0xFF, 0xBB, 0xEE, 0xBB, 0xCC, 0xB2, 0x0D, - 0xBC, 0x07, 0xB4, 0x07, 0xBA, 0x0D, 0xBB, 0xBC, - 0x99, 0xE1, 0xBB, 0xAC; -## no STK500 devcode in XML file, use the ATtiny45 one - stk500_devcode = 0x14; -## avr910_devcode = ?; -## Try the AT90S2313 devcode: - avr910_devcode = 0x20; - signature = 0x1e 0x92 0x07; - reset = io; - chip_erase_delay = 4500; - - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - - hvsp_controlstack = - 0x4C, 0x0C, 0x1C, 0x2C, 0x3C, 0x64, 0x74, 0x66, - 0x68, 0x78, 0x68, 0x68, 0x7A, 0x6A, 0x68, 0x78, - 0x78, 0x7D, 0x6D, 0x0C, 0x80, 0x40, 0x20, 0x10, - 0x11, 0x08, 0x04, 0x02, 0x03, 0x08, 0x04, 0x0F; - hventerstabdelay = 100; - hvspcmdexedelay = 0; - synchcycles = 6; - latchcycles = 1; - togglevtg = 1; - poweroffdelay = 25; - resetdelayms = 0; - resetdelayus = 70; - hvleavestabdelay = 100; - resetdelay = 25; - chiperasepolltimeout = 40; - chiperasetime = 0; - programfusepolltimeout = 25; - programlockpolltimeout = 25; - - memory "eeprom" - size = 256; - paged = no; - page_size = 4; - min_write_delay = 4000; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read = "1 0 1 0 0 0 0 0 0 0 0 x x x x x", - "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; - - write = "1 1 0 0 0 0 0 0 0 0 0 x x x x x", - "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 0 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 x x x x x x", - " x a6 a5 a4 a3 a2 0 0", - " x x x x x x x x"; - - mode = 0x41; - delay = 6; - blocksize = 4; - readsize = 256; - ; - memory "flash" - paged = yes; - size = 4096; - page_size = 64; - num_pages = 64; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - " 0 0 0 0 0 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " 0 0 0 0 0 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " 0 0 0 x x x x x", - " x x x a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " 0 0 0 x x x x x", - " x x x a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - " 0 0 0 0 0 a10 a9 a8", - " a7 a6 a5 x x x x x", - " x x x x x x x x"; - - mode = 0x41; - delay = 6; - blocksize = 32; - readsize = 256; - ; -# ATtiny44 has Signature Bytes: 0x1E 0x92 0x07. - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - memory "lock" - size = 1; - write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", - "x x x x x x x x x x x x x x i i"; - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "lfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "hfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "efuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", - "x x x x x x x x x x x x x x x i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "calibration" - size = 1; - read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", - "0 0 0 0 0 0 0 a0 o o o o o o o o"; - ; - ; - -#------------------------------------------------------------ -# ATtiny84 -#------------------------------------------------------------ - -part - id = "t84"; - desc = "ATtiny84"; - has_debugwire = yes; - flash_instr = 0xB4, 0x07, 0x17; - eeprom_instr = 0xBB, 0xFF, 0xBB, 0xEE, 0xBB, 0xCC, 0xB2, 0x0D, - 0xBC, 0x07, 0xB4, 0x07, 0xBA, 0x0D, 0xBB, 0xBC, - 0x99, 0xE1, 0xBB, 0xAC; -## no STK500 devcode in XML file, use the ATtiny45 one - stk500_devcode = 0x14; -## avr910_devcode = ?; -## Try the AT90S2313 devcode: - avr910_devcode = 0x20; - signature = 0x1e 0x93 0x0c; - reset = io; - chip_erase_delay = 4500; - - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - - hvsp_controlstack = - 0x4C, 0x0C, 0x1C, 0x2C, 0x3C, 0x64, 0x74, 0x66, - 0x68, 0x78, 0x68, 0x68, 0x7A, 0x6A, 0x68, 0x78, - 0x78, 0x7D, 0x6D, 0x0C, 0x80, 0x40, 0x20, 0x10, - 0x11, 0x08, 0x04, 0x02, 0x03, 0x08, 0x04, 0x0F; - hventerstabdelay = 100; - hvspcmdexedelay = 0; - synchcycles = 6; - latchcycles = 1; - togglevtg = 1; - poweroffdelay = 25; - resetdelayms = 0; - resetdelayus = 70; - hvleavestabdelay = 100; - resetdelay = 25; - chiperasepolltimeout = 40; - chiperasetime = 0; - programfusepolltimeout = 25; - programlockpolltimeout = 25; - - memory "eeprom" - size = 512; - paged = no; - page_size = 4; - min_write_delay = 4000; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read = "1 0 1 0 0 0 0 0 0 0 0 x x x x a8", - "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o"; - - write = "1 1 0 0 0 0 0 0 0 0 0 x x x x a8", - "a8 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 0 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 x x x x x x", - " x a6 a5 a4 a3 a2 0 0", - " x x x x x x x x"; - - mode = 0x41; - delay = 6; - blocksize = 4; - readsize = 256; - ; - memory "flash" - paged = yes; - size = 8192; - page_size = 64; - num_pages = 128; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - " 0 0 0 0 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " 0 0 0 0 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " 0 0 0 x x x x x", - " x x x a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " 0 0 0 x x x x x", - " x x x a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - " 0 0 0 0 a11 a10 a9 a8", - " a7 a6 a5 x x x x x", - " x x x x x x x x"; - - mode = 0x41; - delay = 6; - blocksize = 32; - readsize = 256; - ; -# ATtiny84 has Signature Bytes: 0x1E 0x93 0x0C. - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - - memory "lock" - size = 1; - write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", - "x x x x x x x x x x x x x x i i"; - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "lfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "hfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "efuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", - "x x x x x x x x x x x x x x x i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "calibration" - size = 1; - read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x", - "0 0 0 0 0 0 0 a0 o o o o o o o o"; - ; - ; - -#------------------------------------------------------------ -# AT90USB646 -#------------------------------------------------------------ - -part - id = "usb646"; - desc = "AT90USB646"; -# signature = 0x1e 0x96 0x82; ? - signature = 0x1e 0x97 0x82; - has_jtag = yes; -# stk500_devcode = 0xB2; -# avr910_devcode = 0x43; - chip_erase_delay = 9000; - pagel = 0xD7; - bs2 = 0xA0; - reset = dedicated; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 10; - programfusepulsewidth = 0; - programfusepolltimeout = 5; - programlockpulsewidth = 0; - programlockpolltimeout = 5; - - idr = 0x31; - spmcr = 0x57; - rampz = 0x3b; - allowfullpagebitstream = no; - - memory "eeprom" - paged = no; /* leave this "no" */ - page_size = 8; /* for parallel programming */ - size = 2048; - min_write_delay = 9000; - max_write_delay = 9000; - readback_p1 = 0x00; - readback_p2 = 0x00; - read = " 1 0 1 0 0 0 0 0", - " x x x x x a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write = " 1 1 0 0 0 0 0 0", - " x x x x x a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 x x x a10 a9 a8", - " a7 a6 a5 a4 a3 0 0 0", - " x x x x x x x x"; - - mode = 0x41; - delay = 10; - blocksize = 8; - readsize = 256; - ; - - memory "flash" - paged = yes; - size = 65536; - page_size = 256; - num_pages = 256; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0x00; - readback_p2 = 0x00; - read_lo = " 0 0 1 0 0 0 0 0", - " 0 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " 0 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " x x x x x x x x", - " x a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " x x x x x x x x", - " x a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - " 0 a14 a13 a12 a11 a10 a9 a8", - " a7 x x x x x x x", - " x x x x x x x x"; - - mode = 0x41; - delay = 6; - blocksize = 256; - readsize = 256; - ; - - memory "lfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "hfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "efuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", - "x x x x x x x x x x x x i i i i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "lock" - size = 1; - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x x x o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", - "x x x x x x x x 1 1 i i i i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "calibration" - size = 1; - read = "0 0 1 1 1 0 0 0 x x x x x x x x", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - ; - - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 x x x x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - ; - -#------------------------------------------------------------ -# AT90USB647 -#------------------------------------------------------------ -# identical to AT90USB646 - -part - id = "usb647"; - desc = "AT90USB647"; -# signature = 0x1e 0x96 0x82; ? - signature = 0x1e 0x97 0x82; - has_jtag = yes; -# stk500_devcode = 0xB2; -# avr910_devcode = 0x43; - chip_erase_delay = 9000; - pagel = 0xD7; - bs2 = 0xA0; - reset = dedicated; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 10; - programfusepulsewidth = 0; - programfusepolltimeout = 5; - programlockpulsewidth = 0; - programlockpolltimeout = 5; - - idr = 0x31; - spmcr = 0x57; - rampz = 0x3b; - allowfullpagebitstream = no; - - memory "eeprom" - paged = no; /* leave this "no" */ - page_size = 8; /* for parallel programming */ - size = 2048; - min_write_delay = 9000; - max_write_delay = 9000; - readback_p1 = 0x00; - readback_p2 = 0x00; - read = " 1 0 1 0 0 0 0 0", - " x x x x x a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write = " 1 1 0 0 0 0 0 0", - " x x x x x a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 x x x a10 a9 a8", - " a7 a6 a5 a4 a3 0 0 0", - " x x x x x x x x"; - - mode = 0x41; - delay = 10; - blocksize = 8; - readsize = 256; - ; - - memory "flash" - paged = yes; - size = 65536; - page_size = 256; - num_pages = 256; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0x00; - readback_p2 = 0x00; - read_lo = " 0 0 1 0 0 0 0 0", - " 0 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " 0 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " x x x x x x x x", - " x a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " x x x x x x x x", - " x a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - " 0 a14 a13 a12 a11 a10 a9 a8", - " a7 x x x x x x x", - " x x x x x x x x"; - - mode = 0x41; - delay = 6; - blocksize = 256; - readsize = 256; - ; - - memory "lfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "hfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "efuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", - "x x x x x x x x x x x x i i i i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "lock" - size = 1; - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x x x o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", - "x x x x x x x x 1 1 i i i i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "calibration" - size = 1; - read = "0 0 1 1 1 0 0 0 x x x x x x x x", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - ; - - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 x x x x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - ; - -#------------------------------------------------------------ -# AT90USB1286 -#------------------------------------------------------------ - -part - id = "usb1286"; - desc = "AT90USB1286"; - signature = 0x1e 0x97 0x82; - has_jtag = yes; -# stk500_devcode = 0xB2; -# avr910_devcode = 0x43; - chip_erase_delay = 9000; - pagel = 0xD7; - bs2 = 0xA0; - reset = dedicated; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 10; - programfusepulsewidth = 0; - programfusepolltimeout = 5; - programlockpulsewidth = 0; - programlockpolltimeout = 5; - - idr = 0x31; - spmcr = 0x57; - rampz = 0x3b; - allowfullpagebitstream = no; - - memory "eeprom" - paged = no; /* leave this "no" */ - page_size = 8; /* for parallel programming */ - size = 4096; - min_write_delay = 9000; - max_write_delay = 9000; - readback_p1 = 0x00; - readback_p2 = 0x00; - read = " 1 0 1 0 0 0 0 0", - " x x x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write = " 1 1 0 0 0 0 0 0", - " x x x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 x x x a10 a9 a8", - " a7 a6 a5 a4 a3 0 0 0", - " x x x x x x x x"; - - mode = 0x41; - delay = 10; - blocksize = 8; - readsize = 256; - ; - - memory "flash" - paged = yes; - size = 131072; - page_size = 256; - num_pages = 512; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0x00; - readback_p2 = 0x00; - read_lo = " 0 0 1 0 0 0 0 0", - "a15 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - "a15 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " x x x x x x x x", - " x a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " x x x x x x x x", - " x a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - "a15 a14 a13 a12 a11 a10 a9 a8", - " a7 x x x x x x x", - " x x x x x x x x"; - - mode = 0x41; - delay = 6; - blocksize = 256; - readsize = 256; - ; - - memory "lfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "hfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "efuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", - "x x x x x x x x x x x x i i i i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "lock" - size = 1; - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x x x o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", - "x x x x x x x x 1 1 i i i i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "calibration" - size = 1; - read = "0 0 1 1 1 0 0 0 x x x x x x x x", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - ; - - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 x x x x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - ; - -#------------------------------------------------------------ -# AT90USB1287 -#------------------------------------------------------------ -# identical to AT90USB1286 - -part - id = "usb1287"; - desc = "AT90USB1287"; - signature = 0x1e 0x97 0x82; - has_jtag = yes; -# stk500_devcode = 0xB2; -# avr910_devcode = 0x43; - chip_erase_delay = 9000; - pagel = 0xD7; - bs2 = 0xA0; - reset = dedicated; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "x x x x x x x x x x x x x x x x"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", - "x x x x x x x x x x x x x x x x"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 10; - programfusepulsewidth = 0; - programfusepolltimeout = 5; - programlockpulsewidth = 0; - programlockpolltimeout = 5; - - idr = 0x31; - spmcr = 0x57; - rampz = 0x3b; - allowfullpagebitstream = no; - - memory "eeprom" - paged = no; /* leave this "no" */ - page_size = 8; /* for parallel programming */ - size = 4096; - min_write_delay = 9000; - max_write_delay = 9000; - readback_p1 = 0x00; - readback_p2 = 0x00; - read = " 1 0 1 0 0 0 0 0", - " x x x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write = " 1 1 0 0 0 0 0 0", - " x x x x a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 x x x a10 a9 a8", - " a7 a6 a5 a4 a3 0 0 0", - " x x x x x x x x"; - - mode = 0x41; - delay = 10; - blocksize = 8; - readsize = 256; - ; - - memory "flash" - paged = yes; - size = 131072; - page_size = 256; - num_pages = 512; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0x00; - readback_p2 = 0x00; - read_lo = " 0 0 1 0 0 0 0 0", - "a15 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - "a15 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " x x x x x x x x", - " x a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " x x x x x x x x", - " x a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - "a15 a14 a13 a12 a11 a10 a9 a8", - " a7 x x x x x x x", - " x x x x x x x x"; - - mode = 0x41; - delay = 6; - blocksize = 256; - readsize = 256; - ; - - memory "lfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "hfuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "x x x x x x x x i i i i i i i i"; - - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "efuse" - size = 1; - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", - "x x x x x x x x x x x x i i i i"; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", - "x x x x x x x x o o o o o o o o"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "lock" - size = 1; - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x x x o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x", - "x x x x x x x x 1 1 i i i i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "calibration" - size = 1; - read = "0 0 1 1 1 0 0 0 x x x x x x x x", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - ; - - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 x x x x x x x x", - "x x x x x x a1 a0 o o o o o o o o"; - ; - ; - -#------------------------------------------------------------ -# ATmega325 -#------------------------------------------------------------ - -part - id = "m325"; - desc = "ATMEGA325"; - signature = 0x1e 0x95 0x05; - has_jtag = yes; -# stk500_devcode = 0x??; # No STK500v1 support? -# avr910_devcode = 0x??; # Try the ATmega16 one - avr910_devcode = 0x74; - pagel = 0xd7; - bs2 = 0xa0; - chip_erase_delay = 9000; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", - "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 10; - programfusepulsewidth = 0; - programfusepolltimeout = 5; - programlockpulsewidth = 0; - programlockpolltimeout = 5; - - idr = 0x31; - spmcr = 0x57; - allowfullpagebitstream = no; - - memory "eeprom" - paged = no; /* leave this "no" */ - page_size = 4; /* for parallel programming */ - size = 1024; - min_write_delay = 9000; - max_write_delay = 9000; - readback_p1 = 0xff; - readback_p2 = 0xff; - read = " 1 0 1 0 0 0 0 0", - " 0 0 0 0 0 0 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write = " 1 1 0 0 0 0 0 0", - " 0 0 0 0 0 0 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 0 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 0 0 0 0 a9 a8", - " a7 a6 a5 a4 a3 a2 0 0", - " x x x x x x x x"; - - mode = 0x41; - delay = 10; - blocksize = 4; - readsize = 256; - ; - - memory "flash" - paged = yes; - size = 32768; - page_size = 128; - num_pages = 256; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - " 0 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " 0 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " 0 0 0 0 0 0 0 0", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " 0 0 0 0 0 0 0 0", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - " 0 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " x x x x x x x x"; - - mode = 0x41; - delay = 10; - blocksize = 128; - readsize = 256; - ; - - memory "lock" - size = 1; - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x x x o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 1 1 0 0 0 0 0", - "0 0 0 0 0 0 0 0 1 1 i i i i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "lfuse" - size = 1; - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "0 0 0 0 0 0 0 0 i i i i i i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "hfuse" - size = 1; - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "0 0 0 0 0 0 0 0 i i i i i i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "efuse" - size = 1; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", - "0 0 0 0 0 0 0 0 1 1 1 1 1 i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0", - "0 0 0 0 0 0 a1 a0 o o o o o o o o"; - ; - - memory "calibration" - size = 1; - - read = "0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - ; - ; - -#------------------------------------------------------------ -# ATmega645 -#------------------------------------------------------------ - -part - id = "m645"; - desc = "ATMEGA645"; - signature = 0x1E 0x96 0x05; - has_jtag = yes; -# stk500_devcode = 0x??; # No STK500v1 support? -# avr910_devcode = 0x??; # Try the ATmega16 one - avr910_devcode = 0x74; - pagel = 0xd7; - bs2 = 0xa0; - chip_erase_delay = 9000; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", - "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 10; - programfusepulsewidth = 0; - programfusepolltimeout = 5; - programlockpulsewidth = 0; - programlockpolltimeout = 5; - - idr = 0x31; - spmcr = 0x57; - allowfullpagebitstream = no; - - memory "eeprom" - paged = no; /* leave this "no" */ - page_size = 8; /* for parallel programming */ - size = 2048; - min_write_delay = 9000; - max_write_delay = 9000; - readback_p1 = 0xff; - readback_p2 = 0xff; - read = " 1 0 1 0 0 0 0 0", - " 0 0 0 0 0 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write = " 1 1 0 0 0 0 0 0", - " 0 0 0 0 0 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 0 0 0 a10 a9 a8", - " a7 a6 a5 a4 a3 0 0 0", - " x x x x x x x x"; - - mode = 0x41; - delay = 10; - blocksize = 8; - readsize = 256; - ; - - memory "flash" - paged = yes; - size = 65536; - page_size = 256; - num_pages = 256; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - " a15 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " a15 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " 0 0 0 0 0 0 0 0", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " 0 0 0 0 0 0 0 0", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - " a15 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " 0 0 0 0 0 0 0 0"; - - mode = 0x41; - delay = 10; - blocksize = 128; - readsize = 256; - ; - - memory "lock" - size = 1; - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x x x o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 1 1 0 0 0 0 0", - "0 0 0 0 0 0 0 0 1 1 i i i i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "lfuse" - size = 1; - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "0 0 0 0 0 0 0 0 i i i i i i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "hfuse" - size = 1; - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "0 0 0 0 0 0 0 0 i i i i i i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "efuse" - size = 1; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", - "0 0 0 0 0 0 0 0 1 1 1 1 1 i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0", - "0 0 0 0 0 0 a1 a0 o o o o o o o o"; - ; - - memory "calibration" - size = 1; - - read = "0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - ; - ; - -#------------------------------------------------------------ -# ATmega3250 -#------------------------------------------------------------ - -part - id = "m3250"; - desc = "ATMEGA3250"; - signature = 0x1E 0x95 0x06; - has_jtag = yes; -# stk500_devcode = 0x??; # No STK500v1 support? -# avr910_devcode = 0x??; # Try the ATmega16 one - avr910_devcode = 0x74; - pagel = 0xd7; - bs2 = 0xa0; - chip_erase_delay = 9000; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", - "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 10; - programfusepulsewidth = 0; - programfusepolltimeout = 5; - programlockpulsewidth = 0; - programlockpolltimeout = 5; - - idr = 0x31; - spmcr = 0x57; - allowfullpagebitstream = no; - - memory "eeprom" - paged = no; /* leave this "no" */ - page_size = 4; /* for parallel programming */ - size = 1024; - min_write_delay = 9000; - max_write_delay = 9000; - readback_p1 = 0xff; - readback_p2 = 0xff; - read = " 1 0 1 0 0 0 0 0", - " 0 0 0 0 0 0 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write = " 1 1 0 0 0 0 0 0", - " 0 0 0 0 0 0 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 0 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 0 0 0 0 a9 a8", - " a7 a6 a5 a4 a3 a2 0 0", - " x x x x x x x x"; - - mode = 0x41; - delay = 10; - blocksize = 4; - readsize = 256; - ; - - memory "flash" - paged = yes; - size = 32768; - page_size = 128; - num_pages = 256; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - " 0 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " 0 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " 0 0 0 0 0 0 0 0", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " 0 0 0 0 0 0 0 0", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - " 0 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " x x x x x x x x"; - - mode = 0x41; - delay = 10; - blocksize = 128; - readsize = 256; - ; - - memory "lock" - size = 1; - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x x x o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 1 1 0 0 0 0 0", - "0 0 0 0 0 0 0 0 1 1 i i i i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "lfuse" - size = 1; - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "0 0 0 0 0 0 0 0 i i i i i i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "hfuse" - size = 1; - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "0 0 0 0 0 0 0 0 i i i i i i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "efuse" - size = 1; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", - "0 0 0 0 0 0 0 0 1 1 1 1 1 i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0", - "0 0 0 0 0 0 a1 a0 o o o o o o o o"; - ; - - memory "calibration" - size = 1; - - read = "0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - ; - ; - -#------------------------------------------------------------ -# ATmega6450 -#------------------------------------------------------------ - -part - id = "m6450"; - desc = "ATMEGA6450"; - signature = 0x1E 0x96 0x06; - has_jtag = yes; -# stk500_devcode = 0x??; # No STK500v1 support? -# avr910_devcode = 0x??; # Try the ATmega16 one - avr910_devcode = 0x74; - pagel = 0xd7; - bs2 = 0xa0; - chip_erase_delay = 9000; - pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1", - "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"; - - chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0", - "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"; - - timeout = 200; - stabdelay = 100; - cmdexedelay = 25; - synchloops = 32; - bytedelay = 0; - pollindex = 3; - pollvalue = 0x53; - predelay = 1; - postdelay = 1; - pollmethod = 1; - - pp_controlstack = - 0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F, - 0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F, - 0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B, - 0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00; - hventerstabdelay = 100; - progmodedelay = 0; - latchcycles = 5; - togglevtg = 1; - poweroffdelay = 15; - resetdelayms = 1; - resetdelayus = 0; - hvleavestabdelay = 15; - chiperasepulsewidth = 0; - chiperasepolltimeout = 10; - programfusepulsewidth = 0; - programfusepolltimeout = 5; - programlockpulsewidth = 0; - programlockpolltimeout = 5; - - idr = 0x31; - spmcr = 0x57; - allowfullpagebitstream = no; - - memory "eeprom" - paged = no; /* leave this "no" */ - page_size = 8; /* for parallel programming */ - size = 2048; - min_write_delay = 9000; - max_write_delay = 9000; - readback_p1 = 0xff; - readback_p2 = 0xff; - read = " 1 0 1 0 0 0 0 0", - " 0 0 0 0 0 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - write = " 1 1 0 0 0 0 0 0", - " 0 0 0 0 0 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_lo = " 1 1 0 0 0 0 0 1", - " 0 0 0 0 0 0 0 0", - " 0 0 0 0 0 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 1 1 0 0 0 0 1 0", - " 0 0 0 0 0 a10 a9 a8", - " a7 a6 a5 a4 a3 0 0 0", - " x x x x x x x x"; - - mode = 0x41; - delay = 10; - blocksize = 4; - readsize = 256; - ; - - memory "flash" - paged = yes; - size = 65536; - page_size = 256; - num_pages = 256; - min_write_delay = 4500; - max_write_delay = 4500; - readback_p1 = 0xff; - readback_p2 = 0xff; - read_lo = " 0 0 1 0 0 0 0 0", - " a15 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - read_hi = " 0 0 1 0 1 0 0 0", - " a15 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " o o o o o o o o"; - - loadpage_lo = " 0 1 0 0 0 0 0 0", - " 0 0 0 0 0 0 0 0", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - loadpage_hi = " 0 1 0 0 1 0 0 0", - " 0 0 0 0 0 0 0 0", - " a7 a6 a5 a4 a3 a2 a1 a0", - " i i i i i i i i"; - - writepage = " 0 1 0 0 1 1 0 0", - " a15 a14 a13 a12 a11 a10 a9 a8", - " a7 a6 a5 a4 a3 a2 a1 a0", - " 0 0 0 0 0 0 0 0"; - - mode = 0x41; - delay = 10; - blocksize = 128; - readsize = 256; - ; - - memory "lock" - size = 1; - read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0", - "x x x x x x x x x x o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 1 1 0 0 0 0 0", - "0 0 0 0 0 0 0 0 1 1 i i i i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "lfuse" - size = 1; - read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0", - "0 0 0 0 0 0 0 0 i i i i i i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "hfuse" - size = 1; - read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0", - "0 0 0 0 0 0 0 0 i i i i i i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "efuse" - size = 1; - - read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - - write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0", - "0 0 0 0 0 0 0 0 1 1 1 1 1 i i i"; - min_write_delay = 9000; - max_write_delay = 9000; - ; - - memory "signature" - size = 3; - read = "0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0", - "0 0 0 0 0 0 a1 a0 o o o o o o o o"; - ; - - memory "calibration" - size = 1; - - read = "0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0", - "0 0 0 0 0 0 0 0 o o o o o o o o"; - ; - ; diff --git a/arduino-0018-linux-x64/lib/antlr.jar b/arduino-0018-linux-x64/lib/antlr.jar deleted file mode 100644 index 42f25e5..0000000 Binary files a/arduino-0018-linux-x64/lib/antlr.jar and /dev/null differ diff --git a/arduino-0018-linux-x64/lib/core.jar b/arduino-0018-linux-x64/lib/core.jar deleted file mode 100644 index db10153..0000000 Binary files a/arduino-0018-linux-x64/lib/core.jar and /dev/null differ diff --git a/arduino-0018-linux-x64/lib/librxtxSerial.so b/arduino-0018-linux-x64/lib/librxtxSerial.so deleted file mode 100755 index 470dbfa..0000000 Binary files a/arduino-0018-linux-x64/lib/librxtxSerial.so and /dev/null differ diff --git a/arduino-0018-linux-x64/lib/oro.jar b/arduino-0018-linux-x64/lib/oro.jar deleted file mode 100644 index 667e86c..0000000 Binary files a/arduino-0018-linux-x64/lib/oro.jar and /dev/null differ diff --git a/arduino-0018-linux-x64/lib/pde.jar b/arduino-0018-linux-x64/lib/pde.jar deleted file mode 100644 index 87c0e9a..0000000 Binary files a/arduino-0018-linux-x64/lib/pde.jar and /dev/null differ diff --git a/arduino-0018-linux-x64/libraries/Ethernet/examples/ChatServer/ChatServer.pde b/arduino-0018-linux-x64/libraries/Ethernet/examples/ChatServer/ChatServer.pde deleted file mode 100644 index 825d2f8..0000000 --- a/arduino-0018-linux-x64/libraries/Ethernet/examples/ChatServer/ChatServer.pde +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Chat Server - * - * A simple server that distributes any incoming messages to all - * connected clients. To use telnet to 10.0.0.177 and type! - */ - -#include - -// network configuration. gateway and subnet are optional. -byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; -byte ip[] = { 10, 0, 0, 177 }; -byte gateway[] = { 10, 0, 0, 1 }; -byte subnet[] = { 255, 255, 0, 0 }; - -// telnet defaults to port 23 -Server server(23); - -void setup() -{ - // initialize the ethernet device - Ethernet.begin(mac, ip, gateway, subnet); - - // start listening for clients - server.begin(); -} - -void loop() -{ - Client client = server.available(); - if (client) { - server.write(client.read()); - } -} diff --git a/arduino-0018-linux-x64/libraries/Ethernet/examples/WebClient/WebClient.pde b/arduino-0018-linux-x64/libraries/Ethernet/examples/WebClient/WebClient.pde deleted file mode 100644 index 74a6094..0000000 --- a/arduino-0018-linux-x64/libraries/Ethernet/examples/WebClient/WebClient.pde +++ /dev/null @@ -1,41 +0,0 @@ -#include - -byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; -byte ip[] = { 10, 0, 0, 177 }; -byte server[] = { 64, 233, 187, 99 }; // Google - -Client client(server, 80); - -void setup() -{ - Ethernet.begin(mac, ip); - Serial.begin(9600); - - delay(1000); - - Serial.println("connecting..."); - - if (client.connect()) { - Serial.println("connected"); - client.println("GET /search?q=arduino HTTP/1.0"); - client.println(); - } else { - Serial.println("connection failed"); - } -} - -void loop() -{ - if (client.available()) { - char c = client.read(); - Serial.print(c); - } - - if (!client.connected()) { - Serial.println(); - Serial.println("disconnecting."); - client.stop(); - for(;;) - ; - } -} diff --git a/arduino-0018-linux-x64/libraries/Ethernet/examples/WebServer/WebServer.pde b/arduino-0018-linux-x64/libraries/Ethernet/examples/WebServer/WebServer.pde deleted file mode 100644 index b337a8e..0000000 --- a/arduino-0018-linux-x64/libraries/Ethernet/examples/WebServer/WebServer.pde +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Web Server - * - * A simple web server that shows the value of the analog input pins. - */ - -#include - -byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; -byte ip[] = { 10, 0, 0, 177 }; - -Server server(80); - -void setup() -{ - Ethernet.begin(mac, ip); - server.begin(); -} - -void loop() -{ - Client client = server.available(); - if (client) { - // an http request ends with a blank line - boolean current_line_is_blank = true; - while (client.connected()) { - if (client.available()) { - char c = client.read(); - // if we've gotten to the end of the line (received a newline - // character) and the line is blank, the http request has ended, - // so we can send a reply - if (c == '\n' && current_line_is_blank) { - // send a standard http response header - client.println("HTTP/1.1 200 OK"); - client.println("Content-Type: text/html"); - client.println(); - - // output the value of each analog input pin - for (int i = 0; i < 6; i++) { - client.print("analog input "); - client.print(i); - client.print(" is "); - client.print(analogRead(i)); - client.println("
"); - } - break; - } - if (c == '\n') { - // we're starting a new line - current_line_is_blank = true; - } else if (c != '\r') { - // we've gotten a character on the current line - current_line_is_blank = false; - } - } - } - // give the web browser time to receive the data - delay(1); - client.stop(); - } -} diff --git a/arduino-0018-linux-x64/libraries/Ethernet/utility/socket.c b/arduino-0018-linux-x64/libraries/Ethernet/utility/socket.c deleted file mode 100755 index 88c81a8..0000000 --- a/arduino-0018-linux-x64/libraries/Ethernet/utility/socket.c +++ /dev/null @@ -1,558 +0,0 @@ -/* -* -@file socket.c -@brief setting chip register for socket - last update : 2008. Jan -* -*/ - -#include "types.h" -#include "w5100.h" -#include "socket.h" - -static uint16 local_port; - - -/** -@brief This Socket function initialize the channel in perticular mode, and set the port and wait for W5100 done it. -@return 1 for sucess else 0. -*/ -uint8 socket( - SOCKET s, /**< for socket number */ - uint8 protocol, /**< for socket protocol */ - uint16 port, /**< the source port for the socket */ - uint8 flag /**< the option for the socket */ - ) -{ - uint8 ret; -#ifdef __DEF_IINCHIP_DBG__ - printf("socket()\r\n"); -#endif - if ((protocol == Sn_MR_TCP) || (protocol == Sn_MR_UDP) || (protocol == Sn_MR_IPRAW) || (protocol == Sn_MR_MACRAW) || (protocol == Sn_MR_PPPOE)) - { - close(s); - IINCHIP_WRITE(Sn_MR(s),protocol | flag); - if (port != 0) { - IINCHIP_WRITE(Sn_PORT0(s),(uint8)((port & 0xff00) >> 8)); - IINCHIP_WRITE((Sn_PORT0(s) + 1),(uint8)(port & 0x00ff)); - } else { - local_port++; // if don't set the source port, set local_port number. - IINCHIP_WRITE(Sn_PORT0(s),(uint8)((local_port & 0xff00) >> 8)); - IINCHIP_WRITE((Sn_PORT0(s) + 1),(uint8)(local_port & 0x00ff)); - } - IINCHIP_WRITE(Sn_CR(s),Sn_CR_OPEN); // run sockinit Sn_CR - - /* +20071122[chungs]:wait to process the command... */ - while( IINCHIP_READ(Sn_CR(s)) ) - ; - /* ------- */ - ret = 1; - } - else - { - ret = 0; - } -#ifdef __DEF_IINCHIP_DBG__ - printf("Sn_SR = %.2x , Protocol = %.2x\r\n", IINCHIP_READ(Sn_SR(s)), IINCHIP_READ(Sn_MR(s))); -#endif - return ret; -} - - -/** -@brief This function close the socket and parameter is "s" which represent the socket number -*/ -void close(SOCKET s) -{ -#ifdef __DEF_IINCHIP_DBG__ - printf("close()\r\n"); -#endif - - IINCHIP_WRITE(Sn_CR(s),Sn_CR_CLOSE); - - /* +20071122[chungs]:wait to process the command... */ - while( IINCHIP_READ(Sn_CR(s)) ) - ; - /* ------- */ - - /* +2008.01 [hwkim]: clear interrupt */ - #ifdef __DEF_IINCHIP_INT__ - /* m2008.01 [bj] : all clear */ - putISR(s, 0x00); - #else - /* m2008.01 [bj] : all clear */ - IINCHIP_WRITE(Sn_IR(s), 0xFF); - #endif -} - - -/** -@brief This function established the connection for the channel in passive (server) mode. This function waits for the request from the peer. -@return 1 for success else 0. -*/ -uint8 listen( - SOCKET s /**< the socket number */ - ) -{ - uint8 ret; -#ifdef __DEF_IINCHIP_DBG__ - printf("listen()\r\n"); -#endif - if (IINCHIP_READ(Sn_SR(s)) == SOCK_INIT) - { - IINCHIP_WRITE(Sn_CR(s),Sn_CR_LISTEN); - /* +20071122[chungs]:wait to process the command... */ - while( IINCHIP_READ(Sn_CR(s)) ) - ; - /* ------- */ - ret = 1; - } - else - { - ret = 0; -#ifdef __DEF_IINCHIP_DBG__ - printf("Fail[invalid ip,port]\r\n"); -#endif - } - return ret; -} - - -/** -@brief This function established the connection for the channel in Active (client) mode. - This function waits for the untill the connection is established. - -@return 1 for success else 0. -*/ -uint8 connect(SOCKET s, uint8 * addr, uint16 port) -{ - uint8 ret; -#ifdef __DEF_IINCHIP_DBG__ - printf("connect()\r\n"); -#endif - if - ( - ((addr[0] == 0xFF) && (addr[1] == 0xFF) && (addr[2] == 0xFF) && (addr[3] == 0xFF)) || - ((addr[0] == 0x00) && (addr[1] == 0x00) && (addr[2] == 0x00) && (addr[3] == 0x00)) || - (port == 0x00) - ) - { - ret = 0; -#ifdef __DEF_IINCHIP_DBG__ - printf("Fail[invalid ip,port]\r\n"); -#endif - } - else - { - ret = 1; - // set destination IP - IINCHIP_WRITE(Sn_DIPR0(s),addr[0]); - IINCHIP_WRITE((Sn_DIPR0(s) + 1),addr[1]); - IINCHIP_WRITE((Sn_DIPR0(s) + 2),addr[2]); - IINCHIP_WRITE((Sn_DIPR0(s) + 3),addr[3]); - IINCHIP_WRITE(Sn_DPORT0(s),(uint8)((port & 0xff00) >> 8)); - IINCHIP_WRITE((Sn_DPORT0(s) + 1),(uint8)(port & 0x00ff)); - IINCHIP_WRITE(Sn_CR(s),Sn_CR_CONNECT); - /* m2008.01 [bj] : wait for completion */ - while ( IINCHIP_READ(Sn_CR(s)) ) ; - - } - - return ret; -} - - - -/** -@brief This function used for disconnect the socket and parameter is "s" which represent the socket number -@return 1 for success else 0. -*/ -void disconnect(SOCKET s) -{ -#ifdef __DEF_IINCHIP_DBG__ - printf("disconnect()\r\n"); -#endif - IINCHIP_WRITE(Sn_CR(s),Sn_CR_DISCON); - - /* +20071122[chungs]:wait to process the command... */ - while( IINCHIP_READ(Sn_CR(s)) ) - ; - /* ------- */ -} - - -/** -@brief This function used to send the data in TCP mode -@return 1 for success else 0. -*/ -uint16 send( - SOCKET s, /**< the socket index */ - const uint8 * buf, /**< a pointer to data */ - uint16 len /**< the data size to be send */ - ) -{ - uint8 status=0; - uint16 ret=0; - uint16 freesize=0; -#ifdef __DEF_IINCHIP_DBG__ - printf("send()\r\n"); -#endif - - if (len > getIINCHIP_TxMAX(s)) ret = getIINCHIP_TxMAX(s); // check size not to exceed MAX size. - else ret = len; - - // if freebuf is available, start. - do - { - freesize = getSn_TX_FSR(s); - status = IINCHIP_READ(Sn_SR(s)); - if ((status != SOCK_ESTABLISHED) && (status != SOCK_CLOSE_WAIT)) - { - ret = 0; - break; - } -#ifdef __DEF_IINCHIP_DBG__ - printf("socket %d freesize(%d) empty or error\r\n", s, freesize); -#endif - } while (freesize < ret); - - // copy data - send_data_processing(s, (uint8 *)buf, ret); - IINCHIP_WRITE(Sn_CR(s),Sn_CR_SEND); - - /* +20071122[chungs]:wait to process the command... */ - while( IINCHIP_READ(Sn_CR(s)) ) - ; - /* ------- */ - -/* +2008.01 bj */ -#ifdef __DEF_IINCHIP_INT__ - while ( (getISR(s) & Sn_IR_SEND_OK) != Sn_IR_SEND_OK ) -#else - while ( (IINCHIP_READ(Sn_IR(s)) & Sn_IR_SEND_OK) != Sn_IR_SEND_OK ) -#endif - { - /* m2008.01 [bj] : reduce code */ - if ( IINCHIP_READ(Sn_SR(s)) == SOCK_CLOSED ) - { -#ifdef __DEF_IINCHIP_DBG__ - printf("SOCK_CLOSED.\r\n"); -#endif - close(s); - return 0; - } - } -/* +2008.01 bj */ -#ifdef __DEF_IINCHIP_INT__ - putISR(s, getISR(s) & (~Sn_IR_SEND_OK)); -#else - IINCHIP_WRITE(Sn_IR(s), Sn_IR_SEND_OK); -#endif - return ret; -} - - -/** -@brief This function is an application I/F function which is used to receive the data in TCP mode. - It continues to wait for data as much as the application wants to receive. - -@return received data size for success else -1. -*/ -uint16 recv( - SOCKET s, /**< socket index */ - uint8 * buf, /**< a pointer to copy the data to be received */ - uint16 len /**< the data size to be read */ - ) -{ - uint16 ret=0; -#ifdef __DEF_IINCHIP_DBG__ - printf("recv()\r\n"); -#endif - - - if ( len > 0 ) - { - recv_data_processing(s, buf, len); - IINCHIP_WRITE(Sn_CR(s),Sn_CR_RECV); - - /* +20071122[chungs]:wait to process the command... */ - while( IINCHIP_READ(Sn_CR(s)) ) - ; - /* ------- */ - ret = len; - } - return ret; -} - - -/** -@brief This function is an application I/F function which is used to send the data for other then TCP mode. - Unlike TCP transmission, The peer's destination address and the port is needed. - -@return This function return send data size for success else -1. -*/ -uint16 sendto( - SOCKET s, /**< socket index */ - const uint8 * buf, /**< a pointer to the data */ - uint16 len, /**< the data size to send */ - uint8 * addr, /**< the peer's Destination IP address */ - uint16 port /**< the peer's destination port number */ - ) -{ -// uint8 status=0; -// uint8 isr=0; - uint16 ret=0; - -#ifdef __DEF_IINCHIP_DBG__ - printf("sendto()\r\n"); -#endif - if (len > getIINCHIP_TxMAX(s)) ret = getIINCHIP_TxMAX(s); // check size not to exceed MAX size. - else ret = len; - - if - ( - ((addr[0] == 0x00) && (addr[1] == 0x00) && (addr[2] == 0x00) && (addr[3] == 0x00)) || - ((port == 0x00)) ||(ret == 0) - ) - { - /* +2008.01 [bj] : added return value */ - ret = 0; -#ifdef __DEF_IINCHIP_DBG__ - printf("%d Fail[%.2x.%.2x.%.2x.%.2x, %.d, %d]\r\n",s, addr[0], addr[1], addr[2], addr[3] , port, len); - printf("Fail[invalid ip,port]\r\n"); -#endif - } - else - { - IINCHIP_WRITE(Sn_DIPR0(s),addr[0]); - IINCHIP_WRITE((Sn_DIPR0(s) + 1),addr[1]); - IINCHIP_WRITE((Sn_DIPR0(s) + 2),addr[2]); - IINCHIP_WRITE((Sn_DIPR0(s) + 3),addr[3]); - IINCHIP_WRITE(Sn_DPORT0(s),(uint8)((port & 0xff00) >> 8)); - IINCHIP_WRITE((Sn_DPORT0(s) + 1),(uint8)(port & 0x00ff)); - - // copy data - send_data_processing(s, (uint8 *)buf, ret); - IINCHIP_WRITE(Sn_CR(s),Sn_CR_SEND); - - /* +20071122[chungs]:wait to process the command... */ - while( IINCHIP_READ(Sn_CR(s)) ) - ; - /* ------- */ - -/* +2008.01 bj */ -#ifdef __DEF_IINCHIP_INT__ - while ( (getISR(s) & Sn_IR_SEND_OK) != Sn_IR_SEND_OK ) -#else - while ( (IINCHIP_READ(Sn_IR(s)) & Sn_IR_SEND_OK) != Sn_IR_SEND_OK ) -#endif - { -#ifdef __DEF_IINCHIP_INT__ - if (getISR(s) & Sn_IR_TIMEOUT) -#else - if (IINCHIP_READ(Sn_IR(s)) & Sn_IR_TIMEOUT) -#endif - { -#ifdef __DEF_IINCHIP_DBG__ - printf("send fail.\r\n"); -#endif -/* +2008.01 [bj]: clear interrupt */ -#ifdef __DEF_IINCHIP_INT__ - putISR(s, getISR(s) & ~(Sn_IR_SEND_OK | Sn_IR_TIMEOUT)); /* clear SEND_OK & TIMEOUT */ -#else - IINCHIP_WRITE(Sn_IR(s), (Sn_IR_SEND_OK | Sn_IR_TIMEOUT)); /* clear SEND_OK & TIMEOUT */ -#endif - return 0; - } - } - -/* +2008.01 bj */ -#ifdef __DEF_IINCHIP_INT__ - putISR(s, getISR(s) & (~Sn_IR_SEND_OK)); -#else - IINCHIP_WRITE(Sn_IR(s), Sn_IR_SEND_OK); -#endif - - } - return ret; -} - - -/** -@brief This function is an application I/F function which is used to receive the data in other then - TCP mode. This function is used to receive UDP, IP_RAW and MAC_RAW mode, and handle the header as well. - -@return This function return received data size for success else -1. -*/ -uint16 recvfrom( - SOCKET s, /**< the socket number */ - uint8 * buf, /**< a pointer to copy the data to be received */ - uint16 len, /**< the data size to read */ - uint8 * addr, /**< a pointer to store the peer's IP address */ - uint16 *port /**< a pointer to store the peer's port number. */ - ) -{ - uint8 head[8]; - uint16 data_len=0; - uint16 ptr=0; -#ifdef __DEF_IINCHIP_DBG__ - printf("recvfrom()\r\n"); -#endif - - if ( len > 0 ) - { - ptr = IINCHIP_READ(Sn_RX_RD0(s)); - ptr = ((ptr & 0x00ff) << 8) + IINCHIP_READ(Sn_RX_RD0(s) + 1); -#ifdef __DEF_IINCHIP_DBG__ - printf("ISR_RX: rd_ptr : %.4x\r\n", ptr); -#endif - switch (IINCHIP_READ(Sn_MR(s)) & 0x07) - { - case Sn_MR_UDP : - read_data(s, (uint8 *)ptr, head, 0x08); - ptr += 8; - // read peer's IP address, port number. - addr[0] = head[0]; - addr[1] = head[1]; - addr[2] = head[2]; - addr[3] = head[3]; - *port = head[4]; - *port = (*port << 8) + head[5]; - data_len = head[6]; - data_len = (data_len << 8) + head[7]; - -#ifdef __DEF_IINCHIP_DBG__ - printf("UDP msg arrived\r\n"); - printf("source Port : %d\r\n", *port); - printf("source IP : %d.%d.%d.%d\r\n", addr[0], addr[1], addr[2], addr[3]); -#endif - - read_data(s, (uint8 *)ptr, buf, data_len); // data copy. - ptr += data_len; - - IINCHIP_WRITE(Sn_RX_RD0(s),(uint8)((ptr & 0xff00) >> 8)); - IINCHIP_WRITE((Sn_RX_RD0(s) + 1),(uint8)(ptr & 0x00ff)); - break; - - case Sn_MR_IPRAW : - read_data(s, (uint8 *)ptr, head, 0x06); - ptr += 6; - - addr[0] = head[0]; - addr[1] = head[1]; - addr[2] = head[2]; - addr[3] = head[3]; - data_len = head[4]; - data_len = (data_len << 8) + head[5]; - -#ifdef __DEF_IINCHIP_DBG__ - printf("IP RAW msg arrived\r\n"); - printf("source IP : %d.%d.%d.%d\r\n", addr[0], addr[1], addr[2], addr[3]); -#endif - read_data(s, (uint8 *)ptr, buf, data_len); // data copy. - ptr += data_len; - - IINCHIP_WRITE(Sn_RX_RD0(s),(uint8)((ptr & 0xff00) >> 8)); - IINCHIP_WRITE((Sn_RX_RD0(s) + 1),(uint8)(ptr & 0x00ff)); - break; - case Sn_MR_MACRAW : - read_data(s,(uint8*)ptr,head,2); - ptr+=2; - data_len = head[0]; - data_len = (data_len<<8) + head[1] - 2; - - read_data(s,(uint8*) ptr,buf,data_len); - ptr += data_len; - IINCHIP_WRITE(Sn_RX_RD0(s),(uint8)((ptr & 0xff00) >> 8)); - IINCHIP_WRITE((Sn_RX_RD0(s) + 1),(uint8)(ptr & 0x00ff)); - -#ifdef __DEF_IINCHIP_DGB__ - printf("MAC RAW msg arrived\r\n"); - printf("dest mac=%.2X.%.2X.%.2X.%.2X.%.2X.%.2X\r\n",buf[0],buf[1],buf[2],buf[3],buf[4],buf[5]); - printf("src mac=%.2X.%.2X.%.2X.%.2X.%.2X.%.2X\r\n",buf[6],buf[7],buf[8],buf[9],buf[10],buf[11]); - printf("type =%.2X%.2X\r\n",buf[12],buf[13]); -#endif - break; - - default : - break; - } - IINCHIP_WRITE(Sn_CR(s),Sn_CR_RECV); - - /* +20071122[chungs]:wait to process the command... */ - while( IINCHIP_READ(Sn_CR(s)) ) - ; - /* ------- */ - } -#ifdef __DEF_IINCHIP_DBG__ - printf("recvfrom() end ..\r\n"); -#endif - return data_len; -} - - -uint16 igmpsend(SOCKET s, const uint8 * buf, uint16 len) -{ - uint8 status=0; -// uint8 isr=0; - uint16 ret=0; - -#ifdef __DEF_IINCHIP_DBG__ - printf("igmpsend()\r\n"); -#endif - if (len > getIINCHIP_TxMAX(s)) ret = getIINCHIP_TxMAX(s); // check size not to exceed MAX size. - else ret = len; - - if (ret == 0) - { - ; -#ifdef __DEF_IINCHIP_DBG__ - printf("%d Fail[%d]\r\n",len); -#endif - } - else - { - // copy data - send_data_processing(s, (uint8 *)buf, ret); - IINCHIP_WRITE(Sn_CR(s),Sn_CR_SEND); -/* +2008.01 bj */ - while( IINCHIP_READ(Sn_CR(s)) ) - ; -/* ------- */ - -/* +2008.01 bj */ -#ifdef __DEF_IINCHIP_INT__ - while ( (getISR(s) & Sn_IR_SEND_OK) != Sn_IR_SEND_OK ) -#else - while ( (IINCHIP_READ(Sn_IR(s)) & Sn_IR_SEND_OK) != Sn_IR_SEND_OK ) -#endif - { - status = IINCHIP_READ(Sn_SR(s)); -#ifdef __DEF_IINCHIP_INT__ - if (getISR(s) & Sn_IR_TIMEOUT) -#else - if (IINCHIP_READ(Sn_IR(s)) & Sn_IR_TIMEOUT) -#endif - { -#ifdef __DEF_IINCHIP_DBG__ - printf("igmpsend fail.\r\n"); -#endif - /* in case of igmp, if send fails, then socket closed */ - /* if you want change, remove this code. */ - close(s); - /* ----- */ - - return 0; - } - } - -/* +2008.01 bj */ -#ifdef __DEF_IINCHIP_INT__ - putISR(s, getISR(s) & (~Sn_IR_SEND_OK)); -#else - IINCHIP_WRITE(Sn_IR(s), Sn_IR_SEND_OK); -#endif - } - return ret; -} - diff --git a/arduino-0018-linux-x64/libraries/Ethernet/utility/socket.h b/arduino-0018-linux-x64/libraries/Ethernet/utility/socket.h deleted file mode 100755 index a5cce42..0000000 --- a/arduino-0018-linux-x64/libraries/Ethernet/utility/socket.h +++ /dev/null @@ -1,23 +0,0 @@ -/* -* -@file socket.h -@brief define function of socket API -* -*/ - -#ifndef _SOCKET_H_ -#define _SOCKET_H_ - -extern uint8 socket(SOCKET s, uint8 protocol, uint16 port, uint8 flag); // Opens a socket(TCP or UDP or IP_RAW mode) -extern void close(SOCKET s); // Close socket -extern uint8 connect(SOCKET s, uint8 * addr, uint16 port); // Establish TCP connection (Active connection) -extern void disconnect(SOCKET s); // disconnect the connection -extern uint8 listen(SOCKET s); // Establish TCP connection (Passive connection) -extern uint16 send(SOCKET s, const uint8 * buf, uint16 len); // Send data (TCP) -extern uint16 recv(SOCKET s, uint8 * buf, uint16 len); // Receive data (TCP) -extern uint16 sendto(SOCKET s, const uint8 * buf, uint16 len, uint8 * addr, uint16 port); // Send data (UDP/IP RAW) -extern uint16 recvfrom(SOCKET s, uint8 * buf, uint16 len, uint8 * addr, uint16 *port); // Receive data (UDP/IP RAW) - -extern uint16 igmpsend(SOCKET s, const uint8 * buf, uint16 len); -#endif -/* _SOCKET_H_ */ diff --git a/arduino-0018-linux-x64/libraries/Ethernet/utility/spi.h b/arduino-0018-linux-x64/libraries/Ethernet/utility/spi.h deleted file mode 100755 index 000705d..0000000 --- a/arduino-0018-linux-x64/libraries/Ethernet/utility/spi.h +++ /dev/null @@ -1,58 +0,0 @@ -//----------------------------------------------------------------------------- -//AVR Mega168 SPI HAL -#define BIT0 0x01 -#define BIT1 0x02 -#define BIT2 0x04 -#define BIT3 0x08 -#define BIT4 0x10 -#define BIT5 0x20 -#define BIT6 0x40 -#define BIT7 0x80 - -#define SPI0_SS_BIT BIT2 -#define SPI0_SS_DDR DDRB -#define SPI0_SS_PORT PORTB - -#define SPI0_SCLK_BIT BIT5 -#define SPI0_SCLK_DDR DDRB -#define SPI0_SCLK_PORT PORTB - -#define SPI0_MOSI_BIT BIT3 -#define SPI0_MOSI_DDR DDRB -#define SPI0_MOSI_PORT PORTB - -#define SPI0_MISO_BIT BIT4 -#define SPI0_MISO_DDR DDRB -#define SPI0_MISO_PORT PORTB - - -#define SPI0_WaitForReceive() -#define SPI0_RxData() (SPDR) - -#define SPI0_TxData(Data) (SPDR = Data) -#define SPI0_WaitForSend() while( (SPSR & 0x80)==0x00 ) - -#define SPI0_SendByte(Data) SPI0_TxData(Data);SPI0_WaitForSend() -#define SPI0_RecvBute() SPI0_RxData() - -// PB4(MISO), PB3(MOSI), PB5(SCK), PB2(/SS) // CS=1, waiting for SPI start // SPI mode 0, 4MHz -#define SPI0_Init() DDRB |= SPI0_SS_BIT|SPI0_SCLK_BIT|SPI0_MOSI_BIT;\ - PORTB |= SPI0_SS_BIT; PORTB &= ~(SPI0_SCLK_BIT|SPI0_MOSI_BIT);\ - SPCR = 0x50 -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -//IInChip SPI HAL -#define IINCHIP_SpiInit SPI0_Init -#define IINCHIP_SpiSendData SPI0_SendByte -#define IINCHIP_SpiRecvData SPI0_RxData - - -#define IINCHIP_CS_BIT BIT2 -#define IINCHIP_CS_DDR DDRB -#define IINCHIP_CS_PORT PORTB - -#define IINCHIP_CSInit() (IINCHIP_CS_DDR |= IINCHIP_CS_BIT) -#define IINCHIP_CSon() (IINCHIP_CS_PORT |= IINCHIP_CS_BIT) -#define IINCHIP_CSoff() (IINCHIP_CS_PORT &= ~IINCHIP_CS_BIT) -//----------------------------------------------------------------------------- diff --git a/arduino-0018-linux-x64/libraries/Ethernet/utility/types.h b/arduino-0018-linux-x64/libraries/Ethernet/utility/types.h deleted file mode 100755 index 6c350da..0000000 --- a/arduino-0018-linux-x64/libraries/Ethernet/utility/types.h +++ /dev/null @@ -1,165 +0,0 @@ -/* -* -@file type.h -* -*/ - -#ifndef _TYPE_H_ -#define _TYPE_H_ - - -/*************************************************** - * attribute for mcu ( types, ... ) - ***************************************************/ -//#include "mcu_define.h" -#define __MCU_AVR__ 1 -#define __MCU_TYPE__ __MCU_AVR__ - -//---- Refer "Rom File Maker Manual Vx.x.pdf" -#include - -#define _ENDIAN_LITTLE_ 0 /**< This must be defined if system is little-endian alignment */ -#define _ENDIAN_BIG_ 1 -#define SYSTEM_ENDIAN _ENDIAN_LITTLE_ - -#define MAX_SOCK_NUM 4 /**< Maxmium number of socket */ -#define CLK_CPU F_CPU /**< 8Mhz(for serial) */ - -/* ## __DEF_IINCHIP_xxx__ : define option for iinchip driver *****************/ -//#define __DEF_IINCHIP_DBG__ /* involve debug code in driver (socket.c) */ -//#define __DEF_IINCHIP_INT__ /**< involve interrupt service routine (socket.c) */ -//#define __DEF_IINCHIP_PPP__ /* involve pppoe routine (socket.c) */ - /* If it is defined, the source files(md5.h,md5.c) must be included in your project. - Otherwize, the source files must be removed in your project. */ - -#define __DEF_IINCHIP_DIRECT_MODE__ 1 -#define __DEF_IINCHIP_INDIRECT_MODE__ 2 -#define __DEF_IINCHIP_SPI_MODE__ 3 - -//#define __DEF_IINCHIP_BUS__ __DEF_IINCHIP_DIRECT_MODE__ -//#define __DEF_IINCHIP_BUS__ __DEF_IINCHIP_INDIRECT_MODE__ -#define __DEF_IINCHIP_BUS__ __DEF_IINCHIP_SPI_MODE__ /*Enable SPI_mode*/ - - -/** -@brief __DEF_IINCHIP_MAP_xxx__ : define memory map for iinchip -*/ -#define __DEF_IINCHIP_MAP_BASE__ 0x8000 -#if (__DEF_IINCHIP_BUS__ == __DEF_IINCHIP_DIRECT_MODE__) - #define COMMON_BASE __DEF_IINCHIP_MAP_BASE__ -#else - #define COMMON_BASE 0x0000 -#endif -#define __DEF_IINCHIP_MAP_TXBUF__ (COMMON_BASE + 0x4000) /* Internal Tx buffer address of the iinchip */ -#define __DEF_IINCHIP_MAP_RXBUF__ (COMMON_BASE + 0x6000) /* Internal Rx buffer address of the iinchip */ - - -#if (__MCU_TYPE__ == __MCU_AVR__) - #ifdef __DEF_IINCHIP_INT__ - // iinchip use external interrupt 4 - #define IINCHIP_ISR_DISABLE() (EIMSK &= ~(0x10)) - #define IINCHIP_ISR_ENABLE() (EIMSK |= 0x10) - #define IINCHIP_ISR_GET(X) (X = EIMSK) - #define IINCHIP_ISR_SET(X) (EIMSK = X) - #else - #define IINCHIP_ISR_DISABLE() - #define IINCHIP_ISR_ENABLE() - #define IINCHIP_ISR_GET(X) - #define IINCHIP_ISR_SET(X) - #endif -#else -#error "unknown MCU type" -#endif - -#ifndef NULL -#define NULL ((void *) 0) -#endif - -//typedef enum { false, true } bool; - -#ifndef _SIZE_T -#define _SIZE_T -typedef unsigned int size_t; -#endif - -/** - * The 8-bit signed data type. - */ -typedef char int8; -/** - * The volatile 8-bit signed data type. - */ -typedef volatile char vint8; -/** - * The 8-bit unsigned data type. - */ -typedef unsigned char uint8; -/** - * The volatile 8-bit unsigned data type. - */ -typedef volatile unsigned char vuint8; - -/** - * The 16-bit signed data type. - */ -typedef int int16; -/** - * The volatile 16-bit signed data type. - */ -typedef volatile int vint16; -/** - * The 16-bit unsigned data type. - */ -typedef unsigned int uint16; -/** - * The volatile 16-bit unsigned data type. - */ -typedef volatile unsigned int vuint16; -/** - * The 32-bit signed data type. - */ -typedef long int32; -/** - * The volatile 32-bit signed data type. - */ -typedef volatile long vint32; -/** - * The 32-bit unsigned data type. - */ -typedef unsigned long uint32; -/** - * The volatile 32-bit unsigned data type. - */ -typedef volatile unsigned long vuint32; - -/* bsd */ -typedef uint8 u_char; /**< 8-bit value */ -typedef uint8 SOCKET; -typedef uint16 u_short; /**< 16-bit value */ -typedef uint16 u_int; /**< 16-bit value */ -typedef uint32 u_long; /**< 32-bit value */ - -typedef union _un_l2cval { - u_long lVal; - u_char cVal[4]; -}un_l2cval; - -typedef union _un_i2cval { - u_int iVal; - u_char cVal[2]; -}un_i2cval; - - -/** global define */ -#define FW_VERSION 0x01010000 /* System F/W Version : 1.1.0.0 */ -#define HW_VERSION 0x01000000 - - -#define TX_RX_MAX_BUF_SIZE 2048 -#define TX_BUF 0x1100 -#define RX_BUF (TX_BUF+TX_RX_MAX_BUF_SIZE) - -#define UART_DEVICE_CNT 1 /**< UART device number */ -/* #define SUPPORT_UART_ONE */ - -#endif /* _TYPE_H_ */ diff --git a/arduino-0018-linux-x64/libraries/Ethernet/utility/w5100.c b/arduino-0018-linux-x64/libraries/Ethernet/utility/w5100.c deleted file mode 100755 index 7d0f55a..0000000 --- a/arduino-0018-linux-x64/libraries/Ethernet/utility/w5100.c +++ /dev/null @@ -1,1302 +0,0 @@ -/* - * (c)COPYRIGHT - * ALL RIGHT RESERVED - * - * FileName : w5100.c - * Revision History : - * ---------- ------- ------------------------------------------------ - * Date version Description - * ---------- ------- ------------------------------------------------ - * 01/25/2007 1.1 Bug is Fixed in the Indirect Mode - * : Memory mapping error - * ---------- ------- ------------------------------------------------ - * 01/08/2008 1.2 Modification of Socket Command Part - * : Check if the appropriately performed after writing Sn_CR - * - * Modification of SPI Part - * : SPI code changed by adding 'spi.h'. - * : Change control type for SPI port from byte to bit. - * ---------- ------- ------------------------------------------------ - * 01/15/2008 1.3 Bug is Fixed in the pppinit() fuction. - * : do not clear interrupt value, so fixed. - * - * Modification of ISR - * : Do not exit ISR, if there is interrupt. - * ---------- ------- ------------------------------------------------ - * 03/21/2008 1.4 Modification of SetMR() function - * : Use IINCHIP_WRITE() function in Direct or SPI mode. - * ---------- ------- ------------------------------------------------ - */ -#include -#include - -#include -// #include - -#include "types.h" -#include "socket.h" -#include "w5100.h" - - - -#ifdef __DEF_IINCHIP_PPP__ - #include "md5.h" -#endif - - -#if (__DEF_IINCHIP_BUS__ == __DEF_IINCHIP_SPI_MODE__) -#include "spi.h" //+2007113[jhpark] -#endif - -static uint8 I_STATUS[MAX_SOCK_NUM]; -static uint16 SMASK[MAX_SOCK_NUM]; /**< Variable for Tx buffer MASK in each channel */ -static uint16 RMASK[MAX_SOCK_NUM]; /**< Variable for Rx buffer MASK in each channel */ -static uint16 SSIZE[MAX_SOCK_NUM]; /**< Max Tx buffer size by each channel */ -static uint16 RSIZE[MAX_SOCK_NUM]; /**< Max Rx buffer size by each channel */ -static uint16 SBUFBASEADDRESS[MAX_SOCK_NUM]; /**< Tx buffer base address by each channel */ -static uint16 RBUFBASEADDRESS[MAX_SOCK_NUM]; /**< Rx buffer base address by each channel */ - -uint8 getISR(uint8 s) -{ - return I_STATUS[s]; -} - -void putISR(uint8 s, uint8 val) -{ - I_STATUS[s] = val; -} - -uint16 getIINCHIP_RxMAX(uint8 s) -{ - return RSIZE[s]; -} -uint16 getIINCHIP_TxMAX(uint8 s) -{ - return SSIZE[s]; -} -uint16 getIINCHIP_RxMASK(uint8 s) -{ - return RMASK[s]; -} -uint16 getIINCHIP_TxMASK(uint8 s) -{ - return SMASK[s]; -} -uint16 getIINCHIP_RxBASE(uint8 s) -{ - return RBUFBASEADDRESS[s]; -} -uint16 getIINCHIP_TxBASE(uint8 s) -{ - return SBUFBASEADDRESS[s]; -} - - /** -@brief This function writes the data into W5100 registers. -*/ -uint8 IINCHIP_WRITE(uint16 addr,uint8 data) -{ -// DIRECT MODE I/F -#if (__DEF_IINCHIP_BUS__ == __DEF_IINCHIP_DIRECT_MODE__) - IINCHIP_ISR_DISABLE(); - *((vuint8*)(addr)) = data; - IINCHIP_ISR_ENABLE(); -#elif(__DEF_IINCHIP_BUS__ == __DEF_IINCHIP_INDIRECT_MODE__) /* INDIRECT MODE I/F */ - IINCHIP_ISR_DISABLE(); - *((vuint8*)IDM_AR0) = (uint8)((addr & 0xFF00) >> 8); - *((vuint8*)IDM_AR1) = (uint8)(addr & 0x00FF); - *((vuint8*)IDM_DR) = data; - IINCHIP_ISR_ENABLE(); -#elif (__DEF_IINCHIP_BUS__ == __DEF_IINCHIP_SPI_MODE__) - IINCHIP_ISR_DISABLE(); - IINCHIP_SpiInit(); - - //SPI MODE I/F - IINCHIP_CSoff(); // CS=0, SPI start - - IINCHIP_SpiSendData(0xF0); - IINCHIP_SpiSendData((addr & 0xFF00) >> 8); - IINCHIP_SpiSendData(addr & 0x00FF); - IINCHIP_SpiSendData(data); - - IINCHIP_CSon(); - - IINCHIP_ISR_ENABLE(); -#else - #error "unknown bus type" -#endif - return 1; -} - - -/** -@brief This function reads the value from W5100 registers. -*/ -uint8 IINCHIP_READ(uint16 addr) -{ - uint8 data; - -// DIRECT MODE I/F - -#if (__DEF_IINCHIP_BUS__ == __DEF_IINCHIP_DIRECT_MODE__) - IINCHIP_ISR_DISABLE(); - data = *((vuint8*)(addr)); - IINCHIP_ISR_ENABLE(); -#elif(__DEF_IINCHIP_BUS__ == __DEF_IINCHIP_INDIRECT_MODE__) - IINCHIP_ISR_DISABLE(); - *((vuint8*)IDM_AR0) = (uint8)((addr & 0xFF00) >> 8); - *((vuint8*)IDM_AR1) = (uint8)(addr & 0x00FF); - data = *((vuint8*)IDM_DR); - IINCHIP_ISR_ENABLE(); - -#elif (__DEF_IINCHIP_BUS__ == __DEF_IINCHIP_SPI_MODE__) - IINCHIP_ISR_DISABLE(); - IINCHIP_SpiInit(); - IINCHIP_CSoff(); // CS=0, SPI start - - IINCHIP_SpiSendData(0x0F); - IINCHIP_SpiSendData((addr & 0xFF00) >> 8); - IINCHIP_SpiSendData(addr & 0x00FF); - - - IINCHIP_SpiSendData(0); - data = IINCHIP_SpiRecvData(); - - IINCHIP_CSon(); // SPI end - IINCHIP_ISR_ENABLE(); -#else - #error "unknown bus type" -#endif - return data; -} - - -/** -@brief This function writes into W5100 memory(Buffer) -*/ -uint16 wiz_write_buf(uint16 addr,uint8* buf,uint16 len) -{ -#if (__DEF_IINCHIP_BUS__ == __DEF_IINCHIP_DIRECT_MODE__) - IINCHIP_ISR_DISABLE(); - memcpy((uint8 *)addr, buf, len); - IINCHIP_ISR_ENABLE(); -#elif (__DEF_IINCHIP_BUS__ == __DEF_IINCHIP_INDIRECT_MODE__) - uint16 idx = 0; - IINCHIP_ISR_DISABLE(); - *((vuint8*)IDM_AR0) = (uint8)((addr & 0xFF00) >> 8); - *((vuint8*)IDM_AR1) = (uint8)(addr & 0x00FF); - for (idx = 0; idx < len ; idx++) *((vuint8*)IDM_DR) = buf[idx]; - IINCHIP_ISR_ENABLE(); -#elif (__DEF_IINCHIP_BUS__ == __DEF_IINCHIP_SPI_MODE__) - uint16 idx = 0; - - IINCHIP_ISR_DISABLE(); - IINCHIP_SpiInit(); - - //SPI MODE I/F - for(idx=0;idx> 8); - IINCHIP_SpiSendData((addr+idx) & 0x00FF); - IINCHIP_SpiSendData(buf[idx]); - - IINCHIP_CSon(); // CS=0, SPI end - } - - IINCHIP_ISR_ENABLE(); -#else - #error "unknown bus type" -#endif - return len; -} - - -/** -@brief This function reads into W5100 memory(Buffer) -*/ -uint16 wiz_read_buf(uint16 addr, uint8* buf,uint16 len) -{ -#if (__DEF_IINCHIP_BUS__ == __DEF_IINCHIP_DIRECT_MODE__) - IINCHIP_ISR_DISABLE(); - memcpy(buf, (uint8 *)addr, len); - IINCHIP_ISR_ENABLE(); -#elif(__DEF_IINCHIP_BUS__ == __DEF_IINCHIP_INDIRECT_MODE__) - uint16 idx = 0; - IINCHIP_ISR_DISABLE(); - *((vuint8*)IDM_AR0) = (uint8)((addr & 0xFF00) >> 8); - *((vuint8*)IDM_AR1) = (uint8)(addr & 0x00FF); - for (idx = 0; idx < len ; idx++) buf[idx] = *((vuint8*)IDM_DR); - IINCHIP_ISR_ENABLE(); -#elif (__DEF_IINCHIP_BUS__ == __DEF_IINCHIP_SPI_MODE__) - uint16 idx = 0; - IINCHIP_ISR_DISABLE(); - - IINCHIP_SpiInit(); - - for (idx=0; idx> 8); - IINCHIP_SpiSendData((addr+idx) & 0x00FF); - - - IINCHIP_SpiSendData(0); - buf[idx] = IINCHIP_SpiRecvData(); - - IINCHIP_CSon(); // CS=0, SPI end - } - - IINCHIP_ISR_ENABLE(); -#else - #error "unknown bus type" -#endif - return len; -} - - -/** -@brief Socket interrupt routine -*/ -#ifdef __DEF_IINCHIP_INT__ -ISR(INT4_vect) -{ - uint8 int_val; - IINCHIP_ISR_DISABLE(); - int_val = IINCHIP_READ(IR); - - /* +200801[bj] process all of interupt */ - do { - /*---*/ - - if (int_val & IR_CONFLICT) - { - printf("IP conflict : %.2x\r\n", int_val); - } - if (int_val & IR_UNREACH) - { - printf("INT Port Unreachable : %.2x\r\n", int_val); - printf("UIPR0 : %d.%d.%d.%d\r\n", IINCHIP_READ(UIPR0), IINCHIP_READ(UIPR0+1), IINCHIP_READ(UIPR0+2), IINCHIP_READ(UIPR0+3)); - printf("UPORT0 : %.2x %.2x\r\n", IINCHIP_READ(UPORT0), IINCHIP_READ(UPORT0+1)); - } - - /* +200801[bj] interrupt clear */ - IINCHIP_WRITE(IR, 0xf0); - /*---*/ - - if (int_val & IR_SOCK(0)) - { - /* +-200801[bj] save interrupt value*/ - I_STATUS[0] |= IINCHIP_READ(Sn_IR(0)); // can be come to over two times. - IINCHIP_WRITE(Sn_IR(0), I_STATUS[0]); - /*---*/ - } - if (int_val & IR_SOCK(1)) - { - /* +-200801[bj] save interrupt value*/ - I_STATUS[1] |= IINCHIP_READ(Sn_IR(1)); - IINCHIP_WRITE(Sn_IR(1), I_STATUS[1]); - /*---*/ - } - if (int_val & IR_SOCK(2)) - { - /* +-200801[bj] save interrupt value*/ - I_STATUS[2] |= IINCHIP_READ(Sn_IR(2)); - IINCHIP_WRITE(Sn_IR(2), I_STATUS[2]); - /*---*/ - } - if (int_val & IR_SOCK(3)) - { - /* +-200801[bj] save interrupt value*/ - I_STATUS[3] |= IINCHIP_READ(Sn_IR(3)); - IINCHIP_WRITE(Sn_IR(3), I_STATUS[3]); - /*---*/ - } - - /* +-200801[bj] re-read interrupt value*/ - int_val = IINCHIP_READ(IR); - - /* +200801[bj] if exist, contiue to process */ - } while (int_val != 0x00); - /*---*/ - - IINCHIP_ISR_ENABLE(); -} -#endif - -/** -@brief This function is for resetting of the iinchip. Initializes the iinchip to work in whether DIRECT or INDIRECT mode -*/ -void iinchip_init(void) -{ - setMR( MR_RST ); -#if (__DEF_IINCHIP_BUS__ == __DEF_IINCHIP_INDIRECT_MODE__) - setMR( MR_IND | MR_AI ); -#ifdef __DEF_IINCHIP_DBG__ - printf("MR value is %d \r\n",IINCHIP_READ(MR)); -#endif -#endif -} - - -/** -@brief This function set the transmit & receive buffer size as per the channels is used - -Note for TMSR and RMSR bits are as follows\n -bit 1-0 : memory size of channel #0 \n -bit 3-2 : memory size of channel #1 \n -bit 5-4 : memory size of channel #2 \n -bit 7-6 : memory size of channel #3 \n\n -Maximum memory size for Tx, Rx in the W5100 is 8K Bytes,\n -In the range of 8KBytes, the memory size could be allocated dynamically by each channel.\n -Be attentive to sum of memory size shouldn't exceed 8Kbytes\n -and to data transmission and receiption from non-allocated channel may cause some problems.\n -If the 8KBytes memory is already assigned to centain channel, \n -other 3 channels couldn't be used, for there's no available memory.\n -If two 4KBytes memory are assigned to two each channels, \n -other 2 channels couldn't be used, for there's no available memory.\n -*/ -void sysinit( - uint8 tx_size, /**< tx_size Tx memory size (00 - 1KByte, 01- 2KBtye, 10 - 4KByte, 11 - 8KByte) */ - uint8 rx_size /**< rx_size Rx memory size (00 - 1KByte, 01- 2KBtye, 10 - 4KByte, 11 - 8KByte) */ - ) -{ - int16 i; - int16 ssum,rsum; - -#ifdef __DEF_IINCHIP_DBG__ - printf("sysinit()\r\n"); -#endif - - ssum = 0; - rsum = 0; - - IINCHIP_WRITE(TMSR,tx_size); /* Set Tx memory size for each channel */ - IINCHIP_WRITE(RMSR,rx_size); /* Set Rx memory size for each channel */ - - SBUFBASEADDRESS[0] = (uint16)(__DEF_IINCHIP_MAP_TXBUF__); /* Set base address of Tx memory for channel #0 */ - RBUFBASEADDRESS[0] = (uint16)(__DEF_IINCHIP_MAP_RXBUF__); /* Set base address of Rx memory for channel #0 */ - -#ifdef __DEF_IINCHIP_DBG__ - printf("Channel : SEND MEM SIZE : RECV MEM SIZE\r\n"); -#endif - - for (i = 0 ; i < MAX_SOCK_NUM; i++) // Set the size, masking and base address of Tx & Rx memory by each channel - { - SSIZE[i] = (int16)(0); - RSIZE[i] = (int16)(0); - if (ssum < 8192) - { - switch((tx_size >> i*2) & 0x03) // Set Tx memory size - { - case 0: - SSIZE[i] = (int16)(1024); - SMASK[i] = (uint16)(0x03FF); - break; - case 1: - SSIZE[i] = (int16)(2048); - SMASK[i] = (uint16)(0x07FF); - break; - case 2: - SSIZE[i] = (int16)(4096); - SMASK[i] = (uint16)(0x0FFF); - break; - case 3: - SSIZE[i] = (int16)(8192); - SMASK[i] = (uint16)(0x1FFF); - break; - } - } - if (rsum < 8192) - { - switch((rx_size >> i*2) & 0x03) // Set Rx memory size - { - case 0: - RSIZE[i] = (int16)(1024); - RMASK[i] = (uint16)(0x03FF); - break; - case 1: - RSIZE[i] = (int16)(2048); - RMASK[i] = (uint16)(0x07FF); - break; - case 2: - RSIZE[i] = (int16)(4096); - RMASK[i] = (uint16)(0x0FFF); - break; - case 3: - RSIZE[i] = (int16)(8192); - RMASK[i] = (uint16)(0x1FFF); - break; - } - } - ssum += SSIZE[i]; - rsum += RSIZE[i]; - - if (i != 0) // Sets base address of Tx and Rx memory for channel #1,#2,#3 - { - SBUFBASEADDRESS[i] = SBUFBASEADDRESS[i-1] + SSIZE[i-1]; - RBUFBASEADDRESS[i] = RBUFBASEADDRESS[i-1] + RSIZE[i-1]; - } -#ifdef __DEF_IINCHIP_DBG__ - printf("%d : %.4x : %.4x : %.4x : %.4x\r\n", i, (uint16)SBUFBASEADDRESS[i], (uint16)RBUFBASEADDRESS[i], SSIZE[i], RSIZE[i]); -#endif - } -} - - -void setMR(uint8 val) -{ - -#if (__DEF_IINCHIP_BUS__ == __DEF_IINCHIP_INDIRECT_MODE__) - *((volatile uint8*)(MR)) = val; -#else - /* DIRECT ACCESS */ - IINCHIP_WRITE(MR,val); -#endif -} - - -/** -@brief This function sets up gateway IP address. -*/ -void setGAR( - uint8 * addr /**< a pointer to a 4 -byte array responsible to set the Gateway IP address. */ - ) -{ - IINCHIP_WRITE((GAR0 + 0),addr[0]); - IINCHIP_WRITE((GAR0 + 1),addr[1]); - IINCHIP_WRITE((GAR0 + 2),addr[2]); - IINCHIP_WRITE((GAR0 + 3),addr[3]); -} -void getGWIP(uint8 * addr) -{ - addr[0] = IINCHIP_READ((GAR0 + 0)); - addr[1] = IINCHIP_READ((GAR0 + 1)); - addr[2] = IINCHIP_READ((GAR0 + 2)); - addr[3] = IINCHIP_READ((GAR0 + 3)); -} - - -/** -@brief It sets up SubnetMask address -*/ -void setSUBR( - uint8 * addr /**< a pointer to a 4 -byte array responsible to set the SubnetMask address */ - ) -{ - IINCHIP_WRITE((SUBR0 + 0),addr[0]); - IINCHIP_WRITE((SUBR0 + 1),addr[1]); - IINCHIP_WRITE((SUBR0 + 2),addr[2]); - IINCHIP_WRITE((SUBR0 + 3),addr[3]); -} - - -/** -@brief This function sets up MAC address. -*/ -void setSHAR( - uint8 * addr /**< a pointer to a 6 -byte array responsible to set the MAC address. */ - ) -{ - IINCHIP_WRITE((SHAR0 + 0),addr[0]); - IINCHIP_WRITE((SHAR0 + 1),addr[1]); - IINCHIP_WRITE((SHAR0 + 2),addr[2]); - IINCHIP_WRITE((SHAR0 + 3),addr[3]); - IINCHIP_WRITE((SHAR0 + 4),addr[4]); - IINCHIP_WRITE((SHAR0 + 5),addr[5]); -} - - -/** -@brief This function sets up Source IP address. -*/ -void setSIPR( - uint8 * addr /**< a pointer to a 4 -byte array responsible to set the Source IP address. */ - ) -{ - IINCHIP_WRITE((SIPR0 + 0),addr[0]); - IINCHIP_WRITE((SIPR0 + 1),addr[1]); - IINCHIP_WRITE((SIPR0 + 2),addr[2]); - IINCHIP_WRITE((SIPR0 + 3),addr[3]); -} - - -/** -@brief This function gets Interrupt register in common register. - */ -uint8 getIR( void ) -{ - return IINCHIP_READ(IR); -} - - - -/** -@brief This function sets up Retransmission time. - -If there is no response from the peer or delay in response then retransmission -will be there as per RTR (Retry Time-value Register)setting -*/ -void setRTR(uint16 timeout) -{ - IINCHIP_WRITE(RTR0,(uint8)((timeout & 0xff00) >> 8)); - IINCHIP_WRITE((RTR0 + 1),(uint8)(timeout & 0x00ff)); -} - - -/** -@brief This function set the number of Retransmission. - -If there is no response from the peer or delay in response then recorded time -as per RTR & RCR register seeting then time out will occur. -*/ -void setRCR(uint8 retry) -{ - IINCHIP_WRITE(RCR,retry); -} - - -/** -@brief This function set the interrupt mask Enable/Disable appropriate Interrupt. ('1' : interrupt enable) - -If any bit in IMR is set as '0' then there is not interrupt signal though the bit is -set in IR register. -*/ -void setIMR(uint8 mask) -{ - IINCHIP_WRITE(IMR,mask); // must be setted 0x10. -} - - -/** -@brief These below functions are used to get the Gateway, SubnetMask - and Source Hardware Address (MAC Address) and Source IP address -*/ -void getGAR(uint8 * addr) -{ - addr[0] = IINCHIP_READ(GAR0); - addr[1] = IINCHIP_READ(GAR0+1); - addr[2] = IINCHIP_READ(GAR0+2); - addr[3] = IINCHIP_READ(GAR0+3); -} -void getSUBR(uint8 * addr) -{ - addr[0] = IINCHIP_READ(SUBR0); - addr[1] = IINCHIP_READ(SUBR0+1); - addr[2] = IINCHIP_READ(SUBR0+2); - addr[3] = IINCHIP_READ(SUBR0+3); -} -void getSHAR(uint8 * addr) -{ - addr[0] = IINCHIP_READ(SHAR0); - addr[1] = IINCHIP_READ(SHAR0+1); - addr[2] = IINCHIP_READ(SHAR0+2); - addr[3] = IINCHIP_READ(SHAR0+3); - addr[4] = IINCHIP_READ(SHAR0+4); - addr[5] = IINCHIP_READ(SHAR0+5); -} -void getSIPR(uint8 * addr) -{ - addr[0] = IINCHIP_READ(SIPR0); - addr[1] = IINCHIP_READ(SIPR0+1); - addr[2] = IINCHIP_READ(SIPR0+2); - addr[3] = IINCHIP_READ(SIPR0+3); -} - - -/** -@brief These below functions are used to get the Destination Hardware Address (MAC Address), Destination IP address and Destination Port. -*/ -void getSn_DHAR(SOCKET s, uint8 * addr) -{ - addr[0] = IINCHIP_READ(Sn_DHAR0(s)); - addr[1] = IINCHIP_READ(Sn_DHAR0(s)+1); - addr[2] = IINCHIP_READ(Sn_DHAR0(s)+2); - addr[3] = IINCHIP_READ(Sn_DHAR0(s)+3); - addr[4] = IINCHIP_READ(Sn_DHAR0(s)+4); - addr[5] = IINCHIP_READ(Sn_DHAR0(s)+5); -} -void setSn_DHAR(SOCKET s, uint8 * addr) -{ - IINCHIP_WRITE((Sn_DHAR0(s) + 0),addr[0]); - IINCHIP_WRITE((Sn_DHAR0(s) + 1),addr[1]); - IINCHIP_WRITE((Sn_DHAR0(s) + 2),addr[2]); - IINCHIP_WRITE((Sn_DHAR0(s) + 3),addr[3]); - IINCHIP_WRITE((Sn_DHAR0(s) + 4),addr[4]); - IINCHIP_WRITE((Sn_DHAR0(s) + 5),addr[5]); -} -void getSn_DIPR(SOCKET s, uint8 * addr) -{ - addr[0] = IINCHIP_READ(Sn_DIPR0(s)); - addr[1] = IINCHIP_READ(Sn_DIPR0(s)+1); - addr[2] = IINCHIP_READ(Sn_DIPR0(s)+2); - addr[3] = IINCHIP_READ(Sn_DIPR0(s)+3); -} -void setSn_DIPR(SOCKET s, uint8 * addr) -{ - IINCHIP_WRITE((Sn_DIPR0(s) + 0),addr[0]); - IINCHIP_WRITE((Sn_DIPR0(s) + 1),addr[1]); - IINCHIP_WRITE((Sn_DIPR0(s) + 2),addr[2]); - IINCHIP_WRITE((Sn_DIPR0(s) + 3),addr[3]); -} -void getSn_DPORT(SOCKET s, uint8 * addr) -{ - addr[0] = IINCHIP_READ(Sn_DPORT0(s)); - addr[1] = IINCHIP_READ(Sn_DPORT0(s)+1); -} -void setSn_DPORT(SOCKET s, uint8 * addr) -{ - IINCHIP_WRITE((Sn_DPORT0(s) + 0),addr[0]); - IINCHIP_WRITE((Sn_DPORT0(s) + 1),addr[1]); -} - - -/** -@brief This sets the maximum segment size of TCP in Active Mode), while in Passive Mode this is set by peer -*/ -void setSn_MSS(SOCKET s, uint16 Sn_MSSR0) -{ - IINCHIP_WRITE(Sn_MSSR0(s),(uint8)((Sn_MSSR0 & 0xff00) >> 8)); - IINCHIP_WRITE((Sn_MSSR0(s) + 1),(uint8)(Sn_MSSR0 & 0x00ff)); -} - -void setSn_TTL(SOCKET s, uint8 ttl) -{ - IINCHIP_WRITE(Sn_TTL(s), ttl); -} - - -/** -@brief These below function is used to setup the Protocol Field of IP Header when - executing the IP Layer RAW mode. -*/ -void setSn_PROTO(SOCKET s, uint8 proto) -{ - IINCHIP_WRITE(Sn_PROTO(s),proto); -} - - -/** -@brief get socket interrupt status - -These below functions are used to read the Interrupt & Soket Status register -*/ -uint8 getSn_IR(SOCKET s) -{ - return IINCHIP_READ(Sn_IR(s)); -} - - -/** -@brief get socket status -*/ -uint8 getSn_SR(SOCKET s) -{ - return IINCHIP_READ(Sn_SR(s)); -} - - -/** -@brief get socket TX free buf size - -This gives free buffer size of transmit buffer. This is the data size that user can transmit. -User shuold check this value first and control the size of transmitting data -*/ -uint16 getSn_TX_FSR(SOCKET s) -{ - uint16 val=0,val1=0; - do - { - val1 = IINCHIP_READ(Sn_TX_FSR0(s)); - val1 = (val1 << 8) + IINCHIP_READ(Sn_TX_FSR0(s) + 1); - if (val1 != 0) - { - val = IINCHIP_READ(Sn_TX_FSR0(s)); - val = (val << 8) + IINCHIP_READ(Sn_TX_FSR0(s) + 1); - } - } while (val != val1); - return val; -} - - -/** -@brief get socket RX recv buf size - -This gives size of received data in receive buffer. -*/ -uint16 getSn_RX_RSR(SOCKET s) -{ - uint16 val=0,val1=0; - do - { - val1 = IINCHIP_READ(Sn_RX_RSR0(s)); - val1 = (val1 << 8) + IINCHIP_READ(Sn_RX_RSR0(s) + 1); - if(val1 != 0) - { - val = IINCHIP_READ(Sn_RX_RSR0(s)); - val = (val << 8) + IINCHIP_READ(Sn_RX_RSR0(s) + 1); - } - } while (val != val1); - return val; -} - - -/** -@brief This function is being called by send() and sendto() function also. - -This function read the Tx write pointer register and after copy the data in buffer update the Tx write pointer -register. User should read upper byte first and lower byte later to get proper value. -*/ -void send_data_processing(SOCKET s, uint8 *data, uint16 len) -{ - uint16 ptr; - ptr = IINCHIP_READ(Sn_TX_WR0(s)); - ptr = ((ptr & 0x00ff) << 8) + IINCHIP_READ(Sn_TX_WR0(s) + 1); - write_data(s, data, (uint8 *)(ptr), len); - ptr += len; - IINCHIP_WRITE(Sn_TX_WR0(s),(uint8)((ptr & 0xff00) >> 8)); - IINCHIP_WRITE((Sn_TX_WR0(s) + 1),(uint8)(ptr & 0x00ff)); -} - - -/** -@brief This function is being called by recv() also. - -This function read the Rx read pointer register -and after copy the data from receive buffer update the Rx write pointer register. -User should read upper byte first and lower byte later to get proper value. -*/ -void recv_data_processing(SOCKET s, uint8 *data, uint16 len) -{ - uint16 ptr; - ptr = IINCHIP_READ(Sn_RX_RD0(s)); - ptr = ((ptr & 0x00ff) << 8) + IINCHIP_READ(Sn_RX_RD0(s) + 1); -#ifdef __DEF_IINCHIP_DBG__ - printf("ISR_RX: rd_ptr : %.4x\r\n", ptr); -#endif - read_data(s, (uint8 *)ptr, data, len); // read data - ptr += len; - IINCHIP_WRITE(Sn_RX_RD0(s),(uint8)((ptr & 0xff00) >> 8)); - IINCHIP_WRITE((Sn_RX_RD0(s) + 1),(uint8)(ptr & 0x00ff)); -} - - -/** -@brief for copy the data form application buffer to Transmite buffer of the chip. - -This function is being used for copy the data form application buffer to Transmite -buffer of the chip. It calculate the actual physical address where one has to write -the data in transmite buffer. Here also take care of the condition while it exceed -the Tx memory uper-bound of socket. -*/ -void write_data(SOCKET s, vuint8 * src, vuint8 * dst, uint16 len) -{ - uint16 size; - uint16 dst_mask; - uint8 * dst_ptr; - - dst_mask = (uint16)dst & getIINCHIP_TxMASK(s); - dst_ptr = (uint8 *)(getIINCHIP_TxBASE(s) + dst_mask); - - if (dst_mask + len > getIINCHIP_TxMAX(s)) - { - size = getIINCHIP_TxMAX(s) - dst_mask; - wiz_write_buf((uint16)dst_ptr, (uint8*)src, size); - src += size; - size = len - size; - dst_ptr = (uint8 *)(getIINCHIP_TxBASE(s)); - wiz_write_buf((uint16)dst_ptr, (uint8*)src, size); - } - else - { - wiz_write_buf((uint16)dst_ptr, (uint8*)src, len); - } -} - - -/** -@brief This function is being used for copy the data form Receive buffer of the chip to application buffer. - -It calculate the actual physical address where one has to read -the data from Receive buffer. Here also take care of the condition while it exceed -the Rx memory uper-bound of socket. -*/ -void read_data(SOCKET s, vuint8 * src, vuint8 * dst, uint16 len) -{ - uint16 size; - uint16 src_mask; - uint8 * src_ptr; - - src_mask = (uint16)src & getIINCHIP_RxMASK(s); - src_ptr = (uint8 *)(getIINCHIP_RxBASE(s) + src_mask); - - if( (src_mask + len) > getIINCHIP_RxMAX(s) ) - { - size = getIINCHIP_RxMAX(s) - src_mask; - wiz_read_buf((uint16)src_ptr, (uint8*)dst,size); - dst += size; - size = len - size; - src_ptr = (uint8 *)(getIINCHIP_RxBASE(s)); - wiz_read_buf((uint16)src_ptr, (uint8*) dst,size); - } - else - { - wiz_read_buf((uint16)src_ptr, (uint8*) dst,len); - } -} - - -#ifdef __DEF_IINCHIP_PPP__ -#define PPP_OPTION_BUF_LEN 64 - -uint8 pppinit_in(uint8 * id, uint8 idlen, uint8 * passwd, uint8 passwdlen); - - -/** -@brief make PPPoE connection -@return 1 => success to connect, 2 => Auth fail, 3 => timeout, 4 => Auth type not support - -*/ -uint8 pppinit(uint8 * id, uint8 idlen, uint8 * passwd, uint8 passwdlen) -{ - uint8 ret; - uint8 isr; - - // PHASE0. W5100 PPPoE(ADSL) setup - // enable pppoe mode - printf("-- PHASE 0. W5100 PPPoE(ADSL) setup process --\r\n"); - printf("\r\n"); - IINCHIP_WRITE(MR,IINCHIP_READ(MR) | MR_PPPOE); - - // open socket in pppoe mode - isr = IINCHIP_READ(Sn_IR(0));// first clear isr(0), W5100 at present time - IINCHIP_WRITE(Sn_IR(0),isr); - - IINCHIP_WRITE(PTIMER,200); // 5sec timeout - IINCHIP_WRITE(PMAGIC,0x01); // magic number - IINCHIP_WRITE(Sn_MR(0),Sn_MR_PPPOE); - IINCHIP_WRITE(Sn_CR(0),Sn_CR_OPEN); - - /* +20071122[chungs]:wait to process the command... */ - while( IINCHIP_READ(Sn_CR(0)) ) - ; - /* ------- */ - - ret = pppinit_in(id, idlen, passwd, passwdlen); - - // close ppp connection socket - /* +200801 (hwkim) */ - close(0); - /* ------- */ - - return ret; -} - - -uint8 pppinit_in(uint8 * id, uint8 idlen, uint8 * passwd, uint8 passwdlen) -{ - uint8 loop_idx = 0; - uint8 isr = 0; - uint8 buf[PPP_OPTION_BUF_LEN]; - uint16 len; - uint8 str[PPP_OPTION_BUF_LEN]; - uint8 str_idx,dst_idx; - - // PHASE1. PPPoE Discovery - // start to connect pppoe connection - printf("-- PHASE 1. PPPoE Discovery process --"); - printf(" ok\r\n"); - printf("\r\n"); - IINCHIP_WRITE(Sn_CR(0),Sn_CR_PCON); - /* +20071122[chungs]:wait to process the command... */ - while( IINCHIP_READ(Sn_CR(0)) ) - ; - /* ------- */ - - wait_10ms(100); - - loop_idx = 0; - //check whether PPPoE discovery end or not - while (!(IINCHIP_READ(Sn_IR(0)) & Sn_IR_PNEXT)) - { - printf("."); - if (loop_idx++ == 10) // timeout - { - printf("timeout before LCP\r\n"); - return 3; - } - wait_10ms(100); - } - - /* +200801[bj] clear interrupt value*/ - IINCHIP_WRITE(Sn_IR(0), 0xff); - /*---*/ - - // PHASE2. LCP process - printf("-- PHASE 2. LCP process --"); - - // send LCP Request - { - // Magic number option - // option format (type value + length value + data) - // write magic number value - buf[0] = 0x05; // type value - buf[1] = 0x06; // length value - buf[2] = 0x01; buf[3] = 0x01; buf[4] = 0x01; buf[5]= 0x01; // data - // for MRU option, 1492 0x05d4 - // buf[6] = 0x01; buf[7] = 0x04; buf[8] = 0x05; buf[9] = 0xD4; - } - send_data_processing(0, buf, 0x06); - IINCHIP_WRITE(Sn_CR(0),Sn_CR_PCR); // send request - /* +20071122[chungs]:wait to process the command... */ - while( IINCHIP_READ(Sn_CR(0)) ) - ; - /* ------- */ - - wait_10ms(100); - - while (!((isr = IINCHIP_READ(Sn_IR(0))) & Sn_IR_PNEXT)) - { - if (isr & Sn_IR_PRECV) // Not support option - { - /* +200801[bj] clear interrupt value*/ - IINCHIP_WRITE(Sn_IR(0), Sn_IR_PRECV); - /*---*/ - len = getSn_RX_RSR(0); - if ( len > 0 ) - { - recv_data_processing(0, str, len); - IINCHIP_WRITE(Sn_CR(0),Sn_CR_RECV); - /* +20071122[chungs]:wait to process the command... */ - while( IINCHIP_READ(Sn_CR(0)) ) - ; - /* ------- */ - - // for debug - //printf("LCP proc\r\n"); for (i = 0; i < len; i++) printf ("%02x ", str[i]); printf("\r\n"); - // get option length - len = str[4]; len = ((len & 0x00ff) << 8) + str[5]; - len += 2; - str_idx = 6; dst_idx = 0; // ppp header is 6 byte, so starts at 6. - do - { - if ((str[str_idx] == 0x01) || (str[str_idx] == 0x02) || (str[str_idx] == 0x03) || (str[str_idx] == 0x05)) - { - // skip as length of support option. str_idx+1 is option's length. - str_idx += str[str_idx+1]; - } - else - { - // not support option , REJECT - memcpy((uint8 *)(buf+dst_idx), (uint8 *)(str+str_idx), str[str_idx+1]); - dst_idx += str[str_idx+1]; str_idx += str[str_idx+1]; - } - } while (str_idx != len); - // for debug - // printf("LCP dst proc\r\n"); for (i = 0; i < dst_idx; i++) printf ("%02x ", dst[i]); printf("\r\n"); - - // send LCP REJECT packet - send_data_processing(0, buf, dst_idx); - IINCHIP_WRITE(Sn_CR(0),Sn_CR_PCJ); - /* +20071122[chungs]:wait to process the command... */ - while( IINCHIP_READ(Sn_CR(0)) ) - ; - /* ------- */ - } - } - printf("."); - if (loop_idx++ == 10) // timeout - { - printf("timeout after LCP\r\n"); - return 3; - } - wait_10ms(100); - } - printf(" ok\r\n"); - printf("\r\n"); - - /* +200801[bj] clear interrupt value*/ - IINCHIP_WRITE(Sn_IR(0), 0xff); - /*---*/ - - printf("-- PHASE 3. PPPoE(ADSL) Authentication mode --\r\n"); - printf("Authentication protocol : %.2x %.2x, ", IINCHIP_READ(PATR0), IINCHIP_READ(PATR0+1)); - - loop_idx = 0; - if (IINCHIP_READ(PATR0) == 0xc0 && IINCHIP_READ(PATR0+1) == 0x23) - { - printf("PAP\r\n"); // in case of adsl normally supports PAP. - // send authentication data - // copy (idlen + id + passwdlen + passwd) - buf[loop_idx] = idlen; loop_idx++; - memcpy((uint8 *)(buf+loop_idx), (uint8 *)(id), idlen); loop_idx += idlen; - buf[loop_idx] = passwdlen; loop_idx++; - memcpy((uint8 *)(buf+loop_idx), (uint8 *)(passwd), passwdlen); loop_idx += passwdlen; - send_data_processing(0, buf, loop_idx); - IINCHIP_WRITE(Sn_CR(0),Sn_CR_PCR); - /* +20071122[chungs]:wait to process the command... */ - while( IINCHIP_READ(Sn_CR(0)) ) - ; - /* ------- */ - wait_10ms(100); - } - else if (IINCHIP_READ(PATR0) == 0xc2 && IINCHIP_READ(PATR0+1) == 0x23) - { - uint8 chal_len; - md5_ctx context; - uint8 digest[16]; - - len = getSn_RX_RSR(0); - if ( len > 0 ) - { - recv_data_processing(0, str, len); - IINCHIP_WRITE(Sn_CR(0),Sn_CR_RECV); - /* +20071122[chungs]:wait to process the command... */ - while( IINCHIP_READ(Sn_CR(0)) ) - ; - /* ------- */ -#ifdef __DEF_IINCHIP_DBG__ - printf("recv CHAP\r\n"); - { - int16 i; - - for (i = 0; i < 32; i++) - printf ("%02x ", str[i]); - } - printf("\r\n"); -#endif -// str is C2 23 xx CHAL_ID xx xx CHAP_LEN CHAP_DATA -// index 0 1 2 3 4 5 6 7 ... - - memset(buf,0x00,64); - buf[loop_idx] = str[3]; loop_idx++; // chal_id - memcpy((uint8 *)(buf+loop_idx), (uint8 *)(passwd), passwdlen); loop_idx += passwdlen; //passwd - chal_len = str[6]; // chal_id - memcpy((uint8 *)(buf+loop_idx), (uint8 *)(str+7), chal_len); loop_idx += chal_len; //challenge - buf[loop_idx] = 0x80; -#ifdef __DEF_IINCHIP_DBG__ - printf("CHAP proc d1\r\n"); - { - int16 i; - for (i = 0; i < 64; i++) - printf ("%02x ", buf[i]); - } - printf("\r\n"); -#endif - - md5_init(&context); - md5_update(&context, buf, loop_idx); - md5_final(digest, &context); - -#ifdef __DEF_IINCHIP_DBG__ - printf("CHAP proc d1\r\n"); - { - int16 i; - for (i = 0; i < 16; i++) - printf ("%02x", digest[i]); - } - printf("\r\n"); -#endif - loop_idx = 0; - buf[loop_idx] = 16; loop_idx++; // hash_len - memcpy((uint8 *)(buf+loop_idx), (uint8 *)(digest), 16); loop_idx += 16; // hashed value - memcpy((uint8 *)(buf+loop_idx), (uint8 *)(id), idlen); loop_idx += idlen; // id - send_data_processing(0, buf, loop_idx); - IINCHIP_WRITE(Sn_CR(0),Sn_CR_PCR); - /* +20071122[chungs]:wait to process the command... */ - while( IINCHIP_READ(Sn_CR(0)) ) - ; - /* ------- */ - wait_10ms(100); - } - } - else - { - printf("Not support\r\n"); -#ifdef __DEF_IINCHIP_DBG__ - printf("Not support PPP Auth type: %.2x%.2x\r\n",IINCHIP_READ(PATR0), IINCHIP_READ(PATR0+1)); -#endif - return 4; - } - printf("\r\n"); - - printf("-- Waiting for PPPoE server's admission --"); - loop_idx = 0; - while (!((isr = IINCHIP_READ(Sn_IR(0))) & Sn_IR_PNEXT)) - { - if (isr & Sn_IR_PFAIL) - { - /* +200801[bj] clear interrupt value*/ - IINCHIP_WRITE(Sn_IR(0), 0xff); - /*---*/ - printf("failed\r\nReinput id, password..\r\n"); - return 2; - } - printf("."); - if (loop_idx++ == 10) // timeout - { - /* +200801[bj] clear interrupt value*/ - IINCHIP_WRITE(Sn_IR(0), 0xff); - /*---*/ - printf("timeout after PAP\r\n"); - return 3; - } - wait_10ms(100); - } - /* +200801[bj] clear interrupt value*/ - IINCHIP_WRITE(Sn_IR(0), 0xff); - /*---*/ - printf("ok\r\n"); - printf("\r\n"); - printf("-- PHASE 4. IPCP process --"); - // IP Address - buf[0] = 0x03; buf[1] = 0x06; buf[2] = 0x00; buf[3] = 0x00; buf[4] = 0x00; buf[5] = 0x00; - send_data_processing(0, buf, 6); - IINCHIP_WRITE(Sn_CR(0),Sn_CR_PCR); - /* +20071122[chungs]:wait to process the command... */ - while( IINCHIP_READ(Sn_CR(0)) ) - ; - /* ------- */ - wait_10ms(100); - - loop_idx = 0; - while (1) - { - if (IINCHIP_READ(Sn_IR(0)) & Sn_IR_PRECV) - { - /* +200801[bj] clear interrupt value*/ - IINCHIP_WRITE(Sn_IR(0), 0xff); - /*---*/ - len = getSn_RX_RSR(0); - if ( len > 0 ) - { - recv_data_processing(0, str, len); - IINCHIP_WRITE(Sn_CR(0),Sn_CR_RECV); - /* +20071122[chungs]:wait to process the command... */ - while( IINCHIP_READ(Sn_CR(0)) ) - ; - /* ------- */ - //for debug - //printf("IPCP proc\r\n"); for (i = 0; i < len; i++) printf ("%02x ", str[i]); printf("\r\n"); - str_idx = 6; dst_idx = 0; - if (str[2] == 0x03) // in case of NAK - { - do - { - if (str[str_idx] == 0x03) // request only ip information - { - memcpy((uint8 *)(buf+dst_idx), (uint8 *)(str+str_idx), str[str_idx+1]); - dst_idx += str[str_idx+1]; str_idx += str[str_idx+1]; - } - else - { - // skip byte - str_idx += str[str_idx+1]; - } - // for debug - //printf("s: %d, d: %d, l: %d", str_idx, dst_idx, len); - } while (str_idx != len); - send_data_processing(0, buf, dst_idx); - IINCHIP_WRITE(Sn_CR(0),Sn_CR_PCR); // send ipcp request - /* +20071122[chungs]:wait to process the command... */ - while( IINCHIP_READ(Sn_CR(0)) ) - ; - /* ------- */ - wait_10ms(100); - break; - } - } - } - printf("."); - if (loop_idx++ == 10) // timeout - { - printf("timeout after IPCP\r\n"); - return 3; - } - wait_10ms(100); - send_data_processing(0, buf, 6); - IINCHIP_WRITE(Sn_CR(0),Sn_CR_PCR); //ipcp re-request - /* +20071122[chungs]:wait to process the command... */ - while( IINCHIP_READ(Sn_CR(0)) ) - ; - /* ------- */ - } - - loop_idx = 0; - while (!(IINCHIP_READ(Sn_IR(0)) & Sn_IR_PNEXT)) - { - printf("."); - if (loop_idx++ == 10) // timeout - { - printf("timeout after IPCP NAK\r\n"); - return 3; - } - wait_10ms(100); - IINCHIP_WRITE(Sn_CR(0),Sn_CR_PCR); // send ipcp request - /* +20071122[chungs]:wait to process the command... */ - while( IINCHIP_READ(Sn_CR(0)) ) - ; - /* ------- */ - } - /* +200801[bj] clear interrupt value*/ - IINCHIP_WRITE(Sn_IR(0), 0xff); - /*---*/ - printf("ok\r\n"); - printf("\r\n"); - return 1; - // after this function, User must save the pppoe server's mac address and pppoe session id in current connection -} - - -/** -@brief terminate PPPoE connection -*/ -uint8 pppterm(uint8 * mac, uint8 * sessionid) -{ - uint16 i; - uint8 isr; -#ifdef __DEF_IINCHIP_DBG__ - printf("pppterm()\r\n"); -#endif - /* Set PPPoE bit in MR(Common Mode Register) : enable socket0 pppoe */ - IINCHIP_WRITE(MR,IINCHIP_READ(MR) | MR_PPPOE); - - // write pppoe server's mac address and session id - // must be setted these value. - for (i = 0; i < 6; i++) IINCHIP_WRITE((Sn_DHAR0(0)+i),mac[i]); - for (i = 0; i < 2; i++) IINCHIP_WRITE((Sn_DPORT0(0)+i),sessionid[i]); - isr = IINCHIP_READ(Sn_IR(0)); - IINCHIP_WRITE(Sn_IR(0),isr); - - //open socket in pppoe mode - IINCHIP_WRITE(Sn_MR(0),Sn_MR_PPPOE); - IINCHIP_WRITE(Sn_CR(0),Sn_CR_OPEN); - /* +20071122[chungs]:wait to process the command... */ - while( IINCHIP_READ(Sn_CR(0)) ) - ; - /* ------- */ - wait_1us(1); - // close pppoe connection - IINCHIP_WRITE(Sn_CR(0),Sn_CR_PDISCON); - /* +20071122[chungs]:wait to process the command... */ - while( IINCHIP_READ(Sn_CR(0)) ) - ; - /* ------- */ - wait_10ms(100); - // close socket - /* +200801 (hwkim) */ - close(0); - /* ------- */ - - -#ifdef __DEF_IINCHIP_DBG__ - printf("pppterm() end ..\r\n"); -#endif - - return 1; -} -#endif diff --git a/arduino-0018-linux-x64/libraries/Ethernet/utility/w5100.h b/arduino-0018-linux-x64/libraries/Ethernet/utility/w5100.h deleted file mode 100755 index 6eddf91..0000000 --- a/arduino-0018-linux-x64/libraries/Ethernet/utility/w5100.h +++ /dev/null @@ -1,299 +0,0 @@ -/* -@file w5100.h -*/ - -#ifndef _W5100_H_ -#define _W5100_H_ - - -#define MR __DEF_IINCHIP_MAP_BASE__ -#define IDM_OR ((__DEF_IINCHIP_MAP_BASE__ + 0x00)) -#define IDM_AR0 ((__DEF_IINCHIP_MAP_BASE__ + 0x01)) -#define IDM_AR1 ((__DEF_IINCHIP_MAP_BASE__ + 0x02)) -#define IDM_DR ((__DEF_IINCHIP_MAP_BASE__ + 0x03)) - - -/** - @brief Gateway IP Register address - */ -#define GAR0 (COMMON_BASE + 0x0001) -/** - @brief Subnet mask Register address - */ -#define SUBR0 (COMMON_BASE + 0x0005) -/** - @brief Source MAC Register address - */ -#define SHAR0 (COMMON_BASE + 0x0009) -/** - @brief Source IP Register address - */ -#define SIPR0 (COMMON_BASE + 0x000F) -/** - @brief Interrupt Register - */ -#define IR (COMMON_BASE + 0x0015) -/** - @brief Interrupt mask register - */ -#define IMR (COMMON_BASE + 0x0016) -/** - @brief Timeout register address( 1 is 100us ) - */ -#define RTR0 (COMMON_BASE + 0x0017) -/** - @brief Retry count reigster - */ -#define RCR (COMMON_BASE + 0x0019) -/** - @brief Receive memory size reigster - */ -#define RMSR (COMMON_BASE + 0x001A) -/** - @brief Transmit memory size reigster - */ -#define TMSR (COMMON_BASE + 0x001B) -/** - @brief Authentication type register address in PPPoE mode - */ -#define PATR0 (COMMON_BASE + 0x001C) -//#define PPPALGO (COMMON_BASE + 0x001D) -#define PTIMER (COMMON_BASE + 0x0028) -#define PMAGIC (COMMON_BASE + 0x0029) - -/** - @brief Unreachable IP register address in UDP mode - */ -#define UIPR0 (COMMON_BASE + 0x002A) -/** - @brief Unreachable Port register address in UDP mode - */ -#define UPORT0 (COMMON_BASE + 0x002E) - -/** - @brief socket register -*/ -#define CH_BASE (COMMON_BASE + 0x0400) -/** - @brief size of each channel register map - */ -#define CH_SIZE 0x0100 -/** - @brief socket Mode register - */ -#define Sn_MR(ch) (CH_BASE + ch * CH_SIZE + 0x0000) -/** - @brief channel Sn_CR register - */ -#define Sn_CR(ch) (CH_BASE + ch * CH_SIZE + 0x0001) -/** - @brief channel interrupt register - */ -#define Sn_IR(ch) (CH_BASE + ch * CH_SIZE + 0x0002) -/** - @brief channel status register - */ -#define Sn_SR(ch) (CH_BASE + ch * CH_SIZE + 0x0003) -/** - @brief source port register - */ -#define Sn_PORT0(ch) (CH_BASE + ch * CH_SIZE + 0x0004) -/** - @brief Peer MAC register address - */ -#define Sn_DHAR0(ch) (CH_BASE + ch * CH_SIZE + 0x0006) -/** - @brief Peer IP register address - */ -#define Sn_DIPR0(ch) (CH_BASE + ch * CH_SIZE + 0x000C) -/** - @brief Peer port register address - */ -#define Sn_DPORT0(ch) (CH_BASE + ch * CH_SIZE + 0x0010) -/** - @brief Maximum Segment Size(Sn_MSSR0) register address - */ -#define Sn_MSSR0(ch) (CH_BASE + ch * CH_SIZE + 0x0012) -/** - @brief Protocol of IP Header field register in IP raw mode - */ -#define Sn_PROTO(ch) (CH_BASE + ch * CH_SIZE + 0x0014) - -/** - @brief IP Type of Service(TOS) Register - */ -#define Sn_TOS(ch) (CH_BASE + ch * CH_SIZE + 0x0015) -/** - @brief IP Time to live(TTL) Register - */ -#define Sn_TTL(ch) (CH_BASE + ch * CH_SIZE + 0x0016) - -/** - @brief Transmit free memory size register - */ -#define Sn_TX_FSR0(ch) (CH_BASE + ch * CH_SIZE + 0x0020) -/** - @brief Transmit memory read pointer register address - */ -#define Sn_TX_RD0(ch) (CH_BASE + ch * CH_SIZE + 0x0022) -/** - @brief Transmit memory write pointer register address - */ -#define Sn_TX_WR0(ch) (CH_BASE + ch * CH_SIZE + 0x0024) -/** - @brief Received data size register - */ -#define Sn_RX_RSR0(ch) (CH_BASE + ch * CH_SIZE + 0x0026) -/** - @brief Read point of Receive memory - */ -#define Sn_RX_RD0(ch) (CH_BASE + ch * CH_SIZE + 0x0028) -/** - @brief Write point of Receive memory - */ -#define Sn_RX_WR0(ch) (CH_BASE + ch * CH_SIZE + 0x002A) - - - -/* MODE register values */ -#define MR_RST 0x80 /**< reset */ -#define MR_PB 0x10 /**< ping block */ -#define MR_PPPOE 0x08 /**< enable pppoe */ -#define MR_LB 0x04 /**< little or big endian selector in indirect mode */ -#define MR_AI 0x02 /**< auto-increment in indirect mode */ -#define MR_IND 0x01 /**< enable indirect mode */ - -/* IR register values */ -#define IR_CONFLICT 0x80 /**< check ip confict */ -#define IR_UNREACH 0x40 /**< get the destination unreachable message in UDP sending */ -#define IR_PPPoE 0x20 /**< get the PPPoE close message */ -#define IR_SOCK(ch) (0x01 << ch) /**< check socket interrupt */ - -/* Sn_MR values */ -#define Sn_MR_CLOSE 0x00 /**< unused socket */ -#define Sn_MR_TCP 0x01 /**< TCP */ -#define Sn_MR_UDP 0x02 /**< UDP */ -#define Sn_MR_IPRAW 0x03 /**< IP LAYER RAW SOCK */ -#define Sn_MR_MACRAW 0x04 /**< MAC LAYER RAW SOCK */ -#define Sn_MR_PPPOE 0x05 /**< PPPoE */ -#define Sn_MR_ND 0x20 /**< No Delayed Ack(TCP) flag */ -#define Sn_MR_MULTI 0x80 /**< support multicating */ - - -/* Sn_CR values */ -#define Sn_CR_OPEN 0x01 /**< initialize or open socket */ -#define Sn_CR_LISTEN 0x02 /**< wait connection request in tcp mode(Server mode) */ -#define Sn_CR_CONNECT 0x04 /**< send connection request in tcp mode(Client mode) */ -#define Sn_CR_DISCON 0x08 /**< send closing reqeuset in tcp mode */ -#define Sn_CR_CLOSE 0x10 /**< close socket */ -#define Sn_CR_SEND 0x20 /**< updata txbuf pointer, send data */ -#define Sn_CR_SEND_MAC 0x21 /**< send data with MAC address, so without ARP process */ -#define Sn_CR_SEND_KEEP 0x22 /**< send keep alive message */ -#define Sn_CR_RECV 0x40 /**< update rxbuf pointer, recv data */ - -#ifdef __DEF_IINCHIP_PPP__ - #define Sn_CR_PCON 0x23 - #define Sn_CR_PDISCON 0x24 - #define Sn_CR_PCR 0x25 - #define Sn_CR_PCN 0x26 - #define Sn_CR_PCJ 0x27 -#endif - -/* Sn_IR values */ -#ifdef __DEF_IINCHIP_PPP__ - #define Sn_IR_PRECV 0x80 - #define Sn_IR_PFAIL 0x40 - #define Sn_IR_PNEXT 0x20 -#endif -#define Sn_IR_SEND_OK 0x10 /**< complete sending */ -#define Sn_IR_TIMEOUT 0x08 /**< assert timeout */ -#define Sn_IR_RECV 0x04 /**< receiving data */ -#define Sn_IR_DISCON 0x02 /**< closed socket */ -#define Sn_IR_CON 0x01 /**< established connection */ - -/* Sn_SR values */ -#define SOCK_CLOSED 0x00 /**< closed */ -#define SOCK_INIT 0x13 /**< init state */ -#define SOCK_LISTEN 0x14 /**< listen state */ -#define SOCK_SYNSENT 0x15 /**< connection state */ -#define SOCK_SYNRECV 0x16 /**< connection state */ -#define SOCK_ESTABLISHED 0x17 /**< success to connect */ -#define SOCK_FIN_WAIT 0x18 /**< closing state */ -#define SOCK_CLOSING 0x1A /**< closing state */ -#define SOCK_TIME_WAIT 0x1B /**< closing state */ -#define SOCK_CLOSE_WAIT 0x1C /**< closing state */ -#define SOCK_LAST_ACK 0x1D /**< closing state */ -#define SOCK_UDP 0x22 /**< udp socket */ -#define SOCK_IPRAW 0x32 /**< ip raw mode socket */ -#define SOCK_MACRAW 0x42 /**< mac raw mode socket */ -#define SOCK_PPPOE 0x5F /**< pppoe socket */ - -/* IP PROTOCOL */ -#define IPPROTO_IP 0 /**< Dummy for IP */ -#define IPPROTO_ICMP 1 /**< Control message protocol */ -#define IPPROTO_IGMP 2 /**< Internet group management protocol */ -#define IPPROTO_GGP 3 /**< Gateway^2 (deprecated) */ -#define IPPROTO_TCP 6 /**< TCP */ -#define IPPROTO_PUP 12 /**< PUP */ -#define IPPROTO_UDP 17 /**< UDP */ -#define IPPROTO_IDP 22 /**< XNS idp */ -#define IPPROTO_ND 77 /**< UNOFFICIAL net disk protocol */ -#define IPPROTO_RAW 255 /**< Raw IP packet */ - - -/********************************************************* -* iinchip access function -*********************************************************/ -extern uint8 IINCHIP_READ(uint16 addr); -extern uint8 IINCHIP_WRITE(uint16 addr,uint8 data); -extern uint16 wiz_read_buf(uint16 addr, uint8* buf,uint16 len); -extern uint16 wiz_write_buf(uint16 addr,uint8* buf,uint16 len); - -extern void iinchip_init(void); // reset iinchip -extern void sysinit(uint8 tx_size, uint8 rx_size); // setting tx/rx buf size -extern uint8 getISR(uint8 s); -extern void putISR(uint8 s, uint8 val); -extern uint16 getIINCHIP_RxMAX(uint8 s); -extern uint16 getIINCHIP_TxMAX(uint8 s); -extern uint16 getIINCHIP_RxMASK(uint8 s); -extern uint16 getIINCHIP_TxMASK(uint8 s); -extern uint16 getIINCHIP_RxBASE(uint8 s); -extern uint16 getIINCHIP_TxBASE(uint8 s); -extern void setGAR(uint8 * addr); // set gateway address -extern void setSUBR(uint8 * addr); // set subnet mask address -extern void setSHAR(uint8 * addr); // set local MAC address -extern void setSIPR(uint8 * addr); // set local IP address -extern void setRTR(uint16 timeout); // set retry duration for data transmission, connection, closing ... -extern void setRCR(uint8 retry); // set retry count (above the value, assert timeout interrupt) -extern void setIMR(uint8 mask); // set interrupt mask. -extern void getGAR(uint8 * addr); -extern void getSUBR(uint8 * addr); -extern void getSHAR(uint8 * addr); -extern void getSIPR(uint8 * addr); -extern uint8 getIR( void ); -extern void setSn_MSS(SOCKET s, uint16 Sn_MSSR0); // set maximum segment size -extern void setSn_PROTO(SOCKET s, uint8 proto); // set IP Protocol value using IP-Raw mode -extern uint8 getSn_IR(SOCKET s); // get socket interrupt status -extern uint8 getSn_SR(SOCKET s); // get socket status -extern uint16 getSn_TX_FSR(SOCKET s); // get socket TX free buf size -extern uint16 getSn_RX_RSR(SOCKET s); // get socket RX recv buf size -extern void setSn_DHAR(SOCKET s, uint8 * addr); -extern void setSn_DIPR(SOCKET s, uint8 * addr); -extern void setSn_DPORT(SOCKET s, uint8 * addr); -extern void getSn_DHAR(SOCKET s, uint8 * addr); -extern void getSn_DIPR(SOCKET s, uint8 * addr); -extern void getSn_DPORT(SOCKET s, uint8 * addr); -extern void setSn_TTL(SOCKET s, uint8 ttl); -extern void setMR(uint8 val); - -#ifdef __DEF_IINCHIP_PPP__ -extern uint8 pppinit(uint8 *id, uint8 idlen, uint8 *passwd, uint8 passwdlen); -extern uint8 pppterm(uint8 *mac,uint8 *sessionid); -#endif - -extern void send_data_processing(SOCKET s, uint8 *data, uint16 len); -extern void recv_data_processing(SOCKET s, uint8 *data, uint16 len); -extern void read_data(SOCKET s, vuint8 * src, vuint8 * dst, uint16 len); -extern void write_data(SOCKET s, vuint8 * src, vuint8 * dst, uint16 len); - -#endif diff --git a/arduino-0018-linux-x64/libraries/Firmata/examples/StandardFirmata/StandardFirmata.pde b/arduino-0018-linux-x64/libraries/Firmata/examples/StandardFirmata/StandardFirmata.pde deleted file mode 100644 index 9e16b8a..0000000 --- a/arduino-0018-linux-x64/libraries/Firmata/examples/StandardFirmata/StandardFirmata.pde +++ /dev/null @@ -1,302 +0,0 @@ -/* - Copyright (C) 2006-2008 Hans-Christoph Steiner. All rights 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. - - See file LICENSE.txt for further informations on licensing terms. - - formatted using the GNU C formatting and indenting -*/ - -/* - * TODO: use Program Control to load stored profiles from EEPROM - */ - -#include -#include - -/*============================================================================== - * GLOBAL VARIABLES - *============================================================================*/ - -/* analog inputs */ -int analogInputsToReport = 0; // bitwise array to store pin reporting -int analogPin = 0; // counter for reading analog pins - -/* digital pins */ -byte reportPINs[TOTAL_PORTS]; // PIN == input port -byte previousPINs[TOTAL_PORTS]; // PIN == input port -byte pinStatus[TOTAL_DIGITAL_PINS]; // store pin status, default OUTPUT -byte portStatus[TOTAL_PORTS]; - -/* timer variables */ -unsigned long currentMillis; // store the current value from millis() -unsigned long nextExecuteMillis; // for comparison with currentMillis -int samplingInterval = 19; // how often to run the main loop (in ms) - -Servo servos[MAX_SERVOS]; - -/*============================================================================== - * FUNCTIONS - *============================================================================*/ - -void outputPort(byte portNumber, byte portValue) -{ - portValue = portValue &~ portStatus[portNumber]; - if(previousPINs[portNumber] != portValue) { - Firmata.sendDigitalPort(portNumber, portValue); - previousPINs[portNumber] = portValue; - } -} - -/* ----------------------------------------------------------------------------- - * check all the active digital inputs for change of state, then add any events - * to the Serial output queue using Serial.print() */ -void checkDigitalInputs(void) -{ - byte i, tmp; - for(i=0; i < TOTAL_PORTS; i++) { - if(reportPINs[i]) { - switch(i) { - case 0: - outputPort(0, PIND &~ B00000011); // ignore Rx/Tx 0/1 - break; - case 1: - outputPort(1, PINB); - break; - case ANALOG_PORT: - outputPort(ANALOG_PORT, PINC); - break; - } - } - } -} - -// ----------------------------------------------------------------------------- -/* sets the pin mode to the correct state and sets the relevant bits in the - * two bit-arrays that track Digital I/O and PWM status - */ -void setPinModeCallback(byte pin, int mode) { - byte port = 0; - byte offset = 0; - - // TODO: abstract for different boards - if (pin < 8) { - port = 0; - offset = 0; - } else if (pin < 14) { - port = 1; - offset = 8; - } else if (pin < 22) { - port = 2; - offset = 14; - } - - if(pin > 1) { // ignore RxTx (pins 0 and 1) - if (isServoSupportedPin(pin) && mode != SERVO) - if (servos[pin - FIRST_SERVO_PIN].attached()) - servos[pin - FIRST_SERVO_PIN].detach(); - if(pin > 13) - reportAnalogCallback(pin - 14, mode == ANALOG ? 1 : 0); // turn on/off reporting - switch(mode) { - case ANALOG: - digitalWrite(pin, LOW); // disable internal pull-ups and fall thru to 'case INPUT:' - case INPUT: - pinStatus[pin] = mode; - pinMode(pin, INPUT); - portStatus[port] = portStatus[port] &~ (1 << (pin - offset)); - break; - case OUTPUT: - digitalWrite(pin, LOW); // disable PWM and fall thru to 'case PWM:' - case PWM: - pinStatus[pin] = mode; - pinMode(pin, OUTPUT); - portStatus[port] = portStatus[port] | (1 << (pin - offset)); - break; - case SERVO: - // TODO: Support Arduino Mega - if (isServoSupportedPin(pin)) { - pinStatus[pin] = mode; - if (!servos[pin - FIRST_SERVO_PIN].attached()) - servos[pin - FIRST_SERVO_PIN].attach(pin); - } else - Firmata.sendString("Servo only on pins from 2 to 13"); - break; - case I2C: - pinStatus[pin] = mode; - Firmata.sendString("I2C mode not yet supported"); - break; - default: - Firmata.sendString("Unknown pin mode"); // TODO: put error msgs in EEPROM - } - // TODO: save status to EEPROM here, if changed - } -} - -void analogWriteCallback(byte pin, int value) -{ - switch(pinStatus[pin]) { - case SERVO: - if (isServoSupportedPin(pin)) - servos[pin - FIRST_SERVO_PIN].write(value); - break; - case PWM: - analogWrite(pin, value); - break; - } -} - -void digitalWriteCallback(byte port, int value) -{ - switch(port) { - case 0: // pins 2-7 (don't change Rx/Tx, pins 0 and 1) - // 0xFF03 == B1111111100000011 0x03 == B00000011 - PORTD = (value &~ 0xFF03) | (PORTD & 0x03); - break; - case 1: // pins 8-13 (14,15 are disabled for the crystal) - PORTB = (byte)value; - break; - case 2: // analog pins used as digital - byte pin; - byte pinModeMask; - for(pin=0; pin<8; pin++) - if(pinStatus[pin] == OUTPUT) - pinModeMask += 1 << pin; - PORTC = (byte)value & pinModeMask; - break; - } -} - -// ----------------------------------------------------------------------------- -/* sets bits in a bit array (int) to toggle the reporting of the analogIns - */ -//void FirmataClass::setAnalogPinReporting(byte pin, byte state) { -//} -void reportAnalogCallback(byte pin, int value) -{ - if(value == 0) { - analogInputsToReport = analogInputsToReport &~ (1 << pin); - } - else { // everything but 0 enables reporting of that pin - analogInputsToReport = analogInputsToReport | (1 << pin); - } - // TODO: save status to EEPROM here, if changed -} - -void reportDigitalCallback(byte port, int value) -{ - reportPINs[port] = (byte)value; - if(port == ANALOG_PORT) // turn off analog reporting when used as digital - analogInputsToReport = 0; -} - -/*============================================================================== - * SYSEX-BASED commands - *============================================================================*/ - -void sysexCallback(byte command, byte argc, byte *argv) -{ - switch(command) { - case SERVO_CONFIG: - if(argc > 4) { - // these vars are here for clarity, they'll optimized away by the compiler - byte pin = argv[0]; - int minPulse = argv[1] + (argv[2] << 7); - int maxPulse = argv[3] + (argv[4] << 7); - - if (isServoSupportedPin(pin)) { - // servos are pins from 2 to 13, so offset for array - if (servos[pin - FIRST_SERVO_PIN].attached()) - servos[pin - FIRST_SERVO_PIN].detach(); - servos[pin - FIRST_SERVO_PIN].attach(pin, minPulse, maxPulse); - setPinModeCallback(pin, SERVO); - } - } - break; - case SAMPLING_INTERVAL: - if (argc > 1) - samplingInterval = argv[0] + (argv[1] << 7); - else - Firmata.sendString("Not enough data"); - break; - } -} - -boolean isServoSupportedPin(byte pin) -{ - return ((FIRST_SERVO_PIN <= pin) && (pin <= (FIRST_SERVO_PIN + MAX_SERVOS))); -} - -/*============================================================================== - * SETUP() - *============================================================================*/ -void setup() -{ - byte i; - - Firmata.setFirmwareVersion(2, 1); - - Firmata.attach(ANALOG_MESSAGE, analogWriteCallback); - Firmata.attach(DIGITAL_MESSAGE, digitalWriteCallback); - Firmata.attach(REPORT_ANALOG, reportAnalogCallback); - Firmata.attach(REPORT_DIGITAL, reportDigitalCallback); - Firmata.attach(SET_PIN_MODE, setPinModeCallback); - Firmata.attach(START_SYSEX, sysexCallback); - - portStatus[0] = B00000011; // ignore Tx/RX pins - portStatus[1] = B11000000; // ignore 14/15 pins - portStatus[2] = B00000000; - - for(i=0; i < FIRST_ANALOG_PIN; ++i) { - setPinModeCallback(i,OUTPUT); - } - // set all outputs to 0 to make sure internal pull-up resistors are off - PORTB = 0; // pins 8-15 - PORTC = 0; // analog port - PORTD = 0; // pins 0-7 - - // TODO rethink the init, perhaps it should report analog on default - for(i=0; i nextExecuteMillis) { - nextExecuteMillis = currentMillis + samplingInterval; - /* SERIALREAD - Serial.read() uses a 128 byte circular buffer, so handle - * all serialReads at once, i.e. empty the buffer */ - while(Firmata.available()) - Firmata.processInput(); - /* SEND FTDI WRITE BUFFER - make sure that the FTDI buffer doesn't go over - * 60 bytes. Ideally this could send an "event character" every 4 ms to - * trigger the buffer to dump. */ - - /* ANALOGREAD - do all of the analogReads() once per poll cycle */ - for(analogPin=0;analogPin - - - Arduino - Abs - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

abs(x)

-

Description

-

Computes the absolute value of a number. -

-

Parameters

-

x: the number -

-

Returns

-

x: if x is greater than or equal to 0. -

-

-x: if x is less than 0. -

-

Warning

-

Because of the way the abs() function is implemented, avoid using other functions inside the brackets, it may lead to incorrect results. -

-

-abs(a++);   // avoid this - yields incorrect results
-
-a++;          // use this instead -
-abs(a);       // keep other math outside the function
-
-
-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/AnalogRead.html b/arduino-0018-linux-x64/reference/AnalogRead.html deleted file mode 100644 index b62e970..0000000 --- a/arduino-0018-linux-x64/reference/AnalogRead.html +++ /dev/null @@ -1,107 +0,0 @@ - - - - Arduino - AnalogRead - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

analogRead()

-

Description

-

Reads the value from the specified analog pin. The Arduino board contains a 6 channel (8 channels on the Mini and Nano), 10-bit analog to digital converter. This means that it will map input voltages between 0 and 5 volts into integer values between 0 and 1023. This yields a resolution between readings of: 5 volts / 1024 units or, .0049 volts (4.9 mV) per unit. -

-

It takes about 100 us (0.0001 s) to read an analog input, so the maximum reading rate is about 10,000 times a second. -

-

Syntax

-

analogRead(pin) -

-

Parameters

-

pin: the number of the analog input pin to read from (0 to 5 on most boards, 0 to 7 on the Mini and Nano) -

-

Returns

-

int (0 to 1023) -

-

Note

-

If the analog input pin is not connected to anything, the value returned by analogRead() will fluctuate based on a number of factors (e.g. the values of the other analog inputs, how close your hand is to the board, etc.). -

-

Example

-
 
-int analogPin = 3;     // potentiometer wiper (middle terminal) connected to analog pin 3
-                       // outside leads to ground and +5V
-int val = 0;           // variable to store the value read
-
-void setup()
-{
-  Serial.begin(9600);          //  setup serial
-}
-
-void loop()
-{
-  val = analogRead(analogPin);    // read the input pin
-  Serial.println(val);             // debug value
-}
-
-
-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/AnalogReference.html b/arduino-0018-linux-x64/reference/AnalogReference.html deleted file mode 100644 index 43f8cf7..0000000 --- a/arduino-0018-linux-x64/reference/AnalogReference.html +++ /dev/null @@ -1,99 +0,0 @@ - - - - Arduino - AnalogReference - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

analogReference(type)

-

Description

-

Configures the reference voltage used for analog input. The analogRead() function will return 1023 for an input equal to the reference voltage. The options are: -

-

  • DEFAULT: the default analog reference of 5 volts. -
  • INTERNAL: an built-in reference, equal to 1.1 volts on the ATmega168 and 2.56 volts on the ATmega8. -
  • EXTERNAL: the voltage applied to the AREF pin is used as the reference. -

Parameters

-

type: which type of reference to use (DEFAULT, INTERNAL, or EXTERNAL). -

-

Returns

-

None. -

-

Warning

-

It is a good idea to connect external voltages to the AREF pin through a 5K resistor. This will prevent possible internal damage to the Atmega chip if analogReference() software settings are incompatible with the current hardware setup. Note that the resistor will alter the voltage that gets used as the reference because there is an internal 32K resistor on the AREF pin. The two act as a voltage divider, so, for example, 2.5V applied through the resistor will yield ~2.2V at the AREF pin. -

-

Connecting external voltages through a resistor makes it possible to switch the AREF voltage on the fly, say from the 5 volt DEFAULT setting, to a 3.3 volt EXTERNAL setting (and applied voltage), without the hardware setup affecting either ADC configuration. -

-

Use of the AREF pin

-

The voltage applied to the AREF pin directly governs the ADC and sets the voltage at which the ADC will report its highest reading, 1023. Lower voltages applied to ADC (analog) pins will be scaled proportionally, so at the DEFAULT setting (5 volt internal connection), 2.5 volts on an analog pin will report approximately 512. -

-

The default configuration on all Arduino implementations is to have nothing connected externally to the AREF pin (Atmega pin 21). In this case the DEFAULT analogReference software setting connects the AVCC voltage, internally, to the AREF pin. This appears to be a low impedance connection (high current) and voltages, other than AVCC, applied (erroneously) to the AREF pin in the DEFAULT setting could damage the ATMEGA chip. -

-

The AREF pin may also be connected internally to an (internal) 1.1 volt source (or 2.56 on the ATmega8) with analogReference(INTERNAL). With this setting voltages applied to the ADC (analog) pins that are at or above the reference will report 1023 when read with analogRead. Lower voltages will report proportional values, so 0.55 volts will report about 512. -

-

The connection between the 1.1 volt source and the AREF pin is a very high impedance (low current) connection, so that reading the 1.1 (internally supplied) voltage at the AREF pin may only be done with a more expensive, high-impedance multimeter. An external voltage applied (erroneously) to AREF pin while using the INTERNAL setting will not damage the chip, but will totally override the 1.1 volt source, and ADC readings will be governed by the external voltage. It is still desirable to connect any external voltage to the AREF pin however, through a 5K resistor to avoid the problem cited above. -

-

The correct software setting for using the AREF pin with an external voltage is analogReference(EXTERNAL). This disconnects both of the internal references and the voltage applied externally to the AREF pin sets the reference voltage for the ADC. -

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/AnalogWrite.html b/arduino-0018-linux-x64/reference/AnalogWrite.html deleted file mode 100644 index 8f0d708..0000000 --- a/arduino-0018-linux-x64/reference/AnalogWrite.html +++ /dev/null @@ -1,115 +0,0 @@ - - - - Arduino - AnalogWrite - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

analogWrite()

-

Description

-

Writes an analog value (PWM wave) to a pin. Can be used to light a LED at varying brightnesses or drive a motor at various speeds. After a call to analogWrite(), the pin will generate a steady square wave of the specified duty cycle until the next call to analogWrite() (or a call to digitalRead() or digitalWrite() on the same pin). The frequency of the PWM signal is approximately 490 Hz. -

-

On newer Arduino boards (including the Mini and BT) with the ATmega168 chip, this function works on pins 3, 5, 6, 9, 10, and 11. Older USB and serial Arduino boards with an ATmega8 only support analogWrite() on pins 9, 10, and 11. -

-

Syntax

-

analogWrite(pin, value) -

-

Parameters

-

pin: the pin to write to. -

-

value: the duty cycle: between 0 (always off) and 255 (always on). -

-

Returns

-

nothing -

-

Notes and Known Issues

-

analogWrite has nothing whatsoever to do with the analog pins or analogRead. -

-

You do not need to call pinMode() to set the pin as an output before calling analogWrite(). -

-

The PWM outputs generated on pins 5 and 6 will have higher-than-expected duty cycles. This is because of interactions with the millis() and delay() functions, which share the same internal timer used to generate those PWM outputs. This will be noticed mostly on low duty-cycle settings (e.g 0 - 10) and may result in analogWrite(x, 0) not fully turning off the output on pins 5 & 6, as one would expect. -

-

Example

-

Sets the output to the LED proportional to the value read from the potentiometer. -

-

 
-int ledPin = 9;      // LED connected to digital pin 9
-int analogPin = 3;   // potentiometer connected to analog pin 3
-int val = 0;         // variable to store the read value
-
-void setup()
-{
-  pinMode(ledPin, OUTPUT);   // sets the pin as output
-}
-
-void loop()
-{
-  val = analogRead(analogPin);   // read the input pin
-  analogWrite(ledPin, val / 4);  // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
-}
-
-
-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Arithmetic.html b/arduino-0018-linux-x64/reference/Arithmetic.html deleted file mode 100644 index 5fe17bc..0000000 --- a/arduino-0018-linux-x64/reference/Arithmetic.html +++ /dev/null @@ -1,100 +0,0 @@ - - - - Arduino - Arithmetic - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Addition, Subtraction, Multiplication, & Division

-

Description

-

These operators return the sum, difference, product, or quotient (respectively) of the two operands. The operation is conducted using the data type of the operands, so, for example, 9 / 4 gives 2 since 9 and 4 are ints. This also means that the operation can overflow if the result is larger than that which can be stored in the data type (e.g. adding 1 to an int with the value 32,767 gives -32,768). If the operands are of different types, the "larger" type is used for the calculation. -

-

If one of the numbers (operands) are of the type float or of type double, floating point math will be used for the calculation. -

-

Examples

-
-y = y + 3;
-x = x - 7;
-i = j * 6;
-r = r / 5;
-
-
-

Syntax

-
-result = value1 + value2;
-result = value1 - value2;
-result = value1 * value2;
-result = value1 / value2;
-
-
-

Parameters:

-

value1: any variable or constant -

-

value2: any variable or constant -

-

Programming Tips:

-
  • Know that integer constants default to int, so some constant calculations may overflow (e.g. 60 * 1000 will yield a negative result). -

  • Choose variable sizes that are large enough to hold the largest results from your calculations -

  • Know at what point your variable will "roll over" and also what happens in the other direction e.g. (0 - 1) OR (0 - - 32768) -

  • For math that requires fractions, use float variables, but be aware of their drawbacks: large size, slow computation speeds -

  • Use the cast operator e.g. (int)myFloat to convert one variable type to another on the fly. -

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Assignment.html b/arduino-0018-linux-x64/reference/Assignment.html deleted file mode 100644 index a514842..0000000 --- a/arduino-0018-linux-x64/reference/Assignment.html +++ /dev/null @@ -1,86 +0,0 @@ - - - - Arduino - Assignment - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

= assignment operator (single equal sign)

-

Stores the value to the right of the equal sign in the variable to the left of the equal sign. -

-

The single equal sign in the C programming language is called the assignment operator. It has a different meaning than in algebra class where it indicated an equation or equality. The assignment operator tells the microcontroller to evaluate whatever value or expression is on the right side of the equal sign, and store it in the variable to the left of the equal sign. -

-

Example

-
 int sensVal;                 // declare an integer variable named sensVal
- senVal = analogRead(0);       // store the (digitized) input voltage at analog pin 0 in SensVal
-
-

Programming Tips

-

The variable on the left side of the assignment operator ( = sign ) needs to be able to hold the value stored in it. If it is not large enough to hold a value, the value stored in the variable will be incorrect. -

-

Don't confuse the assignment operator [ = ] (single equal sign) with the comparison operator [ == ] (double equal signs), which evaluates whether two expressions are equal. -

-

See Also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/AttachInterrupt.html b/arduino-0018-linux-x64/reference/AttachInterrupt.html deleted file mode 100644 index df4b626..0000000 --- a/arduino-0018-linux-x64/reference/AttachInterrupt.html +++ /dev/null @@ -1,115 +0,0 @@ - - - - Arduino - AttachInterrupt - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

attachInterrupt(interrupt, function, mode)

-

Description

-

Specifies a function to call when an external interrupt occurs. Replaces any previous function that was attached to the interrupt. Most Arduino boards have two external interrupts: numbers 0 (on digital pin 2) and 1 (on digital pin 3). The Arduino Mega has an additional four: numbers 2 (pin 21), 3 (pin 20), 4 (pin 19), and 5 (pin 18). -

-

Parameters

-

interrupt: the number of the interrupt (int) -

-

function: the function to call when the interrupt occurs; this function must take no parameters and return nothing. This function is sometimes referred to as an interrupt service routine. -

-

mode defines when the interrupt should be triggered. Four contstants are predefined as valid values: -

  • LOW to trigger the interrupt whenever the pin is low, -
  • CHANGE to trigger the interrupt whenever the pin changes value -
  • RISING to trigger when the pin goes from low to high, -
  • FALLING for when the pin goes from high to low. -

Returns

-

none -

-

Note

-

Inside the attached function, delay() won't work and the value returned by millis() will not increment. Serial data received while in the function may be lost. You should declare as volatile any variables that you modify within the attached function. -

-

Using Interrupts

-

Interrupts are useful for making things happen automatically in microcontroller programs, and can help solve timing problems. A good task for using an interrupt might be reading a rotary encoder, monitoring user input. -

-

If you wanted to insure that a program always caught the pulses from a rotary encoder, never missing a pulse, it would make it very tricky to write a program to do anything else, because the program would need to constantly poll the sensor lines for the encoder, in order to catch pulses when they occurred. Other sensors have a similar interface dynamic too, such as trying to read a sound sensor that is trying to catch a click, or an infrared slot sensor (photo-interrupter) trying to catch a coin drop. In all of these situations, using an interrupt can free the microcontroller to get some other work done while not missing the doorbell. -

-

Example

-
int pin = 13;
-volatile int state = LOW;
-
-void setup()
-{
-  pinMode(pin, OUTPUT);
-  attachInterrupt(0, blink, CHANGE);
-}
-
-void loop()
-{
-  digitalWrite(pin, state);
-}
-
-void blink()
-{
-  state = !state;
-}
-
-
-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Bit.html b/arduino-0018-linux-x64/reference/Bit.html deleted file mode 100644 index 0baa8c1..0000000 --- a/arduino-0018-linux-x64/reference/Bit.html +++ /dev/null @@ -1,85 +0,0 @@ - - - - Arduino - Bit - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

bit()

-

Description

-

Computes the value of the specified bit (bit 0 is 1, bit 1 is 2, bit 2 is 4, etc.). -

-

Syntax

-

bit(n) -

-

Parameters

-

n: the bit whose value to compute -

-

Returns

-

the value of the bit -

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/BitClear.html b/arduino-0018-linux-x64/reference/BitClear.html deleted file mode 100644 index d392c2c..0000000 --- a/arduino-0018-linux-x64/reference/BitClear.html +++ /dev/null @@ -1,87 +0,0 @@ - - - - Arduino - BitClear - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

bitClear()

-

Description

-

Clears (writes a 0 to) a bit of a numeric variable. -

-

Syntax

-

bitClear(x, n) -

-

Parameters

-

x: the numeric variable whose bit to clear -

-

n: which bit to clear, starting at 0 for the least-significant (rightmost) bit -

-

Returns

-

none -

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/BitRead.html b/arduino-0018-linux-x64/reference/BitRead.html deleted file mode 100644 index dd45e33..0000000 --- a/arduino-0018-linux-x64/reference/BitRead.html +++ /dev/null @@ -1,87 +0,0 @@ - - - - Arduino - BitRead - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

bitRead()

-

Description

-

Reads a bit of a number. -

-

Syntax

-

bitRead(x, n) -

-

Parameters

-

x: the number from which to read -

-

n: which bit to read, starting at 0 for the least-significant (rightmost) bit -

-

Returns

-

the value of the bit (0 or 1). -

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/BitSet.html b/arduino-0018-linux-x64/reference/BitSet.html deleted file mode 100644 index 8e27a94..0000000 --- a/arduino-0018-linux-x64/reference/BitSet.html +++ /dev/null @@ -1,87 +0,0 @@ - - - - Arduino - BitSet - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

bitSet()

-

Description

-

Sets (writes a 1 to) a bit of a numeric variable. -

-

Syntax

-

bitSet(x, n) -

-

Parameters

-

x: the numeric variable whose bit to set -

-

n: which bit to set, starting at 0 for the least-significant (rightmost) bit -

-

Returns

-

none -

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/BitWrite.html b/arduino-0018-linux-x64/reference/BitWrite.html deleted file mode 100644 index 468ba00..0000000 --- a/arduino-0018-linux-x64/reference/BitWrite.html +++ /dev/null @@ -1,89 +0,0 @@ - - - - Arduino - BitWrite - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

bitWrite()

-

Description

-

Writes a bit of a numeric variable. -

-

Syntax

-

bitWrite(x, n, b) -

-

Parameters

-

x: the numeric variable to which to write -

-

n: which bit of the number to write, starting at 0 for the least-significant (rightmost) bit -

-

b: the value to write to the bit (0 or 1) -

-

Returns

-

none -

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/BitwiseXorNot.html b/arduino-0018-linux-x64/reference/BitwiseXorNot.html deleted file mode 100644 index 016b5f5..0000000 --- a/arduino-0018-linux-x64/reference/BitwiseXorNot.html +++ /dev/null @@ -1,84 +0,0 @@ - - - - Arduino - BitwiseXorNot - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Bitwise NOT (~)

-

The bitwise NOT operator in C++ is the tilde character ~. Unlike & and |, the bitwise NOT operator is applied to a single operand to its right. Bitwise NOT changes each bit to its opposite: 0 becomes 1, and 1 becomes 0. For example: -

-

    0  1    operand1
-
-

   ----------
-    1  0   ~ operand1
-
-

    int a = 103;    // binary:  0000000001100111
-    int b = ~a;     // binary:  1111111110011000 = -104
-
-

You might be surprised to see a negative number like -104 as the result of this operation. This is because the highest bit in an int variable is the so-called sign bit. If the highest bit is 1, the number is interpreted as negative. This encoding of positive and negative numbers is referred to as two's complement. For more information, see the Wikipedia article on two's complement. -

-

As an aside, it is interesting to note that for any integer x, ~x is the same as -x-1. -

-

At times, the sign bit in a signed integer expression can cause some unwanted surprises. -

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Boolean.html b/arduino-0018-linux-x64/reference/Boolean.html deleted file mode 100644 index df98a02..0000000 --- a/arduino-0018-linux-x64/reference/Boolean.html +++ /dev/null @@ -1,111 +0,0 @@ - - - - Arduino - Boolean - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Boolean Operators

-

These can be used inside the condition of an if statement. -

-

&& (logical and)

-

True only if both operands are true, e.g. -

-if (digitalRead(2) == HIGH  && digitalRead(3) == HIGH) { // read two switches 
-  // ...
-} 
-

is true only if both inputs are high. -

-

|| (logical or)

-

True if either operand is true, e.g. -

-if (x > 0 || y > 0) {
-  // ...
-} 
-

is true if either x or y is greater than 0. -

-

! (not)

-

True if the operand is false, e.g. -

-if (!x) { 
-  // ...
-} 
-

is true if x is false (i.e. if x equals 0). -

-

Warning

-

Make sure you don't mistake the boolean AND operator, && (double ampersand) for the bitwise AND operator & (single ampersand). They are entirely different beasts. -

-

Similarly, do not confuse the boolean || (double pipe) operator with the bitwise OR operator | (single pipe). -

-

The bitwise not ~ (tilde) looks much different than the boolean not ! (exclamation point or "bang" as the programmers say) but you still have to be sure which one you want where. -

-

Examples

-
-if (a >= 10 && a <= 20){}   // true if a is between 10 and 20
-
-
-

See also

-
  • & (bitwise AND) -
  • | (bitwise OR) -
  • ~ (bitwise NOT -
  • if -

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/BooleanVariables.html b/arduino-0018-linux-x64/reference/BooleanVariables.html deleted file mode 100644 index 671b0b3..0000000 --- a/arduino-0018-linux-x64/reference/BooleanVariables.html +++ /dev/null @@ -1,102 +0,0 @@ - - - - Arduino - BooleanVariables - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

boolean

-

A boolean holds one of two values, true or false. (Each boolean variable occupies one byte of memory.) -

-

Example

-
-int LEDpin = 5;       // LED on pin 5
-int switchPin = 13;   // momentary switch on 13, other side connected to ground
-
-boolean running = false;
-
-void setup()
-{
-  pinMode(LEDpin, OUTPUT);
-  pinMode(switchPin, INPUT);
-  digitalWrite(switchPin, HIGH);      // turn on pullup resistor
-}
-
-void loop()
-{
-  if (digitalRead(switchPin) == LOW)
-  {  // switch is pressed - pullup keeps pin high normally
-    delay(100);                        // delay to debounce switch
-    running = !running;                // toggle running variable
-    digitalWrite(LEDpin, running)      // indicate via LED
-  }
-}
-
-
-
-
-
-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Braces.html b/arduino-0018-linux-x64/reference/Braces.html deleted file mode 100644 index 5e41ad2..0000000 --- a/arduino-0018-linux-x64/reference/Braces.html +++ /dev/null @@ -1,119 +0,0 @@ - - - - Arduino - Braces - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

{} Curly Braces

-

Curly braces (also referred to as just "braces" or as "curly brackets") are a major part of the C programming language. They are used in several different constructs, outlined below, and this can sometimes be confusing for beginners. -

-

An opening curly brace "{" must always be followed by a closing curly brace "}". This is a condition that is often referred to as the braces being balanced. The Arduino IDE (integrated development environment) includes a convenient feature to check the balance of curly braces. Just select a brace, or even click the insertion point immediately following a brace, and its logical companion will be highlighted. -

-

At present this feature is slightly buggy as the IDE will often find (incorrectly) a brace in text that has been "commented out." -

-

Beginning programmers, and programmers coming to C from the BASIC language often find using braces confusing or daunting. After all, the same curly braces replace the RETURN statement in a subroutine (function), the ENDIF statement in a conditional and the NEXT statement in a FOR loop. -

-

Because the use of the curly brace is so varied, it is good programming practice to type the closing brace immediately after typing the opening brace when inserting a construct which requires curly braces. Then insert some carriage returns between your braces and begin inserting statements. Your braces, and your attitude, will never become unbalanced. -

-

Unbalanced braces can often lead to cryptic, impenetrable compiler errors that can sometimes be hard to track down in a large program. Because of their varied usages, braces are also incredibly important to the syntax of a program and moving a brace one or two lines will often dramatically affect the meaning of a program. -

-

The main uses of curly braces

-

Functions

-
  void myfunction(datatype argument){
-    statements(s)
-  }
-
-

Loops

-
  while (boolean expression)
-  {
-     statement(s)
-  }
-
-  do
-  {
-     statement(s)
-  } while (boolean expression);
-
-  for (initialisation; termination condition; incrementing expr)
-  {
-     statement(s)
-  } 
-
-

Conditional statements

-

  if (boolean expression)
-  {
-     statement(s)
-  }
-
-  else if (boolean expression)
-  {
-     statement(s)
-  } 
-  else
-  {
-     statement(s)
-  }
-
-

Reference Home -

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Break.html b/arduino-0018-linux-x64/reference/Break.html deleted file mode 100644 index beb2b5f..0000000 --- a/arduino-0018-linux-x64/reference/Break.html +++ /dev/null @@ -1,85 +0,0 @@ - - - - Arduino - Break - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

break

-

break is used to exit from a do, for, or while loop, bypassing the normal loop condition. It is also used to exit from a switch statement. -

-

Example

-
-for (x = 0; x < 255; x ++)
-{
-    digitalWrite(PWMpin, x);
-    sens = analogRead(sensorPin);  
-    if (sens > threshold){      // bail out on sensor detect
-       x = 0;
-       break;
-    }  
-    delay(50);
-}
-
-
-
-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Byte.html b/arduino-0018-linux-x64/reference/Byte.html deleted file mode 100644 index 0ce2492..0000000 --- a/arduino-0018-linux-x64/reference/Byte.html +++ /dev/null @@ -1,78 +0,0 @@ - - - - Arduino - Byte - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

byte

-

Description

-

A byte stores an 8-bit unsigned number, from 0 to 255. -

-

Example

-
    byte b = B10010;  // "B" is the binary formatter (B10010 = 18 decimal) 
-
-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/ByteCast.html b/arduino-0018-linux-x64/reference/ByteCast.html deleted file mode 100644 index d700b11..0000000 --- a/arduino-0018-linux-x64/reference/ByteCast.html +++ /dev/null @@ -1,82 +0,0 @@ - - - - Arduino - ByteCast - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

byte()

-

Description

-

Converts a value to the byte data type. -

-

Syntax

-

byte(x) -

-

Parameters

-

x: a value of any type -

-

Returns

-

byte -

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Changes.html b/arduino-0018-linux-x64/reference/Changes.html deleted file mode 100644 index c5e7c29..0000000 --- a/arduino-0018-linux-x64/reference/Changes.html +++ /dev/null @@ -1,89 +0,0 @@ - - - - Arduino - Changes - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Changes

-

This page lists major changes to the Arduino core, libraries, and environment. For details, see the release notes. -

-

Changes in Arduino 0017

-
  • Environment: The code base for the Arduino development environment was largely re-written to bring it back into sync with Processing (1.0.3). The main differences include support for multiple sketch windows open simultaneously and a dedicated window for the serial monitor. -

  • Icons: The icons and about images were updated. -

  • Arduino.app: The Mac OS X version of Arduino is now a .app file packaged in a .dmg. -

  • Libraries: Support was added for third-party libraries in the SKETCHBOOK/libraries directory. This allows user-installed libraries to persist across upgrades of the Arduino software. -

  • Servo: The servo library was rewritten to allow support for up to 12 servos (on any pins) and up to 48 on the Mega. -

  • LiquidCrystal: The begin(), cursor(), noCursor(), blink(), noBlink(), display(), noDisplay(), scrollDisplayLeft(), scrollDisplayRight(), autoscroll(), noAutoscroll(), leftToRight(), rightToLeft(), and createChar() functions were added. -

Changes in Arduino 0016

-
  • New functions for writing a string, write(str), or buffer, write(buf, len), were added to the Print, Serial, and Ethernet library Client and Server classes. -

Changes in Arduino 0015

-
  • Support for the Arduino Mega. -

Changes in Arduino 0013

-
  • Support for printing floats was added to the Print, Serial, and Ethernet library Client and Server classes. -

  • The word type and word(), bitRead(), bitWrite(), bitSet(), bitClear(), bit(), lowByte(), and highByte() functions were added. -

Changes in Arduino 0012

-
  • Added the Firmata library, which provides a standard protocol for serial communication. -

  • Added Ethernet library. -

  • Added Servo library. -

  • Added LiquidCrystal library. -

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Char.html b/arduino-0018-linux-x64/reference/Char.html deleted file mode 100644 index f539cbd..0000000 --- a/arduino-0018-linux-x64/reference/Char.html +++ /dev/null @@ -1,85 +0,0 @@ - - - - Arduino - Char - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

char

-

Description

-

A data type that takes up 1 byte of memory that stores a character value. Character literals are written in single quotes, like this: 'A' (for multiple characters - strings - use double quotes: "ABC"). -

-

Characters are stored as numbers however. You can see the specific encoding in the ASCII chart. This means that it is possible to do arithmetic on characters, in which the ASCII value of the character is used (e.g. 'A' + 1 has the value 66, since the ASCII value of the capital letter A is 65). See Serial.println reference for more on how characters are translated to numbers. -

-

The char datatype is a signed type, meaning that it encodes numbers from -128 to 127. For an unsigned, one-byte (8 bit) data type, use the byte data type. -

-

Example

-
  char myChar = 'A';
-  char myChar = 65;      // both are equivalent
-
-
-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/CharCast.html b/arduino-0018-linux-x64/reference/CharCast.html deleted file mode 100644 index 0690347..0000000 --- a/arduino-0018-linux-x64/reference/CharCast.html +++ /dev/null @@ -1,82 +0,0 @@ - - - - Arduino - CharCast - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

char()

-

Description

-

Converts a value to the char data type. -

-

Syntax

-

char(x) -

-

Parameters

-

x: a value of any type -

-

Returns

-

char -

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/ClientAvailable.html b/arduino-0018-linux-x64/reference/ClientAvailable.html deleted file mode 100644 index 7bbd5d8..0000000 --- a/arduino-0018-linux-x64/reference/ClientAvailable.html +++ /dev/null @@ -1,126 +0,0 @@ - - - - Arduino - ClientAvailable - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Ethernet : Client class -

-

available()

-

Description

-

Returns the number of bytes available for reading (that is, the amount of data that has been written to the client by the server it is connected to). -

-

Syntax

-

client.available() -

-

Parameters

-

none -

-

Returns

-

The number of bytes available. -

-

-#include <Ethernet.h>
-
-byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
-byte ip[] = { 10, 0, 0, 177 };
-byte server[] = { 64, 233, 187, 99 }; // Google
-
-Client client(server, 80);
-
-void setup()
-{
-  Ethernet.begin(mac, ip);
-  Serial.begin(9600);
-
-  delay(1000);
-
-  Serial.println("connecting...");
-
-  if (client.connect()) {
-    Serial.println("connected");
-    client.println("GET /search?q=arduino HTTP/1.0");
-    client.println();
-  } else {
-    Serial.println("connection failed");
-  }
-}
-
-void loop()
-{
-  if (client.available()) {
-    char c = client.read();
-    Serial.print(c);
-  }
-
-  if (!client.connected()) {
-    Serial.println();
-    Serial.println("disconnecting.");
-    client.stop();
-    for(;;)
-      ;
-  }
-}
-
-
-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/ClientConnect.html b/arduino-0018-linux-x64/reference/ClientConnect.html deleted file mode 100644 index d45d793..0000000 --- a/arduino-0018-linux-x64/reference/ClientConnect.html +++ /dev/null @@ -1,127 +0,0 @@ - - - - Arduino - ClientConnect - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Ethernet : Client class -

-

connect()

-

Description

-

Connect to the IP address and port specified in the constructor. The return value indicates success or failure. -

-

Syntax

-

client.connect() -

-

Parameters

-

none -

-

Returns

-

Returns true if the connection succeeds, false if not. -

-

Example

-
-#include <Ethernet.h>
-
-byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
-byte ip[] = { 10, 0, 0, 177 };
-byte server[] = { 64, 233, 187, 99 }; // Google
-
-Client client(server, 80);
-
-void setup()
-{
-  Ethernet.begin(mac, ip);
-  Serial.begin(9600);
-
-  delay(1000);
-
-  Serial.println("connecting...");
-
-  if (client.connect()) {
-    Serial.println("connected");
-    client.println("GET /search?q=arduino HTTP/1.0");
-    client.println();
-  } else {
-    Serial.println("connection failed");
-  }
-}
-
-void loop()
-{
-  if (client.available()) {
-    char c = client.read();
-    Serial.print(c);
-  }
-
-  if (!client.connected()) {
-    Serial.println();
-    Serial.println("disconnecting.");
-    client.stop();
-    for(;;)
-      ;
-  }
-}
-
-
-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/ClientConnected.html b/arduino-0018-linux-x64/reference/ClientConnected.html deleted file mode 100644 index b419713..0000000 --- a/arduino-0018-linux-x64/reference/ClientConnected.html +++ /dev/null @@ -1,127 +0,0 @@ - - - - Arduino - ClientConnected - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Ethernet : Client class -

-

connected()

-

Description

-

Whether or not the client is connected. Note that a client is considered connected if the connection has been closed but there is still unread data. -

-

Syntax

-

client.connected() -

-

Parameters

-

none -

-

Returns

-

Returns true if the client is connected, false if not. -

-

Example

-
-#include <Ethernet.h>
-
-byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
-byte ip[] = { 10, 0, 0, 177 };
-byte server[] = { 64, 233, 187, 99 }; // Google
-
-Client client(server, 80);
-
-void setup()
-{
-  Ethernet.begin(mac, ip);
-  Serial.begin(9600);
-
-  delay(1000);
-
-  Serial.println("connecting...");
-
-  if (client.connect()) {
-    Serial.println("connected");
-    client.println("GET /search?q=arduino HTTP/1.0");
-    client.println();
-  } else {
-    Serial.println("connection failed");
-  }
-}
-
-void loop()
-{
-  if (client.available()) {
-    char c = client.read();
-    Serial.print(c);
-  }
-
-  if (!client.connected()) {
-    Serial.println();
-    Serial.println("disconnecting.");
-    client.stop();
-    for(;;)
-      ;
-  }
-}
-
-
-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/ClientConstructor.html b/arduino-0018-linux-x64/reference/ClientConstructor.html deleted file mode 100644 index 2ea0256..0000000 --- a/arduino-0018-linux-x64/reference/ClientConstructor.html +++ /dev/null @@ -1,126 +0,0 @@ - - - - Arduino - ClientConstructor - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Ethernet : Client class -

-

Client()

-

Description

-

Creates a client which can connect to the specified internet IP address and port. -

-

Syntax

-

Client(ip, port) -

-

Parameters

-

ip: the IP address that the client will connect to (array of 4 bytes) -

-

port: the port that the client will connect to (int) -

-

Example

-
-#include <Ethernet.h>
-
-byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
-byte ip[] = { 10, 0, 0, 177 };
-byte server[] = { 64, 233, 187, 99 }; // Google
-
-Client client(server, 80);
-
-void setup()
-{
-  Ethernet.begin(mac, ip);
-  Serial.begin(9600);
-
-  delay(1000);
-
-  Serial.println("connecting...");
-
-  if (client.connect()) {
-    Serial.println("connected");
-    client.println("GET /search?q=arduino HTTP/1.0");
-    client.println();
-  } else {
-    Serial.println("connection failed");
-  }
-}
-
-void loop()
-{
-  if (client.available()) {
-    char c = client.read();
-    Serial.print(c);
-  }
-
-  if (!client.connected()) {
-    Serial.println();
-    Serial.println("disconnecting.");
-    client.stop();
-    for(;;)
-      ;
-  }
-}
-
-
-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/ClientFlush.html b/arduino-0018-linux-x64/reference/ClientFlush.html deleted file mode 100644 index 0b42c67..0000000 --- a/arduino-0018-linux-x64/reference/ClientFlush.html +++ /dev/null @@ -1,81 +0,0 @@ - - - - Arduino - ClientFlush - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Ethernet : Client class -

-

flush()

-

Discard any bytes that have been written to the client but not yet read. -

-

Syntax

-

client.flush() -

-

Parameters

-

none -

-

Returns

-

none -

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/ClientPrint.html b/arduino-0018-linux-x64/reference/ClientPrint.html deleted file mode 100644 index 1f9bb8b..0000000 --- a/arduino-0018-linux-x64/reference/ClientPrint.html +++ /dev/null @@ -1,85 +0,0 @@ - - - - Arduino - ClientPrint - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Ethernet : Client class -

-

print()

-

Description

-

Print data to the server that a client is connected to. Prints numbers as a sequence of digits, each an ASCII character (e.g. the number 123 is sent as the three characters '1', '2', '3'). -

-

Syntax

-

client.print(data)
client.print(data, BASE) -

-

Parameters

-

data: the data to print (char, byte, int, long, or string) -

-

BASE (optional): the base in which to print numbers: BIN for binary (base 2), DEC for decimal (base 10), OCT for octal (base 8), HEX for hexadecimal (base 16). -

-

Example

-
-
-
-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/ClientPrintln.html b/arduino-0018-linux-x64/reference/ClientPrintln.html deleted file mode 100644 index 492cd3b..0000000 --- a/arduino-0018-linux-x64/reference/ClientPrintln.html +++ /dev/null @@ -1,85 +0,0 @@ - - - - Arduino - ClientPrintln - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Ethernet : Client class -

-

println()

-

Description

-

Print data, followed by a newline, to the server a client is connected to. Prints numbers as a sequence of digits, each an ASCII character (e.g. the number 123 is sent as the three characters '1', '2', '3'). -

-

Syntax

-

client.println()
client.println(data)
client.print(data, BASE) -

-

Parameters

-

data (optional): the data to print (char, byte, int, long, or string) -

-

BASE (optional): the base in which to print numbers: BIN for binary (base 2), DEC for decimal (base 10), OCT for octal (base 8), HEX for hexadecimal (base 16). -

-

Example

-
-
-
-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/ClientRead.html b/arduino-0018-linux-x64/reference/ClientRead.html deleted file mode 100644 index 4a36640..0000000 --- a/arduino-0018-linux-x64/reference/ClientRead.html +++ /dev/null @@ -1,81 +0,0 @@ - - - - Arduino - ClientRead - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Ethernet : Client class -

-

read()

-

Read the next byte received from the server the client is connected to (after the last call to read()). -

-

Syntax

-

client.read() -

-

Parameters

-

none -

-

Returns

-

The next byte (or character), or -1 if none is available. -

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/ClientStop.html b/arduino-0018-linux-x64/reference/ClientStop.html deleted file mode 100644 index 2596eb0..0000000 --- a/arduino-0018-linux-x64/reference/ClientStop.html +++ /dev/null @@ -1,82 +0,0 @@ - - - - Arduino - ClientStop - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Ethernet : Client class -

-

stop()

-

Description

-

Disconnect from the server. -

-

Syntax

-

client.stop() -

-

Parameters

-

none -

-

Returns

-

none -

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/ClientWrite.html b/arduino-0018-linux-x64/reference/ClientWrite.html deleted file mode 100644 index 0508d2b..0000000 --- a/arduino-0018-linux-x64/reference/ClientWrite.html +++ /dev/null @@ -1,80 +0,0 @@ - - - - Arduino - ClientWrite - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Ethernet : Client class -

-

write()

-

Description

-

Write data to the server the client is connected to. -

-

Syntax

-

client.write(data) -

-

Parameters

-

data: the byte or char to write -

-

Example

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Comments.html b/arduino-0018-linux-x64/reference/Comments.html deleted file mode 100644 index f9fa2d9..0000000 --- a/arduino-0018-linux-x64/reference/Comments.html +++ /dev/null @@ -1,88 +0,0 @@ - - - - Arduino - Comments - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Comments

-

Comments are lines in the program that are used to inform yourself or others about the way the program works. They are ignored by the compiler, and not exported to the processor, so they don't take up any space on the Atmega chip. -

-

Comments only purpose are to help you understand (or remember) how your program works or to inform others how your program works. -There are two different ways of marking a line as a comment: -

-

Example

-
 x = 5;  // This is a single line comment. Anything after the slashes is a comment 
-         // to the end of the line
-
-/* this is multiline comment - use it to comment out whole blocks of code
-
-if (gwb == 0){   // single line comment is OK inside a multiline comment
-x = 3;           /* but not another multiline comment - this is invalid */
-}
-// don't forget the "closing" comment - they have to be balanced!
-*/
-
-
-

Tip
When experimenting with code, "commenting out" parts of your program is a convenient way to remove lines that may be buggy. This leaves the lines in the code, but turns them into comments, so the compiler just ignores them. This can be especially useful when trying to locate a problem, or when a program refuses to compile and the compiler error is cryptic or unhelpful. -

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Comparison.html b/arduino-0018-linux-x64/reference/Comparison.html deleted file mode 100644 index e8ab3c1..0000000 --- a/arduino-0018-linux-x64/reference/Comparison.html +++ /dev/null @@ -1,94 +0,0 @@ - - - - Arduino - Comparison - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Arduino/Processing Language Comparison

-

The Arduino language (based on Wiring) is implemented in C/C++, and therefore has some differences from the Processing language, which is based on Java. -

-

Arrays

-
Arduino - Processing -
int bar[8];
bar[0] = 1; -
int[] bar = new int[8];
bar[0] = 1; -
int foo[] = { 0, 1, 2 }; - int foo[] = { 0, 1, 2 };
or
int[] foo = { 0, 1, 2 }; -
-

Loops

-
Arduino - Processing -
int i;
for (i = 0; i < 5; i++) { ... } -
for (int i = 0; i < 5; i++) { ... } -
-

Printing

-
Arduino - Processing -
Serial.println("hello world"); - println("hello world"); -
int i = 5;
Serial.println(i); -
int i = 5;
println(i); -
int i = 5;
Serial.print("i = ");
Serial.print(i);
Serial.println(); -
int i = 5;
println("i = " + i); -
-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Const.html b/arduino-0018-linux-x64/reference/Const.html deleted file mode 100644 index 1042b50..0000000 --- a/arduino-0018-linux-x64/reference/Const.html +++ /dev/null @@ -1,90 +0,0 @@ - - - - Arduino - Const - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

const keyword

-

The const keyword stands for constant. It is a variable qualifier that modifies the behavior of the variable, making a variable "read-only". This means that the variable can be used just as any other variable of its type, but its value cannot be changed. You will get a compiler error if you try to assign a value to a const variable. -

-

Constants defined with the const keyword obey the rules of variable scoping that govern other variables. This, and the pitfalls of using#define, makes the const keyword a superior method for defining constants and is preferred over using #define. -

-

Example

-
-const float pi = 3.14;
-float x;
-
-// ....
-
-x = pi * 2;    // it's fine to use const's in math
-
-pi = 7;        // illegal - you can't write to (modify) a constant
-
-
-

#define or const

-

You can use either const or #define for creating numeric or string constants. For arrays, you will need to use const. In general const is preferred over #define for defining constants. -

-

See also: -

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Constrain.html b/arduino-0018-linux-x64/reference/Constrain.html deleted file mode 100644 index d56b429..0000000 --- a/arduino-0018-linux-x64/reference/Constrain.html +++ /dev/null @@ -1,92 +0,0 @@ - - - - Arduino - Constrain - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

constrain(x, a, b)

-

Description

-

Constrains a number to be within a range. -

-

Parameters

-

x: the number to constrain, all data types -

-

a: the lower end of the range, all data types -

-

b: the upper end of the range, all data types -

-

Returns

-

x: if x is between a and b -

-

a: if x is less than a -

-

b: if x is greater than b -

-

Example

-
sensVal = constrain(sensVal, 10, 150);
-// limits range of sensor values to between 10 and 150 
-
-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Continue.html b/arduino-0018-linux-x64/reference/Continue.html deleted file mode 100644 index 5ea4968..0000000 --- a/arduino-0018-linux-x64/reference/Continue.html +++ /dev/null @@ -1,84 +0,0 @@ - - - - Arduino - Continue - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

continue

-

The continue statement skips the rest of the current iteration of a loop (do, for, or while). It continues by checking the conditional expression of the loop, and proceeding with any subsequent iterations. -

-

Example

-
-
-for (x = 0; x < 255; x ++)
-{
-    if (x > 40 && x < 120){      // create jump in values
-        continue;
-    }
-
-    digitalWrite(PWMpin, x);
-    delay(50);
-}
-
-
-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Cos.html b/arduino-0018-linux-x64/reference/Cos.html deleted file mode 100644 index 130c650..0000000 --- a/arduino-0018-linux-x64/reference/Cos.html +++ /dev/null @@ -1,84 +0,0 @@ - - - - Arduino - Cos - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

cos(rad)

-

Description

-

Calculates the cos of an angle (in radians). The result will be between -1 and 1.
-

Parameters

-

rad: the angle in radians (float) -

-

Returns

-

The cos of the angle ("double") -

-

Note

-

Serial.print() and Serial.println() do not currently support printing floats. -

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Define.html b/arduino-0018-linux-x64/reference/Define.html deleted file mode 100644 index 2aec281..0000000 --- a/arduino-0018-linux-x64/reference/Define.html +++ /dev/null @@ -1,99 +0,0 @@ - - - - Arduino - Define - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Define

-

#define is a useful C component that allows the programmer to give a name to a constant value before the program is compiled. Defined constants in arduino don't take up any program memory space on the chip. The compiler will replace references to these constants with the defined value at compile time. -

-

This can have some unwanted side effects though, if for example, a constant name that had been #defined is included in some other constant or variable name. In that case the text would be replaced by the #defined number (or text). -

-

In general, the const keyword is preferred for defining constants and should be used instead of #define. -

-

Arduino defines have the same syntax as C defines: -

-

Syntax

-

#define constantName value -

-

Note that the # is necessary. -

-

Example

-
#define ledPin 3
-// The compiler will replace any mention of ledPin with the value 3 at compile time.
-
-

Tip

-

There is no semicolon after the #define statement. If you include one, the compiler will throw cryptic errors further down the page. -

-

#define ledPin 3;    // this is an error 
-
-
-

Similarly, including an equal sign after the #define statement will also generate a cryptic compiler error further down the page. -

-

#define ledPin  = 3  // this is also an error 
-
-
-

See

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Delay.html b/arduino-0018-linux-x64/reference/Delay.html deleted file mode 100644 index 6f4a923..0000000 --- a/arduino-0018-linux-x64/reference/Delay.html +++ /dev/null @@ -1,108 +0,0 @@ - - - - Arduino - Delay - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

delay()

-

Description

-

Pauses the program for the amount of time (in miliseconds) specified as parameter. (There are 1000 milliseconds in a second.) -

-

Syntax

-

delay(ms) -

-

Parameters

-

ms: the number of milliseconds to pause (unsigned long) -

-

Returns

-

nothing -

-

Example

-
-int ledPin = 13;                 // LED connected to digital pin 13
-
-void setup()
-{
-  pinMode(ledPin, OUTPUT);      // sets the digital pin as output
-}
-
-void loop()
-{
-  digitalWrite(ledPin, HIGH);   // sets the LED on
-  delay(1000);                  // waits for a second
-  digitalWrite(ledPin, LOW);    // sets the LED off
-  delay(1000);                  // waits for a second
-}
-
-
-

Caveat

-

While it is easy to create a blinking LED with the delay() function, and many sketches use short delays for such tasks as switch debouncing, the use of delay() in a sketch has significant drawbacks. No other reading of sensors, mathematical calculations, or pin manipulation can go on during the delay function, so in effect, it brings most other activity to a halt. For alternative approaches to controlling timing see the millis() function and the sketch sited below. More knowledgeable programmers usually avoid the use of delay() for timing of events longer than 10's of milliseconds unless the Arduino sketch is very simple. -

-

Certain things do go on while the delay() function is controlling the Atmega chip however, because the delay function does not disable interrupts. Serial communication that appears at the RX pin is recorded, PWM (analogWrite) values and pin states are maintained, and interrupts will work as they should. -

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/DelayMicroseconds.html b/arduino-0018-linux-x64/reference/DelayMicroseconds.html deleted file mode 100644 index 66ee0ef..0000000 --- a/arduino-0018-linux-x64/reference/DelayMicroseconds.html +++ /dev/null @@ -1,110 +0,0 @@ - - - - Arduino - DelayMicroseconds - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

delayMicroseconds()

-

Description

-

Pauses the program for the amount of time (in microseconds) specified as parameter. There are a thousand microseconds in a millisecond, and a million microseconds in a second. -

-

Currently, the largest value that will produce an accurate delay is 16383. This could change in future Arduino releases. For delays longer than a few thousand microseconds, you should use delay() instead. -

-

Parameters

-

us: the number of microseconds to pause (unsigned int) -

-

Returns

-

None -

-

Example

-
 
-int outPin = 8;                 // digital pin 8
-
-void setup()
-{
-  pinMode(outPin, OUTPUT);      // sets the digital pin as output
-}
-
-void loop()
-{
-  digitalWrite(outPin, HIGH);   // sets the pin on
-  delayMicroseconds(50);        // pauses for 50 microseconds      
-  digitalWrite(outPin, LOW);    // sets the pin off
-  delayMicroseconds(50);        // pauses for 50 microseconds      
-}
-
-
-

configures pin number 8 to work as an output pin. It sends a train of pulses with 100 microseconds period. -

-

Caveats and Known Issues

-

This function works very accurately in the range 3 microseconds and up. We cannot assure that delayMicroseconds will perform precisely for smaller delay-times. -

-

To ensure more accurate delays, this functions disables interrupts during its operation, meaning that some things (like receiving serial data, or incrementing the value returned by millis()) will not happen during the delay. Thus, you should only use this function for short delays, and use delay() for longer ones. -

-

delayMicroseconds(0) will generate a much longer delay than expected (~1020 us) as will using negative numbers as a parameter. -

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/DetachInterrupt.html b/arduino-0018-linux-x64/reference/DetachInterrupt.html deleted file mode 100644 index 3576883..0000000 --- a/arduino-0018-linux-x64/reference/DetachInterrupt.html +++ /dev/null @@ -1,76 +0,0 @@ - - - - Arduino - DetachInterrupt - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

detachInterrupt(interrupt)

-

Description

-

Turns off the given interrupt. -

-

Parameters

-

interrupt: the number of interrupt to disable (0 or 1). -

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/DigitalRead.html b/arduino-0018-linux-x64/reference/DigitalRead.html deleted file mode 100644 index a7dbbc2..0000000 --- a/arduino-0018-linux-x64/reference/DigitalRead.html +++ /dev/null @@ -1,110 +0,0 @@ - - - - Arduino - DigitalRead - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

digitalRead()

-

Description

-

Reads the value from a specified digital pin, either HIGH or LOW. -

-

Syntax

-

digitalRead(pin) -

-

Parameters

-

pin: the number of the digital pin you want to read (int) -

-

Returns

-

HIGH or LOW -

-

Example

-
 
-int ledPin = 13; // LED connected to digital pin 13
-int inPin = 7;   // pushbutton connected to digital pin 7
-int val = 0;     // variable to store the read value
-
-void setup()
-{
-  pinMode(ledPin, OUTPUT);      // sets the digital pin 13 as output
-  pinMode(inPin, INPUT);      // sets the digital pin 7 as input
-}
-
-void loop()
-{
-  val = digitalRead(inPin);   // read the input pin
-  digitalWrite(ledPin, val);    // sets the LED to the button's value
-}
-
-
-

Sets pin 13 to the same value as the pin 7, which is an input. -

-

Note

-

If the pin isn't connected to anything, digitalRead() can return either HIGH or LOW (and this can change randomly). -

-

The analog input pins can be used as digital pins w/ numbers 14 (analog input 0) to 19 (analog input 5). -

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/DigitalWrite.html b/arduino-0018-linux-x64/reference/DigitalWrite.html deleted file mode 100644 index eba6f0b..0000000 --- a/arduino-0018-linux-x64/reference/DigitalWrite.html +++ /dev/null @@ -1,113 +0,0 @@ - - - - Arduino - DigitalWrite - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

digitalWrite()

-

Description

-

Write a HIGH or a LOW value to a digital pin. -

-

If the pin has been configured as an OUTPUT with pinMode(), its voltage will be set to the corresponding value: 5V (or 3.3V on 3.3V boards) for HIGH, 0V (ground) for LOW. -

-

If the pin is configured as an INPUT, writing a HIGH value with digitalWrite() will enable an internal 20K pullup resistor (see the tutorial on digital pins). Writing LOW will disable the pullup. The pullup resistor is enough to light an LED dimly, so if LEDs appear to work, but very dimly, this is a likely cause. The remedy is to set the pin to an output with the pinMode() function. -

-

Syntax

-

digitalWrite(pin, value) -

-

Parameters

-

pin: the pin number -

-

value: HIGH or LOW -

-

Returns

-

none -

-

Example

-
 
-int ledPin = 13;                 // LED connected to digital pin 13
-
-void setup()
-{
-  pinMode(ledPin, OUTPUT);      // sets the digital pin as output
-}
-
-void loop()
-{
-  digitalWrite(ledPin, HIGH);   // sets the LED on
-  delay(1000);                  // waits for a second
-  digitalWrite(ledPin, LOW);    // sets the LED off
-  delay(1000);                  // waits for a second
-}
-
-
-

Sets pin 13 to HIGH, makes a one-second-long delay, and sets the pin back to LOW. -

-

Note

-

The analog input pins can also be used as digital pins, referred to as numbers 14 (analog input 0) to 19 (analog input 5). -

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/DoWhile.html b/arduino-0018-linux-x64/reference/DoWhile.html deleted file mode 100644 index fc452fd..0000000 --- a/arduino-0018-linux-x64/reference/DoWhile.html +++ /dev/null @@ -1,87 +0,0 @@ - - - - Arduino - DoWhile - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

do - while

-

The do loop works in the same manner as the while loop, with the exception that the condition is tested at the end of the loop, so the do loop will always run at least once. -

-

-do
-{
-    // statement block
-} while (test condition);
-
-
-

Example

-
-do
-{
-  delay(50);          // wait for sensors to stabilize
-  x = readSensors();  // check the sensors
-
-} while (x < 100);
-
-
-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Double.html b/arduino-0018-linux-x64/reference/Double.html deleted file mode 100644 index 4b9c1a5..0000000 --- a/arduino-0018-linux-x64/reference/Double.html +++ /dev/null @@ -1,78 +0,0 @@ - - - - Arduino - Double - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

double

-

Desciption

-

Double precision floating point number. Occupies 4 bytes. -

-

The double implementation on the Arduino is currently exactly the same as the float, with no gain in precision. -

-

Tip

-

Users who borrow code from other sources that includes double variables may wish to examine the code to see if the implied precision is different from that actually achieved on the Arduino. -

-

See:

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/EEPROM.html b/arduino-0018-linux-x64/reference/EEPROM.html deleted file mode 100644 index fbeda8b..0000000 --- a/arduino-0018-linux-x64/reference/EEPROM.html +++ /dev/null @@ -1,73 +0,0 @@ - - - - Arduino - EEPROM - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

EEPROM Library

-

The microcontroller on the Arduino board has 512 bytes of EEPROM: memory whose values are kept when the board is turned off (like a tiny hard drive). This library enables you to read and write those bytes. -

-

Functions

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/EEPROMRead.html b/arduino-0018-linux-x64/reference/EEPROMRead.html deleted file mode 100644 index dc05d93..0000000 --- a/arduino-0018-linux-x64/reference/EEPROMRead.html +++ /dev/null @@ -1,109 +0,0 @@ - - - - Arduino - EEPROMRead - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

byte EEPROM.read(address)

-

Description

-

Reads a byte from the EEPROM. Locations that have never been written to have the value of 255. -

-

Parameters

-

address: the location to read from, from 0 to 511 (int) -

-

Returns

-

the value stored in that location (byte) -

-

Example

-
-#include <EEPROM.h>
-
-int a = 0;
-int value;
-
-void setup()
-{
-  Serial.begin(9600);
-}
-
-void loop()
-{
-  value = EEPROM.read(a);
-
-  Serial.print(a);
-  Serial.print("\t");
-  Serial.print(value);
-  Serial.println();
-
-  a = a + 1;
-
-  if (a == 512)
-    a = 0;
-
-  delay(500);
-}
-
-
-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/EEPROMWrite.html b/arduino-0018-linux-x64/reference/EEPROMWrite.html deleted file mode 100644 index fffacc8..0000000 --- a/arduino-0018-linux-x64/reference/EEPROMWrite.html +++ /dev/null @@ -1,102 +0,0 @@ - - - - Arduino - EEPROMWrite - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

EEPROM.write(address, value)

-

Description

-

Write a byte to the EEPROM. -

-

Parameters

-

address: the location to write to, from 0 to 511 (int) -

-

value: the value to write, from 0 to 255 (byte) -

-

Returns

-

none -

-

The Atmega 168 datasheet says that EEPROM memory has a specified life of 100000 write/erase cycles, so there is a limit to how many times you can write information to that memory space. Keep this in mind for long-lived projects or fast-moving data. -

-

The datasheet also specifies that a write cycle takes 3.3 ms to complete. Other EEPROM write and read requests will fail if executed in this time period. This delay appears to be built into the EEPROM library as a casual test shows each cycle taking 3.33 ms to execute. -

-

Hence, you do not specifically need to add a delay to an EEPROM write, just be aware of the built-in time delay. -

-

Example

-
-#include <EEPROM.h>
-
-void setup()
-{
-  for (int i = 0; i < 512; i++)
-    EEPROM.write(i, i);
-}
-
-void loop()
-{
-}
-
-
-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Else.html b/arduino-0018-linux-x64/reference/Else.html deleted file mode 100644 index ece51e9..0000000 --- a/arduino-0018-linux-x64/reference/Else.html +++ /dev/null @@ -1,103 +0,0 @@ - - - - Arduino - Else - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

if / else

-

if/else allows greater control over the flow of code than the basic if statement, by allowing multiple tests to be grouped together. For example, an analog input could be tested and one action taken if the input was less than 500, and another action taken if the input was 500 or greater. The code would look like this: -

-

if (pinFiveInput < 500)
-{
-  // action A
-}
-else
-{
-  // action B
-}
-
-

else can proceed another if test, so that multiple, mutually exclusive tests can be run at the same time. -

-

Each test will proceed to the next one until a true test is encountered. When a true test is found, its associated block of code is run, and the program then skips to the line following the entire if/else construction. If no test proves to be true, the default else block is executed, if one is present, and sets the default behavior. -

-

Note that an else if block may be used with or without a terminating else block and vice versa. An unlimited number of such else if branches is allowed. -

-

if (pinFiveInput < 500)
-{
-  // do Thing A
-}
-else if (pinFiveInput >= 1000)
-{
-  // do Thing B
-}
-else
-{
-  // do Thing C
-}
-
-

Another way to express branching, mutually exclusive tests, is with the switch case statement. -

-

See also:

-

switch case -

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Ethernet.html b/arduino-0018-linux-x64/reference/Ethernet.html deleted file mode 100644 index 95361e9..0000000 --- a/arduino-0018-linux-x64/reference/Ethernet.html +++ /dev/null @@ -1,96 +0,0 @@ - - - - Arduino - Ethernet - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Ethernet library

-

With the Arduino Ethernet Shield, this library allows an Arduino board to connect to the internet. It can serve as either a server accepting incoming connections or a client making outgoing ones. The library supports up to four concurrent connection (incoming or outgoing or a combination). -

-

Ethernet class

-

The Ethernet class initializes the ethernet library and network settings. -

-

Server class

-

The Server class creates servers which can send data to and receive data from connected clients (programs running on other computers or devices). -

-

Client class

-

The client class creates clients that can connect to servers and send and receive data. -

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/EthernetBegin.html b/arduino-0018-linux-x64/reference/EthernetBegin.html deleted file mode 100644 index ffd56d9..0000000 --- a/arduino-0018-linux-x64/reference/EthernetBegin.html +++ /dev/null @@ -1,102 +0,0 @@ - - - - Arduino - EthernetBegin - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Ethernet -

-

Ethernet.begin()

-

Description

-

Initializes the ethernet library and network settings. -

-

Syntax

-

Ethernet.begin(mac, ip);
Ethernet.begin(mac, ip, gateway);
Ethernet.begin(mac, ip, gateway, subnet);
-

Parameters

-

mac: the MAC address for the device (array of 6 bytes) -

-

ip: the IP address of the device (array of 4 bytes) -

-

gateway: the IP address of the network gateway (array of 4 bytes). optional: defaults to the device IP address with the last octet set to 1 -

-

subnet: the subnet mask of the network (array of 4 bytes). optional: defaults to 255.255.255.0 -

-

Returns

-

None -

-

Example

-
-#include <Ethernet.h>
-
-byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
-byte ip[] = { 10, 0, 0, 177 };
-
-void setup()
-{
-  Ethernet.begin(mac, ip);
-}
-
-void loop () {}
-
-
-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/FAQ.html b/arduino-0018-linux-x64/reference/FAQ.html deleted file mode 100644 index 981931c..0000000 --- a/arduino-0018-linux-x64/reference/FAQ.html +++ /dev/null @@ -1,125 +0,0 @@ - - - - Arduino - FAQ - - - - -
- - - - - - -
- -
-

Frequently Asked Questions

-

What is an Arduino? -

-

Glad you asked, we have a great introduction page on Arduino, click here to read it. -

-

What do you mean by open-source hardware? -

-

Open-source hardware shares much of the principles and approach of free and open-source software. In particular, we believe that people should be able to study our hardware to understand how it works, make changes to it, and share those changes. To facilitate this, we release all of the original design files (Eagle CAD) for the Arduino hardware. These files are licensed under a Creative Commons Attribution Share-Alike license, which allows for both personal and commercial derivative works, as long as they credit Arduino and release their designs under the same license. -

-

The Arduino software is also open-source. The source code for the Java environment is released under the GPL and the C/C++ microcontroller libraries are under the LGPL. -

-

How can I get an Arduino board? -

-

You can buy an Arduino board from one of the distributors listed on the buy page. If you'd prefer to build your own, see the Arduino Single-Sided Serial board, which can be easily etched and assembled. -

-

Who makes Arduino boards? -

-

Most of the official Arduino boards are manufactured by SmartProjects in Italy. The Arduino Pro, Pro Mini, and LilyPad are manufactured by SparkFun Electronics (a US company). The Arduino Nano is manufactured by Gravitech (also a US company). -

-

Which are the official Arduino boards? -

-

The official Arduino boards are the ones listed on the hardware page: the Duemilanove, Nano, Mega, Bluetooth (BT), LilyPad, Mini, Pro, Pro Mini, and a few older models, along with the Ethernet, XBee, motor, and prototyping shields. These are boards whose manufacturers work with the Arduino team to ensure a good user experience, compatibility with the Arduino software, and a quality product. In return for their status as official boards, the manufacturers pay a licensing fee to the Arduino team to support the further development of the project. -

-

In general, we try to restrict use of the name “Arduino†to the official boards. If you find a product under a different name but described as “Arduino compatibleâ€, it’s probably not an official board and doesn’t fund continued work on the project. -

-

I want to design my own board; what should I do? -

-

The reference designs for the Arduino boards are available from the hardware page. They're licensed under a Creative Commons Attribution Share-Alike license, so you are free to use and adapt them for your own needs without asking permission or paying a fee. If you're looking to make something of interest to the community, we'd encourage you to discuss your ideas on the hardware development forum so that potential users can offer suggestions. -

-

What should I call my boards? -

-

If you're making your own board, come up with your own name! This will allow people identify you with your products and help you to build a brand. Be creative: try to suggest what people might use the board for, or emphasize the form factor, or just pick a random word that sounds cool. "Arduino" is a trademark of Arduino team and should not be used for unofficial variants. If you're interested in having your design included in the official Arduino product line, please see the So you want to make an Arduino document and contact the Arduino team. Note that while we don't attempt to restrict uses of the "duino" suffix, its use causes the Italians on the team to cringe (apparently it sounds terrible); you might want to avoid it. -

-

Can I build a commercial product based on Arduino? -

-

Yes, with the following conditions: -

-

  • Physically embedding an Arduino board inside a commercial product does not require you to disclose or open-source any information about its design. -

  • Deriving the design of a commercial product from the Eagle files for an Arduino board requires you to release the modified files under the same Creative Commons Attribution Share-Alike license. You may manufacture and sell the resulting product. -

  • Using the Arduino core and libraries for the firmware of a commercial product does not require you to release the source code for the firmware. The LGPL does, however, require you to make available object files that allow for the relinking of the firmware against updated versions of the Arduino core and libraries. Any modifications to the core and libraries must be released under the LGPL. -

  • The source code for the Arduino environment is covered by the GPL, which requires any modifications to be open-sourced under the same license. It does not prevent the sale of derivative software or its inclusion in commercial products. -

In all cases, the exact requirements are determined by the applicable license. Additionally, see the previous question for information about the use of the name “Arduinoâ€. -

-

-How can I run the Arduino IDE under Linux? -

-

See instructions for Ubuntu Linux, for Debian Linux, for Gentoo Linux, for Linux, or for Linux on PPC. This this forum thread has more information. Or, you can use Arduino from the command line, and not have to install Java. -

-

Can I program the Arduino board in C? -

-

In fact, you already are; the Arduino language is merely a set of C/C++ functions that can be called from your code. Your sketch undergoes minor changes (e.g. automatic generation of function prototypes) and then is passed directly to a C/C++ compiler (avr-g++). All standard C and C++ constructs supported by avr-g++ should work in Arduino. For more details, see the page on the Arduino build process. -

-

Can I use a different IDE to program the Arduino board? -

-

It is possible to compile programs for the Arduino using a Makefile and the command line. If you can get your IDE to run make, you should be all set. -

-

Can I use an Arduino board without the Arduino software? -

-

Sure. It's just an AVR development board, you can use straight AVR C or C++ (with avr-gcc and avrdude or AVR Studio) to program it. -

-

Can I use the Arduino software with other AVR boards? -

-

Yes, although it may require some modifications to the Arduino core libraries. See the porting page in the Arduino Google Code project for details. -

-

Troubleshooting

-

These questions have moved to the troubleshooting section of the Arduino guide. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Float.html b/arduino-0018-linux-x64/reference/Float.html deleted file mode 100644 index ce02ead..0000000 --- a/arduino-0018-linux-x64/reference/Float.html +++ /dev/null @@ -1,98 +0,0 @@ - - - - Arduino - Float - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

float

-

Description

-

Datatype for floating-point numbers, a number that has a decimal point. Floating-point numbers are often used to approximate analog and continuous values because they have greater resolution than integers. Floating-point numbers can be as large as 3.4028235E+38 and as low as -3.4028235E+38. They are stored as 32 bits (4 bytes) of information. -

-

Floating point numbers are not exact, and may yield strange results when compared. For example 6.0 / 3.0 may not equal 2.0. You should instead check that the absolute value of the difference between the numbers is less than some small number. -

-

Floating point math is also much slower than integer math in performing calculations, so should be avoided if, for example, a loop has to run at top speed for a critical timing function. Programmers often go to some lengths to convert floating point calculations to integer math to increase speed. -

-

Examples

-
    float myfloat;
-    float sensorCalbrate = 1.117;
-
-

Syntax

-
    float var = val;
-
-

  • var - your float variable name -
  • val - the value you assign to that variable -

Example Code

-
-   int x;
-   int y;
-   float z;
-
-   x = 1;
-   y = x / 2;            // y now contains 0, ints can't hold fractions
-   z = (float)x / 2.0;   // z now contains .5 (you have to use 2.0, not 2)
-
-

See Also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/FloatCast.html b/arduino-0018-linux-x64/reference/FloatCast.html deleted file mode 100644 index e45d843..0000000 --- a/arduino-0018-linux-x64/reference/FloatCast.html +++ /dev/null @@ -1,82 +0,0 @@ - - - - Arduino - FloatCast - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

float()

-

Description

-

Converts a value to the float data type. -

-

Syntax

-

float(x) -

-

Parameters

-

x: a value of any type -

-

Returns

-

float -

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/For.html b/arduino-0018-linux-x64/reference/For.html deleted file mode 100644 index 3d5efb1..0000000 --- a/arduino-0018-linux-x64/reference/For.html +++ /dev/null @@ -1,105 +0,0 @@ - - - - Arduino - For - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

for statements

-

Desciption

-

The for statement is used to repeat a block of statements enclosed in curly braces. An increment counter is usually used to increment and terminate the loop. The for statement is useful for any repetitive operation, and is often used in combination with arrays to operate on collections of data/pins. -

-

There are three parts to the for loop header: -

-

for (initialization; condition; increment) { -

-

//statement(s); -

-

} -

-

The initialization happens first and exactly once. Each time through the loop, the condition is tested; if it's true, the statement block, and the increment is executed, then the condition is tested again. When the condition becomes false, the loop ends. -

-

Example

-
-// Dim an LED using a PWM pin
-int PWMpin = 10; // LED in series with 1k resistor on pin 10
-
-void setup()
-{
-  // no setup needed
-}
-
-void loop()
-{
-   for (int i=0; i <= 255; i++){
-      analogWrite(PWMpin, i);
-      delay(10);
-   } 
-}
-
-
-

Coding Tip

-

The C for loop is much more flexible than for loops found in some other computer languages, including BASIC. Any or all of the three header elements may be omitted, although the semicolons are required. Also the statements for initialization, condition, and increment can be any valid C statements with unrelated variables. These types of unusual for statements may provide solutions to some rare programming problems. -

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Fpconstants.html b/arduino-0018-linux-x64/reference/Fpconstants.html deleted file mode 100644 index c8f6394..0000000 --- a/arduino-0018-linux-x64/reference/Fpconstants.html +++ /dev/null @@ -1,86 +0,0 @@ - - - - Arduino - Fpconstants - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

floating point constants

-

Similar to integer constants, floating point constants are used to make code more readable. Floating point constants are swapped at compile time for the value to which the expression evaluates. -

-

Examples: -

-

n = .005; -

-

Floating point constants can also be expressed in a variety of scientific notation. 'E' and 'e' are both accepted as valid exponent indicators. -

-

-
-floating-point   evaluates to:      also evaluates to:
-  constant 
-
-   10.0	             10
-  2.34E5          2.34 * 10^5             234000
-  67e-12        67.0 * 10^-12         .000000000067
-
-
-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Goto.html b/arduino-0018-linux-x64/reference/Goto.html deleted file mode 100644 index 1e45932..0000000 --- a/arduino-0018-linux-x64/reference/Goto.html +++ /dev/null @@ -1,93 +0,0 @@ - - - - Arduino - Goto - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

goto

-

Transfers program flow to a labeled point in the program -

-

Syntax

-

label: -

-

goto label; // sends program flow to the label -

-

Tip

-

The use of goto is discouraged in C programming, and some authors of C programming books claim that the goto statement is never necessary, but used judiciously, it can simplify certain programs. The reason that many programmers frown upon the use of goto is that with the unrestrained use of goto statements, it is easy to create a program with undefined program flow, which can never be debugged. -

-

With that said, there are instances where a goto statement can come in handy, and simplify coding. One of these situations is to break out of deeply nested for loops, or if logic blocks, on a certain condition. -

-

Example

-
-for(byte r = 0; r < 255; r++){
-    for(byte g = 255; g > -1; g--){
-        for(byte b = 0; b < 255; b++){
-            if (analogRead(0) > 250){ goto bailout;}
-            // more statements ... 
-        }
-    }
-}
-bailout:
-
-
-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Guide_ArduinoBT.html b/arduino-0018-linux-x64/reference/Guide_ArduinoBT.html deleted file mode 100644 index 6c155d2..0000000 --- a/arduino-0018-linux-x64/reference/Guide_ArduinoBT.html +++ /dev/null @@ -1,80 +0,0 @@ - - - - Arduino - ArduinoBT - - - - -
- - - - - - -
- -
-

ArduinoBT

-

The Arduino BT is an Arduino board with built-in bluetooth module, allowing for wireless communication. To get started with the Arduino BT, follow the directions for the Arduino NG on your operating system (Windows, Mac OS X, Linux), with the following modifications: -

-

  • First, pair the Arduino BT with your computer and create a virtual serial port for it. Look for a bluetooth device called ARDUINOBT and the pass code is 12345. -

  • Select Arduino BT from the Tools | Board menu of the Arduino environment. -

Information about the Arduino BT

-

In most respects, the Arduino BT is similar to the Arduino Diecimila. Here are the main differences of BT board (besides the fact that it communicates over bluetooth instead of USB): -

-

  • The Arduino BT is more fragile and easy to break than a regular Arduino board. -

  • Don't power the board with more than 5.5 volts to the or reverse the polarity (power and ground pins) of your power supply, or you might kill the ATmega168 on the Arduino BT. The Arduino BT can, however, run with a minimum of 1.2 volts, making it easier to power with batteries. -

  • The microcontroller (an ATmega168) on the Arduino BT is a physically smaller version of the chip on the USB Arduino boards. You can't remove it, so if you kill it, you need a new Arduino BT. -

  • There are two extra analog inputs on the Arduino BT (8 total). Two of these, however, are not connected to the pin headers on the board; you'll need to solder something to the pads next to the numbers "6" and "7". -

  • Pin 7 is connected to the reset pin of the bluetooth module; don't use it for anything (except resetting the module). -

For more details, see the Arduino BT hardware page. -

-

Using the Arduino BT

-

The on-board serial communication between the bluetooth module and the Arduino sketch (running on the ATmega168) needs to be at 115200 baud (i.e. call Serial.begin(115200) in your setup() function). Communication between the bluetooth module and the computer can be at any baud rate. -

-

Communication between the BT module and the computer can be temperamental. You might want to open the serial monitor a couple of seconds after resetting the board. -The text of the Arduino getting started guide is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the guide are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Guide_ArduinoEthernetShield.html b/arduino-0018-linux-x64/reference/Guide_ArduinoEthernetShield.html deleted file mode 100644 index dc30f26..0000000 --- a/arduino-0018-linux-x64/reference/Guide_ArduinoEthernetShield.html +++ /dev/null @@ -1,73 +0,0 @@ - - - - Arduino - ArduinoEthernetShield - - - - -
- - - - - - -
- -
-

Arduino Ethernet Shield

-

The Arduino Ethernet shield allows an Arduino board to connect to the internet using the Ethernet library. -

-

Connecting the Shield

-
-

To use the shield, mount it on top of an Arduino board (e.g. the Diecimila). To upload sketches to the board, connect it to your computer with a USB cable as you normally would. Once the sketch has been uploaded, you can disconnect the board from your computer and power it with an external power supply. -

-

Connect the shield to your computer or a network hub or router using a standard ethernet cable (CAT5 or CAT6 with RJ45 connectors). Connecting to a computer may require the use of a cross-over cable (although many computers, including all recent Macs can do the cross-over internally). -

-

Network Settings

-

The shield must be assigned a MAC address and a fixed IP address using the Ethernet.begin() function. A MAC address is a globally unique identifier for a particular device; inventing a random one should work, but don't use the same one for multiple boards. Valid IP addresses depend on the configuration of your network. (It is possible to use DHCP to dynamically assign an IP to the shield, but this is not yet implemented.) Optionally, you can also specify a network gateway and subnet. -

-

The text of the Arduino getting started guide is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the guide are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Guide_ArduinoLilyPad.html b/arduino-0018-linux-x64/reference/Guide_ArduinoLilyPad.html deleted file mode 100644 index 46244d9..0000000 --- a/arduino-0018-linux-x64/reference/Guide_ArduinoLilyPad.html +++ /dev/null @@ -1,81 +0,0 @@ - - - - Arduino - ArduinoLilyPad - - - - -
- - - - - - -
- -
-

Guide to the LilyPad Arduino

-

To get started with the LilyPad Arduino, follow the directions for the Arduino NG on your operating system (Windows, Mac OS X, Linux. Connecting the LilyPad Arduino is a bit more complicated than a regular Arduino board (see below for instructions and photos). -

-

The LilyPad Arduino is more fragile and easy to break than a regular Arduino board. Don't connect more than 5.5 volts to the + tab or reverse the power and ground pins of your power supply, or you will very likely kill the ATmega on the LilyPad Arduino. You can't remove the ATmega, so if you kill it, you need a new LilyPad. -

-

Note: More information about getting started with the LilyPad Arduino can be found here. -

-

-

Connecting the LilyPad Arduino

-

To program the LilyPad Arduino, you need to connect it to your computer. The SparkFun FTDI Basic Breakout plugs into the 6-pin male header on the newest version of the LilyPad. Use a USB MiniB cable to connect the FTDI basic breakout to your computer. You can also use an FTDI USB-TTL Serial cable. -

-

-

To connect earlier versions of the board or for information on other connection options see the LilyPad Arduino tutorial on Leah's website -

-

Sewing the LilyPad Arduino

-

The hole on each tab of the LilyPad is large enough for a sewing needle to pass through. You can make both electrical and physical connections with stitching in conductive thread. Sew through the holes several times to insure good contact. Here's a picture showing a sewn LilyPad: -

-

-

See the LilyPad Arduino tutorial on Leah's website for more information about building a working wearable. See SparkFun for more stitchable modules that you can use with your LilyPad Arduino. -

-

The text of the Arduino getting started guide is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the guide are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Guide_ArduinoNano.html b/arduino-0018-linux-x64/reference/Guide_ArduinoNano.html deleted file mode 100644 index 8fb6f0f..0000000 --- a/arduino-0018-linux-x64/reference/Guide_ArduinoNano.html +++ /dev/null @@ -1,73 +0,0 @@ - - - - Arduino - ArduinoNano - - - - -
- - - - - - -
- -
-

Guide to the Arduino Nano

-
-

Connecting the Arduino Nano 2.2 to a computer with a Mini-B USB cable. Note the blue power LED underneath the board. -

-


-

-

To connect the Arduino Nano to your computer, you'll need a Mini-B USB cable. This also provides power to the board, as indicated by the blue LED (which is on the bottom of the Arduino Nano 2.x and the top of the Arduino Nano 3.0). -

-

If you have an Arduino Nano 3.0, you'll need to select Arduino Duemilanove or Nano w/ ATmega32 from the Tools > Board menu. If you have an Arduino Nano 2.x, select Arduino Diecimila, Duemilanove, or Nano w/ ATmega168. Select the correct serial port selected from the Tools > Serial Port menu. Then simply press the upload button in the Arduino environment. The board will automatically reset and the sketch will be uploaded. If you have any problems, see the troubleshooting guide. -

-

For more details on the Arduino Nano, see the hardware page. -

-

The text of the Arduino getting started guide is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the guide are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Guide_MacOSX.html b/arduino-0018-linux-x64/reference/Guide_MacOSX.html deleted file mode 100644 index 7e8a9cf..0000000 --- a/arduino-0018-linux-x64/reference/Guide_MacOSX.html +++ /dev/null @@ -1,125 +0,0 @@ - - - - Arduino - MacOSX - - - - -
- - - - - - -
- -
-

How To Get Arduino Running on Mac OS X (10.3.9 or later)

-

This document explains how to connect your Arduino board to the computer and upload your first sketch. -

-

These are the steps that we'll go through: -

-

  1. Get an Arduino board and cable -
  2. Download the Arduino environment -
  3. Install the USB drivers -
  4. Connect the board -
  5. Run the Arduino environment -
  6. Upload a program -
  7. Look for the blinking LED -
  8. Learn to use Arduino -

1 | Get an Arduino board and cable

-

In this tutorial, we assume you're using an Arduino Duemilanove or Diecimila. If you have another board, read the corresponding page in this getting started guide. -

-

The Arduino is a simple board that contains everything you need to start working with electronics and microcontroller programming. This diagram illustrates the major components of an Arduino Diecimila. (The Arduino Duemilanove is almost identical.) -

-

-

You also need a standard USB cable (A plug to B plug): the kind you would connect to a USB printer, for example. -

-

2 | Download the Arduino environment

-

To program the Arduino board you need the Arduino environment. -

-

Download: the latest version from the download page. -

-

When the download finishes, unzip the downloaded file. Make sure to preserve the folder structure. Double-click the folder to open it. There should be a few files and sub-folders inside. -

-

3 | Install the USB drivers

-

If you are using a USB Arduino, you will need to install the drivers for the FTDI chip on the board. These can be found in the drivers directory of the Arduino distribution. -

-

You'll need to select the correct drivers for your computer. Use: -

  • FTDIUSBSerialDriver_v2_1_9.dmg for older (PPC) Macs like the Powerbook, iBook, G4 or G5 -
  • FTDIUSBSerialDriver_v2_2_9_Intel.dmg for newer (Intel) Macs like the MacBook, MacBook Pro, or Mac Pro -

(The latest version of the drivers can be found on the FTDI website.) -

-

4 | Connect the board

-

On the Diecimila, the power source is selected by the jumper between the USB and power plugs. To power the board from the USB port (good for controlling low power devices like LEDs), place the jumper on the two pins closest to the USB plug. To power the board from an external power supply (6-12V), place the jumper on the two pins closest to the power plug. On the Duemilanove, the power source is selected automatically (there is no power selection jumper). In any case, connect the board to a USB port on your computer. -

-

The green power LED (labelled PWR) should go on. -

-

5 | Run the Arduino environment

-

(Mac OSX): Copy the Arduino application to your Applications directory. Double-click the Arduino application. -

-

(Windows): Open the Arduino folder and double-click the Arduino application. -

-

6 | Upload a program

-

Open the LED blink example sketch: File > Sketchbook > Examples > Digital > Blink. -

-

Select the serial device of the Arduino board from the Tools > Serial Port menu. On the Mac, this should be something with /dev/tty.usbserial in it. -

-

You'll need to select the entry in the Tools > Board menu that corresponds to your Arduino. For newer Arduino boards with an ATmega328 (check the text on the chip on the board), select Arduino Duemilanove w/ ATmega328. Previously, Arduino boards came with an ATmega168; for those, select Arduino Diecimila or Duemilanove w/ ATmega168. -

-

Now, simply click the "Upload" button in the environment. Wait a few seconds - you should see the RX and TX leds on the board flashing. If the upload is successful, the message "Done uploading." will appear in the status bar. (Note: If you have an Arduino Mini, NG, or other board, you'll need to physically present the reset button on the board immediately before pressing the upload button.) -

-

-

7 | Look for the blinking LED

-

A few seconds after the upload finishes, you should see the pin 13 (L) LED on the board start to blink (in orange). If it does, congratulations! You've gotten Arduino up-and-running. -

-

If you have problems, please see the troubleshooting suggestions. -

-

8 | Learn to use Arduino

-
  • Examples: try these example programs. -
  • Reference: read the reference for the Arduino language. -

The text of the Arduino getting started guide is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the guide are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Guide_Windows.html b/arduino-0018-linux-x64/reference/Guide_Windows.html deleted file mode 100644 index 5783d2b..0000000 --- a/arduino-0018-linux-x64/reference/Guide_Windows.html +++ /dev/null @@ -1,137 +0,0 @@ - - - - Arduino - Windows - - - - -
- - - - - - -
- -
-

How To Get Arduino Running on Windows

-

This document explains how to connect your Arduino board to the computer and upload your first sketch. -

-

These are the steps that we'll go through: -

-

  1. Get an Arduino board and cable -
  2. Download the Arduino environment -
  3. Install the USB drivers -
  4. Connect the board -
  5. Run the Arduino environment -
  6. Upload a program -
  7. Look for the blinking LED -
  8. Learn to use Arduino -

1 | Get an Arduino board and cable

-

In this tutorial, we assume you're using an Arduino Duemilanove or Diecimila. If you have another board, read the corresponding page in this getting started guide. -

-

The Arduino is a simple board that contains everything you need to start working with electronics and microcontroller programming. This diagram illustrates the major components of an Arduino Diecimila. (The Arduino Duemilanove is almost identical.) -

-

-

You also need a standard USB cable (A plug to B plug): the kind you would connect to a USB printer, for example. -

-

2 | Download the Arduino environment

-

To program the Arduino board you need the Arduino environment. -

-

Download: the latest version from the download page. -

-

When the download finishes, unzip the downloaded file. Make sure to preserve the folder structure. Double-click the folder to open it. There should be a few files and sub-folders inside. -

-

3 | Locate the USB drivers

-

If you are using a USB Arduino, you will need to install the drivers for the FTDI chip on the board. These can be found in the drivers/FTDI USB Drivers directory of the Arduino distribution. In the next step ("Connect the board"), you will point Window's Add New Hardware wizard to these drivers. -

-

The latest version of the drivers can be found on the FTDI website. -

-

4 | Connect the board

-

On the Diecimila, the power source is selected by the jumper between the USB and power plugs. To power the board from the USB port (good for controlling low power devices like LEDs), place the jumper on the two pins closest to the USB plug. To power the board from an external power supply (6-12V), place the jumper on the two pins closest to the power plug. On the Duemilanove, the power source is selected automatically (there is no power selection jumper). In any case, connect the board to a USB port on your computer. -

-

The green power LED (labelled PWR) should go on. -

-

The Add New Hardware wizard will open. Tell it not to connect to Windows update and click next. -

-

-

Then select "Install from a list or specified location (Advanced)" and click next. -

-

-

Make sure that "Search for the best driver in these locations is checked"; uncheck "Search removable media"; check "Include this location in the search" and browse to the location you unzipped the USB drivers to in the previous step. Click next. -

-

-

The wizard will search for the driver and then tell you that a "USB Serial Converter" was found. Click finish. -

-

-

The new hardware wizard will appear again. Go through the same steps. This time, a "USB Serial Port" will be found. -

-

5 | Run the Arduino environment

-

(Mac OSX): Copy the Arduino application to your Applications directory. Double-click the Arduino application. -

-

(Windows): Open the Arduino folder and double-click the Arduino application. -

-

6 | Upload a program

-

Open the LED blink example sketch: File > Sketchbook > Examples > Digital > Blink. -

-

Select the serial device of the Arduino board from the Tools | Serial Port menu. On Windows, this should be COM1 or COM2 for a serial Arduino board, or COM3, COM4, or COM5 for a USB board. To find out, open the Windows Device Mananger (in the Hardware tab of System control panel). Look for a "USB Serial Port" in the Ports section; that's the Arduino board. -

-

-

You'll need to select the entry in the Tools > Board menu that corresponds to your Arduino. For newer Arduino boards with an ATmega328 (check the text on the chip on the board), select Arduino Duemilanove w/ ATmega328. Previously, Arduino boards came with an ATmega168; for those, select Arduino Diecimila or Duemilanove w/ ATmega168. -

-

Now, simply click the "Upload" button in the environment. Wait a few seconds - you should see the RX and TX leds on the board flashing. If the upload is successful, the message "Done uploading." will appear in the status bar. (Note: If you have an Arduino Mini, NG, or other board, you'll need to physically present the reset button on the board immediately before pressing the upload button.) -

-

-

7 | Look for the blinking LED

-

A few seconds after the upload finishes, you should see the pin 13 (L) LED on the board start to blink (in orange). If it does, congratulations! You've gotten Arduino up-and-running. -

-

If you have problems, please see the troubleshooting suggestions. -

-

8 | Learn to use Arduino

-
  • Examples: try these example programs. -
  • Reference: read the reference for the Arduino language. -

The text of the Arduino getting started guide is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the guide are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Guide_index.html b/arduino-0018-linux-x64/reference/Guide_index.html deleted file mode 100644 index a6b9a5c..0000000 --- a/arduino-0018-linux-x64/reference/Guide_index.html +++ /dev/null @@ -1,86 +0,0 @@ - - - - Arduino - Getting Started - - - - -
- - - - - - -
- -
-

Getting Started with Arduino

-

-

Introduction: What Arduino is and why you'd want to use it. -

-

Installation: Step-by-step instructions for setting up the Arduino software and connecting it to an Arduino Duemilanove. -

-

Environment: Description of the Arduino development environment. -

-

Troubleshooting: Advice on what to do if things don't work. -

-

-

Instructions for other boards: -

-

-

The text of the Arduino getting started guide is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the guide are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/HighByte.html b/arduino-0018-linux-x64/reference/HighByte.html deleted file mode 100644 index 6be009e..0000000 --- a/arduino-0018-linux-x64/reference/HighByte.html +++ /dev/null @@ -1,83 +0,0 @@ - - - - Arduino - HighByte - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

highByte()

-

Description

-

Extracts the high-order (leftmost) byte of a word (or the second lowest byte of a larger data type). -

-

Syntax

-

highByte(x) -

-

Parameters

-

x: a value of any type -

-

Returns

-

byte -

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/If.html b/arduino-0018-linux-x64/reference/If.html deleted file mode 100644 index 1401427..0000000 --- a/arduino-0018-linux-x64/reference/If.html +++ /dev/null @@ -1,110 +0,0 @@ - - - - Arduino - If - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

if (conditional) and ==, !=, <, > (comparison operators)

-

if, which is used in conjunction with a comparison operator, tests whether a certain condition has been reached, such as an input being above a certain number. The format for an if test is: -

-

if (someVariable > 50)
-{
-  // do something here
-}
-
-

The program tests to see if someVariable is greater than 50. If it is, the program takes a particular action. Put another way, if the statement in parentheses is true, the statements inside the brackets are run. If not, the program skips over the code. -

-

The brackets may be omitted after an if statement. If this is done, the next line (defined by the semicolon) becomes the only conditional statement. -

-
-if (x > 120) digitalWrite(LEDpin, HIGH); 
-
-if (x > 120)
-digitalWrite(LEDpin, HIGH); 
-
-if (x > 120){ digitalWrite(LEDpin, HIGH); } 
-
-if (x > 120){ 
-  digitalWrite(LEDpin1, HIGH);
-  digitalWrite(LEDpin2, HIGH); 
-}                                 // all are correct
-
-
-

The statements being evaluated inside the parentheses require the use of one or more operators: -

-

Comparison Operators:

-
 x == y (x is equal to y)
- x != y (x is not equal to y)
- x <  y (x is less than y)  
- x >  y (x is greater than y) 
- x <= y (x is less than or equal to y) 
- x >= y (x is greater than or equal to y)
-
-

Warning:

-

Beware of accidentally using the single equal sign (e.g. if (x = 10) ). The single equal sign is the assignment operator, and sets x to 10 (puts the value 10 into the variable x). Instead use the double equal sign (e.g. if (x == 10) ), which is the comparison operator, and tests whether x is equal to 10 or not. The latter statement is only true if x equals 10, but the former statement will always be true. -

-

This is because C evaluates the statement if (x=10) as follows: 10 is assigned to x (remember that the single equal sign is the assignment operator), so x now contains 10. Then the 'if' conditional evaluates 10, which always evaluates to TRUE, since any non-zero number evaluates to TRUE. Consequently, if (x = 10) will always evaluate to TRUE, which is not the desired result when using an 'if' statement. Additionally, the variable x will be set to 10, which is also not a desired action. -

-

if can also be part of a branching control structure using the if...else] construction. -

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Include.html b/arduino-0018-linux-x64/reference/Include.html deleted file mode 100644 index 7a60fa8..0000000 --- a/arduino-0018-linux-x64/reference/Include.html +++ /dev/null @@ -1,84 +0,0 @@ - - - - Arduino - Include - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

#include

-

#include is used to include outside libraries in your sketch. This gives the programmer access to a large group of standard C libraries (groups of pre-made functions), and also libraries written especially for Arduino. -

-

The main reference page for AVR C libraries (AVR is a reference to the Atmel chips on which the Arduino is based) is here. -

-

Note that #include, similar to #define, has no semicolon terminator, and the compiler will yield cryptic error messages if you add one. -

-

Example

-

This example includes a library that is used to put data into the program space flash instead of ram. This saves the ram space for dynamic memory needs and makes large lookup tables more practical. -

-

-#include <avr/pgmspace.h>
-
-prog_uint16_t myConstants[] PROGMEM = {0, 21140, 702  , 9128,  0, 25764, 8456,
-0,0,0,0,0,0,0,0,29810,8968,29762,29762,4500};
-
-
-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Increment.html b/arduino-0018-linux-x64/reference/Increment.html deleted file mode 100644 index e3cefd2..0000000 --- a/arduino-0018-linux-x64/reference/Increment.html +++ /dev/null @@ -1,93 +0,0 @@ - - - - Arduino - Increment - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

++ (increment) / -- (decrement)

-

Description

-

Increment or decrement a variable -

-

Syntax

-
-x++;  // increment x by one and returns the old value of x
-++x;  // increment x by one and returns the new value of x
-
-x-- ;   // decrement x by one and returns the old value of x 
---x ;   // decrement x by one and returns the new value of x  
-
-

Parameters

-

x: an integer or long (possibly unsigned) -

-

Returns

-

The original or newly incremented / decremented value of the variable. -

-

Examples

-
x = 2;
-y = ++x;      // x now contains 3, y contains 3
-y = x--;      // x contains 2 again, y still contains 3 
-
-

See also

-

+=
-= -

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/IncrementCompound.html b/arduino-0018-linux-x64/reference/IncrementCompound.html deleted file mode 100644 index d99177a..0000000 --- a/arduino-0018-linux-x64/reference/IncrementCompound.html +++ /dev/null @@ -1,92 +0,0 @@ - - - - Arduino - IncrementCompound - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

+= , -= , *= , /=

-

Description

-

Perform a mathematical operation on a variable with another constant or variable. The += (et al) operators are just a convenient shorthand for the expanded syntax, listed below. -

-

Syntax

-
-x += y;   // equivalent to the expression x = x + y;
-x -= y;   // equivalent to the expression x = x - y; 
-x *= y;   // equivalent to the expression x = x * y; 
-x /= y;   // equivalent to the expression x = x / y; 
-
-
-

Parameters

-

x: any variable type -

-

y: any variable type or constant -

-

Examples

-
x = 2;
-x += 4;      // x now contains 6
-x -= 3;      // x now contains 3
-x *= 10;     // x now contains 30
-x /= 2;      // x now contains 15
-
-
-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Int.html b/arduino-0018-linux-x64/reference/Int.html deleted file mode 100644 index be3a5f8..0000000 --- a/arduino-0018-linux-x64/reference/Int.html +++ /dev/null @@ -1,101 +0,0 @@ - - - - Arduino - Int - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

int

-

Description

-

Integers are your primary datatype for number storage, and store a 2 byte value. This yields a range of -32,768 to 32,767 (minimum value of -2^15 and a maximum value of (2^15) - 1). -

-

Int's store negative numbers with a technique called 2's complement math. The highest bit, sometimes refered to as the "sign" bit, flags the number as a negative number. The rest of the bits are inverted and 1 is added. -

-

The Arduino takes care of dealing with negative numbers for you, so that arithmetic operations work transparently in the expected manner. There can be an unexpected complication in dealing with the bitshift right operator (>>) however. -

-

Example

-
    int ledPin = 13;
-
-

Syntax

-
    int var = val;
-
-

  • var - your int variable name -
  • val - the value you assign to that variable -

Coding Tip

-

When variables are made to exceed their maximum capacity they "roll over" back to their minimum capacitiy, note that this happens in both directions. -

-

   int x
-   x = -32,768;
-   x = x - 1;       // x now contains 32,767 - rolls over in neg. direction
-
-   x = 32,767;
-   x = x + 1;       // x now contains -32,768 - rolls over
-
-
-

See Also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/IntCast.html b/arduino-0018-linux-x64/reference/IntCast.html deleted file mode 100644 index 2f062cb..0000000 --- a/arduino-0018-linux-x64/reference/IntCast.html +++ /dev/null @@ -1,82 +0,0 @@ - - - - Arduino - IntCast - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

int()

-

Description

-

Converts a value to the int data type. -

-

Syntax

-

int(x) -

-

Parameters

-

x: a value of any type -

-

Returns

-

int -

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Interrupts.html b/arduino-0018-linux-x64/reference/Interrupts.html deleted file mode 100644 index e331d98..0000000 --- a/arduino-0018-linux-x64/reference/Interrupts.html +++ /dev/null @@ -1,94 +0,0 @@ - - - - Arduino - Interrupts - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

interrupts()

-

Description

-

Re-enables interrupts (after they've been disabled by noInterrupts()). Interrupts allow certain important tasks to happen in the background and are enabled by default. Some functions will not work while interrupts are disabled, and incoming communication may be ignored. Interrupts can slightly disrupt the timing of code, however, and may be disabled for particularly critical sections of code. -

-

Parameters

-

None -

-

Returns

-

None -

-

Example

-
-void setup() {}
-
-void loop()
-{
-  noInterrupts();
-  // critical, time-sensitive code here
-  interrupts();
-  // other code here
-}
-
-
-

See Also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/LiquidCrystal.html b/arduino-0018-linux-x64/reference/LiquidCrystal.html deleted file mode 100644 index 6589f59..0000000 --- a/arduino-0018-linux-x64/reference/LiquidCrystal.html +++ /dev/null @@ -1,101 +0,0 @@ - - - - Arduino - LiquidCrystal - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

LiquidCrystal Library

-

This library allows an Arduino board to control LiquidCrystal displays (LCDs) based on the Hitachi HD44780 (or a compatible) chipset, which is found on most text-based LCDs. The library works with in either 4- or 8-bit mode (i.e. using 4 or 8 data lines in addition to the rs, enable, and, optionally, the rw control lines). -

-

Function

-

Examples -

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/LiquidCrystalAutoscroll.html b/arduino-0018-linux-x64/reference/LiquidCrystalAutoscroll.html deleted file mode 100644 index e85adad..0000000 --- a/arduino-0018-linux-x64/reference/LiquidCrystalAutoscroll.html +++ /dev/null @@ -1,81 +0,0 @@ - - - - Arduino - LiquidCrystalAutoscroll - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

LiquidCrystal -

-

autoscroll()

-

Description

-

Turns on automatic scrolling of the LCD. This causes each character output to the display to push previous characters over by one space. If the current text direction is left-to-right (the default), the display scrolls to the left; if the current direction is right-to-left, the display scrolls to the right. This has the effect of outputting each new character to the same location on the LCD. -

-

Syntax

-

lcd.autoscroll() -

-

Parameters

-

lcd: a variable of type LiquidCrystal -

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/LiquidCrystalBegin.html b/arduino-0018-linux-x64/reference/LiquidCrystalBegin.html deleted file mode 100644 index 0f79234..0000000 --- a/arduino-0018-linux-x64/reference/LiquidCrystalBegin.html +++ /dev/null @@ -1,83 +0,0 @@ - - - - Arduino - LiquidCrystalBegin - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

LiquidCrystal -

-

begin()

-

Description

-

Specifies the dimensions (width and height) of the display. -

-

Syntax

-

lcd.begin(cols, rows) -

-

Parameters

-

lcd: a variable of type LiquidCrystal -

-

cols: the number of columns that the display has -

-

rows: the number of rows that the display has -

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/LiquidCrystalBlink.html b/arduino-0018-linux-x64/reference/LiquidCrystalBlink.html deleted file mode 100644 index 067dd29..0000000 --- a/arduino-0018-linux-x64/reference/LiquidCrystalBlink.html +++ /dev/null @@ -1,84 +0,0 @@ - - - - Arduino - LiquidCrystalBlink - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

LiquidCrystal -

-

blink()

-

Description

-

Display the blinking LCD cursor. If used in combination with the cursor() function, the result will depend on the particular display. -

-

Syntax

-

lcd.blink() -

-

Parameters

-

lcd: a variable of type LiquidCrystal -

-

Example

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/LiquidCrystalClear.html b/arduino-0018-linux-x64/reference/LiquidCrystalClear.html deleted file mode 100644 index 8091c68..0000000 --- a/arduino-0018-linux-x64/reference/LiquidCrystalClear.html +++ /dev/null @@ -1,79 +0,0 @@ - - - - Arduino - LiquidCrystalClear - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

LiquidCrystal -

-

clear()

-

Description

-

Clears the LCD screen and positions the cursor in the upper-left corner. -

-

Syntax

-

lcd.clear() -

-

Parameters

-

lcd: a variable of type LiquidCrystal -

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/LiquidCrystalConstructor.html b/arduino-0018-linux-x64/reference/LiquidCrystalConstructor.html deleted file mode 100644 index 3dfb225..0000000 --- a/arduino-0018-linux-x64/reference/LiquidCrystalConstructor.html +++ /dev/null @@ -1,99 +0,0 @@ - - - - Arduino - LiquidCrystalConstructor - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

LiquidCrystal -

-

LiquidCrystal()

-

Description

-

Creates a variable of type LiquidCrystal. The display can be controlled using 4 or 8 data lines. If the former, omit the pin numbers for d0 to d3 and leave those lines unconnected. The RW pin can be tied to ground instead of connected to a pin on the Arduino; if so, omit it from this function's parameters. -

-

Syntax

-

LiquidCrystal(rs, enable, d4, d5, d6, d7)
LiquidCrystal(rs, rw, enable, d4, d5, d6, d7)
LiquidCrystal(rs, enable, d0, d1, d2, d3, d4, d5, d6, d7)
LiquidCrystal(rs, rw, enable, d0, d1, d2, d3, d4, d5, d6, d7) -

-

Parameters

-

rs: the number of the Arduino pin that is connected to the RS pin on the LCD -

-

rw: the number of the Arduino pin that is connected to the RW pin on the LCD (optional) -

-

enable: the number of the Arduino pin that is connected to the enable pin on the LCD -

-

d0, d1, d2, d3, d4, d5, d6, d7: the numbers of the Arduino pins that are connected to the corresponding data pins on the LCD. d0, d1, d2, and d3 are optional; if omitted, the LCD will be controlled using only the four data lines (d4, d5, d6, d7). -

-

Example

-
-#include <LiquidCrystal.h>
-
-LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);
-
-void setup()
-{
-  lcd.print("hello, world!");
-}
-
-void loop() {}
-
-
-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/LiquidCrystalCreateChar.html b/arduino-0018-linux-x64/reference/LiquidCrystalCreateChar.html deleted file mode 100644 index 5172a75..0000000 --- a/arduino-0018-linux-x64/reference/LiquidCrystalCreateChar.html +++ /dev/null @@ -1,110 +0,0 @@ - - - - Arduino - LiquidCrystalCreateChar - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

LiquidCrystal -

-

createChar()

-

Description

-

Create a custom character (gylph) for use on the LCD. Up to eight characters of 5x8 pixels are supported (numbered 0 to 7). The appearance of each custom character is specified by an array of eight bytes, one for each row. The five least significant bits of each byte determine the pixels in that row. To display a custom character on the screen, write() its number. -

-

Syntax

-

lcd.createChar(num, data) -

-

Parameters

-

lcd: a variable of type LiquidCrystal -

-

num: which character to create (0 to 7) -

-

data: the character's pixel data -

-

Example

-
-
-#include <LiquidCrystal.h>
-
-LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
-
-byte smiley[8] = {
-  B00000,
-  B10001,
-  B00000,
-  B00000,
-  B10001,
-  B01110,
-  B00000,
-};
-
-void setup() {
-  lcd.createChar(0, smiley);
-  lcd.begin(16, 2);  
-  lcd.write(0);
-}
-
-void loop() {}
-
-
-
-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/LiquidCrystalCursor.html b/arduino-0018-linux-x64/reference/LiquidCrystalCursor.html deleted file mode 100644 index 992922b..0000000 --- a/arduino-0018-linux-x64/reference/LiquidCrystalCursor.html +++ /dev/null @@ -1,83 +0,0 @@ - - - - Arduino - LiquidCrystalCursor - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

LiquidCrystal -

-

cursor()

-

Description

-

Display the LCD cursor: an underscore (line) at the position to which the next character will be written. -

-

Syntax

-

lcd.cursor() -

-

Parameters

-

lcd: a variable of type LiquidCrystal -

-

Example

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/LiquidCrystalDisplay.html b/arduino-0018-linux-x64/reference/LiquidCrystalDisplay.html deleted file mode 100644 index 80ad657..0000000 --- a/arduino-0018-linux-x64/reference/LiquidCrystalDisplay.html +++ /dev/null @@ -1,83 +0,0 @@ - - - - Arduino - LiquidCrystalDisplay - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

LiquidCrystal -

-

display()

-

Description

-

Turns on the LCD display, after it's been turned off with noDisplay(). This will restore the text (and cursor) that was on the display. -

-

Syntax

-

lcd.display() -

-

Parameters

-

lcd: a variable of type LiquidCrystal -

-

Example

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/LiquidCrystalHome.html b/arduino-0018-linux-x64/reference/LiquidCrystalHome.html deleted file mode 100644 index 0108a6e..0000000 --- a/arduino-0018-linux-x64/reference/LiquidCrystalHome.html +++ /dev/null @@ -1,79 +0,0 @@ - - - - Arduino - LiquidCrystalHome - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

LiquidCrystal -

-

home()

-

Description

-

Positions the cursor in the upper-left of the LCD. That is, use that location in outputting subsequent text to the display. To also clear the display, use the clear() function instead. -

-

Syntax

-

lcd.home() -

-

Parameters

-

lcd: a variable of type LiquidCrystal -

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/LiquidCrystalLeftToRight.html b/arduino-0018-linux-x64/reference/LiquidCrystalLeftToRight.html deleted file mode 100644 index a89161f..0000000 --- a/arduino-0018-linux-x64/reference/LiquidCrystalLeftToRight.html +++ /dev/null @@ -1,81 +0,0 @@ - - - - Arduino - LiquidCrystalLeftToRight - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

LiquidCrystal -

-

leftToRight()

-

Description

-

Set the direction for text written to the LCD to left-to-right, the default. This means that subsequent characters written to the display will go from left to right, but does not affect previously-output text. -

-

Syntax

-

lcd.leftTorRight() -

-

Parameters

-

lcd: a variable of type LiquidCrystal -

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/LiquidCrystalNoAutoscroll.html b/arduino-0018-linux-x64/reference/LiquidCrystalNoAutoscroll.html deleted file mode 100644 index 55678d1..0000000 --- a/arduino-0018-linux-x64/reference/LiquidCrystalNoAutoscroll.html +++ /dev/null @@ -1,81 +0,0 @@ - - - - Arduino - LiquidCrystalNoAutoscroll - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

LiquidCrystal -

-

noAutoscroll()

-

Description

-

Turns off automatic scrolling of the LCD. -

-

Syntax

-

lcd.noAutoscroll() -

-

Parameters

-

lcd: a variable of type LiquidCrystal -

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/LiquidCrystalNoBlink.html b/arduino-0018-linux-x64/reference/LiquidCrystalNoBlink.html deleted file mode 100644 index 11488b5..0000000 --- a/arduino-0018-linux-x64/reference/LiquidCrystalNoBlink.html +++ /dev/null @@ -1,83 +0,0 @@ - - - - Arduino - LiquidCrystalNoBlink - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

LiquidCrystal -

-

noBlink()

-

Description

-

Turns off the blinking LCD cursor. -

-

Syntax

-

lcd.noBlink() -

-

Parameters

-

lcd: a variable of type LiquidCrystal -

-

Example

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/LiquidCrystalNoCursor.html b/arduino-0018-linux-x64/reference/LiquidCrystalNoCursor.html deleted file mode 100644 index f3ca96b..0000000 --- a/arduino-0018-linux-x64/reference/LiquidCrystalNoCursor.html +++ /dev/null @@ -1,83 +0,0 @@ - - - - Arduino - LiquidCrystalNoCursor - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

LiquidCrystal -

-

noCursor()

-

Description

-

Hides the LCD cursor. -

-

Syntax

-

lcd.noCursor() -

-

Parameters

-

lcd: a variable of type LiquidCrystal -

-

Example

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/LiquidCrystalNoDisplay.html b/arduino-0018-linux-x64/reference/LiquidCrystalNoDisplay.html deleted file mode 100644 index 31779fd..0000000 --- a/arduino-0018-linux-x64/reference/LiquidCrystalNoDisplay.html +++ /dev/null @@ -1,83 +0,0 @@ - - - - Arduino - LiquidCrystalNoDisplay - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

LiquidCrystal -

-

noDisplay()

-

Description

-

Turns off the LCD display, without losing the text currently shown on it. -

-

Syntax

-

lcd.noDisplay() -

-

Parameters

-

lcd: a variable of type LiquidCrystal -

-

Example

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/LiquidCrystalPrint.html b/arduino-0018-linux-x64/reference/LiquidCrystalPrint.html deleted file mode 100644 index d8c5b01..0000000 --- a/arduino-0018-linux-x64/reference/LiquidCrystalPrint.html +++ /dev/null @@ -1,97 +0,0 @@ - - - - Arduino - LiquidCrystalPrint - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

LiquidCrystal -

-

print()

-

Description

-

Prints text to the LCD. -

-

Syntax

-

lcd.print(data)
lcd.print(data, BASE) -

-

Parameters

-

lcd: a variable of type LiquidCrystal -

-

data: the data to print (char, byte, int, long, or string) -

-

BASE (optional): the base in which to print numbers: BIN for binary (base 2), DEC for decimal (base 10), OCT for octal (base 8), HEX for hexadecimal (base 16). -

-

Example

-
-#include <LiquidCrystal.h>
-
-LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);
-
-void setup()
-{
-  lcd.print("hello, world!");
-}
-
-void loop() {}
-
-
-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/LiquidCrystalRightToLeft.html b/arduino-0018-linux-x64/reference/LiquidCrystalRightToLeft.html deleted file mode 100644 index 21bfea9..0000000 --- a/arduino-0018-linux-x64/reference/LiquidCrystalRightToLeft.html +++ /dev/null @@ -1,81 +0,0 @@ - - - - Arduino - LiquidCrystalRightToLeft - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

LiquidCrystal -

-

rightToLeft()

-

Description

-

Set the direction for text written to the LCD to right-to-left (the default is left-to-right). This means that subsequent characters written to the display will go from right to left, but does not affect previously-output text. -

-

Syntax

-

lcd.rightToLeft() -

-

Parameters

-

lcd: a variable of type LiquidCrystal -

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/LiquidCrystalScrollDisplayLeft.html b/arduino-0018-linux-x64/reference/LiquidCrystalScrollDisplayLeft.html deleted file mode 100644 index 58dc3a3..0000000 --- a/arduino-0018-linux-x64/reference/LiquidCrystalScrollDisplayLeft.html +++ /dev/null @@ -1,83 +0,0 @@ - - - - Arduino - LiquidCrystalScrollDisplayLeft - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

LiquidCrystal -

-

scrollDisplayLeft()

-

Description

-

Scrolls the contents of the display (text and cursor) one space to the left. -

-

Syntax

-

lcd.scrollDisplayLeft() -

-

Parameters

-

lcd: a variable of type LiquidCrystal -

-

Example

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/LiquidCrystalScrollDisplayRight.html b/arduino-0018-linux-x64/reference/LiquidCrystalScrollDisplayRight.html deleted file mode 100644 index d908eb2..0000000 --- a/arduino-0018-linux-x64/reference/LiquidCrystalScrollDisplayRight.html +++ /dev/null @@ -1,83 +0,0 @@ - - - - Arduino - LiquidCrystalScrollDisplayRight - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

LiquidCrystal -

-

scrollDisplayRight()

-

Description

-

Scrolls the contents of the display (text and cursor) one space to the right. -

-

Syntax

-

lcd.scrollDisplayRight() -

-

Parameters

-

lcd: a variable of type LiquidCrystal -

-

Example

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/LiquidCrystalSetCursor.html b/arduino-0018-linux-x64/reference/LiquidCrystalSetCursor.html deleted file mode 100644 index 41da461..0000000 --- a/arduino-0018-linux-x64/reference/LiquidCrystalSetCursor.html +++ /dev/null @@ -1,83 +0,0 @@ - - - - Arduino - LiquidCrystalSetCursor - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

LiquidCrystal -

-

setCursor()

-

Description

-

Position the LCD cursor; that is, set the location at which subsequent text written to the LCD will be displayed. -

-

Syntax

-

lcd.setCursor(col, row) -

-

Parameters

-

lcd: a variable of type LiquidCrystal -

-

col: the column at which to position the cursor (with 0 being the first column) -

-

row: the row at which to position the cursor (with 0 being the first row) -

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/LiquidCrystalWrite.html b/arduino-0018-linux-x64/reference/LiquidCrystalWrite.html deleted file mode 100644 index 9dc32f2..0000000 --- a/arduino-0018-linux-x64/reference/LiquidCrystalWrite.html +++ /dev/null @@ -1,100 +0,0 @@ - - - - Arduino - LiquidCrystalWrite - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

LiquidCrystal -

-

write()

-

Description

-

Write a character to the LCD. -

-

Syntax

-

lcd.write(data) -

-

Parameters

-

lcd: a variable of type LiquidCrystal -

-

data: the character to write to the display -

-

Example

-
-#include <LiquidCrystal.h>
-
-LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);
-
-void setup()
-{
-  Serial.begin(9600);
-}
-
-void loop()
-{
-  if (Serial.available()) {
-    lcd.write(Serial.read());
-  }
-}
-
-
-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Long.html b/arduino-0018-linux-x64/reference/Long.html deleted file mode 100644 index 4ea9d85..0000000 --- a/arduino-0018-linux-x64/reference/Long.html +++ /dev/null @@ -1,87 +0,0 @@ - - - - Arduino - Long - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

long

-

Description

-

Long variables are extended size variables for number storage, and store 32 bits (4 bytes), from -2,147,483,648 to 2,147,483,647. -

-

Example

-

    long speedOfLight = 186000L;   // see Integer Constants for explanation of the 'L'
-
-
-

Syntax

-
    long var = val;
-
-

  • var - the long variable name -
  • val - the value assigned to the variable -

See Also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/LongCast.html b/arduino-0018-linux-x64/reference/LongCast.html deleted file mode 100644 index 7cb4131..0000000 --- a/arduino-0018-linux-x64/reference/LongCast.html +++ /dev/null @@ -1,82 +0,0 @@ - - - - Arduino - LongCast - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

long()

-

Description

-

Converts a value to the long data type. -

-

Syntax

-

long(x) -

-

Parameters

-

x: a value of any type -

-

Returns

-

long -

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Loop.html b/arduino-0018-linux-x64/reference/Loop.html deleted file mode 100644 index b78358d..0000000 --- a/arduino-0018-linux-x64/reference/Loop.html +++ /dev/null @@ -1,94 +0,0 @@ - - - - Arduino - Loop - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

loop()

-

After creating a setup() function, which initializes and sets the initial values, the loop() function does precisely what its name suggests, and loops consecutively, allowing your program to change and respond. Use it to actively control the Arduino board. -

-

Example

-
 
-int buttonPin = 3;
-
-// setup initializes serial and the button pin
-void setup()
-{
-  beginSerial(9600);
-  pinMode(buttonPin, INPUT);
-}
-
-// loop checks the button pin each time,
-// and will send serial if it is pressed
-void loop()
-{
-  if (digitalRead(buttonPin) == HIGH)
-    serialWrite('H');
-  else
-    serialWrite('L');
-
-  delay(1000);
-}
-
-
-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/LowByte.html b/arduino-0018-linux-x64/reference/LowByte.html deleted file mode 100644 index 3c81042..0000000 --- a/arduino-0018-linux-x64/reference/LowByte.html +++ /dev/null @@ -1,83 +0,0 @@ - - - - Arduino - LowByte - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

lowByte()

-

Description

-

Extracts the low-order (rightmost) byte of a variable (e.g. a word). -

-

Syntax

-

lowByte(x) -

-

Parameters

-

x: a value of any type -

-

Returns

-

byte -

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Map.html b/arduino-0018-linux-x64/reference/Map.html deleted file mode 100644 index 02d7d25..0000000 --- a/arduino-0018-linux-x64/reference/Map.html +++ /dev/null @@ -1,125 +0,0 @@ - - - - Arduino - Map - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

map(value, fromLow, fromHigh, toLow, toHigh)

-

Description

-

Re-maps a number from one range to another. That is, a value of fromLow would get mapped to toLow, a value of fromHigh to toHigh, values in-between to values in-between, etc. -

-

Does not constrain values to within the range, because out-of-range values are sometimes intended and useful. The constrain() function may be used either before or after this function, if limits to the ranges are desired. -

-

Note that the "lower bounds" of either range may be larger or smaller than the "upper bounds" so the map() function may be used to reverse a range of numbers, for example -

-

y = map(x, 1, 50, 50, 1); -

-

The function also handles negative numbers well, so -that this example -

-

y = map(x, 1, 50, 50, -100); -

-

is also valid and works well. -

-

The map() function uses integer math so will not generate fractions, when the math might indicate that it should do so. Fractional remainders are truncated, and are not rounded or averaged. -

-

Parameters

-

value: the number to map -

-

fromLow: the lower bound of the value's current range -

-

fromHigh: the upper bound of the value's current range -

-

toLow: the lower bound of the value's target range -

-

toHigh: the upper bound of the value's target range -

-

Returns

-

The mapped value. -

-

Example

-
-/* Map an analog value to 8 bits (0 to 255) */
-void setup() {}
-
-void loop()
-{
-  int val = analogRead(0);
-  val = map(val, 0, 1023, 0, 255);
-  analogWrite(9, val);
-}
-
-
-

Appendix

-

For the mathematically inclined, here's the whole function -

-

-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;
-}
-
-
-

See Also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Max.html b/arduino-0018-linux-x64/reference/Max.html deleted file mode 100644 index 3f39d5a..0000000 --- a/arduino-0018-linux-x64/reference/Max.html +++ /dev/null @@ -1,98 +0,0 @@ - - - - Arduino - Max - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

max(x, y)

-

Description

-

Calculates the maximum of two numbers. -

-

Parameters

-

x: the first number, any data type -

-

y: the second number, any data type -

-

Returns

-

The larger of the two parameter values. -

-

Example

-
sensVal = max(senVal, 20); // assigns sensVal to the larger of sensVal or 20
-                           // (effectively ensuring that it is at least 20)
-

Note

-

Perhaps counter-intuitively, max() is often used to constrain the lower end of a variable's range, while min() is used to constrain the upper end of the range. -

-

Warning

-

Because of the way the max() function is implemented, avoid using other functions inside the brackets, it may lead to incorrect results -

-

-max(a--, 0);   // avoid this - yields incorrect results
-
-a--;           // use this instead -
-max(a, 0);     // keep other math outside the function
-
-
-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Micros.html b/arduino-0018-linux-x64/reference/Micros.html deleted file mode 100644 index 20da518..0000000 --- a/arduino-0018-linux-x64/reference/Micros.html +++ /dev/null @@ -1,100 +0,0 @@ - - - - Arduino - Micros - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

micros()

-

Description

-

Returns the number of microseconds since the Arduino board began running the current program. This number will overflow (go back to zero), after approximately 70 minutes. On 16 MHz Arduino boards (e.g. Duemilanove and Nano), this function has a resolution of four microseconds (i.e. the value returned is always a multiple of four). On 8 MHz Arduino boards (e.g. the LilyPad), this function has a resolution of eight microseconds. -

-

Note: there are 1,000 microseconds in a millisecond and 1,000,000 microseconds in a second. -

-

Parameters

-

None -

-

Returns

-

Number of microseconds since the program started (unsigned long) -

-

Example

-
-unsigned long time;
-
-void setup(){
-  Serial.begin(9600);
-}
-void loop(){
-  Serial.print("Time: ");
-  time = micros();
-  //prints time since program started
-  Serial.println(time);
-  // wait a second so as not to send massive amounts of data
-  delay(1000);
-}
-
-
-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Millis.html b/arduino-0018-linux-x64/reference/Millis.html deleted file mode 100644 index 11706b2..0000000 --- a/arduino-0018-linux-x64/reference/Millis.html +++ /dev/null @@ -1,102 +0,0 @@ - - - - Arduino - Millis - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

millis()

-

Description

-

Returns the number of milliseconds since the Arduino board began running the current program. This number will overflow (go back to zero), after approximately 50 days. -

-

Parameters

-

None -

-

Returns

-

Number of milliseconds since the program started (unsigned long) -

-

Example

-
-unsigned long time;
-
-void setup(){
-  Serial.begin(9600);
-}
-void loop(){
-  Serial.print("Time: ");
-  time = millis();
-  //prints time since program started
-  Serial.println(time);
-  // wait a second so as not to send massive amounts of data
-  delay(1000);
-}
-
-
-

Tip:

-

Note that the parameter for millis is an unsigned long, errors may be generated if a programmer tries to do math with other datatypes such as ints. -

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Min.html b/arduino-0018-linux-x64/reference/Min.html deleted file mode 100644 index e926162..0000000 --- a/arduino-0018-linux-x64/reference/Min.html +++ /dev/null @@ -1,98 +0,0 @@ - - - - Arduino - Min - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

min(x, y)

-

Description

-

Calculates the minimum of two numbers. -

-

Parameters

-

x: the first number, any data type -

-

y: the second number, any data type -

-

Returns

-

The smaller of the two numbers. -

-

Examples

-
sensVal = min(sensVal, 100); // assigns sensVal to the smaller of sensVal or 100
-                             // ensuring that it never gets above 100.
-

Note

-

Perhaps counter-intuitively, max() is often used to constrain the lower end of a variable's range, while min() is used to constrain the upper end of the range. -

-

Warning

-

Because of the way the min() function is implemented, avoid using other functions inside the brackets, it may lead to incorrect results -

-

-min(a++, 100);   // avoid this - yields incorrect results
-
-a++;
-min(a, 100);    // use this instead - keep other math outside the function
-
-
-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Modulo.html b/arduino-0018-linux-x64/reference/Modulo.html deleted file mode 100644 index 83fd47e..0000000 --- a/arduino-0018-linux-x64/reference/Modulo.html +++ /dev/null @@ -1,110 +0,0 @@ - - - - Arduino - Modulo - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

% (modulo)

-

Description

-

Calculates the remainder when one integer is divided by another. It is useful for keeping a variable within a particular range (e.g. the size of an array). -

-

Syntax

-

result = dividend % divisor -

-

Parameters

-

dividend: the number to be divided -

-

divisor: the number to divide by -

-

Returns

-

the remainder -

-

Examples

-
x = 7 % 5;   // x now contains 2
-x = 9 % 5;   // x now contains 4
-x = 5 % 5;   // x now contains 0
-x = 4 % 5;   // x now contains 4
-
-
-

Example Code

-
-/* update one value in an array each time through a loop */
-
-int values[10];
-int i = 0;
-
-void setup() {}
-
-void loop()
-{
-  values[i] = analogRead(0);
-  i = (i + 1) % 10;   // modulo operator rolls over variable  
-}
-
-
-

Tip

-

The modulo operator does not work on floats. -

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/NoInterrupts.html b/arduino-0018-linux-x64/reference/NoInterrupts.html deleted file mode 100644 index 94b2e02..0000000 --- a/arduino-0018-linux-x64/reference/NoInterrupts.html +++ /dev/null @@ -1,92 +0,0 @@ - - - - Arduino - NoInterrupts - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

noInterrupts()

-

Description

-

Disables interrupts (you can re-enable them with interrupts()). Interrupts allow certain important tasks to happen in the background and are enabled by default. Some functions will not work while interrupts are disabled, and incoming communication may be ignored. Interrupts can slightly disrupt the timing of code, however, and may be disabled for particularly critical sections of code. -

-

Parameters

-

None. -

-

Returns

-

None. -

-

Example

-
-void setup() {}
-
-void loop()
-{
-  noInterrupts();
-  // critical, time-sensitive code here
-  interrupts();
-  // other code here
-}
-
-
-

See Also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/NoTone.html b/arduino-0018-linux-x64/reference/NoTone.html deleted file mode 100644 index 48b4864..0000000 --- a/arduino-0018-linux-x64/reference/NoTone.html +++ /dev/null @@ -1,82 +0,0 @@ - - - - Arduino - NoTone - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

noTone()

-

Description

-

Stops the generation of a square wave triggered by tone(). Has no effect if no tone is being generated. -

-

Syntax

-

noTone(pin) -

-

Parameters

-

pin: the pin on which to stop generating the tone -

-

Returns

-

nothing -

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/PinMode.html b/arduino-0018-linux-x64/reference/PinMode.html deleted file mode 100644 index 986bb3f..0000000 --- a/arduino-0018-linux-x64/reference/PinMode.html +++ /dev/null @@ -1,109 +0,0 @@ - - - - Arduino - PinMode - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

pinMode()

-

Description

-

Configures the specified pin to behave either as an input or an output. See the description of digital pins for details. -

-

Syntax

-

pinMode(pin, mode) -

-

Parameters

-

pin: the number of the pin whose mode you wish to set -

-

mode: either INPUT or OUTPUT -

-

Returns

-

None -

-

Example

-
-
-int ledPin = 13;                 // LED connected to digital pin 13
-
-void setup()
-{
-  pinMode(ledPin, OUTPUT);      // sets the digital pin as output
-}
-
-void loop()
-{
-  digitalWrite(ledPin, HIGH);   // sets the LED on
-  delay(1000);                  // waits for a second
-  digitalWrite(ledPin, LOW);    // sets the LED off
-  delay(1000);                  // waits for a second
-}
-
-
-

Note

-

The analog input pins can be used as digital pins, referred to as numbers 14 (analog input 0) to 19 (analog input 5). -

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Pointer.html b/arduino-0018-linux-x64/reference/Pointer.html deleted file mode 100644 index 9f9008d..0000000 --- a/arduino-0018-linux-x64/reference/Pointer.html +++ /dev/null @@ -1,71 +0,0 @@ - - - - Arduino - Pointer - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

The pointer operators

-

& (reference) and * (dereference)

-

Pointers are one of the more complicated subjects for beginners in learning C, and it is possible to write the vast majority of Arduino sketches without ever encountering pointers. However for manipulating certain data structures, the use of pointers can simplify the code, and and knowledge of manipulating pointers is handy to have in one's toolkit. -

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Pow.html b/arduino-0018-linux-x64/reference/Pow.html deleted file mode 100644 index 011c422..0000000 --- a/arduino-0018-linux-x64/reference/Pow.html +++ /dev/null @@ -1,86 +0,0 @@ - - - - Arduino - Pow - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

pow(base, exponent)

-

Description

-

Calculates the value of a number raised to a power. Pow() can be used to raise a number to a fractional power. This is useful for generating exponential mapping of values or curves. -

-

Parameters

-

base: the number (float) -

-

exponent: the power to which the base is raised (float) -

-

Returns

-

The result of the exponentiation (double) -

-

Example

-

See the fscale function in the code library. -

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/PulseIn.html b/arduino-0018-linux-x64/reference/PulseIn.html deleted file mode 100644 index 69e140b..0000000 --- a/arduino-0018-linux-x64/reference/PulseIn.html +++ /dev/null @@ -1,103 +0,0 @@ - - - - Arduino - PulseIn - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

pulseIn()

-

Description

-

Reads a pulse (either HIGH or LOW) on a pin. For example, if value is HIGH, pulseIn() waits for the pin to go HIGH, starts timing, then waits for the pin to go LOW and stops timing. Returns the length of the pulse in microseconds. Gives up and returns 0 if no pulse starts within a specified time out. -

-

The timing of this function has been determined empirically and will probably show errors in longer pulses. Works on pulses from 10 microseconds to 3 minutes in length. -

-

Syntax

-

pulseIn(pin, value)
pulseIn(pin, value, timeout) -

-

Parameters

-

pin: the number of the pin on which you want to read the pulse. (int) -

-

value: type of pulse to read: either HIGH or LOW. (int) -

-

timeout (optional): the number of microseconds to wait for the pulse to start; default is one second (unsigned long) -

-

Returns

-

the length of the pulse (in microseconds) or 0 if no pulse started before the timeout (unsigned long) -

-

Example

-
 
-
-int pin = 7;
-unsigned long duration;
-
-void setup()
-{
-  pinMode(pin, INPUT);
-}
-
-void loop()
-{
-  duration = pulseIn(pin, HIGH);
-}
-
-
-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Random.html b/arduino-0018-linux-x64/reference/Random.html deleted file mode 100644 index 7635f21..0000000 --- a/arduino-0018-linux-x64/reference/Random.html +++ /dev/null @@ -1,116 +0,0 @@ - - - - Arduino - Random - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

random()

-

Description

-

The random function generates pseudo-random numbers. -

-

Syntax

-

random(max)
random(min, max) -

-

Parameters

-

min - lower bound of the random value, inclusive (optional) -

-

max - upper bound of the random value, exclusive -

-

Returns

-

a random number between min and max-1 (long) -

-

Note:

-

If it is important for a sequence of values generated by random() to differ, on subsequent executions of a sketch, use randomSeed() to initialize the random number generator with a fairly random input, such as analogRead() on an unconnected pin. -

-

Conversely, it can occasionally be useful to use pseudo-random sequences that repeat exactly. This can be accomplished by calling randomSeed() with a fixed number, before starting the random sequence. -

-

Example

-
-long randNumber;
-
-void setup(){
-  Serial.begin(9600);
-
-  // if analog input pin 0 is unconnected, random analog
-  // noise will cause the call to randomSeed() to generate
-  // different seed numbers each time the sketch runs.
-  // randomSeed() will then shuffle the random function.
-  randomSeed(analogRead(0));
-}
-
-void loop() {
-  // print a random number from 0 to 299
-  randNumber = random(300);
-  Serial.println(randNumber);  
-
-  // print a random number from 10 to 19
-  randNumber = random(10, 20);
-  Serial.println(randNumber);
-
-  delay(50);
-}
-
-
-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/RandomSeed.html b/arduino-0018-linux-x64/reference/RandomSeed.html deleted file mode 100644 index dfe6700..0000000 --- a/arduino-0018-linux-x64/reference/RandomSeed.html +++ /dev/null @@ -1,100 +0,0 @@ - - - - Arduino - RandomSeed - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

randomSeed(seed)

-

Description

-

randomSeed() initializes the pseudo-random number generator, causing it to start at an arbitrary point in its random sequence. This sequence, while very long, and random, is always the same. -

-

If it is important for a sequence of values generated by random() to differ, on subsequent executions of a sketch, use randomSeed() to initialize the random number generator with a fairly random input, such as analogRead() on an unconnected pin. -

-

Conversely, it can occasionally be useful to use pseudo-random sequences that repeat exactly. This can be accomplished by calling randomSeed() with a fixed number, before starting the random sequence. -

-

Parameters

-

long, int - pass a number to generate the seed. -

-

Returns

-

no returns -

-

Example

-
-long randNumber;
-
-void setup(){
-  Serial.begin(9600);
-  randomSeed(analogRead(0));
-}
-
-void loop(){
-  randNumber = random(300);
-  Serial.println(randNumber);
-
-  delay(50);
-}
-
-
-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Return.html b/arduino-0018-linux-x64/reference/Return.html deleted file mode 100644 index 6d870a3..0000000 --- a/arduino-0018-linux-x64/reference/Return.html +++ /dev/null @@ -1,103 +0,0 @@ - - - - Arduino - Return - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

return

-

Terminate a function and return a value from a function to the calling function, if desired. -

-

Syntax:

-

return; -

-

return value; // both forms are valid -

-

Parameters

-

value: any variable or constant type -

-

Examples:

-

A function to compare a sensor input to a threshold -

 int checkSensor(){       
-    if (analogRead(0) > 400) {
-        return 1;
-    else{
-        return 0;
-    }
-}
-
-

The return keyword is handy to test a section of code without having to "comment out" large sections of possibly buggy code. -

-

void loop(){
-
-// brilliant code idea to test here
-
-return;
-
-// the rest of a dysfunctional sketch here
-// this code will never be executed
-}
-
-

See also

-

comments -

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Scope.html b/arduino-0018-linux-x64/reference/Scope.html deleted file mode 100644 index 49422d7..0000000 --- a/arduino-0018-linux-x64/reference/Scope.html +++ /dev/null @@ -1,96 +0,0 @@ - - - - Arduino - Scope - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Variable Scope

-

Variables in the C programming language, which Arduino uses, have a property called scope. This is in contrast to languages such as BASIC where every variable is a global variable. -

-

A global variable is one that can be seen by every function in a program. Local variables are only visible to the function in which they are declared. In the Arduino environment, any variable declared outside of a function (e.g. setup(), loop(), etc. ), is a global variable. -

-

When programs start to get larger and more complex, local variables are a useful way to insure that only one function has access to its own variables. This prevents programming errors when one function inadvertently modifies variables used by another function. -

-

It is also sometimes handy to declare and initialize a variable inside a for loop. This creates a variable that can only be accessed from inside the for-loop brackets. -

-

Example:

-
int gPWMval;  // any function will see this variable
-
-void setup()
-{
-  // ...
-}
-
-void loop()
-{
-  int i;    // "i" is only "visible" inside of "loop"
-  float f;  // "f" is only "visible" inside of "loop"
-  // ...
-
-  for (int j = 0; j <100; j++){
-  // variable j can only be accessed inside the for-loop brackets
-  }
-
-}
-
-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/SemiColon.html b/arduino-0018-linux-x64/reference/SemiColon.html deleted file mode 100644 index 62cc0c8..0000000 --- a/arduino-0018-linux-x64/reference/SemiColon.html +++ /dev/null @@ -1,77 +0,0 @@ - - - - Arduino - SemiColon - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

; semicolon

-

Used to end a statement. -

-

Example

-
-int a = 13;
-
-

Tip

-

Forgetting to end a line in a semicolon will result in a compiler error. The error text may be obvious, and refer to a missing semicolon, or it may not. If an impenetrable or seemingly illogical compiler error comes up, one of the first things to check is a missing semicolon, in the immediate vicinity, preceding the line at which the compiler complained. -

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Serial.html b/arduino-0018-linux-x64/reference/Serial.html deleted file mode 100644 index 47e0d78..0000000 --- a/arduino-0018-linux-x64/reference/Serial.html +++ /dev/null @@ -1,90 +0,0 @@ - - - - Arduino - Serial - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Serial

-

Used for communication between the Arduino board and a computer or other devices. All Arduino boards have at least one serial port (also known as a UART or USART): Serial. It communicates on digital pins 0 (RX) and 1 (TX) as well as with the computer via USB. Thus, if you use these functions, you cannot also use pins 0 and 1 for digital input or output. -

-

You can use the Arduino environment's built-in serial monitor to communicate with an Arduino board. Click the serial monitor button in the toolbar and select the same baud rate used in the call to begin(). -

-

The Arduino Mega has three additional serial ports: Serial1 on pins 19 (RX) and 18 (TX), Serial2 on pins 17 (RX) and 16 (TX), Serial3 on pins 15 (RX) and 14 (TX). To use these pins to communicate with your personal computer, you will need an additional USB-to-serial adaptor, as they are not connected to the Mega's USB-to-serial adaptor. To use them to communicate with an external TTL serial device, connect the TX pin to your device's RX pin, the RX to your device's TX pin, and the ground of your Mega to your device's ground. (Don't connect these pins directly to an RS232 serial port; they operate at +/- 12V and can damage your Arduino board.) -

-

Functions

-

Examples

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Serial_Available.html b/arduino-0018-linux-x64/reference/Serial_Available.html deleted file mode 100644 index 452818e..0000000 --- a/arduino-0018-linux-x64/reference/Serial_Available.html +++ /dev/null @@ -1,121 +0,0 @@ - - - - Arduino - Available - - - - -
- - - - - - -
- -
-

int Serial.available()

-

Description

-

Get the number of bytes (characters) available for reading over the serial port. -

-

Parameters

-

None -

-

Returns

-

The number of bytes are available to read in the serial buffer, or 0 if none are available. If any data has come in, Serial.available() will be greater than 0. The serial buffer can hold up to 128 bytes. -

-

Example

-
-int incomingByte = 0;	// for incoming serial data
-
-void setup() {
-	Serial.begin(9600);	// opens serial port, sets data rate to 9600 bps
-}
-
-void loop() {
-
-	// send data only when you receive data:
-	if (Serial.available() > 0) {
-		// read the incoming byte:
-		incomingByte = Serial.read();
-
-		// say what you got:
-		Serial.print("I received: ");
-		Serial.println(incomingByte, DEC);
-	}
-}
-
-
-

Arduino Mega example: -

-

-void setup() {
-  Serial.begin(9600);
-  Serial1.begin(9600);
-
-}
-
-void loop() {
-  // read from port 0, send to port 1:
-  if (Serial.available()) {
-    int inByte = Serial.read();
-    Serial1.print(inByte, BYTE); 
-
-  }
-  // read from port 1, send to port 0:
-  if (Serial1.available()) {
-    int inByte = Serial1.read();
-    Serial.print(inByte, BYTE); 
-  }
-}
-
-
-

See also

-

Reference Home -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Serial_Begin.html b/arduino-0018-linux-x64/reference/Serial_Begin.html deleted file mode 100644 index 8058f02..0000000 --- a/arduino-0018-linux-x64/reference/Serial_Begin.html +++ /dev/null @@ -1,108 +0,0 @@ - - - - Arduino - Begin - - - - -
- - - - - - -
- -
-

Serial.begin(int speed)

-

Description

-

Sets the data rate in bits per second (baud) for serial data transmission. For communicating with the computer, use one of these rates: 300, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, or 115200. You can, however, specify other rates - for example, to communicate over pins 0 and 1 with a component that requires a particular baud rate. -

-

Parameters

-

long datarate, in bits per second (baud) -

-

Returns

-

nothing -

-

Example:

-
-void setup() {
-	Serial.begin(9600);	// opens serial port, sets data rate to 9600 bps
-}
-
-void loop() {}
-
-
-

Arduino Mega example: -

-

-// Arduino Mega using all four of its Serial ports 
-// (Serial, Serial1, Serial2, Serial3), 
-// with different baud rates:
-
-void setup(){
-  Serial.begin(9600);
-  Serial1.begin(38400);
-  Serial2.begin(19200);
-  Serial3.begin(4800);
-
-  Serial.println("Hello Computer");
-  Serial1.println("Hello Serial 1");
-  Serial2.println("Hello Serial 2");
-  Serial3.println("Hello Serial 3");
-}
-
-void loop() {}
-
-
-

Thanks to Jeff Gray for the mega example -

-

See also

-

Reference Home -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Serial_Flush.html b/arduino-0018-linux-x64/reference/Serial_Flush.html deleted file mode 100644 index 081b15f..0000000 --- a/arduino-0018-linux-x64/reference/Serial_Flush.html +++ /dev/null @@ -1,73 +0,0 @@ - - - - Arduino - Flush - - - - -
- - - - - - -
- -
-

Serial.flush()

-

Description

-

Flushes the buffer of incoming serial data. That is, any call to Serial.read() or Serial.available() will return only data received after all the most recent call to Serial.flush(). -

-

Parameters

-

none -

-

Returns

-

none -

-

See also

-

Reference Home -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Serial_Print.html b/arduino-0018-linux-x64/reference/Serial_Print.html deleted file mode 100644 index 780e174..0000000 --- a/arduino-0018-linux-x64/reference/Serial_Print.html +++ /dev/null @@ -1,200 +0,0 @@ - - - - Arduino - Print - - - - -
- - - - - - -
- -
-

Serial.print(data)

-

Description

-

Prints data to the serial port. -

-

Parameter

-

data: integer types, including char, floats
Printing of floats is supported with a precision of two places to the right of the decimal point.
This may change soon. -

-

Syntax

-

This command can take many forms: -

-

Serial.print(b) -with no format specified, prints b as a decimal number in an ASCII string. For example, -

-

-int b = 79;
-Serial.print(b);
-

prints the ASCII string "79". -

-

Serial.print(b, DEC) -prints b as a decimal number in an ASCII string. For example, -

-

-int b = 79;
-Serial.print(b, DEC);
-

prints the string "79". -

-

Serial.print(b, HEX) -prints b as a hexadecimal number in an ASCII string. For example, -

-

-int b = 79;
-Serial.print(b, HEX);
-

prints the string "4F". -

-

Serial.print(b, OCT) -prints b as an octal number in an ASCII string. For example, -

-

-int b = 79;
-Serial.print(b, OCT);
-

prints the string "117". -

-

Serial.print(b, BIN) -prints b as a binary number in an ASCII string. For example, -

-

-int b = 79;
-Serial.print(b, BIN);
-

prints the string "1001111". -

-

Serial.print(b, BYTE) -prints b as a single byte. For example, -

-

-int b = 79;
-Serial.print(b, BYTE);
-

returns the string "O", which is the ASCII character represented by the value 79. For more information see the ASCII table. -

-

Serial.print(str) -if str is a string or an array of chars, prints str as an ASCII string. For example, -

-

-Serial.print("Hello World!");
-

prints the string "Hello World!". -

-

Parameters

-

b: the byte to print, or -

-

str: the string to print -

-

Returns

-

None -

-

Example:

-
/*
-Uses a FOR loop for data and prints a number in various formats.
-*/
-int x = 0;    // variable
-
-void setup() {
-  Serial.begin(9600);      // open the serial port at 9600 bps:    
-}
-
-void loop() {  
-  // print labels 
-  Serial.print("NO FORMAT");       // prints a label
-  Serial.print("\t");              // prints a tab
-
-  Serial.print("DEC");  
-  Serial.print("\t");      
-
-  Serial.print("HEX"); 
-  Serial.print("\t");   
-
-  Serial.print("OCT");
-  Serial.print("\t");
-
-  Serial.print("BIN");
-  Serial.print("\t"); 
-
-  Serial.println("BYTE");
-
-  for(x=0; x< 64; x++){    // only part of the ASCII chart, change to suit
-
-    // print it out in many formats:
-    Serial.print(x);       // print as an ASCII-encoded decimal - same as "DEC"
-    Serial.print("\t");    // prints a tab
-
-    Serial.print(x, DEC);  // print as an ASCII-encoded decimal
-    Serial.print("\t");    // prints a tab
-
-    Serial.print(x, HEX);  // print as an ASCII-encoded hexadecimal
-    Serial.print("\t");    // prints a tab
-
-    Serial.print(x, OCT);  // print as an ASCII-encoded octal
-    Serial.print("\t");    // prints a tab
-
-    Serial.print(x, BIN);  // print as an ASCII-encoded binary
-    Serial.print("\t");    // prints a tab
-
-    Serial.println(x, BYTE);    // prints as a raw byte value, 
-    //                             then adds the carriage return with "println"
-    delay(200);            // delay 200 milliseconds
-  }
-  Serial.println("");      // prints another carriage return
-}
-
-

Programming Tips / Known Issues

-

Serial.print() doesn't work on floats, so you'll need to cast them to an integral type, losing any fractional values. It is sometimes useful to multiply your float by a power of ten, to preserve some of this fractional resolution. -

-

Be careful about doing math inside the brackets e.g.
Serial.print(x-2, DEC);
The unsigned char data type, and byte data type will yield incorrect results and act as though they are signed types i.e. type char. -

-

The Serial.print function puts data into a buffer. It will wait for one character to send, before going on to the next character. However the function returns before sending the last character. -

-

See also

-

Reference Home -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Serial_Println.html b/arduino-0018-linux-x64/reference/Serial_Println.html deleted file mode 100644 index 6b04b4f..0000000 --- a/arduino-0018-linux-x64/reference/Serial_Println.html +++ /dev/null @@ -1,137 +0,0 @@ - - - - Arduino - Println - - - - -
- - - - - - -
- -
-

Serial.println(data)

-

Description

-

Prints a data to the serial port, followed by a carriage return character(ASCII 13, or '\r') and a newline character (ASCII 10, or '\n'). This command takes the same forms as Serial.print(): -

-

Serial.println(b) -prints b as a decimal number in an ASCII string followed by a carriage return and a linefeed. -

-

Serial.println(b, DEC) -prints b as a decimal number in an ASCII string followed by a carriage return and a linefeed. -

-

Serial.println(b, HEX) -prints b as a hexadecimal number in an ASCII string followed by a carriage return and a linefeed. -

-

Serial.println(b, OCT) -prints b as an octal number in an ASCII string followed by a carriage return and a linefeed. -

-

Serial.println(b, BIN) -prints b as a binary number in an ASCII string followed by a carriage return and a linefeed. -

-

Serial.print(b, BYTE) -prints b as a single byte followed by a carriage return and a linefeed. -

-

Serial.println(str) -if str is a string or an array of chars, prints str an ASCII string. -

-

Serial.println() -just prints a carriage return and a linefeed. -

-

Parameter

-

data types: integer types, including char, strings (char arrays) & floats
Printing of floats is supported with a precision of two places to the right of the decimal point.
This may change soon. -

-

Returns

-

None -

-

Example:

-
-/*
-  Analog input
-
- reads an analog input on analog in 0, prints the value out.
-
- created 24 March 2006
- by Tom Igoe
- */
-
-int analogValue = 0;    // variable to hold the analog value
-
-void setup() {
-  // open the serial port at 9600 bps:
-  Serial.begin(9600);
-}
-
-void loop() {
-  // read the analog input on pin 0:
-  analogValue = analogRead(0);
-
-  // print it out in many formats:
-  Serial.println(analogValue);       // print as an ASCII-encoded decimal
-  Serial.println(analogValue, DEC);  // print as an ASCII-encoded decimal
-  Serial.println(analogValue, HEX);  // print as an ASCII-encoded hexadecimal
-  Serial.println(analogValue, OCT);  // print as an ASCII-encoded octal
-  Serial.println(analogValue, BIN);  // print as an ASCII-encoded binary
-  Serial.println(analogValue, BYTE); // print as a raw byte value
-
-  // delay 10 milliseconds before the next reading:
-  delay(10);
-}
-
-

Programming Tip / Known Issues

-

see Serial.print -

-

See also

-

Reference Home -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Serial_Read.html b/arduino-0018-linux-x64/reference/Serial_Read.html deleted file mode 100644 index 40efbc3..0000000 --- a/arduino-0018-linux-x64/reference/Serial_Read.html +++ /dev/null @@ -1,98 +0,0 @@ - - - - Arduino - Read - - - - -
- - - - - - -
- -
-

int Serial.read()

-

Description

-

Reads incoming serial data. -

-

Parameters

-

None -

-

Returns

-

the first byte of incoming serial data available (or -1 if no data is available) int -

-

Example

-
-int incomingByte = 0;	// for incoming serial data
-
-void setup() {
-	Serial.begin(9600);	// opens serial port, sets data rate to 9600 bps
-}
-
-void loop() {
-
-	// send data only when you receive data:
-	if (Serial.available() > 0) {
-		// read the incoming byte:
-		incomingByte = Serial.read();
-
-		// say what you got:
-		Serial.print("I received: ");
-		Serial.println(incomingByte, DEC);
-	}
-}
-
-
-
-

See also

-

Reference Home -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Serial_Write.html b/arduino-0018-linux-x64/reference/Serial_Write.html deleted file mode 100644 index d16f156..0000000 --- a/arduino-0018-linux-x64/reference/Serial_Write.html +++ /dev/null @@ -1,79 +0,0 @@ - - - - Arduino - Write - - - - -
- - - - - - -
- -
-

Serial.write()

-

Description

-

Writes binary data to the serial port. This data is sent as a byte or series of bytes; to send the characters representing the digits of a number use the print() function instead. -

-

Syntax

-

serial.write(val)
serial.write(str)
serial.write(buf, len) -

-

Parameters

-

val: a value to send as a single byte -

-

str: a string to send as a series of bytes -

-

buf: an array to send as a series of bytes -

-

len: the length of the buffer -

-

See also

- -
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/ServerAvailable.html b/arduino-0018-linux-x64/reference/ServerAvailable.html deleted file mode 100644 index bb99d76..0000000 --- a/arduino-0018-linux-x64/reference/ServerAvailable.html +++ /dev/null @@ -1,113 +0,0 @@ - - - - Arduino - ServerAvailable - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Ethernet : Server class -

-

available()

-

Description

-

Gets a client that is connected to the server and has data available for reading. The connection persists when the returned client object goes out of scope; you can close it by calling client.stop(). -

-

Syntax

-

server.available() -

-

Parameters

-

None -

-

Returns

-

None -

-

Example

-
-#include <Ethernet.h>
-
-// network configuration.  gateway and subnet are optional.
-byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
-byte ip[] = { 10, 0, 0, 177 };
-byte gateway[] = { 10, 0, 0, 1 };
-byte subnet[] = { 255, 255, 0, 0 };
-
-// telnet defaults to port 23
-Server server = Server(23);
-
-void setup()
-{
-  // initialize the ethernet device
-  Ethernet.begin(mac, ip, gateway, subnet);
-
-  // start listening for clients
-  server.begin();
-}
-
-void loop()
-{
-  Client client = server.available();
-  if (client) {
-    server.write(client.read());
-  }
-}
-
-
-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/ServerBegin.html b/arduino-0018-linux-x64/reference/ServerBegin.html deleted file mode 100644 index 10410d6..0000000 --- a/arduino-0018-linux-x64/reference/ServerBegin.html +++ /dev/null @@ -1,113 +0,0 @@ - - - - Arduino - ServerBegin - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Ethernet : Server class -

-

begin()

-

Description

-

Tells the server to begin listening for incoming connections. -

-

Syntax

-

server.begin() -

-

Parameters

-

None -

-

Returns

-

None -

-

Example

-
-#include <Ethernet.h>
-
-// network configuration.  gateway and subnet are optional.
-byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
-byte ip[] = { 10, 0, 0, 177 };
-byte gateway[] = { 10, 0, 0, 1 };
-byte subnet[] = { 255, 255, 0, 0 };
-
-// telnet defaults to port 23
-Server server = Server(23);
-
-void setup()
-{
-  // initialize the ethernet device
-  Ethernet.begin(mac, ip, gateway, subnet);
-
-  // start listening for clients
-  server.begin();
-}
-
-void loop()
-{
-  Client client = server.available();
-  if (client) {
-    server.write(client.read());
-  }
-}
-
-
-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/ServerConstructor.html b/arduino-0018-linux-x64/reference/ServerConstructor.html deleted file mode 100644 index 4164daa..0000000 --- a/arduino-0018-linux-x64/reference/ServerConstructor.html +++ /dev/null @@ -1,113 +0,0 @@ - - - - Arduino - ServerConstructor - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Ethernet : Server class -

-

Server()

-

Description

-

Create a server that listens for incoming connections on the specified port. -

-

Syntax

-

Server(port); -

-

Parameters

-

port: the port to listen on (int) -

-

Returns

-

None -

-

Example

-
-#include <Ethernet.h>
-
-// network configuration.  gateway and subnet are optional.
-byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
-byte ip[] = { 10, 0, 0, 177 };
-byte gateway[] = { 10, 0, 0, 1 };
-byte subnet[] = { 255, 255, 0, 0 };
-
-// telnet defaults to port 23
-Server server = Server(23);
-
-void setup()
-{
-  // initialize the ethernet device
-  Ethernet.begin(mac, ip, gateway, subnet);
-
-  // start listening for clients
-  server.begin();
-}
-
-void loop()
-{
-  Client client = server.available();
-  if (client) {
-    server.write(client.read());
-  }
-}
-
-
-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/ServerPrint.html b/arduino-0018-linux-x64/reference/ServerPrint.html deleted file mode 100644 index 747524e..0000000 --- a/arduino-0018-linux-x64/reference/ServerPrint.html +++ /dev/null @@ -1,85 +0,0 @@ - - - - Arduino - ServerPrint - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Ethernet : Server class -

-

print()

-

Description

-

Print data to all the clients connected to a server. Prints numbers as a sequence of digits, each an ASCII character (e.g. the number 123 is sent as the three characters '1', '2', '3'). -

-

Syntax

-

server.print(data)
server.print(data, BASE) -

-

Parameters

-

data: the data to print (char, byte, int, long, or string) -

-

BASE (optional): the base in which to print numbers: BIN for binary (base 2), DEC for decimal (base 10), OCT for octal (base 8), HEX for hexadecimal (base 16). -

-

Example

-
-
-
-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/ServerPrintln.html b/arduino-0018-linux-x64/reference/ServerPrintln.html deleted file mode 100644 index 0bf8a46..0000000 --- a/arduino-0018-linux-x64/reference/ServerPrintln.html +++ /dev/null @@ -1,85 +0,0 @@ - - - - Arduino - ServerPrintln - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Ethernet : Server class -

-

println()

-

Description

-

Print data, followed by a newline, to all the clients connected to a server. Prints numbers as a sequence of digits, each an ASCII character (e.g. the number 123 is sent as the three characters '1', '2', '3'). -

-

Syntax

-

server.println()
server.println(data)
server.println(data, BASE) -

-

Parameters

-

data (optional): the data to print (char, byte, int, long, or string) -

-

BASE (optional): the base in which to print numbers: BIN for binary (base 2), DEC for decimal (base 10), OCT for octal (base 8), HEX for hexadecimal (base 16). -

-

Example

-
-
-
-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/ServerWrite.html b/arduino-0018-linux-x64/reference/ServerWrite.html deleted file mode 100644 index fc42015..0000000 --- a/arduino-0018-linux-x64/reference/ServerWrite.html +++ /dev/null @@ -1,113 +0,0 @@ - - - - Arduino - ServerWrite - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Ethernet : Server class -

-

write()

-

Description

-

Write data to all the clients connected to a server. -

-

Syntax

-

server.write(data) -

-

Parameters

-

data: the value to write (byte or char) -

-

Returns

-

None -

-

Example

-
-#include <Ethernet.h>
-
-// network configuration.  gateway and subnet are optional.
-byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
-byte ip[] = { 10, 0, 0, 177 };
-byte gateway[] = { 10, 0, 0, 1 };
-byte subnet[] = { 255, 255, 0, 0 };
-
-// telnet defaults to port 23
-Server server = Server(23);
-
-void setup()
-{
-  // initialize the ethernet device
-  Ethernet.begin(mac, ip, gateway, subnet);
-
-  // start listening for clients
-  server.begin();
-}
-
-void loop()
-{
-  Client client = server.available();
-  if (client) {
-    server.write(client.read());
-  }
-}
-
-
-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Servo.html b/arduino-0018-linux-x64/reference/Servo.html deleted file mode 100644 index 2376fb3..0000000 --- a/arduino-0018-linux-x64/reference/Servo.html +++ /dev/null @@ -1,86 +0,0 @@ - - - - Arduino - Servo - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Servo library

-

This library allows an Arduino board to control RC (hobby) servo motors. Servos have integrated gears and a shaft that can precisely controlled. Standard servos allow the shaft to be positioned at various angles, usually between 0 and 180 degrees. Continuous rotation servos allow the rotation of the shaft to be set to various speeds. -

-

As of Arduino 0017, the Servo library supports up to 12 motors on most Arduino boards and 48 on the Arduino Mega. On boards other than the Mega, use of the library disables analogWrite() (PWM) functionality on pins 9 and 10, whether or not there is a Servo on those pins. On the Mega, up to 12 servos can be used without interfering with PWM functionality; use of 12 to 23 motors will disable PWM on pins 11 and 12. -

-

In Arduino 0016 and earlier, the Servo library uses functionality built in to the hardware, and works only on pins 9 and 10 (and does not work on the Arduino Mega). In this case, if only one servo is used, the other pin cannot be used for normal PWM output with analogWrite(). For example, in Arduino 0016 and earlier, you can't have a servo on pin 9 and PWM output on pin 10. -

-

Circuit

-

Servo motors have three wires: power, ground, and signal. The power wire is typically red, and should be connected to the 5V pin on the Arduino board. The ground wire is typically black or brown and should be connected to a ground pin on the Arduino board. The signal pin is typically yellow, orange or white and should be connected to a digital pin on the Arduino board. Note servos draw considerable power, so if you need to drive more than one or two, you'll probably need to power them from a separate supply (i.e. not the +5V pin on your Arduino). Be sure to connect the grounds of the Arduino and external power supply together. -

-

Functions

-

Examples

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/ServoAttach.html b/arduino-0018-linux-x64/reference/ServoAttach.html deleted file mode 100644 index 679e0b5..0000000 --- a/arduino-0018-linux-x64/reference/ServoAttach.html +++ /dev/null @@ -1,102 +0,0 @@ - - - - Arduino - ServoAttach - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Servo -

-

attach()

-

Description

-

Attach the Servo variable to a pin. Note that in Arduino 0016 and earlier, the Servo library supports only servos on only two pins: 9 and 10. -

-

Syntax

-

servo.attach(pin)
servo.attach(pin, min, max) -

-

Parameters

-

servo: a variable of type Servo -

-

pin: the number of the pin that the servo is attached to -

-

min (optional): the pulse width, in microseconds, corresponding to the minimum (0-degree) angle on the servo (defaults to 544) -

-

max (optional): the pulse width, in microseconds, corresponding to the maximum (180-degree) angle on the servo (defaults to 2400) -

-

Example

-
-#include <Servo.h> 
-
-Servo myservo;
-
-void setup() 
-{ 
-  myservo.attach(9);
-} 
-
-void loop() {} 
-
-
-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/ServoAttached.html b/arduino-0018-linux-x64/reference/ServoAttached.html deleted file mode 100644 index e7157e9..0000000 --- a/arduino-0018-linux-x64/reference/ServoAttached.html +++ /dev/null @@ -1,85 +0,0 @@ - - - - Arduino - ServoAttached - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Servo -

-

attached()

-

Description

-

Check whether the Servo variable is attached to a pin. -

-

Syntax

-

servo.attached() -

-

Parameters

-

servo: a variable of type Servo -

-

Returns

-

true if the servo is attached to pin; false otherwise. -

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/ServoDetach.html b/arduino-0018-linux-x64/reference/ServoDetach.html deleted file mode 100644 index 08038fc..0000000 --- a/arduino-0018-linux-x64/reference/ServoDetach.html +++ /dev/null @@ -1,82 +0,0 @@ - - - - Arduino - ServoDetach - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Servo -

-

detach()

-

Description

-

Detach the Servo variable from its pin. If all Servo variables are detached, then pins 9 and 10 can be used for PWM output with analogWrite(). -

-

Syntax

-

servo.detach() -

-

Parameters

-

servo: a variable of type Servo -

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/ServoRead.html b/arduino-0018-linux-x64/reference/ServoRead.html deleted file mode 100644 index 0d1d2e9..0000000 --- a/arduino-0018-linux-x64/reference/ServoRead.html +++ /dev/null @@ -1,84 +0,0 @@ - - - - Arduino - ServoRead - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Servo -

-

read()

-

Description

-

Read the current angle of the servo (the value passed to the last call to write()). -

-

Syntax

-

servo.read() -

-

Parameters

-

servo: a variable of type Servo -

-

Returns

-

The angle of the servo, from 0 to 180 degrees. -

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/ServoWrite.html b/arduino-0018-linux-x64/reference/ServoWrite.html deleted file mode 100644 index 16412d2..0000000 --- a/arduino-0018-linux-x64/reference/ServoWrite.html +++ /dev/null @@ -1,99 +0,0 @@ - - - - Arduino - ServoWrite - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Servo -

-

write()

-

Description

-

Writes a value to the servo, controlling the shaft accordingly. On a standard servo, this will set the angle of the shaft (in degrees), moving the shaft to that orientation. On a continuous rotation servo, this will set the speed of the servo (with 0 being full-speed in one direction, 180 being full speed in the other, and a value near 90 being no movement). -

-

Syntax

-

servo.write(angle) -

-

Parameters

-

servo: a variable of type Servo -

-

angle: the value to write to the servo, from 0 to 180 -

-

Example

-
-#include <Servo.h> 
-
-Servo myservo;
-
-void setup() 
-{ 
-  myservo.attach(9);
-  myservo.write(90);  // set servo to mid-point
-} 
-
-void loop() {} 
-
-
-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/ServoWriteMicroseconds.html b/arduino-0018-linux-x64/reference/ServoWriteMicroseconds.html deleted file mode 100644 index 9fee605..0000000 --- a/arduino-0018-linux-x64/reference/ServoWriteMicroseconds.html +++ /dev/null @@ -1,103 +0,0 @@ - - - - Arduino - ServoWriteMicroseconds - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Servo -

-

writeMicroseconds()

-

Description

-

Writes a value in microseconds (uS) to the servo, controlling the shaft accordingly. On a standard servo, this will set the angle of the shaft. On standard servos a parameter value of 1000 is fully counter-clockwise, 2000 is fully clockwise, and 1500 is in the middle. -

-

Note that some manufactures do not follow this standard very closely so that servos often respond to values between 700 and 2300. Feel free to increase these endpoints until the servo no longer continues to increase its range. Note however that attempting to drive a servo past its endpoints (often indicated by a growling sound) is a high-current state, and should be avoided. -

-

Continuous-rotation servos will respond to the writeMicrosecond function in an analogous manner to the write function. -

-

Syntax

-

servo.writeMicroseconds(uS) -

-

Parameters

-

servo: a variable of type Servo -

-

uS: the value of the parameter in microseconds (int) -

-

Example

-
-#include <Servo.h> 
-
-Servo myservo;
-
-void setup() 
-{ 
-  myservo.attach(9);
-  myservo.writeMicroseconds(1500);  // set servo to mid-point
-} 
-
-void loop() {} 
-
-
-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Setup.html b/arduino-0018-linux-x64/reference/Setup.html deleted file mode 100644 index 3099ede..0000000 --- a/arduino-0018-linux-x64/reference/Setup.html +++ /dev/null @@ -1,86 +0,0 @@ - - - - Arduino - Setup - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

setup()

-

The setup() function is called when a sketch starts. Use it to initialize variables, pin modes, start using libraries, etc. The setup function will only run once, after each powerup or reset of the Arduino board. -

-

Example

-
 
-int buttonPin = 3;
-
-void setup()
-{
-  Serial.begin(9600);
-  pinMode(buttonPin, INPUT);
-}
-
-void loop()
-{
-  // ...
-}
-
-
-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/ShiftOut.html b/arduino-0018-linux-x64/reference/ShiftOut.html deleted file mode 100644 index 12925c7..0000000 --- a/arduino-0018-linux-x64/reference/ShiftOut.html +++ /dev/null @@ -1,146 +0,0 @@ - - - - Arduino - ShiftOut - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

shiftOut()

-

Description

-

Shifts out a byte of data one bit at a time. Starts from either the most (i.e. the leftmost) or least (rightmost) significant bit. Each bit is written in turn to a data pin, after which a clock pin is toggled to indicate that the bit is available. -

-

This is known as synchronous serial protocol and is a common way that microcontrollers communicate with sensors, and with other microcontrollers. The two devices stay synchronized, and communicate at close to maximum speeds, since they both share the same clock line. This is often referred to in chip hardware documentation as Serial Peripheral Interface (SPI). -

-

Syntax

-

shiftOut(dataPin, clockPin, bitOrder, value) -

-

Parameters

-

dataPin: the pin on which to output each bit (int) -

-

clockPin: the pin to toggle once the dataPin has been set to the correct value (int) -

-

bitOrder: which order to shift out the bits; either MSBFIRST or LSBFIRST.
(Most Significant Bit First, or, Least Significant Bit First) -

-

value: the data to shift out. (byte) -

-

Returns

-

None -

-

Note

-

The dataPin and clockPin must already be configured as outputs by a call to pinMode(). -

-

shiftOut is currently written to output 1 byte (8 bits) so it requires a two step operation to output values larger than 255. -

-// Do this for MSBFIRST serial
-int data = 500;
-// shift out highbyte
-shiftOut(dataPin, clock, MSBFIRST, (data >> 8));  
-// shift out lowbyte
-shiftOut(data, clock, MSBFIRST, data);
-
-// Or do this for LSBFIRST serial
-data = 500;
-// shift out lowbyte
-shiftOut(dataPin, clock, LSBFIRST, data);  
-// shift out highbyte 
-shiftOut(dataPin, clock, LSBFIRST, (data >> 8)); 
-
-

Example

-

For accompanying circuit, see the tutorial on controlling a 74HC595 shift register. -

-

//**************************************************************//
-//  Name    : shiftOutCode, Hello World                         //
-//  Author  : Carlyn Maw,Tom Igoe                               //
-//  Date    : 25 Oct, 2006                                      //
-//  Version : 1.0                                               //
-//  Notes   : Code for using a 74HC595 Shift Register           //
-//          : to count from 0 to 255                            //
-//****************************************************************
-
-//Pin connected to ST_CP of 74HC595
-int latchPin = 8;
-//Pin connected to SH_CP of 74HC595
-int clockPin = 12;
-////Pin connected to DS of 74HC595
-int dataPin = 11;
-
-void setup() {
-  //set pins to output because they are addressed in the main loop
-  pinMode(latchPin, OUTPUT);
-  pinMode(clockPin, OUTPUT);
-  pinMode(dataPin, OUTPUT);
-}
-
-void loop() {
-  //count up routine
-  for (int j = 0; j < 256; j++) {
-    //ground latchPin and hold low for as long as you are transmitting
-    digitalWrite(latchPin, LOW);
-    shiftOut(dataPin, clockPin, LSBFIRST, j);   
-    //return the latch pin high to signal chip that it 
-    //no longer needs to listen for information
-    digitalWrite(latchPin, HIGH);
-    delay(1000);
-  }
-} 
-
-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Sin.html b/arduino-0018-linux-x64/reference/Sin.html deleted file mode 100644 index 3d07f48..0000000 --- a/arduino-0018-linux-x64/reference/Sin.html +++ /dev/null @@ -1,85 +0,0 @@ - - - - Arduino - Sin - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

sin(rad)

-

Description

-

Calculates the sine of an angle (in radians). The result will be between -1 and 1. -

-

Parameters

-

rad: the angle in radians (float) -

-

Returns

-

the sine of the angle (double) -

-

Note

-

Serial.print() and Serial.println() do not currently support printing floats. -

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Sizeof.html b/arduino-0018-linux-x64/reference/Sizeof.html deleted file mode 100644 index e526ad2..0000000 --- a/arduino-0018-linux-x64/reference/Sizeof.html +++ /dev/null @@ -1,107 +0,0 @@ - - - - Arduino - Sizeof - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

sizeof

-

Description

-

The sizeof operator returns the number of bytes in a variable type, or the number of bytes occupied by an array. -

-

Syntax

-

sizeof(variable) -

-

Parameters

-

variable: any variable type or array (e.g. int, float, byte) -

-

Example code

-

The sizeof operator is useful for dealing with arrays (such as strings) where it is convenient to be able to change the size of the array without breaking other parts of the program. -

-

This program prints out a text string one character at a time. Try changing the text phrase. -

-

-char myStr[] = "this is a test";
-int i;
-
-void setup(){
-  Serial.begin(9600);
-}
-
-void loop() { 
-  for (i = 0; i < sizeof(myStr) - 1; i++){
-    Serial.print(i, DEC);
-    Serial.print(" = ");
-    Serial.println(myStr[i], BYTE);
-  }
-}
-
-
-

Note that sizeof returns the total number of bytes. So for larger variable types such as ints, the for loop would look something like this. -

-

-for (i = 0; i < (sizeof(myInts)/sizeof(int)) - 1; i++) {
-  // do something with myInts[i]
-}
-
-
-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/SoftwareSerial.html b/arduino-0018-linux-x64/reference/SoftwareSerial.html deleted file mode 100644 index 5f4ad92..0000000 --- a/arduino-0018-linux-x64/reference/SoftwareSerial.html +++ /dev/null @@ -1,91 +0,0 @@ - - - - Arduino - SoftwareSerial - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

SoftwareSerial Library

-

The Arduino hardware has built-in support for serial communication on pins 0 and 1 (which also goes to the computer via the USB connection). The native serial support happens via a piece of hardware (built into the chip) called a UART. This hardware allows the Atmega chip to receive serial communication even while working on other tasks, as long as there room in the 64 byte serial buffer. -

-

The SoftwareSerial library has been developed to allow serial communication on other digital pins of the Arduino, using software to replicate the functionality (hence the name "SoftwareSerial"). -

-

Limitations

-

Because it's not supported by hardware, the library has a few limitations: -

-

  • Only speeds up to 9600 baud work -
  • Serial.available() doesn't work -
  • Serial.read() will wait until data arrives -
  • Only data received while Serial.read() is being called will be received. Data received at other times will be lost, since the chip is not "listening". -

SoftwareSerial appears to have some timing issues and/or software issues. Check this forum thread for discussion. -Software Serial Discussion. In particular, if you are having problems using SoftwareSerial with an Atmega168 chip delete SoftwareSerial.o in your Arduino directory. -

-

Example

-
 SoftwareSerialExample
-
-

Functions

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/SoftwareSerialBegin.html b/arduino-0018-linux-x64/reference/SoftwareSerialBegin.html deleted file mode 100644 index 8cb8f3b..0000000 --- a/arduino-0018-linux-x64/reference/SoftwareSerialBegin.html +++ /dev/null @@ -1,105 +0,0 @@ - - - - Arduino - SoftwareSerialBegin - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

SoftwareSerial: begin(speed)

-

Description

-

Sets the speed (baud rate) for the serial communication. Using speeds higher than 9600 baud will result in faulty communication. -

-

Parameters

-

speed: the baud rate (long) -

-

Returns

-

none -

-

Example

-
// include the SoftwareSerial library so you can use its functions:
-#include <SoftwareSerial.h>
-
-#define rxPin 2
-#define txPin 3
-
-// set up a new serial port
-SoftwareSerial mySerial =  SoftwareSerial(rxPin, txPin);
-
-void setup()  {
-  // define pin modes for tx, rx:
-  pinMode(rxPin, INPUT);
-  pinMode(txPin, OUTPUT);
-  // set the data rate for the SoftwareSerial port
-  mySerial.begin(9600);
-}
-
-void loop() {
-  // ...
-}
-
-
-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/SoftwareSerialConstructor.html b/arduino-0018-linux-x64/reference/SoftwareSerialConstructor.html deleted file mode 100644 index 051ea59..0000000 --- a/arduino-0018-linux-x64/reference/SoftwareSerialConstructor.html +++ /dev/null @@ -1,88 +0,0 @@ - - - - Arduino - SoftwareSerialConstructor - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

SoftwareSerial(rxPin, txPin)

-

Description

-

A call to SoftwareSerial(rxPin, txPin) creates a new SoftwareSerial object, whose name you need to provide as in the example below. You still need to call SoftwareSerial.begin(). -

-

Parameters

-

rxPin: the pin on which to receive serial data -

-

txPin: the pin on which to transmit serial data -

-

Example

-
#define rxPin 2
-#define txPin 3
-
-// set up a new serial port
-SoftwareSerial mySerial =  SoftwareSerial(rxPin, txPin);
-
-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/SoftwareSerialExample.html b/arduino-0018-linux-x64/reference/SoftwareSerialExample.html deleted file mode 100644 index da69d58..0000000 --- a/arduino-0018-linux-x64/reference/SoftwareSerialExample.html +++ /dev/null @@ -1,124 +0,0 @@ - - - - Arduino - SoftwareSerialExample - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

This is a very basic example of SoftwareSerial. It reads in a byte at a time and mirrors it back to you: -

-

-/*
-  SoftwareSerial example
-
-  Sample of the SoftwareSerial library.  Listens for serial in on pin 2
-  and sends it out again on pin 3.
-
-  by Tom Igoe
-  based on examples by David Mellis and Heather Dewey-Hagborg
-  written: 6 Jan 2007
-
-
-*/
-
-// include the SoftwareSerial library so you can use its functions:
-#include <SoftwareSerial.h>
-
-#define rxPin 2
-#define txPin 3
-#define ledPin 13
-
-// set up a new serial port
-SoftwareSerial mySerial =  SoftwareSerial(rxPin, txPin);
-byte pinState = 0;
-
-void setup()  {
-  // define pin modes for tx, rx, led pins:
-  pinMode(rxPin, INPUT);
-  pinMode(txPin, OUTPUT);
-  pinMode(ledPin, OUTPUT);
-  // set the data rate for the SoftwareSerial port
-  mySerial.begin(9600);
-}
-
-void loop() {
-  // listen for new serial coming in:
-  char someChar = mySerial.read();
-  // print out the character:
-  mySerial.print(someChar);
-  // toggle an LED just so you see the thing's alive.  
-  // this LED will go on with every OTHER character received:
-  toggle(13);
-
-}
-
-
-void toggle(int pinNum) {
-  // set the LED pin using the pinState variable:
-  digitalWrite(pinNum, pinState); 
-  // if pinState = 0, set it to 1, and vice versa:
-  pinState = !pinState;
-}
-
-
-
-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/SoftwareSerialPrint.html b/arduino-0018-linux-x64/reference/SoftwareSerialPrint.html deleted file mode 100644 index 00ffe99..0000000 --- a/arduino-0018-linux-x64/reference/SoftwareSerialPrint.html +++ /dev/null @@ -1,118 +0,0 @@ - - - - Arduino - SoftwareSerialPrint - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

SoftwareSerial: print(data)

-

Description

-

Prints data to the transmit pin of the software serial port. Works the same as the Serial.print() function. -

-

Parameters

-

vary, see Serial.print() for details -

-

Returns

-

none -

-

Example

-
SoftwareSerial serial(6, 7);
-int analogValue;
-
-void setup()
-{
-  serial.begin(9600);
-}
-
-void loop()
-{
-  // read the analog input on pin 0:
-  analogValue = analogRead(0);
-
-  // print it out in many formats:
-  serial.print(analogValue);         // print as an ASCII-encoded decimal
-  serial.print("\t");                // print a tab character
-  serial.print(analogValue, DEC);    // print as an ASCII-encoded decimal
-  serial.print("\t");                // print a tab character
-  serial.print(analogValue, HEX);    // print as an ASCII-encoded hexadecimal
-  serial.print("\t");                // print a tab character
-  serial.print(analogValue, OCT);    // print as an ASCII-encoded octal
-  serial.print("\t");                // print a tab character
-  serial.print(analogValue, BIN);    // print as an ASCII-encoded binary
-  serial.print("\t");                // print a tab character
-  serial.print(analogValue/4, BYTE); // print as a raw byte value (divide the
-                                     // value by 4 because analogRead() returns numbers
-                                     // from 0 to 1023, but a byte can only hold values
-                                     // up to 255)
-  serial.print("\t");                // print a tab character    
-  serial.println();                  // print a linefeed character
-
-  // delay 10 milliseconds before the next reading:
-  delay(10);
-} 
-
-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/SoftwareSerialPrintln.html b/arduino-0018-linux-x64/reference/SoftwareSerialPrintln.html deleted file mode 100644 index 25a97c2..0000000 --- a/arduino-0018-linux-x64/reference/SoftwareSerialPrintln.html +++ /dev/null @@ -1,118 +0,0 @@ - - - - Arduino - SoftwareSerialPrintln - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

SoftwareSerial: println(data)

-

Description

-

Prints data to the transmit pin of the software serial port, followed by a carriage return and line feed. Works the same as the Serial.println() function. -

-

Parameters

-

vary, see Serial.println() for details -

-

Returns

-

none -

-

Example

-
SoftwareSerial serial(6, 7);
-int analogValue;
-
-void setup()
-{
-  serial.begin(9600);
-}
-
-void loop()
-{
-  // read the analog input on pin 0:
-  analogValue = analogRead(0);
-
-  // print it out in many formats:
-  serial.print(analogValue);         // print as an ASCII-encoded decimal
-  serial.print("\t");                // print a tab character
-  serial.print(analogValue, DEC);    // print as an ASCII-encoded decimal
-  serial.print("\t");                // print a tab character
-  serial.print(analogValue, HEX);    // print as an ASCII-encoded hexadecimal
-  serial.print("\t");                // print a tab character
-  serial.print(analogValue, OCT);    // print as an ASCII-encoded octal
-  serial.print("\t");                // print a tab character
-  serial.print(analogValue, BIN);    // print as an ASCII-encoded binary
-  serial.print("\t");                // print a tab character
-  serial.print(analogValue/4, BYTE); // print as a raw byte value (divide the
-                                     // value by 4 because analogRead() returns numbers
-                                     // from 0 to 1023, but a byte can only hold values
-                                     // up to 255)
-  serial.print("\t");                // print a tab character    
-  serial.println();                  // print a linefeed character
-
-  // delay 10 milliseconds before the next reading:
-  delay(10);
-} 
-
-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/SoftwareSerialRead.html b/arduino-0018-linux-x64/reference/SoftwareSerialRead.html deleted file mode 100644 index 4d7c0b9..0000000 --- a/arduino-0018-linux-x64/reference/SoftwareSerialRead.html +++ /dev/null @@ -1,95 +0,0 @@ - - - - Arduino - SoftwareSerialRead - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

SoftwareSerial: int read()

-

Description

-

Reads a character from the receive pin of the software serial port. This function waits for a character to arrive, reads it, and returns the character read. Data that arrives at other times is lost. -

-

Parameters

-

none -

-

Returns

-

the character read -

-

Example

-
SoftwareSerial serial(6, 7);
-
-void setup()
-{
-  serial.begin(9600);
-}
-
-void loop()
-{
-  char c = serial.read();
-} 
-
-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Sqrt.html b/arduino-0018-linux-x64/reference/Sqrt.html deleted file mode 100644 index 6096bb1..0000000 --- a/arduino-0018-linux-x64/reference/Sqrt.html +++ /dev/null @@ -1,80 +0,0 @@ - - - - Arduino - Sqrt - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

sqrt(x)

-

Description

-

Calculates the square root of a number. -

-

Parameters

-

x: the number, any data type -

-

Returns

-

double, the number's square root. -

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Static.html b/arduino-0018-linux-x64/reference/Static.html deleted file mode 100644 index b135661..0000000 --- a/arduino-0018-linux-x64/reference/Static.html +++ /dev/null @@ -1,123 +0,0 @@ - - - - Arduino - Static - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Static

-

The static keyword is used to create variables that are visible to only one function. However unlike local variables that get created and destroyed every time a function is called, static variables persist beyond the function call, preserving their data between function calls. -

-

Variables declared as static will only be created and initialized the first time a function is called. -

-

Example

-
-
-
-/* RandomWalk
-* Paul Badger 2007
-* RandomWalk wanders up and down randomly between two
-* endpoints. The maximum move in one loop is governed by
-* the parameter "stepsize".
-* A static variable is moved up and down a random amount.
-* This technique is also known as "pink noise" and "drunken walk".
-*/
-
-#define randomWalkLowRange -20
-#define randomWalkHighRange 20
-int stepsize;
-
-int thisTime;
-int total;
-
-void setup()
-{
-  Serial.begin(9600);
-}
-
-void loop()
-{        //  tetst randomWalk function
-  stepsize = 5;
-  thisTime = randomWalk(stepsize);
-  Serial.println(thisTime);
-   delay(10);
-}
-
-int randomWalk(int moveSize){
-  static int  place;     // variable to store value in random walk - declared static so that it stores
-                         // values in between function calls, but no other functions can change its value
-
-  place = place + (random(-moveSize, moveSize + 1));
-
-  if (place < randomWalkLowRange){                    // check lower and upper limits
-    place = place + (randomWalkLowRange - place);     // reflect number back in positive direction
-  }
-  else if(place > randomWalkHighRange){
-    place = place - (place - randomWalkHighRange);     // reflect number back in negative direction
-  }
-
-  return place;
-}
-
-
-
-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Stepper.html b/arduino-0018-linux-x64/reference/Stepper.html deleted file mode 100644 index e07956d..0000000 --- a/arduino-0018-linux-x64/reference/Stepper.html +++ /dev/null @@ -1,80 +0,0 @@ - - - - Arduino - Stepper - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Stepper Library

-

This library allows you to control unipolar or bipolar stepper motors. To use it you will need a stepper motor, and the appropriate hardware to control it. For more on that, see Tom Igoe's notes on steppers. -

-

Circuits

-

Functions

-

Example

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/StepperBipolarCircuit.html b/arduino-0018-linux-x64/reference/StepperBipolarCircuit.html deleted file mode 100644 index 883bde7..0000000 --- a/arduino-0018-linux-x64/reference/StepperBipolarCircuit.html +++ /dev/null @@ -1,72 +0,0 @@ - - - - Arduino - StepperBipolarCircuit - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Circuit for Bipolar Stepper Motor

-

Two Pins

-
-

Four Pins

-
-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/StepperConstructor.html b/arduino-0018-linux-x64/reference/StepperConstructor.html deleted file mode 100644 index bbecb2e..0000000 --- a/arduino-0018-linux-x64/reference/StepperConstructor.html +++ /dev/null @@ -1,88 +0,0 @@ - - - - Arduino - StepperConstructor - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Stepper(steps, pin1, pin2)

-

Stepper(steps, pin1, pin2, pin3, pin4)

-

Description

-

This function creates a new instance of the Stepper class that represents a particular stepper motor attached to your Arduino board. Use it at the top of your sketch, above setup() and loop(). The number of parameters depends on how you've wired your motor - either using two or four pins of the Arduino board. -

-

Parameters

-

steps: the number of steps in one revolution of your motor. If your motor gives the number of degrees per step, divide that number into 360 to get the number of steps (e.g. 360 / 3.6 gives 100 steps). (int) -

-

pin1, pin2: two pins that are attached to the motor (int) -

-

pin3, pin4: optional the last two pins attached to the motor, if it's connected to four pins (int) -

-

Returns

-

A new instance of the Stepper motor class. -

-

Example

-

Stepper myStepper = Stepper(100, 5, 6); -

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/StepperSetSpeed.html b/arduino-0018-linux-x64/reference/StepperSetSpeed.html deleted file mode 100644 index 3ba8b06..0000000 --- a/arduino-0018-linux-x64/reference/StepperSetSpeed.html +++ /dev/null @@ -1,81 +0,0 @@ - - - - Arduino - StepperSetSpeed - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Stepper: setSpeed(rpms)

-

Description

-

Sets the motor speed in rotations per minute (RPMs). This function doesn't make the motor turn, just sets the speed at which it will when you call step(). -

-

Parameters

-

rpms: the speed at which the motor should turn in rotations per minute - a positive number (long) -

-

Returns

-

None -

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/StepperStep.html b/arduino-0018-linux-x64/reference/StepperStep.html deleted file mode 100644 index 847ba44..0000000 --- a/arduino-0018-linux-x64/reference/StepperStep.html +++ /dev/null @@ -1,81 +0,0 @@ - - - - Arduino - StepperStep - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Stepper: step(steps)

-

Description

-

Turns the motor a specific number of steps, at a speed determined by the most recent call to setSpeed(). This function is blocking; that is, it will wait until the motor has finished moving to pass control to the next line in your sketch. For example, if you set the speed to, say, 1 RPM and called step(100) on a 100-step motor, this function would take a full minute to run. For better control, keep the speed high and only go a few steps with each call to step(). -

-

Parameters

-

steps: the number of steps to turn the motor - positive to turn one direction, negative to turn the other (int) -

-

Returns

-

None -

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/StepperUnipolarCircuit.html b/arduino-0018-linux-x64/reference/StepperUnipolarCircuit.html deleted file mode 100644 index 921574f..0000000 --- a/arduino-0018-linux-x64/reference/StepperUnipolarCircuit.html +++ /dev/null @@ -1,73 +0,0 @@ - - - - Arduino - StepperUnipolarCircuit - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Circuits for Unipolar Stepper Motors

-

Two Pins

-
  
-
-

Four Pins

-
-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/SwitchCase.html b/arduino-0018-linux-x64/reference/SwitchCase.html deleted file mode 100644 index 009e66c..0000000 --- a/arduino-0018-linux-x64/reference/SwitchCase.html +++ /dev/null @@ -1,109 +0,0 @@ - - - - Arduino - SwitchCase - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

switch / case statements

-

Like if statements, switch...case controls the flow of programs by allowing programmers to specify different code that should be executed in various conditions. In particular, a switch statement compares the value of a variable to the values specified in case statements. When a case statement is found whose value matches that of the variable, the code in that case statement is run. -

-

The break keyword exits the switch statement, and is typically used at the end of each case. Without a break statement, the switch statement will continue executing the following expressions ("falling-through") until a break, or the end of the switch statement is reached. -

-

Example

-
-  switch (var) {
-    case 1:
-      //do something when var equals 1
-      break;
-    case 2:
-      //do something when var equals 2
-      break;
-    default: 
-      // if nothing else matches, do the default
-      // default is optional
-  }
-
-
-

Syntax

-
-switch (var) {
-  case label:
-    // statements
-    break;
-  case label:
-    // statements
-    break;
-  default: 
-    // statements
-}
-
-
-

Parameters

-

var: the variable whose value to compare to the various cases -

-

label: a value to compare the variable to -

-

See also:

-

if...else -

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Tan.html b/arduino-0018-linux-x64/reference/Tan.html deleted file mode 100644 index c08220f..0000000 --- a/arduino-0018-linux-x64/reference/Tan.html +++ /dev/null @@ -1,85 +0,0 @@ - - - - Arduino - Tan - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

tan(rad)

-

Description

-

Calculates the tangent of an angle (in radians). The result will be between negative infinity and infinity. -

-

Parameters

-

rad: the angle in radians (float) -

-

Returns

-

The tangent of the angle (double) -

-

Note

-

Serial.print() and Serial.println() do not currently support printing floats. -

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Tone.html b/arduino-0018-linux-x64/reference/Tone.html deleted file mode 100644 index a5afc5e..0000000 --- a/arduino-0018-linux-x64/reference/Tone.html +++ /dev/null @@ -1,90 +0,0 @@ - - - - Arduino - Tone - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

tone()

-

Description

-

Generates a square wave of the specified frequency (and 50% duty cycle) on a pin. A duration can be specified, otherwise the wave continues until a call to noTone(). The pin can be connected to a piezo buzzer or other speaker to play tones. -

-

Only one tone can be generated at a time. If a tone is already playing on a different pin, the call to tone() will have no effect. If the tone is playing on the same pin, the call will set its frequency. -

-

Syntax

-

tone(pin, frequency)
tone(pin, frequency, duration) -

-

Parameters

-

pin: the pin on which to generate the tone -

-

frequency: the frequency of the tone in hertz -

-

duration: the duration of the tone in milliseconds (optional) -

-

Returns

-

nothing -

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/UnsignedChar.html b/arduino-0018-linux-x64/reference/UnsignedChar.html deleted file mode 100644 index 7862231..0000000 --- a/arduino-0018-linux-x64/reference/UnsignedChar.html +++ /dev/null @@ -1,83 +0,0 @@ - - - - Arduino - UnsignedChar - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

unsigned char

-

Description

-

An unsigned data type that occupies 1 byte of memory. Same as the byte datatype. -

-

The unsigned char datatype encodes numbers from 0 to 255. -

-

For consistency of Arduino programming style, the byte data type is to be preferred. -

-

Example

-
    unsigned char myChar = 240;
-
-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/UnsignedInt.html b/arduino-0018-linux-x64/reference/UnsignedInt.html deleted file mode 100644 index be42ed5..0000000 --- a/arduino-0018-linux-x64/reference/UnsignedInt.html +++ /dev/null @@ -1,97 +0,0 @@ - - - - Arduino - UnsignedInt - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

unsigned int

-

Description

-

Unsigned ints (unsigned integers) are the same as ints in -that they store a 2 byte value. Instead of storing negative numbers however they only store positive values, yielding a useful range of 0 to 65,535 (2^16) - 1). -

-

The difference between unsigned ints and (signed) ints, lies in the way the highest bit, sometimes refered to as the "sign" bit, is interpreted. In the Arduino int type (which is signed), if the high bit is a "1", the number is interpreted as a negative number, and the other 15 bits are interpreted with 2's complement math. -

-

Example

-
    unsigned int ledPin = 13;
-
-

Syntax

-
     unsigned int var = val;
-
-

  • var - your unsigned int variable name -
  • val - the value you assign to that variable -

Coding Tip

-

When variables are made to exceed their maximum capacity they "roll over" back to their minimum capacitiy, note that this happens in both directions -

-

   unsigned int x
-   x = 0;
-   x = x - 1;       // x now contains 65535 - rolls over in neg direction
-   x = x + 1;       // x now contains 0 - rolls over
-
-
-

See Also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/UnsignedLong.html b/arduino-0018-linux-x64/reference/UnsignedLong.html deleted file mode 100644 index 0031049..0000000 --- a/arduino-0018-linux-x64/reference/UnsignedLong.html +++ /dev/null @@ -1,101 +0,0 @@ - - - - Arduino - UnsignedLong - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

unsigned long

-

Description

-

Unsigned long variables are extended size variables for number storage, and store 32 bits (4 bytes). Unlike standard longs unsigned longs won't store negative numbers, making their range from 0 to 4,294,967,295 (2^32 - 1). -

-

Example

-
-unsigned long time;
-
-void setup()
-{
-  Serial.begin(9600);
-}
-
-void loop()
-{
-  Serial.print("Time: ");
-  time = millis();
-  //prints time since program started
-  Serial.println(time);
-  // wait a second so as not to send massive amounts of data
-  delay(1000);
-}
-
-

Syntax

-
    unsigned long var = val;
-
-

  • var - your long variable name -
  • val - the value you assign to that variable -

See Also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Void.html b/arduino-0018-linux-x64/reference/Void.html deleted file mode 100644 index cd847e9..0000000 --- a/arduino-0018-linux-x64/reference/Void.html +++ /dev/null @@ -1,89 +0,0 @@ - - - - Arduino - Void - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

void

-

The void keyword is used only in function declarations. It indicates that the function is expected to return no information to the function from which it was called. -

-

Example:

-
-// actions are performed in the functions "setup" and "loop"
-// but  no information is reported to the larger program
-
-void setup()
-{
-  // ...
-}
-
-void loop()
-{
-  // ...
-}
- 
-
-

See also

-

function declaration -

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Volatile.html b/arduino-0018-linux-x64/reference/Volatile.html deleted file mode 100644 index c35264d..0000000 --- a/arduino-0018-linux-x64/reference/Volatile.html +++ /dev/null @@ -1,102 +0,0 @@ - - - - Arduino - Volatile - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

volatile keyword

-

volatile is a keyword known as a variable qualifier, it is usually used before the datatype of a variable, to modify the way in which the compiler and subsequent program treats the variable. -

-

Declaring a variable volatile is a directive to the compiler. The compiler is software which translates your C/C++ code into the machine code, which are the real instructions for the Atmega chip in the Arduino. -

-

Specifically, it directs the compiler to load the variable from RAM and not from a storage register, which is a temporary memory location where program variables are stored and manipulated. Under certain conditions, the value for a variable stored in registers can be inaccurate. -

-

A variable should be declared volatile whenever its value can be changed by something beyond the control of the code section in which it appears, such as a concurrently executing thread. In the Arduino, the only place that this is likely to occur is in sections of code associated with interrupts, called an interrupt service routine. -

-

Example

-
-// toggles LED when interrupt pin changes state
-
-int pin = 13;
-volatile int state = LOW;
-
-void setup()
-{
-  pinMode(pin, OUTPUT);
-  attachInterrupt(0, blink, CHANGE);
-}
-
-void loop()
-{
-  digitalWrite(pin, state);
-}
-
-void blink()
-{
-  state = !state;
-}
-
-
-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/While.html b/arduino-0018-linux-x64/reference/While.html deleted file mode 100644 index 8fe183e..0000000 --- a/arduino-0018-linux-x64/reference/While.html +++ /dev/null @@ -1,88 +0,0 @@ - - - - Arduino - While - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

while loops

-

Description

-

while loops will loop continuously, and infinitely, until the expression inside the parenthesis, () becomes false. Something must change the tested variable, or the while loop will never exit. This could be in your code, such as an incremented variable, or an external condition, such as testing a sensor. -

-

Syntax

-
while(expression){
-  // statement(s)
-}
-
-

Parameters

-

expression - a (boolean) C statement that evaluates to true or false -

-

Example

-
-var = 0;
-while(var < 200){
-  // do something repetitive 200 times
-  var++;
-}
-
-
-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Wire.html b/arduino-0018-linux-x64/reference/Wire.html deleted file mode 100644 index f3fd4af..0000000 --- a/arduino-0018-linux-x64/reference/Wire.html +++ /dev/null @@ -1,84 +0,0 @@ - - - - Arduino - Wire - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Wire Library

-

This library allows you to communicate with I2C / TWI devices. On most Arduino boards, SDA (data line) is on analog input pin 4, and SCL (clock line) is on analog input pin 5. On the Arduino Mega, SDA is digital pin 20 and SCL is 21. -

-

Functions

-

Note

-

There are both 7- and 8-bit versions of I2C addresses. 7 bits identify the device, and the eighth bit determines if it's being written to or read from. The Wire library uses 7 bit addresses throughout. If you have a datasheet or sample code that uses 8 bit address, you'll want to drop the low bit (i.e. shift the value one bit to the right), yielding an address between 0 and 127. -

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/WireAvailable.html b/arduino-0018-linux-x64/reference/WireAvailable.html deleted file mode 100644 index 9ba2bb8..0000000 --- a/arduino-0018-linux-x64/reference/WireAvailable.html +++ /dev/null @@ -1,79 +0,0 @@ - - - - Arduino - WireAvailable - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Wire.available()

-

Description

-

Returns the number of bytes available for retrieval with receive(). This should be called on a master device after a call to requestFrom() or on a slave inside the onReceive() handler. -

-

Parameters

-

None -

-

Returns

-

The number of bytes available for reading. -

-

See Also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/WireBegin.html b/arduino-0018-linux-x64/reference/WireBegin.html deleted file mode 100644 index c47a2ea..0000000 --- a/arduino-0018-linux-x64/reference/WireBegin.html +++ /dev/null @@ -1,78 +0,0 @@ - - - - Arduino - WireBegin - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Wire.begin()

-

Wire.begin(address)

-

Description

-

Initiate the Wire library and join the I2C bus as a master or slave. -

-

Parameters

-

address: the 7-bit slave address (optional); if not specified, join the bus as a master. -

-

Returns

-

None -

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/WireBeginTransmission.html b/arduino-0018-linux-x64/reference/WireBeginTransmission.html deleted file mode 100644 index 5058661..0000000 --- a/arduino-0018-linux-x64/reference/WireBeginTransmission.html +++ /dev/null @@ -1,80 +0,0 @@ - - - - Arduino - WireBeginTransmission - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Wire.beginTransmission(address)

-

Description

-

Begin a transmission to the I2C slave device with the given address. Subsequently, queue bytes for transmission with the send() function and transmit them by calling endTransmission(). -

-

Parameters

-

address: the 7-bit address of the device to transmit to -

-

Returns

-

None -

-

See Also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/WireEndTransmission.html b/arduino-0018-linux-x64/reference/WireEndTransmission.html deleted file mode 100644 index 21d9371..0000000 --- a/arduino-0018-linux-x64/reference/WireEndTransmission.html +++ /dev/null @@ -1,80 +0,0 @@ - - - - Arduino - WireEndTransmission - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Wire.endTransmission()

-

Description

-

Ends a transmission to a slave device that was begun by beginTransmission() and actually transmits the bytes that were queued by send(). -

-

Parameters

-

None -

-

Returns

-

None -

-

See Also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/WireOnReceive.html b/arduino-0018-linux-x64/reference/WireOnReceive.html deleted file mode 100644 index 84f9f94..0000000 --- a/arduino-0018-linux-x64/reference/WireOnReceive.html +++ /dev/null @@ -1,79 +0,0 @@ - - - - Arduino - WireOnReceive - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Wire.onReceive(handler)

-

Description

-

Registers a function to be called when a slave device receives a transmission from a master. -

-

Parameters

-

handler: the function to be called when the slave receives data; this should take a single int parameter (the number of bytes received from the master) and return nothing, e.g.: void myHandler(int numBytes) -

-

Returns

-

None -

-

See Also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/WireOnRequest.html b/arduino-0018-linux-x64/reference/WireOnRequest.html deleted file mode 100644 index a5845ca..0000000 --- a/arduino-0018-linux-x64/reference/WireOnRequest.html +++ /dev/null @@ -1,79 +0,0 @@ - - - - Arduino - WireOnRequest - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Wire.onRequest(handler)

-

Description

-

Register a function to be called when a master requests data from this slave device. -

-

Parameters

-

handler: the function to be called, takes no parameters and returns nothing, e.g.: void myHandler() -

-

Returns

-

None -

-

See Also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/WireReceive.html b/arduino-0018-linux-x64/reference/WireReceive.html deleted file mode 100644 index b92d4bf..0000000 --- a/arduino-0018-linux-x64/reference/WireReceive.html +++ /dev/null @@ -1,79 +0,0 @@ - - - - Arduino - WireReceive - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

byte Wire.receive()

-

Description

-

Retrieve a byte that was transmitted from a slave device to a master after a call to requestFrom or was transmitted from a master to a slave. -

-

Parameters

-

None -

-

Returns

-

The next byte received. -

-

See Also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/WireRequestFrom.html b/arduino-0018-linux-x64/reference/WireRequestFrom.html deleted file mode 100644 index ddf944d..0000000 --- a/arduino-0018-linux-x64/reference/WireRequestFrom.html +++ /dev/null @@ -1,82 +0,0 @@ - - - - Arduino - WireRequestFrom - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Wire.requestFrom(address, quantity)

-

Description

-

Request bytes from another device. The bytes may then be retrieved with the available() and receive() functions. -

-

Parameters

-

address: the 7-bit address of the device to request bytes from -

-

quantity: the number of bytes to request -

-

Returns

-

None -

-

See Also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/WireSend.html b/arduino-0018-linux-x64/reference/WireSend.html deleted file mode 100644 index e01a5fd..0000000 --- a/arduino-0018-linux-x64/reference/WireSend.html +++ /dev/null @@ -1,88 +0,0 @@ - - - - Arduino - WireSend - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Wire.send(value)

-

Wire.send(string)

-

Wire.send(data, quantity)

-

Description

-

Sends data from a slave device in response to a request from a master, or queues bytes for transmission from a master to slave device (in-between calls to beginTransmission() and endTransmission()). -

-

Parameters

-

value: a byte to send (byte) -

-

string: a string to send (char *) -

-

data: an array of data to send (byte *) -

-

quantity: the number of bytes of data to transmit (byte) -

-

Returns

-

None -

-

See Also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/Word.html b/arduino-0018-linux-x64/reference/Word.html deleted file mode 100644 index 7c07959..0000000 --- a/arduino-0018-linux-x64/reference/Word.html +++ /dev/null @@ -1,77 +0,0 @@ - - - - Arduino - Word - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

word

-

Description

-

A word stores a 16-bit unsigned number, from 0 to 65536. Same as an unsigned int. -

-

Example

-
    word w = 10000; 
-
-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/WordCast.html b/arduino-0018-linux-x64/reference/WordCast.html deleted file mode 100644 index add7654..0000000 --- a/arduino-0018-linux-x64/reference/WordCast.html +++ /dev/null @@ -1,86 +0,0 @@ - - - - Arduino - WordCast - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

word()

-

Description

-

Convert a value to the word data type or create a word from two bytes. -

-

Syntax

-

word(x)
word(h, l) -

-

Parameters

-

x: a value of any type -

-

h: the high-order (leftmost) byte of the word -

-

l: the low-order (rightmost) byte of the word -

-

Returns

-

word -

-

See also

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/reference/arduino.css b/arduino-0018-linux-x64/reference/arduino.css deleted file mode 100644 index dc20f30..0000000 --- a/arduino-0018-linux-x64/reference/arduino.css +++ /dev/null @@ -1,140 +0,0 @@ -body { - margin: 0px 20px 20px 20px; - padding: 0px 0px 0px 0px; - background-color: #aaa; - font-family: Verdana, Geneva, Arial, sans-serif; - font-size: 10px; - line-height: 15px; - xxxbackground: url(bg.gif) -} - -h1 { - font-family: Georgia, Times, serif; - color: #555; -} - -h2 { - font-family: Georgia, Times, serif; - color: #555; -} - -h3 { - font-family: Georgia, Times, serif; - color: #555; -} - -p ul li { - color: #555; -} - -a { - color: #111; -} - -hr { - border-top: 1px dotted #555; -} - -a:link { - text-decoration: none; - padding-bottom: 0px; - border-bottom: 1px solid #bbb; -} -a:visited { - text-decoration: none; - padding-bottom: 0px; - border-bottom: 1px solid #bbb; -} -a:active { - text-decoration: none; - padding-bottom: 0px; - border-bottom: 1px solid #bbb; -} -a:hover { - text-decoration: none; - padding-bottom: 0px; - background-color: #ddd; - border-bottom: none; -} - -a.selflink { - font-weight: bold; - text-decoration: none; - border-bottom: 0px solid white; -} - -#page { - width: 700px; -} - - -#pageheader { - height: 60px; - text-align: right; - padding-top: 40px; -} - -#pageheader .title { - float: left; - text-align: left; - margin-left: 20px; - font-family: Georgia, Times, serif; - padding-top: -19px; - font-size: 38px; - letter-spacing: 0px; - color: #fff; - font-weight: bold; - text-shadow: #aaa 0px 0px 5px; -} - -#pageheader .title a { - color: #fff; - border: none; -} - -#pageheader .title a:hover { - color: #fff; - border: none; - background-color: transparent; -} - -#pageheader .search { -} - -#pagenav { - background-color: #fff; - padding: 10px 20px; - border:1px solid #BBBBBB; -} - -#pagenav p { - display: inline; -} - -#pagetext { - padding-left: 20px; - padding-right: 20px; - padding-bottom: 10px; - padding-top: 10px; - color: #555; - background-color: #fff; - border: 1px solid #bbb; -} - -#pagefooter { - clear: both; - height: 30px; - padding-top: 15px; - padding-left: 20px; -} - -#pagefooter a { - color: #666; - border: none; - padding: 2px; -} - -#pagefooter a:hover { - color: #111; - background-color: #eee; -} diff --git a/arduino-0018-linux-x64/reference/environment.html b/arduino-0018-linux-x64/reference/environment.html deleted file mode 100644 index 6f52489..0000000 --- a/arduino-0018-linux-x64/reference/environment.html +++ /dev/null @@ -1,3 +0,0 @@ - - - Redirect \ No newline at end of file diff --git a/arduino-0018-linux-x64/reference/index.html b/arduino-0018-linux-x64/reference/index.html deleted file mode 100644 index f02c6cc..0000000 --- a/arduino-0018-linux-x64/reference/index.html +++ /dev/null @@ -1,195 +0,0 @@ - - - - Arduino - Reference - - - - -
- - - - - - -
- -
-

Reference   Language (extended) | Libraries | Comparison | Changes -

-

Language Reference

-

See the extended reference for more advanced features of the Arduino languages and the libraries page for interfacing with particular types of hardware. -

-

Arduino programs can be divided in three main parts: structure, values (variables and constants), and functions. The Arduino language is based on C/C++. -

-

-
-

Structure

-

Control Structures

-

Further Syntax

-
  • ; (semicolon) -
  • {} (curly braces) -
  • // (single line comment) -
  • /* */ (multi-line comment) -

Arithmetic Operators

-

Comparison Operators

-
  • == (equal to) -
  • != (not equal to) -
  • < (less than) -
  • > (greater than) -
  • <= (less than or equal to) -
  • >= (greater than or equal to) -

Boolean Operators

-
  • && (and) -
  • || (or) -
  • ! (not) -

Compound Operators

-
  • ++ (increment) -
  • -- (decrement) -
  • += (compound addition) -
  • -= (compound subtraction) -
  • *= (compound multiplication) -
  • /= (compound division) -

Variables

-

Variables are expressions that you can use in programs to store values, such as a sensor reading from an analog pin. -

-

Constants

-

Constants are particular values with specific meanings. -

-

Data Types

-

Variables can have various types, which are described below. -

-

Conversion

-

Reference

-

-

Functions

-

Digital I/O -

Analog I/O -

Advanced I/O -

Time -

Math -

Trigonometry -

Random Numbers -

-

Communication -

-


-

-

Didn't find something? Check the extended reference or the libraries. Or see the list of community-contributed code. -

-

-

Reference Home -

-

Corrections, suggestions, and new documentation should be posted to the Forum. -

-

The text of the Arduino reference is licensed under a -Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. -

-
- -
- - - -
- - diff --git a/arduino-0018-linux-x64/arduino b/arduino-0022-linux-x64/arduino similarity index 65% rename from arduino-0018-linux-x64/arduino rename to arduino-0022-linux-x64/arduino index 7128bac..d371e76 100755 --- a/arduino-0018-linux-x64/arduino +++ b/arduino-0022-linux-x64/arduino @@ -1,6 +1,6 @@ #!/bin/sh -APPDIR="$(dirname -- "${0}")" +APPDIR="$(dirname -- $(readlink -f -- "${0}") )" cd $APPDIR @@ -10,11 +10,11 @@ for LIB in \ lib/*.jar \ ; do - CLASSPATH="${CLASSPATH}:${APPDIR}/${LIB}" + CLASSPATH="${CLASSPATH}:${LIB}" done export CLASSPATH -LD_LIBRARY_PATH=`pwd`/lib:${LD_LIBRARY_PATH} +LD_LIBRARY_PATH=`pwd`/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} export LD_LIBRARY_PATH export PATH="${APPDIR}/java/bin:${PATH}" diff --git a/arduino-0022-linux-x64/examples/1.Basics/AnalogReadSerial/AnalogReadSerial.pde b/arduino-0022-linux-x64/examples/1.Basics/AnalogReadSerial/AnalogReadSerial.pde new file mode 100644 index 0000000..97243f3 --- /dev/null +++ b/arduino-0022-linux-x64/examples/1.Basics/AnalogReadSerial/AnalogReadSerial.pde @@ -0,0 +1,15 @@ +/* + AnalogReadSerial + Reads an analog input on pin 0, prints the result to the serial monitor + + This example code is in the public domain. + */ + +void setup() { + Serial.begin(9600); +} + +void loop() { + int sensorValue = analogRead(A0); + Serial.println(sensorValue, DEC); +} diff --git a/arduino-0022-linux-x64/examples/1.Basics/BareMinimum/BareMinimum.pde b/arduino-0022-linux-x64/examples/1.Basics/BareMinimum/BareMinimum.pde new file mode 100644 index 0000000..c9c84ce --- /dev/null +++ b/arduino-0022-linux-x64/examples/1.Basics/BareMinimum/BareMinimum.pde @@ -0,0 +1,9 @@ +void setup() { + // put your setup code here, to run once: + +} + +void loop() { + // put your main code here, to run repeatedly: + +} diff --git a/arduino-0022-linux-x64/examples/1.Basics/Blink/Blink.pde b/arduino-0022-linux-x64/examples/1.Basics/Blink/Blink.pde new file mode 100644 index 0000000..1953c39 --- /dev/null +++ b/arduino-0022-linux-x64/examples/1.Basics/Blink/Blink.pde @@ -0,0 +1,19 @@ +/* + Blink + Turns on an LED on for one second, then off for one second, repeatedly. + + This example code is in the public domain. + */ + +void setup() { + // initialize the digital pin as an output. + // Pin 13 has an LED connected on most Arduino boards: + pinMode(13, OUTPUT); +} + +void loop() { + digitalWrite(13, HIGH); // set the LED on + delay(1000); // wait for a second + digitalWrite(13, LOW); // set the LED off + delay(1000); // wait for a second +} diff --git a/arduino-0018-linux-x64/examples/Stubs/DigitalReadSerial/DigitalReadSerial.pde b/arduino-0022-linux-x64/examples/1.Basics/DigitalReadSerial/DigitalReadSerial.pde similarity index 51% rename from arduino-0018-linux-x64/examples/Stubs/DigitalReadSerial/DigitalReadSerial.pde rename to arduino-0022-linux-x64/examples/1.Basics/DigitalReadSerial/DigitalReadSerial.pde index 369b9a4..7651a8f 100644 --- a/arduino-0018-linux-x64/examples/Stubs/DigitalReadSerial/DigitalReadSerial.pde +++ b/arduino-0022-linux-x64/examples/1.Basics/DigitalReadSerial/DigitalReadSerial.pde @@ -1,3 +1,9 @@ +/* + DigitalReadSerial + Reads a digital input on pin 2, prints the result to the serial monitor + + This example code is in the public domain. + */ void setup() { Serial.begin(9600); diff --git a/arduino-0022-linux-x64/examples/1.Basics/Fade/Fade.pde b/arduino-0022-linux-x64/examples/1.Basics/Fade/Fade.pde new file mode 100644 index 0000000..b47bf43 --- /dev/null +++ b/arduino-0022-linux-x64/examples/1.Basics/Fade/Fade.pde @@ -0,0 +1,31 @@ +/* + Fade + + This example shows how to fade an LED on pin 9 + using the analogWrite() function. + + This example code is in the public domain. + + */ +int brightness = 0; // how bright the LED is +int fadeAmount = 5; // how many points to fade the LED by + +void setup() { + // declare pin 9 to be an output: + pinMode(9, OUTPUT); +} + +void loop() { + // set the brightness of pin 9: + analogWrite(9, brightness); + + // change the brightness for next time through the loop: + brightness = brightness + fadeAmount; + + // reverse the direction of the fading at the ends of the fade: + if (brightness == 0 || brightness == 255) { + fadeAmount = -fadeAmount ; + } + // wait for 30 milliseconds to see the dimming effect + delay(30); +} diff --git a/arduino-0018-linux-x64/examples/Digital/BlinkWithoutDelay/BlinkWithoutDelay.pde b/arduino-0022-linux-x64/examples/2.Digital/BlinkWithoutDelay/BlinkWithoutDelay.pde similarity index 76% rename from arduino-0018-linux-x64/examples/Digital/BlinkWithoutDelay/BlinkWithoutDelay.pde rename to arduino-0022-linux-x64/examples/2.Digital/BlinkWithoutDelay/BlinkWithoutDelay.pde index f1d6984..0143571 100644 --- a/arduino-0018-linux-x64/examples/Digital/BlinkWithoutDelay/BlinkWithoutDelay.pde +++ b/arduino-0022-linux-x64/examples/2.Digital/BlinkWithoutDelay/BlinkWithoutDelay.pde @@ -4,7 +4,7 @@ pin, without using the delay() function. This means that other code can run at the same time without being interrupted by the LED code. - The circuit: + The circuit: * LED attached from pin 13 to ground. * Note: on most Arduinos, there is already an LED on the board that's attached to pin 13, so no hardware is needed for this example. @@ -12,8 +12,11 @@ created 2005 by David A. Mellis - modified 17 Jun 2009 - by Tom Igoe + modified 8 Feb 2010 + by Paul Stoffregen + + This example code is in the public domain. + http://www.arduino.cc/en/Tutorial/BlinkWithoutDelay */ @@ -39,20 +42,24 @@ void loop() { // here is where you'd put code that needs to be running all the time. - // check to see if it's time to blink the LED; that is, is the difference - // between the current time and last time we blinked the LED bigger than - // the interval at which we want to blink the LED. - if (millis() - previousMillis > interval) { + // check to see if it's time to blink the LED; that is, if the + // difference between the current time and last time you blinked + // the LED is bigger than the interval at which you want to + // blink the LED. + unsigned long currentMillis = millis(); + + if(currentMillis - previousMillis > interval) { // save the last time you blinked the LED - previousMillis = millis(); + previousMillis = currentMillis; // if the LED is off turn it on and vice-versa: if (ledState == LOW) ledState = HIGH; else ledState = LOW; - + // set the LED with the ledState of the variable: digitalWrite(ledPin, ledState); } -} \ No newline at end of file +} + diff --git a/arduino-0018-linux-x64/examples/Digital/Button/Button.pde b/arduino-0022-linux-x64/examples/2.Digital/Button/Button.pde similarity index 87% rename from arduino-0018-linux-x64/examples/Digital/Button/Button.pde rename to arduino-0022-linux-x64/examples/2.Digital/Button/Button.pde index 8df98ec..a56ea14 100644 --- a/arduino-0018-linux-x64/examples/Digital/Button/Button.pde +++ b/arduino-0022-linux-x64/examples/2.Digital/Button/Button.pde @@ -2,7 +2,7 @@ Button Turns on and off a light emitting diode(LED) connected to digital - pin 13, when pressing a pushbutton attached to pin 7. + pin 13, when pressing a pushbutton attached to pin 2. The circuit: @@ -16,10 +16,12 @@ created 2005 by DojoDave - modified 17 Jun 2009 + modified 28 Oct 2010 by Tom Igoe - http://www.arduino.cc/en/Tutorial/Button + This example code is in the public domain. + + http://www.arduino.cc/en/Tutorial/Button */ // constants won't change. They're used here to diff --git a/arduino-0018-linux-x64/examples/Digital/Debounce/Debounce.pde b/arduino-0022-linux-x64/examples/2.Digital/Debounce/Debounce.pde similarity index 98% rename from arduino-0018-linux-x64/examples/Digital/Debounce/Debounce.pde rename to arduino-0022-linux-x64/examples/2.Digital/Debounce/Debounce.pde index 568100f..6f184ec 100644 --- a/arduino-0018-linux-x64/examples/Digital/Debounce/Debounce.pde +++ b/arduino-0022-linux-x64/examples/2.Digital/Debounce/Debounce.pde @@ -20,6 +20,7 @@ modified 3 Jul 2009 by Limor Fried +This example code is in the public domain. http://www.arduino.cc/en/Tutorial/Debounce */ diff --git a/arduino-0018-linux-x64/examples/Digital/StateChangeDetection/StateChangeDetection.pde b/arduino-0022-linux-x64/examples/2.Digital/StateChangeDetection/StateChangeDetection.pde similarity index 92% rename from arduino-0018-linux-x64/examples/Digital/StateChangeDetection/StateChangeDetection.pde rename to arduino-0022-linux-x64/examples/2.Digital/StateChangeDetection/StateChangeDetection.pde index 607dfc9..33f997c 100644 --- a/arduino-0018-linux-x64/examples/Digital/StateChangeDetection/StateChangeDetection.pde +++ b/arduino-0022-linux-x64/examples/2.Digital/StateChangeDetection/StateChangeDetection.pde @@ -16,8 +16,10 @@ most Arduino boards) created 27 Sep 2005 - modified 30 Dec 2009 + modified 14 Oct 2010 by Tom Igoe + +This example code is in the public domain. http://arduino.cc/en/Tutorial/ButtonStateChange @@ -62,11 +64,11 @@ void loop() { // wend from on to off: Serial.println("off"); } - - // save the current state as the last state, - //for next time through the loop - lastButtonState = buttonState; } + // save the current state as the last state, + //for next time through the loop + lastButtonState = buttonState; + // turns on the LED every four button pushes by // checking the modulo of the button push counter. diff --git a/arduino-0018-linux-x64/examples/Digital/toneKeyboard/pitches.h b/arduino-0022-linux-x64/examples/2.Digital/toneKeyboard/pitches.h similarity index 100% rename from arduino-0018-linux-x64/examples/Digital/toneKeyboard/pitches.h rename to arduino-0022-linux-x64/examples/2.Digital/toneKeyboard/pitches.h diff --git a/arduino-0018-linux-x64/examples/Digital/toneKeyboard/toneKeyboard.pde b/arduino-0022-linux-x64/examples/2.Digital/toneKeyboard/toneKeyboard.pde similarity index 93% rename from arduino-0018-linux-x64/examples/Digital/toneKeyboard/toneKeyboard.pde rename to arduino-0022-linux-x64/examples/2.Digital/toneKeyboard/toneKeyboard.pde index 57279ef..b1a5364 100644 --- a/arduino-0018-linux-x64/examples/Digital/toneKeyboard/toneKeyboard.pde +++ b/arduino-0022-linux-x64/examples/2.Digital/toneKeyboard/toneKeyboard.pde @@ -9,7 +9,10 @@ * 8-ohm speaker on digital pin 8 created 21 Jan 2010 + Modified 4 Sep 2010 by Tom Igoe + +This example code is in the public domain. http://arduino.cc/en/Tutorial/Tone3 @@ -40,10 +43,3 @@ void loop() { } Serial.println(); } - - - - - - - diff --git a/arduino-0018-linux-x64/examples/Digital/toneMelody/pitches.h b/arduino-0022-linux-x64/examples/2.Digital/toneMelody/pitches.h similarity index 100% rename from arduino-0018-linux-x64/examples/Digital/toneMelody/pitches.h rename to arduino-0022-linux-x64/examples/2.Digital/toneMelody/pitches.h diff --git a/arduino-0018-linux-x64/examples/Digital/toneMelody/toneMelody.pde b/arduino-0022-linux-x64/examples/2.Digital/toneMelody/toneMelody.pde similarity index 90% rename from arduino-0018-linux-x64/examples/Digital/toneMelody/toneMelody.pde rename to arduino-0022-linux-x64/examples/2.Digital/toneMelody/toneMelody.pde index b6e88d0..debcebd 100644 --- a/arduino-0018-linux-x64/examples/Digital/toneMelody/toneMelody.pde +++ b/arduino-0022-linux-x64/examples/2.Digital/toneMelody/toneMelody.pde @@ -7,7 +7,10 @@ * 8-ohm speaker on digital pin 8 created 21 Jan 2010 + modified 14 Oct 2010 by Tom Igoe + +This example code is in the public domain. http://arduino.cc/en/Tutorial/Tone @@ -36,13 +39,11 @@ void setup() { // the note's duration + 30% seems to work well: int pauseBetweenNotes = noteDuration * 1.30; delay(pauseBetweenNotes); + // stop the tone playing: + noTone(8); } } void loop() { // no need to repeat the melody. } - - - - diff --git a/arduino-0022-linux-x64/examples/2.Digital/toneMultiple/pitches.h b/arduino-0022-linux-x64/examples/2.Digital/toneMultiple/pitches.h new file mode 100644 index 0000000..55c7d54 --- /dev/null +++ b/arduino-0022-linux-x64/examples/2.Digital/toneMultiple/pitches.h @@ -0,0 +1,95 @@ +/************************************************* + * Public Constants + *************************************************/ + +#define NOTE_B0 31 +#define NOTE_C1 33 +#define NOTE_CS1 35 +#define NOTE_D1 37 +#define NOTE_DS1 39 +#define NOTE_E1 41 +#define NOTE_F1 44 +#define NOTE_FS1 46 +#define NOTE_G1 49 +#define NOTE_GS1 52 +#define NOTE_A1 55 +#define NOTE_AS1 58 +#define NOTE_B1 62 +#define NOTE_C2 65 +#define NOTE_CS2 69 +#define NOTE_D2 73 +#define NOTE_DS2 78 +#define NOTE_E2 82 +#define NOTE_F2 87 +#define NOTE_FS2 93 +#define NOTE_G2 98 +#define NOTE_GS2 104 +#define NOTE_A2 110 +#define NOTE_AS2 117 +#define NOTE_B2 123 +#define NOTE_C3 131 +#define NOTE_CS3 139 +#define NOTE_D3 147 +#define NOTE_DS3 156 +#define NOTE_E3 165 +#define NOTE_F3 175 +#define NOTE_FS3 185 +#define NOTE_G3 196 +#define NOTE_GS3 208 +#define NOTE_A3 220 +#define NOTE_AS3 233 +#define NOTE_B3 247 +#define NOTE_C4 262 +#define NOTE_CS4 277 +#define NOTE_D4 294 +#define NOTE_DS4 311 +#define NOTE_E4 330 +#define NOTE_F4 349 +#define NOTE_FS4 370 +#define NOTE_G4 392 +#define NOTE_GS4 415 +#define NOTE_A4 440 +#define NOTE_AS4 466 +#define NOTE_B4 494 +#define NOTE_C5 523 +#define NOTE_CS5 554 +#define NOTE_D5 587 +#define NOTE_DS5 622 +#define NOTE_E5 659 +#define NOTE_F5 698 +#define NOTE_FS5 740 +#define NOTE_G5 784 +#define NOTE_GS5 831 +#define NOTE_A5 880 +#define NOTE_AS5 932 +#define NOTE_B5 988 +#define NOTE_C6 1047 +#define NOTE_CS6 1109 +#define NOTE_D6 1175 +#define NOTE_DS6 1245 +#define NOTE_E6 1319 +#define NOTE_F6 1397 +#define NOTE_FS6 1480 +#define NOTE_G6 1568 +#define NOTE_GS6 1661 +#define NOTE_A6 1760 +#define NOTE_AS6 1865 +#define NOTE_B6 1976 +#define NOTE_C7 2093 +#define NOTE_CS7 2217 +#define NOTE_D7 2349 +#define NOTE_DS7 2489 +#define NOTE_E7 2637 +#define NOTE_F7 2794 +#define NOTE_FS7 2960 +#define NOTE_G7 3136 +#define NOTE_GS7 3322 +#define NOTE_A7 3520 +#define NOTE_AS7 3729 +#define NOTE_B7 3951 +#define NOTE_C8 4186 +#define NOTE_CS8 4435 +#define NOTE_D8 4699 +#define NOTE_DS8 4978 + + diff --git a/arduino-0022-linux-x64/examples/2.Digital/toneMultiple/toneMultiple.pde b/arduino-0022-linux-x64/examples/2.Digital/toneMultiple/toneMultiple.pde new file mode 100644 index 0000000..52a06df --- /dev/null +++ b/arduino-0022-linux-x64/examples/2.Digital/toneMultiple/toneMultiple.pde @@ -0,0 +1,42 @@ +/* + Multiple tone player + + Plays multiple tones on multiple pins in sequence + + circuit: + * 3 8-ohm speaker on digital pins 6, 7, and 11 + + created 8 March 2010 + by Tom Igoe + based on a snippet from Greg Borenstein + +This example code is in the public domain. + + http://arduino.cc/en/Tutorial/Tone4 + + */ + +void setup() { + +} + +void loop() { + // turn off tone function for pin 11: + noTone(11); + // play a note on pin 6 for 200 ms: + tone(6, 440, 200); + delay(200); + + // turn off tone function for pin 6: + noTone(6); + // play a note on pin 7 for 500 ms: + tone(7, 494, 500); + delay(500); + + // turn off tone function for pin 7: + noTone(7); + // play a note on pin 11 for 500 ms: + tone(11, 523, 300); + delay(300); + +} diff --git a/arduino-0018-linux-x64/examples/Digital/tonePitchFollower/tonePitchFollower.pde b/arduino-0022-linux-x64/examples/2.Digital/tonePitchFollower/tonePitchFollower.pde similarity index 88% rename from arduino-0018-linux-x64/examples/Digital/tonePitchFollower/tonePitchFollower.pde rename to arduino-0022-linux-x64/examples/2.Digital/tonePitchFollower/tonePitchFollower.pde index 403b2c1..3b9d738 100644 --- a/arduino-0018-linux-x64/examples/Digital/tonePitchFollower/tonePitchFollower.pde +++ b/arduino-0022-linux-x64/examples/2.Digital/tonePitchFollower/tonePitchFollower.pde @@ -9,7 +9,10 @@ * 4.7K resistor on analog 0 to ground created 21 Jan 2010 + Modified 4 Sep 2010 by Tom Igoe + +This example code is in the public domain. http://arduino.cc/en/Tutorial/Tone2 @@ -23,7 +26,7 @@ void setup() { void loop() { // read the sensor: - int sensorReading = analogRead(0); + int sensorReading = analogRead(A0); // print the sensor reading so you know its range Serial.println(sensorReading); // map the pitch to the range of the analog input. diff --git a/arduino-0018-linux-x64/examples/Analog/AnalogInOutSerial/AnalogInOutSerial.pde b/arduino-0022-linux-x64/examples/3.Analog/AnalogInOutSerial/AnalogInOutSerial.pde similarity index 90% rename from arduino-0018-linux-x64/examples/Analog/AnalogInOutSerial/AnalogInOutSerial.pde rename to arduino-0022-linux-x64/examples/3.Analog/AnalogInOutSerial/AnalogInOutSerial.pde index 81c8e81..57c1421 100644 --- a/arduino-0018-linux-x64/examples/Analog/AnalogInOutSerial/AnalogInOutSerial.pde +++ b/arduino-0022-linux-x64/examples/3.Analog/AnalogInOutSerial/AnalogInOutSerial.pde @@ -12,13 +12,16 @@ * LED connected from digital pin 9 to ground created 29 Dec. 2008 + Modified 4 Sep 2010 by Tom Igoe + This example code is in the public domain. + */ // These constants won't change. They're used to give names // to the pins used: -const int analogInPin = 0; // Analog input pin that the potentiometer is attached to +const int analogInPin = A0; // Analog input pin that the potentiometer is attached to const int analogOutPin = 9; // Analog output pin that the LED is attached to int sensorValue = 0; // value read from the pot diff --git a/arduino-0018-linux-x64/examples/Analog/AnalogInput/AnalogInput.pde b/arduino-0022-linux-x64/examples/3.Analog/AnalogInput/AnalogInput.pde similarity index 90% rename from arduino-0018-linux-x64/examples/Analog/AnalogInput/AnalogInput.pde rename to arduino-0022-linux-x64/examples/3.Analog/AnalogInput/AnalogInput.pde index 1ee8ee3..18a0055 100644 --- a/arduino-0018-linux-x64/examples/Analog/AnalogInput/AnalogInput.pde +++ b/arduino-0022-linux-x64/examples/3.Analog/AnalogInput/AnalogInput.pde @@ -18,14 +18,16 @@ Created by David Cuartielles - Modified 16 Jun 2009 + Modified 4 Sep 2010 By Tom Igoe + This example code is in the public domain. + http://arduino.cc/en/Tutorial/AnalogInput */ -int sensorPin = 0; // select the input pin for the potentiometer +int sensorPin = A0; // select the input pin for the potentiometer int ledPin = 13; // select the pin for the LED int sensorValue = 0; // variable to store the value coming from the sensor diff --git a/arduino-0018-linux-x64/examples/Analog/AnalogWriteMega/AnalogWriteMega.pde b/arduino-0022-linux-x64/examples/3.Analog/AnalogWriteMega/AnalogWriteMega.pde similarity index 95% rename from arduino-0018-linux-x64/examples/Analog/AnalogWriteMega/AnalogWriteMega.pde rename to arduino-0022-linux-x64/examples/3.Analog/AnalogWriteMega/AnalogWriteMega.pde index 3166952..04e50c8 100644 --- a/arduino-0018-linux-x64/examples/Analog/AnalogWriteMega/AnalogWriteMega.pde +++ b/arduino-0022-linux-x64/examples/3.Analog/AnalogWriteMega/AnalogWriteMega.pde @@ -9,6 +9,9 @@ created 8 Feb 2009 by Tom Igoe + + This example code is in the public domain. + */ // These constants won't change. They're used to give names // to the pins used: diff --git a/arduino-0018-linux-x64/examples/Analog/Calibration/Calibration.pde b/arduino-0022-linux-x64/examples/3.Analog/Calibration/Calibration.pde similarity index 79% rename from arduino-0018-linux-x64/examples/Analog/Calibration/Calibration.pde rename to arduino-0022-linux-x64/examples/3.Analog/Calibration/Calibration.pde index 52c8d8d..c5734df 100644 --- a/arduino-0018-linux-x64/examples/Analog/Calibration/Calibration.pde +++ b/arduino-0022-linux-x64/examples/3.Analog/Calibration/Calibration.pde @@ -1,14 +1,14 @@ /* Calibration - Demonstrates one techinque for calibrating sensor input. The + Demonstrates one technique for calibrating sensor input. The sensor readings during the first five seconds of the sketch execution define the minimum and maximum of expected values attached to the sensor pin. - The sensor minumum and maximum initial values may seem backwards. + The sensor minimum and maximum initial values may seem backwards. Initially, you set the minimum high and listen for anything - lower, saving it as the new minumum. Likewise, you set the + lower, saving it as the new minimum. Likewise, you set the maximum low and listen for anything higher as the new maximum. The circuit: @@ -17,21 +17,23 @@ created 29 Oct 2008 By David A Mellis - Modified 17 Jun 2009 + Modified 4 Sep 2010 By Tom Igoe http://arduino.cc/en/Tutorial/Calibration + This example code is in the public domain. + */ // These constants won't change: -const int sensorPin = 2; // pin that the sensor is attached to +const int sensorPin = A0; // pin that the sensor is attached to const int ledPin = 9; // pin that the LED is attached to // variables: int sensorValue = 0; // the sensor value -int sensorMin = 1023; // minimum sensor value -int sensorMax = 0; // maximum sensor value +int sensorMin = 1023; // minimum sensor value +int sensorMax = 0; // maximum sensor value void setup() { @@ -70,4 +72,4 @@ void loop() { // fade the LED using the calibrated value: analogWrite(ledPin, sensorValue); -} \ No newline at end of file +} diff --git a/arduino-0018-linux-x64/examples/Analog/Fading/Fading.pde b/arduino-0022-linux-x64/examples/3.Analog/Fading/Fading.pde similarity index 95% rename from arduino-0018-linux-x64/examples/Analog/Fading/Fading.pde rename to arduino-0022-linux-x64/examples/3.Analog/Fading/Fading.pde index 1205078..46959ad 100644 --- a/arduino-0018-linux-x64/examples/Analog/Fading/Fading.pde +++ b/arduino-0022-linux-x64/examples/3.Analog/Fading/Fading.pde @@ -13,6 +13,8 @@ http://arduino.cc/en/Tutorial/Fading + This example code is in the public domain. + */ diff --git a/arduino-0018-linux-x64/examples/Analog/Smoothing/Smoothing.pde b/arduino-0022-linux-x64/examples/3.Analog/Smoothing/Smoothing.pde similarity index 96% rename from arduino-0018-linux-x64/examples/Analog/Smoothing/Smoothing.pde rename to arduino-0022-linux-x64/examples/3.Analog/Smoothing/Smoothing.pde index 881bb13..5de30e8 100644 --- a/arduino-0018-linux-x64/examples/Analog/Smoothing/Smoothing.pde +++ b/arduino-0022-linux-x64/examples/3.Analog/Smoothing/Smoothing.pde @@ -13,6 +13,8 @@ By David A. Mellis http://www.arduino.cc/en/Tutorial/Smoothing + + This example code is in the public domain. */ @@ -29,7 +31,7 @@ int index = 0; // the index of the current reading int total = 0; // the running total int average = 0; // the average -int inputPin = 0; +int inputPin = A0; void setup() { diff --git a/arduino-0018-linux-x64/examples/Communication/ASCIITable/ASCIITable.pde b/arduino-0022-linux-x64/examples/4.Communication/ASCIITable/ASCIITable.pde similarity index 97% rename from arduino-0018-linux-x64/examples/Communication/ASCIITable/ASCIITable.pde rename to arduino-0022-linux-x64/examples/4.Communication/ASCIITable/ASCIITable.pde index 3a20603..3678836 100644 --- a/arduino-0018-linux-x64/examples/Communication/ASCIITable/ASCIITable.pde +++ b/arduino-0022-linux-x64/examples/4.Communication/ASCIITable/ASCIITable.pde @@ -14,7 +14,10 @@ modified 18 Jan 2009 by Tom Igoe + This example code is in the public domain. + + */ void setup() { diff --git a/arduino-0018-linux-x64/examples/Communication/Dimmer/Dimmer.pde b/arduino-0022-linux-x64/examples/4.Communication/Dimmer/Dimmer.pde similarity index 98% rename from arduino-0018-linux-x64/examples/Communication/Dimmer/Dimmer.pde rename to arduino-0022-linux-x64/examples/4.Communication/Dimmer/Dimmer.pde index 0990fe5..3eb92b0 100644 --- a/arduino-0018-linux-x64/examples/Communication/Dimmer/Dimmer.pde +++ b/arduino-0022-linux-x64/examples/4.Communication/Dimmer/Dimmer.pde @@ -15,7 +15,10 @@ modified 14 Apr 2009 by Tom Igoe and Scott Fitzgerald + This example code is in the public domain. + http://www.arduino.cc/en/Tutorial/Dimmer + */ const int ledPin = 9; // the pin that the LED is attached to @@ -43,6 +46,7 @@ void loop() { /* Processing code for this example // Dimmer - sends bytes over a serial port // by David A. Mellis + //This example code is in the public domain. import processing.serial.*; Serial port; diff --git a/arduino-0018-linux-x64/examples/Communication/Graph/Graph.pde b/arduino-0022-linux-x64/examples/4.Communication/Graph/Graph.pde similarity index 99% rename from arduino-0018-linux-x64/examples/Communication/Graph/Graph.pde rename to arduino-0022-linux-x64/examples/4.Communication/Graph/Graph.pde index 1f2fadd..c1e39ac 100644 --- a/arduino-0018-linux-x64/examples/Communication/Graph/Graph.pde +++ b/arduino-0022-linux-x64/examples/4.Communication/Graph/Graph.pde @@ -15,14 +15,14 @@ The circuit: Any analog input sensor is attached to analog in pin 0. - - http://www.arduino.cc/en/Tutorial/Graph - + created 2006 by David A. Mellis modified 14 Apr 2009 by Tom Igoe and Scott Fitzgerald + This example code is in the public domain. + http://www.arduino.cc/en/Tutorial/Graph */ @@ -33,7 +33,7 @@ void setup() { void loop() { // send the value of analog input 0: - Serial.println(analogRead(0)); + Serial.println(analogRead(A0)); // wait a bit for the analog-to-digital converter // to stabilize after the last reading: delay(10); @@ -51,6 +51,7 @@ void loop() { // Created 20 Apr 2005 // Updated 18 Jan 2008 // by Tom Igoe + // This example code is in the public domain. import processing.serial.*; diff --git a/arduino-0018-linux-x64/examples/Communication/MIDI/Midi.pde b/arduino-0022-linux-x64/examples/4.Communication/MIDI/Midi.pde similarity index 96% rename from arduino-0018-linux-x64/examples/Communication/MIDI/Midi.pde rename to arduino-0022-linux-x64/examples/4.Communication/MIDI/Midi.pde index feb3e82..7a25c85 100644 --- a/arduino-0018-linux-x64/examples/Communication/MIDI/Midi.pde +++ b/arduino-0022-linux-x64/examples/4.Communication/MIDI/Midi.pde @@ -15,6 +15,8 @@ created 13 Jun 2006 modified 2 Jul 2009 by Tom Igoe + + This example code is in the public domain. http://www.arduino.cc/en/Tutorial/MIDI diff --git a/arduino-0018-linux-x64/examples/Communication/MultiSerialMega/MultiSerialMega.pde b/arduino-0022-linux-x64/examples/4.Communication/MultiSerialMega/MultiSerialMega.pde similarity index 92% rename from arduino-0018-linux-x64/examples/Communication/MultiSerialMega/MultiSerialMega.pde rename to arduino-0022-linux-x64/examples/4.Communication/MultiSerialMega/MultiSerialMega.pde index f587c63..788bc90 100644 --- a/arduino-0018-linux-x64/examples/Communication/MultiSerialMega/MultiSerialMega.pde +++ b/arduino-0022-linux-x64/examples/4.Communication/MultiSerialMega/MultiSerialMega.pde @@ -13,6 +13,8 @@ created 30 Dec. 2008 by Tom Igoe + This example code is in the public domain. + */ diff --git a/arduino-0018-linux-x64/examples/Communication/PhysicalPixel/PhysicalPixel.pde b/arduino-0022-linux-x64/examples/4.Communication/PhysicalPixel/PhysicalPixel.pde similarity index 99% rename from arduino-0018-linux-x64/examples/Communication/PhysicalPixel/PhysicalPixel.pde rename to arduino-0022-linux-x64/examples/4.Communication/PhysicalPixel/PhysicalPixel.pde index b5006ec..f7371c9 100644 --- a/arduino-0018-linux-x64/examples/Communication/PhysicalPixel/PhysicalPixel.pde +++ b/arduino-0022-linux-x64/examples/4.Communication/PhysicalPixel/PhysicalPixel.pde @@ -18,6 +18,8 @@ modified 14 Apr 2009 by Tom Igoe and Scott Fitzgerald + This example code is in the public domain. + http://www.arduino.cc/en/Tutorial/PhysicalPixel */ @@ -59,6 +61,8 @@ void loop() { // based on examples by Casey Reas and Hernando Barragan // modified 18 Jan 2009 // by Tom Igoe + // This example code is in the public domain. + import processing.serial.*; diff --git a/arduino-0018-linux-x64/examples/Communication/SerialCallResponse/SerialCallResponse.pde b/arduino-0022-linux-x64/examples/4.Communication/SerialCallResponse/SerialCallResponse.pde similarity index 99% rename from arduino-0018-linux-x64/examples/Communication/SerialCallResponse/SerialCallResponse.pde rename to arduino-0022-linux-x64/examples/4.Communication/SerialCallResponse/SerialCallResponse.pde index 809bbf8..6f56d98 100644 --- a/arduino-0018-linux-x64/examples/Communication/SerialCallResponse/SerialCallResponse.pde +++ b/arduino-0022-linux-x64/examples/4.Communication/SerialCallResponse/SerialCallResponse.pde @@ -13,13 +13,15 @@ * potentiometers attached to analog inputs 0 and 1 * pushbutton attached to digital I/O 2 - - http://www.arduino.cc/en/Tutorial/SerialCallResponse - Created 26 Sept. 2005 by Tom Igoe - Modified 14 April 2009 + Modified 4 Sep 2010 by Tom Igoe and Scott Fitzgerald + + This example code is in the public domain. + + http://www.arduino.cc/en/Tutorial/SerialCallResponse + */ int firstSensor = 0; // first analog sensor @@ -42,7 +44,7 @@ void loop() // get incoming byte: inByte = Serial.read(); // read first analog input, divide by 4 to make the range 0-255: - firstSensor = analogRead(0)/4; + firstSensor = analogRead(A0)/4; // delay 10ms to let the ADC recover: delay(10); // read second analog input, divide by 4 to make the range 0-255: @@ -66,6 +68,8 @@ void establishContact() { /* Processing sketch to run with this example: +// This example code is in the public domain. + import processing.serial.*; int bgcolor; // Background color diff --git a/arduino-0018-linux-x64/examples/Communication/SerialCallResponseASCII/SerialCallResponseASCII.pde b/arduino-0022-linux-x64/examples/4.Communication/SerialCallResponseASCII/SerialCallResponseASCII.pde similarity index 99% rename from arduino-0018-linux-x64/examples/Communication/SerialCallResponseASCII/SerialCallResponseASCII.pde rename to arduino-0022-linux-x64/examples/4.Communication/SerialCallResponseASCII/SerialCallResponseASCII.pde index 7c2528d..3caf3f7 100644 --- a/arduino-0018-linux-x64/examples/Communication/SerialCallResponseASCII/SerialCallResponseASCII.pde +++ b/arduino-0022-linux-x64/examples/4.Communication/SerialCallResponseASCII/SerialCallResponseASCII.pde @@ -16,12 +16,16 @@ * pushbutton attached to digital I/O 2 - http://www.arduino.cc/en/Tutorial/SerialCallResponseASCII Created 26 Sept. 2005 by Tom Igoe - Modified 14 April 2009 + Modified 4 Sep 2010 by Tom Igoe and Scott Fitzgerald + + This example code is in the public domain. + + http://www.arduino.cc/en/Tutorial/SerialCallResponseASCII + */ int firstSensor = 0; // first analog sensor @@ -44,7 +48,7 @@ void loop() // get incoming byte: inByte = Serial.read(); // read first analog input, divide by 4 to make the range 0-255: - firstSensor = analogRead(0)/4; + firstSensor = analogRead(A0)/4; // delay 10ms to let the ADC recover: delay(10); // read second analog input, divide by 4 to make the range 0-255: @@ -71,6 +75,7 @@ void establishContact() { /* Processing code to run with this example: +// This example code is in the public domain. import processing.serial.*; // import the Processing serial library Serial myPort; // The serial port diff --git a/arduino-0018-linux-x64/examples/Communication/VirtualColorMixer/VirtualColorMixer.pde b/arduino-0022-linux-x64/examples/4.Communication/VirtualColorMixer/VirtualColorMixer.pde similarity index 98% rename from arduino-0018-linux-x64/examples/Communication/VirtualColorMixer/VirtualColorMixer.pde rename to arduino-0022-linux-x64/examples/4.Communication/VirtualColorMixer/VirtualColorMixer.pde index f23f147..5e8c401 100644 --- a/arduino-0018-linux-x64/examples/Communication/VirtualColorMixer/VirtualColorMixer.pde +++ b/arduino-0022-linux-x64/examples/4.Communication/VirtualColorMixer/VirtualColorMixer.pde @@ -10,14 +10,15 @@ created 2 Dec 2006 by David A. Mellis - modified 14 Apr 2009 + modified 4 Sep 2010 by Tom Igoe and Scott Fitzgerald + This example code is in the public domain. */ -const int redPin = 0; // sensor to control red color -const int greenPin = 1; // sensor to control green color -const int bluePin = 2; // sensor to control blue color +const int redPin = A0; // sensor to control red color +const int greenPin = A1; // sensor to control green color +const int bluePin = A2; // sensor to control blue color void setup() { @@ -35,6 +36,7 @@ void loop() /* Processing code for this example +// This example code is in the public domain. import processing.serial.*; diff --git a/arduino-0018-linux-x64/examples/Control/Arrays/Arrays.pde b/arduino-0022-linux-x64/examples/5.Control/Arrays/Arrays.pde similarity index 97% rename from arduino-0018-linux-x64/examples/Control/Arrays/Arrays.pde rename to arduino-0022-linux-x64/examples/5.Control/Arrays/Arrays.pde index d9d9837..cf83ccf 100644 --- a/arduino-0018-linux-x64/examples/Control/Arrays/Arrays.pde +++ b/arduino-0022-linux-x64/examples/5.Control/Arrays/Arrays.pde @@ -15,6 +15,8 @@ by David A. Mellis modified 5 Jul 2009 by Tom Igoe + +This example code is in the public domain. http://www.arduino.cc/en/Tutorial/Array */ diff --git a/arduino-0018-linux-x64/examples/Control/ForLoopIteration/ForLoopIteration.pde b/arduino-0022-linux-x64/examples/5.Control/ForLoopIteration/ForLoopIteration.pde similarity index 95% rename from arduino-0018-linux-x64/examples/Control/ForLoopIteration/ForLoopIteration.pde rename to arduino-0022-linux-x64/examples/5.Control/ForLoopIteration/ForLoopIteration.pde index 4fd745d..ec60ec9 100644 --- a/arduino-0018-linux-x64/examples/Control/ForLoopIteration/ForLoopIteration.pde +++ b/arduino-0022-linux-x64/examples/5.Control/ForLoopIteration/ForLoopIteration.pde @@ -11,6 +11,8 @@ by David A. Mellis modified 5 Jul 2009 by Tom Igoe + +This example code is in the public domain. http://www.arduino.cc/en/Tutorial/ForLoop */ diff --git a/arduino-0018-linux-x64/examples/Control/IfStatementConditional/IfStatementConditional.pde b/arduino-0022-linux-x64/examples/5.Control/IfStatementConditional/IfStatementConditional.pde similarity index 88% rename from arduino-0018-linux-x64/examples/Control/IfStatementConditional/IfStatementConditional.pde rename to arduino-0022-linux-x64/examples/5.Control/IfStatementConditional/IfStatementConditional.pde index a763ae5..5bc0dff 100644 --- a/arduino-0018-linux-x64/examples/Control/IfStatementConditional/IfStatementConditional.pde +++ b/arduino-0022-linux-x64/examples/5.Control/IfStatementConditional/IfStatementConditional.pde @@ -16,14 +16,17 @@ connected to pin 13, so you don't need any extra components for this example. created 17 Jan 2009 + modified 4 Sep 2010 by Tom Igoe + +This example code is in the public domain. - http://arduino.cc/en/Tutorial/ +http://arduino.cc/en/Tutorial/IfStatement */ // These constants won't change: -const int analogPin = 0; // pin that the sensor is attached to +const int analogPin = A0; // pin that the sensor is attached to const int ledPin = 13; // pin that the LED is attached to const int threshold = 400; // an arbitrary threshold level that's in the range of the analog input diff --git a/arduino-0018-linux-x64/examples/Control/WhileStatementConditional/WhileStatementConditional.pde b/arduino-0022-linux-x64/examples/5.Control/WhileStatementConditional/WhileStatementConditional.pde similarity index 85% rename from arduino-0018-linux-x64/examples/Control/WhileStatementConditional/WhileStatementConditional.pde rename to arduino-0022-linux-x64/examples/5.Control/WhileStatementConditional/WhileStatementConditional.pde index 0500479..69c6fc8 100644 --- a/arduino-0018-linux-x64/examples/Control/WhileStatementConditional/WhileStatementConditional.pde +++ b/arduino-0022-linux-x64/examples/5.Control/WhileStatementConditional/WhileStatementConditional.pde @@ -17,19 +17,21 @@ * 10K resistor attached from pin 2 to ground created 17 Jan 2009 - modified 25 Jun 2009 + modified 4 Sep 2010 by Tom Igoe + This example code is in the public domain. + http://arduino.cc/en/Tutorial/WhileLoop */ // These constants won't change: -const int sensorPin = 2; // pin that the sensor is attached to -const int ledPin = 9; // pin that the LED is attached to -const int indicatorLedPin = 13; // pin that the built-in LED is attached to -const int buttonPin = 2; // pin that the button is attached to +const int sensorPin = A2; // pin that the sensor is attached to +const int ledPin = 9; // pin that the LED is attached to +const int indicatorLedPin = 13; // pin that the built-in LED is attached to +const int buttonPin = 2; // pin that the button is attached to // These variables will change: diff --git a/arduino-0018-linux-x64/examples/Control/switchCase/switchCase.pde b/arduino-0022-linux-x64/examples/5.Control/switchCase/switchCase.pde similarity index 93% rename from arduino-0018-linux-x64/examples/Control/switchCase/switchCase.pde rename to arduino-0022-linux-x64/examples/5.Control/switchCase/switchCase.pde index 10a2be1..1b76e5f 100644 --- a/arduino-0018-linux-x64/examples/Control/switchCase/switchCase.pde +++ b/arduino-0022-linux-x64/examples/5.Control/switchCase/switchCase.pde @@ -14,8 +14,11 @@ * 10K resistor from analog in 0 to ground created 1 Jul 2009 + modified 4 Sep 2010 by Tom Igoe + This example code is in the public domain. + http://www.arduino.cc/en/Tutorial/SwitchCase */ @@ -30,7 +33,7 @@ void setup() { void loop() { // read the sensor: - int sensorReading = analogRead(0); + int sensorReading = analogRead(A0); // map the sensor range to a range of four options: int range = map(sensorReading, sensorMin, sensorMax, 0, 3); diff --git a/arduino-0018-linux-x64/examples/Control/switchCase2/switchCase2.pde b/arduino-0022-linux-x64/examples/5.Control/switchCase2/switchCase2.pde similarity index 97% rename from arduino-0018-linux-x64/examples/Control/switchCase2/switchCase2.pde rename to arduino-0022-linux-x64/examples/5.Control/switchCase2/switchCase2.pde index 94a1b6c..b6d7886 100644 --- a/arduino-0018-linux-x64/examples/Control/switchCase2/switchCase2.pde +++ b/arduino-0022-linux-x64/examples/5.Control/switchCase2/switchCase2.pde @@ -15,6 +15,8 @@ created 1 Jul 2009 by Tom Igoe +This example code is in the public domain. + http://www.arduino.cc/en/Tutorial/SwitchCase2 */ diff --git a/arduino-0018-linux-x64/examples/Sensors/ADXL3xx/ADXL3xx.pde b/arduino-0022-linux-x64/examples/6.Sensors/ADXL3xx/ADXL3xx.pde similarity index 86% rename from arduino-0018-linux-x64/examples/Sensors/ADXL3xx/ADXL3xx.pde rename to arduino-0022-linux-x64/examples/6.Sensors/ADXL3xx/ADXL3xx.pde index 5609c42..58ea129 100644 --- a/arduino-0018-linux-x64/examples/Sensors/ADXL3xx/ADXL3xx.pde +++ b/arduino-0022-linux-x64/examples/6.Sensors/ADXL3xx/ADXL3xx.pde @@ -19,17 +19,19 @@ created 2 Jul 2008 by David A. Mellis - modified 26 Jun 2009 + modified 4 Sep 2010 by Tom Igoe + + This example code is in the public domain. */ // these constants describe the pins. They won't change: const int groundpin = 18; // analog input pin 4 -- ground const int powerpin = 19; // analog input pin 5 -- voltage -const int xpin = 3; // x-axis of the accelerometer -const int ypin = 2; // y-axis -const int zpin = 1; // z-axis (only on 3-axis models) +const int xpin = A3; // x-axis of the accelerometer +const int ypin = A2; // y-axis +const int zpin = A1; // z-axis (only on 3-axis models) void setup() { diff --git a/arduino-0018-linux-x64/examples/Sensors/Knock/Knock.pde b/arduino-0022-linux-x64/examples/6.Sensors/Knock/Knock.pde similarity index 92% rename from arduino-0018-linux-x64/examples/Sensors/Knock/Knock.pde rename to arduino-0022-linux-x64/examples/6.Sensors/Knock/Knock.pde index 05e4632..985f032 100644 --- a/arduino-0018-linux-x64/examples/Sensors/Knock/Knock.pde +++ b/arduino-0022-linux-x64/examples/6.Sensors/Knock/Knock.pde @@ -14,15 +14,17 @@ created 25 Mar 2007 by David Cuartielles - modified 30 Jun 2009 + modified 4 Sep 2010 by Tom Igoe + + This example code is in the public domain. */ // these constants won't change: const int ledPin = 13; // led connected to digital pin 13 -const int knockSensor = 0; // the piezo is connected to analog pin 0 +const int knockSensor = A0; // the piezo is connected to analog pin 0 const int threshold = 100; // threshold value to decide when the detected sound is a knock or not diff --git a/arduino-0018-linux-x64/examples/Sensors/Memsic2125/Memsic2125.pde b/arduino-0022-linux-x64/examples/6.Sensors/Memsic2125/Memsic2125.pde similarity index 96% rename from arduino-0018-linux-x64/examples/Sensors/Memsic2125/Memsic2125.pde rename to arduino-0022-linux-x64/examples/6.Sensors/Memsic2125/Memsic2125.pde index a69e31d..cf5e81c 100644 --- a/arduino-0018-linux-x64/examples/Sensors/Memsic2125/Memsic2125.pde +++ b/arduino-0022-linux-x64/examples/6.Sensors/Memsic2125/Memsic2125.pde @@ -18,6 +18,8 @@ by David A. Mellis modified 30 Jun 2009 by Tom Igoe + + This example code is in the public domain. */ diff --git a/arduino-0018-linux-x64/examples/Sensors/Ping/Ping.pde b/arduino-0022-linux-x64/examples/6.Sensors/Ping/Ping.pde similarity index 98% rename from arduino-0018-linux-x64/examples/Sensors/Ping/Ping.pde rename to arduino-0022-linux-x64/examples/6.Sensors/Ping/Ping.pde index 3e89744..70bab93 100644 --- a/arduino-0018-linux-x64/examples/Sensors/Ping/Ping.pde +++ b/arduino-0022-linux-x64/examples/6.Sensors/Ping/Ping.pde @@ -17,6 +17,8 @@ by David A. Mellis modified 30 Jun 2009 by Tom Igoe + + This example code is in the public domain. */ diff --git a/arduino-0018-linux-x64/examples/Display/RowColumnScanning/RowColumnScanning.pde b/arduino-0022-linux-x64/examples/7.Display/RowColumnScanning/RowColumnScanning.pde similarity index 94% rename from arduino-0018-linux-x64/examples/Display/RowColumnScanning/RowColumnScanning.pde rename to arduino-0022-linux-x64/examples/7.Display/RowColumnScanning/RowColumnScanning.pde index 49f6ab7..bcda4c7 100644 --- a/arduino-0018-linux-x64/examples/Display/RowColumnScanning/RowColumnScanning.pde +++ b/arduino-0022-linux-x64/examples/7.Display/RowColumnScanning/RowColumnScanning.pde @@ -4,7 +4,7 @@ This example controls an 8x8 LED matrix using two analog inputs created 27 May 2009 - modified 29 Jun 2009 + modified 4 Sep 2010 by Tom Igoe This example works for the Lumex LDM-24488NI Matrix. See @@ -26,6 +26,8 @@ * center pins are attached to analog pins 0 and 1, respectively * side pins attached to +5V and ground, respectively. + This example code is in the public domain. + http://www.arduino.cc/en/Tutorial/RowColumnScanning see also http://www.tigoe.net/pcomp/code/category/arduinowiring/514 for more @@ -81,8 +83,8 @@ void readSensors() { // turn off the last position: pixels[x][y] = HIGH; // read the sensors for X and Y values: - x = 7 - map(analogRead(0), 0, 1023, 0, 7); - y = map(analogRead(1), 0, 1023, 0, 7); + x = 7 - map(analogRead(A0), 0, 1023, 0, 7); + y = map(analogRead(A1), 0, 1023, 0, 7); // set the new pixel position low so that the LED will turn on // in the next screen refresh: pixels[x][y] = LOW; diff --git a/arduino-0018-linux-x64/examples/Display/barGraph/barGraph.pde b/arduino-0022-linux-x64/examples/7.Display/barGraph/barGraph.pde similarity index 91% rename from arduino-0018-linux-x64/examples/Display/barGraph/barGraph.pde rename to arduino-0022-linux-x64/examples/7.Display/barGraph/barGraph.pde index 3e6664a..646cd47 100644 --- a/arduino-0018-linux-x64/examples/Display/barGraph/barGraph.pde +++ b/arduino-0022-linux-x64/examples/7.Display/barGraph/barGraph.pde @@ -12,15 +12,17 @@ The circuit: * LEDs from pins 2 through 11 to ground - created 26 Jun 2009 + created 4 Sep 2010 by Tom Igoe + + This example code is in the public domain. http://www.arduino.cc/en/Tutorial/BarGraph */ // these constants won't change: -const int analogPin = 0; // the pin that the potentiometer is attached to +const int analogPin = A0; // the pin that the potentiometer is attached to const int ledCount = 10; // the number of LEDs in the bar graph int ledPins[] = { diff --git a/arduino-0022-linux-x64/examples/8.Strings/CharacterAnalysis/CharacterAnalysis.pde b/arduino-0022-linux-x64/examples/8.Strings/CharacterAnalysis/CharacterAnalysis.pde new file mode 100644 index 0000000..12baca9 --- /dev/null +++ b/arduino-0022-linux-x64/examples/8.Strings/CharacterAnalysis/CharacterAnalysis.pde @@ -0,0 +1,85 @@ +/* + Character analysis operators + + Examples using the character analysis operators. + Send any byte and the sketch will tell you about it. + + created 29 Nov 2010 + by Tom Igoe + + This example code is in the public domain. + */ + +void setup() { + // Open serial communications: + Serial.begin(9600); + + // send an intro: + Serial.println("send any byte and I'll tell you everything I can about it"); + Serial.println(); +} + +void loop() { + // get any incoming bytes: + if (Serial.available() > 0) { + int thisChar = Serial.read(); + + // say what was sent: + Serial.print("You sent me: \'"); + Serial.write(thisChar); + Serial.print("\' ASCII Value: "); + Serial.println(thisChar); + + // analyze what was sent: + if(isAlphaNumeric(thisChar)) { + Serial.println("it's alphanumeric"); + } + if(isAlpha(thisChar)) { + Serial.println("it's alphabetic"); + } + if(isAscii(thisChar)) { + Serial.println("it's ASCII"); + } + if(isWhitespace(thisChar)) { + Serial.println("it's whitespace"); + } + if(isControl(thisChar)) { + Serial.println("it's a control character"); + } + if(isDigit(thisChar)) { + Serial.println("it's a numeric digit"); + } + if(isGraph(thisChar)) { + Serial.println("it's a printable character that's not whitespace"); + } + if(isLowerCase(thisChar)) { + Serial.println("it's lower case"); + } + if(isPrintable(thisChar)) { + Serial.println("it's printable"); + } + if(isPunct(thisChar)) { + Serial.println("it's punctuation"); + } + if(isSpace(thisChar)) { + Serial.println("it's a space character"); + } + if(isUpperCase(thisChar)) { + Serial.println("it's upper case"); + } + if (isHexadecimalDigit(thisChar)) { + Serial.println("it's a valid hexadecimaldigit (i.e. 0 - 9, a - F, or A - F)"); + } + + // add some space and ask for another byte: + Serial.println(); + Serial.println("Give me another byte:"); + Serial.println(); + } +} + + + + + + diff --git a/arduino-0022-linux-x64/examples/8.Strings/StringAdditionOperator/StringAdditionOperator.pde b/arduino-0022-linux-x64/examples/8.Strings/StringAdditionOperator/StringAdditionOperator.pde new file mode 100644 index 0000000..fe631b9 --- /dev/null +++ b/arduino-0022-linux-x64/examples/8.Strings/StringAdditionOperator/StringAdditionOperator.pde @@ -0,0 +1,61 @@ +/* + Adding Strings together + + Examples of how to add strings together + You can also add several different data types to string, as shown here: + + created 27 July 2010 + modified 4 Sep 2010 + by Tom Igoe + + http://arduino.cc/en/Tutorial/StringAdditionOperator + + This example code is in the public domain. + */ + +// declare three strings: +String stringOne, stringTwo, stringThree; + +void setup() { + Serial.begin(9600); + stringOne = String("stringThree = "); + stringTwo = String("this string"); + stringThree = String (); + Serial.println("\n\nAdding strings together (concatenation):"); +} + +void loop() { + // adding a constant integer to a string: + stringThree = stringOne + 123; + Serial.println(stringThree); // prints "stringThree = 123" + + // adding a constant long interger to a string: + stringThree = stringOne + 123456789; + Serial.println(stringThree); // prints " You added 123456789" + + // adding a constant character to a string: + stringThree = stringOne + 'A'; + Serial.println(stringThree); // prints "You added A" + + // adding a constant string to a string: + stringThree = stringOne + "abc"; + Serial.println(stringThree); // prints "You added abc" + + stringThree = stringOne + stringTwo; + Serial.println(stringThree); // prints "You added this string" + + // adding a variable integer to a string: + int sensorValue = analogRead(A0); + stringOne = "Sensor value: "; + stringThree = stringOne + sensorValue; + Serial.println(stringThree); // prints "Sensor Value: 401" or whatever value analogRead(A0) has + + // adding a variable long integer to a string: + long currentTime = millis(); + stringOne="millis() value: "; + stringThree = stringOne + millis(); + Serial.println(stringThree); // prints "The millis: 345345" or whatever value currentTime has + + // do nothing while true: + while(true); +} \ No newline at end of file diff --git a/arduino-0022-linux-x64/examples/8.Strings/StringAppendOperator/StringAppendOperator.pde b/arduino-0022-linux-x64/examples/8.Strings/StringAppendOperator/StringAppendOperator.pde new file mode 100644 index 0000000..6807381 --- /dev/null +++ b/arduino-0022-linux-x64/examples/8.Strings/StringAppendOperator/StringAppendOperator.pde @@ -0,0 +1,64 @@ +/* + Appending to Strings using the += operator and concat() + + Examples of how to append different data types to strings + + created 27 July 2010 + modified 4 Sep 2010 + by Tom Igoe + + http://arduino.cc/en/Tutorial/StringAppendOperator + + This example code is in the public domain. + */ +String stringOne, stringTwo; + +void setup() { + Serial.begin(9600); + stringOne = String("Sensor "); + stringTwo = String("value"); + Serial.println("\n\nAppending to a string:"); +} + +void loop() { + Serial.println(stringOne); // prints "Sensor " + + // adding a string to a string: + stringOne += stringTwo; + Serial.println(stringOne); // prints "Sensor value" + + // adding a constant string to a string: + stringOne += " for input "; + Serial.println(stringOne); // prints "Sensor value for input" + + // adding a constant character to a string: + stringOne += 'A'; + Serial.println(stringOne); // prints "Sensor value for input A" + + // adding a constant integer to a string: + stringOne += 0; + Serial.println(stringOne); // prints "Sensor value for input A0" + + // adding a constant string to a string: + stringOne += ": "; + Serial.println(stringOne); // prints "Sensor value for input" + + // adding a variable integer to a string: + stringOne += analogRead(A0); + Serial.println(stringOne); // prints "Sensor value for input A0: 456" or whatever analogRead(A0) is + + Serial.println("\n\nchanging the Strings' values"); + stringOne = "A long integer: "; + stringTwo = "The millis(): "; + + // adding a constant long integer to a string: + stringOne += 123456789; + Serial.println(stringOne); // prints "A long integer: 123456789" + + // using concat() to add a long variable to a string: + stringTwo.concat(millis()); + Serial.println(stringTwo); // prints "The millis(): 43534" or whatever the value of the millis() is + + // do nothing while true: + while(true); +} \ No newline at end of file diff --git a/arduino-0022-linux-x64/examples/8.Strings/StringCaseChanges/StringCaseChanges.pde b/arduino-0022-linux-x64/examples/8.Strings/StringCaseChanges/StringCaseChanges.pde new file mode 100644 index 0000000..c180014 --- /dev/null +++ b/arduino-0022-linux-x64/examples/8.Strings/StringCaseChanges/StringCaseChanges.pde @@ -0,0 +1,35 @@ +/* + String Case changes + + Examples of how to change the case of a string + + created 27 July 2010 + by Tom Igoe + + http://arduino.cc/en/Tutorial/StringCaseChanges + + This example code is in the public domain. + */ + +void setup() { + Serial.begin(9600); + Serial.println("\n\nString case changes:"); +} + +void loop() { + // toUpperCase() changes all letters to upper case: + String stringOne = ""; + Serial.println(stringOne); + stringOne = (stringOne.toUpperCase()); + Serial.println(stringOne); + + // toLowerCase() changes all letters to lower case: + String stringTwo = ""; + Serial.println(stringTwo); + stringTwo = stringTwo.toLowerCase(); + Serial.println(stringTwo); + + + // do nothing while true: + while(true); +} diff --git a/arduino-0022-linux-x64/examples/8.Strings/StringCharacters/StringCharacters.pde b/arduino-0022-linux-x64/examples/8.Strings/StringCharacters/StringCharacters.pde new file mode 100644 index 0000000..8b8d9bb --- /dev/null +++ b/arduino-0022-linux-x64/examples/8.Strings/StringCharacters/StringCharacters.pde @@ -0,0 +1,37 @@ +/* + String charAt() and setCharAt() + + Examples of how to get and set characters of a String + + created 27 July 2010 + by Tom Igoe + + http://arduino.cc/en/Tutorial/StringCharacters + + This example code is in the public domain. + */ + +void setup() { + Serial.begin(9600); + Serial.println("\n\nString charAt() and setCharAt():"); +} + +void loop() { + // make a string to report a sensor reading: + String reportString = "SensorReading: 456"; + Serial.println(reportString); + + // the reading's most significant digit is at position 15 in the reportString: + String mostSignificantDigit = reportString.charAt(15); + Serial.println("Most significant digit of the sensor reading is: " + mostSignificantDigit); + +// add blank space: + Serial.println(); + + // you can alo set the character of a string. Change the : to a = character + reportString.setCharAt(13, '='); + Serial.println(reportString); + + // do nothing while true: + while(true); +} \ No newline at end of file diff --git a/arduino-0022-linux-x64/examples/8.Strings/StringComparisonOperators/StringComparisonOperators.pde b/arduino-0022-linux-x64/examples/8.Strings/StringComparisonOperators/StringComparisonOperators.pde new file mode 100644 index 0000000..3122b0b --- /dev/null +++ b/arduino-0022-linux-x64/examples/8.Strings/StringComparisonOperators/StringComparisonOperators.pde @@ -0,0 +1,124 @@ +/* + Comparing Strings + + Examples of how to compare strings using the comparison operators + + created 27 July 2010 + modified 4 Sep 2010 + by Tom Igoe + + http://arduino.cc/en/Tutorial/StringComparisonOperators + + This example code is in the public domain. + */ + +String stringOne, stringTwo; + +void setup() { + Serial.begin(9600); + stringOne = String("this"); + stringTwo = String("that"); + Serial.println("\n\nComparing Strings:"); + +} + +void loop() { + // two strings equal: + if (stringOne == "this") { + Serial.println("StringOne == \"this\""); + } + // two strings not equal: + if (stringOne != stringTwo) { + Serial.println(stringOne + " =! " + stringTwo); + } + + // two strings not equal (case sensitivity matters): + stringOne = "This"; + stringTwo = "this"; + if (stringOne != stringTwo) { + Serial.println(stringOne + " =! " + stringTwo); + } + // you can also use equals() to see if two strings are the same: + if (stringOne.equals(stringTwo)) { + Serial.println(stringOne + " equals " + stringTwo); + } + else { + Serial.println(stringOne + " does not equal " + stringTwo); + } + + // or perhaps you want to ignore case: + if (stringOne.equalsIgnoreCase(stringTwo)) { + Serial.println(stringOne + " equals (ignoring case) " + stringTwo); + } + else { + Serial.println(stringOne + " does not equal (ignoring case) " + stringTwo); + } + + // a numeric string compared to the number it represents: + stringOne = "1"; + int numberOne = 1; + if (stringOne == numberOne) { + Serial.println(stringOne + " = " + numberOne); + } + + + + // two numeric strings compared: + stringOne = "2"; + stringTwo = "1"; + if (stringOne >= stringTwo) { + Serial.println(stringOne + " >= " + stringTwo); + } + + // comparison operators can be used to compare strings for alphabetic sorting too: + stringOne = String("Brown"); + if (stringOne < "Charles") { + Serial.println(stringOne + " < Charles"); + } + + if (stringOne > "Adams") { + Serial.println(stringOne + " > Adams"); + } + + if (stringOne <= "Browne") { + Serial.println(stringOne + " <= Browne"); + } + + + if (stringOne >= "Brow") { + Serial.println(stringOne + " >= Brow"); + } + + // the compareTo() operator also allows you to compare strings + // it evaluates on the first character that's different. + // if the first character of the string you're comparing to + // comes first in alphanumeric order, then compareTo() is greater than 0: + stringOne = "Cucumber"; + stringTwo = "Cucuracha"; + if (stringOne.compareTo(stringTwo) < 0 ) { + Serial.println(stringOne + " comes before " + stringTwo); + } + else { + Serial.println(stringOne + " comes after " + stringTwo); + } + + delay(10000); // because the next part is a loop: + + // compareTo() is handy when you've got strings with numbers in them too: + + while (true) { + stringOne = "Sensor: "; + stringTwo= "Sensor: "; + + stringOne += analogRead(A0); + stringTwo += analogRead(A5); + + if (stringOne.compareTo(stringTwo) < 0 ) { + Serial.println(stringOne + " comes before " + stringTwo); + } + else { + Serial.println(stringOne + " comes after " + stringTwo); + + } + } +} \ No newline at end of file diff --git a/arduino-0022-linux-x64/examples/8.Strings/StringConstructors/StringConstructors.pde b/arduino-0022-linux-x64/examples/8.Strings/StringConstructors/StringConstructors.pde new file mode 100644 index 0000000..94ae2dc --- /dev/null +++ b/arduino-0022-linux-x64/examples/8.Strings/StringConstructors/StringConstructors.pde @@ -0,0 +1,64 @@ +/* + String constructors + + Examples of how to create strings from other data types + + created 27 July 2010 + modified 4 Sep 2010 + by Tom Igoe + + http://arduino.cc/en/Tutorial/StringConstructors + + This example code is in the public domain. + */ + +void setup() { + Serial.begin(9600); +} + +void loop() { + // using a constant String: + String stringOne = "Hello String"; + Serial.println(stringOne); // prints "Hello String" + + // converting a constant char into a String: + stringOne = String('a'); + Serial.println(stringOne); // prints "a" + + // converting a constant string into a String object: + String stringTwo = String("This is a string"); + Serial.println(stringTwo); // prints "This is a string" + + // concatenating two strings: + stringOne = String(stringTwo + " with more"); + // prints "This is a string with more": + Serial.println(stringOne); + + // using a constant integer: + stringOne = String(13); + Serial.println(stringOne); // prints "13" + + // using an int and a base: + stringOne = String(analogRead(A0), DEC); + // prints "453" or whatever the value of analogRead(A0) is + Serial.println(stringOne); + + // using an int and a base (hexadecimal): + stringOne = String(45, HEX); + // prints "2d", which is the hexadecimal version of decimal 45: + Serial.println(stringOne); + + // using an int and a base (binary) + stringOne = String(255, BIN); + // prints "11111111" which is the binary value of 255 + Serial.println(stringOne); + + // using a long and a base: + stringOne = String(millis(), DEC); + // prints "123456" or whatever the value of millis() is: + Serial.println(stringOne); + + // do nothing while true: + while(true); + +} \ No newline at end of file diff --git a/arduino-0022-linux-x64/examples/8.Strings/StringIndexOf/StringIndexOf.pde b/arduino-0022-linux-x64/examples/8.Strings/StringIndexOf/StringIndexOf.pde new file mode 100644 index 0000000..a60d127 --- /dev/null +++ b/arduino-0022-linux-x64/examples/8.Strings/StringIndexOf/StringIndexOf.pde @@ -0,0 +1,58 @@ +/* + String indexOf() and lastIndexOf() functions + + Examples of how to evaluate, look for, and replace characters in a String + + created 27 July 2010 + by Tom Igoe + + http://arduino.cc/en/Tutorial/StringIndexOf + + This example code is in the public domain. + */ + +void setup() { + Serial.begin(9600); + Serial.println("\n\nString indexOf() and lastIndexOf() functions:"); + +} + +void loop() { + // indexOf() returns the position (i.e. index) of a particular character + // in a string. For example, if you were parsing HTML tags, you could use it: + String stringOne = ""; + int firstClosingBracket = stringOne.indexOf('>'); + Serial.println("The index of > in the string " + stringOne + " is " + firstClosingBracket); + + stringOne = ""; + int secondOpeningBracket = firstClosingBracket + 1; + int secondClosingBracket = stringOne.indexOf('>', secondOpeningBracket ); + Serial.println("The index of the second > in the string " + stringOne + " is " + secondClosingBracket); + + // you can also use indexOf() to search for Strings: + stringOne = ""; + int bodyTag = stringOne.indexOf(""); + Serial.println("The index of the body tag in the string " + stringOne + " is " + bodyTag); + + stringOne = "
  • item
  • item
  • item
"; + int firstListItem = stringOne.indexOf("
  • "); + int secondListItem = stringOne.indexOf("item", firstListItem + 1 ); + Serial.println("The index of the second list item in the string " + stringOne + " is " + secondClosingBracket); + + // lastIndexOf() gives you the last occurrence of a character or string: + int lastOpeningBracket = stringOne.lastIndexOf('<'); + Serial.println("The index of the last < in the string " + stringOne + " is " + lastOpeningBracket); + + int lastListItem = stringOne.lastIndexOf("
  • "); + Serial.println("The index of the last list item in the string " + stringOne + " is " + lastListItem); + + +// lastIndexOf() can also search for a string: + stringOne = "

    Lorem ipsum dolor sit amet

    Ipsem

    Quod

    "; + int lastParagraph = stringOne.lastIndexOf(" 0) { + char inChar = Serial.read(); + txtMsg += inChar; + } + + // print the message and a notice if it's changed: + if (txtMsg.length() != lastStringLength) { + Serial.println(txtMsg); + Serial.println(txtMsg.length()); + // if the String's longer than 140 characters, complain: + if (txtMsg.length() < 140) { + Serial.println("That's a perfectly acceptable text message"); + } + else { + Serial.println("That's too long for a text message."); + } + // note the length for next time through the loop: + lastStringLength = txtMsg.length(); + } +} \ No newline at end of file diff --git a/arduino-0022-linux-x64/examples/8.Strings/StringLengthTrim/StringLengthTrim.pde b/arduino-0022-linux-x64/examples/8.Strings/StringLengthTrim/StringLengthTrim.pde new file mode 100644 index 0000000..1737b0d --- /dev/null +++ b/arduino-0022-linux-x64/examples/8.Strings/StringLengthTrim/StringLengthTrim.pde @@ -0,0 +1,34 @@ +/* + String length() and trim() + + Examples of how to use length() and trim() in a String + + created 27 July 2010 + by Tom Igoe + + http://arduino.cc/en/Tutorial/StringLengthTrim + + This example code is in the public domain. + */ + +void setup() { + Serial.begin(9600); + Serial.println("\n\nString length() and trim():"); +} + +void loop() { + // here's a String with empty spaces at the end (called white space): + String stringOne = "Hello! "; + Serial.print(stringOne); + Serial.print("<--- end of string. Length: "); + Serial.println(stringOne.length()); + + // trim the white space off the string: + stringOne = stringOne.trim(); + Serial.print(stringOne); + Serial.print("<--- end of trimmed string. Length: "); + Serial.println(stringOne.length()); + + // do nothing while true: + while(true); +} diff --git a/arduino-0022-linux-x64/examples/8.Strings/StringReplace/StringReplace.pde b/arduino-0022-linux-x64/examples/8.Strings/StringReplace/StringReplace.pde new file mode 100644 index 0000000..c906167 --- /dev/null +++ b/arduino-0022-linux-x64/examples/8.Strings/StringReplace/StringReplace.pde @@ -0,0 +1,35 @@ +/* + String replace() + + Examples of how to replace characters or substrings of a string + + created 27 July 2010 + by Tom Igoe + + http://arduino.cc/en/Tutorial/StringReplace + + This example code is in the public domain. + */ + +void setup() { + Serial.begin(9600); + Serial.println("\n\nString replace:"); +} + +void loop() { + String stringOne = ""; + Serial.println(stringOne); + // replace() changes all instances of one substring with another: + String stringTwo = stringOne.replace("<", " 0) { + int inChar = Serial.read(); + if (isDigit(inChar)) { + // convert the incoming byte to a char + // and add it to the string: + inString += (char)inChar; + } + // if you get a newline, print the string, + // then the string's value: + if (inChar == '\n') { + Serial.print("Value:"); + Serial.println(inString.toInt()); + Serial.print("String: "); + Serial.println(inString); + // clear the string for new input: + inString = ""; + } + } +} + + + + diff --git a/arduino-0022-linux-x64/examples/8.Strings/StringToIntRGB/StringToIntRGB.pde b/arduino-0022-linux-x64/examples/8.Strings/StringToIntRGB/StringToIntRGB.pde new file mode 100644 index 0000000..342739d --- /dev/null +++ b/arduino-0022-linux-x64/examples/8.Strings/StringToIntRGB/StringToIntRGB.pde @@ -0,0 +1,230 @@ +/* + Serial RGB controller + + Reads a serial input string looking for three comma-separated + integers with a newline at the end. Values should be between + 0 and 255. The sketch uses those values to set the color + of an RGB LED attached to pins 9 - 11. + + The circuit: + * Common-anode RGB LED cathodes attached to pins 9 - 11 + * LED anode connected to pin 13 + + To turn on any given channel, set the pin LOW. + To turn off, set the pin HIGH. The higher the analogWrite level, + the lower the brightness. + + created 29 Nov 2010 + by Tom Igoe + + This example code is in the public domain. + */ + +String inString = ""; // string to hold input +int currentColor = 0; +int red, green, blue = 0; + +void setup() { + // Initialize serial communications: + Serial.begin(9600); + // set LED cathode pins as outputs: + pinMode(9, OUTPUT); + pinMode(10, OUTPUT); + pinMode(11, OUTPUT); + // turn on pin 13 to power the LEDs: + pinMode(13, OUTPUT); + digitalWrite(13, HIGH); +} + +void loop() { + int inChar; + + // Read serial input: + if (Serial.available() > 0) { + inChar = Serial.read(); + } + + if (isDigit(inChar)) { + // convert the incoming byte to a char + // and add it to the string: + inString += (char)inChar; + } + + // if you get a comma, convert to a number, + // set the appropriate color, and increment + // the color counter: + if (inChar == ',') { + // do something different for each value of currentColor: + switch (currentColor) { + case 0: // 0 = red + red = inString.toInt(); + // clear the string for new input: + inString = ""; + break; + case 1: // 1 = green: + green = inString.toInt(); + // clear the string for new input: + inString = ""; + break; + } + currentColor++; + } + // if you get a newline, you know you've got + // the last color, i.e. blue: + if (inChar == '\n') { + blue = inString.toInt(); + + // set the levels of the LED. + // subtract value from 255 because a higher + // analogWrite level means a dimmer LED, since + // you're raising the level on the anode: + analogWrite(11, 255 - red); + analogWrite(9, 255 - green); + analogWrite(10, 255 - blue); + + // print the colors: + Serial.print("Red: "); + Serial.print(red); + Serial.print(", Green: "); + Serial.print(green); + Serial.print(", Blue: "); + Serial.println(blue); + + // clear the string for new input: + inString = ""; + // reset the color counter: + currentColor = 0; + + } + +} + + +/* +Here's a Processing sketch that will draw a color wheel and send a serial +string with the color you click on: + +// Subtractive Color Wheel with Serial +// Based on a Processing example by Ira Greenberg. +// Serial output added by Tom Igoe +// +// The primaries are red, yellow, and blue. The secondaries are green, +// purple, and orange. The tertiaries are yellow-orange, red-orange, +// red-purple, blue-purple, blue-green, and yellow-green. +// +// Create a shade or tint of the subtractive color wheel using +// SHADE or TINT parameters. + +// Updated 29 November 2010. + + + +import processing.serial.*; + +int segs = 12; +int steps = 6; +float rotAdjust = TWO_PI / segs / 2; +float radius; +float segWidth; +float interval = TWO_PI / segs; + +Serial myPort; + +void setup() { + size(200, 200); + background(127); + smooth(); + ellipseMode(RADIUS); + noStroke(); + // make the diameter 90% of the sketch area + radius = min(width, height) * 0.45; + segWidth = radius / steps; + + // swap which line is commented out to draw the other version + // drawTintWheel(); + drawShadeWheel(); + // open the first serial port in your computer's list + myPort = new Serial(this, Serial.list()[0], 9600); +} + + +void drawShadeWheel() { + for (int j = 0; j < steps; j++) { + color[] cols = { + color(255-(255/steps)*j, 255-(255/steps)*j, 0), + color(255-(255/steps)*j, (255/1.5)-((255/1.5)/steps)*j, 0), + color(255-(255/steps)*j, (255/2)-((255/2)/steps)*j, 0), + color(255-(255/steps)*j, (255/2.5)-((255/2.5)/steps)*j, 0), + color(255-(255/steps)*j, 0, 0), + color(255-(255/steps)*j, 0, (255/2)-((255/2)/steps)*j), + color(255-(255/steps)*j, 0, 255-(255/steps)*j), + color((255/2)-((255/2)/steps)*j, 0, 255-(255/steps)*j), + color(0, 0, 255-(255/steps)*j), + color(0, 255-(255/steps)*j, (255/2.5)-((255/2.5)/steps)*j), + color(0, 255-(255/steps)*j, 0), + color((255/2)-((255/2)/steps)*j, 255-(255/steps)*j, 0) + }; + for (int i = 0; i < segs; i++) { + fill(cols[i]); + arc(width/2, height/2, radius, radius, + interval*i+rotAdjust, interval*(i+1)+rotAdjust); + } + radius -= segWidth; + } +} + + +void drawTintWheel() { + for (int j = 0; j < steps; j++) { + color[] cols = { + color((255/steps)*j, (255/steps)*j, 0), + color((255/steps)*j, ((255/1.5)/steps)*j, 0), + color((255/steps)*j, ((255/2)/steps)*j, 0), + color((255/steps)*j, ((255/2.5)/steps)*j, 0), + color((255/steps)*j, 0, 0), + color((255/steps)*j, 0, ((255/2)/steps)*j), + color((255/steps)*j, 0, (255/steps)*j), + color(((255/2)/steps)*j, 0, (255/steps)*j), + color(0, 0, (255/steps)*j), + color(0, (255/steps)*j, ((255/2.5)/steps)*j), + color(0, (255/steps)*j, 0), + color(((255/2)/steps)*j, (255/steps)*j, 0) + }; + for (int i = 0; i < segs; i++) { + fill(cols[i]); + arc(width/2, height/2, radius, radius, + interval*i+rotAdjust, interval*(i+1)+rotAdjust); + } + radius -= segWidth; + } +} + +void draw() { + // nothing happens here +} + +void mouseReleased() { + // get the color of the mouse position's pixel: + color targetColor = get(mouseX, mouseY); + // get the component values: + int r = int(red(targetColor)); + int g = int(green(targetColor)); + int b = int(blue(targetColor)); + // make a comma-separated string: + String colorString = r + "," + g + "," + b + "\n"; + // send it out the serial port: + myPort.write(colorString ); +} + + +*/ + + + + + + + + + + diff --git a/arduino-0018-linux-x64/examples/ArduinoISP/ArduinoISP.pde b/arduino-0022-linux-x64/examples/ArduinoISP/ArduinoISP.pde similarity index 99% rename from arduino-0018-linux-x64/examples/ArduinoISP/ArduinoISP.pde rename to arduino-0022-linux-x64/examples/ArduinoISP/ArduinoISP.pde index 0012c69..5111c35 100644 --- a/arduino-0018-linux-x64/examples/ArduinoISP/ArduinoISP.pde +++ b/arduino-0022-linux-x64/examples/ArduinoISP/ArduinoISP.pde @@ -24,10 +24,8 @@ // - The SPI functions herein were developed for the AVR910_ARD programmer // - More information at http://code.google.com/p/mega-isp -#define SCK 13 -#define MISO 12 -#define MOSI 11 -#define RESET 10 +#include "pins_arduino.h" // defines SS,MOSI,MISO,SCK +#define RESET SS #define LED_HB 9 #define LED_ERR 8 diff --git a/arduino-0018-linux-x64/hardware/arduino/boards.txt b/arduino-0022-linux-x64/hardware/arduino/boards.txt similarity index 64% rename from arduino-0018-linux-x64/hardware/arduino/boards.txt rename to arduino-0022-linux-x64/hardware/arduino/boards.txt index 4ae4ac9..0ae40d3 100644 --- a/arduino-0018-linux-x64/hardware/arduino/boards.txt +++ b/arduino-0022-linux-x64/hardware/arduino/boards.txt @@ -1,5 +1,22 @@ ############################################################## +uno.name=Arduino Uno +uno.upload.protocol=stk500 +uno.upload.maximum_size=32256 +uno.upload.speed=115200 +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.build.mcu=atmega328p +uno.build.f_cpu=16000000L +uno.build.core=arduino + +############################################################## + atmega328.name=Arduino Duemilanove or Nano w/ ATmega328 atmega328.upload.protocol=stk500 @@ -40,7 +57,27 @@ diecimila.build.core=arduino ############################################################## -mega.name=Arduino Mega +mega2560.name=Arduino Mega 2560 + +mega2560.upload.protocol=stk500v2 +mega2560.upload.maximum_size=258048 +mega2560.upload.speed=115200 + +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 + +mega2560.build.mcu=atmega2560 +mega2560.build.f_cpu=16000000L +mega2560.build.core=arduino + +############################################################## + +mega.name=Arduino Mega (ATmega1280) mega.upload.protocol=stk500 mega.upload.maximum_size=126976 @@ -80,7 +117,48 @@ mini.build.core=arduino ############################################################## -bt.name=Arduino BT +fio.name=Arduino Fio + +fio.upload.protocol=stk500 +fio.upload.maximum_size=30720 +fio.upload.speed=57600 + +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.unlock_bits=0x3F +fio.bootloader.lock_bits=0x0F + +fio.build.mcu=atmega328p +fio.build.f_cpu=8000000L +fio.build.core=arduino:arduino + +############################################################## + +bt328.name=Arduino BT w/ ATmega328 + +bt328.upload.protocol=stk500 +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 + +############################################################## + +bt.name=Arduino BT w/ ATmega168 bt.upload.protocol=stk500 bt.upload.maximum_size=14336 @@ -141,6 +219,46 @@ lilypad.build.core=arduino ############################################################## +pro5v328.name=Arduino Pro or Pro Mini (5V, 16 MHz) w/ ATmega328 + +pro5v328.upload.protocol=stk500 +pro5v328.upload.maximum_size=30720 +pro5v328.upload.speed=57600 + +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 + +pro5v328.build.mcu=atmega328p +pro5v328.build.f_cpu=16000000L +pro5v328.build.core=arduino + +############################################################## + +pro5v.name=Arduino Pro or Pro Mini (5V, 16 MHz) w/ ATmega168 + +pro5v.upload.protocol=stk500 +pro5v.upload.maximum_size=14336 +pro5v.upload.speed=19200 + +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 + +pro5v.build.mcu=atmega168 +pro5v.build.f_cpu=16000000L +pro5v.build.core=arduino + +############################################################## + pro328.name=Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega328 pro328.upload.protocol=stk500 diff --git a/arduino-0018-linux-x64/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168.c b/arduino-0022-linux-x64/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168.c old mode 100755 new mode 100644 similarity index 100% rename from arduino-0018-linux-x64/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168.c rename to arduino-0022-linux-x64/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168.c diff --git a/arduino-0018-linux-x64/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168_atmega1280.hex b/arduino-0022-linux-x64/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168_atmega1280.hex similarity index 100% rename from arduino-0018-linux-x64/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168_atmega1280.hex rename to arduino-0022-linux-x64/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168_atmega1280.hex diff --git a/arduino-0018-linux-x64/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168_atmega328.hex b/arduino-0022-linux-x64/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168_atmega328.hex similarity index 100% rename from arduino-0018-linux-x64/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168_atmega328.hex rename to arduino-0022-linux-x64/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168_atmega328.hex diff --git a/arduino-0018-linux-x64/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168_atmega328_pro_8MHz.hex b/arduino-0022-linux-x64/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168_atmega328_pro_8MHz.hex similarity index 100% rename from arduino-0018-linux-x64/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168_atmega328_pro_8MHz.hex rename to arduino-0022-linux-x64/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168_atmega328_pro_8MHz.hex diff --git a/arduino-0018-linux-x64/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168_diecimila.hex b/arduino-0022-linux-x64/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168_diecimila.hex similarity index 100% rename from arduino-0018-linux-x64/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168_diecimila.hex rename to arduino-0022-linux-x64/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168_diecimila.hex diff --git a/arduino-0018-linux-x64/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168_ng.hex b/arduino-0022-linux-x64/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168_ng.hex similarity index 100% rename from arduino-0018-linux-x64/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168_ng.hex rename to arduino-0022-linux-x64/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168_ng.hex diff --git a/arduino-0018-linux-x64/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168_pro_8MHz.hex b/arduino-0022-linux-x64/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168_pro_8MHz.hex similarity index 100% rename from arduino-0018-linux-x64/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168_pro_8MHz.hex rename to arduino-0022-linux-x64/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168_pro_8MHz.hex diff --git a/arduino-0018-linux-x64/hardware/arduino/bootloaders/atmega/Makefile b/arduino-0022-linux-x64/hardware/arduino/bootloaders/atmega/Makefile old mode 100755 new mode 100644 similarity index 100% rename from arduino-0018-linux-x64/hardware/arduino/bootloaders/atmega/Makefile rename to arduino-0022-linux-x64/hardware/arduino/bootloaders/atmega/Makefile diff --git a/arduino-0018-linux-x64/hardware/arduino/bootloaders/atmega8/ATmegaBOOT.c b/arduino-0022-linux-x64/hardware/arduino/bootloaders/atmega8/ATmegaBOOT.c old mode 100755 new mode 100644 similarity index 100% rename from arduino-0018-linux-x64/hardware/arduino/bootloaders/atmega8/ATmegaBOOT.c rename to arduino-0022-linux-x64/hardware/arduino/bootloaders/atmega8/ATmegaBOOT.c diff --git a/arduino-0018-linux-x64/hardware/arduino/bootloaders/atmega8/ATmegaBOOT.hex b/arduino-0022-linux-x64/hardware/arduino/bootloaders/atmega8/ATmegaBOOT.hex similarity index 100% rename from arduino-0018-linux-x64/hardware/arduino/bootloaders/atmega8/ATmegaBOOT.hex rename to arduino-0022-linux-x64/hardware/arduino/bootloaders/atmega8/ATmegaBOOT.hex diff --git a/arduino-0018-linux-x64/hardware/arduino/bootloaders/atmega8/Makefile b/arduino-0022-linux-x64/hardware/arduino/bootloaders/atmega8/Makefile similarity index 100% rename from arduino-0018-linux-x64/hardware/arduino/bootloaders/atmega8/Makefile rename to arduino-0022-linux-x64/hardware/arduino/bootloaders/atmega8/Makefile diff --git a/arduino-0018-linux-x64/hardware/arduino/bootloaders/bt/ATmegaBOOT_168.c b/arduino-0022-linux-x64/hardware/arduino/bootloaders/bt/ATmegaBOOT_168.c similarity index 97% rename from arduino-0018-linux-x64/hardware/arduino/bootloaders/bt/ATmegaBOOT_168.c rename to arduino-0022-linux-x64/hardware/arduino/bootloaders/bt/ATmegaBOOT_168.c index a85dc9a..c73eefa 100644 --- a/arduino-0018-linux-x64/hardware/arduino/bootloaders/bt/ATmegaBOOT_168.c +++ b/arduino-0022-linux-x64/hardware/arduino/bootloaders/bt/ATmegaBOOT_168.c @@ -79,7 +79,7 @@ /* the current avr-libc eeprom functions do not support the ATmega168 */ /* own eeprom write/read functions are used instead */ -#ifndef __AVR_ATmega168__ +#if !defined(__AVR_ATmega168__) || !defined(__AVR_ATmega328P__) #include #endif @@ -189,6 +189,11 @@ #define SIG3 0x06 #define PAGE_SIZE 0x40U //64 words +#elif defined __AVR_ATmega328P__ +#define SIG2 0x95 +#define SIG3 0x0F +#define PAGE_SIZE 0x40U //64 words + #elif defined __AVR_ATmega162__ #define SIG2 0x94 #define SIG3 0x04 @@ -330,7 +335,8 @@ int main(void) UBRRHI = (F_CPU/(BAUD_RATE*16L)-1) >> 8; UCSRA = 0x00; UCSRB = _BV(TXEN)|_BV(RXEN); -#elif defined __AVR_ATmega168__ +#elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) + UBRR0H = ((F_CPU / 16 + BAUD_RATE / 2) / BAUD_RATE - 1) >> 8; UBRR0L = ((F_CPU / 16 + BAUD_RATE / 2) / BAUD_RATE - 1); @@ -551,7 +557,7 @@ putch(0x0D); if (getch() == ' ') { if (flags.eeprom) { //Write to EEPROM one byte at a time for(w=0;w $@ + +%.hex: %.elf + $(OBJCOPY) -j .text -j .data -O ihex $< $@ + +%.srec: %.elf + $(OBJCOPY) -j .text -j .data -O srec $< $@ + +%.bin: %.elf + $(OBJCOPY) -j .text -j .data -O binary $< $@ + diff --git a/arduino-0018-linux-x64/hardware/arduino/bootloaders/lilypad/LilyPadBOOT_168.hex b/arduino-0022-linux-x64/hardware/arduino/bootloaders/lilypad/LilyPadBOOT_168.hex similarity index 100% rename from arduino-0018-linux-x64/hardware/arduino/bootloaders/lilypad/LilyPadBOOT_168.hex rename to arduino-0022-linux-x64/hardware/arduino/bootloaders/lilypad/LilyPadBOOT_168.hex diff --git a/arduino-0018-linux-x64/hardware/arduino/bootloaders/lilypad/src/ATmegaBOOT.c b/arduino-0022-linux-x64/hardware/arduino/bootloaders/lilypad/src/ATmegaBOOT.c similarity index 100% rename from arduino-0018-linux-x64/hardware/arduino/bootloaders/lilypad/src/ATmegaBOOT.c rename to arduino-0022-linux-x64/hardware/arduino/bootloaders/lilypad/src/ATmegaBOOT.c diff --git a/arduino-0018-linux-x64/hardware/arduino/bootloaders/lilypad/src/Makefile b/arduino-0022-linux-x64/hardware/arduino/bootloaders/lilypad/src/Makefile similarity index 100% rename from arduino-0018-linux-x64/hardware/arduino/bootloaders/lilypad/src/Makefile rename to arduino-0022-linux-x64/hardware/arduino/bootloaders/lilypad/src/Makefile diff --git a/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/Makefile b/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/Makefile new file mode 100644 index 0000000..0fd6005 --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/Makefile @@ -0,0 +1,239 @@ +# Makefile for ATmegaBOOT +# E.Lins, 18.7.2005 +# $Id$ +# +# Instructions +# +# To make bootloader .hex file: +# make diecimila +# make lilypad +# make ng +# etc... +# +# To burn bootloader .hex file: +# make diecimila_isp +# make lilypad_isp +# make ng_isp +# etc... + +# program name should not be changed... +PROGRAM = optiboot + +# enter the parameters for the avrdude isp tool +ISPTOOL = stk500v2 +ISPPORT = usb +ISPSPEED = -b 115200 + +MCU_TARGET = atmega168 +LDSECTION = --section-start=.text=0x3e00 + +# the efuse should really be 0xf8; since, however, only the lower +# three bits of that byte are used on the atmega168, avrdude gets +# confused if you specify 1's for the higher bits, see: +# http://tinker.it/now/2007/02/24/the-tale-of-avrdude-atmega168-and-extended-bits-fuses/ +# +# similarly, the lock bits should be 0xff instead of 0x3f (to +# unlock the bootloader section) and 0xcf instead of 0x0f (to +# lock it), but since the high two bits of the lock byte are +# unused, avrdude would get confused. + +ISPFUSES = avrdude -c $(ISPTOOL) -p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) \ +-e -u -U lock:w:0x3f:m -U efuse:w:0x$(EFUSE):m -U hfuse:w:0x$(HFUSE):m -U lfuse:w:0x$(LFUSE):m +ISPFLASH = avrdude -c $(ISPTOOL) -p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) \ +-U flash:w:$(PROGRAM)_$(TARGET).hex -U lock:w:0x0f:m + +STK500 = "C:\Program Files\Atmel\AVR Tools\STK500\Stk500.exe" +STK500-1 = $(STK500) -e -d$(MCU_TARGET) -pf -vf -if$(PROGRAM)_$(TARGET).hex \ +-lFF -LFF -f$(HFUSE)$(LFUSE) -EF8 -ms -q -cUSB -I200kHz -s -wt +STK500-2 = $(STK500) -d$(MCU_TARGET) -ms -q -lCF -LCF -cUSB -I200kHz -s -wt + +OBJ = $(PROGRAM).o +OPTIMIZE = -Os -fno-inline-small-functions -fno-split-wide-types -mshort-calls + +DEFS = +LIBS = + +CC = avr-gcc + +# Override is only needed by avr-lib build system. + +override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) -DF_CPU=$(AVR_FREQ) $(DEFS) +override LDFLAGS = -Wl,$(LDSECTION) -Wl,--relax -nostartfiles + +OBJCOPY = avr-objcopy +OBJDUMP = avr-objdump + +# 20MHz clocked platforms +# +# These are capable of 230400 baud, or 115200 baud on PC (Arduino Avrdude issue) +# + +pro20: TARGET = pro_20mhz +pro20: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' +pro20: AVR_FREQ = 20000000L +pro20: $(PROGRAM)_pro_20mhz.hex +pro20: $(PROGRAM)_pro_20mhz.lst + +pro20_isp: pro20 +pro20_isp: TARGET = pro_20mhz +pro20_isp: HFUSE = DD # 2.7V brownout +pro20_isp: LFUSE = C6 # Full swing xtal (20MHz) 258CK/14CK+4.1ms +pro20_isp: EFUSE = 02 # 512 byte boot +pro20_isp: isp + +# 16MHz clocked platforms +# +# These are capable of 230400 baud, or 115200 baud on PC (Arduino Avrdude issue) +# + +pro16: TARGET = pro_16MHz +pro16: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' +pro16: AVR_FREQ = 16000000L +pro16: $(PROGRAM)_pro_16MHz.hex +pro16: $(PROGRAM)_pro_16MHz.lst + +pro16_isp: pro16 +pro16_isp: TARGET = pro_16MHz +pro16_isp: HFUSE = DD # 2.7V brownout +pro16_isp: LFUSE = C6 # Full swing xtal (20MHz) 258CK/14CK+4.1ms +pro16_isp: EFUSE = 02 # 512 byte boot +pro16_isp: isp + +# Diecimila and NG use identical bootloaders +# +diecimila: TARGET = diecimila +diecimila: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' +diecimila: AVR_FREQ = 16000000L +diecimila: $(PROGRAM)_diecimila.hex +diecimila: $(PROGRAM)_diecimila.lst + +diecimila_isp: diecimila +diecimila_isp: TARGET = diecimila +diecimila_isp: HFUSE = DD # 2.7V brownout +diecimila_isp: LFUSE = FF # Low power xtal (16MHz) 16KCK/14CK+65ms +diecimila_isp: EFUSE = 02 # 512 byte boot +diecimila_isp: isp + +atmega328: TARGET = atmega328 +atmega328: MCU_TARGET = atmega328p +atmega328: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' +atmega328: AVR_FREQ = 16000000L +atmega328: LDSECTION = --section-start=.text=0x7e00 +atmega328: $(PROGRAM)_atmega328.hex +atmega328: $(PROGRAM)_atmega328.lst + +atmega328_isp: atmega328 +atmega328_isp: TARGET = atmega328 +atmega328_isp: MCU_TARGET = atmega328p +atmega328_isp: HFUSE = DE # 512 byte boot +atmega328_isp: LFUSE = FF # Low power xtal (16MHz) 16KCK/14CK+65ms +atmega328_isp: EFUSE = 05 # 2.7V brownout +atmega328_isp: isp + +# 8MHz clocked platforms +# +# These are capable of 115200 baud +# + +lilypad: TARGET = lilypad +lilypad: CFLAGS += '-DLED_START_FLASHES=3' '-DSOFT_UART' '-DBAUD_RATE=115200' +lilypad: AVR_FREQ = 8000000L +lilypad: $(PROGRAM)_lilypad.hex +lilypad: $(PROGRAM)_lilypad.lst + +lilypad_isp: lilypad +lilypad_isp: TARGET = lilypad +lilypad_isp: HFUSE = DD # 2.7V brownout +lilypad_isp: LFUSE = E2 # Internal 8MHz osc (8MHz) Slow rising power +lilypad_isp: EFUSE = 02 # 512 byte boot +lilypad_isp: isp + +lilypad_resonator: TARGET = lilypad_resonator +lilypad_resonator: CFLAGS += '-DLED_START_FLASHES=3' '-DSOFT_UART' '-DBAUD_RATE=115200' +lilypad_resonator: AVR_FREQ = 8000000L +lilypad_resonator: $(PROGRAM)_lilypad_resonator.hex +lilypad_resonator: $(PROGRAM)_lilypad_resonator.lst + +lilypad_resonator_isp: lilypad_resonator +lilypad_resonator_isp: TARGET = lilypad_resonator +lilypad_resonator_isp: HFUSE = DD # 2.7V brownout +lilypad_resonator_isp: LFUSE = C6 # Full swing xtal (20MHz) 258CK/14CK+4.1ms +lilypad_resonator_isp: EFUSE = 02 # 512 byte boot +lilypad_resonator_isp: isp + +pro8: TARGET = pro_8MHz +pro8: CFLAGS += '-DLED_START_FLASHES=3' '-DSOFT_UART' '-DBAUD_RATE=115200' +pro8: AVR_FREQ = 8000000L +pro8: $(PROGRAM)_pro_8MHz.hex +pro8: $(PROGRAM)_pro_8MHz.lst + +pro8_isp: pro8 +pro8_isp: TARGET = pro_8MHz +pro8_isp: HFUSE = DD # 2.7V brownout +pro8_isp: LFUSE = C6 # Full swing xtal (20MHz) 258CK/14CK+4.1ms +pro8_isp: EFUSE = 02 # 512 byte boot +pro8_isp: isp + +atmega328_pro8: TARGET = atmega328_pro_8MHz +atmega328_pro8: MCU_TARGET = atmega328p +atmega328_pro8: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' +atmega328_pro8: AVR_FREQ = 8000000L +atmega328_pro8: LDSECTION = --section-start=.text=0x7e00 +atmega328_pro8: $(PROGRAM)_atmega328_pro_8MHz.hex +atmega328_pro8: $(PROGRAM)_atmega328_pro_8MHz.lst + +atmega328_pro8_isp: atmega328_pro8 +atmega328_pro8_isp: TARGET = atmega328_pro_8MHz +atmega328_pro8_isp: MCU_TARGET = atmega328p +atmega328_pro8_isp: HFUSE = DE # 512 byte boot +atmega328_pro8_isp: LFUSE = FF # Low power xtal (16MHz) 16KCK/14CK+65ms +atmega328_pro8_isp: EFUSE = 05 # 2.7V brownout +atmega328_pro8_isp: isp + +# 1MHz clocked platforms +# +# These are capable of 9600 baud +# + +luminet: TARGET = luminet +luminet: MCU_TARGET = attiny84 +luminet: CFLAGS += '-DLED_START_FLASHES=3' '-DSOFT_UART' '-DBAUD_RATE=9600' +luminet: CFLAGS += '-DVIRTUAL_BOOT_PARTITION' +luminet: AVR_FREQ = 1000000L +luminet: LDSECTION = --section-start=.text=0x1d00 +luminet: $(PROGRAM)_luminet.hex +luminet: $(PROGRAM)_luminet.lst + +luminet_isp: luminet +luminet_isp: TARGET = luminet +luminet_isp: MCU_TARGET = attiny84 +luminet_isp: HFUSE = DF # Brownout disabled +luminet_isp: LFUSE = 62 # 1MHz internal oscillator, slowly rising power +luminet_isp: EFUSE = FE # Self-programming enable +luminet_isp: isp + +isp: $(TARGET) + $(ISPFUSES) + $(ISPFLASH) + +isp-stk500: $(PROGRAM)_$(TARGET).hex + $(STK500-1) + $(STK500-2) + +%.elf: $(OBJ) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) + +clean: + rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep *.srec *.bin *.hex + +%.lst: %.elf + $(OBJDUMP) -h -S $< > $@ + +%.hex: %.elf + $(OBJCOPY) -j .text -j .data -O ihex $< $@ + +%.srec: %.elf + $(OBJCOPY) -j .text -j .data -O srec $< $@ + +%.bin: %.elf + $(OBJCOPY) -j .text -j .data -O binary $< $@ diff --git a/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/makeall b/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/makeall new file mode 100644 index 0000000..7a0b82d --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/makeall @@ -0,0 +1,13 @@ +#!/bin/bash +make clean +make lilypad +make lilypad_resonator +make pro8 +make pro16 +make pro20 +make diecimila +make ng +make atmega328 +make atmega328_pro8 +make luminet + diff --git a/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot.c b/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot.c new file mode 100644 index 0000000..af92995 --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot.c @@ -0,0 +1,536 @@ +/**********************************************************/ +/* Optiboot bootloader for Arduino */ +/* */ +/* Heavily optimised bootloader that is faster and */ +/* smaller than the Arduino standard bootloader */ +/* */ +/* Enhancements: */ +/* Fits in 512 bytes, saving 1.5K of code space */ +/* Background page erasing speeds up programming */ +/* Higher baud rate speeds up programming */ +/* Written almost entirely in C */ +/* Customisable timeout with accurate timeconstant */ +/* */ +/* What you lose: */ +/* Implements a skeleton STK500 protocol which is */ +/* missing several features including EEPROM */ +/* programming and non-page-aligned writes */ +/* High baud rate breaks compatibility with standard */ +/* Arduino flash settings */ +/* */ +/* Currently supports: */ +/* ATmega168 based devices (Diecimila etc) */ +/* ATmega328P based devices (Duemilanove etc) */ +/* */ +/* Does not support: */ +/* ATmega1280 based devices (eg. Mega) */ +/* */ +/* Assumptions: */ +/* The code makes several assumptions that reduce the */ +/* code size. They are all true after a hardware reset, */ +/* but may not be true if the bootloader is called by */ +/* other means or on other hardware. */ +/* No interrupts can occur */ +/* UART and Timer 1 are set to their reset state */ +/* SP points to RAMEND */ +/* */ +/* Code builds on code, libraries and optimisations from: */ +/* stk500boot.c by Jason P. Kyle */ +/* Arduino bootloader http://arduino.cc */ +/* Spiff's 1K bootloader http://spiffie.org/know/arduino_1k_bootloader/bootloader.shtml */ +/* avr-libc project http://nongnu.org/avr-libc */ +/* Adaboot http://www.ladyada.net/library/arduino/bootloader.html */ +/* AVR305 Atmel Application Note */ +/* */ +/* This program is free software; you can redistribute it */ +/* and/or modify it under the terms of the GNU General */ +/* Public License as published by the Free Software */ +/* Foundation; either version 2 of the License, or */ +/* (at your option) any later version. */ +/* */ +/* This program 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 General Public */ +/* License for more details. */ +/* */ +/* You should have received a copy of the GNU General */ +/* Public License along with this program; if not, write */ +/* to the Free Software Foundation, Inc., */ +/* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +/* */ +/* Licence can be viewed at */ +/* http://www.fsf.org/licenses/gpl.txt */ +/* */ +/**********************************************************/ + +#include +#include +#include +#include + +//#define LED_DATA_FLASH + +#ifndef LED_START_FLASHES +#define LED_START_FLASHES 0 +#endif + +/* Build-time variables */ +/* BAUD_RATE Programming baud rate */ +/* LED_NO_FLASHES Number of LED flashes on boot */ +/* FLASH_TIME_MS Duration of each LED flash */ +/* BOOT_TIMEOUT_MS Serial port wait time before exiting bootloader */ + +/* set the UART baud rate */ +#ifndef BAUD_RATE +#define BAUD_RATE 19200 +#endif + +#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) +/* Onboard LED is connected to pin PB5 in Arduino NG, Diecimila, and Duemilanove */ +#define LED_DDR DDRB +#define LED_PORT PORTB +#define LED_PIN PINB +#define LED PINB5 + +/* Ports for soft UART */ +#ifdef SOFT_UART +#define UART_PORT PORTD +#define UART_PIN PIND +#define UART_DDR DDRD +#define UART_TX_BIT 1 +#define UART_RX_BIT 0 +#endif +#endif + +#if defined(__AVR_ATtiny84__) +/* Onboard LED is connected to pin PB5 in Arduino NG, Diecimila, and Duemilanove */ +#define LED_DDR DDRA +#define LED_PORT PORTA +#define LED_PIN PINA +#define LED PINA4 + +/* Ports for soft UART - left port only for now*/ +#ifdef SOFT_UART +#define UART_PORT PORTA +#define UART_PIN PINA +#define UART_DDR DDRA +#define UART_TX_BIT 2 +#define UART_RX_BIT 3 +#endif +#endif + +/* STK500 constants list, from AVRDUDE */ +#define STK_OK 0x10 +#define STK_FAILED 0x11 // Not used +#define STK_UNKNOWN 0x12 // Not used +#define STK_NODEVICE 0x13 // Not used +#define STK_INSYNC 0x14 // ' ' +#define STK_NOSYNC 0x15 // Not used +#define ADC_CHANNEL_ERROR 0x16 // Not used +#define ADC_MEASURE_OK 0x17 // Not used +#define PWM_CHANNEL_ERROR 0x18 // Not used +#define PWM_ADJUST_OK 0x19 // Not used +#define CRC_EOP 0x20 // 'SPACE' +#define STK_GET_SYNC 0x30 // '0' +#define STK_GET_SIGN_ON 0x31 // '1' +#define STK_SET_PARAMETER 0x40 // '@' +#define STK_GET_PARAMETER 0x41 // 'A' +#define STK_SET_DEVICE 0x42 // 'B' +#define STK_SET_DEVICE_EXT 0x45 // 'E' +#define STK_ENTER_PROGMODE 0x50 // 'P' +#define STK_LEAVE_PROGMODE 0x51 // 'Q' +#define STK_CHIP_ERASE 0x52 // 'R' +#define STK_CHECK_AUTOINC 0x53 // 'S' +#define STK_LOAD_ADDRESS 0x55 // 'U' +#define STK_UNIVERSAL 0x56 // 'V' +#define STK_PROG_FLASH 0x60 // '`' +#define STK_PROG_DATA 0x61 // 'a' +#define STK_PROG_FUSE 0x62 // 'b' +#define STK_PROG_LOCK 0x63 // 'c' +#define STK_PROG_PAGE 0x64 // 'd' +#define STK_PROG_FUSE_EXT 0x65 // 'e' +#define STK_READ_FLASH 0x70 // 'p' +#define STK_READ_DATA 0x71 // 'q' +#define STK_READ_FUSE 0x72 // 'r' +#define STK_READ_LOCK 0x73 // 's' +#define STK_READ_PAGE 0x74 // 't' +#define STK_READ_SIGN 0x75 // 'u' +#define STK_READ_OSCCAL 0x76 // 'v' +#define STK_READ_FUSE_EXT 0x77 // 'w' +#define STK_READ_OSCCAL_EXT 0x78 // 'x' + +/* Watchdog settings */ +#define WATCHDOG_OFF (0) +#define WATCHDOG_16MS (_BV(WDE)) +#define WATCHDOG_32MS (_BV(WDP0) | _BV(WDE)) +#define WATCHDOG_64MS (_BV(WDP1) | _BV(WDE)) +#define WATCHDOG_125MS (_BV(WDP1) | _BV(WDP0) | _BV(WDE)) +#define WATCHDOG_250MS (_BV(WDP2) | _BV(WDE)) +#define WATCHDOG_500MS (_BV(WDP2) | _BV(WDP0) | _BV(WDE)) +#define WATCHDOG_1S (_BV(WDP2) | _BV(WDP1) | _BV(WDE)) +#define WATCHDOG_2S (_BV(WDP2) | _BV(WDP1) | _BV(WDP0) | _BV(WDE)) +#define WATCHDOG_4S (_BV(WDE3) | _BV(WDE)) +#define WATCHDOG_8S (_BV(WDE3) | _BV(WDE0) | _BV(WDE)) + +/* Function Prototypes */ +/* The main function is in init9, which removes the interrupt vector table */ +/* we don't need. It is also 'naked', which means the compiler does not */ +/* generate any entry or exit code itself. */ +int main(void) __attribute__ ((naked)) __attribute__ ((section (".init9"))); +void putch(char); +uint8_t getch(void); +static inline void getNch(uint8_t); /* "static inline" is a compiler hint to reduce code size */ +void verifySpace(); +static inline void flash_led(uint8_t); +uint8_t getLen(); +static inline void watchdogReset(); +void watchdogConfig(uint8_t x); +#ifdef SOFT_UART +void uartDelay() __attribute__ ((naked)); +#endif +void appStart() __attribute__ ((naked)); + +/* C zero initialises all global variables. However, that requires */ +/* These definitions are NOT zero initialised, but that doesn't matter */ +/* This allows us to drop the zero init code, saving us memory */ +#define buff ((uint8_t*)(0x100)) +#define address (*(uint16_t*)(0x200)) +#define length (*(uint8_t*)(0x202)) +#ifdef VIRTUAL_BOOT_PARTITION +#define rstVect (*(uint16_t*)(0x204)) +#define wdtVect (*(uint16_t*)(0x206)) +#endif +/* main program starts here */ +int main(void) { + // After the zero init loop, this is the first code to run. + // + // This code makes the following assumptions: + // No interrupts will execute + // SP points to RAMEND + // r1 contains zero + // + // If not, uncomment the following instructions: + // cli(); + // SP=RAMEND; // This is done by hardware reset + // asm volatile ("clr __zero_reg__"); + + uint8_t ch; + +#if LED_START_FLASHES > 0 + // Set up Timer 1 for timeout counter + TCCR1B = _BV(CS12) | _BV(CS10); // div 1024 +#endif +#ifndef SOFT_UART + UCSR0A = _BV(U2X0); //Double speed mode USART0 + UCSR0B = _BV(RXEN0) | _BV(TXEN0); + UCSR0C = _BV(UCSZ00) | _BV(UCSZ01); + UBRR0L = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 ); +#endif + + // Adaboot no-wait mod + ch = MCUSR; + MCUSR = 0; + if (!(ch & _BV(EXTRF))) appStart(); + + // Set up watchdog to trigger after 500ms + watchdogConfig(WATCHDOG_500MS); + + /* Set LED pin as output */ + LED_DDR |= _BV(LED); + +#ifdef SOFT_UART + /* Set TX pin as output */ + UART_DDR |= _BV(UART_TX_BIT); +#endif + +#if LED_START_FLASHES > 0 + /* Flash onboard LED to signal entering of bootloader */ + flash_led(LED_START_FLASHES * 2); +#endif + + /* Forever loop */ + for (;;) { + /* get character from UART */ + ch = getch(); + + if(ch == STK_GET_PARAMETER) { + // GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy + getNch(1); + putch(0x03); + } + else if(ch == STK_SET_DEVICE) { + // SET DEVICE is ignored + getNch(20); + } + else if(ch == STK_SET_DEVICE_EXT) { + // SET DEVICE EXT is ignored + getNch(5); + } + else if(ch == STK_LOAD_ADDRESS) { + // LOAD ADDRESS + address = getch(); + address = (address & 0xff) | (getch() << 8); + address += address; // Convert from word address to byte address + verifySpace(); + } + else if(ch == STK_UNIVERSAL) { + // UNIVERSAL command is ignored + getNch(4); + putch(0x00); + } + /* Write memory, length is big endian and is in bytes */ + else if(ch == STK_PROG_PAGE) { + // PROGRAM PAGE - we support flash programming only, not EEPROM + uint8_t *bufPtr; + uint16_t addrPtr; + + getLen(); + + // Immediately start page erase - this will 4.5ms + boot_page_erase((uint16_t)(void*)address); + + // While that is going on, read in page contents + bufPtr = buff; + do *bufPtr++ = getch(); + while (--length); + + // Read command terminator, start reply + verifySpace(); + + // If only a partial page is to be programmed, the erase might not be complete. + // So check that here + boot_spm_busy_wait(); + +#ifdef VIRTUAL_BOOT_PARTITION + if ((uint16_t)(void*)address == 0) { + // This is the reset vector page. We need to live-patch the code so the + // bootloader runs. + // + // Move RESET vector to WDT vector + uint16_t vect = buff[0] | (buff[1]<<8); + rstVect = vect; + wdtVect = buff[10] | (buff[11]<<8); + vect -= 4; // Instruction is a relative jump (rjmp), so recalculate. + buff[10] = vect & 0xff; + buff[11] = vect >> 8; + + // Add jump to bootloader at RESET vector + buff[0] = 0x7f; + buff[1] = 0xce; // rjmp 0x1d00 instruction + } +#endif + + // Copy buffer into programming buffer + bufPtr = buff; + addrPtr = (uint16_t)(void*)address; + ch = SPM_PAGESIZE / 2; + do { + uint16_t a; + a = *bufPtr++; + a |= (*bufPtr++) << 8; + boot_page_fill((uint16_t)(void*)addrPtr,a); + addrPtr += 2; + } while (--ch); + + // Write from programming buffer + boot_page_write((uint16_t)(void*)address); + boot_spm_busy_wait(); + +#if defined(RWWSRE) + // Reenable read access to flash + boot_rww_enable(); +#endif + + } + /* Read memory block mode, length is big endian. */ + else if(ch == STK_READ_PAGE) { + // READ PAGE - we only read flash + getLen(); + verifySpace(); +#ifdef VIRTUAL_BOOT_PARTITION + do { + // Undo vector patch in bottom page so verify passes + if (address == 0) ch=rstVect & 0xff; + else if (address == 1) ch=rstVect >> 8; + else if (address == 10) ch=wdtVect & 0xff; + else if (address == 11) ch=wdtVect >> 8; + else ch = pgm_read_byte_near(address); + address++; + putch(ch); + } while (--length); +#else + do putch(pgm_read_byte_near(address++)); + while (--length); +#endif + } + + /* Get device signature bytes */ + else if(ch == STK_READ_SIGN) { + // READ SIGN - return what Avrdude wants to hear + verifySpace(); + putch(SIGNATURE_0); + putch(SIGNATURE_1); + putch(SIGNATURE_2); + } + else if (ch == 'Q') { + // Adaboot no-wait mod + watchdogConfig(WATCHDOG_16MS); + verifySpace(); + } + else { + // This covers the response to commands like STK_ENTER_PROGMODE + verifySpace(); + } + putch(STK_OK); + } +} + +void putch(char ch) { +#ifndef SOFT_UART + while (!(UCSR0A & _BV(UDRE0))); + UDR0 = ch; +#else + __asm__ __volatile__ ( + " com %[ch]\n" // ones complement, carry set + " sec\n" + "1: brcc 2f\n" + " cbi %[uartPort],%[uartBit]\n" + " rjmp 3f\n" + "2: sbi %[uartPort],%[uartBit]\n" + " nop\n" + "3: rcall uartDelay\n" + " rcall uartDelay\n" + " lsr %[ch]\n" + " dec %[bitcnt]\n" + " brne 1b\n" + : + : + [bitcnt] "d" (10), + [ch] "r" (ch), + [uartPort] "I" (_SFR_IO_ADDR(UART_PORT)), + [uartBit] "I" (UART_TX_BIT) + : + "r25" + ); +#endif +} + +uint8_t getch(void) { + uint8_t ch; + + watchdogReset(); + +#ifdef LED_DATA_FLASH + LED_PIN |= _BV(LED); +#endif + +#ifdef SOFT_UART + __asm__ __volatile__ ( + "1: sbic %[uartPin],%[uartBit]\n" // Wait for start edge + " rjmp 1b\n" + " rcall uartDelay\n" // Get to middle of start bit + "2: rcall uartDelay\n" // Wait 1 bit period + " rcall uartDelay\n" // Wait 1 bit period + " clc\n" + " sbic %[uartPin],%[uartBit]\n" + " sec\n" + " dec %[bitCnt]\n" + " breq 3f\n" + " ror %[ch]\n" + " rjmp 2b\n" + "3:\n" + : + [ch] "=r" (ch) + : + [bitCnt] "d" (9), + [uartPin] "I" (_SFR_IO_ADDR(UART_PIN)), + [uartBit] "I" (UART_RX_BIT) + : + "r25" +); +#else + while(!(UCSR0A & _BV(RXC0))); + ch = UDR0; +#endif + +#ifdef LED_DATA_FLASH + LED_PIN |= _BV(LED); +#endif + + return ch; +} + +#ifdef SOFT_UART +//#define UART_B_VALUE (((F_CPU/BAUD_RATE)-23)/6) +#define UART_B_VALUE (((F_CPU/BAUD_RATE)-20)/6) +#if UART_B_VALUE > 255 +#error Baud rate too slow for soft UART +#endif + +void uartDelay() { + __asm__ __volatile__ ( + "ldi r25,%[count]\n" + "1:dec r25\n" + "brne 1b\n" + "ret\n" + ::[count] "M" (UART_B_VALUE) + ); +} +#endif + +void getNch(uint8_t count) { + do getch(); while (--count); + verifySpace(); +} + +void verifySpace() { + if (getch() != CRC_EOP) appStart(); + putch(STK_INSYNC); +} + +#if LED_START_FLASHES > 0 +void flash_led(uint8_t count) { + do { + TCNT1 = -(F_CPU/(1024*16)); + TIFR1 = _BV(TOV1); + while(!(TIFR1 & _BV(TOV1))); + LED_PIN |= _BV(LED); + watchdogReset(); + } while (--count); +} +#endif + +uint8_t getLen() { + getch(); + length = getch(); + return getch(); +} + +// Watchdog functions. These are only safe with interrupts turned off. +void watchdogReset() { + __asm__ __volatile__ ( + "wdr\n" + ); +} + +void watchdogConfig(uint8_t x) { + WDTCSR = _BV(WDCE) | _BV(WDE); + WDTCSR = x; +} + +void appStart() { + watchdogConfig(WATCHDOG_OFF); + __asm__ __volatile__ ( +#ifdef VIRTUAL_BOOT_PARTITION + // Jump to WDT vector + "ldi r30,5\n" + "clr r31\n" +#else + // Jump to RST vector + "clr r30\n" + "clr r31\n" +#endif + "ijmp\n" + ); +} diff --git a/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_atmega328.hex b/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_atmega328.hex new file mode 100644 index 0000000..b1c8567 --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_atmega328.hex @@ -0,0 +1,33 @@ +:107E000085E08093810082E08093C00088E18093C8 +:107E1000C10086E08093C20080E18093C40084B7F3 +:107E200014BE81FFD0D08DE0C8D0259A86E020E333 +:107E30003CEF91E0309385002093840096BBB09B8B +:107E4000FECF1D9AA8958150A9F7DD24D394A5E013 +:107E5000EA2EF1E1FF2EA4D0813421F481E0BED0DE +:107E600083E024C0823411F484E103C0853419F422 +:107E700085E0B4D08AC08535A1F492D0082F10E0F7 +:107E800010930102009300028BD090E0982F882776 +:107E9000802B912B880F991F9093010280930002F1 +:107EA00073C0863529F484E099D080E071D06DC02C +:107EB000843609F043C07CD0E0910002F0910102C9 +:107EC00083E080935700E895C0E0D1E069D08993C2 +:107ED000809102028150809302028823B9F778D002 +:107EE00007B600FCFDCF4091000250910102A0E0D6 +:107EF000B1E02C9130E011968C91119790E0982F81 +:107F00008827822B932B1296FA010C01D0925700EE +:107F1000E89511244E5F5F4FF1E0A038BF0749F7A5 +:107F2000E0910002F0910102E0925700E89507B657 +:107F300000FCFDCFF0925700E89527C08437B9F4D4 +:107F400037D046D0E0910002F09101023196F093D3 +:107F50000102E09300023197E4918E2F19D08091B5 +:107F60000202815080930202882361F70EC0853798 +:107F700039F42ED08EE10CD085E90AD08FE096CF6F +:107F8000813511F488E019D023D080E101D063CF8E +:107F9000982F8091C00085FFFCCF9093C600089574 +:107FA000A8958091C00087FFFCCF8091C6000895FE +:107FB000F7DFF6DF80930202F3CFE0E6F0E098E12E +:107FC00090838083089580E0F8DFEE27FF270994EF +:107FD000E7DF803209F0F7DF84E1DACF1F93182F53 +:0C7FE000DFDF1150E9F7F4DF1F91089576 +:0400000300007E007B +:00000001FF diff --git a/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_atmega328.lst b/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_atmega328.lst new file mode 100644 index 0000000..888871d --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_atmega328.lst @@ -0,0 +1,520 @@ + +optiboot_atmega328.elf: file format elf32-avr + +Sections: +Idx Name Size VMA LMA File off Algn + 0 .text 000001ec 00007e00 00007e00 00000054 2**1 + CONTENTS, ALLOC, LOAD, READONLY, CODE + 1 .debug_aranges 00000028 00000000 00000000 00000240 2**0 + CONTENTS, READONLY, DEBUGGING + 2 .debug_pubnames 0000006a 00000000 00000000 00000268 2**0 + CONTENTS, READONLY, DEBUGGING + 3 .debug_info 00000269 00000000 00000000 000002d2 2**0 + CONTENTS, READONLY, DEBUGGING + 4 .debug_abbrev 00000196 00000000 00000000 0000053b 2**0 + CONTENTS, READONLY, DEBUGGING + 5 .debug_line 000003d3 00000000 00000000 000006d1 2**0 + CONTENTS, READONLY, DEBUGGING + 6 .debug_frame 00000090 00000000 00000000 00000aa4 2**2 + CONTENTS, READONLY, DEBUGGING + 7 .debug_str 00000135 00000000 00000000 00000b34 2**0 + CONTENTS, READONLY, DEBUGGING + 8 .debug_loc 000001d1 00000000 00000000 00000c69 2**0 + CONTENTS, READONLY, DEBUGGING + 9 .debug_ranges 00000068 00000000 00000000 00000e3a 2**0 + CONTENTS, READONLY, DEBUGGING + +Disassembly of section .text: + +00007e00
    : +#ifdef VIRTUAL_BOOT_PARTITION +#define rstVect (*(uint16_t*)(0x204)) +#define wdtVect (*(uint16_t*)(0x206)) +#endif +/* main program starts here */ +int main(void) { + 7e00: 85 e0 ldi r24, 0x05 ; 5 + 7e02: 80 93 81 00 sts 0x0081, r24 +#if LED_START_FLASHES > 0 + // Set up Timer 1 for timeout counter + TCCR1B = _BV(CS12) | _BV(CS10); // div 1024 +#endif +#ifndef SOFT_UART + UCSR0A = _BV(U2X0); //Double speed mode USART0 + 7e06: 82 e0 ldi r24, 0x02 ; 2 + 7e08: 80 93 c0 00 sts 0x00C0, r24 + UCSR0B = _BV(RXEN0) | _BV(TXEN0); + 7e0c: 88 e1 ldi r24, 0x18 ; 24 + 7e0e: 80 93 c1 00 sts 0x00C1, r24 + UCSR0C = _BV(UCSZ00) | _BV(UCSZ01); + 7e12: 86 e0 ldi r24, 0x06 ; 6 + 7e14: 80 93 c2 00 sts 0x00C2, r24 + UBRR0L = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 ); + 7e18: 80 e1 ldi r24, 0x10 ; 16 + 7e1a: 80 93 c4 00 sts 0x00C4, r24 +#endif + + // Adaboot no-wait mod + ch = MCUSR; + 7e1e: 84 b7 in r24, 0x34 ; 52 + MCUSR = 0; + 7e20: 14 be out 0x34, r1 ; 52 + if (!(ch & _BV(EXTRF))) appStart(); + 7e22: 81 ff sbrs r24, 1 + 7e24: d0 d0 rcall .+416 ; 0x7fc6 + + // Set up watchdog to trigger after 500ms + watchdogConfig(WATCHDOG_500MS); + 7e26: 8d e0 ldi r24, 0x0D ; 13 + 7e28: c8 d0 rcall .+400 ; 0x7fba + + /* Set LED pin as output */ + LED_DDR |= _BV(LED); + 7e2a: 25 9a sbi 0x04, 5 ; 4 + 7e2c: 86 e0 ldi r24, 0x06 ; 6 +} + +#if LED_START_FLASHES > 0 +void flash_led(uint8_t count) { + do { + TCNT1 = -(F_CPU/(1024*16)); + 7e2e: 20 e3 ldi r18, 0x30 ; 48 + 7e30: 3c ef ldi r19, 0xFC ; 252 + TIFR1 = _BV(TOV1); + 7e32: 91 e0 ldi r25, 0x01 ; 1 +} + +#if LED_START_FLASHES > 0 +void flash_led(uint8_t count) { + do { + TCNT1 = -(F_CPU/(1024*16)); + 7e34: 30 93 85 00 sts 0x0085, r19 + 7e38: 20 93 84 00 sts 0x0084, r18 + TIFR1 = _BV(TOV1); + 7e3c: 96 bb out 0x16, r25 ; 22 + while(!(TIFR1 & _BV(TOV1))); + 7e3e: b0 9b sbis 0x16, 0 ; 22 + 7e40: fe cf rjmp .-4 ; 0x7e3e + LED_PIN |= _BV(LED); + 7e42: 1d 9a sbi 0x03, 5 ; 3 + return getch(); +} + +// Watchdog functions. These are only safe with interrupts turned off. +void watchdogReset() { + __asm__ __volatile__ ( + 7e44: a8 95 wdr + TCNT1 = -(F_CPU/(1024*16)); + TIFR1 = _BV(TOV1); + while(!(TIFR1 & _BV(TOV1))); + LED_PIN |= _BV(LED); + watchdogReset(); + } while (--count); + 7e46: 81 50 subi r24, 0x01 ; 1 + 7e48: a9 f7 brne .-22 ; 0x7e34 + /* get character from UART */ + ch = getch(); + + if(ch == STK_GET_PARAMETER) { + // GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy + getNch(1); + 7e4a: dd 24 eor r13, r13 + 7e4c: d3 94 inc r13 + boot_page_fill((uint16_t)(void*)addrPtr,a); + addrPtr += 2; + } while (--ch); + + // Write from programming buffer + boot_page_write((uint16_t)(void*)address); + 7e4e: a5 e0 ldi r26, 0x05 ; 5 + 7e50: ea 2e mov r14, r26 + boot_spm_busy_wait(); + +#if defined(RWWSRE) + // Reenable read access to flash + boot_rww_enable(); + 7e52: f1 e1 ldi r31, 0x11 ; 17 + 7e54: ff 2e mov r15, r31 +#endif + + /* Forever loop */ + for (;;) { + /* get character from UART */ + ch = getch(); + 7e56: a4 d0 rcall .+328 ; 0x7fa0 + + if(ch == STK_GET_PARAMETER) { + 7e58: 81 34 cpi r24, 0x41 ; 65 + 7e5a: 21 f4 brne .+8 ; 0x7e64 + // GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy + getNch(1); + 7e5c: 81 e0 ldi r24, 0x01 ; 1 + 7e5e: be d0 rcall .+380 ; 0x7fdc + putch(0x03); + 7e60: 83 e0 ldi r24, 0x03 ; 3 + 7e62: 24 c0 rjmp .+72 ; 0x7eac + } + else if(ch == STK_SET_DEVICE) { + 7e64: 82 34 cpi r24, 0x42 ; 66 + 7e66: 11 f4 brne .+4 ; 0x7e6c + // SET DEVICE is ignored + getNch(20); + 7e68: 84 e1 ldi r24, 0x14 ; 20 + 7e6a: 03 c0 rjmp .+6 ; 0x7e72 + } + else if(ch == STK_SET_DEVICE_EXT) { + 7e6c: 85 34 cpi r24, 0x45 ; 69 + 7e6e: 19 f4 brne .+6 ; 0x7e76 + // SET DEVICE EXT is ignored + getNch(5); + 7e70: 85 e0 ldi r24, 0x05 ; 5 + 7e72: b4 d0 rcall .+360 ; 0x7fdc + 7e74: 8a c0 rjmp .+276 ; 0x7f8a + } + else if(ch == STK_LOAD_ADDRESS) { + 7e76: 85 35 cpi r24, 0x55 ; 85 + 7e78: a1 f4 brne .+40 ; 0x7ea2 + // LOAD ADDRESS + address = getch(); + 7e7a: 92 d0 rcall .+292 ; 0x7fa0 + 7e7c: 08 2f mov r16, r24 + 7e7e: 10 e0 ldi r17, 0x00 ; 0 + 7e80: 10 93 01 02 sts 0x0201, r17 + 7e84: 00 93 00 02 sts 0x0200, r16 + address = (address & 0xff) | (getch() << 8); + 7e88: 8b d0 rcall .+278 ; 0x7fa0 + 7e8a: 90 e0 ldi r25, 0x00 ; 0 + 7e8c: 98 2f mov r25, r24 + 7e8e: 88 27 eor r24, r24 + 7e90: 80 2b or r24, r16 + 7e92: 91 2b or r25, r17 + address += address; // Convert from word address to byte address + 7e94: 88 0f add r24, r24 + 7e96: 99 1f adc r25, r25 + 7e98: 90 93 01 02 sts 0x0201, r25 + 7e9c: 80 93 00 02 sts 0x0200, r24 + 7ea0: 73 c0 rjmp .+230 ; 0x7f88 + verifySpace(); + } + else if(ch == STK_UNIVERSAL) { + 7ea2: 86 35 cpi r24, 0x56 ; 86 + 7ea4: 29 f4 brne .+10 ; 0x7eb0 + // UNIVERSAL command is ignored + getNch(4); + 7ea6: 84 e0 ldi r24, 0x04 ; 4 + 7ea8: 99 d0 rcall .+306 ; 0x7fdc + putch(0x00); + 7eaa: 80 e0 ldi r24, 0x00 ; 0 + 7eac: 71 d0 rcall .+226 ; 0x7f90 + 7eae: 6d c0 rjmp .+218 ; 0x7f8a + } + /* Write memory, length is big endian and is in bytes */ + else if(ch == STK_PROG_PAGE) { + 7eb0: 84 36 cpi r24, 0x64 ; 100 + 7eb2: 09 f0 breq .+2 ; 0x7eb6 + 7eb4: 43 c0 rjmp .+134 ; 0x7f3c + // PROGRAM PAGE - we support flash programming only, not EEPROM + uint8_t *bufPtr; + uint16_t addrPtr; + + getLen(); + 7eb6: 7c d0 rcall .+248 ; 0x7fb0 + + // Immediately start page erase - this will 4.5ms + boot_page_erase((uint16_t)(void*)address); + 7eb8: e0 91 00 02 lds r30, 0x0200 + 7ebc: f0 91 01 02 lds r31, 0x0201 + 7ec0: 83 e0 ldi r24, 0x03 ; 3 + 7ec2: 80 93 57 00 sts 0x0057, r24 + 7ec6: e8 95 spm + 7ec8: c0 e0 ldi r28, 0x00 ; 0 + 7eca: d1 e0 ldi r29, 0x01 ; 1 + + // While that is going on, read in page contents + bufPtr = buff; + do *bufPtr++ = getch(); + 7ecc: 69 d0 rcall .+210 ; 0x7fa0 + 7ece: 89 93 st Y+, r24 + while (--length); + 7ed0: 80 91 02 02 lds r24, 0x0202 + 7ed4: 81 50 subi r24, 0x01 ; 1 + 7ed6: 80 93 02 02 sts 0x0202, r24 + 7eda: 88 23 and r24, r24 + 7edc: b9 f7 brne .-18 ; 0x7ecc + + // Read command terminator, start reply + verifySpace(); + 7ede: 78 d0 rcall .+240 ; 0x7fd0 + + // If only a partial page is to be programmed, the erase might not be complete. + // So check that here + boot_spm_busy_wait(); + 7ee0: 07 b6 in r0, 0x37 ; 55 + 7ee2: 00 fc sbrc r0, 0 + 7ee4: fd cf rjmp .-6 ; 0x7ee0 + } +#endif + + // Copy buffer into programming buffer + bufPtr = buff; + addrPtr = (uint16_t)(void*)address; + 7ee6: 40 91 00 02 lds r20, 0x0200 + 7eea: 50 91 01 02 lds r21, 0x0201 + 7eee: a0 e0 ldi r26, 0x00 ; 0 + 7ef0: b1 e0 ldi r27, 0x01 ; 1 + ch = SPM_PAGESIZE / 2; + do { + uint16_t a; + a = *bufPtr++; + 7ef2: 2c 91 ld r18, X + 7ef4: 30 e0 ldi r19, 0x00 ; 0 + a |= (*bufPtr++) << 8; + 7ef6: 11 96 adiw r26, 0x01 ; 1 + 7ef8: 8c 91 ld r24, X + 7efa: 11 97 sbiw r26, 0x01 ; 1 + 7efc: 90 e0 ldi r25, 0x00 ; 0 + 7efe: 98 2f mov r25, r24 + 7f00: 88 27 eor r24, r24 + 7f02: 82 2b or r24, r18 + 7f04: 93 2b or r25, r19 +#ifdef VIRTUAL_BOOT_PARTITION +#define rstVect (*(uint16_t*)(0x204)) +#define wdtVect (*(uint16_t*)(0x206)) +#endif +/* main program starts here */ +int main(void) { + 7f06: 12 96 adiw r26, 0x02 ; 2 + ch = SPM_PAGESIZE / 2; + do { + uint16_t a; + a = *bufPtr++; + a |= (*bufPtr++) << 8; + boot_page_fill((uint16_t)(void*)addrPtr,a); + 7f08: fa 01 movw r30, r20 + 7f0a: 0c 01 movw r0, r24 + 7f0c: d0 92 57 00 sts 0x0057, r13 + 7f10: e8 95 spm + 7f12: 11 24 eor r1, r1 + addrPtr += 2; + 7f14: 4e 5f subi r20, 0xFE ; 254 + 7f16: 5f 4f sbci r21, 0xFF ; 255 + } while (--ch); + 7f18: f1 e0 ldi r31, 0x01 ; 1 + 7f1a: a0 38 cpi r26, 0x80 ; 128 + 7f1c: bf 07 cpc r27, r31 + 7f1e: 49 f7 brne .-46 ; 0x7ef2 + + // Write from programming buffer + boot_page_write((uint16_t)(void*)address); + 7f20: e0 91 00 02 lds r30, 0x0200 + 7f24: f0 91 01 02 lds r31, 0x0201 + 7f28: e0 92 57 00 sts 0x0057, r14 + 7f2c: e8 95 spm + boot_spm_busy_wait(); + 7f2e: 07 b6 in r0, 0x37 ; 55 + 7f30: 00 fc sbrc r0, 0 + 7f32: fd cf rjmp .-6 ; 0x7f2e + +#if defined(RWWSRE) + // Reenable read access to flash + boot_rww_enable(); + 7f34: f0 92 57 00 sts 0x0057, r15 + 7f38: e8 95 spm + 7f3a: 27 c0 rjmp .+78 ; 0x7f8a +#endif + + } + /* Read memory block mode, length is big endian. */ + else if(ch == STK_READ_PAGE) { + 7f3c: 84 37 cpi r24, 0x74 ; 116 + 7f3e: b9 f4 brne .+46 ; 0x7f6e + // READ PAGE - we only read flash + getLen(); + 7f40: 37 d0 rcall .+110 ; 0x7fb0 + verifySpace(); + 7f42: 46 d0 rcall .+140 ; 0x7fd0 + else ch = pgm_read_byte_near(address); + address++; + putch(ch); + } while (--length); +#else + do putch(pgm_read_byte_near(address++)); + 7f44: e0 91 00 02 lds r30, 0x0200 + 7f48: f0 91 01 02 lds r31, 0x0201 + 7f4c: 31 96 adiw r30, 0x01 ; 1 + 7f4e: f0 93 01 02 sts 0x0201, r31 + 7f52: e0 93 00 02 sts 0x0200, r30 + 7f56: 31 97 sbiw r30, 0x01 ; 1 + 7f58: e4 91 lpm r30, Z+ + 7f5a: 8e 2f mov r24, r30 + 7f5c: 19 d0 rcall .+50 ; 0x7f90 + while (--length); + 7f5e: 80 91 02 02 lds r24, 0x0202 + 7f62: 81 50 subi r24, 0x01 ; 1 + 7f64: 80 93 02 02 sts 0x0202, r24 + 7f68: 88 23 and r24, r24 + 7f6a: 61 f7 brne .-40 ; 0x7f44 + 7f6c: 0e c0 rjmp .+28 ; 0x7f8a +#endif + } + + /* Get device signature bytes */ + else if(ch == STK_READ_SIGN) { + 7f6e: 85 37 cpi r24, 0x75 ; 117 + 7f70: 39 f4 brne .+14 ; 0x7f80 + // READ SIGN - return what Avrdude wants to hear + verifySpace(); + 7f72: 2e d0 rcall .+92 ; 0x7fd0 + putch(SIGNATURE_0); + 7f74: 8e e1 ldi r24, 0x1E ; 30 + 7f76: 0c d0 rcall .+24 ; 0x7f90 + putch(SIGNATURE_1); + 7f78: 85 e9 ldi r24, 0x95 ; 149 + 7f7a: 0a d0 rcall .+20 ; 0x7f90 + putch(SIGNATURE_2); + 7f7c: 8f e0 ldi r24, 0x0F ; 15 + 7f7e: 96 cf rjmp .-212 ; 0x7eac + } + else if (ch == 'Q') { + 7f80: 81 35 cpi r24, 0x51 ; 81 + 7f82: 11 f4 brne .+4 ; 0x7f88 + // Adaboot no-wait mod + watchdogConfig(WATCHDOG_16MS); + 7f84: 88 e0 ldi r24, 0x08 ; 8 + 7f86: 19 d0 rcall .+50 ; 0x7fba + verifySpace(); + } + else { + // This covers the response to commands like STK_ENTER_PROGMODE + verifySpace(); + 7f88: 23 d0 rcall .+70 ; 0x7fd0 + } + putch(STK_OK); + 7f8a: 80 e1 ldi r24, 0x10 ; 16 + 7f8c: 01 d0 rcall .+2 ; 0x7f90 + 7f8e: 63 cf rjmp .-314 ; 0x7e56 + +00007f90 : + } +} + +void putch(char ch) { + 7f90: 98 2f mov r25, r24 +#ifndef SOFT_UART + while (!(UCSR0A & _BV(UDRE0))); + 7f92: 80 91 c0 00 lds r24, 0x00C0 + 7f96: 85 ff sbrs r24, 5 + 7f98: fc cf rjmp .-8 ; 0x7f92 + UDR0 = ch; + 7f9a: 90 93 c6 00 sts 0x00C6, r25 + [uartBit] "I" (UART_TX_BIT) + : + "r25" + ); +#endif +} + 7f9e: 08 95 ret + +00007fa0 : + return getch(); +} + +// Watchdog functions. These are only safe with interrupts turned off. +void watchdogReset() { + __asm__ __volatile__ ( + 7fa0: a8 95 wdr + [uartBit] "I" (UART_RX_BIT) + : + "r25" +); +#else + while(!(UCSR0A & _BV(RXC0))); + 7fa2: 80 91 c0 00 lds r24, 0x00C0 + 7fa6: 87 ff sbrs r24, 7 + 7fa8: fc cf rjmp .-8 ; 0x7fa2 + ch = UDR0; + 7faa: 80 91 c6 00 lds r24, 0x00C6 +#ifdef LED_DATA_FLASH + LED_PIN |= _BV(LED); +#endif + + return ch; +} + 7fae: 08 95 ret + +00007fb0 : + } while (--count); +} +#endif + +uint8_t getLen() { + getch(); + 7fb0: f7 df rcall .-18 ; 0x7fa0 + length = getch(); + 7fb2: f6 df rcall .-20 ; 0x7fa0 + 7fb4: 80 93 02 02 sts 0x0202, r24 + return getch(); +} + 7fb8: f3 cf rjmp .-26 ; 0x7fa0 + +00007fba : + "wdr\n" + ); +} + +void watchdogConfig(uint8_t x) { + WDTCSR = _BV(WDCE) | _BV(WDE); + 7fba: e0 e6 ldi r30, 0x60 ; 96 + 7fbc: f0 e0 ldi r31, 0x00 ; 0 + 7fbe: 98 e1 ldi r25, 0x18 ; 24 + 7fc0: 90 83 st Z, r25 + WDTCSR = x; + 7fc2: 80 83 st Z, r24 +} + 7fc4: 08 95 ret + +00007fc6 : + +void appStart() { + watchdogConfig(WATCHDOG_OFF); + 7fc6: 80 e0 ldi r24, 0x00 ; 0 + 7fc8: f8 df rcall .-16 ; 0x7fba + __asm__ __volatile__ ( + 7fca: ee 27 eor r30, r30 + 7fcc: ff 27 eor r31, r31 + 7fce: 09 94 ijmp + +00007fd0 : + do getch(); while (--count); + verifySpace(); +} + +void verifySpace() { + if (getch() != CRC_EOP) appStart(); + 7fd0: e7 df rcall .-50 ; 0x7fa0 + 7fd2: 80 32 cpi r24, 0x20 ; 32 + 7fd4: 09 f0 breq .+2 ; 0x7fd8 + 7fd6: f7 df rcall .-18 ; 0x7fc6 + putch(STK_INSYNC); + 7fd8: 84 e1 ldi r24, 0x14 ; 20 +} + 7fda: da cf rjmp .-76 ; 0x7f90 + ::[count] "M" (UART_B_VALUE) + ); +} +#endif + +void getNch(uint8_t count) { + 7fdc: 1f 93 push r17 + 7fde: 18 2f mov r17, r24 + +00007fe0 : + do getch(); while (--count); + 7fe0: df df rcall .-66 ; 0x7fa0 + 7fe2: 11 50 subi r17, 0x01 ; 1 + 7fe4: e9 f7 brne .-6 ; 0x7fe0 + verifySpace(); + 7fe6: f4 df rcall .-24 ; 0x7fd0 +} + 7fe8: 1f 91 pop r17 + 7fea: 08 95 ret diff --git a/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_atmega328_pro_8MHz.hex b/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_atmega328_pro_8MHz.hex new file mode 100644 index 0000000..d6ac145 --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_atmega328_pro_8MHz.hex @@ -0,0 +1,33 @@ +:107E000085E08093810082E08093C00088E18093C8 +:107E1000C10086E08093C20088E08093C40084B7EC +:107E200014BE81FFD0D08DE0C8D0259A86E028E12D +:107E30003EEF91E0309385002093840096BBB09B89 +:107E4000FECF1D9AA8958150A9F7DD24D394A5E013 +:107E5000EA2EF1E1FF2EA4D0813421F481E0BED0DE +:107E600083E024C0823411F484E103C0853419F422 +:107E700085E0B4D08AC08535A1F492D0082F10E0F7 +:107E800010930102009300028BD090E0982F882776 +:107E9000802B912B880F991F9093010280930002F1 +:107EA00073C0863529F484E099D080E071D06DC02C +:107EB000843609F043C07CD0E0910002F0910102C9 +:107EC00083E080935700E895C0E0D1E069D08993C2 +:107ED000809102028150809302028823B9F778D002 +:107EE00007B600FCFDCF4091000250910102A0E0D6 +:107EF000B1E02C9130E011968C91119790E0982F81 +:107F00008827822B932B1296FA010C01D0925700EE +:107F1000E89511244E5F5F4FF1E0A038BF0749F7A5 +:107F2000E0910002F0910102E0925700E89507B657 +:107F300000FCFDCFF0925700E89527C08437B9F4D4 +:107F400037D046D0E0910002F09101023196F093D3 +:107F50000102E09300023197E4918E2F19D08091B5 +:107F60000202815080930202882361F70EC0853798 +:107F700039F42ED08EE10CD085E90AD08FE096CF6F +:107F8000813511F488E019D023D080E101D063CF8E +:107F9000982F8091C00085FFFCCF9093C600089574 +:107FA000A8958091C00087FFFCCF8091C6000895FE +:107FB000F7DFF6DF80930202F3CFE0E6F0E098E12E +:107FC00090838083089580E0F8DFEE27FF270994EF +:107FD000E7DF803209F0F7DF84E1DACF1F93182F53 +:0C7FE000DFDF1150E9F7F4DF1F91089576 +:0400000300007E007B +:00000001FF diff --git a/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_atmega328_pro_8MHz.lst b/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_atmega328_pro_8MHz.lst new file mode 100644 index 0000000..46eda68 --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_atmega328_pro_8MHz.lst @@ -0,0 +1,520 @@ + +optiboot_atmega328_pro_8MHz.elf: file format elf32-avr + +Sections: +Idx Name Size VMA LMA File off Algn + 0 .text 000001ec 00007e00 00007e00 00000054 2**1 + CONTENTS, ALLOC, LOAD, READONLY, CODE + 1 .debug_aranges 00000028 00000000 00000000 00000240 2**0 + CONTENTS, READONLY, DEBUGGING + 2 .debug_pubnames 0000006a 00000000 00000000 00000268 2**0 + CONTENTS, READONLY, DEBUGGING + 3 .debug_info 00000269 00000000 00000000 000002d2 2**0 + CONTENTS, READONLY, DEBUGGING + 4 .debug_abbrev 00000196 00000000 00000000 0000053b 2**0 + CONTENTS, READONLY, DEBUGGING + 5 .debug_line 000003d3 00000000 00000000 000006d1 2**0 + CONTENTS, READONLY, DEBUGGING + 6 .debug_frame 00000090 00000000 00000000 00000aa4 2**2 + CONTENTS, READONLY, DEBUGGING + 7 .debug_str 00000135 00000000 00000000 00000b34 2**0 + CONTENTS, READONLY, DEBUGGING + 8 .debug_loc 000001d1 00000000 00000000 00000c69 2**0 + CONTENTS, READONLY, DEBUGGING + 9 .debug_ranges 00000068 00000000 00000000 00000e3a 2**0 + CONTENTS, READONLY, DEBUGGING + +Disassembly of section .text: + +00007e00
    : +#ifdef VIRTUAL_BOOT_PARTITION +#define rstVect (*(uint16_t*)(0x204)) +#define wdtVect (*(uint16_t*)(0x206)) +#endif +/* main program starts here */ +int main(void) { + 7e00: 85 e0 ldi r24, 0x05 ; 5 + 7e02: 80 93 81 00 sts 0x0081, r24 +#if LED_START_FLASHES > 0 + // Set up Timer 1 for timeout counter + TCCR1B = _BV(CS12) | _BV(CS10); // div 1024 +#endif +#ifndef SOFT_UART + UCSR0A = _BV(U2X0); //Double speed mode USART0 + 7e06: 82 e0 ldi r24, 0x02 ; 2 + 7e08: 80 93 c0 00 sts 0x00C0, r24 + UCSR0B = _BV(RXEN0) | _BV(TXEN0); + 7e0c: 88 e1 ldi r24, 0x18 ; 24 + 7e0e: 80 93 c1 00 sts 0x00C1, r24 + UCSR0C = _BV(UCSZ00) | _BV(UCSZ01); + 7e12: 86 e0 ldi r24, 0x06 ; 6 + 7e14: 80 93 c2 00 sts 0x00C2, r24 + UBRR0L = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 ); + 7e18: 88 e0 ldi r24, 0x08 ; 8 + 7e1a: 80 93 c4 00 sts 0x00C4, r24 +#endif + + // Adaboot no-wait mod + ch = MCUSR; + 7e1e: 84 b7 in r24, 0x34 ; 52 + MCUSR = 0; + 7e20: 14 be out 0x34, r1 ; 52 + if (!(ch & _BV(EXTRF))) appStart(); + 7e22: 81 ff sbrs r24, 1 + 7e24: d0 d0 rcall .+416 ; 0x7fc6 + + // Set up watchdog to trigger after 500ms + watchdogConfig(WATCHDOG_500MS); + 7e26: 8d e0 ldi r24, 0x0D ; 13 + 7e28: c8 d0 rcall .+400 ; 0x7fba + + /* Set LED pin as output */ + LED_DDR |= _BV(LED); + 7e2a: 25 9a sbi 0x04, 5 ; 4 + 7e2c: 86 e0 ldi r24, 0x06 ; 6 +} + +#if LED_START_FLASHES > 0 +void flash_led(uint8_t count) { + do { + TCNT1 = -(F_CPU/(1024*16)); + 7e2e: 28 e1 ldi r18, 0x18 ; 24 + 7e30: 3e ef ldi r19, 0xFE ; 254 + TIFR1 = _BV(TOV1); + 7e32: 91 e0 ldi r25, 0x01 ; 1 +} + +#if LED_START_FLASHES > 0 +void flash_led(uint8_t count) { + do { + TCNT1 = -(F_CPU/(1024*16)); + 7e34: 30 93 85 00 sts 0x0085, r19 + 7e38: 20 93 84 00 sts 0x0084, r18 + TIFR1 = _BV(TOV1); + 7e3c: 96 bb out 0x16, r25 ; 22 + while(!(TIFR1 & _BV(TOV1))); + 7e3e: b0 9b sbis 0x16, 0 ; 22 + 7e40: fe cf rjmp .-4 ; 0x7e3e + LED_PIN |= _BV(LED); + 7e42: 1d 9a sbi 0x03, 5 ; 3 + return getch(); +} + +// Watchdog functions. These are only safe with interrupts turned off. +void watchdogReset() { + __asm__ __volatile__ ( + 7e44: a8 95 wdr + TCNT1 = -(F_CPU/(1024*16)); + TIFR1 = _BV(TOV1); + while(!(TIFR1 & _BV(TOV1))); + LED_PIN |= _BV(LED); + watchdogReset(); + } while (--count); + 7e46: 81 50 subi r24, 0x01 ; 1 + 7e48: a9 f7 brne .-22 ; 0x7e34 + /* get character from UART */ + ch = getch(); + + if(ch == STK_GET_PARAMETER) { + // GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy + getNch(1); + 7e4a: dd 24 eor r13, r13 + 7e4c: d3 94 inc r13 + boot_page_fill((uint16_t)(void*)addrPtr,a); + addrPtr += 2; + } while (--ch); + + // Write from programming buffer + boot_page_write((uint16_t)(void*)address); + 7e4e: a5 e0 ldi r26, 0x05 ; 5 + 7e50: ea 2e mov r14, r26 + boot_spm_busy_wait(); + +#if defined(RWWSRE) + // Reenable read access to flash + boot_rww_enable(); + 7e52: f1 e1 ldi r31, 0x11 ; 17 + 7e54: ff 2e mov r15, r31 +#endif + + /* Forever loop */ + for (;;) { + /* get character from UART */ + ch = getch(); + 7e56: a4 d0 rcall .+328 ; 0x7fa0 + + if(ch == STK_GET_PARAMETER) { + 7e58: 81 34 cpi r24, 0x41 ; 65 + 7e5a: 21 f4 brne .+8 ; 0x7e64 + // GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy + getNch(1); + 7e5c: 81 e0 ldi r24, 0x01 ; 1 + 7e5e: be d0 rcall .+380 ; 0x7fdc + putch(0x03); + 7e60: 83 e0 ldi r24, 0x03 ; 3 + 7e62: 24 c0 rjmp .+72 ; 0x7eac + } + else if(ch == STK_SET_DEVICE) { + 7e64: 82 34 cpi r24, 0x42 ; 66 + 7e66: 11 f4 brne .+4 ; 0x7e6c + // SET DEVICE is ignored + getNch(20); + 7e68: 84 e1 ldi r24, 0x14 ; 20 + 7e6a: 03 c0 rjmp .+6 ; 0x7e72 + } + else if(ch == STK_SET_DEVICE_EXT) { + 7e6c: 85 34 cpi r24, 0x45 ; 69 + 7e6e: 19 f4 brne .+6 ; 0x7e76 + // SET DEVICE EXT is ignored + getNch(5); + 7e70: 85 e0 ldi r24, 0x05 ; 5 + 7e72: b4 d0 rcall .+360 ; 0x7fdc + 7e74: 8a c0 rjmp .+276 ; 0x7f8a + } + else if(ch == STK_LOAD_ADDRESS) { + 7e76: 85 35 cpi r24, 0x55 ; 85 + 7e78: a1 f4 brne .+40 ; 0x7ea2 + // LOAD ADDRESS + address = getch(); + 7e7a: 92 d0 rcall .+292 ; 0x7fa0 + 7e7c: 08 2f mov r16, r24 + 7e7e: 10 e0 ldi r17, 0x00 ; 0 + 7e80: 10 93 01 02 sts 0x0201, r17 + 7e84: 00 93 00 02 sts 0x0200, r16 + address = (address & 0xff) | (getch() << 8); + 7e88: 8b d0 rcall .+278 ; 0x7fa0 + 7e8a: 90 e0 ldi r25, 0x00 ; 0 + 7e8c: 98 2f mov r25, r24 + 7e8e: 88 27 eor r24, r24 + 7e90: 80 2b or r24, r16 + 7e92: 91 2b or r25, r17 + address += address; // Convert from word address to byte address + 7e94: 88 0f add r24, r24 + 7e96: 99 1f adc r25, r25 + 7e98: 90 93 01 02 sts 0x0201, r25 + 7e9c: 80 93 00 02 sts 0x0200, r24 + 7ea0: 73 c0 rjmp .+230 ; 0x7f88 + verifySpace(); + } + else if(ch == STK_UNIVERSAL) { + 7ea2: 86 35 cpi r24, 0x56 ; 86 + 7ea4: 29 f4 brne .+10 ; 0x7eb0 + // UNIVERSAL command is ignored + getNch(4); + 7ea6: 84 e0 ldi r24, 0x04 ; 4 + 7ea8: 99 d0 rcall .+306 ; 0x7fdc + putch(0x00); + 7eaa: 80 e0 ldi r24, 0x00 ; 0 + 7eac: 71 d0 rcall .+226 ; 0x7f90 + 7eae: 6d c0 rjmp .+218 ; 0x7f8a + } + /* Write memory, length is big endian and is in bytes */ + else if(ch == STK_PROG_PAGE) { + 7eb0: 84 36 cpi r24, 0x64 ; 100 + 7eb2: 09 f0 breq .+2 ; 0x7eb6 + 7eb4: 43 c0 rjmp .+134 ; 0x7f3c + // PROGRAM PAGE - we support flash programming only, not EEPROM + uint8_t *bufPtr; + uint16_t addrPtr; + + getLen(); + 7eb6: 7c d0 rcall .+248 ; 0x7fb0 + + // Immediately start page erase - this will 4.5ms + boot_page_erase((uint16_t)(void*)address); + 7eb8: e0 91 00 02 lds r30, 0x0200 + 7ebc: f0 91 01 02 lds r31, 0x0201 + 7ec0: 83 e0 ldi r24, 0x03 ; 3 + 7ec2: 80 93 57 00 sts 0x0057, r24 + 7ec6: e8 95 spm + 7ec8: c0 e0 ldi r28, 0x00 ; 0 + 7eca: d1 e0 ldi r29, 0x01 ; 1 + + // While that is going on, read in page contents + bufPtr = buff; + do *bufPtr++ = getch(); + 7ecc: 69 d0 rcall .+210 ; 0x7fa0 + 7ece: 89 93 st Y+, r24 + while (--length); + 7ed0: 80 91 02 02 lds r24, 0x0202 + 7ed4: 81 50 subi r24, 0x01 ; 1 + 7ed6: 80 93 02 02 sts 0x0202, r24 + 7eda: 88 23 and r24, r24 + 7edc: b9 f7 brne .-18 ; 0x7ecc + + // Read command terminator, start reply + verifySpace(); + 7ede: 78 d0 rcall .+240 ; 0x7fd0 + + // If only a partial page is to be programmed, the erase might not be complete. + // So check that here + boot_spm_busy_wait(); + 7ee0: 07 b6 in r0, 0x37 ; 55 + 7ee2: 00 fc sbrc r0, 0 + 7ee4: fd cf rjmp .-6 ; 0x7ee0 + } +#endif + + // Copy buffer into programming buffer + bufPtr = buff; + addrPtr = (uint16_t)(void*)address; + 7ee6: 40 91 00 02 lds r20, 0x0200 + 7eea: 50 91 01 02 lds r21, 0x0201 + 7eee: a0 e0 ldi r26, 0x00 ; 0 + 7ef0: b1 e0 ldi r27, 0x01 ; 1 + ch = SPM_PAGESIZE / 2; + do { + uint16_t a; + a = *bufPtr++; + 7ef2: 2c 91 ld r18, X + 7ef4: 30 e0 ldi r19, 0x00 ; 0 + a |= (*bufPtr++) << 8; + 7ef6: 11 96 adiw r26, 0x01 ; 1 + 7ef8: 8c 91 ld r24, X + 7efa: 11 97 sbiw r26, 0x01 ; 1 + 7efc: 90 e0 ldi r25, 0x00 ; 0 + 7efe: 98 2f mov r25, r24 + 7f00: 88 27 eor r24, r24 + 7f02: 82 2b or r24, r18 + 7f04: 93 2b or r25, r19 +#ifdef VIRTUAL_BOOT_PARTITION +#define rstVect (*(uint16_t*)(0x204)) +#define wdtVect (*(uint16_t*)(0x206)) +#endif +/* main program starts here */ +int main(void) { + 7f06: 12 96 adiw r26, 0x02 ; 2 + ch = SPM_PAGESIZE / 2; + do { + uint16_t a; + a = *bufPtr++; + a |= (*bufPtr++) << 8; + boot_page_fill((uint16_t)(void*)addrPtr,a); + 7f08: fa 01 movw r30, r20 + 7f0a: 0c 01 movw r0, r24 + 7f0c: d0 92 57 00 sts 0x0057, r13 + 7f10: e8 95 spm + 7f12: 11 24 eor r1, r1 + addrPtr += 2; + 7f14: 4e 5f subi r20, 0xFE ; 254 + 7f16: 5f 4f sbci r21, 0xFF ; 255 + } while (--ch); + 7f18: f1 e0 ldi r31, 0x01 ; 1 + 7f1a: a0 38 cpi r26, 0x80 ; 128 + 7f1c: bf 07 cpc r27, r31 + 7f1e: 49 f7 brne .-46 ; 0x7ef2 + + // Write from programming buffer + boot_page_write((uint16_t)(void*)address); + 7f20: e0 91 00 02 lds r30, 0x0200 + 7f24: f0 91 01 02 lds r31, 0x0201 + 7f28: e0 92 57 00 sts 0x0057, r14 + 7f2c: e8 95 spm + boot_spm_busy_wait(); + 7f2e: 07 b6 in r0, 0x37 ; 55 + 7f30: 00 fc sbrc r0, 0 + 7f32: fd cf rjmp .-6 ; 0x7f2e + +#if defined(RWWSRE) + // Reenable read access to flash + boot_rww_enable(); + 7f34: f0 92 57 00 sts 0x0057, r15 + 7f38: e8 95 spm + 7f3a: 27 c0 rjmp .+78 ; 0x7f8a +#endif + + } + /* Read memory block mode, length is big endian. */ + else if(ch == STK_READ_PAGE) { + 7f3c: 84 37 cpi r24, 0x74 ; 116 + 7f3e: b9 f4 brne .+46 ; 0x7f6e + // READ PAGE - we only read flash + getLen(); + 7f40: 37 d0 rcall .+110 ; 0x7fb0 + verifySpace(); + 7f42: 46 d0 rcall .+140 ; 0x7fd0 + else ch = pgm_read_byte_near(address); + address++; + putch(ch); + } while (--length); +#else + do putch(pgm_read_byte_near(address++)); + 7f44: e0 91 00 02 lds r30, 0x0200 + 7f48: f0 91 01 02 lds r31, 0x0201 + 7f4c: 31 96 adiw r30, 0x01 ; 1 + 7f4e: f0 93 01 02 sts 0x0201, r31 + 7f52: e0 93 00 02 sts 0x0200, r30 + 7f56: 31 97 sbiw r30, 0x01 ; 1 + 7f58: e4 91 lpm r30, Z+ + 7f5a: 8e 2f mov r24, r30 + 7f5c: 19 d0 rcall .+50 ; 0x7f90 + while (--length); + 7f5e: 80 91 02 02 lds r24, 0x0202 + 7f62: 81 50 subi r24, 0x01 ; 1 + 7f64: 80 93 02 02 sts 0x0202, r24 + 7f68: 88 23 and r24, r24 + 7f6a: 61 f7 brne .-40 ; 0x7f44 + 7f6c: 0e c0 rjmp .+28 ; 0x7f8a +#endif + } + + /* Get device signature bytes */ + else if(ch == STK_READ_SIGN) { + 7f6e: 85 37 cpi r24, 0x75 ; 117 + 7f70: 39 f4 brne .+14 ; 0x7f80 + // READ SIGN - return what Avrdude wants to hear + verifySpace(); + 7f72: 2e d0 rcall .+92 ; 0x7fd0 + putch(SIGNATURE_0); + 7f74: 8e e1 ldi r24, 0x1E ; 30 + 7f76: 0c d0 rcall .+24 ; 0x7f90 + putch(SIGNATURE_1); + 7f78: 85 e9 ldi r24, 0x95 ; 149 + 7f7a: 0a d0 rcall .+20 ; 0x7f90 + putch(SIGNATURE_2); + 7f7c: 8f e0 ldi r24, 0x0F ; 15 + 7f7e: 96 cf rjmp .-212 ; 0x7eac + } + else if (ch == 'Q') { + 7f80: 81 35 cpi r24, 0x51 ; 81 + 7f82: 11 f4 brne .+4 ; 0x7f88 + // Adaboot no-wait mod + watchdogConfig(WATCHDOG_16MS); + 7f84: 88 e0 ldi r24, 0x08 ; 8 + 7f86: 19 d0 rcall .+50 ; 0x7fba + verifySpace(); + } + else { + // This covers the response to commands like STK_ENTER_PROGMODE + verifySpace(); + 7f88: 23 d0 rcall .+70 ; 0x7fd0 + } + putch(STK_OK); + 7f8a: 80 e1 ldi r24, 0x10 ; 16 + 7f8c: 01 d0 rcall .+2 ; 0x7f90 + 7f8e: 63 cf rjmp .-314 ; 0x7e56 + +00007f90 : + } +} + +void putch(char ch) { + 7f90: 98 2f mov r25, r24 +#ifndef SOFT_UART + while (!(UCSR0A & _BV(UDRE0))); + 7f92: 80 91 c0 00 lds r24, 0x00C0 + 7f96: 85 ff sbrs r24, 5 + 7f98: fc cf rjmp .-8 ; 0x7f92 + UDR0 = ch; + 7f9a: 90 93 c6 00 sts 0x00C6, r25 + [uartBit] "I" (UART_TX_BIT) + : + "r25" + ); +#endif +} + 7f9e: 08 95 ret + +00007fa0 : + return getch(); +} + +// Watchdog functions. These are only safe with interrupts turned off. +void watchdogReset() { + __asm__ __volatile__ ( + 7fa0: a8 95 wdr + [uartBit] "I" (UART_RX_BIT) + : + "r25" +); +#else + while(!(UCSR0A & _BV(RXC0))); + 7fa2: 80 91 c0 00 lds r24, 0x00C0 + 7fa6: 87 ff sbrs r24, 7 + 7fa8: fc cf rjmp .-8 ; 0x7fa2 + ch = UDR0; + 7faa: 80 91 c6 00 lds r24, 0x00C6 +#ifdef LED_DATA_FLASH + LED_PIN |= _BV(LED); +#endif + + return ch; +} + 7fae: 08 95 ret + +00007fb0 : + } while (--count); +} +#endif + +uint8_t getLen() { + getch(); + 7fb0: f7 df rcall .-18 ; 0x7fa0 + length = getch(); + 7fb2: f6 df rcall .-20 ; 0x7fa0 + 7fb4: 80 93 02 02 sts 0x0202, r24 + return getch(); +} + 7fb8: f3 cf rjmp .-26 ; 0x7fa0 + +00007fba : + "wdr\n" + ); +} + +void watchdogConfig(uint8_t x) { + WDTCSR = _BV(WDCE) | _BV(WDE); + 7fba: e0 e6 ldi r30, 0x60 ; 96 + 7fbc: f0 e0 ldi r31, 0x00 ; 0 + 7fbe: 98 e1 ldi r25, 0x18 ; 24 + 7fc0: 90 83 st Z, r25 + WDTCSR = x; + 7fc2: 80 83 st Z, r24 +} + 7fc4: 08 95 ret + +00007fc6 : + +void appStart() { + watchdogConfig(WATCHDOG_OFF); + 7fc6: 80 e0 ldi r24, 0x00 ; 0 + 7fc8: f8 df rcall .-16 ; 0x7fba + __asm__ __volatile__ ( + 7fca: ee 27 eor r30, r30 + 7fcc: ff 27 eor r31, r31 + 7fce: 09 94 ijmp + +00007fd0 : + do getch(); while (--count); + verifySpace(); +} + +void verifySpace() { + if (getch() != CRC_EOP) appStart(); + 7fd0: e7 df rcall .-50 ; 0x7fa0 + 7fd2: 80 32 cpi r24, 0x20 ; 32 + 7fd4: 09 f0 breq .+2 ; 0x7fd8 + 7fd6: f7 df rcall .-18 ; 0x7fc6 + putch(STK_INSYNC); + 7fd8: 84 e1 ldi r24, 0x14 ; 20 +} + 7fda: da cf rjmp .-76 ; 0x7f90 + ::[count] "M" (UART_B_VALUE) + ); +} +#endif + +void getNch(uint8_t count) { + 7fdc: 1f 93 push r17 + 7fde: 18 2f mov r17, r24 + +00007fe0 : + do getch(); while (--count); + 7fe0: df df rcall .-66 ; 0x7fa0 + 7fe2: 11 50 subi r17, 0x01 ; 1 + 7fe4: e9 f7 brne .-6 ; 0x7fe0 + verifySpace(); + 7fe6: f4 df rcall .-24 ; 0x7fd0 +} + 7fe8: 1f 91 pop r17 + 7fea: 08 95 ret diff --git a/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_diecimila.hex b/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_diecimila.hex new file mode 100644 index 0000000..1e93414 --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_diecimila.hex @@ -0,0 +1,33 @@ +:103E000085E08093810082E08093C00088E1809308 +:103E1000C10086E08093C20080E18093C40084B733 +:103E200014BE81FFD0D08DE0C8D0259A86E020E373 +:103E30003CEF91E0309385002093840096BBB09BCB +:103E4000FECF1D9AA8958150A9F7DD24D394A5E053 +:103E5000EA2EF1E1FF2EA4D0813421F481E0BED01E +:103E600083E024C0823411F484E103C0853419F462 +:103E700085E0B4D08AC08535A1F492D0082F10E037 +:103E800010930102009300028BD090E0982F8827B6 +:103E9000802B912B880F991F909301028093000231 +:103EA00073C0863529F484E099D080E071D06DC06C +:103EB000843609F043C07CD0E0910002F091010209 +:103EC00083E080935700E895C0E0D1E069D0899302 +:103ED000809102028150809302028823B9F778D042 +:103EE00007B600FCFDCF4091000250910102A0E016 +:103EF000B1E02C9130E011968C91119790E0982FC1 +:103F00008827822B932B1296FA010C01D09257002E +:103F1000E89511244E5F5F4FF1E0A038BF0749F7E5 +:103F2000E0910002F0910102E0925700E89507B697 +:103F300000FCFDCFF0925700E89527C08437B9F414 +:103F400037D046D0E0910002F09101023196F09313 +:103F50000102E09300023197E4918E2F19D08091F5 +:103F60000202815080930202882361F70EC08537D8 +:103F700039F42ED08EE10CD084E90AD086E096CFB9 +:103F8000813511F488E019D023D080E101D063CFCE +:103F9000982F8091C00085FFFCCF9093C6000895B4 +:103FA000A8958091C00087FFFCCF8091C60008953E +:103FB000F7DFF6DF80930202F3CFE0E6F0E098E16E +:103FC00090838083089580E0F8DFEE27FF2709942F +:103FD000E7DF803209F0F7DF84E1DACF1F93182F93 +:0C3FE000DFDF1150E9F7F4DF1F910895B6 +:0400000300003E00BB +:00000001FF diff --git a/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_diecimila.lst b/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_diecimila.lst new file mode 100644 index 0000000..1121893 --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_diecimila.lst @@ -0,0 +1,520 @@ + +optiboot_diecimila.elf: file format elf32-avr + +Sections: +Idx Name Size VMA LMA File off Algn + 0 .text 000001ec 00003e00 00003e00 00000054 2**1 + CONTENTS, ALLOC, LOAD, READONLY, CODE + 1 .debug_aranges 00000028 00000000 00000000 00000240 2**0 + CONTENTS, READONLY, DEBUGGING + 2 .debug_pubnames 0000006a 00000000 00000000 00000268 2**0 + CONTENTS, READONLY, DEBUGGING + 3 .debug_info 00000269 00000000 00000000 000002d2 2**0 + CONTENTS, READONLY, DEBUGGING + 4 .debug_abbrev 00000196 00000000 00000000 0000053b 2**0 + CONTENTS, READONLY, DEBUGGING + 5 .debug_line 000003d3 00000000 00000000 000006d1 2**0 + CONTENTS, READONLY, DEBUGGING + 6 .debug_frame 00000090 00000000 00000000 00000aa4 2**2 + CONTENTS, READONLY, DEBUGGING + 7 .debug_str 00000135 00000000 00000000 00000b34 2**0 + CONTENTS, READONLY, DEBUGGING + 8 .debug_loc 000001d1 00000000 00000000 00000c69 2**0 + CONTENTS, READONLY, DEBUGGING + 9 .debug_ranges 00000068 00000000 00000000 00000e3a 2**0 + CONTENTS, READONLY, DEBUGGING + +Disassembly of section .text: + +00003e00
    : +#ifdef VIRTUAL_BOOT_PARTITION +#define rstVect (*(uint16_t*)(0x204)) +#define wdtVect (*(uint16_t*)(0x206)) +#endif +/* main program starts here */ +int main(void) { + 3e00: 85 e0 ldi r24, 0x05 ; 5 + 3e02: 80 93 81 00 sts 0x0081, r24 +#if LED_START_FLASHES > 0 + // Set up Timer 1 for timeout counter + TCCR1B = _BV(CS12) | _BV(CS10); // div 1024 +#endif +#ifndef SOFT_UART + UCSR0A = _BV(U2X0); //Double speed mode USART0 + 3e06: 82 e0 ldi r24, 0x02 ; 2 + 3e08: 80 93 c0 00 sts 0x00C0, r24 + UCSR0B = _BV(RXEN0) | _BV(TXEN0); + 3e0c: 88 e1 ldi r24, 0x18 ; 24 + 3e0e: 80 93 c1 00 sts 0x00C1, r24 + UCSR0C = _BV(UCSZ00) | _BV(UCSZ01); + 3e12: 86 e0 ldi r24, 0x06 ; 6 + 3e14: 80 93 c2 00 sts 0x00C2, r24 + UBRR0L = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 ); + 3e18: 80 e1 ldi r24, 0x10 ; 16 + 3e1a: 80 93 c4 00 sts 0x00C4, r24 +#endif + + // Adaboot no-wait mod + ch = MCUSR; + 3e1e: 84 b7 in r24, 0x34 ; 52 + MCUSR = 0; + 3e20: 14 be out 0x34, r1 ; 52 + if (!(ch & _BV(EXTRF))) appStart(); + 3e22: 81 ff sbrs r24, 1 + 3e24: d0 d0 rcall .+416 ; 0x3fc6 + + // Set up watchdog to trigger after 500ms + watchdogConfig(WATCHDOG_500MS); + 3e26: 8d e0 ldi r24, 0x0D ; 13 + 3e28: c8 d0 rcall .+400 ; 0x3fba + + /* Set LED pin as output */ + LED_DDR |= _BV(LED); + 3e2a: 25 9a sbi 0x04, 5 ; 4 + 3e2c: 86 e0 ldi r24, 0x06 ; 6 +} + +#if LED_START_FLASHES > 0 +void flash_led(uint8_t count) { + do { + TCNT1 = -(F_CPU/(1024*16)); + 3e2e: 20 e3 ldi r18, 0x30 ; 48 + 3e30: 3c ef ldi r19, 0xFC ; 252 + TIFR1 = _BV(TOV1); + 3e32: 91 e0 ldi r25, 0x01 ; 1 +} + +#if LED_START_FLASHES > 0 +void flash_led(uint8_t count) { + do { + TCNT1 = -(F_CPU/(1024*16)); + 3e34: 30 93 85 00 sts 0x0085, r19 + 3e38: 20 93 84 00 sts 0x0084, r18 + TIFR1 = _BV(TOV1); + 3e3c: 96 bb out 0x16, r25 ; 22 + while(!(TIFR1 & _BV(TOV1))); + 3e3e: b0 9b sbis 0x16, 0 ; 22 + 3e40: fe cf rjmp .-4 ; 0x3e3e + LED_PIN |= _BV(LED); + 3e42: 1d 9a sbi 0x03, 5 ; 3 + return getch(); +} + +// Watchdog functions. These are only safe with interrupts turned off. +void watchdogReset() { + __asm__ __volatile__ ( + 3e44: a8 95 wdr + TCNT1 = -(F_CPU/(1024*16)); + TIFR1 = _BV(TOV1); + while(!(TIFR1 & _BV(TOV1))); + LED_PIN |= _BV(LED); + watchdogReset(); + } while (--count); + 3e46: 81 50 subi r24, 0x01 ; 1 + 3e48: a9 f7 brne .-22 ; 0x3e34 + /* get character from UART */ + ch = getch(); + + if(ch == STK_GET_PARAMETER) { + // GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy + getNch(1); + 3e4a: dd 24 eor r13, r13 + 3e4c: d3 94 inc r13 + boot_page_fill((uint16_t)(void*)addrPtr,a); + addrPtr += 2; + } while (--ch); + + // Write from programming buffer + boot_page_write((uint16_t)(void*)address); + 3e4e: a5 e0 ldi r26, 0x05 ; 5 + 3e50: ea 2e mov r14, r26 + boot_spm_busy_wait(); + +#if defined(RWWSRE) + // Reenable read access to flash + boot_rww_enable(); + 3e52: f1 e1 ldi r31, 0x11 ; 17 + 3e54: ff 2e mov r15, r31 +#endif + + /* Forever loop */ + for (;;) { + /* get character from UART */ + ch = getch(); + 3e56: a4 d0 rcall .+328 ; 0x3fa0 + + if(ch == STK_GET_PARAMETER) { + 3e58: 81 34 cpi r24, 0x41 ; 65 + 3e5a: 21 f4 brne .+8 ; 0x3e64 + // GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy + getNch(1); + 3e5c: 81 e0 ldi r24, 0x01 ; 1 + 3e5e: be d0 rcall .+380 ; 0x3fdc + putch(0x03); + 3e60: 83 e0 ldi r24, 0x03 ; 3 + 3e62: 24 c0 rjmp .+72 ; 0x3eac + } + else if(ch == STK_SET_DEVICE) { + 3e64: 82 34 cpi r24, 0x42 ; 66 + 3e66: 11 f4 brne .+4 ; 0x3e6c + // SET DEVICE is ignored + getNch(20); + 3e68: 84 e1 ldi r24, 0x14 ; 20 + 3e6a: 03 c0 rjmp .+6 ; 0x3e72 + } + else if(ch == STK_SET_DEVICE_EXT) { + 3e6c: 85 34 cpi r24, 0x45 ; 69 + 3e6e: 19 f4 brne .+6 ; 0x3e76 + // SET DEVICE EXT is ignored + getNch(5); + 3e70: 85 e0 ldi r24, 0x05 ; 5 + 3e72: b4 d0 rcall .+360 ; 0x3fdc + 3e74: 8a c0 rjmp .+276 ; 0x3f8a + } + else if(ch == STK_LOAD_ADDRESS) { + 3e76: 85 35 cpi r24, 0x55 ; 85 + 3e78: a1 f4 brne .+40 ; 0x3ea2 + // LOAD ADDRESS + address = getch(); + 3e7a: 92 d0 rcall .+292 ; 0x3fa0 + 3e7c: 08 2f mov r16, r24 + 3e7e: 10 e0 ldi r17, 0x00 ; 0 + 3e80: 10 93 01 02 sts 0x0201, r17 + 3e84: 00 93 00 02 sts 0x0200, r16 + address = (address & 0xff) | (getch() << 8); + 3e88: 8b d0 rcall .+278 ; 0x3fa0 + 3e8a: 90 e0 ldi r25, 0x00 ; 0 + 3e8c: 98 2f mov r25, r24 + 3e8e: 88 27 eor r24, r24 + 3e90: 80 2b or r24, r16 + 3e92: 91 2b or r25, r17 + address += address; // Convert from word address to byte address + 3e94: 88 0f add r24, r24 + 3e96: 99 1f adc r25, r25 + 3e98: 90 93 01 02 sts 0x0201, r25 + 3e9c: 80 93 00 02 sts 0x0200, r24 + 3ea0: 73 c0 rjmp .+230 ; 0x3f88 + verifySpace(); + } + else if(ch == STK_UNIVERSAL) { + 3ea2: 86 35 cpi r24, 0x56 ; 86 + 3ea4: 29 f4 brne .+10 ; 0x3eb0 + // UNIVERSAL command is ignored + getNch(4); + 3ea6: 84 e0 ldi r24, 0x04 ; 4 + 3ea8: 99 d0 rcall .+306 ; 0x3fdc + putch(0x00); + 3eaa: 80 e0 ldi r24, 0x00 ; 0 + 3eac: 71 d0 rcall .+226 ; 0x3f90 + 3eae: 6d c0 rjmp .+218 ; 0x3f8a + } + /* Write memory, length is big endian and is in bytes */ + else if(ch == STK_PROG_PAGE) { + 3eb0: 84 36 cpi r24, 0x64 ; 100 + 3eb2: 09 f0 breq .+2 ; 0x3eb6 + 3eb4: 43 c0 rjmp .+134 ; 0x3f3c + // PROGRAM PAGE - we support flash programming only, not EEPROM + uint8_t *bufPtr; + uint16_t addrPtr; + + getLen(); + 3eb6: 7c d0 rcall .+248 ; 0x3fb0 + + // Immediately start page erase - this will 4.5ms + boot_page_erase((uint16_t)(void*)address); + 3eb8: e0 91 00 02 lds r30, 0x0200 + 3ebc: f0 91 01 02 lds r31, 0x0201 + 3ec0: 83 e0 ldi r24, 0x03 ; 3 + 3ec2: 80 93 57 00 sts 0x0057, r24 + 3ec6: e8 95 spm + 3ec8: c0 e0 ldi r28, 0x00 ; 0 + 3eca: d1 e0 ldi r29, 0x01 ; 1 + + // While that is going on, read in page contents + bufPtr = buff; + do *bufPtr++ = getch(); + 3ecc: 69 d0 rcall .+210 ; 0x3fa0 + 3ece: 89 93 st Y+, r24 + while (--length); + 3ed0: 80 91 02 02 lds r24, 0x0202 + 3ed4: 81 50 subi r24, 0x01 ; 1 + 3ed6: 80 93 02 02 sts 0x0202, r24 + 3eda: 88 23 and r24, r24 + 3edc: b9 f7 brne .-18 ; 0x3ecc + + // Read command terminator, start reply + verifySpace(); + 3ede: 78 d0 rcall .+240 ; 0x3fd0 + + // If only a partial page is to be programmed, the erase might not be complete. + // So check that here + boot_spm_busy_wait(); + 3ee0: 07 b6 in r0, 0x37 ; 55 + 3ee2: 00 fc sbrc r0, 0 + 3ee4: fd cf rjmp .-6 ; 0x3ee0 + } +#endif + + // Copy buffer into programming buffer + bufPtr = buff; + addrPtr = (uint16_t)(void*)address; + 3ee6: 40 91 00 02 lds r20, 0x0200 + 3eea: 50 91 01 02 lds r21, 0x0201 + 3eee: a0 e0 ldi r26, 0x00 ; 0 + 3ef0: b1 e0 ldi r27, 0x01 ; 1 + ch = SPM_PAGESIZE / 2; + do { + uint16_t a; + a = *bufPtr++; + 3ef2: 2c 91 ld r18, X + 3ef4: 30 e0 ldi r19, 0x00 ; 0 + a |= (*bufPtr++) << 8; + 3ef6: 11 96 adiw r26, 0x01 ; 1 + 3ef8: 8c 91 ld r24, X + 3efa: 11 97 sbiw r26, 0x01 ; 1 + 3efc: 90 e0 ldi r25, 0x00 ; 0 + 3efe: 98 2f mov r25, r24 + 3f00: 88 27 eor r24, r24 + 3f02: 82 2b or r24, r18 + 3f04: 93 2b or r25, r19 +#ifdef VIRTUAL_BOOT_PARTITION +#define rstVect (*(uint16_t*)(0x204)) +#define wdtVect (*(uint16_t*)(0x206)) +#endif +/* main program starts here */ +int main(void) { + 3f06: 12 96 adiw r26, 0x02 ; 2 + ch = SPM_PAGESIZE / 2; + do { + uint16_t a; + a = *bufPtr++; + a |= (*bufPtr++) << 8; + boot_page_fill((uint16_t)(void*)addrPtr,a); + 3f08: fa 01 movw r30, r20 + 3f0a: 0c 01 movw r0, r24 + 3f0c: d0 92 57 00 sts 0x0057, r13 + 3f10: e8 95 spm + 3f12: 11 24 eor r1, r1 + addrPtr += 2; + 3f14: 4e 5f subi r20, 0xFE ; 254 + 3f16: 5f 4f sbci r21, 0xFF ; 255 + } while (--ch); + 3f18: f1 e0 ldi r31, 0x01 ; 1 + 3f1a: a0 38 cpi r26, 0x80 ; 128 + 3f1c: bf 07 cpc r27, r31 + 3f1e: 49 f7 brne .-46 ; 0x3ef2 + + // Write from programming buffer + boot_page_write((uint16_t)(void*)address); + 3f20: e0 91 00 02 lds r30, 0x0200 + 3f24: f0 91 01 02 lds r31, 0x0201 + 3f28: e0 92 57 00 sts 0x0057, r14 + 3f2c: e8 95 spm + boot_spm_busy_wait(); + 3f2e: 07 b6 in r0, 0x37 ; 55 + 3f30: 00 fc sbrc r0, 0 + 3f32: fd cf rjmp .-6 ; 0x3f2e + +#if defined(RWWSRE) + // Reenable read access to flash + boot_rww_enable(); + 3f34: f0 92 57 00 sts 0x0057, r15 + 3f38: e8 95 spm + 3f3a: 27 c0 rjmp .+78 ; 0x3f8a +#endif + + } + /* Read memory block mode, length is big endian. */ + else if(ch == STK_READ_PAGE) { + 3f3c: 84 37 cpi r24, 0x74 ; 116 + 3f3e: b9 f4 brne .+46 ; 0x3f6e + // READ PAGE - we only read flash + getLen(); + 3f40: 37 d0 rcall .+110 ; 0x3fb0 + verifySpace(); + 3f42: 46 d0 rcall .+140 ; 0x3fd0 + else ch = pgm_read_byte_near(address); + address++; + putch(ch); + } while (--length); +#else + do putch(pgm_read_byte_near(address++)); + 3f44: e0 91 00 02 lds r30, 0x0200 + 3f48: f0 91 01 02 lds r31, 0x0201 + 3f4c: 31 96 adiw r30, 0x01 ; 1 + 3f4e: f0 93 01 02 sts 0x0201, r31 + 3f52: e0 93 00 02 sts 0x0200, r30 + 3f56: 31 97 sbiw r30, 0x01 ; 1 + 3f58: e4 91 lpm r30, Z+ + 3f5a: 8e 2f mov r24, r30 + 3f5c: 19 d0 rcall .+50 ; 0x3f90 + while (--length); + 3f5e: 80 91 02 02 lds r24, 0x0202 + 3f62: 81 50 subi r24, 0x01 ; 1 + 3f64: 80 93 02 02 sts 0x0202, r24 + 3f68: 88 23 and r24, r24 + 3f6a: 61 f7 brne .-40 ; 0x3f44 + 3f6c: 0e c0 rjmp .+28 ; 0x3f8a +#endif + } + + /* Get device signature bytes */ + else if(ch == STK_READ_SIGN) { + 3f6e: 85 37 cpi r24, 0x75 ; 117 + 3f70: 39 f4 brne .+14 ; 0x3f80 + // READ SIGN - return what Avrdude wants to hear + verifySpace(); + 3f72: 2e d0 rcall .+92 ; 0x3fd0 + putch(SIGNATURE_0); + 3f74: 8e e1 ldi r24, 0x1E ; 30 + 3f76: 0c d0 rcall .+24 ; 0x3f90 + putch(SIGNATURE_1); + 3f78: 84 e9 ldi r24, 0x94 ; 148 + 3f7a: 0a d0 rcall .+20 ; 0x3f90 + putch(SIGNATURE_2); + 3f7c: 86 e0 ldi r24, 0x06 ; 6 + 3f7e: 96 cf rjmp .-212 ; 0x3eac + } + else if (ch == 'Q') { + 3f80: 81 35 cpi r24, 0x51 ; 81 + 3f82: 11 f4 brne .+4 ; 0x3f88 + // Adaboot no-wait mod + watchdogConfig(WATCHDOG_16MS); + 3f84: 88 e0 ldi r24, 0x08 ; 8 + 3f86: 19 d0 rcall .+50 ; 0x3fba + verifySpace(); + } + else { + // This covers the response to commands like STK_ENTER_PROGMODE + verifySpace(); + 3f88: 23 d0 rcall .+70 ; 0x3fd0 + } + putch(STK_OK); + 3f8a: 80 e1 ldi r24, 0x10 ; 16 + 3f8c: 01 d0 rcall .+2 ; 0x3f90 + 3f8e: 63 cf rjmp .-314 ; 0x3e56 + +00003f90 : + } +} + +void putch(char ch) { + 3f90: 98 2f mov r25, r24 +#ifndef SOFT_UART + while (!(UCSR0A & _BV(UDRE0))); + 3f92: 80 91 c0 00 lds r24, 0x00C0 + 3f96: 85 ff sbrs r24, 5 + 3f98: fc cf rjmp .-8 ; 0x3f92 + UDR0 = ch; + 3f9a: 90 93 c6 00 sts 0x00C6, r25 + [uartBit] "I" (UART_TX_BIT) + : + "r25" + ); +#endif +} + 3f9e: 08 95 ret + +00003fa0 : + return getch(); +} + +// Watchdog functions. These are only safe with interrupts turned off. +void watchdogReset() { + __asm__ __volatile__ ( + 3fa0: a8 95 wdr + [uartBit] "I" (UART_RX_BIT) + : + "r25" +); +#else + while(!(UCSR0A & _BV(RXC0))); + 3fa2: 80 91 c0 00 lds r24, 0x00C0 + 3fa6: 87 ff sbrs r24, 7 + 3fa8: fc cf rjmp .-8 ; 0x3fa2 + ch = UDR0; + 3faa: 80 91 c6 00 lds r24, 0x00C6 +#ifdef LED_DATA_FLASH + LED_PIN |= _BV(LED); +#endif + + return ch; +} + 3fae: 08 95 ret + +00003fb0 : + } while (--count); +} +#endif + +uint8_t getLen() { + getch(); + 3fb0: f7 df rcall .-18 ; 0x3fa0 + length = getch(); + 3fb2: f6 df rcall .-20 ; 0x3fa0 + 3fb4: 80 93 02 02 sts 0x0202, r24 + return getch(); +} + 3fb8: f3 cf rjmp .-26 ; 0x3fa0 + +00003fba : + "wdr\n" + ); +} + +void watchdogConfig(uint8_t x) { + WDTCSR = _BV(WDCE) | _BV(WDE); + 3fba: e0 e6 ldi r30, 0x60 ; 96 + 3fbc: f0 e0 ldi r31, 0x00 ; 0 + 3fbe: 98 e1 ldi r25, 0x18 ; 24 + 3fc0: 90 83 st Z, r25 + WDTCSR = x; + 3fc2: 80 83 st Z, r24 +} + 3fc4: 08 95 ret + +00003fc6 : + +void appStart() { + watchdogConfig(WATCHDOG_OFF); + 3fc6: 80 e0 ldi r24, 0x00 ; 0 + 3fc8: f8 df rcall .-16 ; 0x3fba + __asm__ __volatile__ ( + 3fca: ee 27 eor r30, r30 + 3fcc: ff 27 eor r31, r31 + 3fce: 09 94 ijmp + +00003fd0 : + do getch(); while (--count); + verifySpace(); +} + +void verifySpace() { + if (getch() != CRC_EOP) appStart(); + 3fd0: e7 df rcall .-50 ; 0x3fa0 + 3fd2: 80 32 cpi r24, 0x20 ; 32 + 3fd4: 09 f0 breq .+2 ; 0x3fd8 + 3fd6: f7 df rcall .-18 ; 0x3fc6 + putch(STK_INSYNC); + 3fd8: 84 e1 ldi r24, 0x14 ; 20 +} + 3fda: da cf rjmp .-76 ; 0x3f90 + ::[count] "M" (UART_B_VALUE) + ); +} +#endif + +void getNch(uint8_t count) { + 3fdc: 1f 93 push r17 + 3fde: 18 2f mov r17, r24 + +00003fe0 : + do getch(); while (--count); + 3fe0: df df rcall .-66 ; 0x3fa0 + 3fe2: 11 50 subi r17, 0x01 ; 1 + 3fe4: e9 f7 brne .-6 ; 0x3fe0 + verifySpace(); + 3fe6: f4 df rcall .-24 ; 0x3fd0 +} + 3fe8: 1f 91 pop r17 + 3fea: 08 95 ret diff --git a/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_lilypad.hex b/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_lilypad.hex new file mode 100644 index 0000000..9d31a7a --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_lilypad.hex @@ -0,0 +1,34 @@ +:103E000085E08093810084B714BE81FFE4D08DE00B +:103E1000DCD0259A519A86E028E13EEF91E030937C +:103E200085002093840096BBB09BFECF1D9AA89579 +:103E30008150A9F7DD24D394A5E0EA2EF1E1FF2E0D +:103E4000ABD0813421F481E0D1D083E024C082342E +:103E500011F484E103C0853419F485E0C7D08AC029 +:103E60008535A1F499D0082F10E01093010200933A +:103E7000000292D090E0982F8827802B912B880FFA +:103E8000991F909301028093000273C0863529F434 +:103E900084E0ACD080E071D06DC0843609F043C0BE +:103EA0008FD0E0910002F091010283E080935700EF +:103EB000E895C0E0D1E070D08993809102028150F2 +:103EC000809302028823B9F78BD007B600FCFDCFA0 +:103ED0004091000250910102A0E0B1E02C9130E04D +:103EE00011968C91119790E0982F8827822B932B15 +:103EF0001296FA010C01D0925700E89511244E5FFA +:103F00005F4FF1E0A038BF0749F7E0910002F09160 +:103F10000102E0925700E89507B600FCFDCFF09251 +:103F20005700E89527C08437B9F44AD059D0E091BA +:103F30000002F09101023196F0930102E093000239 +:103F40003197E4918E2F19D0809102028150809395 +:103F50000202882361F70EC0853739F441D08EE123 +:103F60000CD084E90AD086E096CF813511F488E040 +:103F70002CD036D080E101D063CF2AE030E08095AC +:103F8000089410F4599802C0599A000015D014D022 +:103F900086952A95B1F70895A89529E030E04899CB +:103FA000FECF0AD009D008D08894489908942A9561 +:103FB00011F08795F7CF089598E09A95F1F7089555 +:103FC000EBDFEADF80930202E7CFE0E6F0E098E182 +:103FD00090838083089580E0F8DFEE27FF2709941F +:103FE000DBDF803209F0F7DF84E1C7CF1F93182FA2 +:0C3FF000D3DF1150E9F7F4DF1F910895B2 +:0400000300003E00BB +:00000001FF diff --git a/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_lilypad.lst b/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_lilypad.lst new file mode 100644 index 0000000..0e46bd1 --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_lilypad.lst @@ -0,0 +1,533 @@ + +optiboot_lilypad.elf: file format elf32-avr + +Sections: +Idx Name Size VMA LMA File off Algn + 0 .text 000001fc 00003e00 00003e00 00000054 2**1 + CONTENTS, ALLOC, LOAD, READONLY, CODE + 1 .debug_aranges 00000028 00000000 00000000 00000250 2**0 + CONTENTS, READONLY, DEBUGGING + 2 .debug_pubnames 00000078 00000000 00000000 00000278 2**0 + CONTENTS, READONLY, DEBUGGING + 3 .debug_info 00000277 00000000 00000000 000002f0 2**0 + CONTENTS, READONLY, DEBUGGING + 4 .debug_abbrev 00000194 00000000 00000000 00000567 2**0 + CONTENTS, READONLY, DEBUGGING + 5 .debug_line 000003bb 00000000 00000000 000006fb 2**0 + CONTENTS, READONLY, DEBUGGING + 6 .debug_frame 000000a0 00000000 00000000 00000ab8 2**2 + CONTENTS, READONLY, DEBUGGING + 7 .debug_str 0000013f 00000000 00000000 00000b58 2**0 + CONTENTS, READONLY, DEBUGGING + 8 .debug_loc 000001a0 00000000 00000000 00000c97 2**0 + CONTENTS, READONLY, DEBUGGING + 9 .debug_ranges 00000070 00000000 00000000 00000e37 2**0 + CONTENTS, READONLY, DEBUGGING + +Disassembly of section .text: + +00003e00
    : +#ifdef VIRTUAL_BOOT_PARTITION +#define rstVect (*(uint16_t*)(0x204)) +#define wdtVect (*(uint16_t*)(0x206)) +#endif +/* main program starts here */ +int main(void) { + 3e00: 85 e0 ldi r24, 0x05 ; 5 + 3e02: 80 93 81 00 sts 0x0081, r24 + UCSR0C = _BV(UCSZ00) | _BV(UCSZ01); + UBRR0L = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 ); +#endif + + // Adaboot no-wait mod + ch = MCUSR; + 3e06: 84 b7 in r24, 0x34 ; 52 + MCUSR = 0; + 3e08: 14 be out 0x34, r1 ; 52 + if (!(ch & _BV(EXTRF))) appStart(); + 3e0a: 81 ff sbrs r24, 1 + 3e0c: e4 d0 rcall .+456 ; 0x3fd6 + + // Set up watchdog to trigger after 500ms + watchdogConfig(WATCHDOG_500MS); + 3e0e: 8d e0 ldi r24, 0x0D ; 13 + 3e10: dc d0 rcall .+440 ; 0x3fca + + /* Set LED pin as output */ + LED_DDR |= _BV(LED); + 3e12: 25 9a sbi 0x04, 5 ; 4 + +#ifdef SOFT_UART + /* Set TX pin as output */ + UART_DDR |= _BV(UART_TX_BIT); + 3e14: 51 9a sbi 0x0a, 1 ; 10 + 3e16: 86 e0 ldi r24, 0x06 ; 6 +} + +#if LED_START_FLASHES > 0 +void flash_led(uint8_t count) { + do { + TCNT1 = -(F_CPU/(1024*16)); + 3e18: 28 e1 ldi r18, 0x18 ; 24 + 3e1a: 3e ef ldi r19, 0xFE ; 254 + TIFR1 = _BV(TOV1); + 3e1c: 91 e0 ldi r25, 0x01 ; 1 +} + +#if LED_START_FLASHES > 0 +void flash_led(uint8_t count) { + do { + TCNT1 = -(F_CPU/(1024*16)); + 3e1e: 30 93 85 00 sts 0x0085, r19 + 3e22: 20 93 84 00 sts 0x0084, r18 + TIFR1 = _BV(TOV1); + 3e26: 96 bb out 0x16, r25 ; 22 + while(!(TIFR1 & _BV(TOV1))); + 3e28: b0 9b sbis 0x16, 0 ; 22 + 3e2a: fe cf rjmp .-4 ; 0x3e28 + LED_PIN |= _BV(LED); + 3e2c: 1d 9a sbi 0x03, 5 ; 3 + return getch(); +} + +// Watchdog functions. These are only safe with interrupts turned off. +void watchdogReset() { + __asm__ __volatile__ ( + 3e2e: a8 95 wdr + TCNT1 = -(F_CPU/(1024*16)); + TIFR1 = _BV(TOV1); + while(!(TIFR1 & _BV(TOV1))); + LED_PIN |= _BV(LED); + watchdogReset(); + } while (--count); + 3e30: 81 50 subi r24, 0x01 ; 1 + 3e32: a9 f7 brne .-22 ; 0x3e1e + /* get character from UART */ + ch = getch(); + + if(ch == STK_GET_PARAMETER) { + // GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy + getNch(1); + 3e34: dd 24 eor r13, r13 + 3e36: d3 94 inc r13 + boot_page_fill((uint16_t)(void*)addrPtr,a); + addrPtr += 2; + } while (--ch); + + // Write from programming buffer + boot_page_write((uint16_t)(void*)address); + 3e38: a5 e0 ldi r26, 0x05 ; 5 + 3e3a: ea 2e mov r14, r26 + boot_spm_busy_wait(); + +#if defined(RWWSRE) + // Reenable read access to flash + boot_rww_enable(); + 3e3c: f1 e1 ldi r31, 0x11 ; 17 + 3e3e: ff 2e mov r15, r31 +#endif + + /* Forever loop */ + for (;;) { + /* get character from UART */ + ch = getch(); + 3e40: ab d0 rcall .+342 ; 0x3f98 + + if(ch == STK_GET_PARAMETER) { + 3e42: 81 34 cpi r24, 0x41 ; 65 + 3e44: 21 f4 brne .+8 ; 0x3e4e + // GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy + getNch(1); + 3e46: 81 e0 ldi r24, 0x01 ; 1 + 3e48: d1 d0 rcall .+418 ; 0x3fec + putch(0x03); + 3e4a: 83 e0 ldi r24, 0x03 ; 3 + 3e4c: 24 c0 rjmp .+72 ; 0x3e96 + } + else if(ch == STK_SET_DEVICE) { + 3e4e: 82 34 cpi r24, 0x42 ; 66 + 3e50: 11 f4 brne .+4 ; 0x3e56 + // SET DEVICE is ignored + getNch(20); + 3e52: 84 e1 ldi r24, 0x14 ; 20 + 3e54: 03 c0 rjmp .+6 ; 0x3e5c + } + else if(ch == STK_SET_DEVICE_EXT) { + 3e56: 85 34 cpi r24, 0x45 ; 69 + 3e58: 19 f4 brne .+6 ; 0x3e60 + // SET DEVICE EXT is ignored + getNch(5); + 3e5a: 85 e0 ldi r24, 0x05 ; 5 + 3e5c: c7 d0 rcall .+398 ; 0x3fec + 3e5e: 8a c0 rjmp .+276 ; 0x3f74 + } + else if(ch == STK_LOAD_ADDRESS) { + 3e60: 85 35 cpi r24, 0x55 ; 85 + 3e62: a1 f4 brne .+40 ; 0x3e8c + // LOAD ADDRESS + address = getch(); + 3e64: 99 d0 rcall .+306 ; 0x3f98 + 3e66: 08 2f mov r16, r24 + 3e68: 10 e0 ldi r17, 0x00 ; 0 + 3e6a: 10 93 01 02 sts 0x0201, r17 + 3e6e: 00 93 00 02 sts 0x0200, r16 + address = (address & 0xff) | (getch() << 8); + 3e72: 92 d0 rcall .+292 ; 0x3f98 + 3e74: 90 e0 ldi r25, 0x00 ; 0 + 3e76: 98 2f mov r25, r24 + 3e78: 88 27 eor r24, r24 + 3e7a: 80 2b or r24, r16 + 3e7c: 91 2b or r25, r17 + address += address; // Convert from word address to byte address + 3e7e: 88 0f add r24, r24 + 3e80: 99 1f adc r25, r25 + 3e82: 90 93 01 02 sts 0x0201, r25 + 3e86: 80 93 00 02 sts 0x0200, r24 + 3e8a: 73 c0 rjmp .+230 ; 0x3f72 + verifySpace(); + } + else if(ch == STK_UNIVERSAL) { + 3e8c: 86 35 cpi r24, 0x56 ; 86 + 3e8e: 29 f4 brne .+10 ; 0x3e9a + // UNIVERSAL command is ignored + getNch(4); + 3e90: 84 e0 ldi r24, 0x04 ; 4 + 3e92: ac d0 rcall .+344 ; 0x3fec + putch(0x00); + 3e94: 80 e0 ldi r24, 0x00 ; 0 + 3e96: 71 d0 rcall .+226 ; 0x3f7a + 3e98: 6d c0 rjmp .+218 ; 0x3f74 + } + /* Write memory, length is big endian and is in bytes */ + else if(ch == STK_PROG_PAGE) { + 3e9a: 84 36 cpi r24, 0x64 ; 100 + 3e9c: 09 f0 breq .+2 ; 0x3ea0 + 3e9e: 43 c0 rjmp .+134 ; 0x3f26 + // PROGRAM PAGE - we support flash programming only, not EEPROM + uint8_t *bufPtr; + uint16_t addrPtr; + + getLen(); + 3ea0: 8f d0 rcall .+286 ; 0x3fc0 + + // Immediately start page erase - this will 4.5ms + boot_page_erase((uint16_t)(void*)address); + 3ea2: e0 91 00 02 lds r30, 0x0200 + 3ea6: f0 91 01 02 lds r31, 0x0201 + 3eaa: 83 e0 ldi r24, 0x03 ; 3 + 3eac: 80 93 57 00 sts 0x0057, r24 + 3eb0: e8 95 spm + 3eb2: c0 e0 ldi r28, 0x00 ; 0 + 3eb4: d1 e0 ldi r29, 0x01 ; 1 + + // While that is going on, read in page contents + bufPtr = buff; + do *bufPtr++ = getch(); + 3eb6: 70 d0 rcall .+224 ; 0x3f98 + 3eb8: 89 93 st Y+, r24 + while (--length); + 3eba: 80 91 02 02 lds r24, 0x0202 + 3ebe: 81 50 subi r24, 0x01 ; 1 + 3ec0: 80 93 02 02 sts 0x0202, r24 + 3ec4: 88 23 and r24, r24 + 3ec6: b9 f7 brne .-18 ; 0x3eb6 + + // Read command terminator, start reply + verifySpace(); + 3ec8: 8b d0 rcall .+278 ; 0x3fe0 + + // If only a partial page is to be programmed, the erase might not be complete. + // So check that here + boot_spm_busy_wait(); + 3eca: 07 b6 in r0, 0x37 ; 55 + 3ecc: 00 fc sbrc r0, 0 + 3ece: fd cf rjmp .-6 ; 0x3eca + } +#endif + + // Copy buffer into programming buffer + bufPtr = buff; + addrPtr = (uint16_t)(void*)address; + 3ed0: 40 91 00 02 lds r20, 0x0200 + 3ed4: 50 91 01 02 lds r21, 0x0201 + 3ed8: a0 e0 ldi r26, 0x00 ; 0 + 3eda: b1 e0 ldi r27, 0x01 ; 1 + ch = SPM_PAGESIZE / 2; + do { + uint16_t a; + a = *bufPtr++; + 3edc: 2c 91 ld r18, X + 3ede: 30 e0 ldi r19, 0x00 ; 0 + a |= (*bufPtr++) << 8; + 3ee0: 11 96 adiw r26, 0x01 ; 1 + 3ee2: 8c 91 ld r24, X + 3ee4: 11 97 sbiw r26, 0x01 ; 1 + 3ee6: 90 e0 ldi r25, 0x00 ; 0 + 3ee8: 98 2f mov r25, r24 + 3eea: 88 27 eor r24, r24 + 3eec: 82 2b or r24, r18 + 3eee: 93 2b or r25, r19 +#ifdef VIRTUAL_BOOT_PARTITION +#define rstVect (*(uint16_t*)(0x204)) +#define wdtVect (*(uint16_t*)(0x206)) +#endif +/* main program starts here */ +int main(void) { + 3ef0: 12 96 adiw r26, 0x02 ; 2 + ch = SPM_PAGESIZE / 2; + do { + uint16_t a; + a = *bufPtr++; + a |= (*bufPtr++) << 8; + boot_page_fill((uint16_t)(void*)addrPtr,a); + 3ef2: fa 01 movw r30, r20 + 3ef4: 0c 01 movw r0, r24 + 3ef6: d0 92 57 00 sts 0x0057, r13 + 3efa: e8 95 spm + 3efc: 11 24 eor r1, r1 + addrPtr += 2; + 3efe: 4e 5f subi r20, 0xFE ; 254 + 3f00: 5f 4f sbci r21, 0xFF ; 255 + } while (--ch); + 3f02: f1 e0 ldi r31, 0x01 ; 1 + 3f04: a0 38 cpi r26, 0x80 ; 128 + 3f06: bf 07 cpc r27, r31 + 3f08: 49 f7 brne .-46 ; 0x3edc + + // Write from programming buffer + boot_page_write((uint16_t)(void*)address); + 3f0a: e0 91 00 02 lds r30, 0x0200 + 3f0e: f0 91 01 02 lds r31, 0x0201 + 3f12: e0 92 57 00 sts 0x0057, r14 + 3f16: e8 95 spm + boot_spm_busy_wait(); + 3f18: 07 b6 in r0, 0x37 ; 55 + 3f1a: 00 fc sbrc r0, 0 + 3f1c: fd cf rjmp .-6 ; 0x3f18 + +#if defined(RWWSRE) + // Reenable read access to flash + boot_rww_enable(); + 3f1e: f0 92 57 00 sts 0x0057, r15 + 3f22: e8 95 spm + 3f24: 27 c0 rjmp .+78 ; 0x3f74 +#endif + + } + /* Read memory block mode, length is big endian. */ + else if(ch == STK_READ_PAGE) { + 3f26: 84 37 cpi r24, 0x74 ; 116 + 3f28: b9 f4 brne .+46 ; 0x3f58 + // READ PAGE - we only read flash + getLen(); + 3f2a: 4a d0 rcall .+148 ; 0x3fc0 + verifySpace(); + 3f2c: 59 d0 rcall .+178 ; 0x3fe0 + else ch = pgm_read_byte_near(address); + address++; + putch(ch); + } while (--length); +#else + do putch(pgm_read_byte_near(address++)); + 3f2e: e0 91 00 02 lds r30, 0x0200 + 3f32: f0 91 01 02 lds r31, 0x0201 + 3f36: 31 96 adiw r30, 0x01 ; 1 + 3f38: f0 93 01 02 sts 0x0201, r31 + 3f3c: e0 93 00 02 sts 0x0200, r30 + 3f40: 31 97 sbiw r30, 0x01 ; 1 + 3f42: e4 91 lpm r30, Z+ + 3f44: 8e 2f mov r24, r30 + 3f46: 19 d0 rcall .+50 ; 0x3f7a + while (--length); + 3f48: 80 91 02 02 lds r24, 0x0202 + 3f4c: 81 50 subi r24, 0x01 ; 1 + 3f4e: 80 93 02 02 sts 0x0202, r24 + 3f52: 88 23 and r24, r24 + 3f54: 61 f7 brne .-40 ; 0x3f2e + 3f56: 0e c0 rjmp .+28 ; 0x3f74 +#endif + } + + /* Get device signature bytes */ + else if(ch == STK_READ_SIGN) { + 3f58: 85 37 cpi r24, 0x75 ; 117 + 3f5a: 39 f4 brne .+14 ; 0x3f6a + // READ SIGN - return what Avrdude wants to hear + verifySpace(); + 3f5c: 41 d0 rcall .+130 ; 0x3fe0 + putch(SIGNATURE_0); + 3f5e: 8e e1 ldi r24, 0x1E ; 30 + 3f60: 0c d0 rcall .+24 ; 0x3f7a + putch(SIGNATURE_1); + 3f62: 84 e9 ldi r24, 0x94 ; 148 + 3f64: 0a d0 rcall .+20 ; 0x3f7a + putch(SIGNATURE_2); + 3f66: 86 e0 ldi r24, 0x06 ; 6 + 3f68: 96 cf rjmp .-212 ; 0x3e96 + } + else if (ch == 'Q') { + 3f6a: 81 35 cpi r24, 0x51 ; 81 + 3f6c: 11 f4 brne .+4 ; 0x3f72 + // Adaboot no-wait mod + watchdogConfig(WATCHDOG_16MS); + 3f6e: 88 e0 ldi r24, 0x08 ; 8 + 3f70: 2c d0 rcall .+88 ; 0x3fca + verifySpace(); + } + else { + // This covers the response to commands like STK_ENTER_PROGMODE + verifySpace(); + 3f72: 36 d0 rcall .+108 ; 0x3fe0 + } + putch(STK_OK); + 3f74: 80 e1 ldi r24, 0x10 ; 16 + 3f76: 01 d0 rcall .+2 ; 0x3f7a + 3f78: 63 cf rjmp .-314 ; 0x3e40 + +00003f7a : +void putch(char ch) { +#ifndef SOFT_UART + while (!(UCSR0A & _BV(UDRE0))); + UDR0 = ch; +#else + __asm__ __volatile__ ( + 3f7a: 2a e0 ldi r18, 0x0A ; 10 + 3f7c: 30 e0 ldi r19, 0x00 ; 0 + 3f7e: 80 95 com r24 + 3f80: 08 94 sec + 3f82: 10 f4 brcc .+4 ; 0x3f88 + 3f84: 59 98 cbi 0x0b, 1 ; 11 + 3f86: 02 c0 rjmp .+4 ; 0x3f8c + 3f88: 59 9a sbi 0x0b, 1 ; 11 + 3f8a: 00 00 nop + 3f8c: 15 d0 rcall .+42 ; 0x3fb8 + 3f8e: 14 d0 rcall .+40 ; 0x3fb8 + 3f90: 86 95 lsr r24 + 3f92: 2a 95 dec r18 + 3f94: b1 f7 brne .-20 ; 0x3f82 + [uartBit] "I" (UART_TX_BIT) + : + "r25" + ); +#endif +} + 3f96: 08 95 ret + +00003f98 : + return getch(); +} + +// Watchdog functions. These are only safe with interrupts turned off. +void watchdogReset() { + __asm__ __volatile__ ( + 3f98: a8 95 wdr +#ifdef LED_DATA_FLASH + LED_PIN |= _BV(LED); +#endif + + return ch; +} + 3f9a: 29 e0 ldi r18, 0x09 ; 9 + 3f9c: 30 e0 ldi r19, 0x00 ; 0 + 3f9e: 48 99 sbic 0x09, 0 ; 9 + 3fa0: fe cf rjmp .-4 ; 0x3f9e + 3fa2: 0a d0 rcall .+20 ; 0x3fb8 + 3fa4: 09 d0 rcall .+18 ; 0x3fb8 + 3fa6: 08 d0 rcall .+16 ; 0x3fb8 + 3fa8: 88 94 clc + 3faa: 48 99 sbic 0x09, 0 ; 9 + 3fac: 08 94 sec + 3fae: 2a 95 dec r18 + 3fb0: 11 f0 breq .+4 ; 0x3fb6 + 3fb2: 87 95 ror r24 + 3fb4: f7 cf rjmp .-18 ; 0x3fa4 + 3fb6: 08 95 ret + +00003fb8 : +#if UART_B_VALUE > 255 +#error Baud rate too slow for soft UART +#endif + +void uartDelay() { + __asm__ __volatile__ ( + 3fb8: 98 e0 ldi r25, 0x08 ; 8 + 3fba: 9a 95 dec r25 + 3fbc: f1 f7 brne .-4 ; 0x3fba + 3fbe: 08 95 ret + +00003fc0 : + } while (--count); +} +#endif + +uint8_t getLen() { + getch(); + 3fc0: eb df rcall .-42 ; 0x3f98 + length = getch(); + 3fc2: ea df rcall .-44 ; 0x3f98 + 3fc4: 80 93 02 02 sts 0x0202, r24 + return getch(); +} + 3fc8: e7 cf rjmp .-50 ; 0x3f98 + +00003fca : + "wdr\n" + ); +} + +void watchdogConfig(uint8_t x) { + WDTCSR = _BV(WDCE) | _BV(WDE); + 3fca: e0 e6 ldi r30, 0x60 ; 96 + 3fcc: f0 e0 ldi r31, 0x00 ; 0 + 3fce: 98 e1 ldi r25, 0x18 ; 24 + 3fd0: 90 83 st Z, r25 + WDTCSR = x; + 3fd2: 80 83 st Z, r24 +} + 3fd4: 08 95 ret + +00003fd6 : + +void appStart() { + watchdogConfig(WATCHDOG_OFF); + 3fd6: 80 e0 ldi r24, 0x00 ; 0 + 3fd8: f8 df rcall .-16 ; 0x3fca + __asm__ __volatile__ ( + 3fda: ee 27 eor r30, r30 + 3fdc: ff 27 eor r31, r31 + 3fde: 09 94 ijmp + +00003fe0 : + do getch(); while (--count); + verifySpace(); +} + +void verifySpace() { + if (getch() != CRC_EOP) appStart(); + 3fe0: db df rcall .-74 ; 0x3f98 + 3fe2: 80 32 cpi r24, 0x20 ; 32 + 3fe4: 09 f0 breq .+2 ; 0x3fe8 + 3fe6: f7 df rcall .-18 ; 0x3fd6 + putch(STK_INSYNC); + 3fe8: 84 e1 ldi r24, 0x14 ; 20 +} + 3fea: c7 cf rjmp .-114 ; 0x3f7a + ::[count] "M" (UART_B_VALUE) + ); +} +#endif + +void getNch(uint8_t count) { + 3fec: 1f 93 push r17 + 3fee: 18 2f mov r17, r24 + +00003ff0 : + do getch(); while (--count); + 3ff0: d3 df rcall .-90 ; 0x3f98 + 3ff2: 11 50 subi r17, 0x01 ; 1 + 3ff4: e9 f7 brne .-6 ; 0x3ff0 + verifySpace(); + 3ff6: f4 df rcall .-24 ; 0x3fe0 +} + 3ff8: 1f 91 pop r17 + 3ffa: 08 95 ret diff --git a/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_lilypad_resonator.hex b/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_lilypad_resonator.hex new file mode 100644 index 0000000..9d31a7a --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_lilypad_resonator.hex @@ -0,0 +1,34 @@ +:103E000085E08093810084B714BE81FFE4D08DE00B +:103E1000DCD0259A519A86E028E13EEF91E030937C +:103E200085002093840096BBB09BFECF1D9AA89579 +:103E30008150A9F7DD24D394A5E0EA2EF1E1FF2E0D +:103E4000ABD0813421F481E0D1D083E024C082342E +:103E500011F484E103C0853419F485E0C7D08AC029 +:103E60008535A1F499D0082F10E01093010200933A +:103E7000000292D090E0982F8827802B912B880FFA +:103E8000991F909301028093000273C0863529F434 +:103E900084E0ACD080E071D06DC0843609F043C0BE +:103EA0008FD0E0910002F091010283E080935700EF +:103EB000E895C0E0D1E070D08993809102028150F2 +:103EC000809302028823B9F78BD007B600FCFDCFA0 +:103ED0004091000250910102A0E0B1E02C9130E04D +:103EE00011968C91119790E0982F8827822B932B15 +:103EF0001296FA010C01D0925700E89511244E5FFA +:103F00005F4FF1E0A038BF0749F7E0910002F09160 +:103F10000102E0925700E89507B600FCFDCFF09251 +:103F20005700E89527C08437B9F44AD059D0E091BA +:103F30000002F09101023196F0930102E093000239 +:103F40003197E4918E2F19D0809102028150809395 +:103F50000202882361F70EC0853739F441D08EE123 +:103F60000CD084E90AD086E096CF813511F488E040 +:103F70002CD036D080E101D063CF2AE030E08095AC +:103F8000089410F4599802C0599A000015D014D022 +:103F900086952A95B1F70895A89529E030E04899CB +:103FA000FECF0AD009D008D08894489908942A9561 +:103FB00011F08795F7CF089598E09A95F1F7089555 +:103FC000EBDFEADF80930202E7CFE0E6F0E098E182 +:103FD00090838083089580E0F8DFEE27FF2709941F +:103FE000DBDF803209F0F7DF84E1C7CF1F93182FA2 +:0C3FF000D3DF1150E9F7F4DF1F910895B2 +:0400000300003E00BB +:00000001FF diff --git a/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_lilypad_resonator.lst b/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_lilypad_resonator.lst new file mode 100644 index 0000000..80ecb83 --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_lilypad_resonator.lst @@ -0,0 +1,533 @@ + +optiboot_lilypad_resonator.elf: file format elf32-avr + +Sections: +Idx Name Size VMA LMA File off Algn + 0 .text 000001fc 00003e00 00003e00 00000054 2**1 + CONTENTS, ALLOC, LOAD, READONLY, CODE + 1 .debug_aranges 00000028 00000000 00000000 00000250 2**0 + CONTENTS, READONLY, DEBUGGING + 2 .debug_pubnames 00000078 00000000 00000000 00000278 2**0 + CONTENTS, READONLY, DEBUGGING + 3 .debug_info 00000277 00000000 00000000 000002f0 2**0 + CONTENTS, READONLY, DEBUGGING + 4 .debug_abbrev 00000194 00000000 00000000 00000567 2**0 + CONTENTS, READONLY, DEBUGGING + 5 .debug_line 000003bb 00000000 00000000 000006fb 2**0 + CONTENTS, READONLY, DEBUGGING + 6 .debug_frame 000000a0 00000000 00000000 00000ab8 2**2 + CONTENTS, READONLY, DEBUGGING + 7 .debug_str 0000013f 00000000 00000000 00000b58 2**0 + CONTENTS, READONLY, DEBUGGING + 8 .debug_loc 000001a0 00000000 00000000 00000c97 2**0 + CONTENTS, READONLY, DEBUGGING + 9 .debug_ranges 00000070 00000000 00000000 00000e37 2**0 + CONTENTS, READONLY, DEBUGGING + +Disassembly of section .text: + +00003e00
    : +#ifdef VIRTUAL_BOOT_PARTITION +#define rstVect (*(uint16_t*)(0x204)) +#define wdtVect (*(uint16_t*)(0x206)) +#endif +/* main program starts here */ +int main(void) { + 3e00: 85 e0 ldi r24, 0x05 ; 5 + 3e02: 80 93 81 00 sts 0x0081, r24 + UCSR0C = _BV(UCSZ00) | _BV(UCSZ01); + UBRR0L = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 ); +#endif + + // Adaboot no-wait mod + ch = MCUSR; + 3e06: 84 b7 in r24, 0x34 ; 52 + MCUSR = 0; + 3e08: 14 be out 0x34, r1 ; 52 + if (!(ch & _BV(EXTRF))) appStart(); + 3e0a: 81 ff sbrs r24, 1 + 3e0c: e4 d0 rcall .+456 ; 0x3fd6 + + // Set up watchdog to trigger after 500ms + watchdogConfig(WATCHDOG_500MS); + 3e0e: 8d e0 ldi r24, 0x0D ; 13 + 3e10: dc d0 rcall .+440 ; 0x3fca + + /* Set LED pin as output */ + LED_DDR |= _BV(LED); + 3e12: 25 9a sbi 0x04, 5 ; 4 + +#ifdef SOFT_UART + /* Set TX pin as output */ + UART_DDR |= _BV(UART_TX_BIT); + 3e14: 51 9a sbi 0x0a, 1 ; 10 + 3e16: 86 e0 ldi r24, 0x06 ; 6 +} + +#if LED_START_FLASHES > 0 +void flash_led(uint8_t count) { + do { + TCNT1 = -(F_CPU/(1024*16)); + 3e18: 28 e1 ldi r18, 0x18 ; 24 + 3e1a: 3e ef ldi r19, 0xFE ; 254 + TIFR1 = _BV(TOV1); + 3e1c: 91 e0 ldi r25, 0x01 ; 1 +} + +#if LED_START_FLASHES > 0 +void flash_led(uint8_t count) { + do { + TCNT1 = -(F_CPU/(1024*16)); + 3e1e: 30 93 85 00 sts 0x0085, r19 + 3e22: 20 93 84 00 sts 0x0084, r18 + TIFR1 = _BV(TOV1); + 3e26: 96 bb out 0x16, r25 ; 22 + while(!(TIFR1 & _BV(TOV1))); + 3e28: b0 9b sbis 0x16, 0 ; 22 + 3e2a: fe cf rjmp .-4 ; 0x3e28 + LED_PIN |= _BV(LED); + 3e2c: 1d 9a sbi 0x03, 5 ; 3 + return getch(); +} + +// Watchdog functions. These are only safe with interrupts turned off. +void watchdogReset() { + __asm__ __volatile__ ( + 3e2e: a8 95 wdr + TCNT1 = -(F_CPU/(1024*16)); + TIFR1 = _BV(TOV1); + while(!(TIFR1 & _BV(TOV1))); + LED_PIN |= _BV(LED); + watchdogReset(); + } while (--count); + 3e30: 81 50 subi r24, 0x01 ; 1 + 3e32: a9 f7 brne .-22 ; 0x3e1e + /* get character from UART */ + ch = getch(); + + if(ch == STK_GET_PARAMETER) { + // GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy + getNch(1); + 3e34: dd 24 eor r13, r13 + 3e36: d3 94 inc r13 + boot_page_fill((uint16_t)(void*)addrPtr,a); + addrPtr += 2; + } while (--ch); + + // Write from programming buffer + boot_page_write((uint16_t)(void*)address); + 3e38: a5 e0 ldi r26, 0x05 ; 5 + 3e3a: ea 2e mov r14, r26 + boot_spm_busy_wait(); + +#if defined(RWWSRE) + // Reenable read access to flash + boot_rww_enable(); + 3e3c: f1 e1 ldi r31, 0x11 ; 17 + 3e3e: ff 2e mov r15, r31 +#endif + + /* Forever loop */ + for (;;) { + /* get character from UART */ + ch = getch(); + 3e40: ab d0 rcall .+342 ; 0x3f98 + + if(ch == STK_GET_PARAMETER) { + 3e42: 81 34 cpi r24, 0x41 ; 65 + 3e44: 21 f4 brne .+8 ; 0x3e4e + // GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy + getNch(1); + 3e46: 81 e0 ldi r24, 0x01 ; 1 + 3e48: d1 d0 rcall .+418 ; 0x3fec + putch(0x03); + 3e4a: 83 e0 ldi r24, 0x03 ; 3 + 3e4c: 24 c0 rjmp .+72 ; 0x3e96 + } + else if(ch == STK_SET_DEVICE) { + 3e4e: 82 34 cpi r24, 0x42 ; 66 + 3e50: 11 f4 brne .+4 ; 0x3e56 + // SET DEVICE is ignored + getNch(20); + 3e52: 84 e1 ldi r24, 0x14 ; 20 + 3e54: 03 c0 rjmp .+6 ; 0x3e5c + } + else if(ch == STK_SET_DEVICE_EXT) { + 3e56: 85 34 cpi r24, 0x45 ; 69 + 3e58: 19 f4 brne .+6 ; 0x3e60 + // SET DEVICE EXT is ignored + getNch(5); + 3e5a: 85 e0 ldi r24, 0x05 ; 5 + 3e5c: c7 d0 rcall .+398 ; 0x3fec + 3e5e: 8a c0 rjmp .+276 ; 0x3f74 + } + else if(ch == STK_LOAD_ADDRESS) { + 3e60: 85 35 cpi r24, 0x55 ; 85 + 3e62: a1 f4 brne .+40 ; 0x3e8c + // LOAD ADDRESS + address = getch(); + 3e64: 99 d0 rcall .+306 ; 0x3f98 + 3e66: 08 2f mov r16, r24 + 3e68: 10 e0 ldi r17, 0x00 ; 0 + 3e6a: 10 93 01 02 sts 0x0201, r17 + 3e6e: 00 93 00 02 sts 0x0200, r16 + address = (address & 0xff) | (getch() << 8); + 3e72: 92 d0 rcall .+292 ; 0x3f98 + 3e74: 90 e0 ldi r25, 0x00 ; 0 + 3e76: 98 2f mov r25, r24 + 3e78: 88 27 eor r24, r24 + 3e7a: 80 2b or r24, r16 + 3e7c: 91 2b or r25, r17 + address += address; // Convert from word address to byte address + 3e7e: 88 0f add r24, r24 + 3e80: 99 1f adc r25, r25 + 3e82: 90 93 01 02 sts 0x0201, r25 + 3e86: 80 93 00 02 sts 0x0200, r24 + 3e8a: 73 c0 rjmp .+230 ; 0x3f72 + verifySpace(); + } + else if(ch == STK_UNIVERSAL) { + 3e8c: 86 35 cpi r24, 0x56 ; 86 + 3e8e: 29 f4 brne .+10 ; 0x3e9a + // UNIVERSAL command is ignored + getNch(4); + 3e90: 84 e0 ldi r24, 0x04 ; 4 + 3e92: ac d0 rcall .+344 ; 0x3fec + putch(0x00); + 3e94: 80 e0 ldi r24, 0x00 ; 0 + 3e96: 71 d0 rcall .+226 ; 0x3f7a + 3e98: 6d c0 rjmp .+218 ; 0x3f74 + } + /* Write memory, length is big endian and is in bytes */ + else if(ch == STK_PROG_PAGE) { + 3e9a: 84 36 cpi r24, 0x64 ; 100 + 3e9c: 09 f0 breq .+2 ; 0x3ea0 + 3e9e: 43 c0 rjmp .+134 ; 0x3f26 + // PROGRAM PAGE - we support flash programming only, not EEPROM + uint8_t *bufPtr; + uint16_t addrPtr; + + getLen(); + 3ea0: 8f d0 rcall .+286 ; 0x3fc0 + + // Immediately start page erase - this will 4.5ms + boot_page_erase((uint16_t)(void*)address); + 3ea2: e0 91 00 02 lds r30, 0x0200 + 3ea6: f0 91 01 02 lds r31, 0x0201 + 3eaa: 83 e0 ldi r24, 0x03 ; 3 + 3eac: 80 93 57 00 sts 0x0057, r24 + 3eb0: e8 95 spm + 3eb2: c0 e0 ldi r28, 0x00 ; 0 + 3eb4: d1 e0 ldi r29, 0x01 ; 1 + + // While that is going on, read in page contents + bufPtr = buff; + do *bufPtr++ = getch(); + 3eb6: 70 d0 rcall .+224 ; 0x3f98 + 3eb8: 89 93 st Y+, r24 + while (--length); + 3eba: 80 91 02 02 lds r24, 0x0202 + 3ebe: 81 50 subi r24, 0x01 ; 1 + 3ec0: 80 93 02 02 sts 0x0202, r24 + 3ec4: 88 23 and r24, r24 + 3ec6: b9 f7 brne .-18 ; 0x3eb6 + + // Read command terminator, start reply + verifySpace(); + 3ec8: 8b d0 rcall .+278 ; 0x3fe0 + + // If only a partial page is to be programmed, the erase might not be complete. + // So check that here + boot_spm_busy_wait(); + 3eca: 07 b6 in r0, 0x37 ; 55 + 3ecc: 00 fc sbrc r0, 0 + 3ece: fd cf rjmp .-6 ; 0x3eca + } +#endif + + // Copy buffer into programming buffer + bufPtr = buff; + addrPtr = (uint16_t)(void*)address; + 3ed0: 40 91 00 02 lds r20, 0x0200 + 3ed4: 50 91 01 02 lds r21, 0x0201 + 3ed8: a0 e0 ldi r26, 0x00 ; 0 + 3eda: b1 e0 ldi r27, 0x01 ; 1 + ch = SPM_PAGESIZE / 2; + do { + uint16_t a; + a = *bufPtr++; + 3edc: 2c 91 ld r18, X + 3ede: 30 e0 ldi r19, 0x00 ; 0 + a |= (*bufPtr++) << 8; + 3ee0: 11 96 adiw r26, 0x01 ; 1 + 3ee2: 8c 91 ld r24, X + 3ee4: 11 97 sbiw r26, 0x01 ; 1 + 3ee6: 90 e0 ldi r25, 0x00 ; 0 + 3ee8: 98 2f mov r25, r24 + 3eea: 88 27 eor r24, r24 + 3eec: 82 2b or r24, r18 + 3eee: 93 2b or r25, r19 +#ifdef VIRTUAL_BOOT_PARTITION +#define rstVect (*(uint16_t*)(0x204)) +#define wdtVect (*(uint16_t*)(0x206)) +#endif +/* main program starts here */ +int main(void) { + 3ef0: 12 96 adiw r26, 0x02 ; 2 + ch = SPM_PAGESIZE / 2; + do { + uint16_t a; + a = *bufPtr++; + a |= (*bufPtr++) << 8; + boot_page_fill((uint16_t)(void*)addrPtr,a); + 3ef2: fa 01 movw r30, r20 + 3ef4: 0c 01 movw r0, r24 + 3ef6: d0 92 57 00 sts 0x0057, r13 + 3efa: e8 95 spm + 3efc: 11 24 eor r1, r1 + addrPtr += 2; + 3efe: 4e 5f subi r20, 0xFE ; 254 + 3f00: 5f 4f sbci r21, 0xFF ; 255 + } while (--ch); + 3f02: f1 e0 ldi r31, 0x01 ; 1 + 3f04: a0 38 cpi r26, 0x80 ; 128 + 3f06: bf 07 cpc r27, r31 + 3f08: 49 f7 brne .-46 ; 0x3edc + + // Write from programming buffer + boot_page_write((uint16_t)(void*)address); + 3f0a: e0 91 00 02 lds r30, 0x0200 + 3f0e: f0 91 01 02 lds r31, 0x0201 + 3f12: e0 92 57 00 sts 0x0057, r14 + 3f16: e8 95 spm + boot_spm_busy_wait(); + 3f18: 07 b6 in r0, 0x37 ; 55 + 3f1a: 00 fc sbrc r0, 0 + 3f1c: fd cf rjmp .-6 ; 0x3f18 + +#if defined(RWWSRE) + // Reenable read access to flash + boot_rww_enable(); + 3f1e: f0 92 57 00 sts 0x0057, r15 + 3f22: e8 95 spm + 3f24: 27 c0 rjmp .+78 ; 0x3f74 +#endif + + } + /* Read memory block mode, length is big endian. */ + else if(ch == STK_READ_PAGE) { + 3f26: 84 37 cpi r24, 0x74 ; 116 + 3f28: b9 f4 brne .+46 ; 0x3f58 + // READ PAGE - we only read flash + getLen(); + 3f2a: 4a d0 rcall .+148 ; 0x3fc0 + verifySpace(); + 3f2c: 59 d0 rcall .+178 ; 0x3fe0 + else ch = pgm_read_byte_near(address); + address++; + putch(ch); + } while (--length); +#else + do putch(pgm_read_byte_near(address++)); + 3f2e: e0 91 00 02 lds r30, 0x0200 + 3f32: f0 91 01 02 lds r31, 0x0201 + 3f36: 31 96 adiw r30, 0x01 ; 1 + 3f38: f0 93 01 02 sts 0x0201, r31 + 3f3c: e0 93 00 02 sts 0x0200, r30 + 3f40: 31 97 sbiw r30, 0x01 ; 1 + 3f42: e4 91 lpm r30, Z+ + 3f44: 8e 2f mov r24, r30 + 3f46: 19 d0 rcall .+50 ; 0x3f7a + while (--length); + 3f48: 80 91 02 02 lds r24, 0x0202 + 3f4c: 81 50 subi r24, 0x01 ; 1 + 3f4e: 80 93 02 02 sts 0x0202, r24 + 3f52: 88 23 and r24, r24 + 3f54: 61 f7 brne .-40 ; 0x3f2e + 3f56: 0e c0 rjmp .+28 ; 0x3f74 +#endif + } + + /* Get device signature bytes */ + else if(ch == STK_READ_SIGN) { + 3f58: 85 37 cpi r24, 0x75 ; 117 + 3f5a: 39 f4 brne .+14 ; 0x3f6a + // READ SIGN - return what Avrdude wants to hear + verifySpace(); + 3f5c: 41 d0 rcall .+130 ; 0x3fe0 + putch(SIGNATURE_0); + 3f5e: 8e e1 ldi r24, 0x1E ; 30 + 3f60: 0c d0 rcall .+24 ; 0x3f7a + putch(SIGNATURE_1); + 3f62: 84 e9 ldi r24, 0x94 ; 148 + 3f64: 0a d0 rcall .+20 ; 0x3f7a + putch(SIGNATURE_2); + 3f66: 86 e0 ldi r24, 0x06 ; 6 + 3f68: 96 cf rjmp .-212 ; 0x3e96 + } + else if (ch == 'Q') { + 3f6a: 81 35 cpi r24, 0x51 ; 81 + 3f6c: 11 f4 brne .+4 ; 0x3f72 + // Adaboot no-wait mod + watchdogConfig(WATCHDOG_16MS); + 3f6e: 88 e0 ldi r24, 0x08 ; 8 + 3f70: 2c d0 rcall .+88 ; 0x3fca + verifySpace(); + } + else { + // This covers the response to commands like STK_ENTER_PROGMODE + verifySpace(); + 3f72: 36 d0 rcall .+108 ; 0x3fe0 + } + putch(STK_OK); + 3f74: 80 e1 ldi r24, 0x10 ; 16 + 3f76: 01 d0 rcall .+2 ; 0x3f7a + 3f78: 63 cf rjmp .-314 ; 0x3e40 + +00003f7a : +void putch(char ch) { +#ifndef SOFT_UART + while (!(UCSR0A & _BV(UDRE0))); + UDR0 = ch; +#else + __asm__ __volatile__ ( + 3f7a: 2a e0 ldi r18, 0x0A ; 10 + 3f7c: 30 e0 ldi r19, 0x00 ; 0 + 3f7e: 80 95 com r24 + 3f80: 08 94 sec + 3f82: 10 f4 brcc .+4 ; 0x3f88 + 3f84: 59 98 cbi 0x0b, 1 ; 11 + 3f86: 02 c0 rjmp .+4 ; 0x3f8c + 3f88: 59 9a sbi 0x0b, 1 ; 11 + 3f8a: 00 00 nop + 3f8c: 15 d0 rcall .+42 ; 0x3fb8 + 3f8e: 14 d0 rcall .+40 ; 0x3fb8 + 3f90: 86 95 lsr r24 + 3f92: 2a 95 dec r18 + 3f94: b1 f7 brne .-20 ; 0x3f82 + [uartBit] "I" (UART_TX_BIT) + : + "r25" + ); +#endif +} + 3f96: 08 95 ret + +00003f98 : + return getch(); +} + +// Watchdog functions. These are only safe with interrupts turned off. +void watchdogReset() { + __asm__ __volatile__ ( + 3f98: a8 95 wdr +#ifdef LED_DATA_FLASH + LED_PIN |= _BV(LED); +#endif + + return ch; +} + 3f9a: 29 e0 ldi r18, 0x09 ; 9 + 3f9c: 30 e0 ldi r19, 0x00 ; 0 + 3f9e: 48 99 sbic 0x09, 0 ; 9 + 3fa0: fe cf rjmp .-4 ; 0x3f9e + 3fa2: 0a d0 rcall .+20 ; 0x3fb8 + 3fa4: 09 d0 rcall .+18 ; 0x3fb8 + 3fa6: 08 d0 rcall .+16 ; 0x3fb8 + 3fa8: 88 94 clc + 3faa: 48 99 sbic 0x09, 0 ; 9 + 3fac: 08 94 sec + 3fae: 2a 95 dec r18 + 3fb0: 11 f0 breq .+4 ; 0x3fb6 + 3fb2: 87 95 ror r24 + 3fb4: f7 cf rjmp .-18 ; 0x3fa4 + 3fb6: 08 95 ret + +00003fb8 : +#if UART_B_VALUE > 255 +#error Baud rate too slow for soft UART +#endif + +void uartDelay() { + __asm__ __volatile__ ( + 3fb8: 98 e0 ldi r25, 0x08 ; 8 + 3fba: 9a 95 dec r25 + 3fbc: f1 f7 brne .-4 ; 0x3fba + 3fbe: 08 95 ret + +00003fc0 : + } while (--count); +} +#endif + +uint8_t getLen() { + getch(); + 3fc0: eb df rcall .-42 ; 0x3f98 + length = getch(); + 3fc2: ea df rcall .-44 ; 0x3f98 + 3fc4: 80 93 02 02 sts 0x0202, r24 + return getch(); +} + 3fc8: e7 cf rjmp .-50 ; 0x3f98 + +00003fca : + "wdr\n" + ); +} + +void watchdogConfig(uint8_t x) { + WDTCSR = _BV(WDCE) | _BV(WDE); + 3fca: e0 e6 ldi r30, 0x60 ; 96 + 3fcc: f0 e0 ldi r31, 0x00 ; 0 + 3fce: 98 e1 ldi r25, 0x18 ; 24 + 3fd0: 90 83 st Z, r25 + WDTCSR = x; + 3fd2: 80 83 st Z, r24 +} + 3fd4: 08 95 ret + +00003fd6 : + +void appStart() { + watchdogConfig(WATCHDOG_OFF); + 3fd6: 80 e0 ldi r24, 0x00 ; 0 + 3fd8: f8 df rcall .-16 ; 0x3fca + __asm__ __volatile__ ( + 3fda: ee 27 eor r30, r30 + 3fdc: ff 27 eor r31, r31 + 3fde: 09 94 ijmp + +00003fe0 : + do getch(); while (--count); + verifySpace(); +} + +void verifySpace() { + if (getch() != CRC_EOP) appStart(); + 3fe0: db df rcall .-74 ; 0x3f98 + 3fe2: 80 32 cpi r24, 0x20 ; 32 + 3fe4: 09 f0 breq .+2 ; 0x3fe8 + 3fe6: f7 df rcall .-18 ; 0x3fd6 + putch(STK_INSYNC); + 3fe8: 84 e1 ldi r24, 0x14 ; 20 +} + 3fea: c7 cf rjmp .-114 ; 0x3f7a + ::[count] "M" (UART_B_VALUE) + ); +} +#endif + +void getNch(uint8_t count) { + 3fec: 1f 93 push r17 + 3fee: 18 2f mov r17, r24 + +00003ff0 : + do getch(); while (--count); + 3ff0: d3 df rcall .-90 ; 0x3f98 + 3ff2: 11 50 subi r17, 0x01 ; 1 + 3ff4: e9 f7 brne .-6 ; 0x3ff0 + verifySpace(); + 3ff6: f4 df rcall .-24 ; 0x3fe0 +} + 3ff8: 1f 91 pop r17 + 3ffa: 08 95 ret diff --git a/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_luminet.hex b/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_luminet.hex new file mode 100644 index 0000000..0e51124 --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_luminet.hex @@ -0,0 +1,42 @@ +:101D000085E08EBD84B714BE81FF27D18DE021D13F +:101D1000D49AD29A86E023EC3FEF91E03DBD2CBDF2 +:101D20009BB9589BFECFCC9AA8958150B9F7CC248B +:101D3000C39485E0E82E0FE7D02E1EECF12EF0D0F4 +:101D4000813421F481E014D183E024C0823411F481 +:101D500084E103C0853419F485E00AD1CFC085350C +:101D6000A1F4DED0082F10E01093010200930002CE +:101D7000D7D090E0982F8827802B912B880F991F20 +:101D80009093010280930002B8C0863529F484E064 +:101D9000EFD080E0B6D0B2C0843609F06EC0D4D0A7 +:101DA000E0910002F091010283E080935700E895F2 +:101DB000C0E0D1E0B5D08993809102028150809338 +:101DC00002028823B9F7CED007B600FCFDCF809180 +:101DD000000290910102892B41F580910001209130 +:101DE000010130E0322F222790E0282B392B30934D +:101DF00005022093040240910A0180910B0190E0BA +:101E0000982F882750E0842B952B9093070280937E +:101E100006022450304020930A01232F33272093B9 +:101E20000B01D0920001F09201014091000250910B +:101E30000102A0E0B1E02C9130E011968C91119755 +:101E400090E0982F8827822B932B1296FA010C0191 +:101E5000C0925700E89511244E5F5F4FF1E0A03427 +:101E6000BF0749F7E0910002F0910102E0925700AC +:101E7000E89507B600FCFDCF41C0843789F564D0F2 +:101E800071D0E0910002F0910102309719F4209195 +:101E9000040213C0E130F10519F4209105020DC0D0 +:101EA000EA30F10519F42091060207C0EB30F10584 +:101EB00019F42091070201C02491809100029091B1 +:101EC000010201969093010280930002822F19D0A3 +:101ED00080910202815080930202882391F60EC005 +:101EE000853739F43FD08EE10CD083E90AD08CE0FD +:101EF00051CF813511F488E02CD034D080E101D06D +:101F00001ECF2AE030E08095089410F4DA9802C0E1 +:101F1000DA9A000015D014D086952A95B1F7089565 +:101F2000A89529E030E0CB99FECF0AD009D008D09F +:101F30008894CB9908942A9511F08795F7CF089546 +:101F40009EE09A95F1F70895EBDFEADF80930202B5 +:101F5000E7CF98E191BD81BD089580E0FADFE5E02B +:101F6000FF270994DDDF803209F0F7DF84E1C9CF74 +:101F70001F93182FD5DF1150E9F7F4DF1F91089553 +:0400000300001D00DC +:00000001FF diff --git a/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_luminet.lst b/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_luminet.lst new file mode 100644 index 0000000..59468cb --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_luminet.lst @@ -0,0 +1,604 @@ + +optiboot_luminet.elf: file format elf32-avr + +Sections: +Idx Name Size VMA LMA File off Algn + 0 .text 00000280 00001d00 00001d00 00000054 2**1 + CONTENTS, ALLOC, LOAD, READONLY, CODE + 1 .debug_aranges 00000028 00000000 00000000 000002d4 2**0 + CONTENTS, READONLY, DEBUGGING + 2 .debug_pubnames 00000078 00000000 00000000 000002fc 2**0 + CONTENTS, READONLY, DEBUGGING + 3 .debug_info 00000289 00000000 00000000 00000374 2**0 + CONTENTS, READONLY, DEBUGGING + 4 .debug_abbrev 000001a1 00000000 00000000 000005fd 2**0 + CONTENTS, READONLY, DEBUGGING + 5 .debug_line 00000435 00000000 00000000 0000079e 2**0 + CONTENTS, READONLY, DEBUGGING + 6 .debug_frame 000000a0 00000000 00000000 00000bd4 2**2 + CONTENTS, READONLY, DEBUGGING + 7 .debug_str 00000144 00000000 00000000 00000c74 2**0 + CONTENTS, READONLY, DEBUGGING + 8 .debug_loc 00000194 00000000 00000000 00000db8 2**0 + CONTENTS, READONLY, DEBUGGING + 9 .debug_ranges 00000088 00000000 00000000 00000f4c 2**0 + CONTENTS, READONLY, DEBUGGING + +Disassembly of section .text: + +00001d00
    : +#ifdef VIRTUAL_BOOT_PARTITION +#define rstVect (*(uint16_t*)(0x204)) +#define wdtVect (*(uint16_t*)(0x206)) +#endif +/* main program starts here */ +int main(void) { + 1d00: 85 e0 ldi r24, 0x05 ; 5 + 1d02: 8e bd out 0x2e, r24 ; 46 + UCSR0C = _BV(UCSZ00) | _BV(UCSZ01); + UBRR0L = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 ); +#endif + + // Adaboot no-wait mod + ch = MCUSR; + 1d04: 84 b7 in r24, 0x34 ; 52 + MCUSR = 0; + 1d06: 14 be out 0x34, r1 ; 52 + if (!(ch & _BV(EXTRF))) appStart(); + 1d08: 81 ff sbrs r24, 1 + 1d0a: 27 d1 rcall .+590 ; 0x1f5a + + // Set up watchdog to trigger after 500ms + watchdogConfig(WATCHDOG_500MS); + 1d0c: 8d e0 ldi r24, 0x0D ; 13 + 1d0e: 21 d1 rcall .+578 ; 0x1f52 + + /* Set LED pin as output */ + LED_DDR |= _BV(LED); + 1d10: d4 9a sbi 0x1a, 4 ; 26 + +#ifdef SOFT_UART + /* Set TX pin as output */ + UART_DDR |= _BV(UART_TX_BIT); + 1d12: d2 9a sbi 0x1a, 2 ; 26 + 1d14: 86 e0 ldi r24, 0x06 ; 6 +} + +#if LED_START_FLASHES > 0 +void flash_led(uint8_t count) { + do { + TCNT1 = -(F_CPU/(1024*16)); + 1d16: 23 ec ldi r18, 0xC3 ; 195 + 1d18: 3f ef ldi r19, 0xFF ; 255 + TIFR1 = _BV(TOV1); + 1d1a: 91 e0 ldi r25, 0x01 ; 1 +} + +#if LED_START_FLASHES > 0 +void flash_led(uint8_t count) { + do { + TCNT1 = -(F_CPU/(1024*16)); + 1d1c: 3d bd out 0x2d, r19 ; 45 + 1d1e: 2c bd out 0x2c, r18 ; 44 + TIFR1 = _BV(TOV1); + 1d20: 9b b9 out 0x0b, r25 ; 11 + while(!(TIFR1 & _BV(TOV1))); + 1d22: 58 9b sbis 0x0b, 0 ; 11 + 1d24: fe cf rjmp .-4 ; 0x1d22 + LED_PIN |= _BV(LED); + 1d26: cc 9a sbi 0x19, 4 ; 25 + return getch(); +} + +// Watchdog functions. These are only safe with interrupts turned off. +void watchdogReset() { + __asm__ __volatile__ ( + 1d28: a8 95 wdr + TCNT1 = -(F_CPU/(1024*16)); + TIFR1 = _BV(TOV1); + while(!(TIFR1 & _BV(TOV1))); + LED_PIN |= _BV(LED); + watchdogReset(); + } while (--count); + 1d2a: 81 50 subi r24, 0x01 ; 1 + 1d2c: b9 f7 brne .-18 ; 0x1d1c + /* get character from UART */ + ch = getch(); + + if(ch == STK_GET_PARAMETER) { + // GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy + getNch(1); + 1d2e: cc 24 eor r12, r12 + 1d30: c3 94 inc r12 + boot_page_fill((uint16_t)(void*)addrPtr,a); + addrPtr += 2; + } while (--ch); + + // Write from programming buffer + boot_page_write((uint16_t)(void*)address); + 1d32: 85 e0 ldi r24, 0x05 ; 5 + 1d34: e8 2e mov r14, r24 + vect -= 4; // Instruction is a relative jump (rjmp), so recalculate. + buff[10] = vect & 0xff; + buff[11] = vect >> 8; + + // Add jump to bootloader at RESET vector + buff[0] = 0x7f; + 1d36: 0f e7 ldi r16, 0x7F ; 127 + 1d38: d0 2e mov r13, r16 + buff[1] = 0xce; // rjmp 0x1d00 instruction + 1d3a: 1e ec ldi r17, 0xCE ; 206 + 1d3c: f1 2e mov r15, r17 +#endif + + /* Forever loop */ + for (;;) { + /* get character from UART */ + ch = getch(); + 1d3e: f0 d0 rcall .+480 ; 0x1f20 + + if(ch == STK_GET_PARAMETER) { + 1d40: 81 34 cpi r24, 0x41 ; 65 + 1d42: 21 f4 brne .+8 ; 0x1d4c + // GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy + getNch(1); + 1d44: 81 e0 ldi r24, 0x01 ; 1 + 1d46: 14 d1 rcall .+552 ; 0x1f70 + putch(0x03); + 1d48: 83 e0 ldi r24, 0x03 ; 3 + 1d4a: 24 c0 rjmp .+72 ; 0x1d94 + } + else if(ch == STK_SET_DEVICE) { + 1d4c: 82 34 cpi r24, 0x42 ; 66 + 1d4e: 11 f4 brne .+4 ; 0x1d54 + // SET DEVICE is ignored + getNch(20); + 1d50: 84 e1 ldi r24, 0x14 ; 20 + 1d52: 03 c0 rjmp .+6 ; 0x1d5a + } + else if(ch == STK_SET_DEVICE_EXT) { + 1d54: 85 34 cpi r24, 0x45 ; 69 + 1d56: 19 f4 brne .+6 ; 0x1d5e + // SET DEVICE EXT is ignored + getNch(5); + 1d58: 85 e0 ldi r24, 0x05 ; 5 + 1d5a: 0a d1 rcall .+532 ; 0x1f70 + 1d5c: cf c0 rjmp .+414 ; 0x1efc + } + else if(ch == STK_LOAD_ADDRESS) { + 1d5e: 85 35 cpi r24, 0x55 ; 85 + 1d60: a1 f4 brne .+40 ; 0x1d8a + // LOAD ADDRESS + address = getch(); + 1d62: de d0 rcall .+444 ; 0x1f20 + 1d64: 08 2f mov r16, r24 + 1d66: 10 e0 ldi r17, 0x00 ; 0 + 1d68: 10 93 01 02 sts 0x0201, r17 + 1d6c: 00 93 00 02 sts 0x0200, r16 + address = (address & 0xff) | (getch() << 8); + 1d70: d7 d0 rcall .+430 ; 0x1f20 + 1d72: 90 e0 ldi r25, 0x00 ; 0 + 1d74: 98 2f mov r25, r24 + 1d76: 88 27 eor r24, r24 + 1d78: 80 2b or r24, r16 + 1d7a: 91 2b or r25, r17 + address += address; // Convert from word address to byte address + 1d7c: 88 0f add r24, r24 + 1d7e: 99 1f adc r25, r25 + 1d80: 90 93 01 02 sts 0x0201, r25 + 1d84: 80 93 00 02 sts 0x0200, r24 + 1d88: b8 c0 rjmp .+368 ; 0x1efa + verifySpace(); + } + else if(ch == STK_UNIVERSAL) { + 1d8a: 86 35 cpi r24, 0x56 ; 86 + 1d8c: 29 f4 brne .+10 ; 0x1d98 + // UNIVERSAL command is ignored + getNch(4); + 1d8e: 84 e0 ldi r24, 0x04 ; 4 + 1d90: ef d0 rcall .+478 ; 0x1f70 + putch(0x00); + 1d92: 80 e0 ldi r24, 0x00 ; 0 + 1d94: b6 d0 rcall .+364 ; 0x1f02 + 1d96: b2 c0 rjmp .+356 ; 0x1efc + } + /* Write memory, length is big endian and is in bytes */ + else if(ch == STK_PROG_PAGE) { + 1d98: 84 36 cpi r24, 0x64 ; 100 + 1d9a: 09 f0 breq .+2 ; 0x1d9e + 1d9c: 6e c0 rjmp .+220 ; 0x1e7a + // PROGRAM PAGE - we support flash programming only, not EEPROM + uint8_t *bufPtr; + uint16_t addrPtr; + + getLen(); + 1d9e: d4 d0 rcall .+424 ; 0x1f48 + + // Immediately start page erase - this will 4.5ms + boot_page_erase((uint16_t)(void*)address); + 1da0: e0 91 00 02 lds r30, 0x0200 + 1da4: f0 91 01 02 lds r31, 0x0201 + 1da8: 83 e0 ldi r24, 0x03 ; 3 + 1daa: 80 93 57 00 sts 0x0057, r24 + 1dae: e8 95 spm + 1db0: c0 e0 ldi r28, 0x00 ; 0 + 1db2: d1 e0 ldi r29, 0x01 ; 1 + + // While that is going on, read in page contents + bufPtr = buff; + do *bufPtr++ = getch(); + 1db4: b5 d0 rcall .+362 ; 0x1f20 + 1db6: 89 93 st Y+, r24 + while (--length); + 1db8: 80 91 02 02 lds r24, 0x0202 + 1dbc: 81 50 subi r24, 0x01 ; 1 + 1dbe: 80 93 02 02 sts 0x0202, r24 + 1dc2: 88 23 and r24, r24 + 1dc4: b9 f7 brne .-18 ; 0x1db4 + + // Read command terminator, start reply + verifySpace(); + 1dc6: ce d0 rcall .+412 ; 0x1f64 + + // If only a partial page is to be programmed, the erase might not be complete. + // So check that here + boot_spm_busy_wait(); + 1dc8: 07 b6 in r0, 0x37 ; 55 + 1dca: 00 fc sbrc r0, 0 + 1dcc: fd cf rjmp .-6 ; 0x1dc8 + +#ifdef VIRTUAL_BOOT_PARTITION + if ((uint16_t)(void*)address == 0) { + 1dce: 80 91 00 02 lds r24, 0x0200 + 1dd2: 90 91 01 02 lds r25, 0x0201 + 1dd6: 89 2b or r24, r25 + 1dd8: 41 f5 brne .+80 ; 0x1e2a + // This is the reset vector page. We need to live-patch the code so the + // bootloader runs. + // + // Move RESET vector to WDT vector + uint16_t vect = buff[0] | (buff[1]<<8); + 1dda: 80 91 00 01 lds r24, 0x0100 + 1dde: 20 91 01 01 lds r18, 0x0101 + 1de2: 30 e0 ldi r19, 0x00 ; 0 + 1de4: 32 2f mov r19, r18 + 1de6: 22 27 eor r18, r18 + 1de8: 90 e0 ldi r25, 0x00 ; 0 + 1dea: 28 2b or r18, r24 + 1dec: 39 2b or r19, r25 + rstVect = vect; + 1dee: 30 93 05 02 sts 0x0205, r19 + 1df2: 20 93 04 02 sts 0x0204, r18 + wdtVect = buff[10] | (buff[11]<<8); + 1df6: 40 91 0a 01 lds r20, 0x010A + 1dfa: 80 91 0b 01 lds r24, 0x010B + 1dfe: 90 e0 ldi r25, 0x00 ; 0 + 1e00: 98 2f mov r25, r24 + 1e02: 88 27 eor r24, r24 + 1e04: 50 e0 ldi r21, 0x00 ; 0 + 1e06: 84 2b or r24, r20 + 1e08: 95 2b or r25, r21 + 1e0a: 90 93 07 02 sts 0x0207, r25 + 1e0e: 80 93 06 02 sts 0x0206, r24 + vect -= 4; // Instruction is a relative jump (rjmp), so recalculate. + 1e12: 24 50 subi r18, 0x04 ; 4 + 1e14: 30 40 sbci r19, 0x00 ; 0 + buff[10] = vect & 0xff; + 1e16: 20 93 0a 01 sts 0x010A, r18 + buff[11] = vect >> 8; + 1e1a: 23 2f mov r18, r19 + 1e1c: 33 27 eor r19, r19 + 1e1e: 20 93 0b 01 sts 0x010B, r18 + + // Add jump to bootloader at RESET vector + buff[0] = 0x7f; + 1e22: d0 92 00 01 sts 0x0100, r13 + buff[1] = 0xce; // rjmp 0x1d00 instruction + 1e26: f0 92 01 01 sts 0x0101, r15 + } +#endif + + // Copy buffer into programming buffer + bufPtr = buff; + addrPtr = (uint16_t)(void*)address; + 1e2a: 40 91 00 02 lds r20, 0x0200 + 1e2e: 50 91 01 02 lds r21, 0x0201 + 1e32: a0 e0 ldi r26, 0x00 ; 0 + 1e34: b1 e0 ldi r27, 0x01 ; 1 + ch = SPM_PAGESIZE / 2; + do { + uint16_t a; + a = *bufPtr++; + 1e36: 2c 91 ld r18, X + 1e38: 30 e0 ldi r19, 0x00 ; 0 + a |= (*bufPtr++) << 8; + 1e3a: 11 96 adiw r26, 0x01 ; 1 + 1e3c: 8c 91 ld r24, X + 1e3e: 11 97 sbiw r26, 0x01 ; 1 + 1e40: 90 e0 ldi r25, 0x00 ; 0 + 1e42: 98 2f mov r25, r24 + 1e44: 88 27 eor r24, r24 + 1e46: 82 2b or r24, r18 + 1e48: 93 2b or r25, r19 +#ifdef VIRTUAL_BOOT_PARTITION +#define rstVect (*(uint16_t*)(0x204)) +#define wdtVect (*(uint16_t*)(0x206)) +#endif +/* main program starts here */ +int main(void) { + 1e4a: 12 96 adiw r26, 0x02 ; 2 + ch = SPM_PAGESIZE / 2; + do { + uint16_t a; + a = *bufPtr++; + a |= (*bufPtr++) << 8; + boot_page_fill((uint16_t)(void*)addrPtr,a); + 1e4c: fa 01 movw r30, r20 + 1e4e: 0c 01 movw r0, r24 + 1e50: c0 92 57 00 sts 0x0057, r12 + 1e54: e8 95 spm + 1e56: 11 24 eor r1, r1 + addrPtr += 2; + 1e58: 4e 5f subi r20, 0xFE ; 254 + 1e5a: 5f 4f sbci r21, 0xFF ; 255 + } while (--ch); + 1e5c: f1 e0 ldi r31, 0x01 ; 1 + 1e5e: a0 34 cpi r26, 0x40 ; 64 + 1e60: bf 07 cpc r27, r31 + 1e62: 49 f7 brne .-46 ; 0x1e36 + + // Write from programming buffer + boot_page_write((uint16_t)(void*)address); + 1e64: e0 91 00 02 lds r30, 0x0200 + 1e68: f0 91 01 02 lds r31, 0x0201 + 1e6c: e0 92 57 00 sts 0x0057, r14 + 1e70: e8 95 spm + boot_spm_busy_wait(); + 1e72: 07 b6 in r0, 0x37 ; 55 + 1e74: 00 fc sbrc r0, 0 + 1e76: fd cf rjmp .-6 ; 0x1e72 + 1e78: 41 c0 rjmp .+130 ; 0x1efc + boot_rww_enable(); +#endif + + } + /* Read memory block mode, length is big endian. */ + else if(ch == STK_READ_PAGE) { + 1e7a: 84 37 cpi r24, 0x74 ; 116 + 1e7c: 89 f5 brne .+98 ; 0x1ee0 + // READ PAGE - we only read flash + getLen(); + 1e7e: 64 d0 rcall .+200 ; 0x1f48 + verifySpace(); + 1e80: 71 d0 rcall .+226 ; 0x1f64 +#ifdef VIRTUAL_BOOT_PARTITION + do { + // Undo vector patch in bottom page so verify passes + if (address == 0) ch=rstVect & 0xff; + 1e82: e0 91 00 02 lds r30, 0x0200 + 1e86: f0 91 01 02 lds r31, 0x0201 + 1e8a: 30 97 sbiw r30, 0x00 ; 0 + 1e8c: 19 f4 brne .+6 ; 0x1e94 + 1e8e: 20 91 04 02 lds r18, 0x0204 + 1e92: 13 c0 rjmp .+38 ; 0x1eba + else if (address == 1) ch=rstVect >> 8; + 1e94: e1 30 cpi r30, 0x01 ; 1 + 1e96: f1 05 cpc r31, r1 + 1e98: 19 f4 brne .+6 ; 0x1ea0 + 1e9a: 20 91 05 02 lds r18, 0x0205 + 1e9e: 0d c0 rjmp .+26 ; 0x1eba + else if (address == 10) ch=wdtVect & 0xff; + 1ea0: ea 30 cpi r30, 0x0A ; 10 + 1ea2: f1 05 cpc r31, r1 + 1ea4: 19 f4 brne .+6 ; 0x1eac + 1ea6: 20 91 06 02 lds r18, 0x0206 + 1eaa: 07 c0 rjmp .+14 ; 0x1eba + else if (address == 11) ch=wdtVect >> 8; + 1eac: eb 30 cpi r30, 0x0B ; 11 + 1eae: f1 05 cpc r31, r1 + 1eb0: 19 f4 brne .+6 ; 0x1eb8 + 1eb2: 20 91 07 02 lds r18, 0x0207 + 1eb6: 01 c0 rjmp .+2 ; 0x1eba + else ch = pgm_read_byte_near(address); + 1eb8: 24 91 lpm r18, Z+ + address++; + 1eba: 80 91 00 02 lds r24, 0x0200 + 1ebe: 90 91 01 02 lds r25, 0x0201 + 1ec2: 01 96 adiw r24, 0x01 ; 1 + 1ec4: 90 93 01 02 sts 0x0201, r25 + 1ec8: 80 93 00 02 sts 0x0200, r24 + putch(ch); + 1ecc: 82 2f mov r24, r18 + 1ece: 19 d0 rcall .+50 ; 0x1f02 + } while (--length); + 1ed0: 80 91 02 02 lds r24, 0x0202 + 1ed4: 81 50 subi r24, 0x01 ; 1 + 1ed6: 80 93 02 02 sts 0x0202, r24 + 1eda: 88 23 and r24, r24 + 1edc: 91 f6 brne .-92 ; 0x1e82 + 1ede: 0e c0 rjmp .+28 ; 0x1efc + while (--length); +#endif + } + + /* Get device signature bytes */ + else if(ch == STK_READ_SIGN) { + 1ee0: 85 37 cpi r24, 0x75 ; 117 + 1ee2: 39 f4 brne .+14 ; 0x1ef2 + // READ SIGN - return what Avrdude wants to hear + verifySpace(); + 1ee4: 3f d0 rcall .+126 ; 0x1f64 + putch(SIGNATURE_0); + 1ee6: 8e e1 ldi r24, 0x1E ; 30 + 1ee8: 0c d0 rcall .+24 ; 0x1f02 + putch(SIGNATURE_1); + 1eea: 83 e9 ldi r24, 0x93 ; 147 + 1eec: 0a d0 rcall .+20 ; 0x1f02 + putch(SIGNATURE_2); + 1eee: 8c e0 ldi r24, 0x0C ; 12 + 1ef0: 51 cf rjmp .-350 ; 0x1d94 + } + else if (ch == 'Q') { + 1ef2: 81 35 cpi r24, 0x51 ; 81 + 1ef4: 11 f4 brne .+4 ; 0x1efa + // Adaboot no-wait mod + watchdogConfig(WATCHDOG_16MS); + 1ef6: 88 e0 ldi r24, 0x08 ; 8 + 1ef8: 2c d0 rcall .+88 ; 0x1f52 + verifySpace(); + } + else { + // This covers the response to commands like STK_ENTER_PROGMODE + verifySpace(); + 1efa: 34 d0 rcall .+104 ; 0x1f64 + } + putch(STK_OK); + 1efc: 80 e1 ldi r24, 0x10 ; 16 + 1efe: 01 d0 rcall .+2 ; 0x1f02 + 1f00: 1e cf rjmp .-452 ; 0x1d3e + +00001f02 : +void putch(char ch) { +#ifndef SOFT_UART + while (!(UCSR0A & _BV(UDRE0))); + UDR0 = ch; +#else + __asm__ __volatile__ ( + 1f02: 2a e0 ldi r18, 0x0A ; 10 + 1f04: 30 e0 ldi r19, 0x00 ; 0 + 1f06: 80 95 com r24 + 1f08: 08 94 sec + 1f0a: 10 f4 brcc .+4 ; 0x1f10 + 1f0c: da 98 cbi 0x1b, 2 ; 27 + 1f0e: 02 c0 rjmp .+4 ; 0x1f14 + 1f10: da 9a sbi 0x1b, 2 ; 27 + 1f12: 00 00 nop + 1f14: 15 d0 rcall .+42 ; 0x1f40 + 1f16: 14 d0 rcall .+40 ; 0x1f40 + 1f18: 86 95 lsr r24 + 1f1a: 2a 95 dec r18 + 1f1c: b1 f7 brne .-20 ; 0x1f0a + [uartBit] "I" (UART_TX_BIT) + : + "r25" + ); +#endif +} + 1f1e: 08 95 ret + +00001f20 : + return getch(); +} + +// Watchdog functions. These are only safe with interrupts turned off. +void watchdogReset() { + __asm__ __volatile__ ( + 1f20: a8 95 wdr +#ifdef LED_DATA_FLASH + LED_PIN |= _BV(LED); +#endif + + return ch; +} + 1f22: 29 e0 ldi r18, 0x09 ; 9 + 1f24: 30 e0 ldi r19, 0x00 ; 0 + 1f26: cb 99 sbic 0x19, 3 ; 25 + 1f28: fe cf rjmp .-4 ; 0x1f26 + 1f2a: 0a d0 rcall .+20 ; 0x1f40 + 1f2c: 09 d0 rcall .+18 ; 0x1f40 + 1f2e: 08 d0 rcall .+16 ; 0x1f40 + 1f30: 88 94 clc + 1f32: cb 99 sbic 0x19, 3 ; 25 + 1f34: 08 94 sec + 1f36: 2a 95 dec r18 + 1f38: 11 f0 breq .+4 ; 0x1f3e + 1f3a: 87 95 ror r24 + 1f3c: f7 cf rjmp .-18 ; 0x1f2c + 1f3e: 08 95 ret + +00001f40 : +#if UART_B_VALUE > 255 +#error Baud rate too slow for soft UART +#endif + +void uartDelay() { + __asm__ __volatile__ ( + 1f40: 9e e0 ldi r25, 0x0E ; 14 + 1f42: 9a 95 dec r25 + 1f44: f1 f7 brne .-4 ; 0x1f42 + 1f46: 08 95 ret + +00001f48 : + } while (--count); +} +#endif + +uint8_t getLen() { + getch(); + 1f48: eb df rcall .-42 ; 0x1f20 + length = getch(); + 1f4a: ea df rcall .-44 ; 0x1f20 + 1f4c: 80 93 02 02 sts 0x0202, r24 + return getch(); +} + 1f50: e7 cf rjmp .-50 ; 0x1f20 + +00001f52 : + "wdr\n" + ); +} + +void watchdogConfig(uint8_t x) { + WDTCSR = _BV(WDCE) | _BV(WDE); + 1f52: 98 e1 ldi r25, 0x18 ; 24 + 1f54: 91 bd out 0x21, r25 ; 33 + WDTCSR = x; + 1f56: 81 bd out 0x21, r24 ; 33 +} + 1f58: 08 95 ret + +00001f5a : + +void appStart() { + watchdogConfig(WATCHDOG_OFF); + 1f5a: 80 e0 ldi r24, 0x00 ; 0 + 1f5c: fa df rcall .-12 ; 0x1f52 + __asm__ __volatile__ ( + 1f5e: e5 e0 ldi r30, 0x05 ; 5 + 1f60: ff 27 eor r31, r31 + 1f62: 09 94 ijmp + +00001f64 : + do getch(); while (--count); + verifySpace(); +} + +void verifySpace() { + if (getch() != CRC_EOP) appStart(); + 1f64: dd df rcall .-70 ; 0x1f20 + 1f66: 80 32 cpi r24, 0x20 ; 32 + 1f68: 09 f0 breq .+2 ; 0x1f6c + 1f6a: f7 df rcall .-18 ; 0x1f5a + putch(STK_INSYNC); + 1f6c: 84 e1 ldi r24, 0x14 ; 20 +} + 1f6e: c9 cf rjmp .-110 ; 0x1f02 + ::[count] "M" (UART_B_VALUE) + ); +} +#endif + +void getNch(uint8_t count) { + 1f70: 1f 93 push r17 + 1f72: 18 2f mov r17, r24 + +00001f74 : + do getch(); while (--count); + 1f74: d5 df rcall .-86 ; 0x1f20 + 1f76: 11 50 subi r17, 0x01 ; 1 + 1f78: e9 f7 brne .-6 ; 0x1f74 + verifySpace(); + 1f7a: f4 df rcall .-24 ; 0x1f64 +} + 1f7c: 1f 91 pop r17 + 1f7e: 08 95 ret diff --git a/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_pro_16MHz.hex b/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_pro_16MHz.hex new file mode 100644 index 0000000..1e93414 --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_pro_16MHz.hex @@ -0,0 +1,33 @@ +:103E000085E08093810082E08093C00088E1809308 +:103E1000C10086E08093C20080E18093C40084B733 +:103E200014BE81FFD0D08DE0C8D0259A86E020E373 +:103E30003CEF91E0309385002093840096BBB09BCB +:103E4000FECF1D9AA8958150A9F7DD24D394A5E053 +:103E5000EA2EF1E1FF2EA4D0813421F481E0BED01E +:103E600083E024C0823411F484E103C0853419F462 +:103E700085E0B4D08AC08535A1F492D0082F10E037 +:103E800010930102009300028BD090E0982F8827B6 +:103E9000802B912B880F991F909301028093000231 +:103EA00073C0863529F484E099D080E071D06DC06C +:103EB000843609F043C07CD0E0910002F091010209 +:103EC00083E080935700E895C0E0D1E069D0899302 +:103ED000809102028150809302028823B9F778D042 +:103EE00007B600FCFDCF4091000250910102A0E016 +:103EF000B1E02C9130E011968C91119790E0982FC1 +:103F00008827822B932B1296FA010C01D09257002E +:103F1000E89511244E5F5F4FF1E0A038BF0749F7E5 +:103F2000E0910002F0910102E0925700E89507B697 +:103F300000FCFDCFF0925700E89527C08437B9F414 +:103F400037D046D0E0910002F09101023196F09313 +:103F50000102E09300023197E4918E2F19D08091F5 +:103F60000202815080930202882361F70EC08537D8 +:103F700039F42ED08EE10CD084E90AD086E096CFB9 +:103F8000813511F488E019D023D080E101D063CFCE +:103F9000982F8091C00085FFFCCF9093C6000895B4 +:103FA000A8958091C00087FFFCCF8091C60008953E +:103FB000F7DFF6DF80930202F3CFE0E6F0E098E16E +:103FC00090838083089580E0F8DFEE27FF2709942F +:103FD000E7DF803209F0F7DF84E1DACF1F93182F93 +:0C3FE000DFDF1150E9F7F4DF1F910895B6 +:0400000300003E00BB +:00000001FF diff --git a/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_pro_16MHz.lst b/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_pro_16MHz.lst new file mode 100644 index 0000000..9920a76 --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_pro_16MHz.lst @@ -0,0 +1,520 @@ + +optiboot_pro_16MHz.elf: file format elf32-avr + +Sections: +Idx Name Size VMA LMA File off Algn + 0 .text 000001ec 00003e00 00003e00 00000054 2**1 + CONTENTS, ALLOC, LOAD, READONLY, CODE + 1 .debug_aranges 00000028 00000000 00000000 00000240 2**0 + CONTENTS, READONLY, DEBUGGING + 2 .debug_pubnames 0000006a 00000000 00000000 00000268 2**0 + CONTENTS, READONLY, DEBUGGING + 3 .debug_info 00000269 00000000 00000000 000002d2 2**0 + CONTENTS, READONLY, DEBUGGING + 4 .debug_abbrev 00000196 00000000 00000000 0000053b 2**0 + CONTENTS, READONLY, DEBUGGING + 5 .debug_line 000003d3 00000000 00000000 000006d1 2**0 + CONTENTS, READONLY, DEBUGGING + 6 .debug_frame 00000090 00000000 00000000 00000aa4 2**2 + CONTENTS, READONLY, DEBUGGING + 7 .debug_str 00000135 00000000 00000000 00000b34 2**0 + CONTENTS, READONLY, DEBUGGING + 8 .debug_loc 000001d1 00000000 00000000 00000c69 2**0 + CONTENTS, READONLY, DEBUGGING + 9 .debug_ranges 00000068 00000000 00000000 00000e3a 2**0 + CONTENTS, READONLY, DEBUGGING + +Disassembly of section .text: + +00003e00
    : +#ifdef VIRTUAL_BOOT_PARTITION +#define rstVect (*(uint16_t*)(0x204)) +#define wdtVect (*(uint16_t*)(0x206)) +#endif +/* main program starts here */ +int main(void) { + 3e00: 85 e0 ldi r24, 0x05 ; 5 + 3e02: 80 93 81 00 sts 0x0081, r24 +#if LED_START_FLASHES > 0 + // Set up Timer 1 for timeout counter + TCCR1B = _BV(CS12) | _BV(CS10); // div 1024 +#endif +#ifndef SOFT_UART + UCSR0A = _BV(U2X0); //Double speed mode USART0 + 3e06: 82 e0 ldi r24, 0x02 ; 2 + 3e08: 80 93 c0 00 sts 0x00C0, r24 + UCSR0B = _BV(RXEN0) | _BV(TXEN0); + 3e0c: 88 e1 ldi r24, 0x18 ; 24 + 3e0e: 80 93 c1 00 sts 0x00C1, r24 + UCSR0C = _BV(UCSZ00) | _BV(UCSZ01); + 3e12: 86 e0 ldi r24, 0x06 ; 6 + 3e14: 80 93 c2 00 sts 0x00C2, r24 + UBRR0L = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 ); + 3e18: 80 e1 ldi r24, 0x10 ; 16 + 3e1a: 80 93 c4 00 sts 0x00C4, r24 +#endif + + // Adaboot no-wait mod + ch = MCUSR; + 3e1e: 84 b7 in r24, 0x34 ; 52 + MCUSR = 0; + 3e20: 14 be out 0x34, r1 ; 52 + if (!(ch & _BV(EXTRF))) appStart(); + 3e22: 81 ff sbrs r24, 1 + 3e24: d0 d0 rcall .+416 ; 0x3fc6 + + // Set up watchdog to trigger after 500ms + watchdogConfig(WATCHDOG_500MS); + 3e26: 8d e0 ldi r24, 0x0D ; 13 + 3e28: c8 d0 rcall .+400 ; 0x3fba + + /* Set LED pin as output */ + LED_DDR |= _BV(LED); + 3e2a: 25 9a sbi 0x04, 5 ; 4 + 3e2c: 86 e0 ldi r24, 0x06 ; 6 +} + +#if LED_START_FLASHES > 0 +void flash_led(uint8_t count) { + do { + TCNT1 = -(F_CPU/(1024*16)); + 3e2e: 20 e3 ldi r18, 0x30 ; 48 + 3e30: 3c ef ldi r19, 0xFC ; 252 + TIFR1 = _BV(TOV1); + 3e32: 91 e0 ldi r25, 0x01 ; 1 +} + +#if LED_START_FLASHES > 0 +void flash_led(uint8_t count) { + do { + TCNT1 = -(F_CPU/(1024*16)); + 3e34: 30 93 85 00 sts 0x0085, r19 + 3e38: 20 93 84 00 sts 0x0084, r18 + TIFR1 = _BV(TOV1); + 3e3c: 96 bb out 0x16, r25 ; 22 + while(!(TIFR1 & _BV(TOV1))); + 3e3e: b0 9b sbis 0x16, 0 ; 22 + 3e40: fe cf rjmp .-4 ; 0x3e3e + LED_PIN |= _BV(LED); + 3e42: 1d 9a sbi 0x03, 5 ; 3 + return getch(); +} + +// Watchdog functions. These are only safe with interrupts turned off. +void watchdogReset() { + __asm__ __volatile__ ( + 3e44: a8 95 wdr + TCNT1 = -(F_CPU/(1024*16)); + TIFR1 = _BV(TOV1); + while(!(TIFR1 & _BV(TOV1))); + LED_PIN |= _BV(LED); + watchdogReset(); + } while (--count); + 3e46: 81 50 subi r24, 0x01 ; 1 + 3e48: a9 f7 brne .-22 ; 0x3e34 + /* get character from UART */ + ch = getch(); + + if(ch == STK_GET_PARAMETER) { + // GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy + getNch(1); + 3e4a: dd 24 eor r13, r13 + 3e4c: d3 94 inc r13 + boot_page_fill((uint16_t)(void*)addrPtr,a); + addrPtr += 2; + } while (--ch); + + // Write from programming buffer + boot_page_write((uint16_t)(void*)address); + 3e4e: a5 e0 ldi r26, 0x05 ; 5 + 3e50: ea 2e mov r14, r26 + boot_spm_busy_wait(); + +#if defined(RWWSRE) + // Reenable read access to flash + boot_rww_enable(); + 3e52: f1 e1 ldi r31, 0x11 ; 17 + 3e54: ff 2e mov r15, r31 +#endif + + /* Forever loop */ + for (;;) { + /* get character from UART */ + ch = getch(); + 3e56: a4 d0 rcall .+328 ; 0x3fa0 + + if(ch == STK_GET_PARAMETER) { + 3e58: 81 34 cpi r24, 0x41 ; 65 + 3e5a: 21 f4 brne .+8 ; 0x3e64 + // GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy + getNch(1); + 3e5c: 81 e0 ldi r24, 0x01 ; 1 + 3e5e: be d0 rcall .+380 ; 0x3fdc + putch(0x03); + 3e60: 83 e0 ldi r24, 0x03 ; 3 + 3e62: 24 c0 rjmp .+72 ; 0x3eac + } + else if(ch == STK_SET_DEVICE) { + 3e64: 82 34 cpi r24, 0x42 ; 66 + 3e66: 11 f4 brne .+4 ; 0x3e6c + // SET DEVICE is ignored + getNch(20); + 3e68: 84 e1 ldi r24, 0x14 ; 20 + 3e6a: 03 c0 rjmp .+6 ; 0x3e72 + } + else if(ch == STK_SET_DEVICE_EXT) { + 3e6c: 85 34 cpi r24, 0x45 ; 69 + 3e6e: 19 f4 brne .+6 ; 0x3e76 + // SET DEVICE EXT is ignored + getNch(5); + 3e70: 85 e0 ldi r24, 0x05 ; 5 + 3e72: b4 d0 rcall .+360 ; 0x3fdc + 3e74: 8a c0 rjmp .+276 ; 0x3f8a + } + else if(ch == STK_LOAD_ADDRESS) { + 3e76: 85 35 cpi r24, 0x55 ; 85 + 3e78: a1 f4 brne .+40 ; 0x3ea2 + // LOAD ADDRESS + address = getch(); + 3e7a: 92 d0 rcall .+292 ; 0x3fa0 + 3e7c: 08 2f mov r16, r24 + 3e7e: 10 e0 ldi r17, 0x00 ; 0 + 3e80: 10 93 01 02 sts 0x0201, r17 + 3e84: 00 93 00 02 sts 0x0200, r16 + address = (address & 0xff) | (getch() << 8); + 3e88: 8b d0 rcall .+278 ; 0x3fa0 + 3e8a: 90 e0 ldi r25, 0x00 ; 0 + 3e8c: 98 2f mov r25, r24 + 3e8e: 88 27 eor r24, r24 + 3e90: 80 2b or r24, r16 + 3e92: 91 2b or r25, r17 + address += address; // Convert from word address to byte address + 3e94: 88 0f add r24, r24 + 3e96: 99 1f adc r25, r25 + 3e98: 90 93 01 02 sts 0x0201, r25 + 3e9c: 80 93 00 02 sts 0x0200, r24 + 3ea0: 73 c0 rjmp .+230 ; 0x3f88 + verifySpace(); + } + else if(ch == STK_UNIVERSAL) { + 3ea2: 86 35 cpi r24, 0x56 ; 86 + 3ea4: 29 f4 brne .+10 ; 0x3eb0 + // UNIVERSAL command is ignored + getNch(4); + 3ea6: 84 e0 ldi r24, 0x04 ; 4 + 3ea8: 99 d0 rcall .+306 ; 0x3fdc + putch(0x00); + 3eaa: 80 e0 ldi r24, 0x00 ; 0 + 3eac: 71 d0 rcall .+226 ; 0x3f90 + 3eae: 6d c0 rjmp .+218 ; 0x3f8a + } + /* Write memory, length is big endian and is in bytes */ + else if(ch == STK_PROG_PAGE) { + 3eb0: 84 36 cpi r24, 0x64 ; 100 + 3eb2: 09 f0 breq .+2 ; 0x3eb6 + 3eb4: 43 c0 rjmp .+134 ; 0x3f3c + // PROGRAM PAGE - we support flash programming only, not EEPROM + uint8_t *bufPtr; + uint16_t addrPtr; + + getLen(); + 3eb6: 7c d0 rcall .+248 ; 0x3fb0 + + // Immediately start page erase - this will 4.5ms + boot_page_erase((uint16_t)(void*)address); + 3eb8: e0 91 00 02 lds r30, 0x0200 + 3ebc: f0 91 01 02 lds r31, 0x0201 + 3ec0: 83 e0 ldi r24, 0x03 ; 3 + 3ec2: 80 93 57 00 sts 0x0057, r24 + 3ec6: e8 95 spm + 3ec8: c0 e0 ldi r28, 0x00 ; 0 + 3eca: d1 e0 ldi r29, 0x01 ; 1 + + // While that is going on, read in page contents + bufPtr = buff; + do *bufPtr++ = getch(); + 3ecc: 69 d0 rcall .+210 ; 0x3fa0 + 3ece: 89 93 st Y+, r24 + while (--length); + 3ed0: 80 91 02 02 lds r24, 0x0202 + 3ed4: 81 50 subi r24, 0x01 ; 1 + 3ed6: 80 93 02 02 sts 0x0202, r24 + 3eda: 88 23 and r24, r24 + 3edc: b9 f7 brne .-18 ; 0x3ecc + + // Read command terminator, start reply + verifySpace(); + 3ede: 78 d0 rcall .+240 ; 0x3fd0 + + // If only a partial page is to be programmed, the erase might not be complete. + // So check that here + boot_spm_busy_wait(); + 3ee0: 07 b6 in r0, 0x37 ; 55 + 3ee2: 00 fc sbrc r0, 0 + 3ee4: fd cf rjmp .-6 ; 0x3ee0 + } +#endif + + // Copy buffer into programming buffer + bufPtr = buff; + addrPtr = (uint16_t)(void*)address; + 3ee6: 40 91 00 02 lds r20, 0x0200 + 3eea: 50 91 01 02 lds r21, 0x0201 + 3eee: a0 e0 ldi r26, 0x00 ; 0 + 3ef0: b1 e0 ldi r27, 0x01 ; 1 + ch = SPM_PAGESIZE / 2; + do { + uint16_t a; + a = *bufPtr++; + 3ef2: 2c 91 ld r18, X + 3ef4: 30 e0 ldi r19, 0x00 ; 0 + a |= (*bufPtr++) << 8; + 3ef6: 11 96 adiw r26, 0x01 ; 1 + 3ef8: 8c 91 ld r24, X + 3efa: 11 97 sbiw r26, 0x01 ; 1 + 3efc: 90 e0 ldi r25, 0x00 ; 0 + 3efe: 98 2f mov r25, r24 + 3f00: 88 27 eor r24, r24 + 3f02: 82 2b or r24, r18 + 3f04: 93 2b or r25, r19 +#ifdef VIRTUAL_BOOT_PARTITION +#define rstVect (*(uint16_t*)(0x204)) +#define wdtVect (*(uint16_t*)(0x206)) +#endif +/* main program starts here */ +int main(void) { + 3f06: 12 96 adiw r26, 0x02 ; 2 + ch = SPM_PAGESIZE / 2; + do { + uint16_t a; + a = *bufPtr++; + a |= (*bufPtr++) << 8; + boot_page_fill((uint16_t)(void*)addrPtr,a); + 3f08: fa 01 movw r30, r20 + 3f0a: 0c 01 movw r0, r24 + 3f0c: d0 92 57 00 sts 0x0057, r13 + 3f10: e8 95 spm + 3f12: 11 24 eor r1, r1 + addrPtr += 2; + 3f14: 4e 5f subi r20, 0xFE ; 254 + 3f16: 5f 4f sbci r21, 0xFF ; 255 + } while (--ch); + 3f18: f1 e0 ldi r31, 0x01 ; 1 + 3f1a: a0 38 cpi r26, 0x80 ; 128 + 3f1c: bf 07 cpc r27, r31 + 3f1e: 49 f7 brne .-46 ; 0x3ef2 + + // Write from programming buffer + boot_page_write((uint16_t)(void*)address); + 3f20: e0 91 00 02 lds r30, 0x0200 + 3f24: f0 91 01 02 lds r31, 0x0201 + 3f28: e0 92 57 00 sts 0x0057, r14 + 3f2c: e8 95 spm + boot_spm_busy_wait(); + 3f2e: 07 b6 in r0, 0x37 ; 55 + 3f30: 00 fc sbrc r0, 0 + 3f32: fd cf rjmp .-6 ; 0x3f2e + +#if defined(RWWSRE) + // Reenable read access to flash + boot_rww_enable(); + 3f34: f0 92 57 00 sts 0x0057, r15 + 3f38: e8 95 spm + 3f3a: 27 c0 rjmp .+78 ; 0x3f8a +#endif + + } + /* Read memory block mode, length is big endian. */ + else if(ch == STK_READ_PAGE) { + 3f3c: 84 37 cpi r24, 0x74 ; 116 + 3f3e: b9 f4 brne .+46 ; 0x3f6e + // READ PAGE - we only read flash + getLen(); + 3f40: 37 d0 rcall .+110 ; 0x3fb0 + verifySpace(); + 3f42: 46 d0 rcall .+140 ; 0x3fd0 + else ch = pgm_read_byte_near(address); + address++; + putch(ch); + } while (--length); +#else + do putch(pgm_read_byte_near(address++)); + 3f44: e0 91 00 02 lds r30, 0x0200 + 3f48: f0 91 01 02 lds r31, 0x0201 + 3f4c: 31 96 adiw r30, 0x01 ; 1 + 3f4e: f0 93 01 02 sts 0x0201, r31 + 3f52: e0 93 00 02 sts 0x0200, r30 + 3f56: 31 97 sbiw r30, 0x01 ; 1 + 3f58: e4 91 lpm r30, Z+ + 3f5a: 8e 2f mov r24, r30 + 3f5c: 19 d0 rcall .+50 ; 0x3f90 + while (--length); + 3f5e: 80 91 02 02 lds r24, 0x0202 + 3f62: 81 50 subi r24, 0x01 ; 1 + 3f64: 80 93 02 02 sts 0x0202, r24 + 3f68: 88 23 and r24, r24 + 3f6a: 61 f7 brne .-40 ; 0x3f44 + 3f6c: 0e c0 rjmp .+28 ; 0x3f8a +#endif + } + + /* Get device signature bytes */ + else if(ch == STK_READ_SIGN) { + 3f6e: 85 37 cpi r24, 0x75 ; 117 + 3f70: 39 f4 brne .+14 ; 0x3f80 + // READ SIGN - return what Avrdude wants to hear + verifySpace(); + 3f72: 2e d0 rcall .+92 ; 0x3fd0 + putch(SIGNATURE_0); + 3f74: 8e e1 ldi r24, 0x1E ; 30 + 3f76: 0c d0 rcall .+24 ; 0x3f90 + putch(SIGNATURE_1); + 3f78: 84 e9 ldi r24, 0x94 ; 148 + 3f7a: 0a d0 rcall .+20 ; 0x3f90 + putch(SIGNATURE_2); + 3f7c: 86 e0 ldi r24, 0x06 ; 6 + 3f7e: 96 cf rjmp .-212 ; 0x3eac + } + else if (ch == 'Q') { + 3f80: 81 35 cpi r24, 0x51 ; 81 + 3f82: 11 f4 brne .+4 ; 0x3f88 + // Adaboot no-wait mod + watchdogConfig(WATCHDOG_16MS); + 3f84: 88 e0 ldi r24, 0x08 ; 8 + 3f86: 19 d0 rcall .+50 ; 0x3fba + verifySpace(); + } + else { + // This covers the response to commands like STK_ENTER_PROGMODE + verifySpace(); + 3f88: 23 d0 rcall .+70 ; 0x3fd0 + } + putch(STK_OK); + 3f8a: 80 e1 ldi r24, 0x10 ; 16 + 3f8c: 01 d0 rcall .+2 ; 0x3f90 + 3f8e: 63 cf rjmp .-314 ; 0x3e56 + +00003f90 : + } +} + +void putch(char ch) { + 3f90: 98 2f mov r25, r24 +#ifndef SOFT_UART + while (!(UCSR0A & _BV(UDRE0))); + 3f92: 80 91 c0 00 lds r24, 0x00C0 + 3f96: 85 ff sbrs r24, 5 + 3f98: fc cf rjmp .-8 ; 0x3f92 + UDR0 = ch; + 3f9a: 90 93 c6 00 sts 0x00C6, r25 + [uartBit] "I" (UART_TX_BIT) + : + "r25" + ); +#endif +} + 3f9e: 08 95 ret + +00003fa0 : + return getch(); +} + +// Watchdog functions. These are only safe with interrupts turned off. +void watchdogReset() { + __asm__ __volatile__ ( + 3fa0: a8 95 wdr + [uartBit] "I" (UART_RX_BIT) + : + "r25" +); +#else + while(!(UCSR0A & _BV(RXC0))); + 3fa2: 80 91 c0 00 lds r24, 0x00C0 + 3fa6: 87 ff sbrs r24, 7 + 3fa8: fc cf rjmp .-8 ; 0x3fa2 + ch = UDR0; + 3faa: 80 91 c6 00 lds r24, 0x00C6 +#ifdef LED_DATA_FLASH + LED_PIN |= _BV(LED); +#endif + + return ch; +} + 3fae: 08 95 ret + +00003fb0 : + } while (--count); +} +#endif + +uint8_t getLen() { + getch(); + 3fb0: f7 df rcall .-18 ; 0x3fa0 + length = getch(); + 3fb2: f6 df rcall .-20 ; 0x3fa0 + 3fb4: 80 93 02 02 sts 0x0202, r24 + return getch(); +} + 3fb8: f3 cf rjmp .-26 ; 0x3fa0 + +00003fba : + "wdr\n" + ); +} + +void watchdogConfig(uint8_t x) { + WDTCSR = _BV(WDCE) | _BV(WDE); + 3fba: e0 e6 ldi r30, 0x60 ; 96 + 3fbc: f0 e0 ldi r31, 0x00 ; 0 + 3fbe: 98 e1 ldi r25, 0x18 ; 24 + 3fc0: 90 83 st Z, r25 + WDTCSR = x; + 3fc2: 80 83 st Z, r24 +} + 3fc4: 08 95 ret + +00003fc6 : + +void appStart() { + watchdogConfig(WATCHDOG_OFF); + 3fc6: 80 e0 ldi r24, 0x00 ; 0 + 3fc8: f8 df rcall .-16 ; 0x3fba + __asm__ __volatile__ ( + 3fca: ee 27 eor r30, r30 + 3fcc: ff 27 eor r31, r31 + 3fce: 09 94 ijmp + +00003fd0 : + do getch(); while (--count); + verifySpace(); +} + +void verifySpace() { + if (getch() != CRC_EOP) appStart(); + 3fd0: e7 df rcall .-50 ; 0x3fa0 + 3fd2: 80 32 cpi r24, 0x20 ; 32 + 3fd4: 09 f0 breq .+2 ; 0x3fd8 + 3fd6: f7 df rcall .-18 ; 0x3fc6 + putch(STK_INSYNC); + 3fd8: 84 e1 ldi r24, 0x14 ; 20 +} + 3fda: da cf rjmp .-76 ; 0x3f90 + ::[count] "M" (UART_B_VALUE) + ); +} +#endif + +void getNch(uint8_t count) { + 3fdc: 1f 93 push r17 + 3fde: 18 2f mov r17, r24 + +00003fe0 : + do getch(); while (--count); + 3fe0: df df rcall .-66 ; 0x3fa0 + 3fe2: 11 50 subi r17, 0x01 ; 1 + 3fe4: e9 f7 brne .-6 ; 0x3fe0 + verifySpace(); + 3fe6: f4 df rcall .-24 ; 0x3fd0 +} + 3fe8: 1f 91 pop r17 + 3fea: 08 95 ret diff --git a/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_pro_20mhz.hex b/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_pro_20mhz.hex new file mode 100644 index 0000000..19c9ae4 --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_pro_20mhz.hex @@ -0,0 +1,33 @@ +:103E000085E08093810082E08093C00088E1809308 +:103E1000C10086E08093C20085E18093C40084B72E +:103E200014BE81FFD0D08DE0C8D0259A86E02CE367 +:103E30003BEF91E0309385002093840096BBB09BCC +:103E4000FECF1D9AA8958150A9F7DD24D394A5E053 +:103E5000EA2EF1E1FF2EA4D0813421F481E0BED01E +:103E600083E024C0823411F484E103C0853419F462 +:103E700085E0B4D08AC08535A1F492D0082F10E037 +:103E800010930102009300028BD090E0982F8827B6 +:103E9000802B912B880F991F909301028093000231 +:103EA00073C0863529F484E099D080E071D06DC06C +:103EB000843609F043C07CD0E0910002F091010209 +:103EC00083E080935700E895C0E0D1E069D0899302 +:103ED000809102028150809302028823B9F778D042 +:103EE00007B600FCFDCF4091000250910102A0E016 +:103EF000B1E02C9130E011968C91119790E0982FC1 +:103F00008827822B932B1296FA010C01D09257002E +:103F1000E89511244E5F5F4FF1E0A038BF0749F7E5 +:103F2000E0910002F0910102E0925700E89507B697 +:103F300000FCFDCFF0925700E89527C08437B9F414 +:103F400037D046D0E0910002F09101023196F09313 +:103F50000102E09300023197E4918E2F19D08091F5 +:103F60000202815080930202882361F70EC08537D8 +:103F700039F42ED08EE10CD084E90AD086E096CFB9 +:103F8000813511F488E019D023D080E101D063CFCE +:103F9000982F8091C00085FFFCCF9093C6000895B4 +:103FA000A8958091C00087FFFCCF8091C60008953E +:103FB000F7DFF6DF80930202F3CFE0E6F0E098E16E +:103FC00090838083089580E0F8DFEE27FF2709942F +:103FD000E7DF803209F0F7DF84E1DACF1F93182F93 +:0C3FE000DFDF1150E9F7F4DF1F910895B6 +:0400000300003E00BB +:00000001FF diff --git a/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_pro_20mhz.lst b/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_pro_20mhz.lst new file mode 100644 index 0000000..62178d3 --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_pro_20mhz.lst @@ -0,0 +1,520 @@ + +optiboot_pro_20mhz.elf: file format elf32-avr + +Sections: +Idx Name Size VMA LMA File off Algn + 0 .text 000001ec 00003e00 00003e00 00000054 2**1 + CONTENTS, ALLOC, LOAD, READONLY, CODE + 1 .debug_aranges 00000028 00000000 00000000 00000240 2**0 + CONTENTS, READONLY, DEBUGGING + 2 .debug_pubnames 0000006a 00000000 00000000 00000268 2**0 + CONTENTS, READONLY, DEBUGGING + 3 .debug_info 00000269 00000000 00000000 000002d2 2**0 + CONTENTS, READONLY, DEBUGGING + 4 .debug_abbrev 00000196 00000000 00000000 0000053b 2**0 + CONTENTS, READONLY, DEBUGGING + 5 .debug_line 000003d3 00000000 00000000 000006d1 2**0 + CONTENTS, READONLY, DEBUGGING + 6 .debug_frame 00000090 00000000 00000000 00000aa4 2**2 + CONTENTS, READONLY, DEBUGGING + 7 .debug_str 00000135 00000000 00000000 00000b34 2**0 + CONTENTS, READONLY, DEBUGGING + 8 .debug_loc 000001d1 00000000 00000000 00000c69 2**0 + CONTENTS, READONLY, DEBUGGING + 9 .debug_ranges 00000068 00000000 00000000 00000e3a 2**0 + CONTENTS, READONLY, DEBUGGING + +Disassembly of section .text: + +00003e00
    : +#ifdef VIRTUAL_BOOT_PARTITION +#define rstVect (*(uint16_t*)(0x204)) +#define wdtVect (*(uint16_t*)(0x206)) +#endif +/* main program starts here */ +int main(void) { + 3e00: 85 e0 ldi r24, 0x05 ; 5 + 3e02: 80 93 81 00 sts 0x0081, r24 +#if LED_START_FLASHES > 0 + // Set up Timer 1 for timeout counter + TCCR1B = _BV(CS12) | _BV(CS10); // div 1024 +#endif +#ifndef SOFT_UART + UCSR0A = _BV(U2X0); //Double speed mode USART0 + 3e06: 82 e0 ldi r24, 0x02 ; 2 + 3e08: 80 93 c0 00 sts 0x00C0, r24 + UCSR0B = _BV(RXEN0) | _BV(TXEN0); + 3e0c: 88 e1 ldi r24, 0x18 ; 24 + 3e0e: 80 93 c1 00 sts 0x00C1, r24 + UCSR0C = _BV(UCSZ00) | _BV(UCSZ01); + 3e12: 86 e0 ldi r24, 0x06 ; 6 + 3e14: 80 93 c2 00 sts 0x00C2, r24 + UBRR0L = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 ); + 3e18: 85 e1 ldi r24, 0x15 ; 21 + 3e1a: 80 93 c4 00 sts 0x00C4, r24 +#endif + + // Adaboot no-wait mod + ch = MCUSR; + 3e1e: 84 b7 in r24, 0x34 ; 52 + MCUSR = 0; + 3e20: 14 be out 0x34, r1 ; 52 + if (!(ch & _BV(EXTRF))) appStart(); + 3e22: 81 ff sbrs r24, 1 + 3e24: d0 d0 rcall .+416 ; 0x3fc6 + + // Set up watchdog to trigger after 500ms + watchdogConfig(WATCHDOG_500MS); + 3e26: 8d e0 ldi r24, 0x0D ; 13 + 3e28: c8 d0 rcall .+400 ; 0x3fba + + /* Set LED pin as output */ + LED_DDR |= _BV(LED); + 3e2a: 25 9a sbi 0x04, 5 ; 4 + 3e2c: 86 e0 ldi r24, 0x06 ; 6 +} + +#if LED_START_FLASHES > 0 +void flash_led(uint8_t count) { + do { + TCNT1 = -(F_CPU/(1024*16)); + 3e2e: 2c e3 ldi r18, 0x3C ; 60 + 3e30: 3b ef ldi r19, 0xFB ; 251 + TIFR1 = _BV(TOV1); + 3e32: 91 e0 ldi r25, 0x01 ; 1 +} + +#if LED_START_FLASHES > 0 +void flash_led(uint8_t count) { + do { + TCNT1 = -(F_CPU/(1024*16)); + 3e34: 30 93 85 00 sts 0x0085, r19 + 3e38: 20 93 84 00 sts 0x0084, r18 + TIFR1 = _BV(TOV1); + 3e3c: 96 bb out 0x16, r25 ; 22 + while(!(TIFR1 & _BV(TOV1))); + 3e3e: b0 9b sbis 0x16, 0 ; 22 + 3e40: fe cf rjmp .-4 ; 0x3e3e + LED_PIN |= _BV(LED); + 3e42: 1d 9a sbi 0x03, 5 ; 3 + return getch(); +} + +// Watchdog functions. These are only safe with interrupts turned off. +void watchdogReset() { + __asm__ __volatile__ ( + 3e44: a8 95 wdr + TCNT1 = -(F_CPU/(1024*16)); + TIFR1 = _BV(TOV1); + while(!(TIFR1 & _BV(TOV1))); + LED_PIN |= _BV(LED); + watchdogReset(); + } while (--count); + 3e46: 81 50 subi r24, 0x01 ; 1 + 3e48: a9 f7 brne .-22 ; 0x3e34 + /* get character from UART */ + ch = getch(); + + if(ch == STK_GET_PARAMETER) { + // GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy + getNch(1); + 3e4a: dd 24 eor r13, r13 + 3e4c: d3 94 inc r13 + boot_page_fill((uint16_t)(void*)addrPtr,a); + addrPtr += 2; + } while (--ch); + + // Write from programming buffer + boot_page_write((uint16_t)(void*)address); + 3e4e: a5 e0 ldi r26, 0x05 ; 5 + 3e50: ea 2e mov r14, r26 + boot_spm_busy_wait(); + +#if defined(RWWSRE) + // Reenable read access to flash + boot_rww_enable(); + 3e52: f1 e1 ldi r31, 0x11 ; 17 + 3e54: ff 2e mov r15, r31 +#endif + + /* Forever loop */ + for (;;) { + /* get character from UART */ + ch = getch(); + 3e56: a4 d0 rcall .+328 ; 0x3fa0 + + if(ch == STK_GET_PARAMETER) { + 3e58: 81 34 cpi r24, 0x41 ; 65 + 3e5a: 21 f4 brne .+8 ; 0x3e64 + // GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy + getNch(1); + 3e5c: 81 e0 ldi r24, 0x01 ; 1 + 3e5e: be d0 rcall .+380 ; 0x3fdc + putch(0x03); + 3e60: 83 e0 ldi r24, 0x03 ; 3 + 3e62: 24 c0 rjmp .+72 ; 0x3eac + } + else if(ch == STK_SET_DEVICE) { + 3e64: 82 34 cpi r24, 0x42 ; 66 + 3e66: 11 f4 brne .+4 ; 0x3e6c + // SET DEVICE is ignored + getNch(20); + 3e68: 84 e1 ldi r24, 0x14 ; 20 + 3e6a: 03 c0 rjmp .+6 ; 0x3e72 + } + else if(ch == STK_SET_DEVICE_EXT) { + 3e6c: 85 34 cpi r24, 0x45 ; 69 + 3e6e: 19 f4 brne .+6 ; 0x3e76 + // SET DEVICE EXT is ignored + getNch(5); + 3e70: 85 e0 ldi r24, 0x05 ; 5 + 3e72: b4 d0 rcall .+360 ; 0x3fdc + 3e74: 8a c0 rjmp .+276 ; 0x3f8a + } + else if(ch == STK_LOAD_ADDRESS) { + 3e76: 85 35 cpi r24, 0x55 ; 85 + 3e78: a1 f4 brne .+40 ; 0x3ea2 + // LOAD ADDRESS + address = getch(); + 3e7a: 92 d0 rcall .+292 ; 0x3fa0 + 3e7c: 08 2f mov r16, r24 + 3e7e: 10 e0 ldi r17, 0x00 ; 0 + 3e80: 10 93 01 02 sts 0x0201, r17 + 3e84: 00 93 00 02 sts 0x0200, r16 + address = (address & 0xff) | (getch() << 8); + 3e88: 8b d0 rcall .+278 ; 0x3fa0 + 3e8a: 90 e0 ldi r25, 0x00 ; 0 + 3e8c: 98 2f mov r25, r24 + 3e8e: 88 27 eor r24, r24 + 3e90: 80 2b or r24, r16 + 3e92: 91 2b or r25, r17 + address += address; // Convert from word address to byte address + 3e94: 88 0f add r24, r24 + 3e96: 99 1f adc r25, r25 + 3e98: 90 93 01 02 sts 0x0201, r25 + 3e9c: 80 93 00 02 sts 0x0200, r24 + 3ea0: 73 c0 rjmp .+230 ; 0x3f88 + verifySpace(); + } + else if(ch == STK_UNIVERSAL) { + 3ea2: 86 35 cpi r24, 0x56 ; 86 + 3ea4: 29 f4 brne .+10 ; 0x3eb0 + // UNIVERSAL command is ignored + getNch(4); + 3ea6: 84 e0 ldi r24, 0x04 ; 4 + 3ea8: 99 d0 rcall .+306 ; 0x3fdc + putch(0x00); + 3eaa: 80 e0 ldi r24, 0x00 ; 0 + 3eac: 71 d0 rcall .+226 ; 0x3f90 + 3eae: 6d c0 rjmp .+218 ; 0x3f8a + } + /* Write memory, length is big endian and is in bytes */ + else if(ch == STK_PROG_PAGE) { + 3eb0: 84 36 cpi r24, 0x64 ; 100 + 3eb2: 09 f0 breq .+2 ; 0x3eb6 + 3eb4: 43 c0 rjmp .+134 ; 0x3f3c + // PROGRAM PAGE - we support flash programming only, not EEPROM + uint8_t *bufPtr; + uint16_t addrPtr; + + getLen(); + 3eb6: 7c d0 rcall .+248 ; 0x3fb0 + + // Immediately start page erase - this will 4.5ms + boot_page_erase((uint16_t)(void*)address); + 3eb8: e0 91 00 02 lds r30, 0x0200 + 3ebc: f0 91 01 02 lds r31, 0x0201 + 3ec0: 83 e0 ldi r24, 0x03 ; 3 + 3ec2: 80 93 57 00 sts 0x0057, r24 + 3ec6: e8 95 spm + 3ec8: c0 e0 ldi r28, 0x00 ; 0 + 3eca: d1 e0 ldi r29, 0x01 ; 1 + + // While that is going on, read in page contents + bufPtr = buff; + do *bufPtr++ = getch(); + 3ecc: 69 d0 rcall .+210 ; 0x3fa0 + 3ece: 89 93 st Y+, r24 + while (--length); + 3ed0: 80 91 02 02 lds r24, 0x0202 + 3ed4: 81 50 subi r24, 0x01 ; 1 + 3ed6: 80 93 02 02 sts 0x0202, r24 + 3eda: 88 23 and r24, r24 + 3edc: b9 f7 brne .-18 ; 0x3ecc + + // Read command terminator, start reply + verifySpace(); + 3ede: 78 d0 rcall .+240 ; 0x3fd0 + + // If only a partial page is to be programmed, the erase might not be complete. + // So check that here + boot_spm_busy_wait(); + 3ee0: 07 b6 in r0, 0x37 ; 55 + 3ee2: 00 fc sbrc r0, 0 + 3ee4: fd cf rjmp .-6 ; 0x3ee0 + } +#endif + + // Copy buffer into programming buffer + bufPtr = buff; + addrPtr = (uint16_t)(void*)address; + 3ee6: 40 91 00 02 lds r20, 0x0200 + 3eea: 50 91 01 02 lds r21, 0x0201 + 3eee: a0 e0 ldi r26, 0x00 ; 0 + 3ef0: b1 e0 ldi r27, 0x01 ; 1 + ch = SPM_PAGESIZE / 2; + do { + uint16_t a; + a = *bufPtr++; + 3ef2: 2c 91 ld r18, X + 3ef4: 30 e0 ldi r19, 0x00 ; 0 + a |= (*bufPtr++) << 8; + 3ef6: 11 96 adiw r26, 0x01 ; 1 + 3ef8: 8c 91 ld r24, X + 3efa: 11 97 sbiw r26, 0x01 ; 1 + 3efc: 90 e0 ldi r25, 0x00 ; 0 + 3efe: 98 2f mov r25, r24 + 3f00: 88 27 eor r24, r24 + 3f02: 82 2b or r24, r18 + 3f04: 93 2b or r25, r19 +#ifdef VIRTUAL_BOOT_PARTITION +#define rstVect (*(uint16_t*)(0x204)) +#define wdtVect (*(uint16_t*)(0x206)) +#endif +/* main program starts here */ +int main(void) { + 3f06: 12 96 adiw r26, 0x02 ; 2 + ch = SPM_PAGESIZE / 2; + do { + uint16_t a; + a = *bufPtr++; + a |= (*bufPtr++) << 8; + boot_page_fill((uint16_t)(void*)addrPtr,a); + 3f08: fa 01 movw r30, r20 + 3f0a: 0c 01 movw r0, r24 + 3f0c: d0 92 57 00 sts 0x0057, r13 + 3f10: e8 95 spm + 3f12: 11 24 eor r1, r1 + addrPtr += 2; + 3f14: 4e 5f subi r20, 0xFE ; 254 + 3f16: 5f 4f sbci r21, 0xFF ; 255 + } while (--ch); + 3f18: f1 e0 ldi r31, 0x01 ; 1 + 3f1a: a0 38 cpi r26, 0x80 ; 128 + 3f1c: bf 07 cpc r27, r31 + 3f1e: 49 f7 brne .-46 ; 0x3ef2 + + // Write from programming buffer + boot_page_write((uint16_t)(void*)address); + 3f20: e0 91 00 02 lds r30, 0x0200 + 3f24: f0 91 01 02 lds r31, 0x0201 + 3f28: e0 92 57 00 sts 0x0057, r14 + 3f2c: e8 95 spm + boot_spm_busy_wait(); + 3f2e: 07 b6 in r0, 0x37 ; 55 + 3f30: 00 fc sbrc r0, 0 + 3f32: fd cf rjmp .-6 ; 0x3f2e + +#if defined(RWWSRE) + // Reenable read access to flash + boot_rww_enable(); + 3f34: f0 92 57 00 sts 0x0057, r15 + 3f38: e8 95 spm + 3f3a: 27 c0 rjmp .+78 ; 0x3f8a +#endif + + } + /* Read memory block mode, length is big endian. */ + else if(ch == STK_READ_PAGE) { + 3f3c: 84 37 cpi r24, 0x74 ; 116 + 3f3e: b9 f4 brne .+46 ; 0x3f6e + // READ PAGE - we only read flash + getLen(); + 3f40: 37 d0 rcall .+110 ; 0x3fb0 + verifySpace(); + 3f42: 46 d0 rcall .+140 ; 0x3fd0 + else ch = pgm_read_byte_near(address); + address++; + putch(ch); + } while (--length); +#else + do putch(pgm_read_byte_near(address++)); + 3f44: e0 91 00 02 lds r30, 0x0200 + 3f48: f0 91 01 02 lds r31, 0x0201 + 3f4c: 31 96 adiw r30, 0x01 ; 1 + 3f4e: f0 93 01 02 sts 0x0201, r31 + 3f52: e0 93 00 02 sts 0x0200, r30 + 3f56: 31 97 sbiw r30, 0x01 ; 1 + 3f58: e4 91 lpm r30, Z+ + 3f5a: 8e 2f mov r24, r30 + 3f5c: 19 d0 rcall .+50 ; 0x3f90 + while (--length); + 3f5e: 80 91 02 02 lds r24, 0x0202 + 3f62: 81 50 subi r24, 0x01 ; 1 + 3f64: 80 93 02 02 sts 0x0202, r24 + 3f68: 88 23 and r24, r24 + 3f6a: 61 f7 brne .-40 ; 0x3f44 + 3f6c: 0e c0 rjmp .+28 ; 0x3f8a +#endif + } + + /* Get device signature bytes */ + else if(ch == STK_READ_SIGN) { + 3f6e: 85 37 cpi r24, 0x75 ; 117 + 3f70: 39 f4 brne .+14 ; 0x3f80 + // READ SIGN - return what Avrdude wants to hear + verifySpace(); + 3f72: 2e d0 rcall .+92 ; 0x3fd0 + putch(SIGNATURE_0); + 3f74: 8e e1 ldi r24, 0x1E ; 30 + 3f76: 0c d0 rcall .+24 ; 0x3f90 + putch(SIGNATURE_1); + 3f78: 84 e9 ldi r24, 0x94 ; 148 + 3f7a: 0a d0 rcall .+20 ; 0x3f90 + putch(SIGNATURE_2); + 3f7c: 86 e0 ldi r24, 0x06 ; 6 + 3f7e: 96 cf rjmp .-212 ; 0x3eac + } + else if (ch == 'Q') { + 3f80: 81 35 cpi r24, 0x51 ; 81 + 3f82: 11 f4 brne .+4 ; 0x3f88 + // Adaboot no-wait mod + watchdogConfig(WATCHDOG_16MS); + 3f84: 88 e0 ldi r24, 0x08 ; 8 + 3f86: 19 d0 rcall .+50 ; 0x3fba + verifySpace(); + } + else { + // This covers the response to commands like STK_ENTER_PROGMODE + verifySpace(); + 3f88: 23 d0 rcall .+70 ; 0x3fd0 + } + putch(STK_OK); + 3f8a: 80 e1 ldi r24, 0x10 ; 16 + 3f8c: 01 d0 rcall .+2 ; 0x3f90 + 3f8e: 63 cf rjmp .-314 ; 0x3e56 + +00003f90 : + } +} + +void putch(char ch) { + 3f90: 98 2f mov r25, r24 +#ifndef SOFT_UART + while (!(UCSR0A & _BV(UDRE0))); + 3f92: 80 91 c0 00 lds r24, 0x00C0 + 3f96: 85 ff sbrs r24, 5 + 3f98: fc cf rjmp .-8 ; 0x3f92 + UDR0 = ch; + 3f9a: 90 93 c6 00 sts 0x00C6, r25 + [uartBit] "I" (UART_TX_BIT) + : + "r25" + ); +#endif +} + 3f9e: 08 95 ret + +00003fa0 : + return getch(); +} + +// Watchdog functions. These are only safe with interrupts turned off. +void watchdogReset() { + __asm__ __volatile__ ( + 3fa0: a8 95 wdr + [uartBit] "I" (UART_RX_BIT) + : + "r25" +); +#else + while(!(UCSR0A & _BV(RXC0))); + 3fa2: 80 91 c0 00 lds r24, 0x00C0 + 3fa6: 87 ff sbrs r24, 7 + 3fa8: fc cf rjmp .-8 ; 0x3fa2 + ch = UDR0; + 3faa: 80 91 c6 00 lds r24, 0x00C6 +#ifdef LED_DATA_FLASH + LED_PIN |= _BV(LED); +#endif + + return ch; +} + 3fae: 08 95 ret + +00003fb0 : + } while (--count); +} +#endif + +uint8_t getLen() { + getch(); + 3fb0: f7 df rcall .-18 ; 0x3fa0 + length = getch(); + 3fb2: f6 df rcall .-20 ; 0x3fa0 + 3fb4: 80 93 02 02 sts 0x0202, r24 + return getch(); +} + 3fb8: f3 cf rjmp .-26 ; 0x3fa0 + +00003fba : + "wdr\n" + ); +} + +void watchdogConfig(uint8_t x) { + WDTCSR = _BV(WDCE) | _BV(WDE); + 3fba: e0 e6 ldi r30, 0x60 ; 96 + 3fbc: f0 e0 ldi r31, 0x00 ; 0 + 3fbe: 98 e1 ldi r25, 0x18 ; 24 + 3fc0: 90 83 st Z, r25 + WDTCSR = x; + 3fc2: 80 83 st Z, r24 +} + 3fc4: 08 95 ret + +00003fc6 : + +void appStart() { + watchdogConfig(WATCHDOG_OFF); + 3fc6: 80 e0 ldi r24, 0x00 ; 0 + 3fc8: f8 df rcall .-16 ; 0x3fba + __asm__ __volatile__ ( + 3fca: ee 27 eor r30, r30 + 3fcc: ff 27 eor r31, r31 + 3fce: 09 94 ijmp + +00003fd0 : + do getch(); while (--count); + verifySpace(); +} + +void verifySpace() { + if (getch() != CRC_EOP) appStart(); + 3fd0: e7 df rcall .-50 ; 0x3fa0 + 3fd2: 80 32 cpi r24, 0x20 ; 32 + 3fd4: 09 f0 breq .+2 ; 0x3fd8 + 3fd6: f7 df rcall .-18 ; 0x3fc6 + putch(STK_INSYNC); + 3fd8: 84 e1 ldi r24, 0x14 ; 20 +} + 3fda: da cf rjmp .-76 ; 0x3f90 + ::[count] "M" (UART_B_VALUE) + ); +} +#endif + +void getNch(uint8_t count) { + 3fdc: 1f 93 push r17 + 3fde: 18 2f mov r17, r24 + +00003fe0 : + do getch(); while (--count); + 3fe0: df df rcall .-66 ; 0x3fa0 + 3fe2: 11 50 subi r17, 0x01 ; 1 + 3fe4: e9 f7 brne .-6 ; 0x3fe0 + verifySpace(); + 3fe6: f4 df rcall .-24 ; 0x3fd0 +} + 3fe8: 1f 91 pop r17 + 3fea: 08 95 ret diff --git a/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_pro_8MHz.hex b/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_pro_8MHz.hex new file mode 100644 index 0000000..9d31a7a --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_pro_8MHz.hex @@ -0,0 +1,34 @@ +:103E000085E08093810084B714BE81FFE4D08DE00B +:103E1000DCD0259A519A86E028E13EEF91E030937C +:103E200085002093840096BBB09BFECF1D9AA89579 +:103E30008150A9F7DD24D394A5E0EA2EF1E1FF2E0D +:103E4000ABD0813421F481E0D1D083E024C082342E +:103E500011F484E103C0853419F485E0C7D08AC029 +:103E60008535A1F499D0082F10E01093010200933A +:103E7000000292D090E0982F8827802B912B880FFA +:103E8000991F909301028093000273C0863529F434 +:103E900084E0ACD080E071D06DC0843609F043C0BE +:103EA0008FD0E0910002F091010283E080935700EF +:103EB000E895C0E0D1E070D08993809102028150F2 +:103EC000809302028823B9F78BD007B600FCFDCFA0 +:103ED0004091000250910102A0E0B1E02C9130E04D +:103EE00011968C91119790E0982F8827822B932B15 +:103EF0001296FA010C01D0925700E89511244E5FFA +:103F00005F4FF1E0A038BF0749F7E0910002F09160 +:103F10000102E0925700E89507B600FCFDCFF09251 +:103F20005700E89527C08437B9F44AD059D0E091BA +:103F30000002F09101023196F0930102E093000239 +:103F40003197E4918E2F19D0809102028150809395 +:103F50000202882361F70EC0853739F441D08EE123 +:103F60000CD084E90AD086E096CF813511F488E040 +:103F70002CD036D080E101D063CF2AE030E08095AC +:103F8000089410F4599802C0599A000015D014D022 +:103F900086952A95B1F70895A89529E030E04899CB +:103FA000FECF0AD009D008D08894489908942A9561 +:103FB00011F08795F7CF089598E09A95F1F7089555 +:103FC000EBDFEADF80930202E7CFE0E6F0E098E182 +:103FD00090838083089580E0F8DFEE27FF2709941F +:103FE000DBDF803209F0F7DF84E1C7CF1F93182FA2 +:0C3FF000D3DF1150E9F7F4DF1F910895B2 +:0400000300003E00BB +:00000001FF diff --git a/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_pro_8MHz.lst b/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_pro_8MHz.lst new file mode 100644 index 0000000..94603e2 --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/bootloaders/optiboot/optiboot_pro_8MHz.lst @@ -0,0 +1,533 @@ + +optiboot_pro_8MHz.elf: file format elf32-avr + +Sections: +Idx Name Size VMA LMA File off Algn + 0 .text 000001fc 00003e00 00003e00 00000054 2**1 + CONTENTS, ALLOC, LOAD, READONLY, CODE + 1 .debug_aranges 00000028 00000000 00000000 00000250 2**0 + CONTENTS, READONLY, DEBUGGING + 2 .debug_pubnames 00000078 00000000 00000000 00000278 2**0 + CONTENTS, READONLY, DEBUGGING + 3 .debug_info 00000277 00000000 00000000 000002f0 2**0 + CONTENTS, READONLY, DEBUGGING + 4 .debug_abbrev 00000194 00000000 00000000 00000567 2**0 + CONTENTS, READONLY, DEBUGGING + 5 .debug_line 000003bb 00000000 00000000 000006fb 2**0 + CONTENTS, READONLY, DEBUGGING + 6 .debug_frame 000000a0 00000000 00000000 00000ab8 2**2 + CONTENTS, READONLY, DEBUGGING + 7 .debug_str 0000013f 00000000 00000000 00000b58 2**0 + CONTENTS, READONLY, DEBUGGING + 8 .debug_loc 000001a0 00000000 00000000 00000c97 2**0 + CONTENTS, READONLY, DEBUGGING + 9 .debug_ranges 00000070 00000000 00000000 00000e37 2**0 + CONTENTS, READONLY, DEBUGGING + +Disassembly of section .text: + +00003e00
    : +#ifdef VIRTUAL_BOOT_PARTITION +#define rstVect (*(uint16_t*)(0x204)) +#define wdtVect (*(uint16_t*)(0x206)) +#endif +/* main program starts here */ +int main(void) { + 3e00: 85 e0 ldi r24, 0x05 ; 5 + 3e02: 80 93 81 00 sts 0x0081, r24 + UCSR0C = _BV(UCSZ00) | _BV(UCSZ01); + UBRR0L = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 ); +#endif + + // Adaboot no-wait mod + ch = MCUSR; + 3e06: 84 b7 in r24, 0x34 ; 52 + MCUSR = 0; + 3e08: 14 be out 0x34, r1 ; 52 + if (!(ch & _BV(EXTRF))) appStart(); + 3e0a: 81 ff sbrs r24, 1 + 3e0c: e4 d0 rcall .+456 ; 0x3fd6 + + // Set up watchdog to trigger after 500ms + watchdogConfig(WATCHDOG_500MS); + 3e0e: 8d e0 ldi r24, 0x0D ; 13 + 3e10: dc d0 rcall .+440 ; 0x3fca + + /* Set LED pin as output */ + LED_DDR |= _BV(LED); + 3e12: 25 9a sbi 0x04, 5 ; 4 + +#ifdef SOFT_UART + /* Set TX pin as output */ + UART_DDR |= _BV(UART_TX_BIT); + 3e14: 51 9a sbi 0x0a, 1 ; 10 + 3e16: 86 e0 ldi r24, 0x06 ; 6 +} + +#if LED_START_FLASHES > 0 +void flash_led(uint8_t count) { + do { + TCNT1 = -(F_CPU/(1024*16)); + 3e18: 28 e1 ldi r18, 0x18 ; 24 + 3e1a: 3e ef ldi r19, 0xFE ; 254 + TIFR1 = _BV(TOV1); + 3e1c: 91 e0 ldi r25, 0x01 ; 1 +} + +#if LED_START_FLASHES > 0 +void flash_led(uint8_t count) { + do { + TCNT1 = -(F_CPU/(1024*16)); + 3e1e: 30 93 85 00 sts 0x0085, r19 + 3e22: 20 93 84 00 sts 0x0084, r18 + TIFR1 = _BV(TOV1); + 3e26: 96 bb out 0x16, r25 ; 22 + while(!(TIFR1 & _BV(TOV1))); + 3e28: b0 9b sbis 0x16, 0 ; 22 + 3e2a: fe cf rjmp .-4 ; 0x3e28 + LED_PIN |= _BV(LED); + 3e2c: 1d 9a sbi 0x03, 5 ; 3 + return getch(); +} + +// Watchdog functions. These are only safe with interrupts turned off. +void watchdogReset() { + __asm__ __volatile__ ( + 3e2e: a8 95 wdr + TCNT1 = -(F_CPU/(1024*16)); + TIFR1 = _BV(TOV1); + while(!(TIFR1 & _BV(TOV1))); + LED_PIN |= _BV(LED); + watchdogReset(); + } while (--count); + 3e30: 81 50 subi r24, 0x01 ; 1 + 3e32: a9 f7 brne .-22 ; 0x3e1e + /* get character from UART */ + ch = getch(); + + if(ch == STK_GET_PARAMETER) { + // GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy + getNch(1); + 3e34: dd 24 eor r13, r13 + 3e36: d3 94 inc r13 + boot_page_fill((uint16_t)(void*)addrPtr,a); + addrPtr += 2; + } while (--ch); + + // Write from programming buffer + boot_page_write((uint16_t)(void*)address); + 3e38: a5 e0 ldi r26, 0x05 ; 5 + 3e3a: ea 2e mov r14, r26 + boot_spm_busy_wait(); + +#if defined(RWWSRE) + // Reenable read access to flash + boot_rww_enable(); + 3e3c: f1 e1 ldi r31, 0x11 ; 17 + 3e3e: ff 2e mov r15, r31 +#endif + + /* Forever loop */ + for (;;) { + /* get character from UART */ + ch = getch(); + 3e40: ab d0 rcall .+342 ; 0x3f98 + + if(ch == STK_GET_PARAMETER) { + 3e42: 81 34 cpi r24, 0x41 ; 65 + 3e44: 21 f4 brne .+8 ; 0x3e4e + // GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy + getNch(1); + 3e46: 81 e0 ldi r24, 0x01 ; 1 + 3e48: d1 d0 rcall .+418 ; 0x3fec + putch(0x03); + 3e4a: 83 e0 ldi r24, 0x03 ; 3 + 3e4c: 24 c0 rjmp .+72 ; 0x3e96 + } + else if(ch == STK_SET_DEVICE) { + 3e4e: 82 34 cpi r24, 0x42 ; 66 + 3e50: 11 f4 brne .+4 ; 0x3e56 + // SET DEVICE is ignored + getNch(20); + 3e52: 84 e1 ldi r24, 0x14 ; 20 + 3e54: 03 c0 rjmp .+6 ; 0x3e5c + } + else if(ch == STK_SET_DEVICE_EXT) { + 3e56: 85 34 cpi r24, 0x45 ; 69 + 3e58: 19 f4 brne .+6 ; 0x3e60 + // SET DEVICE EXT is ignored + getNch(5); + 3e5a: 85 e0 ldi r24, 0x05 ; 5 + 3e5c: c7 d0 rcall .+398 ; 0x3fec + 3e5e: 8a c0 rjmp .+276 ; 0x3f74 + } + else if(ch == STK_LOAD_ADDRESS) { + 3e60: 85 35 cpi r24, 0x55 ; 85 + 3e62: a1 f4 brne .+40 ; 0x3e8c + // LOAD ADDRESS + address = getch(); + 3e64: 99 d0 rcall .+306 ; 0x3f98 + 3e66: 08 2f mov r16, r24 + 3e68: 10 e0 ldi r17, 0x00 ; 0 + 3e6a: 10 93 01 02 sts 0x0201, r17 + 3e6e: 00 93 00 02 sts 0x0200, r16 + address = (address & 0xff) | (getch() << 8); + 3e72: 92 d0 rcall .+292 ; 0x3f98 + 3e74: 90 e0 ldi r25, 0x00 ; 0 + 3e76: 98 2f mov r25, r24 + 3e78: 88 27 eor r24, r24 + 3e7a: 80 2b or r24, r16 + 3e7c: 91 2b or r25, r17 + address += address; // Convert from word address to byte address + 3e7e: 88 0f add r24, r24 + 3e80: 99 1f adc r25, r25 + 3e82: 90 93 01 02 sts 0x0201, r25 + 3e86: 80 93 00 02 sts 0x0200, r24 + 3e8a: 73 c0 rjmp .+230 ; 0x3f72 + verifySpace(); + } + else if(ch == STK_UNIVERSAL) { + 3e8c: 86 35 cpi r24, 0x56 ; 86 + 3e8e: 29 f4 brne .+10 ; 0x3e9a + // UNIVERSAL command is ignored + getNch(4); + 3e90: 84 e0 ldi r24, 0x04 ; 4 + 3e92: ac d0 rcall .+344 ; 0x3fec + putch(0x00); + 3e94: 80 e0 ldi r24, 0x00 ; 0 + 3e96: 71 d0 rcall .+226 ; 0x3f7a + 3e98: 6d c0 rjmp .+218 ; 0x3f74 + } + /* Write memory, length is big endian and is in bytes */ + else if(ch == STK_PROG_PAGE) { + 3e9a: 84 36 cpi r24, 0x64 ; 100 + 3e9c: 09 f0 breq .+2 ; 0x3ea0 + 3e9e: 43 c0 rjmp .+134 ; 0x3f26 + // PROGRAM PAGE - we support flash programming only, not EEPROM + uint8_t *bufPtr; + uint16_t addrPtr; + + getLen(); + 3ea0: 8f d0 rcall .+286 ; 0x3fc0 + + // Immediately start page erase - this will 4.5ms + boot_page_erase((uint16_t)(void*)address); + 3ea2: e0 91 00 02 lds r30, 0x0200 + 3ea6: f0 91 01 02 lds r31, 0x0201 + 3eaa: 83 e0 ldi r24, 0x03 ; 3 + 3eac: 80 93 57 00 sts 0x0057, r24 + 3eb0: e8 95 spm + 3eb2: c0 e0 ldi r28, 0x00 ; 0 + 3eb4: d1 e0 ldi r29, 0x01 ; 1 + + // While that is going on, read in page contents + bufPtr = buff; + do *bufPtr++ = getch(); + 3eb6: 70 d0 rcall .+224 ; 0x3f98 + 3eb8: 89 93 st Y+, r24 + while (--length); + 3eba: 80 91 02 02 lds r24, 0x0202 + 3ebe: 81 50 subi r24, 0x01 ; 1 + 3ec0: 80 93 02 02 sts 0x0202, r24 + 3ec4: 88 23 and r24, r24 + 3ec6: b9 f7 brne .-18 ; 0x3eb6 + + // Read command terminator, start reply + verifySpace(); + 3ec8: 8b d0 rcall .+278 ; 0x3fe0 + + // If only a partial page is to be programmed, the erase might not be complete. + // So check that here + boot_spm_busy_wait(); + 3eca: 07 b6 in r0, 0x37 ; 55 + 3ecc: 00 fc sbrc r0, 0 + 3ece: fd cf rjmp .-6 ; 0x3eca + } +#endif + + // Copy buffer into programming buffer + bufPtr = buff; + addrPtr = (uint16_t)(void*)address; + 3ed0: 40 91 00 02 lds r20, 0x0200 + 3ed4: 50 91 01 02 lds r21, 0x0201 + 3ed8: a0 e0 ldi r26, 0x00 ; 0 + 3eda: b1 e0 ldi r27, 0x01 ; 1 + ch = SPM_PAGESIZE / 2; + do { + uint16_t a; + a = *bufPtr++; + 3edc: 2c 91 ld r18, X + 3ede: 30 e0 ldi r19, 0x00 ; 0 + a |= (*bufPtr++) << 8; + 3ee0: 11 96 adiw r26, 0x01 ; 1 + 3ee2: 8c 91 ld r24, X + 3ee4: 11 97 sbiw r26, 0x01 ; 1 + 3ee6: 90 e0 ldi r25, 0x00 ; 0 + 3ee8: 98 2f mov r25, r24 + 3eea: 88 27 eor r24, r24 + 3eec: 82 2b or r24, r18 + 3eee: 93 2b or r25, r19 +#ifdef VIRTUAL_BOOT_PARTITION +#define rstVect (*(uint16_t*)(0x204)) +#define wdtVect (*(uint16_t*)(0x206)) +#endif +/* main program starts here */ +int main(void) { + 3ef0: 12 96 adiw r26, 0x02 ; 2 + ch = SPM_PAGESIZE / 2; + do { + uint16_t a; + a = *bufPtr++; + a |= (*bufPtr++) << 8; + boot_page_fill((uint16_t)(void*)addrPtr,a); + 3ef2: fa 01 movw r30, r20 + 3ef4: 0c 01 movw r0, r24 + 3ef6: d0 92 57 00 sts 0x0057, r13 + 3efa: e8 95 spm + 3efc: 11 24 eor r1, r1 + addrPtr += 2; + 3efe: 4e 5f subi r20, 0xFE ; 254 + 3f00: 5f 4f sbci r21, 0xFF ; 255 + } while (--ch); + 3f02: f1 e0 ldi r31, 0x01 ; 1 + 3f04: a0 38 cpi r26, 0x80 ; 128 + 3f06: bf 07 cpc r27, r31 + 3f08: 49 f7 brne .-46 ; 0x3edc + + // Write from programming buffer + boot_page_write((uint16_t)(void*)address); + 3f0a: e0 91 00 02 lds r30, 0x0200 + 3f0e: f0 91 01 02 lds r31, 0x0201 + 3f12: e0 92 57 00 sts 0x0057, r14 + 3f16: e8 95 spm + boot_spm_busy_wait(); + 3f18: 07 b6 in r0, 0x37 ; 55 + 3f1a: 00 fc sbrc r0, 0 + 3f1c: fd cf rjmp .-6 ; 0x3f18 + +#if defined(RWWSRE) + // Reenable read access to flash + boot_rww_enable(); + 3f1e: f0 92 57 00 sts 0x0057, r15 + 3f22: e8 95 spm + 3f24: 27 c0 rjmp .+78 ; 0x3f74 +#endif + + } + /* Read memory block mode, length is big endian. */ + else if(ch == STK_READ_PAGE) { + 3f26: 84 37 cpi r24, 0x74 ; 116 + 3f28: b9 f4 brne .+46 ; 0x3f58 + // READ PAGE - we only read flash + getLen(); + 3f2a: 4a d0 rcall .+148 ; 0x3fc0 + verifySpace(); + 3f2c: 59 d0 rcall .+178 ; 0x3fe0 + else ch = pgm_read_byte_near(address); + address++; + putch(ch); + } while (--length); +#else + do putch(pgm_read_byte_near(address++)); + 3f2e: e0 91 00 02 lds r30, 0x0200 + 3f32: f0 91 01 02 lds r31, 0x0201 + 3f36: 31 96 adiw r30, 0x01 ; 1 + 3f38: f0 93 01 02 sts 0x0201, r31 + 3f3c: e0 93 00 02 sts 0x0200, r30 + 3f40: 31 97 sbiw r30, 0x01 ; 1 + 3f42: e4 91 lpm r30, Z+ + 3f44: 8e 2f mov r24, r30 + 3f46: 19 d0 rcall .+50 ; 0x3f7a + while (--length); + 3f48: 80 91 02 02 lds r24, 0x0202 + 3f4c: 81 50 subi r24, 0x01 ; 1 + 3f4e: 80 93 02 02 sts 0x0202, r24 + 3f52: 88 23 and r24, r24 + 3f54: 61 f7 brne .-40 ; 0x3f2e + 3f56: 0e c0 rjmp .+28 ; 0x3f74 +#endif + } + + /* Get device signature bytes */ + else if(ch == STK_READ_SIGN) { + 3f58: 85 37 cpi r24, 0x75 ; 117 + 3f5a: 39 f4 brne .+14 ; 0x3f6a + // READ SIGN - return what Avrdude wants to hear + verifySpace(); + 3f5c: 41 d0 rcall .+130 ; 0x3fe0 + putch(SIGNATURE_0); + 3f5e: 8e e1 ldi r24, 0x1E ; 30 + 3f60: 0c d0 rcall .+24 ; 0x3f7a + putch(SIGNATURE_1); + 3f62: 84 e9 ldi r24, 0x94 ; 148 + 3f64: 0a d0 rcall .+20 ; 0x3f7a + putch(SIGNATURE_2); + 3f66: 86 e0 ldi r24, 0x06 ; 6 + 3f68: 96 cf rjmp .-212 ; 0x3e96 + } + else if (ch == 'Q') { + 3f6a: 81 35 cpi r24, 0x51 ; 81 + 3f6c: 11 f4 brne .+4 ; 0x3f72 + // Adaboot no-wait mod + watchdogConfig(WATCHDOG_16MS); + 3f6e: 88 e0 ldi r24, 0x08 ; 8 + 3f70: 2c d0 rcall .+88 ; 0x3fca + verifySpace(); + } + else { + // This covers the response to commands like STK_ENTER_PROGMODE + verifySpace(); + 3f72: 36 d0 rcall .+108 ; 0x3fe0 + } + putch(STK_OK); + 3f74: 80 e1 ldi r24, 0x10 ; 16 + 3f76: 01 d0 rcall .+2 ; 0x3f7a + 3f78: 63 cf rjmp .-314 ; 0x3e40 + +00003f7a : +void putch(char ch) { +#ifndef SOFT_UART + while (!(UCSR0A & _BV(UDRE0))); + UDR0 = ch; +#else + __asm__ __volatile__ ( + 3f7a: 2a e0 ldi r18, 0x0A ; 10 + 3f7c: 30 e0 ldi r19, 0x00 ; 0 + 3f7e: 80 95 com r24 + 3f80: 08 94 sec + 3f82: 10 f4 brcc .+4 ; 0x3f88 + 3f84: 59 98 cbi 0x0b, 1 ; 11 + 3f86: 02 c0 rjmp .+4 ; 0x3f8c + 3f88: 59 9a sbi 0x0b, 1 ; 11 + 3f8a: 00 00 nop + 3f8c: 15 d0 rcall .+42 ; 0x3fb8 + 3f8e: 14 d0 rcall .+40 ; 0x3fb8 + 3f90: 86 95 lsr r24 + 3f92: 2a 95 dec r18 + 3f94: b1 f7 brne .-20 ; 0x3f82 + [uartBit] "I" (UART_TX_BIT) + : + "r25" + ); +#endif +} + 3f96: 08 95 ret + +00003f98 : + return getch(); +} + +// Watchdog functions. These are only safe with interrupts turned off. +void watchdogReset() { + __asm__ __volatile__ ( + 3f98: a8 95 wdr +#ifdef LED_DATA_FLASH + LED_PIN |= _BV(LED); +#endif + + return ch; +} + 3f9a: 29 e0 ldi r18, 0x09 ; 9 + 3f9c: 30 e0 ldi r19, 0x00 ; 0 + 3f9e: 48 99 sbic 0x09, 0 ; 9 + 3fa0: fe cf rjmp .-4 ; 0x3f9e + 3fa2: 0a d0 rcall .+20 ; 0x3fb8 + 3fa4: 09 d0 rcall .+18 ; 0x3fb8 + 3fa6: 08 d0 rcall .+16 ; 0x3fb8 + 3fa8: 88 94 clc + 3faa: 48 99 sbic 0x09, 0 ; 9 + 3fac: 08 94 sec + 3fae: 2a 95 dec r18 + 3fb0: 11 f0 breq .+4 ; 0x3fb6 + 3fb2: 87 95 ror r24 + 3fb4: f7 cf rjmp .-18 ; 0x3fa4 + 3fb6: 08 95 ret + +00003fb8 : +#if UART_B_VALUE > 255 +#error Baud rate too slow for soft UART +#endif + +void uartDelay() { + __asm__ __volatile__ ( + 3fb8: 98 e0 ldi r25, 0x08 ; 8 + 3fba: 9a 95 dec r25 + 3fbc: f1 f7 brne .-4 ; 0x3fba + 3fbe: 08 95 ret + +00003fc0 : + } while (--count); +} +#endif + +uint8_t getLen() { + getch(); + 3fc0: eb df rcall .-42 ; 0x3f98 + length = getch(); + 3fc2: ea df rcall .-44 ; 0x3f98 + 3fc4: 80 93 02 02 sts 0x0202, r24 + return getch(); +} + 3fc8: e7 cf rjmp .-50 ; 0x3f98 + +00003fca : + "wdr\n" + ); +} + +void watchdogConfig(uint8_t x) { + WDTCSR = _BV(WDCE) | _BV(WDE); + 3fca: e0 e6 ldi r30, 0x60 ; 96 + 3fcc: f0 e0 ldi r31, 0x00 ; 0 + 3fce: 98 e1 ldi r25, 0x18 ; 24 + 3fd0: 90 83 st Z, r25 + WDTCSR = x; + 3fd2: 80 83 st Z, r24 +} + 3fd4: 08 95 ret + +00003fd6 : + +void appStart() { + watchdogConfig(WATCHDOG_OFF); + 3fd6: 80 e0 ldi r24, 0x00 ; 0 + 3fd8: f8 df rcall .-16 ; 0x3fca + __asm__ __volatile__ ( + 3fda: ee 27 eor r30, r30 + 3fdc: ff 27 eor r31, r31 + 3fde: 09 94 ijmp + +00003fe0 : + do getch(); while (--count); + verifySpace(); +} + +void verifySpace() { + if (getch() != CRC_EOP) appStart(); + 3fe0: db df rcall .-74 ; 0x3f98 + 3fe2: 80 32 cpi r24, 0x20 ; 32 + 3fe4: 09 f0 breq .+2 ; 0x3fe8 + 3fe6: f7 df rcall .-18 ; 0x3fd6 + putch(STK_INSYNC); + 3fe8: 84 e1 ldi r24, 0x14 ; 20 +} + 3fea: c7 cf rjmp .-114 ; 0x3f7a + ::[count] "M" (UART_B_VALUE) + ); +} +#endif + +void getNch(uint8_t count) { + 3fec: 1f 93 push r17 + 3fee: 18 2f mov r17, r24 + +00003ff0 : + do getch(); while (--count); + 3ff0: d3 df rcall .-90 ; 0x3f98 + 3ff2: 11 50 subi r17, 0x01 ; 1 + 3ff4: e9 f7 brne .-6 ; 0x3ff0 + verifySpace(); + 3ff6: f4 df rcall .-24 ; 0x3fe0 +} + 3ff8: 1f 91 pop r17 + 3ffa: 08 95 ret diff --git a/arduino-0022-linux-x64/hardware/arduino/bootloaders/stk500v2/License.txt b/arduino-0022-linux-x64/hardware/arduino/bootloaders/stk500v2/License.txt new file mode 100644 index 0000000..e7dcdd8 --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/bootloaders/stk500v2/License.txt @@ -0,0 +1,280 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS diff --git a/arduino-0022-linux-x64/hardware/arduino/bootloaders/stk500v2/Makefile b/arduino-0022-linux-x64/hardware/arduino/bootloaders/stk500v2/Makefile new file mode 100644 index 0000000..54c5f85 --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/bootloaders/stk500v2/Makefile @@ -0,0 +1,588 @@ +# ---------------------------------------------------------------------------- +# Makefile to compile and link stk500boot bootloader +# Author: Peter Fleury +# File: $Id: Makefile,v 1.3 2006/03/04 19:26:17 peter Exp $ +# based on WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al. +# +# Adjust F_CPU below to the clock frequency in Mhz of your AVR target +# Adjust BOOTLOADER_ADDRESS to your AVR target +# +#---------------------------------------------------------------------------- +# On command line: +# +# make all = Make software. +# +# make clean = Clean out built project files. +# +# make coff = Convert ELF to AVR COFF. +# +# make extcoff = Convert ELF to AVR Extended COFF. +# +# make program = Download the hex file to the device, using avrdude. +# Please customize the avrdude settings below first! +# +# make debug = Start either simulavr or avarice as specified for debugging, +# with avr-gdb or avr-insight as the front end for debugging. +# +# make filename.s = Just compile filename.c into the assembler code only. +# +# make filename.i = Create a preprocessed source file for use in submitting +# bug reports to the GCC project. +# +# To rebuild project do "make clean" then "make all". +#---------------------------------------------------------------------------- +# = Mark Sproul msproul-at-skychariot.com + + +# MCU name +#MCU = atmega128 + + +# Processor frequency. +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency. You can then use this symbol in your source code to +# calculate timings. Do NOT tack on a 'UL' at the end, this will be done +# automatically to create a 32-bit value in your source code. +#F_CPU = 16000000 + + +# Bootloader +# Please adjust if using a different AVR +# 0x0e00*2=0x1C00 for ATmega8 512 words Boot Size +# 0xFC00*2=0x1F800 for ATmega128 1024 words Boot Size +# 0xF800*2=0x1F000 for ATmega1280 +# 0xF000*2=0x1E000 for ATmega1280 +#BOOTLOADER_ADDRESS = 1E000 + + +# Output format. (can be srec, ihex, binary) +FORMAT = ihex + + +# Target file name (without extension). +TARGET = stk500boot + + +# List C source files here. (C dependencies are automatically generated.) +SRC = stk500boot.c + + +# List Assembler source files here. +# Make them always end in a capital .S. Files ending in a lowercase .s +# will not be considered source files but generated files (assembler +# output from the compiler), and will be deleted upon "make clean"! +# Even though the DOS/Win* filesystem matches both .s and .S the same, +# it will preserve the spelling of the filenames, and gcc itself does +# care about how the name is spelled on its command-line. +ASRC = + + +# Optimization level, can be [0, 1, 2, 3, s]. +# 0 = turn off optimization. s = optimize for size. +# (Note: 3 is not always the best optimization level. See avr-libc FAQ.) +OPT = s + + +# Debugging format. +# Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs. +# AVR Studio 4.10 requires dwarf-2. +# AVR [Extended] COFF format requires stabs, plus an avr-objcopy run. +DEBUG = dwarf-2 + + +# List any extra directories to look for include files here. +# Each directory must be seperated by a space. +# Use forward slashes for directory separators. +# For a directory that has spaces, enclose it in quotes. +EXTRAINCDIRS = + + +# Compiler flag to set the C Standard level. +# c89 = "ANSI" C +# gnu89 = c89 plus GCC extensions +# c99 = ISO C99 standard (not yet fully implemented) +# gnu99 = c99 plus GCC extensions +CSTANDARD = -std=gnu99 + + +# Place -D or -U options here +CDEFS = -DF_CPU=$(F_CPU)UL + + +# Place -I options here +CINCS = + + + +#---------------- Compiler Options ---------------- +# -g*: generate debugging information +# -O*: optimization level +# -f...: tuning, see GCC manual and avr-libc documentation +# -Wall...: warning level +# -Wa,...: tell GCC to pass this to the assembler. +# -adhlns...: create assembler listing +CFLAGS = -g$(DEBUG) +CFLAGS += $(CDEFS) $(CINCS) +CFLAGS += -O$(OPT) +CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -mno-tablejump +CFLAGS += -Wall -Wstrict-prototypes +CFLAGS += -Wa,-adhlns=$(<:.c=.lst) +CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) +CFLAGS += $(CSTANDARD) + + +#---------------- Assembler Options ---------------- +# -Wa,...: tell GCC to pass this to the assembler. +# -ahlms: create listing +# -gstabs: have the assembler create line number information; note that +# for use in COFF files, additional information about filenames +# and function names needs to be present in the assembler source +# files -- see avr-libc docs [FIXME: not yet described there] +ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs + + +#---------------- Library Options ---------------- +# Minimalistic printf version +PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min + +# Floating point printf version (requires MATH_LIB = -lm below) +PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt + +# If this is left blank, then it will use the Standard printf version. +PRINTF_LIB = +#PRINTF_LIB = $(PRINTF_LIB_MIN) +#PRINTF_LIB = $(PRINTF_LIB_FLOAT) + + +# Minimalistic scanf version +SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min + +# Floating point + %[ scanf version (requires MATH_LIB = -lm below) +SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt + +# If this is left blank, then it will use the Standard scanf version. +SCANF_LIB = +#SCANF_LIB = $(SCANF_LIB_MIN) +#SCANF_LIB = $(SCANF_LIB_FLOAT) + + +MATH_LIB = -lm + + + +#---------------- External Memory Options ---------------- + +# 64 KB of external RAM, starting after internal RAM (ATmega128!), +# used for variables (.data/.bss) and heap (malloc()). +#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff + +# 64 KB of external RAM, starting after internal RAM (ATmega128!), +# only used for heap (malloc()). +#EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff + +EXTMEMOPTS = + + + + +#---------------- Linker Options ---------------- +# -Wl,...: tell GCC to pass this to linker. +# -Map: create map file +# --cref: add cross reference to map file +LDFLAGS = -Wl,-Map=$(TARGET).map,--cref +LDFLAGS += $(EXTMEMOPTS) +LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB) + + +#--------------- bootloader linker Options ------- +# BOOTLOADER_ADDRESS (=Start of Boot Loader section +# in bytes - not words) is defined above. +#LDFLAGS += -Wl,--section-start=.text=$(BOOTLOADER_ADDRESS) -nostartfiles -nodefaultlibs +#LDFLAGS += -Wl,--section-start=.text=$(BOOTLOADER_ADDRESS) -nostartfiles +LDFLAGS += -Wl,--section-start=.text=$(BOOTLOADER_ADDRESS) + +#---------------- Programming Options (avrdude) ---------------- + +# Programming hardware: alf avr910 avrisp bascom bsd +# dt006 pavr picoweb pony-stk200 sp12 stk200 stk500 +# +# Type: avrdude -c ? +# to get a full listing. +# +AVRDUDE_PROGRAMMER = stk500v2 + +# com1 = serial port. Use lpt1 to connect to parallel port. +AVRDUDE_PORT = com1 # programmer connected to serial device + +AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex +#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep + + +# Uncomment the following if you want avrdude's erase cycle counter. +# Note that this counter needs to be initialized first using -Yn, +# see avrdude manual. +#AVRDUDE_ERASE_COUNTER = -y + +# Uncomment the following if you do /not/ wish a verification to be +# performed after programming the device. +#AVRDUDE_NO_VERIFY = -V + +# Increase verbosity level. Please use this when submitting bug +# reports about avrdude. See +# to submit bug reports. +#AVRDUDE_VERBOSE = -v -v + +AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) +AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY) +AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE) +AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER) + + + +#---------------- Debugging Options ---------------- + +# For simulavr only - target MCU frequency. +DEBUG_MFREQ = $(F_CPU) + +# Set the DEBUG_UI to either gdb or insight. +# DEBUG_UI = gdb +DEBUG_UI = insight + +# Set the debugging back-end to either avarice, simulavr. +DEBUG_BACKEND = avarice +#DEBUG_BACKEND = simulavr + +# GDB Init Filename. +GDBINIT_FILE = __avr_gdbinit + +# When using avarice settings for the JTAG +JTAG_DEV = /dev/com1 + +# Debugging port used to communicate between GDB / avarice / simulavr. +DEBUG_PORT = 4242 + +# Debugging host used to communicate between GDB / avarice / simulavr, normally +# just set to localhost unless doing some sort of crazy debugging when +# avarice is running on a different computer. +DEBUG_HOST = localhost + + + +#============================================================================ + + +# Define programs and commands. +SHELL = sh +CC = avr-gcc +OBJCOPY = avr-objcopy +OBJDUMP = avr-objdump +SIZE = avr-size +NM = avr-nm +AVRDUDE = avrdude +REMOVE = rm -f +COPY = cp +WINSHELL = cmd + + +# Define Messages +# English +MSG_ERRORS_NONE = Errors: none +MSG_BEGIN = -------- begin -------- +MSG_END = -------- end -------- +MSG_SIZE_BEFORE = Size before: +MSG_SIZE_AFTER = Size after: +MSG_COFF = Converting to AVR COFF: +MSG_EXTENDED_COFF = Converting to AVR Extended COFF: +MSG_FLASH = Creating load file for Flash: +MSG_EEPROM = Creating load file for EEPROM: +MSG_EXTENDED_LISTING = Creating Extended Listing: +MSG_SYMBOL_TABLE = Creating Symbol Table: +MSG_LINKING = Linking: +MSG_COMPILING = Compiling: +MSG_ASSEMBLING = Assembling: +MSG_CLEANING = Cleaning project: + + + + +# Define all object files. +OBJ = $(SRC:.c=.o) $(ASRC:.S=.o) + +# Define all listing files. +LST = $(SRC:.c=.lst) $(ASRC:.S=.lst) + + +# Compiler flags to generate dependency files. +GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d + + +# Combine all necessary flags and optional flags. +# Add target processor to flags. +ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS) +ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) + + + +############################################################ +# May 25, 2010 Adding 1280 support +mega1280: MCU = atmega1280 +mega1280: F_CPU = 16000000 +mega1280: BOOTLOADER_ADDRESS = 1E000 +mega1280: CFLAGS += -D_MEGA_BOARD_ +mega1280: begin gccversion sizebefore build sizeafter end + mv $(TARGET).hex stk500boot_v2_mega1280.hex + + +############################################################ +# Jul 6, 2010 Adding 2560 support +mega2560: MCU = atmega2560 +mega2560: F_CPU = 16000000 +mega2560: BOOTLOADER_ADDRESS = 3E000 +mega2560: CFLAGS += -D_MEGA_BOARD_ +mega2560: begin gccversion sizebefore build sizeafter end + mv $(TARGET).hex stk500boot_v2_mega2560.hex + + +############################################################ +#Initial config on Amber128 board +# avrdude: Device signature = 0x1e9702 +# avrdude: safemode: lfuse reads as 8F +# avrdude: safemode: hfuse reads as CB +# avrdude: safemode: efuse reads as FF +# Jul 17, 2010 Adding 128 support +############################################################ +amber128: MCU = atmega128 +#amber128: F_CPU = 16000000 +amber128: F_CPU = 14745600 +amber128: BOOTLOADER_ADDRESS = 1E000 +amber128: CFLAGS += -D_BOARD_AMBER128_ +amber128: begin gccversion sizebefore build sizeafter end + mv $(TARGET).hex stk500boot_v2_amber128.hex + +############################################################ +# Aug 23, 2010 Adding atmega2561 support +m2561: MCU = atmega2561 +m2561: F_CPU = 8000000 +m2561: BOOTLOADER_ADDRESS = 3E000 +m2561: CFLAGS += -D_ANDROID_2561_ -DBAUDRATE=57600 +m2561: begin gccversion sizebefore build sizeafter end + mv $(TARGET).hex stk500boot_v2_android2561.hex + + +############################################################ +# avrdude: Device signature = 0x1e9801 +# avrdude: safemode: lfuse reads as EC +# avrdude: safemode: hfuse reads as 18 +# avrdude: safemode: efuse reads as FD +# Aug 23, 2010 Adding cerebot 2560 @ 8mhz +#avrdude -P usb -c usbtiny -p m2560 -v -U flash:w:/Arduino/WiringBootV2_upd1/stk500boot_v2_cerebotplus.hex +############################################################ +cerebot: MCU = atmega2560 +cerebot: F_CPU = 8000000 +cerebot: BOOTLOADER_ADDRESS = 3E000 +cerebot: CFLAGS += -D_CEREBOTPLUS_BOARD_ -DBAUDRATE=38400 -DUART_BAUDRATE_DOUBLE_SPEED=1 +cerebot: begin gccversion sizebefore build sizeafter end + mv $(TARGET).hex stk500boot_v2_cerebotplus.hex + + +############################################################ +# Aug 23, 2010 Adding atmega2561 support +penguino: MCU = atmega32 +penguino: F_CPU = 16000000 +penguino: BOOTLOADER_ADDRESS = 7800 +penguino: CFLAGS += -D_PENGUINO_ -DBAUDRATE=57600 +penguino: begin gccversion sizebefore build sizeafter end + mv $(TARGET).hex stk500boot_v2_penguino.hex + + +# Default target. +all: begin gccversion sizebefore build sizeafter end + +build: elf hex eep lss sym +#build: hex eep lss sym + +elf: $(TARGET).elf +hex: $(TARGET).hex +eep: $(TARGET).eep +lss: $(TARGET).lss +sym: $(TARGET).sym + + + +# Eye candy. +# AVR Studio 3.x does not check make's exit code but relies on +# the following magic strings to be generated by the compile job. +begin: + @echo + @echo $(MSG_BEGIN) + +end: + @echo $(MSG_END) + @echo + + +# Display size of file. +HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex +ELFSIZE = $(SIZE) --format=avr --mcu=$(MCU) $(TARGET).elf + +sizebefore: + @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \ + 2>/dev/null; echo; fi + +sizeafter: + @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \ + 2>/dev/null; echo; fi + + + +# Display compiler version information. +gccversion : + @$(CC) --version + + + +# Program the device. +program: $(TARGET).hex $(TARGET).eep + $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) + + +# Generate avr-gdb config/init file which does the following: +# define the reset signal, load the target file, connect to target, and set +# a breakpoint at main(). +gdb-config: + @$(REMOVE) $(GDBINIT_FILE) + @echo define reset >> $(GDBINIT_FILE) + @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) + @echo end >> $(GDBINIT_FILE) + @echo file $(TARGET).elf >> $(GDBINIT_FILE) + @echo target remote $(DEBUG_HOST):$(DEBUG_PORT) >> $(GDBINIT_FILE) +ifeq ($(DEBUG_BACKEND),simulavr) + @echo load >> $(GDBINIT_FILE) +endif + @echo break main >> $(GDBINIT_FILE) + +debug: gdb-config $(TARGET).elf +ifeq ($(DEBUG_BACKEND), avarice) + @echo Starting AVaRICE - Press enter when "waiting to connect" message displays. + @$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \ + $(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT) + @$(WINSHELL) /c pause + +else + @$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \ + $(DEBUG_MFREQ) --port $(DEBUG_PORT) +endif + @$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE) + + + + +# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. +COFFCONVERT=$(OBJCOPY) --debugging \ +--change-section-address .data-0x800000 \ +--change-section-address .bss-0x800000 \ +--change-section-address .noinit-0x800000 \ +--change-section-address .eeprom-0x810000 + + + +coff: $(TARGET).elf + @echo + @echo $(MSG_COFF) $(TARGET).cof + $(COFFCONVERT) -O coff-avr $< $(TARGET).cof + + +extcoff: $(TARGET).elf + @echo + @echo $(MSG_EXTENDED_COFF) $(TARGET).cof + $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof + + +# Create final output files (.hex, .eep) from ELF output file. +%.hex: %.elf + @echo + @echo $(MSG_FLASH) $@ + $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@ + +%.eep: %.elf + @echo + @echo $(MSG_EEPROM) $@ + -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ + --change-section-lma .eeprom=0 -O $(FORMAT) $< $@ + +# Create extended listing file from ELF output file. +%.lss: %.elf + @echo + @echo $(MSG_EXTENDED_LISTING) $@ + $(OBJDUMP) -h -S $< > $@ + +# Create a symbol table from ELF output file. +%.sym: %.elf + @echo + @echo $(MSG_SYMBOL_TABLE) $@ + $(NM) -n $< > $@ + + + +# Link: create ELF output file from object files. +.SECONDARY : $(TARGET).elf +.PRECIOUS : $(OBJ) +%.elf: $(OBJ) + @echo + @echo $(MSG_LINKING) $@ + $(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS) + + +# Compile: create object files from C source files. +%.o : %.c + @echo + @echo $(MSG_COMPILING) $< + $(CC) -c $(ALL_CFLAGS) $< -o $@ + + +# Compile: create assembler files from C source files. +%.s : %.c + $(CC) -S $(ALL_CFLAGS) $< -o $@ + + +# Assemble: create object files from assembler source files. +%.o : %.S + @echo + @echo $(MSG_ASSEMBLING) $< + $(CC) -c $(ALL_ASFLAGS) $< -o $@ + +# Create preprocessed source for use in sending a bug report. +%.i : %.c + $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ + + +# Target: clean project. +clean: begin clean_list end + +clean_list : + @echo + @echo $(MSG_CLEANING) + $(REMOVE) *.hex + $(REMOVE) *.eep + $(REMOVE) *.cof + $(REMOVE) *.elf + $(REMOVE) *.map + $(REMOVE) *.sym + $(REMOVE) *.lss + $(REMOVE) $(OBJ) + $(REMOVE) $(LST) + $(REMOVE) $(SRC:.c=.s) + $(REMOVE) $(SRC:.c=.d) + $(REMOVE) .dep/* + + + +# Include the dependency files. +-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) + + +# Listing of phony targets. +.PHONY : all begin finish end sizebefore sizeafter gccversion \ +build elf hex eep lss sym coff extcoff \ +clean clean_list program debug gdb-config + diff --git a/arduino-0022-linux-x64/hardware/arduino/bootloaders/stk500v2/STK500V2.pnproj b/arduino-0022-linux-x64/hardware/arduino/bootloaders/stk500v2/STK500V2.pnproj new file mode 100644 index 0000000..d935019 --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/bootloaders/stk500v2/STK500V2.pnproj @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/arduino-0022-linux-x64/hardware/arduino/bootloaders/stk500v2/STK500V2.pnps b/arduino-0022-linux-x64/hardware/arduino/bootloaders/stk500v2/STK500V2.pnps new file mode 100644 index 0000000..f85cde5 --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/bootloaders/stk500v2/STK500V2.pnps @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/arduino-0022-linux-x64/hardware/arduino/bootloaders/stk500v2/avrinterruptnames.h b/arduino-0022-linux-x64/hardware/arduino/bootloaders/stk500v2/avrinterruptnames.h new file mode 100644 index 0000000..0ae80f9 --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/bootloaders/stk500v2/avrinterruptnames.h @@ -0,0 +1,742 @@ +//************************************************************************************************** +//* +//* interrupt vector names +//* +//* It is important to note that the vector numbers listed here +//* are the ATMEL documentation numbers. The Arduino numbers are 1 less +//* This is because the Atmel docs start numbering the interrupts at 1 +//* when it is actually vector #0 in the table. +//************************************************************************************************** +//* Jun 1, 2010 Added support for ATmega1281 +//* Jun 30, 2010 Putting in more ifdefs to conserve space +//* Jul 3, 2010 More #ifdefs to conserve space and testing on most of my boards +//* Jul 4, 2010 Started using vector defs for #ifdefs as defined in +//* Jul 13, 2010 Added support for __AVR_ATmega128__ +//* Aug 26, 2010 Added support for __AVR_ATmega2561__ +//************************************************************************************************** + +//#include "avrinterruptnames.h" + +//************************************************************************************************** +//* this defines the interrupt vectors and allows us to compile ONLY those strings that are actually +//* in the target CPU. This way we do not have to keep making changes based on cpu, it will be +//* automatic even if we add a new CPU +#ifndef _AVR_IO_H_ + #include +#endif +//************************************************************************************************** + +#ifdef __MWERKS__ + #define prog_char char + #define PGM_P char * +#endif + + prog_char gAvrInt_RESET[] PROGMEM = "RESET"; +#ifdef INT0_vect + prog_char gAvrInt_INT0[] PROGMEM = "INT0"; +#endif +#ifdef INT1_vect + prog_char gAvrInt_INT1[] PROGMEM = "INT1"; +#endif +#ifdef INT2_vect + prog_char gAvrInt_INT2[] PROGMEM = "INT2"; +#endif +#ifdef INT3_vect + prog_char gAvrInt_INT3[] PROGMEM = "INT3"; +#endif +#ifdef INT4_vect + prog_char gAvrInt_INT4[] PROGMEM = "INT4"; +#endif +#ifdef INT5_vect + prog_char gAvrInt_INT5[] PROGMEM = "INT5"; +#endif +#ifdef INT6_vect + prog_char gAvrInt_INT6[] PROGMEM = "INT6"; +#endif +#ifdef INT7_vect + prog_char gAvrInt_INT7[] PROGMEM = "INT7"; +#endif +#ifdef PCINT0_vect + prog_char gAvrInt_PCINT0[] PROGMEM = "PCINT0"; +#endif +#ifdef PCINT1_vect + prog_char gAvrInt_PCINT1[] PROGMEM = "PCINT1"; +#endif +#ifdef PCINT2_vect + prog_char gAvrInt_PCINT2[] PROGMEM = "PCINT2"; +#endif +#ifdef PCINT3_vect + prog_char gAvrInt_PCINT3[] PROGMEM = "PCINT3"; +#endif +#ifdef WDT_vect + prog_char gAvrInt_WDT[] PROGMEM = "WDT"; +#endif +#ifdef TIMER0_COMP_vect + prog_char gAvrInt_TIMER0_COMP[] PROGMEM = "TIMER0 COMP"; +#endif +#ifdef TIMER0_COMPA_vect + prog_char gAvrInt_TIMER0_COMPA[] PROGMEM = "TIMER0 COMPA"; +#endif +#ifdef TIMER0_COMPB_vect + prog_char gAvrInt_TIMER0_COMPB[] PROGMEM = "TIMER0 COMPB"; +#endif +#ifdef TIMER0_OVF_vect + prog_char gAvrInt_TIMER0_OVF[] PROGMEM = "TIMER0 OVF"; +#endif +#ifdef TIMER1_CAPT_vect + prog_char gAvrInt_TIMER1_CAPT[] PROGMEM = "TIMER1 CAPT"; +#endif +#ifdef TIMER1_COMPA_vect + prog_char gAvrInt_TIMER1_COMPA[] PROGMEM = "TIMER1 COMPA"; +#endif +#ifdef TIMER1_COMPB_vect + prog_char gAvrInt_TIMER1_COMPB[] PROGMEM = "TIMER1 COMPB"; +#endif +#ifdef TIMER1_COMPC_vect + prog_char gAvrInt_TIMER1_COMPC[] PROGMEM = "TIMER1 COMPC"; +#endif +#ifdef TIMER1_OVF_vect + prog_char gAvrInt_TIMER1_OVF[] PROGMEM = "TIMER1 OVF"; +#endif +#ifdef TIMER2_COMP_vect + prog_char gAvrInt_TIMER2_COMP[] PROGMEM = "TIMER2 COMP"; +#endif +#ifdef TIMER2_COMPA_vect + prog_char gAvrInt_TIMER2_COMPA[] PROGMEM = "TIMER2 COMPA"; +#endif +#ifdef TIMER2_COMPB_vect + prog_char gAvrInt_TIMER2_COMPB[] PROGMEM = "TIMER2 COMPB"; +#endif +#ifdef TIMER2_OVF_vect + prog_char gAvrInt_TIMER2_OVF[] PROGMEM = "TIMER2 OVF"; +#endif +#ifdef TIMER3_CAPT_vect + prog_char gAvrInt_TIMER3_CAPT[] PROGMEM = "TIMER3 CAPT"; +#endif +#ifdef TIMER3_COMPA_vect + prog_char gAvrInt_TIMER3_COMPA[] PROGMEM = "TIMER3 COMPA"; +#endif +#ifdef TIMER3_COMPB_vect + prog_char gAvrInt_TIMER3_COMPB[] PROGMEM = "TIMER3 COMPB"; +#endif +#ifdef TIMER3_COMPC_vect + prog_char gAvrInt_TIMER3_COMPC[] PROGMEM = "TIMER3 COMPC"; +#endif +#ifdef TIMER3_OVF_vect + prog_char gAvrInt_TIMER3_OVF[] PROGMEM = "TIMER3 OVF"; +#endif +#ifdef TIMER4_CAPT_vect + prog_char gAvrInt_TIMER4_CAPT[] PROGMEM = "TIMER4 CAPT"; +#endif +#ifdef TIMER4_COMPA_vect + prog_char gAvrInt_TIMER4_COMPA[] PROGMEM = "TIMER4 COMPA"; +#endif +#ifdef TIMER4_COMPB_vect + prog_char gAvrInt_TIMER4_COMPB[] PROGMEM = "TIMER4 COMPB"; +#endif +#ifdef TIMER4_COMPC_vect + prog_char gAvrInt_TIMER4_COMPC[] PROGMEM = "TIMER4 COMPC"; +#endif +#ifdef TIMER4_COMPD_vect + prog_char gAvrInt_TIMER4_COMPD[] PROGMEM = "TIMER4 COMPD"; +#endif +#ifdef TIMER4_OVF_vect + prog_char gAvrInt_TIMER4_OVF[] PROGMEM = "TIMER4 OVF"; +#endif +#ifdef TIMER4_FPF_vect + prog_char gAvrInt_TIMER4_FPF[] PROGMEM = "TIMER4 Fault Protection"; +#endif +#ifdef TIMER5_CAPT_vect + prog_char gAvrInt_TIMER5_CAPT[] PROGMEM = "TIMER5 CAPT"; +#endif +#ifdef TIMER5_COMPA_vect + prog_char gAvrInt_TIMER5_COMPA[] PROGMEM = "TIMER5 COMPA"; +#endif +#ifdef TIMER5_COMPB_vect + prog_char gAvrInt_TIMER5_COMPB[] PROGMEM = "TIMER5 COMPB"; +#endif +#ifdef TIMER5_COMPC_vect + prog_char gAvrInt_TIMER5_COMPC[] PROGMEM = "TIMER5 COMPC"; +#endif +#ifdef TIMER5_OVF_vect + prog_char gAvrInt_TIMER5_OVF[] PROGMEM = "TIMER5 OVF"; +#endif + +//* when there is only 1 usart +#if defined(USART_RX_vect) || defined(USART_RXC_vect) + prog_char gAvrInt_USART_RX[] PROGMEM = "USART RX"; +#endif +#if defined(USART_UDRE_vect) + prog_char gAvrInt_USART_UDRE[] PROGMEM = "USART UDRE"; +#endif +#if defined(USART_TX_vect) || defined(USART_TXC_vect) + prog_char gAvrInt_USART_TX[] PROGMEM = "USART TX"; +#endif + + +//* usart 0 +#if defined(USART0_RX_vect) + prog_char gAvrInt_USART0_RX[] PROGMEM = "USART0 RX"; +#endif +#if defined(USART0_UDRE_vect) + prog_char gAvrInt_USART0_UDRE[] PROGMEM = "USART0 UDRE"; +#endif +#if defined(USART0_TX_vect) + prog_char gAvrInt_USART0_TX[] PROGMEM = "USART0 TX"; +#endif + + +//* usart 1 +#ifdef USART1_RX_vect + prog_char gAvrInt_USART1_RX[] PROGMEM = "USART1 RX"; +#endif +#ifdef USART1_UDRE_vect + prog_char gAvrInt_USART1_UDRE[] PROGMEM = "USART1 UDRE"; +#endif +#ifdef USART1_TX_vect + prog_char gAvrInt_USART1_TX[] PROGMEM = "USART1 TX"; +#endif + +//* usart 2 +#ifdef USART2_RX_vect + prog_char gAvrInt_USART2_RX[] PROGMEM = "USART2 RX"; +#endif +#ifdef USART2_UDRE_vect + prog_char gAvrInt_USART2_UDRE[] PROGMEM = "USART2 UDRE"; +#endif +#ifdef USART2_TX_vect + prog_char gAvrInt_USART2_TX[] PROGMEM = "USART2 TX"; +#endif + +//* usart 3 +#ifdef USART3_RX_vect + prog_char gAvrInt_USART3_RX[] PROGMEM = "USART3 RX"; +#endif +#ifdef USART3_UDRE_vect + prog_char gAvrInt_USART3_UDRE[] PROGMEM = "USART3 UDRE"; +#endif +#ifdef USART3_TX_vect + prog_char gAvrInt_USART3_TX[] PROGMEM = "USART3 TX"; +#endif +#ifdef SPI_STC_vect + prog_char gAvrInt_SPI_STC[] PROGMEM = "SPI STC"; +#endif +#ifdef ADC_vect + prog_char gAvrInt_ADC[] PROGMEM = "ADC"; +#endif +#if defined(ANALOG_COMP_vect) || defined(ANA_COMP_vect) + prog_char gAvrInt_ANALOG_COMP[] PROGMEM = "ANALOG COMP"; +#endif +#if defined(EE_READY_vect) || defined(EE_RDY_vect) + prog_char gAvrInt_EE_READY[] PROGMEM = "EE READY"; +#endif +#ifdef TWI_vect + prog_char gAvrInt_TWI[] PROGMEM = "TWI"; +#endif +#if defined(SPM_READY_vect) || defined(SPM_RDY_vect) + prog_char gAvrInt_SPM_READY[] PROGMEM = "SPM READY"; +#endif +#ifdef USI_START_vect + prog_char gAvrInt_USI_START[] PROGMEM = "USI START"; +#endif +#ifdef USI_OVERFLOW_vect + prog_char gAvrInt_USI_OVERFLOW[] PROGMEM = "USI OVERFLOW"; +#endif +#ifdef USB_GEN_vect + prog_char gAvrInt_USB_General[] PROGMEM = "USB General"; +#endif +#ifdef USB_COM_vect + prog_char gAvrInt_USB_Endpoint[] PROGMEM = "USB Endpoint"; +#endif + +#ifdef LCD_vect + prog_char gAvrInt_LCD_StartFrame[] PROGMEM = "LCD Start of Frame"; +#endif + + +//************************************************************************************************** +//* these do not have vector defs and have to be done by CPU type +#if defined(__AVR_ATmega645__ ) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__) + prog_char gAvrInt_NOT_USED[] PROGMEM = "NOT_USED"; +#endif +#if defined(__AVR_ATmega32U4__) + prog_char gAvrInt_RESERVED[] PROGMEM = "Reserved"; +#endif + + prog_char gAvrInt_END[] PROGMEM = "*"; + + + + + +//************************************************************************************************** +#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) +#pragma mark __AVR_ATmega168__ / __AVR_ATmega328P__ + +#define _INTERRUPT_NAMES_DEFINED_ + +PGM_P gInterruptNameTable[] PROGMEM = +{ + + gAvrInt_RESET, // 1 + gAvrInt_INT0, // 2 + gAvrInt_INT1, // 3 + gAvrInt_PCINT0, // 4 + gAvrInt_PCINT1, // 5 + gAvrInt_PCINT2, // 6 + gAvrInt_WDT, // 7 + gAvrInt_TIMER2_COMPA, // 8 + gAvrInt_TIMER2_COMPB, // 9 + gAvrInt_TIMER2_OVF, // 10 + gAvrInt_TIMER1_CAPT, // 11 + gAvrInt_TIMER1_COMPA, // 12 + gAvrInt_TIMER1_COMPB, // 13 + gAvrInt_TIMER1_OVF, // 14 + gAvrInt_TIMER0_COMPA, // 15 + gAvrInt_TIMER0_COMPB, // 16 + gAvrInt_TIMER0_OVF, // 17 + gAvrInt_SPI_STC, // 18 + gAvrInt_USART_RX, // 19 + gAvrInt_USART_UDRE, // 20 + gAvrInt_USART_TX, // 21 + gAvrInt_ADC, // 22 + gAvrInt_EE_READY, // 23 + gAvrInt_ANALOG_COMP, // 24 + gAvrInt_TWI, // 25 + gAvrInt_SPM_READY, // 26 +}; + +#endif + +//************************************************************************************************** +#pragma mark __AVR_ATmega169__ +#if defined(__AVR_ATmega169__) + +#define _INTERRUPT_NAMES_DEFINED_ + +PGM_P gInterruptNameTable[] PROGMEM = +{ + + gAvrInt_RESET, // 1 + gAvrInt_INT0, // 2 + gAvrInt_PCINT0, // 3 + gAvrInt_PCINT1, // 4 + gAvrInt_TIMER2_COMP, // 5 + gAvrInt_TIMER2_OVF, // 6 + gAvrInt_TIMER1_CAPT, // 7 + gAvrInt_TIMER1_COMPA, // 8 + gAvrInt_TIMER1_COMPB, // 9 + gAvrInt_TIMER1_OVF, // 10 + gAvrInt_TIMER0_COMP, // 11 + gAvrInt_TIMER0_OVF, // 12 + gAvrInt_SPI_STC, // 13 + gAvrInt_USART0_RX, // 14 + gAvrInt_USART0_UDRE, // 15 + gAvrInt_USART0_TX, // 16 + gAvrInt_USI_START, // 17 + gAvrInt_USI_OVERFLOW, // 18 + gAvrInt_ANALOG_COMP, // 19 + gAvrInt_ADC, // 20 + gAvrInt_EE_READY, // 21 + gAvrInt_SPM_READY, // 22 + gAvrInt_LCD_StartFrame, // 23 + +}; + +#endif + + +//************************************************************************************************** +#if defined(__AVR_ATmega640__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) +#pragma mark __AVR_ATmega640__ __AVR_ATmega1280__ __AVR_ATmega1281__ __AVR_ATmega2560__ __AVR_ATmega2561__ + +#define _INTERRUPT_NAMES_DEFINED_ + +PGM_P gInterruptNameTable[] PROGMEM = +{ + + gAvrInt_RESET, // 1 + gAvrInt_INT0, // 2 + gAvrInt_INT1, // 3 + gAvrInt_INT2, // 4 + gAvrInt_INT3, // 5 + gAvrInt_INT4, // 6 + gAvrInt_INT5, // 7 + gAvrInt_INT6, // 8 + gAvrInt_INT7, // 9 + gAvrInt_PCINT0, // 10 + gAvrInt_PCINT1, // 11 +#if defined(__AVR_ATmega640__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) + gAvrInt_PCINT2, // 12 +#else + gAvrInt_NOT_USED, // 12 +#endif + gAvrInt_WDT, // 13 + gAvrInt_TIMER2_COMPA, // 14 + gAvrInt_TIMER2_COMPB, // 15 + gAvrInt_TIMER2_OVF, // 16 + gAvrInt_TIMER1_CAPT, // 17 + gAvrInt_TIMER1_COMPA, // 18 + gAvrInt_TIMER1_COMPB, // 19 + gAvrInt_TIMER1_COMPC, // 20 + gAvrInt_TIMER1_OVF, // 21 + gAvrInt_TIMER0_COMPA, // 22 + gAvrInt_TIMER0_COMPB, // 23 + gAvrInt_TIMER0_OVF, // 24 + gAvrInt_SPI_STC, // 25 + + gAvrInt_USART0_RX, // 26 + gAvrInt_USART0_UDRE, // 27 + gAvrInt_USART0_TX, // 28 + gAvrInt_ANALOG_COMP, // 29 + gAvrInt_ADC, // 30 + gAvrInt_EE_READY, // 31 + + gAvrInt_TIMER3_CAPT, // 32 + gAvrInt_TIMER3_COMPA, // 33 + gAvrInt_TIMER3_COMPB, // 34 + gAvrInt_TIMER3_COMPC, // 35 + gAvrInt_TIMER3_OVF, // 36 + + gAvrInt_USART1_RX, // 37 + gAvrInt_USART1_UDRE, // 38 + gAvrInt_USART1_TX, // 39 + gAvrInt_TWI, // 40 + gAvrInt_SPM_READY, // 41 +#if defined(__AVR_ATmega640__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) + gAvrInt_TIMER4_CAPT, // 42 +#else + gAvrInt_NOT_USED, // 42 +#endif + gAvrInt_TIMER4_COMPA, // 43 + gAvrInt_TIMER4_COMPB, // 44 + gAvrInt_TIMER4_COMPC, // 45 + gAvrInt_TIMER4_OVF, // 46 +#if defined(__AVR_ATmega640__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) + gAvrInt_TIMER5_CAPT, // 47 +#else + gAvrInt_NOT_USED, // 47 +#endif + gAvrInt_TIMER5_COMPA, // 48 + gAvrInt_TIMER5_COMPB, // 49 + gAvrInt_TIMER5_COMPC, // 50 + gAvrInt_TIMER5_OVF, // 51 + +#if defined(__AVR_ATmega640__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) + gAvrInt_USART2_RX, // 52 + gAvrInt_USART2_UDRE, // 53 + gAvrInt_USART2_TX, // 54 + + gAvrInt_USART3_RX, // 55 + gAvrInt_USART3_UDRE, // 56 + gAvrInt_USART3_TX, // 57 +#endif + +}; + +#endif + + + +//************************************************************************************************** +#if defined(__AVR_ATmega324P__ ) || defined(__AVR_ATmega644__ ) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__) +#pragma mark __AVR_ATmega324P__ __AVR_ATmega644__ __AVR_ATmega644P__ __AVR_ATmega1284P__ + +#define _INTERRUPT_NAMES_DEFINED_ + +PGM_P gInterruptNameTable[] PROGMEM = +{ + + gAvrInt_RESET, // 1 + gAvrInt_INT0, // 2 + gAvrInt_INT1, // 3 + gAvrInt_INT2, // 4 + gAvrInt_PCINT0, // 5 + gAvrInt_PCINT1, // 6 + gAvrInt_PCINT2, // 7 + gAvrInt_PCINT3, // 8 + gAvrInt_WDT, // 9 + gAvrInt_TIMER2_COMPA, // 10 + gAvrInt_TIMER2_COMPB, // 11 + gAvrInt_TIMER2_OVF, // 12 + gAvrInt_TIMER1_CAPT, // 13 + gAvrInt_TIMER1_COMPA, // 14 + gAvrInt_TIMER1_COMPB, // 15 + gAvrInt_TIMER1_OVF, // 16 + gAvrInt_TIMER0_COMPA, // 17 + gAvrInt_TIMER0_COMPB, // 18 + gAvrInt_TIMER0_OVF, // 19 + gAvrInt_SPI_STC, // 20 + gAvrInt_USART0_RX, // 21 + gAvrInt_USART0_UDRE, // 22 + gAvrInt_USART0_TX, // 23 + gAvrInt_ANALOG_COMP, // 24 + gAvrInt_ADC, // 25 + gAvrInt_EE_READY, // 26 + gAvrInt_TWI, // 27 + gAvrInt_SPM_READY, // 28 + +#if defined(__AVR_ATmega324P__ ) || defined(__AVR_ATmega644P__) + gAvrInt_USART1_RX, // 29 + gAvrInt_USART1_UDRE, // 30 + gAvrInt_USART1_TX, // 31 +#endif + +}; + + +#endif + +//************************************************************************************************** +#if defined(__AVR_ATmega645__ ) +#pragma mark __AVR_ATmega645__ + +#define _INTERRUPT_NAMES_DEFINED_ + +PGM_P gInterruptNameTable[] PROGMEM = +{ + + gAvrInt_RESET, // 1 + gAvrInt_INT0, // 2 + gAvrInt_PCINT0, // 3 + gAvrInt_PCINT1, // 4 + gAvrInt_TIMER2_COMP, // 5 + gAvrInt_TIMER2_OVF, // 6 + gAvrInt_TIMER1_CAPT, // 7 + gAvrInt_TIMER1_COMPA, // 8 + gAvrInt_TIMER1_COMPB, // 9 + gAvrInt_TIMER1_OVF, // 10 + gAvrInt_TIMER0_COMP, // 11 + gAvrInt_TIMER0_OVF, // 12 + gAvrInt_SPI_STC, // 13 + gAvrInt_USART0_RX, // 14 + gAvrInt_USART0_UDRE, // 15 + gAvrInt_USART0_TX, // 16 + gAvrInt_USI_START, // 17 + gAvrInt_USI_OVERFLOW, // 18 + gAvrInt_ANALOG_COMP, // 19 + gAvrInt_ADC, // 20 + gAvrInt_EE_READY, // 21 + gAvrInt_SPM_READY, // 22 + gAvrInt_NOT_USED, // 23 + +#if defined(__AVR_ATmega3250__) || defined(__AVR_ATmega6450__) + gAvrInt_PCINT2, // 24 + gAvrInt_PCINT3, // 25 +#endif +}; + + +#endif + + +//************************************************************************************************** +#if defined(__AVR_ATmega32__ ) +#pragma mark __AVR_ATmega32__ + +#define _INTERRUPT_NAMES_DEFINED_ + +PGM_P gInterruptNameTable[] PROGMEM = +{ + + gAvrInt_RESET, // 1 + gAvrInt_INT0, // 2 + gAvrInt_INT1, // 3 + gAvrInt_INT2, // 4 + gAvrInt_TIMER2_COMP, // 5 + gAvrInt_TIMER2_OVF, // 6 + gAvrInt_TIMER1_CAPT, // 7 + gAvrInt_TIMER1_COMPA, // 8 + gAvrInt_TIMER1_COMPB, // 9 + gAvrInt_TIMER1_OVF, // 10 + gAvrInt_TIMER0_COMP, // 11 + gAvrInt_TIMER0_OVF, // 12 + gAvrInt_SPI_STC, // 13 + gAvrInt_USART_RX, // 14 + gAvrInt_USART_UDRE, // 15 + gAvrInt_USART_TX, // 16 + gAvrInt_ADC, // 17 + gAvrInt_EE_READY, // 18 + gAvrInt_ANALOG_COMP, // 19 + gAvrInt_TWI, // 20 + gAvrInt_SPM_READY, // 21 + +}; + + +#endif + +//************************************************************************************************** +#if defined(__AVR_ATmega32U4__) +#pragma mark __AVR_ATmega32U4__ +//* teensy 2.0 +//* http://www.pjrc.com/teensy/pinout.html +#define _INTERRUPT_NAMES_DEFINED_ + + +PGM_P gInterruptNameTable[] PROGMEM = +{ + + gAvrInt_RESET, // 1 + gAvrInt_INT0, // 2 + gAvrInt_INT1, // 3 + gAvrInt_INT2, // 4 + gAvrInt_INT3, // 5 + gAvrInt_RESERVED, // 6 + gAvrInt_RESERVED, // 7 + gAvrInt_INT6, // 8 + gAvrInt_RESERVED, // 9 + gAvrInt_PCINT0, // 10 + gAvrInt_USB_General, // 11 + gAvrInt_USB_Endpoint, // 12 + gAvrInt_WDT, // 13 + gAvrInt_RESERVED, // 14 + gAvrInt_RESERVED, // 15 + gAvrInt_RESERVED, // 16 + gAvrInt_TIMER1_CAPT, // 17 + gAvrInt_TIMER1_COMPA, // 18 + gAvrInt_TIMER1_COMPB, // 19 + gAvrInt_TIMER1_COMPC, // 20 + gAvrInt_TIMER1_OVF, // 21 + gAvrInt_TIMER0_COMPA, // 22 + gAvrInt_TIMER0_COMPB, // 23 + gAvrInt_TIMER0_OVF, // 24 + gAvrInt_SPI_STC, // 25 + + gAvrInt_USART1_RX, // 26 + gAvrInt_USART1_UDRE, // 27 + gAvrInt_USART1_TX, // 28 + gAvrInt_ANALOG_COMP, // 29 + + gAvrInt_ADC, // 30 + gAvrInt_EE_READY, // 31 + + gAvrInt_TIMER3_CAPT, // 32 + gAvrInt_TIMER3_COMPA, // 33 + gAvrInt_TIMER3_COMPB, // 34 + gAvrInt_TIMER3_COMPC, // 35 + gAvrInt_TIMER3_OVF, // 36 + gAvrInt_TWI, // 37 + gAvrInt_SPM_READY, // 38 + + gAvrInt_TIMER4_COMPA, // 39 + gAvrInt_TIMER4_COMPB, // 40 + gAvrInt_TIMER4_COMPD, // 41 + gAvrInt_TIMER4_OVF, // 42 + gAvrInt_TIMER4_FPF, // 43 +}; + +#endif + +//************************************************************************************************** +#if defined(__AVR_AT90USB1286__) +#pragma mark __AVR_AT90USB1286__ +//* teensy++ 2.0 +//* http://www.pjrc.com/teensy/pinout.html +#define _INTERRUPT_NAMES_DEFINED_ + + +PGM_P gInterruptNameTable[] PROGMEM = +{ + + gAvrInt_RESET, // 1 + gAvrInt_INT0, // 2 + gAvrInt_INT1, // 3 + gAvrInt_INT2, // 4 + gAvrInt_INT3, // 5 + gAvrInt_INT4, // 6 + gAvrInt_INT5, // 7 + gAvrInt_INT6, // 8 + gAvrInt_INT7, // 9 + gAvrInt_PCINT0, // 10 + gAvrInt_USB_General, // 11 + gAvrInt_USB_Endpoint, // 12 + gAvrInt_WDT, // 13 + gAvrInt_TIMER2_COMPA, // 14 + gAvrInt_TIMER2_COMPB, // 15 + gAvrInt_TIMER2_OVF, // 16 + gAvrInt_TIMER1_CAPT, // 17 + gAvrInt_TIMER1_COMPA, // 18 + gAvrInt_TIMER1_COMPB, // 19 + gAvrInt_TIMER1_COMPC, // 20 + gAvrInt_TIMER1_OVF, // 21 + gAvrInt_TIMER0_COMPA, // 22 + gAvrInt_TIMER0_COMPB, // 23 + gAvrInt_TIMER0_OVF, // 24 + gAvrInt_SPI_STC, // 25 + + gAvrInt_USART1_RX, // 26 + gAvrInt_USART1_UDRE, // 27 + gAvrInt_USART1_TX, // 28 + gAvrInt_ANALOG_COMP, // 29 + + gAvrInt_ADC, // 30 + gAvrInt_EE_READY, // 31 + + gAvrInt_TIMER3_CAPT, // 32 + gAvrInt_TIMER3_COMPA, // 33 + gAvrInt_TIMER3_COMPB, // 34 + gAvrInt_TIMER3_COMPC, // 35 + gAvrInt_TIMER3_OVF, // 36 + gAvrInt_TWI, // 37 + gAvrInt_SPM_READY, // 38 + +}; + +#endif + + + + +//************************************************************************************************** +#if defined(__AVR_ATmega128__) +#pragma mark __AVR_ATmega128__ +#define _INTERRUPT_NAMES_DEFINED_ + + +PGM_P gInterruptNameTable[] PROGMEM = +{ + + gAvrInt_RESET, // 1 + gAvrInt_INT0, // 2 + gAvrInt_INT1, // 3 + gAvrInt_INT2, // 4 + gAvrInt_INT3, // 5 + gAvrInt_INT4, // 6 + gAvrInt_INT5, // 7 + gAvrInt_INT6, // 8 + gAvrInt_INT7, // 9 + gAvrInt_TIMER2_COMP, // 10 + gAvrInt_TIMER2_OVF, // 11 + gAvrInt_TIMER1_CAPT, // 12 + gAvrInt_TIMER1_COMPA, // 13 + gAvrInt_TIMER1_COMPB, // 14 + gAvrInt_TIMER1_OVF, // 15 + gAvrInt_TIMER0_COMP, // 16 + gAvrInt_TIMER0_OVF, // 17 + gAvrInt_SPI_STC, // 18 + gAvrInt_USART0_RX, // 19 + gAvrInt_USART0_UDRE, // 20 + gAvrInt_USART0_TX, // 21 + gAvrInt_ADC, // 22 + gAvrInt_EE_READY, // 23 + gAvrInt_ANALOG_COMP, // 24 + gAvrInt_TIMER1_COMPC, // 25 + gAvrInt_TIMER3_CAPT, // 26 + gAvrInt_TIMER3_COMPA, // 27 + gAvrInt_TIMER3_COMPB, // 28 + gAvrInt_TIMER3_COMPC, // 29 + gAvrInt_TIMER3_OVF, // 30 + gAvrInt_USART1_RX, // 31 + gAvrInt_USART1_UDRE, // 32 + gAvrInt_USART1_TX, // 33 + gAvrInt_TWI, // 34 + gAvrInt_SPM_READY, // 35 + +}; + +#endif + +#if !defined(_INTERRUPT_NAMES_DEFINED_) + #warning No interrupt string defs for this cpu +#endif \ No newline at end of file diff --git a/arduino-0022-linux-x64/hardware/arduino/bootloaders/stk500v2/command.h b/arduino-0022-linux-x64/hardware/arduino/bootloaders/stk500v2/command.h new file mode 100644 index 0000000..03b1b38 --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/bootloaders/stk500v2/command.h @@ -0,0 +1,114 @@ +//**** ATMEL AVR - A P P L I C A T I O N N O T E ************************ +//* +//* Title: AVR068 - STK500 Communication Protocol +//* Filename: command.h +//* Version: 1.0 +//* Last updated: 31.01.2005 +//* +//* Support E-mail: avr@atmel.com +//* +//************************************************************************** + +// *****************[ STK message constants ]*************************** + +#define MESSAGE_START 0x1B //= ESC = 27 decimal +#define TOKEN 0x0E + +// *****************[ STK general command constants ]************************** + +#define CMD_SIGN_ON 0x01 +#define CMD_SET_PARAMETER 0x02 +#define CMD_GET_PARAMETER 0x03 +#define CMD_SET_DEVICE_PARAMETERS 0x04 +#define CMD_OSCCAL 0x05 +#define CMD_LOAD_ADDRESS 0x06 +#define CMD_FIRMWARE_UPGRADE 0x07 + + +// *****************[ STK ISP command constants ]****************************** + +#define CMD_ENTER_PROGMODE_ISP 0x10 +#define CMD_LEAVE_PROGMODE_ISP 0x11 +#define CMD_CHIP_ERASE_ISP 0x12 +#define CMD_PROGRAM_FLASH_ISP 0x13 +#define CMD_READ_FLASH_ISP 0x14 +#define CMD_PROGRAM_EEPROM_ISP 0x15 +#define CMD_READ_EEPROM_ISP 0x16 +#define CMD_PROGRAM_FUSE_ISP 0x17 +#define CMD_READ_FUSE_ISP 0x18 +#define CMD_PROGRAM_LOCK_ISP 0x19 +#define CMD_READ_LOCK_ISP 0x1A +#define CMD_READ_SIGNATURE_ISP 0x1B +#define CMD_READ_OSCCAL_ISP 0x1C +#define CMD_SPI_MULTI 0x1D + +// *****************[ STK PP command constants ]******************************* + +#define CMD_ENTER_PROGMODE_PP 0x20 +#define CMD_LEAVE_PROGMODE_PP 0x21 +#define CMD_CHIP_ERASE_PP 0x22 +#define CMD_PROGRAM_FLASH_PP 0x23 +#define CMD_READ_FLASH_PP 0x24 +#define CMD_PROGRAM_EEPROM_PP 0x25 +#define CMD_READ_EEPROM_PP 0x26 +#define CMD_PROGRAM_FUSE_PP 0x27 +#define CMD_READ_FUSE_PP 0x28 +#define CMD_PROGRAM_LOCK_PP 0x29 +#define CMD_READ_LOCK_PP 0x2A +#define CMD_READ_SIGNATURE_PP 0x2B +#define CMD_READ_OSCCAL_PP 0x2C + +#define CMD_SET_CONTROL_STACK 0x2D + +// *****************[ STK HVSP command constants ]***************************** + +#define CMD_ENTER_PROGMODE_HVSP 0x30 +#define CMD_LEAVE_PROGMODE_HVSP 0x31 +#define CMD_CHIP_ERASE_HVSP 0x32 +#define CMD_PROGRAM_FLASH_HVSP ` 0x33 +#define CMD_READ_FLASH_HVSP 0x34 +#define CMD_PROGRAM_EEPROM_HVSP 0x35 +#define CMD_READ_EEPROM_HVSP 0x36 +#define CMD_PROGRAM_FUSE_HVSP 0x37 +#define CMD_READ_FUSE_HVSP 0x38 +#define CMD_PROGRAM_LOCK_HVSP 0x39 +#define CMD_READ_LOCK_HVSP 0x3A +#define CMD_READ_SIGNATURE_HVSP 0x3B +#define CMD_READ_OSCCAL_HVSP 0x3C + +// *****************[ STK status constants ]*************************** + +// Success +#define STATUS_CMD_OK 0x00 + +// Warnings +#define STATUS_CMD_TOUT 0x80 +#define STATUS_RDY_BSY_TOUT 0x81 +#define STATUS_SET_PARAM_MISSING 0x82 + +// Errors +#define STATUS_CMD_FAILED 0xC0 +#define STATUS_CKSUM_ERROR 0xC1 +#define STATUS_CMD_UNKNOWN 0xC9 + +// *****************[ STK parameter constants ]*************************** +#define PARAM_BUILD_NUMBER_LOW 0x80 +#define PARAM_BUILD_NUMBER_HIGH 0x81 +#define PARAM_HW_VER 0x90 +#define PARAM_SW_MAJOR 0x91 +#define PARAM_SW_MINOR 0x92 +#define PARAM_VTARGET 0x94 +#define PARAM_VADJUST 0x95 +#define PARAM_OSC_PSCALE 0x96 +#define PARAM_OSC_CMATCH 0x97 +#define PARAM_SCK_DURATION 0x98 +#define PARAM_TOPCARD_DETECT 0x9A +#define PARAM_STATUS 0x9C +#define PARAM_DATA 0x9D +#define PARAM_RESET_POLARITY 0x9E +#define PARAM_CONTROLLER_INIT 0x9F + +// *****************[ STK answer constants ]*************************** + +#define ANSWER_CKSUM_ERROR 0xB0 + diff --git a/arduino-0022-linux-x64/hardware/arduino/bootloaders/stk500v2/stk500boot.c b/arduino-0022-linux-x64/hardware/arduino/bootloaders/stk500v2/stk500boot.c new file mode 100644 index 0000000..13dec89 --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/bootloaders/stk500v2/stk500boot.c @@ -0,0 +1,1996 @@ +/***************************************************************************** +Title: STK500v2 compatible bootloader + Modified for Wiring board ATMega128-16MHz +Author: Peter Fleury http://jump.to/fleury +File: $Id: stk500boot.c,v 1.11 2006/06/25 12:39:17 peter Exp $ +Compiler: avr-gcc 3.4.5 or 4.1 / avr-libc 1.4.3 +Hardware: All AVRs with bootloader support, tested with ATmega8 +License: GNU General Public License + +Modified: Worapoht Kornkaewwattanakul http://www.avride.com +Date: 17 October 2007 +Update: 1st, 29 Dec 2007 : Enable CMD_SPI_MULTI but ignore unused command by return 0x00 byte response.. +Compiler: WINAVR20060421 +Description: add timeout feature like previous Wiring bootloader + +DESCRIPTION: + This program allows an AVR with bootloader capabilities to + read/write its own Flash/EEprom. To enter Programming mode + an input pin is checked. If this pin is pulled low, programming mode + is entered. If not, normal execution is done from $0000 + "reset" vector in Application area. + Size fits into a 1024 word bootloader section + when compiled with avr-gcc 4.1 + (direct replace on Wiring Board without fuse setting changed) + +USAGE: + - Set AVR MCU type and clock-frequency (F_CPU) in the Makefile. + - Set baud rate below (AVRISP only works with 115200 bps) + - compile/link the bootloader with the supplied Makefile + - program the "Boot Flash section size" (BOOTSZ fuses), + for boot-size 1024 words: program BOOTSZ01 + - enable the BOOT Reset Vector (program BOOTRST) + - Upload the hex file to the AVR using any ISP programmer + - Program Boot Lock Mode 3 (program BootLock 11 and BootLock 12 lock bits) // (leave them) + - Reset your AVR while keeping PROG_PIN pulled low // (for enter bootloader by switch) + - Start AVRISP Programmer (AVRStudio/Tools/Program AVR) + - AVRISP will detect the bootloader + - Program your application FLASH file and optional EEPROM file using AVRISP + +Note: + Erasing the device without flashing, through AVRISP GUI button "Erase Device" + is not implemented, due to AVRStudio limitations. + Flash is always erased before programming. + + AVRdude: + Please uncomment #define REMOVE_CMD_SPI_MULTI when using AVRdude. + Comment #define REMOVE_PROGRAM_LOCK_BIT_SUPPORT to reduce code size + Read Fuse Bits and Read/Write Lock Bits is not supported + +NOTES: + Based on Atmel Application Note AVR109 - Self-programming + Based on Atmel Application Note AVR068 - STK500v2 Protocol + +LICENSE: + Copyright (C) 2006 Peter Fleury + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + any later version. + + This program 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 General Public License for more details. + +*****************************************************************************/ + +//************************************************************************ +//* Edit History +//************************************************************************ +//* Jul 7, 2010 = Mark Sproul msproul@skycharoit.com +//* Jul 7, 2010 Working on mega2560. No Auto-restart +//* Jul 7, 2010 Switched to 8K bytes (4K words) so that we have room for the monitor +//* Jul 8, 2010 Found older version of source that had auto restart, put that code back in +//* Jul 8, 2010 Adding monitor code +//* Jul 11, 2010 Added blinking LED while waiting for download to start +//* Jul 11, 2010 Added EEPROM test +//* Jul 29, 2010 Added recchar_timeout for timing out on bootloading +//* Aug 23, 2010 Added support for atmega2561 +//* Aug 26, 2010 Removed support for BOOT_BY_SWITCH +//************************************************************************ + + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "command.h" + + +#if defined(_MEGA_BOARD_) || defined(_BOARD_AMBER128_) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) + #define ENABLE_MONITOR + static void RunMonitor(void); +#endif + +//#define _DEBUG_SERIAL_ +//#define _DEBUG_WITH_LEDS_ + + +/* + * Uncomment the following lines to save code space + */ +//#define REMOVE_PROGRAM_LOCK_BIT_SUPPORT // disable program lock bits +//#define REMOVE_BOOTLOADER_LED // no LED to show active bootloader +//#define REMOVE_CMD_SPI_MULTI // disable processing of SPI_MULTI commands, Remark this line for AVRDUDE +// + + + +//************************************************************************ +//* LED on pin "PROGLED_PIN" on port "PROGLED_PORT" +//* indicates that bootloader is active +//* PG2 -> LED on Wiring board +//************************************************************************ +#define BLINK_LED_WHILE_WAITING + +#ifdef _MEGA_BOARD_ + #define PROGLED_PORT PORTB + #define PROGLED_DDR DDRB + #define PROGLED_PIN PINB7 +#elif defined( _BOARD_AMBER128_ ) + //* this is for the amber 128 http://www.soc-robotics.com/ + //* onbarod led is PORTE4 + #define PROGLED_PORT PORTD + #define PROGLED_DDR DDRD + #define PROGLED_PIN PINE7 +#elif defined( _CEREBOTPLUS_BOARD_ ) + //* this is for the Cerebot 2560 board + //* onbarod leds are on PORTE4-7 + #define PROGLED_PORT PORTE + #define PROGLED_DDR DDRE + #define PROGLED_PIN PINE7 +#elif defined( _PENGUINO_ ) + //* this is for the Penguino + //* onbarod led is PORTE4 + #define PROGLED_PORT PORTC + #define PROGLED_DDR DDRC + #define PROGLED_PIN PINC6 +#elif defined( _ANDROID_2561_ ) || defined( __AVR_ATmega2561__ ) + //* this is for the Boston Android 2561 + //* onbarod led is PORTE4 + #define PROGLED_PORT PORTA + #define PROGLED_DDR DDRA + #define PROGLED_PIN PINA3 +#else + #define PROGLED_PORT PORTG + #define PROGLED_DDR DDRG + #define PROGLED_PIN PING2 +#endif + + + +/* + * define CPU frequency in Mhz here if not defined in Makefile + */ +#ifndef F_CPU + #define F_CPU 16000000UL +#endif + +/* + * UART Baudrate, AVRStudio AVRISP only accepts 115200 bps + */ + +#ifndef BAUDRATE + #define BAUDRATE 115200 +#endif + +/* + * Enable (1) or disable (0) USART double speed operation + */ +#ifndef UART_BAUDRATE_DOUBLE_SPEED + #if defined (__AVR_ATmega32__) + #define UART_BAUDRATE_DOUBLE_SPEED 0 + #else + #define UART_BAUDRATE_DOUBLE_SPEED 1 + #endif +#endif + +/* + * HW and SW version, reported to AVRISP, must match version of AVRStudio + */ +#define CONFIG_PARAM_BUILD_NUMBER_LOW 0 +#define CONFIG_PARAM_BUILD_NUMBER_HIGH 0 +#define CONFIG_PARAM_HW_VER 0x0F +#define CONFIG_PARAM_SW_MAJOR 2 +#define CONFIG_PARAM_SW_MINOR 0x0A + +/* + * Calculate the address where the bootloader starts from FLASHEND and BOOTSIZE + * (adjust BOOTSIZE below and BOOTLOADER_ADDRESS in Makefile if you want to change the size of the bootloader) + */ +//#define BOOTSIZE 1024 +#if FLASHEND > 0x0F000 + #define BOOTSIZE 8192 +#else + #define BOOTSIZE 2048 +#endif + +#define APP_END (FLASHEND -(2*BOOTSIZE) + 1) + +/* + * Signature bytes are not available in avr-gcc io_xxx.h + */ +#if defined (__AVR_ATmega8__) + #define SIGNATURE_BYTES 0x1E9307 +#elif defined (__AVR_ATmega16__) + #define SIGNATURE_BYTES 0x1E9403 +#elif defined (__AVR_ATmega32__) + #define SIGNATURE_BYTES 0x1E9502 +#elif defined (__AVR_ATmega8515__) + #define SIGNATURE_BYTES 0x1E9306 +#elif defined (__AVR_ATmega8535__) + #define SIGNATURE_BYTES 0x1E9308 +#elif defined (__AVR_ATmega162__) + #define SIGNATURE_BYTES 0x1E9404 +#elif defined (__AVR_ATmega128__) + #define SIGNATURE_BYTES 0x1E9702 +#elif defined (__AVR_ATmega1280__) + #define SIGNATURE_BYTES 0x1E9703 +#elif defined (__AVR_ATmega2560__) + #define SIGNATURE_BYTES 0x1E9801 +#elif defined (__AVR_ATmega2561__) + #define SIGNATURE_BYTES 0x1e9802 +#else + #error "no signature definition for MCU available" +#endif + + +#if defined(__AVR_ATmega8__) || defined(__AVR_ATmega16__) || defined(__AVR_ATmega32__) \ + || defined(__AVR_ATmega8515__) || defined(__AVR_ATmega8535__) + /* ATMega8 with one USART */ + #define UART_BAUD_RATE_LOW UBRRL + #define UART_STATUS_REG UCSRA + #define UART_CONTROL_REG UCSRB + #define UART_ENABLE_TRANSMITTER TXEN + #define UART_ENABLE_RECEIVER RXEN + #define UART_TRANSMIT_COMPLETE TXC + #define UART_RECEIVE_COMPLETE RXC + #define UART_DATA_REG UDR + #define UART_DOUBLE_SPEED U2X + +#elif defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) || defined(__AVR_ATmega162__) \ + || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) + /* ATMega with two USART, use UART0 */ + #define UART_BAUD_RATE_LOW UBRR0L + #define UART_STATUS_REG UCSR0A + #define UART_CONTROL_REG UCSR0B + #define UART_ENABLE_TRANSMITTER TXEN0 + #define UART_ENABLE_RECEIVER RXEN0 + #define UART_TRANSMIT_COMPLETE TXC0 + #define UART_RECEIVE_COMPLETE RXC0 + #define UART_DATA_REG UDR0 + #define UART_DOUBLE_SPEED U2X0 +#else + #error "no UART definition for MCU available" +#endif + + + +/* + * Macro to calculate UBBR from XTAL and baudrate + */ +#if defined(__AVR_ATmega32__) && UART_BAUDRATE_DOUBLE_SPEED + #define UART_BAUD_SELECT(baudRate,xtalCpu) ((xtalCpu / 4 / baudRate - 1) / 2) +#elif defined(__AVR_ATmega32__) + #define UART_BAUD_SELECT(baudRate,xtalCpu) ((xtalCpu / 8 / baudRate - 1) / 2) +#elif UART_BAUDRATE_DOUBLE_SPEED + #define UART_BAUD_SELECT(baudRate,xtalCpu) (((float)(xtalCpu))/(((float)(baudRate))*8.0)-1.0+0.5) +#else + #define UART_BAUD_SELECT(baudRate,xtalCpu) (((float)(xtalCpu))/(((float)(baudRate))*16.0)-1.0+0.5) +#endif + + +/* + * States used in the receive state machine + */ +#define ST_START 0 +#define ST_GET_SEQ_NUM 1 +#define ST_MSG_SIZE_1 2 +#define ST_MSG_SIZE_2 3 +#define ST_GET_TOKEN 4 +#define ST_GET_DATA 5 +#define ST_GET_CHECK 6 +#define ST_PROCESS 7 + +/* + * use 16bit address variable for ATmegas with <= 64K flash + */ +#if defined(RAMPZ) + typedef uint32_t address_t; +#else + typedef uint16_t address_t; +#endif + +/* + * function prototypes + */ +static void sendchar(char c); +static unsigned char recchar(void); + +/* + * since this bootloader is not linked against the avr-gcc crt1 functions, + * to reduce the code size, we need to provide our own initialization + */ +void __jumpMain (void) __attribute__ ((naked)) __attribute__ ((section (".init9"))); +#include + +//#define SPH_REG 0x3E +//#define SPL_REG 0x3D + +//***************************************************************************** +void __jumpMain(void) +{ +//* July 17, 2010 Added stack pointer initialzation +//* the first line did not do the job on the ATmega128 + + asm volatile ( ".set __stack, %0" :: "i" (RAMEND) ); + +// ldi r16,high(RAMEND) +// out SPH,r16 ; Set stack pointer to top of RAM + +// asm volatile ( "ldi 16, 0x10"); + asm volatile ( "ldi 16, %0" :: "i" (RAMEND >> 8) ); +// asm volatile ( "out 0x3E,16"); +// asm volatile ( "out %0,16" :: "i" (SPH_REG) ); + asm volatile ( "out %0,16" :: "i" (AVR_STACK_POINTER_HI_ADDR) ); + +// asm volatile ( "ldi 16, 0x00"); + asm volatile ( "ldi 16, %0" :: "i" (RAMEND & 0x0ff) ); +// asm volatile ( "out 0x3d,16"); +// asm volatile ( "out %0,16" :: "i" (SPL_REG) ); + asm volatile ( "out %0,16" :: "i" (AVR_STACK_POINTER_LO_ADDR) ); + + + + asm volatile ( "clr __zero_reg__" ); // GCC depends on register r1 set to 0 + asm volatile ( "out %0, __zero_reg__" :: "I" (_SFR_IO_ADDR(SREG)) ); // set SREG to 0 +// asm volatile ( "rjmp main"); // jump to main() + asm volatile ( "jmp main"); // jump to main() +} + + +//***************************************************************************** +void delay_ms(unsigned int timedelay) +{ + unsigned int i; + for (i=0;i> 1) +//***************************************************************************** +static unsigned char recchar_timeout(void) +{ +uint32_t count = 0; + + while (!(UART_STATUS_REG & (1 << UART_RECEIVE_COMPLETE))) + { + // wait for data + count++; + if (count > MAX_TIME_COUNT) + { + unsigned int data; + #if (FLASHEND > 0x0FFFF) + data = pgm_read_word_far(0); //* get the first word of the user program + #else + data = pgm_read_word_near(0); //* get the first word of the user program + #endif + if (data != 0xffff) //* make sure its valid before jumping to it. + { + asm volatile( + "clr r30 \n\t" + "clr r31 \n\t" + "ijmp \n\t" + ); + } + count = 0; + } + } + return UART_DATA_REG; +} + + + +//***************************************************************************** +int main(void) +{ + address_t address = 0; + address_t eraseAddress = 0; + unsigned char msgParseState; + unsigned int ii = 0; + unsigned char checksum = 0; + unsigned char seqNum = 0; + unsigned int msgLength = 0; + unsigned char msgBuffer[285]; + unsigned char c, *p; + unsigned char isLeave = 0; + + unsigned long boot_timeout; + unsigned long boot_timer; + unsigned int boot_state; +#ifdef ENABLE_MONITOR + unsigned int exPointCntr = 0; +#endif + + + boot_timer = 0; + boot_state = 0; + +#ifdef BLINK_LED_WHILE_WAITING + boot_timeout = 20000; //* should be about 1 second +// boot_timeout = 170000; +#else + boot_timeout = 3500000; // 7 seconds , approx 2us per step when optimize "s" +#endif + /* + * Branch to bootloader or application code ? + */ + +#ifndef REMOVE_BOOTLOADER_LED + /* PROG_PIN pulled low, indicate with LED that bootloader is active */ + PROGLED_DDR |= (1< boot_timeout) + { + boot_state = 1; // (after ++ -> boot_state=2 bootloader timeout, jump to main 0x00000 ) + } + #ifdef BLINK_LED_WHILE_WAITING + if ((boot_timer % 7000) == 0) + { + //* toggle the LED + PROGLED_PORT ^= (1<>16) & 0x000000FF; + else if ( signatureIndex == 1 ) + answerByte = (SIGNATURE_BYTES >> 8) & 0x000000FF; + else + answerByte = SIGNATURE_BYTES & 0x000000FF; + } + else if ( msgBuffer[4] & 0x50 ) + { + answerByte = 0; //read fuse/lock bits not implemented, return dummy value + } + else + { + answerByte = 0; // for all others command are not implemented, return dummy value for AVRDUDE happy + // flag = 1; // Remark this line for AVRDUDE + } + if ( !flag ) + { + msgLength = 7; + msgBuffer[1] = STATUS_CMD_OK; + msgBuffer[2] = 0; + msgBuffer[3] = msgBuffer[4]; + msgBuffer[4] = 0; + msgBuffer[5] = answerByte; + msgBuffer[6] = STATUS_CMD_OK; + } + } + break; + #endif + case CMD_SIGN_ON: + msgLength = 11; + msgBuffer[1] = STATUS_CMD_OK; + msgBuffer[2] = 8; + msgBuffer[3] = 'A'; + msgBuffer[4] = 'V'; + msgBuffer[5] = 'R'; + msgBuffer[6] = 'I'; + msgBuffer[7] = 'S'; + msgBuffer[8] = 'P'; + msgBuffer[9] = '_'; + msgBuffer[10] = '2'; + break; + + case CMD_GET_PARAMETER: + { + unsigned char value; + + switch(msgBuffer[1]) + { + case PARAM_BUILD_NUMBER_LOW: + value = CONFIG_PARAM_BUILD_NUMBER_LOW; + break; + case PARAM_BUILD_NUMBER_HIGH: + value = CONFIG_PARAM_BUILD_NUMBER_HIGH; + break; + case PARAM_HW_VER: + value = CONFIG_PARAM_HW_VER; + break; + case PARAM_SW_MAJOR: + value = CONFIG_PARAM_SW_MAJOR; + break; + case PARAM_SW_MINOR: + value = CONFIG_PARAM_SW_MINOR; + break; + default: + value = 0; + break; + } + msgLength = 3; + msgBuffer[1] = STATUS_CMD_OK; + msgBuffer[2] = value; + } + break; + + case CMD_LEAVE_PROGMODE_ISP: + isLeave = 1; + //* fall thru + + case CMD_SET_PARAMETER: + case CMD_ENTER_PROGMODE_ISP: + msgLength = 2; + msgBuffer[1] = STATUS_CMD_OK; + break; + + case CMD_READ_SIGNATURE_ISP: + { + unsigned char signatureIndex = msgBuffer[4]; + unsigned char signature; + + if ( signatureIndex == 0 ) + signature = (SIGNATURE_BYTES >>16) & 0x000000FF; + else if ( signatureIndex == 1 ) + signature = (SIGNATURE_BYTES >> 8) & 0x000000FF; + else + signature = SIGNATURE_BYTES & 0x000000FF; + + msgLength = 4; + msgBuffer[1] = STATUS_CMD_OK; + msgBuffer[2] = signature; + msgBuffer[3] = STATUS_CMD_OK; + } + break; + + case CMD_READ_LOCK_ISP: + msgLength = 4; + msgBuffer[1] = STATUS_CMD_OK; + msgBuffer[2] = boot_lock_fuse_bits_get( GET_LOCK_BITS ); + msgBuffer[3] = STATUS_CMD_OK; + break; + + case CMD_READ_FUSE_ISP: + { + unsigned char fuseBits; + + if ( msgBuffer[2] == 0x50 ) + { + if ( msgBuffer[3] == 0x08 ) + fuseBits = boot_lock_fuse_bits_get( GET_EXTENDED_FUSE_BITS ); + else + fuseBits = boot_lock_fuse_bits_get( GET_LOW_FUSE_BITS ); + } + else + { + fuseBits = boot_lock_fuse_bits_get( GET_HIGH_FUSE_BITS ); + } + msgLength = 4; + msgBuffer[1] = STATUS_CMD_OK; + msgBuffer[2] = fuseBits; + msgBuffer[3] = STATUS_CMD_OK; + } + break; + + #ifndef REMOVE_PROGRAM_LOCK_BIT_SUPPORT + case CMD_PROGRAM_LOCK_ISP: + { + unsigned char lockBits = msgBuffer[4]; + + lockBits = (~lockBits) & 0x3C; // mask BLBxx bits + boot_lock_bits_set(lockBits); // and program it + boot_spm_busy_wait(); + + msgLength = 3; + msgBuffer[1] = STATUS_CMD_OK; + msgBuffer[2] = STATUS_CMD_OK; + } + break; + #endif + case CMD_CHIP_ERASE_ISP: + eraseAddress = 0; + msgLength = 2; + msgBuffer[1] = STATUS_CMD_OK; + break; + + case CMD_LOAD_ADDRESS: + #if defined(RAMPZ) + address = ( ((address_t)(msgBuffer[1])<<24)|((address_t)(msgBuffer[2])<<16)|((address_t)(msgBuffer[3])<<8)|(msgBuffer[4]) )<<1; + #else + address = ( ((msgBuffer[3])<<8)|(msgBuffer[4]) )<<1; //convert word to byte address + #endif + msgLength = 2; + msgBuffer[1] = STATUS_CMD_OK; + break; + + case CMD_PROGRAM_FLASH_ISP: + case CMD_PROGRAM_EEPROM_ISP: + { + unsigned int size = ((msgBuffer[1])<<8) | msgBuffer[2]; + unsigned char *p = msgBuffer+10; + unsigned int data; + unsigned char highByte, lowByte; + address_t tempaddress = address; + + + if ( msgBuffer[0] == CMD_PROGRAM_FLASH_ISP ) + { + // erase only main section (bootloader protection) + if (eraseAddress < APP_END ) + { + boot_page_erase(eraseAddress); // Perform page erase + boot_spm_busy_wait(); // Wait until the memory is erased. + eraseAddress += SPM_PAGESIZE; // point to next page to be erase + } + + /* Write FLASH */ + do { + lowByte = *p++; + highByte = *p++; + + data = (highByte << 8) | lowByte; + boot_page_fill(address,data); + + address = address + 2; // Select next word in memory + size -= 2; // Reduce number of bytes to write by two + } while (size); // Loop until all bytes written + + boot_page_write(tempaddress); + boot_spm_busy_wait(); + boot_rww_enable(); // Re-enable the RWW section + } + else + { + #if (!defined(__AVR_ATmega1280__) && !defined(__AVR_ATmega2560__) && !defined(__AVR_ATmega2561__)) + /* write EEPROM */ + do { + EEARL = address; // Setup EEPROM address + EEARH = (address >> 8); + address++; // Select next EEPROM byte + + EEDR = *p++; // get byte from buffer + EECR |= (1<> 8); //MSB + address += 2; // Select next word in memory + size -= 2; + }while (size); + } + else + { + /* Read EEPROM */ + do { + EEARL = address; // Setup EEPROM address + EEARH = ((address >> 8)); + address++; // Select next EEPROM byte + EECR |= (1<>8)&0xFF); + sendchar(c); + checksum ^= c; + + c = msgLength&0x00FF; + sendchar(c); + checksum ^= c; + + sendchar(TOKEN); + checksum ^= TOKEN; + + p = msgBuffer; + while ( msgLength ) + { + c = *p++; + sendchar(c); + checksum ^=c; + msgLength--; + } + sendchar(checksum); + seqNum++; + + #ifndef REMOVE_BOOTLOADER_LED + //* toggle the LED + PROGLED_PORT ^= (1< + + +base address = f000 +avrdude: Device signature = 0x1e9703 +avrdude: safemode: lfuse reads as FF +avrdude: safemode: hfuse reads as D8 +avrdude: safemode: efuse reads as F5 +avrdude> +*/ + +//************************************************************************ +#ifdef ENABLE_MONITOR +#include + +unsigned long gRamIndex; +unsigned long gFlashIndex; +unsigned long gEepromIndex; + + +#define true 1 +#define false 0 + +#if defined(__AVR_ATmega128__) + #define kCPU_NAME "ATmega128" +#elif defined(__AVR_ATmega1280__) + #define kCPU_NAME "ATmega1280" +#elif defined(__AVR_ATmega1281__) + #define kCPU_NAME "ATmega1281" +#elif defined(__AVR_ATmega2560__) + #define kCPU_NAME "ATmega2560" +#elif defined(__AVR_ATmega2561__) + #define kCPU_NAME "ATmega2561" +#endif + +#ifdef _VECTORS_SIZE + #define kInterruptVectorCount (_VECTORS_SIZE / 4) +#else + #define kInterruptVectorCount 23 +#endif + + +void PrintDecInt(int theNumber, int digitCnt); + +#ifdef kCPU_NAME + prog_char gTextMsg_CPU_Name[] PROGMEM = kCPU_NAME; +#else + prog_char gTextMsg_CPU_Name[] PROGMEM = "UNKNOWN"; +#endif + + prog_char gTextMsg_Explorer[] PROGMEM = "Arduino explorer stk500V2 by MLS"; + prog_char gTextMsg_Prompt[] PROGMEM = "Bootloader>"; + prog_char gTextMsg_HUH[] PROGMEM = "Huh?"; + prog_char gTextMsg_COMPILED_ON[] PROGMEM = "Compiled on = "; + prog_char gTextMsg_CPU_Type[] PROGMEM = "CPU Type = "; + prog_char gTextMsg_AVR_ARCH[] PROGMEM = "__AVR_ARCH__ = "; + prog_char gTextMsg_AVR_LIBC[] PROGMEM = "AVR LibC Ver = "; + prog_char gTextMsg_GCC_VERSION[] PROGMEM = "GCC Version = "; + prog_char gTextMsg_CPU_SIGNATURE[] PROGMEM = "CPU signature= "; + prog_char gTextMsg_FUSE_BYTE_LOW[] PROGMEM = "Low fuse = "; + prog_char gTextMsg_FUSE_BYTE_HIGH[] PROGMEM = "High fuse = "; + prog_char gTextMsg_FUSE_BYTE_EXT[] PROGMEM = "Ext fuse = "; + prog_char gTextMsg_FUSE_BYTE_LOCK[] PROGMEM = "Lock fuse = "; + prog_char gTextMsg_GCC_DATE_STR[] PROGMEM = __DATE__; + prog_char gTextMsg_AVR_LIBC_VER_STR[] PROGMEM = __AVR_LIBC_VERSION_STRING__; + prog_char gTextMsg_GCC_VERSION_STR[] PROGMEM = __VERSION__; + prog_char gTextMsg_VECTOR_HEADER[] PROGMEM = "V# ADDR op code instruction addr Interrupt"; + prog_char gTextMsg_noVector[] PROGMEM = "no vector"; + prog_char gTextMsg_rjmp[] PROGMEM = "rjmp "; + prog_char gTextMsg_jmp[] PROGMEM = "jmp "; + prog_char gTextMsg_WHAT_PORT[] PROGMEM = "What port:"; + prog_char gTextMsg_PortNotSupported[] PROGMEM = "Port not supported"; + prog_char gTextMsg_MustBeLetter[] PROGMEM = "Must be a letter"; + prog_char gTextMsg_SPACE[] PROGMEM = " "; + prog_char gTextMsg_WriteToEEprom[] PROGMEM = "Writting EE"; + prog_char gTextMsg_ReadingEEprom[] PROGMEM = "Reading EE"; + prog_char gTextMsg_EEPROMerrorCnt[] PROGMEM = "eeprom error count="; + prog_char gTextMsg_PORT[] PROGMEM = "PORT"; + + +//************************************************************************ +//* Help messages + prog_char gTextMsg_HELP_MSG_0[] PROGMEM = "0=Zero address ctrs"; + prog_char gTextMsg_HELP_MSG_QM[] PROGMEM = "?=CPU stats"; + prog_char gTextMsg_HELP_MSG_AT[] PROGMEM = "@=EEPROM test"; + prog_char gTextMsg_HELP_MSG_B[] PROGMEM = "B=Blink LED"; + prog_char gTextMsg_HELP_MSG_E[] PROGMEM = "E=Dump EEPROM"; + prog_char gTextMsg_HELP_MSG_F[] PROGMEM = "F=Dump FLASH"; + prog_char gTextMsg_HELP_MSG_H[] PROGMEM = "H=Help"; + prog_char gTextMsg_HELP_MSG_L[] PROGMEM = "L=List I/O Ports"; + prog_char gTextMsg_HELP_MSG_Q[] PROGMEM = "Q=Quit & jump to user pgm"; + prog_char gTextMsg_HELP_MSG_R[] PROGMEM = "R=Dump RAM"; + prog_char gTextMsg_HELP_MSG_V[] PROGMEM = "V=show interrupt Vectors"; + prog_char gTextMsg_HELP_MSG_Y[] PROGMEM = "Y=Port blink"; + + prog_char gTextMsg_END[] PROGMEM = "*"; + + +//************************************************************************ +void PrintFromPROGMEM(void *dataPtr, unsigned char offset) +{ +uint8_t ii; +char theChar; + + ii = offset; + theChar = 1; + + while (theChar != 0) + { + theChar = pgm_read_byte_far((uint32_t)dataPtr + ii); + if (theChar != 0) + { + sendchar(theChar); + } + ii++; + } +} + +//************************************************************************ +void PrintNewLine(void) +{ + sendchar(0x0d); + sendchar(0x0a); +} + + +//************************************************************************ +void PrintFromPROGMEMln(void *dataPtr, unsigned char offset) +{ + PrintFromPROGMEM(dataPtr, offset); + + PrintNewLine(); +} + + +//************************************************************************ +void PrintString(char *textString) +{ +char theChar; +int ii; + + theChar = 1; + ii = 0; + while (theChar != 0) + { + theChar = textString[ii]; + if (theChar != 0) + { + sendchar(theChar); + } + ii++; + } +} + +//************************************************************************ +void PrintHexByte(unsigned char theByte) +{ +char theChar; + + theChar = 0x30 + ((theByte >> 4) & 0x0f); + if (theChar > 0x39) + { + theChar += 7; + } + sendchar(theChar ); + + theChar = 0x30 + (theByte & 0x0f); + if (theChar > 0x39) + { + theChar += 7; + } + sendchar(theChar ); +} + +//************************************************************************ +void PrintDecInt(int theNumber, int digitCnt) +{ +int theChar; +int myNumber; + + myNumber = theNumber; + + if ((myNumber > 100) || (digitCnt >= 3)) + { + theChar = 0x30 + myNumber / 100; + sendchar(theChar ); + } + + if ((myNumber > 10) || (digitCnt >= 2)) + { + theChar = 0x30 + ((myNumber % 100) / 10 ); + sendchar(theChar ); + } + theChar = 0x30 + (myNumber % 10); + sendchar(theChar ); +} + + + + +//************************************************************************ +static void PrintCPUstats(void) +{ +unsigned char fuseByte; + + PrintFromPROGMEMln(gTextMsg_Explorer, 0); + + PrintFromPROGMEM(gTextMsg_COMPILED_ON, 0); + PrintFromPROGMEMln(gTextMsg_GCC_DATE_STR, 0); + + PrintFromPROGMEM(gTextMsg_CPU_Type, 0); + PrintFromPROGMEMln(gTextMsg_CPU_Name, 0); + + PrintFromPROGMEM(gTextMsg_AVR_ARCH, 0); + PrintDecInt(__AVR_ARCH__, 1); + PrintNewLine(); + + PrintFromPROGMEM(gTextMsg_GCC_VERSION, 0); + PrintFromPROGMEMln(gTextMsg_GCC_VERSION_STR, 0); + + //* these can be found in avr/version.h + PrintFromPROGMEM(gTextMsg_AVR_LIBC, 0); + PrintFromPROGMEMln(gTextMsg_AVR_LIBC_VER_STR, 0); + +#if defined(SIGNATURE_0) + PrintFromPROGMEM(gTextMsg_CPU_SIGNATURE, 0); + //* these can be found in avr/iomxxx.h + PrintHexByte(SIGNATURE_0); + PrintHexByte(SIGNATURE_1); + PrintHexByte(SIGNATURE_2); + PrintNewLine(); +#endif + + +#if defined(GET_LOW_FUSE_BITS) + //* fuse settings + PrintFromPROGMEM(gTextMsg_FUSE_BYTE_LOW, 0); + fuseByte = boot_lock_fuse_bits_get(GET_LOW_FUSE_BITS); + PrintHexByte(fuseByte); + PrintNewLine(); + + PrintFromPROGMEM(gTextMsg_FUSE_BYTE_HIGH, 0); + fuseByte = boot_lock_fuse_bits_get(GET_HIGH_FUSE_BITS); + PrintHexByte(fuseByte); + PrintNewLine(); + + PrintFromPROGMEM(gTextMsg_FUSE_BYTE_EXT, 0); + fuseByte = boot_lock_fuse_bits_get(GET_EXTENDED_FUSE_BITS); + PrintHexByte(fuseByte); + PrintNewLine(); + + PrintFromPROGMEM(gTextMsg_FUSE_BYTE_LOCK, 0); + fuseByte = boot_lock_fuse_bits_get(GET_LOCK_BITS); + PrintHexByte(fuseByte); + PrintNewLine(); + +#endif + +} + +#ifndef sbi + #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit)) +#endif + +//************************************************************************ +int analogRead(uint8_t pin) +{ +uint8_t low, high; + + // 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). +// ADMUX = (analog_reference << 6) | (pin & 0x07); + ADMUX = (1 << 6) | (pin & 0x07); + +#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) + // 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 + + // without a delay, we seem to read from the wrong channel + //delay(1); + + // 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; + + // combine the two bytes + return (high << 8) | low; +} + +//************************************************************************ +static void BlinkLED(void) +{ + PROGLED_DDR |= (1< 0) + { + if (myAddressPointer > 0x10000) + { + PrintHexByte((myAddressPointer >> 16) & 0x00ff); + } + PrintHexByte((myAddressPointer >> 8) & 0x00ff); + PrintHexByte(myAddressPointer & 0x00ff); + sendchar(0x20); + sendchar('-'); + sendchar(0x20); + + asciiDump[0] = 0; + for (ii=0; ii<16; ii++) + { + switch(dumpWhat) + { + case kDUMP_FLASH: + theValue = pgm_read_byte_far(myAddressPointer); + break; + + case kDUMP_EEPROM: + theValue = eeprom_read_byte((void *)myAddressPointer); + break; + + case kDUMP_RAM: + theValue = ramPtr[myAddressPointer]; + break; + + } + PrintHexByte(theValue); + sendchar(0x20); + if ((theValue >= 0x20) && (theValue < 0x7f)) + { + asciiDump[ii % 16] = theValue; + } + else + { + asciiDump[ii % 16] = '.'; + } + + myAddressPointer++; + } + asciiDump[16] = 0; + PrintString(asciiDump); + PrintNewLine(); + + numRows--; + } +} + + + +//************************************************************************ +//* returns amount of extended memory +static void EEPROMtest(void) +{ +int ii; +char theChar; +char theEEPROMchar; +int errorCount; + + PrintFromPROGMEMln(gTextMsg_WriteToEEprom, 0); + PrintNewLine(); + ii = 0; + while (((theChar = pgm_read_byte_far(gTextMsg_Explorer + ii)) != '*') && (ii < 512)) + { + eeprom_write_byte((uint8_t *)ii, theChar); + if (theChar == 0) + { + PrintFromPROGMEM(gTextMsg_SPACE, 0); + } + else + { + sendchar(theChar); + } + ii++; + } + + //* no go back through and test + PrintNewLine(); + PrintNewLine(); + PrintFromPROGMEMln(gTextMsg_ReadingEEprom, 0); + PrintNewLine(); + errorCount = 0; + ii = 0; + while (((theChar = pgm_read_byte_far(gTextMsg_Explorer + ii)) != '*') && (ii < 512)) + { + theEEPROMchar = eeprom_read_byte((uint8_t *)ii); + if (theEEPROMchar == 0) + { + PrintFromPROGMEM(gTextMsg_SPACE, 0); + } + else + { + sendchar(theEEPROMchar); + } + if (theEEPROMchar != theChar) + { + errorCount++; + } + ii++; + } + PrintNewLine(); + PrintNewLine(); + PrintFromPROGMEM(gTextMsg_EEPROMerrorCnt, 0); + PrintDecInt(errorCount, 1); + PrintNewLine(); + PrintNewLine(); + + gEepromIndex = 0; //* set index back to zero for next eeprom dump + +} + + + +#if (FLASHEND > 0x08000) + #include "avrinterruptnames.h" + #ifndef _INTERRUPT_NAMES_DEFINED_ + #warning Interrupt vectors not defined + #endif +#endif + +//************************************************************************ +static void VectorDisplay(void) +{ +unsigned long byte1; +unsigned long byte2; +unsigned long byte3; +unsigned long byte4; +unsigned long word1; +unsigned long word2; +int vectorIndex; +unsigned long myMemoryPtr; +unsigned long wordMemoryAddress; +unsigned long realitiveAddr; +unsigned long myFullAddress; +unsigned long absoluteAddr; +#if defined(_INTERRUPT_NAMES_DEFINED_) + long stringPointer; +#endif + + myMemoryPtr = 0; + vectorIndex = 0; + PrintFromPROGMEMln(gTextMsg_CPU_Name, 0); + PrintFromPROGMEMln(gTextMsg_VECTOR_HEADER, 0); + // V# ADDR op code + // 1 - 0000 = C3 BB 00 00 rjmp 03BB >000776 RESET + while (vectorIndex < kInterruptVectorCount) + { + wordMemoryAddress = myMemoryPtr / 2; + // 01 - 0000 = 12 34 + PrintDecInt(vectorIndex + 1, 2); + sendchar(0x20); + sendchar('-'); + sendchar(0x20); + PrintHexByte((wordMemoryAddress >> 8) & 0x00ff); + PrintHexByte((wordMemoryAddress) & 0x00ff); + sendchar(0x20); + sendchar('='); + sendchar(0x20); + + + //* the AVR is LITTLE ENDIAN, swap the byte order + byte1 = pgm_read_byte_far(myMemoryPtr++); + byte2 = pgm_read_byte_far(myMemoryPtr++); + word1 = (byte2 << 8) + byte1; + + byte3 = pgm_read_byte_far(myMemoryPtr++); + byte4 = pgm_read_byte_far(myMemoryPtr++); + word2 = (byte4 << 8) + byte3; + + + PrintHexByte(byte2); + sendchar(0x20); + PrintHexByte(byte1); + sendchar(0x20); + PrintHexByte(byte4); + sendchar(0x20); + PrintHexByte(byte3); + sendchar(0x20); + + if (word1 == 0xffff) + { + PrintFromPROGMEM(gTextMsg_noVector, 0); + } + else if ((word1 & 0xc000) == 0xc000) + { + //* rjmp instruction + realitiveAddr = word1 & 0x3FFF; + absoluteAddr = wordMemoryAddress + realitiveAddr; //* add the offset to the current address + absoluteAddr = absoluteAddr << 1; //* multiply by 2 for byte address + + PrintFromPROGMEM(gTextMsg_rjmp, 0); + PrintHexByte((realitiveAddr >> 8) & 0x00ff); + PrintHexByte((realitiveAddr) & 0x00ff); + sendchar(0x20); + sendchar('>'); + PrintHexByte((absoluteAddr >> 16) & 0x00ff); + PrintHexByte((absoluteAddr >> 8) & 0x00ff); + PrintHexByte((absoluteAddr) & 0x00ff); + + } + else if ((word1 & 0xfE0E) == 0x940c) + { + //* jmp instruction, this is REALLY complicated, refer to the instruction manual (JMP) + myFullAddress = ((byte1 & 0x01) << 16) + + ((byte1 & 0xf0) << 17) + + ((byte2 & 0x01) << 21) + + word2; + + absoluteAddr = myFullAddress << 1; + + PrintFromPROGMEM(gTextMsg_jmp, 0); + PrintHexByte((myFullAddress >> 16) & 0x00ff); + PrintHexByte((myFullAddress >> 8) & 0x00ff); + PrintHexByte((myFullAddress) & 0x00ff); + sendchar(0x20); + sendchar('>'); + PrintHexByte((absoluteAddr >> 16) & 0x00ff); + PrintHexByte((absoluteAddr >> 8) & 0x00ff); + PrintHexByte((absoluteAddr) & 0x00ff); + } + + #if defined(_INTERRUPT_NAMES_DEFINED_) + sendchar(0x20); + stringPointer = pgm_read_word_far(&(gInterruptNameTable[vectorIndex])); + PrintFromPROGMEM((char *)stringPointer, 0); + #endif + PrintNewLine(); + + vectorIndex++; + } +} + +//************************************************************************ +static void PrintAvailablePort(char thePortLetter) +{ + PrintFromPROGMEM(gTextMsg_PORT, 0); + sendchar(thePortLetter); + PrintNewLine(); +} + +//************************************************************************ +static void ListAvailablePorts(void) +{ + +#ifdef DDRA + PrintAvailablePort('A'); +#endif + +#ifdef DDRB + PrintAvailablePort('B'); +#endif + +#ifdef DDRC + PrintAvailablePort('C'); +#endif + +#ifdef DDRD + PrintAvailablePort('D'); +#endif + +#ifdef DDRE + PrintAvailablePort('E'); +#endif + +#ifdef DDRF + PrintAvailablePort('F'); +#endif + +#ifdef DDRG + PrintAvailablePort('G'); +#endif + +#ifdef DDRH + PrintAvailablePort('H'); +#endif + +#ifdef DDRI + PrintAvailablePort('I'); +#endif + +#ifdef DDRJ + PrintAvailablePort('J'); +#endif + +#ifdef DDRK + PrintAvailablePort('K'); +#endif + +#ifdef DDRL + PrintAvailablePort('L'); +#endif + +} + +//************************************************************************ +static void AVR_PortOutput(void) +{ +char portLetter; +char getCharFlag; + + PrintFromPROGMEM(gTextMsg_WHAT_PORT, 0); + + portLetter = recchar(); + portLetter = portLetter & 0x5f; + sendchar(portLetter); + PrintNewLine(); + + if ((portLetter >= 'A') && (portLetter <= 'Z')) + { + getCharFlag = true; + switch(portLetter) + { + #ifdef DDRA + case 'A': + DDRA = 0xff; + while (!Serial_Available()) + { + PORTA ^= 0xff; + delay_ms(200); + } + PORTA = 0; + break; + #endif + + #ifdef DDRB + case 'B': + DDRB = 0xff; + while (!Serial_Available()) + { + PORTB ^= 0xff; + delay_ms(200); + } + PORTB = 0; + break; + #endif + + #ifdef DDRC + case 'C': + DDRC = 0xff; + while (!Serial_Available()) + { + PORTC ^= 0xff; + delay_ms(200); + } + PORTC = 0; + break; + #endif + + #ifdef DDRD + case 'D': + DDRD = 0xff; + while (!Serial_Available()) + { + PORTD ^= 0xff; + delay_ms(200); + } + PORTD = 0; + break; + #endif + + #ifdef DDRE + case 'E': + DDRE = 0xff; + while (!Serial_Available()) + { + PORTE ^= 0xff; + delay_ms(200); + } + PORTE = 0; + break; + #endif + + #ifdef DDRF + case 'F': + DDRF = 0xff; + while (!Serial_Available()) + { + PORTF ^= 0xff; + delay_ms(200); + } + PORTF = 0; + break; + #endif + + #ifdef DDRG + case 'G': + DDRG = 0xff; + while (!Serial_Available()) + { + PORTG ^= 0xff; + delay_ms(200); + } + PORTG = 0; + break; + #endif + + #ifdef DDRH + case 'H': + DDRH = 0xff; + while (!Serial_Available()) + { + PORTH ^= 0xff; + delay_ms(200); + } + PORTH = 0; + break; + #endif + + #ifdef DDRI + case 'I': + DDRI = 0xff; + while (!Serial_Available()) + { + PORTI ^= 0xff; + delay_ms(200); + } + PORTI = 0; + break; + #endif + + #ifdef DDRJ + case 'J': + DDRJ = 0xff; + while (!Serial_Available()) + { + PORTJ ^= 0xff; + delay_ms(200); + } + PORTJ = 0; + break; + #endif + + #ifdef DDRK + case 'K': + DDRK = 0xff; + while (!Serial_Available()) + { + PORTK ^= 0xff; + delay_ms(200); + } + PORTK = 0; + break; + #endif + + #ifdef DDRL + case 'L': + DDRL = 0xff; + while (!Serial_Available()) + { + PORTL ^= 0xff; + delay_ms(200); + } + PORTL = 0; + break; + #endif + + default: + PrintFromPROGMEMln(gTextMsg_PortNotSupported, 0); + getCharFlag = false; + break; + } + if (getCharFlag) + { + recchar(); + } + } + else + { + PrintFromPROGMEMln(gTextMsg_MustBeLetter, 0); + } +} + + +//******************************************************************* +static void PrintHelp(void) +{ + PrintFromPROGMEMln(gTextMsg_HELP_MSG_0, 0); + PrintFromPROGMEMln(gTextMsg_HELP_MSG_QM, 0); + PrintFromPROGMEMln(gTextMsg_HELP_MSG_AT, 0); + PrintFromPROGMEMln(gTextMsg_HELP_MSG_B, 0); + PrintFromPROGMEMln(gTextMsg_HELP_MSG_E, 0); + PrintFromPROGMEMln(gTextMsg_HELP_MSG_F, 0); + PrintFromPROGMEMln(gTextMsg_HELP_MSG_H, 0); + + PrintFromPROGMEMln(gTextMsg_HELP_MSG_L, 0); + PrintFromPROGMEMln(gTextMsg_HELP_MSG_Q, 0); + PrintFromPROGMEMln(gTextMsg_HELP_MSG_R, 0); + PrintFromPROGMEMln(gTextMsg_HELP_MSG_V, 0); + PrintFromPROGMEMln(gTextMsg_HELP_MSG_Y, 0); +} + +//************************************************************************ +static void RunMonitor(void) +{ +char keepGoing; +unsigned char theChar; +int ii, jj; + + for (ii=0; ii<5; ii++) + { + for (jj=0; jj<25; jj++) + { + sendchar('!'); + } + PrintNewLine(); + } + + gRamIndex = 0; + gFlashIndex = 0; + gEepromIndex = 0; + + PrintFromPROGMEMln(gTextMsg_Explorer, 0); + + keepGoing = 1; + while (keepGoing) + { + PrintFromPROGMEM(gTextMsg_Prompt, 0); + theChar = recchar(); + if (theChar >= 0x60) + { + theChar = theChar & 0x5F; + } + #if defined( _CEREBOTPLUS_BOARD_ ) + if (theChar == 0x5F) + { + + } + else + #endif + if (theChar >= 0x20) + { + sendchar(theChar); + sendchar(0x20); + } + + switch(theChar) + { + case '0': + PrintFromPROGMEMln(gTextMsg_HELP_MSG_0, 2); + gFlashIndex = 0; + gRamIndex = 0; + gEepromIndex = 0; + break; + + case '?': + PrintFromPROGMEMln(gTextMsg_HELP_MSG_QM, 2); + PrintCPUstats(); + break; + + case '@': + PrintFromPROGMEMln(gTextMsg_HELP_MSG_AT, 2); + EEPROMtest(); + break; + + case 'B': + PrintFromPROGMEMln(gTextMsg_HELP_MSG_B, 2); + BlinkLED(); + break; + + case 'E': + PrintFromPROGMEMln(gTextMsg_HELP_MSG_E, 2); + DumpHex(kDUMP_EEPROM, gEepromIndex, 16); + gEepromIndex += 256; + if (gEepromIndex > E2END) + { + gEepromIndex = 0; + } + break; + + case 'F': + PrintFromPROGMEMln(gTextMsg_HELP_MSG_F, 2); + DumpHex(kDUMP_FLASH, gFlashIndex, 16); + gFlashIndex += 256; + break; + + case 'H': + PrintFromPROGMEMln(gTextMsg_HELP_MSG_H, 2); + PrintHelp(); + break; + + case 'L': + PrintFromPROGMEMln(gTextMsg_HELP_MSG_L, 2); + ListAvailablePorts(); + break; + + case 'Q': + PrintFromPROGMEMln(gTextMsg_HELP_MSG_Q, 2); + keepGoing = false; + break; + + case 'R': + PrintFromPROGMEMln(gTextMsg_HELP_MSG_R, 2); + DumpHex(kDUMP_RAM, gRamIndex, 16); + gRamIndex += 256; + break; + + case 'V': + PrintFromPROGMEMln(gTextMsg_HELP_MSG_V, 2); + VectorDisplay(); + break; + + case 'Y': + PrintFromPROGMEMln(gTextMsg_HELP_MSG_Y, 2); + AVR_PortOutput(); + break; + + #if defined( _CEREBOTPLUS_BOARD_ ) + case 0x5F: + //* do nothing + break; + #endif + + default: + PrintFromPROGMEMln(gTextMsg_HUH, 0); + break; + } + } +} + +#endif + diff --git a/arduino-0022-linux-x64/hardware/arduino/bootloaders/stk500v2/stk500boot.ppg b/arduino-0022-linux-x64/hardware/arduino/bootloaders/stk500v2/stk500boot.ppg new file mode 100644 index 0000000..a8929d7 --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/bootloaders/stk500v2/stk500boot.ppg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/arduino-0022-linux-x64/hardware/arduino/bootloaders/stk500v2/stk500boot_v2_mega2560.hex b/arduino-0022-linux-x64/hardware/arduino/bootloaders/stk500v2/stk500boot_v2_mega2560.hex new file mode 100644 index 0000000..4f36699 --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/bootloaders/stk500v2/stk500boot_v2_mega2560.hex @@ -0,0 +1,513 @@ +:020000023000CC +:10E000000D94F6F20D941FF30D941FF30D941FF36E +:10E010000D941FF30D941FF30D941FF30D941FF334 +:10E020000D941FF30D941FF30D941FF30D941FF324 +:10E030000D941FF30D941FF30D941FF30D941FF314 +:10E040000D941FF30D941FF30D941FF30D941FF304 +:10E050000D941FF30D941FF30D941FF30D941FF3F4 +:10E060000D941FF30D941FF30D941FF30D941FF3E4 +:10E070000D941FF30D941FF30D941FF30D941FF3D4 +:10E080000D941FF30D941FF30D941FF30D941FF3C4 +:10E090000D941FF30D941FF30D941FF30D941FF3B4 +:10E0A0000D941FF30D941FF30D941FF30D941FF3A4 +:10E0B0000D941FF30D941FF30D941FF30D941FF394 +:10E0C0000D941FF30D941FF30D941FF30D941FF384 +:10E0D0000D941FF30D941FF30D941FF30D941FF374 +:10E0E0000D941FF341546D65676132353630004140 +:10E0F000726475696E6F206578706C6F72657220DE +:10E1000073746B3530305632206279204D4C530099 +:10E11000426F6F746C6F616465723E004875683F52 +:10E1200000436F6D70696C6564206F6E20203D2028 +:10E1300000435055205479706520202020203D2038 +:10E14000005F5F4156525F415243485F5F203D2070 +:10E1500000415652204C69624320566572203D2092 +:10E16000004743432056657273696F6E20203D203F +:10E1700000435055207369676E61747572653D2068 +:10E18000004C6F77206675736520202020203D208D +:10E1900000486967682066757365202020203D204F +:10E1A00000457874206675736520202020203D206E +:10E1B000004C6F636B2066757365202020203D2026 +:10E1C00000536570202039203230313000312E3636 +:10E1D0002E3700342E332E33005623202020414486 +:10E1E00044522020206F7020636F6465202020201F +:10E1F00020696E737472756374696F6E20616464F4 +:10E2000072202020496E74657272757074006E6F92 +:10E2100020766563746F7200726A6D702020006AE8 +:10E220006D7020005768617420706F72743A0050EE +:10E230006F7274206E6F7420737570706F72746576 +:10E2400064004D7573742062652061206C65747480 +:10E2500065720020005772697474696E67204545C5 +:10E260000052656164696E6720454500656570729E +:10E270006F6D206572726F7220636F756E743D00F2 +:10E28000504F525400303D5A65726F206164647281 +:10E290006573732063747273003F3D435055207360 +:10E2A0007461747300403D454550524F4D20746574 +:10E2B000737400423D426C696E6B204C45440045CE +:10E2C0003D44756D7020454550524F4D00463D44CC +:10E2D000756D7020464C41534800483D48656C7050 +:10E2E000004C3D4C69737420492F4F20506F72745D +:10E2F0007300513D517569742026206A756D702038 +:10E30000746F20757365722070676D00523D44759F +:10E310006D702052414D00563D73686F7720696ED5 +:10E320007465727275707420566563746F727300D1 +:10E33000593D506F727420626C696E6B002A0052F6 +:10E340004553455400494E543000494E543100491C +:10E350004E543200494E543300494E543400494E15 +:10E36000543500494E543600494E54370050434905 +:10E370004E5430005043494E5431005043494E549E +:10E3800032005744540054494D45523020434F4DBC +:10E3900050410054494D45523020434F4D504200AA +:10E3A00054494D455230204F56460054494D455230 +:10E3B0003120434150540054494D45523120434F80 +:10E3C0004D50410054494D45523120434F4D50422C +:10E3D0000054494D45523120434F4D50430054495C +:10E3E0004D455231204F56460054494D455232203A +:10E3F000434F4D50410054494D45523220434F4DFB +:10E4000050420054494D455232204F56460054491F +:10E410004D45523320434150540054494D455233E9 +:10E4200020434F4D50410054494D45523320434FF6 +:10E430004D50420054494D45523320434F4D5043B7 +:10E440000054494D455233204F56460054494D45DE +:10E45000523420434150540054494D4552342043D6 +:10E460004F4D50410054494D45523420434F4D507B +:10E47000420054494D45523420434F4D50430054BF +:10E48000494D455234204F56460054494D4552356A +:10E4900020434150540054494D45523520434F4D7F +:10E4A00050410054494D45523520434F4D50420094 +:10E4B00054494D45523520434F4D50430054494D2A +:10E4C000455235204F564600555341525430205244 +:10E4D000580055534152543020554452450055532D +:10E4E0004152543020545800555341525431205217 +:10E4F000580055534152543120554452450055530C +:10E5000041525431205458005553415254322052F4 +:10E5100058005553415254322055445245005553EA +:10E5200041525432205458005553415254332052D2 +:10E5300058005553415254332055445245005553C9 +:10E5400041525433205458005350492053544300EF +:10E5500041444300414E414C4F4720434F4D5000F2 +:10E560004545205245414459005457490053504DA8 +:10E57000205245414459002A003FE345E34AE34F16 +:10E58000E354E359E35EE363E368E36DE374E37B41 +:10E59000E382E3E9E3F6E303E4ABE3B7E3C4E3D107 +:10E5A000E3DEE386E393E3A0E348E5C8E4D2E4DEF8 +:10E5B000E454E550E560E50EE41AE427E434E44170 +:10E5C000E4E8E4F2E4FEE469E56DE54CE458E46572 +:10E5D000E472E47FE48AE496E4A3E4B0E4BDE408F2 +:10E5E000E512E51EE528E532E53EE50011241FBEF3 +:10E5F000CFEFD1E2DEBFCDBF01E00CBF12E0A0E063 +:10E60000B2E0EAEDFFEF03E00BBF02C007900D920E +:10E61000A030B107D9F712E0A0E0B2E001C01D922E +:10E62000AC30B107E1F70F94FBF40D94EBFF01E27E +:10E630000EBF0FEF0DBF11241FBE0D94FBF40D9400 +:10E6400000F020E030E040ED57E005C0FA013197DE +:10E65000F1F72F5F3F4F28173907C0F308959C014A +:10E66000442737FD4095542FDA01C901860F911DCB +:10E67000A11DB11DABBFFC018791882369F0809378 +:10E68000C6008091C00086FFFCCF8091C0008064EE +:10E690008093C0006F5FE8CF08958DE08093C6003F +:10E6A0008091C00086FFFCCF8091C0008064809381 +:10E6B000C0008AE08093C6008091C00086FFFCCF36 +:10E6C0008091C00080648093C00008950F942FF360 +:10E6D0000F944DF30895FC019081992359F0909384 +:10E6E000C6008091C00086FFFCCF8091C00080648E +:10E6F0008093C0003196992379F70895282F982F99 +:10E7000092959F70892F805D8A3308F0895F80938E +:10E71000C6008091C00086FFFCCF8091C00080645D +:10E720008093C000822F8F70982F905D9A3308F0ED +:10E73000995F9093C6008091C00086FFFCCF8091C6 +:10E74000C00080648093C00008959C01FB01853661 +:10E7500091051CF46330710594F0C90164E670E022 +:10E760000F948CFF605D7F4F6093C6008091C00066 +:10E7700086FFFCCF8091C00080648093C0002B3066 +:10E78000310514F43297B4F0C90164E670E00F94D7 +:10E790008CFF6AE070E00F948CFF605D7F4F6093A8 +:10E7A000C6008091C00086FFFCCF8091C0008064CD +:10E7B0008093C000C9016AE070E00F948CFFC0969E +:10E7C0008093C6008091C00086FFFCCF8091C0007E +:10E7D00080648093C0000895282F277020642093C0 +:10E7E0007C0020917B0086958695869590E08170CF +:10E7F000907033E0880F991F3A95E1F7277F282B17 +:10E8000020937B0080917A00806480937A008091CD +:10E810007A0086FDFCCF2091780040917900942FFA +:10E8200080E030E0282B392BC90108951F93182F61 +:10E8300080E892EE60E00F942FF31093C600809171 +:10E84000C00086FFFCCF8091C00080648093C00030 +:10E850000F944DF31F9108952F923F924F925F9224 +:10E860006F927F928F929F92AF92BF92CF92DF92E0 +:10E87000EF92FF920F931F93DF93CF93CDB7DEB745 +:10E8800062970FB6F894DEBF0FBECDBF382E622E52 +:10E89000CA01DB015C016D01772460E2262E2E01A6 +:10E8A0000894411C511C8BC081E0A81680E0B8067A +:10E8B00081E0C80680E0D80628F0C601AA27BB2759 +:10E8C0000F947EF3BB27AD2D9C2D8B2D0F947EF3E3 +:10E8D0008A2D0F947EF32092C6008091C00086FF9F +:10E8E000FCCF8091C00080648093C0009DE2909333 +:10E8F000C6008091C00086FFFCCF8091C00080647C +:10E900008093C0002092C6008091C00086FFFCCF9B +:10E910008091C00080648093C000198286017501D7 +:10E9200088249924A1E03A1651F03A1620F0B2E07A +:10E930003B1661F409C00BBFF701779007C0C70110 +:10E940000F94D5FF782E02C0F7017080872D0F94A9 +:10E950007EF32092C6008091C00086FFFCCF80919C +:10E96000C00080648093C000872D8052F401EF7056 +:10E97000F0708F3520F4E40DF51D708204C0E40DB5 +:10E98000F51D8EE280830894E11CF11C011D111D10 +:10E990000894811C911C90E18916910409F0C2CF62 +:10E9A00080E190E0A0E0B0E0A80EB91ECA1EDB1E18 +:10E9B000198AC2010F946BF30F944DF36A94662089 +:10E9C00009F072CF62960FB6F894DEBF0FBECDBFCE +:10E9D000CF91DF911F910F91FF90EF90DF90CF903B +:10E9E000BF90AF909F908F907F906F905F904F906F +:10E9F0003F902F9008952F923F924F925F926F9287 +:10EA00007F928F929F92AF92BF92CF92DF92EF92BE +:10EA1000FF920F931F93DF93CF93CDB7DEB7CD5304 +:10EA2000D1400FB6F894DEBF0FBECDBF279A2F9A04 +:10EA30008091C00082608093C00080E18093C40018 +:10EA400088E18093C1000000EE24FF248701B4E038 +:10EA5000AB2EB12CCC24DD2424C0C5010197F1F7E5 +:10EA60000894E11CF11C011D111D21E2E2162EE4A7 +:10EA7000F20620E0020720E0120718F0A1E0CA2EFB +:10EA8000D12CC801B70128E53BE140E050E00F94EC +:10EA90009FFF611571058105910519F485B18058B5 +:10EAA00085B98091C00087FD03C0C114D104A9F2CB +:10EAB000A6014F5F5F4FC25EDE4F59834883CE5140 +:10EAC000D140C25EDE4F68817981CE51D140613044 +:10EAD000710511F00D946EFFC05DDE4F1982188232 +:10EAE000C053D14060E0C15DDE4F1882CF52D140AB +:10EAF000AA24BB24C05EDE4F188219821A821B82B0 +:10EB0000C052D140CE5CDE4F188219821A821B821D +:10EB1000C253D14080E090E0A0E0B0E0ABBFFC0188 +:10EB2000A791B691C45CDE4FB983A883CC53D14082 +:10EB30000D9469FFC25EDE4FE881F981CE51D1406C +:10EB4000319709F52091C600C25EDE4F1982188206 +:10EB5000CE51D14022C02F5F3F4F4F4F5F4F2130EA +:10EB6000F2E13F07FAE74F07F0E05F0780F0C45C8F +:10EB7000DE4F08811981CC53D1400F5F1F4F19F030 +:10EB8000EE27FF27099420E030E040E050E080913C +:10EB9000C00087FFE0CF2091C600213209F094C663 +:10EBA0000894A11CB11C33E0A316B10409F08EC671 +:10EBB00000E010E018C041E24093C6008091C00020 +:10EBC00086FFFCCF8091C00080648093C0002F5FDF +:10EBD0003F4F2931310579F70F944DF30F5F1F4FE8 +:10EBE0000530110519F020E030E0E5CF1092080261 +:10EBF0001092090210920A0210920B021092040263 +:10EC00001092050210920602109207021092000262 +:10EC10001092010210920202109203028FEE90EE07 +:10EC200060E00F9466F380E191EE60E00F942FF3C3 +:10EC30008091C00087FFFCCF9091C600903608F00D +:10EC40009F759032B8F09093C6008091C00086FF07 +:10EC5000FCCF8091C00080648093C00080E28093EC +:10EC6000C6008091C00086FFFCCF8091C000806408 +:10EC70008093C000983409F4DBC19934B8F492341D +:10EC800009F45DC1933458F4903319F1903308F4CA +:10EC900018C69F33A1F1903409F013C6BDC0953456 +:10ECA00009F474C1963409F00CC69CC1923509F47C +:10ECB0002FC2933538F49C3409F4F9C1913509F029 +:10ECC00000C61CC2963509F449C2993509F0F9C548 +:10ECD0009CC485E892EE62E00F9466F31092040201 +:10ECE000109205021092060210920702109208027A +:10ECF0001092090210920A0210920B0217C189E9C0 +:10ED000092EE62E00F9466F38FEE90EE60E00F9467 +:10ED100066F381E291EE60E00F942FF381EC91EEC7 +:10ED200060E00F9466F381E391EE60E00F942FF3BF +:10ED300084EE90EE60E00F9466F381E491EE60E083 +:10ED40000F942FF386E090E061E070E00F94A5F35C +:10ED50000F944DF381E691EE60E00F942FF383ED75 +:10ED600091EE60E00F9466F381E591EE60E00F9420 +:10ED70002FF38DEC91EE60E00F9466F381E791EE56 +:10ED800060E00F942FF38EE10F947EF388E90F94E7 +:10ED90007EF381E00F947EF30F944DF381E891EEC2 +:10EDA00060E00F942FF319E0E0E0F0E010935700DB +:10EDB000E4918E2F0F947EF30F944DF381E991EE41 +:10EDC00060E00F942FF3E3E0F0E010935700E4913C +:10EDD0008E2F0F947EF30F944DF381EA91EE60E055 +:10EDE0000F942FF3E2E0F0E010935700E4918E2FA0 +:10EDF0000F947EF30F944DF381EB91EE60E00F944E +:10EE00002FF3E1E0F0E0109357001491812F0F945D +:10EE10007EF30F944DF307CF85EA92EE62E00F94F4 +:10EE200066F385E592EE60E00F9466F30F944DF380 +:10EE300000E010E019C0C8016F2D0F94DDFFFF2026 +:10EE400031F483E592EE60E00F942FF30BC0F09263 +:10EE5000C6008091C00086FFFCCF8091C000806416 +:10EE60008093C0000F5F1F4FC80181519F41AA27A7 +:10EE700097FDA095BA2FABBFFC01F7905AE2F516AB +:10EE800021F062E000301607B1F60F944DF30F94B5 +:10EE90004DF381E692EE60E00F9466F30F944DF32C +:10EEA000CC24DD2400E010E01EC0C8010F94D5FF83 +:10EEB000F82E882331F483E592EE60E00F942FF36F +:10EEC0000BC08093C6008091C00086FFFCCF80916C +:10EED000C00080648093C000FE1419F00894C11C27 +:10EEE000D11C0F5F1F4FC80181519F41AA2797FD79 +:10EEF000A095BA2FABBFFC01E7907AE2E71621F0AC +:10EF000082E00030180789F60F944DF30F944DF30B +:10EF10008CE692EE60E00F942FF3C60161E070E0A2 +:10EF20000F94A5F30F944DF30F944DF3109200023C +:10EF300010920102109202021092030274CE83EB2F +:10EF400092EE62E00F9466F3279A2F9A16C02F98DC +:10EF500080E090E0E0EDF7E03197F1F7019684363C +:10EF60009105C1F72F9A80E090E0E0EDF7E031974E +:10EF7000F1F7019684369105C1F78091C00087FFB3 +:10EF8000E6CF8091C00087FFFCCF95C48FEB92EE57 +:10EF900062E00F9466F3409100025091010260918B +:10EFA00002027091030281E020E10F942CF4809121 +:10EFB000000290910102A0910202B09103028050E0 +:10EFC0009F4FAF4FBF4F8093000290930102A093D9 +:10EFD0000202B093030280509041A040B04008F478 +:10EFE00022CEA4CF8DEC92EE62E00F9466F34091B6 +:10EFF000040250910502609106027091070280E0C0 +:10F0000020E10F942CF48091040290910502A091CC +:10F010000602B091070280509F4FAF4FBF4F8093C1 +:10F02000040290930502A0930602B0930702FBCD61 +:10F030008AED92EE62E00F9466F385E892EE60E06E +:10F040000F9466F389E992EE60E00F9466F385EA27 +:10F0500092EE60E00F9466F383EB92EE60E00F9423 +:10F0600066F38FEB92EE60E00F9466F38DEC92EE18 +:10F0700060E00F9466F38AED92EE60E00F9466F321 +:10F0800081EE92EE60E00F9466F382EF92EE60E024 +:10F090000F9466F38CE093EE60E00F9466F387E1E3 +:10F0A00093EE60E00F9466F380E393EEB9CD81EECA +:10F0B00092EE62E00F9466F381E40F9416F482E41A +:10F0C0000F9416F483E40F9416F484E40F9416F46A +:10F0D00085E40F9416F486E40F9416F487E40F94F5 +:10F0E00016F488E40F9416F48AE40F9416F48BE473 +:10F0F0000F9416F48CE40F9416F495CD82EF92EEF3 +:10F1000062E00F9466F399249394AA24BB2445C427 +:10F110008CE093EE62E00F9466F340910802509108 +:10F12000090260910A0270910B0282E020E10F94C3 +:10F130002CF48091080290910902A0910A02B091EA +:10F140000B0280509F4FAF4FBF4F809308029093A8 +:10F150000902A0930A02B0930B0265CD87E193EEFA +:10F1600062E00F9466F384EE90EE60E00F9466F335 +:10F1700089ED91EE60E00F9466F309E715EECC5D42 +:10F18000DE4F19830883C452D1406624772443019B +:10F19000CA5DDE4F19821882C652D140A401930184 +:10F1A0005695479537952795C85DDE4F2883398357 +:10F1B0004A835B83C852D140CA5DDE4F4881598182 +:10F1C000C652D1404F5F5F4FCA5DDE4F59834883BF +:10F1D000C652D140CA0162E070E00F94A5F350E23C +:10F1E0005093C6008091C00086FFFCCF8091C00084 +:10F1F00080648093C0006DE26093C6008091C0007F +:10F2000086FFFCCF8091C00080648093C00070E2D4 +:10F210007093C6008091C00086FFFCCF8091C00033 +:10F2200080648093C000C85DDE4FE880F9800A8169 +:10F230001B81C852D140BB27A12F902F8F2D0F9437 +:10F240007EF3C85DDE4F8881C852D1400F947EF3B3 +:10F2500070E2F72EF092C6008091C00086FFFCCFCE +:10F260008091C00080648093C0000DE30093C600CD +:10F270008091C00086FFFCCF8091C00080648093A5 +:10F28000C00010E21093C6008091C00086FFFCCF42 +:10F290008091C00080648093C0008BBEF3012791F1 +:10F2A000C45DDE4F2883CC52D140A22EBB24CC2497 +:10F2B000DD240894611C711C811C911C8BBEF30120 +:10F2C0008791282E332444245524142D032DF22C09 +:10F2D000EE24EA0CFB1C0C1D1D1D0894611C711C06 +:10F2E000811C911C8BBEF3013791C35DDE4F3883C7 +:10F2F000CD52D1400894611C711C811C911C8BBEA5 +:10F30000F3014791C25DDE4F4883CE52D1402DEFCD +:10F310003FEF4FEF5FEF620E731E841E951E0F943A +:10F320007EF330E23093C6008091C00086FFFCCFB0 +:10F330008091C00080648093C000C45DDE4F8881EE +:10F34000CC52D1400F947EF340E24093C6008091AE +:10F35000C00086FFFCCF8091C00080648093C00015 +:10F36000C25DDE4F8881CE52D1400F947EF350E2D1 +:10F370005093C6008091C00086FFFCCF8091C000F2 +:10F3800080648093C000C35DDE4F8881CD52D14040 +:10F390000F947EF360E26093C6008091C00086FF08 +:10F3A000FCCF8091C00080648093C0007FEFE7169F +:10F3B0007FEFF70670E0070770E0170731F48EE083 +:10F3C00092EE60E00F942FF3DFC0D801C701807088 +:10F3D000907CA070B0708050904CA040B040D1F5AF +:10F3E0002FEF3FE340E050E0E222F3220423152315 +:10F3F000C85DDE4FA880B980CA80DB80C852D1408A +:10F40000AE0CBF1CC01ED11EAA0CBB1CCC1CDD1C2C +:10F4100088E192EE60E00F942FF3BB27A12F902F8D +:10F420008F2D0F947EF38E2D0F947EF330E2309368 +:10F43000C6008091C00086FFFCCF8091C000806430 +:10F440008093C0004EE34093C6008091C00086FFC9 +:10F45000FCCF87C06EE07EEF80E090E0E622F722EE +:10F46000082319237CE0E71674E9F70670E0070724 +:10F4700070E0170709F088C0C25DDE4F8881CE5268 +:10F48000D140E82EFF2400E010E0102F0F2DFE2CBD +:10F49000EE24C35DDE4F9881CD52D140E90EF11CC0 +:10F4A000011D111DD601C50181709070A070B07052 +:10F4B000DC0199278827E80EF91E0A1F1B1F20EF81 +:10F4C00030E040E050E0A222B322C422D522F1E194 +:10F4D000AA0CBB1CCC1CDD1CFA95D1F7EA0CFB1C5A +:10F4E0000C1D1D1D41E050E060E070E0242235223B +:10F4F00046225722E5E1220C331C441C551CEA9598 +:10F50000D1F7E20CF31C041D151D57016801AA0C6C +:10F51000BB1CCC1CDD1C8FE192EE60E00F942FF33E +:10F52000C801AA27BB270F947EF3BB27A12F902FDA +:10F530008F2D0F947EF38E2D0F947EF350E2509317 +:10F54000C6008091C00086FFFCCF8091C00080641F +:10F550008093C0006EE36093C6008091C00086FF78 +:10F56000FCCF8091C00080648093C000C601AA27B0 +:10F57000BB270F947EF3BB27AD2D9C2D8B2D0F94B5 +:10F580007EF38A2D0F947EF370E27093C600809113 +:10F59000C00086FFFCCF8091C00080648093C000D3 +:10F5A000CC5DDE4FE881F981C452D140CF01AA275A +:10F5B00097FDA095BA2FABBFFC018791969160E0B3 +:10F5C0000F942FF30F944DF3CC5DDE4F088119811A +:10F5D000C452D1400E5F1F4FCC5DDE4F19830883AC +:10F5E000C452D140CA5DDE4F28813981C652D14014 +:10F5F0002933310509F417CB44E050E060E070E0B6 +:10F60000640E751E861E971EC9CD80E393EE62E0E0 +:10F610000F9466F384E292EE60E00F942FF38091F2 +:10F62000C00087FFFCCF1091C6001F751093C60065 +:10F630008091C00086FFFCCF8091C00080648093E1 +:10F64000C0000F944DF3812F81548A3108F036C1E8 +:10F65000163409F495C0173490F4133409F44EC0ED +:10F66000143430F41134F1F0123409F01DC130C0FB +:10F67000143409F459C0153409F016C16BC01A349A +:10F6800009F4C4C01B3438F4173409F48FC018349B +:10F6900009F00AC1A1C01B3409F4D2C01C3409F01E +:10F6A00003C1E8C08FEF81B90DC082B1809582B9E6 +:10F6B00080E090E0E0EDF7E03197F1F70196883CCB +:10F6C0009105C1F78091C00087FFEFCF12B8EFC05E +:10F6D0008FEF84B90DC085B1809585B980E090E049 +:10F6E000E0EDF7E03197F1F70196883C9105C1F71D +:10F6F0008091C00087FFEFCF15B8D9C08FEF87B9D1 +:10F700000DC088B1809588B980E090E0E0EDF7E029 +:10F710003197F1F70196883C9105C1F78091C000BF +:10F7200087FFEFCF18B8C3C08FEF8AB90DC08BB178 +:10F7300080958BB980E090E0E0EDF7E03197F1F74C +:10F740000196883C9105C1F78091C00087FFEFCFFB +:10F750001BB8ADC08FEF8DB90DC08EB180958EB93D +:10F7600080E090E0E0EDF7E03197F1F70196883C1A +:10F770009105C1F78091C00087FFEFCF1EB897C0F9 +:10F780008FEF80BB0DC081B3809581BB80E090E09E +:10F79000E0EDF7E03197F1F70196883C9105C1F76C +:10F7A0008091C00087FFEFCF11BA81C08FEF83BB7C +:10F7B0000DC084B3809584BB80E090E0E0EDF7E07D +:10F7C0003197F1F70196883C9105C1F78091C0000F +:10F7D00087FFEFCF14BA6BC08FEF809301010FC08A +:10F7E0008091020180958093020180E090E0E0ED3D +:10F7F000F7E03197F1F70196883C9105C1F78091C8 +:10F80000C00087FFEDCF1092020151C08FEF8093AF +:10F8100004010FC08091050180958093050180E06F +:10F8200090E0E0EDF7E03197F1F70196883C910523 +:10F83000C1F78091C00087FFEDCF1092050137C05E +:10F840008FEF809307010FC080910801809580930E +:10F85000080180E090E0E0EDF7E03197F1F70196E4 +:10F86000883C9105C1F78091C00087FFEDCF1092D1 +:10F8700008011DC08FEF80930A010FC080910B011A +:10F88000809580930B0180E090E0E0EDF7E0319708 +:10F89000F1F70196883C9105C1F78091C00087FF80 +:10F8A000EDCF10920B0103C08FE292EEB9C98091A7 +:10F8B000C00087FFFCCF8091C600B5C982E492EEFC +:10F8C000AFC98CE191EEACC9AA24BB24933061F19D +:10F8D000943028F4913089F0923008F508C09530C2 +:10F8E000B1F1953040F1963009F053C04EC02B3144 +:10F8F00009F020C991E06BE11DC9213041F0C15DE3 +:10F90000DE4F5881CF52D140251709F002C362273C +:10F91000C15DDE4F2883CF52D14092E00BC9B22F98 +:10F92000A0E0622793E006C9822F90E0A82BB92BB4 +:10F93000622794E0FFC82E3009F0EBC2622795E001 +:10F94000C05DDE4F19821882C053D140F3C8E1E098 +:10F95000F0E0EC0FFD1FC05DDE4FE880F980C05382 +:10F96000D140EE0DFF1D208387010F5F1F4FC05D4B +:10F97000DE4F19830883C053D14062270A171B0743 +:10F9800009F0D8C8D80196E0D5C8261709F0C1C239 +:10F9900003C0973009F0CEC899248981833109F4D6 +:10F9A000FCC08431C8F4863009F4C2C0873050F4FA +:10F9B000823009F4F0C0833009F458C0813009F076 +:10F9C0000AC23EC0813109F462C0823108F0A6C08B +:10F9D000803109F000C2DFC0883109F472C089317A +:10F9E00050F4853109F4D9C0853108F477C18631E6 +:10F9F00009F0F1C173C18A3109F457C08A3108F4A2 +:10FA00007CC08B3109F446C08D3109F0E4C18D8191 +:10FA1000803311F090E00AC08F81882311F49EE1B9 +:10FA200005C0813011F091E001C098E91A821B8273 +:10FA30008D818C831D829E831F8227E030E0CFC1A1 +:10FA40001A8288E08B8381E48C8386E58D8382E54E +:10FA50008E8389E48F8383E5888780E589878FE5B6 +:10FA60008A8782E38B872BE030E0B9C18A818139B4 +:10FA700041F0823941F0803911F48FE005C080E017 +:10FA800003C082E001C08AE01A828B8344C09924BB +:10FA9000939481C08D81882311F48EE12CC0813034 +:10FAA00011F081E028C088E926C01A82E1E0F0E088 +:10FAB00089E08093570084918B831C8224E030E09E +:10FAC0008EC18B81803589F48C81883039F4E2E0F5 +:10FAD000F0E089E08093570084910DC0E0E0F0E011 +:10FAE00089E080935700849106C0E3E0F0E089E06C +:10FAF0008093570084911A82DFCF8D81836C99E0C7 +:10FB0000E1E0F0E0082E90935700E89507B600FC7E +:10FB1000FDCF1A821B8223E030E061C11A82CE5CE5 +:10FB2000DE4F188219821A821B82C253D14055C1FE +:10FB30008A8190E0A0E0B0E0582F442733272227A5 +:10FB40008B8190E0A0E0B0E0DC0199278827282B8A +:10FB5000392B4A2B5B2B8D8190E0A0E0B0E0282B65 +:10FB6000392B4A2B5B2B8C8190E0A0E0B0E0BA2FC0 +:10FB7000A92F982F8827282B392B4A2B5B2B220F54 +:10FB8000331F441F551FC05EDE4F288339834A83CD +:10FB90005B83C052D1401A8220C19A812B8183316C +:10FBA00049F0C05EDE4F488159816A817B81C05235 +:10FBB000D1408AC0CE5CDE4F488159816A817B8109 +:10FBC000C253D140403080EC580783E0680780E0A2 +:10FBD0007807F0F483E0FA0160935B0080935700AC +:10FBE000E89507B600FCFDCFCE5CDE4F4881598119 +:10FBF0006A817B81C253D14040505F4F6F4F7F4F2E +:10FC0000CE5CDE4F488359836A837B83C253D140E5 +:10FC1000C95CDE4F9883C753D140CA5CDE4F18825F +:10FC2000C653D140022F10E0CA5CDE4F6881798153 +:10FC3000C653D140062B172BC05EDE4F4881598139 +:10FC40006A817B81C052D140DE011B9631E08C91EC +:10FC500011962C9111971296C75CDE4F2883C953D9 +:10FC6000D140C85CDE4F1882C853D14090E0C85CD8 +:10FC7000DE4FE881F981C853D1408E2B9F2B0C01B8 +:10FC8000FA0160935B0030935700E89511244E5FB2 +:10FC90005F4F6F4F7F4F02501040C9F685E0C05E46 +:10FCA000DE4FE880F9800A811B81C052D140F70104 +:10FCB00000935B0080935700E89507B600FCFDCFEA +:10FCC00081E180935700E8951A82C05EDE4F488339 +:10FCD00059836A837B83C052D1407FC0FA80C55C60 +:10FCE000DE4FF882CB53D140C65CDE4F1882CA5338 +:10FCF000D1408B81C82EDD24C65CDE4F088119817E +:10FD0000CA53D140C02AD12A1A828981BE016D5FAF +:10FD10007F4F843121F59601C05EDE4FE880F98087 +:10FD20000A811B81C052D1400BBFF7018791969188 +:10FD3000DB018C9311969C936E5F7F4FD801C701B6 +:10FD40000296A11DB11DC05EDE4F88839983AA83F0 +:10FD5000BB83C052D14022503040F1F636C0C05E65 +:10FD6000DE4F288139814A815B81C052D14008949D +:10FD7000C108D108760100E010E00894C11CD11C34 +:10FD80000894E11CF11C011D111DE20EF31E041F5D +:10FD9000151F21BDBB27A52F942F832F82BD2F5F59 +:10FDA0003F4F4F4F5F4FF89A80B5DB018D93BD01F8 +:10FDB0002E153F054007510761F7C05EDE4F2883CF +:10FDC00039834A835B83C052D14096012D5F3F4FF8 +:10FDD000FB01108204C080EC8A8322E030E08BE1DA +:10FDE0008093C6008091C00086FFFCCF8091C00048 +:10FDF00080648093C000C15DDE4FF881CF52D14056 +:10FE0000F093C6008091C00086FFFCCF8091C000B7 +:10FE100080648093C000432F3093C6008091C0005F +:10FE200086FFFCCF8091C00080648093C000922F39 +:10FE30002093C6008091C00086FFFCCF8091C00057 +:10FE400080648093C0008EE08093C6008091C000E3 +:10FE500086FFFCCF8091C00080648093C00065E184 +:10FE6000C15DDE4FE880CF52D1406E2569276427FF +:10FE7000FE01319610C090819093C6008091C00021 +:10FE800086FFFCCF31968091C00080648093C000D3 +:10FE90006927215030402115310569F76093C6006C +:10FEA0008091C00086FFFCCF8091C0008064809369 +:10FEB000C00085B1805885B9992081F4C15DDE4FBD +:10FEC0000881CF52D1400F5FC15DDE4F0883CF5212 +:10FED000D14090E0A0E0B0E00D949AF527982F98DB +:10FEE00080E090E020ED37E0F9013197F1F70196DD +:10FEF00084369105C9F700008091C0008D7F809302 +:10FF0000C00081E180935700E895EE27FF27099410 +:10FF1000FFCF90E00D949AF597FB092E07260AD0A3 +:10FF200077FD04D02ED006D000201AF4709561958C +:10FF30007F4F0895F6F7909581959F4F0895A1E220 +:10FF40001A2EAA1BBB1BFD010DC0AA1FBB1FEE1F53 +:10FF5000FF1FA217B307E407F50720F0A21BB30B9E +:10FF6000E40BF50B661F771F881F991F1A9469F71A +:10FF700060957095809590959B01AC01BD01CF0176 +:10FF80000895AA1BBB1B51E107C0AA1FBB1FA617E0 +:10FF9000B70710F0A61BB70B881F991F5A95A9F732 +:10FFA00080959095BC01CD010895F999FECF92BD41 +:10FFB00081BDF89A992780B50895262FF999FECF2B +:10FFC0001FBA92BD81BD20BD0FB6F894FA9AF99A76 +:0AFFD0000FBE01960895F894FFCFCC +:040000033000E000E9 +:00000001FF diff --git a/arduino-0018-linux-x64/hardware/arduino/cores/arduino/HardwareSerial.cpp b/arduino-0022-linux-x64/hardware/arduino/cores/arduino/HardwareSerial.cpp old mode 100755 new mode 100644 similarity index 50% rename from arduino-0018-linux-x64/hardware/arduino/cores/arduino/HardwareSerial.cpp rename to arduino-0022-linux-x64/hardware/arduino/cores/arduino/HardwareSerial.cpp index 712a4c7..4397efb --- a/arduino-0018-linux-x64/hardware/arduino/cores/arduino/HardwareSerial.cpp +++ b/arduino-0022-linux-x64/hardware/arduino/cores/arduino/HardwareSerial.cpp @@ -17,39 +17,55 @@ 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 */ +#include #include #include #include #include "wiring.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" // Define constants and variables for buffering incoming serial data. We're // using a ring buffer (I think), in which rx_buffer_head is the index of the // location to which to write the next incoming character and rx_buffer_tail // is the index of the location from which to read. -#define RX_BUFFER_SIZE 128 +#if (RAMEND < 1000) + #define RX_BUFFER_SIZE 32 +#else + #define RX_BUFFER_SIZE 128 +#endif -struct ring_buffer { +struct ring_buffer +{ unsigned char buffer[RX_BUFFER_SIZE]; int head; int tail; }; -ring_buffer rx_buffer = { { 0 }, 0, 0 }; - -#if defined(__AVR_ATmega1280__) -ring_buffer rx_buffer1 = { { 0 }, 0, 0 }; -ring_buffer rx_buffer2 = { { 0 }, 0, 0 }; -ring_buffer rx_buffer3 = { { 0 }, 0, 0 }; +#if defined(UBRRH) || defined(UBRR0H) + ring_buffer rx_buffer = { { 0 }, 0, 0 }; +#endif +#if defined(UBRR1H) + ring_buffer rx_buffer1 = { { 0 }, 0, 0 }; +#endif +#if defined(UBRR2H) + ring_buffer rx_buffer2 = { { 0 }, 0, 0 }; +#endif +#if defined(UBRR3H) + ring_buffer rx_buffer3 = { { 0 }, 0, 0 }; #endif inline void store_char(unsigned char c, ring_buffer *rx_buffer) { - int i = (rx_buffer->head + 1) % RX_BUFFER_SIZE; + int i = (unsigned int)(rx_buffer->head + 1) % RX_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 @@ -61,50 +77,97 @@ inline void store_char(unsigned char c, ring_buffer *rx_buffer) } } -#if defined(__AVR_ATmega1280__) - -SIGNAL(SIG_USART0_RECV) -{ - unsigned char c = UDR0; - store_char(c, &rx_buffer); -} - -SIGNAL(SIG_USART1_RECV) -{ - unsigned char c = UDR1; - store_char(c, &rx_buffer1); -} - -SIGNAL(SIG_USART2_RECV) -{ - unsigned char c = UDR2; - store_char(c, &rx_buffer2); -} - -SIGNAL(SIG_USART3_RECV) -{ - unsigned char c = UDR3; - store_char(c, &rx_buffer3); -} - +#if defined(USART_RX_vect) + SIGNAL(USART_RX_vect) + { + #if defined(UDR0) + unsigned char c = UDR0; + #elif defined(UDR) + unsigned char c = UDR; // atmega8535 + #else + #error UDR not defined + #endif + store_char(c, &rx_buffer); + } +#elif defined(SIG_USART0_RECV) && defined(UDR0) + SIGNAL(SIG_USART0_RECV) + { + unsigned char c = UDR0; + store_char(c, &rx_buffer); + } +#elif defined(SIG_UART0_RECV) && defined(UDR0) + SIGNAL(SIG_UART0_RECV) + { + unsigned char c = UDR0; + store_char(c, &rx_buffer); + } +//#elif defined(SIG_USART_RECV) +#elif defined(USART0_RX_vect) + // fixed by Mark Sproul this is on the 644/644p + //SIGNAL(SIG_USART_RECV) + SIGNAL(USART0_RX_vect) + { + #if defined(UDR0) + unsigned char c = UDR0; + #elif defined(UDR) + unsigned char c = UDR; // atmega8, atmega32 + #else + #error UDR not defined + #endif + store_char(c, &rx_buffer); + } +#elif defined(SIG_UART_RECV) + // this is for atmega8 + SIGNAL(SIG_UART_RECV) + { + #if defined(UDR0) + unsigned char c = UDR0; // atmega645 + #elif defined(UDR) + unsigned char c = UDR; // atmega8 + #endif + store_char(c, &rx_buffer); + } +#elif defined(USBCON) + #warning No interrupt handler for usart 0 + #warning Serial(0) is on USB interface #else + #error No interrupt handler for usart 0 +#endif -#if defined(__AVR_ATmega8__) -SIGNAL(SIG_UART_RECV) -#else -SIGNAL(USART_RX_vect) +//#if defined(SIG_USART1_RECV) +#if defined(USART1_RX_vect) + //SIGNAL(SIG_USART1_RECV) + SIGNAL(USART1_RX_vect) + { + unsigned char c = UDR1; + store_char(c, &rx_buffer1); + } +#elif defined(SIG_USART1_RECV) + #error SIG_USART1_RECV #endif -{ -#if defined(__AVR_ATmega8__) - unsigned char c = UDR; -#else - unsigned char c = UDR0; + +#if defined(USART2_RX_vect) && defined(UDR2) + SIGNAL(USART2_RX_vect) + { + unsigned char c = UDR2; + store_char(c, &rx_buffer2); + } +#elif defined(SIG_USART2_RECV) + #error SIG_USART2_RECV #endif - store_char(c, &rx_buffer); -} +#if defined(USART3_RX_vect) && defined(UDR3) + SIGNAL(USART3_RX_vect) + { + unsigned char c = UDR3; + store_char(c, &rx_buffer3); + } +#elif defined(SIG_USART3_RECV) + #error SIG_USART3_RECV #endif + + // Constructors //////////////////////////////////////////////////////////////// HardwareSerial::HardwareSerial(ring_buffer *rx_buffer, @@ -131,22 +194,16 @@ HardwareSerial::HardwareSerial(ring_buffer *rx_buffer, void HardwareSerial::begin(long baud) { uint16_t baud_setting; - bool use_u2x; - - // U2X mode is needed for baud rates higher than (CPU Hz / 16) - if (baud > F_CPU / 16) { - use_u2x = true; - } else { - // figure out if U2X mode would allow for a better connection - - // calculate the percent difference between the baud-rate specified and - // the real baud rate for both U2X and non-U2X mode (0-255 error percent) - uint8_t nonu2x_baud_error = abs((int)(255-((F_CPU/(16*(((F_CPU/8/baud-1)/2)+1))*255)/baud))); - uint8_t u2x_baud_error = abs((int)(255-((F_CPU/(8*(((F_CPU/4/baud-1)/2)+1))*255)/baud))); - - // prefer non-U2X mode because it handles clock skew better - use_u2x = (nonu2x_baud_error > u2x_baud_error); + 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 if (use_u2x) { *_ucsra = 1 << _u2x; @@ -172,9 +229,18 @@ void HardwareSerial::end() cbi(*_ucsrb, _rxcie); } -uint8_t HardwareSerial::available(void) +int HardwareSerial::available(void) +{ + return (unsigned int)(RX_BUFFER_SIZE + _rx_buffer->head - _rx_buffer->tail) % RX_BUFFER_SIZE; +} + +int HardwareSerial::peek(void) { - return (RX_BUFFER_SIZE + _rx_buffer->head - _rx_buffer->tail) % RX_BUFFER_SIZE; + if (_rx_buffer->head == _rx_buffer->tail) { + return -1; + } else { + return _rx_buffer->buffer[_rx_buffer->tail]; + } } int HardwareSerial::read(void) @@ -184,7 +250,7 @@ int HardwareSerial::read(void) return -1; } else { unsigned char c = _rx_buffer->buffer[_rx_buffer->tail]; - _rx_buffer->tail = (_rx_buffer->tail + 1) % RX_BUFFER_SIZE; + _rx_buffer->tail = (unsigned int)(_rx_buffer->tail + 1) % RX_BUFFER_SIZE; return c; } } @@ -213,14 +279,25 @@ void HardwareSerial::write(uint8_t c) // Preinstantiate Objects ////////////////////////////////////////////////////// -#if defined(__AVR_ATmega8__) -HardwareSerial Serial(&rx_buffer, &UBRRH, &UBRRL, &UCSRA, &UCSRB, &UDR, RXEN, TXEN, RXCIE, UDRE, U2X); +#if defined(UBRRH) && defined(UBRRL) + HardwareSerial Serial(&rx_buffer, &UBRRH, &UBRRL, &UCSRA, &UCSRB, &UDR, RXEN, TXEN, RXCIE, UDRE, U2X); +#elif defined(UBRR0H) && defined(UBRR0L) + HardwareSerial Serial(&rx_buffer, &UBRR0H, &UBRR0L, &UCSR0A, &UCSR0B, &UDR0, RXEN0, TXEN0, RXCIE0, UDRE0, U2X0); +#elif defined(USBCON) + #warning no serial port defined (port 0) #else -HardwareSerial Serial(&rx_buffer, &UBRR0H, &UBRR0L, &UCSR0A, &UCSR0B, &UDR0, RXEN0, TXEN0, RXCIE0, UDRE0, U2X0); + #error no serial port defined (port 0) #endif -#if defined(__AVR_ATmega1280__) -HardwareSerial Serial1(&rx_buffer1, &UBRR1H, &UBRR1L, &UCSR1A, &UCSR1B, &UDR1, RXEN1, TXEN1, RXCIE1, UDRE1, U2X1); -HardwareSerial Serial2(&rx_buffer2, &UBRR2H, &UBRR2L, &UCSR2A, &UCSR2B, &UDR2, RXEN2, TXEN2, RXCIE2, UDRE2, U2X2); -HardwareSerial Serial3(&rx_buffer3, &UBRR3H, &UBRR3L, &UCSR3A, &UCSR3B, &UDR3, RXEN3, TXEN3, RXCIE3, UDRE3, U2X3); +#if defined(UBRR1H) + HardwareSerial Serial1(&rx_buffer1, &UBRR1H, &UBRR1L, &UCSR1A, &UCSR1B, &UDR1, RXEN1, TXEN1, RXCIE1, UDRE1, U2X1); +#endif +#if defined(UBRR2H) + HardwareSerial Serial2(&rx_buffer2, &UBRR2H, &UBRR2L, &UCSR2A, &UCSR2B, &UDR2, RXEN2, TXEN2, RXCIE2, UDRE2, U2X2); #endif +#if defined(UBRR3H) + HardwareSerial Serial3(&rx_buffer3, &UBRR3H, &UBRR3L, &UCSR3A, &UCSR3B, &UDR3, RXEN3, TXEN3, RXCIE3, UDRE3, U2X3); +#endif + +#endif // whole file + diff --git a/arduino-0018-linux-x64/hardware/arduino/cores/arduino/HardwareSerial.h b/arduino-0022-linux-x64/hardware/arduino/cores/arduino/HardwareSerial.h old mode 100755 new mode 100644 similarity index 76% rename from arduino-0018-linux-x64/hardware/arduino/cores/arduino/HardwareSerial.h rename to arduino-0022-linux-x64/hardware/arduino/cores/arduino/HardwareSerial.h index 6b620ed..3efa775 --- a/arduino-0018-linux-x64/hardware/arduino/cores/arduino/HardwareSerial.h +++ b/arduino-0022-linux-x64/hardware/arduino/cores/arduino/HardwareSerial.h @@ -15,6 +15,8 @@ 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 */ #ifndef HardwareSerial_h @@ -22,11 +24,11 @@ #include -#include "Print.h" +#include "Stream.h" struct ring_buffer; -class HardwareSerial : public Print +class HardwareSerial : public Stream { private: ring_buffer *_rx_buffer; @@ -48,19 +50,27 @@ class HardwareSerial : public Print uint8_t rxen, uint8_t txen, uint8_t rxcie, uint8_t udre, uint8_t u2x); void begin(long); void end(); - uint8_t available(void); - int read(void); - void flush(void); + virtual int available(void); + virtual int peek(void); + virtual int read(void); + virtual void flush(void); virtual void write(uint8_t); using Print::write; // pull in write(str) and write(buf, size) from Print }; -extern HardwareSerial Serial; - -#if defined(__AVR_ATmega1280__) -extern HardwareSerial Serial1; -extern HardwareSerial Serial2; -extern HardwareSerial Serial3; +#if defined(UBRRH) || defined(UBRR0H) + extern HardwareSerial Serial; +#elif defined(USBCON) + #include "usb_api.h" +#endif +#if defined(UBRR1H) + extern HardwareSerial Serial1; +#endif +#if defined(UBRR2H) + extern HardwareSerial Serial2; +#endif +#if defined(UBRR3H) + extern HardwareSerial Serial3; #endif #endif diff --git a/arduino-0018-linux-x64/hardware/arduino/cores/arduino/Print.cpp b/arduino-0022-linux-x64/hardware/arduino/cores/arduino/Print.cpp old mode 100755 new mode 100644 similarity index 95% rename from arduino-0018-linux-x64/hardware/arduino/cores/arduino/Print.cpp rename to arduino-0022-linux-x64/hardware/arduino/cores/arduino/Print.cpp index fb5afc1..4ee556d --- a/arduino-0018-linux-x64/hardware/arduino/cores/arduino/Print.cpp +++ b/arduino-0022-linux-x64/hardware/arduino/cores/arduino/Print.cpp @@ -19,6 +19,7 @@ Modified 23 November 2006 by David A. Mellis */ +#include #include #include #include @@ -42,6 +43,13 @@ void Print::write(const uint8_t *buffer, size_t size) write(*buffer++); } +void Print::print(const String &s) +{ + for (int i = 0; i < s.length(); i++) { + write(s[i]); + } +} + void Print::print(const char str[]) { write(str); @@ -99,6 +107,12 @@ void Print::println(void) print('\n'); } +void Print::println(const String &s) +{ + print(s); + println(); +} + void Print::println(const char c[]) { print(c); diff --git a/arduino-0018-linux-x64/hardware/arduino/cores/arduino/Print.h b/arduino-0022-linux-x64/hardware/arduino/cores/arduino/Print.h old mode 100755 new mode 100644 similarity index 95% rename from arduino-0018-linux-x64/hardware/arduino/cores/arduino/Print.h rename to arduino-0022-linux-x64/hardware/arduino/cores/arduino/Print.h index 8a1e2b8..b092ae5 --- a/arduino-0018-linux-x64/hardware/arduino/cores/arduino/Print.h +++ b/arduino-0022-linux-x64/hardware/arduino/cores/arduino/Print.h @@ -23,6 +23,8 @@ #include #include // for size_t +#include "WString.h" + #define DEC 10 #define HEX 16 #define OCT 8 @@ -38,7 +40,8 @@ class Print virtual void write(uint8_t) = 0; virtual void write(const char *str); virtual void write(const uint8_t *buffer, size_t size); - + + void print(const String &); void print(const char[]); void print(char, int = BYTE); void print(unsigned char, int = BYTE); @@ -48,6 +51,7 @@ class Print void print(unsigned long, int = DEC); void print(double, int = 2); + void println(const String &s); void println(const char[]); void println(char, int = BYTE); void println(unsigned char, int = BYTE); diff --git a/arduino-0022-linux-x64/hardware/arduino/cores/arduino/Stream.h b/arduino-0022-linux-x64/hardware/arduino/cores/arduino/Stream.h new file mode 100644 index 0000000..93d8275 --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/cores/arduino/Stream.h @@ -0,0 +1,35 @@ +/* + 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 +*/ + +#ifndef Stream_h +#define Stream_h + +#include +#include "Print.h" + +class Stream : public Print +{ + public: + virtual int available() = 0; + virtual int read() = 0; + virtual int peek() = 0; + virtual void flush() = 0; +}; + +#endif diff --git a/arduino-0018-linux-x64/hardware/arduino/cores/arduino/Tone.cpp b/arduino-0022-linux-x64/hardware/arduino/cores/arduino/Tone.cpp old mode 100755 new mode 100644 similarity index 78% rename from arduino-0018-linux-x64/hardware/arduino/cores/arduino/Tone.cpp rename to arduino-0022-linux-x64/hardware/arduino/cores/arduino/Tone.cpp index 827fe49..c3910e7 --- a/arduino-0018-linux-x64/hardware/arduino/cores/arduino/Tone.cpp +++ b/arduino-0022-linux-x64/hardware/arduino/cores/arduino/Tone.cpp @@ -28,15 +28,15 @@ Version Modified By Date Comments 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 *************************************************/ #include #include -#include -#include +#include "wiring.h" +#include "pins_arduino.h" -#if defined(__AVR_ATmega8__) +#if defined(__AVR_ATmega8__) || defined(__AVR_ATmega128__) #define TCCR2A TCCR2 #define TCCR2B TCCR2 #define COM2A1 COM21 @@ -66,20 +66,27 @@ volatile long timer2_toggle_count; volatile uint8_t *timer2_pin_port; volatile uint8_t timer2_pin_mask; -#if defined(__AVR_ATmega1280__) +#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__) +// MLS: This does not make sense, the 3 options are the same +#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) #define AVAILABLE_TONE_PINS 1 @@ -133,7 +140,7 @@ static int8_t toneBegin(uint8_t _pin) // whereas 16 bit timers are set to either ck/1 or ck/64 prescalar switch (_timer) { -#if !defined(__AVR_ATmega8__) + #if defined(TCCR0A) && defined(TCCR0B) case 0: // 8 bit timer TCCR0A = 0; @@ -143,8 +150,9 @@ static int8_t toneBegin(uint8_t _pin) timer0_pin_port = portOutputRegister(digitalPinToPort(_pin)); timer0_pin_mask = digitalPinToBitMask(_pin); break; -#endif + #endif + #if defined(TCCR1A) && defined(TCCR1B) && defined(WGM12) case 1: // 16 bit timer TCCR1A = 0; @@ -154,6 +162,9 @@ static int8_t toneBegin(uint8_t _pin) 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; @@ -163,8 +174,9 @@ static int8_t toneBegin(uint8_t _pin) timer2_pin_port = portOutputRegister(digitalPinToPort(_pin)); timer2_pin_mask = digitalPinToBitMask(_pin); break; + #endif -#if defined(__AVR_ATmega1280__) + #if defined(TCCR3A) && defined(TCCR3B) && defined(TIMSK3) case 3: // 16 bit timer TCCR3A = 0; @@ -174,15 +186,27 @@ static int8_t toneBegin(uint8_t _pin) 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; - bitWrite(TCCR4B, WGM42, 1); + #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; @@ -192,7 +216,7 @@ static int8_t toneBegin(uint8_t _pin) timer5_pin_port = portOutputRegister(digitalPinToPort(_pin)); timer5_pin_mask = digitalPinToBitMask(_pin); break; -#endif + #endif } } @@ -258,12 +282,22 @@ void tone(uint8_t _pin, unsigned int frequency, unsigned long duration) } } -#if !defined(__AVR_ATmega8__) +#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 { @@ -278,12 +312,20 @@ void tone(uint8_t _pin, unsigned int frequency, unsigned long duration) } if (_timer == 1) + { +#if defined(TCCR1B) TCCR1B = (TCCR1B & 0b11111000) | prescalarbits; -#if defined(__AVR_ATmega1280__) +#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 @@ -307,7 +349,7 @@ void tone(uint8_t _pin, unsigned int frequency, unsigned long duration) switch (_timer) { -#if !defined(__AVR_ATmega8__) +#if defined(OCR0A) && defined(TIMSK0) && defined(OCIE0A) case 0: OCR0A = ocr; timer0_toggle_count = toggle_count; @@ -316,27 +358,43 @@ void tone(uint8_t _pin, unsigned int frequency, unsigned long duration) #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(__AVR_ATmega1280__) +#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; @@ -349,51 +407,75 @@ void tone(uint8_t _pin, unsigned int frequency, unsigned long duration) } -void noTone(uint8_t _pin) +// 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) { - 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; - } - } - switch (_timer) { -#if defined(__AVR_ATmega8__) - case 1: - bitWrite(TIMSK1, OCIE1A, 0); - break; - case 2: - bitWrite(TIMSK2, OCIE2A, 0); - break; - -#else case 0: - TIMSK0 = 0; + #if defined(TIMSK0) + TIMSK0 = 0; + #elif defined(TIMSK) + TIMSK = 0; // atmega32 + #endif break; + +#if defined(TIMSK1) && defined(OCIE1A) case 1: - TIMSK1 = 0; + bitWrite(TIMSK1, OCIE1A, 0); break; +#endif + case 2: - TIMSK2 = 0; + #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; -#endif -#if defined(__AVR_ATmega1280__) +#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); } @@ -412,7 +494,7 @@ ISR(TIMER0_COMPA_vect) } else { - TIMSK0 = 0; // disable the interrupt + disableTimer(0); *timer0_pin_port &= ~(timer0_pin_mask); // keep pin low after stop } } @@ -431,7 +513,7 @@ ISR(TIMER1_COMPA_vect) } else { - TIMSK1 = 0; // disable the interrupt + disableTimer(1); *timer1_pin_port &= ~(timer1_pin_mask); // keep pin low after stop } } @@ -451,14 +533,18 @@ ISR(TIMER2_COMPA_vect) } else { - TIMSK2 = 0; // disable the interrupt - *timer2_pin_port &= ~(timer2_pin_mask); // keep pin low after stop + // 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 } } -//#if defined(__AVR_ATmega1280__) +//#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) #if 0 ISR(TIMER3_COMPA_vect) @@ -473,7 +559,7 @@ ISR(TIMER3_COMPA_vect) } else { - TIMSK3 = 0; // disable the interrupt + disableTimer(3); *timer3_pin_port &= ~(timer3_pin_mask); // keep pin low after stop } } @@ -490,7 +576,7 @@ ISR(TIMER4_COMPA_vect) } else { - TIMSK4 = 0; // disable the interrupt + disableTimer(4); *timer4_pin_port &= ~(timer4_pin_mask); // keep pin low after stop } } @@ -507,7 +593,7 @@ ISR(TIMER5_COMPA_vect) } else { - TIMSK5 = 0; // disable the interrupt + disableTimer(5); *timer5_pin_port &= ~(timer5_pin_mask); // keep pin low after stop } } diff --git a/arduino-0022-linux-x64/hardware/arduino/cores/arduino/WCharacter.h b/arduino-0022-linux-x64/hardware/arduino/cores/arduino/WCharacter.h new file mode 100644 index 0000000..79733b5 --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/cores/arduino/WCharacter.h @@ -0,0 +1,168 @@ +/* + 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 + +// 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/arduino-0018-linux-x64/hardware/arduino/cores/arduino/WConstants.h b/arduino-0022-linux-x64/hardware/arduino/cores/arduino/WConstants.h similarity index 100% rename from arduino-0018-linux-x64/hardware/arduino/cores/arduino/WConstants.h rename to arduino-0022-linux-x64/hardware/arduino/cores/arduino/WConstants.h diff --git a/arduino-0018-linux-x64/hardware/arduino/cores/arduino/WInterrupts.c b/arduino-0022-linux-x64/hardware/arduino/cores/arduino/WInterrupts.c old mode 100755 new mode 100644 similarity index 74% rename from arduino-0018-linux-x64/hardware/arduino/cores/arduino/WInterrupts.c rename to arduino-0022-linux-x64/hardware/arduino/cores/arduino/WInterrupts.c index 69a78b0..3b3e0c9 --- a/arduino-0018-linux-x64/hardware/arduino/cores/arduino/WInterrupts.c +++ b/arduino-0022-linux-x64/hardware/arduino/cores/arduino/WInterrupts.c @@ -21,6 +21,7 @@ Boston, MA 02111-1307 USA Modified 24 November 2006 by David A. Mellis + Modified 1 August 2010 by Mark Sproul */ #include @@ -35,11 +36,6 @@ volatile static voidFuncPtr intFunc[EXTERNAL_NUM_INTERRUPTS]; // volatile static voidFuncPtr twiIntFunc; -#if defined(__AVR_ATmega8__) -#define EICRA MCUCR -#define EIMSK GICR -#endif - void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), int mode) { if(interruptNum < EXTERNAL_NUM_INTERRUPTS) { intFunc[interruptNum] = userFunc; @@ -52,7 +48,7 @@ void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), int mode) { // Enable the interrupt. switch (interruptNum) { -#if defined(__AVR_ATmega1280__) +#if defined(EICRA) && defined(EICRB) && defined(EIMSK) case 2: EICRA = (EICRA & ~((1 << ISC00) | (1 << ISC01))) | (mode << ISC00); EIMSK |= (1 << INT0); @@ -87,12 +83,33 @@ void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), int mode) { 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; #endif } @@ -105,7 +122,7 @@ void detachInterrupt(uint8_t interruptNum) { // 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_ATmega1280__) +#if defined(EICRA) && defined(EICRB) && defined(EIMSK) case 2: EIMSK &= ~(1 << INT0); break; @@ -132,10 +149,27 @@ void detachInterrupt(uint8_t interruptNum) { 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 } @@ -150,7 +184,7 @@ void attachInterruptTwi(void (*userFunc)(void) ) { } */ -#if defined(__AVR_ATmega1280__) +#if defined(EICRA) && defined(EICRB) SIGNAL(INT0_vect) { if(intFunc[EXTERNAL_INT_2]) diff --git a/arduino-0018-linux-x64/hardware/arduino/cores/arduino/WMath.cpp b/arduino-0022-linux-x64/hardware/arduino/cores/arduino/WMath.cpp similarity index 100% rename from arduino-0018-linux-x64/hardware/arduino/cores/arduino/WMath.cpp rename to arduino-0022-linux-x64/hardware/arduino/cores/arduino/WMath.cpp diff --git a/arduino-0022-linux-x64/hardware/arduino/cores/arduino/WProgram.h b/arduino-0022-linux-x64/hardware/arduino/cores/arduino/WProgram.h new file mode 100644 index 0000000..f73e760 --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/cores/arduino/WProgram.h @@ -0,0 +1,63 @@ +#ifndef WProgram_h +#define WProgram_h + +#include +#include +#include + +#include + +#include "wiring.h" + +#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); + +#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) +const static uint8_t A0 = 54; +const static uint8_t A1 = 55; +const static uint8_t A2 = 56; +const static uint8_t A3 = 57; +const static uint8_t A4 = 58; +const static uint8_t A5 = 59; +const static uint8_t A6 = 60; +const static uint8_t A7 = 61; +const static uint8_t A8 = 62; +const static uint8_t A9 = 63; +const static uint8_t A10 = 64; +const static uint8_t A11 = 65; +const static uint8_t A12 = 66; +const static uint8_t A13 = 67; +const static uint8_t A14 = 68; +const static uint8_t A15 = 69; +#else +const static uint8_t A0 = 14; +const static uint8_t A1 = 15; +const static uint8_t A2 = 16; +const static uint8_t A3 = 17; +const static uint8_t A4 = 18; +const static uint8_t A5 = 19; +const static uint8_t A6 = 20; +const static uint8_t A7 = 21; +#endif + +#endif + +#endif \ No newline at end of file diff --git a/arduino-0022-linux-x64/hardware/arduino/cores/arduino/WString.cpp b/arduino-0022-linux-x64/hardware/arduino/cores/arduino/WString.cpp new file mode 100644 index 0000000..db5a441 --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/cores/arduino/WString.cpp @@ -0,0 +1,443 @@ +/* + WString.cpp - String library for Wiring & Arduino + Copyright (c) 2009-10 Hernando Barragan. All rights reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include +#include "WProgram.h" +#include "WString.h" + + +String::String( const char *value ) +{ + if ( value == NULL ) + value = ""; + getBuffer( _length = strlen( value ) ); + if ( _buffer != NULL ) + strcpy( _buffer, value ); +} + +String::String( const String &value ) +{ + getBuffer( _length = value._length ); + if ( _buffer != NULL ) + strcpy( _buffer, value._buffer ); +} + +String::String( const char value ) +{ + _length = 1; + getBuffer(1); + if ( _buffer != NULL ) { + _buffer[0] = value; + _buffer[1] = 0; + } +} + +String::String( const unsigned char value ) +{ + _length = 1; + getBuffer(1); + if ( _buffer != NULL) { + _buffer[0] = value; + _buffer[1] = 0; + } +} + +String::String( const int value, const int base ) +{ + char buf[33]; + itoa((signed long)value, buf, base); + getBuffer( _length = strlen(buf) ); + if ( _buffer != NULL ) + strcpy( _buffer, buf ); +} + +String::String( const unsigned int value, const int base ) +{ + char buf[33]; + ultoa((unsigned long)value, buf, base); + getBuffer( _length = strlen(buf) ); + if ( _buffer != NULL ) + strcpy( _buffer, buf ); +} + +String::String( const long value, const int base ) +{ + char buf[33]; + ltoa(value, buf, base); + getBuffer( _length = strlen(buf) ); + if ( _buffer != NULL ) + strcpy( _buffer, buf ); +} + +String::String( const unsigned long value, const int base ) +{ + char buf[33]; + ultoa(value, buf, 10); + getBuffer( _length = strlen(buf) ); + if ( _buffer != NULL ) + strcpy( _buffer, buf ); +} + +char String::charAt( unsigned int loc ) const +{ + return operator[]( loc ); +} + +void String::setCharAt( unsigned int loc, const char aChar ) +{ + if(_buffer == NULL) return; + if(_length > loc) { + _buffer[loc] = aChar; + } +} + +int String::compareTo( const String &s2 ) const +{ + return strcmp( _buffer, s2._buffer ); +} + +const String & String::concat( const String &s2 ) +{ + return (*this) += s2; +} + +const String & String::operator=( const String &rhs ) +{ + if ( this == &rhs ) + return *this; + + if ( rhs._length > _length ) + { + free(_buffer); + getBuffer( rhs._length ); + } + + if ( _buffer != NULL ) { + _length = rhs._length; + strcpy( _buffer, rhs._buffer ); + } + return *this; +} + +//const String & String::operator+=( const char aChar ) +//{ +// if ( _length == _capacity ) +// doubleBuffer(); +// +// _buffer[ _length++ ] = aChar; +// _buffer[ _length ] = '\0'; +// return *this; +//} + +const String & String::operator+=( const String &other ) +{ + _length += other._length; + if ( _length > _capacity ) + { + char *temp = (char *)realloc(_buffer, _length + 1); + if ( temp != NULL ) { + _buffer = temp; + _capacity = _length; + } else { + _length -= other._length; + return *this; + } + } + strcat( _buffer, other._buffer ); + return *this; +} + + +int String::operator==( const String &rhs ) const +{ + return ( _length == rhs._length && strcmp( _buffer, rhs._buffer ) == 0 ); +} + +int String::operator!=( const String &rhs ) const +{ + return ( _length != rhs.length() || strcmp( _buffer, rhs._buffer ) != 0 ); +} + +int String::operator<( const String &rhs ) const +{ + return strcmp( _buffer, rhs._buffer ) < 0; +} + +int String::operator>( const String &rhs ) const +{ + return strcmp( _buffer, rhs._buffer ) > 0; +} + +int String::operator<=( const String &rhs ) const +{ + return strcmp( _buffer, rhs._buffer ) <= 0; +} + +int String::operator>=( const String & rhs ) const +{ + return strcmp( _buffer, rhs._buffer ) >= 0; +} + +char & String::operator[]( unsigned int index ) +{ + static char dummy_writable_char; + if (index >= _length || !_buffer) { + dummy_writable_char = 0; + return dummy_writable_char; + } + return _buffer[ index ]; +} + +char String::operator[]( unsigned int index ) const +{ + // need to check for valid index, to do later + return _buffer[ index ]; +} + +boolean String::endsWith( const String &s2 ) const +{ + if ( _length < s2._length ) + return 0; + + return strcmp( &_buffer[ _length - s2._length], s2._buffer ) == 0; +} + +boolean String::equals( const String &s2 ) const +{ + return ( _length == s2._length && strcmp( _buffer,s2._buffer ) == 0 ); +} + +boolean String::equalsIgnoreCase( const String &s2 ) const +{ + if ( this == &s2 ) + return true; //1; + else if ( _length != s2._length ) + return false; //0; + + return strcmp(toLowerCase()._buffer, s2.toLowerCase()._buffer) == 0; +} + +String String::replace( char findChar, char replaceChar ) +{ + if ( _buffer == NULL ) return *this; + String theReturn = _buffer; + char* temp = theReturn._buffer; + while( (temp = strchr( temp, findChar )) != 0 ) + *temp = replaceChar; + + return theReturn; +} + +String String::replace( const String& match, const String& replace ) +{ + if ( _buffer == NULL ) return *this; + String temp = _buffer, newString; + + int loc; + while ( (loc = temp.indexOf( match )) != -1 ) + { + newString += temp.substring( 0, loc ); + newString += replace; + temp = temp.substring( loc + match._length ); + } + newString += temp; + return newString; +} + +int String::indexOf( char temp ) const +{ + return indexOf( temp, 0 ); +} + +int String::indexOf( char ch, unsigned int fromIndex ) const +{ + if ( fromIndex >= _length ) + 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 >= _length ) + return -1; + + const char *theFind = strstr( &_buffer[ fromIndex ], s2._buffer ); + + if ( theFind == NULL ) + return -1; + + return theFind - _buffer; // pointer subtraction +} + +int String::lastIndexOf( char theChar ) const +{ + return lastIndexOf( theChar, _length - 1 ); +} + +int String::lastIndexOf( char ch, unsigned int fromIndex ) const +{ + if ( fromIndex >= _length ) + 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, _length - s2._length ); +} + +int String::lastIndexOf( const String &s2, unsigned int fromIndex ) const +{ + // check for empty strings + if ( s2._length == 0 || s2._length - 1 > fromIndex || fromIndex >= _length ) + return -1; + + // matching first character + char temp = s2[ 0 ]; + + for ( int i = fromIndex; i >= 0; i-- ) + { + if ( _buffer[ i ] == temp && (*this).substring( i, i + s2._length ).equals( s2 ) ) + return i; + } + return -1; +} + +boolean String::startsWith( const String &s2 ) const +{ + if ( _length < s2._length ) + return 0; + + return startsWith( s2, 0 ); +} + +boolean String::startsWith( const String &s2, unsigned int offset ) const +{ + if ( offset > _length - s2._length ) + return 0; + + return strncmp( &_buffer[offset], s2._buffer, s2._length ) == 0; +} + +String String::substring( unsigned int left ) const +{ + return substring( left, _length ); +} + +String String::substring( unsigned int left, unsigned int right ) const +{ + if ( left > right ) + { + int temp = right; + right = left; + left = temp; + } + + if ( right > _length ) + { + right = _length; + } + + char temp = _buffer[ right ]; // save the replaced character + _buffer[ right ] = '\0'; + String outPut = ( _buffer + left ); // pointer arithmetic + _buffer[ right ] = temp; //restore character + return outPut; +} + +String String::toLowerCase() const +{ + String temp = _buffer; + + for ( unsigned int i = 0; i < _length; i++ ) + temp._buffer[ i ] = (char)tolower( temp._buffer[ i ] ); + return temp; +} + +String String::toUpperCase() const +{ + String temp = _buffer; + + for ( unsigned int i = 0; i < _length; i++ ) + temp._buffer[ i ] = (char)toupper( temp._buffer[ i ] ); + return temp; +} + +String String::trim() const +{ + if ( _buffer == NULL ) return *this; + String temp = _buffer; + unsigned int i,j; + + for ( i = 0; i < _length; i++ ) + { + if ( !isspace(_buffer[i]) ) + break; + } + + for ( j = temp._length - 1; j > i; j-- ) + { + if ( !isspace(_buffer[j]) ) + break; + } + + return temp.substring( i, j + 1); +} + +void String::getBytes(unsigned char *buf, unsigned int bufsize) +{ + if (!bufsize || !buf) return; + unsigned int len = bufsize - 1; + if (len > _length) len = _length; + strncpy((char *)buf, _buffer, len); + buf[len] = 0; +} + +void String::toCharArray(char *buf, unsigned int bufsize) +{ + if (!bufsize || !buf) return; + unsigned int len = bufsize - 1; + if (len > _length) len = _length; + strncpy(buf, _buffer, len); + buf[len] = 0; +} + + +long String::toInt() { + return atol(_buffer); +} diff --git a/arduino-0022-linux-x64/hardware/arduino/cores/arduino/WString.h b/arduino-0022-linux-x64/hardware/arduino/cores/arduino/WString.h new file mode 100644 index 0000000..cadddb9 --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/cores/arduino/WString.h @@ -0,0 +1,112 @@ +/* + WString.h - String library for Wiring & Arduino + Copyright (c) 2009-10 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 String_h +#define String_h + +//#include "WProgram.h" +#include +#include +#include + +class String +{ + public: + // constructors + String( const char *value = "" ); + String( const String &value ); + String( const char ); + String( const unsigned char ); + String( const int, const int base=10); + String( const unsigned int, const int base=10 ); + String( const long, const int base=10 ); + String( const unsigned long, const int base=10 ); + ~String() { free(_buffer); _length = _capacity = 0;} //added _length = _capacity = 0; + + // operators + const String & operator = ( const String &rhs ); + const String & operator +=( const String &rhs ); + //const String & operator +=( const char ); + int operator ==( const String &rhs ) const; + int operator !=( const String &rhs ) const; + int operator < ( const String &rhs ) const; + int operator > ( const String &rhs ) const; + int operator <=( const String &rhs ) const; + int operator >=( const String &rhs ) const; + char operator []( unsigned int index ) const; + char& operator []( unsigned int index ); + //operator const char *() const { return _buffer; } + + // general methods + char charAt( unsigned int index ) const; + int compareTo( const String &anotherString ) const; + unsigned char endsWith( const String &suffix ) const; + unsigned char equals( const String &anObject ) const; + unsigned char equalsIgnoreCase( const String &anotherString ) const; + 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; + const unsigned int length( ) const { return _length; } + void setCharAt(unsigned int index, const char ch); + unsigned char startsWith( const String &prefix ) const; + unsigned char startsWith( const String &prefix, unsigned int toffset ) const; + String substring( unsigned int beginIndex ) const; + String substring( unsigned int beginIndex, unsigned int endIndex ) const; + String toLowerCase( ) const; + String toUpperCase( ) const; + String trim( ) const; + void getBytes(unsigned char *buf, unsigned int bufsize); + void toCharArray(char *buf, unsigned int bufsize); + long toInt( ); + const String& concat( const String &str ); + String replace( char oldChar, char newChar ); + String replace( const String& match, const String& replace ); + friend String operator + ( String lhs, const String &rhs ); + + protected: + char *_buffer; // the actual char array + unsigned int _capacity; // the array length minus one (for the '\0') + unsigned int _length; // the String length (not counting the '\0') + + void getBuffer(unsigned int maxStrLen); + + private: + +}; + +// allocate buffer space +inline void String::getBuffer(unsigned int maxStrLen) +{ + _capacity = maxStrLen; + _buffer = (char *) malloc(_capacity + 1); + if (_buffer == NULL) _length = _capacity = 0; +} + +inline String operator+( String lhs, const String &rhs ) +{ + return lhs += rhs; +} + + +#endif diff --git a/arduino-0018-linux-x64/hardware/arduino/cores/arduino/binary.h b/arduino-0022-linux-x64/hardware/arduino/cores/arduino/binary.h similarity index 100% rename from arduino-0018-linux-x64/hardware/arduino/cores/arduino/binary.h rename to arduino-0022-linux-x64/hardware/arduino/cores/arduino/binary.h diff --git a/arduino-0018-linux-x64/hardware/arduino/cores/arduino/main.cpp b/arduino-0022-linux-x64/hardware/arduino/cores/arduino/main.cpp old mode 100755 new mode 100644 similarity index 100% rename from arduino-0018-linux-x64/hardware/arduino/cores/arduino/main.cpp rename to arduino-0022-linux-x64/hardware/arduino/cores/arduino/main.cpp diff --git a/arduino-0018-linux-x64/hardware/arduino/cores/arduino/pins_arduino.c b/arduino-0022-linux-x64/hardware/arduino/cores/arduino/pins_arduino.c old mode 100755 new mode 100644 similarity index 97% rename from arduino-0018-linux-x64/hardware/arduino/cores/arduino/pins_arduino.c rename to arduino-0022-linux-x64/hardware/arduino/cores/arduino/pins_arduino.c index d7b076d..0c816e9 --- a/arduino-0018-linux-x64/hardware/arduino/cores/arduino/pins_arduino.c +++ b/arduino-0022-linux-x64/hardware/arduino/cores/arduino/pins_arduino.c @@ -19,7 +19,7 @@ Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - $Id: pins_arduino.c 804 2009-12-18 16:05:52Z dmellis $ + $Id$ */ #include @@ -77,12 +77,8 @@ #define PK 11 #define PL 12 -#define REPEAT8(x) x, x, x, x, x, x, x, x -#define BV0TO7 _BV(0), _BV(1), _BV(2), _BV(3), _BV(4), _BV(5), _BV(6), _BV(7) -#define BV7TO0 _BV(7), _BV(6), _BV(5), _BV(4), _BV(3), _BV(2), _BV(1), _BV(0) - -#if defined(__AVR_ATmega1280__) +#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) const uint16_t PROGMEM port_to_mode_PGM[] = { NOT_A_PORT, &DDRA, diff --git a/arduino-0018-linux-x64/hardware/arduino/cores/arduino/pins_arduino.h b/arduino-0022-linux-x64/hardware/arduino/cores/arduino/pins_arduino.h similarity index 88% rename from arduino-0018-linux-x64/hardware/arduino/cores/arduino/pins_arduino.h rename to arduino-0022-linux-x64/hardware/arduino/cores/arduino/pins_arduino.h index c7e40fd..bc931c5 100644 --- a/arduino-0018-linux-x64/hardware/arduino/cores/arduino/pins_arduino.h +++ b/arduino-0022-linux-x64/hardware/arduino/cores/arduino/pins_arduino.h @@ -49,6 +49,18 @@ #define TIMER5B 15 #define TIMER5C 16 +#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) +const static uint8_t SS = 53; +const static uint8_t MOSI = 51; +const static uint8_t MISO = 50; +const static uint8_t SCK = 52; +#else +const static uint8_t SS = 10; +const static uint8_t MOSI = 11; +const static uint8_t MISO = 12; +const static uint8_t SCK = 13; +#endif + // 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[]; diff --git a/arduino-0018-linux-x64/hardware/arduino/cores/arduino/wiring.c b/arduino-0022-linux-x64/hardware/arduino/cores/arduino/wiring.c old mode 100755 new mode 100644 similarity index 73% rename from arduino-0018-linux-x64/hardware/arduino/cores/arduino/wiring.c rename to arduino-0022-linux-x64/hardware/arduino/cores/arduino/wiring.c index d857e8a..b90d07e --- a/arduino-0018-linux-x64/hardware/arduino/cores/arduino/wiring.c +++ b/arduino-0022-linux-x64/hardware/arduino/cores/arduino/wiring.c @@ -19,7 +19,7 @@ Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - $Id: wiring.c 808 2009-12-18 17:44:08Z dmellis $ + $Id$ */ #include "wiring_private.h" @@ -80,7 +80,14 @@ unsigned long micros() { 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)) @@ -97,10 +104,14 @@ unsigned long micros() { void delay(unsigned long ms) { - unsigned long start = millis(); - - while (millis() - start <= 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. */ @@ -162,23 +173,38 @@ void init() // 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(__AVR_ATmega8__) +#if defined(TCCR0A) && defined(WGM01) sbi(TCCR0A, WGM01); sbi(TCCR0A, WGM00); #endif + // set timer 0 prescale factor to 64 -#if defined(__AVR_ATmega8__) +#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); -#else +#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(__AVR_ATmega8__) +#if defined(TIMSK) && defined(TOIE0) sbi(TIMSK, TOIE0); -#else +#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 @@ -186,36 +212,60 @@ void init() // note, however, that fast pwm mode can achieve a frequency of up // 8 MHz (with a 16 MHz clock) at 50% duty cycle + TCCR1B = 0; + // set timer 1 prescale factor to 64 +#if defined(TCCR1B) && defined(CS11) && defined(CS10) sbi(TCCR1B, CS11); sbi(TCCR1B, CS10); +#elif defined(TCCR1) && defined(CS11) && defined(CS10) + sbi(TCCR1, CS11); + sbi(TCCR1, CS10); +#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(__AVR_ATmega8__) +#if defined(TCCR2) && defined(CS22) sbi(TCCR2, CS22); -#else +#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(__AVR_ATmega8__) +#if defined(TCCR2) && defined(WGM20) sbi(TCCR2, WGM20); -#else +#elif defined(TCCR2A) && defined(WGM20) sbi(TCCR2A, WGM20); +#else + #warning Timer 2 not finished (may not be present on this CPU) #endif -#if defined(__AVR_ATmega1280__) - // set timer 3, 4, 5 prescale factor to 64 - sbi(TCCR3B, CS31); sbi(TCCR3B, CS30); - sbi(TCCR4B, CS41); sbi(TCCR4B, CS40); - sbi(TCCR5B, CS51); sbi(TCCR5B, CS50); - // put timer 3, 4, 5 in 8-bit phase correct pwm mode - sbi(TCCR3A, WGM30); - sbi(TCCR4A, WGM40); - sbi(TCCR5A, WGM50); +#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(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 + +#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 @@ -226,13 +276,14 @@ void init() // 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(__AVR_ATmega8__) +#if defined(UCSRB) UCSRB = 0; -#else +#elif defined(UCSR0B) UCSR0B = 0; #endif -} \ No newline at end of file +} diff --git a/arduino-0018-linux-x64/hardware/arduino/cores/arduino/wiring.h b/arduino-0022-linux-x64/hardware/arduino/cores/arduino/wiring.h old mode 100755 new mode 100644 similarity index 89% rename from arduino-0018-linux-x64/hardware/arduino/cores/arduino/wiring.h rename to arduino-0022-linux-x64/hardware/arduino/cores/arduino/wiring.h index 8b42629..e29959b --- a/arduino-0018-linux-x64/hardware/arduino/cores/arduino/wiring.h +++ b/arduino-0022-linux-x64/hardware/arduino/cores/arduino/wiring.h @@ -19,13 +19,14 @@ Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - $Id: wiring.h 804 2009-12-18 16:05:52Z dmellis $ + $Id$ */ #ifndef Wiring_h #define Wiring_h #include +#include #include "binary.h" #ifdef __cplusplus @@ -57,7 +58,12 @@ extern "C"{ #define FALLING 2 #define RISING 3 +#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) +#define INTERNAL1V1 2 +#define INTERNAL2V56 3 +#else #define INTERNAL 3 +#endif #define DEFAULT 1 #define EXTERNAL 0 @@ -79,8 +85,8 @@ extern "C"{ #define noInterrupts() cli() #define clockCyclesPerMicrosecond() ( F_CPU / 1000000L ) -#define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() ) -#define microsecondsToClockCycles(a) ( (a) * clockCyclesPerMicrosecond() ) +#define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (F_CPU / 1000L) ) +#define microsecondsToClockCycles(a) ( ((a) * (F_CPU / 1000L)) / 1000L ) #define lowByte(w) ((uint8_t) ((w) & 0xff)) #define highByte(w) ((uint8_t) ((w) >> 8)) @@ -90,6 +96,7 @@ extern "C"{ #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)) @@ -106,19 +113,14 @@ int analogRead(uint8_t); void analogReference(uint8_t mode); void analogWrite(uint8_t, int); -void beginSerial(long); -void serialWrite(unsigned char); -int serialAvailable(void); -int serialRead(void); -void serialFlush(void); - 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, byte val); +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); diff --git a/arduino-0022-linux-x64/hardware/arduino/cores/arduino/wiring_analog.c b/arduino-0022-linux-x64/hardware/arduino/cores/arduino/wiring_analog.c new file mode 100644 index 0000000..d248f4c --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/cores/arduino/wiring_analog.c @@ -0,0 +1,259 @@ +/* + 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 +#else + if (pin >= 14) pin -= 14; // allow for channel or pin numbers +#endif + +#if defined(ADCSRB) && defined(MUX5) + // the MUX5 bit of ADCSRB selects whether we're reading from channels + // 0 to 7 (MUX5 low) or 8 to 15 (MUX5 high). + ADCSRB = (ADCSRB & ~(1 << MUX5)) | (((pin >> 3) & 0x01) << MUX5); +#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) && defined(COM4A1) + case TIMER4A: + // connect pwm to pin on timer 4, channel A + sbi(TCCR4A, COM4A1); + 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(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/arduino-0018-linux-x64/hardware/arduino/cores/arduino/wiring_digital.c b/arduino-0022-linux-x64/hardware/arduino/cores/arduino/wiring_digital.c old mode 100755 new mode 100644 similarity index 50% rename from arduino-0018-linux-x64/hardware/arduino/cores/arduino/wiring_digital.c rename to arduino-0022-linux-x64/hardware/arduino/cores/arduino/wiring_digital.c index 1cdbf6c..0949da4 --- a/arduino-0018-linux-x64/hardware/arduino/cores/arduino/wiring_digital.c +++ b/arduino-0022-linux-x64/hardware/arduino/cores/arduino/wiring_digital.c @@ -19,6 +19,8 @@ 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 $ */ @@ -36,8 +38,17 @@ void pinMode(uint8_t pin, uint8_t mode) // JWS: can I let the optimizer do this? reg = portModeRegister(port); - if (mode == INPUT) *reg &= ~bit; - else *reg |= bit; + if (mode == INPUT) { + uint8_t oldSREG = SREG; + cli(); + *reg &= ~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 @@ -47,32 +58,67 @@ void pinMode(uint8_t pin, uint8_t mode) // But shouldn't this be moved into pinMode? Seems silly to check and do on // each digitalread or write. // -static inline void turnOffPWM(uint8_t timer) __attribute__ ((always_inline)); -static inline void turnOffPWM(uint8_t timer) +// 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) { - if (timer == TIMER1A) cbi(TCCR1A, COM1A1); - if (timer == TIMER1B) cbi(TCCR1A, COM1B1); - -#if defined(__AVR_ATmega8__) - if (timer == TIMER2) cbi(TCCR2, COM21); -#else - if (timer == TIMER0A) cbi(TCCR0A, COM0A1); - if (timer == TIMER0B) cbi(TCCR0A, COM0B1); - if (timer == TIMER2A) cbi(TCCR2A, COM2A1); - if (timer == TIMER2B) cbi(TCCR2A, COM2B1); -#endif - -#if defined(__AVR_ATmega1280__) - if (timer == TIMER3A) cbi(TCCR3A, COM3A1); - if (timer == TIMER3B) cbi(TCCR3A, COM3B1); - if (timer == TIMER3C) cbi(TCCR3A, COM3C1); - if (timer == TIMER4A) cbi(TCCR4A, COM4A1); - if (timer == TIMER4B) cbi(TCCR4A, COM4B1); - if (timer == TIMER4C) cbi(TCCR4A, COM4C1); - if (timer == TIMER5A) cbi(TCCR5A, COM5A1); - if (timer == TIMER5B) cbi(TCCR5A, COM5B1); - if (timer == TIMER5C) cbi(TCCR5A, COM5C1); -#endif + 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(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) @@ -90,8 +136,17 @@ void digitalWrite(uint8_t pin, uint8_t val) out = portOutputRegister(port); - if (val == LOW) *out &= ~bit; - else *out |= bit; + if (val == LOW) { + uint8_t oldSREG = SREG; + cli(); + *out &= ~bit; + SREG = oldSREG; + } else { + uint8_t oldSREG = SREG; + cli(); + *out |= bit; + SREG = oldSREG; + } } int digitalRead(uint8_t pin) diff --git a/arduino-0018-linux-x64/hardware/arduino/cores/arduino/wiring_private.h b/arduino-0022-linux-x64/hardware/arduino/cores/arduino/wiring_private.h old mode 100755 new mode 100644 similarity index 96% rename from arduino-0018-linux-x64/hardware/arduino/cores/arduino/wiring_private.h rename to arduino-0022-linux-x64/hardware/arduino/cores/arduino/wiring_private.h index 2dfe552..11f6f00 --- a/arduino-0018-linux-x64/hardware/arduino/cores/arduino/wiring_private.h +++ b/arduino-0022-linux-x64/hardware/arduino/cores/arduino/wiring_private.h @@ -53,7 +53,7 @@ extern "C"{ #define EXTERNAL_INT_6 6 #define EXTERNAL_INT_7 7 -#if defined(__AVR_ATmega1280__) +#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) #define EXTERNAL_NUM_INTERRUPTS 8 #else #define EXTERNAL_NUM_INTERRUPTS 2 diff --git a/arduino-0018-linux-x64/hardware/arduino/cores/arduino/wiring_pulse.c b/arduino-0022-linux-x64/hardware/arduino/cores/arduino/wiring_pulse.c old mode 100755 new mode 100644 similarity index 91% rename from arduino-0018-linux-x64/hardware/arduino/cores/arduino/wiring_pulse.c rename to arduino-0022-linux-x64/hardware/arduino/cores/arduino/wiring_pulse.c index 8f232f1..0d96886 --- a/arduino-0018-linux-x64/hardware/arduino/cores/arduino/wiring_pulse.c +++ b/arduino-0022-linux-x64/hardware/arduino/cores/arduino/wiring_pulse.c @@ -55,12 +55,15 @@ unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout) return 0; // wait for the pulse to stop - while ((*portInputRegister(port) & bit) == stateMask) + while ((*portInputRegister(port) & bit) == stateMask) { + if (numloops++ == maxloops) + return 0; width++; + } // convert the reading to microseconds. The loop has been determined - // to be 10 clock cycles long and have about 16 clocks between the edge + // 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 * 10 + 16); + return clockCyclesToMicroseconds(width * 21 + 16); } diff --git a/arduino-0018-linux-x64/hardware/arduino/cores/arduino/wiring_shift.c b/arduino-0022-linux-x64/hardware/arduino/cores/arduino/wiring_shift.c old mode 100755 new mode 100644 similarity index 77% rename from arduino-0018-linux-x64/hardware/arduino/cores/arduino/wiring_shift.c rename to arduino-0022-linux-x64/hardware/arduino/cores/arduino/wiring_shift.c index 956f864..cfe7867 --- a/arduino-0018-linux-x64/hardware/arduino/cores/arduino/wiring_shift.c +++ b/arduino-0022-linux-x64/hardware/arduino/cores/arduino/wiring_shift.c @@ -24,9 +24,24 @@ #include "wiring_private.h" -void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, byte val) +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) { - int i; + uint8_t i; for (i = 0; i < 8; i++) { if (bitOrder == LSBFIRST) diff --git a/arduino-0022-linux-x64/hardware/arduino/firmwares/MEGA-dfu_and_usbserial_combined.hex b/arduino-0022-linux-x64/hardware/arduino/firmwares/MEGA-dfu_and_usbserial_combined.hex new file mode 100644 index 0000000..e22196c --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/firmwares/MEGA-dfu_and_usbserial_combined.hex @@ -0,0 +1,234 @@ +:20000000A2C00000BBC00000B9C00000B7C00000B5C00000B3C00000B1C00000AFC000004B +:20002000ADC00000ABC00000A9C000005AC400001EC40000A3C00000A1C000009FC000005C +:200040009DC000009BC0000099C0000097C0000095C0000093C0000091C0000014C100006A +:200060008DC000008BC0000089C0000087C0000085C0000083C0000081C000007FC0000050 +:200080007DC000007BC0000079C0000077C0000075C0000073C000001201100102000008E2 +:2000A0004123100001000102DC0109023E00020100C0320904000001020201000524000170 +:2000C00010042402060524060001070582030800FF09040100020A000000070504024000AC +:2000E0000107058302400001040309043203410072006400750069006E006F0020002800CA +:200100007700770077002E00610072006400750069006E006F002E0063006300290000003D +:200120002403410072006400750069006E006F0020004D00650067006100200032003500A5 +:2001400036003000000011241FBECFEFD2E0DEBFCDBF11E0A0E0B1E0E0EDFFE002C0059089 +:200160000D92A631B107D9F712E0A6E1B1E001C01D92AF32B107E1F7F1D028C741CF9C0139 +:20018000DC01AE57BF4FED91FC91119741911196FC93EE9380589F4FE817F90711F42D93A9 +:2001A0003C939FB7F894F901EC57FF4F8081815080839FBF842F0895DF92EF92FF920F935B +:2001C0001F93FC018489813019F0823021F405C040E3D42E04C0DD2402C030E2D32E838952 +:2001E000823011F488E0D82A8589873031F0883031F0863031F482E003C084E001C086E094 +:20020000D82A1092C9001092C8001092CA00E784F0880189128980E0E81681EEF80680E068 +:20022000080780E0180719F420E130E00FC0C801B701969587957795679560587B47814E2A +:200240009F4FA8019701A0D6215030403093CD002093CC00D092CA0080E0E81681EEF80612 +:2002600080E0080780E0180711F082E001C080E08093C80088E98093C9001F910F91FF9005 +:20028000EF90DF9008951F920F920FB60F9211242F938F939F93EF93FF939091CE008EB38C +:2002A0008430F1F4E0919901F0919A019083E0919901F0919A01CF01019690939A0180930C +:2002C00099018959914021F489E191E0928381839FB7F89480919D018F5F80939D019FBF3A +:2002E000FF91EF919F918F912F910F900FBE0F901F901895FC01858580FF02C05F9808959B +:200300005F9A089580E091E0D5C580E091E088C584B7877F84BF28E10FB6F89420936000CD +:20032000109260000FBE87E690E09093CD008093CC0086E08093CA001092C8002093C90019 +:20034000539A5A9A8AB180638AB98BB180638BB983D284E085BD5F9A579A08950F931F9322 +:20036000CF93DF93D5DF2FB7F8948EE991E090931F0280931E0290932102809320022FBFBB +:200380002FB7F89489E191E090939A018093990190939C0180939B012FBF7894CEE9D1E0D4 +:2003A00003E08FB7F894909122028FBF903809F180E091E0ABD497FD1CC0E0911E02F09161 +:2003C0001F028083E0911E02F0911F02CF01019690931F0280931E028E51924011F4D283DD +:2003E000C1839FB7F894809122028F5F809322029FBF8FB7F89410919D018FBFA89902C0BD +:20040000113678F1A89A80919D01882361F05D980093160108C089E191E0B1DE682F80E077 +:2004200091E0DAD411501123B1F780911601882351F0809116018150809316018091160101 +:20044000882309F45D9A80911701882351F08091170181508093170180911701882309F4F2 +:200460005C9A8FB7F894909122028FBF992369F08EE991E084DE982F8091C80085FFFCCFD3 +:200480009093CE005C980093170180E091E095D42AD487CFDA01923049F0933061F0913093 +:2004A000F9F4E8E9F0E022E130E01EC0EAEAF0E02EE330E019C0813049F0813018F08230CA +:2004C00079F408C0E8EEF0E0849107C0ECEEF0E0849103C0E0E2F1E08491282F30E004C010 +:2004E000E0E0F0E020E030E0ED93FC93C901089528E030E040E003C04F5F220F331F28177B +:200500003907D0F3842F8295807F08958093E9008091EB0081608093EB001092ED00609319 +:20052000EC004093ED008091EE00881F8827881F08951092F40090E09093E9001092F000D2 +:200540001092E8001092ED008091EB008E7F8093EB009F5F953081F70895809127028823BE +:200560008CF403C08EB38823B1F08091E80082FFF9CF8091E8008B778093E80008958EB395 +:20058000882349F08091E80080FFF9CF8091E8008E778093E800089594E68091EC0080FFAB +:2005A00005C08091E80080FF05C023C08091E80082FD1FC08EB3882311F482E008958EB3CE +:2005C000853011F483E008958091EB0085FF02C081E008958091E10082FFDFCF8091E1000E +:2005E0008B7F8093E100992311F484E008959150D4CF80E008959C0140912D0250912E020C +:200600004617570718F4F90120E038C06115710511F0AB01F8CF8091E8008E778093E800C8 +:2006200040E050E0F0CF8091E80083FF02C081E008958091E80082FD2DC08EB3882381F1AD +:200640008EB3853079F18091E80080FF17C09091F20006C081918093F100415050409F5FDD +:200660004115510511F09830A8F320E0983009F421E08091E8008E778093E80041155105FF +:2006800091F6222381F606C08EB3882349F08EB3853041F08091E80082FFF6CF80E00895C9 +:2006A00082E0089583E008959C0140912D0250912E024617570710F490E03BC06115710577 +:2006C00011F0AB01F9CF8091E8008E778093E80040E050E0F1CF8091E80083FF02C081E0FE +:2006E00008958091E80082FD30C08EB3882399F18EB3853091F18091E80080FF1AC08091A4 +:20070000F20009C0F9012F5F3F4FE491E093F100415050408F5F4115510511F0883090F338 +:2007200090E0883009F491E08091E8008E778093E8004115510579F6992369F606C08EB3ED +:20074000882349F08EB3853041F08091E80082FFF6CF80E0089582E0089583E008959C01B6 +:200760006115710529F48091E8008B778093E800F90120C08091E80083FF02C081E0089565 +:200780008EB3882339F18EB3853031F18091E80082FFF0CF06C08091F100819361507040B5 +:2007A00021F08091F2008823B1F78091E8008B778093E80061157105E9F606C08EB388235F +:2007C00049F08EB3853041F08091E80080FFF6CF80E0089582E0089583E0089542D044D05A +:2007E0001EBA10922502109224021092230284E089BD89B5826089BD09B400FEFDCF809121 +:20080000D800982F9F779093D80080688093D800809163008E7F809363008091D8008F7D69 +:200820008093D8008091E0008E7F8093E0008091E1008E7F8093E1008091E2008160809302 +:20084000E2008091E100877F8093E1008091E20088608093E2000895C1DF81E08093260221 +:2008600008951092E20008951092E10008951F920F920FB60F9211241F932F933F934F9385 +:200880005F936F937F938F939F93AF93BF93EF93FF93E9EEF0E0108117701082E0EFF0E066 +:2008A0008081877F80837894C3D0F894A9EEB0E01C92E0EFF0E08081886080831C93FF9164 +:2008C000EF91BF91AF919F918F917F916F915F914F913F912F911F910F900FBE0F901F90DE +:2008E00018951F920F920FB60F9211242F933F934F935F936F937F938F939F93AF93BF93FA +:20090000EF93FF938091E10080FF1BC08091E20080FF17C08091E1008E7F8093E10080912A +:20092000E2008E7F8093E2008091E20080618093E2008091D80080628093D80019BC1EBAA7 +:20094000D1D18091E10084FF29C08091E20084FF25C084E089BD89B5826089BD09B400FE71 +:20096000FDCF8091D8008F7D8093D8008091E1008F7E8093E1008091E2008F7E8093E200E3 +:200980008091E20081608093E20080912502882311F481E001C084E08EBBA4D18091E10070 +:2009A00083FF27C08091E20083FF23C08091E100877F8093E10082E08EBB10922502809105 +:2009C000E1008E7F8093E1008091E2008E7F8093E2008091E20080618093E200AADD80E090 +:2009E00060E042E093DD8091F00088608093F00079D18091E10082FF0AC08091E20082FF3E +:200A000006C08091E1008B7F8093E1006BD1FF91EF91BF91AF919F918F917F916F915F91F4 +:200A20004F913F912F910F900FBE0F901F9018951F93DF93CF93CDB7DEB7AC970FB6F894AC +:200A4000DEBF0FBECDBFE7E2F2E08091F100819322E0EF32F207C9F78091270230912802EE +:200A6000353009F487C0363040F43130C9F1313070F0333009F01DC133C0383009F4EFC016 +:200A8000393009F4FEC0363009F013C192C0803821F0823809F00DC108C090912302809144 +:200AA0002402882399F0926011C080912B0287708093E9008091EB0090E025E09695879530 +:200AC0002A95E1F7982F91701092E9008091E800877F8093E8009093F1001092F100CAC001 +:200AE000882319F0823009F0E4C090E08F719070009721F0029709F0DDC00CC080912902A4 +:200B0000813009F0D7C010922402333069F5809324022AC080912902882331F520912B02FD +:200B2000277009F4C7C02093E9008091EB0080FFC1C0333021F48091EB00806213C08091C8 +:200B4000EB0080618093EB0081E090E002C0880F991F2A95E2F78093EA001092EA008091B7 +:200B6000EB0088608093EB001092E9008091E800877F83C0882309F09CC0109129028091FA +:200B8000E800877F8093E800E8DC04C08EB3882309F490C08091E80080FFF8CF812F8F77B6 +:200BA00011F492E001C093E09EBB80688093E30081C08058823008F07CC0809129029091F7 +:200BC0002A0223E08C3D920799F55FB7F894DE0115964EE020E030E061E2E42FF0E0609373 +:200BE0005700849120FF03C082958F704F5F982F9F70892F805D8A3308F0895F8C93119615 +:200C00001C9211972F5F3F4F12962431310529F75FBF8AE28B8383E08C838091E800877F06 +:200C20008093E800CE0103966AE270E0E4DC11C060912B02AE014F5F5F4F2CDCBC0100979F +:200C4000C9F18091E800877F8093E80089819A812BDD8091E8008B778093E8002BC080381A +:200C600041F58091E800877F8093E800809125028093F1008091E8008E778093E8006DDCC6 +:200C800019C08823B1F490912902923098F48091E800877F8093E800909325025EDC809102 +:200CA0002502882311F483E001C084E08EBB2DDB01C028DB8091E80083FF0AC08091EB007F +:200CC00080628093EB008091E800877F8093E800AC960FB6F894DEBF0FBECDBFCF91DF91E1 +:200CE0001F91089508951F938EB3882361F01091E9001092E9008091E80083FF01C098DE54 +:200D000017701093E9001F9108950895FC018EB3843021F587859089A189B2890097A10507 +:200D2000B105E1F085818093E9008091E80082FF15C08091F200882319F42FEF3FEF04C010 +:200D40008091F100282F30E08091F200882341F48091E8008B778093E80002C02FEF3FEF43 +:200D6000C9010895FC018EB3843011F587859089A189B2890097A105B105D1F081818093C1 +:200D8000E9008091F2008823A9F09091E8008091E8008E778093E80095FD0CC0FDDB982F24 +:200DA000882349F48091E8008E778093E80003C092E001C090E0892F0895FC018EB38430A5 +:200DC00051F487859089A189B2890097A105B10511F0CF01C7CF08951F93FC01162F8EB318 +:200DE0008430D9F487859089A189B2890097A105B10599F081818093E9008091E80085FDF3 +:200E000008C08091E8008E778093E800C5DB882329F41093F10080E001C082E01F91089545 +:200E20000F931F93CF93DF93EC010D96FC0189E0DF011D928A95E9F72A813B8109818C8108 +:200E4000882311F410E001C014E0C90151DB182B1260802F61E8412F59DB882329F12E8182 +:200E60003F810D818885882311F410E001C014E0C9013EDB182B1260802F60E8412F46DBA2 +:200E8000882391F02A853B8509858C85882311F410E001C014E0C9012BDB182B1260802F8F +:200EA00061EC412F33DB01C080E0DF91CF911F910F910895CF93DF93EC018091E80083FF4D +:200EC00060C0888190E020912B0230912C022817390709F056C080912802813261F082322B +:200EE00020F4803209F04DC019C0823269F1833209F047C038C080912702813A09F041C0A3 +:200F00008091E800877F8093E800CE010F9667E070E071DB8091E8008B7713C08091270278 +:200F2000813279F58091E800877F8093E800CE010F9667E070E013DCCE013ED98091E800BD +:200F40008E778093E8001DC0809127028132C9F48091E800877F8093E800809129028D87C0 +:200F6000CE01C8D90DC080912702813251F48091E800877F8093E800CE0160912902C5DE7A +:200F8000ECDADF91CF910895A1E21A2EAA1BBB1BFD010DC0AA1FBB1FEE1FFF1FA217B307AC +:200FA000E407F50720F0A21BB30BE40BF50B661F771F881F991F1A9469F760957095809539 +:200FC00090959B01AC01BD01CF010895F894FFCF000340000004400000020800000000008D +:200FE000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0B +:201000004BC0000064C0000062C0000060C000005EC000005CC000005AC0000058C00000F3 +:2010200056C0000054C0000052C00000CBC400004EC000004CC000004AC0000048C00000B9 +:2010400046C0000044C0000042C0000040C000003EC000003CC000003AC0000038C0000098 +:2010600036C0000034C0000032C0000030C000002EC000002CC000002AC0000028C00000F8 +:2010800026C0000024C0000022C0000020C000001EC000001CC0000011241FBECFEFD2E088 +:2010A000DEBFCDBF11E0A0E0B1E0E4EBFCE102C005900D92A836B107D9F711E0A8E6B1E0ED +:2010C00001C01D92A738B107E1F74FD3F1C598CF982F15C08091F200882371F48091E8004A +:2010E0008B7F8093E80003C08EB3882351F08091E80082FFF9CF02C08091F1009150992358 +:2011000049F708952091760130917501809174019091730180936D0190936E01C901809388 +:201120006F0190937001089580917101843009F45AC0853030F4813059F0833009F0C3C0BE +:201140001FC0853009F4A0C0863009F0BCC0AFC080917201823008F0B6C0D4DF8091720129 +:20116000882361F480916D0190916E0123E0FC0120935700E89507B600FCFDCF85E008C027 +:2011800080917201882311F0823029F4BBDF89E0809301010895813009F095C020E030E08C +:2011A00040E050E0F90184918F3F81F0CA01AA27BB2780936C0130936E0120936D018AE0D6 +:2011C0008093010185E08093690108952F5F3F4F4F4F5F4F2030F0E13F07F0E04F07F0E0B6 +:2011E0005F0701F7089580917201833051F581E0809368018091770190917801892B71F062 +:2012000080917301813009F05EC0809176019091750190936B0180936A0108958091730133 +:20122000882361F42CE088E190E00FB6F894A895809360000FBE20936000089510920001A8 +:201240000895882309F03FC0809173018F3F09F03AC0E0E0F0E093E085E090935700E895A9 +:2012600007B600FCFDCF80935700E89507B600FCFDCFE058FF4F20E1E030F20771F781E123 +:2012800080935700E8950895E091730180917201882321F4F0E0EB5FFE4F05C0813099F437 +:2012A000F0E0EE52FF4F808180937C01089580917201833041F480917301882321F48091E0 +:2012C000740180936C0108952F923F924F925F926F927F929F92AF92BF92CF92DF92EF92F0 +:2012E000FF920F931F93CF93DF938091850190918601909378018093770180917901882399 +:2013000051F08091790181508093790180917901882309F45D9A80917A01882351F08091F0 +:201320007A01815080937A0180917A01882309F45C9A80918001833009F4B2C1843030F41C +:20134000813071F0823009F0E3C111C1853009F4C5C1853008F4BAC1863009F0D9C1CDC11F +:201360005C9883E080937A018091E800877F8093E80080916801882329F0D6DE5D9A5C9AAF +:201380001092680120917701309178012115310529F42AC08EB3882309F4BAC18091E8000F +:2013A00082FFF8CF8091F10080937101215030403093780120937701E2E7F1E00CC080919F +:2013C000F10081932150304081E0E737F80719F43183208308C08091F200882381F7309394 +:2013E000780120937701A0DE80910101853009F0BAC08091770190917801892B21F482E042 +:2014000080930101B0C08AE163DE80916D018F715FDEC0916F01D091700120916D0130916C +:201420006E0121968E01021B130B219780917201882309F093C0180136942794C901A091F0 +:201440006C01B0E09C01AD0162E0E62EF12C012D112DE20EF31E041F151F59016A0190E0D8 +:2014600099249394B5E0A3E048C08091F200882371F48091E8008B7F8093E80004C08EB352 +:20148000882309F445C18091E80082FFF8CF0894210831088091F100682F8091F100782F1D +:2014A000F5010B0190925700E89511249F5F903419F021143104A1F4F901B0935700E89524 +:2014C00007B600FCFDCF2114310451F0F701A0935700E89507B600FCFDCFA801970190E0A7 +:2014E00042E0442E512C612C712CE40CF51C061D171DA40CB51CC61CD71C2114310409F0A0 +:20150000B4CFD0936E01C0936D0181E180935700E89527C08091F200882371F48091E80079 +:201520008B7F8093E80004C08EB3882309F4F0C08091E80082FFF8CF6091F10080916D01A7 +:2015400090916E01A7D380916D0190916E01019690936E0180936D010150104001151105FB +:20156000C9F680E1B5DD8091E8008B7FC3C08091E800877F8093E8005D9883E08093790154 +:2015800004C08EB3882309F4C3C08091E80080FFF8CF80910101893091F08A3069F4809167 +:2015A0007201813049F480916D0190916E018093F1009093F1009BC080917C0196C0609173 +:2015C0006F017091700120916D0130916E016F5F7F4F7B01E21AF30A6150704080917201E4 +:2015E000882389F5870116950795C901A0916C01B0E09C01AD011FC08091F200803271F4B7 +:201600008091E8008E7F8093E80004C08EB3882309F47EC08091E80080FFF8CFF90185918F +:2016200094918093F1009093F100015010402E5F3F4F4F4F5F4F01151105F1F670936E01E0 +:2016400060936D0129C0823039F523C08091F200803271F48091E8008E7F8093E80004C09E +:201660008EB3882309F454C08091E80080FFF8CF00916D0110916E01C80104D38093F1007B +:201680000F5F1F4F10936E0100936D010894E108F108E114F104D1F682E08093010127C0CE +:2016A0008091E800877F8093E800809169018093F1001092F1001092F1001092F1008091E7 +:2016C00001018093F1001092F10011C08091E800877F8093E8001092690119C08091E800C8 +:2016E000877F8093E800809101018093F1008091E8008E7F8093E8000AC08091E800877F08 +:201700008093E8005D9A5C9A82E08093010187D0DF91CF911F910F91FF90EF90DF90CF9017 +:20172000BF90AF909F907F906F905F904F903F902F9008952BD181E085BF15BE089584B799 +:20174000877F84BF88E10FB6F89480936000109260000FBE81E085BF82E085BF8AB18063DB +:201760008AB98BB180638BB90CC1E9DF789401C080D2809100018823D9F78091680188235D +:20178000B9F7D8DFE0916A01F0916B010995FA01923071F0933089F0913029F488E091E06A +:2017A00022E130E019C080E090E020E030E014C08AE191E02BE130E00FC0882339F48091D9 +:2017C0003501282F30E085E391E006C080913901282F30E089E391E091838083C9010895C0 +:2017E0008091EB0081608093EB001092ED006093EC004093ED008091EE00881F8827881FE4 +:2018000008951092F4001092F0001092E8001092ED00EBEEF0E080818E7F80830895809182 +:201820007F0188238CF403C08EB38823B1F08091E80082FFF9CF8091E8008B7F8093E8006D +:2018400008958EB3882349F08091E80080FFF9CF8091E8008E7F8093E80008959C0140917A +:201860008501509186014617570718F4F90120E038C06115710511F0AB01F8CF8091E80068 +:201880008E7F8093E80040E050E0F0CF8091E80083FF02C081E008958091E80082FD2DC091 +:2018A0008EB3882381F18EB3853079F18091E80080FF17C09091F20006C081918093F1002C +:2018C000415050409F5F4115510511F09032A8F320E0903209F421E08091E8008E7F809306 +:2018E000E8004115510591F6222381F606C08EB3882349F08EB3853041F08091E80082FF85 +:20190000F6CF80E0089582E0089583E0089554D056D01EBA10927D0184E089BD89B58260FA +:2019200089BD09B400FEFDCF8091D800982F9F779093D80080688093D800809163008E7FC5 +:20194000809363008091D8008F7D8093D8008091E0008E7F8093E0008091E1008E7F80932E +:20196000E1008091E20081608093E2008091E100877F8093E1008091E20088608093E20001 +:201980000895C5DF81E080937E010895C0DFE0EEF0E0808181608083E8EDF0E080818F77A8 +:2019A00080830AD00CD019BCE3E6F0E080818160808310927E0108951092E200089510929A +:2019C000E10008951F920F920FB60F9211242F933F934F935F936F937F938F939F93AF938A +:2019E000BF93EF93FF938091E10080FF1BC08091E20080FF17C08091E1008E7F8093E100F9 +:201A00008091E2008E7F8093E2008091E20080618093E2008091D80080628093D80019BC7D +:201A20001EBA26D18091E10084FF29C08091E20084FF25C084E089BD89B5826089BD09B451 +:201A400000FEFDCF8091D8008F7D8093D8008091E1008F7E8093E1008091E2008F7E8093D6 +:201A6000E2008091E20081608093E20080917D01882311F481E001C084E08EBBF9D08091D3 +:201A8000E10083FF22C08091E20083FF1EC08091E100877F8093E10082E08EBB10927D01F7 +:201AA0008091E1008E7F8093E1008091E2008E7F8093E2008091E20080618093E200A1DEF6 +:201AC00080E060E042E28CDED3D08091E10082FF0AC08091E20082FF06C08091E1008B7FC2 +:201AE0008093E100C5D0FF91EF91BF91AF919F918F917F916F915F914F913F912F910F905E +:201B00000FBE0F901F9018951F93DF93CF9300D0CDB7DEB7EFE7F1E08091F100819381E070 +:201B2000E738F807C9F790917F0180918001853011F1863040F48130B9F0813070F08330D5 +:201B400009F081C011C0883009F453C0893009F462C0863009F077C02DC0903809F474C00E +:201B6000923809F070C070C0992309F46DC0923009F069C069C0992309F065C01091810152 +:201B80008091E800877F8093E80049DE04C08EB3882309F459C08091E80080FFF8CF812F6F +:201BA0008F7711F492E001C093E09EBB80688093E3004AC09058923008F045C080918101F9 +:201BC0009091820160918301AE014F5F5F4FDFDDBC010097C9F18091E800877F8093E8001D +:201BE00089819A813BDE8091E8008B7F8093E8002BC0903841F58091E800877F8093E800C6 +:201C000080917D018093F1008091E8008E7F8093E80005DE19C09923B1F4909181019230AE +:201C200098F48091E800877F8093E80090937D01F6DD80917D01882311F483E001C084E0E3 +:201C40008EBB16D001C040DB8091E80083FF0AC08091EB0080628093EB008091E800877F59 +:201C60008093E8000F900F90CF91DF911F91089508958EB3882329F08091E80083FF01C030 +:201C800043CF0895F999FECF92BD81BDF89A992780B50895262FF999FECF1FBA92BD81BD6B +:201CA00020BD0FB6F894FA9AF99A0FBE01960895F894FFCF01021E938220DCFB1201100123 +:201CC00000000020EB03F72F00000001000109021B0001010080320904000000FE010200E6 +:201CE0000921030000000C0001040309042C03410072006400750069006E006F0020004D28 +:1C1D000000650067006100200032003500360030002000440046005500000000AE +:00000001FF diff --git a/arduino-0022-linux-x64/hardware/arduino/firmwares/README.txt b/arduino-0022-linux-x64/hardware/arduino/firmwares/README.txt new file mode 100644 index 0000000..386dcf0 --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/firmwares/README.txt @@ -0,0 +1,33 @@ +Arduino Uno and Mega 2560 Firmwares for the ATmega8U2 + +This directory contains the firmwares used on the ATmega8U2 on the Arduino +Uno and Arduino Mega 2560. The arduino-usbdfu directory contains the DFU +bootloader on the 8U2; the arduino-usbserial directory contains the actual +usb to serial firmware. Both should be compiled against LUFA 100807. The +two .hex files in this directory combine the dfu and serial firmwares into +a single file to burn onto the 8U2. + +To burn (Uno): +avrdude -p at90usb82 -F -P usb -c avrispmkii -U flash:w:UNO-dfu_and_usbserial_combined.hex -U lfuse:w:0xFF:m -U hfuse:w:0xD9:m -U efuse:w:0xF4:m -U lock:w:0x0F:m + +To burn (Mega 2560): +avrdude -p at90usb82 -F -P usb -c avrispmkii -U flash:w:MEGA-dfu_and_usbserial_combined.hex -U lfuse:w:0xFF:m -U hfuse:w:0xD9:m -U efuse:w:0xF4:m -U lock:w:0x0F:m + + +Note on USB Vendor IDs (VID) and Product IDs (PID): The arduino-usbdfu +project uses Atmel's VID and MCU-specific PIDs to maintain compatibility +with their FLIP software. The source code to the arduino-usbserial +project includes Atmel's VID and a PID donated by them to LUFA. This +PID is used in LUFA's USBtoSerial project, which forms the basis for +arduino-usbserial. According to the LUFA documentation, this VID/PID +combination is: + + "For use in testing of LUFA powered devices during development only, + by non-commercial entities. All devices must accept collisions on this + VID/PID range (from other in-development LUFA devices) to be resolved + by using a unique release number in the Device Descriptor. No devices + using this VID/PID combination may be released to the general public." + +The production version of the arduino-usbserial firmware uses the +Arduino VID. This is only for use with official Arduino hardware and +should not be used on other products. \ No newline at end of file diff --git a/arduino-0022-linux-x64/hardware/arduino/firmwares/UNO-dfu_and_usbserial_combined.hex b/arduino-0022-linux-x64/hardware/arduino/firmwares/UNO-dfu_and_usbserial_combined.hex new file mode 100644 index 0000000..60acf44 --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/firmwares/UNO-dfu_and_usbserial_combined.hex @@ -0,0 +1,234 @@ +:200000009CC00000B5C00000B3C00000B1C00000AFC00000ADC00000ABC00000A9C000007B +:20002000A7C00000A5C00000A3C0000054C4000018C400009DC000009BC0000099C000008C +:2000400097C0000095C0000093C0000091C000008FC000008DC000008BC000000EC100009A +:2000600087C0000085C0000083C0000081C000007FC000007DC000007BC0000079C0000080 +:2000800077C0000075C0000073C0000071C000006FC000006DC00000120110010200000806 +:2000A0004123010001000102DC0109023E00020100C032090400000102020100052400017F +:2000C00010042402060524060001070582030800FF09040100020A000000070504024000AC +:2000E0000107058302400001040309043203410072006400750069006E006F0020002800CA +:200100007700770077002E00610072006400750069006E006F002E0063006300290000003D +:200120001803410072006400750069006E006F00200055006E006F00000011241FBECFEFB0 +:20014000D2E0DEBFCDBF11E0A0E0B1E0E4ECFFE002C005900D92A631B107D9F712E0A6E145 +:20016000B1E001C01D92AF32B107E1F7F1D028C747CF9C01DC01AE57BF4FED91FC91119707 +:2001800041911196FC93EE9380589F4FE817F90711F42D933C939FB7F894F901EC57FF4F10 +:2001A0008081815080839FBF842F0895DF92EF92FF920F931F93FC018489813019F082306F +:2001C00021F405C040E3D42E04C0DD2402C030E2D32E8389823011F488E0D82A8589873094 +:2001E00031F0883031F0863031F482E003C084E001C086E0D82A1092C9001092C800109201 +:20020000CA00E784F0880189128980E0E81681EEF80680E0080780E0180719F420E130E035 +:200220000FC0C801B701969587957795679560587B47814E9F4FA8019701A0D62150304050 +:200240003093CD002093CC00D092CA0080E0E81681EEF80680E0080780E0180711F082E047 +:2002600001C080E08093C80088E98093C9001F910F91FF90EF90DF9008951F920F920FB6B4 +:200280000F9211242F938F939F93EF93FF939091CE008EB38430F1F4E0919901F0919A016E +:2002A0009083E0919901F0919A01CF01019690939A01809399018959914021F489E191E08F +:2002C000928381839FB7F89480919D018F5F80939D019FBFFF91EF919F918F912F910F90B8 +:2002E0000FBE0F901F901895FC01858580FF02C05F9808955F9A089580E091E0D5C580E0F9 +:2003000091E088C584B7877F84BF28E10FB6F89420936000109260000FBE87E690E090935F +:20032000CD008093CC0086E08093CA001092C8002093C900539A5A9A8AB180638AB98BB16A +:2003400080638BB983D284E085BD5F9A579A08950F931F93CF93DF93D5DF2FB7F8948EE92F +:2003600091E090931F0280931E0290932102809320022FBF2FB7F89489E191E090939A0121 +:200380008093990190939C0180939B012FBF7894CEE9D1E003E08FB7F894909122028FBF97 +:2003A000903809F180E091E0ABD497FD1CC0E0911E02F0911F028083E0911E02F0911F0252 +:2003C000CF01019690931F0280931E028E51924011F4D283C1839FB7F894809122028F5FEB +:2003E000809322029FBF8FB7F89410919D018FBFA89902C0113678F1A89A80919D018823BA +:2004000061F05D980093160108C089E191E0B1DE682F80E091E0DAD411501123B1F7809156 +:200420001601882351F08091160181508093160180911601882309F45D9A809117018823FB +:2004400051F08091170181508093170180911701882309F45C9A8FB7F894909122028FBF0A +:20046000992369F08EE991E084DE982F8091C80085FFFCCF9093CE005C980093170180E03E +:2004800091E095D42AD487CFDA01923049F0933061F09130F9F4E8E9F0E022E130E01EC004 +:2004A000EAEAF0E02EE330E019C0813049F0813018F0823079F408C0E8EEF0E0849107C092 +:2004C000ECEEF0E0849103C0E0E2F1E08491282F30E004C0E0E0F0E020E030E0ED93FC9318 +:2004E000C901089528E030E040E003C04F5F220F331F28173907D0F3842F8295807F0895C1 +:200500008093E9008091EB0081608093EB001092ED006093EC004093ED008091EE00881F30 +:200520008827881F08951092F40090E09093E9001092F0001092E8001092ED008091EB000F +:200540008E7F8093EB009F5F953081F708958091270288238CF403C08EB38823B1F08091F2 +:20056000E80082FFF9CF8091E8008B778093E80008958EB3882349F08091E80080FFF9CF52 +:200580008091E8008E778093E800089594E68091EC0080FF05C08091E80080FF05C023C0EA +:2005A0008091E80082FD1FC08EB3882311F482E008958EB3853011F483E008958091EB00FD +:2005C00085FF02C081E008958091E10082FFDFCF8091E1008B7F8093E100992311F484E0A1 +:2005E00008959150D4CF80E008959C0140912D0250912E024617570718F4F90120E038C076 +:200600006115710511F0AB01F8CF8091E8008E778093E80040E050E0F0CF8091E80083FFF7 +:2006200002C081E008958091E80082FD2DC08EB3882381F18EB3853079F18091E80080FF5F +:2006400017C09091F20006C081918093F100415050409F5F4115510511F09830A8F320E0A5 +:20066000983009F421E08091E8008E778093E8004115510591F6222381F606C08EB388231A +:2006800049F08EB3853041F08091E80082FFF6CF80E0089582E0089583E008959C01409151 +:2006A0002D0250912E024617570710F490E03BC06115710511F0AB01F9CF8091E8008E7771 +:2006C0008093E80040E050E0F1CF8091E80083FF02C081E008958091E80082FD30C08EB32B +:2006E000882399F18EB3853091F18091E80080FF1AC08091F20009C0F9012F5F3F4FE491A4 +:20070000E093F100415050408F5F4115510511F0883090F390E0883009F491E08091E800EF +:200720008E778093E8004115510579F6992369F606C08EB3882349F08EB3853041F0809160 +:20074000E80082FFF6CF80E0089582E0089583E008959C016115710529F48091E8008B77CE +:200760008093E800F90120C08091E80083FF02C081E008958EB3882339F18EB3853031F13B +:200780008091E80082FFF0CF06C08091F10081936150704021F08091F2008823B1F780916B +:2007A000E8008B778093E80061157105E9F606C08EB3882349F08EB3853041F08091E8007E +:2007C00080FFF6CF80E0089582E0089583E0089542D044D01EBA10922502109224021092A8 +:2007E000230284E089BD89B5826089BD09B400FEFDCF8091D800982F9F779093D800806894 +:200800008093D800809163008E7F809363008091D8008F7D8093D8008091E0008E7F809305 +:20082000E0008091E1008E7F8093E1008091E20081608093E2008091E100877F8093E10030 +:200840008091E20088608093E2000895C1DF81E08093260208951092E20008951092E100AE +:2008600008951F920F920FB60F9211241F932F933F934F935F936F937F938F939F93AF932A +:20088000BF93EF93FF93E9EEF0E0108117701082E0EFF0E08081877F80837894C3D0F894CD +:2008A000A9EEB0E01C92E0EFF0E08081886080831C93FF91EF91BF91AF919F918F917F9129 +:2008C0006F915F914F913F912F911F910F900FBE0F901F9018951F920F920FB60F921124B4 +:2008E0002F933F934F935F936F937F938F939F93AF93BF93EF93FF938091E10080FF1BC034 +:200900008091E20080FF17C08091E1008E7F8093E1008091E2008E7F8093E2008091E200B3 +:2009200080618093E2008091D80080628093D80019BC1EBAD1D18091E10084FF29C080916D +:20094000E20084FF25C084E089BD89B5826089BD09B400FEFDCF8091D8008F7D8093D800D6 +:200960008091E1008F7E8093E1008091E2008F7E8093E2008091E20081608093E2008091B5 +:200980002502882311F481E001C084E08EBBA4D18091E10083FF27C08091E20083FF23C089 +:2009A0008091E100877F8093E10082E08EBB109225028091E1008E7F8093E1008091E200F1 +:2009C0008E7F8093E2008091E20080618093E200AADD80E060E042E093DD8091F0008860AA +:2009E0008093F00079D18091E10082FF0AC08091E20082FF06C08091E1008B7F8093E10043 +:200A00006BD1FF91EF91BF91AF919F918F917F916F915F914F913F912F910F900FBE0F902F +:200A20001F9018951F93DF93CF93CDB7DEB7AC970FB6F894DEBF0FBECDBFE7E2F2E0809185 +:200A4000F100819322E0EF32F207C9F78091270230912802353009F487C0363040F43130EC +:200A6000C9F1313070F0333009F01DC133C0383009F4EFC0393009F4FEC0363009F013C163 +:200A800092C0803821F0823809F00DC108C09091230280912402882399F0926011C080916D +:200AA0002B0287708093E9008091EB0090E025E0969587952A95E1F7982F91701092E90074 +:200AC0008091E800877F8093E8009093F1001092F100CAC0882319F0823009F0E4C090E078 +:200AE0008F719070009721F0029709F0DDC00CC080912902813009F0D7C0109224023330AB +:200B000069F5809324022AC080912902882331F520912B02277009F4C7C02093E9008091A1 +:200B2000EB0080FFC1C0333021F48091EB00806213C08091EB0080618093EB0081E090E0F5 +:200B400002C0880F991F2A95E2F78093EA001092EA008091EB0088608093EB001092E900F6 +:200B60008091E800877F83C0882309F09CC0109129028091E800877F8093E800E8DC04C0E5 +:200B80008EB3882309F490C08091E80080FFF8CF812F8F7711F492E001C093E09EBB80683B +:200BA0008093E30081C08058823008F07CC08091290290912A0223E08C3D920799F55FB7AE +:200BC000F894DE0115964EE020E030E061E2E42FF0E060935700849120FF03C082958F7044 +:200BE0004F5F982F9F70892F805D8A3308F0895F8C9311961C9211972F5F3F4F129624310A +:200C0000310529F75FBF8AE28B8383E08C838091E800877F8093E800CE0103966AE270E076 +:200C2000E4DC11C060912B02AE014F5F5F4F2CDCBC010097C9F18091E800877F8093E800EA +:200C400089819A812BDD8091E8008B778093E8002BC0803841F58091E800877F8093E8009E +:200C6000809125028093F1008091E8008E778093E8006DDC19C08823B1F4909129029230BF +:200C800098F48091E800877F8093E800909325025EDC80912502882311F483E001C084E0DA +:200CA0008EBB2DDB01C028DB8091E80083FF0AC08091EB0080628093EB008091E800877FFF +:200CC0008093E800AC960FB6F894DEBF0FBECDBFCF91DF911F91089508951F938EB3882338 +:200CE00061F01091E9001092E9008091E80083FF01C098DE17701093E9001F9108950895DF +:200D0000FC018EB3843021F587859089A189B2890097A105B105E1F085818093E90080916A +:200D2000E80082FF15C08091F200882319F42FEF3FEF04C08091F100282F30E08091F2003E +:200D4000882341F48091E8008B778093E80002C02FEF3FEFC9010895FC018EB3843011F550 +:200D600087859089A189B2890097A105B105D1F081818093E9008091F2008823A9F09091CF +:200D8000E8008091E8008E778093E80095FD0CC0FDDB982F882349F48091E8008E7780937C +:200DA000E80003C092E001C090E0892F0895FC018EB3843051F487859089A189B289009738 +:200DC000A105B10511F0CF01C7CF08951F93FC01162F8EB38430D9F487859089A189B28973 +:200DE0000097A105B10599F081818093E9008091E80085FD08C08091E8008E778093E8003D +:200E0000C5DB882329F41093F10080E001C082E01F9108950F931F93CF93DF93EC010D964E +:200E2000FC0189E0DF011D928A95E9F72A813B8109818C81882311F410E001C014E0C901A1 +:200E400051DB182B1260802F61E8412F59DB882329F12E813F810D818885882311F410E0A6 +:200E600001C014E0C9013EDB182B1260802F60E8412F46DB882391F02A853B8509858C8563 +:200E8000882311F410E001C014E0C9012BDB182B1260802F61EC412F33DB01C080E0DF916D +:200EA000CF911F910F910895CF93DF93EC018091E80083FF60C0888190E020912B02309171 +:200EC0002C022817390709F056C080912802813261F0823220F4803209F04DC019C082320A +:200EE00069F1833209F047C038C080912702813A09F041C08091E800877F8093E800CE0133 +:200F00000F9667E070E071DB8091E8008B7713C080912702813279F58091E800877F80930E +:200F2000E800CE010F9667E070E013DCCE013ED98091E8008E778093E8001DC080912702D9 +:200F40008132C9F48091E800877F8093E800809129028D87CE01C8D90DC0809127028132AD +:200F600051F48091E800877F8093E800CE0160912902C5DEECDADF91CF910895A1E21A2EA6 +:200F8000AA1BBB1BFD010DC0AA1FBB1FEE1FFF1FA217B307E407F50720F0A21BB30BE40B49 +:200FA000F50B661F771F881F991F1A9469F760957095809590959B01AC01BD01CF01089501 +:200FC000F894FFCF00034000000440000002080000000000000000000000FFFFFFFFFFFF2C +:200FE000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF11 +:201000004BC0000064C0000062C0000060C000005EC000005CC000005AC0000058C00000F3 +:2010200056C0000054C0000052C00000CBC400004EC000004CC000004AC0000048C00000B9 +:2010400046C0000044C0000042C0000040C000003EC000003CC000003AC0000038C0000098 +:2010600036C0000034C0000032C0000030C000002EC000002CC000002AC0000028C00000F8 +:2010800026C0000024C0000022C0000020C000001EC000001CC0000011241FBECFEFD2E088 +:2010A000DEBFCDBF11E0A0E0B1E0E4EBFCE102C005900D92AC35B107D9F711E0ACE5B1E0E7 +:2010C00001C01D92AB37B107E1F74FD3F1C598CF982F15C08091F200882371F48091E80047 +:2010E0008B7F8093E80003C08EB3882351F08091E80082FFF9CF02C08091F1009150992358 +:2011000049F7089520916A013091690180916801909167018093610190936201C9018093D0 +:20112000630190936401089580916501843009F45AC0853030F4813059F0833009F0C3C0E2 +:201140001FC0853009F4A0C0863009F0BCC0AFC080916601823008F0B6C0D4DF8091660141 +:20116000882361F4809161019091620123E0FC0120935700E89507B600FCFDCF85E008C03F +:2011800080916601882311F0823029F4BBDF89E0809301010895813009F095C020E030E098 +:2011A00040E050E0F90184918F3F81F0CA01AA27BB278093600130936201209361018AE0FA +:2011C0008093010185E080935D0108952F5F3F4F4F4F5F4F2030F0E13F07F0E04F07F0E0C2 +:2011E0005F0701F7089580916601833051F581E080935C0180916B0190916C01892B71F092 +:2012000080916701813009F05EC080916A019091690190935F0180935E010895809167017B +:20122000882361F42CE088E190E00FB6F894A895809360000FBE20936000089510920001A8 +:201240000895882309F03FC0809167018F3F09F03AC0E0E0F0E093E085E090935700E895B5 +:2012600007B600FCFDCF80935700E89507B600FCFDCFE058FF4F20E1E030F20771F781E123 +:2012800080935700E8950895E091670180916601882321F4F0E0EB5FFE4F05C0813099F44F +:2012A000F0E0EE52FF4F808180937001089580916601833041F480916701882321F4809104 +:2012C00068018093600108952F923F924F925F926F927F929F92AF92BF92CF92DF92EF9208 +:2012E000FF920F931F93CF93DF938091790190917A0190936C0180936B0180916D018823D5 +:2013000051F080916D01815080936D0180916D01882309F45D9A80916E01882351F0809120 +:201320006E01815080936E0180916E01882309F45C9A80917401833009F4B2C1843030F44C +:20134000813071F0823009F0E3C111C1853009F4C5C1853008F4BAC1863009F0D9C1CDC11F +:201360005C9883E080936E018091E800877F8093E80080915C01882329F0D6DE5D9A5C9AC7 +:2013800010925C0120916B0130916C012115310529F42AC08EB3882309F4BAC18091E80033 +:2013A00082FFF8CF8091F100809365012150304030936C0120936B01E6E6F1E00CC08091C0 +:2013C000F10081932150304081E0EB36F80719F43183208308C08091F200882381F7309391 +:2013E0006C0120936B01A0DE80910101853009F0BAC080916B0190916C01892B21F482E072 +:2014000080930101B0C08AE163DE809161018F715FDEC0916301D09164012091610130919C +:20142000620121968E01021B130B219780916601882309F093C0180136942794C901A09108 +:201440006001B0E09C01AD0162E0E62EF12C012D112DE20EF31E041F151F59016A0190E0E4 +:2014600099249394B5E0A3E048C08091F200882371F48091E8008B7F8093E80004C08EB352 +:20148000882309F445C18091E80082FFF8CF0894210831088091F100682F8091F100782F1D +:2014A000F5010B0190925700E89511249F5F903419F021143104A1F4F901B0935700E89524 +:2014C00007B600FCFDCF2114310451F0F701A0935700E89507B600FCFDCFA801970190E0A7 +:2014E00042E0442E512C612C712CE40CF51C061D171DA40CB51CC61CD71C2114310409F0A0 +:20150000B4CFD0936201C093610181E180935700E89527C08091F200882371F48091E80091 +:201520008B7F8093E80004C08EB3882309F4F0C08091E80082FFF8CF6091F10080916101B3 +:2015400090916201A7D3809161019091620101969093620180936101015010400115110537 +:20156000C9F680E1B5DD8091E8008B7FC3C08091E800877F8093E8005D9883E080936D0160 +:2015800004C08EB3882309F4C3C08091E80080FFF8CF80910101893091F08A3069F4809167 +:2015A0006601813049F480916101909162018093F1009093F1009BC08091700196C06091A3 +:2015C00063017091640120916101309162016F5F7F4F7B01E21AF30A615070408091660120 +:2015E000882389F5870116950795C901A0916001B0E09C01AD011FC08091F200803271F4C3 +:201600008091E8008E7F8093E80004C08EB3882309F47EC08091E80080FFF8CFF90185918F +:2016200094918093F1009093F100015010402E5F3F4F4F4F5F4F01151105F1F670936201EC +:201640006093610129C0823039F523C08091F200803271F48091E8008E7F8093E80004C0AA +:201660008EB3882309F454C08091E80080FFF8CF0091610110916201C80104D38093F10093 +:201680000F5F1F4F10936201009361010894E108F108E114F104D1F682E08093010127C0E6 +:2016A0008091E800877F8093E80080915D018093F1001092F1001092F1001092F1008091F3 +:2016C00001018093F1001092F10011C08091E800877F8093E80010925D0119C08091E800D4 +:2016E000877F8093E800809101018093F1008091E8008E7F8093E8000AC08091E800877F08 +:201700008093E8005D9A5C9A82E08093010187D0DF91CF911F910F91FF90EF90DF90CF9017 +:20172000BF90AF909F907F906F905F904F903F902F9008952BD181E085BF15BE089584B799 +:20174000877F84BF88E10FB6F89480936000109260000FBE81E085BF82E085BF8AB18063DB +:201760008AB98BB180638BB90CC1E9DF789401C080D2809100018823D9F780915C01882369 +:20178000B9F7D8DFE0915E01F0915F010995FA01923071F0933089F0913029F488E091E082 +:2017A00022E130E019C080E090E020E030E014C08AE191E02BE130E00FC0882339F48091D9 +:2017C0003501282F30E085E391E006C080913901282F30E089E391E091838083C9010895C0 +:2017E0008091EB0081608093EB001092ED006093EC004093ED008091EE00881F8827881FE4 +:2018000008951092F4001092F0001092E8001092ED00EBEEF0E080818E7F80830895809182 +:20182000730188238CF403C08EB38823B1F08091E80082FFF9CF8091E8008B7F8093E80079 +:2018400008958EB3882349F08091E80080FFF9CF8091E8008E7F8093E80008959C0140917A +:20186000790150917A014617570718F4F90120E038C06115710511F0AB01F8CF8091E80080 +:201880008E7F8093E80040E050E0F0CF8091E80083FF02C081E008958091E80082FD2DC091 +:2018A0008EB3882381F18EB3853079F18091E80080FF17C09091F20006C081918093F1002C +:2018C000415050409F5F4115510511F09032A8F320E0903209F421E08091E8008E7F809306 +:2018E000E8004115510591F6222381F606C08EB3882349F08EB3853041F08091E80082FF85 +:20190000F6CF80E0089582E0089583E0089554D056D01EBA1092710184E089BD89B5826006 +:2019200089BD09B400FEFDCF8091D800982F9F779093D80080688093D800809163008E7FC5 +:20194000809363008091D8008F7D8093D8008091E0008E7F8093E0008091E1008E7F80932E +:20196000E1008091E20081608093E2008091E100877F8093E1008091E20088608093E20001 +:201980000895C5DF81E0809372010895C0DFE0EEF0E0808181608083E8EDF0E080818F77B4 +:2019A00080830AD00CD019BCE3E6F0E08081816080831092720108951092E20008951092A6 +:2019C000E10008951F920F920FB60F9211242F933F934F935F936F937F938F939F93AF938A +:2019E000BF93EF93FF938091E10080FF1BC08091E20080FF17C08091E1008E7F8093E100F9 +:201A00008091E2008E7F8093E2008091E20080618093E2008091D80080628093D80019BC7D +:201A20001EBA26D18091E10084FF29C08091E20084FF25C084E089BD89B5826089BD09B451 +:201A400000FEFDCF8091D8008F7D8093D8008091E1008F7E8093E1008091E2008F7E8093D6 +:201A6000E2008091E20081608093E20080917101882311F481E001C084E08EBBF9D08091DF +:201A8000E10083FF22C08091E20083FF1EC08091E100877F8093E10082E08EBB1092710103 +:201AA0008091E1008E7F8093E1008091E2008E7F8093E2008091E20080618093E200A1DEF6 +:201AC00080E060E042E28CDED3D08091E10082FF0AC08091E20082FF06C08091E1008B7FC2 +:201AE0008093E100C5D0FF91EF91BF91AF919F918F917F916F915F914F913F912F910F905E +:201B00000FBE0F901F9018951F93DF93CF9300D0CDB7DEB7E3E7F1E08091F100819381E07C +:201B2000EB37F807C9F79091730180917401853011F1863040F48130B9F0813070F08330EA +:201B400009F081C011C0883009F453C0893009F462C0863009F077C02DC0903809F474C00E +:201B6000923809F070C070C0992309F46DC0923009F069C069C0992309F065C0109175015E +:201B80008091E800877F8093E80049DE04C08EB3882309F459C08091E80080FFF8CF812F6F +:201BA0008F7711F492E001C093E09EBB80688093E3004AC09058923008F045C08091750105 +:201BC0009091760160917701AE014F5F5F4FDFDDBC010097C9F18091E800877F8093E80035 +:201BE00089819A813BDE8091E8008B7F8093E8002BC0903841F58091E800877F8093E800C6 +:201C0000809171018093F1008091E8008E7F8093E80005DE19C09923B1F4909175019230C6 +:201C200098F48091E800877F8093E80090937101F6DD80917101882311F483E001C084E0FB +:201C40008EBB16D001C040DB8091E80083FF0AC08091EB0080628093EB008091E800877F59 +:201C60008093E8000F900F90CF91DF911F91089508958EB3882329F08091E80083FF01C030 +:201C800043CF0895F999FECF92BD81BDF89A992780B50895262FF999FECF1FBA92BD81BD6B +:201CA00020BD0FB6F894FA9AF99A0FBE01960895F894FFCF01021E938220DCFB1201100123 +:201CC00000000020EB03F72F00000001000109021B0001010080320904000000FE010200E6 +:201CE0000921030000000C0001040309042003410072006400750069006E006F002000552C +:101D0000006E006F002000440046005500000000F7 +:00000001FF diff --git a/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbdfu/Arduino-usbdfu.c b/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbdfu/Arduino-usbdfu.c new file mode 100644 index 0000000..7bed831 --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbdfu/Arduino-usbdfu.c @@ -0,0 +1,728 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim 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, 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. +*/ + +/** \file + * + * Main source file for the DFU class bootloader. This file contains the complete bootloader logic. + */ + +#define INCLUDE_FROM_BOOTLOADER_C +#include "Arduino-usbdfu.h" + +/** Flag to indicate if the bootloader should be running, or should exit and allow the application code to run + * via a soft reset. When cleared, the bootloader will abort, the USB interface will shut down and the application + * jumped to via an indirect jump to location 0x0000 (or other location specified by the host). + */ +bool RunBootloader = true; + +/** Flag to indicate if the bootloader is waiting to exit. When the host requests the bootloader to exit and + * jump to the application address it specifies, it sends two sequential commands which must be properly + * acknowledged. Upon reception of the first the RunBootloader flag is cleared and the WaitForExit flag is set, + * causing the bootloader to wait for the final exit command before shutting down. + */ +bool WaitForExit = false; + +/** Current DFU state machine state, one of the values in the DFU_State_t enum. */ +uint8_t DFU_State = dfuIDLE; + +/** Status code of the last executed DFU command. This is set to one of the values in the DFU_Status_t enum after + * each operation, and returned to the host when a Get Status DFU request is issued. + */ +uint8_t DFU_Status = OK; + +/** Data containing the DFU command sent from the host. */ +DFU_Command_t SentCommand; + +/** Response to the last issued Read Data DFU command. Unlike other DFU commands, the read command + * requires a single byte response from the bootloader containing the read data when the next DFU_UPLOAD command + * is issued by the host. + */ +uint8_t ResponseByte; + +/** Pointer to the start of the user application. By default this is 0x0000 (the reset vector), however the host + * may specify an alternate address when issuing the application soft-start command. + */ +AppPtr_t AppStartPtr = (AppPtr_t)0x0000; + +/** 64-bit flash page number. This is concatenated with the current 16-bit address on USB AVRs containing more than + * 64KB of flash memory. + */ +uint8_t Flash64KBPage = 0; + +/** Memory start address, indicating the current address in the memory being addressed (either FLASH or EEPROM + * depending on the issued command from the host). + */ +uint16_t StartAddr = 0x0000; + +/** Memory end address, indicating the end address to read to/write from in the memory being addressed (either FLASH + * of EEPROM depending on the issued command from the host). + */ +uint16_t EndAddr = 0x0000; + + +/** Pulse generation counters to keep track of the number of milliseconds remaining for each pulse type */ +volatile struct +{ + uint8_t TxLEDPulse; /**< Milliseconds remaining for data Tx LED pulse */ + uint8_t RxLEDPulse; /**< Milliseconds remaining for data Rx LED pulse */ + uint8_t PingPongLEDPulse; /**< Milliseconds remaining for enumeration Tx/Rx ping-pong LED pulse */ +} PulseMSRemaining; + +/** Main program entry point. This routine configures the hardware required by the bootloader, then continuously + * runs the bootloader processing routine until instructed to soft-exit, or hard-reset via the watchdog to start + * the loaded application code. + */ +int main(void) +{ + /* Configure hardware required by the bootloader */ + SetupHardware(); + + /* Enable global interrupts so that the USB stack can function */ + sei(); + + /* Run the USB management task while the bootloader is supposed to be running */ + while (RunBootloader || WaitForExit) + USB_USBTask(); + + /* Reset configured hardware back to their original states for the user application */ + ResetHardware(); + + /* Start the user application */ + AppStartPtr(); +} + +/** Configures all hardware required for the bootloader. */ +void SetupHardware(void) +{ + /* Disable watchdog if enabled by bootloader/fuses */ + MCUSR &= ~(1 << WDRF); + wdt_disable(); + + /* Disable clock division */ +// clock_prescale_set(clock_div_1); + + /* Relocate the interrupt vector table to the bootloader section */ + MCUCR = (1 << IVCE); + MCUCR = (1 << IVSEL); + + LEDs_Init(); + + /* Initialize the USB subsystem */ + USB_Init(); +} + +/** Resets all configured hardware required for the bootloader back to their original states. */ +void ResetHardware(void) +{ + /* Shut down the USB subsystem */ + USB_ShutDown(); + + /* Relocate the interrupt vector table back to the application section */ + MCUCR = (1 << IVCE); + MCUCR = 0; +} + +/** Event handler for the USB_UnhandledControlRequest event. This is used to catch standard and class specific + * control requests that are not handled internally by the USB library (including the DFU commands, which are + * all issued via the control endpoint), so that they can be handled appropriately for the application. + */ +void EVENT_USB_Device_UnhandledControlRequest(void) +{ + /* Get the size of the command and data from the wLength value */ + SentCommand.DataSize = USB_ControlRequest.wLength; + + /* Turn off TX LED(s) once the TX pulse period has elapsed */ + if (PulseMSRemaining.TxLEDPulse && !(--PulseMSRemaining.TxLEDPulse)) + LEDs_TurnOffLEDs(LEDMASK_TX); + + /* Turn off RX LED(s) once the RX pulse period has elapsed */ + if (PulseMSRemaining.RxLEDPulse && !(--PulseMSRemaining.RxLEDPulse)) + LEDs_TurnOffLEDs(LEDMASK_RX); + + switch (USB_ControlRequest.bRequest) + { + case DFU_DNLOAD: + LEDs_TurnOnLEDs(LEDMASK_RX); + PulseMSRemaining.RxLEDPulse = TX_RX_LED_PULSE_MS; + + Endpoint_ClearSETUP(); + + /* Check if bootloader is waiting to terminate */ + if (WaitForExit) + { + /* Bootloader is terminating - process last received command */ + ProcessBootloaderCommand(); + + /* Turn off TX/RX status LEDs so that they're not left on when application starts */ + LEDs_TurnOffLEDs(LEDMASK_TX); + LEDs_TurnOffLEDs(LEDMASK_RX); + + /* Indicate that the last command has now been processed - free to exit bootloader */ + WaitForExit = false; + } + + /* If the request has a data stage, load it into the command struct */ + if (SentCommand.DataSize) + { + while (!(Endpoint_IsOUTReceived())) + { + if (USB_DeviceState == DEVICE_STATE_Unattached) + return; + } + + /* First byte of the data stage is the DNLOAD request's command */ + SentCommand.Command = Endpoint_Read_Byte(); + + /* One byte of the data stage is the command, so subtract it from the total data bytes */ + SentCommand.DataSize--; + + /* Load in the rest of the data stage as command parameters */ + for (uint8_t DataByte = 0; (DataByte < sizeof(SentCommand.Data)) && + Endpoint_BytesInEndpoint(); DataByte++) + { + SentCommand.Data[DataByte] = Endpoint_Read_Byte(); + SentCommand.DataSize--; + } + + /* Process the command */ + ProcessBootloaderCommand(); + } + + /* Check if currently downloading firmware */ + if (DFU_State == dfuDNLOAD_IDLE) + { + if (!(SentCommand.DataSize)) + { + DFU_State = dfuIDLE; + } + else + { + /* Throw away the filler bytes before the start of the firmware */ + DiscardFillerBytes(DFU_FILLER_BYTES_SIZE); + + /* Throw away the packet alignment filler bytes before the start of the firmware */ + DiscardFillerBytes(StartAddr % FIXED_CONTROL_ENDPOINT_SIZE); + + /* Calculate the number of bytes remaining to be written */ + uint16_t BytesRemaining = ((EndAddr - StartAddr) + 1); + + if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x00)) // Write flash + { + /* Calculate the number of words to be written from the number of bytes to be written */ + uint16_t WordsRemaining = (BytesRemaining >> 1); + + union + { + uint16_t Words[2]; + uint32_t Long; + } CurrFlashAddress = {.Words = {StartAddr, Flash64KBPage}}; + + uint32_t CurrFlashPageStartAddress = CurrFlashAddress.Long; + uint8_t WordsInFlashPage = 0; + + while (WordsRemaining--) + { + /* Check if endpoint is empty - if so clear it and wait until ready for next packet */ + if (!(Endpoint_BytesInEndpoint())) + { + Endpoint_ClearOUT(); + + while (!(Endpoint_IsOUTReceived())) + { + if (USB_DeviceState == DEVICE_STATE_Unattached) + return; + } + } + + /* Write the next word into the current flash page */ + boot_page_fill(CurrFlashAddress.Long, Endpoint_Read_Word_LE()); + + /* Adjust counters */ + WordsInFlashPage += 1; + CurrFlashAddress.Long += 2; + + /* See if an entire page has been written to the flash page buffer */ + if ((WordsInFlashPage == (SPM_PAGESIZE >> 1)) || !(WordsRemaining)) + { + /* Commit the flash page to memory */ + boot_page_write(CurrFlashPageStartAddress); + boot_spm_busy_wait(); + + /* Check if programming incomplete */ + if (WordsRemaining) + { + CurrFlashPageStartAddress = CurrFlashAddress.Long; + WordsInFlashPage = 0; + + /* Erase next page's temp buffer */ + boot_page_erase(CurrFlashAddress.Long); + boot_spm_busy_wait(); + } + } + } + + /* Once programming complete, start address equals the end address */ + StartAddr = EndAddr; + + /* Re-enable the RWW section of flash */ + boot_rww_enable(); + } + else // Write EEPROM + { + while (BytesRemaining--) + { + /* Check if endpoint is empty - if so clear it and wait until ready for next packet */ + if (!(Endpoint_BytesInEndpoint())) + { + Endpoint_ClearOUT(); + + while (!(Endpoint_IsOUTReceived())) + { + if (USB_DeviceState == DEVICE_STATE_Unattached) + return; + } + } + + /* Read the byte from the USB interface and write to to the EEPROM */ + eeprom_write_byte((uint8_t*)StartAddr, Endpoint_Read_Byte()); + + /* Adjust counters */ + StartAddr++; + } + } + + /* Throw away the currently unused DFU file suffix */ + DiscardFillerBytes(DFU_FILE_SUFFIX_SIZE); + } + } + + Endpoint_ClearOUT(); + + Endpoint_ClearStatusStage(); + + break; + case DFU_UPLOAD: + Endpoint_ClearSETUP(); + + LEDs_TurnOnLEDs(LEDMASK_TX); + PulseMSRemaining.TxLEDPulse = TX_RX_LED_PULSE_MS; + + while (!(Endpoint_IsINReady())) + { + if (USB_DeviceState == DEVICE_STATE_Unattached) + return; + } + + if (DFU_State != dfuUPLOAD_IDLE) + { + if ((DFU_State == dfuERROR) && IS_ONEBYTE_COMMAND(SentCommand.Data, 0x01)) // Blank Check + { + /* Blank checking is performed in the DFU_DNLOAD request - if we get here we've told the host + that the memory isn't blank, and the host is requesting the first non-blank address */ + Endpoint_Write_Word_LE(StartAddr); + } + else + { + /* Idle state upload - send response to last issued command */ + Endpoint_Write_Byte(ResponseByte); + } + } + else + { + /* Determine the number of bytes remaining in the current block */ + uint16_t BytesRemaining = ((EndAddr - StartAddr) + 1); + + if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x00)) // Read FLASH + { + /* Calculate the number of words to be written from the number of bytes to be written */ + uint16_t WordsRemaining = (BytesRemaining >> 1); + + union + { + uint16_t Words[2]; + uint32_t Long; + } CurrFlashAddress = {.Words = {StartAddr, Flash64KBPage}}; + + while (WordsRemaining--) + { + /* Check if endpoint is full - if so clear it and wait until ready for next packet */ + if (Endpoint_BytesInEndpoint() == FIXED_CONTROL_ENDPOINT_SIZE) + { + Endpoint_ClearIN(); + + while (!(Endpoint_IsINReady())) + { + if (USB_DeviceState == DEVICE_STATE_Unattached) + return; + } + } + + /* Read the flash word and send it via USB to the host */ + #if (FLASHEND > 0xFFFF) + Endpoint_Write_Word_LE(pgm_read_word_far(CurrFlashAddress.Long)); + #else + Endpoint_Write_Word_LE(pgm_read_word(CurrFlashAddress.Long)); + #endif + + /* Adjust counters */ + CurrFlashAddress.Long += 2; + } + + /* Once reading is complete, start address equals the end address */ + StartAddr = EndAddr; + } + else if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x02)) // Read EEPROM + { + while (BytesRemaining--) + { + /* Check if endpoint is full - if so clear it and wait until ready for next packet */ + if (Endpoint_BytesInEndpoint() == FIXED_CONTROL_ENDPOINT_SIZE) + { + Endpoint_ClearIN(); + + while (!(Endpoint_IsINReady())) + { + if (USB_DeviceState == DEVICE_STATE_Unattached) + return; + } + } + + /* Read the EEPROM byte and send it via USB to the host */ + Endpoint_Write_Byte(eeprom_read_byte((uint8_t*)StartAddr)); + + /* Adjust counters */ + StartAddr++; + } + } + + /* Return to idle state */ + DFU_State = dfuIDLE; + } + + Endpoint_ClearIN(); + + Endpoint_ClearStatusStage(); + break; + case DFU_GETSTATUS: + Endpoint_ClearSETUP(); + + /* Write 8-bit status value */ + Endpoint_Write_Byte(DFU_Status); + + /* Write 24-bit poll timeout value */ + Endpoint_Write_Byte(0); + Endpoint_Write_Word_LE(0); + + /* Write 8-bit state value */ + Endpoint_Write_Byte(DFU_State); + + /* Write 8-bit state string ID number */ + Endpoint_Write_Byte(0); + + Endpoint_ClearIN(); + + Endpoint_ClearStatusStage(); + break; + case DFU_CLRSTATUS: + Endpoint_ClearSETUP(); + + /* Reset the status value variable to the default OK status */ + DFU_Status = OK; + + Endpoint_ClearStatusStage(); + break; + case DFU_GETSTATE: + Endpoint_ClearSETUP(); + + /* Write the current device state to the endpoint */ + Endpoint_Write_Byte(DFU_State); + + Endpoint_ClearIN(); + + Endpoint_ClearStatusStage(); + break; + case DFU_ABORT: + Endpoint_ClearSETUP(); + + /* Turn off TX/RX status LEDs so that they're not left on when application starts */ + LEDs_TurnOffLEDs(LEDMASK_TX); + LEDs_TurnOffLEDs(LEDMASK_RX); + + /* Reset the current state variable to the default idle state */ + DFU_State = dfuIDLE; + + Endpoint_ClearStatusStage(); + break; + } +} + +/** Routine to discard the specified number of bytes from the control endpoint stream. This is used to + * discard unused bytes in the stream from the host, including the memory program block suffix. + * + * \param[in] NumberOfBytes Number of bytes to discard from the host from the control endpoint + */ +static void DiscardFillerBytes(uint8_t NumberOfBytes) +{ + while (NumberOfBytes--) + { + if (!(Endpoint_BytesInEndpoint())) + { + Endpoint_ClearOUT(); + + /* Wait until next data packet received */ + while (!(Endpoint_IsOUTReceived())) + { + if (USB_DeviceState == DEVICE_STATE_Unattached) + return; + } + } + else + { + Endpoint_Discard_Byte(); + } + } +} + +/** Routine to process an issued command from the host, via a DFU_DNLOAD request wrapper. This routine ensures + * that the command is allowed based on the current secure mode flag value, and passes the command off to the + * appropriate handler function. + */ +static void ProcessBootloaderCommand(void) +{ + /* Check if device is in secure mode */ +// if (IsSecure) +// { +// /* Don't process command unless it is a READ or chip erase command */ +// if (!(((SentCommand.Command == COMMAND_WRITE) && +// IS_TWOBYTE_COMMAND(SentCommand.Data, 0x00, 0xFF)) || +// (SentCommand.Command == COMMAND_READ))) +// { +// /* Set the state and status variables to indicate the error */ +// DFU_State = dfuERROR; +// DFU_Status = errWRITE; +// +// /* Stall command */ +// Endpoint_StallTransaction(); +// +// /* Don't process the command */ +// return; +// } +// } + + /* Dispatch the required command processing routine based on the command type */ + switch (SentCommand.Command) + { + case COMMAND_PROG_START: + ProcessMemProgCommand(); + break; + case COMMAND_DISP_DATA: + ProcessMemReadCommand(); + break; + case COMMAND_WRITE: + ProcessWriteCommand(); + break; + case COMMAND_READ: + ProcessReadCommand(); + break; + case COMMAND_CHANGE_BASE_ADDR: + if (IS_TWOBYTE_COMMAND(SentCommand.Data, 0x03, 0x00)) // Set 64KB flash page command + Flash64KBPage = SentCommand.Data[2]; + break; + } +} + +/** Routine to concatenate the given pair of 16-bit memory start and end addresses from the host, and store them + * in the StartAddr and EndAddr global variables. + */ +static void LoadStartEndAddresses(void) +{ + union + { + uint8_t Bytes[2]; + uint16_t Word; + } Address[2] = {{.Bytes = {SentCommand.Data[2], SentCommand.Data[1]}}, + {.Bytes = {SentCommand.Data[4], SentCommand.Data[3]}}}; + + /* Load in the start and ending read addresses from the sent data packet */ + StartAddr = Address[0].Word; + EndAddr = Address[1].Word; +} + +/** Handler for a Memory Program command issued by the host. This routine handles the preparations needed + * to write subsequent data from the host into the specified memory. + */ +static void ProcessMemProgCommand(void) +{ + if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x00) || // Write FLASH command + IS_ONEBYTE_COMMAND(SentCommand.Data, 0x01)) // Write EEPROM command + { + /* Load in the start and ending read addresses */ + LoadStartEndAddresses(); + + /* If FLASH is being written to, we need to pre-erase the first page to write to */ + if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x00)) + { + union + { + uint16_t Words[2]; + uint32_t Long; + } CurrFlashAddress = {.Words = {StartAddr, Flash64KBPage}}; + + /* Erase the current page's temp buffer */ + boot_page_erase(CurrFlashAddress.Long); + boot_spm_busy_wait(); + } + + /* Set the state so that the next DNLOAD requests reads in the firmware */ + DFU_State = dfuDNLOAD_IDLE; + } +} + +/** Handler for a Memory Read command issued by the host. This routine handles the preparations needed + * to read subsequent data from the specified memory out to the host, as well as implementing the memory + * blank check command. + */ +static void ProcessMemReadCommand(void) +{ + if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x00) || // Read FLASH command + IS_ONEBYTE_COMMAND(SentCommand.Data, 0x02)) // Read EEPROM command + { + /* Load in the start and ending read addresses */ + LoadStartEndAddresses(); + + /* Set the state so that the next UPLOAD requests read out the firmware */ + DFU_State = dfuUPLOAD_IDLE; + } + else if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x01)) // Blank check FLASH command + { + uint32_t CurrFlashAddress = 0; + + while (CurrFlashAddress < BOOT_START_ADDR) + { + /* Check if the current byte is not blank */ + #if (FLASHEND > 0xFFFF) + if (pgm_read_byte_far(CurrFlashAddress) != 0xFF) + #else + if (pgm_read_byte(CurrFlashAddress) != 0xFF) + #endif + { + /* Save the location of the first non-blank byte for response back to the host */ + Flash64KBPage = (CurrFlashAddress >> 16); + StartAddr = CurrFlashAddress; + + /* Set state and status variables to the appropriate error values */ + DFU_State = dfuERROR; + DFU_Status = errCHECK_ERASED; + + break; + } + + CurrFlashAddress++; + } + } +} + +/** Handler for a Data Write command issued by the host. This routine handles non-programming commands such as + * bootloader exit (both via software jumps and hardware watchdog resets) and flash memory erasure. + */ +static void ProcessWriteCommand(void) +{ + if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x03)) // Start application + { + /* Indicate that the bootloader is terminating */ + WaitForExit = true; + + /* Check if data supplied for the Start Program command - no data executes the program */ + if (SentCommand.DataSize) + { + if (SentCommand.Data[1] == 0x01) // Start via jump + { + union + { + uint8_t Bytes[2]; + AppPtr_t FuncPtr; + } Address = {.Bytes = {SentCommand.Data[4], SentCommand.Data[3]}}; + + /* Load in the jump address into the application start address pointer */ + AppStartPtr = Address.FuncPtr; + } + } + else + { + if (SentCommand.Data[1] == 0x00) // Start via watchdog + { + /* Start the watchdog to reset the AVR once the communications are finalized */ + wdt_enable(WDTO_250MS); + } + else // Start via jump + { + /* Set the flag to terminate the bootloader at next opportunity */ + RunBootloader = false; + } + } + } + else if (IS_TWOBYTE_COMMAND(SentCommand.Data, 0x00, 0xFF)) // Erase flash + { + uint32_t CurrFlashAddress = 0; + + /* Clear the application section of flash */ + while (CurrFlashAddress < BOOT_START_ADDR) + { + boot_page_erase(CurrFlashAddress); + boot_spm_busy_wait(); + boot_page_write(CurrFlashAddress); + boot_spm_busy_wait(); + + CurrFlashAddress += SPM_PAGESIZE; + } + + /* Re-enable the RWW section of flash as writing to the flash locks it out */ + boot_rww_enable(); + + /* Memory has been erased, reset the security bit so that programming/reading is allowed */ +// IsSecure = false; + } +} + +/** Handler for a Data Read command issued by the host. This routine handles bootloader information retrieval + * commands such as device signature and bootloader version retrieval. + */ +static void ProcessReadCommand(void) +{ + const uint8_t BootloaderInfo[3] = {BOOTLOADER_VERSION, BOOTLOADER_ID_BYTE1, BOOTLOADER_ID_BYTE2}; + const uint8_t SignatureInfo[3] = {AVR_SIGNATURE_1, AVR_SIGNATURE_2, AVR_SIGNATURE_3}; + + uint8_t DataIndexToRead = SentCommand.Data[1]; + + if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x00)) // Read bootloader info + ResponseByte = BootloaderInfo[DataIndexToRead]; + else if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x01)) // Read signature byte + ResponseByte = SignatureInfo[DataIndexToRead - 0x30]; +} diff --git a/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbdfu/Arduino-usbdfu.h b/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbdfu/Arduino-usbdfu.h new file mode 100644 index 0000000..4fb236e --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbdfu/Arduino-usbdfu.h @@ -0,0 +1,220 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim 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, 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. +*/ + +/** \file + * + * Header file for Arduino-usbdfu.c. + */ + +#ifndef _ARDUINO_USB_DFU_BOOTLOADER_H_ +#define _ARDUINO_USB_DFU_BOOTLOADER_H_ + + /* Includes: */ + #include + #include + #include + #include + #include + #include + #include + #include + + #include "Descriptors.h" + + #include + #include + + /* Macros: */ + /** LED mask for the library LED driver, to indicate TX activity. */ + #define LEDMASK_TX LEDS_LED1 + + /** LED mask for the library LED driver, to indicate RX activity. */ + #define LEDMASK_RX LEDS_LED2 + + /** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ + #define LEDMASK_ERROR (LEDS_LED1 | LEDS_LED2) + + /** LED mask for the library LED driver, to indicate that the USB interface is busy. */ + #define LEDMASK_BUSY (LEDS_LED1 | LEDS_LED2) + + /** Configuration define. Define this token to true to case the bootloader to reject all memory commands + * until a memory erase has been performed. When used in conjunction with the lockbits of the AVR, this + * can protect the AVR's firmware from being dumped from a secured AVR. When false, memory operations are + * allowed at any time. + */ +// #define SECURE_MODE false + + /** Major bootloader version number. */ + #define BOOTLOADER_VERSION_MINOR 2 + + /** Minor bootloader version number. */ + #define BOOTLOADER_VERSION_REV 0 + + /** Complete bootloader version number expressed as a packed byte, constructed from the + * two individual bootloader version macros. + */ + #define BOOTLOADER_VERSION ((BOOTLOADER_VERSION_MINOR << 4) | BOOTLOADER_VERSION_REV) + + /** First byte of the bootloader identification bytes, used to identify a device's bootloader. */ + #define BOOTLOADER_ID_BYTE1 0xDC + + /** Second byte of the bootloader identification bytes, used to identify a device's bootloader. */ + #define BOOTLOADER_ID_BYTE2 0xFB + + /** Convenience macro, used to determine if the issued command is the given one-byte long command. + * + * \param[in] dataarr Command byte array to check against + * \param[in] cb1 First command byte to check + */ + #define IS_ONEBYTE_COMMAND(dataarr, cb1) (dataarr[0] == (cb1)) + + /** Convenience macro, used to determine if the issued command is the given two-byte long command. + * + * \param[in] dataarr Command byte array to check against + * \param[in] cb1 First command byte to check + * \param[in] cb2 Second command byte to check + */ + #define IS_TWOBYTE_COMMAND(dataarr, cb1, cb2) ((dataarr[0] == (cb1)) && (dataarr[1] == (cb2))) + + /** Length of the DFU file suffix block, appended to the end of each complete memory write command. + * The DFU file suffix is currently unused (but is designed to give extra file information, such as + * a CRC of the complete firmware for error checking) and so is discarded. + */ + #define DFU_FILE_SUFFIX_SIZE 16 + + /** Length of the DFU file filler block, appended to the start of each complete memory write command. + * Filler bytes are added to the start of each complete memory write command, and must be discarded. + */ + #define DFU_FILLER_BYTES_SIZE 26 + + /** DFU class command request to detach from the host. */ + #define DFU_DETATCH 0x00 + + /** DFU class command request to send data from the host to the bootloader. */ + #define DFU_DNLOAD 0x01 + + /** DFU class command request to send data from the bootloader to the host. */ + #define DFU_UPLOAD 0x02 + + /** DFU class command request to get the current DFU status and state from the bootloader. */ + #define DFU_GETSTATUS 0x03 + + /** DFU class command request to reset the current DFU status and state variables to their defaults. */ + #define DFU_CLRSTATUS 0x04 + + /** DFU class command request to get the current DFU state of the bootloader. */ + #define DFU_GETSTATE 0x05 + + /** DFU class command request to abort the current multi-request transfer and return to the dfuIDLE state. */ + #define DFU_ABORT 0x06 + + /** DFU command to begin programming the device's memory. */ + #define COMMAND_PROG_START 0x01 + + /** DFU command to begin reading the device's memory. */ + #define COMMAND_DISP_DATA 0x03 + + /** DFU command to issue a write command. */ + #define COMMAND_WRITE 0x04 + + /** DFU command to issue a read command. */ + #define COMMAND_READ 0x05 + + /** DFU command to issue a memory base address change command, to set the current 64KB flash page + * that subsequent flash operations should use. */ + #define COMMAND_CHANGE_BASE_ADDR 0x06 + + /* Type Defines: */ + /** Type define for a non-returning function pointer to the loaded application. */ + typedef void (*AppPtr_t)(void) ATTR_NO_RETURN; + + /** Type define for a structure containing a complete DFU command issued by the host. */ + typedef struct + { + uint8_t Command; /**< Single byte command to perform, one of the COMMAND_* macro values */ + uint8_t Data[5]; /**< Command parameters */ + uint16_t DataSize; /**< Size of the command parameters */ + } DFU_Command_t; + + /* Enums: */ + /** DFU bootloader states. Refer to the DFU class specification for information on each state. */ + enum DFU_State_t + { + appIDLE = 0, + appDETACH = 1, + dfuIDLE = 2, + dfuDNLOAD_SYNC = 3, + dfuDNBUSY = 4, + dfuDNLOAD_IDLE = 5, + dfuMANIFEST_SYNC = 6, + dfuMANIFEST = 7, + dfuMANIFEST_WAIT_RESET = 8, + dfuUPLOAD_IDLE = 9, + dfuERROR = 10 + }; + + /** DFU command status error codes. Refer to the DFU class specification for information on each error code. */ + enum DFU_Status_t + { + OK = 0, + errTARGET = 1, + errFILE = 2, + errWRITE = 3, + errERASE = 4, + errCHECK_ERASED = 5, + errPROG = 6, + errVERIFY = 7, + errADDRESS = 8, + errNOTDONE = 9, + errFIRMWARE = 10, + errVENDOR = 11, + errUSBR = 12, + errPOR = 13, + errUNKNOWN = 14, + errSTALLEDPKT = 15 + }; + + /* Function Prototypes: */ + void SetupHardware(void); + void ResetHardware(void); + + void EVENT_USB_Device_UnhandledControlRequest(void); + + #if defined(INCLUDE_FROM_BOOTLOADER_C) + static void DiscardFillerBytes(uint8_t NumberOfBytes); + static void ProcessBootloaderCommand(void); + static void LoadStartEndAddresses(void); + static void ProcessMemProgCommand(void); + static void ProcessMemReadCommand(void); + static void ProcessWriteCommand(void); + static void ProcessReadCommand(void); + #endif + +#endif /* _ARDUINO_USB_DFU_BOOTLOADER_H_ */ diff --git a/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbdfu/Board/LEDs.h b/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbdfu/Board/LEDs.h new file mode 100644 index 0000000..152e8f5 --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbdfu/Board/LEDs.h @@ -0,0 +1,110 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim 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, 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. +*/ + +/* + Board LEDs driver for the Benito board, from www.dorkbotpdx.org. +*/ + +#ifndef __LEDS_ARDUINOUNO_H__ +#define __LEDS_ARDUINOUNO_H__ + + /* Includes: */ + #include + +/* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(INCLUDE_FROM_LEDS_H) + #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** LED mask for the first LED on the board. */ + #define LEDS_LED1 (1 << 5) + + /** LED mask for the second LED on the board. */ + #define LEDS_LED2 (1 << 4) + + /** LED mask for all the LEDs on the board. */ + #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2) + + /** LED mask for the none of the board LEDs */ + #define LEDS_NO_LEDS 0 + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void LEDs_Init(void) + { + DDRD |= LEDS_ALL_LEDS; + PORTD |= LEDS_ALL_LEDS; + } + + static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) + { + PORTD &= ~LEDMask; + } + + static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) + { + PORTD |= LEDMask; + } + + static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) + { + PORTD = ((PORTD | LEDS_ALL_LEDS) & ~LEDMask); + } + + static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, const uint8_t ActiveMask) + { + PORTD = ((PORTD | ActiveMask) & ~LEDMask); + } + + static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) + { + PORTD ^= LEDMask; + } + + static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t LEDs_GetLEDs(void) + { + return (PORTD & LEDS_ALL_LEDS); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif diff --git a/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbdfu/Descriptors.c b/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbdfu/Descriptors.c new file mode 100644 index 0000000..4deaa06 --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbdfu/Descriptors.c @@ -0,0 +1,189 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim 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, 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. +*/ + +/** \file + * + * USB Device Descriptors, for library use when in USB device mode. Descriptors are special + * computer-readable structures which the host requests upon device enumeration, to determine + * the device's capabilities and functions. + */ + +#include "Descriptors.h" + +/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall + * device characteristics, including the supported USB version, control endpoint size and the + * number of device configurations. The descriptor is read out by the USB host when the enumeration + * process begins. + */ +USB_Descriptor_Device_t DeviceDescriptor = +{ + .Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device}, + + .USBSpecification = VERSION_BCD(01.10), + .Class = 0x00, + .SubClass = 0x00, + .Protocol = 0x00, + + .Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE, + + .VendorID = 0x03EB, // Atmel + .ProductID = PRODUCT_ID_CODE, // MCU-dependent + .ReleaseNumber = 0x0000, + + .ManufacturerStrIndex = NO_DESCRIPTOR, + .ProductStrIndex = 0x01, + .SerialNumStrIndex = NO_DESCRIPTOR, + + .NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS +}; + +/** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage + * of the device in one of its supported configurations, including information about any device interfaces + * and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting + * a configuration so that the host may correctly communicate with the USB device. + */ +USB_Descriptor_Configuration_t ConfigurationDescriptor = +{ + .Config = + { + .Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration}, + + .TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t), + .TotalInterfaces = 1, + + .ConfigurationNumber = 1, + .ConfigurationStrIndex = NO_DESCRIPTOR, + + .ConfigAttributes = USB_CONFIG_ATTR_BUSPOWERED, + + .MaxPowerConsumption = USB_CONFIG_POWER_MA(100) + }, + + .DFU_Interface = + { + .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, + + .InterfaceNumber = 0, + .AlternateSetting = 0, + + .TotalEndpoints = 0, + + .Class = 0xFE, + .SubClass = 0x01, + .Protocol = 0x02, + + .InterfaceStrIndex = NO_DESCRIPTOR + }, + + .DFU_Functional = + { + .Header = {.Size = sizeof(USB_DFU_Functional_Descriptor_t), .Type = DTYPE_DFUFunctional}, + + .Attributes = (ATTR_CAN_UPLOAD | ATTR_CAN_DOWNLOAD), + + .DetachTimeout = 0x0000, + .TransferSize = 0x0c00, + + .DFUSpecification = VERSION_BCD(01.01) + } +}; + +/** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests + * the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate + * via the language ID table available at USB.org what languages the device supports for its string descriptors. + */ +USB_Descriptor_String_t LanguageString = +{ + .Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String}, + + .UnicodeString = {LANGUAGE_ID_ENG} +}; + +/** Product descriptor string. This is a Unicode string containing the product's details in human readable form, + * and is read out upon request by the host when the appropriate string ID is requested, listed in the Device + * Descriptor. + */ +USB_Descriptor_String_t ProductString = +{ + #if (ARDUINO_MODEL_PID == ARDUINO_UNO_PID) + .Header = {.Size = USB_STRING_LEN(15), .Type = DTYPE_String}, + + .UnicodeString = L"Arduino Uno DFU" + #elif (ARDUINO_MODEL_PID == ARDUINO_MEGA2560_PID) + .Header = {.Size = USB_STRING_LEN(21), .Type = DTYPE_String}, + + .UnicodeString = L"Arduino Mega 2560 DFU" + #endif +}; + +/** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors" + * documentation) by the application code so that the address and size of a requested descriptor can be given + * to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function + * is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the + * USB host. + */ +uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, + const uint8_t wIndex, + void** const DescriptorAddress) +{ + const uint8_t DescriptorType = (wValue >> 8); + const uint8_t DescriptorNumber = (wValue & 0xFF); + + void* Address = NULL; + uint16_t Size = NO_DESCRIPTOR; + + switch (DescriptorType) + { + case DTYPE_Device: + Address = &DeviceDescriptor; + Size = sizeof(USB_Descriptor_Device_t); + break; + case DTYPE_Configuration: + Address = &ConfigurationDescriptor; + Size = sizeof(USB_Descriptor_Configuration_t); + break; + case DTYPE_String: + if (!(DescriptorNumber)) + { + Address = &LanguageString; + Size = LanguageString.Header.Size; + } + else + { + Address = &ProductString; + Size = ProductString.Header.Size; + } + + break; + } + + *DescriptorAddress = Address; + return Size; +} diff --git a/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbdfu/Descriptors.h b/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbdfu/Descriptors.h new file mode 100644 index 0000000..6c93f20 --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbdfu/Descriptors.h @@ -0,0 +1,177 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim 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, 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. +*/ + +/** \file + * + * Header file for Descriptors.c. + */ + +#ifndef _DESCRIPTORS_H_ +#define _DESCRIPTORS_H_ + + /* Includes: */ + #include + + /* Product-specific definitions: */ + #define ARDUINO_UNO_PID 0x0001 + #define ARDUINO_MEGA2560_PID 0x0010 + + /* Macros: */ + /** Descriptor type value for a DFU class functional descriptor. */ + #define DTYPE_DFUFunctional 0x21 + + /** DFU attribute mask, indicating that the DFU device will detach and re-attach when a DFU_DETACH + * command is issued, rather than the host issuing a USB Reset. + */ + #define ATTR_WILL_DETATCH (1 << 3) + + /** DFU attribute mask, indicating that the DFU device can communicate during the manifestation phase + * (memory programming phase). + */ + #define ATTR_MANEFESTATION_TOLLERANT (1 << 2) + + /** DFU attribute mask, indicating that the DFU device can accept DFU_UPLOAD requests to send data from + * the device to the host. + */ + #define ATTR_CAN_UPLOAD (1 << 1) + + /** DFU attribute mask, indicating that the DFU device can accept DFU_DNLOAD requests to send data from + * the host to the device. + */ + #define ATTR_CAN_DOWNLOAD (1 << 0) + + #if defined(__AVR_AT90USB1287__) + #define PRODUCT_ID_CODE 0x2FFB + #define AVR_SIGNATURE_1 0x1E + #define AVR_SIGNATURE_2 0x97 + #define AVR_SIGNATURE_3 0x82 + #elif defined(__AVR_AT90USB1286__) + #define PRODUCT_ID_CODE 0x2FFB + #define AVR_SIGNATURE_1 0x1E + #define AVR_SIGNATURE_2 0x97 + #define AVR_SIGNATURE_3 0x82 + #elif defined(__AVR_AT90USB647__) + #define PRODUCT_ID_CODE 0x2FF9 + #define AVR_SIGNATURE_1 0x1E + #define AVR_SIGNATURE_2 0x96 + #define AVR_SIGNATURE_3 0x82 + #elif defined(__AVR_AT90USB646__) + #define PRODUCT_ID_CODE 0x2FF9 + #define AVR_SIGNATURE_1 0x1E + #define AVR_SIGNATURE_2 0x96 + #define AVR_SIGNATURE_3 0x82 + #elif defined(__AVR_ATmega32U6__) + #define PRODUCT_ID_CODE 0x2FFB + #define AVR_SIGNATURE_1 0x1E + #define AVR_SIGNATURE_2 0x95 + #define AVR_SIGNATURE_3 0x88 + #elif defined(__AVR_ATmega32U4__) + #define PRODUCT_ID_CODE 0x2FF4 + #define AVR_SIGNATURE_1 0x1E + #define AVR_SIGNATURE_2 0x95 + #define AVR_SIGNATURE_3 0x87 + #elif defined(__AVR_ATmega32U2__) + #define PRODUCT_ID_CODE 0x2FF0 + #define AVR_SIGNATURE_1 0x1E + #define AVR_SIGNATURE_2 0x95 + #define AVR_SIGNATURE_3 0x8A + #elif defined(__AVR_ATmega16U4__) + #define PRODUCT_ID_CODE 0x2FF3 + #define AVR_SIGNATURE_1 0x1E + #define AVR_SIGNATURE_2 0x94 + #define AVR_SIGNATURE_3 0x88 + #elif defined(__AVR_ATmega16U2__) + #define PRODUCT_ID_CODE 0x2FEF + #define AVR_SIGNATURE_1 0x1E + #define AVR_SIGNATURE_2 0x94 + #define AVR_SIGNATURE_3 0x89 + #elif defined(__AVR_AT90USB162__) + #define PRODUCT_ID_CODE 0x2FFA + #define AVR_SIGNATURE_1 0x1E + #define AVR_SIGNATURE_2 0x94 + #define AVR_SIGNATURE_3 0x82 + #elif defined(__AVR_AT90USB82__) + #define PRODUCT_ID_CODE 0x2FEE + #define AVR_SIGNATURE_1 0x1E + #define AVR_SIGNATURE_2 0x93 + #define AVR_SIGNATURE_3 0x89 + #elif defined(__AVR_ATmega8U2__) + #define PRODUCT_ID_CODE 0x2FF7 + #define AVR_SIGNATURE_1 0x1E + #define AVR_SIGNATURE_2 0x93 + #define AVR_SIGNATURE_3 0x82 + #else + #error The selected AVR part is not currently supported by this bootloader. + #endif + + #if !defined(PRODUCT_ID_CODE) + #error Current AVR model is not supported by this bootloader. + #endif + + /* Type Defines: */ + /** Type define for a DFU class function descriptor. This descriptor gives DFU class information + * to the host when read, indicating the DFU device's capabilities. + */ + typedef struct + { + USB_Descriptor_Header_t Header; /**< Standard descriptor header structure */ + + uint8_t Attributes; /**< DFU device attributes, a mask comprising of the + * ATTR_* macros listed in this source file + */ + uint16_t DetachTimeout; /**< Timeout in milliseconds between a USB_DETACH + * command being issued and the device detaching + * from the USB bus + */ + uint16_t TransferSize; /**< Maximum number of bytes the DFU device can accept + * from the host in a transaction + */ + uint16_t DFUSpecification; /**< BCD packed DFU specification number this DFU + * device complies with + */ + } USB_DFU_Functional_Descriptor_t; + + /** Type define for the device configuration descriptor structure. This must be defined in the + * application code, as the configuration descriptor contains several sub-descriptors which + * vary between devices, and which describe the device's usage to the host. + */ + typedef struct + { + USB_Descriptor_Configuration_Header_t Config; + USB_Descriptor_Interface_t DFU_Interface; + USB_DFU_Functional_Descriptor_t DFU_Functional; + } USB_Descriptor_Configuration_t; + + /* Function Prototypes: */ + uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, + const uint8_t wIndex, + void** const DescriptorAddress) ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); + +#endif diff --git a/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbdfu/makefile b/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbdfu/makefile new file mode 100644 index 0000000..1fb4ed3 --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbdfu/makefile @@ -0,0 +1,710 @@ +# Hey Emacs, this is a -*- makefile -*- +#---------------------------------------------------------------------------- +# WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al. +# >> Modified for use with the LUFA project. << +# +# Released to the Public Domain +# +# Additional material for this makefile was written by: +# Peter Fleury +# Tim Henigan +# Colin O'Flynn +# Reiner Patommel +# Markus Pfaff +# Sander Pool +# Frederik Rouleau +# Carlos Lamas +# Dean Camera +# Opendous Inc. +# Denver Gingerich +# +#---------------------------------------------------------------------------- +# On command line: +# +# make all = Make software. +# +# make clean = Clean out built project files. +# +# make coff = Convert ELF to AVR COFF. +# +# make extcoff = Convert ELF to AVR Extended COFF. +# +# make program = Download the hex file to the device, using avrdude. +# Please customize the avrdude settings below first! +# +# make doxygen = Generate DoxyGen documentation for the project (must have +# DoxyGen installed) +# +# make debug = Start either simulavr or avarice as specified for debugging, +# with avr-gdb or avr-insight as the front end for debugging. +# +# make filename.s = Just compile filename.c into the assembler code only. +# +# make filename.i = Create a preprocessed source file for use in submitting +# bug reports to the GCC project. +# +# To rebuild project do "make clean" then "make all". +#---------------------------------------------------------------------------- + + +# MCU name +MCU = atmega8u2 +MCU_AVRDUDE = at90usb82 + +# Specify the Arduino model using the assigned PID. This is used by Descriptors.c +# to set the product descriptor string (for DFU we must use the PID for each +# chip that dfu-bootloader or Flip expect) +# Uno PID: +ARDUINO_MODEL_PID = 0x0001 +# Mega 2560 PID: +#ARDUINO_MODEL_PID = 0x0010 + +# Target board (see library "Board Types" documentation, NONE for projects not requiring +# LUFA board drivers). If USER is selected, put custom board drivers in a directory called +# "Board" inside the application directory. +BOARD = USER + + +# Processor frequency. +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to +# calculate timings. Do NOT tack on a 'UL' at the end, this will be done +# automatically to create a 32-bit value in your source code. +# +# This will be an integer division of F_CLOCK below, as it is sourced by +# F_CLOCK after it has run through any CPU prescalers. Note that this value +# does not *change* the processor frequency - it should merely be updated to +# reflect the processor speed set externally so that the code can use accurate +# software delays. +F_CPU = 16000000 + + +# Input clock frequency. +# This will define a symbol, F_CLOCK, in all source code files equal to the +# input clock frequency (before any prescaling is performed) in Hz. This value may +# differ from F_CPU if prescaling is used on the latter, and is required as the +# raw input clock is fed directly to the PLL sections of the AVR for high speed +# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' +# at the end, this will be done automatically to create a 32-bit value in your +# source code. +# +# If no clock division is performed on the input clock inside the AVR (via the +# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. +F_CLOCK = $(F_CPU) + + +# Starting byte address of the bootloader, as a byte address - computed via the formula +# BOOT_START = ((TOTAL_FLASH_BYTES - BOOTLOADER_SECTION_SIZE_BYTES) * 1024) +# +# Note that the bootloader size and start address given in AVRStudio is in words and not +# bytes, and so will need to be doubled to obtain the byte address needed by AVR-GCC. +BOOT_START = 0x1000 + + +# Output format. (can be srec, ihex, binary) +FORMAT = ihex + + +# Target file name (without extension). +TARGET = Arduino-usbdfu + + +# Object files directory +# To put object files in current directory, use a dot (.), do NOT make +# this an empty or blank macro! +OBJDIR = . + + +# Path to the LUFA library +LUFA_PATH = ../.. + + +# LUFA library compile-time options and predefined tokens +LUFA_OPTS = -D USB_DEVICE_ONLY +LUFA_OPTS += -D DEVICE_STATE_AS_GPIOR=0 +LUFA_OPTS += -D CONTROL_ONLY_DEVICE +LUFA_OPTS += -D FIXED_CONTROL_ENDPOINT_SIZE=32 +LUFA_OPTS += -D FIXED_NUM_CONFIGURATIONS=1 +LUFA_OPTS += -D USE_RAM_DESCRIPTORS +LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" +LUFA_OPTS += -D NO_INTERNAL_SERIAL +LUFA_OPTS += -D NO_DEVICE_SELF_POWER +LUFA_OPTS += -D NO_DEVICE_REMOTE_WAKEUP +LUFA_OPTS += -D NO_STREAM_CALLBACKS + + +# Create the LUFA source path variables by including the LUFA root makefile +include $(LUFA_PATH)/LUFA/makefile + + +# List C source files here. (C dependencies are automatically generated.) +SRC = $(TARGET).c \ + Descriptors.c \ + $(LUFA_SRC_USB) \ + + +# List C++ source files here. (C dependencies are automatically generated.) +CPPSRC = + + +# List Assembler source files here. +# Make them always end in a capital .S. Files ending in a lowercase .s +# will not be considered source files but generated files (assembler +# output from the compiler), and will be deleted upon "make clean"! +# Even though the DOS/Win* filesystem matches both .s and .S the same, +# it will preserve the spelling of the filenames, and gcc itself does +# care about how the name is spelled on its command-line. +ASRC = + + +# Optimization level, can be [0, 1, 2, 3, s]. +# 0 = turn off optimization. s = optimize for size. +# (Note: 3 is not always the best optimization level. See avr-libc FAQ.) +OPT = s + + +# Debugging format. +# Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs. +# AVR Studio 4.10 requires dwarf-2. +# AVR [Extended] COFF format requires stabs, plus an avr-objcopy run. +DEBUG = dwarf-2 + + +# List any extra directories to look for include files here. +# Each directory must be seperated by a space. +# Use forward slashes for directory separators. +# For a directory that has spaces, enclose it in quotes. +EXTRAINCDIRS = $(LUFA_PATH)/ + + +# Compiler flag to set the C Standard level. +# c89 = "ANSI" C +# gnu89 = c89 plus GCC extensions +# c99 = ISO C99 standard (not yet fully implemented) +# gnu99 = c99 plus GCC extensions +CSTANDARD = -std=c99 + + +# Place -D or -U options here for C sources +CDEFS = -DF_CPU=$(F_CPU)UL +CDEFS += -DARDUINO_MODEL_PID=$(ARDUINO_MODEL_PID) +CDEFS += -DF_CLOCK=$(F_CLOCK)UL +CDEFS += -DBOARD=BOARD_$(BOARD) +CDEFS += -DBOOT_START_ADDR=$(BOOT_START)UL +CDEFS += -DTX_RX_LED_PULSE_MS=3 +CDEFS += $(LUFA_OPTS) + + +# Place -D or -U options here for ASM sources +ADEFS = -DF_CPU=$(F_CPU) +ADEFS += -DF_CLOCK=$(F_CLOCK)UL +ADEFS += -DBOARD=BOARD_$(BOARD) +CDEFS += -DBOOT_START_ADDR=$(BOOT_START)UL +ADEFS += $(LUFA_OPTS) + +# Place -D or -U options here for C++ sources +CPPDEFS = -DF_CPU=$(F_CPU)UL +CPPDEFS += -DF_CLOCK=$(F_CLOCK)UL +CPPDEFS += -DBOARD=BOARD_$(BOARD) +CDEFS += -DBOOT_START_ADDR=$(BOOT_START)UL +CPPDEFS += $(LUFA_OPTS) +#CPPDEFS += -D__STDC_LIMIT_MACROS +#CPPDEFS += -D__STDC_CONSTANT_MACROS + + + +#---------------- Compiler Options C ---------------- +# -g*: generate debugging information +# -O*: optimization level +# -f...: tuning, see GCC manual and avr-libc documentation +# -Wall...: warning level +# -Wa,...: tell GCC to pass this to the assembler. +# -adhlns...: create assembler listing +CFLAGS = -g$(DEBUG) +CFLAGS += $(CDEFS) +CFLAGS += -O$(OPT) +CFLAGS += -funsigned-char +CFLAGS += -funsigned-bitfields +CFLAGS += -ffunction-sections +CFLAGS += -fno-inline-small-functions +CFLAGS += -fpack-struct +CFLAGS += -fshort-enums +CFLAGS += -fno-strict-aliasing +CFLAGS += -Wall +CFLAGS += -Wstrict-prototypes +#CFLAGS += -mshort-calls +#CFLAGS += -fno-unit-at-a-time +#CFLAGS += -Wundef +#CFLAGS += -Wunreachable-code +#CFLAGS += -Wsign-compare +CFLAGS += -Wa,-adhlns=$(<:%.c=$(OBJDIR)/%.lst) +CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) +CFLAGS += $(CSTANDARD) + + +#---------------- Compiler Options C++ ---------------- +# -g*: generate debugging information +# -O*: optimization level +# -f...: tuning, see GCC manual and avr-libc documentation +# -Wall...: warning level +# -Wa,...: tell GCC to pass this to the assembler. +# -adhlns...: create assembler listing +CPPFLAGS = -g$(DEBUG) +CPPFLAGS += $(CPPDEFS) +CPPFLAGS += -O$(OPT) +CPPFLAGS += -funsigned-char +CPPFLAGS += -funsigned-bitfields +CPPFLAGS += -fpack-struct +CPPFLAGS += -fshort-enums +CPPFLAGS += -fno-exceptions +CPPFLAGS += -Wall +CPPFLAGS += -Wundef +#CPPFLAGS += -mshort-calls +#CPPFLAGS += -fno-unit-at-a-time +#CPPFLAGS += -Wstrict-prototypes +#CPPFLAGS += -Wunreachable-code +#CPPFLAGS += -Wsign-compare +CPPFLAGS += -Wa,-adhlns=$(<:%.cpp=$(OBJDIR)/%.lst) +CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) +#CPPFLAGS += $(CSTANDARD) + + +#---------------- Assembler Options ---------------- +# -Wa,...: tell GCC to pass this to the assembler. +# -adhlns: create listing +# -gstabs: have the assembler create line number information; note that +# for use in COFF files, additional information about filenames +# and function names needs to be present in the assembler source +# files -- see avr-libc docs [FIXME: not yet described there] +# -listing-cont-lines: Sets the maximum number of continuation lines of hex +# dump that will be displayed for a given single line of source input. +ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100 + + +#---------------- Library Options ---------------- +# Minimalistic printf version +PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min + +# Floating point printf version (requires MATH_LIB = -lm below) +PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt + +# If this is left blank, then it will use the Standard printf version. +PRINTF_LIB = +#PRINTF_LIB = $(PRINTF_LIB_MIN) +#PRINTF_LIB = $(PRINTF_LIB_FLOAT) + + +# Minimalistic scanf version +SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min + +# Floating point + %[ scanf version (requires MATH_LIB = -lm below) +SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt + +# If this is left blank, then it will use the Standard scanf version. +SCANF_LIB = +#SCANF_LIB = $(SCANF_LIB_MIN) +#SCANF_LIB = $(SCANF_LIB_FLOAT) + + +MATH_LIB = -lm + + +# List any extra directories to look for libraries here. +# Each directory must be seperated by a space. +# Use forward slashes for directory separators. +# For a directory that has spaces, enclose it in quotes. +EXTRALIBDIRS = + + + +#---------------- External Memory Options ---------------- + +# 64 KB of external RAM, starting after internal RAM (ATmega128!), +# used for variables (.data/.bss) and heap (malloc()). +#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff + +# 64 KB of external RAM, starting after internal RAM (ATmega128!), +# only used for heap (malloc()). +#EXTMEMOPTS = -Wl,--section-start,.data=0x801100,--defsym=__heap_end=0x80ffff + +EXTMEMOPTS = + + + +#---------------- Linker Options ---------------- +# -Wl,...: tell GCC to pass this to linker. +# -Map: create map file +# --cref: add cross reference to map file +LDFLAGS = -Wl,-Map=$(TARGET).map,--cref +LDFLAGS += -Wl,--section-start=.text=$(BOOT_START) +LDFLAGS += -Wl,--relax +LDFLAGS += -Wl,--gc-sections +LDFLAGS += $(EXTMEMOPTS) +LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS)) +LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB) +#LDFLAGS += -T linker_script.x + + + +#---------------- Programming Options (avrdude) ---------------- + +# Fuse settings for Arduino Uno DFU bootloader project +AVRDUDE_FUSES = -U efuse:w:0xF4:m -U hfuse:w:0xD9:m -U lfuse:w:0xFF:m + +# Lock settings for Arduino Uno DFU bootloader project +AVRDUDE_LOCK = -U lock:w:0x0F:m + +# Programming hardware +# Type: avrdude -c ? +# to get a full listing. +# +AVRDUDE_PROGRAMMER = avrispmkii + +# com1 = serial port. Use lpt1 to connect to parallel port. +AVRDUDE_PORT = usb + +AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex +#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep + +# Uncomment the following if you want avrdude's erase cycle counter. +# Note that this counter needs to be initialized first using -Yn, +# see avrdude manual. +#AVRDUDE_ERASE_COUNTER = -y + +# Uncomment the following if you do /not/ wish a verification to be +# performed after programming the device. +#AVRDUDE_NO_VERIFY = -V + +# Increase verbosity level. Please use this when submitting bug +# reports about avrdude. See +# to submit bug reports. +#AVRDUDE_VERBOSE = -v -v + +AVRDUDE_FLAGS = -p $(MCU_AVRDUDE) -F -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) +AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY) +AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE) +AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER) + + + +#---------------- Debugging Options ---------------- + +# For simulavr only - target MCU frequency. +DEBUG_MFREQ = $(F_CPU) + +# Set the DEBUG_UI to either gdb or insight. +# DEBUG_UI = gdb +DEBUG_UI = insight + +# Set the debugging back-end to either avarice, simulavr. +DEBUG_BACKEND = avarice +#DEBUG_BACKEND = simulavr + +# GDB Init Filename. +GDBINIT_FILE = __avr_gdbinit + +# When using avarice settings for the JTAG +JTAG_DEV = /dev/com1 + +# Debugging port used to communicate between GDB / avarice / simulavr. +DEBUG_PORT = 4242 + +# Debugging host used to communicate between GDB / avarice / simulavr, normally +# just set to localhost unless doing some sort of crazy debugging when +# avarice is running on a different computer. +DEBUG_HOST = localhost + + + +#============================================================================ + + +# Define programs and commands. +SHELL = sh +CC = avr-gcc +OBJCOPY = avr-objcopy +OBJDUMP = avr-objdump +SIZE = avr-size +AR = avr-ar rcs +NM = avr-nm +AVRDUDE = avrdude +REMOVE = rm -f +REMOVEDIR = rm -rf +COPY = cp +WINSHELL = cmd + + +# Define Messages +# English +MSG_ERRORS_NONE = Errors: none +MSG_BEGIN = -------- begin -------- +MSG_END = -------- end -------- +MSG_SIZE_BEFORE = Size before: +MSG_SIZE_AFTER = Size after: +MSG_COFF = Converting to AVR COFF: +MSG_EXTENDED_COFF = Converting to AVR Extended COFF: +MSG_FLASH = Creating load file for Flash: +MSG_EEPROM = Creating load file for EEPROM: +MSG_EXTENDED_LISTING = Creating Extended Listing: +MSG_SYMBOL_TABLE = Creating Symbol Table: +MSG_LINKING = Linking: +MSG_COMPILING = Compiling C: +MSG_COMPILING_CPP = Compiling C++: +MSG_ASSEMBLING = Assembling: +MSG_CLEANING = Cleaning project: +MSG_CREATING_LIBRARY = Creating library: + + + + +# Define all object files. +OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) + +# Define all listing files. +LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) + + +# Compiler flags to generate dependency files. +GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d + + +# Combine all necessary flags and optional flags. +# Add target processor to flags. +ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS) +ALL_CPPFLAGS = -mmcu=$(MCU) -I. -x c++ $(CPPFLAGS) $(GENDEPFLAGS) +ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) + + + + + +# Default target. +all: begin gccversion sizebefore build sizeafter end + +# Change the build target to build a HEX file or a library. +build: elf hex eep lss sym +#build: lib + + +elf: $(TARGET).elf +hex: $(TARGET).hex +eep: $(TARGET).eep +lss: $(TARGET).lss +sym: $(TARGET).sym +LIBNAME=lib$(TARGET).a +lib: $(LIBNAME) + + + +# Eye candy. +# AVR Studio 3.x does not check make's exit code but relies on +# the following magic strings to be generated by the compile job. +begin: + @echo + @echo $(MSG_BEGIN) + +end: + @echo $(MSG_END) + @echo + + +# Display size of file. +HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex +ELFSIZE = $(SIZE) $(MCU_FLAG) $(FORMAT_FLAG) $(TARGET).elf +MCU_FLAG = $(shell $(SIZE) --help | grep -- --mcu > /dev/null && echo --mcu=$(MCU) ) +FORMAT_FLAG = $(shell $(SIZE) --help | grep -- --format=.*avr > /dev/null && echo --format=avr ) + + +sizebefore: + @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \ + 2>/dev/null; echo; fi + +sizeafter: + @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \ + 2>/dev/null; echo; fi + + + +# Display compiler version information. +gccversion : + @$(CC) --version + + +# Program the device. +program: $(TARGET).hex $(TARGET).eep + $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) $(AVRDUDE_FUSES) $(AVRDUDE_LOCK) + + +# Generate avr-gdb config/init file which does the following: +# define the reset signal, load the target file, connect to target, and set +# a breakpoint at main(). +gdb-config: + @$(REMOVE) $(GDBINIT_FILE) + @echo define reset >> $(GDBINIT_FILE) + @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) + @echo end >> $(GDBINIT_FILE) + @echo file $(TARGET).elf >> $(GDBINIT_FILE) + @echo target remote $(DEBUG_HOST):$(DEBUG_PORT) >> $(GDBINIT_FILE) +ifeq ($(DEBUG_BACKEND),simulavr) + @echo load >> $(GDBINIT_FILE) +endif + @echo break main >> $(GDBINIT_FILE) + +debug: gdb-config $(TARGET).elf +ifeq ($(DEBUG_BACKEND), avarice) + @echo Starting AVaRICE - Press enter when "waiting to connect" message displays. + @$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \ + $(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT) + @$(WINSHELL) /c pause + +else + @$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \ + $(DEBUG_MFREQ) --port $(DEBUG_PORT) +endif + @$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE) + + + + +# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. +COFFCONVERT = $(OBJCOPY) --debugging +COFFCONVERT += --change-section-address .data-0x800000 +COFFCONVERT += --change-section-address .bss-0x800000 +COFFCONVERT += --change-section-address .noinit-0x800000 +COFFCONVERT += --change-section-address .eeprom-0x810000 + + + +coff: $(TARGET).elf + @echo + @echo $(MSG_COFF) $(TARGET).cof + $(COFFCONVERT) -O coff-avr $< $(TARGET).cof + + +extcoff: $(TARGET).elf + @echo + @echo $(MSG_EXTENDED_COFF) $(TARGET).cof + $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof + + + +# Create final output files (.hex, .eep) from ELF output file. +%.hex: %.elf + @echo + @echo $(MSG_FLASH) $@ + $(OBJCOPY) -O $(FORMAT) -R .eeprom -R .fuse -R .lock $< $@ + +%.eep: %.elf + @echo + @echo $(MSG_EEPROM) $@ + -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ + --change-section-lma .eeprom=0 --no-change-warnings -O $(FORMAT) $< $@ || exit 0 + +# Create extended listing file from ELF output file. +%.lss: %.elf + @echo + @echo $(MSG_EXTENDED_LISTING) $@ + $(OBJDUMP) -h -S -z $< > $@ + +# Create a symbol table from ELF output file. +%.sym: %.elf + @echo + @echo $(MSG_SYMBOL_TABLE) $@ + $(NM) -n $< > $@ + + + +# Create library from object files. +.SECONDARY : $(TARGET).a +.PRECIOUS : $(OBJ) +%.a: $(OBJ) + @echo + @echo $(MSG_CREATING_LIBRARY) $@ + $(AR) $@ $(OBJ) + + +# Link: create ELF output file from object files. +.SECONDARY : $(TARGET).elf +.PRECIOUS : $(OBJ) +%.elf: $(OBJ) + @echo + @echo $(MSG_LINKING) $@ + $(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS) + + +# Compile: create object files from C source files. +$(OBJDIR)/%.o : %.c + @echo + @echo $(MSG_COMPILING) $< + $(CC) -c $(ALL_CFLAGS) $< -o $@ + + +# Compile: create object files from C++ source files. +$(OBJDIR)/%.o : %.cpp + @echo + @echo $(MSG_COMPILING_CPP) $< + $(CC) -c $(ALL_CPPFLAGS) $< -o $@ + + +# Compile: create assembler files from C source files. +%.s : %.c + $(CC) -S $(ALL_CFLAGS) $< -o $@ + + +# Compile: create assembler files from C++ source files. +%.s : %.cpp + $(CC) -S $(ALL_CPPFLAGS) $< -o $@ + + +# Assemble: create object files from assembler source files. +$(OBJDIR)/%.o : %.S + @echo + @echo $(MSG_ASSEMBLING) $< + $(CC) -c $(ALL_ASFLAGS) $< -o $@ + + +# Create preprocessed source for use in sending a bug report. +%.i : %.c + $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ + + +# Target: clean project. +clean: begin clean_list end + +clean_list : + @echo + @echo $(MSG_CLEANING) + $(REMOVE) $(TARGET).hex + $(REMOVE) $(TARGET).eep + $(REMOVE) $(TARGET).cof + $(REMOVE) $(TARGET).elf + $(REMOVE) $(TARGET).map + $(REMOVE) $(TARGET).sym + $(REMOVE) $(TARGET).lss + $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.o) + $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.lst) + $(REMOVE) $(SRC:.c=.s) + $(REMOVE) $(SRC:.c=.d) + $(REMOVE) $(SRC:.c=.i) + $(REMOVEDIR) .dep + +doxygen: + @echo Generating Project Documentation... + @doxygen Doxygen.conf + @echo Documentation Generation Complete. + +clean_doxygen: + rm -rf Documentation + +# Create object files directory +$(shell mkdir $(OBJDIR) 2>/dev/null) + + +# Include the dependency files. +-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) + + +# Listing of phony targets. +.PHONY : all begin finish end sizebefore sizeafter gccversion \ +build elf hex eep lss sym coff extcoff doxygen clean \ +clean_list clean_doxygen program debug gdb-config diff --git a/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbdfu/readme.txt b/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbdfu/readme.txt new file mode 100644 index 0000000..e376679 --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbdfu/readme.txt @@ -0,0 +1,7 @@ +To setup the project and program an ATMEG8U2 with the Arduino USB DFU bootloader: +1. unpack the source into LUFA's Bootloader directory +2. set ARDUINO_MODEL_PID in the makefile as appropriate +3. do "make clean; make; make program" + +Check that the board enumerates as either "Arduino Uno DFU" or "Arduino Mega 2560 DFU". Test by uploading the Arduino-usbserial application firmware (see instructions in Arduino-usbserial directory) + diff --git a/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbserial/Arduino-usbserial-mega.hex b/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbserial/Arduino-usbserial-mega.hex new file mode 100644 index 0000000..fbbeb07 --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbserial/Arduino-usbserial-mega.hex @@ -0,0 +1,256 @@ +:10000000A2C00000BBC00000B9C00000B7C0000023 +:10001000B5C00000B3C00000B1C00000AFC0000018 +:10002000ADC00000ABC00000A9C000005AC4000071 +:100030001EC40000A3C00000A1C000009FC00000BB +:100040009DC000009BC0000099C0000097C0000048 +:1000500095C0000093C0000091C0000014C10000D2 +:100060008DC000008BC0000089C0000087C0000068 +:1000700085C0000083C0000081C000007FC0000078 +:100080007DC000007BC0000079C0000077C0000088 +:1000900075C0000073C000001201100102000008CA +:1000A0004123100001000102DC0109023E000201AF +:1000B00000C0320904000001020201000524000111 +:1000C0001004240206052406000107058203080027 +:1000D000FF09040100020A000000070504024000B5 +:1000E00001070583024000010403090432034100B3 +:1000F00072006400750069006E006F002000280027 +:100100007700770077002E006100720064007500B0 +:1001100069006E006F002E0063006300290000007C +:100120002403410072006400750069006E006F00D6 +:1001300020004D006500670061002000320035009E +:1001400036003000000011241FBECFEFD2E0DEBF2A +:10015000CDBF11E0A0E0B1E0E0EDFFE002C005900E +:100160000D92A631B107D9F712E0A6E1B1E001C0C6 +:100170001D92AF32B107E1F7F1D028C741CF9C0102 +:10018000DC01AE57BF4FED91FC9111974191119653 +:10019000FC93EE9380589F4FE817F90711F42D93C5 +:1001A0003C939FB7F894F901EC57FF4F8081815041 +:1001B00080839FBF842F0895DF92EF92FF920F9369 +:1001C0001F93FC018489813019F0823021F405C02D +:1001D00040E3D42E04C0DD2402C030E2D32E838954 +:1001E000823011F488E0D82A8589873031F0883050 +:1001F00031F0863031F482E003C084E001C086E053 +:10020000D82A1092C9001092C8001092CA00E78440 +:10021000F0880189128980E0E81681EEF80680E016 +:10022000080780E0180719F420E130E00FC0C8018A +:10023000B701969587957795679560587B47814E6E +:100240009F4FA8019701A0D6215030403093CD0098 +:100250002093CC00D092CA0080E0E81681EEF80628 +:1002600080E0080780E0180711F082E001C080E01C +:100270008093C80088E98093C9001F910F91FF9077 +:10028000EF90DF9008951F920F920FB60F921124F6 +:100290002F938F939F93EF93FF939091CE008EB304 +:1002A0008430F1F4E0919901F0919A019083E0910A +:1002B0009901F0919A01CF01019690939A01809350 +:1002C00099018959914021F489E191E092838183D8 +:1002D0009FB7F89480919D018F5F80939D019FBF90 +:1002E000FF91EF919F918F912F910F900FBE0F90E3 +:1002F0001F901895FC01858580FF02C05F980895C6 +:100300005F9A089580E091E0D5C580E091E088C5CE +:1003100084B7877F84BF28E10FB6F89420936000EC +:10032000109260000FBE87E690E09093CD0080931E +:10033000CC0086E08093CA001092C8002093C900C8 +:10034000539A5A9A8AB180638AB98BB180638BB908 +:1003500083D284E085BD5F9A579A08950F931F93C7 +:10036000CF93DF93D5DF2FB7F8948EE991E0909388 +:100370001F0280931E0290932102809320022FBFC0 +:100380002FB7F89489E191E090939A0180939901B5 +:1003900090939C0180939B012FBF7894CEE9D1E08C +:1003A00003E08FB7F894909122028FBF903809F143 +:1003B00080E091E0ABD497FD1CC0E0911E02F0916B +:1003C0001F028083E0911E02F0911F02CF0101966F +:1003D00090931F0280931E028E51924011F4D2839B +:1003E000C1839FB7F894809122028F5F809322028D +:1003F0009FBF8FB7F89410919D018FBFA89902C03D +:10040000113678F1A89A80919D01882361F05D985A +:100410000093160108C089E191E0B1DE682F80E009 +:1004200091E0DAD411501123B1F78091160188239D +:1004300051F0809116018150809316018091160130 +:10044000882309F45D9A80911701882351F08091E7 +:10045000170181508093170180911701882309F4B7 +:100460005C9A8FB7F894909122028FBF992369F01C +:100470008EE991E084DE982F8091C80085FFFCCF43 +:100480009093CE005C980093170180E091E095D4A2 +:100490002AD487CFDA01923049F0933061F091305D +:1004A000F9F4E8E9F0E022E130E01EC0EAEAF0E029 +:1004B0002EE330E019C0813049F0813018F08230ED +:1004C00079F408C0E8EEF0E0849107C0ECEEF0E0CB +:1004D000849103C0E0E2F1E08491282F30E004C071 +:1004E000E0E0F0E020E030E0ED93FC93C9010895F6 +:1004F00028E030E040E003C04F5F220F331F281791 +:100500003907D0F3842F8295807F08958093E90086 +:100510008091EB0081608093EB001092ED0060937E +:10052000EC004093ED008091EE00881F8827881F23 +:1005300008951092F40090E09093E9001092F0007A +:100540001092E8001092ED008091EB008E7F809376 +:10055000EB009F5F953081F70895809127028823F3 +:100560008CF403C08EB38823B1F08091E80082FF41 +:10057000F9CF8091E8008B778093E80008958EB3DF +:10058000882349F08091E80080FFF9CF8091E8004E +:100590008E778093E800089594E68091EC0080FFC8 +:1005A00005C08091E80080FF05C023C08091E8006D +:1005B00082FD1FC08EB3882311F482E008958EB3AC +:1005C000853011F483E008958091EB0085FF02C02F +:1005D00081E008958091E10082FFDFCF8091E1000A +:1005E0008B7F8093E100992311F484E0089591506A +:1005F000D4CF80E008959C0140912D0250912E02AD +:100600004617570718F4F90120E038C06115710545 +:1006100011F0AB01F8CF8091E8008E778093E8006D +:1006200040E050E0F0CF8091E80083FF02C081E01D +:1006300008958091E80082FD2DC08EB3882381F15A +:100640008EB3853079F18091E80080FF17C09091DA +:10065000F20006C081918093F100415050409F5FAD +:100660004115510511F09830A8F320E0983009F4B5 +:1006700021E08091E8008E778093E80041155105D4 +:1006800091F6222381F606C08EB3882349F08EB3FB +:10069000853041F08091E80082FFF6CF80E0089538 +:1006A00082E0089583E008959C0140912D025091CD +:1006B0002E024617570710F490E03BC061157105F4 +:1006C00011F0AB01F9CF8091E8008E778093E800BC +:1006D00040E050E0F1CF8091E80083FF02C081E06C +:1006E00008958091E80082FD30C08EB3882399F18F +:1006F0008EB3853091F18091E80080FF1AC080911F +:10070000F20009C0F9012F5F3F4FE491E093F1003F +:10071000415050408F5F4115510511F0883090F3E2 +:1007200090E0883009F491E08091E8008E77809322 +:10073000E8004115510579F6992369F606C08EB394 +:10074000882349F08EB3853041F08091E80082FF24 +:10075000F6CF80E0089582E0089583E008959C013B +:100760006115710529F48091E8008B778093E8008A +:10077000F90120C08091E80083FF02C081E0089564 +:100780008EB3882339F18EB3853031F18091E80042 +:1007900082FFF0CF06C08091F100819361507040DC +:1007A00021F08091F2008823B1F78091E8008B77E7 +:1007B0008093E80061157105E9F606C08EB38823C1 +:1007C00049F08EB3853041F08091E80080FFF6CF8C +:1007D00080E0089582E0089583E0089542D044D0F7 +:1007E0001EBA10922502109224021092230284E075 +:1007F00089BD89B5826089BD09B400FEFDCF8091B5 +:10080000D800982F9F779093D80080688093D80065 +:10081000809163008E7F809363008091D8008F7DEC +:100820008093D8008091E0008E7F8093E0008091DB +:10083000E1008E7F8093E1008091E20081608093EF +:10084000E2008091E100877F8093E1008091E200E7 +:1008500088608093E2000895C1DF81E080932602E2 +:1008600008951092E20008951092E10008951F92F9 +:100870000F920FB60F9211241F932F933F934F9314 +:100880005F936F937F938F939F93AF93BF93EF93F8 +:10089000FF93E9EEF0E0108117701082E0EFF0E0D6 +:1008A0008081877F80837894C3D0F894A9EEB0E0EC +:1008B0001C92E0EFF0E08081886080831C93FF91C0 +:1008C000EF91BF91AF919F918F917F916F915F91C8 +:1008D0004F913F912F911F910F900FBE0F901F903E +:1008E00018951F920F920FB60F9211242F933F93DA +:1008F0004F935F936F937F938F939F93AF93BF9328 +:10090000EF93FF938091E10080FF1BC08091E20094 +:1009100080FF17C08091E1008E7F8093E10080917D +:10092000E2008E7F8093E2008091E20080618093FC +:10093000E2008091D80080628093D80019BC1EBA72 +:10094000D1D18091E10084FF29C08091E20084FF31 +:1009500025C084E089BD89B5826089BD09B400FEE7 +:10096000FDCF8091D8008F7D8093D8008091E100E9 +:100970008F7E8093E1008091E2008F7E8093E20081 +:100980008091E20081608093E200809125028823BB +:1009900011F481E001C084E08EBBA4D18091E1001C +:1009A00083FF27C08091E20083FF23C08091E10094 +:1009B000877F8093E10082E08EBB109225028091B8 +:1009C000E1008E7F8093E1008091E2008E7F809332 +:1009D000E2008091E20080618093E200AADD80E085 +:1009E00060E042E093DD8091F00088608093F00049 +:1009F00079D18091E10082FF0AC08091E20082FFFC +:100A000006C08091E1008B7F8093E1006BD1FF9164 +:100A1000EF91BF91AF919F918F917F916F915F9176 +:100A20004F913F912F910F900FBE0F901F901895EF +:100A30001F93DF93CF93CDB7DEB7AC970FB6F89483 +:100A4000DEBF0FBECDBFE7E2F2E08091F1008193FF +:100A500022E0EF32F207C9F7809127023091280295 +:100A6000353009F487C0363040F43130C9F13130C7 +:100A700070F0333009F01DC133C0383009F4EFC0D5 +:100A8000393009F4FEC0363009F013C192C0803805 +:100A900021F0823809F00DC108C0909123028091A5 +:100AA0002402882399F0926011C080912B028770F4 +:100AB0008093E9008091EB0090E025E09695879582 +:100AC0002A95E1F7982F91701092E9008091E80043 +:100AD000877F8093E8009093F1001092F100CAC0E4 +:100AE000882319F0823009F0E4C090E08F71907093 +:100AF000009721F0029709F0DDC00CC08091290217 +:100B0000813009F0D7C010922402333069F5809308 +:100B100024022AC080912902882331F520912B02DA +:100B2000277009F4C7C02093E9008091EB0080FF93 +:100B3000C1C0333021F48091EB00806213C08091FA +:100B4000EB0080618093EB0081E090E002C0880FB1 +:100B5000991F2A95E2F78093EA001092EA008091AB +:100B6000EB0088608093EB001092E9008091E80030 +:100B7000877F83C0882309F09CC01091290280914F +:100B8000E800877F8093E800E8DC04C08EB3882308 +:100B900009F490C08091E80080FFF8CF812F8F7713 +:100BA00011F492E001C093E09EBB80688093E30063 +:100BB00081C08058823008F07CC0809129029091D9 +:100BC0002A0223E08C3D920799F55FB7F894DE0185 +:100BD00015964EE020E030E061E2E42FF0E0609313 +:100BE0005700849120FF03C082958F704F5F982F2C +:100BF0009F70892F805D8A3308F0895F8C931196EE +:100C00001C9211972F5F3F4F12962431310529F71F +:100C10005FBF8AE28B8383E08C838091E800877FCB +:100C20008093E800CE0103966AE270E0E4DC11C034 +:100C300060912B02AE014F5F5F4F2CDCBC0100972F +:100C4000C9F18091E800877F8093E80089819A81CB +:100C50002BDD8091E8008B778093E8002BC08038F3 +:100C600041F58091E800877F8093E800809125021C +:100C70008093F1008091E8008E778093E8006DDC2E +:100C800019C08823B1F490912902923098F4809190 +:100C9000E800877F8093E800909325025EDC8091D6 +:100CA0002502882311F483E001C084E08EBB2DDB94 +:100CB00001C028DB8091E80083FF0AC08091EB002F +:100CC00080628093EB008091E800877F8093E8004A +:100CD000AC960FB6F894DEBF0FBECDBFCF91DF91BB +:100CE0001F91089508951F938EB3882361F010918A +:100CF000E9001092E9008091E80083FF01C098DECE +:100D000017701093E9001F9108950895FC018EB3A8 +:100D1000843021F587859089A189B2890097A10542 +:100D2000B105E1F085818093E9008091E80082FFC0 +:100D300015C08091F200882319F42FEF3FEF04C013 +:100D40008091F100282F30E08091F200882341F457 +:100D50008091E8008B778093E80002C02FEF3FEF8F +:100D6000C9010895FC018EB3843011F587859089FF +:100D7000A189B2890097A105B105D1F08181809345 +:100D8000E9008091F2008823A9F09091E800809119 +:100D9000E8008E778093E80095FD0CC0FDDB982F6E +:100DA000882349F48091E8008E778093E80003C09F +:100DB00092E001C090E0892F0895FC018EB3843049 +:100DC00051F487859089A189B2890097A105B10561 +:100DD00011F0CF01C7CF08951F93FC01162F8EB3DA +:100DE0008430D9F487859089A189B2890097A105BB +:100DF000B10599F081818093E9008091E80085FD3B +:100E000008C08091E8008E778093E800C5DB8823D6 +:100E100029F41093F10080E001C082E01F91089551 +:100E20000F931F93CF93DF93EC010D96FC0189E0A4 +:100E3000DF011D928A95E9F72A813B8109818C8126 +:100E4000882311F410E001C014E0C90151DB182B14 +:100E50001260802F61E8412F59DB882329F12E8110 +:100E60003F810D818885882311F410E001C014E0D2 +:100E7000C9013EDB182B1260802F60E8412F46DB52 +:100E8000882391F02A853B8509858C85882311F478 +:100E900010E001C014E0C9012BDB182B1260802F79 +:100EA00061EC412F33DB01C080E0DF91CF911F91D6 +:100EB0000F910895CF93DF93EC018091E80083FFB9 +:100EC00060C0888190E020912B0230912C0228177D +:100ED000390709F056C080912802813261F08232D0 +:100EE00020F4803209F04DC019C0823269F183329A +:100EF00009F047C038C080912702813A09F041C00B +:100F00008091E800877F8093E800CE010F9667E02C +:100F100070E071DB8091E8008B7713C0809127022D +:100F2000813279F58091E800877F8093E800CE01D7 +:100F30000F9667E070E013DCCE013ED98091E800A7 +:100F40008E778093E8001DC0809127028132C9F41A +:100F50008091E800877F8093E800809129028D8747 +:100F6000CE01C8D90DC080912702813251F4809101 +:100F7000E800877F8093E800CE0160912902C5DEFA +:100F8000ECDADF91CF910895A1E21A2EAA1BBB1BC8 +:100F9000FD010DC0AA1FBB1FEE1FFF1FA217B30745 +:100FA000E407F50720F0A21BB30BE40BF50B661F5B +:100FB000771F881F991F1A9469F76095709580951F +:100FC00090959B01AC01BD01CF010895F894FFCF2E +:100FD0000003400000044000000208000000000080 +:060FE0000000000000000B +:00000001FF diff --git a/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbserial/Arduino-usbserial-uno.hex b/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbserial/Arduino-usbserial-uno.hex new file mode 100644 index 0000000..ca51dfa --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbserial/Arduino-usbserial-uno.hex @@ -0,0 +1,256 @@ +:100000009CC00000B5C00000B3C00000B1C000003B +:10001000AFC00000ADC00000ABC00000A9C0000030 +:10002000A7C00000A5C00000A3C0000054C4000089 +:1000300018C400009DC000009BC0000099C00000D3 +:1000400097C0000095C0000093C0000091C0000060 +:100050008FC000008DC000008BC000000EC10000EA +:1000600087C0000085C0000083C0000081C0000080 +:100070007FC000007DC000007BC0000079C0000090 +:1000800077C0000075C0000073C0000071C00000A0 +:100090006FC000006DC000001201100102000008D6 +:1000A0004123010001000102DC0109023E000201BE +:1000B00000C0320904000001020201000524000111 +:1000C0001004240206052406000107058203080027 +:1000D000FF09040100020A000000070504024000B5 +:1000E00001070583024000010403090432034100B3 +:1000F00072006400750069006E006F002000280027 +:100100007700770077002E006100720064007500B0 +:1001100069006E006F002E0063006300290000007C +:100120001803410072006400750069006E006F00E2 +:10013000200055006E006F00000011241FBECFEF9D +:10014000D2E0DEBFCDBF11E0A0E0B1E0E4ECFFE023 +:1001500002C005900D92A631B107D9F712E0A6E1D1 +:10016000B1E001C01D92AF32B107E1F7F1D028C76D +:1001700047CF9C01DC01AE57BF4FED91FC91119729 +:1001800041911196FC93EE9380589F4FE817F90721 +:1001900011F42D933C939FB7F894F901EC57FF4F5E +:1001A0008081815080839FBF842F0895DF92EF92DA +:1001B000FF920F931F93FC018489813019F08230E4 +:1001C00021F405C040E3D42E04C0DD2402C030E297 +:1001D000D32E8389823011F488E0D82A858987302C +:1001E00031F0883031F0863031F482E003C084E0B1 +:1001F00001C086E0D82A1092C9001092C80010925F +:10020000CA00E784F0880189128980E0E81681EE4F +:10021000F80680E0080780E0180719F420E130E0D4 +:100220000FC0C801B7019695879577956795605877 +:100230007B47814E9F4FA8019701A0D621503040A7 +:100240003093CD002093CC00D092CA0080E0E81615 +:1002500081EEF80680E0080780E0180711F082E0E0 +:1002600001C080E08093C80088E98093C9001F9195 +:100270000F91FF90EF90DF9008951F920F920FB6AD +:100280000F9211242F938F939F93EF93FF9390914D +:10029000CE008EB38430F1F4E0919901F0919A018F +:1002A0009083E0919901F0919A01CF01019690938A +:1002B0009A01809399018959914021F489E191E053 +:1002C000928381839FB7F89480919D018F5F809383 +:1002D0009D019FBFFF91EF919F918F912F910F9063 +:1002E0000FBE0F901F901895FC01858580FF02C0FE +:1002F0005F9808955F9A089580E091E0D5C580E009 +:1003000091E088C584B7877F84BF28E10FB6F89451 +:1003100020936000109260000FBE87E690E09093FB +:10032000CD008093CC0086E08093CA001092C80074 +:100330002093C900539A5A9A8AB180638AB98BB1C3 +:1003400080638BB983D284E085BD5F9A579A089504 +:100350000F931F93CF93DF93D5DF2FB7F8948EE9D8 +:1003600091E090931F0280931E029093210280934C +:1003700020022FBF2FB7F89489E191E090939A0162 +:100380008093990190939C0180939B012FBF789457 +:10039000CEE9D1E003E08FB7F894909122028FBFAD +:1003A000903809F180E091E0ABD497FD1CC0E0915A +:1003B0001E02F0911F028083E0911E02F0911F0245 +:1003C000CF01019690931F0280931E028E5192409E +:1003D00011F4D283C1839FB7F894809122028F5F7A +:1003E000809322029FBF8FB7F89410919D018FBF19 +:1003F000A89902C0113678F1A89A80919D018823AE +:1004000061F05D980093160108C089E191E0B1DECA +:10041000682F80E091E0DAD411501123B1F7809178 +:100420001601882351F080911601815080931601A6 +:1004300080911601882309F45D9A80911701882321 +:1004400051F080911701815080931701809117011D +:10045000882309F45C9A8FB7F894909122028FBF99 +:10046000992369F08EE991E084DE982F8091C8008D +:1004700085FFFCCF9093CE005C980093170180E03D +:1004800091E095D42AD487CFDA01923049F09330A5 +:1004900061F09130F9F4E8E9F0E022E130E01EC0CB +:1004A000EAEAF0E02EE330E019C0813049F0813013 +:1004B00018F0823079F408C0E8EEF0E0849107C0CB +:1004C000ECEEF0E0849103C0E0E2F1E08491282FAB +:1004D00030E004C0E0E0F0E020E030E0ED93FC9399 +:1004E000C901089528E030E040E003C04F5F220FCB +:1004F000331F28173907D0F3842F8295807F089502 +:100500008093E9008091EB0081608093EB00109272 +:10051000ED006093EC004093ED008091EE00881FA9 +:100520008827881F08951092F40090E09093E900C6 +:100530001092F0001092E8001092ED008091EB0014 +:100540008E7F8093EB009F5F953081F708958091B7 +:10055000270288238CF403C08EB38823B1F08091E6 +:10056000E80082FFF9CF8091E8008B778093E80064 +:1005700008958EB3882349F08091E80080FFF9CF79 +:100580008091E8008E778093E800089594E680914A +:10059000EC0080FF05C08091E80080FF05C023C00B +:1005A0008091E80082FD1FC08EB3882311F482E0A1 +:1005B00008958EB3853011F483E008958091EB00A7 +:1005C00085FF02C081E008958091E10082FFDFCFC6 +:1005D0008091E1008B7F8093E100992311F484E006 +:1005E00008959150D4CF80E008959C0140912D0250 +:1005F00050912E024617570718F4F90120E038C031 +:100600006115710511F0AB01F8CF8091E8008E778C +:100610008093E80040E050E0F0CF8091E80083FF55 +:1006200002C081E008958091E80082FD2DC08EB364 +:10063000882381F18EB3853079F18091E80080FFC5 +:1006400017C09091F20006C081918093F100415053 +:1006500050409F5F4115510511F09830A8F320E0FC +:10066000983009F421E08091E8008E778093E800CB +:100670004115510591F6222381F606C08EB38823D9 +:1006800049F08EB3853041F08091E80082FFF6CFCB +:1006900080E0089582E0089583E008959C014091F0 +:1006A0002D0250912E024617570710F490E03BC0E0 +:1006B0006115710511F0AB01F9CF8091E8008E77DB +:1006C0008093E80040E050E0F1CF8091E80083FFA4 +:1006D00002C081E008958091E80082FD30C08EB3B1 +:1006E000882399F18EB3853091F18091E80080FFE5 +:1006F0001AC08091F20009C0F9012F5F3F4FE491C9 +:10070000E093F100415050408F5F4115510511F0C9 +:10071000883090F390E0883009F491E08091E8000F +:100720008E778093E8004115510579F6992369F693 +:1007300006C08EB3882349F08EB3853041F0809196 +:10074000E80082FFF6CF80E0089582E0089583E01C +:1007500008959C016115710529F48091E8008B775B +:100760008093E800F90120C08091E80083FF02C077 +:1007700081E008958EB3882339F18EB3853031F14D +:100780008091E80082FFF0CF06C08091F100819354 +:100790006150704021F08091F2008823B1F7809180 +:1007A000E8008B778093E80061157105E9F606C0D3 +:1007B0008EB3882349F08EB3853041F08091E800F4 +:1007C00080FFF6CF80E0089582E0089583E00895E9 +:1007D00042D044D01EBA10922502109224021092E8 +:1007E000230284E089BD89B5826089BD09B400FE19 +:1007F000FDCF8091D800982F9F779093D800806884 +:100800008093D800809163008E7F809363008091F5 +:10081000D8008F7D8093D8008091E0008E7F8093F8 +:10082000E0008091E1008E7F8093E1008091E20002 +:1008300081608093E2008091E100877F8093E100F6 +:100840008091E20088608093E2000895C1DF81E03A +:100850008093260208951092E20008951092E1001C +:1008600008951F920F920FB60F9211241F932F938A +:100870003F934F935F936F937F938F939F93AF9328 +:10088000BF93EF93FF93E9EEF0E0108117701082B1 +:10089000E0EFF0E08081877F80837894C3D0F89484 +:1008A000A9EEB0E01C92E0EFF0E0808188608083E8 +:1008B0001C93FF91EF91BF91AF919F918F917F9189 +:1008C0006F915F914F913F912F911F910F900FBEAC +:1008D0000F901F9018951F920F920FB60F92112430 +:1008E0002F933F934F935F936F937F938F939F9338 +:1008F000AF93BF93EF93FF938091E10080FF1BC004 +:100900008091E20080FF17C08091E1008E7F80938C +:10091000E1008091E2008E7F8093E2008091E2000E +:1009200080618093E2008091D80080628093D8003B +:1009300019BC1EBAD1D18091E10084FF29C08091F9 +:10094000E20084FF25C084E089BD89B5826089BD4D +:1009500009B400FEFDCF8091D8008F7D8093D80030 +:100960008091E1008F7E8093E1008091E2008F7E94 +:100970008093E2008091E20081608093E2008091A8 +:100980002502882311F481E001C084E08EBBA4D14C +:100990008091E10083FF27C08091E20083FF23C0A4 +:1009A0008091E100877F8093E10082E08EBB10920E +:1009B00025028091E1008E7F8093E1008091E2002A +:1009C0008E7F8093E2008091E20080618093E2005C +:1009D000AADD80E060E042E093DD8091F000886075 +:1009E0008093F00079D18091E10082FF0AC080916C +:1009F000E20082FF06C08091E1008B7F8093E100DE +:100A00006BD1FF91EF91BF91AF919F918F917F91AA +:100A10006F915F914F913F912F910F900FBE0F906B +:100A20001F9018951F93DF93CF93CDB7DEB7AC9788 +:100A30000FB6F894DEBF0FBECDBFE7E2F2E08091C3 +:100A4000F100819322E0EF32F207C9F7809127028B +:100A500030912802353009F487C0363040F4313007 +:100A6000C9F1313070F0333009F01DC133C0383076 +:100A700009F4EFC0393009F4FEC0363009F013C173 +:100A800092C0803821F0823809F00DC108C09091E1 +:100A9000230280912402882399F0926011C08091F2 +:100AA0002B0287708093E9008091EB0090E025E0B5 +:100AB000969587952A95E1F7982F91701092E90005 +:100AC0008091E800877F8093E8009093F100109276 +:100AD000F100CAC0882319F0823009F0E4C090E028 +:100AE0008F719070009721F0029709F0DDC00CC063 +:100AF00080912902813009F0D7C01092240233304E +:100B000069F5809324022AC080912902882331F557 +:100B100020912B02277009F4C7C02093E90080912F +:100B2000EB0080FFC1C0333021F48091EB00806284 +:100B300013C08091EB0080618093EB0081E090E036 +:100B400002C0880F991F2A95E2F78093EA0010925D +:100B5000EA008091EB0088608093EB001092E9003E +:100B60008091E800877F83C0882309F09CC01091A2 +:100B700029028091E800877F8093E800E8DC04C0C8 +:100B80008EB3882309F490C08091E80080FFF8CFED +:100B9000812F8F7711F492E001C093E09EBB8068B3 +:100BA0008093E30081C08058823008F07CC080913F +:100BB000290290912A0223E08C3D920799F55FB7B4 +:100BC000F894DE0115964EE020E030E061E2E42F7B +:100BD000F0E060935700849120FF03C082958F70EE +:100BE0004F5F982F9F70892F805D8A3308F0895F4F +:100BF0008C9311961C9211972F5F3F4F12962431C0 +:100C0000310529F75FBF8AE28B8383E08C83809173 +:100C1000E800877F8093E800CE0103966AE270E0E7 +:100C2000E4DC11C060912B02AE014F5F5F4F2CDC02 +:100C3000BC010097C9F18091E800877F8093E800AC +:100C400089819A812BDD8091E8008B778093E80081 +:100C50002BC0803841F58091E800877F8093E800C1 +:100C6000809125028093F1008091E8008E77809337 +:100C7000E8006DDC19C08823B1F49091290292300C +:100C800098F48091E800877F8093E8009093250294 +:100C90005EDC80912502882311F483E001C084E0AA +:100CA0008EBB2DDB01C028DB8091E80083FF0AC0EA +:100CB0008091EB0080628093EB008091E800877F59 +:100CC0008093E800AC960FB6F894DEBF0FBECDBFA0 +:100CD000CF91DF911F91089508951F938EB38823BC +:100CE00061F01091E9001092E9008091E80083FF23 +:100CF00001C098DE17701093E9001F9108950895C0 +:100D0000FC018EB3843021F587859089A189B28951 +:100D10000097A105B105E1F085818093E9008091FC +:100D2000E80082FF15C08091F200882319F42FEFAC +:100D30003FEF04C08091F100282F30E08091F20055 +:100D4000882341F48091E8008B778093E80002C00B +:100D50002FEF3FEFC9010895FC018EB3843011F5E8 +:100D600087859089A189B2890097A105B105D1F045 +:100D700081818093E9008091F2008823A9F090910D +:100D8000E8008091E8008E778093E80095FD0CC024 +:100D9000FDDB982F882349F48091E8008E778093BB +:100DA000E80003C092E001C090E0892F0895FC01A3 +:100DB0008EB3843051F487859089A189B2890097D8 +:100DC000A105B10511F0CF01C7CF08951F93FC0114 +:100DD000162F8EB38430D9F487859089A189B28982 +:100DE0000097A105B10599F081818093E900809178 +:100DF000E80085FD08C08091E8008E778093E800C8 +:100E0000C5DB882329F41093F10080E001C082E063 +:100E10001F9108950F931F93CF93DF93EC010D96CD +:100E2000FC0189E0DF011D928A95E9F72A813B8167 +:100E300009818C81882311F410E001C014E0C901FC +:100E400051DB182B1260802F61E8412F59DB88237A +:100E500029F12E813F810D818885882311F410E0CE +:100E600001C014E0C9013EDB182B1260802F60E83E +:100E7000412F46DB882391F02A853B8509858C85A7 +:100E8000882311F410E001C014E0C9012BDB182BFA +:100E90001260802F61EC412F33DB01C080E0DF91D5 +:100EA000CF911F910F910895CF93DF93EC01809123 +:100EB000E80083FF60C0888190E020912B02309190 +:100EC0002C022817390709F056C080912802813278 +:100ED00061F0823220F4803209F04DC019C08232B4 +:100EE00069F1833209F047C038C080912702813A06 +:100EF00009F041C08091E800877F8093E800CE012F +:100F00000F9667E070E071DB8091E8008B7713C08B +:100F100080912702813279F58091E800877F809364 +:100F2000E800CE010F9667E070E013DCCE013ED9F9 +:100F30008091E8008E778093E8001DC080912702A1 +:100F40008132C9F48091E800877F8093E800809126 +:100F500029028D87CE01C8D90DC080912702813228 +:100F600051F48091E800877F8093E800CE01609182 +:100F70002902C5DEECDADF91CF910895A1E21A2EA5 +:100F8000AA1BBB1BFD010DC0AA1FBB1FEE1FFF1F2D +:100F9000A217B307E407F50720F0A21BB30BE40B7D +:100FA000F50B661F771F881F991F1A9469F76095C4 +:100FB0007095809590959B01AC01BD01CF0108957E +:040FC000F894FFCFD3 +:100FC400000340000004400000020800000000008C +:060FD40000000000000017 +:00000001FF diff --git a/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbserial/Arduino-usbserial.c b/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbserial/Arduino-usbserial.c new file mode 100644 index 0000000..4de73c8 --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbserial/Arduino-usbserial.c @@ -0,0 +1,242 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim 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, 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. +*/ + +/** \file + * + * Main source file for the Arduino-usbserial project. This file contains the main tasks of + * the project and is responsible for the initial application hardware configuration. + */ + +#include "Arduino-usbserial.h" + +/** Circular buffer to hold data from the host before it is sent to the device via the serial port. */ +RingBuff_t USBtoUSART_Buffer; + +/** Circular buffer to hold data from the serial port before it is sent to the host. */ +RingBuff_t USARTtoUSB_Buffer; + +/** Pulse generation counters to keep track of the number of milliseconds remaining for each pulse type */ +volatile struct +{ + uint8_t TxLEDPulse; /**< Milliseconds remaining for data Tx LED pulse */ + uint8_t RxLEDPulse; /**< Milliseconds remaining for data Rx LED pulse */ + uint8_t PingPongLEDPulse; /**< Milliseconds remaining for enumeration Tx/Rx ping-pong LED pulse */ +} PulseMSRemaining; + +/** LUFA CDC Class driver interface configuration and state information. This structure is + * passed to all CDC Class driver functions, so that multiple instances of the same class + * within a device can be differentiated from one another. + */ +USB_ClassInfo_CDC_Device_t VirtualSerial_CDC_Interface = + { + .Config = + { + .ControlInterfaceNumber = 0, + + .DataINEndpointNumber = CDC_TX_EPNUM, + .DataINEndpointSize = CDC_TXRX_EPSIZE, + .DataINEndpointDoubleBank = false, + + .DataOUTEndpointNumber = CDC_RX_EPNUM, + .DataOUTEndpointSize = CDC_TXRX_EPSIZE, + .DataOUTEndpointDoubleBank = false, + + .NotificationEndpointNumber = CDC_NOTIFICATION_EPNUM, + .NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE, + .NotificationEndpointDoubleBank = false, + }, + }; + +/** Main program entry point. This routine contains the overall program flow, including initial + * setup of all components and the main program loop. + */ +int main(void) +{ + SetupHardware(); + + RingBuffer_InitBuffer(&USBtoUSART_Buffer); + RingBuffer_InitBuffer(&USARTtoUSB_Buffer); + + sei(); + + for (;;) + { + /* Only try to read in bytes from the CDC interface if the transmit buffer is not full */ + if (!(RingBuffer_IsFull(&USBtoUSART_Buffer))) + { + int16_t ReceivedByte = CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface); + + /* Read bytes from the USB OUT endpoint into the USART transmit buffer */ + if (!(ReceivedByte < 0)) + RingBuffer_Insert(&USBtoUSART_Buffer, ReceivedByte); + } + + /* Check if the UART receive buffer flush timer has expired or the buffer is nearly full */ + RingBuff_Count_t BufferCount = RingBuffer_GetCount(&USARTtoUSB_Buffer); + if ((TIFR0 & (1 << TOV0)) || (BufferCount > BUFFER_NEARLY_FULL)) + { + TIFR0 |= (1 << TOV0); + + if (USARTtoUSB_Buffer.Count) { + LEDs_TurnOnLEDs(LEDMASK_TX); + PulseMSRemaining.TxLEDPulse = TX_RX_LED_PULSE_MS; + } + + /* Read bytes from the USART receive buffer into the USB IN endpoint */ + while (BufferCount--) + CDC_Device_SendByte(&VirtualSerial_CDC_Interface, RingBuffer_Remove(&USARTtoUSB_Buffer)); + + /* Turn off TX LED(s) once the TX pulse period has elapsed */ + if (PulseMSRemaining.TxLEDPulse && !(--PulseMSRemaining.TxLEDPulse)) + LEDs_TurnOffLEDs(LEDMASK_TX); + + /* Turn off RX LED(s) once the RX pulse period has elapsed */ + if (PulseMSRemaining.RxLEDPulse && !(--PulseMSRemaining.RxLEDPulse)) + LEDs_TurnOffLEDs(LEDMASK_RX); + } + + /* Load the next byte from the USART transmit buffer into the USART */ + if (!(RingBuffer_IsEmpty(&USBtoUSART_Buffer))) { + Serial_TxByte(RingBuffer_Remove(&USBtoUSART_Buffer)); + + LEDs_TurnOnLEDs(LEDMASK_RX); + PulseMSRemaining.RxLEDPulse = TX_RX_LED_PULSE_MS; + } + + CDC_Device_USBTask(&VirtualSerial_CDC_Interface); + USB_USBTask(); + } +} + +/** Configures the board hardware and chip peripherals for the demo's functionality. */ +void SetupHardware(void) +{ + /* Disable watchdog if enabled by bootloader/fuses */ + MCUSR &= ~(1 << WDRF); + wdt_disable(); + + /* Hardware Initialization */ + Serial_Init(9600, false); + LEDs_Init(); + USB_Init(); + + /* Start the flush timer so that overflows occur rapidly to push received bytes to the USB interface */ + TCCR0B = (1 << CS02); + + /* Pull target /RESET line high */ + AVR_RESET_LINE_PORT |= AVR_RESET_LINE_MASK; + AVR_RESET_LINE_DDR |= AVR_RESET_LINE_MASK; +} + +/** Event handler for the library USB Configuration Changed event. */ +void EVENT_USB_Device_ConfigurationChanged(void) +{ + CDC_Device_ConfigureEndpoints(&VirtualSerial_CDC_Interface); +} + +/** Event handler for the library USB Unhandled Control Request event. */ +void EVENT_USB_Device_UnhandledControlRequest(void) +{ + CDC_Device_ProcessControlRequest(&VirtualSerial_CDC_Interface); +} + +/** Event handler for the CDC Class driver Line Encoding Changed event. + * + * \param[in] CDCInterfaceInfo Pointer to the CDC class interface configuration structure being referenced + */ +void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) +{ + uint8_t ConfigMask = 0; + + switch (CDCInterfaceInfo->State.LineEncoding.ParityType) + { + case CDC_PARITY_Odd: + ConfigMask = ((1 << UPM11) | (1 << UPM10)); + break; + case CDC_PARITY_Even: + ConfigMask = (1 << UPM11); + break; + } + + if (CDCInterfaceInfo->State.LineEncoding.CharFormat == CDC_LINEENCODING_TwoStopBits) + ConfigMask |= (1 << USBS1); + + switch (CDCInterfaceInfo->State.LineEncoding.DataBits) + { + case 6: + ConfigMask |= (1 << UCSZ10); + break; + case 7: + ConfigMask |= (1 << UCSZ11); + break; + case 8: + ConfigMask |= ((1 << UCSZ11) | (1 << UCSZ10)); + break; + } + + /* Must turn off USART before reconfiguring it, otherwise incorrect operation may occur */ + UCSR1B = 0; + UCSR1A = 0; + UCSR1C = 0; + + /* Special case 57600 baud for compatibility with the ATmega328 bootloader. */ + UBRR1 = (CDCInterfaceInfo->State.LineEncoding.BaudRateBPS == 57600) + ? SERIAL_UBBRVAL(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS) + : SERIAL_2X_UBBRVAL(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS); + + UCSR1C = ConfigMask; + UCSR1A = (CDCInterfaceInfo->State.LineEncoding.BaudRateBPS == 57600) ? 0 : (1 << U2X1); + UCSR1B = ((1 << RXCIE1) | (1 << TXEN1) | (1 << RXEN1)); +} + +/** ISR to manage the reception of data from the serial port, placing received bytes into a circular buffer + * for later transmission to the host. + */ +ISR(USART1_RX_vect, ISR_BLOCK) +{ + uint8_t ReceivedByte = UDR1; + + if (USB_DeviceState == DEVICE_STATE_Configured) + RingBuffer_Insert(&USARTtoUSB_Buffer, ReceivedByte); +} + +/** Event handler for the CDC Class driver Host-to-Device Line Encoding Changed event. + * + * \param[in] CDCInterfaceInfo Pointer to the CDC class interface configuration structure being referenced + */ +void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) +{ + bool CurrentDTRState = (CDCInterfaceInfo->State.ControlLineStates.HostToDevice & CDC_CONTROL_LINE_OUT_DTR); + + if (CurrentDTRState) + AVR_RESET_LINE_PORT &= ~AVR_RESET_LINE_MASK; + else + AVR_RESET_LINE_PORT |= AVR_RESET_LINE_MASK; +} diff --git a/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbserial/Arduino-usbserial.h b/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbserial/Arduino-usbserial.h new file mode 100644 index 0000000..99fde39 --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbserial/Arduino-usbserial.h @@ -0,0 +1,79 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim 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, 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. +*/ + +/** \file + * + * Header file for Arduino-usbserial.c. + */ + +#ifndef _ARDUINO_USBSERIAL_H_ +#define _ARDUINO_USBSERIAL_H_ + + /* Includes: */ + #include + #include + #include + #include + + #include "Descriptors.h" + + #include "Lib/LightweightRingBuff.h" + + #include + #include + #include + #include + #include + + /* Macros: */ + /** LED mask for the library LED driver, to indicate TX activity. */ + #define LEDMASK_TX LEDS_LED1 + + /** LED mask for the library LED driver, to indicate RX activity. */ + #define LEDMASK_RX LEDS_LED2 + + /** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ + #define LEDMASK_ERROR (LEDS_LED1 | LEDS_LED2) + + /** LED mask for the library LED driver, to indicate that the USB interface is busy. */ + #define LEDMASK_BUSY (LEDS_LED1 | LEDS_LED2) + + /* Function Prototypes: */ + void SetupHardware(void); + + void EVENT_USB_Device_Connect(void); + void EVENT_USB_Device_Disconnect(void); + void EVENT_USB_Device_ConfigurationChanged(void); + void EVENT_USB_Device_UnhandledControlRequest(void); + + void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo); + void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo); + +#endif /* _ARDUINO_USBSERIAL_H_ */ diff --git a/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbserial/Board/LEDs.h b/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbserial/Board/LEDs.h new file mode 100644 index 0000000..152e8f5 --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbserial/Board/LEDs.h @@ -0,0 +1,110 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim 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, 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. +*/ + +/* + Board LEDs driver for the Benito board, from www.dorkbotpdx.org. +*/ + +#ifndef __LEDS_ARDUINOUNO_H__ +#define __LEDS_ARDUINOUNO_H__ + + /* Includes: */ + #include + +/* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(INCLUDE_FROM_LEDS_H) + #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** LED mask for the first LED on the board. */ + #define LEDS_LED1 (1 << 5) + + /** LED mask for the second LED on the board. */ + #define LEDS_LED2 (1 << 4) + + /** LED mask for all the LEDs on the board. */ + #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2) + + /** LED mask for the none of the board LEDs */ + #define LEDS_NO_LEDS 0 + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void LEDs_Init(void) + { + DDRD |= LEDS_ALL_LEDS; + PORTD |= LEDS_ALL_LEDS; + } + + static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) + { + PORTD &= ~LEDMask; + } + + static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) + { + PORTD |= LEDMask; + } + + static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) + { + PORTD = ((PORTD | LEDS_ALL_LEDS) & ~LEDMask); + } + + static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, const uint8_t ActiveMask) + { + PORTD = ((PORTD | ActiveMask) & ~LEDMask); + } + + static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) + { + PORTD ^= LEDMask; + } + + static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t LEDs_GetLEDs(void) + { + return (PORTD & LEDS_ALL_LEDS); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif diff --git a/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbserial/Descriptors.c b/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbserial/Descriptors.c new file mode 100644 index 0000000..705dddf --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbserial/Descriptors.c @@ -0,0 +1,277 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim 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, 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. +*/ + +/** \file + * + * USB Device Descriptors, for library use when in USB device mode. Descriptors are special + * computer-readable structures which the host requests upon device enumeration, to determine + * the device's capabilities and functions. + */ + +#include "Descriptors.h" + +/* On some devices, there is a factory set internal serial number which can be automatically sent to the host as + * the device's serial number when the Device Descriptor's .SerialNumStrIndex entry is set to USE_INTERNAL_SERIAL. + * This allows the host to track a device across insertions on different ports, allowing them to retain allocated + * resources like COM port numbers and drivers. On demos using this feature, give a warning on unsupported devices + * so that the user can supply their own serial number descriptor instead or remove the USE_INTERNAL_SERIAL value + * from the Device Descriptor (forcing the host to generate a serial number for each device from the VID, PID and + * port location). + */ +#if (USE_INTERNAL_SERIAL == NO_DESCRIPTOR) + #warning USE_INTERNAL_SERIAL is not available on this AVR - please manually construct a device serial descriptor. +#endif + +/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall + * device characteristics, including the supported USB version, control endpoint size and the + * number of device configurations. The descriptor is read out by the USB host when the enumeration + * process begins. + */ +USB_Descriptor_Device_t PROGMEM DeviceDescriptor = +{ + .Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device}, + + .USBSpecification = VERSION_BCD(01.10), + .Class = 0x02, + .SubClass = 0x00, + .Protocol = 0x00, + + .Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE, + + .VendorID = 0x03EB, // Atmel + + .ProductID = 0x204B, // LUFA USB to Serial Demo Application + .ReleaseNumber = 0x0001, + + .ManufacturerStrIndex = 0x01, + .ProductStrIndex = 0x02, + .SerialNumStrIndex = USE_INTERNAL_SERIAL, + + .NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS +}; + +/** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage + * of the device in one of its supported configurations, including information about any device interfaces + * and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting + * a configuration so that the host may correctly communicate with the USB device. + */ +USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = +{ + .Config = + { + .Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration}, + + .TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t), + .TotalInterfaces = 2, + + .ConfigurationNumber = 1, + .ConfigurationStrIndex = NO_DESCRIPTOR, + + .ConfigAttributes = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED), + + .MaxPowerConsumption = USB_CONFIG_POWER_MA(100) + }, + + .CDC_CCI_Interface = + { + .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, + + .InterfaceNumber = 0, + .AlternateSetting = 0, + + .TotalEndpoints = 1, + + .Class = 0x02, + .SubClass = 0x02, + .Protocol = 0x01, + + .InterfaceStrIndex = NO_DESCRIPTOR + }, + + .CDC_Functional_IntHeader = + { + .Header = {.Size = sizeof(CDC_FUNCTIONAL_DESCRIPTOR(2)), .Type = 0x24}, + .SubType = 0x00, + + .Data = {0x01, 0x10} + }, + + .CDC_Functional_AbstractControlManagement = + { + .Header = {.Size = sizeof(CDC_FUNCTIONAL_DESCRIPTOR(1)), .Type = 0x24}, + .SubType = 0x02, + + .Data = {0x06} + }, + + .CDC_Functional_Union = + { + .Header = {.Size = sizeof(CDC_FUNCTIONAL_DESCRIPTOR(2)), .Type = 0x24}, + .SubType = 0x06, + + .Data = {0x00, 0x01} + }, + + .CDC_NotificationEndpoint = + { + .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, + + .EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC_NOTIFICATION_EPNUM), + .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), + .EndpointSize = CDC_NOTIFICATION_EPSIZE, + .PollingIntervalMS = 0xFF + }, + + .CDC_DCI_Interface = + { + .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, + + .InterfaceNumber = 1, + .AlternateSetting = 0, + + .TotalEndpoints = 2, + + .Class = 0x0A, + .SubClass = 0x00, + .Protocol = 0x00, + + .InterfaceStrIndex = NO_DESCRIPTOR + }, + + .CDC_DataOutEndpoint = + { + .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, + + .EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_OUT | CDC_RX_EPNUM), + .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), + .EndpointSize = CDC_TXRX_EPSIZE, + .PollingIntervalMS = 0x01 + }, + + .CDC_DataInEndpoint = + { + .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, + + .EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC_TX_EPNUM), + .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), + .EndpointSize = CDC_TXRX_EPSIZE, + .PollingIntervalMS = 0x01 + } +}; + +/** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests + * the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate + * via the language ID table available at USB.org what languages the device supports for its string descriptors. + */ +USB_Descriptor_String_t PROGMEM LanguageString = +{ + .Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String}, + + .UnicodeString = {LANGUAGE_ID_ENG} +}; + +/** Manufacturer descriptor string. This is a Unicode string containing the manufacturer's details in human readable + * form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device + * Descriptor. + */ +USB_Descriptor_String_t PROGMEM ManufacturerString = +{ + .Header = {.Size = USB_STRING_LEN(24), .Type = DTYPE_String}, + + .UnicodeString = L"Arduino (www.arduino.cc)" +}; + +/** Product descriptor string. This is a Unicode string containing the product's details in human readable form, + * and is read out upon request by the host when the appropriate string ID is requested, listed in the Device + * Descriptor. + */ +USB_Descriptor_String_t PROGMEM ProductString = +{ + #if (ARDUINO_MODEL_PID == ARDUINO_UNO_PID) + .Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String}, + + .UnicodeString = L"Arduino Uno" + #elif (ARDUINO_MODEL_PID == ARDUINO_MEGA2560_PID) + .Header = {.Size = USB_STRING_LEN(17), .Type = DTYPE_String}, + + .UnicodeString = L"Arduino Mega 2560" + #endif + +}; + +/** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors" + * documentation) by the application code so that the address and size of a requested descriptor can be given + * to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function + * is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the + * USB host. + */ +uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, + const uint8_t wIndex, + void** const DescriptorAddress) +{ + const uint8_t DescriptorType = (wValue >> 8); + const uint8_t DescriptorNumber = (wValue & 0xFF); + + void* Address = NULL; + uint16_t Size = NO_DESCRIPTOR; + + switch (DescriptorType) + { + case DTYPE_Device: + Address = (void*)&DeviceDescriptor; + Size = sizeof(USB_Descriptor_Device_t); + break; + case DTYPE_Configuration: + Address = (void*)&ConfigurationDescriptor; + Size = sizeof(USB_Descriptor_Configuration_t); + break; + case DTYPE_String: + switch (DescriptorNumber) + { + case 0x00: + Address = (void*)&LanguageString; + Size = pgm_read_byte(&LanguageString.Header.Size); + break; + case 0x01: + Address = (void*)&ManufacturerString; + Size = pgm_read_byte(&ManufacturerString.Header.Size); + break; + case 0x02: + Address = (void*)&ProductString; + Size = pgm_read_byte(&ProductString.Header.Size); + break; + } + + break; + } + + *DescriptorAddress = Address; + return Size; +} diff --git a/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbserial/Descriptors.h b/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbserial/Descriptors.h new file mode 100644 index 0000000..3ac4e52 --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbserial/Descriptors.h @@ -0,0 +1,88 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim 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, 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. +*/ + +/** \file + * + * Header file for Descriptors.c. + */ + +#ifndef _DESCRIPTORS_H_ +#define _DESCRIPTORS_H_ + + /* Includes: */ + #include + + #include + #include + + /* Product-specific definitions: */ + #define ARDUINO_UNO_PID 0x0001 + #define ARDUINO_MEGA2560_PID 0x0010 + + /* Macros: */ + /** Endpoint number of the CDC device-to-host notification IN endpoint. */ + #define CDC_NOTIFICATION_EPNUM 2 + + /** Endpoint number of the CDC device-to-host data IN endpoint. */ + #define CDC_TX_EPNUM 3 + + /** Endpoint number of the CDC host-to-device data OUT endpoint. */ + #define CDC_RX_EPNUM 4 + + /** Size in bytes of the CDC device-to-host notification IN endpoint. */ + #define CDC_NOTIFICATION_EPSIZE 8 + + /** Size in bytes of the CDC data IN and OUT endpoints. */ + #define CDC_TXRX_EPSIZE 64 + + /* Type Defines: */ + /** Type define for the device configuration descriptor structure. This must be defined in the + * application code, as the configuration descriptor contains several sub-descriptors which + * vary between devices, and which describe the device's usage to the host. + */ + typedef struct + { + USB_Descriptor_Configuration_Header_t Config; + USB_Descriptor_Interface_t CDC_CCI_Interface; + CDC_FUNCTIONAL_DESCRIPTOR(2) CDC_Functional_IntHeader; + CDC_FUNCTIONAL_DESCRIPTOR(1) CDC_Functional_AbstractControlManagement; + CDC_FUNCTIONAL_DESCRIPTOR(2) CDC_Functional_Union; + USB_Descriptor_Endpoint_t CDC_NotificationEndpoint; + USB_Descriptor_Interface_t CDC_DCI_Interface; + USB_Descriptor_Endpoint_t CDC_DataOutEndpoint; + USB_Descriptor_Endpoint_t CDC_DataInEndpoint; + } USB_Descriptor_Configuration_t; + + /* Function Prototypes: */ + uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, + const uint8_t wIndex, + void** const DescriptorAddress) ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); + +#endif diff --git a/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbserial/Lib/LightweightRingBuff.h b/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbserial/Lib/LightweightRingBuff.h new file mode 100644 index 0000000..fb48c1f --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbserial/Lib/LightweightRingBuff.h @@ -0,0 +1,197 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim 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, 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. +*/ + +/** \file + * + * Ultra lightweight ring buffer, for fast insertion/deletion. + */ + +#ifndef _ULW_RING_BUFF_H_ +#define _ULW_RING_BUFF_H_ + + /* Includes: */ + #include + + #include + #include + + /* Defines: */ + /** Size of each ring buffer, in data elements - must be between 1 and 255. */ + #define BUFFER_SIZE 128 + + /** Maximum number of data elements to buffer before forcing a flush. + * Must be less than BUFFER_SIZE + */ + #define BUFFER_NEARLY_FULL 96 + + /** Type of data to store into the buffer. */ + #define RingBuff_Data_t uint8_t + + /** Datatype which may be used to store the count of data stored in a buffer, retrieved + * via a call to \ref RingBuffer_GetCount(). + */ + #if (BUFFER_SIZE <= 0xFF) + #define RingBuff_Count_t uint8_t + #else + #define RingBuff_Count_t uint16_t + #endif + + /* Type Defines: */ + /** Type define for a new ring buffer object. Buffers should be initialized via a call to + * \ref RingBuffer_InitBuffer() before use. + */ + typedef struct + { + RingBuff_Data_t Buffer[BUFFER_SIZE]; /**< Internal ring buffer data, referenced by the buffer pointers. */ + RingBuff_Data_t* In; /**< Current storage location in the circular buffer */ + RingBuff_Data_t* Out; /**< Current retrieval location in the circular buffer */ + RingBuff_Count_t Count; + } RingBuff_t; + + /* Inline Functions: */ + /** Initializes a ring buffer ready for use. Buffers must be initialized via this function + * before any operations are called upon them. Already initialized buffers may be reset + * by re-initializing them using this function. + * + * \param[out] Buffer Pointer to a ring buffer structure to initialize + */ + static inline void RingBuffer_InitBuffer(RingBuff_t* const Buffer) + { + ATOMIC_BLOCK(ATOMIC_RESTORESTATE) + { + Buffer->In = Buffer->Buffer; + Buffer->Out = Buffer->Buffer; + } + } + + /** Retrieves the minimum number of bytes stored in a particular buffer. This value is computed + * by entering an atomic lock on the buffer while the IN and OUT locations are fetched, so that + * the buffer cannot be modified while the computation takes place. This value should be cached + * when reading out the contents of the buffer, so that as small a time as possible is spent + * in an atomic lock. + * + * \note The value returned by this function is guaranteed to only be the minimum number of bytes + * stored in the given buffer; this value may change as other threads write new data and so + * the returned number should be used only to determine how many successive reads may safely + * be performed on the buffer. + * + * \param[in] Buffer Pointer to a ring buffer structure whose count is to be computed + */ + static inline RingBuff_Count_t RingBuffer_GetCount(RingBuff_t* const Buffer) + { + RingBuff_Count_t Count; + + ATOMIC_BLOCK(ATOMIC_RESTORESTATE) + { + Count = Buffer->Count; + } + + return Count; + } + + /** Atomically determines if the specified ring buffer contains any free space. This should + * be tested before storing data to the buffer, to ensure that no data is lost due to a + * buffer overrun. + * + * \param[in,out] Buffer Pointer to a ring buffer structure to insert into + * + * \return Boolean true if the buffer contains no free space, false otherwise + */ + static inline bool RingBuffer_IsFull(RingBuff_t* const Buffer) + { + return (RingBuffer_GetCount(Buffer) == BUFFER_SIZE); + } + + /** Atomically determines if the specified ring buffer contains any data. This should + * be tested before removing data from the buffer, to ensure that the buffer does not + * underflow. + * + * If the data is to be removed in a loop, store the total number of bytes stored in the + * buffer (via a call to the \ref RingBuffer_GetCount() function) in a temporary variable + * to reduce the time spent in atomicity locks. + * + * \param[in,out] Buffer Pointer to a ring buffer structure to insert into + * + * \return Boolean true if the buffer contains no free space, false otherwise + */ + static inline bool RingBuffer_IsEmpty(RingBuff_t* const Buffer) + { + return (RingBuffer_GetCount(Buffer) == 0); + } + + /** Inserts an element into the ring buffer. + * + * \note Only one execution thread (main program thread or an ISR) may insert into a single buffer + * otherwise data corruption may occur. Insertion and removal may occur from different execution + * threads. + * + * \param[in,out] Buffer Pointer to a ring buffer structure to insert into + * \param[in] Data Data element to insert into the buffer + */ + static inline void RingBuffer_Insert(RingBuff_t* const Buffer, + const RingBuff_Data_t Data) + { + *Buffer->In = Data; + + if (++Buffer->In == &Buffer->Buffer[BUFFER_SIZE]) + Buffer->In = Buffer->Buffer; + + ATOMIC_BLOCK(ATOMIC_RESTORESTATE) + { + Buffer->Count++; + } + } + + /** Removes an element from the ring buffer. + * + * \note Only one execution thread (main program thread or an ISR) may remove from a single buffer + * otherwise data corruption may occur. Insertion and removal may occur from different execution + * threads. + * + * \param[in,out] Buffer Pointer to a ring buffer structure to retrieve from + * + * \return Next data element stored in the buffer + */ + static inline RingBuff_Data_t RingBuffer_Remove(RingBuff_t* const Buffer) + { + RingBuff_Data_t Data = *Buffer->Out; + + if (++Buffer->Out == &Buffer->Buffer[BUFFER_SIZE]) + Buffer->Out = Buffer->Buffer; + + ATOMIC_BLOCK(ATOMIC_RESTORESTATE) + { + Buffer->Count--; + } + + return Data; + } + +#endif diff --git a/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbserial/makefile b/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbserial/makefile new file mode 100644 index 0000000..79d6be2 --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbserial/makefile @@ -0,0 +1,776 @@ +# Hey Emacs, this is a -*- makefile -*- +#---------------------------------------------------------------------------- +# WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al. +# >> Modified for use with the LUFA project. << +# +# Released to the Public Domain +# +# Additional material for this makefile was written by: +# Peter Fleury +# Tim Henigan +# Colin O'Flynn +# Reiner Patommel +# Markus Pfaff +# Sander Pool +# Frederik Rouleau +# Carlos Lamas +# Dean Camera +# Opendous Inc. +# Denver Gingerich +# +#---------------------------------------------------------------------------- +# On command line: +# +# make all = Make software. +# +# make clean = Clean out built project files. +# +# make coff = Convert ELF to AVR COFF. +# +# make extcoff = Convert ELF to AVR Extended COFF. +# +# make program = Download the hex file to the device, using avrdude. +# Please customize the avrdude settings below first! +# +# make dfu = Download the hex file to the device, using dfu-programmer (must +# have dfu-programmer installed). +# +# make flip = Download the hex file to the device, using Atmel FLIP (must +# have Atmel FLIP installed). +# +# make dfu-ee = Download the eeprom file to the device, using dfu-programmer +# (must have dfu-programmer installed). +# +# make flip-ee = Download the eeprom file to the device, using Atmel FLIP +# (must have Atmel FLIP installed). +# +# make doxygen = Generate DoxyGen documentation for the project (must have +# DoxyGen installed) +# +# make debug = Start either simulavr or avarice as specified for debugging, +# with avr-gdb or avr-insight as the front end for debugging. +# +# make filename.s = Just compile filename.c into the assembler code only. +# +# make filename.i = Create a preprocessed source file for use in submitting +# bug reports to the GCC project. +# +# To rebuild project do "make clean" then "make all". +#---------------------------------------------------------------------------- + +# MCU name(s) +# Since the ATMEGA8U2 part is not directly supported by the current +# versions of either avrdude or dfu-programmer, we specify a dummy +# part; AT90USB82 which is close enough in memory size and organization +MCU = atmega8u2 +MCU_AVRDUDE = at90usb82 +MCU_DFU = at90usb82 + +# Specify the Arduino model using the assigned PID. This is used by Descriptors.c +# to set PID and product descriptor string +# Uno PID: +ARDUINO_MODEL_PID = 0x0001 +# Mega 2560 PID: +#ARDUINO_MODEL_PID = 0x0010 + + +# Target board (see library "Board Types" documentation, NONE for projects not requiring +# LUFA board drivers). If USER is selected, put custom board drivers in a directory called +# "Board" inside the application directory. +BOARD = USER + + +# Processor frequency. +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to +# calculate timings. Do NOT tack on a 'UL' at the end, this will be done +# automatically to create a 32-bit value in your source code. +# +# This will be an integer division of F_CLOCK below, as it is sourced by +# F_CLOCK after it has run through any CPU prescalers. Note that this value +# does not *change* the processor frequency - it should merely be updated to +# reflect the processor speed set externally so that the code can use accurate +# software delays. +F_CPU = 16000000 + + +# Input clock frequency. +# This will define a symbol, F_CLOCK, in all source code files equal to the +# input clock frequency (before any prescaling is performed) in Hz. This value may +# differ from F_CPU if prescaling is used on the latter, and is required as the +# raw input clock is fed directly to the PLL sections of the AVR for high speed +# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' +# at the end, this will be done automatically to create a 32-bit value in your +# source code. +# +# If no clock division is performed on the input clock inside the AVR (via the +# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. +F_CLOCK = $(F_CPU) + + +# Output format. (can be srec, ihex, binary) +FORMAT = ihex + + +# Target file name (without extension). +TARGET = Arduino-usbserial + + +# Object files directory +# To put object files in current directory, use a dot (.), do NOT make +# this an empty or blank macro! +OBJDIR = . + + +# Path to the LUFA library +LUFA_PATH = ../.. + + +# LUFA library compile-time options +LUFA_OPTS = -D USB_DEVICE_ONLY +LUFA_OPTS += -D FIXED_CONTROL_ENDPOINT_SIZE=8 +LUFA_OPTS += -D FIXED_NUM_CONFIGURATIONS=1 +LUFA_OPTS += -D USE_FLASH_DESCRIPTORS +LUFA_OPTS += -D INTERRUPT_CONTROL_ENDPOINT +LUFA_OPTS += -D DEVICE_STATE_AS_GPIOR=0 +LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" + + +# Create the LUFA source path variables by including the LUFA root makefile +include $(LUFA_PATH)/LUFA/makefile + + +# List C source files here. (C dependencies are automatically generated.) +SRC = $(TARGET).c \ + Descriptors.c \ + $(LUFA_SRC_USB) \ + $(LUFA_SRC_USBCLASS) \ + $(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/Device.c \ + $(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/Endpoint.c \ + $(LUFA_PATH)/LUFA/Drivers/USB/HighLevel/HostStandardReq.c \ + $(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/Host.c \ + $(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/Pipe.c \ + $(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/USBController.c \ + $(LUFA_PATH)/LUFA/Drivers/USB/HighLevel/Events.c \ + $(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/USBInterrupt.c \ + $(LUFA_PATH)/LUFA/Drivers/USB/HighLevel/USBTask.c \ + $(LUFA_PATH)/LUFA/Drivers/USB/HighLevel/DeviceStandardReq.c \ + $(LUFA_PATH)/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.c \ + $(LUFA_PATH)/LUFA/Drivers/USB/Class/Device/CDC.c \ + $(LUFA_PATH)/LUFA/Drivers/USB/Class/Host/CDC.c + + +# List C++ source files here. (C dependencies are automatically generated.) +CPPSRC = + + +# List Assembler source files here. +# Make them always end in a capital .S. Files ending in a lowercase .s +# will not be considered source files but generated files (assembler +# output from the compiler), and will be deleted upon "make clean"! +# Even though the DOS/Win* filesystem matches both .s and .S the same, +# it will preserve the spelling of the filenames, and gcc itself does +# care about how the name is spelled on its command-line. +ASRC = + + +# Optimization level, can be [0, 1, 2, 3, s]. +# 0 = turn off optimization. s = optimize for size. +# (Note: 3 is not always the best optimization level. See avr-libc FAQ.) +OPT = s + + +# Debugging format. +# Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs. +# AVR Studio 4.10 requires dwarf-2. +# AVR [Extended] COFF format requires stabs, plus an avr-objcopy run. +DEBUG = dwarf-2 + + +# List any extra directories to look for include files here. +# Each directory must be seperated by a space. +# Use forward slashes for directory separators. +# For a directory that has spaces, enclose it in quotes. +EXTRAINCDIRS = $(LUFA_PATH)/ + + +# Compiler flag to set the C Standard level. +# c89 = "ANSI" C +# gnu89 = c89 plus GCC extensions +# c99 = ISO C99 standard (not yet fully implemented) +# gnu99 = c99 plus GCC extensions +CSTANDARD = -std=gnu99 + + +# Place -D or -U options here for C sources +CDEFS = -DF_CPU=$(F_CPU)UL +CDEFS += -DF_CLOCK=$(F_CLOCK)UL +CDEFS += -DARDUINO_MODEL_PID=$(ARDUINO_MODEL_PID) +CDEFS += -DBOARD=BOARD_$(BOARD) +CDEFS += $(LUFA_OPTS) +CDEFS += -DAVR_RESET_LINE_PORT="PORTD" +CDEFS += -DAVR_RESET_LINE_DDR="DDRD" +CDEFS += -DAVR_RESET_LINE_MASK="(1 << 7)" +CDEFS += -DTX_RX_LED_PULSE_MS=3 +CDEFS += -DPING_PONG_LED_PULSE_MS=100 + +# Place -D or -U options here for ASM sources +ADEFS = -DF_CPU=$(F_CPU) +ADEFS += -DF_CLOCK=$(F_CLOCK)UL +ADEFS += -DBOARD=BOARD_$(BOARD) +ADEFS += $(LUFA_OPTS) + +# Place -D or -U options here for C++ sources +CPPDEFS = -DF_CPU=$(F_CPU)UL +CPPDEFS += -DF_CLOCK=$(F_CLOCK)UL +CPPDEFS += -DBOARD=BOARD_$(BOARD) +CPPDEFS += $(LUFA_OPTS) +#CPPDEFS += -D__STDC_LIMIT_MACROS +#CPPDEFS += -D__STDC_CONSTANT_MACROS + + + +#---------------- Compiler Options C ---------------- +# -g*: generate debugging information +# -O*: optimization level +# -f...: tuning, see GCC manual and avr-libc documentation +# -Wall...: warning level +# -Wa,...: tell GCC to pass this to the assembler. +# -adhlns...: create assembler listing +CFLAGS = -g$(DEBUG) +CFLAGS += $(CDEFS) +CFLAGS += -O$(OPT) +CFLAGS += -funsigned-char +CFLAGS += -funsigned-bitfields +CFLAGS += -ffunction-sections +CFLAGS += -fno-inline-small-functions +CFLAGS += -fpack-struct +CFLAGS += -fshort-enums +CFLAGS += -fno-strict-aliasing +CFLAGS += -Wall +CFLAGS += -Wstrict-prototypes +#CFLAGS += -mshort-calls +#CFLAGS += -fno-unit-at-a-time +#CFLAGS += -Wundef +#CFLAGS += -Wunreachable-code +#CFLAGS += -Wsign-compare +CFLAGS += -Wa,-adhlns=$(<:%.c=$(OBJDIR)/%.lst) +CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) +CFLAGS += $(CSTANDARD) + + +#---------------- Compiler Options C++ ---------------- +# -g*: generate debugging information +# -O*: optimization level +# -f...: tuning, see GCC manual and avr-libc documentation +# -Wall...: warning level +# -Wa,...: tell GCC to pass this to the assembler. +# -adhlns...: create assembler listing +CPPFLAGS = -g$(DEBUG) +CPPFLAGS += $(CPPDEFS) +CPPFLAGS += -O$(OPT) +CPPFLAGS += -funsigned-char +CPPFLAGS += -funsigned-bitfields +CPPFLAGS += -fpack-struct +CPPFLAGS += -fshort-enums +CPPFLAGS += -fno-exceptions +CPPFLAGS += -Wall +CPPFLAGS += -Wundef +CFLAGS += -Wundef +#CPPFLAGS += -mshort-calls +#CPPFLAGS += -fno-unit-at-a-time +#CPPFLAGS += -Wstrict-prototypes +#CPPFLAGS += -Wunreachable-code +#CPPFLAGS += -Wsign-compare +CPPFLAGS += -Wa,-adhlns=$(<:%.cpp=$(OBJDIR)/%.lst) +CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) +#CPPFLAGS += $(CSTANDARD) + + +#---------------- Assembler Options ---------------- +# -Wa,...: tell GCC to pass this to the assembler. +# -adhlns: create listing +# -gstabs: have the assembler create line number information; note that +# for use in COFF files, additional information about filenames +# and function names needs to be present in the assembler source +# files -- see avr-libc docs [FIXME: not yet described there] +# -listing-cont-lines: Sets the maximum number of continuation lines of hex +# dump that will be displayed for a given single line of source input. +ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100 + + +#---------------- Library Options ---------------- +# Minimalistic printf version +PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min + +# Floating point printf version (requires MATH_LIB = -lm below) +PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt + +# If this is left blank, then it will use the Standard printf version. +PRINTF_LIB = +#PRINTF_LIB = $(PRINTF_LIB_MIN) +#PRINTF_LIB = $(PRINTF_LIB_FLOAT) + + +# Minimalistic scanf version +SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min + +# Floating point + %[ scanf version (requires MATH_LIB = -lm below) +SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt + +# If this is left blank, then it will use the Standard scanf version. +SCANF_LIB = +#SCANF_LIB = $(SCANF_LIB_MIN) +#SCANF_LIB = $(SCANF_LIB_FLOAT) + + +MATH_LIB = -lm + + +# List any extra directories to look for libraries here. +# Each directory must be seperated by a space. +# Use forward slashes for directory separators. +# For a directory that has spaces, enclose it in quotes. +EXTRALIBDIRS = + + + +#---------------- External Memory Options ---------------- + +# 64 KB of external RAM, starting after internal RAM (ATmega128!), +# used for variables (.data/.bss) and heap (malloc()). +#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff + +# 64 KB of external RAM, starting after internal RAM (ATmega128!), +# only used for heap (malloc()). +#EXTMEMOPTS = -Wl,--section-start,.data=0x801100,--defsym=__heap_end=0x80ffff + +EXTMEMOPTS = + + + +#---------------- Linker Options ---------------- +# -Wl,...: tell GCC to pass this to linker. +# -Map: create map file +# --cref: add cross reference to map file +LDFLAGS = -Wl,-Map=$(TARGET).map,--cref +LDFLAGS += -Wl,--relax +LDFLAGS += -Wl,--gc-sections +LDFLAGS += $(EXTMEMOPTS) +LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS)) +LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB) +#LDFLAGS += -T linker_script.x + + + +#---------------- Programming Options (avrdude) ---------------- + +# Programming hardware +# Type: avrdude -c ? +# to get a full listing. +# +AVRDUDE_PROGRAMMER = avrispmkii + +# com1 = serial port. Use lpt1 to connect to parallel port. +AVRDUDE_PORT = usb + +AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex +#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep + + +# Uncomment the following if you want avrdude's erase cycle counter. +# Note that this counter needs to be initialized first using -Yn, +# see avrdude manual. +#AVRDUDE_ERASE_COUNTER = -y + +# Uncomment the following if you do /not/ wish a verification to be +# performed after programming the device. +#AVRDUDE_NO_VERIFY = -V + +# Increase verbosity level. Please use this when submitting bug +# reports about avrdude. See +# to submit bug reports. +#AVRDUDE_VERBOSE = -v -v + +AVRDUDE_FORCE = -F + +AVRDUDE_FLAGS = -p $(MCU_AVRDUDE) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) +AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY) +AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE) +AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER) +AVRDUDE_FLAGS += $(AVRDUDE_FORCE) + + + +#---------------- Debugging Options ---------------- + +# For simulavr only - target MCU frequency. +DEBUG_MFREQ = $(F_CPU) + +# Set the DEBUG_UI to either gdb or insight. +# DEBUG_UI = gdb +DEBUG_UI = insight + +# Set the debugging back-end to either avarice, simulavr. +DEBUG_BACKEND = avarice +#DEBUG_BACKEND = simulavr + +# GDB Init Filename. +GDBINIT_FILE = __avr_gdbinit + +# When using avarice settings for the JTAG +JTAG_DEV = /dev/com1 + +# Debugging port used to communicate between GDB / avarice / simulavr. +DEBUG_PORT = 4242 + +# Debugging host used to communicate between GDB / avarice / simulavr, normally +# just set to localhost unless doing some sort of crazy debugging when +# avarice is running on a different computer. +DEBUG_HOST = localhost + + + +#============================================================================ + + +# Define programs and commands. +SHELL = sh +CC = avr-gcc +OBJCOPY = avr-objcopy +OBJDUMP = avr-objdump +SIZE = avr-size +AR = avr-ar rcs +NM = avr-nm +AVRDUDE = avrdude +REMOVE = rm -f +REMOVEDIR = rm -rf +COPY = cp +WINSHELL = cmd + +# Define Messages +# English +MSG_ERRORS_NONE = Errors: none +MSG_BEGIN = -------- begin -------- +MSG_END = -------- end -------- +MSG_SIZE_BEFORE = Size before: +MSG_SIZE_AFTER = Size after: +MSG_COFF = Converting to AVR COFF: +MSG_EXTENDED_COFF = Converting to AVR Extended COFF: +MSG_FLASH = Creating load file for Flash: +MSG_EEPROM = Creating load file for EEPROM: +MSG_EXTENDED_LISTING = Creating Extended Listing: +MSG_SYMBOL_TABLE = Creating Symbol Table: +MSG_LINKING = Linking: +MSG_COMPILING = Compiling C: +MSG_COMPILING_CPP = Compiling C++: +MSG_ASSEMBLING = Assembling: +MSG_CLEANING = Cleaning project: +MSG_CREATING_LIBRARY = Creating library: + + + + +# Define all object files. +OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) + +# Define all listing files. +LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) + + +# Compiler flags to generate dependency files. +GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d + + +# Combine all necessary flags and optional flags. +# Add target processor to flags. +ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS) +ALL_CPPFLAGS = -mmcu=$(MCU) -I. -x c++ $(CPPFLAGS) $(GENDEPFLAGS) +ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) + + + + + +# Default target. +#all: begin gccversion sizebefore build checkinvalidevents showliboptions showtarget sizeafter end +all: begin gccversion sizebefore build showliboptions showtarget sizeafter end + +# Change the build target to build a HEX file or a library. +build: elf hex eep lss sym asm +#build: lib + + +elf: $(TARGET).elf +hex: $(TARGET).hex +eep: $(TARGET).eep +lss: $(TARGET).lss +sym: $(TARGET).sym +asm: $(TARGET).s +LIBNAME=lib$(TARGET).a +lib: $(LIBNAME) + + + +# Eye candy. +# AVR Studio 3.x does not check make's exit code but relies on +# the following magic strings to be generated by the compile job. +begin: + @echo + @echo $(MSG_BEGIN) + +end: + @echo $(MSG_END) + @echo + + +# Display size of file. +HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex +ELFSIZE = $(SIZE) $(MCU_FLAG) $(FORMAT_FLAG) $(TARGET).elf +MCU_FLAG = $(shell $(SIZE) --help | grep -- --mcu > /dev/null && echo --mcu=$(MCU) ) +FORMAT_FLAG = $(shell $(SIZE) --help | grep -- --format=.*avr > /dev/null && echo --format=avr ) + +sizebefore: + @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \ + 2>/dev/null; echo; fi + +sizeafter: + @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \ + 2>/dev/null; echo; fi + +#$(LUFA_PATH)/LUFA/LUFA_Events.lst: +# @make -C $(LUFA_PATH)/LUFA/ LUFA_Events.lst + +#checkinvalidevents: $(LUFA_PATH)/LUFA/LUFA_Events.lst +# @echo +# @echo Checking for invalid events... +# @$(shell) avr-nm $(OBJ) | sed -n -e 's/^.*EVENT_/EVENT_/p' | \ +# grep -F -v --file=$(LUFA_PATH)/LUFA/LUFA_Events.lst > InvalidEvents.tmp || true +# @sed -n -e 's/^/ WARNING - INVALID EVENT NAME: /p' InvalidEvents.tmp +# @if test -s InvalidEvents.tmp; then exit 1; fi + +showliboptions: + @echo + @echo ---- Compile Time Library Options ---- + @for i in $(LUFA_OPTS:-D%=%); do \ + echo $$i; \ + done + @echo -------------------------------------- + +showtarget: + @echo + @echo --------- Target Information --------- + @echo AVR Model: $(MCU) + @echo Board: $(BOARD) + @echo Clock: $(F_CPU)Hz CPU, $(F_CLOCK)Hz Master + @echo -------------------------------------- + + +# Display compiler version information. +gccversion : + @$(CC) --version + + +# Program the device. +program: $(TARGET).hex $(TARGET).eep + $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) + +flip: $(TARGET).hex + batchisp -hardware usb -device $(MCU_DFU) -operation erase f + batchisp -hardware usb -device $(MCU_DFU) -operation loadbuffer $(TARGET).hex program + batchisp -hardware usb -device $(MCU_DFU) -operation start reset 0 + +dfu: $(TARGET).hex + dfu-programmer $(MCU_DFU) erase + dfu-programmer $(MCU_DFU) flash --debug 1 $(TARGET).hex + dfu-programmer $(MCU_DFU) reset + + +flip-ee: $(TARGET).hex $(TARGET).eep + $(COPY) $(TARGET).eep $(TARGET)eep.hex + batchisp -hardware usb -device $(MCU_DFU) -operation memory EEPROM erase + batchisp -hardware usb -device $(MCU_DFU) -operation memory EEPROM loadbuffer $(TARGET)eep.hex program + batchisp -hardware usb -device $(MCU_DFU) -operation start reset 0 + $(REMOVE) $(TARGET)eep.hex + +dfu-ee: $(TARGET).hex $(TARGET).eep + dfu-programmer $(MCU_DFU) flash-eeprom --debug 1 --suppress-bootloader-mem $(TARGET).eep + dfu-programmer $(MCU_DFU) reset + + +# Generate avr-gdb config/init file which does the following: +# define the reset signal, load the target file, connect to target, and set +# a breakpoint at main(). +gdb-config: + @$(REMOVE) $(GDBINIT_FILE) + @echo define reset >> $(GDBINIT_FILE) + @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) + @echo end >> $(GDBINIT_FILE) + @echo file $(TARGET).elf >> $(GDBINIT_FILE) + @echo target remote $(DEBUG_HOST):$(DEBUG_PORT) >> $(GDBINIT_FILE) +ifeq ($(DEBUG_BACKEND),simulavr) + @echo load >> $(GDBINIT_FILE) +endif + @echo break main >> $(GDBINIT_FILE) + +debug: gdb-config $(TARGET).elf +ifeq ($(DEBUG_BACKEND), avarice) + @echo Starting AVaRICE - Press enter when "waiting to connect" message displays. + @$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \ + $(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT) + @$(WINSHELL) /c pause + +else + @$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \ + $(DEBUG_MFREQ) --port $(DEBUG_PORT) +endif + @$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE) + + + + +# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. +COFFCONVERT = $(OBJCOPY) --debugging +COFFCONVERT += --change-section-address .data-0x800000 +COFFCONVERT += --change-section-address .bss-0x800000 +COFFCONVERT += --change-section-address .noinit-0x800000 +COFFCONVERT += --change-section-address .eeprom-0x810000 + + + +coff: $(TARGET).elf + @echo + @echo $(MSG_COFF) $(TARGET).cof + $(COFFCONVERT) -O coff-avr $< $(TARGET).cof + + +extcoff: $(TARGET).elf + @echo + @echo $(MSG_EXTENDED_COFF) $(TARGET).cof + $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof + + + +# Create final output files (.hex, .eep) from ELF output file. +%.hex: %.elf + @echo + @echo $(MSG_FLASH) $@ + $(OBJCOPY) -O $(FORMAT) -R .eeprom -R .fuse -R .lock $< $@ + +%.eep: %.elf + @echo + @echo $(MSG_EEPROM) $@ + -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ + --change-section-lma .eeprom=0 --no-change-warnings -O $(FORMAT) $< $@ || exit 0 + +# Create extended listing file from ELF output file. +%.lss: %.elf + @echo + @echo $(MSG_EXTENDED_LISTING) $@ + $(OBJDUMP) -h -S -z $< > $@ + +# Create a symbol table from ELF output file. +%.sym: %.elf + @echo + @echo $(MSG_SYMBOL_TABLE) $@ + $(NM) -n $< > $@ + + + +# Create library from object files. +.SECONDARY : $(TARGET).a +.PRECIOUS : $(OBJ) +%.a: $(OBJ) + @echo + @echo $(MSG_CREATING_LIBRARY) $@ + $(AR) $@ $(OBJ) + + +# Link: create ELF output file from object files. +.SECONDARY : $(TARGET).elf +.PRECIOUS : $(OBJ) +%.elf: $(OBJ) + @echo + @echo $(MSG_LINKING) $@ + $(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS) + + +# Compile: create object files from C source files. +$(OBJDIR)/%.o : %.c + @echo + @echo $(MSG_COMPILING) $< + $(CC) -c $(ALL_CFLAGS) $< -o $@ + + +# Compile: create object files from C++ source files. +$(OBJDIR)/%.o : %.cpp + @echo + @echo $(MSG_COMPILING_CPP) $< + $(CC) -c $(ALL_CPPFLAGS) $< -o $@ + + +# Compile: create assembler files from C source files. +%.s : %.c + $(CC) -S $(ALL_CFLAGS) $< -o $@ + + +# Compile: create assembler files from C++ source files. +%.s : %.cpp + $(CC) -S $(ALL_CPPFLAGS) $< -o $@ + + +# Assemble: create object files from assembler source files. +$(OBJDIR)/%.o : %.S + @echo + @echo $(MSG_ASSEMBLING) $< + $(CC) -c $(ALL_ASFLAGS) $< -o $@ + + +# Create preprocessed source for use in sending a bug report. +%.i : %.c + $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ + + +# Target: clean project. +clean: begin clean_list clean_binary end + +clean_binary: + $(REMOVE) $(TARGET).hex + +clean_list: + @echo $(MSG_CLEANING) + $(REMOVE) $(TARGET).hex + $(REMOVE) $(TARGET).eep + $(REMOVE) $(TARGET).cof + $(REMOVE) $(TARGET).elf + $(REMOVE) $(TARGET).map + $(REMOVE) $(TARGET).sym + $(REMOVE) $(TARGET).lss + $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.o) + $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.lst) + $(REMOVE) $(SRC:.c=.s) + $(REMOVE) $(SRC:.c=.d) + $(REMOVE) $(SRC:.c=.i) + $(REMOVEDIR) .dep + +doxygen: + @echo Generating Project Documentation... + @doxygen Doxygen.conf + @echo Documentation Generation Complete. + +clean_doxygen: + rm -rf Documentation + +# Create object files directory +$(shell mkdir $(OBJDIR) 2>/dev/null) + + +# Include the dependency files. +-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) + + +# Listing of phony targets. +.PHONY : all begin finish end sizebefore sizeafter gccversion \ +build elf hex eep lss sym coff extcoff doxygen clean \ +clean_list clean_doxygen program dfu flip flip-ee dfu-ee \ +debug gdb-config diff --git a/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbserial/readme.txt b/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbserial/readme.txt new file mode 100644 index 0000000..289326b --- /dev/null +++ b/arduino-0022-linux-x64/hardware/arduino/firmwares/arduino-usbserial/readme.txt @@ -0,0 +1,13 @@ +To setup the project and upload the Arduino usbserial application firmware to an ATMEGA8U2 using the Arduino USB DFU bootloader: +1. unpack the source into LUFA's Projects directory +2. set ARDUINO_MODEL_PID in the makefile as appropriate +3. do "make clean; make" +4. put the 8U2 into USB DFU mode: +4.a. assert and hold the 8U2's RESET line +4.b. assert and hold the 8U2's HWB line +4.c. release the 8U2's RESET line +4.d. release the 8U2's HWB line +5. confirm that the board enumerates as either "Arduino Uno DFU" or "Arduino Mega 2560 DFU" +6. do "make dfu" (OS X or Linux - dfu-programmer must be installed first) or "make flip" (Windows - Flip must be installed first) + +Check that the board enumerates as either "Arduino Uno" or "Arduino Mega 2560". Test by uploading a new Arduino sketch from the Arduino IDE. diff --git a/arduino-0018-linux-x64/hardware/arduino/programmers.txt b/arduino-0022-linux-x64/hardware/arduino/programmers.txt similarity index 100% rename from arduino-0018-linux-x64/hardware/arduino/programmers.txt rename to arduino-0022-linux-x64/hardware/arduino/programmers.txt diff --git a/arduino-0022-linux-x64/hardware/tools/avrdude b/arduino-0022-linux-x64/hardware/tools/avrdude new file mode 100755 index 0000000..f13912a Binary files /dev/null and b/arduino-0022-linux-x64/hardware/tools/avrdude differ diff --git a/arduino-0018-linux-x64/hardware/tools/avrdude.conf~ b/arduino-0022-linux-x64/hardware/tools/avrdude.conf similarity index 100% rename from arduino-0018-linux-x64/hardware/tools/avrdude.conf~ rename to arduino-0022-linux-x64/hardware/tools/avrdude.conf diff --git a/arduino-0018-linux-x64/lib/RXTXcomm.jar b/arduino-0022-linux-x64/lib/RXTXcomm.jar similarity index 89% rename from arduino-0018-linux-x64/lib/RXTXcomm.jar rename to arduino-0022-linux-x64/lib/RXTXcomm.jar index 84e5f01..8971c81 100644 Binary files a/arduino-0018-linux-x64/lib/RXTXcomm.jar and b/arduino-0022-linux-x64/lib/RXTXcomm.jar differ diff --git a/arduino-0018-linux-x64/lib/about.jpg b/arduino-0022-linux-x64/lib/about.jpg old mode 100755 new mode 100644 similarity index 100% rename from arduino-0018-linux-x64/lib/about.jpg rename to arduino-0022-linux-x64/lib/about.jpg diff --git a/arduino-0022-linux-x64/lib/core.jar b/arduino-0022-linux-x64/lib/core.jar new file mode 100644 index 0000000..70095f8 Binary files /dev/null and b/arduino-0022-linux-x64/lib/core.jar differ diff --git a/arduino-0018-linux-x64/lib/ecj.jar b/arduino-0022-linux-x64/lib/ecj.jar similarity index 100% rename from arduino-0018-linux-x64/lib/ecj.jar rename to arduino-0022-linux-x64/lib/ecj.jar diff --git a/arduino-0018-linux-x64/lib/jna.jar b/arduino-0022-linux-x64/lib/jna.jar similarity index 100% rename from arduino-0018-linux-x64/lib/jna.jar rename to arduino-0022-linux-x64/lib/jna.jar diff --git a/arduino-0018-linux-x64/lib/keywords.txt b/arduino-0022-linux-x64/lib/keywords.txt similarity index 94% rename from arduino-0018-linux-x64/lib/keywords.txt rename to arduino-0022-linux-x64/lib/keywords.txt index fbf8f39..ad53668 100644 --- a/arduino-0018-linux-x64/lib/keywords.txt +++ b/arduino-0022-linux-x64/lib/keywords.txt @@ -19,7 +19,9 @@ FALLING LITERAL1 AttachInterrupt RISING LITERAL1 AttachInterrupt DEFAULT LITERAL1 AnalogReference EXTERNAL LITERAL1 AnalogReference -INTERAL LITERAL1 AnalogReference +INTERNAL LITERAL1 AnalogReference +INTERNAL1V1 LITERAL1 AnalogReference +INTERNAL2V56 LITERAL1 AnalogReference # KEYWORD1 specifies datatypes and C/C++ keywords @@ -48,7 +50,8 @@ public KEYWORD1 return KEYWORD1 Return short KEYWORD1 signed KEYWORD1 -static KEYWORD1 Static +static KEYWORD1 Static +String KEYWORD1 String switch KEYWORD1 SwitchCase this KEYWORD1 throw KEYWORD1 @@ -154,6 +157,7 @@ noInterrupts KEYWORD2 NoInterrupts noTone KEYWORD2 NoTone pinMode KEYWORD2 PinMode pulseIn KEYWORD2 PulseIn +shiftIn KEYWORD2 ShiftIn shiftOut KEYWORD2 ShiftOut tone KEYWORD2 Tone @@ -163,6 +167,7 @@ Serial2 KEYWORD3 Serial Serial3 KEYWORD3 Serial begin KEYWORD2 Serial_Begin end KEYWORD2 Serial_End +peek KEYWORD2 Serial_Peek read KEYWORD2 Serial_Read print KEYWORD2 Serial_Print println KEYWORD2 Serial_Println diff --git a/arduino-0022-linux-x64/lib/librxtxSerial.so b/arduino-0022-linux-x64/lib/librxtxSerial.so new file mode 100644 index 0000000..853b87a Binary files /dev/null and b/arduino-0022-linux-x64/lib/librxtxSerial.so differ diff --git a/arduino-0022-linux-x64/lib/pde.jar b/arduino-0022-linux-x64/lib/pde.jar new file mode 100644 index 0000000..2519452 Binary files /dev/null and b/arduino-0022-linux-x64/lib/pde.jar differ diff --git a/arduino-0018-linux-x64/lib/preferences.txt b/arduino-0022-linux-x64/lib/preferences.txt old mode 100755 new mode 100644 similarity index 83% rename from arduino-0018-linux-x64/lib/preferences.txt rename to arduino-0022-linux-x64/lib/preferences.txt index 0dc7963..63f63ac --- a/arduino-0018-linux-x64/lib/preferences.txt +++ b/arduino-0022-linux-x64/lib/preferences.txt @@ -72,8 +72,15 @@ platform.auto_file_type_associations = true # default size for the main window -default.window.width = 500 -default.window.height = 600 +editor.window.width.default = 500 +editor.window.height.default = 600 + +editor.window.width.min = 400 +editor.window.height.min = 500 +# tested as approx 440 on OS X +editor.window.height.min.macosx = 450 +# tested to be 515 on Windows XP, this leaves some room +editor.window.height.min.windows = 530 # font size for editor editor.font=Monospaced,plain,12 @@ -92,6 +99,21 @@ editor.caret.blink=true # area that's not in use by the text (replaced with tildes) editor.invalid=false +# enable ctrl-ins, shift-ins, shift-delete for cut/copy/paste +# on windows and linux, but disable on the mac +editor.keys.alternative_cut_copy_paste = true +editor.keys.alternative_cut_copy_paste.macosx = false + +# true if shift-backspace sends the delete character, +# false if shift-backspace just means backspace +editor.keys.shift_backspace_is_delete = true + +# home and end keys should only travel to the start/end of the current line +editor.keys.home_and_end_travel_far = false +# the OS X HI Guidelines say that home/end are relative to the document +# if you don't like it, this is the preference to change +editor.keys.home_and_end_travel_far.macosx = true + console = true console.output.file = stdout.txt console.error.file = stderr.txt @@ -197,14 +219,14 @@ preproc.substitute_unicode = true # viewed in (at least) Mozilla or IE. useful when debugging the preprocessor. preproc.output_parse_tree = false -# imports to use by default (changed for 0149, some imports removed) -preproc.imports = java.applet,java.awt,java.awt.image,java.awt.event,java.io,java.net,java.text,java.util,java.util.zip,java.util.regex +# Changed after 1.0.9 to a new name, and also includes the specific entries +preproc.imports.list = java.applet.*,java.awt.Dimension,java.awt.Frame,java.awt.event.MouseEvent,java.awt.event.KeyEvent,java.awt.event.FocusEvent,java.awt.Image,java.io.*,java.net.*,java.text.*,java.util.*,java.util.zip.*,java.util.regex.* # set the browser to be used on linux browser.linux = mozilla # set to the program to be used for launching apps on linux -#launcher.linux = gnome-open +#launcher.linux = xdg-open # FULL SCREEN (PRESENT MODE) run.present.bgcolor = #666666 @@ -215,7 +237,7 @@ run.present.exclusive = false run.present.exclusive.macosx = true # ARDUINO PREFERENCES -board = atmega328 +board = uno target = arduino upload.using = bootloader diff --git a/arduino-0018-linux-x64/lib/theme/buttons.gif b/arduino-0022-linux-x64/lib/theme/buttons.gif similarity index 100% rename from arduino-0018-linux-x64/lib/theme/buttons.gif rename to arduino-0022-linux-x64/lib/theme/buttons.gif diff --git a/arduino-0018-linux-x64/lib/theme/resize.gif b/arduino-0022-linux-x64/lib/theme/resize.gif similarity index 100% rename from arduino-0018-linux-x64/lib/theme/resize.gif rename to arduino-0022-linux-x64/lib/theme/resize.gif diff --git a/arduino-0018-linux-x64/lib/theme/tab-sel-left.gif b/arduino-0022-linux-x64/lib/theme/tab-sel-left.gif similarity index 100% rename from arduino-0018-linux-x64/lib/theme/tab-sel-left.gif rename to arduino-0022-linux-x64/lib/theme/tab-sel-left.gif diff --git a/arduino-0018-linux-x64/lib/theme/tab-sel-menu.gif b/arduino-0022-linux-x64/lib/theme/tab-sel-menu.gif similarity index 100% rename from arduino-0018-linux-x64/lib/theme/tab-sel-menu.gif rename to arduino-0022-linux-x64/lib/theme/tab-sel-menu.gif diff --git a/arduino-0018-linux-x64/lib/theme/tab-sel-mid.gif b/arduino-0022-linux-x64/lib/theme/tab-sel-mid.gif similarity index 100% rename from arduino-0018-linux-x64/lib/theme/tab-sel-mid.gif rename to arduino-0022-linux-x64/lib/theme/tab-sel-mid.gif diff --git a/arduino-0018-linux-x64/lib/theme/tab-sel-right.gif b/arduino-0022-linux-x64/lib/theme/tab-sel-right.gif similarity index 100% rename from arduino-0018-linux-x64/lib/theme/tab-sel-right.gif rename to arduino-0022-linux-x64/lib/theme/tab-sel-right.gif diff --git a/arduino-0018-linux-x64/lib/theme/tab-unsel-left.gif b/arduino-0022-linux-x64/lib/theme/tab-unsel-left.gif similarity index 100% rename from arduino-0018-linux-x64/lib/theme/tab-unsel-left.gif rename to arduino-0022-linux-x64/lib/theme/tab-unsel-left.gif diff --git a/arduino-0018-linux-x64/lib/theme/tab-unsel-menu.gif b/arduino-0022-linux-x64/lib/theme/tab-unsel-menu.gif similarity index 100% rename from arduino-0018-linux-x64/lib/theme/tab-unsel-menu.gif rename to arduino-0022-linux-x64/lib/theme/tab-unsel-menu.gif diff --git a/arduino-0018-linux-x64/lib/theme/tab-unsel-mid.gif b/arduino-0022-linux-x64/lib/theme/tab-unsel-mid.gif similarity index 100% rename from arduino-0018-linux-x64/lib/theme/tab-unsel-mid.gif rename to arduino-0022-linux-x64/lib/theme/tab-unsel-mid.gif diff --git a/arduino-0018-linux-x64/lib/theme/tab-unsel-right.gif b/arduino-0022-linux-x64/lib/theme/tab-unsel-right.gif similarity index 100% rename from arduino-0018-linux-x64/lib/theme/tab-unsel-right.gif rename to arduino-0022-linux-x64/lib/theme/tab-unsel-right.gif diff --git a/arduino-0018-linux-x64/lib/theme/theme.txt b/arduino-0022-linux-x64/lib/theme/theme.txt similarity index 100% rename from arduino-0018-linux-x64/lib/theme/theme.txt rename to arduino-0022-linux-x64/lib/theme/theme.txt diff --git a/arduino-0022-linux-x64/lib/version.txt b/arduino-0022-linux-x64/lib/version.txt new file mode 100644 index 0000000..e7b4a12 --- /dev/null +++ b/arduino-0022-linux-x64/lib/version.txt @@ -0,0 +1 @@ +0022 \ No newline at end of file diff --git a/arduino-0022-linux-x64/libraries/ArduinoTestSuite/ArduinoTestSuite.cpp b/arduino-0022-linux-x64/libraries/ArduinoTestSuite/ArduinoTestSuite.cpp new file mode 100644 index 0000000..845e2ef --- /dev/null +++ b/arduino-0022-linux-x64/libraries/ArduinoTestSuite/ArduinoTestSuite.cpp @@ -0,0 +1,715 @@ +//************************************************************************ +//* Arduino Test Suite +//* (C) 2010 by Mark Sproul +//* Open source as per standard Arduino code +//* +//* 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. +//************************************************************************ +//* Aug 31, 2010 Started on TestArduino +//* Oct 18, 2010 Added memory testing +//************************************************************************ + +#include +#include +#include + + + +#include "ArduinoTestSuite.h" + + +#include "WProgram.h" +#include "HardwareSerial.h" +#include "pins_arduino.h" + + +#include "avr_cpunames.h" + +#if defined(USART3_RX_vect) + #define SERIAL_PORT_COUNT 4 +#elif defined(USART1_RX_vect) + #define SERIAL_PORT_COUNT 2 +#else + #define SERIAL_PORT_COUNT 1 +#endif + + + + +//************************************************************************ +enum +{ + ATS_Manufacturer = 1, + ATS_CPU, + ATS_GCC_version, + ATS_LIBC_version, + ATS_CompiledDate, + ATS_TestSuiteName, + ATS_FreeMemory, + + +}; +unsigned long gTestStartTime; +short gTagIndent; +int gYotalErrors; +int gTestCount; + + + +prog_char gTextMsg_Manufacturer[] PROGMEM = "MANUFACTURER"; +prog_char gTextMsg_CPUname[] PROGMEM = "CPU-NAME"; +prog_char gTextMsg_GCC_VERSION[] PROGMEM = "GCC-Version"; +prog_char gTextMsg_AVR_LIBC[] PROGMEM = "AVR-LibC-Ver"; +prog_char gTextMsg_COMPILED_DATE[] PROGMEM = "Compiled-date"; +prog_char gTextMsg_TEST_SUITE_NAME[] PROGMEM = "Test-Suite-Name"; +prog_char gTextMsg_memoryUsage[] PROGMEM = "Free-memory"; +prog_char gTextMsg_dotdotdot[] PROGMEM = "... "; +prog_char gTextMsg_ok[] PROGMEM = "ok"; +prog_char gTextMsg_FAIL[] PROGMEM = "FAIL"; +prog_char gTextMsg_spaceEqual[] PROGMEM = " = "; +prog_char gTextMsg_info[] PROGMEM = "info."; +prog_char gTextMsg_dashLine[] PROGMEM = "--------------------------"; +prog_char gTextMsg_DigitalRW[] PROGMEM = "DigitalReadWrite_"; +prog_char gTextMsg_PWMoutput[] PROGMEM = "PWMoutput_"; +prog_char gTextMsg_AnalogInput[] PROGMEM = "AnalogInput_"; + +//************************************************************************ +void Serial_print_P(prog_char *flashMemStr) +{ +char theChar; +int ii; + + ii = 0; +#if (FLASHEND > 0x10000) + while (theChar = pgm_read_byte_far(flashMemStr + ii++)) +#else + while (theChar = pgm_read_byte_near(flashMemStr + ii++)) +#endif + { + Serial.print(theChar); + } +} + +//************************************************************************ +void Serial_println_P(prog_char *flashMemStr) +{ + Serial_print_P(flashMemStr); + Serial.println(); +} + +//************************************************************************ +//* this is for internal use only, not made pubic to the API +static void ATS_PrintProperty( int propertyTagNum, + char *propertyName, + char *propertyValue) +{ +char lineBuffer[64]; + + strcpy_P(lineBuffer, gTextMsg_info); + switch(propertyTagNum) + { + case 0: + strcat(lineBuffer, propertyName); + break; + + case ATS_Manufacturer: + strcat_P(lineBuffer, gTextMsg_Manufacturer); + break; + + case ATS_CPU: + strcat_P(lineBuffer, gTextMsg_CPUname); + break; + + case ATS_GCC_version: + strcat_P(lineBuffer, gTextMsg_GCC_VERSION); + break; + + case ATS_LIBC_version: + strcat_P(lineBuffer, gTextMsg_AVR_LIBC); + break; + + case ATS_CompiledDate: + strcat_P(lineBuffer, gTextMsg_COMPILED_DATE); + break; + + case ATS_TestSuiteName: + strcat_P(lineBuffer, gTextMsg_TEST_SUITE_NAME); + break; + + case ATS_FreeMemory: + strcat_P(lineBuffer, gTextMsg_memoryUsage); + break; + } + + while (strlen(lineBuffer) < 20) + { + strcat(lineBuffer, " "); + } + + strcat_P(lineBuffer, gTextMsg_spaceEqual); + if (propertyValue != 0) + { + strcat(lineBuffer, propertyValue); + } + Serial.println(lineBuffer); + +} + + + + +//************************************************************************ +void ATS_begin(char *manufName, char *testSuiteName) +{ +int freeMemory; +char memoryMsg[48]; + + gYotalErrors = 0; + gTestCount = 0; + + Serial.begin(9600); + delay(1000); + + gTestStartTime = millis(); + + Serial.println(); + Serial.println(); + Serial.println(); + + ATS_PrintProperty(ATS_Manufacturer, 0, manufName); + ATS_PrintProperty(ATS_CPU, 0, _AVR_CPU_NAME_); + ATS_PrintProperty(ATS_GCC_version, 0, __VERSION__); + ATS_PrintProperty(ATS_LIBC_version, 0, __AVR_LIBC_VERSION_STRING__); + ATS_PrintProperty(ATS_CompiledDate, 0, __DATE__); + ATS_PrintProperty(ATS_TestSuiteName, 0, testSuiteName); + + freeMemory = ATS_GetFreeMemory(); + sprintf(memoryMsg, "%d bytes", freeMemory); + ATS_PrintProperty(ATS_FreeMemory, 0, memoryMsg); + + randomSeed(analogRead(0)); + +} + +//************************************************************************ +void ATS_end() +{ +long seconds; +long milliSecs; + + + Serial_println_P(gTextMsg_dashLine); + + // Ran 4 tests in 0.000s + Serial.print("Ran "); + Serial.print(gTestCount); + Serial.print(" tests in "); + + seconds = millis() / 1000; + milliSecs = millis() % 1000; + Serial.print(seconds); + Serial.print('.'); + Serial.print(milliSecs); + Serial.print('s'); + Serial.println(); + Serial.println(); + + if (gYotalErrors == 0) + { + Serial.print("OK"); + } + else + { + Serial.print("FAILED (failures="); + Serial.print(gYotalErrors); + Serial.print(")"); + } + Serial.println(); + + //* send control D to terminate (End Of File) + Serial.write(0x04); +} + + + +//************************************************************************ +void ATS_PrintTestStatus(char *testString, boolean passed) +{ +int sLen; + + Serial.print(testString); + sLen = strlen(testString); + while (sLen < 60) + { + Serial.print(' '); + sLen++; + } + Serial_print_P(gTextMsg_dotdotdot); + if (passed) + { + Serial_print_P(gTextMsg_ok); + } + else + { + Serial_print_P(gTextMsg_FAIL); + gYotalErrors++; + } + Serial.println(); + + gTestCount++; +} + + + +//************************************************************************ +//* returns true if no errors, false if there is an error +int ATS_Test_DigitalPinWithHelper(uint8_t digitalPinToTest, uint8_t helperpin) +{ +boolean passedOK; +int pinValue; +char testName[64]; +char numString[32]; + + strcpy_P(testName, gTextMsg_DigitalRW); + sprintf(numString, "%02d", digitalPinToTest); + strcat(testName, numString); + + passedOK = true; + + //* test senario 1 + pinMode(digitalPinToTest, OUTPUT); + pinMode(helperpin, INPUT); + + digitalWrite(digitalPinToTest, HIGH); + pinValue = digitalRead(helperpin); + if (pinValue != HIGH) + { + passedOK = false; + } + + digitalWrite(digitalPinToTest, LOW); + pinValue = digitalRead(helperpin); + if (pinValue != LOW) + { + passedOK = false; + } + + + //* now reverse the input/output + pinMode(digitalPinToTest, INPUT); + pinMode(helperpin, OUTPUT); + + digitalWrite(helperpin, HIGH); + pinValue = digitalRead(digitalPinToTest); + if (pinValue != HIGH) + { + passedOK = false; + } + + digitalWrite(helperpin, LOW); + pinValue = digitalRead(digitalPinToTest); + if (pinValue != LOW) + { + passedOK = false; + } + + + if (! passedOK) + { + sprintf(numString, " (helper pin=%02d)", helperpin); + strcat(testName, numString); + } + ATS_PrintTestStatus(testName, passedOK); + return(passedOK); +} + +//************************************************************************ +boolean ATS_Test_DigitalPin(uint8_t digitalPinToTest) +{ +boolean passedOK; +uint8_t helperpin; + + if ((digitalPinToTest % 2) == 0) + { + //* if its EVEN, add 1 + helperpin = digitalPinToTest + 1; + } + else + { + //* if its ODD + helperpin = digitalPinToTest - 1; + } + passedOK = ATS_Test_DigitalPinWithHelper(digitalPinToTest, helperpin); + return(passedOK); +} + + + +//************************************************************************ +//* returns true if no errors, false if there is an error +int ATS_TestTimer( uint8_t timerPinNumber, + uint8_t inputPin, + char *statusString, + char *errorString) +{ +boolean passedOK; +unsigned long loopCounter; +unsigned long lowCount; +unsigned long highCount; +unsigned long startTime; +int percentLow; +int percentHigh; +int pinValue; +char numString[48]; +int pwmValue; + + pwmValue = 128; + loopCounter = 0; + lowCount = 0; + highCount = 0; + passedOK = true; + + startTime = millis(); + pinMode(inputPin, INPUT); + analogWrite(timerPinNumber, pwmValue); + while ((millis() - startTime) < 500) + { + pinValue = digitalRead(inputPin); + if (pinValue == HIGH) + { + highCount++; + } + else + { + lowCount++; + } + } + analogWrite(timerPinNumber, 0); + + //* the difference should be about 50% + percentLow = lowCount / ((lowCount + highCount) / 100); + percentHigh = highCount / ((lowCount + highCount) / 100); + if ((percentLow > 45) && (percentLow < 55)) + { + passedOK = true; + } + else + { + passedOK = false; + strcat(errorString, " PWM ERROR"); + } + sprintf(numString, " (PWM=%02d %d%% LOW %d%% HIGH)", pwmValue, percentLow, percentHigh); + strcat(statusString, numString); + + return(passedOK); +} + + +//************************************************************************ +//* returns true if no errors, false if there is an error +boolean ATS_Test_PWMPinWithHelper(uint8_t pwmPinToTest, uint8_t helperpin) +{ +boolean passedOK; +char testName[64]; +char errorString[48]; +char numString[8]; +uint8_t timerNumber; + + + + strcpy_P(testName, gTextMsg_PWMoutput); + sprintf(numString, "%02d", pwmPinToTest); + strcat(testName, numString); + + passedOK = true; + errorString[0] = 0; + + + //* is pin1 a timer? + timerNumber = digitalPinToTimer(pwmPinToTest); + if (timerNumber != NOT_ON_TIMER) + { + passedOK = ATS_TestTimer(pwmPinToTest, helperpin, testName, errorString); + } + else + { + //* we should not get here + passedOK = false; + } + + ATS_PrintTestStatus(testName, passedOK); + + + return(passedOK); +} + +//************************************************************************ +boolean ATS_Test_PWM_Pin(uint8_t pwmPinToTest) +{ +boolean passedOK; +uint8_t helperpin; + + if ((pwmPinToTest % 2) == 0) + { + //* if its EVEN, add 1 + helperpin = pwmPinToTest + 1; + } + else + { + //* if its ODD + helperpin = pwmPinToTest - 1; + } + passedOK = ATS_Test_PWMPinWithHelper(pwmPinToTest, helperpin); + return(passedOK); +} + + +#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) + #define kAnalogPinOffset 54 +#else + #define kAnalogPinOffset 14 +#endif + + +//************************************************************************ +boolean ATS_Test_AnalogInputWithHelper(uint8_t analogPintoTest, uint8_t helperPin) +{ +boolean passedOK; +char testName[64]; +char infoString[48]; +int analogValueHigh; +int analogValueLow; + + + //* first we have to set the ANALOG pin to INPUT + pinMode(analogPintoTest + kAnalogPinOffset, INPUT); + + passedOK = true; + + strcpy_P(testName, gTextMsg_AnalogInput); + sprintf(infoString, "%02d", analogPintoTest); + strcat(testName, infoString); + + + pinMode(helperPin, OUTPUT); + + digitalWrite(helperPin, LOW); + analogValueLow = analogRead(analogPintoTest); + if (analogValueLow > 100) + { + passedOK = false; + } + + + digitalWrite(helperPin, HIGH); + analogValueHigh = analogRead(analogPintoTest); + if (analogValueHigh < 1000) + { + passedOK = false; + } + + + sprintf(infoString, " (Low=%4d High=%4d helper pin=%d)", analogValueLow, analogValueHigh, helperPin); + strcat(testName, infoString); + + ATS_PrintTestStatus(testName, passedOK); + + return(passedOK); +} + + +//************************************************************************ +boolean ATS_Test_AnalogInput(uint8_t analogPinToTest) +{ +boolean passedOK; +uint8_t helperpin; + + if ((analogPinToTest % 2) == 0) + { + //* if its EVEN, add 1 + helperpin = kAnalogPinOffset + analogPinToTest + 1; + } + else + { + //* if its ODD + helperpin = kAnalogPinOffset + analogPinToTest - 1; + } + passedOK = ATS_Test_AnalogInputWithHelper(analogPinToTest, helperpin); + return(passedOK); +} + + +#define kSerialTestBaudRate 9600 +#define kSerialTestDelay 3 + + +#if (SERIAL_PORT_COUNT > 1) && !defined(__AVR_ATmega32U4__) +//************************************************************************ +//* retunrs 0 if no errors, 1 if an error occured +short ATS_TestSerialLoopback(HardwareSerial *theSerialPort, char *serialPortName) +{ +char xmitChar; +char rcvChar; +short ii; +short serialErrCt; +short timeOutLoopCtr; + + + serialErrCt = 1; + if (theSerialPort != 0) + { + serialErrCt = 0; + theSerialPort->begin(kSerialTestBaudRate); + + for (ii=0; ii<150; ii++) + { + xmitChar = ii; + theSerialPort->print(xmitChar); + + timeOutLoopCtr = 0; + //* wait for data to come back or timeout + while (!theSerialPort->available() && (timeOutLoopCtr < kSerialTestDelay)) + { + delay(1); + timeOutLoopCtr++; + } + + if (theSerialPort->available()) + { + //* get the char + rcvChar = theSerialPort->read(); + if (rcvChar != xmitChar) + { + serialErrCt = 1; + } + } + else + { + serialErrCt = 1; + } + } + theSerialPort->end(); + + if (serialErrCt == 0) + { + ATS_PrintTestStatus(serialPortName, PASSED); + } + else + { + ATS_PrintTestStatus(serialPortName, FAILED); + } + } + + return(serialErrCt); +} +#endif + + +//************************************************************************ +boolean ATS_Test_EEPROM(void) +{ +boolean passedOK; +uint8_t dataByte; +uint8_t dataByteRead; +uint16_t dataWord; +uint16_t dataWordRead; +uint32_t dataLongWord; +uint32_t dataLongWordRead; +int addressPtr; +char reportString[48]; + + passedOK = true; + //* test BYTE read/write + addressPtr = random(E2END); + dataByte = 0x5A; + eeprom_write_byte((uint8_t *)addressPtr, dataByte); + dataByteRead = eeprom_read_byte((uint8_t *)addressPtr); + + sprintf(reportString, "EEPROM_byte_rw (addr= 0x%04X)", addressPtr); + if (dataByteRead == dataByte) + { + ATS_PrintTestStatus(reportString, PASSED); + } + else + { + ATS_PrintTestStatus(reportString, FAILED); + passedOK = false; + } + + + //* test WORD read/write + addressPtr = random(E2END); + dataWord = 0xA55A; + eeprom_write_word((uint16_t *)addressPtr, dataWord); + dataWordRead = eeprom_read_word((uint16_t *)addressPtr); + + sprintf(reportString, "EEPROM_word_rw (addr= 0x%04X)", addressPtr); + if (dataWordRead == dataWord) + { + ATS_PrintTestStatus(reportString, PASSED); + } + else + { + ATS_PrintTestStatus(reportString, FAILED); + passedOK = false; + } + + + //* test Long WORD read/write + addressPtr = random(E2END); + dataLongWord = 0x5AA5A55A; + eeprom_write_dword((uint32_t *)addressPtr, dataLongWord); + dataLongWordRead = eeprom_read_dword((uint32_t *)addressPtr); + + sprintf(reportString, "EEPROM_dword_rw (addr= 0x%04X)", addressPtr); + if (dataLongWordRead == dataLongWord) + { + ATS_PrintTestStatus(reportString, PASSED); + } + else + { + ATS_PrintTestStatus(reportString, FAILED); + passedOK = false; + } + + + return(passedOK); +} + + + +//************************************************************************ +extern unsigned int __data_start; +extern unsigned int __data_end; +extern unsigned int __bss_start; +extern unsigned int __bss_end; +extern unsigned int __heap_start; +extern void *__brkval; + + + +//************************************************************************ +int ATS_GetFreeMemory() +{ +int free_memory; + + if((int)__brkval == 0) + { + free_memory = ((int)&free_memory) - ((int)&__bss_end); + } + else + { + free_memory = ((int)&free_memory) - ((int)__brkval); + } + return free_memory; +} + + diff --git a/arduino-0022-linux-x64/libraries/ArduinoTestSuite/ArduinoTestSuite.h b/arduino-0022-linux-x64/libraries/ArduinoTestSuite/ArduinoTestSuite.h new file mode 100644 index 0000000..9501d67 --- /dev/null +++ b/arduino-0022-linux-x64/libraries/ArduinoTestSuite/ArduinoTestSuite.h @@ -0,0 +1,74 @@ +//************************************************************************ +//************************************************************************ +//* Aug 31, 2010 Started on TestArduino +//************************************************************************ + +#ifndef _AVR_IO_H_ + #include +#endif + +#ifndef WProgram_h + #include "WProgram.h" +#endif +#ifndef HardwareSerial_h + #include "HardwareSerial.h" +#endif + + +#if defined(USART3_RX_vect) + #define SERIAL_PORT_COUNT 4 +#elif defined(USART1_RX_vect) + #define SERIAL_PORT_COUNT 2 +#else + #define SERIAL_PORT_COUNT 1 +#endif + + +void ATS_begin(char *manufName, char *testSuiteName); +void ATS_end(); + +void ATS_PrintTestStatus(char *testString, boolean passed); +boolean ATS_Test_DigitalPin(uint8_t digitalPinToTest); +boolean ATS_Test_PWM_Pin(uint8_t digitalPinToTest); +boolean ATS_Test_AnalogInput(uint8_t analogPintoTest); +boolean ATS_Test_EEPROM(void); + +short ATS_TestSerialLoopback(HardwareSerial *theSerialPort, char *serialPortName); + + +int ATS_GetFreeMemory(); + +//************************************************************************ +//* this has to be an inline function because calling subroutines affects free memory +inline void ATS_ReportMemoryUsage(int _memoryUsageAtStart) +{ +int freeMemoryAtEnd; +int lostMemory; +boolean memoryOK; +char memoryUsage[48]; + + freeMemoryAtEnd = ATS_GetFreeMemory(); + lostMemory = _memoryUsageAtStart - freeMemoryAtEnd; + if (lostMemory == 0) + { + strcpy(memoryUsage, "Memory Usage"); + memoryOK = true; + } + else + { + sprintf(memoryUsage, "Memory Usage (lost %d bytes)", lostMemory); + memoryOK = false; + } + ATS_PrintTestStatus(memoryUsage, memoryOK); +} + + + +extern unsigned long gTestStartTime; +extern int gYotalErrors; +extern int gTestCount; + + +#define PASSED true +#define FAILED false + diff --git a/arduino-0022-linux-x64/libraries/ArduinoTestSuite/avr_cpunames.h b/arduino-0022-linux-x64/libraries/ArduinoTestSuite/avr_cpunames.h new file mode 100644 index 0000000..8083216 --- /dev/null +++ b/arduino-0022-linux-x64/libraries/ArduinoTestSuite/avr_cpunames.h @@ -0,0 +1,186 @@ +//************************************************************************************************** +//* +//* Atmel AVR CPU name strings +//* +//************************************************************************************************** +//* Sep 19, 2010 Started on avr_cpunames.h +//************************************************************************************************** + +//#include "avr_cpunames.h" + +//************************************************************************************************** + + +#if defined (__AVR_AT94K__) + #define _AVR_CPU_NAME_ "AT94k" +#elif defined (__AVR_AT43USB320__) +#elif defined (__AVR_AT43USB355__) +#elif defined (__AVR_AT76C711__) +#elif defined (__AVR_AT86RF401__) +#elif defined (__AVR_AT90PWM1__) +#elif defined (__AVR_AT90PWM2__) +#elif defined (__AVR_AT90PWM2B__) +#elif defined (__AVR_AT90PWM3__) +#elif defined (__AVR_AT90PWM3B__) +#elif defined (__AVR_AT90PWM216__) +#elif defined (__AVR_AT90PWM316__) +#elif defined (__AVR_ATmega32C1__) +#elif defined (__AVR_ATmega32M1__) +#elif defined (__AVR_ATmega32U4__) + #define _AVR_CPU_NAME_ "ATmega32U4" +#elif defined (__AVR_ATmega32U6__) + #define _AVR_CPU_NAME_ "ATmega32U6" +#elif defined (__AVR_ATmega128__) + #define _AVR_CPU_NAME_ "Atmega128" +#elif defined (__AVR_ATmega1280__) + #define _AVR_CPU_NAME_ "ATmega1280" +#elif defined (__AVR_ATmega1281__) + #define _AVR_CPU_NAME_ "ATmega1281" +#elif defined (__AVR_ATmega1284P__) + #define _AVR_CPU_NAME_ "ATmega1284" +#elif defined (__AVR_ATmega2560__) + #define _AVR_CPU_NAME_ "ATmega2560" +#elif defined (__AVR_ATmega2561__) + #define _AVR_CPU_NAME_ "ATmega2561" +#elif defined (__AVR_AT90CAN32__) + #define _AVR_CPU_NAME_ "AT90CAN32" +#elif defined (__AVR_AT90CAN64__) + #define _AVR_CPU_NAME_ "AT90CAN64" +#elif defined (__AVR_AT90CAN128__) + #define _AVR_CPU_NAME_ "AT90CAN128" +#elif defined (__AVR_AT90USB82__) + #define _AVR_CPU_NAME_ "AT90USB82" +#elif defined (__AVR_AT90USB162__) + #define _AVR_CPU_NAME_ "AT90USB162" +#elif defined (__AVR_AT90USB646__) + #define _AVR_CPU_NAME_ "AT90USB646" +#elif defined (__AVR_AT90USB647__) + #define _AVR_CPU_NAME_ "AT90USB647" +#elif defined (__AVR_AT90USB1286__) + #define _AVR_CPU_NAME_ "AT90USB1286" +#elif defined (__AVR_AT90USB1287__) + #define _AVR_CPU_NAME_ "AT90USB1287" +#elif defined (__AVR_ATmega64__) + #define _AVR_CPU_NAME_ "ATmega64" +#elif defined (__AVR_ATmega640__) + #define _AVR_CPU_NAME_ "ATmega640" +#elif defined (__AVR_ATmega644__) + #define _AVR_CPU_NAME_ "ATmega644" +#elif defined (__AVR_ATmega644P__) + #define _AVR_CPU_NAME_ "ATmega644P" +#elif defined (__AVR_ATmega645__) + #define _AVR_CPU_NAME_ "ATmega645" +#elif defined (__AVR_ATmega6450__) + #define _AVR_CPU_NAME_ "ATmega6450" +#elif defined (__AVR_ATmega649__) + #define _AVR_CPU_NAME_ "ATmega649" +#elif defined (__AVR_ATmega6490__) + #define _AVR_CPU_NAME_ "ATmega6490" +#elif defined (__AVR_ATmega103__) + #define _AVR_CPU_NAME_ "ATmega103" +#elif defined (__AVR_ATmega32__) + #define _AVR_CPU_NAME_ "Atmega32" +#elif defined (__AVR_ATmega323__) + #define _AVR_CPU_NAME_ "ATmega323" +#elif defined (__AVR_ATmega324P__) + #define _AVR_CPU_NAME_ "ATmega324P" +#elif defined (__AVR_ATmega325__) + #define _AVR_CPU_NAME_ "ATmega325" +#elif defined (__AVR_ATmega325P__) + #define _AVR_CPU_NAME_ "ATmega325P" +#elif defined (__AVR_ATmega3250__) + #define _AVR_CPU_NAME_ "ATmega3250" +#elif defined (__AVR_ATmega3250P__) + #define _AVR_CPU_NAME_ "ATmega3250P" +#elif defined (__AVR_ATmega328P__) + #define _AVR_CPU_NAME_ "ATmega328P" +#elif defined (__AVR_ATmega329__) + #define _AVR_CPU_NAME_ "ATmega329" +#elif defined (__AVR_ATmega329P__) + #define _AVR_CPU_NAME_ "ATmega329P" +#elif defined (__AVR_ATmega3290__) + #define _AVR_CPU_NAME_ "ATmega3290" +#elif defined (__AVR_ATmega3290P__) + #define _AVR_CPU_NAME_ "ATmega3290P" +#elif defined (__AVR_ATmega32HVB__) + #define _AVR_CPU_NAME_ "ATmega32HVB" +#elif defined (__AVR_ATmega406__) + #define _AVR_CPU_NAME_ "ATmega406" +#elif defined (__AVR_ATmega16__) + #define _AVR_CPU_NAME_ "Atmega16" +#elif defined (__AVR_ATmega161__) + #define _AVR_CPU_NAME_ "ATmega161" +#elif defined (__AVR_ATmega162__) + #define _AVR_CPU_NAME_ "ATmega162" +#elif defined (__AVR_ATmega163__) + #define _AVR_CPU_NAME_ "ATmega163" +#elif defined (__AVR_ATmega164P__) + #define _AVR_CPU_NAME_ "ATmega164P" +#elif defined (__AVR_ATmega165__) + #define _AVR_CPU_NAME_ "ATmega165" +#elif defined (__AVR_ATmega165P__) + #define _AVR_CPU_NAME_ "ATmega165P" +#elif defined (__AVR_ATmega168__) + #define _AVR_CPU_NAME_ "ATmega168" +#elif defined (__AVR_ATmega168P__) + #define _AVR_CPU_NAME_ "ATmega168P" +#elif defined (__AVR_ATmega169__) + #define _AVR_CPU_NAME_ "Atmega169" +#elif defined (__AVR_ATmega169P__) + #define _AVR_CPU_NAME_ "ATmega169P" +#elif defined (__AVR_ATmega8HVA__) + #define _AVR_CPU_NAME_ "ATmega8HVA" +#elif defined (__AVR_ATmega16HVA__) + #define _AVR_CPU_NAME_ "ATmega16HVA" +#elif defined (__AVR_ATmega8__) + #define _AVR_CPU_NAME_ "ATmega8" +#elif defined (__AVR_ATmega48__) + #define _AVR_CPU_NAME_ "ATmega48" +#elif defined (__AVR_ATmega48P__) + #define _AVR_CPU_NAME_ "ATmega48P" +#elif defined (__AVR_ATmega88__) + #define _AVR_CPU_NAME_ "ATmega88" +#elif defined (__AVR_ATmega88P__) + #define _AVR_CPU_NAME_ "ATmega88P" +#elif defined (__AVR_ATmega8515__) + #define _AVR_CPU_NAME_ "ATmega8515" +#elif defined (__AVR_ATmega8535__) + #define _AVR_CPU_NAME_ "ATmega8535" +#elif defined (__AVR_AT90S8535__) +#elif defined (__AVR_AT90C8534__) +#elif defined (__AVR_AT90S8515__) +#elif defined (__AVR_AT90S4434__) +#elif defined (__AVR_AT90S4433__) +#elif defined (__AVR_AT90S4414__) +#elif defined (__AVR_ATtiny22__) +#elif defined (__AVR_ATtiny26__) +#elif defined (__AVR_AT90S2343__) +#elif defined (__AVR_AT90S2333__) +#elif defined (__AVR_AT90S2323__) +#elif defined (__AVR_AT90S2313__) +#elif defined (__AVR_ATtiny2313__) + #define _AVR_CPU_NAME_ "ATtiny2313" +#elif defined (__AVR_ATtiny13__) +#elif defined (__AVR_ATtiny13A__) +#elif defined (__AVR_ATtiny25__) +#elif defined (__AVR_ATtiny45__) +#elif defined (__AVR_ATtiny85__) +#elif defined (__AVR_ATtiny24__) +#elif defined (__AVR_ATtiny44__) +#elif defined (__AVR_ATtiny84__) +#elif defined (__AVR_ATtiny261__) +#elif defined (__AVR_ATtiny461__) +#elif defined (__AVR_ATtiny861__) +#elif defined (__AVR_ATtiny43U__) +#elif defined (__AVR_ATtiny48__) +#elif defined (__AVR_ATtiny88__) +#elif defined (__AVR_ATtiny167__) + +#else + #error cpu not defined +#endif + + +#if !defined (_AVR_CPU_NAME_) +// #define _AVR_CPU_NAME_ "UNKNOWN" +#endif diff --git a/arduino-0022-linux-x64/libraries/ArduinoTestSuite/examples/ATS_Constants/ATS_Constants.pde b/arduino-0022-linux-x64/libraries/ArduinoTestSuite/examples/ATS_Constants/ATS_Constants.pde new file mode 100644 index 0000000..d58e8ba --- /dev/null +++ b/arduino-0022-linux-x64/libraries/ArduinoTestSuite/examples/ATS_Constants/ATS_Constants.pde @@ -0,0 +1,76 @@ +//************************************************************************ +//* Arduino Test of Arduino Constants +//* (C) 2010 by Rick Anderson +//* Open source as per standard Arduino code +//* +//************************************************************************ +//* Oct 16, 2010 Test of Arduino Constants +//************************************************************************ + +#include "WProgram.h" +#include "HardwareSerial.h" +#include + +//************************************************************************ +void setup() +{ + int startMemoryUsage; + + //Start memory usage must be site prior to ATS_begin + startMemoryUsage = ATS_GetFreeMemory(); + ATS_begin("Arduino", "Test of Arduino Constants"); + /* + * Test Run Start + */ + + + //test true constant + ATS_PrintTestStatus("1. Test of true constant", true == 1); + + //test false consts + ATS_PrintTestStatus( "2. Test of false constant", false == 0); + + //Test of HIGH == 1 + ATS_PrintTestStatus( "3. Test of HIGH == 1", HIGH == 1); + + //Test of LOW == 0 + ATS_PrintTestStatus( "4. Test of LOW == 0", LOW == 0); + + //Test of INPUT == 1 + ATS_PrintTestStatus( "5. Test of INPUT == 1", HIGH == 1); + + //Test of OUTPUT == 0 + ATS_PrintTestStatus( "6. Test of OUTPUT == 0", LOW == 0); + + //test decimal + ATS_PrintTestStatus( "7. Test of decimal constant", 101 == ((1 * pow(10,2)) + (0 * pow(10,1)) + 1)); + + //test binary + ATS_PrintTestStatus( "8. Test of binary constant", B101 == 5); + + //test octal + ATS_PrintTestStatus( "9. Test of octal constant", 0101 == 65); + + //test hexadecimal + ATS_PrintTestStatus( "7. Test of hexadecimal constant", (0x101 == 257)); + + /* + * Test Run End + */ + ATS_ReportMemoryUsage(startMemoryUsage); + ATS_end(); + +} + + +//************************************************************************ +void loop() +{ + + +} + + + + + diff --git a/arduino-0022-linux-x64/libraries/ArduinoTestSuite/examples/ATS_Delay/ATS_Delay.pde b/arduino-0022-linux-x64/libraries/ArduinoTestSuite/examples/ATS_Delay/ATS_Delay.pde new file mode 100644 index 0000000..8ac9fd2 --- /dev/null +++ b/arduino-0022-linux-x64/libraries/ArduinoTestSuite/examples/ATS_Delay/ATS_Delay.pde @@ -0,0 +1 @@ +//************************************************************************ //* Arduino Test Suite //* ATS_ToneTest //* //* Copyright (c) 2010 Mark Sproul 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 //************************************************************************ //* Aug 31, 2010 Started on TestArduino //* Oct 28, 2010 Started on Delay //************************************************************************ #include "WProgram.h" #include "HardwareSerial.h" #include //************************************************************************ void setup() { short ii; short testNum; int startMemoryUsage; unsigned long startMillis; unsigned long endMillis; unsigned long deltaMillis; unsigned long errMillis; boolean passed; char testNameString[80]; startMemoryUsage = ATS_GetFreeMemory(); ATS_begin("Arduino", "DelayTest"); testNum = 1; //* we start at 2 because 0/1 are RXD/TXD for (ii=0; ii<1000; ii+= 15) { startMillis = millis(); delay(ii); endMillis = millis(); deltaMillis = endMillis - startMillis; if (deltaMillis >= ii) { errMillis = deltaMillis - ii; } else { errMillis = ii - deltaMillis; } if (errMillis <= 1) { passed = true; } else { passed = false; } sprintf(testNameString, "DelayTest.%02d (delay= %4d actual delay=%ld err=%ld)", testNum, ii, deltaMillis, errMillis); ATS_PrintTestStatus(testNameString, passed); testNum++; } ATS_ReportMemoryUsage(startMemoryUsage); ATS_end(); } //************************************************************************ void loop() { } \ No newline at end of file diff --git a/arduino-0022-linux-x64/libraries/ArduinoTestSuite/examples/ATS_General/ATS_General.pde b/arduino-0022-linux-x64/libraries/ArduinoTestSuite/examples/ATS_General/ATS_General.pde new file mode 100644 index 0000000..502248a --- /dev/null +++ b/arduino-0022-linux-x64/libraries/ArduinoTestSuite/examples/ATS_General/ATS_General.pde @@ -0,0 +1,94 @@ +//************************************************************************ +//* Arduino Test Suite +//* (C) 2010 by Mark Sproul +//* Open source as per standard Arduino code +//* +//************************************************************************ +//* Aug 31, 2010 Started on TestArduino +//* Oct 18, 2010 Added memory testing +//************************************************************************ + +#include "WProgram.h" +#include "HardwareSerial.h" +#include "pins_arduino.h" +#include +#include "avr_cpunames.h" + + +#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) +#define kBoard_PinCount 20 +#define kBoard_AnalogCount 6 +#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) +#define kBoard_PinCount 70 +#define kBoard_AnalogCount 16 +#endif + + + + +//************************************************************************ +void setup() +{ + short ii; + uint8_t timerNumber; + int startMemoryUsage; + + startMemoryUsage = ATS_GetFreeMemory(); + + ATS_begin("Arduino", "general"); + + //* test digital pins + //* we start at 2 because 0/1 are RXD/TXD + for (ii=2; ii 1) + ATS_TestSerialLoopback(&Serial1, "Serial1"); +#endif +#if (SERIAL_PORT_COUNT > 2) + ATS_TestSerialLoopback(&Serial2, "Serial2"); +#endif +#if (SERIAL_PORT_COUNT > 3) + ATS_TestSerialLoopback(&Serial3, "Serial3"); +#endif + + ATS_Test_EEPROM(); + + + ATS_ReportMemoryUsage(startMemoryUsage); + + ATS_end(); + +} + + +//************************************************************************ +void loop() +{ + + +} + + + + + diff --git a/arduino-0022-linux-x64/libraries/ArduinoTestSuite/examples/ATS_SD_File/ATS_SD_File.pde b/arduino-0022-linux-x64/libraries/ArduinoTestSuite/examples/ATS_SD_File/ATS_SD_File.pde new file mode 100644 index 0000000..fefd6b0 --- /dev/null +++ b/arduino-0022-linux-x64/libraries/ArduinoTestSuite/examples/ATS_SD_File/ATS_SD_File.pde @@ -0,0 +1,106 @@ +// Tests writing to and reading from a file, in particular the +// the Stream implementation (e.g. read() and peek()). + +#include +#include + +void setup() +{ + int startMemoryUsage = ATS_GetFreeMemory(); + boolean b; + File f; + + ATS_begin("Arduino", "SD Test"); + + ATS_PrintTestStatus("SD.begin()", b = SD.begin(4)); + if (!b) goto done; + + SD.remove("test.txt"); + + f = SD.open("test.txt", FILE_WRITE); + ATS_PrintTestStatus("SD.open()", f); + if (!f) goto done; + + f.print("abc"); + f.print("de"); + f.close(); + + f = SD.open("test.txt", FILE_WRITE); + ATS_PrintTestStatus("SD.open()", f); + if (!f) goto done; + + f.print("fgh"); + f.close(); + + f = SD.open("test.txt"); + ATS_PrintTestStatus("SD.open()", f); + if (!f) goto done; + + ATS_PrintTestStatus("read()", f.read() == 'a'); + ATS_PrintTestStatus("peek()", f.peek() == 'b'); + ATS_PrintTestStatus("read()", f.read() == 'b'); + ATS_PrintTestStatus("read()", f.read() == 'c'); + ATS_PrintTestStatus("peek()", f.peek() == 'd'); + ATS_PrintTestStatus("peek()", f.peek() == 'd'); + ATS_PrintTestStatus("peek()", f.peek() == 'd'); + ATS_PrintTestStatus("peek()", f.peek() == 'd'); + ATS_PrintTestStatus("read()", f.read() == 'd'); + ATS_PrintTestStatus("available()", f.available() != 0); + ATS_PrintTestStatus("read()", f.read() == 'e'); + ATS_PrintTestStatus("available()", f.available() != 0); + ATS_PrintTestStatus("peek()", f.peek() == 'f'); + ATS_PrintTestStatus("read()", f.read() == 'f'); + ATS_PrintTestStatus("peek()", f.peek() == 'g'); + ATS_PrintTestStatus("available()", f.available() != 0); + ATS_PrintTestStatus("peek()", f.peek() == 'g'); + ATS_PrintTestStatus("read()", f.read() == 'g'); + ATS_PrintTestStatus("available()", f.available() != 0); + ATS_PrintTestStatus("available()", f.available() != 0); + ATS_PrintTestStatus("available()", f.available() != 0); + ATS_PrintTestStatus("peek()", f.peek() == 'h'); + ATS_PrintTestStatus("read()", f.read() == 'h'); + ATS_PrintTestStatus("available()", f.available() == 0); + ATS_PrintTestStatus("peek()", f.peek() == -1); + ATS_PrintTestStatus("read()", f.read() == -1); + ATS_PrintTestStatus("peek()", f.peek() == -1); + ATS_PrintTestStatus("read()", f.read() == -1); + + f.close(); + + SD.remove("test2.txt"); + + f = SD.open("test2.txt", FILE_WRITE); + ATS_PrintTestStatus("SD.open()", f); + if (!f) goto done; + + f.print("ABC"); + f.close(); + + f = SD.open("test.txt"); + ATS_PrintTestStatus("SD.open()", f); + if (!f) goto done; + + ATS_PrintTestStatus("peek()", f.peek() == 'a'); + + f.close(); + + f = SD.open("test2.txt"); + ATS_PrintTestStatus("SD.open()", f); + if (!f) goto done; + + ATS_PrintTestStatus("peek()", f.peek() == 'A'); + ATS_PrintTestStatus("read()", f.read() == 'A'); + + f.close(); + +done: + ATS_ReportMemoryUsage(startMemoryUsage); + ATS_end(); + +} + +void loop() {} + + + + diff --git a/arduino-0022-linux-x64/libraries/ArduinoTestSuite/examples/ATS_SD_Files/ATS_SD_Files.pde b/arduino-0022-linux-x64/libraries/ArduinoTestSuite/examples/ATS_SD_Files/ATS_SD_Files.pde new file mode 100644 index 0000000..c3804f4 --- /dev/null +++ b/arduino-0022-linux-x64/libraries/ArduinoTestSuite/examples/ATS_SD_Files/ATS_SD_Files.pde @@ -0,0 +1,78 @@ +#include +#include + +void setup() +{ + int startMemoryUsage = ATS_GetFreeMemory(); + boolean b; + File f; + + ATS_begin("Arduino", "SD Files Test"); + + ATS_PrintTestStatus("SD.begin()", b = SD.begin(4)); + if (!b) goto done; + + ATS_PrintTestStatus("!SD.exists()", !SD.exists("asdf.txt")); + ATS_PrintTestStatus("SD.open()", f = SD.open("asdf.txt", FILE_WRITE)); f.close(); + ATS_PrintTestStatus("SD.exists()", SD.exists("asdf.txt")); + ATS_PrintTestStatus("SD.exists()", SD.exists("/asdf.txt")); + ATS_PrintTestStatus("SD.remove()", SD.remove("asdf.txt")); + ATS_PrintTestStatus("!SD.exists()", !SD.exists("asdf.txt")); + + ATS_PrintTestStatus("!SD.exists()", !SD.exists("asdf")); + ATS_PrintTestStatus("SD.mkdir()", SD.mkdir("asdf")); + ATS_PrintTestStatus("SD.exists()", SD.exists("asdf")); + ATS_PrintTestStatus("SD.exists()", SD.exists("/asdf")); + ATS_PrintTestStatus("SD.exists()", SD.exists("asdf/")); + ATS_PrintTestStatus("SD.rmdir()", SD.rmdir("asdf")); + ATS_PrintTestStatus("!SD.exists()", !SD.exists("asdf")); + + ATS_PrintTestStatus("SD.mkdir()", SD.mkdir("x/y/z")); + ATS_PrintTestStatus("SD.exists()", SD.exists("x")); + ATS_PrintTestStatus("SD.exists()", SD.exists("x/")); + ATS_PrintTestStatus("SD.exists()", SD.exists("x/y")); + ATS_PrintTestStatus("SD.exists()", SD.exists("x/y/")); + ATS_PrintTestStatus("SD.exists()", SD.exists("x/y/z")); + ATS_PrintTestStatus("SD.exists()", SD.exists("x/y/z/")); + ATS_PrintTestStatus("SD.exists()", SD.exists("/x/y/z/")); + ATS_PrintTestStatus("SD.rmdir()", SD.rmdir("x/y/z")); + ATS_PrintTestStatus("SD.exists()", SD.exists("x")); + ATS_PrintTestStatus("SD.exists()", SD.exists("x/y")); + ATS_PrintTestStatus("!SD.exists()", !SD.exists("x/y/z")); + ATS_PrintTestStatus("SD.rmdir()", SD.rmdir("x/y/")); + ATS_PrintTestStatus("SD.exists()", SD.exists("x")); + ATS_PrintTestStatus("!SD.exists()", !SD.exists("x/y")); + ATS_PrintTestStatus("!SD.exists()", !SD.exists("x/y/z")); + ATS_PrintTestStatus("SD.rmdir()", SD.rmdir("/x")); + ATS_PrintTestStatus("!SD.exists()", !SD.exists("x")); + ATS_PrintTestStatus("!SD.exists()", !SD.exists("x/y")); + ATS_PrintTestStatus("!SD.exists()", !SD.exists("x/y/z")); + + ATS_PrintTestStatus("!SD.open()", !(f = SD.open("asdf/asdf.txt", FILE_WRITE))); f.close(); + ATS_PrintTestStatus("!SD.exists()", !SD.exists("asdf")); + ATS_PrintTestStatus("!SD.exists()", !SD.exists("asdf.txt")); + ATS_PrintTestStatus("!SD.exists()", !SD.exists("asdf/asdf.txt")); + ATS_PrintTestStatus("SD.mkdir()", SD.mkdir("asdf")); + ATS_PrintTestStatus("SD.exists()", SD.exists("asdf")); + ATS_PrintTestStatus("SD.open()", f = SD.open("asdf/asdf.txt", FILE_WRITE)); f.close(); + ATS_PrintTestStatus("SD.exists()", SD.exists("asdf/asdf.txt")); + ATS_PrintTestStatus("!SD.rmdir()", !SD.rmdir("asdf")); + ATS_PrintTestStatus("SD.exists()", SD.exists("asdf")); + ATS_PrintTestStatus("SD.exists()", SD.exists("asdf/asdf.txt")); + ATS_PrintTestStatus("SD.remove()", SD.remove("asdf/asdf.txt")); + ATS_PrintTestStatus("!SD.exists()", !SD.exists("asdf/asdf.txt")); + ATS_PrintTestStatus("SD.exists()", SD.exists("asdf")); + ATS_PrintTestStatus("SD.rmdir()", SD.rmdir("asdf")); + ATS_PrintTestStatus("!SD.exists()", !SD.exists("asdf")); + +done: + ATS_ReportMemoryUsage(startMemoryUsage); + ATS_end(); + +} + +void loop() {} + + + + diff --git a/arduino-0022-linux-x64/libraries/ArduinoTestSuite/examples/ATS_SD_Seek/ATS_SD_Seek.pde b/arduino-0022-linux-x64/libraries/ArduinoTestSuite/examples/ATS_SD_Seek/ATS_SD_Seek.pde new file mode 100644 index 0000000..5b0916c --- /dev/null +++ b/arduino-0022-linux-x64/libraries/ArduinoTestSuite/examples/ATS_SD_Seek/ATS_SD_Seek.pde @@ -0,0 +1,109 @@ +// Tests writing to and reading from a file, in particular the +// the Stream implementation (e.g. read() and peek()). + +#include +#include + +void setup() +{ + int startMemoryUsage = ATS_GetFreeMemory(); + boolean b; + File f; + + ATS_begin("Arduino", "SD Test"); + + ATS_PrintTestStatus("SD.begin()", b = SD.begin(4)); + if (!b) goto done; + + SD.remove("test.txt"); + + f = SD.open("test.txt", FILE_WRITE); + ATS_PrintTestStatus("SD.open()", f); + if (!f) goto done; + + ATS_PrintTestStatus("initial position", f.position() == 0); + ATS_PrintTestStatus("initial size", f.size() == 0); + + f.print("0123456789"); + + ATS_PrintTestStatus("position after writing", f.position() == 10); + ATS_PrintTestStatus("size after writing", f.size() == 10); + + f.seek(0); + + ATS_PrintTestStatus("size after seek", f.size() == 10); + ATS_PrintTestStatus("position after seek", f.position() == 0); + + f.seek(7); + + ATS_PrintTestStatus("position after seek", f.position() == 7); + ATS_PrintTestStatus("reading after seek", f.read() == '7'); + ATS_PrintTestStatus("position after reading after seeking", f.position() == 8); + ATS_PrintTestStatus("reading after reading after seeking", f.read() == '8'); + + f.seek(3); + + ATS_PrintTestStatus("position after seeking", f.position() == 3); + ATS_PrintTestStatus("peeking after seeking", f.peek() == '3'); + ATS_PrintTestStatus("position after peeking after seeking", f.position() == 3); + ATS_PrintTestStatus("peeking after peeking after seeking", f.peek() == '3'); + ATS_PrintTestStatus("position after peeking after seeking", f.position() == 3); + ATS_PrintTestStatus("peeking after peeking after seeking", f.read() == '3'); + ATS_PrintTestStatus("position after peeking after seeking", f.position() == 4); + + f.seek(1); + + ATS_PrintTestStatus("position after seeking", f.position() == 1); + ATS_PrintTestStatus("peeking after seeking", f.peek() == '1'); + + f.seek(4); + + ATS_PrintTestStatus("position after seeking", f.position() == 4); + ATS_PrintTestStatus("peeking after seeking", f.peek() == '4'); + + f.seek(7); + + ATS_PrintTestStatus("position()", f.position() == 7); + ATS_PrintTestStatus("read()", f.read() == '7'); + + f.seek(0); + f.peek(); + f.print("AB"); + + ATS_PrintTestStatus("position()", f.position() == 2); + ATS_PrintTestStatus("size()", f.size() == 10); + ATS_PrintTestStatus("read()", f.read() == '2'); + + f.seek(0); + + ATS_PrintTestStatus("read()", f.read() == 'A'); + ATS_PrintTestStatus("read()", f.read() == 'B'); + ATS_PrintTestStatus("read()", f.read() == '2'); + + f.close(); + + f = SD.open("test.txt"); + ATS_PrintTestStatus("SD.open()", f); + if (!f) goto done; + + ATS_PrintTestStatus("position()", f.position() == 0); + ATS_PrintTestStatus("size()", f.size() == 10); + ATS_PrintTestStatus("peek()", f.peek() == 'A'); + ATS_PrintTestStatus("read()", f.read() == 'A'); + + f.seek(4); + + ATS_PrintTestStatus("position()", f.position() == 4); + ATS_PrintTestStatus("size()", f.size() == 10); + ATS_PrintTestStatus("peek()", f.peek() == '4'); + ATS_PrintTestStatus("read()", f.read() == '4'); + + f.close(); + +done: + ATS_ReportMemoryUsage(startMemoryUsage); + ATS_end(); + +} + +void loop() {} diff --git a/arduino-0022-linux-x64/libraries/ArduinoTestSuite/examples/ATS_Skeleton/ATS_Skeleton.pde b/arduino-0022-linux-x64/libraries/ArduinoTestSuite/examples/ATS_Skeleton/ATS_Skeleton.pde new file mode 100644 index 0000000..33fc816 --- /dev/null +++ b/arduino-0022-linux-x64/libraries/ArduinoTestSuite/examples/ATS_Skeleton/ATS_Skeleton.pde @@ -0,0 +1,52 @@ +//************************************************************************ +//* Arduino Test Example Skeleton +//* (C) 2010 by Rick Anderson +//* Open source as per standard Arduino code +//* +//************************************************************************ +//* Oct 16, 2010 Started on String Test +//************************************************************************ + +#include "WProgram.h" +#include "HardwareSerial.h" +#include + +//************************************************************************ +void setup() +{ + int startMemoryUsage; + + //startMemoryUsage must be set directly before ATS_begin + startMemoryUsage = ATS_GetFreeMemory(); + ATS_begin("Arduino", "Skeleton Test"); + /* + * Test Run Start + * Test one passes because result is set to true + * Test two fails becuase result is set to false + * You can test memory for any set of tests by using the ATS_ReportMemoryUsage test + * There is also a way to print current memeory for debugging + */ + ATS_PrintTestStatus("1. Test of true test status", true); + + ATS_PrintTestStatus("2. Test of false test status, this will fail.", false); + + ATS_ReportMemoryUsage(startMemoryUsage); + /* + * Test Run End + */ + + ATS_end(); + +} + + +//************************************************************************ +void loop() +{ + + +} + + + + diff --git a/arduino-0022-linux-x64/libraries/ArduinoTestSuite/examples/ATS_StringIndexOfMemory/ATS_StringIndexOfMemory.pde b/arduino-0022-linux-x64/libraries/ArduinoTestSuite/examples/ATS_StringIndexOfMemory/ATS_StringIndexOfMemory.pde new file mode 100644 index 0000000..71a6bea --- /dev/null +++ b/arduino-0022-linux-x64/libraries/ArduinoTestSuite/examples/ATS_StringIndexOfMemory/ATS_StringIndexOfMemory.pde @@ -0,0 +1,102 @@ +//************************************************************************ +//* Arduino Test Example Skeleton +//* (C) 2010 by Rick Anderson +//* Open source as per standard Arduino code +//* +//************************************************************************ +//* Oct 16, 2010 Started on String Test +//************************************************************************ + +#include "WProgram.h" +#include "HardwareSerial.h" +#include + +//************************************************************************ +void setup() +{ + char testName[64]; + int startMemoryUsage; + /* + * Create variable for the tests. + */ + + + String stringOne; + int firstClosingBracket; + int firstOpeningBracket; + int secondOpeningBracket; + int secondClosingBracket; + int bodyTag; + int firstListItem; + int secondListItem; + int lastOpeningBracket; + int lastListItem; + int lastParagraph; + int secondLastGraf; + + /*; + * initiate the test run + */ + startMemoryUsage = ATS_GetFreeMemory(); + ATS_begin("Arduino", "String Memory Test"); + // indexOf() returns the position (i.e. index) of a particular character + // in a string. For example, if you were parsing HTML tags, you could use it: + stringOne = ""; + firstClosingBracket = stringOne.indexOf('>'); + Serial.println("The index of > in the string " + stringOne + " is " + firstClosingBracket); + + stringOne = ""; + secondOpeningBracket = firstClosingBracket + 1; + secondClosingBracket = stringOne.indexOf('>', secondOpeningBracket ); + Serial.println("The index of the second > in the string " + stringOne + " is " + secondClosingBracket); + + // you can also use indexOf() to search for Strings: + stringOne = ""; + bodyTag = stringOne.indexOf(""); + Serial.println("The index of the body tag in the string " + stringOne + " is " + bodyTag); + + stringOne = "
    • item
    • item
    • item
    "; + firstListItem = stringOne.indexOf("
  • "); + secondListItem = stringOne.indexOf("item", firstListItem + 1 ); + Serial.println("The index of the second list item in the string " + stringOne + " is " + secondClosingBracket); + + // lastIndexOf() gives you the last occurrence of a character or string: + lastOpeningBracket = stringOne.lastIndexOf('<'); + Serial.println("The index of the last < in the string " + stringOne + " is " + lastOpeningBracket); + + lastListItem = stringOne.lastIndexOf("
  • "); + Serial.println("The index of the last list item in the string " + stringOne + " is " + lastListItem); + + + // lastIndexOf() can also search for a string: + stringOne = "

    Lorem ipsum dolor sit amet

    Ipsem

    Quod

    "; + lastParagraph = stringOne.lastIndexOf(" Started on String Test +//************************************************************************ + +#include "WProgram.h" +#include "HardwareSerial.h" +#include + +//************************************************************************ +void setup() +{ + + int startMemoryUsage; + + ATS_begin("Arduino", "Test of String Library"); + + /* + * Test Variable Setup + * Best practive set all your test variables prior to teseting. + * This is required for Memory tests. + */ + + String stringOne = String("stringThree = "); + String stringTwo = String("this string"); + String stringThree = String (); + char charResult[100]; + + + + /* + * Run the tests + */ + + // adding a constant integer to a string: + stringThree = stringOne + 123; + //strcpy(charResult, "\0"); + stringThree.toCharArray(charResult, sizeof(charResult)); + + ATS_PrintTestStatus("1. Adding a constant integer to a string:", strcmp(charResult,"stringThree = 123" ) == 0); + + // adding a constant long interger to a string: + stringThree = stringOne + 123456789; + stringThree.toCharArray(charResult, sizeof(charResult)); + + ATS_PrintTestStatus("2. Adding a constant long interger to a string", strcmp(charResult,"stringThree = 123456789" ) == 0); + + + // adding a constant character to a string: + stringThree = stringOne + 'A'; + stringThree.toCharArray(charResult, sizeof(charResult)); + + ATS_PrintTestStatus("3. Adding a constant character to a string", strcmp(charResult,"stringThree = A" ) == 0); + + + // adding a constant string to a string: + stringThree = stringOne + "abc"; + stringThree.toCharArray(charResult, sizeof(charResult)); + + ATS_PrintTestStatus("4. Adding a constant string variable to a string", strcmp(charResult,"stringThree = abc" ) == 0); + + //"5. Adding a constant long interger to a string" + stringThree = stringOne + stringTwo; + stringThree.toCharArray(charResult, sizeof(charResult)); + + ATS_PrintTestStatus("5. Adding a constant long interger to a string", strcmp(charResult,"stringThree = this string" ) == 0); + + + /* + * setup up String Comparison Operater Tests + */ + + stringOne = String("this"); + stringTwo = String("that"); + + // two strings equal: + ATS_PrintTestStatus("6. Two strings equal",stringOne == "this"); + + // two strings not equal: + ATS_PrintTestStatus("7. Two strings not equal",stringOne != stringTwo); + + // two strings not equal (case sensitivity matters): + stringOne = "This"; + stringTwo = "this"; + ATS_PrintTestStatus("8. Two strings not equal [case sensitivity matters]", stringOne != stringTwo); + + // you can also use equals() to see if two strings are the same: + stringOne = "this"; + stringTwo = "this"; + ATS_PrintTestStatus("9. Equals() method equals", stringOne.equals(stringTwo)); + + + // you can also use not equals() to see if two strings are not the same: + stringOne = String("This"); + stringTwo = String("this"); + ATS_PrintTestStatus("10. Not equals() method equals", !stringOne.equals(stringTwo)); + + // or perhaps you want to ignore case: + ATS_PrintTestStatus("11. EqualsIgnoreCase() method equals", stringOne.equalsIgnoreCase(stringTwo)); + + // a numeric string compared to the number it represents: + stringOne = "1"; + int numberOne = 1; + ATS_PrintTestStatus("12. A numeric string compared to the number it represents", stringOne == numberOne); + + // two numeric strings compared: + stringOne = "2"; + stringTwo = "1"; + ATS_PrintTestStatus("13. Two numeric strings compared",stringOne >= stringTwo); + + + // comparison operators can be used to compare strings for alphabetic sorting too: + +/* + stringOne = String("Brown"); + ATS_PrintTestStatus("14. comparison operator < can be used to compare strings for alphabetic sorting ",stringOne < "Charles"); + ATS_PrintTestStatus("15. comparison operator > can be used to compare strings for alphabetic sorting ",stringOne > "Adams"); + ATS_PrintTestStatus("16. comparison operator <= can be used to compare strings for alphabetic sorting ",stringOne <= "Browne"); + ATS_PrintTestStatus("17. comparison operator >= can be used to compare strings for alphabetic sorting ",stringOne >= "Brow"); + */ + + + // the compareTo() operator also allows you to compare strings + stringOne = "Cucumber"; + stringTwo = "Cucuracha"; + + ATS_PrintTestStatus("18. The compareTo() operator also allows you to compare strings", stringOne.compareTo(stringTwo) < 0); + + // compareTo() String with numnber > String with number: + stringOne = "Sensor: 50"; + stringTwo= "Sensor: 150"; + ATS_PrintTestStatus("19. The compareTo() String with integers", stringOne.compareTo(stringTwo) < 0); + + +// compareTo() String with numnber > String with number append integer, matches example code: + stringOne = "Sensor: "; + stringTwo= "Sensor: "; + stringOne += 50; + stringTwo += 150; + ATS_PrintTestStatus("20. The compareTo() compare strings with appended integers", stringOne.compareTo(stringTwo) < 0); + + + /* + * setup up String Append Operation Tests + */ + // Serious awful problem here + stringOne = String("Sensor "); + stringTwo = String("value"); + + stringOne += stringTwo; + ATS_PrintTestStatus("21. Adding string to string += ", stringOne.equals("Sensor value")); + + ATS_PrintTestStatus("22. The compareTo() compare strings with appended integers", stringOne.compareTo(stringTwo) < 0); + /* + * Test complete + */ + + ATS_end(); + +} + + +//************************************************************************ +void loop() +{ + + +} + + + + + + + + + + + + diff --git a/arduino-0022-linux-x64/libraries/ArduinoTestSuite/examples/ATS_ToneTest/ATS_ToneTest.pde b/arduino-0022-linux-x64/libraries/ArduinoTestSuite/examples/ATS_ToneTest/ATS_ToneTest.pde new file mode 100644 index 0000000..8bec6be --- /dev/null +++ b/arduino-0022-linux-x64/libraries/ArduinoTestSuite/examples/ATS_ToneTest/ATS_ToneTest.pde @@ -0,0 +1,250 @@ +//************************************************************************ +//* Arduino Test Suite +//* ATS_ToneTest +//* +//* Copyright (c) 2010 Mark Sproul 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 +//************************************************************************ +//* Aug 31, 2010 Started on TestArduino +//* Oct 23, 2010 Started on ToneTest +//************************************************************************ + + + + + +#include "WProgram.h" +#include "HardwareSerial.h" + +#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) + #define kBoard_PinCount 20 + #define kBoard_AnalogCount 6 +#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) + #define kBoard_PinCount 70 + #define kBoard_AnalogCount 16 +#endif + +#include + +//************************************************************************ +void TestTonePin(uint8_t toneOutputPinNumber) +{ +uint8_t helperpin; +unsigned long startMilliSecs; +unsigned long highCount, lowCount; +int previousState; +int currentState; +char testNameString[80]; +long outputFreq; +long measuredFreq; +boolean passed; +long percentError; +long deltaFreq; + + if ((toneOutputPinNumber % 2) == 0) + { + //* if its EVEN, add 1 + helperpin = toneOutputPinNumber + 1; + } + else + { + //* if its ODD + helperpin = toneOutputPinNumber - 1; + } + + //* dont set the mode of the OUTPUT pin, the tone command does that + + pinMode(helperpin, INPUT); + + previousState = digitalRead(helperpin); + startMilliSecs = millis(); + highCount = 0; + lowCount = 0; + measuredFreq = 0; + //* we are going to watch for one second + outputFreq = random(200, 2000); + + tone(toneOutputPinNumber, outputFreq); + while ((millis() - startMilliSecs) < 1000) + { + currentState = digitalRead(helperpin); + if (currentState == HIGH) + { + highCount++; + } + else + { + lowCount++; + } + //* check to see if it changed state + if ((currentState == HIGH) && (previousState == LOW)) + { + measuredFreq++; + } + + previousState = currentState; + } + noTone(toneOutputPinNumber); + + deltaFreq = abs(measuredFreq - outputFreq); + + percentError = 100 - abs(((outputFreq - deltaFreq) * 100) / outputFreq); + + sprintf(testNameString, "ToneTest.%02d (out freq= %4ld measured freq= %4ld err= %ld%%)", toneOutputPinNumber, outputFreq, measuredFreq, percentError); + if (percentError < 5) + { + passed = true; + } + else + { + passed = false; + } + + ATS_PrintTestStatus(testNameString, passed); +} + + +//************************************************************************ +//* this test to make sure the duration option works +void TestToneDuration(uint8_t toneOutputPinNumber) +{ +uint8_t helperpin; +unsigned long startMilliSecs; +unsigned long highCount, lowCount; +int previousState; +int currentState; +char testNameString[80]; +long outputFreq; +long measuredFreq; +boolean passed; +long percentError; +long deltaFreq; +long durationTime; + + if ((toneOutputPinNumber % 2) == 0) + { + //* if its EVEN, add 1 + helperpin = toneOutputPinNumber + 1; + } + else + { + //* if its ODD + helperpin = toneOutputPinNumber - 1; + } + + //* dont set the mode of the OUTPUT pin, the tone command does that + + pinMode(helperpin, INPUT); + + previousState = digitalRead(helperpin); + startMilliSecs = millis(); + highCount = 0; + lowCount = 0; + measuredFreq = 0; + durationTime = 0; + //* we are going to watch for one second + outputFreq = random(500, 2000); + + tone(toneOutputPinNumber, outputFreq, 1000); + while ((millis() - startMilliSecs) < 2000) + { + currentState = digitalRead(helperpin); + if (currentState == HIGH) + { + highCount++; + } + else + { + lowCount++; + } + //* count the freq + if ((currentState == HIGH) && (previousState == LOW)) + { + measuredFreq++; + } + + //* check to see if it changed state + if (currentState != previousState) + { + durationTime = millis() - startMilliSecs; + } + + previousState = currentState; + } + + deltaFreq = abs(measuredFreq - outputFreq); + + percentError = 100 - abs(((outputFreq - deltaFreq) * 100) / outputFreq); + + sprintf(testNameString, "ToneTesDurationt.%02d (durationTime =%4ld/1000 freq err= %ld%%)", toneOutputPinNumber, durationTime, percentError); + if ((durationTime > 990) && (durationTime < 1010) && (percentError < 5)) + { + passed = true; + } + else + { + passed = false; + } + noTone(toneOutputPinNumber); + + ATS_PrintTestStatus(testNameString, passed); +} + + + +//************************************************************************ +void setup() +{ +short ii; +uint8_t timerNumber; +int startMemoryUsage; + + startMemoryUsage = ATS_GetFreeMemory(); + + ATS_begin("Arduino", "ToneTest"); + + + //* we start at 2 because 0/1 are RXD/TXD + for (ii=2; ii diff --git a/arduino-0018-linux-x64/libraries/EEPROM/examples/eeprom_read/eeprom_read.pde b/arduino-0022-linux-x64/libraries/EEPROM/examples/eeprom_read/eeprom_read.pde similarity index 93% rename from arduino-0018-linux-x64/libraries/EEPROM/examples/eeprom_read/eeprom_read.pde rename to arduino-0022-linux-x64/libraries/EEPROM/examples/eeprom_read/eeprom_read.pde index 2e30708..88e3488 100644 --- a/arduino-0018-linux-x64/libraries/EEPROM/examples/eeprom_read/eeprom_read.pde +++ b/arduino-0022-linux-x64/libraries/EEPROM/examples/eeprom_read/eeprom_read.pde @@ -3,6 +3,7 @@ * * Reads the value of each byte of the EEPROM and prints it * to the computer. + * This example code is in the public domain. */ #include diff --git a/arduino-0018-linux-x64/libraries/EEPROM/examples/eeprom_write/eeprom_write.pde b/arduino-0022-linux-x64/libraries/EEPROM/examples/eeprom_write/eeprom_write.pde similarity index 100% rename from arduino-0018-linux-x64/libraries/EEPROM/examples/eeprom_write/eeprom_write.pde rename to arduino-0022-linux-x64/libraries/EEPROM/examples/eeprom_write/eeprom_write.pde diff --git a/arduino-0018-linux-x64/libraries/EEPROM/keywords.txt b/arduino-0022-linux-x64/libraries/EEPROM/keywords.txt similarity index 100% rename from arduino-0018-linux-x64/libraries/EEPROM/keywords.txt rename to arduino-0022-linux-x64/libraries/EEPROM/keywords.txt diff --git a/arduino-0018-linux-x64/libraries/Ethernet/Client.cpp b/arduino-0022-linux-x64/libraries/Ethernet/Client.cpp similarity index 53% rename from arduino-0018-linux-x64/libraries/Ethernet/Client.cpp rename to arduino-0022-linux-x64/libraries/Ethernet/Client.cpp index 0511c7b..3b1084f 100644 --- a/arduino-0018-linux-x64/libraries/Ethernet/Client.cpp +++ b/arduino-0022-linux-x64/libraries/Ethernet/Client.cpp @@ -1,7 +1,7 @@ +#include "w5100.h" +#include "socket.h" + extern "C" { - #include "types.h" - #include "w5100.h" - #include "socket.h" #include "string.h" } @@ -11,71 +11,67 @@ extern "C" { #include "Client.h" #include "Server.h" -uint16_t Client::_srcport = 0; +uint16_t Client::_srcport = 1024; -Client::Client(uint8_t sock) { - _sock = sock; +Client::Client(uint8_t sock) : _sock(sock) { } -Client::Client(uint8_t *ip, uint16_t port) { - _ip = ip; - _port = port; - _sock = 255; +Client::Client(uint8_t *ip, uint16_t port) : _ip(ip), _port(port), _sock(MAX_SOCK_NUM) { } uint8_t Client::connect() { - if (_sock != 255) + if (_sock != MAX_SOCK_NUM) return 0; - + for (int i = 0; i < MAX_SOCK_NUM; i++) { - uint8_t s = getSn_SR(i); - if (s == SOCK_CLOSED || s == SOCK_FIN_WAIT) { + uint8_t s = W5100.readSnSR(i); + if (s == SnSR::CLOSED || s == SnSR::FIN_WAIT) { _sock = i; break; } } - - if (_sock == 255) + + if (_sock == MAX_SOCK_NUM) return 0; - + _srcport++; - if (_srcport + 1024 == 0) _srcport = 0; - socket(_sock, Sn_MR_TCP, _srcport + 1024, 0); - + if (_srcport == 0) _srcport = 1024; + socket(_sock, SnMR::TCP, _srcport, 0); + if (!::connect(_sock, _ip, _port)) { - _sock = 255; + _sock = MAX_SOCK_NUM; return 0; } - - while (status() != SOCK_ESTABLISHED) { + + while (status() != SnSR::ESTABLISHED) { delay(1); - if (status() == SOCK_CLOSED) { - _sock = 255; + if (status() == SnSR::CLOSED) { + _sock = MAX_SOCK_NUM; return 0; } } - + return 1; } void Client::write(uint8_t b) { - if (_sock != 255) + if (_sock != MAX_SOCK_NUM) send(_sock, &b, 1); } void Client::write(const char *str) { - if (_sock != 255) + if (_sock != MAX_SOCK_NUM) send(_sock, (const uint8_t *)str, strlen(str)); } void Client::write(const uint8_t *buf, size_t size) { - if (_sock != 255) + if (_sock != MAX_SOCK_NUM) send(_sock, buf, size); } int Client::available() { - if (_sock != 255) - return getSn_RX_RSR(_sock); + if (_sock != MAX_SOCK_NUM) + return W5100.getRXReceivedSize(_sock); return 0; } @@ -87,47 +83,50 @@ int Client::read() { return b; } +int Client::peek() { + uint8_t b; + if (!available()) + return -1; + ::peek(_sock, &b); + return b; +} + void Client::flush() { while (available()) read(); } void Client::stop() { - if (_sock == 255) + if (_sock == MAX_SOCK_NUM) return; - + // attempt to close the connection gracefully (send a FIN to other side) disconnect(_sock); unsigned long start = millis(); - + // wait a second for the connection to close - while (status() != SOCK_CLOSED && millis() - start < 1000) + while (status() != SnSR::CLOSED && millis() - start < 1000) delay(1); - + // if it hasn't closed, close it forcefully - if (status() != SOCK_CLOSED) + if (status() != SnSR::CLOSED) close(_sock); - + EthernetClass::_server_port[_sock] = 0; - _sock = 255; + _sock = MAX_SOCK_NUM; } uint8_t Client::connected() { - if (_sock == 255) { - return 0; - } else { - uint8_t s = status(); - return !(s == SOCK_LISTEN || s == SOCK_CLOSED || s == SOCK_FIN_WAIT || - (s == SOCK_CLOSE_WAIT && !available())); - } + if (_sock == MAX_SOCK_NUM) return 0; + + uint8_t s = status(); + return !(s == SnSR::LISTEN || s == SnSR::CLOSED || s == SnSR::FIN_WAIT || + (s == SnSR::CLOSE_WAIT && !available())); } uint8_t Client::status() { - if (_sock == 255) { - return SOCK_CLOSED; - } else { - return getSn_SR(_sock); - } + if (_sock == MAX_SOCK_NUM) return SnSR::CLOSED; + return W5100.readSnSR(_sock); } // the next three functions are a hack so we can compare the client returned @@ -136,13 +135,13 @@ uint8_t Client::status() { // library. uint8_t Client::operator==(int p) { - return _sock == 255; + return _sock == MAX_SOCK_NUM; } uint8_t Client::operator!=(int p) { - return _sock != 255; + return _sock != MAX_SOCK_NUM; } Client::operator bool() { - return _sock != 255; + return _sock != MAX_SOCK_NUM; } diff --git a/arduino-0018-linux-x64/libraries/Ethernet/Client.h b/arduino-0022-linux-x64/libraries/Ethernet/Client.h similarity index 70% rename from arduino-0018-linux-x64/libraries/Ethernet/Client.h rename to arduino-0022-linux-x64/libraries/Ethernet/Client.h index 7c0ccdf..f0080bd 100644 --- a/arduino-0018-linux-x64/libraries/Ethernet/Client.h +++ b/arduino-0022-linux-x64/libraries/Ethernet/Client.h @@ -1,31 +1,37 @@ -#ifndef Client_h -#define Client_h - +#ifndef client_h +#define client_h +#include "WProgram.h" #include "Print.h" -class Client : public Print { -private: - static uint16_t _srcport; - uint8_t _sock; - uint8_t *_ip; - uint16_t _port; +class Client : public Stream { + public: + Client(); Client(uint8_t); Client(uint8_t *, uint16_t); + uint8_t status(); uint8_t connect(); virtual void write(uint8_t); virtual void write(const char *str); virtual void write(const uint8_t *buf, size_t size); - int available(); - int read(); - void flush(); + virtual int available(); + virtual int read(); + virtual int peek(); + virtual void flush(); void stop(); uint8_t connected(); uint8_t operator==(int); uint8_t operator!=(int); operator bool(); + friend class Server; + +private: + static uint16_t _srcport; + uint8_t _sock; + uint8_t *_ip; + uint16_t _port; }; #endif diff --git a/arduino-0018-linux-x64/libraries/Ethernet/Ethernet.cpp b/arduino-0022-linux-x64/libraries/Ethernet/Ethernet.cpp similarity index 59% rename from arduino-0018-linux-x64/libraries/Ethernet/Ethernet.cpp rename to arduino-0022-linux-x64/libraries/Ethernet/Ethernet.cpp index cb74876..91cbacd 100644 --- a/arduino-0018-linux-x64/libraries/Ethernet/Ethernet.cpp +++ b/arduino-0022-linux-x64/libraries/Ethernet/Ethernet.cpp @@ -1,13 +1,11 @@ -extern "C" { - #include "types.h" - #include "w5100.h" -} - +#include "w5100.h" #include "Ethernet.h" // XXX: don't make assumptions about the value of MAX_SOCK_NUM. -uint8_t EthernetClass::_state[MAX_SOCK_NUM] = { 0, 0, 0, 0 }; -uint16_t EthernetClass::_server_port[MAX_SOCK_NUM] = { 0, 0, 0, 0 }; +uint8_t EthernetClass::_state[MAX_SOCK_NUM] = { + 0, 0, 0, 0 }; +uint16_t EthernetClass::_server_port[MAX_SOCK_NUM] = { + 0, 0, 0, 0 }; void EthernetClass::begin(uint8_t *mac, uint8_t *ip) { @@ -21,18 +19,18 @@ void EthernetClass::begin(uint8_t *mac, uint8_t *ip) void EthernetClass::begin(uint8_t *mac, uint8_t *ip, uint8_t *gateway) { - uint8_t subnet[] = { 255, 255, 255, 0 }; + uint8_t subnet[] = { + 255, 255, 255, 0 }; begin(mac, ip, gateway, subnet); } void EthernetClass::begin(uint8_t *mac, uint8_t *ip, uint8_t *gateway, uint8_t *subnet) { - iinchip_init(); - sysinit(0x55, 0x55); - setSHAR(mac); - setSIPR(ip); - setGAR(gateway); - setSUBR(subnet); + W5100.init(); + W5100.setMACAddress(mac); + W5100.setIPAddress(ip); + W5100.setGatewayIp(gateway); + W5100.setSubnetMask(subnet); } EthernetClass Ethernet; diff --git a/arduino-0018-linux-x64/libraries/Ethernet/Ethernet.h b/arduino-0022-linux-x64/libraries/Ethernet/Ethernet.h similarity index 83% rename from arduino-0018-linux-x64/libraries/Ethernet/Ethernet.h rename to arduino-0022-linux-x64/libraries/Ethernet/Ethernet.h index bdfc4dd..a91f1aa 100644 --- a/arduino-0018-linux-x64/libraries/Ethernet/Ethernet.h +++ b/arduino-0022-linux-x64/libraries/Ethernet/Ethernet.h @@ -1,10 +1,13 @@ -#ifndef Ethernet_h -#define Ethernet_h +#ifndef ethernet_h +#define ethernet_h #include +//#include "w5100.h" #include "Client.h" #include "Server.h" +#define MAX_SOCK_NUM 4 + class EthernetClass { private: public: diff --git a/arduino-0018-linux-x64/libraries/Ethernet/Server.cpp b/arduino-0022-linux-x64/libraries/Ethernet/Server.cpp similarity index 74% rename from arduino-0018-linux-x64/libraries/Ethernet/Server.cpp rename to arduino-0022-linux-x64/libraries/Ethernet/Server.cpp index d17a5d3..4271741 100644 --- a/arduino-0018-linux-x64/libraries/Ethernet/Server.cpp +++ b/arduino-0022-linux-x64/libraries/Ethernet/Server.cpp @@ -1,8 +1,7 @@ +#include "w5100.h" +#include "socket.h" extern "C" { - #include "types.h" - #include "w5100.h" - #include "socket.h" - #include "string.h" +#include "string.h" } #include "Ethernet.h" @@ -18,8 +17,8 @@ void Server::begin() { for (int sock = 0; sock < MAX_SOCK_NUM; sock++) { Client client(sock); - if (client.status() == SOCK_CLOSED) { - socket(sock, Sn_MR_TCP, _port, 0); + if (client.status() == SnSR::CLOSED) { + socket(sock, SnMR::TCP, _port, 0); listen(sock); EthernetClass::_server_port[sock] = _port; break; @@ -30,19 +29,20 @@ void Server::begin() void Server::accept() { int listening = 0; - + for (int sock = 0; sock < MAX_SOCK_NUM; sock++) { Client client(sock); - + if (EthernetClass::_server_port[sock] == _port) { - if (client.status() == SOCK_LISTEN) { + if (client.status() == SnSR::LISTEN) { listening = 1; - } else if (client.status() == SOCK_CLOSE_WAIT && !client.available()) { + } + else if (client.status() == SnSR::CLOSE_WAIT && !client.available()) { client.stop(); } } } - + if (!listening) { begin(); } @@ -51,19 +51,20 @@ void Server::accept() Client Server::available() { accept(); - + for (int sock = 0; sock < MAX_SOCK_NUM; sock++) { Client client(sock); if (EthernetClass::_server_port[sock] == _port && - client.status() == SOCK_ESTABLISHED) { + (client.status() == SnSR::ESTABLISHED || + client.status() == SnSR::CLOSE_WAIT)) { if (client.available()) { // XXX: don't always pick the lowest numbered socket. return client; } } } - - return Client(255); + + return Client(MAX_SOCK_NUM); } void Server::write(uint8_t b) @@ -79,12 +80,12 @@ void Server::write(const char *str) void Server::write(const uint8_t *buffer, size_t size) { accept(); - + for (int sock = 0; sock < MAX_SOCK_NUM; sock++) { Client client(sock); - + if (EthernetClass::_server_port[sock] == _port && - client.status() == SOCK_ESTABLISHED) { + client.status() == SnSR::ESTABLISHED) { client.write(buffer, size); } } diff --git a/arduino-0018-linux-x64/libraries/Ethernet/Server.h b/arduino-0022-linux-x64/libraries/Ethernet/Server.h similarity index 72% rename from arduino-0018-linux-x64/libraries/Ethernet/Server.h rename to arduino-0022-linux-x64/libraries/Ethernet/Server.h index 73d6a5e..6aa5d3a 100644 --- a/arduino-0018-linux-x64/libraries/Ethernet/Server.h +++ b/arduino-0022-linux-x64/libraries/Ethernet/Server.h @@ -1,15 +1,12 @@ -#ifndef Server_h -#define Server_h - -extern "C" { - #include "utility/types.h" -} +#ifndef server_h +#define server_h #include "Print.h" class Client; -class Server : public Print { +class Server : +public Print { private: uint16_t _port; void accept(); diff --git a/arduino-0022-linux-x64/libraries/Ethernet/Udp.cpp b/arduino-0022-linux-x64/libraries/Ethernet/Udp.cpp new file mode 100644 index 0000000..17eaac6 --- /dev/null +++ b/arduino-0022-linux-x64/libraries/Ethernet/Udp.cpp @@ -0,0 +1,136 @@ +/* + * Udp.cpp: Library to send/receive UDP packets with the Arduino ethernet shield. + * This version only offers minimal wrapping of socket.c/socket.h + * Drop Udp.h/.cpp into the Ethernet library directory at hardware/libraries/Ethernet/ + * + * 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 + */ + +#include "w5100.h" +#include "socket.h" +#include "Ethernet.h" +#include "Udp.h" + +/* Start UDP socket, listening at local port PORT */ +void UdpClass::begin(uint16_t port) { + _port = port; + _sock = 0; //TODO: should not be hardcoded + socket(_sock, SnMR::UDP, _port, 0); +} + +/* Send packet contained in buf of length len to peer at specified ip, and port */ +/* Use this function to transmit binary data that might contain 0x00 bytes*/ +/* This function returns sent data size for success else -1. */ +uint16_t UdpClass::sendPacket(uint8_t * buf, uint16_t len, uint8_t * ip, uint16_t port){ + return sendto(_sock,(const uint8_t *)buf,len,ip,port); +} + +/* Send zero-terminated string str as packet to peer at specified ip, and port */ +/* This function returns sent data size for success else -1. */ +uint16_t UdpClass::sendPacket(const char str[], uint8_t * ip, uint16_t port){ + // compute strlen + const char *s; + for(s = str; *s; ++s); + uint16_t len = (s-str); + // send packet + return sendto(_sock,(const uint8_t *)str,len,ip,port); +} +/* Is data available in rx buffer? Returns 0 if no, number of available bytes if yes. + * returned value includes 8 byte UDP header!*/ +int UdpClass::available() { + return W5100.getRXReceivedSize(_sock); +} + + +/* Read a received packet into buffer buf (which is of maximum length len); */ +/* store calling ip and port as well. Call available() to make sure data is ready first. */ +/* NOTE: I don't believe len is ever checked in implementation of recvfrom(),*/ +/* so it's easy to overflow buffer. so we check and truncate. */ +/* returns number of bytes read, or negative number of bytes we would have needed if we truncated */ +int UdpClass::readPacket(uint8_t * buf, uint16_t bufLen, uint8_t *ip, uint16_t *port) { + int packetLen = available()-8; //skip UDP header; + if(packetLen < 0 ) return 0; // no real data here + if(packetLen > (int)bufLen) { + //packet is too large - truncate + //HACK - hand-parse the UDP packet using TCP recv method + uint8_t tmpBuf[8]; + int i; + //read 8 header bytes and get IP and port from it + recv(_sock,tmpBuf,8); + ip[0] = tmpBuf[0]; + ip[1] = tmpBuf[1]; + ip[2] = tmpBuf[2]; + ip[3] = tmpBuf[3]; + *port = tmpBuf[4]; + *port = (*port << 8) + tmpBuf[5]; + + //now copy first (bufLen) bytes into buf + for(i=0;i<(int)bufLen;i++) { + recv(_sock,tmpBuf,1); + buf[i]=tmpBuf[0]; + } + + //and just read the rest byte by byte and throw it away + while(available()) { + recv(_sock,tmpBuf,1); + } + + return (-1*packetLen); + + //ALTERNATIVE: requires stdlib - takes a bunch of space + /*//create new buffer and read everything into it + uint8_t * tmpBuf = (uint8_t *)malloc(packetLen); + recvfrom(_sock,tmpBuf,packetLen,ip,port); + if(!tmpBuf) return 0; //couldn't allocate + // copy first bufLen bytes + for(unsigned int i=0; i +// the sensor communicates using SPI, so include the library: +#include + + +// assign a MAC address for the ethernet controller. +// fill in your address here: +byte mac[] = { + 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED}; +// assign an IP address for the controller: +byte ip[] = { + 192,168,1,20 }; +byte gateway[] = { + 192,168,1,1}; +byte subnet[] = { + 255, 255, 255, 0 }; + + +// Initialize the Ethernet server library +// with the IP address and port you want to use +// (port 80 is default for HTTP): +Server server(80); + + +//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 + +// pins used for the connection with the sensor +// the others you need are controlled by the SPI library): +const int dataReadyPin = 6; +const int chipSelectPin = 7; + +float temperature = 0.0; +long pressure = 0; +long lastReadingTime = 0; + +void setup() { + // start the SPI library: + SPI.begin(); + + // start the Ethernet connection and the server: + Ethernet.begin(mac, ip); + server.begin(); + + // initalize the data ready and chip select pins: + pinMode(dataReadyPin, INPUT); + pinMode(chipSelectPin, OUTPUT); + + Serial.begin(9600); + + //Configure SCP1000 for low noise configuration: + writeRegister(0x02, 0x2D); + writeRegister(0x01, 0x03); + writeRegister(0x03, 0x02); + + // give the sensor and Ethernet shield time to set up: + delay(1000); + + //Set the sensor to high resolution mode tp start readings: + writeRegister(0x03, 0x0A); + +} + +void loop() { + // check for a reading no more than once a second. + if (millis() - lastReadingTime > 1000){ + // if there's a reading ready, read it: + // don't do anything until the data ready pin is high: + if (digitalRead(dataReadyPin) == HIGH) { + getData(); + // timestamp the last time you got a reading: + lastReadingTime = millis(); + } + } + + // listen for incoming Ethernet connections: + listenForClients(); +} + + +void getData() { + Serial.println("Getting reading"); + //Read the temperature data + int tempData = readRegister(0x21, 2); + + // convert the temperature to celsius and display it: + temperature = (float)tempData / 20.0; + + //Read the pressure data highest 3 bits: + byte pressureDataHigh = readRegister(0x1F, 1); + pressureDataHigh &= 0b00000111; //you only needs bits 2 to 0 + + //Read the pressure data lower 16 bits: + unsigned int pressureDataLow = readRegister(0x20, 2); + //combine the two parts into one 19-bit number: + pressure = ((pressureDataHigh << 16) | pressureDataLow)/4; + + Serial.print("Temperature: "); + Serial.print(temperature); + Serial.println(" degrees C"); + Serial.print("Pressure: " + String(pressure)); + Serial.println(" Pa"); +} + +void listenForClients() { + // listen for incoming clients + Client client = server.available(); + if (client) { + Serial.println("Got a client"); + // an http request ends with a blank line + boolean currentLineIsBlank = true; + while (client.connected()) { + if (client.available()) { + char c = client.read(); + // if you've gotten to the end of the line (received a newline + // character) and the line is blank, the http request has ended, + // so you can send a reply + if (c == '\n' && currentLineIsBlank) { + // send a standard http response header + client.println("HTTP/1.1 200 OK"); + client.println("Content-Type: text/html"); + client.println(); + // print the current readings, in HTML format: + client.print("Temperature: "); + client.print(temperature); + client.print(" degrees C"); + client.println("
    "); + client.print("Pressure: " + String(pressure)); + client.print(" Pa"); + client.println("
    "); + break; + } + if (c == '\n') { + // you're starting a new line + currentLineIsBlank = true; + } + else if (c != '\r') { + // you've gotten a character on the current line + currentLineIsBlank = false; + } + } + } + // give the web browser time to receive the data + delay(1); + // close the connection: + client.stop(); + } +} + + +//Send a write command to SCP1000 +void writeRegister(byte registerName, byte registerValue) { + // SCP1000 expects the register name in the upper 6 bits + // of the byte: + registerName <<= 2; + // command (read or write) goes in the lower two bits: + registerName |= 0b00000010; //Write command + + // take the chip select low to select the device: + digitalWrite(chipSelectPin, LOW); + + SPI.transfer(registerName); //Send register location + SPI.transfer(registerValue); //Send value to record into register + + // take the chip select high to de-select: + digitalWrite(chipSelectPin, HIGH); +} + + +//Read register from the SCP1000: +unsigned int readRegister(byte registerName, int numBytes) { + byte inByte = 0; // incoming from the SPI read + unsigned int result = 0; // result to return + + // SCP1000 expects the register name in the upper 6 bits + // of the byte: + registerName <<= 2; + // command (read or write) goes in the lower two bits: + registerName &= 0b11111100; //Read command + + // take the chip select low to select the device: + digitalWrite(chipSelectPin, LOW); + // send the device the register you want to read: + int command = SPI.transfer(registerName); + // send a value of 0 to read the first byte returned: + inByte = SPI.transfer(0x00); + + result = inByte; + // if there's more than one byte returned, + // shift the first byte then get the second byte: + if (numBytes > 1){ + result = inByte << 8; + inByte = SPI.transfer(0x00); + result = result |inByte; + } + // take the chip select high to de-select: + digitalWrite(chipSelectPin, HIGH); + // return the result: + return(result); +} diff --git a/arduino-0022-linux-x64/libraries/Ethernet/examples/ChatServer/ChatServer.pde b/arduino-0022-linux-x64/libraries/Ethernet/examples/ChatServer/ChatServer.pde new file mode 100644 index 0000000..50ae014 --- /dev/null +++ b/arduino-0022-linux-x64/libraries/Ethernet/examples/ChatServer/ChatServer.pde @@ -0,0 +1,63 @@ +/* + Chat Server + + A simple server that distributes any incoming messages to all + connected clients. To use telnet to your device's IP address and type. + You can see the client's input in the serial monitor as well. + Using an Arduino Wiznet Ethernet shield. + + Circuit: + * Ethernet shield attached to pins 10, 11, 12, 13 + * Analog inputs attached to pins A0 through A5 (optional) + + created 18 Dec 2009 + by David A. Mellis + modified 10 August 2010 + by Tom Igoe + + */ + +#include +#include + +// Enter a MAC address and IP address for your controller below. +// The IP address will be dependent on your local network. +// gateway and subnet are optional: +byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; +byte ip[] = { 192,168,1, 177 }; +byte gateway[] = { 192,168,1, 1 }; +byte subnet[] = { 255, 255, 0, 0 }; + +// telnet defaults to port 23 +Server server(23); +boolean gotAMessage = false; // whether or not you got a message from the client yet + +void setup() { + // initialize the ethernet device + Ethernet.begin(mac, ip, gateway, subnet); + // start listening for clients + server.begin(); + // open the serial port + Serial.begin(9600); +} + +void loop() { + // wait for a new client: + Client client = server.available(); + + // when the client sends the first byte, say hello: + if (client) { + if (!gotAMessage) { + Serial.println("We have a new client"); + client.println("Hello, client!"); + gotAMessage = true; + } + + // read the bytes incoming from the client: + char thisChar = client.read(); + // echo the bytes back to the client: + server.write(thisChar); + // echo the bytes to the server as well: + Serial.print(thisChar); + } +} \ No newline at end of file diff --git a/arduino-0022-linux-x64/libraries/Ethernet/examples/PachubeClient/PachubeClient.pde b/arduino-0022-linux-x64/libraries/Ethernet/examples/PachubeClient/PachubeClient.pde new file mode 100644 index 0000000..fe94541 --- /dev/null +++ b/arduino-0022-linux-x64/libraries/Ethernet/examples/PachubeClient/PachubeClient.pde @@ -0,0 +1,139 @@ +/* + Pachube sensor client + + This sketch connects an analog sensor to Pachube (http://www.pachube.com) + using a Wiznet Ethernet shield. You can use the Arduino Ethernet shield, or + the Adafruit Ethernet shield, either one will work, as long as it's got + a Wiznet Ethernet module on board. + + Circuit: + * Analog sensor attached to analog in 0 + * Ethernet shield attached to pins 10, 11, 12, 13 + + created 15 March 2010 + updated 4 Sep 2010 + by Tom Igoe + + http://www.tigoe.net/pcomp/code/category/arduinowiring/873 + This code is in the public domain. + + */ + +#include +#include + +// assign a MAC address for the ethernet controller. +// fill in your address here: +byte mac[] = { + 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED}; +// assign an IP address for the controller: +byte ip[] = { + 192,169,1,20 }; +byte gateway[] = { + 192,168,1,1}; +byte subnet[] = { + 255, 255, 255, 0 }; + +// The address of the server you want to connect to (pachube.com): +byte server[] = { + 209,40,205,190 }; + +// initialize the library instance: +Client client(server, 80); + +long lastConnectionTime = 0; // last time you connected to the server, in milliseconds +boolean lastConnected = false; // state of the connection last time through the main loop +const int postingInterval = 10000; //delay between updates to Pachube.com + +void setup() { + // start the ethernet connection and serial port: + Ethernet.begin(mac, ip); + Serial.begin(9600); + // give the ethernet module time to boot up: + delay(1000); +} + +void loop() { + // read the analog sensor: + int sensorReading = analogRead(A0); + + // if there's incoming data from the net connection. + // send it out the serial port. This is for debugging + // purposes only: + if (client.available()) { + char c = client.read(); + Serial.print(c); + } + + // if there's no net connection, but there was one last time + // through the loop, then stop the client: + if (!client.connected() && lastConnected) { + Serial.println(); + Serial.println("disconnecting."); + client.stop(); + } + + // if you're not connected, and ten seconds have passed since + // your last connection, then connect again and send data: + if(!client.connected() && (millis() - lastConnectionTime > postingInterval)) { + sendData(sensorReading); + } + // store the state of the connection for next time through + // the loop: + lastConnected = client.connected(); +} + +// this method makes a HTTP connection to the server: +void sendData(int thisData) { + // if there's a successful connection: + if (client.connect()) { + Serial.println("connecting..."); + // send the HTTP PUT request. + // fill in your feed address here: + client.print("PUT /api/YOUR_FEED_HERE.csv HTTP/1.1\n"); + client.print("Host: www.pachube.com\n"); + // fill in your Pachube API key here: + client.print("X-PachubeApiKey: YOUR_KEY_HERE\n"); + client.print("Content-Length: "); + + // calculate the length of the sensor reading in bytes: + int thisLength = getLength(thisData); + client.println(thisLength, DEC); + + // last pieces of the HTTP PUT request: + client.print("Content-Type: text/csv\n"); + client.println("Connection: close\n"); + + // here's the actual content of the PUT request: + client.println(thisData, DEC); + + // note the time that the connection was made: + lastConnectionTime = millis(); + } + else { + // if you couldn't make a connection: + Serial.println("connection failed"); + } +} + + +// This method calculates the number of digits in the +// sensor reading. Since each digit of the ASCII decimal +// representation is a byte, the number of digits equals +// the number of bytes: + +int getLength(int someValue) { + // there's at least one byte: + int digits = 1; + // continually divide the value by ten, + // adding one to the digit count for each + // time you divide, until you're at 0: + int dividend = someValue /10; + while (dividend > 0) { + dividend = dividend /10; + digits++; + } + // return the number of digits: + return digits; +} + diff --git a/arduino-0022-linux-x64/libraries/Ethernet/examples/PachubeClientString/PachubeClientString.pde b/arduino-0022-linux-x64/libraries/Ethernet/examples/PachubeClientString/PachubeClientString.pde new file mode 100644 index 0000000..225823a --- /dev/null +++ b/arduino-0022-linux-x64/libraries/Ethernet/examples/PachubeClientString/PachubeClientString.pde @@ -0,0 +1,124 @@ +/* + Pachube sensor client with Strings + + This sketch connects an analog sensor to Pachube (http://www.pachube.com) + using a Wiznet Ethernet shield. You can use the Arduino Ethernet shield, or + the Adafruit Ethernet shield, either one will work, as long as it's got + a Wiznet Ethernet module on board. + + This example uses the String library, which is part of the Arduino core from + version 0019. + + Circuit: + * Analog sensor attached to analog in 0 + * Ethernet shield attached to pins 10, 11, 12, 13 + + created 15 March 2010 + updated 4 Sep 2010 + by Tom Igoe + + This code is in the public domain. + + */ + +#include +#include + +// assign a MAC address for the ethernet controller. +// fill in your address here: +byte mac[] = { + 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED}; +// assign an IP address for the controller: +byte ip[] = { + 192,169,1,20 }; +byte gateway[] = { + 192,168,1,1}; +byte subnet[] = { + 255, 255, 255, 0 }; + +// The address of the server you want to connect to (pachube.com): +byte server[] = { + 209,40,205,190 }; + +// initialize the library instance: +Client client(server, 80); + +long lastConnectionTime = 0; // last time you connected to the server, in milliseconds +boolean lastConnected = false; // state of the connection last time through the main loop +const int postingInterval = 10000; //delay between updates to Pachube.com + +void setup() { + // start the ethernet connection and serial port: + Ethernet.begin(mac, ip); + Serial.begin(9600); + // give the ethernet module time to boot up: + delay(1000); +} + +void loop() { + // read the analog sensor: + int sensorReading = analogRead(A0); + // convert the data to a String to send it: + String dataString = String(sensorReading); + + // you can append multiple readings to this String if your + // pachube feed is set up to handle multiple values: + int otherSensorReading = analogRead(A1); + dataString += ","; + dataString += String(otherSensorReading); + + // if there's incoming data from the net connection. + // send it out the serial port. This is for debugging + // purposes only: + if (client.available()) { + char c = client.read(); + Serial.print(c); + } + + // if there's no net connection, but there was one last time + // through the loop, then stop the client: + if (!client.connected() && lastConnected) { + Serial.println(); + Serial.println("disconnecting."); + client.stop(); + } + + // if you're not connected, and ten seconds have passed since + // your last connection, then connect again and send data: + if(!client.connected() && (millis() - lastConnectionTime > postingInterval)) { + sendData(dataString); + } + // store the state of the connection for next time through + // the loop: + lastConnected = client.connected(); +} + +// this method makes a HTTP connection to the server: +void sendData(String thisData) { + // if there's a successful connection: + if (client.connect()) { + Serial.println("connecting..."); + // send the HTTP PUT request. + // fill in your feed address here: + client.print("PUT /api/YOUR_FEED_HERE.csv HTTP/1.1\n"); + client.print("Host: www.pachube.com\n"); + // fill in your Pachube API key here: + client.print("X-PachubeApiKey: YOUR_KEY_HERE\n"); + client.print("Content-Length: "); + client.println(thisData.length(), DEC); + + // last pieces of the HTTP PUT request: + client.print("Content-Type: text/csv\n"); + client.println("Connection: close\n"); + + // here's the actual content of the PUT request: + client.println(thisData); + + // note the time that the connection was made: + lastConnectionTime = millis(); + } + else { + // if you couldn't make a connection: + Serial.println("connection failed"); + } +} diff --git a/arduino-0022-linux-x64/libraries/Ethernet/examples/TelnetClient/TelnetClient.pde b/arduino-0022-linux-x64/libraries/Ethernet/examples/TelnetClient/TelnetClient.pde new file mode 100644 index 0000000..aca1fa9 --- /dev/null +++ b/arduino-0022-linux-x64/libraries/Ethernet/examples/TelnetClient/TelnetClient.pde @@ -0,0 +1,89 @@ +/* + Telnet client + + This sketch connects to a a telnet server (http://www.google.com) + using an Arduino Wiznet Ethernet shield. You'll need a telnet server + to test this with. + Processing's ChatServer example (part of the network library) works well, + running on port 10002. It can be found as part of the examples + in the Processing application, available at + http://processing.org/ + + Circuit: + * Ethernet shield attached to pins 10, 11, 12, 13 + + created 14 Sep 2010 + by Tom Igoe + + */ + +#include +#include + +// Enter a MAC address and IP address for your controller below. +// The IP address will be dependent on your local network: +byte mac[] = { + 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; +byte ip[] = { + 192,168,1,177 }; + +// Enter the IP address of the server you're connecting to: +byte server[] = { + 1,1,1,1 }; + +// Initialize the Ethernet client library +// with the IP address and port of the server +// that you want to connect to (port 23 is default for telnet; +// if you're using Processing's ChatServer, use port 10002): +Client client(server, 10002); + +void setup() { + // start the Ethernet connection: + Ethernet.begin(mac, ip); + // start the serial library: + Serial.begin(9600); + // give the Ethernet shield a second to initialize: + delay(1000); + Serial.println("connecting..."); + + // if you get a connection, report back via serial: + if (client.connect()) { + Serial.println("connected"); + } + else { + // if you didn't get a connection to the server: + Serial.println("connection failed"); + } +} + +void loop() +{ + // if there are incoming bytes available + // from the server, read them and print them: + if (client.available()) { + char c = client.read(); + Serial.print(c); + } + + // as long as there are bytes in the serial queue, + // read them and send them out the socket if it's open: + while (Serial.available() > 0) { + char inChar = Serial.read(); + if (client.connected()) { + client.print(inChar); + } + } + + // if the server's disconnected, stop the client: + if (!client.connected()) { + Serial.println(); + Serial.println("disconnecting."); + client.stop(); + // do nothing: + while(true); + } +} + + + + diff --git a/arduino-0022-linux-x64/libraries/Ethernet/examples/UDPSendReceiveString/UDPSendReceiveString.pde b/arduino-0022-linux-x64/libraries/Ethernet/examples/UDPSendReceiveString/UDPSendReceiveString.pde new file mode 100644 index 0000000..cfe1b58 --- /dev/null +++ b/arduino-0022-linux-x64/libraries/Ethernet/examples/UDPSendReceiveString/UDPSendReceiveString.pde @@ -0,0 +1,107 @@ +/* + UDPSendReceive.pde: + This sketch receives UDP message strings, prints them to the serial port + and sends an "acknowledge" string back to the sender + + A Processing sketch is included at the end of file that can be used to send + and received messages for testing with a computer. + + created 21 Aug 2010 + by Michael Margolis + + This code is in the public domain. + */ + + +#include // needed for Arduino versions later than 0018 +#include +#include // UDP library from: bjoern@cs.stanford.edu 12/30/2008 + + +// Enter a MAC address and IP address for your controller below. +// The IP address will be dependent on your local network: +byte mac[] = { + 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; +byte ip[] = { + 192,168,1,177 }; + +unsigned int localPort = 8888; // local port to listen on + +// the next two variables are set when a packet is received +byte remoteIp[4]; // holds received packet's originating IP +unsigned int remotePort; // holds received packet's originating port + +// buffers for receiving and sending data +char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; //buffer to hold incoming packet, +char ReplyBuffer[] = "acknowledged"; // a string to send back + + +void setup() { + // start the Ethernet and UDP: + Ethernet.begin(mac,ip); + Udp.begin(localPort); + + Serial.begin(9600); +} + +void loop() { + // if there's data available, read a packet + int packetSize = Udp.available(); // note that this includes the UDP header + if(packetSize) + { + packetSize = packetSize - 8; // subtract the 8 byte header + Serial.print("Received packet of size "); + Serial.println(packetSize); + + // read the packet into packetBufffer and get the senders IP addr and port number + Udp.readPacket(packetBuffer,UDP_TX_PACKET_MAX_SIZE, remoteIp, remotePort); + Serial.println("Contents:"); + Serial.println(packetBuffer); + + Udp.sendPacket( ReplyBuffer, remoteIp, remotePort); + } + delay(10); +} + + +/* + Processing sketch to run with this example + ===================================================== + + // Processing UDP example to send and receive string data from Arduino + // press any key to send the "Hello Arduino" message + + + import hypermedia.net.*; + + UDP udp; // define the UDP object + + + void setup() { + udp = new UDP( this, 6000 ); // create a new datagram connection on port 6000 + //udp.log( true ); // <-- printout the connection activity + udp.listen( true ); // and wait for incoming message + } + + void draw() + { + } + + void keyPressed() { + String ip = "192.168.1.177"; // the remote IP address + int port = 8888; // the destination port + + udp.send("Hello World", ip, port ); // the message to send + + } + + void receive( byte[] data ) { // <-- default handler + //void receive( byte[] data, String ip, int port ) { // <-- extended handler + + for(int i=0; i < data.length; i++) + print(char(data[i])); + println(); + } + */ + + diff --git a/arduino-0022-linux-x64/libraries/Ethernet/examples/UdpNtpClient/UdpNtpClient.pde b/arduino-0022-linux-x64/libraries/Ethernet/examples/UdpNtpClient/UdpNtpClient.pde new file mode 100644 index 0000000..0b3832b --- /dev/null +++ b/arduino-0022-linux-x64/libraries/Ethernet/examples/UdpNtpClient/UdpNtpClient.pde @@ -0,0 +1,121 @@ +/* + + Udp NTP Client + + Get the time from a Network Time Protocol (NTP) time server + Demonstrates use of UDP sendPacket and ReceivePacket + For more on NTP time servers and the messages needed to communicate with them, + see http://en.wikipedia.org/wiki/Network_Time_Protocol + + created 4 Sep 2010 + by Michael Margolis + modified 17 Sep 2010 + by Tom Igoe + + This code is in the public domain. + + */ + +#include +#include +#include + +// Enter a MAC address and IP address for your controller below. +// The IP address will be dependent on your local network: +byte mac[] = { + 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; +byte ip[] = { + 192,168,1,177 }; + + +unsigned int localPort = 8888; // local port to listen for UDP packets + +byte timeServer[] = { + 192, 43, 244, 18}; // time.nist.gov NTP server + +const int NTP_PACKET_SIZE= 48; // NTP time stamp is in the first 48 bytes of the message + +byte packetBuffer[ NTP_PACKET_SIZE]; //buffer to hold incoming and outgoing packets + +void setup() +{ + // start Ethernet and UDP + Ethernet.begin(mac,ip); + Udp.begin(localPort); + + Serial.begin(9600); +} + +void loop() +{ + sendNTPpacket(timeServer); // send an NTP packet to a time server + + // wait to see if a reply is available + delay(1000); + if ( Udp.available() ) { + Udp.readPacket(packetBuffer,NTP_PACKET_SIZE); // read the packet into the buffer + + //the timestamp starts at byte 40 of the received packet and is four bytes, + // or two words, long. First, esxtract the two words: + + unsigned long highWord = word(packetBuffer[40], packetBuffer[41]); + unsigned long lowWord = word(packetBuffer[42], packetBuffer[43]); + // combine the four bytes (two words) into a long integer + // this is NTP time (seconds since Jan 1 1900): + unsigned long secsSince1900 = highWord << 16 | lowWord; + Serial.print("Seconds since Jan 1 1900 = " ); + Serial.println(secsSince1900); + + // now convert NTP time into everyday time: + Serial.print("Unix time = "); + // Unix time starts on Jan 1 1970. In seconds, that's 2208988800: + const unsigned long seventyYears = 2208988800UL; + // subtract seventy years: + unsigned long epoch = secsSince1900 - seventyYears; + // print Unix time: + Serial.println(epoch); + + + // print the hour, minute and second: + Serial.print("The UTC time is "); // UTC is the time at Greenwich Meridian (GMT) + Serial.print((epoch % 86400L) / 3600); // print the hour (86400 equals secs per day) + Serial.print(':'); + Serial.print((epoch % 3600) / 60); // print the minute (3600 equals secs per minute) + Serial.print(':'); + Serial.println(epoch %60); // print the second + } + // wait ten seconds before asking for the time again + delay(10000); +} + +// send an NTP request to the time server at the given address +unsigned long sendNTPpacket(byte *address) +{ + // set all bytes in the buffer to 0 + memset(packetBuffer, 0, NTP_PACKET_SIZE); + // Initialize values needed to form NTP request + // (see URL above for details on the packets) + packetBuffer[0] = 0b11100011; // LI, Version, Mode + packetBuffer[1] = 0; // Stratum, or type of clock + packetBuffer[2] = 6; // Polling Interval + packetBuffer[3] = 0xEC; // Peer Clock Precision + // 8 bytes of zero for Root Delay & Root Dispersion + packetBuffer[12] = 49; + packetBuffer[13] = 0x4E; + packetBuffer[14] = 49; + packetBuffer[15] = 52; + + // all NTP fields have been given values, now + // you can send a packet requesting a timestamp: + Udp.sendPacket( packetBuffer,NTP_PACKET_SIZE, address, 123); //NTP requests are to port 123 +} + + + + + + + + + + diff --git a/arduino-0022-linux-x64/libraries/Ethernet/examples/WebClient/WebClient.pde b/arduino-0022-linux-x64/libraries/Ethernet/examples/WebClient/WebClient.pde new file mode 100644 index 0000000..a2d3503 --- /dev/null +++ b/arduino-0022-linux-x64/libraries/Ethernet/examples/WebClient/WebClient.pde @@ -0,0 +1,71 @@ +/* + Web client + + This sketch connects to a website (http://www.google.com) + using an Arduino Wiznet Ethernet shield. + + Circuit: + * Ethernet shield attached to pins 10, 11, 12, 13 + + created 18 Dec 2009 + by David A. Mellis + + */ + +#include +#include + +// Enter a MAC address and IP address for your controller below. +// The IP address will be dependent on your local network: +byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; +byte ip[] = { 192,168,1,177 }; +byte server[] = { 173,194,33,104 }; // Google + +// Initialize the Ethernet client library +// with the IP address and port of the server +// that you want to connect to (port 80 is default for HTTP): +Client client(server, 80); + +void setup() { + // start the Ethernet connection: + Ethernet.begin(mac, ip); + // start the serial library: + Serial.begin(9600); + // give the Ethernet shield a second to initialize: + delay(1000); + Serial.println("connecting..."); + + // if you get a connection, report back via serial: + if (client.connect()) { + Serial.println("connected"); + // Make a HTTP request: + client.println("GET /search?q=arduino HTTP/1.0"); + client.println(); + } + else { + // kf you didn't get a connection to the server: + Serial.println("connection failed"); + } +} + +void loop() +{ + // if there are incoming bytes available + // from the server, read them and print them: + if (client.available()) { + char c = client.read(); + Serial.print(c); + } + + // if the server's disconnected, stop the client: + if (!client.connected()) { + Serial.println(); + Serial.println("disconnecting."); + client.stop(); + + // do nothing forevermore: + for(;;) + ; + } +} + diff --git a/arduino-0022-linux-x64/libraries/Ethernet/examples/WebServer/WebServer.pde b/arduino-0022-linux-x64/libraries/Ethernet/examples/WebServer/WebServer.pde new file mode 100644 index 0000000..77bcb20 --- /dev/null +++ b/arduino-0022-linux-x64/libraries/Ethernet/examples/WebServer/WebServer.pde @@ -0,0 +1,82 @@ +/* + Web Server + + A simple web server that shows the value of the analog input pins. + using an Arduino Wiznet Ethernet shield. + + Circuit: + * Ethernet shield attached to pins 10, 11, 12, 13 + * Analog inputs attached to pins A0 through A5 (optional) + + created 18 Dec 2009 + by David A. Mellis + modified 4 Sep 2010 + by Tom Igoe + + */ + +#include +#include + +// Enter a MAC address and IP address for your controller below. +// The IP address will be dependent on your local network: +byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; +byte ip[] = { 192,168,1, 177 }; + +// Initialize the Ethernet server library +// with the IP address and port you want to use +// (port 80 is default for HTTP): +Server server(80); + +void setup() +{ + // start the Ethernet connection and the server: + Ethernet.begin(mac, ip); + server.begin(); +} + +void loop() +{ + // listen for incoming clients + Client client = server.available(); + if (client) { + // an http request ends with a blank line + boolean currentLineIsBlank = true; + while (client.connected()) { + if (client.available()) { + char c = client.read(); + // if you've gotten to the end of the line (received a newline + // character) and the line is blank, the http request has ended, + // so you can send a reply + if (c == '\n' && currentLineIsBlank) { + // send a standard http response header + client.println("HTTP/1.1 200 OK"); + client.println("Content-Type: text/html"); + client.println(); + + // output the value of each analog input pin + for (int analogChannel = 0; analogChannel < 6; analogChannel++) { + client.print("analog input "); + client.print(analogChannel); + client.print(" is "); + client.print(analogRead(analogChannel)); + client.println("
    "); + } + break; + } + if (c == '\n') { + // you're starting a new line + currentLineIsBlank = true; + } + else if (c != '\r') { + // you've gotten a character on the current line + currentLineIsBlank = false; + } + } + } + // give the web browser time to receive the data + delay(1); + // close the connection: + client.stop(); + } +} \ No newline at end of file diff --git a/arduino-0018-linux-x64/libraries/Ethernet/keywords.txt b/arduino-0022-linux-x64/libraries/Ethernet/keywords.txt similarity index 100% rename from arduino-0018-linux-x64/libraries/Ethernet/keywords.txt rename to arduino-0022-linux-x64/libraries/Ethernet/keywords.txt diff --git a/arduino-0022-linux-x64/libraries/Ethernet/utility/socket.cpp b/arduino-0022-linux-x64/libraries/Ethernet/utility/socket.cpp new file mode 100644 index 0000000..628bca8 --- /dev/null +++ b/arduino-0022-linux-x64/libraries/Ethernet/utility/socket.cpp @@ -0,0 +1,327 @@ +#include "w5100.h" +#include "socket.h" + +static uint16_t local_port; + +/** + * @brief This Socket function initialize the channel in perticular mode, and set the port and wait for W5100 done it. + * @return 1 for success else 0. + */ +uint8_t socket(SOCKET s, uint8_t protocol, uint16_t port, uint8_t flag) +{ + uint8_t ret; + if ((protocol == SnMR::TCP) || (protocol == SnMR::UDP) || (protocol == SnMR::IPRAW) || (protocol == SnMR::MACRAW) || (protocol == SnMR::PPPOE)) + { + close(s); + W5100.writeSnMR(s, protocol | flag); + if (port != 0) { + W5100.writeSnPORT(s, port); + } + else { + local_port++; // if don't set the source port, set local_port number. + W5100.writeSnPORT(s, local_port); + } + + W5100.execCmdSn(s, Sock_OPEN); + + return 1; + } + + return 0; +} + + +/** + * @brief This function close the socket and parameter is "s" which represent the socket number + */ +void close(SOCKET s) +{ + W5100.execCmdSn(s, Sock_CLOSE); + W5100.writeSnIR(s, 0xFF); +} + + +/** + * @brief This function established the connection for the channel in passive (server) mode. This function waits for the request from the peer. + * @return 1 for success else 0. + */ +uint8_t listen(SOCKET s) +{ + if (W5100.readSnSR(s) != SnSR::INIT) + return 0; + W5100.execCmdSn(s, Sock_LISTEN); + return 1; +} + + +/** + * @brief This function established the connection for the channel in Active (client) mode. + * This function waits for the untill the connection is established. + * + * @return 1 for success else 0. + */ +uint8_t connect(SOCKET s, uint8_t * addr, uint16_t port) +{ + if + ( + ((addr[0] == 0xFF) && (addr[1] == 0xFF) && (addr[2] == 0xFF) && (addr[3] == 0xFF)) || + ((addr[0] == 0x00) && (addr[1] == 0x00) && (addr[2] == 0x00) && (addr[3] == 0x00)) || + (port == 0x00) + ) + return 0; + + // set destination IP + W5100.writeSnDIPR(s, addr); + W5100.writeSnDPORT(s, port); + W5100.execCmdSn(s, Sock_CONNECT); + + return 1; +} + + + +/** + * @brief This function used for disconnect the socket and parameter is "s" which represent the socket number + * @return 1 for success else 0. + */ +void disconnect(SOCKET s) +{ + W5100.execCmdSn(s, Sock_DISCON); +} + + +/** + * @brief This function used to send the data in TCP mode + * @return 1 for success else 0. + */ +uint16_t send(SOCKET s, const uint8_t * buf, uint16_t len) +{ + uint8_t status=0; + uint16_t ret=0; + uint16_t freesize=0; + + if (len > W5100.SSIZE) + ret = W5100.SSIZE; // check size not to exceed MAX size. + else + ret = len; + + // if freebuf is available, start. + do + { + freesize = W5100.getTXFreeSize(s); + status = W5100.readSnSR(s); + if ((status != SnSR::ESTABLISHED) && (status != SnSR::CLOSE_WAIT)) + { + ret = 0; + break; + } + } + while (freesize < ret); + + // copy data + W5100.send_data_processing(s, (uint8_t *)buf, ret); + W5100.execCmdSn(s, Sock_SEND); + + /* +2008.01 bj */ + while ( (W5100.readSnIR(s) & SnIR::SEND_OK) != SnIR::SEND_OK ) + { + /* m2008.01 [bj] : reduce code */ + if ( W5100.readSnSR(s) == SnSR::CLOSED ) + { + close(s); + return 0; + } + } + /* +2008.01 bj */ + W5100.writeSnIR(s, SnIR::SEND_OK); + return ret; +} + + +/** + * @brief This function is an application I/F function which is used to receive the data in TCP mode. + * It continues to wait for data as much as the application wants to receive. + * + * @return received data size for success else -1. + */ +uint16_t recv(SOCKET s, uint8_t *buf, uint16_t len) +{ + uint16_t ret=0; + + if ( len > 0 ) + { + W5100.recv_data_processing(s, buf, len); + W5100.execCmdSn(s, Sock_RECV); + ret = len; + } + return ret; +} + + +/** + * @brief Returns the first byte in the receive queue (no checking) + * + * @return + */ +uint16_t peek(SOCKET s, uint8_t *buf) +{ + W5100.recv_data_processing(s, buf, 1, 1); + + return 1; +} + + +/** + * @brief This function is an application I/F function which is used to send the data for other then TCP mode. + * Unlike TCP transmission, The peer's destination address and the port is needed. + * + * @return This function return send data size for success else -1. + */ +uint16_t sendto(SOCKET s, const uint8_t *buf, uint16_t len, uint8_t *addr, uint16_t port) +{ + uint16_t ret=0; + + if (len > W5100.SSIZE) ret = W5100.SSIZE; // check size not to exceed MAX size. + else ret = len; + + if + ( + ((addr[0] == 0x00) && (addr[1] == 0x00) && (addr[2] == 0x00) && (addr[3] == 0x00)) || + ((port == 0x00)) ||(ret == 0) + ) + { + /* +2008.01 [bj] : added return value */ + ret = 0; + } + else + { + W5100.writeSnDIPR(s, addr); + W5100.writeSnDPORT(s, port); + + // copy data + W5100.send_data_processing(s, (uint8_t *)buf, ret); + W5100.execCmdSn(s, Sock_SEND); + + /* +2008.01 bj */ + while ( (W5100.readSnIR(s) & SnIR::SEND_OK) != SnIR::SEND_OK ) + { + if (W5100.readSnIR(s) & SnIR::TIMEOUT) + { + /* +2008.01 [bj]: clear interrupt */ + W5100.writeSnIR(s, (SnIR::SEND_OK | SnIR::TIMEOUT)); /* clear SEND_OK & TIMEOUT */ + return 0; + } + } + + /* +2008.01 bj */ + W5100.writeSnIR(s, SnIR::SEND_OK); + } + return ret; +} + + +/** + * @brief This function is an application I/F function which is used to receive the data in other then + * TCP mode. This function is used to receive UDP, IP_RAW and MAC_RAW mode, and handle the header as well. + * + * @return This function return received data size for success else -1. + */ +uint16_t recvfrom(SOCKET s, uint8_t *buf, uint16_t len, uint8_t *addr, uint16_t *port) +{ + uint8_t head[8]; + uint16_t data_len=0; + uint16_t ptr=0; + + if ( len > 0 ) + { + ptr = W5100.readSnRX_RD(s); + switch (W5100.readSnMR(s) & 0x07) + { + case SnMR::UDP : + W5100.read_data(s, (uint8_t *)ptr, head, 0x08); + ptr += 8; + // read peer's IP address, port number. + addr[0] = head[0]; + addr[1] = head[1]; + addr[2] = head[2]; + addr[3] = head[3]; + *port = head[4]; + *port = (*port << 8) + head[5]; + data_len = head[6]; + data_len = (data_len << 8) + head[7]; + + W5100.read_data(s, (uint8_t *)ptr, buf, data_len); // data copy. + ptr += data_len; + + W5100.writeSnRX_RD(s, ptr); + break; + + case SnMR::IPRAW : + W5100.read_data(s, (uint8_t *)ptr, head, 0x06); + ptr += 6; + + addr[0] = head[0]; + addr[1] = head[1]; + addr[2] = head[2]; + addr[3] = head[3]; + data_len = head[4]; + data_len = (data_len << 8) + head[5]; + + W5100.read_data(s, (uint8_t *)ptr, buf, data_len); // data copy. + ptr += data_len; + + W5100.writeSnRX_RD(s, ptr); + break; + + case SnMR::MACRAW: + W5100.read_data(s,(uint8_t*)ptr,head,2); + ptr+=2; + data_len = head[0]; + data_len = (data_len<<8) + head[1] - 2; + + W5100.read_data(s,(uint8_t*) ptr,buf,data_len); + ptr += data_len; + W5100.writeSnRX_RD(s, ptr); + break; + + default : + break; + } + W5100.execCmdSn(s, Sock_RECV); + } + return data_len; +} + + +uint16_t igmpsend(SOCKET s, const uint8_t * buf, uint16_t len) +{ + uint8_t status=0; + uint16_t ret=0; + + if (len > W5100.SSIZE) + ret = W5100.SSIZE; // check size not to exceed MAX size. + else + ret = len; + + if (ret == 0) + return 0; + + W5100.send_data_processing(s, (uint8_t *)buf, ret); + W5100.execCmdSn(s, Sock_SEND); + + while ( (W5100.readSnIR(s) & SnIR::SEND_OK) != SnIR::SEND_OK ) + { + status = W5100.readSnSR(s); + if (W5100.readSnIR(s) & SnIR::TIMEOUT) + { + /* in case of igmp, if send fails, then socket closed */ + /* if you want change, remove this code. */ + close(s); + return 0; + } + } + + W5100.writeSnIR(s, SnIR::SEND_OK); + return ret; +} + diff --git a/arduino-0022-linux-x64/libraries/Ethernet/utility/socket.h b/arduino-0022-linux-x64/libraries/Ethernet/utility/socket.h new file mode 100644 index 0000000..48e2d87 --- /dev/null +++ b/arduino-0022-linux-x64/libraries/Ethernet/utility/socket.h @@ -0,0 +1,20 @@ +#ifndef _SOCKET_H_ +#define _SOCKET_H_ + +#include "w5100.h" + +extern uint8_t socket(SOCKET s, uint8_t protocol, uint16_t port, uint8_t flag); // Opens a socket(TCP or UDP or IP_RAW mode) +extern void close(SOCKET s); // Close socket +extern uint8_t connect(SOCKET s, uint8_t * addr, uint16_t port); // Establish TCP connection (Active connection) +extern void disconnect(SOCKET s); // disconnect the connection +extern uint8_t listen(SOCKET s); // Establish TCP connection (Passive connection) +extern uint16_t send(SOCKET s, const uint8_t * buf, uint16_t len); // Send data (TCP) +extern uint16_t recv(SOCKET s, uint8_t * buf, uint16_t len); // Receive data (TCP) +extern uint16_t peek(SOCKET s, uint8_t *buf); +extern uint16_t sendto(SOCKET s, const uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port); // Send data (UDP/IP RAW) +extern uint16_t recvfrom(SOCKET s, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t *port); // Receive data (UDP/IP RAW) + +extern uint16_t igmpsend(SOCKET s, const uint8_t * buf, uint16_t len); + +#endif +/* _SOCKET_H_ */ diff --git a/arduino-0022-linux-x64/libraries/Ethernet/utility/w5100.cpp b/arduino-0022-linux-x64/libraries/Ethernet/utility/w5100.cpp new file mode 100644 index 0000000..aaf3071 --- /dev/null +++ b/arduino-0022-linux-x64/libraries/Ethernet/utility/w5100.cpp @@ -0,0 +1,182 @@ +/* + * Copyright (c) 2010 by Cristian Maglie + * + * 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 +#include +#include + +#include "w5100.h" + +// W5100 controller instance +W5100Class W5100; + +#define TX_RX_MAX_BUF_SIZE 2048 +#define TX_BUF 0x1100 +#define RX_BUF (TX_BUF + TX_RX_MAX_BUF_SIZE) + +#define TXBUF_BASE 0x4000 +#define RXBUF_BASE 0x6000 + +void W5100Class::init(void) +{ + delay(300); + + SPI.begin(); + initSS(); + + writeMR(1< SSIZE) + { + // Wrap around circular buffer + uint16_t size = SSIZE - offset; + write(dstAddr, data, size); + write(SBASE[s], data + size, len - size); + } + else { + write(dstAddr, data, len); + } + + ptr += len; + writeSnTX_WR(s, ptr); +} + + +void W5100Class::recv_data_processing(SOCKET s, uint8_t *data, uint16_t len, uint8_t peek) +{ + uint16_t ptr; + ptr = readSnRX_RD(s); + read_data(s, (uint8_t *)ptr, data, len); + if (!peek) + { + ptr += len; + writeSnRX_RD(s, ptr); + } +} + +void W5100Class::read_data(SOCKET s, volatile uint8_t *src, volatile uint8_t *dst, uint16_t len) +{ + uint16_t size; + uint16_t src_mask; + uint16_t src_ptr; + + src_mask = (uint16_t)src & RMASK; + src_ptr = RBASE[s] + src_mask; + + if( (src_mask + len) > RSIZE ) + { + size = RSIZE - src_mask; + read(src_ptr, (uint8_t *)dst, size); + dst += size; + read(RBASE[s], (uint8_t *) dst, len - size); + } + else + read(src_ptr, (uint8_t *) dst, len); +} + + +uint8_t W5100Class::write(uint16_t _addr, uint8_t _data) +{ + setSS(); + SPI.transfer(0xF0); + SPI.transfer(_addr >> 8); + SPI.transfer(_addr & 0xFF); + SPI.transfer(_data); + resetSS(); + return 1; +} + +uint16_t W5100Class::write(uint16_t _addr, uint8_t *_buf, uint16_t _len) +{ + for (int i=0; i<_len; i++) + { + setSS(); + SPI.transfer(0xF0); + SPI.transfer(_addr >> 8); + SPI.transfer(_addr & 0xFF); + _addr++; + SPI.transfer(_buf[i]); + resetSS(); + } + return _len; +} + +uint8_t W5100Class::read(uint16_t _addr) +{ + setSS(); + SPI.transfer(0x0F); + SPI.transfer(_addr >> 8); + SPI.transfer(_addr & 0xFF); + uint8_t _data = SPI.transfer(0); + resetSS(); + return _data; +} + +uint16_t W5100Class::read(uint16_t _addr, uint8_t *_buf, uint16_t _len) +{ + for (int i=0; i<_len; i++) + { + setSS(); + SPI.transfer(0x0F); + SPI.transfer(_addr >> 8); + SPI.transfer(_addr & 0xFF); + _addr++; + _buf[i] = SPI.transfer(0); + resetSS(); + } + return _len; +} + +void W5100Class::execCmdSn(SOCKET s, SockCMD _cmd) { + // Send command to socket + writeSnCR(s, _cmd); + // Wait for command to complete + while (readSnCR(s)) + ; +} diff --git a/arduino-0022-linux-x64/libraries/Ethernet/utility/w5100.h b/arduino-0022-linux-x64/libraries/Ethernet/utility/w5100.h new file mode 100644 index 0000000..118e5d8 --- /dev/null +++ b/arduino-0022-linux-x64/libraries/Ethernet/utility/w5100.h @@ -0,0 +1,381 @@ +/* + * Copyright (c) 2010 by Cristian Maglie + * + * 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 W5100_H_INCLUDED +#define W5100_H_INCLUDED + +#include +#include + +#define MAX_SOCK_NUM 4 + +typedef uint8_t SOCKET; + +#define IDM_OR 0x8000 +#define IDM_AR0 0x8001 +#define IDM_AR1 0x8002 +#define IDM_DR 0x8003 +/* +class MR { +public: + static const uint8_t RST = 0x80; + static const uint8_t PB = 0x10; + static const uint8_t PPPOE = 0x08; + static const uint8_t LB = 0x04; + static const uint8_t AI = 0x02; + static const uint8_t IND = 0x01; +}; +*/ +/* +class IR { +public: + static const uint8_t CONFLICT = 0x80; + static const uint8_t UNREACH = 0x40; + static const uint8_t PPPoE = 0x20; + static const uint8_t SOCK0 = 0x01; + static const uint8_t SOCK1 = 0x02; + static const uint8_t SOCK2 = 0x04; + static const uint8_t SOCK3 = 0x08; + static inline uint8_t SOCK(SOCKET ch) { return (0x01 << ch); }; +}; +*/ + +class SnMR { +public: + static const uint8_t CLOSE = 0x00; + static const uint8_t TCP = 0x01; + static const uint8_t UDP = 0x02; + static const uint8_t IPRAW = 0x03; + static const uint8_t MACRAW = 0x04; + static const uint8_t PPPOE = 0x05; + static const uint8_t ND = 0x20; + static const uint8_t MULTI = 0x80; +}; + +enum SockCMD { + Sock_OPEN = 0x01, + Sock_LISTEN = 0x02, + Sock_CONNECT = 0x04, + Sock_DISCON = 0x08, + Sock_CLOSE = 0x10, + Sock_SEND = 0x20, + Sock_SEND_MAC = 0x21, + Sock_SEND_KEEP = 0x22, + Sock_RECV = 0x40 +}; + +/*class SnCmd { +public: + static const uint8_t OPEN = 0x01; + static const uint8_t LISTEN = 0x02; + static const uint8_t CONNECT = 0x04; + static const uint8_t DISCON = 0x08; + static const uint8_t CLOSE = 0x10; + static const uint8_t SEND = 0x20; + static const uint8_t SEND_MAC = 0x21; + static const uint8_t SEND_KEEP = 0x22; + static const uint8_t RECV = 0x40; +}; +*/ + +class SnIR { +public: + static const uint8_t SEND_OK = 0x10; + static const uint8_t TIMEOUT = 0x08; + static const uint8_t RECV = 0x04; + static const uint8_t DISCON = 0x02; + static const uint8_t CON = 0x01; +}; + +class SnSR { +public: + static const uint8_t CLOSED = 0x00; + static const uint8_t INIT = 0x13; + static const uint8_t LISTEN = 0x14; + static const uint8_t SYNSENT = 0x15; + static const uint8_t SYNRECV = 0x16; + static const uint8_t ESTABLISHED = 0x17; + static const uint8_t FIN_WAIT = 0x18; + static const uint8_t CLOSING = 0x1A; + static const uint8_t TIME_WAIT = 0x1B; + static const uint8_t CLOSE_WAIT = 0x1C; + static const uint8_t LAST_ACK = 0x1D; + static const uint8_t UDP = 0x22; + static const uint8_t IPRAW = 0x32; + static const uint8_t MACRAW = 0x42; + static const uint8_t PPPOE = 0x5F; +}; + +class IPPROTO { +public: + static const uint8_t IP = 0; + static const uint8_t ICMP = 1; + static const uint8_t IGMP = 2; + static const uint8_t GGP = 3; + static const uint8_t TCP = 6; + static const uint8_t PUP = 12; + static const uint8_t UDP = 17; + static const uint8_t IDP = 22; + static const uint8_t ND = 77; + static const uint8_t RAW = 255; +}; + +class W5100Class { + +public: + void init(); + + /** + * @brief This function is being used for copy the data form Receive buffer of the chip to application buffer. + * + * It calculate the actual physical address where one has to read + * the data from Receive buffer. Here also take care of the condition while it exceed + * the Rx memory uper-bound of socket. + */ + void read_data(SOCKET s, volatile uint8_t * src, volatile uint8_t * dst, uint16_t len); + + /** + * @brief This function is being called by send() and sendto() function also. + * + * This function read the Tx write pointer register and after copy the data in buffer update the Tx write pointer + * register. User should read upper byte first and lower byte later to get proper value. + */ + void send_data_processing(SOCKET s, uint8_t *data, uint16_t len); + + /** + * @brief This function is being called by recv() also. + * + * This function read the Rx read pointer register + * and after copy the data from receive buffer update the Rx write pointer register. + * User should read upper byte first and lower byte later to get proper value. + */ + void recv_data_processing(SOCKET s, uint8_t *data, uint16_t len, uint8_t peek = 0); + + inline void setGatewayIp(uint8_t *_addr); + inline void getGatewayIp(uint8_t *_addr); + + inline void setSubnetMask(uint8_t *_addr); + inline void getSubnetMask(uint8_t *_addr); + + inline void setMACAddress(uint8_t * addr); + inline void getMACAddress(uint8_t * addr); + + inline void setIPAddress(uint8_t * addr); + inline void getIPAddress(uint8_t * addr); + + inline void setRetransmissionTime(uint16_t timeout); + inline void setRetransmissionCount(uint8_t _retry); + + void execCmdSn(SOCKET s, SockCMD _cmd); + + uint16_t getTXFreeSize(SOCKET s); + uint16_t getRXReceivedSize(SOCKET s); + + + // W5100 Registers + // --------------- +private: + static uint8_t write(uint16_t _addr, uint8_t _data); + static uint16_t write(uint16_t addr, uint8_t *buf, uint16_t len); + static uint8_t read(uint16_t addr); + static uint16_t read(uint16_t addr, uint8_t *buf, uint16_t len); + +#define __GP_REGISTER8(name, address) \ + static inline void write##name(uint8_t _data) { \ + write(address, _data); \ + } \ + static inline uint8_t read##name() { \ + return read(address); \ + } +#define __GP_REGISTER16(name, address) \ + static void write##name(uint16_t _data) { \ + write(address, _data >> 8); \ + write(address+1, _data & 0xFF); \ + } \ + static uint16_t read##name() { \ + uint16_t res = read(address); \ + res = (res << 8) + read(address + 1); \ + return res; \ + } +#define __GP_REGISTER_N(name, address, size) \ + static uint16_t write##name(uint8_t *_buff) { \ + return write(address, _buff, size); \ + } \ + static uint16_t read##name(uint8_t *_buff) { \ + return read(address, _buff, size); \ + } + +public: + __GP_REGISTER8 (MR, 0x0000); // Mode + __GP_REGISTER_N(GAR, 0x0001, 4); // Gateway IP address + __GP_REGISTER_N(SUBR, 0x0005, 4); // Subnet mask address + __GP_REGISTER_N(SHAR, 0x0009, 6); // Source MAC address + __GP_REGISTER_N(SIPR, 0x000F, 4); // Source IP address + __GP_REGISTER8 (IR, 0x0015); // Interrupt + __GP_REGISTER8 (IMR, 0x0016); // Interrupt Mask + __GP_REGISTER16(RTR, 0x0017); // Timeout address + __GP_REGISTER8 (RCR, 0x0019); // Retry count + __GP_REGISTER8 (RMSR, 0x001A); // Receive memory size + __GP_REGISTER8 (TMSR, 0x001B); // Transmit memory size + __GP_REGISTER8 (PATR, 0x001C); // Authentication type address in PPPoE mode + __GP_REGISTER8 (PTIMER, 0x0028); // PPP LCP Request Timer + __GP_REGISTER8 (PMAGIC, 0x0029); // PPP LCP Magic Number + __GP_REGISTER_N(UIPR, 0x002A, 4); // Unreachable IP address in UDP mode + __GP_REGISTER16(UPORT, 0x002E); // Unreachable Port address in UDP mode + +#undef __GP_REGISTER8 +#undef __GP_REGISTER16 +#undef __GP_REGISTER_N + + // W5100 Socket registers + // ---------------------- +private: + static inline uint8_t readSn(SOCKET _s, uint16_t _addr); + static inline uint8_t writeSn(SOCKET _s, uint16_t _addr, uint8_t _data); + static inline uint16_t readSn(SOCKET _s, uint16_t _addr, uint8_t *_buf, uint16_t len); + static inline uint16_t writeSn(SOCKET _s, uint16_t _addr, uint8_t *_buf, uint16_t len); + + static const uint16_t CH_BASE = 0x0400; + static const uint16_t CH_SIZE = 0x0100; + +#define __SOCKET_REGISTER8(name, address) \ + static inline void write##name(SOCKET _s, uint8_t _data) { \ + writeSn(_s, address, _data); \ + } \ + static inline uint8_t read##name(SOCKET _s) { \ + return readSn(_s, address); \ + } +#define __SOCKET_REGISTER16(name, address) \ + static void write##name(SOCKET _s, uint16_t _data) { \ + writeSn(_s, address, _data >> 8); \ + writeSn(_s, address+1, _data & 0xFF); \ + } \ + static uint16_t read##name(SOCKET _s) { \ + uint16_t res = readSn(_s, address); \ + res = (res << 8) + readSn(_s, address + 1); \ + return res; \ + } +#define __SOCKET_REGISTER_N(name, address, size) \ + static uint16_t write##name(SOCKET _s, uint8_t *_buff) { \ + return writeSn(_s, address, _buff, size); \ + } \ + static uint16_t read##name(SOCKET _s, uint8_t *_buff) { \ + return readSn(_s, address, _buff, size); \ + } + +public: + __SOCKET_REGISTER8(SnMR, 0x0000) // Mode + __SOCKET_REGISTER8(SnCR, 0x0001) // Command + __SOCKET_REGISTER8(SnIR, 0x0002) // Interrupt + __SOCKET_REGISTER8(SnSR, 0x0003) // Status + __SOCKET_REGISTER16(SnPORT, 0x0004) // Source Port + __SOCKET_REGISTER_N(SnDHAR, 0x0006, 6) // Destination Hardw Addr + __SOCKET_REGISTER_N(SnDIPR, 0x000C, 4) // Destination IP Addr + __SOCKET_REGISTER16(SnDPORT, 0x0010) // Destination Port + __SOCKET_REGISTER16(SnMSSR, 0x0012) // Max Segment Size + __SOCKET_REGISTER8(SnPROTO, 0x0014) // Protocol in IP RAW Mode + __SOCKET_REGISTER8(SnTOS, 0x0015) // IP TOS + __SOCKET_REGISTER8(SnTTL, 0x0016) // IP TTL + __SOCKET_REGISTER16(SnTX_FSR, 0x0020) // TX Free Size + __SOCKET_REGISTER16(SnTX_RD, 0x0022) // TX Read Pointer + __SOCKET_REGISTER16(SnTX_WR, 0x0024) // TX Write Pointer + __SOCKET_REGISTER16(SnRX_RSR, 0x0026) // RX Free Size + __SOCKET_REGISTER16(SnRX_RD, 0x0028) // RX Read Pointer + __SOCKET_REGISTER16(SnRX_WR, 0x002A) // RX Write Pointer (supported?) + +#undef __SOCKET_REGISTER8 +#undef __SOCKET_REGISTER16 +#undef __SOCKET_REGISTER_N + + +private: + static const uint8_t RST = 7; // Reset BIT + + static const int SOCKETS = 4; + static const uint16_t SMASK = 0x07FF; // Tx buffer MASK + static const uint16_t RMASK = 0x07FF; // Rx buffer MASK +public: + static const uint16_t SSIZE = 2048; // Max Tx buffer size +private: + static const uint16_t RSIZE = 2048; // Max Rx buffer size + uint16_t SBASE[SOCKETS]; // Tx buffer base address + uint16_t RBASE[SOCKETS]; // Rx buffer base address + +private: +#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) + inline static void initSS() { DDRB |= _BV(4); }; + inline static void setSS() { PORTB &= ~_BV(4); }; + inline static void resetSS() { PORTB |= _BV(4); }; +#else + inline static void initSS() { DDRB |= _BV(2); }; + inline static void setSS() { PORTB &= ~_BV(2); }; + inline static void resetSS() { PORTB |= _BV(2); }; +#endif + +}; + +extern W5100Class W5100; + +uint8_t W5100Class::readSn(SOCKET _s, uint16_t _addr) { + return read(CH_BASE + _s * CH_SIZE + _addr); +} + +uint8_t W5100Class::writeSn(SOCKET _s, uint16_t _addr, uint8_t _data) { + return write(CH_BASE + _s * CH_SIZE + _addr, _data); +} + +uint16_t W5100Class::readSn(SOCKET _s, uint16_t _addr, uint8_t *_buf, uint16_t _len) { + return read(CH_BASE + _s * CH_SIZE + _addr, _buf, _len); +} + +uint16_t W5100Class::writeSn(SOCKET _s, uint16_t _addr, uint8_t *_buf, uint16_t _len) { + return write(CH_BASE + _s * CH_SIZE + _addr, _buf, _len); +} + +void W5100Class::getGatewayIp(uint8_t *_addr) { + readGAR(_addr); +} + +void W5100Class::setGatewayIp(uint8_t *_addr) { + writeGAR(_addr); +} + +void W5100Class::getSubnetMask(uint8_t *_addr) { + readSUBR(_addr); +} + +void W5100Class::setSubnetMask(uint8_t *_addr) { + writeSUBR(_addr); +} + +void W5100Class::getMACAddress(uint8_t *_addr) { + readSHAR(_addr); +} + +void W5100Class::setMACAddress(uint8_t *_addr) { + writeSHAR(_addr); +} + +void W5100Class::getIPAddress(uint8_t *_addr) { + readSIPR(_addr); +} + +void W5100Class::setIPAddress(uint8_t *_addr) { + writeSIPR(_addr); +} + +void W5100Class::setRetransmissionTime(uint16_t _timeout) { + writeRTR(_timeout); +} + +void W5100Class::setRetransmissionCount(uint8_t _retry) { + writeRCR(_retry); +} + +#endif diff --git a/arduino-0022-linux-x64/libraries/Firmata/Boards.h b/arduino-0022-linux-x64/libraries/Firmata/Boards.h new file mode 100644 index 0000000..2036454 --- /dev/null +++ b/arduino-0022-linux-x64/libraries/Firmata/Boards.h @@ -0,0 +1,335 @@ +/* Boards.h - Hardware Abstraction Layer for Firmata library */ + +#ifndef Firmata_Boards_h +#define Firmata_Boards_h + +#include // for digitalRead, digitalWrite, etc + +// Normally Servo.h must be included before Firmata.h (which then includes +// this file). If Servo.h wasn't included, this allows the code to still +// compile, but without support for any Servos. Hopefully that's what the +// user intended by not including Servo.h +#ifndef MAX_SERVOS +#define MAX_SERVOS 0 +#endif + +/* + Firmata Hardware Abstraction Layer + +Firmata is built on top of the hardware abstraction functions of Arduino, +specifically digitalWrite, digitalRead, analogWrite, analogRead, and +pinMode. While these functions offer simple integer pin numbers, Firmata +needs more information than is provided by Arduino. This file provides +all other hardware specific details. To make Firmata support a new board, +only this file should require editing. + +The key concept is every "pin" implemented by Firmata may be mapped to +any pin as implemented by Arduino. Usually a simple 1-to-1 mapping is +best, but such mapping should not be assumed. This hardware abstraction +layer allows Firmata to implement any number of pins which map onto the +Arduino implemented pins in almost any arbitrary way. + + +General Constants: + +These constants provide basic information Firmata requires. + +TOTAL_PINS: The total number of pins Firmata implemented by Firmata. + Usually this will match the number of pins the Arduino functions + implement, including any pins pins capable of analog or digital. + However, Firmata may implement any number of pins. For example, + on Arduino Mini with 8 analog inputs, 6 of these may be used + for digital functions, and 2 are analog only. On such boards, + Firmata can implement more pins than Arduino's pinMode() + function, in order to accommodate those special pins. The + Firmata protocol supports a maximum of 128 pins, so this + constant must not exceed 128. + +TOTAL_ANALOG_PINS: The total number of analog input pins implemented. + The Firmata protocol allows up to 16 analog inputs, accessed + using offsets 0 to 15. Because Firmata presents the analog + inputs using different offsets than the actual pin numbers + (a legacy of Arduino's analogRead function, and the way the + analog input capable pins are physically labeled on all + Arduino boards), the total number of analog input signals + must be specified. 16 is the maximum. + +VERSION_BLINK_PIN: When Firmata starts up, it will blink the version + number. This constant is the Arduino pin number where a + LED is connected. + + +Pin Mapping Macros: + +These macros provide the mapping between pins as implemented by +Firmata protocol and the actual pin numbers used by the Arduino +functions. Even though such mappings are often simple, pin +numbers received by Firmata protocol should always be used as +input to these macros, and the result of the macro should be +used with with any Arduino function. + +When Firmata is extended to support a new pin mode or feature, +a pair of macros should be added and used for all hardware +access. For simple 1:1 mapping, these macros add no actual +overhead, yet their consistent use allows source code which +uses them consistently to be easily adapted to all other boards +with different requirements. + +IS_PIN_XXXX(pin): The IS_PIN macros resolve to true or non-zero + if a pin as implemented by Firmata corresponds to a pin + that actually implements the named feature. + +PIN_TO_XXXX(pin): The PIN_TO macros translate pin numbers as + implemented by Firmata to the pin numbers needed as inputs + to the Arduino functions. The corresponding IS_PIN macro + should always be tested before using a PIN_TO macro, so + these macros only need to handle valid Firmata pin + numbers for the named feature. + + +Port Access Inline Funtions: + +For efficiency, Firmata protocol provides access to digital +input and output pins grouped by 8 bit ports. When these +groups of 8 correspond to actual 8 bit ports as implemented +by the hardware, these inline functions can provide high +speed direct port access. Otherwise, a default implementation +using 8 calls to digitalWrite or digitalRead is used. + +When porting Firmata to a new board, it is recommended to +use the default functions first and focus only on the constants +and macros above. When those are working, if optimized port +access is desired, these inline functions may be extended. +The recommended approach defines a symbol indicating which +optimization to use, and then conditional complication is +used within these functions. + +readPort(port, bitmask): Read an 8 bit port, returning the value. + port: The port number, Firmata pins port*8 to port*8+7 + bitmask: The actual pins to read, indicated by 1 bits. + +writePort(port, value, bitmask): Write an 8 bit port. + port: The port number, Firmata pins port*8 to port*8+7 + value: The 8 bit value to write + bitmask: The actual pins to write, indicated by 1 bits. +*/ + +/*============================================================================== + * Board Specific Configuration + *============================================================================*/ + +// Arduino Duemilanove, Diecimila, and NG +#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) +#define TOTAL_ANALOG_PINS 8 +#define TOTAL_PINS 24 // 14 digital + 2 unused + 8 analog +#define VERSION_BLINK_PIN 13 +#define IS_PIN_DIGITAL(p) (((p) >= 2 && (p) <= 13) || ((p) >= 16 && (p) <= 21)) +#define IS_PIN_ANALOG(p) ((p) >= 16 && (p) <= 23) +#define IS_PIN_PWM(p) IS_PIN_DIGITAL(p) +#define IS_PIN_SERVO(p) ((p) >= 2 && (p) <= 13 && (p) - 2 < MAX_SERVOS) +#define IS_PIN_I2C(p) (0) +#define PIN_TO_DIGITAL(p) (((p) < 16) ? (p) : (p) - 2) +#define PIN_TO_ANALOG(p) ((p) - 16) +#define PIN_TO_PWM(p) PIN_TO_DIGITAL(p) +#define PIN_TO_SERVO(p) ((p) - 2) +#define ARDUINO_PINOUT_OPTIMIZE 1 + + +// old Arduinos +#elif defined(__AVR_ATmega8__) +#define TOTAL_ANALOG_PINS 6 +#define TOTAL_PINS 22 // 14 digital + 2 unused + 6 analog +#define VERSION_BLINK_PIN 13 +#define IS_PIN_DIGITAL(p) (((p) >= 2 && (p) <= 13) || ((p) >= 16 && (p) <= 21)) +#define IS_PIN_ANALOG(p) ((p) >= 16 && (p) <= 21) +#define IS_PIN_PWM(p) IS_PIN_DIGITAL(p) +#define IS_PIN_SERVO(p) ((p) >= 2 && (p) <= 13 && (p) - 2 < MAX_SERVOS) +#define IS_PIN_I2C(p) (0) +#define PIN_TO_DIGITAL(p) (((p) < 16) ? (p) : (p) - 2) +#define PIN_TO_ANALOG(p) ((p) - 16) +#define PIN_TO_PWM(p) PIN_TO_DIGITAL(p) +#define PIN_TO_SERVO(p) ((p) - 2) +#define ARDUINO_PINOUT_OPTIMIZE 1 + + +// Arduino Mega +#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) +#define TOTAL_ANALOG_PINS 16 +#define TOTAL_PINS 70 // 54 digital + 16 analog +#define VERSION_BLINK_PIN 13 +#define IS_PIN_DIGITAL(p) ((p) >= 2 && (p) < TOTAL_PINS) +#define IS_PIN_ANALOG(p) ((p) >= 54 && (p) < TOTAL_PINS) +#define IS_PIN_PWM(p) IS_PIN_DIGITAL(p) +#define IS_PIN_SERVO(p) ((p) >= 2 && (p) - 2 < MAX_SERVOS) +#define IS_PIN_I2C(p) (0) +#define PIN_TO_DIGITAL(p) (p) +#define PIN_TO_ANALOG(p) ((p) - 54) +#define PIN_TO_PWM(p) PIN_TO_DIGITAL(p) +#define PIN_TO_SERVO(p) ((p) - 2) + + +// Wiring +#elif defined(__AVR_ATmega128__) +#define TOTAL_ANALOG_PINS 8 +#define TOTAL_PINS 51 +#define VERSION_BLINK_PIN 48 +// TODO: hardware abstraction for wiring board + + +// Teensy 1.0 +#elif defined(__AVR_AT90USB162__) +#define TOTAL_ANALOG_PINS 0 +#define TOTAL_PINS 21 // 21 digital + no analog +#define VERSION_BLINK_PIN 6 +#define IS_PIN_DIGITAL(p) ((p) >= 0 && (p) < TOTAL_PINS) +#define IS_PIN_ANALOG(p) (0) +#define IS_PIN_PWM(p) IS_PIN_DIGITAL(p) +#define IS_PIN_SERVO(p) ((p) >= 0 && (p) < MAX_SERVOS) +#define IS_PIN_I2C(p) (0) +#define PIN_TO_DIGITAL(p) (p) +#define PIN_TO_ANALOG(p) (0) +#define PIN_TO_PWM(p) PIN_TO_DIGITAL(p) +#define PIN_TO_SERVO(p) (p) + + +// Teensy 2.0 +#elif defined(__AVR_ATmega32U4__) +#define TOTAL_ANALOG_PINS 12 +#define TOTAL_PINS 25 // 11 digital + 12 analog +#define VERSION_BLINK_PIN 11 +#define IS_PIN_DIGITAL(p) ((p) >= 0 && (p) < TOTAL_PINS) +#define IS_PIN_ANALOG(p) ((p) >= 11 && (p) <= 22) +#define IS_PIN_PWM(p) IS_PIN_DIGITAL(p) +#define IS_PIN_SERVO(p) ((p) >= 0 && (p) < MAX_SERVOS) +#define IS_PIN_I2C(p) (0) +#define PIN_TO_DIGITAL(p) (p) +#define PIN_TO_ANALOG(p) (((p)<22)?21-(p):11) +#define PIN_TO_PWM(p) PIN_TO_DIGITAL(p) +#define PIN_TO_SERVO(p) (p) + + +// Teensy++ 1.0 and 2.0 +#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) +#define TOTAL_ANALOG_PINS 8 +#define TOTAL_PINS 46 // 38 digital + 8 analog +#define VERSION_BLINK_PIN 6 +#define IS_PIN_DIGITAL(p) ((p) >= 0 && (p) < TOTAL_PINS) +#define IS_PIN_ANALOG(p) ((p) >= 38 && (p) < TOTAL_PINS) +#define IS_PIN_PWM(p) IS_PIN_DIGITAL(p) +#define IS_PIN_SERVO(p) ((p) >= 0 && (p) < MAX_SERVOS) +#define IS_PIN_I2C(p) (0) +#define PIN_TO_DIGITAL(p) (p) +#define PIN_TO_ANALOG(p) ((p) - 38) +#define PIN_TO_PWM(p) PIN_TO_DIGITAL(p) +#define PIN_TO_SERVO(p) (p) + + +// Sanguino +#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__) +#define TOTAL_ANALOG_PINS 8 +#define TOTAL_PINS 32 // 24 digital + 8 analog +#define VERSION_BLINK_PIN 0 +#define IS_PIN_DIGITAL(p) ((p) >= 2 && (p) < TOTAL_PINS) +#define IS_PIN_ANALOG(p) ((p) >= 24 && (p) < TOTAL_PINS) +#define IS_PIN_PWM(p) IS_PIN_DIGITAL(p) +#define IS_PIN_SERVO(p) ((p) >= 0 && (p) < MAX_SERVOS) +#define IS_PIN_I2C(p) (0) +#define PIN_TO_DIGITAL(p) (p) +#define PIN_TO_ANALOG(p) ((p) - 24) +#define PIN_TO_PWM(p) PIN_TO_DIGITAL(p) +#define PIN_TO_SERVO(p) ((p) - 2) + + +// Illuminato +#elif defined(__AVR_ATmega645__) +#define TOTAL_ANALOG_PINS 6 +#define TOTAL_PINS 42 // 36 digital + 6 analog +#define VERSION_BLINK_PIN 13 +#define IS_PIN_DIGITAL(p) ((p) >= 2 && (p) < TOTAL_PINS) +#define IS_PIN_ANALOG(p) ((p) >= 36 && (p) < TOTAL_PINS) +#define IS_PIN_PWM(p) IS_PIN_DIGITAL(p) +#define IS_PIN_SERVO(p) ((p) >= 0 && (p) < MAX_SERVOS) +#define IS_PIN_I2C(p) (0) +#define PIN_TO_DIGITAL(p) (p) +#define PIN_TO_ANALOG(p) ((p) - 36) +#define PIN_TO_PWM(p) PIN_TO_DIGITAL(p) +#define PIN_TO_SERVO(p) ((p) - 2) + + +// anything else +#else +#error "Please edit Boards.h with a hardware abstraction for this board" +#endif + + +/*============================================================================== + * readPort() - Read an 8 bit port + *============================================================================*/ + +static inline unsigned char readPort(byte, byte) __attribute__((always_inline, unused)); +static inline unsigned char readPort(byte port, byte bitmask) +{ +#if defined(ARDUINO_PINOUT_OPTIMIZE) + if (port == 0) return PIND & B11111100 & bitmask; // ignore Rx/Tx 0/1 + if (port == 1) return PINB & B00111111 & bitmask; // pins 8-13 (14,15 are disabled for the crystal) + if (port == 2) return PINC & bitmask; + return 0; +#else + unsigned char out=0, pin=port*8; + if (IS_PIN_DIGITAL(pin+0) && (bitmask & 0x01) && digitalRead(PIN_TO_DIGITAL(pin+0))) out |= 0x01; + if (IS_PIN_DIGITAL(pin+1) && (bitmask & 0x02) && digitalRead(PIN_TO_DIGITAL(pin+1))) out |= 0x02; + if (IS_PIN_DIGITAL(pin+2) && (bitmask & 0x04) && digitalRead(PIN_TO_DIGITAL(pin+2))) out |= 0x04; + if (IS_PIN_DIGITAL(pin+3) && (bitmask & 0x08) && digitalRead(PIN_TO_DIGITAL(pin+3))) out |= 0x08; + if (IS_PIN_DIGITAL(pin+4) && (bitmask & 0x10) && digitalRead(PIN_TO_DIGITAL(pin+4))) out |= 0x10; + if (IS_PIN_DIGITAL(pin+5) && (bitmask & 0x20) && digitalRead(PIN_TO_DIGITAL(pin+5))) out |= 0x20; + if (IS_PIN_DIGITAL(pin+6) && (bitmask & 0x40) && digitalRead(PIN_TO_DIGITAL(pin+6))) out |= 0x40; + if (IS_PIN_DIGITAL(pin+7) && (bitmask & 0x80) && digitalRead(PIN_TO_DIGITAL(pin+7))) out |= 0x80; + return out; +#endif +} + +/*============================================================================== + * writePort() - Write an 8 bit port, only touch pins specified by a bitmask + *============================================================================*/ + +static inline unsigned char writePort(byte, byte, byte) __attribute__((always_inline, unused)); +static inline unsigned char writePort(byte port, byte value, byte bitmask) +{ +#if defined(ARDUINO_PINOUT_OPTIMIZE) + if (port == 0) { + bitmask = bitmask & 0xFC; // Tx & Rx pins + cli(); + PORTD = (PORTD & ~bitmask) | (bitmask & value); + sei(); + } else if (port == 1) { + cli(); + PORTB = (PORTB & ~bitmask) | (bitmask & value); + sei(); + } else if (port == 2) { + cli(); + PORTC = (PORTC & ~bitmask) | (bitmask & value); + sei(); + } +#else + byte pin=port*8; + if ((bitmask & 0x01)) digitalWrite(PIN_TO_DIGITAL(pin+0), (value & 0x01)); + if ((bitmask & 0x02)) digitalWrite(PIN_TO_DIGITAL(pin+1), (value & 0x02)); + if ((bitmask & 0x04)) digitalWrite(PIN_TO_DIGITAL(pin+2), (value & 0x04)); + if ((bitmask & 0x08)) digitalWrite(PIN_TO_DIGITAL(pin+3), (value & 0x08)); + if ((bitmask & 0x10)) digitalWrite(PIN_TO_DIGITAL(pin+4), (value & 0x10)); + if ((bitmask & 0x20)) digitalWrite(PIN_TO_DIGITAL(pin+5), (value & 0x20)); + if ((bitmask & 0x40)) digitalWrite(PIN_TO_DIGITAL(pin+6), (value & 0x40)); + if ((bitmask & 0x80)) digitalWrite(PIN_TO_DIGITAL(pin+7), (value & 0x80)); +#endif +} + + + + +#ifndef TOTAL_PORTS +#define TOTAL_PORTS ((TOTAL_PINS + 7) / 8) +#endif + + +#endif /* Firmata_Boards_h */ + diff --git a/arduino-0018-linux-x64/libraries/Firmata/Firmata.cpp b/arduino-0022-linux-x64/libraries/Firmata/Firmata.cpp similarity index 100% rename from arduino-0018-linux-x64/libraries/Firmata/Firmata.cpp rename to arduino-0022-linux-x64/libraries/Firmata/Firmata.cpp diff --git a/arduino-0018-linux-x64/libraries/Firmata/Firmata.h b/arduino-0022-linux-x64/libraries/Firmata/Firmata.h similarity index 57% rename from arduino-0018-linux-x64/libraries/Firmata/Firmata.h rename to arduino-0022-linux-x64/libraries/Firmata/Firmata.h index 899d845..9e8dda0 100644 --- a/arduino-0018-linux-x64/libraries/Firmata/Firmata.h +++ b/arduino-0022-linux-x64/libraries/Firmata/Firmata.h @@ -22,7 +22,7 @@ * software can test whether it will be compatible with the currently * installed firmware. */ #define FIRMATA_MAJOR_VERSION 2 // for non-compatible changes -#define FIRMATA_MINOR_VERSION 1 // for backwards compatible changes +#define FIRMATA_MINOR_VERSION 2 // for backwards compatible changes #define MAX_DATA_BYTES 32 // max number of data bytes in non-Sysex messages @@ -47,7 +47,14 @@ #define SHIFT_DATA 0x75 // a bitstream to/from a shift register #define I2C_REQUEST 0x76 // send an I2C read/write request #define I2C_REPLY 0x77 // a reply to an I2C read request -#define I2C_CONFIG 0x78 // config I2C settings such as delay times and power pins +#define I2C_CONFIG 0x78 // config I2C settings such as delay times and power pins +#define EXTENDED_ANALOG 0x6F // analog write (PWM, Servo, etc) to any pin +#define PIN_STATE_QUERY 0x6D // ask for a pin's current mode and value +#define PIN_STATE_RESPONSE 0x6E // reply with pin's current mode and value +#define CAPABILITY_QUERY 0x6B // ask for supported modes and resolution of all pins +#define CAPABILITY_RESPONSE 0x6C // reply with supported modes and resolution +#define ANALOG_MAPPING_QUERY 0x69 // ask for mapping of analog to pin numbers +#define ANALOG_MAPPING_RESPONSE 0x6A // reply with mapping info #define REPORT_FIRMWARE 0x79 // report name and version of the firmware #define SAMPLING_INTERVAL 0x7A // set the poll rate of the main loop #define SYSEX_NON_REALTIME 0x7E // MIDI Reserved for non-realtime messages @@ -66,6 +73,7 @@ #define SERVO 0x04 // digital pin in Servo output mode #define SHIFT 0x05 // shiftIn/shiftOut mode #define I2C 0x06 // pin included in I2C setup +#define TOTAL_PIN_MODES 7 extern "C" { // callback function types @@ -147,84 +155,8 @@ extern FirmataClass Firmata; */ #define setFirmwareVersion(x, y) setFirmwareNameAndVersion(__FILE__, x, y) -// total number of pins currently supported -#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) // Arduino NG and Diecimila -#define TOTAL_ANALOG_PINS 8 -#define TOTAL_DIGITAL_PINS 22 // 14 digital + 8 analog -#define TOTAL_PORTS 3 // total number of ports for the board -#define ANALOG_PORT 2 // port# of analog used as digital -#define FIRST_ANALOG_PIN 14 // pin# corresponding to analog 0 -#define VERSION_BLINK_PIN 13 // digital pin to blink version on -#define FIRST_SERVO_PIN 2 // pin# of the first servo pin -#elif defined(__AVR_ATmega8__) // old Arduinos -#define TOTAL_ANALOG_PINS 6 -#define TOTAL_DIGITAL_PINS 20 // 14 digital + 6 analog -#define TOTAL_PORTS 3 // total number of ports for the board -#define ANALOG_PORT 2 // port# of analog used as digital -#define FIRST_ANALOG_PIN 14 // pin# corresponding to analog 0 -#define VERSION_BLINK_PIN 13 // digital pin to blink version on -#define FIRST_SERVO_PIN 2 // pin# of the first servo pin -#elif defined(__AVR_ATmega1280__)// Arduino Mega -#define TOTAL_ANALOG_PINS 16 -#define TOTAL_DIGITAL_PINS 70 // 54 digital + 16 analog -#define TOTAL_PORTS 9 // total number of ports for the board -#define ANALOG_PORT 8 // port# of analog used as digital -#define FIRST_ANALOG_PIN 54 // pin# corresponding to analog 0 -#define VERSION_BLINK_PIN 13 // digital pin to blink version on -#define FIRST_SERVO_PIN 2 // pin# of the first servo pin -#elif defined(__AVR_ATmega128__)// Wiring -#define TOTAL_ANALOG_PINS 8 -#define TOTAL_DIGITAL_PINS 51 -#define TOTAL_PORTS 7 // total number of ports for the board -#define ANALOG_PORT 5 // port# of analog used as digital -#define FIRST_ANALOG_PIN 40 // pin# corresponding to analog 0 -#define VERSION_BLINK_PIN 48 // digital pin to blink version on -#define FIRST_SERVO_PIN 8 // pin# of the first servo pin -#elif defined(__AVR_AT90USB162__) // Teensy -#define TOTAL_ANALOG_PINS 0 -#define TOTAL_DIGITAL_PINS 21 // 21 digital + no analog -#define TOTAL_PORTS 4 // total number of ports for the board -#define ANALOG_PORT 3 // port# of analog used as digital -#define FIRST_ANALOG_PIN 21 // pin# corresponding to analog 0 -#define VERSION_BLINK_PIN 6 // digital pin to blink version on -#elif defined(__AVR_ATmega32U4__) // Teensy -#define TOTAL_ANALOG_PINS 12 -#define TOTAL_DIGITAL_PINS 25 // 11 digital + 12 analog -#define TOTAL_PORTS 4 // total number of ports for the board -#define ANALOG_PORT 3 // port# of analog used as digital -#define FIRST_ANALOG_PIN 11 // pin# corresponding to analog 0 -#define VERSION_BLINK_PIN 11 // digital pin to blink version on -#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) // Teensy++ -#define TOTAL_ANALOG_PINS 8 -#define TOTAL_DIGITAL_PINS 46 // 38 digital + 8 analog -#define TOTAL_PORTS 6 // total number of ports for the board -#define ANALOG_PORT 5 // port# of analog used as digital -#define FIRST_ANALOG_PIN 38 // pin# corresponding to analog 0 -#define VERSION_BLINK_PIN 6 // digital pin to blink version on -#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__) // Sanguino -#define TOTAL_ANALOG_PINS 8 -#define TOTAL_DIGITAL_PINS 32 // 24 digital + 8 analog -#define TOTAL_PORTS 4 // total number of ports for the board -#define ANALOG_PORT 3 // port# of analog used as digital -#define FIRST_ANALOG_PIN 24 // pin# corresponding to analog 0 -#define VERSION_BLINK_PIN 0 // digital pin to blink version on -#elif defined(__AVR_ATmega645__) // Illuminato -#define TOTAL_ANALOG_PINS 6 -#define TOTAL_DIGITAL_PINS 42 // 36 digital + 6 analog -#define TOTAL_PORTS 6 // total number of ports for the board -#define ANALOG_PORT 4 // port# of analog used as digital -#define FIRST_ANALOG_PIN 36 // pin# corresponding to analog 0 -#define VERSION_BLINK_PIN 13 // digital pin to blink version on -#else // anything else -#define TOTAL_ANALOG_PINS 6 -#define TOTAL_DIGITAL_PINS 14 -#define TOTAL_PORTS 3 // total number of ports for the board -#define ANALOG_PORT 2 // port# of analog used as digital -#define FIRST_ANALOG_PIN 14 // pin# corresponding to analog 0 -#define VERSION_BLINK_PIN 13 // digital pin to blink version on -#endif - - +/* Hardware Abstraction Layer */ +#include "Boards.h" #endif /* Firmata_h */ diff --git a/arduino-0018-linux-x64/libraries/Firmata/LICENSE.txt b/arduino-0022-linux-x64/libraries/Firmata/LICENSE.txt similarity index 100% rename from arduino-0018-linux-x64/libraries/Firmata/LICENSE.txt rename to arduino-0022-linux-x64/libraries/Firmata/LICENSE.txt diff --git a/arduino-0018-linux-x64/libraries/Firmata/TODO.txt b/arduino-0022-linux-x64/libraries/Firmata/TODO.txt similarity index 100% rename from arduino-0018-linux-x64/libraries/Firmata/TODO.txt rename to arduino-0022-linux-x64/libraries/Firmata/TODO.txt diff --git a/arduino-0018-linux-x64/libraries/Firmata/examples/AllInputsFirmata/AllInputsFirmata.pde b/arduino-0022-linux-x64/libraries/Firmata/examples/AllInputsFirmata/AllInputsFirmata.pde similarity index 67% rename from arduino-0018-linux-x64/libraries/Firmata/examples/AllInputsFirmata/AllInputsFirmata.pde rename to arduino-0022-linux-x64/libraries/Firmata/examples/AllInputsFirmata/AllInputsFirmata.pde index cd50791..5bca72a 100644 --- a/arduino-0018-linux-x64/libraries/Firmata/examples/AllInputsFirmata/AllInputsFirmata.pde +++ b/arduino-0022-linux-x64/libraries/Firmata/examples/AllInputsFirmata/AllInputsFirmata.pde @@ -11,19 +11,19 @@ byte pin; int analogValue; int previousAnalogValues[TOTAL_ANALOG_PINS]; -byte portStatus[TOTAL_PORTS]; +byte portStatus[TOTAL_PORTS]; // each bit: 1=pin is digital input, 0=other/ignore byte previousPINs[TOTAL_PORTS]; /* timer variables */ unsigned long currentMillis; // store the current value from millis() -unsigned long nextExecuteMillis; // for comparison with currentMillis +unsigned long previousMillis; // for comparison with currentMillis /* make sure that the FTDI buffer doesn't go over 60 bytes, otherwise you get long, random delays. So only read analogs every 20ms or so */ int samplingInterval = 19; // how often to run the main loop (in ms) void sendPort(byte portNumber, byte portValue) { - portValue = portValue &~ portStatus[portNumber]; + portValue = portValue & portStatus[portNumber]; if(previousPINs[portNumber] != portValue) { Firmata.sendDigitalPort(portNumber, portValue); previousPINs[portNumber] = portValue; @@ -32,29 +32,37 @@ void sendPort(byte portNumber, byte portValue) void setup() { + byte i, port, status; + Firmata.setFirmwareVersion(0, 1); - for(pin = 0; pin < TOTAL_DIGITAL_PINS; pin++) { - pinMode(pin, INPUT); + for(pin = 0; pin < TOTAL_PINS; pin++) { + if IS_PIN_DIGITAL(pin) pinMode(PIN_TO_DIGITAL(pin), INPUT); } - portStatus[0] = B00000011; // ignore Tx/RX pins - portStatus[1] = B11000000; // ignore 14/15 pins - portStatus[2] = B00000000; + for (port=0; port nextExecuteMillis) { - nextExecuteMillis = currentMillis + samplingInterval; + if(currentMillis - previousMillis > samplingInterval) { + previousMillis += samplingInterval; while(Firmata.available()) { Firmata.processInput(); } diff --git a/arduino-0018-linux-x64/libraries/Firmata/examples/AnalogFirmata/AnalogFirmata.pde b/arduino-0022-linux-x64/libraries/Firmata/examples/AnalogFirmata/AnalogFirmata.pde similarity index 93% rename from arduino-0018-linux-x64/libraries/Firmata/examples/AnalogFirmata/AnalogFirmata.pde rename to arduino-0022-linux-x64/libraries/Firmata/examples/AnalogFirmata/AnalogFirmata.pde index ab83726..df8b674 100644 --- a/arduino-0018-linux-x64/libraries/Firmata/examples/AnalogFirmata/AnalogFirmata.pde +++ b/arduino-0022-linux-x64/libraries/Firmata/examples/AnalogFirmata/AnalogFirmata.pde @@ -3,8 +3,8 @@ * * This example code is in the public domain. */ -#include #include +#include /*============================================================================== * GLOBAL VARIABLES @@ -17,7 +17,7 @@ int analogInputsToReport = 0; // bitwise array to store pin reporting int analogPin = 0; // counter for reading analog pins /* timer variables */ unsigned long currentMillis; // store the current value from millis() -unsigned long nextExecuteMillis; // for comparison with currentMillis +unsigned long previousMillis; // for comparison with currentMillis /*============================================================================== @@ -72,8 +72,8 @@ void loop() while(Firmata.available()) Firmata.processInput(); currentMillis = millis(); - if(currentMillis > nextExecuteMillis) { - nextExecuteMillis = currentMillis + 19; // run this every 20ms + if(currentMillis - previousMillis > 20) { + previousMillis += 20; // run this every 20ms for(analogPin=0;analogPin nextExecuteMillis) { - nextExecuteMillis = currentMillis + samplingInterval; + if (currentMillis - previousMillis > samplingInterval) { + previousMillis += samplingInterval; for (byte i = 0; i < queryIndex; i++) { readAndReportData(query[i].addr, query[i].reg, query[i].bytes); diff --git a/arduino-0018-linux-x64/libraries/Firmata/examples/OldStandardFirmata/LICENSE.txt b/arduino-0022-linux-x64/libraries/Firmata/examples/OldStandardFirmata/LICENSE.txt similarity index 100% rename from arduino-0018-linux-x64/libraries/Firmata/examples/OldStandardFirmata/LICENSE.txt rename to arduino-0022-linux-x64/libraries/Firmata/examples/OldStandardFirmata/LICENSE.txt diff --git a/arduino-0018-linux-x64/libraries/Firmata/examples/OldStandardFirmata/OldStandardFirmata.pde b/arduino-0022-linux-x64/libraries/Firmata/examples/OldStandardFirmata/OldStandardFirmata.pde similarity index 93% rename from arduino-0018-linux-x64/libraries/Firmata/examples/OldStandardFirmata/OldStandardFirmata.pde rename to arduino-0022-linux-x64/libraries/Firmata/examples/OldStandardFirmata/OldStandardFirmata.pde index 5dd3679..56a47ac 100644 --- a/arduino-0018-linux-x64/libraries/Firmata/examples/OldStandardFirmata/OldStandardFirmata.pde +++ b/arduino-0022-linux-x64/libraries/Firmata/examples/OldStandardFirmata/OldStandardFirmata.pde @@ -30,12 +30,12 @@ int analogPin = 0; // counter for reading analog pins /* digital pins */ byte reportPINs[TOTAL_PORTS]; // PIN == input port byte previousPINs[TOTAL_PORTS]; // PIN == input port -byte pinStatus[TOTAL_DIGITAL_PINS]; // store pin status, default OUTPUT +byte pinStatus[TOTAL_PINS]; // store pin status, default OUTPUT byte portStatus[TOTAL_PORTS]; /* timer variables */ unsigned long currentMillis; // store the current value from millis() -unsigned long nextExecuteMillis; // for comparison with currentMillis +unsigned long previousMillis; // for comparison with currentMillis /*============================================================================== @@ -63,7 +63,7 @@ void checkDigitalInputs(void) switch(i) { case 0: outputPort(0, PIND &~ B00000011); break; // ignore Rx/Tx 0/1 case 1: outputPort(1, PINB); break; - case ANALOG_PORT: outputPort(ANALOG_PORT, PINC); break; + case 2: outputPort(2, PINC); break; } } } @@ -150,7 +150,7 @@ void reportAnalogCallback(byte pin, int value) void reportDigitalCallback(byte port, int value) { reportPINs[port] = (byte)value; - if(port == ANALOG_PORT) // turn off analog reporting when used as digital + if(port == 2) // turn off analog reporting when used as digital analogInputsToReport = 0; } @@ -173,7 +173,7 @@ void setup() portStatus[1] = B11000000; // ignore 14/15 pins portStatus[2] = B00000000; -// for(i=0; i nextExecuteMillis) { - nextExecuteMillis = currentMillis + 19; // run this every 20ms + if(currentMillis - previousMillis > 20) { + previousMillis += 20; // run this every 20ms /* SERIALREAD - Serial.read() uses a 128 byte circular buffer, so handle * all serialReads at once, i.e. empty the buffer */ while(Firmata.available()) diff --git a/arduino-0018-linux-x64/libraries/Firmata/examples/ServoFirmata/Makefile b/arduino-0022-linux-x64/libraries/Firmata/examples/ServoFirmata/Makefile similarity index 100% rename from arduino-0018-linux-x64/libraries/Firmata/examples/ServoFirmata/Makefile rename to arduino-0022-linux-x64/libraries/Firmata/examples/ServoFirmata/Makefile diff --git a/arduino-0018-linux-x64/libraries/Firmata/examples/ServoFirmata/ServoFirmata.pde b/arduino-0022-linux-x64/libraries/Firmata/examples/ServoFirmata/ServoFirmata.pde similarity index 61% rename from arduino-0018-linux-x64/libraries/Firmata/examples/ServoFirmata/ServoFirmata.pde rename to arduino-0022-linux-x64/libraries/Firmata/examples/ServoFirmata/ServoFirmata.pde index fa48e2b..6f78ccd 100644 --- a/arduino-0018-linux-x64/libraries/Firmata/examples/ServoFirmata/ServoFirmata.pde +++ b/arduino-0022-linux-x64/libraries/Firmata/examples/ServoFirmata/ServoFirmata.pde @@ -1,32 +1,35 @@ -/* This firmware supports as many servos as possible using the Servo" library - * included in Arduino 0012 +/* This firmware supports as many servos as possible using the Servo library + * included in Arduino 0017 * * TODO add message to configure minPulse/maxPulse/degrees * * This example code is in the public domain. */ -#include #include +#include -Servo servo9; -Servo servo10; +Servo servos[MAX_SERVOS]; void analogWriteCallback(byte pin, int value) { - if(pin == 9) - servo9.write(value); - if(pin == 10) - servo10.write(value); + if (IS_PIN_SERVO(pin)) { + servos[PIN_TO_SERVO(pin)].write(value); + } } void setup() { + byte pin; + Firmata.setFirmwareVersion(0, 2); Firmata.attach(ANALOG_MESSAGE, analogWriteCallback); - servo9.attach(9); - servo10.attach(10); + for (pin=0; pin < TOTAL_PINS; pin++) { + if (IS_PIN_SERVO(pin)) { + servos[PIN_TO_SERVO(pin)].attach(PIN_TO_DIGITAL(pin)); + } + } Firmata.begin(57600); } diff --git a/arduino-0018-linux-x64/libraries/Firmata/examples/SimpleAnalogFirmata/Makefile b/arduino-0022-linux-x64/libraries/Firmata/examples/SimpleAnalogFirmata/Makefile similarity index 100% rename from arduino-0018-linux-x64/libraries/Firmata/examples/SimpleAnalogFirmata/Makefile rename to arduino-0022-linux-x64/libraries/Firmata/examples/SimpleAnalogFirmata/Makefile diff --git a/arduino-0018-linux-x64/libraries/Firmata/examples/SimpleAnalogFirmata/SimpleAnalogFirmata.pde b/arduino-0022-linux-x64/libraries/Firmata/examples/SimpleAnalogFirmata/SimpleAnalogFirmata.pde similarity index 51% rename from arduino-0018-linux-x64/libraries/Firmata/examples/SimpleAnalogFirmata/SimpleAnalogFirmata.pde rename to arduino-0022-linux-x64/libraries/Firmata/examples/SimpleAnalogFirmata/SimpleAnalogFirmata.pde index 430d0d0..b505b33 100644 --- a/arduino-0018-linux-x64/libraries/Firmata/examples/SimpleAnalogFirmata/SimpleAnalogFirmata.pde +++ b/arduino-0022-linux-x64/libraries/Firmata/examples/SimpleAnalogFirmata/SimpleAnalogFirmata.pde @@ -4,12 +4,14 @@ */ #include -byte analogPin; +byte analogPin = 0; void analogWriteCallback(byte pin, int value) { - pinMode(pin,OUTPUT); - analogWrite(pin, value); + if (IS_PIN_PWM(pin)) { + pinMode(PIN_TO_DIGITAL(pin), OUTPUT); + analogWrite(PIN_TO_PWM(pin), value); + } } void setup() @@ -24,9 +26,10 @@ void loop() while(Firmata.available()) { Firmata.processInput(); } - for(analogPin = 0; analogPin < TOTAL_ANALOG_PINS; analogPin++) { - Firmata.sendAnalog(analogPin, analogRead(analogPin)); - } + // do one analogRead per loop, so if PC is sending a lot of + // analog write messages, we will only delay 1 analogRead + Firmata.sendAnalog(analogPin, analogRead(analogPin)); + analogPin = analogPin + 1; + if (analogPin >= TOTAL_ANALOG_PINS) analogPin = 0; } - diff --git a/arduino-0018-linux-x64/libraries/Firmata/examples/SimpleDigitalFirmata/Makefile b/arduino-0022-linux-x64/libraries/Firmata/examples/SimpleDigitalFirmata/Makefile similarity index 100% rename from arduino-0018-linux-x64/libraries/Firmata/examples/SimpleDigitalFirmata/Makefile rename to arduino-0022-linux-x64/libraries/Firmata/examples/SimpleDigitalFirmata/Makefile diff --git a/arduino-0018-linux-x64/libraries/Firmata/examples/SimpleDigitalFirmata/SimpleDigitalFirmata.pde b/arduino-0022-linux-x64/libraries/Firmata/examples/SimpleDigitalFirmata/SimpleDigitalFirmata.pde similarity index 70% rename from arduino-0018-linux-x64/libraries/Firmata/examples/SimpleDigitalFirmata/SimpleDigitalFirmata.pde rename to arduino-0022-linux-x64/libraries/Firmata/examples/SimpleDigitalFirmata/SimpleDigitalFirmata.pde index 50b54dd..64b566e 100644 --- a/arduino-0018-linux-x64/libraries/Firmata/examples/SimpleDigitalFirmata/SimpleDigitalFirmata.pde +++ b/arduino-0022-linux-x64/libraries/Firmata/examples/SimpleDigitalFirmata/SimpleDigitalFirmata.pde @@ -4,21 +4,21 @@ */ #include -byte previousPIN[2]; // PIN means PORT for input -byte previousPORT[2]; +byte previousPIN[TOTAL_PORTS]; // PIN means PORT for input +byte previousPORT[TOTAL_PORTS]; void outputPort(byte portNumber, byte portValue) { -// only send the data when it changes, otherwise you get too many messages! - if(previousPIN[portNumber] != portValue) { + // only send the data when it changes, otherwise you get too many messages! + if (previousPIN[portNumber] != portValue) { Firmata.sendDigitalPort(portNumber, portValue); previousPIN[portNumber] = portValue; } } void setPinModeCallback(byte pin, int mode) { - if(pin > 1) { // don't touch RxTx pins (0,1) - pinMode(pin, mode); + if (IS_PIN_DIGITAL(pin)) { + pinMode(PIN_TO_DIGITAL(pin), mode); } } @@ -27,7 +27,7 @@ void digitalWriteCallback(byte port, int value) byte i; byte currentPinValue, previousPinValue; - if(value != previousPORT[port]) { + if (port < TOTAL_PORTS && value != previousPORT[port]) { for(i=0; i<8; i++) { currentPinValue = (byte) value & (1 << i); previousPinValue = previousPORT[port] & (1 << i); @@ -49,8 +49,12 @@ void setup() void loop() { - outputPort(0, PIND &~ B00000011); // pins 0-7, ignoring Rx/Tx pins (0/1) - outputPort(1, PINB); // pins 8-13 + byte i; + + for (i=0; i +#include + +/*============================================================================== + * GLOBAL VARIABLES + *============================================================================*/ + +/* analog inputs */ +int analogInputsToReport = 0; // bitwise array to store pin reporting + +/* digital input ports */ +byte reportPINs[TOTAL_PORTS]; // 1 = report this port, 0 = silence +byte previousPINs[TOTAL_PORTS]; // previous 8 bits sent + +/* pins configuration */ +byte pinConfig[TOTAL_PINS]; // configuration of every pin +byte portConfigInputs[TOTAL_PORTS]; // each bit: 1 = pin in INPUT, 0 = anything else +int pinState[TOTAL_PINS]; // any value that has been written + +/* timer variables */ +unsigned long currentMillis; // store the current value from millis() +unsigned long previousMillis; // for comparison with currentMillis +int samplingInterval = 19; // how often to run the main loop (in ms) + +Servo servos[MAX_SERVOS]; + +/*============================================================================== + * FUNCTIONS + *============================================================================*/ + +void outputPort(byte portNumber, byte portValue, byte forceSend) +{ + // pins not configured as INPUT are cleared to zeros + portValue = portValue & portConfigInputs[portNumber]; + // only send if the value is different than previously sent + if(forceSend || previousPINs[portNumber] != portValue) { + Firmata.sendDigitalPort(portNumber, portValue); + previousPINs[portNumber] = portValue; + } +} + +/* ----------------------------------------------------------------------------- + * check all the active digital inputs for change of state, then add any events + * to the Serial output queue using Serial.print() */ +void checkDigitalInputs(void) +{ + /* Using non-looping code allows constants to be given to readPort(). + * The compiler will apply substantial optimizations if the inputs + * to readPort() are compile-time constants. */ + if (TOTAL_PORTS > 0 && reportPINs[0]) outputPort(0, readPort(0, portConfigInputs[0]), false); + if (TOTAL_PORTS > 1 && reportPINs[1]) outputPort(1, readPort(1, portConfigInputs[1]), false); + if (TOTAL_PORTS > 2 && reportPINs[2]) outputPort(2, readPort(2, portConfigInputs[2]), false); + if (TOTAL_PORTS > 3 && reportPINs[3]) outputPort(3, readPort(3, portConfigInputs[3]), false); + if (TOTAL_PORTS > 4 && reportPINs[4]) outputPort(4, readPort(4, portConfigInputs[4]), false); + if (TOTAL_PORTS > 5 && reportPINs[5]) outputPort(5, readPort(5, portConfigInputs[5]), false); + if (TOTAL_PORTS > 6 && reportPINs[6]) outputPort(6, readPort(6, portConfigInputs[6]), false); + if (TOTAL_PORTS > 7 && reportPINs[7]) outputPort(7, readPort(7, portConfigInputs[7]), false); + if (TOTAL_PORTS > 8 && reportPINs[8]) outputPort(8, readPort(8, portConfigInputs[8]), false); + if (TOTAL_PORTS > 9 && reportPINs[9]) outputPort(9, readPort(9, portConfigInputs[9]), false); + if (TOTAL_PORTS > 10 && reportPINs[10]) outputPort(10, readPort(10, portConfigInputs[10]), false); + if (TOTAL_PORTS > 11 && reportPINs[11]) outputPort(11, readPort(11, portConfigInputs[11]), false); + if (TOTAL_PORTS > 12 && reportPINs[12]) outputPort(12, readPort(12, portConfigInputs[12]), false); + if (TOTAL_PORTS > 13 && reportPINs[13]) outputPort(13, readPort(13, portConfigInputs[13]), false); + if (TOTAL_PORTS > 14 && reportPINs[14]) outputPort(14, readPort(14, portConfigInputs[14]), false); + if (TOTAL_PORTS > 15 && reportPINs[15]) outputPort(15, readPort(15, portConfigInputs[15]), false); +} + +// ----------------------------------------------------------------------------- +/* sets the pin mode to the correct state and sets the relevant bits in the + * two bit-arrays that track Digital I/O and PWM status + */ +void setPinModeCallback(byte pin, int mode) +{ + if (IS_PIN_SERVO(pin) && mode != SERVO && servos[PIN_TO_SERVO(pin)].attached()) { + servos[PIN_TO_SERVO(pin)].detach(); + } + if (IS_PIN_ANALOG(pin)) { + reportAnalogCallback(PIN_TO_ANALOG(pin), mode == ANALOG ? 1 : 0); // turn on/off reporting + } + if (IS_PIN_DIGITAL(pin)) { + if (mode == INPUT) { + portConfigInputs[pin/8] |= (1 << (pin & 7)); + } else { + portConfigInputs[pin/8] &= ~(1 << (pin & 7)); + } + } + pinState[pin] = 0; + switch(mode) { + case ANALOG: + if (IS_PIN_ANALOG(pin)) { + if (IS_PIN_DIGITAL(pin)) { + pinMode(PIN_TO_DIGITAL(pin), INPUT); // disable output driver + digitalWrite(PIN_TO_DIGITAL(pin), LOW); // disable internal pull-ups + } + pinConfig[pin] = ANALOG; + } + break; + case INPUT: + if (IS_PIN_DIGITAL(pin)) { + pinMode(PIN_TO_DIGITAL(pin), INPUT); // disable output driver + digitalWrite(PIN_TO_DIGITAL(pin), LOW); // disable internal pull-ups + pinConfig[pin] = INPUT; + } + break; + case OUTPUT: + if (IS_PIN_DIGITAL(pin)) { + digitalWrite(PIN_TO_DIGITAL(pin), LOW); // disable PWM + pinMode(PIN_TO_DIGITAL(pin), OUTPUT); + pinConfig[pin] = OUTPUT; + } + break; + case PWM: + if (IS_PIN_PWM(pin)) { + pinMode(PIN_TO_PWM(pin), OUTPUT); + analogWrite(PIN_TO_PWM(pin), 0); + pinConfig[pin] = PWM; + } + break; + case SERVO: + if (IS_PIN_SERVO(pin)) { + pinConfig[pin] = SERVO; + if (!servos[PIN_TO_SERVO(pin)].attached()) { + servos[PIN_TO_SERVO(pin)].attach(PIN_TO_DIGITAL(pin)); + } else { + Firmata.sendString("Servo only on pins from 2 to 13"); + } + } + break; + case I2C: + pinConfig[pin] = mode; + Firmata.sendString("I2C mode not yet supported"); + break; + default: + Firmata.sendString("Unknown pin mode"); // TODO: put error msgs in EEPROM + } + // TODO: save status to EEPROM here, if changed +} + +void analogWriteCallback(byte pin, int value) +{ + if (pin < TOTAL_PINS) { + switch(pinConfig[pin]) { + case SERVO: + if (IS_PIN_SERVO(pin)) + servos[PIN_TO_SERVO(pin)].write(value); + pinState[pin] = value; + break; + case PWM: + if (IS_PIN_PWM(pin)) + analogWrite(PIN_TO_PWM(pin), value); + pinState[pin] = value; + break; + } + } +} + +void digitalWriteCallback(byte port, int value) +{ + byte pin, lastPin, mask=1, pinWriteMask=0; + + if (port < TOTAL_PORTS) { + // create a mask of the pins on this port that are writable. + lastPin = port*8+8; + if (lastPin > TOTAL_PINS) lastPin = TOTAL_PINS; + for (pin=port*8; pin < lastPin; pin++) { + // do not disturb non-digital pins (eg, Rx & Tx) + if (IS_PIN_DIGITAL(pin)) { + // only write to OUTPUT and INPUT (enables pullup) + // do not touch pins in PWM, ANALOG, SERVO or other modes + if (pinConfig[pin] == OUTPUT || pinConfig[pin] == INPUT) { + pinWriteMask |= mask; + pinState[pin] = ((byte)value & mask) ? 1 : 0; + } + } + mask = mask << 1; + } + writePort(port, (byte)value, pinWriteMask); + } +} + + +// ----------------------------------------------------------------------------- +/* sets bits in a bit array (int) to toggle the reporting of the analogIns + */ +//void FirmataClass::setAnalogPinReporting(byte pin, byte state) { +//} +void reportAnalogCallback(byte analogPin, int value) +{ + if (analogPin < TOTAL_ANALOG_PINS) { + if(value == 0) { + analogInputsToReport = analogInputsToReport &~ (1 << analogPin); + } else { + analogInputsToReport = analogInputsToReport | (1 << analogPin); + } + } + // TODO: save status to EEPROM here, if changed +} + +void reportDigitalCallback(byte port, int value) +{ + if (port < TOTAL_PORTS) { + reportPINs[port] = (byte)value; + } + // do not disable analog reporting on these 8 pins, to allow some + // pins used for digital, others analog. Instead, allow both types + // of reporting to be enabled, but check if the pin is configured + // as analog when sampling the analog inputs. Likewise, while + // scanning digital pins, portConfigInputs will mask off values from any + // pins configured as analog +} + +/*============================================================================== + * SYSEX-BASED commands + *============================================================================*/ + +void sysexCallback(byte command, byte argc, byte *argv) +{ + switch(command) { + case SERVO_CONFIG: + if(argc > 4) { + // these vars are here for clarity, they'll optimized away by the compiler + byte pin = argv[0]; + int minPulse = argv[1] + (argv[2] << 7); + int maxPulse = argv[3] + (argv[4] << 7); + + if (IS_PIN_SERVO(pin)) { + // servos are pins from 2 to 13, so offset for array + if (servos[PIN_TO_SERVO(pin)].attached()) + servos[PIN_TO_SERVO(pin)].detach(); + servos[PIN_TO_SERVO(pin)].attach(PIN_TO_DIGITAL(pin), minPulse, maxPulse); + setPinModeCallback(pin, SERVO); + } + } + break; + case SAMPLING_INTERVAL: + if (argc > 1) + samplingInterval = argv[0] + (argv[1] << 7); + else + Firmata.sendString("Not enough data"); + break; + case EXTENDED_ANALOG: + if (argc > 1) { + int val = argv[1]; + if (argc > 2) val |= (argv[2] << 7); + if (argc > 3) val |= (argv[3] << 14); + analogWriteCallback(argv[0], val); + } + break; + case CAPABILITY_QUERY: + Serial.write(START_SYSEX); + Serial.write(CAPABILITY_RESPONSE); + for (byte pin=0; pin < TOTAL_PINS; pin++) { + if (IS_PIN_DIGITAL(pin)) { + Serial.write((byte)INPUT); + Serial.write(1); + Serial.write((byte)OUTPUT); + Serial.write(1); + } + if (IS_PIN_ANALOG(pin)) { + Serial.write(ANALOG); + Serial.write(10); + } + if (IS_PIN_PWM(pin)) { + Serial.write(PWM); + Serial.write(8); + } + if (IS_PIN_SERVO(pin)) { + Serial.write(SERVO); + Serial.write(14); + } + Serial.write(127); + } + Serial.write(END_SYSEX); + break; + case PIN_STATE_QUERY: + if (argc > 0) { + byte pin=argv[0]; + Serial.write(START_SYSEX); + Serial.write(PIN_STATE_RESPONSE); + Serial.write(pin); + if (pin < TOTAL_PINS) { + Serial.write((byte)pinConfig[pin]); + Serial.write((byte)pinState[pin] & 0x7F); + if (pinState[pin] & 0xFF80) Serial.write((byte)(pinState[pin] >> 7) & 0x7F); + if (pinState[pin] & 0xC000) Serial.write((byte)(pinState[pin] >> 14) & 0x7F); + } + Serial.write(END_SYSEX); + } + break; + case ANALOG_MAPPING_QUERY: + Serial.write(START_SYSEX); + Serial.write(ANALOG_MAPPING_RESPONSE); + for (byte pin=0; pin < TOTAL_PINS; pin++) { + Serial.write(IS_PIN_ANALOG(pin) ? PIN_TO_ANALOG(pin) : 127); + } + Serial.write(END_SYSEX); + break; + } +} + + +/*============================================================================== + * SETUP() + *============================================================================*/ +void setup() +{ + byte i; + + Firmata.setFirmwareVersion(2, 2); + + Firmata.attach(ANALOG_MESSAGE, analogWriteCallback); + Firmata.attach(DIGITAL_MESSAGE, digitalWriteCallback); + Firmata.attach(REPORT_ANALOG, reportAnalogCallback); + Firmata.attach(REPORT_DIGITAL, reportDigitalCallback); + Firmata.attach(SET_PIN_MODE, setPinModeCallback); + Firmata.attach(START_SYSEX, sysexCallback); + + // TODO: load state from EEPROM here + + /* these are initialized to zero by the compiler startup code + for (i=0; i < TOTAL_PORTS; i++) { + reportPINs[i] = false; + portConfigInputs[i] = 0; + previousPINs[i] = 0; + } + */ + for (i=0; i < TOTAL_PINS; i++) { + if (IS_PIN_ANALOG(i)) { + // turns off pullup, configures everything + setPinModeCallback(i, ANALOG); + } else { + // sets the output to 0, configures portConfigInputs + setPinModeCallback(i, OUTPUT); + } + } + // by defult, do not report any analog inputs + analogInputsToReport = 0; + + Firmata.begin(57600); + + /* send digital inputs to set the initial state on the host computer, + * since once in the loop(), this firmware will only send on change */ + for (i=0; i < TOTAL_PORTS; i++) { + outputPort(i, readPort(i, portConfigInputs[i]), true); + } +} + +/*============================================================================== + * LOOP() + *============================================================================*/ +void loop() +{ + byte pin, analogPin; + + /* DIGITALREAD - as fast as possible, check for changes and output them to the + * FTDI buffer using Serial.print() */ + checkDigitalInputs(); + + /* SERIALREAD - processing incoming messagse as soon as possible, while still + * checking digital inputs. */ + while(Firmata.available()) + Firmata.processInput(); + + /* SEND FTDI WRITE BUFFER - make sure that the FTDI buffer doesn't go over + * 60 bytes. use a timer to sending an event character every 4 ms to + * trigger the buffer to dump. */ + + currentMillis = millis(); + if (currentMillis - previousMillis > samplingInterval) { + previousMillis += samplingInterval; + /* ANALOGREAD - do all analogReads() at the configured sampling interval */ + for(pin=0; pin +#include + +/*============================================================================== + * GLOBAL VARIABLES + *============================================================================*/ + +/* has the command arrived? */ +boolean firstCommand = false; +int dataOnSerial = 0; +boolean statusLed = false; + +/* analog inputs */ +int analogInputsToReport = 0; // bitwise array to store pin reporting + +/* digital input ports */ +byte reportPINs[TOTAL_PORTS]; // 1 = report this port, 0 = silence +byte previousPINs[TOTAL_PORTS]; // previous 8 bits sent + +/* pins configuration */ +byte pinConfig[TOTAL_PINS]; // configuration of every pin +byte portConfigInputs[TOTAL_PORTS]; // each bit: 1 = pin in INPUT, 0 = anything else +int pinState[TOTAL_PINS]; // any value that has been written + +/* timer variables */ +unsigned long currentMillis; // store the current value from millis() +unsigned long previousMillis; // for comparison with currentMillis +int samplingInterval = 19; // how often to run the main loop (in ms) +unsigned long toggleMillis; + +Servo servos[MAX_SERVOS]; + +/*============================================================================== + * FUNCTIONS + *============================================================================*/ + +void toggleLed() +{ + if (millis() - toggleMillis > 500) { + statusLed = !statusLed; + digitalWrite(13, statusLed); + toggleMillis = millis(); + } +} + +void outputPort(byte portNumber, byte portValue, byte forceSend) +{ + // pins not configured as INPUT are cleared to zeros + portValue = portValue & portConfigInputs[portNumber]; + // only send if the value is different than previously sent + if(forceSend || previousPINs[portNumber] != portValue) { + Firmata.sendDigitalPort(portNumber, portValue); + previousPINs[portNumber] = portValue; + } +} + +/* ----------------------------------------------------------------------------- + * check all the active digital inputs for change of state, then add any events + * to the Serial output queue using Serial.print() */ +void checkDigitalInputs(void) +{ + /* Using non-looping code allows constants to be given to readPort(). + * The compiler will apply substantial optimizations if the inputs + * to readPort() are compile-time constants. */ + if (TOTAL_PORTS > 0 && reportPINs[0]) outputPort(0, readPort(0, portConfigInputs[0]), false); + if (TOTAL_PORTS > 1 && reportPINs[1]) outputPort(1, readPort(1, portConfigInputs[1]), false); + if (TOTAL_PORTS > 2 && reportPINs[2]) outputPort(2, readPort(2, portConfigInputs[2]), false); + if (TOTAL_PORTS > 3 && reportPINs[3]) outputPort(3, readPort(3, portConfigInputs[3]), false); + if (TOTAL_PORTS > 4 && reportPINs[4]) outputPort(4, readPort(4, portConfigInputs[4]), false); + if (TOTAL_PORTS > 5 && reportPINs[5]) outputPort(5, readPort(5, portConfigInputs[5]), false); + if (TOTAL_PORTS > 6 && reportPINs[6]) outputPort(6, readPort(6, portConfigInputs[6]), false); + if (TOTAL_PORTS > 7 && reportPINs[7]) outputPort(7, readPort(7, portConfigInputs[7]), false); + if (TOTAL_PORTS > 8 && reportPINs[8]) outputPort(8, readPort(8, portConfigInputs[8]), false); + if (TOTAL_PORTS > 9 && reportPINs[9]) outputPort(9, readPort(9, portConfigInputs[9]), false); + if (TOTAL_PORTS > 10 && reportPINs[10]) outputPort(10, readPort(10, portConfigInputs[10]), false); + if (TOTAL_PORTS > 11 && reportPINs[11]) outputPort(11, readPort(11, portConfigInputs[11]), false); + if (TOTAL_PORTS > 12 && reportPINs[12]) outputPort(12, readPort(12, portConfigInputs[12]), false); + if (TOTAL_PORTS > 13 && reportPINs[13]) outputPort(13, readPort(13, portConfigInputs[13]), false); + if (TOTAL_PORTS > 14 && reportPINs[14]) outputPort(14, readPort(14, portConfigInputs[14]), false); + if (TOTAL_PORTS > 15 && reportPINs[15]) outputPort(15, readPort(15, portConfigInputs[15]), false); +} + +// ----------------------------------------------------------------------------- +/* sets the pin mode to the correct state and sets the relevant bits in the + * two bit-arrays that track Digital I/O and PWM status + */ +void setPinModeCallback(byte pin, int mode) +{ + if (IS_PIN_SERVO(pin) && mode != SERVO && servos[PIN_TO_SERVO(pin)].attached()) { + servos[PIN_TO_SERVO(pin)].detach(); + } + if (IS_PIN_ANALOG(pin)) { + reportAnalogCallback(PIN_TO_ANALOG(pin), mode == ANALOG ? 1 : 0); // turn on/off reporting + } + if (IS_PIN_DIGITAL(pin)) { + if (mode == INPUT) { + portConfigInputs[pin/8] |= (1 << (pin & 7)); + } else { + portConfigInputs[pin/8] &= ~(1 << (pin & 7)); + } + } + pinState[pin] = 0; + switch(mode) { + case ANALOG: + if (IS_PIN_ANALOG(pin)) { + if (IS_PIN_DIGITAL(pin)) { + pinMode(PIN_TO_DIGITAL(pin), INPUT); // disable output driver + digitalWrite(PIN_TO_DIGITAL(pin), LOW); // disable internal pull-ups + } + pinConfig[pin] = ANALOG; + } + break; + case INPUT: + if (IS_PIN_DIGITAL(pin)) { + pinMode(PIN_TO_DIGITAL(pin), INPUT); // disable output driver + digitalWrite(PIN_TO_DIGITAL(pin), LOW); // disable internal pull-ups + pinConfig[pin] = INPUT; + } + break; + case OUTPUT: + if (IS_PIN_DIGITAL(pin)) { + digitalWrite(PIN_TO_DIGITAL(pin), LOW); // disable PWM + pinMode(PIN_TO_DIGITAL(pin), OUTPUT); + pinConfig[pin] = OUTPUT; + } + break; + case PWM: + if (IS_PIN_PWM(pin)) { + pinMode(PIN_TO_PWM(pin), OUTPUT); + analogWrite(PIN_TO_PWM(pin), 0); + pinConfig[pin] = PWM; + } + break; + case SERVO: + if (IS_PIN_SERVO(pin)) { + pinConfig[pin] = SERVO; + if (!servos[PIN_TO_SERVO(pin)].attached()) { + servos[PIN_TO_SERVO(pin)].attach(PIN_TO_DIGITAL(pin)); + } else { + Firmata.sendString("Servo only on pins from 2 to 13"); + } + } + break; + case I2C: + pinConfig[pin] = mode; + Firmata.sendString("I2C mode not yet supported"); + break; + default: + Firmata.sendString("Unknown pin mode"); // TODO: put error msgs in EEPROM + } + // TODO: save status to EEPROM here, if changed +} + +void analogWriteCallback(byte pin, int value) +{ + if (pin < TOTAL_PINS) { + switch(pinConfig[pin]) { + case SERVO: + if (IS_PIN_SERVO(pin)) + servos[PIN_TO_SERVO(pin)].write(value); + pinState[pin] = value; + break; + case PWM: + if (IS_PIN_PWM(pin)) + analogWrite(PIN_TO_PWM(pin), value); + pinState[pin] = value; + break; + } + } +} + +void digitalWriteCallback(byte port, int value) +{ + byte pin, lastPin, mask=1, pinWriteMask=0; + + if (port < TOTAL_PORTS) { + // create a mask of the pins on this port that are writable. + lastPin = port*8+8; + if (lastPin > TOTAL_PINS) lastPin = TOTAL_PINS; + for (pin=port*8; pin < lastPin; pin++) { + // do not disturb non-digital pins (eg, Rx & Tx) + if (IS_PIN_DIGITAL(pin)) { + // only write to OUTPUT and INPUT (enables pullup) + // do not touch pins in PWM, ANALOG, SERVO or other modes + if (pinConfig[pin] == OUTPUT || pinConfig[pin] == INPUT) { + pinWriteMask |= mask; + pinState[pin] = ((byte)value & mask) ? 1 : 0; + } + } + mask = mask << 1; + } + writePort(port, (byte)value, pinWriteMask); + } +} + + +// ----------------------------------------------------------------------------- +/* sets bits in a bit array (int) to toggle the reporting of the analogIns + */ +//void FirmataClass::setAnalogPinReporting(byte pin, byte state) { +//} +void reportAnalogCallback(byte analogPin, int value) +{ + if (analogPin < TOTAL_ANALOG_PINS) { + if(value == 0) { + analogInputsToReport = analogInputsToReport &~ (1 << analogPin); + } else { + analogInputsToReport = analogInputsToReport | (1 << analogPin); + } + } + // TODO: save status to EEPROM here, if changed +} + +void reportDigitalCallback(byte port, int value) +{ + if (port < TOTAL_PORTS) { + reportPINs[port] = (byte)value; + } + // do not disable analog reporting on these 8 pins, to allow some + // pins used for digital, others analog. Instead, allow both types + // of reporting to be enabled, but check if the pin is configured + // as analog when sampling the analog inputs. Likewise, while + // scanning digital pins, portConfigInputs will mask off values from any + // pins configured as analog +} + +/*============================================================================== + * SYSEX-BASED commands + *============================================================================*/ + +void sysexCallback(byte command, byte argc, byte *argv) +{ + switch(command) { + case SERVO_CONFIG: + if(argc > 4) { + // these vars are here for clarity, they'll optimized away by the compiler + byte pin = argv[0]; + int minPulse = argv[1] + (argv[2] << 7); + int maxPulse = argv[3] + (argv[4] << 7); + + if (IS_PIN_SERVO(pin)) { + // servos are pins from 2 to 13, so offset for array + if (servos[PIN_TO_SERVO(pin)].attached()) + servos[PIN_TO_SERVO(pin)].detach(); + servos[PIN_TO_SERVO(pin)].attach(PIN_TO_DIGITAL(pin), minPulse, maxPulse); + setPinModeCallback(pin, SERVO); + } + } + break; + case SAMPLING_INTERVAL: + if (argc > 1) + samplingInterval = argv[0] + (argv[1] << 7); + else + Firmata.sendString("Not enough data"); + break; + case EXTENDED_ANALOG: + if (argc > 1) { + int val = argv[1]; + if (argc > 2) val |= (argv[2] << 7); + if (argc > 3) val |= (argv[3] << 14); + analogWriteCallback(argv[0], val); + } + break; + case CAPABILITY_QUERY: + Serial.write(START_SYSEX); + Serial.write(CAPABILITY_RESPONSE); + for (byte pin=0; pin < TOTAL_PINS; pin++) { + if (IS_PIN_DIGITAL(pin)) { + Serial.write((byte)INPUT); + Serial.write(1); + Serial.write((byte)OUTPUT); + Serial.write(1); + } + if (IS_PIN_ANALOG(pin)) { + Serial.write(ANALOG); + Serial.write(10); + } + if (IS_PIN_PWM(pin)) { + Serial.write(PWM); + Serial.write(8); + } + if (IS_PIN_SERVO(pin)) { + Serial.write(SERVO); + Serial.write(14); + } + Serial.write(127); + } + Serial.write(END_SYSEX); + break; + case PIN_STATE_QUERY: + if (argc > 0) { + byte pin=argv[0]; + Serial.write(START_SYSEX); + Serial.write(PIN_STATE_RESPONSE); + Serial.write(pin); + if (pin < TOTAL_PINS) { + Serial.write((byte)pinConfig[pin]); + Serial.write((byte)pinState[pin] & 0x7F); + if (pinState[pin] & 0xFF80) Serial.write((byte)(pinState[pin] >> 7) & 0x7F); + if (pinState[pin] & 0xC000) Serial.write((byte)(pinState[pin] >> 14) & 0x7F); + } + Serial.write(END_SYSEX); + } + break; + case ANALOG_MAPPING_QUERY: + Serial.write(START_SYSEX); + Serial.write(ANALOG_MAPPING_RESPONSE); + for (byte pin=0; pin < TOTAL_PINS; pin++) { + Serial.write(IS_PIN_ANALOG(pin) ? PIN_TO_ANALOG(pin) : 127); + } + Serial.write(END_SYSEX); + break; + } +} + +/*============================================================================== + * SETUP() + *============================================================================*/ +void setup() +{ + byte i; + + Firmata.setFirmwareVersion(2, 2); + + Firmata.attach(ANALOG_MESSAGE, analogWriteCallback); + Firmata.attach(DIGITAL_MESSAGE, digitalWriteCallback); + Firmata.attach(REPORT_ANALOG, reportAnalogCallback); + Firmata.attach(REPORT_DIGITAL, reportDigitalCallback); + Firmata.attach(SET_PIN_MODE, setPinModeCallback); + Firmata.attach(START_SYSEX, sysexCallback); + + // TODO: load state from EEPROM here + + /* these are initialized to zero by the compiler startup code + for (i=0; i < TOTAL_PORTS; i++) { + reportPINs[i] = false; + portConfigInputs[i] = 0; + previousPINs[i] = 0; + } + */ + for (i=0; i < TOTAL_PINS; i++) { + if (IS_PIN_ANALOG(i)) { + // turns off pullup, configures everything + setPinModeCallback(i, ANALOG); + } else { + // sets the output to 0, configures portConfigInputs + setPinModeCallback(i, OUTPUT); + } + } + // by defult, do not report any analog inputs + analogInputsToReport = 0; + + Firmata.begin(57600); + + /* send digital inputs to set the initial state on the host computer, + * since once in the loop(), this firmware will only send on change */ + for (i=0; i < TOTAL_PORTS; i++) { + outputPort(i, readPort(i, portConfigInputs[i]), true); + } + + /* init the toggleLed counter */ + toggleMillis = millis(); + pinMode(13, OUTPUT); +} + +/*============================================================================== + * LOOP() + *============================================================================*/ +void loop() +{ + byte pin, analogPin; + + /* DIGITALREAD - as fast as possible, check for changes and output them to the + * FTDI buffer using Serial.print() */ + checkDigitalInputs(); + + //XXX: hack Firmata to blink until serial command arrives + dataOnSerial = Firmata.available(); + if (dataOnSerial > 0 && !firstCommand) { + firstCommand = true; + } + //XXX: do the blink if the first command hasn't arrived yet + // configures pin 13 as output and then back as input + if (!firstCommand) { + toggleLed(); + } + + /* SERIALREAD - processing incoming messagse as soon as possible, while still + * checking digital inputs. */ + while(dataOnSerial) { + Firmata.processInput(); + dataOnSerial = Firmata.available(); + } + + /* SEND FTDI WRITE BUFFER - make sure that the FTDI buffer doesn't go over + * 60 bytes. use a timer to sending an event character every 4 ms to + * trigger the buffer to dump. */ + + currentMillis = millis(); + if (currentMillis - previousMillis > samplingInterval) { + previousMillis += samplingInterval; + /* ANALOGREAD - do all analogReads() at the configured sampling interval */ + for(pin=0; pin + +void File::write(uint8_t val) { + SD.file.write(val); +} + +void File::write(const char *str) { + SD.file.write(str); +} + +void File::write(const uint8_t *buf, size_t size) { + SD.file.write(buf, size); +} + +int File::peek() { + char c = SD.file.read(); + if (c != -1) SD.file.seekCur(-1); + return c; +} + +int File::read() { + return SD.file.read(); +} + +int File::available() { + return size() - position(); +} + +void File::flush() { + SD.file.sync(); +} + +boolean File::seek(uint32_t pos) { + return SD.file.seekSet(pos); +} + +uint32_t File::position() { + return SD.file.curPosition(); +} + +uint32_t File::size() { + return SD.file.fileSize(); +} + +void File::close() { + SD.file.close(); +} + +File::operator bool() { + return SD.file.isOpen(); +} diff --git a/arduino-0022-linux-x64/libraries/SD/README.txt b/arduino-0022-linux-x64/libraries/SD/README.txt new file mode 100644 index 0000000..863e878 --- /dev/null +++ b/arduino-0022-linux-x64/libraries/SD/README.txt @@ -0,0 +1,11 @@ + +** SD - a slightly more friendly wrapper for sdfatlib ** + +This library aims to expose a subset of SD card functionality in the +form of a higher level "wrapper" object. + +License: GNU General Public License V3 + (Because sdfatlib is licensed with this.) + +(C) Copyright 2010 SparkFun Electronics + diff --git a/arduino-0022-linux-x64/libraries/SD/SD.cpp b/arduino-0022-linux-x64/libraries/SD/SD.cpp new file mode 100644 index 0000000..aca7468 --- /dev/null +++ b/arduino-0022-linux-x64/libraries/SD/SD.cpp @@ -0,0 +1,439 @@ +/* + + SD - a slightly more friendly wrapper for sdfatlib + + This library aims to expose a subset of SD card functionality + in the form of a higher level "wrapper" object. + + License: GNU General Public License V3 + (Because sdfatlib is licensed with this.) + + (C) Copyright 2010 SparkFun Electronics + + + This library provides four key benefits: + + * Including `SD.h` automatically creates a global + `SD` object which can be interacted with in a similar + manner to other standard global objects like `Serial` and `Ethernet`. + + * Boilerplate initialisation code is contained in one method named + `begin` and no further objects need to be created in order to access + the SD card. + + * Calls to `open` can supply a full path name including parent + directories which simplifies interacting with files in subdirectories. + + * Utility methods are provided to determine whether a file exists + and to create a directory heirarchy. + + + Note however that not all functionality provided by the underlying + sdfatlib library is exposed. + + */ + +/* + + Implementation Notes + + In order to handle multi-directory path traversal, functionality that + requires this ability is implemented as callback functions. + + Individual methods call the `walkPath` function which performs the actual + directory traversal (swapping between two different directory/file handles + along the way) and at each level calls the supplied callback function. + + Some types of functionality will take an action at each level (e.g. exists + or make directory) which others will only take an action at the bottom + level (e.g. open). + + */ + +#include "SD.h" + +// Used by `getNextPathComponent` +#define MAX_COMPONENT_LEN 12 // What is max length? +#define PATH_COMPONENT_BUFFER_LEN MAX_COMPONENT_LEN+1 + +bool getNextPathComponent(char *path, unsigned int *p_offset, + char *buffer) { + /* + + Parse individual path components from a path. + + e.g. after repeated calls '/foo/bar/baz' will be split + into 'foo', 'bar', 'baz'. + + This is similar to `strtok()` but copies the component into the + supplied buffer rather than modifying the original string. + + + `buffer` needs to be PATH_COMPONENT_BUFFER_LEN in size. + + `p_offset` needs to point to an integer of the offset at + which the previous path component finished. + + Returns `true` if more components remain. + + Returns `false` if this is the last component. + (This means path ended with 'foo' or 'foo/'.) + + */ + + // TODO: Have buffer local to this function, so we know it's the + // correct length? + + int bufferOffset = 0; + + int offset = *p_offset; + + // Skip root or other separator + if (path[offset] == '/') { + offset++; + } + + // Copy the next next path segment + while (bufferOffset < MAX_COMPONENT_LEN + && (path[offset] != '/') + && (path[offset] != '\0')) { + buffer[bufferOffset++] = path[offset++]; + } + + buffer[bufferOffset] = '\0'; + + // Skip trailing separator so we can determine if this + // is the last component in the path or not. + if (path[offset] == '/') { + offset++; + } + + *p_offset = offset; + + return (path[offset] != '\0'); +} + + + +boolean walkPath(char *filepath, SdFile& parentDir, + boolean (*callback)(SdFile& parentDir, + char *filePathComponent, + boolean isLastComponent, + void *object), + void *object = NULL) { + /* + + When given a file path (and parent directory--normally root), + this function traverses the directories in the path and at each + level calls the supplied callback function while also providing + the supplied object for context if required. + + e.g. given the path '/foo/bar/baz' + the callback would be called at the equivalent of + '/foo', '/foo/bar' and '/foo/bar/baz'. + + The implementation swaps between two different directory/file + handles as it traverses the directories and does not use recursion + in an attempt to use memory efficiently. + + If a callback wishes to stop the directory traversal it should + return false--in this case the function will stop the traversal, + tidy up and return false. + + If a directory path doesn't exist at some point this function will + also return false and not subsequently call the callback. + + If a directory path specified is complete, valid and the callback + did not indicate the traversal should be interrupted then this + function will return true. + + */ + + + SdFile subfile1; + SdFile subfile2; + + char buffer[PATH_COMPONENT_BUFFER_LEN]; + + unsigned int offset = 0; + + SdFile *p_parent; + SdFile *p_child; + + SdFile *p_tmp_sdfile; + + p_child = &subfile1; + + p_parent = &parentDir; + + while (true) { + + boolean moreComponents = getNextPathComponent(filepath, &offset, buffer); + + boolean shouldContinue = callback((*p_parent), buffer, !moreComponents, object); + + if (!shouldContinue) { + // TODO: Don't repeat this code? + // If it's one we've created then we + // don't need the parent handle anymore. + if (p_parent != &parentDir) { + (*p_parent).close(); + } + return false; + } + + if (!moreComponents) { + break; + } + + boolean exists = (*p_child).open(*p_parent, buffer, O_RDONLY); + + // If it's one we've created then we + // don't need the parent handle anymore. + if (p_parent != &parentDir) { + (*p_parent).close(); + } + + // Handle case when it doesn't exist and we can't continue... + if (exists) { + // We alternate between two file handles as we go down + // the path. + if (p_parent == &parentDir) { + p_parent = &subfile2; + } + + p_tmp_sdfile = p_parent; + p_parent = p_child; + p_child = p_tmp_sdfile; + } else { + return false; + } + } + + if (p_parent != &parentDir) { + (*p_parent).close(); // TODO: Return/ handle different? + } + + return true; +} + + + +/* + + The callbacks used to implement various functionality follow. + + Each callback is supplied with a parent directory handle, + character string with the name of the current file path component, + a flag indicating if this component is the last in the path and + a pointer to an arbitrary object used for context. + + */ + +boolean callback_pathExists(SdFile& parentDir, char *filePathComponent, + boolean isLastComponent, void *object) { + /* + + Callback used to determine if a file/directory exists in parent + directory. + + Returns true if file path exists. + + */ + SdFile child; + + boolean exists = child.open(parentDir, filePathComponent, O_RDONLY); + + if (exists) { + child.close(); + } + + return exists; +} + + + +boolean callback_makeDirPath(SdFile& parentDir, char *filePathComponent, + boolean isLastComponent, void *object) { + /* + + Callback used to create a directory in the parent directory if + it does not already exist. + + Returns true if a directory was created or it already existed. + + */ + boolean result = false; + SdFile child; + + result = callback_pathExists(parentDir, filePathComponent, isLastComponent, object); + if (!result) { + result = child.makeDir(parentDir, filePathComponent); + } + + return result; +} + + + +boolean callback_openPath(SdFile& parentDir, char *filePathComponent, + boolean isLastComponent, void *object) { + /* + + Callback used to open a file specified by a filepath that may + specify one or more directories above it. + + Expects the context object to be an instance of `SDClass` and + will use the `file` property of the instance to open the requested + file/directory with the associated file open mode property. + + Always returns true if the directory traversal hasn't reached the + bottom of the directory heirarchy. + + Returns false once the file has been opened--to prevent the traversal + from descending further. (This may be unnecessary.) + + */ + if (isLastComponent) { + SDClass *p_SD = static_cast(object); + p_SD->file.open(parentDir, filePathComponent, p_SD->fileOpenMode); + if (p_SD->fileOpenMode == FILE_WRITE) { + p_SD->file.seekSet(p_SD->file.fileSize()); + } + // TODO: Return file open result? + return false; + } + return true; +} + + +boolean callback_remove(SdFile& parentDir, char *filePathComponent, + boolean isLastComponent, void *object) { + if (isLastComponent) { + return SdFile::remove(parentDir, filePathComponent); + } + return true; +} + +boolean callback_rmdir(SdFile& parentDir, char *filePathComponent, + boolean isLastComponent, void *object) { + if (isLastComponent) { + SdFile f; + if (!f.open(parentDir, filePathComponent, O_READ)) return false; + return f.rmDir(); + } + return true; +} + + + +/* Implementation of class used to create `SDCard` object. */ + + + +boolean SDClass::begin(uint8_t csPin) { + /* + + Performs the initialisation required by the sdfatlib library. + + Return true if initialization succeeds, false otherwise. + + */ + return card.init(SPI_HALF_SPEED, csPin) && + volume.init(card) && + root.openRoot(volume); +} + + +File SDClass::open(char *filepath, uint8_t mode) { + /* + + Open the supplied file path for reading or writing. + + The file content can be accessed via the `file` property of + the `SDClass` object--this property is currently + a standard `SdFile` object from `sdfatlib`. + + Defaults to read only. + + If `write` is true, default action (when `append` is true) is to + append data to the end of the file. + + If `append` is false then the file will be truncated first. + + If the file does not exist and it is opened for writing the file + will be created. + + An attempt to open a file for reading that does not exist is an + error. + + */ + + // TODO: Allow for read&write? (Possibly not, as it requires seek.) + + fileOpenMode = mode; + walkPath(filepath, root, callback_openPath, this); + + return File(); + +} + + +//boolean SDClass::close() { +// /* +// +// Closes the file opened by the `open` method. +// +// */ +// file.close(); +//} + + +boolean SDClass::exists(char *filepath) { + /* + + Returns true if the supplied file path exists. + + */ + return walkPath(filepath, root, callback_pathExists); +} + + +//boolean SDClass::exists(char *filepath, SdFile& parentDir) { +// /* +// +// Returns true if the supplied file path rooted at `parentDir` +// exists. +// +// */ +// return walkPath(filepath, parentDir, callback_pathExists); +//} + + +boolean SDClass::mkdir(char *filepath) { + /* + + Makes a single directory or a heirarchy of directories. + + A rough equivalent to `mkdir -p`. + + */ + return walkPath(filepath, root, callback_makeDirPath); +} + +boolean SDClass::rmdir(char *filepath) { + /* + + Makes a single directory or a heirarchy of directories. + + A rough equivalent to `mkdir -p`. + + */ + return walkPath(filepath, root, callback_rmdir); +} + +boolean SDClass::remove(char *filepath) { + return walkPath(filepath, root, callback_remove); +} + +SDClass SD; \ No newline at end of file diff --git a/arduino-0022-linux-x64/libraries/SD/SD.h b/arduino-0022-linux-x64/libraries/SD/SD.h new file mode 100644 index 0000000..2c5c323 --- /dev/null +++ b/arduino-0022-linux-x64/libraries/SD/SD.h @@ -0,0 +1,88 @@ +/* + + SD - a slightly more friendly wrapper for sdfatlib + + This library aims to expose a subset of SD card functionality + in the form of a higher level "wrapper" object. + + License: GNU General Public License V3 + (Because sdfatlib is licensed with this.) + + (C) Copyright 2010 SparkFun Electronics + + */ + +#ifndef __SD_H__ +#define __SD_H__ + +#include + +#include +#include + +#define FILE_READ O_READ +#define FILE_WRITE (O_READ | O_WRITE | O_CREAT | O_SYNC) + +class File : public Stream { +public: + virtual void write(uint8_t); + virtual void write(const char *str); + virtual void write(const uint8_t *buf, size_t size); + virtual int read(); + virtual int peek(); + virtual int available(); + virtual void flush(); + boolean seek(uint32_t pos); + uint32_t position(); + uint32_t size(); + void close(); + operator bool(); +}; + +class SDClass { + +private: + // These are required for initialisation and use of sdfatlib + Sd2Card card; + SdVolume volume; + SdFile root; + +public: + // This needs to be called to set up the connection to the SD card + // before other methods are used. + boolean begin(uint8_t csPin = SD_CHIP_SELECT_PIN); + + // Open the specified file/directory with the supplied mode (e.g. read or + // write, etc). Returns a File object for interacting with the file. + // Note that currently only one file can be open at a time. + File open(char *filename, uint8_t mode = FILE_READ); + + // Methods to determine if the requested file path exists. + boolean exists(char *filepath); + + // Create the requested directory heirarchy--if intermediate directories + // do not exist they will be created. + boolean mkdir(char *filepath); + + // Delete the file. + boolean remove(char *filepath); + + boolean rmdir(char *filepath); + +private: + SdFile file; + + // This is used to determine the mode used to open a file + // it's here because it's the easiest place to pass the + // information through the directory walking function. But + // it's probably not the best place for it. + // It shouldn't be set directly--it is set via the parameters to `open`. + int fileOpenMode; + + friend class File; + friend boolean callback_openPath(SdFile&, char *, boolean, void *); +}; + +extern SDClass SD; + +#endif diff --git a/arduino-0022-linux-x64/libraries/SD/examples/Datalogger/Datalogger.pde b/arduino-0022-linux-x64/libraries/SD/examples/Datalogger/Datalogger.pde new file mode 100644 index 0000000..73d81af --- /dev/null +++ b/arduino-0022-linux-x64/libraries/SD/examples/Datalogger/Datalogger.pde @@ -0,0 +1,86 @@ +/* + SD card datalogger + + This example shows how to log data from three analog sensors + to an SD card using the SD library. + + The circuit: + * analog sensors on analog ins 0, 1, and 2 + * SD card attached to SPI bus as follows: + ** MOSI - pin 11 + ** MISO - pin 12 + ** CLK - pin 13 + ** CS - pin 4 + + created 24 Nov 2010 + updated 2 Dec 2010 + by Tom Igoe + + This example code is in the public domain. + + */ + +#include + +// On the Ethernet Shield, CS is pin 4. Note that even if it's not +// used as the CS pin, the hardware CS pin (10 on most Arduino boards, +// 53 on the Mega) must be left as an output or the SD library +// functions will not work. +const int chipSelect = 4; + +void setup() +{ + Serial.begin(9600); + Serial.print("Initializing SD card..."); + // make sure that the default chip select pin is set to + // output, even if you don't use it: + pinMode(10, OUTPUT); + + // see if the card is present and can be initialized: + if (!SD.begin(chipSelect)) { + Serial.println("Card failed, or not present"); + // don't do anything more: + return; + } + Serial.println("card initialized."); +} + +void loop() +{ + // make a string for assembling the data to log: + String dataString = ""; + + // read three sensors and append to the string: + for (int analogPin = 0; analogPin < 3; analogPin++) { + int sensor = analogRead(analogPin); + dataString += String(sensor); + if (analogPin < 2) { + dataString += ","; + } + } + + // open the file. note that only one file can be open at a time, + // so you have to close this one before opening another. + File dataFile = SD.open("datalog.txt", FILE_WRITE); + + // if the file is available, write to it: + if (dataFile) { + dataFile.println(dataString); + dataFile.close(); + // print to the serial port too: + Serial.println(dataString); + } + // if the file isn't open, pop up an error: + else { + Serial.println("error opening datalog.txt"); + } +} + + + + + + + + + diff --git a/arduino-0022-linux-x64/libraries/SD/examples/DumpFile/DumpFile.pde b/arduino-0022-linux-x64/libraries/SD/examples/DumpFile/DumpFile.pde new file mode 100644 index 0000000..961717f --- /dev/null +++ b/arduino-0022-linux-x64/libraries/SD/examples/DumpFile/DumpFile.pde @@ -0,0 +1,64 @@ +/* + SD card file dump + + This example shows how to read a file from the SD card using the + SD library and send it over the serial port. + + The circuit: + * SD card attached to SPI bus as follows: + ** MOSI - pin 11 + ** MISO - pin 12 + ** CLK - pin 13 + ** CS - pin 4 + + created 22 December 2010 + + This example code is in the public domain. + + */ + +#include + +// On the Ethernet Shield, CS is pin 4. Note that even if it's not +// used as the CS pin, the hardware CS pin (10 on most Arduino boards, +// 53 on the Mega) must be left as an output or the SD library +// functions will not work. +const int chipSelect = 4; + +void setup() +{ + Serial.begin(9600); + Serial.print("Initializing SD card..."); + // make sure that the default chip select pin is set to + // output, even if you don't use it: + pinMode(10, OUTPUT); + + // see if the card is present and can be initialized: + if (!SD.begin(chipSelect)) { + Serial.println("Card failed, or not present"); + // don't do anything more: + return; + } + Serial.println("card initialized."); + + // open the file. note that only one file can be open at a time, + // so you have to close this one before opening another. + File dataFile = SD.open("datalog.txt"); + + // if the file is available, write to it: + if (dataFile) { + while (dataFile.available()) { + Serial.write(dataFile.read()); + } + dataFile.close(); + } + // if the file isn't open, pop up an error: + else { + Serial.println("error opening datalog.txt"); + } +} + +void loop() +{ +} + diff --git a/arduino-0022-linux-x64/libraries/SD/examples/Files/Files.pde b/arduino-0022-linux-x64/libraries/SD/examples/Files/Files.pde new file mode 100644 index 0000000..5ed9fea --- /dev/null +++ b/arduino-0022-linux-x64/libraries/SD/examples/Files/Files.pde @@ -0,0 +1,78 @@ +/* + SD card basic file example + + This example shows how to create and destroy an SD card file + The circuit: + * SD card attached to SPI bus as follows: + ** MOSI - pin 11 + ** MISO - pin 12 + ** CLK - pin 13 + ** CS - pin 4 + + created Nov 2010 + by David A. Mellis + updated 2 Dec 2010 + by Tom Igoe + + This example code is in the public domain. + + */ +#include + +File myFile; + +void setup() +{ + Serial.begin(9600); + Serial.print("Initializing SD card..."); + // On the Ethernet Shield, CS is pin 4. It's set as an output by default. + // Note that even if it's not used as the CS pin, the hardware SS pin + // (10 on most Arduino boards, 53 on the Mega) must be left as an output + // or the SD library functions will not work. + pinMode(10, OUTPUT); + + if (!SD.begin(4)) { + Serial.println("initialization failed!"); + return; + } + Serial.println("initialization done."); + + if (SD.exists("example.txt")) { + Serial.println("example.txt exists."); + } + else { + Serial.println("example.txt doesn't exist."); + } + + // open a new file and immediately close it: + Serial.println("Creating example.txt..."); + myFile = SD.open("example.txt", FILE_WRITE); + myFile.close(); + + // Check to see if the file exists: + if (SD.exists("example.txt")) { + Serial.println("example.txt exists."); + } + else { + Serial.println("example.txt doesn't exist."); + } + + // delete the file: + Serial.println("Removing example.txt..."); + SD.remove("example.txt"); + + if (SD.exists("example.txt")){ + Serial.println("example.txt exists."); + } + else { + Serial.println("example.txt doesn't exist."); + } +} + +void loop() +{ + // nothing happens after setup finishes. +} + + + diff --git a/arduino-0022-linux-x64/libraries/SD/examples/ReadWrite/ReadWrite.pde b/arduino-0022-linux-x64/libraries/SD/examples/ReadWrite/ReadWrite.pde new file mode 100644 index 0000000..9957218 --- /dev/null +++ b/arduino-0022-linux-x64/libraries/SD/examples/ReadWrite/ReadWrite.pde @@ -0,0 +1,79 @@ +/* + SD card read/write + + This example shows how to read and write data to and from an SD card file + The circuit: + * SD card attached to SPI bus as follows: + ** MOSI - pin 11 + ** MISO - pin 12 + ** CLK - pin 13 + ** CS - pin 4 + + created Nov 2010 + by David A. Mellis + updated 2 Dec 2010 + by Tom Igoe + + This example code is in the public domain. + + */ + +#include + +File myFile; + +void setup() +{ + Serial.begin(9600); + Serial.print("Initializing SD card..."); + // On the Ethernet Shield, CS is pin 4. It's set as an output by default. + // Note that even if it's not used as the CS pin, the hardware SS pin + // (10 on most Arduino boards, 53 on the Mega) must be left as an output + // or the SD library functions will not work. + pinMode(10, OUTPUT); + + if (!SD.begin(4)) { + Serial.println("initialization failed!"); + return; + } + Serial.println("initialization done."); + + // open the file. note that only one file can be open at a time, + // so you have to close this one before opening another. + myFile = SD.open("test.txt", FILE_WRITE); + + // if the file opened okay, write to it: + if (myFile) { + Serial.print("Writing to test.txt..."); + myFile.println("testing 1, 2, 3."); + // close the file: + myFile.close(); + Serial.println("done."); + } else { + // if the file didn't open, print an error: + Serial.println("error opening test.txt"); + } + + // re-open the file for reading: + myFile = SD.open("test.txt"); + if (myFile) { + Serial.println("test.txt:"); + + // read from the file until there's nothing else in it: + while (myFile.available()) { + Serial.write(myFile.read()); + } + // close the file: + myFile.close(); + } else { + // if the file didn't open, print an error: + Serial.println("error opening test.txt"); + } +} + +void loop() +{ + // nothing happens after setup +} + + diff --git a/arduino-0022-linux-x64/libraries/SD/keywords.txt b/arduino-0022-linux-x64/libraries/SD/keywords.txt new file mode 100644 index 0000000..419fe04 --- /dev/null +++ b/arduino-0022-linux-x64/libraries/SD/keywords.txt @@ -0,0 +1,30 @@ +####################################### +# Syntax Coloring Map SD +####################################### + +####################################### +# Datatypes (KEYWORD1) +####################################### + +SD KEYWORD1 +File KEYWORD1 + +####################################### +# Methods and Functions (KEYWORD2) +####################################### +begin KEYWORD2 +exists KEYWORD2 +mkdir KEYWORD2 +remove KEYWORD2 +rmdir KEYWORD2 +open KEYWORD2 +close KEYWORD2 +seek KEYWORD2 +position KEYWORD2 +size KEYWORD2 + +####################################### +# Constants (LITERAL1) +####################################### +FILE_READ LITERAL1 +FILE_WRITE LITERAL1 diff --git a/arduino-0022-linux-x64/libraries/SD/utility/FatStructs.h b/arduino-0022-linux-x64/libraries/SD/utility/FatStructs.h new file mode 100644 index 0000000..f5bdaa5 --- /dev/null +++ b/arduino-0022-linux-x64/libraries/SD/utility/FatStructs.h @@ -0,0 +1,418 @@ +/* Arduino SdFat Library + * Copyright (C) 2009 by William Greiman + * + * This file is part of the Arduino SdFat Library + * + * This Library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with the Arduino SdFat Library. If not, see + * . + */ +#ifndef FatStructs_h +#define FatStructs_h +/** + * \file + * FAT file structures + */ +/* + * mostly from Microsoft document fatgen103.doc + * http://www.microsoft.com/whdc/system/platform/firmware/fatgen.mspx + */ +//------------------------------------------------------------------------------ +/** Value for byte 510 of boot block or MBR */ +uint8_t const BOOTSIG0 = 0X55; +/** Value for byte 511 of boot block or MBR */ +uint8_t const BOOTSIG1 = 0XAA; +//------------------------------------------------------------------------------ +/** + * \struct partitionTable + * \brief MBR partition table entry + * + * A partition table entry for a MBR formatted storage device. + * The MBR partition table has four entries. + */ +struct partitionTable { + /** + * Boot Indicator . Indicates whether the volume is the active + * partition. Legal values include: 0X00. Do not use for booting. + * 0X80 Active partition. + */ + uint8_t boot; + /** + * Head part of Cylinder-head-sector address of the first block in + * the partition. Legal values are 0-255. Only used in old PC BIOS. + */ + uint8_t beginHead; + /** + * Sector part of Cylinder-head-sector address of the first block in + * the partition. Legal values are 1-63. Only used in old PC BIOS. + */ + unsigned beginSector : 6; + /** High bits cylinder for first block in partition. */ + unsigned beginCylinderHigh : 2; + /** + * Combine beginCylinderLow with beginCylinderHigh. Legal values + * are 0-1023. Only used in old PC BIOS. + */ + uint8_t beginCylinderLow; + /** + * Partition type. See defines that begin with PART_TYPE_ for + * some Microsoft partition types. + */ + uint8_t type; + /** + * head part of cylinder-head-sector address of the last sector in the + * partition. Legal values are 0-255. Only used in old PC BIOS. + */ + uint8_t endHead; + /** + * Sector part of cylinder-head-sector address of the last sector in + * the partition. Legal values are 1-63. Only used in old PC BIOS. + */ + unsigned endSector : 6; + /** High bits of end cylinder */ + unsigned endCylinderHigh : 2; + /** + * Combine endCylinderLow with endCylinderHigh. Legal values + * are 0-1023. Only used in old PC BIOS. + */ + uint8_t endCylinderLow; + /** Logical block address of the first block in the partition. */ + uint32_t firstSector; + /** Length of the partition, in blocks. */ + uint32_t totalSectors; +}; +/** Type name for partitionTable */ +typedef struct partitionTable part_t; +//------------------------------------------------------------------------------ +/** + * \struct masterBootRecord + * + * \brief Master Boot Record + * + * The first block of a storage device that is formatted with a MBR. + */ +struct masterBootRecord { + /** Code Area for master boot program. */ + uint8_t codeArea[440]; + /** Optional WindowsNT disk signature. May contain more boot code. */ + uint32_t diskSignature; + /** Usually zero but may be more boot code. */ + uint16_t usuallyZero; + /** Partition tables. */ + part_t part[4]; + /** First MBR signature byte. Must be 0X55 */ + uint8_t mbrSig0; + /** Second MBR signature byte. Must be 0XAA */ + uint8_t mbrSig1; +}; +/** Type name for masterBootRecord */ +typedef struct masterBootRecord mbr_t; +//------------------------------------------------------------------------------ +/** + * \struct biosParmBlock + * + * \brief BIOS parameter block + * + * The BIOS parameter block describes the physical layout of a FAT volume. + */ +struct biosParmBlock { + /** + * Count of bytes per sector. This value may take on only the + * following values: 512, 1024, 2048 or 4096 + */ + uint16_t bytesPerSector; + /** + * Number of sectors per allocation unit. This value must be a + * power of 2 that is greater than 0. The legal values are + * 1, 2, 4, 8, 16, 32, 64, and 128. + */ + uint8_t sectorsPerCluster; + /** + * Number of sectors before the first FAT. + * This value must not be zero. + */ + uint16_t reservedSectorCount; + /** The count of FAT data structures on the volume. This field should + * always contain the value 2 for any FAT volume of any type. + */ + uint8_t fatCount; + /** + * For FAT12 and FAT16 volumes, this field contains the count of + * 32-byte directory entries in the root directory. For FAT32 volumes, + * this field must be set to 0. For FAT12 and FAT16 volumes, this + * value should always specify a count that when multiplied by 32 + * results in a multiple of bytesPerSector. FAT16 volumes should + * use the value 512. + */ + uint16_t rootDirEntryCount; + /** + * This field is the old 16-bit total count of sectors on the volume. + * This count includes the count of all sectors in all four regions + * of the volume. This field can be 0; if it is 0, then totalSectors32 + * must be non-zero. For FAT32 volumes, this field must be 0. For + * FAT12 and FAT16 volumes, this field contains the sector count, and + * totalSectors32 is 0 if the total sector count fits + * (is less than 0x10000). + */ + uint16_t totalSectors16; + /** + * This dates back to the old MS-DOS 1.x media determination and is + * no longer usually used for anything. 0xF8 is the standard value + * for fixed (non-removable) media. For removable media, 0xF0 is + * frequently used. Legal values are 0xF0 or 0xF8-0xFF. + */ + uint8_t mediaType; + /** + * Count of sectors occupied by one FAT on FAT12/FAT16 volumes. + * On FAT32 volumes this field must be 0, and sectorsPerFat32 + * contains the FAT size count. + */ + uint16_t sectorsPerFat16; + /** Sectors per track for interrupt 0x13. Not used otherwise. */ + uint16_t sectorsPerTrtack; + /** Number of heads for interrupt 0x13. Not used otherwise. */ + uint16_t headCount; + /** + * Count of hidden sectors preceding the partition that contains this + * FAT volume. This field is generally only relevant for media + * visible on interrupt 0x13. + */ + uint32_t hidddenSectors; + /** + * This field is the new 32-bit total count of sectors on the volume. + * This count includes the count of all sectors in all four regions + * of the volume. This field can be 0; if it is 0, then + * totalSectors16 must be non-zero. + */ + uint32_t totalSectors32; + /** + * Count of sectors occupied by one FAT on FAT32 volumes. + */ + uint32_t sectorsPerFat32; + /** + * This field is only defined for FAT32 media and does not exist on + * FAT12 and FAT16 media. + * Bits 0-3 -- Zero-based number of active FAT. + * Only valid if mirroring is disabled. + * Bits 4-6 -- Reserved. + * Bit 7 -- 0 means the FAT is mirrored at runtime into all FATs. + * -- 1 means only one FAT is active; it is the one referenced in bits 0-3. + * Bits 8-15 -- Reserved. + */ + uint16_t fat32Flags; + /** + * FAT32 version. High byte is major revision number. + * Low byte is minor revision number. Only 0.0 define. + */ + uint16_t fat32Version; + /** + * Cluster number of the first cluster of the root directory for FAT32. + * This usually 2 but not required to be 2. + */ + uint32_t fat32RootCluster; + /** + * Sector number of FSINFO structure in the reserved area of the + * FAT32 volume. Usually 1. + */ + uint16_t fat32FSInfo; + /** + * If non-zero, indicates the sector number in the reserved area + * of the volume of a copy of the boot record. Usually 6. + * No value other than 6 is recommended. + */ + uint16_t fat32BackBootBlock; + /** + * Reserved for future expansion. Code that formats FAT32 volumes + * should always set all of the bytes of this field to 0. + */ + uint8_t fat32Reserved[12]; +}; +/** Type name for biosParmBlock */ +typedef struct biosParmBlock bpb_t; +//------------------------------------------------------------------------------ +/** + * \struct fat32BootSector + * + * \brief Boot sector for a FAT16 or FAT32 volume. + * + */ +struct fat32BootSector { + /** X86 jmp to boot program */ + uint8_t jmpToBootCode[3]; + /** informational only - don't depend on it */ + char oemName[8]; + /** BIOS Parameter Block */ + bpb_t bpb; + /** for int0x13 use value 0X80 for hard drive */ + uint8_t driveNumber; + /** used by Windows NT - should be zero for FAT */ + uint8_t reserved1; + /** 0X29 if next three fields are valid */ + uint8_t bootSignature; + /** usually generated by combining date and time */ + uint32_t volumeSerialNumber; + /** should match volume label in root dir */ + char volumeLabel[11]; + /** informational only - don't depend on it */ + char fileSystemType[8]; + /** X86 boot code */ + uint8_t bootCode[420]; + /** must be 0X55 */ + uint8_t bootSectorSig0; + /** must be 0XAA */ + uint8_t bootSectorSig1; +}; +//------------------------------------------------------------------------------ +// End Of Chain values for FAT entries +/** FAT16 end of chain value used by Microsoft. */ +uint16_t const FAT16EOC = 0XFFFF; +/** Minimum value for FAT16 EOC. Use to test for EOC. */ +uint16_t const FAT16EOC_MIN = 0XFFF8; +/** FAT32 end of chain value used by Microsoft. */ +uint32_t const FAT32EOC = 0X0FFFFFFF; +/** Minimum value for FAT32 EOC. Use to test for EOC. */ +uint32_t const FAT32EOC_MIN = 0X0FFFFFF8; +/** Mask a for FAT32 entry. Entries are 28 bits. */ +uint32_t const FAT32MASK = 0X0FFFFFFF; + +/** Type name for fat32BootSector */ +typedef struct fat32BootSector fbs_t; +//------------------------------------------------------------------------------ +/** + * \struct directoryEntry + * \brief FAT short directory entry + * + * Short means short 8.3 name, not the entry size. + * + * Date Format. A FAT directory entry date stamp is a 16-bit field that is + * basically a date relative to the MS-DOS epoch of 01/01/1980. Here is the + * format (bit 0 is the LSB of the 16-bit word, bit 15 is the MSB of the + * 16-bit word): + * + * Bits 9-15: Count of years from 1980, valid value range 0-127 + * inclusive (1980-2107). + * + * Bits 5-8: Month of year, 1 = January, valid value range 1-12 inclusive. + * + * Bits 0-4: Day of month, valid value range 1-31 inclusive. + * + * Time Format. A FAT directory entry time stamp is a 16-bit field that has + * a granularity of 2 seconds. Here is the format (bit 0 is the LSB of the + * 16-bit word, bit 15 is the MSB of the 16-bit word). + * + * Bits 11-15: Hours, valid value range 0-23 inclusive. + * + * Bits 5-10: Minutes, valid value range 0-59 inclusive. + * + * Bits 0-4: 2-second count, valid value range 0-29 inclusive (0 - 58 seconds). + * + * The valid time range is from Midnight 00:00:00 to 23:59:58. + */ +struct directoryEntry { + /** + * Short 8.3 name. + * The first eight bytes contain the file name with blank fill. + * The last three bytes contain the file extension with blank fill. + */ + uint8_t name[11]; + /** Entry attributes. + * + * The upper two bits of the attribute byte are reserved and should + * always be set to 0 when a file is created and never modified or + * looked at after that. See defines that begin with DIR_ATT_. + */ + uint8_t attributes; + /** + * Reserved for use by Windows NT. Set value to 0 when a file is + * created and never modify or look at it after that. + */ + uint8_t reservedNT; + /** + * The granularity of the seconds part of creationTime is 2 seconds + * so this field is a count of tenths of a second and its valid + * value range is 0-199 inclusive. (WHG note - seems to be hundredths) + */ + uint8_t creationTimeTenths; + /** Time file was created. */ + uint16_t creationTime; + /** Date file was created. */ + uint16_t creationDate; + /** + * Last access date. Note that there is no last access time, only + * a date. This is the date of last read or write. In the case of + * a write, this should be set to the same date as lastWriteDate. + */ + uint16_t lastAccessDate; + /** + * High word of this entry's first cluster number (always 0 for a + * FAT12 or FAT16 volume). + */ + uint16_t firstClusterHigh; + /** Time of last write. File creation is considered a write. */ + uint16_t lastWriteTime; + /** Date of last write. File creation is considered a write. */ + uint16_t lastWriteDate; + /** Low word of this entry's first cluster number. */ + uint16_t firstClusterLow; + /** 32-bit unsigned holding this file's size in bytes. */ + uint32_t fileSize; +}; +//------------------------------------------------------------------------------ +// Definitions for directory entries +// +/** Type name for directoryEntry */ +typedef struct directoryEntry dir_t; +/** escape for name[0] = 0XE5 */ +uint8_t const DIR_NAME_0XE5 = 0X05; +/** name[0] value for entry that is free after being "deleted" */ +uint8_t const DIR_NAME_DELETED = 0XE5; +/** name[0] value for entry that is free and no allocated entries follow */ +uint8_t const DIR_NAME_FREE = 0X00; +/** file is read-only */ +uint8_t const DIR_ATT_READ_ONLY = 0X01; +/** File should hidden in directory listings */ +uint8_t const DIR_ATT_HIDDEN = 0X02; +/** Entry is for a system file */ +uint8_t const DIR_ATT_SYSTEM = 0X04; +/** Directory entry contains the volume label */ +uint8_t const DIR_ATT_VOLUME_ID = 0X08; +/** Entry is for a directory */ +uint8_t const DIR_ATT_DIRECTORY = 0X10; +/** Old DOS archive bit for backup support */ +uint8_t const DIR_ATT_ARCHIVE = 0X20; +/** Test value for long name entry. Test is + (d->attributes & DIR_ATT_LONG_NAME_MASK) == DIR_ATT_LONG_NAME. */ +uint8_t const DIR_ATT_LONG_NAME = 0X0F; +/** Test mask for long name entry */ +uint8_t const DIR_ATT_LONG_NAME_MASK = 0X3F; +/** defined attribute bits */ +uint8_t const DIR_ATT_DEFINED_BITS = 0X3F; +/** Directory entry is part of a long name */ +static inline uint8_t DIR_IS_LONG_NAME(const dir_t* dir) { + return (dir->attributes & DIR_ATT_LONG_NAME_MASK) == DIR_ATT_LONG_NAME; +} +/** Mask for file/subdirectory tests */ +uint8_t const DIR_ATT_FILE_TYPE_MASK = (DIR_ATT_VOLUME_ID | DIR_ATT_DIRECTORY); +/** Directory entry is for a file */ +static inline uint8_t DIR_IS_FILE(const dir_t* dir) { + return (dir->attributes & DIR_ATT_FILE_TYPE_MASK) == 0; +} +/** Directory entry is for a subdirectory */ +static inline uint8_t DIR_IS_SUBDIR(const dir_t* dir) { + return (dir->attributes & DIR_ATT_FILE_TYPE_MASK) == DIR_ATT_DIRECTORY; +} +/** Directory entry is for a file or subdirectory */ +static inline uint8_t DIR_IS_FILE_OR_SUBDIR(const dir_t* dir) { + return (dir->attributes & DIR_ATT_VOLUME_ID) == 0; +} +#endif // FatStructs_h diff --git a/arduino-0022-linux-x64/libraries/SD/utility/Sd2Card.cpp b/arduino-0022-linux-x64/libraries/SD/utility/Sd2Card.cpp new file mode 100644 index 0000000..26c4236 --- /dev/null +++ b/arduino-0022-linux-x64/libraries/SD/utility/Sd2Card.cpp @@ -0,0 +1,644 @@ +/* Arduino Sd2Card Library + * Copyright (C) 2009 by William Greiman + * + * This file is part of the Arduino Sd2Card Library + * + * This Library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with the Arduino Sd2Card Library. If not, see + * . + */ +#include +#include "Sd2Card.h" +//------------------------------------------------------------------------------ +#ifndef SOFTWARE_SPI +// functions for hardware SPI +/** Send a byte to the card */ +static void spiSend(uint8_t b) { + SPDR = b; + while (!(SPSR & (1 << SPIF))); +} +/** Receive a byte from the card */ +static uint8_t spiRec(void) { + spiSend(0XFF); + return SPDR; +} +#else // SOFTWARE_SPI +//------------------------------------------------------------------------------ +/** nop to tune soft SPI timing */ +#define nop asm volatile ("nop\n\t") +//------------------------------------------------------------------------------ +/** Soft SPI receive */ +uint8_t spiRec(void) { + uint8_t data = 0; + // no interrupts during byte receive - about 8 us + cli(); + // output pin high - like sending 0XFF + fastDigitalWrite(SPI_MOSI_PIN, HIGH); + + for (uint8_t i = 0; i < 8; i++) { + fastDigitalWrite(SPI_SCK_PIN, HIGH); + + // adjust so SCK is nice + nop; + nop; + + data <<= 1; + + if (fastDigitalRead(SPI_MISO_PIN)) data |= 1; + + fastDigitalWrite(SPI_SCK_PIN, LOW); + } + // enable interrupts + sei(); + return data; +} +//------------------------------------------------------------------------------ +/** Soft SPI send */ +void spiSend(uint8_t data) { + // no interrupts during byte send - about 8 us + cli(); + for (uint8_t i = 0; i < 8; i++) { + fastDigitalWrite(SPI_SCK_PIN, LOW); + + fastDigitalWrite(SPI_MOSI_PIN, data & 0X80); + + data <<= 1; + + fastDigitalWrite(SPI_SCK_PIN, HIGH); + } + // hold SCK high for a few ns + nop; + nop; + nop; + nop; + + fastDigitalWrite(SPI_SCK_PIN, LOW); + // enable interrupts + sei(); +} +#endif // SOFTWARE_SPI +//------------------------------------------------------------------------------ +// send command and return error code. Return zero for OK +uint8_t Sd2Card::cardCommand(uint8_t cmd, uint32_t arg) { + // end read if in partialBlockRead mode + readEnd(); + + // select card + chipSelectLow(); + + // wait up to 300 ms if busy + waitNotBusy(300); + + // send command + spiSend(cmd | 0x40); + + // send argument + for (int8_t s = 24; s >= 0; s -= 8) spiSend(arg >> s); + + // send CRC + uint8_t crc = 0XFF; + if (cmd == CMD0) crc = 0X95; // correct crc for CMD0 with arg 0 + if (cmd == CMD8) crc = 0X87; // correct crc for CMD8 with arg 0X1AA + spiSend(crc); + + // wait for response + for (uint8_t i = 0; ((status_ = spiRec()) & 0X80) && i != 0XFF; i++); + return status_; +} +//------------------------------------------------------------------------------ +/** + * Determine the size of an SD flash memory card. + * + * \return The number of 512 byte data blocks in the card + * or zero if an error occurs. + */ +uint32_t Sd2Card::cardSize(void) { + csd_t csd; + if (!readCSD(&csd)) return 0; + if (csd.v1.csd_ver == 0) { + uint8_t read_bl_len = csd.v1.read_bl_len; + uint16_t c_size = (csd.v1.c_size_high << 10) + | (csd.v1.c_size_mid << 2) | csd.v1.c_size_low; + uint8_t c_size_mult = (csd.v1.c_size_mult_high << 1) + | csd.v1.c_size_mult_low; + return (uint32_t)(c_size + 1) << (c_size_mult + read_bl_len - 7); + } else if (csd.v2.csd_ver == 1) { + uint32_t c_size = ((uint32_t)csd.v2.c_size_high << 16) + | (csd.v2.c_size_mid << 8) | csd.v2.c_size_low; + return (c_size + 1) << 10; + } else { + error(SD_CARD_ERROR_BAD_CSD); + return 0; + } +} +//------------------------------------------------------------------------------ +void Sd2Card::chipSelectHigh(void) { + digitalWrite(chipSelectPin_, HIGH); +} +//------------------------------------------------------------------------------ +void Sd2Card::chipSelectLow(void) { + digitalWrite(chipSelectPin_, LOW); +} +//------------------------------------------------------------------------------ +/** Erase a range of blocks. + * + * \param[in] firstBlock The address of the first block in the range. + * \param[in] lastBlock The address of the last block in the range. + * + * \note This function requests the SD card to do a flash erase for a + * range of blocks. The data on the card after an erase operation is + * either 0 or 1, depends on the card vendor. The card must support + * single block erase. + * + * \return The value one, true, is returned for success and + * the value zero, false, is returned for failure. + */ +uint8_t Sd2Card::erase(uint32_t firstBlock, uint32_t lastBlock) { + if (!eraseSingleBlockEnable()) { + error(SD_CARD_ERROR_ERASE_SINGLE_BLOCK); + goto fail; + } + if (type_ != SD_CARD_TYPE_SDHC) { + firstBlock <<= 9; + lastBlock <<= 9; + } + if (cardCommand(CMD32, firstBlock) + || cardCommand(CMD33, lastBlock) + || cardCommand(CMD38, 0)) { + error(SD_CARD_ERROR_ERASE); + goto fail; + } + if (!waitNotBusy(SD_ERASE_TIMEOUT)) { + error(SD_CARD_ERROR_ERASE_TIMEOUT); + goto fail; + } + chipSelectHigh(); + return true; + + fail: + chipSelectHigh(); + return false; +} +//------------------------------------------------------------------------------ +/** Determine if card supports single block erase. + * + * \return The value one, true, is returned if single block erase is supported. + * The value zero, false, is returned if single block erase is not supported. + */ +uint8_t Sd2Card::eraseSingleBlockEnable(void) { + csd_t csd; + return readCSD(&csd) ? csd.v1.erase_blk_en : 0; +} +//------------------------------------------------------------------------------ +/** + * Initialize an SD flash memory card. + * + * \param[in] sckRateID SPI clock rate selector. See setSckRate(). + * \param[in] chipSelectPin SD chip select pin number. + * + * \return The value one, true, is returned for success and + * the value zero, false, is returned for failure. The reason for failure + * can be determined by calling errorCode() and errorData(). + */ +uint8_t Sd2Card::init(uint8_t sckRateID, uint8_t chipSelectPin) { + errorCode_ = inBlock_ = partialBlockRead_ = type_ = 0; + chipSelectPin_ = chipSelectPin; + // 16-bit init start time allows over a minute + uint16_t t0 = (uint16_t)millis(); + uint32_t arg; + + // set pin modes + pinMode(chipSelectPin_, OUTPUT); + chipSelectHigh(); + pinMode(SPI_MISO_PIN, INPUT); + pinMode(SPI_MOSI_PIN, OUTPUT); + pinMode(SPI_SCK_PIN, OUTPUT); + +#ifndef SOFTWARE_SPI + // SS must be in output mode even it is not chip select + pinMode(SS_PIN, OUTPUT); + digitalWrite(SS_PIN, HIGH); // disable any SPI device using hardware SS pin + // Enable SPI, Master, clock rate f_osc/128 + SPCR = (1 << SPE) | (1 << MSTR) | (1 << SPR1) | (1 << SPR0); + // clear double speed + SPSR &= ~(1 << SPI2X); +#endif // SOFTWARE_SPI + + // must supply min of 74 clock cycles with CS high. + for (uint8_t i = 0; i < 10; i++) spiSend(0XFF); + + chipSelectLow(); + + // command to go idle in SPI mode + while ((status_ = cardCommand(CMD0, 0)) != R1_IDLE_STATE) { + if (((uint16_t)millis() - t0) > SD_INIT_TIMEOUT) { + error(SD_CARD_ERROR_CMD0); + goto fail; + } + } + // check SD version + if ((cardCommand(CMD8, 0x1AA) & R1_ILLEGAL_COMMAND)) { + type(SD_CARD_TYPE_SD1); + } else { + // only need last byte of r7 response + for (uint8_t i = 0; i < 4; i++) status_ = spiRec(); + if (status_ != 0XAA) { + error(SD_CARD_ERROR_CMD8); + goto fail; + } + type(SD_CARD_TYPE_SD2); + } + // initialize card and send host supports SDHC if SD2 + arg = type() == SD_CARD_TYPE_SD2 ? 0X40000000 : 0; + + while ((status_ = cardAcmd(ACMD41, arg)) != R1_READY_STATE) { + // check for timeout + if (((uint16_t)millis() - t0) > SD_INIT_TIMEOUT) { + error(SD_CARD_ERROR_ACMD41); + goto fail; + } + } + // if SD2 read OCR register to check for SDHC card + if (type() == SD_CARD_TYPE_SD2) { + if (cardCommand(CMD58, 0)) { + error(SD_CARD_ERROR_CMD58); + goto fail; + } + if ((spiRec() & 0XC0) == 0XC0) type(SD_CARD_TYPE_SDHC); + // discard rest of ocr - contains allowed voltage range + for (uint8_t i = 0; i < 3; i++) spiRec(); + } + chipSelectHigh(); + +#ifndef SOFTWARE_SPI + return setSckRate(sckRateID); +#else // SOFTWARE_SPI + return true; +#endif // SOFTWARE_SPI + + fail: + chipSelectHigh(); + return false; +} +//------------------------------------------------------------------------------ +/** + * Enable or disable partial block reads. + * + * Enabling partial block reads improves performance by allowing a block + * to be read over the SPI bus as several sub-blocks. Errors may occur + * if the time between reads is too long since the SD card may timeout. + * The SPI SS line will be held low until the entire block is read or + * readEnd() is called. + * + * Use this for applications like the Adafruit Wave Shield. + * + * \param[in] value The value TRUE (non-zero) or FALSE (zero).) + */ +void Sd2Card::partialBlockRead(uint8_t value) { + readEnd(); + partialBlockRead_ = value; +} +//------------------------------------------------------------------------------ +/** + * Read a 512 byte block from an SD card device. + * + * \param[in] block Logical block to be read. + * \param[out] dst Pointer to the location that will receive the data. + + * \return The value one, true, is returned for success and + * the value zero, false, is returned for failure. + */ +uint8_t Sd2Card::readBlock(uint32_t block, uint8_t* dst) { + return readData(block, 0, 512, dst); +} +//------------------------------------------------------------------------------ +/** + * Read part of a 512 byte block from an SD card. + * + * \param[in] block Logical block to be read. + * \param[in] offset Number of bytes to skip at start of block + * \param[out] dst Pointer to the location that will receive the data. + * \param[in] count Number of bytes to read + * \return The value one, true, is returned for success and + * the value zero, false, is returned for failure. + */ +uint8_t Sd2Card::readData(uint32_t block, + uint16_t offset, uint16_t count, uint8_t* dst) { + uint16_t n; + if (count == 0) return true; + if ((count + offset) > 512) { + goto fail; + } + if (!inBlock_ || block != block_ || offset < offset_) { + block_ = block; + // use address if not SDHC card + if (type()!= SD_CARD_TYPE_SDHC) block <<= 9; + if (cardCommand(CMD17, block)) { + error(SD_CARD_ERROR_CMD17); + goto fail; + } + if (!waitStartBlock()) { + goto fail; + } + offset_ = 0; + inBlock_ = 1; + } + +#ifdef OPTIMIZE_HARDWARE_SPI + // start first spi transfer + SPDR = 0XFF; + + // skip data before offset + for (;offset_ < offset; offset_++) { + while (!(SPSR & (1 << SPIF))); + SPDR = 0XFF; + } + // transfer data + n = count - 1; + for (uint16_t i = 0; i < n; i++) { + while (!(SPSR & (1 << SPIF))); + dst[i] = SPDR; + SPDR = 0XFF; + } + // wait for last byte + while (!(SPSR & (1 << SPIF))); + dst[n] = SPDR; + +#else // OPTIMIZE_HARDWARE_SPI + + // skip data before offset + for (;offset_ < offset; offset_++) { + spiRec(); + } + // transfer data + for (uint16_t i = 0; i < count; i++) { + dst[i] = spiRec(); + } +#endif // OPTIMIZE_HARDWARE_SPI + + offset_ += count; + if (!partialBlockRead_ || offset_ >= 512) { + // read rest of data, checksum and set chip select high + readEnd(); + } + return true; + + fail: + chipSelectHigh(); + return false; +} +//------------------------------------------------------------------------------ +/** Skip remaining data in a block when in partial block read mode. */ +void Sd2Card::readEnd(void) { + if (inBlock_) { + // skip data and crc +#ifdef OPTIMIZE_HARDWARE_SPI + // optimize skip for hardware + SPDR = 0XFF; + while (offset_++ < 513) { + while (!(SPSR & (1 << SPIF))); + SPDR = 0XFF; + } + // wait for last crc byte + while (!(SPSR & (1 << SPIF))); +#else // OPTIMIZE_HARDWARE_SPI + while (offset_++ < 514) spiRec(); +#endif // OPTIMIZE_HARDWARE_SPI + chipSelectHigh(); + inBlock_ = 0; + } +} +//------------------------------------------------------------------------------ +/** read CID or CSR register */ +uint8_t Sd2Card::readRegister(uint8_t cmd, void* buf) { + uint8_t* dst = reinterpret_cast(buf); + if (cardCommand(cmd, 0)) { + error(SD_CARD_ERROR_READ_REG); + goto fail; + } + if (!waitStartBlock()) goto fail; + // transfer data + for (uint16_t i = 0; i < 16; i++) dst[i] = spiRec(); + spiRec(); // get first crc byte + spiRec(); // get second crc byte + chipSelectHigh(); + return true; + + fail: + chipSelectHigh(); + return false; +} +//------------------------------------------------------------------------------ +/** + * Set the SPI clock rate. + * + * \param[in] sckRateID A value in the range [0, 6]. + * + * The SPI clock will be set to F_CPU/pow(2, 1 + sckRateID). The maximum + * SPI rate is F_CPU/2 for \a sckRateID = 0 and the minimum rate is F_CPU/128 + * for \a scsRateID = 6. + * + * \return The value one, true, is returned for success and the value zero, + * false, is returned for an invalid value of \a sckRateID. + */ +uint8_t Sd2Card::setSckRate(uint8_t sckRateID) { + if (sckRateID > 6) { + error(SD_CARD_ERROR_SCK_RATE); + return false; + } + // see avr processor datasheet for SPI register bit definitions + if ((sckRateID & 1) || sckRateID == 6) { + SPSR &= ~(1 << SPI2X); + } else { + SPSR |= (1 << SPI2X); + } + SPCR &= ~((1 < SD_READ_TIMEOUT) { + error(SD_CARD_ERROR_READ_TIMEOUT); + goto fail; + } + } + if (status_ != DATA_START_BLOCK) { + error(SD_CARD_ERROR_READ); + goto fail; + } + return true; + + fail: + chipSelectHigh(); + return false; +} +//------------------------------------------------------------------------------ +/** + * Writes a 512 byte block to an SD card. + * + * \param[in] blockNumber Logical block to be written. + * \param[in] src Pointer to the location of the data to be written. + * \return The value one, true, is returned for success and + * the value zero, false, is returned for failure. + */ +uint8_t Sd2Card::writeBlock(uint32_t blockNumber, const uint8_t* src) { +#if SD_PROTECT_BLOCK_ZERO + // don't allow write to first block + if (blockNumber == 0) { + error(SD_CARD_ERROR_WRITE_BLOCK_ZERO); + goto fail; + } +#endif // SD_PROTECT_BLOCK_ZERO + + // use address if not SDHC card + if (type() != SD_CARD_TYPE_SDHC) blockNumber <<= 9; + if (cardCommand(CMD24, blockNumber)) { + error(SD_CARD_ERROR_CMD24); + goto fail; + } + if (!writeData(DATA_START_BLOCK, src)) goto fail; + + // wait for flash programming to complete + if (!waitNotBusy(SD_WRITE_TIMEOUT)) { + error(SD_CARD_ERROR_WRITE_TIMEOUT); + goto fail; + } + // response is r2 so get and check two bytes for nonzero + if (cardCommand(CMD13, 0) || spiRec()) { + error(SD_CARD_ERROR_WRITE_PROGRAMMING); + goto fail; + } + chipSelectHigh(); + return true; + + fail: + chipSelectHigh(); + return false; +} +//------------------------------------------------------------------------------ +/** Write one data block in a multiple block write sequence */ +uint8_t Sd2Card::writeData(const uint8_t* src) { + // wait for previous write to finish + if (!waitNotBusy(SD_WRITE_TIMEOUT)) { + error(SD_CARD_ERROR_WRITE_MULTIPLE); + chipSelectHigh(); + return false; + } + return writeData(WRITE_MULTIPLE_TOKEN, src); +} +//------------------------------------------------------------------------------ +// send one block of data for write block or write multiple blocks +uint8_t Sd2Card::writeData(uint8_t token, const uint8_t* src) { +#ifdef OPTIMIZE_HARDWARE_SPI + + // send data - optimized loop + SPDR = token; + + // send two byte per iteration + for (uint16_t i = 0; i < 512; i += 2) { + while (!(SPSR & (1 << SPIF))); + SPDR = src[i]; + while (!(SPSR & (1 << SPIF))); + SPDR = src[i+1]; + } + + // wait for last data byte + while (!(SPSR & (1 << SPIF))); + +#else // OPTIMIZE_HARDWARE_SPI + spiSend(token); + for (uint16_t i = 0; i < 512; i++) { + spiSend(src[i]); + } +#endif // OPTIMIZE_HARDWARE_SPI + spiSend(0xff); // dummy crc + spiSend(0xff); // dummy crc + + status_ = spiRec(); + if ((status_ & DATA_RES_MASK) != DATA_RES_ACCEPTED) { + error(SD_CARD_ERROR_WRITE); + chipSelectHigh(); + return false; + } + return true; +} +//------------------------------------------------------------------------------ +/** Start a write multiple blocks sequence. + * + * \param[in] blockNumber Address of first block in sequence. + * \param[in] eraseCount The number of blocks to be pre-erased. + * + * \note This function is used with writeData() and writeStop() + * for optimized multiple block writes. + * + * \return The value one, true, is returned for success and + * the value zero, false, is returned for failure. + */ +uint8_t Sd2Card::writeStart(uint32_t blockNumber, uint32_t eraseCount) { +#if SD_PROTECT_BLOCK_ZERO + // don't allow write to first block + if (blockNumber == 0) { + error(SD_CARD_ERROR_WRITE_BLOCK_ZERO); + goto fail; + } +#endif // SD_PROTECT_BLOCK_ZERO + // send pre-erase count + if (cardAcmd(ACMD23, eraseCount)) { + error(SD_CARD_ERROR_ACMD23); + goto fail; + } + // use address if not SDHC card + if (type() != SD_CARD_TYPE_SDHC) blockNumber <<= 9; + if (cardCommand(CMD25, blockNumber)) { + error(SD_CARD_ERROR_CMD25); + goto fail; + } + return true; + + fail: + chipSelectHigh(); + return false; +} +//------------------------------------------------------------------------------ +/** End a write multiple blocks sequence. + * +* \return The value one, true, is returned for success and + * the value zero, false, is returned for failure. + */ +uint8_t Sd2Card::writeStop(void) { + if (!waitNotBusy(SD_WRITE_TIMEOUT)) goto fail; + spiSend(STOP_TRAN_TOKEN); + if (!waitNotBusy(SD_WRITE_TIMEOUT)) goto fail; + chipSelectHigh(); + return true; + + fail: + error(SD_CARD_ERROR_STOP_TRAN); + chipSelectHigh(); + return false; +} diff --git a/arduino-0022-linux-x64/libraries/SD/utility/Sd2Card.h b/arduino-0022-linux-x64/libraries/SD/utility/Sd2Card.h new file mode 100644 index 0000000..73b46fb --- /dev/null +++ b/arduino-0022-linux-x64/libraries/SD/utility/Sd2Card.h @@ -0,0 +1,233 @@ +/* Arduino Sd2Card Library + * Copyright (C) 2009 by William Greiman + * + * This file is part of the Arduino Sd2Card Library + * + * This Library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with the Arduino Sd2Card Library. If not, see + * . + */ +#ifndef Sd2Card_h +#define Sd2Card_h +/** + * \file + * Sd2Card class + */ +#include "Sd2PinMap.h" +#include "SdInfo.h" +/** Set SCK to max rate of F_CPU/2. See Sd2Card::setSckRate(). */ +uint8_t const SPI_FULL_SPEED = 0; +/** Set SCK rate to F_CPU/4. See Sd2Card::setSckRate(). */ +uint8_t const SPI_HALF_SPEED = 1; +/** Set SCK rate to F_CPU/8. Sd2Card::setSckRate(). */ +uint8_t const SPI_QUARTER_SPEED = 2; +/** + * Define MEGA_SOFT_SPI non-zero to use software SPI on Mega Arduinos. + * Pins used are SS 10, MOSI 11, MISO 12, and SCK 13. + * + * MEGA_SOFT_SPI allows an unmodified Adafruit GPS Shield to be used + * on Mega Arduinos. Software SPI works well with GPS Shield V1.1 + * but many SD cards will fail with GPS Shield V1.0. + */ +#define MEGA_SOFT_SPI 0 +//------------------------------------------------------------------------------ +#if MEGA_SOFT_SPI && (defined(__AVR_ATmega1280__)||defined(__AVR_ATmega2560__)) +#define SOFTWARE_SPI +#endif // MEGA_SOFT_SPI +//------------------------------------------------------------------------------ +// SPI pin definitions +// +#ifndef SOFTWARE_SPI +// hardware pin defs +/** + * SD Chip Select pin + * + * Warning if this pin is redefined the hardware SS will pin will be enabled + * as an output by init(). An avr processor will not function as an SPI + * master unless SS is set to output mode. + */ +/** The default chip select pin for the SD card is SS. */ +uint8_t const SD_CHIP_SELECT_PIN = SS_PIN; +// The following three pins must not be redefined for hardware SPI. +/** SPI Master Out Slave In pin */ +uint8_t const SPI_MOSI_PIN = MOSI_PIN; +/** SPI Master In Slave Out pin */ +uint8_t const SPI_MISO_PIN = MISO_PIN; +/** SPI Clock pin */ +uint8_t const SPI_SCK_PIN = SCK_PIN; +/** optimize loops for hardware SPI */ +#define OPTIMIZE_HARDWARE_SPI + +#else // SOFTWARE_SPI +// define software SPI pins so Mega can use unmodified GPS Shield +/** SPI chip select pin */ +uint8_t const SD_CHIP_SELECT_PIN = 10; +/** SPI Master Out Slave In pin */ +uint8_t const SPI_MOSI_PIN = 11; +/** SPI Master In Slave Out pin */ +uint8_t const SPI_MISO_PIN = 12; +/** SPI Clock pin */ +uint8_t const SPI_SCK_PIN = 13; +#endif // SOFTWARE_SPI +//------------------------------------------------------------------------------ +/** Protect block zero from write if nonzero */ +#define SD_PROTECT_BLOCK_ZERO 1 +/** init timeout ms */ +uint16_t const SD_INIT_TIMEOUT = 2000; +/** erase timeout ms */ +uint16_t const SD_ERASE_TIMEOUT = 10000; +/** read timeout ms */ +uint16_t const SD_READ_TIMEOUT = 300; +/** write time out ms */ +uint16_t const SD_WRITE_TIMEOUT = 600; +//------------------------------------------------------------------------------ +// SD card errors +/** timeout error for command CMD0 */ +uint8_t const SD_CARD_ERROR_CMD0 = 0X1; +/** CMD8 was not accepted - not a valid SD card*/ +uint8_t const SD_CARD_ERROR_CMD8 = 0X2; +/** card returned an error response for CMD17 (read block) */ +uint8_t const SD_CARD_ERROR_CMD17 = 0X3; +/** card returned an error response for CMD24 (write block) */ +uint8_t const SD_CARD_ERROR_CMD24 = 0X4; +/** WRITE_MULTIPLE_BLOCKS command failed */ +uint8_t const SD_CARD_ERROR_CMD25 = 0X05; +/** card returned an error response for CMD58 (read OCR) */ +uint8_t const SD_CARD_ERROR_CMD58 = 0X06; +/** SET_WR_BLK_ERASE_COUNT failed */ +uint8_t const SD_CARD_ERROR_ACMD23 = 0X07; +/** card's ACMD41 initialization process timeout */ +uint8_t const SD_CARD_ERROR_ACMD41 = 0X08; +/** card returned a bad CSR version field */ +uint8_t const SD_CARD_ERROR_BAD_CSD = 0X09; +/** erase block group command failed */ +uint8_t const SD_CARD_ERROR_ERASE = 0X0A; +/** card not capable of single block erase */ +uint8_t const SD_CARD_ERROR_ERASE_SINGLE_BLOCK = 0X0B; +/** Erase sequence timed out */ +uint8_t const SD_CARD_ERROR_ERASE_TIMEOUT = 0X0C; +/** card returned an error token instead of read data */ +uint8_t const SD_CARD_ERROR_READ = 0X0D; +/** read CID or CSD failed */ +uint8_t const SD_CARD_ERROR_READ_REG = 0X0E; +/** timeout while waiting for start of read data */ +uint8_t const SD_CARD_ERROR_READ_TIMEOUT = 0X0F; +/** card did not accept STOP_TRAN_TOKEN */ +uint8_t const SD_CARD_ERROR_STOP_TRAN = 0X10; +/** card returned an error token as a response to a write operation */ +uint8_t const SD_CARD_ERROR_WRITE = 0X11; +/** attempt to write protected block zero */ +uint8_t const SD_CARD_ERROR_WRITE_BLOCK_ZERO = 0X12; +/** card did not go ready for a multiple block write */ +uint8_t const SD_CARD_ERROR_WRITE_MULTIPLE = 0X13; +/** card returned an error to a CMD13 status check after a write */ +uint8_t const SD_CARD_ERROR_WRITE_PROGRAMMING = 0X14; +/** timeout occurred during write programming */ +uint8_t const SD_CARD_ERROR_WRITE_TIMEOUT = 0X15; +/** incorrect rate selected */ +uint8_t const SD_CARD_ERROR_SCK_RATE = 0X16; +//------------------------------------------------------------------------------ +// card types +/** Standard capacity V1 SD card */ +uint8_t const SD_CARD_TYPE_SD1 = 1; +/** Standard capacity V2 SD card */ +uint8_t const SD_CARD_TYPE_SD2 = 2; +/** High Capacity SD card */ +uint8_t const SD_CARD_TYPE_SDHC = 3; +//------------------------------------------------------------------------------ +/** + * \class Sd2Card + * \brief Raw access to SD and SDHC flash memory cards. + */ +class Sd2Card { + public: + /** Construct an instance of Sd2Card. */ + Sd2Card(void) : errorCode_(0), inBlock_(0), partialBlockRead_(0), type_(0) {} + uint32_t cardSize(void); + uint8_t erase(uint32_t firstBlock, uint32_t lastBlock); + uint8_t eraseSingleBlockEnable(void); + /** + * \return error code for last error. See Sd2Card.h for a list of error codes. + */ + uint8_t errorCode(void) const {return errorCode_;} + /** \return error data for last error. */ + uint8_t errorData(void) const {return status_;} + /** + * Initialize an SD flash memory card with default clock rate and chip + * select pin. See sd2Card::init(uint8_t sckRateID, uint8_t chipSelectPin). + */ + uint8_t init(void) { + return init(SPI_FULL_SPEED, SD_CHIP_SELECT_PIN); + } + /** + * Initialize an SD flash memory card with the selected SPI clock rate + * and the default SD chip select pin. + * See sd2Card::init(uint8_t sckRateID, uint8_t chipSelectPin). + */ + uint8_t init(uint8_t sckRateID) { + return init(sckRateID, SD_CHIP_SELECT_PIN); + } + uint8_t init(uint8_t sckRateID, uint8_t chipSelectPin); + void partialBlockRead(uint8_t value); + /** Returns the current value, true or false, for partial block read. */ + uint8_t partialBlockRead(void) const {return partialBlockRead_;} + uint8_t readBlock(uint32_t block, uint8_t* dst); + uint8_t readData(uint32_t block, + uint16_t offset, uint16_t count, uint8_t* dst); + /** + * Read a cards CID register. The CID contains card identification + * information such as Manufacturer ID, Product name, Product serial + * number and Manufacturing date. */ + uint8_t readCID(cid_t* cid) { + return readRegister(CMD10, cid); + } + /** + * Read a cards CSD register. The CSD contains Card-Specific Data that + * provides information regarding access to the card's contents. */ + uint8_t readCSD(csd_t* csd) { + return readRegister(CMD9, csd); + } + void readEnd(void); + uint8_t setSckRate(uint8_t sckRateID); + /** Return the card type: SD V1, SD V2 or SDHC */ + uint8_t type(void) const {return type_;} + uint8_t writeBlock(uint32_t blockNumber, const uint8_t* src); + uint8_t writeData(const uint8_t* src); + uint8_t writeStart(uint32_t blockNumber, uint32_t eraseCount); + uint8_t writeStop(void); + private: + uint32_t block_; + uint8_t chipSelectPin_; + uint8_t errorCode_; + uint8_t inBlock_; + uint16_t offset_; + uint8_t partialBlockRead_; + uint8_t status_; + uint8_t type_; + // private functions + uint8_t cardAcmd(uint8_t cmd, uint32_t arg) { + cardCommand(CMD55, 0); + return cardCommand(cmd, arg); + } + uint8_t cardCommand(uint8_t cmd, uint32_t arg); + void error(uint8_t code) {errorCode_ = code;} + uint8_t readRegister(uint8_t cmd, void* buf); + uint8_t sendWriteCommand(uint32_t blockNumber, uint32_t eraseCount); + void chipSelectHigh(void); + void chipSelectLow(void); + void type(uint8_t value) {type_ = value;} + uint8_t waitNotBusy(uint16_t timeoutMillis); + uint8_t writeData(uint8_t token, const uint8_t* src); + uint8_t waitStartBlock(void); +}; +#endif // Sd2Card_h diff --git a/arduino-0022-linux-x64/libraries/SD/utility/Sd2PinMap.h b/arduino-0022-linux-x64/libraries/SD/utility/Sd2PinMap.h new file mode 100644 index 0000000..4bd75a3 --- /dev/null +++ b/arduino-0022-linux-x64/libraries/SD/utility/Sd2PinMap.h @@ -0,0 +1,353 @@ +/* Arduino SdFat Library + * Copyright (C) 2010 by William Greiman + * + * This file is part of the Arduino SdFat Library + * + * This Library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with the Arduino SdFat Library. If not, see + * . + */ +// Warning this file was generated by a program. +#ifndef Sd2PinMap_h +#define Sd2PinMap_h +#include + +//------------------------------------------------------------------------------ +/** struct for mapping digital pins */ +struct pin_map_t { + volatile uint8_t* ddr; + volatile uint8_t* pin; + volatile uint8_t* port; + uint8_t bit; +}; +//------------------------------------------------------------------------------ +#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) +// Mega + +// Two Wire (aka I2C) ports +uint8_t const SDA_PIN = 20; +uint8_t const SCL_PIN = 21; + +// SPI port +uint8_t const SS_PIN = 53; +uint8_t const MOSI_PIN = 51; +uint8_t const MISO_PIN = 50; +uint8_t const SCK_PIN = 52; + +static const pin_map_t digitalPinMap[] = { + {&DDRE, &PINE, &PORTE, 0}, // E0 0 + {&DDRE, &PINE, &PORTE, 1}, // E1 1 + {&DDRE, &PINE, &PORTE, 4}, // E4 2 + {&DDRE, &PINE, &PORTE, 5}, // E5 3 + {&DDRG, &PING, &PORTG, 5}, // G5 4 + {&DDRE, &PINE, &PORTE, 3}, // E3 5 + {&DDRH, &PINH, &PORTH, 3}, // H3 6 + {&DDRH, &PINH, &PORTH, 4}, // H4 7 + {&DDRH, &PINH, &PORTH, 5}, // H5 8 + {&DDRH, &PINH, &PORTH, 6}, // H6 9 + {&DDRB, &PINB, &PORTB, 4}, // B4 10 + {&DDRB, &PINB, &PORTB, 5}, // B5 11 + {&DDRB, &PINB, &PORTB, 6}, // B6 12 + {&DDRB, &PINB, &PORTB, 7}, // B7 13 + {&DDRJ, &PINJ, &PORTJ, 1}, // J1 14 + {&DDRJ, &PINJ, &PORTJ, 0}, // J0 15 + {&DDRH, &PINH, &PORTH, 1}, // H1 16 + {&DDRH, &PINH, &PORTH, 0}, // H0 17 + {&DDRD, &PIND, &PORTD, 3}, // D3 18 + {&DDRD, &PIND, &PORTD, 2}, // D2 19 + {&DDRD, &PIND, &PORTD, 1}, // D1 20 + {&DDRD, &PIND, &PORTD, 0}, // D0 21 + {&DDRA, &PINA, &PORTA, 0}, // A0 22 + {&DDRA, &PINA, &PORTA, 1}, // A1 23 + {&DDRA, &PINA, &PORTA, 2}, // A2 24 + {&DDRA, &PINA, &PORTA, 3}, // A3 25 + {&DDRA, &PINA, &PORTA, 4}, // A4 26 + {&DDRA, &PINA, &PORTA, 5}, // A5 27 + {&DDRA, &PINA, &PORTA, 6}, // A6 28 + {&DDRA, &PINA, &PORTA, 7}, // A7 29 + {&DDRC, &PINC, &PORTC, 7}, // C7 30 + {&DDRC, &PINC, &PORTC, 6}, // C6 31 + {&DDRC, &PINC, &PORTC, 5}, // C5 32 + {&DDRC, &PINC, &PORTC, 4}, // C4 33 + {&DDRC, &PINC, &PORTC, 3}, // C3 34 + {&DDRC, &PINC, &PORTC, 2}, // C2 35 + {&DDRC, &PINC, &PORTC, 1}, // C1 36 + {&DDRC, &PINC, &PORTC, 0}, // C0 37 + {&DDRD, &PIND, &PORTD, 7}, // D7 38 + {&DDRG, &PING, &PORTG, 2}, // G2 39 + {&DDRG, &PING, &PORTG, 1}, // G1 40 + {&DDRG, &PING, &PORTG, 0}, // G0 41 + {&DDRL, &PINL, &PORTL, 7}, // L7 42 + {&DDRL, &PINL, &PORTL, 6}, // L6 43 + {&DDRL, &PINL, &PORTL, 5}, // L5 44 + {&DDRL, &PINL, &PORTL, 4}, // L4 45 + {&DDRL, &PINL, &PORTL, 3}, // L3 46 + {&DDRL, &PINL, &PORTL, 2}, // L2 47 + {&DDRL, &PINL, &PORTL, 1}, // L1 48 + {&DDRL, &PINL, &PORTL, 0}, // L0 49 + {&DDRB, &PINB, &PORTB, 3}, // B3 50 + {&DDRB, &PINB, &PORTB, 2}, // B2 51 + {&DDRB, &PINB, &PORTB, 1}, // B1 52 + {&DDRB, &PINB, &PORTB, 0}, // B0 53 + {&DDRF, &PINF, &PORTF, 0}, // F0 54 + {&DDRF, &PINF, &PORTF, 1}, // F1 55 + {&DDRF, &PINF, &PORTF, 2}, // F2 56 + {&DDRF, &PINF, &PORTF, 3}, // F3 57 + {&DDRF, &PINF, &PORTF, 4}, // F4 58 + {&DDRF, &PINF, &PORTF, 5}, // F5 59 + {&DDRF, &PINF, &PORTF, 6}, // F6 60 + {&DDRF, &PINF, &PORTF, 7}, // F7 61 + {&DDRK, &PINK, &PORTK, 0}, // K0 62 + {&DDRK, &PINK, &PORTK, 1}, // K1 63 + {&DDRK, &PINK, &PORTK, 2}, // K2 64 + {&DDRK, &PINK, &PORTK, 3}, // K3 65 + {&DDRK, &PINK, &PORTK, 4}, // K4 66 + {&DDRK, &PINK, &PORTK, 5}, // K5 67 + {&DDRK, &PINK, &PORTK, 6}, // K6 68 + {&DDRK, &PINK, &PORTK, 7} // K7 69 +}; +//------------------------------------------------------------------------------ +#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__) +// Sanguino + +// Two Wire (aka I2C) ports +uint8_t const SDA_PIN = 17; +uint8_t const SCL_PIN = 18; + +// SPI port +uint8_t const SS_PIN = 4; +uint8_t const MOSI_PIN = 5; +uint8_t const MISO_PIN = 6; +uint8_t const SCK_PIN = 7; + +static const pin_map_t digitalPinMap[] = { + {&DDRB, &PINB, &PORTB, 0}, // B0 0 + {&DDRB, &PINB, &PORTB, 1}, // B1 1 + {&DDRB, &PINB, &PORTB, 2}, // B2 2 + {&DDRB, &PINB, &PORTB, 3}, // B3 3 + {&DDRB, &PINB, &PORTB, 4}, // B4 4 + {&DDRB, &PINB, &PORTB, 5}, // B5 5 + {&DDRB, &PINB, &PORTB, 6}, // B6 6 + {&DDRB, &PINB, &PORTB, 7}, // B7 7 + {&DDRD, &PIND, &PORTD, 0}, // D0 8 + {&DDRD, &PIND, &PORTD, 1}, // D1 9 + {&DDRD, &PIND, &PORTD, 2}, // D2 10 + {&DDRD, &PIND, &PORTD, 3}, // D3 11 + {&DDRD, &PIND, &PORTD, 4}, // D4 12 + {&DDRD, &PIND, &PORTD, 5}, // D5 13 + {&DDRD, &PIND, &PORTD, 6}, // D6 14 + {&DDRD, &PIND, &PORTD, 7}, // D7 15 + {&DDRC, &PINC, &PORTC, 0}, // C0 16 + {&DDRC, &PINC, &PORTC, 1}, // C1 17 + {&DDRC, &PINC, &PORTC, 2}, // C2 18 + {&DDRC, &PINC, &PORTC, 3}, // C3 19 + {&DDRC, &PINC, &PORTC, 4}, // C4 20 + {&DDRC, &PINC, &PORTC, 5}, // C5 21 + {&DDRC, &PINC, &PORTC, 6}, // C6 22 + {&DDRC, &PINC, &PORTC, 7}, // C7 23 + {&DDRA, &PINA, &PORTA, 7}, // A7 24 + {&DDRA, &PINA, &PORTA, 6}, // A6 25 + {&DDRA, &PINA, &PORTA, 5}, // A5 26 + {&DDRA, &PINA, &PORTA, 4}, // A4 27 + {&DDRA, &PINA, &PORTA, 3}, // A3 28 + {&DDRA, &PINA, &PORTA, 2}, // A2 29 + {&DDRA, &PINA, &PORTA, 1}, // A1 30 + {&DDRA, &PINA, &PORTA, 0} // A0 31 +}; +//------------------------------------------------------------------------------ +#elif defined(__AVR_ATmega32U4__) +// Teensy 2.0 + +// Two Wire (aka I2C) ports +uint8_t const SDA_PIN = 6; +uint8_t const SCL_PIN = 5; + +// SPI port +uint8_t const SS_PIN = 0; +uint8_t const MOSI_PIN = 2; +uint8_t const MISO_PIN = 3; +uint8_t const SCK_PIN = 1; + +static const pin_map_t digitalPinMap[] = { + {&DDRB, &PINB, &PORTB, 0}, // B0 0 + {&DDRB, &PINB, &PORTB, 1}, // B1 1 + {&DDRB, &PINB, &PORTB, 2}, // B2 2 + {&DDRB, &PINB, &PORTB, 3}, // B3 3 + {&DDRB, &PINB, &PORTB, 7}, // B7 4 + {&DDRD, &PIND, &PORTD, 0}, // D0 5 + {&DDRD, &PIND, &PORTD, 1}, // D1 6 + {&DDRD, &PIND, &PORTD, 2}, // D2 7 + {&DDRD, &PIND, &PORTD, 3}, // D3 8 + {&DDRC, &PINC, &PORTC, 6}, // C6 9 + {&DDRC, &PINC, &PORTC, 7}, // C7 10 + {&DDRD, &PIND, &PORTD, 6}, // D6 11 + {&DDRD, &PIND, &PORTD, 7}, // D7 12 + {&DDRB, &PINB, &PORTB, 4}, // B4 13 + {&DDRB, &PINB, &PORTB, 5}, // B5 14 + {&DDRB, &PINB, &PORTB, 6}, // B6 15 + {&DDRF, &PINF, &PORTF, 7}, // F7 16 + {&DDRF, &PINF, &PORTF, 6}, // F6 17 + {&DDRF, &PINF, &PORTF, 5}, // F5 18 + {&DDRF, &PINF, &PORTF, 4}, // F4 19 + {&DDRF, &PINF, &PORTF, 1}, // F1 20 + {&DDRF, &PINF, &PORTF, 0}, // F0 21 + {&DDRD, &PIND, &PORTD, 4}, // D4 22 + {&DDRD, &PIND, &PORTD, 5}, // D5 23 + {&DDRE, &PINE, &PORTE, 6} // E6 24 +}; +//------------------------------------------------------------------------------ +#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) +// Teensy++ 1.0 & 2.0 + +// Two Wire (aka I2C) ports +uint8_t const SDA_PIN = 1; +uint8_t const SCL_PIN = 0; + +// SPI port +uint8_t const SS_PIN = 20; +uint8_t const MOSI_PIN = 22; +uint8_t const MISO_PIN = 23; +uint8_t const SCK_PIN = 21; + +static const pin_map_t digitalPinMap[] = { + {&DDRD, &PIND, &PORTD, 0}, // D0 0 + {&DDRD, &PIND, &PORTD, 1}, // D1 1 + {&DDRD, &PIND, &PORTD, 2}, // D2 2 + {&DDRD, &PIND, &PORTD, 3}, // D3 3 + {&DDRD, &PIND, &PORTD, 4}, // D4 4 + {&DDRD, &PIND, &PORTD, 5}, // D5 5 + {&DDRD, &PIND, &PORTD, 6}, // D6 6 + {&DDRD, &PIND, &PORTD, 7}, // D7 7 + {&DDRE, &PINE, &PORTE, 0}, // E0 8 + {&DDRE, &PINE, &PORTE, 1}, // E1 9 + {&DDRC, &PINC, &PORTC, 0}, // C0 10 + {&DDRC, &PINC, &PORTC, 1}, // C1 11 + {&DDRC, &PINC, &PORTC, 2}, // C2 12 + {&DDRC, &PINC, &PORTC, 3}, // C3 13 + {&DDRC, &PINC, &PORTC, 4}, // C4 14 + {&DDRC, &PINC, &PORTC, 5}, // C5 15 + {&DDRC, &PINC, &PORTC, 6}, // C6 16 + {&DDRC, &PINC, &PORTC, 7}, // C7 17 + {&DDRE, &PINE, &PORTE, 6}, // E6 18 + {&DDRE, &PINE, &PORTE, 7}, // E7 19 + {&DDRB, &PINB, &PORTB, 0}, // B0 20 + {&DDRB, &PINB, &PORTB, 1}, // B1 21 + {&DDRB, &PINB, &PORTB, 2}, // B2 22 + {&DDRB, &PINB, &PORTB, 3}, // B3 23 + {&DDRB, &PINB, &PORTB, 4}, // B4 24 + {&DDRB, &PINB, &PORTB, 5}, // B5 25 + {&DDRB, &PINB, &PORTB, 6}, // B6 26 + {&DDRB, &PINB, &PORTB, 7}, // B7 27 + {&DDRA, &PINA, &PORTA, 0}, // A0 28 + {&DDRA, &PINA, &PORTA, 1}, // A1 29 + {&DDRA, &PINA, &PORTA, 2}, // A2 30 + {&DDRA, &PINA, &PORTA, 3}, // A3 31 + {&DDRA, &PINA, &PORTA, 4}, // A4 32 + {&DDRA, &PINA, &PORTA, 5}, // A5 33 + {&DDRA, &PINA, &PORTA, 6}, // A6 34 + {&DDRA, &PINA, &PORTA, 7}, // A7 35 + {&DDRE, &PINE, &PORTE, 4}, // E4 36 + {&DDRE, &PINE, &PORTE, 5}, // E5 37 + {&DDRF, &PINF, &PORTF, 0}, // F0 38 + {&DDRF, &PINF, &PORTF, 1}, // F1 39 + {&DDRF, &PINF, &PORTF, 2}, // F2 40 + {&DDRF, &PINF, &PORTF, 3}, // F3 41 + {&DDRF, &PINF, &PORTF, 4}, // F4 42 + {&DDRF, &PINF, &PORTF, 5}, // F5 43 + {&DDRF, &PINF, &PORTF, 6}, // F6 44 + {&DDRF, &PINF, &PORTF, 7} // F7 45 +}; +//------------------------------------------------------------------------------ +#else // defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) +// 168 and 328 Arduinos + +// Two Wire (aka I2C) ports +uint8_t const SDA_PIN = 18; +uint8_t const SCL_PIN = 19; + +// SPI port +uint8_t const SS_PIN = 10; +uint8_t const MOSI_PIN = 11; +uint8_t const MISO_PIN = 12; +uint8_t const SCK_PIN = 13; + +static const pin_map_t digitalPinMap[] = { + {&DDRD, &PIND, &PORTD, 0}, // D0 0 + {&DDRD, &PIND, &PORTD, 1}, // D1 1 + {&DDRD, &PIND, &PORTD, 2}, // D2 2 + {&DDRD, &PIND, &PORTD, 3}, // D3 3 + {&DDRD, &PIND, &PORTD, 4}, // D4 4 + {&DDRD, &PIND, &PORTD, 5}, // D5 5 + {&DDRD, &PIND, &PORTD, 6}, // D6 6 + {&DDRD, &PIND, &PORTD, 7}, // D7 7 + {&DDRB, &PINB, &PORTB, 0}, // B0 8 + {&DDRB, &PINB, &PORTB, 1}, // B1 9 + {&DDRB, &PINB, &PORTB, 2}, // B2 10 + {&DDRB, &PINB, &PORTB, 3}, // B3 11 + {&DDRB, &PINB, &PORTB, 4}, // B4 12 + {&DDRB, &PINB, &PORTB, 5}, // B5 13 + {&DDRC, &PINC, &PORTC, 0}, // C0 14 + {&DDRC, &PINC, &PORTC, 1}, // C1 15 + {&DDRC, &PINC, &PORTC, 2}, // C2 16 + {&DDRC, &PINC, &PORTC, 3}, // C3 17 + {&DDRC, &PINC, &PORTC, 4}, // C4 18 + {&DDRC, &PINC, &PORTC, 5} // C5 19 +}; +#endif // defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) +//------------------------------------------------------------------------------ +static const uint8_t digitalPinCount = sizeof(digitalPinMap)/sizeof(pin_map_t); + +uint8_t badPinNumber(void) + __attribute__((error("Pin number is too large or not a constant"))); + +static inline __attribute__((always_inline)) + uint8_t getPinMode(uint8_t pin) { + if (__builtin_constant_p(pin) && pin < digitalPinCount) { + return (*digitalPinMap[pin].ddr >> digitalPinMap[pin].bit) & 1; + } else { + return badPinNumber(); + } +} +static inline __attribute__((always_inline)) + void setPinMode(uint8_t pin, uint8_t mode) { + if (__builtin_constant_p(pin) && pin < digitalPinCount) { + if (mode) { + *digitalPinMap[pin].ddr |= 1 << digitalPinMap[pin].bit; + } else { + *digitalPinMap[pin].ddr &= ~(1 << digitalPinMap[pin].bit); + } + } else { + badPinNumber(); + } +} +static inline __attribute__((always_inline)) + uint8_t fastDigitalRead(uint8_t pin) { + if (__builtin_constant_p(pin) && pin < digitalPinCount) { + return (*digitalPinMap[pin].pin >> digitalPinMap[pin].bit) & 1; + } else { + return badPinNumber(); + } +} +static inline __attribute__((always_inline)) + void fastDigitalWrite(uint8_t pin, uint8_t value) { + if (__builtin_constant_p(pin) && pin < digitalPinCount) { + if (value) { + *digitalPinMap[pin].port |= 1 << digitalPinMap[pin].bit; + } else { + *digitalPinMap[pin].port &= ~(1 << digitalPinMap[pin].bit); + } + } else { + badPinNumber(); + } +} +#endif // Sd2PinMap_h diff --git a/arduino-0022-linux-x64/libraries/SD/utility/SdFat.h b/arduino-0022-linux-x64/libraries/SD/utility/SdFat.h new file mode 100644 index 0000000..048fa71 --- /dev/null +++ b/arduino-0022-linux-x64/libraries/SD/utility/SdFat.h @@ -0,0 +1,547 @@ +/* Arduino SdFat Library + * Copyright (C) 2009 by William Greiman + * + * This file is part of the Arduino SdFat Library + * + * This Library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with the Arduino SdFat Library. If not, see + * . + */ +#ifndef SdFat_h +#define SdFat_h +/** + * \file + * SdFile and SdVolume classes + */ +#include +#include "Sd2Card.h" +#include "FatStructs.h" +#include "Print.h" +//------------------------------------------------------------------------------ +/** + * Allow use of deprecated functions if non-zero + */ +#define ALLOW_DEPRECATED_FUNCTIONS 1 +//------------------------------------------------------------------------------ +// forward declaration since SdVolume is used in SdFile +class SdVolume; +//============================================================================== +// SdFile class + +// flags for ls() +/** ls() flag to print modify date */ +uint8_t const LS_DATE = 1; +/** ls() flag to print file size */ +uint8_t const LS_SIZE = 2; +/** ls() flag for recursive list of subdirectories */ +uint8_t const LS_R = 4; + +// use the gnu style oflag in open() +/** open() oflag for reading */ +uint8_t const O_READ = 0X01; +/** open() oflag - same as O_READ */ +uint8_t const O_RDONLY = O_READ; +/** open() oflag for write */ +uint8_t const O_WRITE = 0X02; +/** open() oflag - same as O_WRITE */ +uint8_t const O_WRONLY = O_WRITE; +/** open() oflag for reading and writing */ +uint8_t const O_RDWR = (O_READ | O_WRITE); +/** open() oflag mask for access modes */ +uint8_t const O_ACCMODE = (O_READ | O_WRITE); +/** The file offset shall be set to the end of the file prior to each write. */ +uint8_t const O_APPEND = 0X04; +/** synchronous writes - call sync() after each write */ +uint8_t const O_SYNC = 0X08; +/** create the file if nonexistent */ +uint8_t const O_CREAT = 0X10; +/** If O_CREAT and O_EXCL are set, open() shall fail if the file exists */ +uint8_t const O_EXCL = 0X20; +/** truncate the file to zero length */ +uint8_t const O_TRUNC = 0X40; + +// flags for timestamp +/** set the file's last access date */ +uint8_t const T_ACCESS = 1; +/** set the file's creation date and time */ +uint8_t const T_CREATE = 2; +/** Set the file's write date and time */ +uint8_t const T_WRITE = 4; +// values for type_ +/** This SdFile has not been opened. */ +uint8_t const FAT_FILE_TYPE_CLOSED = 0; +/** SdFile for a file */ +uint8_t const FAT_FILE_TYPE_NORMAL = 1; +/** SdFile for a FAT16 root directory */ +uint8_t const FAT_FILE_TYPE_ROOT16 = 2; +/** SdFile for a FAT32 root directory */ +uint8_t const FAT_FILE_TYPE_ROOT32 = 3; +/** SdFile for a subdirectory */ +uint8_t const FAT_FILE_TYPE_SUBDIR = 4; +/** Test value for directory type */ +uint8_t const FAT_FILE_TYPE_MIN_DIR = FAT_FILE_TYPE_ROOT16; + +/** date field for FAT directory entry */ +static inline uint16_t FAT_DATE(uint16_t year, uint8_t month, uint8_t day) { + return (year - 1980) << 9 | month << 5 | day; +} +/** year part of FAT directory date field */ +static inline uint16_t FAT_YEAR(uint16_t fatDate) { + return 1980 + (fatDate >> 9); +} +/** month part of FAT directory date field */ +static inline uint8_t FAT_MONTH(uint16_t fatDate) { + return (fatDate >> 5) & 0XF; +} +/** day part of FAT directory date field */ +static inline uint8_t FAT_DAY(uint16_t fatDate) { + return fatDate & 0X1F; +} +/** time field for FAT directory entry */ +static inline uint16_t FAT_TIME(uint8_t hour, uint8_t minute, uint8_t second) { + return hour << 11 | minute << 5 | second >> 1; +} +/** hour part of FAT directory time field */ +static inline uint8_t FAT_HOUR(uint16_t fatTime) { + return fatTime >> 11; +} +/** minute part of FAT directory time field */ +static inline uint8_t FAT_MINUTE(uint16_t fatTime) { + return(fatTime >> 5) & 0X3F; +} +/** second part of FAT directory time field */ +static inline uint8_t FAT_SECOND(uint16_t fatTime) { + return 2*(fatTime & 0X1F); +} +/** Default date for file timestamps is 1 Jan 2000 */ +uint16_t const FAT_DEFAULT_DATE = ((2000 - 1980) << 9) | (1 << 5) | 1; +/** Default time for file timestamp is 1 am */ +uint16_t const FAT_DEFAULT_TIME = (1 << 11); +//------------------------------------------------------------------------------ +/** + * \class SdFile + * \brief Access FAT16 and FAT32 files on SD and SDHC cards. + */ +class SdFile : public Print { + public: + /** Create an instance of SdFile. */ + SdFile(void) : type_(FAT_FILE_TYPE_CLOSED) {} + /** + * writeError is set to true if an error occurs during a write(). + * Set writeError to false before calling print() and/or write() and check + * for true after calls to print() and/or write(). + */ + bool writeError; + /** + * Cancel unbuffered reads for this file. + * See setUnbufferedRead() + */ + void clearUnbufferedRead(void) { + flags_ &= ~F_FILE_UNBUFFERED_READ; + } + uint8_t close(void); + uint8_t contiguousRange(uint32_t* bgnBlock, uint32_t* endBlock); + uint8_t createContiguous(SdFile* dirFile, + const char* fileName, uint32_t size); + /** \return The current cluster number for a file or directory. */ + uint32_t curCluster(void) const {return curCluster_;} + /** \return The current position for a file or directory. */ + uint32_t curPosition(void) const {return curPosition_;} + /** + * Set the date/time callback function + * + * \param[in] dateTime The user's call back function. The callback + * function is of the form: + * + * \code + * void dateTime(uint16_t* date, uint16_t* time) { + * uint16_t year; + * uint8_t month, day, hour, minute, second; + * + * // User gets date and time from GPS or real-time clock here + * + * // return date using FAT_DATE macro to format fields + * *date = FAT_DATE(year, month, day); + * + * // return time using FAT_TIME macro to format fields + * *time = FAT_TIME(hour, minute, second); + * } + * \endcode + * + * Sets the function that is called when a file is created or when + * a file's directory entry is modified by sync(). All timestamps, + * access, creation, and modify, are set when a file is created. + * sync() maintains the last access date and last modify date/time. + * + * See the timestamp() function. + */ + static void dateTimeCallback( + void (*dateTime)(uint16_t* date, uint16_t* time)) { + dateTime_ = dateTime; + } + /** + * Cancel the date/time callback function. + */ + static void dateTimeCallbackCancel(void) { + // use explicit zero since NULL is not defined for Sanguino + dateTime_ = 0; + } + /** \return Address of the block that contains this file's directory. */ + uint32_t dirBlock(void) const {return dirBlock_;} + uint8_t dirEntry(dir_t* dir); + /** \return Index of this file's directory in the block dirBlock. */ + uint8_t dirIndex(void) const {return dirIndex_;} + static void dirName(const dir_t& dir, char* name); + /** \return The total number of bytes in a file or directory. */ + uint32_t fileSize(void) const {return fileSize_;} + /** \return The first cluster number for a file or directory. */ + uint32_t firstCluster(void) const {return firstCluster_;} + /** \return True if this is a SdFile for a directory else false. */ + uint8_t isDir(void) const {return type_ >= FAT_FILE_TYPE_MIN_DIR;} + /** \return True if this is a SdFile for a file else false. */ + uint8_t isFile(void) const {return type_ == FAT_FILE_TYPE_NORMAL;} + /** \return True if this is a SdFile for an open file/directory else false. */ + uint8_t isOpen(void) const {return type_ != FAT_FILE_TYPE_CLOSED;} + /** \return True if this is a SdFile for a subdirectory else false. */ + uint8_t isSubDir(void) const {return type_ == FAT_FILE_TYPE_SUBDIR;} + /** \return True if this is a SdFile for the root directory. */ + uint8_t isRoot(void) const { + return type_ == FAT_FILE_TYPE_ROOT16 || type_ == FAT_FILE_TYPE_ROOT32; + } + void ls(uint8_t flags = 0, uint8_t indent = 0); + uint8_t makeDir(SdFile* dir, const char* dirName); + uint8_t open(SdFile* dirFile, uint16_t index, uint8_t oflag); + uint8_t open(SdFile* dirFile, const char* fileName, uint8_t oflag); + + uint8_t openRoot(SdVolume* vol); + static void printDirName(const dir_t& dir, uint8_t width); + static void printFatDate(uint16_t fatDate); + static void printFatTime(uint16_t fatTime); + static void printTwoDigits(uint8_t v); + /** + * Read the next byte from a file. + * + * \return For success read returns the next byte in the file as an int. + * If an error occurs or end of file is reached -1 is returned. + */ + int16_t read(void) { + uint8_t b; + return read(&b, 1) == 1 ? b : -1; + } + int16_t read(void* buf, uint16_t nbyte); + int8_t readDir(dir_t* dir); + static uint8_t remove(SdFile* dirFile, const char* fileName); + uint8_t remove(void); + /** Set the file's current position to zero. */ + void rewind(void) { + curPosition_ = curCluster_ = 0; + } + uint8_t rmDir(void); + uint8_t rmRfStar(void); + /** Set the files position to current position + \a pos. See seekSet(). */ + uint8_t seekCur(uint32_t pos) { + return seekSet(curPosition_ + pos); + } + /** + * Set the files current position to end of file. Useful to position + * a file for append. See seekSet(). + */ + uint8_t seekEnd(void) {return seekSet(fileSize_);} + uint8_t seekSet(uint32_t pos); + /** + * Use unbuffered reads to access this file. Used with Wave + * Shield ISR. Used with Sd2Card::partialBlockRead() in WaveRP. + * + * Not recommended for normal applications. + */ + void setUnbufferedRead(void) { + if (isFile()) flags_ |= F_FILE_UNBUFFERED_READ; + } + uint8_t timestamp(uint8_t flag, uint16_t year, uint8_t month, uint8_t day, + uint8_t hour, uint8_t minute, uint8_t second); + uint8_t sync(void); + /** Type of this SdFile. You should use isFile() or isDir() instead of type() + * if possible. + * + * \return The file or directory type. + */ + uint8_t type(void) const {return type_;} + uint8_t truncate(uint32_t size); + /** \return Unbuffered read flag. */ + uint8_t unbufferedRead(void) const { + return flags_ & F_FILE_UNBUFFERED_READ; + } + /** \return SdVolume that contains this file. */ + SdVolume* volume(void) const {return vol_;} + void write(uint8_t b); + int16_t write(const void* buf, uint16_t nbyte); + void write(const char* str); + void write_P(PGM_P str); + void writeln_P(PGM_P str); +//------------------------------------------------------------------------------ +#if ALLOW_DEPRECATED_FUNCTIONS +// Deprecated functions - suppress cpplint warnings with NOLINT comment + /** \deprecated Use: + * uint8_t SdFile::contiguousRange(uint32_t* bgnBlock, uint32_t* endBlock); + */ + uint8_t contiguousRange(uint32_t& bgnBlock, uint32_t& endBlock) { // NOLINT + return contiguousRange(&bgnBlock, &endBlock); + } + /** \deprecated Use: + * uint8_t SdFile::createContiguous(SdFile* dirFile, + * const char* fileName, uint32_t size) + */ + uint8_t createContiguous(SdFile& dirFile, // NOLINT + const char* fileName, uint32_t size) { + return createContiguous(&dirFile, fileName, size); + } + + /** + * \deprecated Use: + * static void SdFile::dateTimeCallback( + * void (*dateTime)(uint16_t* date, uint16_t* time)); + */ + static void dateTimeCallback( + void (*dateTime)(uint16_t& date, uint16_t& time)) { // NOLINT + oldDateTime_ = dateTime; + dateTime_ = dateTime ? oldToNew : 0; + } + /** \deprecated Use: uint8_t SdFile::dirEntry(dir_t* dir); */ + uint8_t dirEntry(dir_t& dir) {return dirEntry(&dir);} // NOLINT + /** \deprecated Use: + * uint8_t SdFile::makeDir(SdFile* dir, const char* dirName); + */ + uint8_t makeDir(SdFile& dir, const char* dirName) { // NOLINT + return makeDir(&dir, dirName); + } + /** \deprecated Use: + * uint8_t SdFile::open(SdFile* dirFile, const char* fileName, uint8_t oflag); + */ + uint8_t open(SdFile& dirFile, // NOLINT + const char* fileName, uint8_t oflag) { + return open(&dirFile, fileName, oflag); + } + /** \deprecated Do not use in new apps */ + uint8_t open(SdFile& dirFile, const char* fileName) { // NOLINT + return open(dirFile, fileName, O_RDWR); + } + /** \deprecated Use: + * uint8_t SdFile::open(SdFile* dirFile, uint16_t index, uint8_t oflag); + */ + uint8_t open(SdFile& dirFile, uint16_t index, uint8_t oflag) { // NOLINT + return open(&dirFile, index, oflag); + } + /** \deprecated Use: uint8_t SdFile::openRoot(SdVolume* vol); */ + uint8_t openRoot(SdVolume& vol) {return openRoot(&vol);} // NOLINT + + /** \deprecated Use: int8_t SdFile::readDir(dir_t* dir); */ + int8_t readDir(dir_t& dir) {return readDir(&dir);} // NOLINT + /** \deprecated Use: + * static uint8_t SdFile::remove(SdFile* dirFile, const char* fileName); + */ + static uint8_t remove(SdFile& dirFile, const char* fileName) { // NOLINT + return remove(&dirFile, fileName); + } +//------------------------------------------------------------------------------ +// rest are private + private: + static void (*oldDateTime_)(uint16_t& date, uint16_t& time); // NOLINT + static void oldToNew(uint16_t* date, uint16_t* time) { + uint16_t d; + uint16_t t; + oldDateTime_(d, t); + *date = d; + *time = t; + } +#endif // ALLOW_DEPRECATED_FUNCTIONS + private: + // bits defined in flags_ + // should be 0XF + static uint8_t const F_OFLAG = (O_ACCMODE | O_APPEND | O_SYNC); + // available bits + static uint8_t const F_UNUSED = 0X30; + // use unbuffered SD read + static uint8_t const F_FILE_UNBUFFERED_READ = 0X40; + // sync of directory entry required + static uint8_t const F_FILE_DIR_DIRTY = 0X80; + +// make sure F_OFLAG is ok +#if ((F_UNUSED | F_FILE_UNBUFFERED_READ | F_FILE_DIR_DIRTY) & F_OFLAG) +#error flags_ bits conflict +#endif // flags_ bits + + // private data + uint8_t flags_; // See above for definition of flags_ bits + uint8_t type_; // type of file see above for values + uint32_t curCluster_; // cluster for current file position + uint32_t curPosition_; // current file position in bytes from beginning + uint32_t dirBlock_; // SD block that contains directory entry for file + uint8_t dirIndex_; // index of entry in dirBlock 0 <= dirIndex_ <= 0XF + uint32_t fileSize_; // file size in bytes + uint32_t firstCluster_; // first cluster of file + SdVolume* vol_; // volume where file is located + + // private functions + uint8_t addCluster(void); + uint8_t addDirCluster(void); + dir_t* cacheDirEntry(uint8_t action); + static void (*dateTime_)(uint16_t* date, uint16_t* time); + static uint8_t make83Name(const char* str, uint8_t* name); + uint8_t openCachedEntry(uint8_t cacheIndex, uint8_t oflags); + dir_t* readDirCache(void); +}; +//============================================================================== +// SdVolume class +/** + * \brief Cache for an SD data block + */ +union cache_t { + /** Used to access cached file data blocks. */ + uint8_t data[512]; + /** Used to access cached FAT16 entries. */ + uint16_t fat16[256]; + /** Used to access cached FAT32 entries. */ + uint32_t fat32[128]; + /** Used to access cached directory entries. */ + dir_t dir[16]; + /** Used to access a cached MasterBoot Record. */ + mbr_t mbr; + /** Used to access to a cached FAT boot sector. */ + fbs_t fbs; +}; +//------------------------------------------------------------------------------ +/** + * \class SdVolume + * \brief Access FAT16 and FAT32 volumes on SD and SDHC cards. + */ +class SdVolume { + public: + /** Create an instance of SdVolume */ + SdVolume(void) :allocSearchStart_(2), fatType_(0) {} + /** Clear the cache and returns a pointer to the cache. Used by the WaveRP + * recorder to do raw write to the SD card. Not for normal apps. + */ + static uint8_t* cacheClear(void) { + cacheFlush(); + cacheBlockNumber_ = 0XFFFFFFFF; + return cacheBuffer_.data; + } + /** + * Initialize a FAT volume. Try partition one first then try super + * floppy format. + * + * \param[in] dev The Sd2Card where the volume is located. + * + * \return The value one, true, is returned for success and + * the value zero, false, is returned for failure. Reasons for + * failure include not finding a valid partition, not finding a valid + * FAT file system or an I/O error. + */ + uint8_t init(Sd2Card* dev) { return init(dev, 1) ? true : init(dev, 0);} + uint8_t init(Sd2Card* dev, uint8_t part); + + // inline functions that return volume info + /** \return The volume's cluster size in blocks. */ + uint8_t blocksPerCluster(void) const {return blocksPerCluster_;} + /** \return The number of blocks in one FAT. */ + uint32_t blocksPerFat(void) const {return blocksPerFat_;} + /** \return The total number of clusters in the volume. */ + uint32_t clusterCount(void) const {return clusterCount_;} + /** \return The shift count required to multiply by blocksPerCluster. */ + uint8_t clusterSizeShift(void) const {return clusterSizeShift_;} + /** \return The logical block number for the start of file data. */ + uint32_t dataStartBlock(void) const {return dataStartBlock_;} + /** \return The number of FAT structures on the volume. */ + uint8_t fatCount(void) const {return fatCount_;} + /** \return The logical block number for the start of the first FAT. */ + uint32_t fatStartBlock(void) const {return fatStartBlock_;} + /** \return The FAT type of the volume. Values are 12, 16 or 32. */ + uint8_t fatType(void) const {return fatType_;} + /** \return The number of entries in the root directory for FAT16 volumes. */ + uint32_t rootDirEntryCount(void) const {return rootDirEntryCount_;} + /** \return The logical block number for the start of the root directory + on FAT16 volumes or the first cluster number on FAT32 volumes. */ + uint32_t rootDirStart(void) const {return rootDirStart_;} + /** return a pointer to the Sd2Card object for this volume */ + static Sd2Card* sdCard(void) {return sdCard_;} +//------------------------------------------------------------------------------ +#if ALLOW_DEPRECATED_FUNCTIONS + // Deprecated functions - suppress cpplint warnings with NOLINT comment + /** \deprecated Use: uint8_t SdVolume::init(Sd2Card* dev); */ + uint8_t init(Sd2Card& dev) {return init(&dev);} // NOLINT + + /** \deprecated Use: uint8_t SdVolume::init(Sd2Card* dev, uint8_t vol); */ + uint8_t init(Sd2Card& dev, uint8_t part) { // NOLINT + return init(&dev, part); + } +#endif // ALLOW_DEPRECATED_FUNCTIONS +//------------------------------------------------------------------------------ + private: + // Allow SdFile access to SdVolume private data. + friend class SdFile; + + // value for action argument in cacheRawBlock to indicate read from cache + static uint8_t const CACHE_FOR_READ = 0; + // value for action argument in cacheRawBlock to indicate cache dirty + static uint8_t const CACHE_FOR_WRITE = 1; + + static cache_t cacheBuffer_; // 512 byte cache for device blocks + static uint32_t cacheBlockNumber_; // Logical number of block in the cache + static Sd2Card* sdCard_; // Sd2Card object for cache + static uint8_t cacheDirty_; // cacheFlush() will write block if true + static uint32_t cacheMirrorBlock_; // block number for mirror FAT +// + uint32_t allocSearchStart_; // start cluster for alloc search + uint8_t blocksPerCluster_; // cluster size in blocks + uint32_t blocksPerFat_; // FAT size in blocks + uint32_t clusterCount_; // clusters in one FAT + uint8_t clusterSizeShift_; // shift to convert cluster count to block count + uint32_t dataStartBlock_; // first data block number + uint8_t fatCount_; // number of FATs on volume + uint32_t fatStartBlock_; // start block for first FAT + uint8_t fatType_; // volume type (12, 16, OR 32) + uint16_t rootDirEntryCount_; // number of entries in FAT16 root dir + uint32_t rootDirStart_; // root start block for FAT16, cluster for FAT32 + //---------------------------------------------------------------------------- + uint8_t allocContiguous(uint32_t count, uint32_t* curCluster); + uint8_t blockOfCluster(uint32_t position) const { + return (position >> 9) & (blocksPerCluster_ - 1);} + uint32_t clusterStartBlock(uint32_t cluster) const { + return dataStartBlock_ + ((cluster - 2) << clusterSizeShift_);} + uint32_t blockNumber(uint32_t cluster, uint32_t position) const { + return clusterStartBlock(cluster) + blockOfCluster(position);} + static uint8_t cacheFlush(void); + static uint8_t cacheRawBlock(uint32_t blockNumber, uint8_t action); + static void cacheSetDirty(void) {cacheDirty_ |= CACHE_FOR_WRITE;} + static uint8_t cacheZeroBlock(uint32_t blockNumber); + uint8_t chainSize(uint32_t beginCluster, uint32_t* size) const; + uint8_t fatGet(uint32_t cluster, uint32_t* value) const; + uint8_t fatPut(uint32_t cluster, uint32_t value); + uint8_t fatPutEOC(uint32_t cluster) { + return fatPut(cluster, 0x0FFFFFFF); + } + uint8_t freeChain(uint32_t cluster); + uint8_t isEOC(uint32_t cluster) const { + return cluster >= (fatType_ == 16 ? FAT16EOC_MIN : FAT32EOC_MIN); + } + uint8_t readBlock(uint32_t block, uint8_t* dst) { + return sdCard_->readBlock(block, dst);} + uint8_t readData(uint32_t block, uint16_t offset, + uint16_t count, uint8_t* dst) { + return sdCard_->readData(block, offset, count, dst); + } + uint8_t writeBlock(uint32_t block, const uint8_t* dst) { + return sdCard_->writeBlock(block, dst); + } +}; +#endif // SdFat_h diff --git a/arduino-0022-linux-x64/libraries/SD/utility/SdFatUtil.h b/arduino-0022-linux-x64/libraries/SD/utility/SdFatUtil.h new file mode 100644 index 0000000..8bf9048 --- /dev/null +++ b/arduino-0022-linux-x64/libraries/SD/utility/SdFatUtil.h @@ -0,0 +1,70 @@ +/* Arduino SdFat Library + * Copyright (C) 2008 by William Greiman + * + * This file is part of the Arduino SdFat Library + * + * This Library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 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 General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with the Arduino SdFat Library. If not, see + * . + */ +#ifndef SdFatUtil_h +#define SdFatUtil_h +/** + * \file + * Useful utility functions. + */ +#include +#include +/** Store and print a string in flash memory.*/ +#define PgmPrint(x) SerialPrint_P(PSTR(x)) +/** Store and print a string in flash memory followed by a CR/LF.*/ +#define PgmPrintln(x) SerialPrintln_P(PSTR(x)) +/** Defined so doxygen works for function definitions. */ +#define NOINLINE __attribute__((noinline)) +//------------------------------------------------------------------------------ +/** Return the number of bytes currently free in RAM. */ +static int FreeRam(void) { + extern int __bss_end; + extern int* __brkval; + int free_memory; + if (reinterpret_cast(__brkval) == 0) { + // if no heap use from end of bss section + free_memory = reinterpret_cast(&free_memory) + - reinterpret_cast(&__bss_end); + } else { + // use from top of stack to heap + free_memory = reinterpret_cast(&free_memory) + - reinterpret_cast(__brkval); + } + return free_memory; +} +//------------------------------------------------------------------------------ +/** + * %Print a string in flash memory to the serial port. + * + * \param[in] str Pointer to string stored in flash memory. + */ +static NOINLINE void SerialPrint_P(PGM_P str) { + for (uint8_t c; (c = pgm_read_byte(str)); str++) Serial.print(c); +} +//------------------------------------------------------------------------------ +/** + * %Print a string in flash memory followed by a CR/LF. + * + * \param[in] str Pointer to string stored in flash memory. + */ +static NOINLINE void SerialPrintln_P(PGM_P str) { + SerialPrint_P(str); + Serial.println(); +} +#endif // #define SdFatUtil_h diff --git a/arduino-0022-linux-x64/libraries/SD/utility/SdFatmainpage.h b/arduino-0022-linux-x64/libraries/SD/utility/SdFatmainpage.h new file mode 100644 index 0000000..73b3b63 --- /dev/null +++ b/arduino-0022-linux-x64/libraries/SD/utility/SdFatmainpage.h @@ -0,0 +1,202 @@ +/* Arduino SdFat Library + * Copyright (C) 2009 by William Greiman + * + * This file is part of the Arduino SdFat Library + * + * This Library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with the Arduino SdFat Library. If not, see + * . + */ + +/** +\mainpage Arduino SdFat Library +
    Copyright © 2009 by William Greiman +
    + +\section Intro Introduction +The Arduino SdFat Library is a minimal implementation of FAT16 and FAT32 +file systems on SD flash memory cards. Standard SD and high capacity +SDHC cards are supported. + +The SdFat only supports short 8.3 names. + +The main classes in SdFat are Sd2Card, SdVolume, and SdFile. + +The Sd2Card class supports access to standard SD cards and SDHC cards. Most +applications will only need to call the Sd2Card::init() member function. + +The SdVolume class supports FAT16 and FAT32 partitions. Most applications +will only need to call the SdVolume::init() member function. + +The SdFile class provides file access functions such as open(), read(), +remove(), write(), close() and sync(). This class supports access to the root +directory and subdirectories. + +A number of example are provided in the SdFat/examples folder. These were +developed to test SdFat and illustrate its use. + +SdFat was developed for high speed data recording. SdFat was used to implement +an audio record/play class, WaveRP, for the Adafruit Wave Shield. This +application uses special Sd2Card calls to write to contiguous files in raw mode. +These functions reduce write latency so that audio can be recorded with the +small amount of RAM in the Arduino. + +\section SDcard SD\SDHC Cards + +Arduinos access SD cards using the cards SPI protocol. PCs, Macs, and +most consumer devices use the 4-bit parallel SD protocol. A card that +functions well on A PC or Mac may not work well on the Arduino. + +Most cards have good SPI read performance but cards vary widely in SPI +write performance. Write performance is limited by how efficiently the +card manages internal erase/remapping operations. The Arduino cannot +optimize writes to reduce erase operations because of its limit RAM. + +SanDisk cards generally have good write performance. They seem to have +more internal RAM buffering than other cards and therefore can limit +the number of flash erase operations that the Arduino forces due to its +limited RAM. + +\section Hardware Hardware Configuration + +SdFat was developed using an + Adafruit Industries + Wave Shield. + +The hardware interface to the SD card should not use a resistor based level +shifter. SdFat sets the SPI bus frequency to 8 MHz which results in signal +rise times that are too slow for the edge detectors in many newer SD card +controllers when resistor voltage dividers are used. + +The 5 to 3.3 V level shifter for 5 V Arduinos should be IC based like the +74HC4050N based circuit shown in the file SdLevel.png. The Adafruit Wave Shield +uses a 74AHC125N. Gravitech sells SD and MicroSD Card Adapters based on the +74LCX245. + +If you are using a resistor based level shifter and are having problems try +setting the SPI bus frequency to 4 MHz. This can be done by using +card.init(SPI_HALF_SPEED) to initialize the SD card. + +\section comment Bugs and Comments + +If you wish to report bugs or have comments, send email to fat16lib@sbcglobal.net. + +\section SdFatClass SdFat Usage + +SdFat uses a slightly restricted form of short names. +Only printable ASCII characters are supported. No characters with code point +values greater than 127 are allowed. Space is not allowed even though space +was allowed in the API of early versions of DOS. + +Short names are limited to 8 characters followed by an optional period (.) +and extension of up to 3 characters. The characters may be any combination +of letters and digits. The following special characters are also allowed: + +$ % ' - _ @ ~ ` ! ( ) { } ^ # & + +Short names are always converted to upper case and their original case +value is lost. + +\note + The Arduino Print class uses character +at a time writes so it was necessary to use a \link SdFile::sync() sync() \endlink +function to control when data is written to the SD card. + +\par +An application which writes to a file using \link Print::print() print()\endlink, +\link Print::println() println() \endlink +or \link SdFile::write write() \endlink must call \link SdFile::sync() sync() \endlink +at the appropriate time to force data and directory information to be written +to the SD Card. Data and directory information are also written to the SD card +when \link SdFile::close() close() \endlink is called. + +\par +Applications must use care calling \link SdFile::sync() sync() \endlink +since 2048 bytes of I/O is required to update file and +directory information. This includes writing the current data block, reading +the block that contains the directory entry for update, writing the directory +block back and reading back the current data block. + +It is possible to open a file with two or more instances of SdFile. A file may +be corrupted if data is written to the file by more than one instance of SdFile. + +\section HowTo How to format SD Cards as FAT Volumes + +You should use a freshly formatted SD card for best performance. FAT +file systems become slower if many files have been created and deleted. +This is because the directory entry for a deleted file is marked as deleted, +but is not deleted. When a new file is created, these entries must be scanned +before creating the file, a flaw in the FAT design. Also files can become +fragmented which causes reads and writes to be slower. + +Microsoft operating systems support removable media formatted with a +Master Boot Record, MBR, or formatted as a super floppy with a FAT Boot Sector +in block zero. + +Microsoft operating systems expect MBR formatted removable media +to have only one partition. The first partition should be used. + +Microsoft operating systems do not support partitioning SD flash cards. +If you erase an SD card with a program like KillDisk, Most versions of +Windows will format the card as a super floppy. + +The best way to restore an SD card's format is to use SDFormatter +which can be downloaded from: + +http://www.sdcard.org/consumers/formatter/ + +SDFormatter aligns flash erase boundaries with file +system structures which reduces write latency and file system overhead. + +SDFormatter does not have an option for FAT type so it may format +small cards as FAT12. + +After the MBR is restored by SDFormatter you may need to reformat small +cards that have been formatted FAT12 to force the volume type to be FAT16. + +If you reformat the SD card with an OS utility, choose a cluster size that +will result in: + +4084 < CountOfClusters && CountOfClusters < 65525 + +The volume will then be FAT16. + +If you are formatting an SD card on OS X or Linux, be sure to use the first +partition. Format this partition with a cluster count in above range. + +\section References References + +Adafruit Industries: + +http://www.adafruit.com/ + +http://www.ladyada.net/make/waveshield/ + +The Arduino site: + +http://www.arduino.cc/ + +For more information about FAT file systems see: + +http://www.microsoft.com/whdc/system/platform/firmware/fatgen.mspx + +For information about using SD cards as SPI devices see: + +http://www.sdcard.org/developers/tech/sdcard/pls/Simplified_Physical_Layer_Spec.pdf + +The ATmega328 datasheet: + +http://www.atmel.com/dyn/resources/prod_documents/doc8161.pdf + + + */ diff --git a/arduino-0022-linux-x64/libraries/SD/utility/SdFile.cpp b/arduino-0022-linux-x64/libraries/SD/utility/SdFile.cpp new file mode 100644 index 0000000..3eb58f4 --- /dev/null +++ b/arduino-0022-linux-x64/libraries/SD/utility/SdFile.cpp @@ -0,0 +1,1252 @@ +/* Arduino SdFat Library + * Copyright (C) 2009 by William Greiman + * + * This file is part of the Arduino SdFat Library + * + * This Library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with the Arduino SdFat Library. If not, see + * . + */ +#include +#include +#include +//------------------------------------------------------------------------------ +// callback function for date/time +void (*SdFile::dateTime_)(uint16_t* date, uint16_t* time) = NULL; + +#if ALLOW_DEPRECATED_FUNCTIONS +// suppress cpplint warnings with NOLINT comment +void (*SdFile::oldDateTime_)(uint16_t& date, uint16_t& time) = NULL; // NOLINT +#endif // ALLOW_DEPRECATED_FUNCTIONS +//------------------------------------------------------------------------------ +// add a cluster to a file +uint8_t SdFile::addCluster() { + if (!vol_->allocContiguous(1, &curCluster_)) return false; + + // if first cluster of file link to directory entry + if (firstCluster_ == 0) { + firstCluster_ = curCluster_; + flags_ |= F_FILE_DIR_DIRTY; + } + return true; +} +//------------------------------------------------------------------------------ +// Add a cluster to a directory file and zero the cluster. +// return with first block of cluster in the cache +uint8_t SdFile::addDirCluster(void) { + if (!addCluster()) return false; + + // zero data in cluster insure first cluster is in cache + uint32_t block = vol_->clusterStartBlock(curCluster_); + for (uint8_t i = vol_->blocksPerCluster_; i != 0; i--) { + if (!SdVolume::cacheZeroBlock(block + i - 1)) return false; + } + // Increase directory file size by cluster size + fileSize_ += 512UL << vol_->clusterSizeShift_; + return true; +} +//------------------------------------------------------------------------------ +// cache a file's directory entry +// return pointer to cached entry or null for failure +dir_t* SdFile::cacheDirEntry(uint8_t action) { + if (!SdVolume::cacheRawBlock(dirBlock_, action)) return NULL; + return SdVolume::cacheBuffer_.dir + dirIndex_; +} +//------------------------------------------------------------------------------ +/** + * Close a file and force cached data and directory information + * to be written to the storage device. + * + * \return The value one, true, is returned for success and + * the value zero, false, is returned for failure. + * Reasons for failure include no file is open or an I/O error. + */ +uint8_t SdFile::close(void) { + if (!sync())return false; + type_ = FAT_FILE_TYPE_CLOSED; + return true; +} +//------------------------------------------------------------------------------ +/** + * Check for contiguous file and return its raw block range. + * + * \param[out] bgnBlock the first block address for the file. + * \param[out] endBlock the last block address for the file. + * + * \return The value one, true, is returned for success and + * the value zero, false, is returned for failure. + * Reasons for failure include file is not contiguous, file has zero length + * or an I/O error occurred. + */ +uint8_t SdFile::contiguousRange(uint32_t* bgnBlock, uint32_t* endBlock) { + // error if no blocks + if (firstCluster_ == 0) return false; + + for (uint32_t c = firstCluster_; ; c++) { + uint32_t next; + if (!vol_->fatGet(c, &next)) return false; + + // check for contiguous + if (next != (c + 1)) { + // error if not end of chain + if (!vol_->isEOC(next)) return false; + *bgnBlock = vol_->clusterStartBlock(firstCluster_); + *endBlock = vol_->clusterStartBlock(c) + + vol_->blocksPerCluster_ - 1; + return true; + } + } +} +//------------------------------------------------------------------------------ +/** + * Create and open a new contiguous file of a specified size. + * + * \note This function only supports short DOS 8.3 names. + * See open() for more information. + * + * \param[in] dirFile The directory where the file will be created. + * \param[in] fileName A valid DOS 8.3 file name. + * \param[in] size The desired file size. + * + * \return The value one, true, is returned for success and + * the value zero, false, is returned for failure. + * Reasons for failure include \a fileName contains + * an invalid DOS 8.3 file name, the FAT volume has not been initialized, + * a file is already open, the file already exists, the root + * directory is full or an I/O error. + * + */ +uint8_t SdFile::createContiguous(SdFile* dirFile, + const char* fileName, uint32_t size) { + // don't allow zero length file + if (size == 0) return false; + if (!open(dirFile, fileName, O_CREAT | O_EXCL | O_RDWR)) return false; + + // calculate number of clusters needed + uint32_t count = ((size - 1) >> (vol_->clusterSizeShift_ + 9)) + 1; + + // allocate clusters + if (!vol_->allocContiguous(count, &firstCluster_)) { + remove(); + return false; + } + fileSize_ = size; + + // insure sync() will update dir entry + flags_ |= F_FILE_DIR_DIRTY; + return sync(); +} +//------------------------------------------------------------------------------ +/** + * Return a files directory entry + * + * \param[out] dir Location for return of the files directory entry. + * + * \return The value one, true, is returned for success and + * the value zero, false, is returned for failure. + */ +uint8_t SdFile::dirEntry(dir_t* dir) { + // make sure fields on SD are correct + if (!sync()) return false; + + // read entry + dir_t* p = cacheDirEntry(SdVolume::CACHE_FOR_READ); + if (!p) return false; + + // copy to caller's struct + memcpy(dir, p, sizeof(dir_t)); + return true; +} +//------------------------------------------------------------------------------ +/** + * Format the name field of \a dir into the 13 byte array + * \a name in standard 8.3 short name format. + * + * \param[in] dir The directory structure containing the name. + * \param[out] name A 13 byte char array for the formatted name. + */ +void SdFile::dirName(const dir_t& dir, char* name) { + uint8_t j = 0; + for (uint8_t i = 0; i < 11; i++) { + if (dir.name[i] == ' ')continue; + if (i == 8) name[j++] = '.'; + name[j++] = dir.name[i]; + } + name[j] = 0; +} +//------------------------------------------------------------------------------ +/** List directory contents to Serial. + * + * \param[in] flags The inclusive OR of + * + * LS_DATE - %Print file modification date + * + * LS_SIZE - %Print file size. + * + * LS_R - Recursive list of subdirectories. + * + * \param[in] indent Amount of space before file name. Used for recursive + * list to indicate subdirectory level. + */ +void SdFile::ls(uint8_t flags, uint8_t indent) { + dir_t* p; + + rewind(); + while ((p = readDirCache())) { + // done if past last used entry + if (p->name[0] == DIR_NAME_FREE) break; + + // skip deleted entry and entries for . and .. + if (p->name[0] == DIR_NAME_DELETED || p->name[0] == '.') continue; + + // only list subdirectories and files + if (!DIR_IS_FILE_OR_SUBDIR(p)) continue; + + // print any indent spaces + for (int8_t i = 0; i < indent; i++) Serial.print(' '); + + // print file name with possible blank fill + printDirName(*p, flags & (LS_DATE | LS_SIZE) ? 14 : 0); + + // print modify date/time if requested + if (flags & LS_DATE) { + printFatDate(p->lastWriteDate); + Serial.print(' '); + printFatTime(p->lastWriteTime); + } + // print size if requested + if (!DIR_IS_SUBDIR(p) && (flags & LS_SIZE)) { + Serial.print(' '); + Serial.print(p->fileSize); + } + Serial.println(); + + // list subdirectory content if requested + if ((flags & LS_R) && DIR_IS_SUBDIR(p)) { + uint16_t index = curPosition()/32 - 1; + SdFile s; + if (s.open(this, index, O_READ)) s.ls(flags, indent + 2); + seekSet(32 * (index + 1)); + } + } +} +//------------------------------------------------------------------------------ +// format directory name field from a 8.3 name string +uint8_t SdFile::make83Name(const char* str, uint8_t* name) { + uint8_t c; + uint8_t n = 7; // max index for part before dot + uint8_t i = 0; + // blank fill name and extension + while (i < 11) name[i++] = ' '; + i = 0; + while ((c = *str++) != '\0') { + if (c == '.') { + if (n == 10) return false; // only one dot allowed + n = 10; // max index for full 8.3 name + i = 8; // place for extension + } else { + // illegal FAT characters + PGM_P p = PSTR("|<>^+=?/[];,*\"\\"); + uint8_t b; + while ((b = pgm_read_byte(p++))) if (b == c) return false; + // check size and only allow ASCII printable characters + if (i > n || c < 0X21 || c > 0X7E)return false; + // only upper case allowed in 8.3 names - convert lower to upper + name[i++] = c < 'a' || c > 'z' ? c : c + ('A' - 'a'); + } + } + // must have a file name, extension is optional + return name[0] != ' '; +} +//------------------------------------------------------------------------------ +/** Make a new directory. + * + * \param[in] dir An open SdFat instance for the directory that will containing + * the new directory. + * + * \param[in] dirName A valid 8.3 DOS name for the new directory. + * + * \return The value one, true, is returned for success and + * the value zero, false, is returned for failure. + * Reasons for failure include this SdFile is already open, \a dir is not a + * directory, \a dirName is invalid or already exists in \a dir. + */ +uint8_t SdFile::makeDir(SdFile* dir, const char* dirName) { + dir_t d; + + // create a normal file + if (!open(dir, dirName, O_CREAT | O_EXCL | O_RDWR)) return false; + + // convert SdFile to directory + flags_ = O_READ; + type_ = FAT_FILE_TYPE_SUBDIR; + + // allocate and zero first cluster + if (!addDirCluster())return false; + + // force entry to SD + if (!sync()) return false; + + // cache entry - should already be in cache due to sync() call + dir_t* p = cacheDirEntry(SdVolume::CACHE_FOR_WRITE); + if (!p) return false; + + // change directory entry attribute + p->attributes = DIR_ATT_DIRECTORY; + + // make entry for '.' + memcpy(&d, p, sizeof(d)); + for (uint8_t i = 1; i < 11; i++) d.name[i] = ' '; + d.name[0] = '.'; + + // cache block for '.' and '..' + uint32_t block = vol_->clusterStartBlock(firstCluster_); + if (!SdVolume::cacheRawBlock(block, SdVolume::CACHE_FOR_WRITE)) return false; + + // copy '.' to block + memcpy(&SdVolume::cacheBuffer_.dir[0], &d, sizeof(d)); + + // make entry for '..' + d.name[1] = '.'; + if (dir->isRoot()) { + d.firstClusterLow = 0; + d.firstClusterHigh = 0; + } else { + d.firstClusterLow = dir->firstCluster_ & 0XFFFF; + d.firstClusterHigh = dir->firstCluster_ >> 16; + } + // copy '..' to block + memcpy(&SdVolume::cacheBuffer_.dir[1], &d, sizeof(d)); + + // set position after '..' + curPosition_ = 2 * sizeof(d); + + // write first block + return SdVolume::cacheFlush(); +} +//------------------------------------------------------------------------------ +/** + * Open a file or directory by name. + * + * \param[in] dirFile An open SdFat instance for the directory containing the + * file to be opened. + * + * \param[in] fileName A valid 8.3 DOS name for a file to be opened. + * + * \param[in] oflag Values for \a oflag are constructed by a bitwise-inclusive + * OR of flags from the following list + * + * O_READ - Open for reading. + * + * O_RDONLY - Same as O_READ. + * + * O_WRITE - Open for writing. + * + * O_WRONLY - Same as O_WRITE. + * + * O_RDWR - Open for reading and writing. + * + * O_APPEND - If set, the file offset shall be set to the end of the + * file prior to each write. + * + * O_CREAT - If the file exists, this flag has no effect except as noted + * under O_EXCL below. Otherwise, the file shall be created + * + * O_EXCL - If O_CREAT and O_EXCL are set, open() shall fail if the file exists. + * + * O_SYNC - Call sync() after each write. This flag should not be used with + * write(uint8_t), write_P(PGM_P), writeln_P(PGM_P), or the Arduino Print class. + * These functions do character at a time writes so sync() will be called + * after each byte. + * + * O_TRUNC - If the file exists and is a regular file, and the file is + * successfully opened and is not read only, its length shall be truncated to 0. + * + * \note Directory files must be opened read only. Write and truncation is + * not allowed for directory files. + * + * \return The value one, true, is returned for success and + * the value zero, false, is returned for failure. + * Reasons for failure include this SdFile is already open, \a difFile is not + * a directory, \a fileName is invalid, the file does not exist + * or can't be opened in the access mode specified by oflag. + */ +uint8_t SdFile::open(SdFile* dirFile, const char* fileName, uint8_t oflag) { + uint8_t dname[11]; + dir_t* p; + + // error if already open + if (isOpen())return false; + + if (!make83Name(fileName, dname)) return false; + vol_ = dirFile->vol_; + dirFile->rewind(); + + // bool for empty entry found + uint8_t emptyFound = false; + + // search for file + while (dirFile->curPosition_ < dirFile->fileSize_) { + uint8_t index = 0XF & (dirFile->curPosition_ >> 5); + p = dirFile->readDirCache(); + if (p == NULL) return false; + + if (p->name[0] == DIR_NAME_FREE || p->name[0] == DIR_NAME_DELETED) { + // remember first empty slot + if (!emptyFound) { + emptyFound = true; + dirIndex_ = index; + dirBlock_ = SdVolume::cacheBlockNumber_; + } + // done if no entries follow + if (p->name[0] == DIR_NAME_FREE) break; + } else if (!memcmp(dname, p->name, 11)) { + // don't open existing file if O_CREAT and O_EXCL + if ((oflag & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)) return false; + + // open found file + return openCachedEntry(0XF & index, oflag); + } + } + // only create file if O_CREAT and O_WRITE + if ((oflag & (O_CREAT | O_WRITE)) != (O_CREAT | O_WRITE)) return false; + + // cache found slot or add cluster if end of file + if (emptyFound) { + p = cacheDirEntry(SdVolume::CACHE_FOR_WRITE); + if (!p) return false; + } else { + if (dirFile->type_ == FAT_FILE_TYPE_ROOT16) return false; + + // add and zero cluster for dirFile - first cluster is in cache for write + if (!dirFile->addDirCluster()) return false; + + // use first entry in cluster + dirIndex_ = 0; + p = SdVolume::cacheBuffer_.dir; + } + // initialize as empty file + memset(p, 0, sizeof(dir_t)); + memcpy(p->name, dname, 11); + + // set timestamps + if (dateTime_) { + // call user function + dateTime_(&p->creationDate, &p->creationTime); + } else { + // use default date/time + p->creationDate = FAT_DEFAULT_DATE; + p->creationTime = FAT_DEFAULT_TIME; + } + p->lastAccessDate = p->creationDate; + p->lastWriteDate = p->creationDate; + p->lastWriteTime = p->creationTime; + + // force write of entry to SD + if (!SdVolume::cacheFlush()) return false; + + // open entry in cache + return openCachedEntry(dirIndex_, oflag); +} +//------------------------------------------------------------------------------ +/** + * Open a file by index. + * + * \param[in] dirFile An open SdFat instance for the directory. + * + * \param[in] index The \a index of the directory entry for the file to be + * opened. The value for \a index is (directory file position)/32. + * + * \param[in] oflag Values for \a oflag are constructed by a bitwise-inclusive + * OR of flags O_READ, O_WRITE, O_TRUNC, and O_SYNC. + * + * See open() by fileName for definition of flags and return values. + * + */ +uint8_t SdFile::open(SdFile* dirFile, uint16_t index, uint8_t oflag) { + // error if already open + if (isOpen())return false; + + // don't open existing file if O_CREAT and O_EXCL - user call error + if ((oflag & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)) return false; + + vol_ = dirFile->vol_; + + // seek to location of entry + if (!dirFile->seekSet(32 * index)) return false; + + // read entry into cache + dir_t* p = dirFile->readDirCache(); + if (p == NULL) return false; + + // error if empty slot or '.' or '..' + if (p->name[0] == DIR_NAME_FREE || + p->name[0] == DIR_NAME_DELETED || p->name[0] == '.') { + return false; + } + // open cached entry + return openCachedEntry(index & 0XF, oflag); +} +//------------------------------------------------------------------------------ +// open a cached directory entry. Assumes vol_ is initializes +uint8_t SdFile::openCachedEntry(uint8_t dirIndex, uint8_t oflag) { + // location of entry in cache + dir_t* p = SdVolume::cacheBuffer_.dir + dirIndex; + + // write or truncate is an error for a directory or read-only file + if (p->attributes & (DIR_ATT_READ_ONLY | DIR_ATT_DIRECTORY)) { + if (oflag & (O_WRITE | O_TRUNC)) return false; + } + // remember location of directory entry on SD + dirIndex_ = dirIndex; + dirBlock_ = SdVolume::cacheBlockNumber_; + + // copy first cluster number for directory fields + firstCluster_ = (uint32_t)p->firstClusterHigh << 16; + firstCluster_ |= p->firstClusterLow; + + // make sure it is a normal file or subdirectory + if (DIR_IS_FILE(p)) { + fileSize_ = p->fileSize; + type_ = FAT_FILE_TYPE_NORMAL; + } else if (DIR_IS_SUBDIR(p)) { + if (!vol_->chainSize(firstCluster_, &fileSize_)) return false; + type_ = FAT_FILE_TYPE_SUBDIR; + } else { + return false; + } + // save open flags for read/write + flags_ = oflag & (O_ACCMODE | O_SYNC | O_APPEND); + + // set to start of file + curCluster_ = 0; + curPosition_ = 0; + + // truncate file to zero length if requested + if (oflag & O_TRUNC) return truncate(0); + return true; +} +//------------------------------------------------------------------------------ +/** + * Open a volume's root directory. + * + * \param[in] vol The FAT volume containing the root directory to be opened. + * + * \return The value one, true, is returned for success and + * the value zero, false, is returned for failure. + * Reasons for failure include the FAT volume has not been initialized + * or it a FAT12 volume. + */ +uint8_t SdFile::openRoot(SdVolume* vol) { + // error if file is already open + if (isOpen()) return false; + + if (vol->fatType() == 16) { + type_ = FAT_FILE_TYPE_ROOT16; + firstCluster_ = 0; + fileSize_ = 32 * vol->rootDirEntryCount(); + } else if (vol->fatType() == 32) { + type_ = FAT_FILE_TYPE_ROOT32; + firstCluster_ = vol->rootDirStart(); + if (!vol->chainSize(firstCluster_, &fileSize_)) return false; + } else { + // volume is not initialized or FAT12 + return false; + } + vol_ = vol; + // read only + flags_ = O_READ; + + // set to start of file + curCluster_ = 0; + curPosition_ = 0; + + // root has no directory entry + dirBlock_ = 0; + dirIndex_ = 0; + return true; +} +//------------------------------------------------------------------------------ +/** %Print the name field of a directory entry in 8.3 format to Serial. + * + * \param[in] dir The directory structure containing the name. + * \param[in] width Blank fill name if length is less than \a width. + */ +void SdFile::printDirName(const dir_t& dir, uint8_t width) { + uint8_t w = 0; + for (uint8_t i = 0; i < 11; i++) { + if (dir.name[i] == ' ')continue; + if (i == 8) { + Serial.print('.'); + w++; + } + Serial.print(dir.name[i]); + w++; + } + if (DIR_IS_SUBDIR(&dir)) { + Serial.print('/'); + w++; + } + while (w < width) { + Serial.print(' '); + w++; + } +} +//------------------------------------------------------------------------------ +/** %Print a directory date field to Serial. + * + * Format is yyyy-mm-dd. + * + * \param[in] fatDate The date field from a directory entry. + */ +void SdFile::printFatDate(uint16_t fatDate) { + Serial.print(FAT_YEAR(fatDate)); + Serial.print('-'); + printTwoDigits(FAT_MONTH(fatDate)); + Serial.print('-'); + printTwoDigits(FAT_DAY(fatDate)); +} +//------------------------------------------------------------------------------ +/** %Print a directory time field to Serial. + * + * Format is hh:mm:ss. + * + * \param[in] fatTime The time field from a directory entry. + */ +void SdFile::printFatTime(uint16_t fatTime) { + printTwoDigits(FAT_HOUR(fatTime)); + Serial.print(':'); + printTwoDigits(FAT_MINUTE(fatTime)); + Serial.print(':'); + printTwoDigits(FAT_SECOND(fatTime)); +} +//------------------------------------------------------------------------------ +/** %Print a value as two digits to Serial. + * + * \param[in] v Value to be printed, 0 <= \a v <= 99 + */ +void SdFile::printTwoDigits(uint8_t v) { + char str[3]; + str[0] = '0' + v/10; + str[1] = '0' + v % 10; + str[2] = 0; + Serial.print(str); +} +//------------------------------------------------------------------------------ +/** + * Read data from a file starting at the current position. + * + * \param[out] buf Pointer to the location that will receive the data. + * + * \param[in] nbyte Maximum number of bytes to read. + * + * \return For success read() returns the number of bytes read. + * A value less than \a nbyte, including zero, will be returned + * if end of file is reached. + * If an error occurs, read() returns -1. Possible errors include + * read() called before a file has been opened, corrupt file system + * or an I/O error occurred. + */ +int16_t SdFile::read(void* buf, uint16_t nbyte) { + uint8_t* dst = reinterpret_cast(buf); + + // error if not open or write only + if (!isOpen() || !(flags_ & O_READ)) return -1; + + // max bytes left in file + if (nbyte > (fileSize_ - curPosition_)) nbyte = fileSize_ - curPosition_; + + // amount left to read + uint16_t toRead = nbyte; + while (toRead > 0) { + uint32_t block; // raw device block number + uint16_t offset = curPosition_ & 0X1FF; // offset in block + if (type_ == FAT_FILE_TYPE_ROOT16) { + block = vol_->rootDirStart() + (curPosition_ >> 9); + } else { + uint8_t blockOfCluster = vol_->blockOfCluster(curPosition_); + if (offset == 0 && blockOfCluster == 0) { + // start of new cluster + if (curPosition_ == 0) { + // use first cluster in file + curCluster_ = firstCluster_; + } else { + // get next cluster from FAT + if (!vol_->fatGet(curCluster_, &curCluster_)) return -1; + } + } + block = vol_->clusterStartBlock(curCluster_) + blockOfCluster; + } + uint16_t n = toRead; + + // amount to be read from current block + if (n > (512 - offset)) n = 512 - offset; + + // no buffering needed if n == 512 or user requests no buffering + if ((unbufferedRead() || n == 512) && + block != SdVolume::cacheBlockNumber_) { + if (!vol_->readData(block, offset, n, dst)) return -1; + dst += n; + } else { + // read block to cache and copy data to caller + if (!SdVolume::cacheRawBlock(block, SdVolume::CACHE_FOR_READ)) return -1; + uint8_t* src = SdVolume::cacheBuffer_.data + offset; + uint8_t* end = src + n; + while (src != end) *dst++ = *src++; + } + curPosition_ += n; + toRead -= n; + } + return nbyte; +} +//------------------------------------------------------------------------------ +/** + * Read the next directory entry from a directory file. + * + * \param[out] dir The dir_t struct that will receive the data. + * + * \return For success readDir() returns the number of bytes read. + * A value of zero will be returned if end of file is reached. + * If an error occurs, readDir() returns -1. Possible errors include + * readDir() called before a directory has been opened, this is not + * a directory file or an I/O error occurred. + */ +int8_t SdFile::readDir(dir_t* dir) { + int8_t n; + // if not a directory file or miss-positioned return an error + if (!isDir() || (0X1F & curPosition_)) return -1; + + while ((n = read(dir, sizeof(dir_t))) == sizeof(dir_t)) { + // last entry if DIR_NAME_FREE + if (dir->name[0] == DIR_NAME_FREE) break; + // skip empty entries and entry for . and .. + if (dir->name[0] == DIR_NAME_DELETED || dir->name[0] == '.') continue; + // return if normal file or subdirectory + if (DIR_IS_FILE_OR_SUBDIR(dir)) return n; + } + // error, end of file, or past last entry + return n < 0 ? -1 : 0; +} +//------------------------------------------------------------------------------ +// Read next directory entry into the cache +// Assumes file is correctly positioned +dir_t* SdFile::readDirCache(void) { + // error if not directory + if (!isDir()) return NULL; + + // index of entry in cache + uint8_t i = (curPosition_ >> 5) & 0XF; + + // use read to locate and cache block + if (read() < 0) return NULL; + + // advance to next entry + curPosition_ += 31; + + // return pointer to entry + return (SdVolume::cacheBuffer_.dir + i); +} +//------------------------------------------------------------------------------ +/** + * Remove a file. + * + * The directory entry and all data for the file are deleted. + * + * \note This function should not be used to delete the 8.3 version of a + * file that has a long name. For example if a file has the long name + * "New Text Document.txt" you should not delete the 8.3 name "NEWTEX~1.TXT". + * + * \return The value one, true, is returned for success and + * the value zero, false, is returned for failure. + * Reasons for failure include the file read-only, is a directory, + * or an I/O error occurred. + */ +uint8_t SdFile::remove(void) { + // free any clusters - will fail if read-only or directory + if (!truncate(0)) return false; + + // cache directory entry + dir_t* d = cacheDirEntry(SdVolume::CACHE_FOR_WRITE); + if (!d) return false; + + // mark entry deleted + d->name[0] = DIR_NAME_DELETED; + + // set this SdFile closed + type_ = FAT_FILE_TYPE_CLOSED; + + // write entry to SD + return SdVolume::cacheFlush(); +} +//------------------------------------------------------------------------------ +/** + * Remove a file. + * + * The directory entry and all data for the file are deleted. + * + * \param[in] dirFile The directory that contains the file. + * \param[in] fileName The name of the file to be removed. + * + * \note This function should not be used to delete the 8.3 version of a + * file that has a long name. For example if a file has the long name + * "New Text Document.txt" you should not delete the 8.3 name "NEWTEX~1.TXT". + * + * \return The value one, true, is returned for success and + * the value zero, false, is returned for failure. + * Reasons for failure include the file is a directory, is read only, + * \a dirFile is not a directory, \a fileName is not found + * or an I/O error occurred. + */ +uint8_t SdFile::remove(SdFile* dirFile, const char* fileName) { + SdFile file; + if (!file.open(dirFile, fileName, O_WRITE)) return false; + return file.remove(); +} +//------------------------------------------------------------------------------ +/** Remove a directory file. + * + * The directory file will be removed only if it is empty and is not the + * root directory. rmDir() follows DOS and Windows and ignores the + * read-only attribute for the directory. + * + * \note This function should not be used to delete the 8.3 version of a + * directory that has a long name. For example if a directory has the + * long name "New folder" you should not delete the 8.3 name "NEWFOL~1". + * + * \return The value one, true, is returned for success and + * the value zero, false, is returned for failure. + * Reasons for failure include the file is not a directory, is the root + * directory, is not empty, or an I/O error occurred. + */ +uint8_t SdFile::rmDir(void) { + // must be open subdirectory + if (!isSubDir()) return false; + + rewind(); + + // make sure directory is empty + while (curPosition_ < fileSize_) { + dir_t* p = readDirCache(); + if (p == NULL) return false; + // done if past last used entry + if (p->name[0] == DIR_NAME_FREE) break; + // skip empty slot or '.' or '..' + if (p->name[0] == DIR_NAME_DELETED || p->name[0] == '.') continue; + // error not empty + if (DIR_IS_FILE_OR_SUBDIR(p)) return false; + } + // convert empty directory to normal file for remove + type_ = FAT_FILE_TYPE_NORMAL; + flags_ |= O_WRITE; + return remove(); +} +//------------------------------------------------------------------------------ +/** Recursively delete a directory and all contained files. + * + * This is like the Unix/Linux 'rm -rf *' if called with the root directory + * hence the name. + * + * Warning - This will remove all contents of the directory including + * subdirectories. The directory will then be removed if it is not root. + * The read-only attribute for files will be ignored. + * + * \note This function should not be used to delete the 8.3 version of + * a directory that has a long name. See remove() and rmDir(). + * + * \return The value one, true, is returned for success and + * the value zero, false, is returned for failure. + */ +uint8_t SdFile::rmRfStar(void) { + rewind(); + while (curPosition_ < fileSize_) { + SdFile f; + + // remember position + uint16_t index = curPosition_/32; + + dir_t* p = readDirCache(); + if (!p) return false; + + // done if past last entry + if (p->name[0] == DIR_NAME_FREE) break; + + // skip empty slot or '.' or '..' + if (p->name[0] == DIR_NAME_DELETED || p->name[0] == '.') continue; + + // skip if part of long file name or volume label in root + if (!DIR_IS_FILE_OR_SUBDIR(p)) continue; + + if (!f.open(this, index, O_READ)) return false; + if (f.isSubDir()) { + // recursively delete + if (!f.rmRfStar()) return false; + } else { + // ignore read-only + f.flags_ |= O_WRITE; + if (!f.remove()) return false; + } + // position to next entry if required + if (curPosition_ != (32*(index + 1))) { + if (!seekSet(32*(index + 1))) return false; + } + } + // don't try to delete root + if (isRoot()) return true; + return rmDir(); +} +//------------------------------------------------------------------------------ +/** + * Sets a file's position. + * + * \param[in] pos The new position in bytes from the beginning of the file. + * + * \return The value one, true, is returned for success and + * the value zero, false, is returned for failure. + */ +uint8_t SdFile::seekSet(uint32_t pos) { + // error if file not open or seek past end of file + if (!isOpen() || pos > fileSize_) return false; + + if (type_ == FAT_FILE_TYPE_ROOT16) { + curPosition_ = pos; + return true; + } + if (pos == 0) { + // set position to start of file + curCluster_ = 0; + curPosition_ = 0; + return true; + } + // calculate cluster index for cur and new position + uint32_t nCur = (curPosition_ - 1) >> (vol_->clusterSizeShift_ + 9); + uint32_t nNew = (pos - 1) >> (vol_->clusterSizeShift_ + 9); + + if (nNew < nCur || curPosition_ == 0) { + // must follow chain from first cluster + curCluster_ = firstCluster_; + } else { + // advance from curPosition + nNew -= nCur; + } + while (nNew--) { + if (!vol_->fatGet(curCluster_, &curCluster_)) return false; + } + curPosition_ = pos; + return true; +} +//------------------------------------------------------------------------------ +/** + * The sync() call causes all modified data and directory fields + * to be written to the storage device. + * + * \return The value one, true, is returned for success and + * the value zero, false, is returned for failure. + * Reasons for failure include a call to sync() before a file has been + * opened or an I/O error. + */ +uint8_t SdFile::sync(void) { + // only allow open files and directories + if (!isOpen()) return false; + + if (flags_ & F_FILE_DIR_DIRTY) { + dir_t* d = cacheDirEntry(SdVolume::CACHE_FOR_WRITE); + if (!d) return false; + + // do not set filesize for dir files + if (!isDir()) d->fileSize = fileSize_; + + // update first cluster fields + d->firstClusterLow = firstCluster_ & 0XFFFF; + d->firstClusterHigh = firstCluster_ >> 16; + + // set modify time if user supplied a callback date/time function + if (dateTime_) { + dateTime_(&d->lastWriteDate, &d->lastWriteTime); + d->lastAccessDate = d->lastWriteDate; + } + // clear directory dirty + flags_ &= ~F_FILE_DIR_DIRTY; + } + return SdVolume::cacheFlush(); +} +//------------------------------------------------------------------------------ +/** + * Set a file's timestamps in its directory entry. + * + * \param[in] flags Values for \a flags are constructed by a bitwise-inclusive + * OR of flags from the following list + * + * T_ACCESS - Set the file's last access date. + * + * T_CREATE - Set the file's creation date and time. + * + * T_WRITE - Set the file's last write/modification date and time. + * + * \param[in] year Valid range 1980 - 2107 inclusive. + * + * \param[in] month Valid range 1 - 12 inclusive. + * + * \param[in] day Valid range 1 - 31 inclusive. + * + * \param[in] hour Valid range 0 - 23 inclusive. + * + * \param[in] minute Valid range 0 - 59 inclusive. + * + * \param[in] second Valid range 0 - 59 inclusive + * + * \note It is possible to set an invalid date since there is no check for + * the number of days in a month. + * + * \note + * Modify and access timestamps may be overwritten if a date time callback + * function has been set by dateTimeCallback(). + * + * \return The value one, true, is returned for success and + * the value zero, false, is returned for failure. + */ +uint8_t SdFile::timestamp(uint8_t flags, uint16_t year, uint8_t month, + uint8_t day, uint8_t hour, uint8_t minute, uint8_t second) { + if (!isOpen() + || year < 1980 + || year > 2107 + || month < 1 + || month > 12 + || day < 1 + || day > 31 + || hour > 23 + || minute > 59 + || second > 59) { + return false; + } + dir_t* d = cacheDirEntry(SdVolume::CACHE_FOR_WRITE); + if (!d) return false; + + uint16_t dirDate = FAT_DATE(year, month, day); + uint16_t dirTime = FAT_TIME(hour, minute, second); + if (flags & T_ACCESS) { + d->lastAccessDate = dirDate; + } + if (flags & T_CREATE) { + d->creationDate = dirDate; + d->creationTime = dirTime; + // seems to be units of 1/100 second not 1/10 as Microsoft states + d->creationTimeTenths = second & 1 ? 100 : 0; + } + if (flags & T_WRITE) { + d->lastWriteDate = dirDate; + d->lastWriteTime = dirTime; + } + SdVolume::cacheSetDirty(); + return sync(); +} +//------------------------------------------------------------------------------ +/** + * Truncate a file to a specified length. The current file position + * will be maintained if it is less than or equal to \a length otherwise + * it will be set to end of file. + * + * \param[in] length The desired length for the file. + * + * \return The value one, true, is returned for success and + * the value zero, false, is returned for failure. + * Reasons for failure include file is read only, file is a directory, + * \a length is greater than the current file size or an I/O error occurs. + */ +uint8_t SdFile::truncate(uint32_t length) { +// error if not a normal file or read-only + if (!isFile() || !(flags_ & O_WRITE)) return false; + + // error if length is greater than current size + if (length > fileSize_) return false; + + // fileSize and length are zero - nothing to do + if (fileSize_ == 0) return true; + + // remember position for seek after truncation + uint32_t newPos = curPosition_ > length ? length : curPosition_; + + // position to last cluster in truncated file + if (!seekSet(length)) return false; + + if (length == 0) { + // free all clusters + if (!vol_->freeChain(firstCluster_)) return false; + firstCluster_ = 0; + } else { + uint32_t toFree; + if (!vol_->fatGet(curCluster_, &toFree)) return false; + + if (!vol_->isEOC(toFree)) { + // free extra clusters + if (!vol_->freeChain(toFree)) return false; + + // current cluster is end of chain + if (!vol_->fatPutEOC(curCluster_)) return false; + } + } + fileSize_ = length; + + // need to update directory entry + flags_ |= F_FILE_DIR_DIRTY; + + if (!sync()) return false; + + // set file to correct position + return seekSet(newPos); +} +//------------------------------------------------------------------------------ +/** + * Write data to an open file. + * + * \note Data is moved to the cache but may not be written to the + * storage device until sync() is called. + * + * \param[in] buf Pointer to the location of the data to be written. + * + * \param[in] nbyte Number of bytes to write. + * + * \return For success write() returns the number of bytes written, always + * \a nbyte. If an error occurs, write() returns -1. Possible errors + * include write() is called before a file has been opened, write is called + * for a read-only file, device is full, a corrupt file system or an I/O error. + * + */ +int16_t SdFile::write(const void* buf, uint16_t nbyte) { + // convert void* to uint8_t* - must be before goto statements + const uint8_t* src = reinterpret_cast(buf); + + // number of bytes left to write - must be before goto statements + uint16_t nToWrite = nbyte; + + // error if not a normal file or is read-only + if (!isFile() || !(flags_ & O_WRITE)) goto writeErrorReturn; + + // seek to end of file if append flag + if ((flags_ & O_APPEND) && curPosition_ != fileSize_) { + if (!seekEnd()) goto writeErrorReturn; + } + + while (nToWrite > 0) { + uint8_t blockOfCluster = vol_->blockOfCluster(curPosition_); + uint16_t blockOffset = curPosition_ & 0X1FF; + if (blockOfCluster == 0 && blockOffset == 0) { + // start of new cluster + if (curCluster_ == 0) { + if (firstCluster_ == 0) { + // allocate first cluster of file + if (!addCluster()) goto writeErrorReturn; + } else { + curCluster_ = firstCluster_; + } + } else { + uint32_t next; + if (!vol_->fatGet(curCluster_, &next)) return false; + if (vol_->isEOC(next)) { + // add cluster if at end of chain + if (!addCluster()) goto writeErrorReturn; + } else { + curCluster_ = next; + } + } + } + // max space in block + uint16_t n = 512 - blockOffset; + + // lesser of space and amount to write + if (n > nToWrite) n = nToWrite; + + // block for data write + uint32_t block = vol_->clusterStartBlock(curCluster_) + blockOfCluster; + if (n == 512) { + // full block - don't need to use cache + // invalidate cache if block is in cache + if (SdVolume::cacheBlockNumber_ == block) { + SdVolume::cacheBlockNumber_ = 0XFFFFFFFF; + } + if (!vol_->writeBlock(block, src)) goto writeErrorReturn; + src += 512; + } else { + if (blockOffset == 0 && curPosition_ >= fileSize_) { + // start of new block don't need to read into cache + if (!SdVolume::cacheFlush()) goto writeErrorReturn; + SdVolume::cacheBlockNumber_ = block; + SdVolume::cacheSetDirty(); + } else { + // rewrite part of block + if (!SdVolume::cacheRawBlock(block, SdVolume::CACHE_FOR_WRITE)) { + goto writeErrorReturn; + } + } + uint8_t* dst = SdVolume::cacheBuffer_.data + blockOffset; + uint8_t* end = dst + n; + while (dst != end) *dst++ = *src++; + } + nToWrite -= n; + curPosition_ += n; + } + if (curPosition_ > fileSize_) { + // update fileSize and insure sync will update dir entry + fileSize_ = curPosition_; + flags_ |= F_FILE_DIR_DIRTY; + } else if (dateTime_ && nbyte) { + // insure sync will update modified date and time + flags_ |= F_FILE_DIR_DIRTY; + } + + if (flags_ & O_SYNC) { + if (!sync()) goto writeErrorReturn; + } + return nbyte; + + writeErrorReturn: + // return for write error + writeError = true; + return -1; +} +//------------------------------------------------------------------------------ +/** + * Write a byte to a file. Required by the Arduino Print class. + * + * Use SdFile::writeError to check for errors. + */ +void SdFile::write(uint8_t b) { + write(&b, 1); +} +//------------------------------------------------------------------------------ +/** + * Write a string to a file. Used by the Arduino Print class. + * + * Use SdFile::writeError to check for errors. + */ +void SdFile::write(const char* str) { + write(str, strlen(str)); +} +//------------------------------------------------------------------------------ +/** + * Write a PROGMEM string to a file. + * + * Use SdFile::writeError to check for errors. + */ +void SdFile::write_P(PGM_P str) { + for (uint8_t c; (c = pgm_read_byte(str)); str++) write(c); +} +//------------------------------------------------------------------------------ +/** + * Write a PROGMEM string followed by CR/LF to a file. + * + * Use SdFile::writeError to check for errors. + */ +void SdFile::writeln_P(PGM_P str) { + write_P(str); + println(); +} diff --git a/arduino-0022-linux-x64/libraries/SD/utility/SdInfo.h b/arduino-0022-linux-x64/libraries/SD/utility/SdInfo.h new file mode 100644 index 0000000..acde74d --- /dev/null +++ b/arduino-0022-linux-x64/libraries/SD/utility/SdInfo.h @@ -0,0 +1,232 @@ +/* Arduino Sd2Card Library + * Copyright (C) 2009 by William Greiman + * + * This file is part of the Arduino Sd2Card Library + * + * This Library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with the Arduino Sd2Card Library. If not, see + * . + */ +#ifndef SdInfo_h +#define SdInfo_h +#include +// Based on the document: +// +// SD Specifications +// Part 1 +// Physical Layer +// Simplified Specification +// Version 2.00 +// September 25, 2006 +// +// www.sdcard.org/developers/tech/sdcard/pls/Simplified_Physical_Layer_Spec.pdf +//------------------------------------------------------------------------------ +// SD card commands +/** GO_IDLE_STATE - init card in spi mode if CS low */ +uint8_t const CMD0 = 0X00; +/** SEND_IF_COND - verify SD Memory Card interface operating condition.*/ +uint8_t const CMD8 = 0X08; +/** SEND_CSD - read the Card Specific Data (CSD register) */ +uint8_t const CMD9 = 0X09; +/** SEND_CID - read the card identification information (CID register) */ +uint8_t const CMD10 = 0X0A; +/** SEND_STATUS - read the card status register */ +uint8_t const CMD13 = 0X0D; +/** READ_BLOCK - read a single data block from the card */ +uint8_t const CMD17 = 0X11; +/** WRITE_BLOCK - write a single data block to the card */ +uint8_t const CMD24 = 0X18; +/** WRITE_MULTIPLE_BLOCK - write blocks of data until a STOP_TRANSMISSION */ +uint8_t const CMD25 = 0X19; +/** ERASE_WR_BLK_START - sets the address of the first block to be erased */ +uint8_t const CMD32 = 0X20; +/** ERASE_WR_BLK_END - sets the address of the last block of the continuous + range to be erased*/ +uint8_t const CMD33 = 0X21; +/** ERASE - erase all previously selected blocks */ +uint8_t const CMD38 = 0X26; +/** APP_CMD - escape for application specific command */ +uint8_t const CMD55 = 0X37; +/** READ_OCR - read the OCR register of a card */ +uint8_t const CMD58 = 0X3A; +/** SET_WR_BLK_ERASE_COUNT - Set the number of write blocks to be + pre-erased before writing */ +uint8_t const ACMD23 = 0X17; +/** SD_SEND_OP_COMD - Sends host capacity support information and + activates the card's initialization process */ +uint8_t const ACMD41 = 0X29; +//------------------------------------------------------------------------------ +/** status for card in the ready state */ +uint8_t const R1_READY_STATE = 0X00; +/** status for card in the idle state */ +uint8_t const R1_IDLE_STATE = 0X01; +/** status bit for illegal command */ +uint8_t const R1_ILLEGAL_COMMAND = 0X04; +/** start data token for read or write single block*/ +uint8_t const DATA_START_BLOCK = 0XFE; +/** stop token for write multiple blocks*/ +uint8_t const STOP_TRAN_TOKEN = 0XFD; +/** start data token for write multiple blocks*/ +uint8_t const WRITE_MULTIPLE_TOKEN = 0XFC; +/** mask for data response tokens after a write block operation */ +uint8_t const DATA_RES_MASK = 0X1F; +/** write data accepted token */ +uint8_t const DATA_RES_ACCEPTED = 0X05; +//------------------------------------------------------------------------------ +typedef struct CID { + // byte 0 + uint8_t mid; // Manufacturer ID + // byte 1-2 + char oid[2]; // OEM/Application ID + // byte 3-7 + char pnm[5]; // Product name + // byte 8 + unsigned prv_m : 4; // Product revision n.m + unsigned prv_n : 4; + // byte 9-12 + uint32_t psn; // Product serial number + // byte 13 + unsigned mdt_year_high : 4; // Manufacturing date + unsigned reserved : 4; + // byte 14 + unsigned mdt_month : 4; + unsigned mdt_year_low :4; + // byte 15 + unsigned always1 : 1; + unsigned crc : 7; +}cid_t; +//------------------------------------------------------------------------------ +// CSD for version 1.00 cards +typedef struct CSDV1 { + // byte 0 + unsigned reserved1 : 6; + unsigned csd_ver : 2; + // byte 1 + uint8_t taac; + // byte 2 + uint8_t nsac; + // byte 3 + uint8_t tran_speed; + // byte 4 + uint8_t ccc_high; + // byte 5 + unsigned read_bl_len : 4; + unsigned ccc_low : 4; + // byte 6 + unsigned c_size_high : 2; + unsigned reserved2 : 2; + unsigned dsr_imp : 1; + unsigned read_blk_misalign :1; + unsigned write_blk_misalign : 1; + unsigned read_bl_partial : 1; + // byte 7 + uint8_t c_size_mid; + // byte 8 + unsigned vdd_r_curr_max : 3; + unsigned vdd_r_curr_min : 3; + unsigned c_size_low :2; + // byte 9 + unsigned c_size_mult_high : 2; + unsigned vdd_w_cur_max : 3; + unsigned vdd_w_curr_min : 3; + // byte 10 + unsigned sector_size_high : 6; + unsigned erase_blk_en : 1; + unsigned c_size_mult_low : 1; + // byte 11 + unsigned wp_grp_size : 7; + unsigned sector_size_low : 1; + // byte 12 + unsigned write_bl_len_high : 2; + unsigned r2w_factor : 3; + unsigned reserved3 : 2; + unsigned wp_grp_enable : 1; + // byte 13 + unsigned reserved4 : 5; + unsigned write_partial : 1; + unsigned write_bl_len_low : 2; + // byte 14 + unsigned reserved5: 2; + unsigned file_format : 2; + unsigned tmp_write_protect : 1; + unsigned perm_write_protect : 1; + unsigned copy : 1; + unsigned file_format_grp : 1; + // byte 15 + unsigned always1 : 1; + unsigned crc : 7; +}csd1_t; +//------------------------------------------------------------------------------ +// CSD for version 2.00 cards +typedef struct CSDV2 { + // byte 0 + unsigned reserved1 : 6; + unsigned csd_ver : 2; + // byte 1 + uint8_t taac; + // byte 2 + uint8_t nsac; + // byte 3 + uint8_t tran_speed; + // byte 4 + uint8_t ccc_high; + // byte 5 + unsigned read_bl_len : 4; + unsigned ccc_low : 4; + // byte 6 + unsigned reserved2 : 4; + unsigned dsr_imp : 1; + unsigned read_blk_misalign :1; + unsigned write_blk_misalign : 1; + unsigned read_bl_partial : 1; + // byte 7 + unsigned reserved3 : 2; + unsigned c_size_high : 6; + // byte 8 + uint8_t c_size_mid; + // byte 9 + uint8_t c_size_low; + // byte 10 + unsigned sector_size_high : 6; + unsigned erase_blk_en : 1; + unsigned reserved4 : 1; + // byte 11 + unsigned wp_grp_size : 7; + unsigned sector_size_low : 1; + // byte 12 + unsigned write_bl_len_high : 2; + unsigned r2w_factor : 3; + unsigned reserved5 : 2; + unsigned wp_grp_enable : 1; + // byte 13 + unsigned reserved6 : 5; + unsigned write_partial : 1; + unsigned write_bl_len_low : 2; + // byte 14 + unsigned reserved7: 2; + unsigned file_format : 2; + unsigned tmp_write_protect : 1; + unsigned perm_write_protect : 1; + unsigned copy : 1; + unsigned file_format_grp : 1; + // byte 15 + unsigned always1 : 1; + unsigned crc : 7; +}csd2_t; +//------------------------------------------------------------------------------ +// union of old and new style CSD register +union csd_t { + csd1_t v1; + csd2_t v2; +}; +#endif // SdInfo_h diff --git a/arduino-0022-linux-x64/libraries/SD/utility/SdVolume.cpp b/arduino-0022-linux-x64/libraries/SD/utility/SdVolume.cpp new file mode 100644 index 0000000..ece4acb --- /dev/null +++ b/arduino-0022-linux-x64/libraries/SD/utility/SdVolume.cpp @@ -0,0 +1,295 @@ +/* Arduino SdFat Library + * Copyright (C) 2009 by William Greiman + * + * This file is part of the Arduino SdFat Library + * + * This Library is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with the Arduino SdFat Library. If not, see + * . + */ +#include +//------------------------------------------------------------------------------ +// raw block cache +// init cacheBlockNumber_to invalid SD block number +uint32_t SdVolume::cacheBlockNumber_ = 0XFFFFFFFF; +cache_t SdVolume::cacheBuffer_; // 512 byte cache for Sd2Card +Sd2Card* SdVolume::sdCard_; // pointer to SD card object +uint8_t SdVolume::cacheDirty_ = 0; // cacheFlush() will write block if true +uint32_t SdVolume::cacheMirrorBlock_ = 0; // mirror block for second FAT +//------------------------------------------------------------------------------ +// find a contiguous group of clusters +uint8_t SdVolume::allocContiguous(uint32_t count, uint32_t* curCluster) { + // start of group + uint32_t bgnCluster; + + // flag to save place to start next search + uint8_t setStart; + + // set search start cluster + if (*curCluster) { + // try to make file contiguous + bgnCluster = *curCluster + 1; + + // don't save new start location + setStart = false; + } else { + // start at likely place for free cluster + bgnCluster = allocSearchStart_; + + // save next search start if one cluster + setStart = 1 == count; + } + // end of group + uint32_t endCluster = bgnCluster; + + // last cluster of FAT + uint32_t fatEnd = clusterCount_ + 1; + + // search the FAT for free clusters + for (uint32_t n = 0;; n++, endCluster++) { + // can't find space checked all clusters + if (n >= clusterCount_) return false; + + // past end - start from beginning of FAT + if (endCluster > fatEnd) { + bgnCluster = endCluster = 2; + } + uint32_t f; + if (!fatGet(endCluster, &f)) return false; + + if (f != 0) { + // cluster in use try next cluster as bgnCluster + bgnCluster = endCluster + 1; + } else if ((endCluster - bgnCluster + 1) == count) { + // done - found space + break; + } + } + // mark end of chain + if (!fatPutEOC(endCluster)) return false; + + // link clusters + while (endCluster > bgnCluster) { + if (!fatPut(endCluster - 1, endCluster)) return false; + endCluster--; + } + if (*curCluster != 0) { + // connect chains + if (!fatPut(*curCluster, bgnCluster)) return false; + } + // return first cluster number to caller + *curCluster = bgnCluster; + + // remember possible next free cluster + if (setStart) allocSearchStart_ = bgnCluster + 1; + + return true; +} +//------------------------------------------------------------------------------ +uint8_t SdVolume::cacheFlush(void) { + if (cacheDirty_) { + if (!sdCard_->writeBlock(cacheBlockNumber_, cacheBuffer_.data)) { + return false; + } + // mirror FAT tables + if (cacheMirrorBlock_) { + if (!sdCard_->writeBlock(cacheMirrorBlock_, cacheBuffer_.data)) { + return false; + } + cacheMirrorBlock_ = 0; + } + cacheDirty_ = 0; + } + return true; +} +//------------------------------------------------------------------------------ +uint8_t SdVolume::cacheRawBlock(uint32_t blockNumber, uint8_t action) { + if (cacheBlockNumber_ != blockNumber) { + if (!cacheFlush()) return false; + if (!sdCard_->readBlock(blockNumber, cacheBuffer_.data)) return false; + cacheBlockNumber_ = blockNumber; + } + cacheDirty_ |= action; + return true; +} +//------------------------------------------------------------------------------ +// cache a zero block for blockNumber +uint8_t SdVolume::cacheZeroBlock(uint32_t blockNumber) { + if (!cacheFlush()) return false; + + // loop take less flash than memset(cacheBuffer_.data, 0, 512); + for (uint16_t i = 0; i < 512; i++) { + cacheBuffer_.data[i] = 0; + } + cacheBlockNumber_ = blockNumber; + cacheSetDirty(); + return true; +} +//------------------------------------------------------------------------------ +// return the size in bytes of a cluster chain +uint8_t SdVolume::chainSize(uint32_t cluster, uint32_t* size) const { + uint32_t s = 0; + do { + if (!fatGet(cluster, &cluster)) return false; + s += 512UL << clusterSizeShift_; + } while (!isEOC(cluster)); + *size = s; + return true; +} +//------------------------------------------------------------------------------ +// Fetch a FAT entry +uint8_t SdVolume::fatGet(uint32_t cluster, uint32_t* value) const { + if (cluster > (clusterCount_ + 1)) return false; + uint32_t lba = fatStartBlock_; + lba += fatType_ == 16 ? cluster >> 8 : cluster >> 7; + if (lba != cacheBlockNumber_) { + if (!cacheRawBlock(lba, CACHE_FOR_READ)) return false; + } + if (fatType_ == 16) { + *value = cacheBuffer_.fat16[cluster & 0XFF]; + } else { + *value = cacheBuffer_.fat32[cluster & 0X7F] & FAT32MASK; + } + return true; +} +//------------------------------------------------------------------------------ +// Store a FAT entry +uint8_t SdVolume::fatPut(uint32_t cluster, uint32_t value) { + // error if reserved cluster + if (cluster < 2) return false; + + // error if not in FAT + if (cluster > (clusterCount_ + 1)) return false; + + // calculate block address for entry + uint32_t lba = fatStartBlock_; + lba += fatType_ == 16 ? cluster >> 8 : cluster >> 7; + + if (lba != cacheBlockNumber_) { + if (!cacheRawBlock(lba, CACHE_FOR_READ)) return false; + } + // store entry + if (fatType_ == 16) { + cacheBuffer_.fat16[cluster & 0XFF] = value; + } else { + cacheBuffer_.fat32[cluster & 0X7F] = value; + } + cacheSetDirty(); + + // mirror second FAT + if (fatCount_ > 1) cacheMirrorBlock_ = lba + blocksPerFat_; + return true; +} +//------------------------------------------------------------------------------ +// free a cluster chain +uint8_t SdVolume::freeChain(uint32_t cluster) { + // clear free cluster location + allocSearchStart_ = 2; + + do { + uint32_t next; + if (!fatGet(cluster, &next)) return false; + + // free cluster + if (!fatPut(cluster, 0)) return false; + + cluster = next; + } while (!isEOC(cluster)); + + return true; +} +//------------------------------------------------------------------------------ +/** + * Initialize a FAT volume. + * + * \param[in] dev The SD card where the volume is located. + * + * \param[in] part The partition to be used. Legal values for \a part are + * 1-4 to use the corresponding partition on a device formatted with + * a MBR, Master Boot Record, or zero if the device is formatted as + * a super floppy with the FAT boot sector in block zero. + * + * \return The value one, true, is returned for success and + * the value zero, false, is returned for failure. Reasons for + * failure include not finding a valid partition, not finding a valid + * FAT file system in the specified partition or an I/O error. + */ +uint8_t SdVolume::init(Sd2Card* dev, uint8_t part) { + uint32_t volumeStartBlock = 0; + sdCard_ = dev; + // if part == 0 assume super floppy with FAT boot sector in block zero + // if part > 0 assume mbr volume with partition table + if (part) { + if (part > 4)return false; + if (!cacheRawBlock(volumeStartBlock, CACHE_FOR_READ)) return false; + part_t* p = &cacheBuffer_.mbr.part[part-1]; + if ((p->boot & 0X7F) !=0 || + p->totalSectors < 100 || + p->firstSector == 0) { + // not a valid partition + return false; + } + volumeStartBlock = p->firstSector; + } + if (!cacheRawBlock(volumeStartBlock, CACHE_FOR_READ)) return false; + bpb_t* bpb = &cacheBuffer_.fbs.bpb; + if (bpb->bytesPerSector != 512 || + bpb->fatCount == 0 || + bpb->reservedSectorCount == 0 || + bpb->sectorsPerCluster == 0) { + // not valid FAT volume + return false; + } + fatCount_ = bpb->fatCount; + blocksPerCluster_ = bpb->sectorsPerCluster; + + // determine shift that is same as multiply by blocksPerCluster_ + clusterSizeShift_ = 0; + while (blocksPerCluster_ != (1 << clusterSizeShift_)) { + // error if not power of 2 + if (clusterSizeShift_++ > 7) return false; + } + blocksPerFat_ = bpb->sectorsPerFat16 ? + bpb->sectorsPerFat16 : bpb->sectorsPerFat32; + + fatStartBlock_ = volumeStartBlock + bpb->reservedSectorCount; + + // count for FAT16 zero for FAT32 + rootDirEntryCount_ = bpb->rootDirEntryCount; + + // directory start for FAT16 dataStart for FAT32 + rootDirStart_ = fatStartBlock_ + bpb->fatCount * blocksPerFat_; + + // data start for FAT16 and FAT32 + dataStartBlock_ = rootDirStart_ + ((32 * bpb->rootDirEntryCount + 511)/512); + + // total blocks for FAT16 or FAT32 + uint32_t totalBlocks = bpb->totalSectors16 ? + bpb->totalSectors16 : bpb->totalSectors32; + // total data blocks + clusterCount_ = totalBlocks - (dataStartBlock_ - volumeStartBlock); + + // divide by cluster size to get cluster count + clusterCount_ >>= clusterSizeShift_; + + // FAT type is determined by cluster count + if (clusterCount_ < 4085) { + fatType_ = 12; + } else if (clusterCount_ < 65525) { + fatType_ = 16; + } else { + rootDirStart_ = bpb->fat32RootCluster; + fatType_ = 32; + } + return true; +} diff --git a/arduino-0022-linux-x64/libraries/SPI/SPI.cpp b/arduino-0022-linux-x64/libraries/SPI/SPI.cpp new file mode 100644 index 0000000..42915df --- /dev/null +++ b/arduino-0022-linux-x64/libraries/SPI/SPI.cpp @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2010 by Cristian Maglie + * 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 direction register for SCK and MOSI pin. + // MISO pin automatically overrides to INPUT. + // 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(SCK, OUTPUT); + pinMode(MOSI, OUTPUT); + pinMode(SS, OUTPUT); + + digitalWrite(SCK, LOW); + digitalWrite(MOSI, LOW); + digitalWrite(SS, HIGH); + + // 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); +} + +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/arduino-0022-linux-x64/libraries/SPI/SPI.h b/arduino-0022-linux-x64/libraries/SPI/SPI.h new file mode 100644 index 0000000..9d7c3c7 --- /dev/null +++ b/arduino-0022-linux-x64/libraries/SPI/SPI.h @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2010 by Cristian Maglie + * 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 +#include +#include + +#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/arduino-0022-linux-x64/libraries/SPI/examples/BarometricPressureSensor/BarometricPressureSensor.pde b/arduino-0022-linux-x64/libraries/SPI/examples/BarometricPressureSensor/BarometricPressureSensor.pde new file mode 100644 index 0000000..9d77a42 --- /dev/null +++ b/arduino-0022-linux-x64/libraries/SPI/examples/BarometricPressureSensor/BarometricPressureSensor.pde @@ -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 + +//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/arduino-0022-linux-x64/libraries/SPI/examples/BarometricPressureSensor/BarometricPressureSensor/BarometricPressureSensor.pde b/arduino-0022-linux-x64/libraries/SPI/examples/BarometricPressureSensor/BarometricPressureSensor/BarometricPressureSensor.pde new file mode 100644 index 0000000..9c9c9b6 --- /dev/null +++ b/arduino-0022-linux-x64/libraries/SPI/examples/BarometricPressureSensor/BarometricPressureSensor/BarometricPressureSensor.pde @@ -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 + +//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 +cont byte READ = 0b00000000; // 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 + + // 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 + dataToSend = thisRegister & READ; + + // 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: + 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/arduino-0022-linux-x64/libraries/SPI/examples/DigitalPotControl/DigitalPotControl.pde b/arduino-0022-linux-x64/libraries/SPI/examples/DigitalPotControl/DigitalPotControl.pde new file mode 100644 index 0000000..ef97dae --- /dev/null +++ b/arduino-0022-linux-x64/libraries/SPI/examples/DigitalPotControl/DigitalPotControl.pde @@ -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 + + +// 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); + } + } + +} + +int 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); +} \ No newline at end of file diff --git a/arduino-0022-linux-x64/libraries/SPI/keywords.txt b/arduino-0022-linux-x64/libraries/SPI/keywords.txt new file mode 100644 index 0000000..fa76165 --- /dev/null +++ b/arduino-0022-linux-x64/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/arduino-0018-linux-x64/libraries/Servo/Servo.cpp b/arduino-0022-linux-x64/libraries/Servo/Servo.cpp old mode 100755 new mode 100644 similarity index 100% rename from arduino-0018-linux-x64/libraries/Servo/Servo.cpp rename to arduino-0022-linux-x64/libraries/Servo/Servo.cpp diff --git a/arduino-0018-linux-x64/libraries/Servo/Servo.h b/arduino-0022-linux-x64/libraries/Servo/Servo.h old mode 100755 new mode 100644 similarity index 98% rename from arduino-0018-linux-x64/libraries/Servo/Servo.h rename to arduino-0022-linux-x64/libraries/Servo/Servo.h index 7d608b3..bf3e012 --- a/arduino-0018-linux-x64/libraries/Servo/Servo.h +++ b/arduino-0022-linux-x64/libraries/Servo/Servo.h @@ -57,7 +57,7 @@ */ // Say which 16 bit timers can be used and in what order -#if defined(__AVR_ATmega1280__) +#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) #define _useTimer5 #define _useTimer1 #define _useTimer3 diff --git a/arduino-0018-linux-x64/libraries/Servo/examples/Knob/Knob.pde b/arduino-0022-linux-x64/libraries/Servo/examples/Knob/Knob.pde similarity index 100% rename from arduino-0018-linux-x64/libraries/Servo/examples/Knob/Knob.pde rename to arduino-0022-linux-x64/libraries/Servo/examples/Knob/Knob.pde diff --git a/arduino-0018-linux-x64/libraries/Servo/examples/Sweep/Sweep.pde b/arduino-0022-linux-x64/libraries/Servo/examples/Sweep/Sweep.pde similarity index 95% rename from arduino-0018-linux-x64/libraries/Servo/examples/Sweep/Sweep.pde rename to arduino-0022-linux-x64/libraries/Servo/examples/Sweep/Sweep.pde index 52e6056..fb326e7 100644 --- a/arduino-0018-linux-x64/libraries/Servo/examples/Sweep/Sweep.pde +++ b/arduino-0022-linux-x64/libraries/Servo/examples/Sweep/Sweep.pde @@ -1,5 +1,7 @@ // Sweep // by BARRAGAN +// This example code is in the public domain. + #include diff --git a/arduino-0018-linux-x64/libraries/Servo/keywords.txt b/arduino-0022-linux-x64/libraries/Servo/keywords.txt old mode 100755 new mode 100644 similarity index 100% rename from arduino-0018-linux-x64/libraries/Servo/keywords.txt rename to arduino-0022-linux-x64/libraries/Servo/keywords.txt diff --git a/arduino-0018-linux-x64/libraries/SoftwareSerial/SoftwareSerial.cpp b/arduino-0022-linux-x64/libraries/SoftwareSerial/SoftwareSerial.cpp old mode 100755 new mode 100644 similarity index 100% rename from arduino-0018-linux-x64/libraries/SoftwareSerial/SoftwareSerial.cpp rename to arduino-0022-linux-x64/libraries/SoftwareSerial/SoftwareSerial.cpp diff --git a/arduino-0018-linux-x64/libraries/SoftwareSerial/SoftwareSerial.h b/arduino-0022-linux-x64/libraries/SoftwareSerial/SoftwareSerial.h old mode 100755 new mode 100644 similarity index 100% rename from arduino-0018-linux-x64/libraries/SoftwareSerial/SoftwareSerial.h rename to arduino-0022-linux-x64/libraries/SoftwareSerial/SoftwareSerial.h diff --git a/arduino-0018-linux-x64/libraries/SoftwareSerial/keywords.txt b/arduino-0022-linux-x64/libraries/SoftwareSerial/keywords.txt similarity index 100% rename from arduino-0018-linux-x64/libraries/SoftwareSerial/keywords.txt rename to arduino-0022-linux-x64/libraries/SoftwareSerial/keywords.txt diff --git a/arduino-0018-linux-x64/libraries/Sprite/Sprite.cpp b/arduino-0022-linux-x64/libraries/Sprite/Sprite.cpp similarity index 100% rename from arduino-0018-linux-x64/libraries/Sprite/Sprite.cpp rename to arduino-0022-linux-x64/libraries/Sprite/Sprite.cpp diff --git a/arduino-0018-linux-x64/libraries/Sprite/Sprite.h b/arduino-0022-linux-x64/libraries/Sprite/Sprite.h similarity index 100% rename from arduino-0018-linux-x64/libraries/Sprite/Sprite.h rename to arduino-0022-linux-x64/libraries/Sprite/Sprite.h diff --git a/arduino-0018-linux-x64/libraries/Sprite/binary.h b/arduino-0022-linux-x64/libraries/Sprite/binary.h similarity index 100% rename from arduino-0018-linux-x64/libraries/Sprite/binary.h rename to arduino-0022-linux-x64/libraries/Sprite/binary.h diff --git a/arduino-0018-linux-x64/libraries/Sprite/keywords.txt b/arduino-0022-linux-x64/libraries/Sprite/keywords.txt similarity index 100% rename from arduino-0018-linux-x64/libraries/Sprite/keywords.txt rename to arduino-0022-linux-x64/libraries/Sprite/keywords.txt diff --git a/arduino-0018-linux-x64/libraries/Stepper/Stepper.cpp b/arduino-0022-linux-x64/libraries/Stepper/Stepper.cpp similarity index 100% rename from arduino-0018-linux-x64/libraries/Stepper/Stepper.cpp rename to arduino-0022-linux-x64/libraries/Stepper/Stepper.cpp diff --git a/arduino-0018-linux-x64/libraries/Stepper/Stepper.h b/arduino-0022-linux-x64/libraries/Stepper/Stepper.h similarity index 100% rename from arduino-0018-linux-x64/libraries/Stepper/Stepper.h rename to arduino-0022-linux-x64/libraries/Stepper/Stepper.h diff --git a/arduino-0018-linux-x64/libraries/Stepper/examples/MotorKnob/MotorKnob.pde b/arduino-0022-linux-x64/libraries/Stepper/examples/MotorKnob/MotorKnob.pde similarity index 94% rename from arduino-0018-linux-x64/libraries/Stepper/examples/MotorKnob/MotorKnob.pde rename to arduino-0022-linux-x64/libraries/Stepper/examples/MotorKnob/MotorKnob.pde index 062cac9..d428186 100644 --- a/arduino-0018-linux-x64/libraries/Stepper/examples/MotorKnob/MotorKnob.pde +++ b/arduino-0022-linux-x64/libraries/Stepper/examples/MotorKnob/MotorKnob.pde @@ -5,6 +5,7 @@ * (or other sensor) on analog input 0. * * http://www.arduino.cc/en/Reference/Stepper + * This example code is in the public domain. */ #include diff --git a/arduino-0022-linux-x64/libraries/Stepper/examples/stepper_oneRevolution/stepper_oneRevolution.pde b/arduino-0022-linux-x64/libraries/Stepper/examples/stepper_oneRevolution/stepper_oneRevolution.pde new file mode 100644 index 0000000..2dbb57d --- /dev/null +++ b/arduino-0022-linux-x64/libraries/Stepper/examples/stepper_oneRevolution/stepper_oneRevolution.pde @@ -0,0 +1,44 @@ + +/* + Stepper Motor Control - one revolution + + This program drives a unipolar or bipolar stepper motor. + The motor is attached to digital pins 8 - 11 of the Arduino. + + The motor should revolve one revolution in one direction, then + one revolution in the other direction. + + + Created 11 Mar. 2007 + Modified 30 Nov. 2009 + by Tom Igoe + + */ + +#include + +const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution + // for your motor + +// initialize the stepper library on pins 8 through 11: +Stepper myStepper(stepsPerRevolution, 8,9,10,11); + +void setup() { + // set the speed at 60 rpm: + myStepper.setSpeed(60); + // initialize the serial port: + Serial.begin(9600); +} + +void loop() { + // step one revolution in one direction: + Serial.println("clockwise"); + myStepper.step(stepsPerRevolution); + delay(500); + + // step one revolution in the other direction: + Serial.println("counterclockwise"); + myStepper.step(-stepsPerRevolution); + delay(500); +} + diff --git a/arduino-0022-linux-x64/libraries/Stepper/examples/stepper_oneStepAtATime/stepper_oneStepAtATime.pde b/arduino-0022-linux-x64/libraries/Stepper/examples/stepper_oneStepAtATime/stepper_oneStepAtATime.pde new file mode 100644 index 0000000..36d3299 --- /dev/null +++ b/arduino-0022-linux-x64/libraries/Stepper/examples/stepper_oneStepAtATime/stepper_oneStepAtATime.pde @@ -0,0 +1,44 @@ + +/* + Stepper Motor Control - one step at a time + + This program drives a unipolar or bipolar stepper motor. + The motor is attached to digital pins 8 - 11 of the Arduino. + + The motor will step one step at a time, very slowly. You can use this to + test that you've got the four wires of your stepper wired to the correct + pins. If wired correctly, all steps should be in the same direction. + + Use this also to count the number of steps per revolution of your motor, + if you don't know it. Then plug that number into the oneRevolution + example to see if you got it right. + + Created 30 Nov. 2009 + by Tom Igoe + + */ + +#include + +const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution + // for your motor + +// initialize the stepper library on pins 8 through 11: +Stepper myStepper(stepsPerRevolution, 8,9,10,11); + +int stepCount = 0; // number of steps the motor has taken + +void setup() { + // initialize the serial port: + Serial.begin(9600); +} + +void loop() { + // step one step: + myStepper.step(1); + Serial.print("steps:" ); + Serial.println(stepCount); + stepCount++; + delay(500); +} + diff --git a/arduino-0022-linux-x64/libraries/Stepper/examples/stepper_speedControl/stepper_speedControl.pde b/arduino-0022-linux-x64/libraries/Stepper/examples/stepper_speedControl/stepper_speedControl.pde new file mode 100644 index 0000000..dbd0f7f --- /dev/null +++ b/arduino-0022-linux-x64/libraries/Stepper/examples/stepper_speedControl/stepper_speedControl.pde @@ -0,0 +1,49 @@ + +/* + Stepper Motor Control - speed control + + This program drives a unipolar or bipolar stepper motor. + The motor is attached to digital pins 8 - 11 of the Arduino. + A potentiometer is connected to analog input 0. + + The motor will rotate in a clockwise direction. The higher the potentiometer value, + the faster the motor speed. Because setSpeed() sets the delay between steps, + you may notice the motor is less responsive to changes in the sensor value at + low speeds. + + Created 30 Nov. 2009 + Modified 28 Oct 2010 + by Tom Igoe + + */ + +#include + +const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution +// for your motor + + +// initialize the stepper library on pins 8 through 11: +Stepper myStepper(stepsPerRevolution, 8,9,10,11); + +int stepCount = 0; // number of steps the motor has taken + +void setup() { + // initialize the serial port: + Serial.begin(9600); +} + +void loop() { + // read the sensor value: + int sensorReading = analogRead(A0); + // map it to a range from 0 to 100: + int motorSpeed = map(sensorReading, 0, 1023, 0, 100); + // set the motor speed: + if (motorSpeed > 0) { + myStepper.setSpeed(motorSpeed); + // step 1/100 of a revolution: + myStepper.step(stepsPerRevolution/100); + } +} + + diff --git a/arduino-0018-linux-x64/libraries/Stepper/keywords.txt b/arduino-0022-linux-x64/libraries/Stepper/keywords.txt similarity index 100% rename from arduino-0018-linux-x64/libraries/Stepper/keywords.txt rename to arduino-0022-linux-x64/libraries/Stepper/keywords.txt diff --git a/arduino-0018-linux-x64/libraries/Wire/Wire.cpp b/arduino-0022-linux-x64/libraries/Wire/Wire.cpp old mode 100755 new mode 100644 similarity index 96% rename from arduino-0018-linux-x64/libraries/Wire/Wire.cpp rename to arduino-0022-linux-x64/libraries/Wire/Wire.cpp index 0ee3012..849439b --- a/arduino-0018-linux-x64/libraries/Wire/Wire.cpp +++ b/arduino-0022-linux-x64/libraries/Wire/Wire.cpp @@ -28,12 +28,12 @@ extern "C" { // Initialize Class Variables ////////////////////////////////////////////////// -uint8_t* TwoWire::rxBuffer = 0; +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 = 0; +uint8_t TwoWire::txBuffer[BUFFER_LENGTH]; uint8_t TwoWire::txBufferIndex = 0; uint8_t TwoWire::txBufferLength = 0; @@ -51,13 +51,9 @@ TwoWire::TwoWire() void TwoWire::begin(void) { - // init buffer for reads - rxBuffer = (uint8_t*) calloc(BUFFER_LENGTH, sizeof(uint8_t)); rxBufferIndex = 0; rxBufferLength = 0; - // init buffer for writes - txBuffer = (uint8_t*) calloc(BUFFER_LENGTH, sizeof(uint8_t)); txBufferIndex = 0; txBufferLength = 0; diff --git a/arduino-0018-linux-x64/libraries/Wire/Wire.h b/arduino-0022-linux-x64/libraries/Wire/Wire.h old mode 100755 new mode 100644 similarity index 96% rename from arduino-0018-linux-x64/libraries/Wire/Wire.h rename to arduino-0022-linux-x64/libraries/Wire/Wire.h index 9e849d5..a6c29c4 --- a/arduino-0018-linux-x64/libraries/Wire/Wire.h +++ b/arduino-0022-linux-x64/libraries/Wire/Wire.h @@ -27,12 +27,12 @@ class TwoWire { private: - static uint8_t* rxBuffer; + static uint8_t rxBuffer[]; static uint8_t rxBufferIndex; static uint8_t rxBufferLength; static uint8_t txAddress; - static uint8_t* txBuffer; + static uint8_t txBuffer[]; static uint8_t txBufferIndex; static uint8_t txBufferLength; diff --git a/arduino-0018-linux-x64/libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.pde b/arduino-0022-linux-x64/libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.pde old mode 100755 new mode 100644 similarity index 98% rename from arduino-0018-linux-x64/libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.pde rename to arduino-0022-linux-x64/libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.pde index c89b0f0..4bb4b83 --- a/arduino-0018-linux-x64/libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.pde +++ b/arduino-0022-linux-x64/libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.pde @@ -7,6 +7,9 @@ // Created 29 April 2006 +// This example code is in the public domain. + + #include void setup() diff --git a/arduino-0018-linux-x64/libraries/Wire/examples/digital_potentiometer/digital_potentiometer.pde b/arduino-0022-linux-x64/libraries/Wire/examples/digital_potentiometer/digital_potentiometer.pde similarity index 90% rename from arduino-0018-linux-x64/libraries/Wire/examples/digital_potentiometer/digital_potentiometer.pde rename to arduino-0022-linux-x64/libraries/Wire/examples/digital_potentiometer/digital_potentiometer.pde index 35ee5d6..00a15cc 100644 --- a/arduino-0018-linux-x64/libraries/Wire/examples/digital_potentiometer/digital_potentiometer.pde +++ b/arduino-0022-linux-x64/libraries/Wire/examples/digital_potentiometer/digital_potentiometer.pde @@ -7,6 +7,11 @@ // Created 31 March 2006 +// This example code is in the public domain. + +// This example code is in the public domain. + + #include void setup() diff --git a/arduino-0018-linux-x64/libraries/Wire/examples/master_reader/master_reader.pde b/arduino-0022-linux-x64/libraries/Wire/examples/master_reader/master_reader.pde similarity index 93% rename from arduino-0018-linux-x64/libraries/Wire/examples/master_reader/master_reader.pde rename to arduino-0022-linux-x64/libraries/Wire/examples/master_reader/master_reader.pde index 1b139de..4e0ffba 100644 --- a/arduino-0018-linux-x64/libraries/Wire/examples/master_reader/master_reader.pde +++ b/arduino-0022-linux-x64/libraries/Wire/examples/master_reader/master_reader.pde @@ -7,6 +7,9 @@ // Created 29 March 2006 +// This example code is in the public domain. + + #include void setup() diff --git a/arduino-0018-linux-x64/libraries/Wire/examples/master_writer/master_writer.pde b/arduino-0022-linux-x64/libraries/Wire/examples/master_writer/master_writer.pde similarity index 92% rename from arduino-0018-linux-x64/libraries/Wire/examples/master_writer/master_writer.pde rename to arduino-0022-linux-x64/libraries/Wire/examples/master_writer/master_writer.pde index d0ff9fa..5278787 100644 --- a/arduino-0018-linux-x64/libraries/Wire/examples/master_writer/master_writer.pde +++ b/arduino-0022-linux-x64/libraries/Wire/examples/master_writer/master_writer.pde @@ -7,6 +7,9 @@ // Created 29 March 2006 +// This example code is in the public domain. + + #include void setup() diff --git a/arduino-0018-linux-x64/libraries/Wire/examples/slave_receiver/slave_receiver.pde b/arduino-0022-linux-x64/libraries/Wire/examples/slave_receiver/slave_receiver.pde similarity index 95% rename from arduino-0018-linux-x64/libraries/Wire/examples/slave_receiver/slave_receiver.pde rename to arduino-0022-linux-x64/libraries/Wire/examples/slave_receiver/slave_receiver.pde index 53c86b5..3e85f3d 100644 --- a/arduino-0018-linux-x64/libraries/Wire/examples/slave_receiver/slave_receiver.pde +++ b/arduino-0022-linux-x64/libraries/Wire/examples/slave_receiver/slave_receiver.pde @@ -7,6 +7,9 @@ // Created 29 March 2006 +// This example code is in the public domain. + + #include void setup() diff --git a/arduino-0018-linux-x64/libraries/Wire/examples/slave_sender/slave_sender.pde b/arduino-0022-linux-x64/libraries/Wire/examples/slave_sender/slave_sender.pde similarity index 93% rename from arduino-0018-linux-x64/libraries/Wire/examples/slave_sender/slave_sender.pde rename to arduino-0022-linux-x64/libraries/Wire/examples/slave_sender/slave_sender.pde index f500644..e19f0e7 100644 --- a/arduino-0018-linux-x64/libraries/Wire/examples/slave_sender/slave_sender.pde +++ b/arduino-0022-linux-x64/libraries/Wire/examples/slave_sender/slave_sender.pde @@ -7,6 +7,9 @@ // Created 29 March 2006 +// This example code is in the public domain. + + #include void setup() diff --git a/arduino-0018-linux-x64/libraries/Wire/keywords.txt b/arduino-0022-linux-x64/libraries/Wire/keywords.txt similarity index 100% rename from arduino-0018-linux-x64/libraries/Wire/keywords.txt rename to arduino-0022-linux-x64/libraries/Wire/keywords.txt diff --git a/arduino-0018-linux-x64/libraries/Wire/utility/twi.c b/arduino-0022-linux-x64/libraries/Wire/utility/twi.c similarity index 96% rename from arduino-0018-linux-x64/libraries/Wire/utility/twi.c rename to arduino-0022-linux-x64/libraries/Wire/utility/twi.c index 2ad2a71..236878c 100644 --- a/arduino-0018-linux-x64/libraries/Wire/utility/twi.c +++ b/arduino-0022-linux-x64/libraries/Wire/utility/twi.c @@ -40,15 +40,15 @@ static uint8_t twi_slarw; static void (*twi_onSlaveTransmit)(void); static void (*twi_onSlaveReceive)(uint8_t*, int); -static uint8_t* twi_masterBuffer; +static uint8_t twi_masterBuffer[TWI_BUFFER_LENGTH]; static volatile uint8_t twi_masterBufferIndex; static uint8_t twi_masterBufferLength; -static uint8_t* twi_txBuffer; +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; +static uint8_t twi_rxBuffer[TWI_BUFFER_LENGTH]; static volatile uint8_t twi_rxBufferIndex; static volatile uint8_t twi_error; @@ -88,11 +88,6 @@ void twi_init(void) // enable twi module, acks, and twi interrupt TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA); - - // allocate buffers - twi_masterBuffer = (uint8_t*) calloc(TWI_BUFFER_LENGTH, sizeof(uint8_t)); - twi_txBuffer = (uint8_t*) calloc(TWI_BUFFER_LENGTH, sizeof(uint8_t)); - twi_rxBuffer = (uint8_t*) calloc(TWI_BUFFER_LENGTH, sizeof(uint8_t)); } /* @@ -418,12 +413,14 @@ SIGNAL(TWI_vect) 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); - // ack future responses - twi_reply(1); - // leave slave receiver state - twi_state = TWI_READY; + // 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 diff --git a/arduino-0018-linux-x64/libraries/Wire/utility/twi.h b/arduino-0022-linux-x64/libraries/Wire/utility/twi.h old mode 100755 new mode 100644 similarity index 100% rename from arduino-0018-linux-x64/libraries/Wire/utility/twi.h rename to arduino-0022-linux-x64/libraries/Wire/utility/twi.h diff --git a/arduino-0018-linux-x64/reference/ASCIIchart.html b/arduino-0022-linux-x64/reference/ASCIIchart.html similarity index 100% rename from arduino-0018-linux-x64/reference/ASCIIchart.html rename to arduino-0022-linux-x64/reference/ASCIIchart.html diff --git a/arduino-0022-linux-x64/reference/Abs.html b/arduino-0022-linux-x64/reference/Abs.html new file mode 100644 index 0000000..591cbdf --- /dev/null +++ b/arduino-0022-linux-x64/reference/Abs.html @@ -0,0 +1,172 @@ + + + + Arduino - Abs + + + + + + + +
    + + + + + + +
    + +
    +

    Reference   Language | Libraries | Comparison | Changes +

    +

    abs(x)

    +

    Description

    +

    Computes the absolute value of a number. +

    +

    Parameters

    +

    x: the number +

    +

    Returns

    +

    x: if x is greater than or equal to 0. +

    +

    -x: if x is less than 0. +

    +

    Warning

    +

    Because of the way the abs() function is implemented, avoid using other functions inside the brackets, it may lead to incorrect results. +

    +

    +abs(a++);   // avoid this - yields incorrect results
    +
    +a++;          // use this instead -
    +abs(a);       // keep other math outside the function
    +
    +
    +

    Reference Home +

    +

    Corrections, suggestions, and new documentation should be posted to the Forum. +

    +

    The text of the Arduino reference is licensed under a +Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. +

    +
    + + + + + + + +
    + + + +
    + + diff --git a/arduino-0022-linux-x64/reference/AnalogRead.html b/arduino-0022-linux-x64/reference/AnalogRead.html new file mode 100644 index 0000000..53f9d74 --- /dev/null +++ b/arduino-0022-linux-x64/reference/AnalogRead.html @@ -0,0 +1,189 @@ + + + + Arduino - AnalogRead + + + + + + + +
    + + + + + + +
    + +
    +

    Reference   Language | Libraries | Comparison | Changes +

    +

    analogRead()

    +

    Description

    +

    Reads the value from the specified analog pin. The Arduino board contains a 6 channel (8 channels on the Mini and Nano, 16 on the Mega), 10-bit analog to digital converter. This means that it will map input voltages between 0 and 5 volts into integer values between 0 and 1023. This yields a resolution between readings of: 5 volts / 1024 units or, .0049 volts (4.9 mV) per unit. The input range and resolution can be changed using analogReference(). +

    +

    It takes about 100 microseconds (0.0001 s) to read an analog input, so the maximum reading rate is about 10,000 times a second. +

    +

    Syntax

    +

    analogRead(pin) +

    +

    Parameters

    +

    pin: the number of the analog input pin to read from (0 to 5 on most boards, 0 to 7 on the Mini and Nano, 0 to 15 on the Mega) +

    +

    Returns

    +

    int (0 to 1023) +

    +

    Note

    +

    If the analog input pin is not connected to anything, the value returned by analogRead() will fluctuate based on a number of factors (e.g. the values of the other analog inputs, how close your hand is to the board, etc.). +

    +

    Example

    +
     
    +int analogPin = 3;     // potentiometer wiper (middle terminal) connected to analog pin 3
    +                       // outside leads to ground and +5V
    +int val = 0;           // variable to store the value read
    +
    +void setup()
    +{
    +  Serial.begin(9600);          //  setup serial
    +}
    +
    +void loop()
    +{
    +  val = analogRead(analogPin);    // read the input pin
    +  Serial.println(val);             // debug value
    +}
    +
    +
    +

    See also

    +

    Reference Home +

    +

    Corrections, suggestions, and new documentation should be posted to the Forum. +

    +

    The text of the Arduino reference is licensed under a +Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. +

    +
    + + + + + + + +
    + + + +
    + + diff --git a/arduino-0022-linux-x64/reference/AnalogReference.html b/arduino-0022-linux-x64/reference/AnalogReference.html new file mode 100644 index 0000000..86f064e --- /dev/null +++ b/arduino-0022-linux-x64/reference/AnalogReference.html @@ -0,0 +1,176 @@ + + + + Arduino - AnalogReference + + + + + + + +
    + + + + + + +
    + +
    +

    Reference   Language | Libraries | Comparison | Changes +

    +

    analogReference(type)

    +

    Description

    +

    Configures the reference voltage used for analog input (i.e. the value used as the top of the input range). The options are: +

    +

    • DEFAULT: the default analog reference of 5 volts (on 5V Arduino boards) or 3.3 volts (on 3.3V Arduino boards) +
    • INTERNAL: an built-in reference, equal to 1.1 volts on the ATmega168 or ATmega328 and 2.56 volts on the ATmega8 (not available on the Arduino Mega) +
    • INTERNAL1V1: a built-in 1.1V reference (Arduino Mega only) +
    • INTERNAL2V56: a built-in 2.56V reference (Arduino Mega only) +
    • EXTERNAL: the voltage applied to the AREF pin is used as the reference. +

    Parameters

    +

    type: which type of reference to use (DEFAULT, INTERNAL, INTERNAL1V1, INTERNAL2V56, or EXTERNAL). +

    +

    Returns

    +

    None. +

    +

    Note

    +

    After changing the analog reference, the first few readings from analogRead() may not be accurate. +

    +

    Warning

    +

    If you're using an external reference voltage (applied to the AREF pin), you must set the analog reference to EXTERNAL before calling analogRead(). Otherwise, you will short together the active reference voltage (internally generated) and the AREF pin, possibly damaging the microcontroller on your Arduino board. +

    +

    Alternatively, you can connect the external reference voltage to the AREF pin through a 5K resistor, allowing you to switch between external and internal reference voltages. Note that the resistor will alter the voltage that gets used as the reference because there is an internal 32K resistor on the AREF pin. The two act as a voltage divider, so, for example, 2.5V applied through the resistor will yield 2.5 * 32 / (32 + 5) = ~2.2V at the AREF pin. +

    +

    See also

    +

    Reference Home +

    +

    Corrections, suggestions, and new documentation should be posted to the Forum. +

    +

    The text of the Arduino reference is licensed under a +Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. +

    +
    + + + + + + + +
    + + + +
    + + diff --git a/arduino-0022-linux-x64/reference/AnalogWrite.html b/arduino-0022-linux-x64/reference/AnalogWrite.html new file mode 100644 index 0000000..cd8b688 --- /dev/null +++ b/arduino-0022-linux-x64/reference/AnalogWrite.html @@ -0,0 +1,195 @@ + + + + Arduino - AnalogWrite + + + + + + + +
    + + + + + + +
    + +
    +

    Reference   Language | Libraries | Comparison | Changes +

    +

    analogWrite()

    +

    Description

    +

    Writes an analog value (PWM wave) to a pin. Can be used to light a LED at varying brightnesses or drive a motor at various speeds. After a call to analogWrite(), the pin will generate a steady square wave of the specified duty cycle until the next call to analogWrite() (or a call to digitalRead() or digitalWrite() on the same pin). The frequency of the PWM signal is approximately 490 Hz. +

    +

    On most Arduino boards (those with the ATmega168 or ATmega328), this function works on pins 3, 5, 6, 9, 10, and 11. On the Arduino Mega, it works on pins 2 through 13. Older Arduino boards with an ATmega8 only support analogWrite() on pins 9, 10, and 11. You do not need to call pinMode() to set the pin as an output before calling analogWrite(). +

    +

    The analogWrite function has nothing whatsoever to do with the analog pins or the analogRead function. +

    +

    Syntax

    +

    analogWrite(pin, value) +

    +

    Parameters

    +

    pin: the pin to write to. +

    +

    value: the duty cycle: between 0 (always off) and 255 (always on). +

    +

    Returns

    +

    nothing +

    +

    Notes and Known Issues

    +

    The PWM outputs generated on pins 5 and 6 will have higher-than-expected duty cycles. This is because of interactions with the millis() and delay() functions, which share the same internal timer used to generate those PWM outputs. This will be noticed mostly on low duty-cycle settings (e.g 0 - 10) and may result in a value of 0 not fully turning off the output on pins 5 and 6. +

    +

    Example

    +

    Sets the output to the LED proportional to the value read from the potentiometer. +

    +

     
    +int ledPin = 9;      // LED connected to digital pin 9
    +int analogPin = 3;   // potentiometer connected to analog pin 3
    +int val = 0;         // variable to store the read value
    +
    +void setup()
    +{
    +  pinMode(ledPin, OUTPUT);   // sets the pin as output
    +}
    +
    +void loop()
    +{
    +  val = analogRead(analogPin);   // read the input pin
    +  analogWrite(ledPin, val / 4);  // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
    +}
    +
    +
    +

    See also

    +

    Reference Home +

    +

    Corrections, suggestions, and new documentation should be posted to the Forum. +

    +

    The text of the Arduino reference is licensed under a +Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. +

    +
    + + + + + + + +
    + + + +
    + + diff --git a/arduino-0022-linux-x64/reference/Arithmetic.html b/arduino-0022-linux-x64/reference/Arithmetic.html new file mode 100644 index 0000000..8d1003b --- /dev/null +++ b/arduino-0022-linux-x64/reference/Arithmetic.html @@ -0,0 +1,183 @@ + + + + Arduino - Arithmetic + + + + + + + +
    + + + + + + +
    + +
    +

    Reference   Language | Libraries | Comparison | Changes +

    +

    Addition, Subtraction, Multiplication, & Division

    +

    Description

    +

    These operators return the sum, difference, product, or quotient (respectively) of the two operands. The operation is conducted using the data type of the operands, so, for example, 9 / 4 gives 2 since 9 and 4 are ints. This also means that the operation can overflow if the result is larger than that which can be stored in the data type (e.g. adding 1 to an int with the value 32,767 gives -32,768). If the operands are of different types, the "larger" type is used for the calculation. +

    +

    If one of the numbers (operands) are of the type float or of type double, floating point math will be used for the calculation. +

    +

    Examples

    +
    +y = y + 3;
    +x = x - 7;
    +i = j * 6;
    +r = r / 5;
    +
    +
    +

    Syntax

    +
    +result = value1 + value2;
    +result = value1 - value2;
    +result = value1 * value2;
    +result = value1 / value2;
    +
    +
    +

    Parameters:

    +

    value1: any variable or constant +

    +

    value2: any variable or constant +

    +

    Programming Tips:

    +
    • Know that integer constants default to int, so some constant calculations may overflow (e.g. 60 * 1000 will yield a negative result). +

    • Choose variable sizes that are large enough to hold the largest results from your calculations +

    • Know at what point your variable will "roll over" and also what happens in the other direction e.g. (0 - 1) OR (0 - - 32768) +

    • For math that requires fractions, use float variables, but be aware of their drawbacks: large size, slow computation speeds +

    • Use the cast operator e.g. (int)myFloat to convert one variable type to another on the fly. +

    Reference Home +

    +

    Corrections, suggestions, and new documentation should be posted to the Forum. +

    +

    The text of the Arduino reference is licensed under a +Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain. +

    +
    + + + + + + + +
    + + + +
    + + diff --git a/arduino-0018-linux-x64/reference/Array.html b/arduino-0022-linux-x64/reference/Array.html similarity index 51% rename from arduino-0018-linux-x64/reference/Array.html rename to arduino-0022-linux-x64/reference/Array.html index 01382b4..fb6afdc 100644 --- a/arduino-0018-linux-x64/reference/Array.html +++ b/arduino-0022-linux-x64/reference/Array.html @@ -1,51 +1,122 @@ - + Arduino - Array - + + + +
    -