Browse Source

Remove the "cores" directory from optiboot. These (which were copies of
core files normally distributed with the Arduino IDE or with other boards
(Sanguino, Luminet) have long been so obsolete that they do more harm than
good, and there is now a mechanism for pointing add-on "boards.txt" entries
to the common platform code.

See http://code.google.com/p/optiboot/issues/detail?id=11

Bill Westfield 13 years ago
parent
commit
4ad7a6e3cd
80 changed files with 0 additions and 10724 deletions
  1. 0 226
      optiboot/cores/arduino/HardwareSerial.cpp
  2. 0 66
      optiboot/cores/arduino/HardwareSerial.h
  3. 0 206
      optiboot/cores/arduino/Print.cpp
  4. 0 62
      optiboot/cores/arduino/Print.h
  5. 0 515
      optiboot/cores/arduino/Tone.cpp
  6. 0 1
      optiboot/cores/arduino/WConstants.h
  7. 0 215
      optiboot/cores/arduino/WInterrupts.c
  8. 0 60
      optiboot/cores/arduino/WMath.cpp
  9. 0 32
      optiboot/cores/arduino/WProgram.h
  10. 0 3
      optiboot/cores/arduino/_ReadMe.txt
  11. 0 515
      optiboot/cores/arduino/binary.h
  12. 0 14
      optiboot/cores/arduino/main.cpp
  13. 0 469
      optiboot/cores/arduino/pins_arduino.c
  14. 0 76
      optiboot/cores/arduino/pins_arduino.h
  15. 0 238
      optiboot/cores/arduino/wiring.c
  16. 0 133
      optiboot/cores/arduino/wiring.h
  17. 0 179
      optiboot/cores/arduino/wiring_analog.c
  18. 0 111
      optiboot/cores/arduino/wiring_digital.c
  19. 0 68
      optiboot/cores/arduino/wiring_private.h
  20. 0 66
      optiboot/cores/arduino/wiring_pulse.c
  21. 0 40
      optiboot/cores/arduino/wiring_shift.c
  22. 0 149
      optiboot/cores/luminet/COM.c
  23. 0 70
      optiboot/cores/luminet/COM.h
  24. 0 361
      optiboot/cores/luminet/COMasm.S
  25. 0 62
      optiboot/cores/luminet/HardwareSerial.cpp
  26. 0 41
      optiboot/cores/luminet/HardwareSerial.h
  27. 0 14
      optiboot/cores/luminet/LEDExtensions.c
  28. 0 17
      optiboot/cores/luminet/LEDExtensions.h
  29. 0 253
      optiboot/cores/luminet/Makefile
  30. 0 213
      optiboot/cores/luminet/Print.cpp
  31. 0 59
      optiboot/cores/luminet/Print.h
  32. 0 1
      optiboot/cores/luminet/WConstants.h
  33. 0 106
      optiboot/cores/luminet/WInterrupts.c
  34. 0 60
      optiboot/cores/luminet/WMath.cpp
  35. 0 37
      optiboot/cores/luminet/WProgram.h
  36. 0 515
      optiboot/cores/luminet/binary.h
  37. 0 304
      optiboot/cores/luminet/bynase.c
  38. 0 30
      optiboot/cores/luminet/bynase.h
  39. BIN
      optiboot/cores/luminet/cmd.exe.lnk
  40. 0 72
      optiboot/cores/luminet/digitalWriteASM.S
  41. 0 6
      optiboot/cores/luminet/fastDigital.c
  42. 0 20
      optiboot/cores/luminet/fastDigital.h
  43. 0 152
      optiboot/cores/luminet/luminet.h
  44. 0 39
      optiboot/cores/luminet/main.cxx
  45. 0 154
      optiboot/cores/luminet/pins_arduino.c
  46. 0 65
      optiboot/cores/luminet/pins_arduino.h
  47. 0 268
      optiboot/cores/luminet/topology.c
  48. 0 26
      optiboot/cores/luminet/topology.h
  49. 0 224
      optiboot/cores/luminet/wiring.c
  50. 0 134
      optiboot/cores/luminet/wiring.h
  51. 0 184
      optiboot/cores/luminet/wiring_analog.c
  52. 0 93
      optiboot/cores/luminet/wiring_digital.c
  53. 0 58
      optiboot/cores/luminet/wiring_private.h
  54. 0 66
      optiboot/cores/luminet/wiring_pulse.c
  55. 0 135
      optiboot/cores/luminet/wiring_serial.c
  56. 0 40
      optiboot/cores/luminet/wiring_shift.c
  57. 0 218
      optiboot/cores/sanguino/HardwareSerial.cpp
  58. 0 65
      optiboot/cores/sanguino/HardwareSerial.h
  59. 0 243
      optiboot/cores/sanguino/Makefile
  60. 0 206
      optiboot/cores/sanguino/Print.cpp
  61. 0 62
      optiboot/cores/sanguino/Print.h
  62. 0 515
      optiboot/cores/sanguino/Tone.cpp
  63. 0 1
      optiboot/cores/sanguino/WConstants.h
  64. 0 215
      optiboot/cores/sanguino/WInterrupts.c
  65. 0 60
      optiboot/cores/sanguino/WMath.cpp
  66. 0 32
      optiboot/cores/sanguino/WProgram.h
  67. 0 5
      optiboot/cores/sanguino/_ReadMe.txt
  68. 0 515
      optiboot/cores/sanguino/binary.h
  69. 0 14
      optiboot/cores/sanguino/main.cpp
  70. 0 12
      optiboot/cores/sanguino/main.cxx
  71. 0 200
      optiboot/cores/sanguino/pins_arduino.c
  72. 0 65
      optiboot/cores/sanguino/pins_arduino.h
  73. 0 238
      optiboot/cores/sanguino/wiring.c
  74. 0 133
      optiboot/cores/sanguino/wiring.h
  75. 0 179
      optiboot/cores/sanguino/wiring_analog.c
  76. 0 111
      optiboot/cores/sanguino/wiring_digital.c
  77. 0 68
      optiboot/cores/sanguino/wiring_private.h
  78. 0 66
      optiboot/cores/sanguino/wiring_pulse.c
  79. 0 138
      optiboot/cores/sanguino/wiring_serial.c
  80. 0 40
      optiboot/cores/sanguino/wiring_shift.c

+ 0 - 226
optiboot/cores/arduino/HardwareSerial.cpp

@@ -1,226 +0,0 @@
-/*
-  HardwareSerial.cpp - Hardware serial library for Wiring
-  Copyright (c) 2006 Nicholas Zambetti.  All right reserved.
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public
-  License along with this library; if not, write to the Free Software
-  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-  
-  Modified 23 November 2006 by David A. Mellis
-*/
-
-#include <stdio.h>
-#include <string.h>
-#include <inttypes.h>
-#include "wiring.h"
-#include "wiring_private.h"
-
-#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
-
-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 };
-#endif
-
-inline void store_char(unsigned char c, ring_buffer *rx_buffer)
-{
-  int i = (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
-  // current location of the tail), we're about to overflow the buffer
-  // and so we don't write the character or advance the head.
-  if (i != rx_buffer->tail) {
-    rx_buffer->buffer[rx_buffer->head] = c;
-    rx_buffer->head = i;
-  }
-}
-
-#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);
-}
-
-#else
-
-#if defined(__AVR_ATmega8__)
-SIGNAL(SIG_UART_RECV)
-#else
-SIGNAL(USART_RX_vect)
-#endif
-{
-#if defined(__AVR_ATmega8__)
-  unsigned char c = UDR;
-#else
-  unsigned char c = UDR0;
-#endif
-  store_char(c, &rx_buffer);
-}
-
-#endif
-
-// Constructors ////////////////////////////////////////////////////////////////
-
-HardwareSerial::HardwareSerial(ring_buffer *rx_buffer,
-  volatile uint8_t *ubrrh, volatile uint8_t *ubrrl,
-  volatile uint8_t *ucsra, volatile uint8_t *ucsrb,
-  volatile uint8_t *udr,
-  uint8_t rxen, uint8_t txen, uint8_t rxcie, uint8_t udre, uint8_t u2x)
-{
-  _rx_buffer = rx_buffer;
-  _ubrrh = ubrrh;
-  _ubrrl = ubrrl;
-  _ucsra = ucsra;
-  _ucsrb = ucsrb;
-  _udr = udr;
-  _rxen = rxen;
-  _txen = txen;
-  _rxcie = rxcie;
-  _udre = udre;
-  _u2x = u2x;
-}
-
-// Public Methods //////////////////////////////////////////////////////////////
-
-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);
-  }
-  
-  if (use_u2x) {
-    *_ucsra = 1 << _u2x;
-    baud_setting = (F_CPU / 4 / baud - 1) / 2;
-  } else {
-    *_ucsra = 0;
-    baud_setting = (F_CPU / 8 / baud - 1) / 2;
-  }
-
-  // assign the baud_setting, a.k.a. ubbr (USART Baud Rate Register)
-  *_ubrrh = baud_setting >> 8;
-  *_ubrrl = baud_setting;
-
-  sbi(*_ucsrb, _rxen);
-  sbi(*_ucsrb, _txen);
-  sbi(*_ucsrb, _rxcie);
-}
-
-void HardwareSerial::end()
-{
-  cbi(*_ucsrb, _rxen);
-  cbi(*_ucsrb, _txen);
-  cbi(*_ucsrb, _rxcie);  
-}
-
-uint8_t HardwareSerial::available(void)
-{
-  return (RX_BUFFER_SIZE + _rx_buffer->head - _rx_buffer->tail) % RX_BUFFER_SIZE;
-}
-
-int HardwareSerial::read(void)
-{
-  // if the head isn't ahead of the tail, we don't have any characters
-  if (_rx_buffer->head == _rx_buffer->tail) {
-    return -1;
-  } else {
-    unsigned char c = _rx_buffer->buffer[_rx_buffer->tail];
-    _rx_buffer->tail = (_rx_buffer->tail + 1) % RX_BUFFER_SIZE;
-    return c;
-  }
-}
-
-void HardwareSerial::flush()
-{
-  // don't reverse this or there may be problems if the RX interrupt
-  // occurs after reading the value of rx_buffer_head but before writing
-  // the value to rx_buffer_tail; the previous value of rx_buffer_head
-  // may be written to rx_buffer_tail, making it appear as if the buffer
-  // don't reverse this or there may be problems if the RX interrupt
-  // occurs after reading the value of rx_buffer_head but before writing
-  // the value to rx_buffer_tail; the previous value of rx_buffer_head
-  // may be written to rx_buffer_tail, making it appear as if the buffer
-  // were full, not empty.
-  _rx_buffer->head = _rx_buffer->tail;
-}
-
-void HardwareSerial::write(uint8_t c)
-{
-  while (!((*_ucsra) & (1 << _udre)))
-    ;
-
-  *_udr = c;
-}
-
-// Preinstantiate Objects //////////////////////////////////////////////////////
-
-#if defined(__AVR_ATmega8__)
-HardwareSerial Serial(&rx_buffer, &UBRRH, &UBRRL, &UCSRA, &UCSRB, &UDR, RXEN, TXEN, RXCIE, UDRE, U2X);
-#else
-HardwareSerial Serial(&rx_buffer, &UBRR0H, &UBRR0L, &UCSR0A, &UCSR0B, &UDR0, RXEN0, TXEN0, RXCIE0, UDRE0, U2X0);
-#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);
-#endif

+ 0 - 66
optiboot/cores/arduino/HardwareSerial.h

@@ -1,66 +0,0 @@
-/*
-  HardwareSerial.h - Hardware serial library for Wiring
-  Copyright (c) 2006 Nicholas Zambetti.  All right reserved.
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public
-  License along with this library; if not, write to the Free Software
-  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-*/
-
-#ifndef HardwareSerial_h
-#define HardwareSerial_h
-
-#include <inttypes.h>
-
-#include "Print.h"
-
-struct ring_buffer;
-
-class HardwareSerial : public Print
-{
-  private:
-    ring_buffer *_rx_buffer;
-    volatile uint8_t *_ubrrh;
-    volatile uint8_t *_ubrrl;
-    volatile uint8_t *_ucsra;
-    volatile uint8_t *_ucsrb;
-    volatile uint8_t *_udr;
-    uint8_t _rxen;
-    uint8_t _txen;
-    uint8_t _rxcie;
-    uint8_t _udre;
-    uint8_t _u2x;
-  public:
-    HardwareSerial(ring_buffer *rx_buffer,
-      volatile uint8_t *ubrrh, volatile uint8_t *ubrrl,
-      volatile uint8_t *ucsra, volatile uint8_t *ucsrb,
-      volatile uint8_t *udr,
-      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 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;
-#endif
-
-#endif

+ 0 - 206
optiboot/cores/arduino/Print.cpp

@@ -1,206 +0,0 @@
-/*
- Print.cpp - Base class that provides print() and println()
- Copyright (c) 2008 David A. Mellis.  All right reserved.
- 
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
- 
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- Lesser General Public License for more details.
- 
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- 
- Modified 23 November 2006 by David A. Mellis
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <math.h>
-#include "wiring.h"
-
-#include "Print.h"
-
-// Public Methods //////////////////////////////////////////////////////////////
-
-/* default implementation: may be overridden */
-void Print::write(const char *str)
-{
-  while (*str)
-    write(*str++);
-}
-
-/* default implementation: may be overridden */
-void Print::write(const uint8_t *buffer, size_t size)
-{
-  while (size--)
-    write(*buffer++);
-}
-
-void Print::print(const char str[])
-{
-  write(str);
-}
-
-void Print::print(char c, int base)
-{
-  print((long) c, base);
-}
-
-void Print::print(unsigned char b, int base)
-{
-  print((unsigned long) b, base);
-}
-
-void Print::print(int n, int base)
-{
-  print((long) n, base);
-}
-
-void Print::print(unsigned int n, int base)
-{
-  print((unsigned long) n, base);
-}
-
-void Print::print(long n, int base)
-{
-  if (base == 0) {
-    write(n);
-  } else if (base == 10) {
-    if (n < 0) {
-      print('-');
-      n = -n;
-    }
-    printNumber(n, 10);
-  } else {
-    printNumber(n, base);
-  }
-}
-
-void Print::print(unsigned long n, int base)
-{
-  if (base == 0) write(n);
-  else printNumber(n, base);
-}
-
-void Print::print(double n, int digits)
-{
-  printFloat(n, digits);
-}
-
-void Print::println(void)
-{
-  print('\r');
-  print('\n');  
-}
-
-void Print::println(const char c[])
-{
-  print(c);
-  println();
-}
-
-void Print::println(char c, int base)
-{
-  print(c, base);
-  println();
-}
-
-void Print::println(unsigned char b, int base)
-{
-  print(b, base);
-  println();
-}
-
-void Print::println(int n, int base)
-{
-  print(n, base);
-  println();
-}
-
-void Print::println(unsigned int n, int base)
-{
-  print(n, base);
-  println();
-}
-
-void Print::println(long n, int base)
-{
-  print(n, base);
-  println();
-}
-
-void Print::println(unsigned long n, int base)
-{
-  print(n, base);
-  println();
-}
-
-void Print::println(double n, int digits)
-{
-  print(n, digits);
-  println();
-}
-
-// Private Methods /////////////////////////////////////////////////////////////
-
-void Print::printNumber(unsigned long n, uint8_t base)
-{
-  unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars. 
-  unsigned long i = 0;
-
-  if (n == 0) {
-    print('0');
-    return;
-  } 
-
-  while (n > 0) {
-    buf[i++] = n % base;
-    n /= base;
-  }
-
-  for (; i > 0; i--)
-    print((char) (buf[i - 1] < 10 ?
-      '0' + buf[i - 1] :
-      'A' + buf[i - 1] - 10));
-}
-
-void Print::printFloat(double number, uint8_t digits) 
-{ 
-  // Handle negative numbers
-  if (number < 0.0)
-  {
-     print('-');
-     number = -number;
-  }
-
-  // Round correctly so that print(1.999, 2) prints as "2.00"
-  double rounding = 0.5;
-  for (uint8_t i=0; i<digits; ++i)
-    rounding /= 10.0;
-  
-  number += rounding;
-
-  // Extract the integer part of the number and print it
-  unsigned long int_part = (unsigned long)number;
-  double remainder = number - (double)int_part;
-  print(int_part);
-
-  // Print the decimal point, but only if there are digits beyond
-  if (digits > 0)
-    print("."); 
-
-  // Extract digits from the remainder one at a time
-  while (digits-- > 0)
-  {
-    remainder *= 10.0;
-    int toPrint = int(remainder);
-    print(toPrint);
-    remainder -= toPrint; 
-  } 
-}

+ 0 - 62
optiboot/cores/arduino/Print.h

@@ -1,62 +0,0 @@
-/*
-  Print.h - Base class that provides print() and println()
-  Copyright (c) 2008 David A. Mellis.  All right reserved.
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public
-  License along with this library; if not, write to the Free Software
-  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-*/
-
-#ifndef Print_h
-#define Print_h
-
-#include <inttypes.h>
-#include <stdio.h> // for size_t
-
-#define DEC 10
-#define HEX 16
-#define OCT 8
-#define BIN 2
-#define BYTE 0
-
-class Print
-{
-  private:
-    void printNumber(unsigned long, uint8_t);
-    void printFloat(double, uint8_t);
-  public:
-    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 char[]);
-    void print(char, int = BYTE);
-    void print(unsigned char, int = BYTE);
-    void print(int, int = DEC);
-    void print(unsigned int, int = DEC);
-    void print(long, int = DEC);
-    void print(unsigned long, int = DEC);
-    void print(double, int = 2);
-
-    void println(const char[]);
-    void println(char, int = BYTE);
-    void println(unsigned char, int = BYTE);
-    void println(int, int = DEC);
-    void println(unsigned int, int = DEC);
-    void println(long, int = DEC);
-    void println(unsigned long, int = DEC);
-    void println(double, int = 2);
-    void println(void);
-};
-
-#endif

+ 0 - 515
optiboot/cores/arduino/Tone.cpp

@@ -1,515 +0,0 @@
-/* Tone.cpp
-
-  A Tone Generator Library
-
-  Written by Brett Hagman
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public
-  License along with this library; if not, write to the Free Software
-  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-Version Modified By Date     Comments
-------- ----------- -------- --------
-0001    B Hagman    09/08/02 Initial coding
-0002    B Hagman    09/08/18 Multiple pins
-0003    B Hagman    09/08/18 Moved initialization from constructor to begin()
-0004    B Hagman    09/09/26 Fixed problems with ATmega8
-0005    B Hagman    09/11/23 Scanned prescalars for best fit on 8 bit timers
-                    09/11/25 Changed pin toggle method to XOR
-                    09/11/25 Fixed timer0 from being excluded
-0006    D Mellis    09/12/29 Replaced objects with functions
-
-*************************************************/
-
-#include <avr/interrupt.h>
-#include <avr/pgmspace.h>
-#include <wiring.h>
-#include <pins_arduino.h>
-
-#if defined(__AVR_ATmega8__)
-#define TCCR2A TCCR2
-#define TCCR2B TCCR2
-#define COM2A1 COM21
-#define COM2A0 COM20
-#define OCR2A OCR2
-#define TIMSK2 TIMSK
-#define OCIE2A OCIE2
-#define TIMER2_COMPA_vect TIMER2_COMP_vect
-#define TIMSK1 TIMSK
-#endif
-
-// timerx_toggle_count:
-//  > 0 - duration specified
-//  = 0 - stopped
-//  < 0 - infinitely (until stop() method called, or new play() called)
-
-#if !defined(__AVR_ATmega8__)
-volatile long timer0_toggle_count;
-volatile uint8_t *timer0_pin_port;
-volatile uint8_t timer0_pin_mask;
-#endif
-
-volatile long timer1_toggle_count;
-volatile uint8_t *timer1_pin_port;
-volatile uint8_t timer1_pin_mask;
-volatile long timer2_toggle_count;
-volatile uint8_t *timer2_pin_port;
-volatile uint8_t timer2_pin_mask;
-
-#if defined(__AVR_ATmega1280__)
-volatile long timer3_toggle_count;
-volatile uint8_t *timer3_pin_port;
-volatile uint8_t timer3_pin_mask;
-volatile long timer4_toggle_count;
-volatile uint8_t *timer4_pin_port;
-volatile uint8_t timer4_pin_mask;
-volatile long timer5_toggle_count;
-volatile uint8_t *timer5_pin_port;
-volatile uint8_t timer5_pin_mask;
-#endif
-
-
-#if defined(__AVR_ATmega1280__)
-
-#define AVAILABLE_TONE_PINS 1
-
-const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 3, 4, 5, 1, 0 */ };
-static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255, 255, 255, 255, 255 */ };
-
-#elif defined(__AVR_ATmega8__)
-
-#define AVAILABLE_TONE_PINS 1
-
-const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 1 */ };
-static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255 */ };
-
-#else
-
-#define AVAILABLE_TONE_PINS 1
-
-// Leave timer 0 to last.
-const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 1, 0 */ };
-static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255, 255 */ };
-
-#endif
-
-
-
-static int8_t toneBegin(uint8_t _pin)
-{
-  int8_t _timer = -1;
-
-  // if we're already using the pin, the timer should be configured.  
-  for (int i = 0; i < AVAILABLE_TONE_PINS; i++) {
-    if (tone_pins[i] == _pin) {
-      return pgm_read_byte(tone_pin_to_timer_PGM + i);
-    }
-  }
-  
-  // search for an unused timer.
-  for (int i = 0; i < AVAILABLE_TONE_PINS; i++) {
-    if (tone_pins[i] == 255) {
-      tone_pins[i] = _pin;
-      _timer = pgm_read_byte(tone_pin_to_timer_PGM + i);
-      break;
-    }
-  }
-  
-  if (_timer != -1)
-  {
-    // Set timer specific stuff
-    // All timers in CTC mode
-    // 8 bit timers will require changing prescalar values,
-    // whereas 16 bit timers are set to either ck/1 or ck/64 prescalar
-    switch (_timer)
-    {
-#if !defined(__AVR_ATmega8__)
-      case 0:
-        // 8 bit timer
-        TCCR0A = 0;
-        TCCR0B = 0;
-        bitWrite(TCCR0A, WGM01, 1);
-        bitWrite(TCCR0B, CS00, 1);
-        timer0_pin_port = portOutputRegister(digitalPinToPort(_pin));
-        timer0_pin_mask = digitalPinToBitMask(_pin);
-        break;
-#endif
-
-      case 1:
-        // 16 bit timer
-        TCCR1A = 0;
-        TCCR1B = 0;
-        bitWrite(TCCR1B, WGM12, 1);
-        bitWrite(TCCR1B, CS10, 1);
-        timer1_pin_port = portOutputRegister(digitalPinToPort(_pin));
-        timer1_pin_mask = digitalPinToBitMask(_pin);
-        break;
-      case 2:
-        // 8 bit timer
-        TCCR2A = 0;
-        TCCR2B = 0;
-        bitWrite(TCCR2A, WGM21, 1);
-        bitWrite(TCCR2B, CS20, 1);
-        timer2_pin_port = portOutputRegister(digitalPinToPort(_pin));
-        timer2_pin_mask = digitalPinToBitMask(_pin);
-        break;
-
-#if defined(__AVR_ATmega1280__)
-      case 3:
-        // 16 bit timer
-        TCCR3A = 0;
-        TCCR3B = 0;
-        bitWrite(TCCR3B, WGM32, 1);
-        bitWrite(TCCR3B, CS30, 1);
-        timer3_pin_port = portOutputRegister(digitalPinToPort(_pin));
-        timer3_pin_mask = digitalPinToBitMask(_pin);
-        break;
-      case 4:
-        // 16 bit timer
-        TCCR4A = 0;
-        TCCR4B = 0;
-        bitWrite(TCCR4B, WGM42, 1);
-        bitWrite(TCCR4B, CS40, 1);
-        timer4_pin_port = portOutputRegister(digitalPinToPort(_pin));
-        timer4_pin_mask = digitalPinToBitMask(_pin);
-        break;
-      case 5:
-        // 16 bit timer
-        TCCR5A = 0;
-        TCCR5B = 0;
-        bitWrite(TCCR5B, WGM52, 1);
-        bitWrite(TCCR5B, CS50, 1);
-        timer5_pin_port = portOutputRegister(digitalPinToPort(_pin));
-        timer5_pin_mask = digitalPinToBitMask(_pin);
-        break;
-#endif
-    }
-  }
-
-  return _timer;
-}
-
-
-
-// frequency (in hertz) and duration (in milliseconds).
-
-void tone(uint8_t _pin, unsigned int frequency, unsigned long duration)
-{
-  uint8_t prescalarbits = 0b001;
-  long toggle_count = 0;
-  uint32_t ocr = 0;
-  int8_t _timer;
-
-  _timer = toneBegin(_pin);
-
-  if (_timer >= 0)
-  {
-    // Set the pinMode as OUTPUT
-    pinMode(_pin, OUTPUT);
-    
-    // if we are using an 8 bit timer, scan through prescalars to find the best fit
-    if (_timer == 0 || _timer == 2)
-    {
-      ocr = F_CPU / frequency / 2 - 1;
-      prescalarbits = 0b001;  // ck/1: same for both timers
-      if (ocr > 255)
-      {
-        ocr = F_CPU / frequency / 2 / 8 - 1;
-        prescalarbits = 0b010;  // ck/8: same for both timers
-
-        if (_timer == 2 && ocr > 255)
-        {
-          ocr = F_CPU / frequency / 2 / 32 - 1;
-          prescalarbits = 0b011;
-        }
-
-        if (ocr > 255)
-        {
-          ocr = F_CPU / frequency / 2 / 64 - 1;
-          prescalarbits = _timer == 0 ? 0b011 : 0b100;
-
-          if (_timer == 2 && ocr > 255)
-          {
-            ocr = F_CPU / frequency / 2 / 128 - 1;
-            prescalarbits = 0b101;
-          }
-
-          if (ocr > 255)
-          {
-            ocr = F_CPU / frequency / 2 / 256 - 1;
-            prescalarbits = _timer == 0 ? 0b100 : 0b110;
-            if (ocr > 255)
-            {
-              // can't do any better than /1024
-              ocr = F_CPU / frequency / 2 / 1024 - 1;
-              prescalarbits = _timer == 0 ? 0b101 : 0b111;
-            }
-          }
-        }
-      }
-
-#if !defined(__AVR_ATmega8__)
-      if (_timer == 0)
-        TCCR0B = prescalarbits;
-      else
-#endif
-        TCCR2B = prescalarbits;
-    }
-    else
-    {
-      // two choices for the 16 bit timers: ck/1 or ck/64
-      ocr = F_CPU / frequency / 2 - 1;
-
-      prescalarbits = 0b001;
-      if (ocr > 0xffff)
-      {
-        ocr = F_CPU / frequency / 2 / 64 - 1;
-        prescalarbits = 0b011;
-      }
-
-      if (_timer == 1)
-        TCCR1B = (TCCR1B & 0b11111000) | prescalarbits;
-#if defined(__AVR_ATmega1280__)
-      else if (_timer == 3)
-        TCCR3B = (TCCR3B & 0b11111000) | prescalarbits;
-      else if (_timer == 4)
-        TCCR4B = (TCCR4B & 0b11111000) | prescalarbits;
-      else if (_timer == 5)
-        TCCR5B = (TCCR5B & 0b11111000) | prescalarbits;
-#endif
-
-    }
-    
-
-    // Calculate the toggle count
-    if (duration > 0)
-    {
-      toggle_count = 2 * frequency * duration / 1000;
-    }
-    else
-    {
-      toggle_count = -1;
-    }
-
-    // Set the OCR for the given timer,
-    // set the toggle count,
-    // then turn on the interrupts
-    switch (_timer)
-    {
-
-#if !defined(__AVR_ATmega8__)
-      case 0:
-        OCR0A = ocr;
-        timer0_toggle_count = toggle_count;
-        bitWrite(TIMSK0, OCIE0A, 1);
-        break;
-#endif
-
-      case 1:
-        OCR1A = ocr;
-        timer1_toggle_count = toggle_count;
-        bitWrite(TIMSK1, OCIE1A, 1);
-        break;
-      case 2:
-        OCR2A = ocr;
-        timer2_toggle_count = toggle_count;
-        bitWrite(TIMSK2, OCIE2A, 1);
-        break;
-
-#if defined(__AVR_ATmega1280__)
-      case 3:
-        OCR3A = ocr;
-        timer3_toggle_count = toggle_count;
-        bitWrite(TIMSK3, OCIE3A, 1);
-        break;
-      case 4:
-        OCR4A = ocr;
-        timer4_toggle_count = toggle_count;
-        bitWrite(TIMSK4, OCIE4A, 1);
-        break;
-      case 5:
-        OCR5A = ocr;
-        timer5_toggle_count = toggle_count;
-        bitWrite(TIMSK5, OCIE5A, 1);
-        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;
-    }
-  }
-  
-  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;
-      break;
-    case 1:
-      TIMSK1 = 0;
-      break;
-    case 2:
-      TIMSK2 = 0;
-      break;
-#endif
-
-#if defined(__AVR_ATmega1280__)
-    case 3:
-      TIMSK3 = 0;
-      break;
-    case 4:
-      TIMSK4 = 0;
-      break;
-    case 5:
-      TIMSK5 = 0;
-      break;
-#endif
-  }
-
-  digitalWrite(_pin, 0);
-}
-
-#if 0
-#if !defined(__AVR_ATmega8__)
-ISR(TIMER0_COMPA_vect)
-{
-  if (timer0_toggle_count != 0)
-  {
-    // toggle the pin
-    *timer0_pin_port ^= timer0_pin_mask;
-
-    if (timer0_toggle_count > 0)
-      timer0_toggle_count--;
-  }
-  else
-  {
-    TIMSK0 = 0;   // disable the interrupt
-    *timer0_pin_port &= ~(timer0_pin_mask);  // keep pin low after stop
-  }
-}
-#endif
-
-
-ISR(TIMER1_COMPA_vect)
-{
-  if (timer1_toggle_count != 0)
-  {
-    // toggle the pin
-    *timer1_pin_port ^= timer1_pin_mask;
-
-    if (timer1_toggle_count > 0)
-      timer1_toggle_count--;
-  }
-  else
-  {
-    TIMSK1 = 0;   // disable the interrupt
-    *timer1_pin_port &= ~(timer1_pin_mask);  // keep pin low after stop
-  }
-}
-#endif
-
-
-ISR(TIMER2_COMPA_vect)
-{
-
-  if (timer2_toggle_count != 0)
-  {
-    // toggle the pin
-    *timer2_pin_port ^= timer2_pin_mask;
-
-    if (timer2_toggle_count > 0)
-      timer2_toggle_count--;
-  }
-  else
-  {
-    TIMSK2 = 0;   // disable the interrupt
-    *timer2_pin_port &= ~(timer2_pin_mask);  // keep pin low after stop
-  }
-}
-
-
-
-//#if defined(__AVR_ATmega1280__)
-#if 0
-
-ISR(TIMER3_COMPA_vect)
-{
-  if (timer3_toggle_count != 0)
-  {
-    // toggle the pin
-    *timer3_pin_port ^= timer3_pin_mask;
-
-    if (timer3_toggle_count > 0)
-      timer3_toggle_count--;
-  }
-  else
-  {
-    TIMSK3 = 0;   // disable the interrupt
-    *timer3_pin_port &= ~(timer3_pin_mask);  // keep pin low after stop
-  }
-}
-
-ISR(TIMER4_COMPA_vect)
-{
-  if (timer4_toggle_count != 0)
-  {
-    // toggle the pin
-    *timer4_pin_port ^= timer4_pin_mask;
-
-    if (timer4_toggle_count > 0)
-      timer4_toggle_count--;
-  }
-  else
-  {
-    TIMSK4 = 0;   // disable the interrupt
-    *timer4_pin_port &= ~(timer4_pin_mask);  // keep pin low after stop
-  }
-}
-
-ISR(TIMER5_COMPA_vect)
-{
-  if (timer5_toggle_count != 0)
-  {
-    // toggle the pin
-    *timer5_pin_port ^= timer5_pin_mask;
-
-    if (timer5_toggle_count > 0)
-      timer5_toggle_count--;
-  }
-  else
-  {
-    TIMSK5 = 0;   // disable the interrupt
-    *timer5_pin_port &= ~(timer5_pin_mask);  // keep pin low after stop
-  }
-}
-
-#endif

+ 0 - 1
optiboot/cores/arduino/WConstants.h

@@ -1 +0,0 @@
-#include "wiring.h"

+ 0 - 215
optiboot/cores/arduino/WInterrupts.c

@@ -1,215 +0,0 @@
-/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
-
-/*
-  Part of the Wiring project - http://wiring.uniandes.edu.co
-
-  Copyright (c) 2004-05 Hernando Barragan
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General
-  Public License along with this library; if not, write to the
-  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
-  Boston, MA  02111-1307  USA
-  
-  Modified 24 November 2006 by David A. Mellis
-*/
-
-#include <inttypes.h>
-#include <avr/io.h>
-#include <avr/interrupt.h>
-#include <avr/pgmspace.h>
-#include <stdio.h>
-
-#include "WConstants.h"
-#include "wiring_private.h"
-
-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;
-    
-    // Configure the interrupt mode (trigger on low input, any change, rising
-    // edge, or falling edge).  The mode constants were chosen to correspond
-    // to the configuration bits in the hardware register, so we simply shift
-    // the mode into place.
-      
-    // Enable the interrupt.
-      
-    switch (interruptNum) {
-#if defined(__AVR_ATmega1280__)
-    case 2:
-      EICRA = (EICRA & ~((1 << ISC00) | (1 << ISC01))) | (mode << ISC00);
-      EIMSK |= (1 << INT0);
-      break;
-    case 3:
-      EICRA = (EICRA & ~((1 << ISC10) | (1 << ISC11))) | (mode << ISC10);
-      EIMSK |= (1 << INT1);
-      break;
-    case 4:
-      EICRA = (EICRA & ~((1 << ISC20) | (1 << ISC21))) | (mode << ISC20);
-      EIMSK |= (1 << INT2);
-      break;
-    case 5:
-      EICRA = (EICRA & ~((1 << ISC30) | (1 << ISC31))) | (mode << ISC30);
-      EIMSK |= (1 << INT3);
-      break;
-    case 0:
-      EICRB = (EICRB & ~((1 << ISC40) | (1 << ISC41))) | (mode << ISC40);
-      EIMSK |= (1 << INT4);
-      break;
-    case 1:
-      EICRB = (EICRB & ~((1 << ISC50) | (1 << ISC51))) | (mode << ISC50);
-      EIMSK |= (1 << INT5);
-      break;
-    case 6:
-      EICRB = (EICRB & ~((1 << ISC60) | (1 << ISC61))) | (mode << ISC60);
-      EIMSK |= (1 << INT6);
-      break;
-    case 7:
-      EICRB = (EICRB & ~((1 << ISC70) | (1 << ISC71))) | (mode << ISC70);
-      EIMSK |= (1 << INT7);
-      break;
-#else
-    case 0:
-      EICRA = (EICRA & ~((1 << ISC00) | (1 << ISC01))) | (mode << ISC00);
-      EIMSK |= (1 << INT0);
-      break;
-    case 1:
-      EICRA = (EICRA & ~((1 << ISC10) | (1 << ISC11))) | (mode << ISC10);
-      EIMSK |= (1 << INT1);
-      break;
-#endif
-    }
-  }
-}
-
-void detachInterrupt(uint8_t interruptNum) {
-  if(interruptNum < EXTERNAL_NUM_INTERRUPTS) {
-    // Disable the interrupt.  (We can't assume that interruptNum is equal
-    // to the number of the EIMSK bit to clear, as this isn't true on the 
-    // ATmega8.  There, INT0 is 6 and INT1 is 7.)
-    switch (interruptNum) {
-#if defined(__AVR_ATmega1280__)
-    case 2:
-      EIMSK &= ~(1 << INT0);
-      break;
-    case 3:
-      EIMSK &= ~(1 << INT1);
-      break;
-    case 4:
-      EIMSK &= ~(1 << INT2);
-      break;
-    case 5:
-      EIMSK &= ~(1 << INT3);
-      break;
-    case 0:
-      EIMSK &= ~(1 << INT4);
-      break;
-    case 1:
-      EIMSK &= ~(1 << INT5);
-      break;
-    case 6:
-      EIMSK &= ~(1 << INT6);
-      break;
-    case 7:
-      EIMSK &= ~(1 << INT7);
-      break;
-#else
-    case 0:
-      EIMSK &= ~(1 << INT0);
-      break;
-    case 1:
-      EIMSK &= ~(1 << INT1);
-      break;
-#endif
-    }
-      
-    intFunc[interruptNum] = 0;
-  }
-}
-
-/*
-void attachInterruptTwi(void (*userFunc)(void) ) {
-  twiIntFunc = userFunc;
-}
-*/
-
-#if defined(__AVR_ATmega1280__)
-
-SIGNAL(INT0_vect) {
-  if(intFunc[EXTERNAL_INT_2])
-    intFunc[EXTERNAL_INT_2]();
-}
-
-SIGNAL(INT1_vect) {
-  if(intFunc[EXTERNAL_INT_3])
-    intFunc[EXTERNAL_INT_3]();
-}
-
-SIGNAL(INT2_vect) {
-  if(intFunc[EXTERNAL_INT_4])
-    intFunc[EXTERNAL_INT_4]();
-}
-
-SIGNAL(INT3_vect) {
-  if(intFunc[EXTERNAL_INT_5])
-    intFunc[EXTERNAL_INT_5]();
-}
-
-SIGNAL(INT4_vect) {
-  if(intFunc[EXTERNAL_INT_0])
-    intFunc[EXTERNAL_INT_0]();
-}
-
-SIGNAL(INT5_vect) {
-  if(intFunc[EXTERNAL_INT_1])
-    intFunc[EXTERNAL_INT_1]();
-}
-
-SIGNAL(INT6_vect) {
-  if(intFunc[EXTERNAL_INT_6])
-    intFunc[EXTERNAL_INT_6]();
-}
-
-SIGNAL(INT7_vect) {
-  if(intFunc[EXTERNAL_INT_7])
-    intFunc[EXTERNAL_INT_7]();
-}
-
-#else
-
-SIGNAL(INT0_vect) {
-  if(intFunc[EXTERNAL_INT_0])
-    intFunc[EXTERNAL_INT_0]();
-}
-
-SIGNAL(INT1_vect) {
-  if(intFunc[EXTERNAL_INT_1])
-    intFunc[EXTERNAL_INT_1]();
-}
-
-#endif
-
-/*
-SIGNAL(SIG_2WIRE_SERIAL) {
-  if(twiIntFunc)
-    twiIntFunc();
-}
-*/
-

+ 0 - 60
optiboot/cores/arduino/WMath.cpp

@@ -1,60 +0,0 @@
-/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
-
-/*
-  Part of the Wiring project - http://wiring.org.co
-  Copyright (c) 2004-06 Hernando Barragan
-  Modified 13 August 2006, David A. Mellis for Arduino - http://www.arduino.cc/
-  
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General
-  Public License along with this library; if not, write to the
-  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
-  Boston, MA  02111-1307  USA
-  
-  $Id$
-*/
-
-extern "C" {
-  #include "stdlib.h"
-}
-
-void randomSeed(unsigned int seed)
-{
-  if (seed != 0) {
-    srandom(seed);
-  }
-}
-
-long random(long howbig)
-{
-  if (howbig == 0) {
-    return 0;
-  }
-  return random() % howbig;
-}
-
-long random(long howsmall, long howbig)
-{
-  if (howsmall >= howbig) {
-    return howsmall;
-  }
-  long diff = howbig - howsmall;
-  return random(diff) + howsmall;
-}
-
-long map(long x, long in_min, long in_max, long out_min, long out_max)
-{
-  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
-}
-
-unsigned int makeWord(unsigned int w) { return w; }
-unsigned int makeWord(unsigned char h, unsigned char l) { return (h << 8) | l; }

+ 0 - 32
optiboot/cores/arduino/WProgram.h

@@ -1,32 +0,0 @@
-#ifndef WProgram_h
-#define WProgram_h
-
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-
-#include <avr/interrupt.h>
-
-#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

+ 0 - 3
optiboot/cores/arduino/_ReadMe.txt

@@ -1,3 +0,0 @@
-Arduino does not currently allow additional hardware directories to share the standard Arduino core. So a copy of the Arduino 18 core is included here. No changes have been made.
-
-Arduino source is from http://arduino.cc

+ 0 - 515
optiboot/cores/arduino/binary.h

@@ -1,515 +0,0 @@
-#ifndef Binary_h
-#define Binary_h
-
-#define B0 0
-#define B00 0
-#define B000 0
-#define B0000 0
-#define B00000 0
-#define B000000 0
-#define B0000000 0
-#define B00000000 0
-#define B1 1
-#define B01 1
-#define B001 1
-#define B0001 1
-#define B00001 1
-#define B000001 1
-#define B0000001 1
-#define B00000001 1
-#define B10 2
-#define B010 2
-#define B0010 2
-#define B00010 2
-#define B000010 2
-#define B0000010 2
-#define B00000010 2
-#define B11 3
-#define B011 3
-#define B0011 3
-#define B00011 3
-#define B000011 3
-#define B0000011 3
-#define B00000011 3
-#define B100 4
-#define B0100 4
-#define B00100 4
-#define B000100 4
-#define B0000100 4
-#define B00000100 4
-#define B101 5
-#define B0101 5
-#define B00101 5
-#define B000101 5
-#define B0000101 5
-#define B00000101 5
-#define B110 6
-#define B0110 6
-#define B00110 6
-#define B000110 6
-#define B0000110 6
-#define B00000110 6
-#define B111 7
-#define B0111 7
-#define B00111 7
-#define B000111 7
-#define B0000111 7
-#define B00000111 7
-#define B1000 8
-#define B01000 8
-#define B001000 8
-#define B0001000 8
-#define B00001000 8
-#define B1001 9
-#define B01001 9
-#define B001001 9
-#define B0001001 9
-#define B00001001 9
-#define B1010 10
-#define B01010 10
-#define B001010 10
-#define B0001010 10
-#define B00001010 10
-#define B1011 11
-#define B01011 11
-#define B001011 11
-#define B0001011 11
-#define B00001011 11
-#define B1100 12
-#define B01100 12
-#define B001100 12
-#define B0001100 12
-#define B00001100 12
-#define B1101 13
-#define B01101 13
-#define B001101 13
-#define B0001101 13
-#define B00001101 13
-#define B1110 14
-#define B01110 14
-#define B001110 14
-#define B0001110 14
-#define B00001110 14
-#define B1111 15
-#define B01111 15
-#define B001111 15
-#define B0001111 15
-#define B00001111 15
-#define B10000 16
-#define B010000 16
-#define B0010000 16
-#define B00010000 16
-#define B10001 17
-#define B010001 17
-#define B0010001 17
-#define B00010001 17
-#define B10010 18
-#define B010010 18
-#define B0010010 18
-#define B00010010 18
-#define B10011 19
-#define B010011 19
-#define B0010011 19
-#define B00010011 19
-#define B10100 20
-#define B010100 20
-#define B0010100 20
-#define B00010100 20
-#define B10101 21
-#define B010101 21
-#define B0010101 21
-#define B00010101 21
-#define B10110 22
-#define B010110 22
-#define B0010110 22
-#define B00010110 22
-#define B10111 23
-#define B010111 23
-#define B0010111 23
-#define B00010111 23
-#define B11000 24
-#define B011000 24
-#define B0011000 24
-#define B00011000 24
-#define B11001 25
-#define B011001 25
-#define B0011001 25
-#define B00011001 25
-#define B11010 26
-#define B011010 26
-#define B0011010 26
-#define B00011010 26
-#define B11011 27
-#define B011011 27
-#define B0011011 27
-#define B00011011 27
-#define B11100 28
-#define B011100 28
-#define B0011100 28
-#define B00011100 28
-#define B11101 29
-#define B011101 29
-#define B0011101 29
-#define B00011101 29
-#define B11110 30
-#define B011110 30
-#define B0011110 30
-#define B00011110 30
-#define B11111 31
-#define B011111 31
-#define B0011111 31
-#define B00011111 31
-#define B100000 32
-#define B0100000 32
-#define B00100000 32
-#define B100001 33
-#define B0100001 33
-#define B00100001 33
-#define B100010 34
-#define B0100010 34
-#define B00100010 34
-#define B100011 35
-#define B0100011 35
-#define B00100011 35
-#define B100100 36
-#define B0100100 36
-#define B00100100 36
-#define B100101 37
-#define B0100101 37
-#define B00100101 37
-#define B100110 38
-#define B0100110 38
-#define B00100110 38
-#define B100111 39
-#define B0100111 39
-#define B00100111 39
-#define B101000 40
-#define B0101000 40
-#define B00101000 40
-#define B101001 41
-#define B0101001 41
-#define B00101001 41
-#define B101010 42
-#define B0101010 42
-#define B00101010 42
-#define B101011 43
-#define B0101011 43
-#define B00101011 43
-#define B101100 44
-#define B0101100 44
-#define B00101100 44
-#define B101101 45
-#define B0101101 45
-#define B00101101 45
-#define B101110 46
-#define B0101110 46
-#define B00101110 46
-#define B101111 47
-#define B0101111 47
-#define B00101111 47
-#define B110000 48
-#define B0110000 48
-#define B00110000 48
-#define B110001 49
-#define B0110001 49
-#define B00110001 49
-#define B110010 50
-#define B0110010 50
-#define B00110010 50
-#define B110011 51
-#define B0110011 51
-#define B00110011 51
-#define B110100 52
-#define B0110100 52
-#define B00110100 52
-#define B110101 53
-#define B0110101 53
-#define B00110101 53
-#define B110110 54
-#define B0110110 54
-#define B00110110 54
-#define B110111 55
-#define B0110111 55
-#define B00110111 55
-#define B111000 56
-#define B0111000 56
-#define B00111000 56
-#define B111001 57
-#define B0111001 57
-#define B00111001 57
-#define B111010 58
-#define B0111010 58
-#define B00111010 58
-#define B111011 59
-#define B0111011 59
-#define B00111011 59
-#define B111100 60
-#define B0111100 60
-#define B00111100 60
-#define B111101 61
-#define B0111101 61
-#define B00111101 61
-#define B111110 62
-#define B0111110 62
-#define B00111110 62
-#define B111111 63
-#define B0111111 63
-#define B00111111 63
-#define B1000000 64
-#define B01000000 64
-#define B1000001 65
-#define B01000001 65
-#define B1000010 66
-#define B01000010 66
-#define B1000011 67
-#define B01000011 67
-#define B1000100 68
-#define B01000100 68
-#define B1000101 69
-#define B01000101 69
-#define B1000110 70
-#define B01000110 70
-#define B1000111 71
-#define B01000111 71
-#define B1001000 72
-#define B01001000 72
-#define B1001001 73
-#define B01001001 73
-#define B1001010 74
-#define B01001010 74
-#define B1001011 75
-#define B01001011 75
-#define B1001100 76
-#define B01001100 76
-#define B1001101 77
-#define B01001101 77
-#define B1001110 78
-#define B01001110 78
-#define B1001111 79
-#define B01001111 79
-#define B1010000 80
-#define B01010000 80
-#define B1010001 81
-#define B01010001 81
-#define B1010010 82
-#define B01010010 82
-#define B1010011 83
-#define B01010011 83
-#define B1010100 84
-#define B01010100 84
-#define B1010101 85
-#define B01010101 85
-#define B1010110 86
-#define B01010110 86
-#define B1010111 87
-#define B01010111 87
-#define B1011000 88
-#define B01011000 88
-#define B1011001 89
-#define B01011001 89
-#define B1011010 90
-#define B01011010 90
-#define B1011011 91
-#define B01011011 91
-#define B1011100 92
-#define B01011100 92
-#define B1011101 93
-#define B01011101 93
-#define B1011110 94
-#define B01011110 94
-#define B1011111 95
-#define B01011111 95
-#define B1100000 96
-#define B01100000 96
-#define B1100001 97
-#define B01100001 97
-#define B1100010 98
-#define B01100010 98
-#define B1100011 99
-#define B01100011 99
-#define B1100100 100
-#define B01100100 100
-#define B1100101 101
-#define B01100101 101
-#define B1100110 102
-#define B01100110 102
-#define B1100111 103
-#define B01100111 103
-#define B1101000 104
-#define B01101000 104
-#define B1101001 105
-#define B01101001 105
-#define B1101010 106
-#define B01101010 106
-#define B1101011 107
-#define B01101011 107
-#define B1101100 108
-#define B01101100 108
-#define B1101101 109
-#define B01101101 109
-#define B1101110 110
-#define B01101110 110
-#define B1101111 111
-#define B01101111 111
-#define B1110000 112
-#define B01110000 112
-#define B1110001 113
-#define B01110001 113
-#define B1110010 114
-#define B01110010 114
-#define B1110011 115
-#define B01110011 115
-#define B1110100 116
-#define B01110100 116
-#define B1110101 117
-#define B01110101 117
-#define B1110110 118
-#define B01110110 118
-#define B1110111 119
-#define B01110111 119
-#define B1111000 120
-#define B01111000 120
-#define B1111001 121
-#define B01111001 121
-#define B1111010 122
-#define B01111010 122
-#define B1111011 123
-#define B01111011 123
-#define B1111100 124
-#define B01111100 124
-#define B1111101 125
-#define B01111101 125
-#define B1111110 126
-#define B01111110 126
-#define B1111111 127
-#define B01111111 127
-#define B10000000 128
-#define B10000001 129
-#define B10000010 130
-#define B10000011 131
-#define B10000100 132
-#define B10000101 133
-#define B10000110 134
-#define B10000111 135
-#define B10001000 136
-#define B10001001 137
-#define B10001010 138
-#define B10001011 139
-#define B10001100 140
-#define B10001101 141
-#define B10001110 142
-#define B10001111 143
-#define B10010000 144
-#define B10010001 145
-#define B10010010 146
-#define B10010011 147
-#define B10010100 148
-#define B10010101 149
-#define B10010110 150
-#define B10010111 151
-#define B10011000 152
-#define B10011001 153
-#define B10011010 154
-#define B10011011 155
-#define B10011100 156
-#define B10011101 157
-#define B10011110 158
-#define B10011111 159
-#define B10100000 160
-#define B10100001 161
-#define B10100010 162
-#define B10100011 163
-#define B10100100 164
-#define B10100101 165
-#define B10100110 166
-#define B10100111 167
-#define B10101000 168
-#define B10101001 169
-#define B10101010 170
-#define B10101011 171
-#define B10101100 172
-#define B10101101 173
-#define B10101110 174
-#define B10101111 175
-#define B10110000 176
-#define B10110001 177
-#define B10110010 178
-#define B10110011 179
-#define B10110100 180
-#define B10110101 181
-#define B10110110 182
-#define B10110111 183
-#define B10111000 184
-#define B10111001 185
-#define B10111010 186
-#define B10111011 187
-#define B10111100 188
-#define B10111101 189
-#define B10111110 190
-#define B10111111 191
-#define B11000000 192
-#define B11000001 193
-#define B11000010 194
-#define B11000011 195
-#define B11000100 196
-#define B11000101 197
-#define B11000110 198
-#define B11000111 199
-#define B11001000 200
-#define B11001001 201
-#define B11001010 202
-#define B11001011 203
-#define B11001100 204
-#define B11001101 205
-#define B11001110 206
-#define B11001111 207
-#define B11010000 208
-#define B11010001 209
-#define B11010010 210
-#define B11010011 211
-#define B11010100 212
-#define B11010101 213
-#define B11010110 214
-#define B11010111 215
-#define B11011000 216
-#define B11011001 217
-#define B11011010 218
-#define B11011011 219
-#define B11011100 220
-#define B11011101 221
-#define B11011110 222
-#define B11011111 223
-#define B11100000 224
-#define B11100001 225
-#define B11100010 226
-#define B11100011 227
-#define B11100100 228
-#define B11100101 229
-#define B11100110 230
-#define B11100111 231
-#define B11101000 232
-#define B11101001 233
-#define B11101010 234
-#define B11101011 235
-#define B11101100 236
-#define B11101101 237
-#define B11101110 238
-#define B11101111 239
-#define B11110000 240
-#define B11110001 241
-#define B11110010 242
-#define B11110011 243
-#define B11110100 244
-#define B11110101 245
-#define B11110110 246
-#define B11110111 247
-#define B11111000 248
-#define B11111001 249
-#define B11111010 250
-#define B11111011 251
-#define B11111100 252
-#define B11111101 253
-#define B11111110 254
-#define B11111111 255
-
-#endif

+ 0 - 14
optiboot/cores/arduino/main.cpp

@@ -1,14 +0,0 @@
-#include <WProgram.h>
-
-int main(void)
-{
-	init();
-
-	setup();
-    
-	for (;;)
-		loop();
-        
-	return 0;
-}
-

+ 0 - 469
optiboot/cores/arduino/pins_arduino.c

@@ -1,469 +0,0 @@
-/*
-  pins_arduino.c - pin definitions for the Arduino board
-  Part of Arduino / Wiring Lite
-
-  Copyright (c) 2005 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: pins_arduino.c 804 2009-12-18 16:05:52Z dmellis $
-*/
-
-#include <avr/io.h>
-#include "wiring_private.h"
-#include "pins_arduino.h"
-
-// On the Arduino board, digital pins are also used
-// for the analog output (software PWM).  Analog input
-// pins are a separate set.
-
-// ATMEL ATMEGA8 & 168 / ARDUINO
-//
-//                  +-\/-+
-//            PC6  1|    |28  PC5 (AI 5)
-//      (D 0) PD0  2|    |27  PC4 (AI 4)
-//      (D 1) PD1  3|    |26  PC3 (AI 3)
-//      (D 2) PD2  4|    |25  PC2 (AI 2)
-// PWM+ (D 3) PD3  5|    |24  PC1 (AI 1)
-//      (D 4) PD4  6|    |23  PC0 (AI 0)
-//            VCC  7|    |22  GND
-//            GND  8|    |21  AREF
-//            PB6  9|    |20  AVCC
-//            PB7 10|    |19  PB5 (D 13)
-// PWM+ (D 5) PD5 11|    |18  PB4 (D 12)
-// PWM+ (D 6) PD6 12|    |17  PB3 (D 11) PWM
-//      (D 7) PD7 13|    |16  PB2 (D 10) PWM
-//      (D 8) PB0 14|    |15  PB1 (D 9) PWM
-//                  +----+
-//
-// (PWM+ indicates the additional PWM pins on the ATmega168.)
-
-// ATMEL ATMEGA1280 / ARDUINO
-//
-// 0-7 PE0-PE7   works
-// 8-13 PB0-PB5  works
-// 14-21 PA0-PA7 works 
-// 22-29 PH0-PH7 works
-// 30-35 PG5-PG0 works
-// 36-43 PC7-PC0 works
-// 44-51 PJ7-PJ0 works
-// 52-59 PL7-PL0 works
-// 60-67 PD7-PD0 works
-// A0-A7 PF0-PF7
-// A8-A15 PK0-PK7
-
-#define PA 1
-#define PB 2
-#define PC 3
-#define PD 4
-#define PE 5
-#define PF 6
-#define PG 7
-#define PH 8
-#define PJ 10
-#define PK 11
-#define PL 12
-
-#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__)
-const uint16_t PROGMEM port_to_mode_PGM[] = {
-	NOT_A_PORT,
-	&DDRA,
-	&DDRB,
-	&DDRC,
-	&DDRD,
-	&DDRE,
-	&DDRF,
-	&DDRG,
-	&DDRH,
-	NOT_A_PORT,
-	&DDRJ,
-	&DDRK,
-	&DDRL,
-};
-
-const uint16_t PROGMEM port_to_output_PGM[] = {
-	NOT_A_PORT,
-	&PORTA,
-	&PORTB,
-	&PORTC,
-	&PORTD,
-	&PORTE,
-	&PORTF,
-	&PORTG,
-	&PORTH,
-	NOT_A_PORT,
-	&PORTJ,
-	&PORTK,
-	&PORTL,
-};
-
-const uint16_t PROGMEM port_to_input_PGM[] = {
-	NOT_A_PIN,
-	&PINA,
-	&PINB,
-	&PINC,
-	&PIND,
-	&PINE,
-	&PINF,
-	&PING,
-	&PINH,
-	NOT_A_PIN,
-	&PINJ,
-	&PINK,
-	&PINL,
-};
-
-const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
-	// PORTLIST		
-	// -------------------------------------------		
-	PE	, // PE 0 ** 0 ** USART0_RX	
-	PE	, // PE 1 ** 1 ** USART0_TX	
-	PE	, // PE 4 ** 2 ** PWM2	
-	PE	, // PE 5 ** 3 ** PWM3	
-	PG	, // PG 5 ** 4 ** PWM4	
-	PE	, // PE 3 ** 5 ** PWM5	
-	PH	, // PH 3 ** 6 ** PWM6	
-	PH	, // PH 4 ** 7 ** PWM7	
-	PH	, // PH 5 ** 8 ** PWM8	
-	PH	, // PH 6 ** 9 ** PWM9	
-	PB	, // PB 4 ** 10 ** PWM10	
-	PB	, // PB 5 ** 11 ** PWM11	
-	PB	, // PB 6 ** 12 ** PWM12	
-	PB	, // PB 7 ** 13 ** PWM13	
-	PJ	, // PJ 1 ** 14 ** USART3_TX	
-	PJ	, // PJ 0 ** 15 ** USART3_RX	
-	PH	, // PH 1 ** 16 ** USART2_TX	
-	PH	, // PH 0 ** 17 ** USART2_RX	
-	PD	, // PD 3 ** 18 ** USART1_TX	
-	PD	, // PD 2 ** 19 ** USART1_RX	
-	PD	, // PD 1 ** 20 ** I2C_SDA	
-	PD	, // PD 0 ** 21 ** I2C_SCL	
-	PA	, // PA 0 ** 22 ** D22	
-	PA	, // PA 1 ** 23 ** D23	
-	PA	, // PA 2 ** 24 ** D24	
-	PA	, // PA 3 ** 25 ** D25	
-	PA	, // PA 4 ** 26 ** D26	
-	PA	, // PA 5 ** 27 ** D27	
-	PA	, // PA 6 ** 28 ** D28	
-	PA	, // PA 7 ** 29 ** D29	
-	PC	, // PC 7 ** 30 ** D30	
-	PC	, // PC 6 ** 31 ** D31	
-	PC	, // PC 5 ** 32 ** D32	
-	PC	, // PC 4 ** 33 ** D33	
-	PC	, // PC 3 ** 34 ** D34	
-	PC	, // PC 2 ** 35 ** D35	
-	PC	, // PC 1 ** 36 ** D36	
-	PC	, // PC 0 ** 37 ** D37	
-	PD	, // PD 7 ** 38 ** D38	
-	PG	, // PG 2 ** 39 ** D39	
-	PG	, // PG 1 ** 40 ** D40	
-	PG	, // PG 0 ** 41 ** D41	
-	PL	, // PL 7 ** 42 ** D42	
-	PL	, // PL 6 ** 43 ** D43	
-	PL	, // PL 5 ** 44 ** D44	
-	PL	, // PL 4 ** 45 ** D45	
-	PL	, // PL 3 ** 46 ** D46	
-	PL	, // PL 2 ** 47 ** D47	
-	PL	, // PL 1 ** 48 ** D48	
-	PL	, // PL 0 ** 49 ** D49	
-	PB	, // PB 3 ** 50 ** SPI_MISO	
-	PB	, // PB 2 ** 51 ** SPI_MOSI	
-	PB	, // PB 1 ** 52 ** SPI_SCK	
-	PB	, // PB 0 ** 53 ** SPI_SS	
-	PF	, // PF 0 ** 54 ** A0	
-	PF	, // PF 1 ** 55 ** A1	
-	PF	, // PF 2 ** 56 ** A2	
-	PF	, // PF 3 ** 57 ** A3	
-	PF	, // PF 4 ** 58 ** A4	
-	PF	, // PF 5 ** 59 ** A5	
-	PF	, // PF 6 ** 60 ** A6	
-	PF	, // PF 7 ** 61 ** A7	
-	PK	, // PK 0 ** 62 ** A8	
-	PK	, // PK 1 ** 63 ** A9	
-	PK	, // PK 2 ** 64 ** A10	
-	PK	, // PK 3 ** 65 ** A11	
-	PK	, // PK 4 ** 66 ** A12	
-	PK	, // PK 5 ** 67 ** A13	
-	PK	, // PK 6 ** 68 ** A14	
-	PK	, // PK 7 ** 69 ** A15	
-};
-
-const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = {
-	// PIN IN PORT		
-	// -------------------------------------------		
-	_BV( 0 )	, // PE 0 ** 0 ** USART0_RX	
-	_BV( 1 )	, // PE 1 ** 1 ** USART0_TX	
-	_BV( 4 )	, // PE 4 ** 2 ** PWM2	
-	_BV( 5 )	, // PE 5 ** 3 ** PWM3	
-	_BV( 5 )	, // PG 5 ** 4 ** PWM4	
-	_BV( 3 )	, // PE 3 ** 5 ** PWM5	
-	_BV( 3 )	, // PH 3 ** 6 ** PWM6	
-	_BV( 4 )	, // PH 4 ** 7 ** PWM7	
-	_BV( 5 )	, // PH 5 ** 8 ** PWM8	
-	_BV( 6 )	, // PH 6 ** 9 ** PWM9	
-	_BV( 4 )	, // PB 4 ** 10 ** PWM10	
-	_BV( 5 )	, // PB 5 ** 11 ** PWM11	
-	_BV( 6 )	, // PB 6 ** 12 ** PWM12	
-	_BV( 7 )	, // PB 7 ** 13 ** PWM13	
-	_BV( 1 )	, // PJ 1 ** 14 ** USART3_TX	
-	_BV( 0 )	, // PJ 0 ** 15 ** USART3_RX	
-	_BV( 1 )	, // PH 1 ** 16 ** USART2_TX	
-	_BV( 0 )	, // PH 0 ** 17 ** USART2_RX	
-	_BV( 3 )	, // PD 3 ** 18 ** USART1_TX	
-	_BV( 2 )	, // PD 2 ** 19 ** USART1_RX	
-	_BV( 1 )	, // PD 1 ** 20 ** I2C_SDA	
-	_BV( 0 )	, // PD 0 ** 21 ** I2C_SCL	
-	_BV( 0 )	, // PA 0 ** 22 ** D22	
-	_BV( 1 )	, // PA 1 ** 23 ** D23	
-	_BV( 2 )	, // PA 2 ** 24 ** D24	
-	_BV( 3 )	, // PA 3 ** 25 ** D25	
-	_BV( 4 )	, // PA 4 ** 26 ** D26	
-	_BV( 5 )	, // PA 5 ** 27 ** D27	
-	_BV( 6 )	, // PA 6 ** 28 ** D28	
-	_BV( 7 )	, // PA 7 ** 29 ** D29	
-	_BV( 7 )	, // PC 7 ** 30 ** D30	
-	_BV( 6 )	, // PC 6 ** 31 ** D31	
-	_BV( 5 )	, // PC 5 ** 32 ** D32	
-	_BV( 4 )	, // PC 4 ** 33 ** D33	
-	_BV( 3 )	, // PC 3 ** 34 ** D34	
-	_BV( 2 )	, // PC 2 ** 35 ** D35	
-	_BV( 1 )	, // PC 1 ** 36 ** D36	
-	_BV( 0 )	, // PC 0 ** 37 ** D37	
-	_BV( 7 )	, // PD 7 ** 38 ** D38	
-	_BV( 2 )	, // PG 2 ** 39 ** D39	
-	_BV( 1 )	, // PG 1 ** 40 ** D40	
-	_BV( 0 )	, // PG 0 ** 41 ** D41	
-	_BV( 7 )	, // PL 7 ** 42 ** D42	
-	_BV( 6 )	, // PL 6 ** 43 ** D43	
-	_BV( 5 )	, // PL 5 ** 44 ** D44	
-	_BV( 4 )	, // PL 4 ** 45 ** D45	
-	_BV( 3 )	, // PL 3 ** 46 ** D46	
-	_BV( 2 )	, // PL 2 ** 47 ** D47	
-	_BV( 1 )	, // PL 1 ** 48 ** D48	
-	_BV( 0 )	, // PL 0 ** 49 ** D49	
-	_BV( 3 )	, // PB 3 ** 50 ** SPI_MISO	
-	_BV( 2 )	, // PB 2 ** 51 ** SPI_MOSI	
-	_BV( 1 )	, // PB 1 ** 52 ** SPI_SCK	
-	_BV( 0 )	, // PB 0 ** 53 ** SPI_SS	
-	_BV( 0 )	, // PF 0 ** 54 ** A0	
-	_BV( 1 )	, // PF 1 ** 55 ** A1	
-	_BV( 2 )	, // PF 2 ** 56 ** A2	
-	_BV( 3 )	, // PF 3 ** 57 ** A3	
-	_BV( 4 )	, // PF 4 ** 58 ** A4	
-	_BV( 5 )	, // PF 5 ** 59 ** A5	
-	_BV( 6 )	, // PF 6 ** 60 ** A6	
-	_BV( 7 )	, // PF 7 ** 61 ** A7	
-	_BV( 0 )	, // PK 0 ** 62 ** A8	
-	_BV( 1 )	, // PK 1 ** 63 ** A9	
-	_BV( 2 )	, // PK 2 ** 64 ** A10	
-	_BV( 3 )	, // PK 3 ** 65 ** A11	
-	_BV( 4 )	, // PK 4 ** 66 ** A12	
-	_BV( 5 )	, // PK 5 ** 67 ** A13	
-	_BV( 6 )	, // PK 6 ** 68 ** A14	
-	_BV( 7 )	, // PK 7 ** 69 ** A15	
-};
-
-const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {
-	// TIMERS		
-	// -------------------------------------------		
-	NOT_ON_TIMER	, // PE 0 ** 0 ** USART0_RX	
-	NOT_ON_TIMER	, // PE 1 ** 1 ** USART0_TX	
-	TIMER3B	, // PE 4 ** 2 ** PWM2	
-	TIMER3C	, // PE 5 ** 3 ** PWM3	
-	TIMER0B	, // PG 5 ** 4 ** PWM4	
-	TIMER3A	, // PE 3 ** 5 ** PWM5	
-	TIMER4A	, // PH 3 ** 6 ** PWM6	
-	TIMER4B	, // PH 4 ** 7 ** PWM7	
-	TIMER4C	, // PH 5 ** 8 ** PWM8	
-	TIMER2B	, // PH 6 ** 9 ** PWM9	
-	TIMER2A	, // PB 4 ** 10 ** PWM10	
-	TIMER1A	, // PB 5 ** 11 ** PWM11	
-	TIMER1B	, // PB 6 ** 12 ** PWM12	
-	TIMER0A	, // PB 7 ** 13 ** PWM13	
-	NOT_ON_TIMER	, // PJ 1 ** 14 ** USART3_TX	
-	NOT_ON_TIMER	, // PJ 0 ** 15 ** USART3_RX	
-	NOT_ON_TIMER	, // PH 1 ** 16 ** USART2_TX	
-	NOT_ON_TIMER	, // PH 0 ** 17 ** USART2_RX	
-	NOT_ON_TIMER	, // PD 3 ** 18 ** USART1_TX	
-	NOT_ON_TIMER	, // PD 2 ** 19 ** USART1_RX	
-	NOT_ON_TIMER	, // PD 1 ** 20 ** I2C_SDA	
-	NOT_ON_TIMER	, // PD 0 ** 21 ** I2C_SCL	
-	NOT_ON_TIMER	, // PA 0 ** 22 ** D22	
-	NOT_ON_TIMER	, // PA 1 ** 23 ** D23	
-	NOT_ON_TIMER	, // PA 2 ** 24 ** D24	
-	NOT_ON_TIMER	, // PA 3 ** 25 ** D25	
-	NOT_ON_TIMER	, // PA 4 ** 26 ** D26	
-	NOT_ON_TIMER	, // PA 5 ** 27 ** D27	
-	NOT_ON_TIMER	, // PA 6 ** 28 ** D28	
-	NOT_ON_TIMER	, // PA 7 ** 29 ** D29	
-	NOT_ON_TIMER	, // PC 7 ** 30 ** D30	
-	NOT_ON_TIMER	, // PC 6 ** 31 ** D31	
-	NOT_ON_TIMER	, // PC 5 ** 32 ** D32	
-	NOT_ON_TIMER	, // PC 4 ** 33 ** D33	
-	NOT_ON_TIMER	, // PC 3 ** 34 ** D34	
-	NOT_ON_TIMER	, // PC 2 ** 35 ** D35	
-	NOT_ON_TIMER	, // PC 1 ** 36 ** D36	
-	NOT_ON_TIMER	, // PC 0 ** 37 ** D37	
-	NOT_ON_TIMER	, // PD 7 ** 38 ** D38	
-	NOT_ON_TIMER	, // PG 2 ** 39 ** D39	
-	NOT_ON_TIMER	, // PG 1 ** 40 ** D40	
-	NOT_ON_TIMER	, // PG 0 ** 41 ** D41	
-	NOT_ON_TIMER	, // PL 7 ** 42 ** D42	
-	NOT_ON_TIMER	, // PL 6 ** 43 ** D43	
-	TIMER5C	, // PL 5 ** 44 ** D44	
-	TIMER5B	, // PL 4 ** 45 ** D45	
-	TIMER5A	, // PL 3 ** 46 ** D46	
-	NOT_ON_TIMER	, // PL 2 ** 47 ** D47	
-	NOT_ON_TIMER	, // PL 1 ** 48 ** D48	
-	NOT_ON_TIMER	, // PL 0 ** 49 ** D49	
-	NOT_ON_TIMER	, // PB 3 ** 50 ** SPI_MISO	
-	NOT_ON_TIMER	, // PB 2 ** 51 ** SPI_MOSI	
-	NOT_ON_TIMER	, // PB 1 ** 52 ** SPI_SCK	
-	NOT_ON_TIMER	, // PB 0 ** 53 ** SPI_SS	
-	NOT_ON_TIMER	, // PF 0 ** 54 ** A0	
-	NOT_ON_TIMER	, // PF 1 ** 55 ** A1	
-	NOT_ON_TIMER	, // PF 2 ** 56 ** A2	
-	NOT_ON_TIMER	, // PF 3 ** 57 ** A3	
-	NOT_ON_TIMER	, // PF 4 ** 58 ** A4	
-	NOT_ON_TIMER	, // PF 5 ** 59 ** A5	
-	NOT_ON_TIMER	, // PF 6 ** 60 ** A6	
-	NOT_ON_TIMER	, // PF 7 ** 61 ** A7	
-	NOT_ON_TIMER	, // PK 0 ** 62 ** A8	
-	NOT_ON_TIMER	, // PK 1 ** 63 ** A9	
-	NOT_ON_TIMER	, // PK 2 ** 64 ** A10	
-	NOT_ON_TIMER	, // PK 3 ** 65 ** A11	
-	NOT_ON_TIMER	, // PK 4 ** 66 ** A12	
-	NOT_ON_TIMER	, // PK 5 ** 67 ** A13	
-	NOT_ON_TIMER	, // PK 6 ** 68 ** A14	
-	NOT_ON_TIMER	, // PK 7 ** 69 ** A15	
-};
-#else
-// these arrays map port names (e.g. port B) to the
-// appropriate addresses for various functions (e.g. reading
-// and writing)
-const uint16_t PROGMEM port_to_mode_PGM[] = {
-	NOT_A_PORT,
-	NOT_A_PORT,
-	&DDRB,
-	&DDRC,
-	&DDRD,
-};
-
-const uint16_t PROGMEM port_to_output_PGM[] = {
-	NOT_A_PORT,
-	NOT_A_PORT,
-	&PORTB,
-	&PORTC,
-	&PORTD,
-};
-
-const uint16_t PROGMEM port_to_input_PGM[] = {
-	NOT_A_PORT,
-	NOT_A_PORT,
-	&PINB,
-	&PINC,
-	&PIND,
-};
-
-const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
-	PD, /* 0 */
-	PD,
-	PD,
-	PD,
-	PD,
-	PD,
-	PD,
-	PD,
-	PB, /* 8 */
-	PB,
-	PB,
-	PB,
-	PB,
-	PB,
-	PC, /* 14 */
-	PC,
-	PC,
-	PC,
-	PC,
-	PC,
-};
-
-const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = {
-	_BV(0), /* 0, port D */
-	_BV(1),
-	_BV(2),
-	_BV(3),
-	_BV(4),
-	_BV(5),
-	_BV(6),
-	_BV(7),
-	_BV(0), /* 8, port B */
-	_BV(1),
-	_BV(2),
-	_BV(3),
-	_BV(4),
-	_BV(5),
-	_BV(0), /* 14, port C */
-	_BV(1),
-	_BV(2),
-	_BV(3),
-	_BV(4),
-	_BV(5),
-};
-
-const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {
-	NOT_ON_TIMER, /* 0 - port D */
-	NOT_ON_TIMER,
-	NOT_ON_TIMER,
-	// on the ATmega168, digital pin 3 has hardware pwm
-#if defined(__AVR_ATmega8__)
-	NOT_ON_TIMER,
-#else
-	TIMER2B,
-#endif
-	NOT_ON_TIMER,
-	// on the ATmega168, digital pins 5 and 6 have hardware pwm
-#if defined(__AVR_ATmega8__)
-	NOT_ON_TIMER,
-	NOT_ON_TIMER,
-#else
-	TIMER0B,
-	TIMER0A,
-#endif
-	NOT_ON_TIMER,
-	NOT_ON_TIMER, /* 8 - port B */
-	TIMER1A,
-	TIMER1B,
-#if defined(__AVR_ATmega8__)
-	TIMER2,
-#else
-	TIMER2A,
-#endif
-	NOT_ON_TIMER,
-	NOT_ON_TIMER,
-	NOT_ON_TIMER,
-	NOT_ON_TIMER, /* 14 - port C */
-	NOT_ON_TIMER,
-	NOT_ON_TIMER,
-	NOT_ON_TIMER,
-	NOT_ON_TIMER,
-};
-#endif

+ 0 - 76
optiboot/cores/arduino/pins_arduino.h

@@ -1,76 +0,0 @@
-/*
-  pins_arduino.h - Pin definition functions for Arduino
-  Part of Arduino - http://www.arduino.cc/
-
-  Copyright (c) 2007 David A. Mellis
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General
-  Public License along with this library; if not, write to the
-  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
-  Boston, MA  02111-1307  USA
-
-  $Id: wiring.h 249 2007-02-03 16:52:51Z mellis $
-*/
-
-#ifndef Pins_Arduino_h
-#define Pins_Arduino_h
-
-#include <avr/pgmspace.h>
-
-#define NOT_A_PIN 0
-#define NOT_A_PORT 0
-
-#define NOT_ON_TIMER 0
-#define TIMER0A 1
-#define TIMER0B 2
-#define TIMER1A 3
-#define TIMER1B 4
-#define TIMER2  5
-#define TIMER2A 6
-#define TIMER2B 7
-
-#define TIMER3A 8
-#define TIMER3B 9
-#define TIMER3C 10
-#define TIMER4A 11
-#define TIMER4B 12
-#define TIMER4C 13
-#define TIMER5A 14
-#define TIMER5B 15
-#define TIMER5C 16
-
-// On the ATmega1280, the addresses of some of the port registers are
-// greater than 255, so we can't store them in uint8_t's.
-extern const uint16_t PROGMEM port_to_mode_PGM[];
-extern const uint16_t PROGMEM port_to_input_PGM[];
-extern const uint16_t PROGMEM port_to_output_PGM[];
-
-extern const uint8_t PROGMEM digital_pin_to_port_PGM[];
-// extern const uint8_t PROGMEM digital_pin_to_bit_PGM[];
-extern const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[];
-extern const uint8_t PROGMEM digital_pin_to_timer_PGM[];
-
-// Get the bit location within the hardware port of the given virtual pin.
-// This comes from the pins_*.c file for the active board configuration.
-// 
-// These perform slightly better as macros compared to inline functions
-//
-#define digitalPinToPort(P) ( pgm_read_byte( digital_pin_to_port_PGM + (P) ) )
-#define digitalPinToBitMask(P) ( pgm_read_byte( digital_pin_to_bit_mask_PGM + (P) ) )
-#define digitalPinToTimer(P) ( pgm_read_byte( digital_pin_to_timer_PGM + (P) ) )
-#define analogInPinToBit(P) (P)
-#define portOutputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_output_PGM + (P))) )
-#define portInputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_input_PGM + (P))) )
-#define portModeRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_mode_PGM + (P))) )
-
-#endif

+ 0 - 238
optiboot/cores/arduino/wiring.c

@@ -1,238 +0,0 @@
-/*
-  wiring.c - Partial implementation of the Wiring API for the ATmega8.
-  Part of Arduino - http://www.arduino.cc/
-
-  Copyright (c) 2005-2006 David A. Mellis
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General
-  Public License along with this library; if not, write to the
-  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
-  Boston, MA  02111-1307  USA
-
-  $Id: wiring.c 808 2009-12-18 17:44:08Z dmellis $
-*/
-
-#include "wiring_private.h"
-
-// the prescaler is set so that timer0 ticks every 64 clock cycles, and the
-// the overflow handler is called every 256 ticks.
-#define MICROSECONDS_PER_TIMER0_OVERFLOW (clockCyclesToMicroseconds(64 * 256))
-
-// the whole number of milliseconds per timer0 overflow
-#define MILLIS_INC (MICROSECONDS_PER_TIMER0_OVERFLOW / 1000)
-
-// the fractional number of milliseconds per timer0 overflow. we shift right
-// by three to fit these numbers into a byte. (for the clock speeds we care
-// about - 8 and 16 MHz - this doesn't lose precision.)
-#define FRACT_INC ((MICROSECONDS_PER_TIMER0_OVERFLOW % 1000) >> 3)
-#define FRACT_MAX (1000 >> 3)
-
-volatile unsigned long timer0_overflow_count = 0;
-volatile unsigned long timer0_millis = 0;
-static unsigned char timer0_fract = 0;
-
-SIGNAL(TIMER0_OVF_vect)
-{
-	// copy these to local variables so they can be stored in registers
-	// (volatile variables must be read from memory on every access)
-	unsigned long m = timer0_millis;
-	unsigned char f = timer0_fract;
-
-	m += MILLIS_INC;
-	f += FRACT_INC;
-	if (f >= FRACT_MAX) {
-		f -= FRACT_MAX;
-		m += 1;
-	}
-
-	timer0_fract = f;
-	timer0_millis = m;
-	timer0_overflow_count++;
-}
-
-unsigned long millis()
-{
-	unsigned long m;
-	uint8_t oldSREG = SREG;
-
-	// disable interrupts while we read timer0_millis or we might get an
-	// inconsistent value (e.g. in the middle of a write to timer0_millis)
-	cli();
-	m = timer0_millis;
-	SREG = oldSREG;
-
-	return m;
-}
-
-unsigned long micros() {
-	unsigned long m;
-	uint8_t oldSREG = SREG, t;
-	
-	cli();
-	m = timer0_overflow_count;
-	t = TCNT0;
-  
-#ifdef TIFR0
-	if ((TIFR0 & _BV(TOV0)) && (t < 255))
-		m++;
-#else
-	if ((TIFR & _BV(TOV0)) && (t < 255))
-		m++;
-#endif
-
-	SREG = oldSREG;
-	
-	return ((m << 8) + t) * (64 / clockCyclesPerMicrosecond());
-}
-
-void delay(unsigned long ms)
-{
-	unsigned long start = millis();
-	
-	while (millis() - start <= ms)
-		;
-}
-
-/* Delay for the given number of microseconds.  Assumes a 8 or 16 MHz clock. */
-void delayMicroseconds(unsigned int us)
-{
-	// calling avrlib's delay_us() function with low values (e.g. 1 or
-	// 2 microseconds) gives delays longer than desired.
-	//delay_us(us);
-
-#if F_CPU >= 16000000L
-	// for the 16 MHz clock on most Arduino boards
-
-	// for a one-microsecond delay, simply return.  the overhead
-	// of the function call yields a delay of approximately 1 1/8 us.
-	if (--us == 0)
-		return;
-
-	// the following loop takes a quarter of a microsecond (4 cycles)
-	// per iteration, so execute it four times for each microsecond of
-	// delay requested.
-	us <<= 2;
-
-	// account for the time taken in the preceeding commands.
-	us -= 2;
-#else
-	// for the 8 MHz internal clock on the ATmega168
-
-	// for a one- or two-microsecond delay, simply return.  the overhead of
-	// the function calls takes more than two microseconds.  can't just
-	// subtract two, since us is unsigned; we'd overflow.
-	if (--us == 0)
-		return;
-	if (--us == 0)
-		return;
-
-	// the following loop takes half of a microsecond (4 cycles)
-	// per iteration, so execute it twice for each microsecond of
-	// delay requested.
-	us <<= 1;
-    
-	// partially compensate for the time taken by the preceeding commands.
-	// we can't subtract any more than this or we'd overflow w/ small delays.
-	us--;
-#endif
-
-	// busy wait
-	__asm__ __volatile__ (
-		"1: sbiw %0,1" "\n\t" // 2 cycles
-		"brne 1b" : "=w" (us) : "0" (us) // 2 cycles
-	);
-}
-
-void init()
-{
-	// this needs to be called before setup() or some functions won't
-	// work there
-	sei();
-	
-	// on the ATmega168, timer 0 is also used for fast hardware pwm
-	// (using phase-correct PWM would mean that timer 0 overflowed half as often
-	// resulting in different millis() behavior on the ATmega8 and ATmega168)
-#if !defined(__AVR_ATmega8__)
-	sbi(TCCR0A, WGM01);
-	sbi(TCCR0A, WGM00);
-#endif  
-	// set timer 0 prescale factor to 64
-#if defined(__AVR_ATmega8__)
-	sbi(TCCR0, CS01);
-	sbi(TCCR0, CS00);
-#else
-	sbi(TCCR0B, CS01);
-	sbi(TCCR0B, CS00);
-#endif
-	// enable timer 0 overflow interrupt
-#if defined(__AVR_ATmega8__)
-	sbi(TIMSK, TOIE0);
-#else
-	sbi(TIMSK0, TOIE0);
-#endif
-
-	// timers 1 and 2 are used for phase-correct hardware pwm
-	// this is better for motors as it ensures an even waveform
-	// note, however, that fast pwm mode can achieve a frequency of up
-	// 8 MHz (with a 16 MHz clock) at 50% duty cycle
-
-	// set timer 1 prescale factor to 64
-	sbi(TCCR1B, CS11);
-	sbi(TCCR1B, CS10);
-	// put timer 1 in 8-bit phase correct pwm mode
-	sbi(TCCR1A, WGM10);
-
-	// set timer 2 prescale factor to 64
-#if defined(__AVR_ATmega8__)
-	sbi(TCCR2, CS22);
-#else
-	sbi(TCCR2B, CS22);
-#endif
-	// configure timer 2 for phase correct pwm (8-bit)
-#if defined(__AVR_ATmega8__)
-	sbi(TCCR2, WGM20);
-#else
-	sbi(TCCR2A, WGM20);
-#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);
-#endif
-
-	// set a2d prescale factor to 128
-	// 16 MHz / 128 = 125 KHz, inside the desired 50-200 KHz range.
-	// XXX: this will not work properly for other clock speeds, and
-	// this code should use F_CPU to determine the prescale factor.
-	sbi(ADCSRA, ADPS2);
-	sbi(ADCSRA, ADPS1);
-	sbi(ADCSRA, ADPS0);
-
-	// enable a2d conversions
-	sbi(ADCSRA, ADEN);
-
-	// 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__)
-	UCSRB = 0;
-#else
-	UCSR0B = 0;
-#endif
-}

+ 0 - 133
optiboot/cores/arduino/wiring.h

@@ -1,133 +0,0 @@
-/*
-  wiring.h - Partial implementation of the Wiring API for the ATmega8.
-  Part of Arduino - http://www.arduino.cc/
-
-  Copyright (c) 2005-2006 David A. Mellis
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General
-  Public License along with this library; if not, write to the
-  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
-  Boston, MA  02111-1307  USA
-
-  $Id: wiring.h 804 2009-12-18 16:05:52Z dmellis $
-*/
-
-#ifndef Wiring_h
-#define Wiring_h
-
-#include <avr/io.h>
-#include "binary.h"
-
-#ifdef __cplusplus
-extern "C"{
-#endif
-
-#define HIGH 0x1
-#define LOW  0x0
-
-#define INPUT 0x0
-#define OUTPUT 0x1
-
-#define true 0x1
-#define false 0x0
-
-#define PI 3.1415926535897932384626433832795
-#define HALF_PI 1.5707963267948966192313216916398
-#define TWO_PI 6.283185307179586476925286766559
-#define DEG_TO_RAD 0.017453292519943295769236907684886
-#define RAD_TO_DEG 57.295779513082320876798154814105
-
-#define SERIAL  0x0
-#define DISPLAY 0x1
-
-#define LSBFIRST 0
-#define MSBFIRST 1
-
-#define CHANGE 1
-#define FALLING 2
-#define RISING 3
-
-#define INTERNAL 3
-#define DEFAULT 1
-#define EXTERNAL 0
-
-// undefine stdlib's abs if encountered
-#ifdef abs
-#undef abs
-#endif
-
-#define min(a,b) ((a)<(b)?(a):(b))
-#define max(a,b) ((a)>(b)?(a):(b))
-#define abs(x) ((x)>0?(x):-(x))
-#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
-#define round(x)     ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
-#define radians(deg) ((deg)*DEG_TO_RAD)
-#define degrees(rad) ((rad)*RAD_TO_DEG)
-#define sq(x) ((x)*(x))
-
-#define interrupts() sei()
-#define noInterrupts() cli()
-
-#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L )
-#define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() )
-#define microsecondsToClockCycles(a) ( (a) * clockCyclesPerMicrosecond() )
-
-#define lowByte(w) ((uint8_t) ((w) & 0xff))
-#define highByte(w) ((uint8_t) ((w) >> 8))
-
-#define bitRead(value, bit) (((value) >> (bit)) & 0x01)
-#define bitSet(value, bit) ((value) |= (1UL << (bit)))
-#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
-#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))
-
-typedef unsigned int word;
-
-#define bit(b) (1UL << (b))
-
-typedef uint8_t boolean;
-typedef uint8_t byte;
-
-void init(void);
-
-void pinMode(uint8_t, uint8_t);
-void digitalWrite(uint8_t, uint8_t);
-int digitalRead(uint8_t);
-int analogRead(uint8_t);
-void analogReference(uint8_t mode);
-void analogWrite(uint8_t, int);
-
-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 attachInterrupt(uint8_t, void (*)(void), int mode);
-void detachInterrupt(uint8_t);
-
-void setup(void);
-void loop(void);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif

+ 0 - 179
optiboot/cores/arduino/wiring_analog.c

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

+ 0 - 111
optiboot/cores/arduino/wiring_digital.c

@@ -1,111 +0,0 @@
-/*
-  wiring_digital.c - digital input and output functions
-  Part of Arduino - http://www.arduino.cc/
-
-  Copyright (c) 2005-2006 David A. Mellis
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General
-  Public License along with this library; if not, write to the
-  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
-  Boston, MA  02111-1307  USA
-
-  $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $
-*/
-
-#include "wiring_private.h"
-#include "pins_arduino.h"
-
-void pinMode(uint8_t pin, uint8_t mode)
-{
-	uint8_t bit = digitalPinToBitMask(pin);
-	uint8_t port = digitalPinToPort(pin);
-	volatile uint8_t *reg;
-
-	if (port == NOT_A_PIN) return;
-
-	// JWS: can I let the optimizer do this?
-	reg = portModeRegister(port);
-
-	if (mode == INPUT) *reg &= ~bit;
-	else *reg |= bit;
-}
-
-// Forcing this inline keeps the callers from having to push their own stuff
-// on the stack. It is a good performance win and only takes 1 more byte per
-// user than calling. (It will take more bytes on the 168.)
-//
-// But shouldn't this be moved into pinMode? Seems silly to check and do on
-// each digitalread or write.
-//
-static inline void turnOffPWM(uint8_t timer) __attribute__ ((always_inline));
-static inline 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
-}
-
-void digitalWrite(uint8_t pin, uint8_t val)
-{
-	uint8_t timer = digitalPinToTimer(pin);
-	uint8_t bit = digitalPinToBitMask(pin);
-	uint8_t port = digitalPinToPort(pin);
-	volatile uint8_t *out;
-
-	if (port == NOT_A_PIN) return;
-
-	// If the pin that support PWM output, we need to turn it off
-	// before doing a digital write.
-	if (timer != NOT_ON_TIMER) turnOffPWM(timer);
-
-	out = portOutputRegister(port);
-
-	if (val == LOW) *out &= ~bit;
-	else *out |= bit;
-}
-
-int digitalRead(uint8_t pin)
-{
-	uint8_t timer = digitalPinToTimer(pin);
-	uint8_t bit = digitalPinToBitMask(pin);
-	uint8_t port = digitalPinToPort(pin);
-
-	if (port == NOT_A_PIN) return LOW;
-
-	// If the pin that support PWM output, we need to turn it off
-	// before getting a digital reading.
-	if (timer != NOT_ON_TIMER) turnOffPWM(timer);
-
-	if (*portInputRegister(port) & bit) return HIGH;
-	return LOW;
-}

+ 0 - 68
optiboot/cores/arduino/wiring_private.h

@@ -1,68 +0,0 @@
-/*
-  wiring_private.h - Internal header file.
-  Part of Arduino - http://www.arduino.cc/
-
-  Copyright (c) 2005-2006 David A. Mellis
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General
-  Public License along with this library; if not, write to the
-  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
-  Boston, MA  02111-1307  USA
-
-  $Id: wiring.h 239 2007-01-12 17:58:39Z mellis $
-*/
-
-#ifndef WiringPrivate_h
-#define WiringPrivate_h
-
-#include <avr/io.h>
-#include <avr/interrupt.h>
-#include <avr/delay.h>
-#include <stdio.h>
-#include <stdarg.h>
-
-#include "wiring.h"
-
-#ifdef __cplusplus
-extern "C"{
-#endif
-
-#ifndef cbi
-#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
-#endif
-#ifndef sbi
-#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
-#endif
-
-#define EXTERNAL_INT_0 0
-#define EXTERNAL_INT_1 1
-#define EXTERNAL_INT_2 2
-#define EXTERNAL_INT_3 3
-#define EXTERNAL_INT_4 4
-#define EXTERNAL_INT_5 5
-#define EXTERNAL_INT_6 6
-#define EXTERNAL_INT_7 7
-
-#if defined(__AVR_ATmega1280__)
-#define EXTERNAL_NUM_INTERRUPTS 8
-#else
-#define EXTERNAL_NUM_INTERRUPTS 2
-#endif
-
-typedef void (*voidFuncPtr)(void);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif

+ 0 - 66
optiboot/cores/arduino/wiring_pulse.c

@@ -1,66 +0,0 @@
-/*
-  wiring_pulse.c - pulseIn() function
-  Part of Arduino - http://www.arduino.cc/
-
-  Copyright (c) 2005-2006 David A. Mellis
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General
-  Public License along with this library; if not, write to the
-  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
-  Boston, MA  02111-1307  USA
-
-  $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $
-*/
-
-#include "wiring_private.h"
-#include "pins_arduino.h"
-
-/* Measures the length (in microseconds) of a pulse on the pin; state is HIGH
- * or LOW, the type of pulse to measure.  Works on pulses from 2-3 microseconds
- * to 3 minutes in length, but must be called at least a few dozen microseconds
- * before the start of the pulse. */
-unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout)
-{
-	// cache the port and bit of the pin in order to speed up the
-	// pulse width measuring loop and achieve finer resolution.  calling
-	// digitalRead() instead yields much coarser resolution.
-	uint8_t bit = digitalPinToBitMask(pin);
-	uint8_t port = digitalPinToPort(pin);
-	uint8_t stateMask = (state ? bit : 0);
-	unsigned long width = 0; // keep initialization out of time critical area
-	
-	// convert the timeout from microseconds to a number of times through
-	// the initial loop; it takes 16 clock cycles per iteration.
-	unsigned long numloops = 0;
-	unsigned long maxloops = microsecondsToClockCycles(timeout) / 16;
-	
-	// wait for any previous pulse to end
-	while ((*portInputRegister(port) & bit) == stateMask)
-		if (numloops++ == maxloops)
-			return 0;
-	
-	// wait for the pulse to start
-	while ((*portInputRegister(port) & bit) != stateMask)
-		if (numloops++ == maxloops)
-			return 0;
-	
-	// wait for the pulse to stop
-	while ((*portInputRegister(port) & bit) == stateMask)
-		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
-	// and the start of the loop. There will be some error introduced by
-	// the interrupt handlers.
-	return clockCyclesToMicroseconds(width * 10 + 16); 
-}

+ 0 - 40
optiboot/cores/arduino/wiring_shift.c

@@ -1,40 +0,0 @@
-/*
-  wiring_shift.c - shiftOut() function
-  Part of Arduino - http://www.arduino.cc/
-
-  Copyright (c) 2005-2006 David A. Mellis
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General
-  Public License along with this library; if not, write to the
-  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
-  Boston, MA  02111-1307  USA
-
-  $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $
-*/
-
-#include "wiring_private.h"
-
-void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, byte val)
-{
-	int i;
-
-	for (i = 0; i < 8; i++)  {
-		if (bitOrder == LSBFIRST)
-			digitalWrite(dataPin, !!(val & (1 << i)));
-		else	
-			digitalWrite(dataPin, !!(val & (1 << (7 - i))));
-			
-		digitalWrite(clockPin, HIGH);
-		digitalWrite(clockPin, LOW);		
-	}
-}

+ 0 - 149
optiboot/cores/luminet/COM.c

@@ -1,149 +0,0 @@
-#include "COM.h"
-
-//void (*startBootloader)( void ) = (void *)BOOTADR;  // pointer to the bootloader start address
-
-void COM_init(void)
-{
-	uint8_t sreg = SREG;
-	cli();
-	COM_initASM();
-	SREG = sreg;
-}
-
-void LEFT_putc(uint8_t c)
-{
-	uint8_t sreg = SREG;
-	cli();
-	LEFT_putcASM(c);
-	SREG = sreg;
-}
-
-uint8_t LEFT_getc(void)
-{
-	uint8_t ret;
-	uint8_t sreg = SREG;
-	cli();
-	ret = LEFT_getcASM();
-	SREG = sreg;
-	return ret;
-}
-
-void RIGHT_putc(uint8_t c)
-{
-	uint8_t sreg = SREG;
-	cli();
-	RIGHT_putcASM(c);
-	SREG = sreg;
-}
-
-uint8_t RIGHT_getc(void)
-{
-	uint8_t ret;
-	uint8_t sreg = SREG;
-	cli();
-	ret = RIGHT_getcASM();
-	SREG = sreg;
-	return ret;
-}
-
-void UP_putc(uint8_t c)
-{
-	uint8_t sreg = SREG;
-	cli();
-	UP_putcASM(c);
-	SREG = sreg;
-}
-
-uint8_t UP_getc(void)
-{
-	uint8_t ret;
-	uint8_t sreg = SREG;
-	cli();
-	ret = UP_getcASM();
-	SREG = sreg;
-	return ret;
-}
-
-void DOWN_putc(uint8_t c)
-{
-	uint8_t sreg = SREG;
-	cli();
-	DOWN_putcASM(c);
-	SREG = sreg;
-}
-
-uint8_t DOWN_getc(void)
-{
-	uint8_t ret;
-	uint8_t sreg = SREG;
-	cli();
-	ret = DOWN_getcASM();
-	SREG = sreg;
-	return ret;
-}
-
-//destination: WEST, EAST, NORTH, SOUTH
-//c: char to be send
-void COM_putc(uint8_t destination, uint8_t c)
-{
-	void (*ptr) (uint8_t data);
-	
-	if(destination == WEST)
-	{
-		ptr = LEFT_putc;
-	}
-	else if(destination == EAST)
-	{
-		ptr = RIGHT_putc;
-	}
-	else if(destination == NORTH)
-	{
-		ptr = UP_putc;
-	}
-	else if(destination == SOUTH)
-	{
-		ptr = DOWN_putc;
-	}
-	
-	ptr(c);
-}
-
-//source: WEST, EAST, NORTH, SOUTH
-uint8_t COM_getc(uint8_t source)
-{
-	uint8_t c;
-	uint8_t d;
-	
-	uint8_t (*ptr) (void);
-	
-	if(source == WEST)
-	{
-		ptr = LEFT_getc;
-	}
-	else if(source == EAST)
-	{
-		ptr = RIGHT_getc;
-	}
-	else if(source == NORTH)
-	{
-		ptr = UP_getc;
-	}
-	else if(source == SOUTH)
-	{
-		ptr = DOWN_getc;
-	}
-	
-	c = ptr();
-	if(c == 0xF0)
-	{
-		d = ptr();
-		return d;
-	}
-	else if(c == 0xA0)
-	{
-		//startBootloader();
-	}
-	
-	return 0x00;
-}
-

+ 0 - 70
optiboot/cores/luminet/COM.h

@@ -1,70 +0,0 @@
-#ifndef _COM_H_
-#define _COM_H_
-
-#include "WProgram.h"
-
-#ifdef __cplusplus
-extern "C"{
-#endif
-
-
-#include <util/delay_basic.h>
-
-
-
-#define WEST 0
-#define EAST 1
-#define NORTH 2
-#define SOUTH 3
-
-#ifndef BOOTADR
-#define BOOTADR 0x1A00
-#endif
-
-
-void COM_init(void);
-
-//destination: WEST, EAST, NORTH, SOUTH
-//c: char to be send
-void COM_putc(uint8_t destination, uint8_t c);
-
-//source: WEST, EAST, NORTH, SOUTH
-uint8_t COM_getc(uint8_t source);
-
-void LEFT_putc(uint8_t c);//DO NOT USE!
-uint8_t LEFT_getc(void);//DO NOT USE!
-
-void RIGHT_putc(uint8_t c);//DO NOT USE!
-uint8_t RIGHT_getc(void);//DO NOT USE!
-
-void UP_putc(uint8_t c);//DO NOT USE!
-uint8_t UP_getc(void);//DO NOT USE!
-
-void DOWN_putc(uint8_t c);//DO NOT USE!
-uint8_t DOWN_getc(void);//DO NOT USE!
-
-
-//DO NOT USE THESE FUNCTIONS:
-//use them only in the bootloader code
-
-
-extern void COM_initASM(void);
-
-extern void LEFT_putcASM(uint8_t c);//DO NOT USE!
-extern uint8_t LEFT_getcASM(void);//DO NOT USE!
-
-extern void RIGHT_putcASM(uint8_t c);//DO NOT USE!
-extern uint8_t RIGHT_getcASM(void);//DO NOT USE!
-
-extern void UP_putcASM(uint8_t c);//DO NOT USE!
-extern uint8_t UP_getcASM(void);//DO NOT USE!
-
-extern void DOWN_putcASM(uint8_t c);//DO NOT USE!
-extern uint8_t DOWN_getcASM(void);//DO NOT USE!
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-
-#endif /* _COM_H_ */

+ 0 - 361
optiboot/cores/luminet/COMasm.S

@@ -1,361 +0,0 @@
-#include <avr/io.h>
-
-#define	LEFT_TXDDR DDRA
-#define	LEFT_TXPORT PORTA
-#define LEFT_TXPINNumber  PA2			
-		
-#define	LEFT_RXDDR  DDRA
-#define	LEFT_RXPORT PORTA
-#define	LEFT_RXPIN  PINA
-#define	LEFT_RXPINNumber PA3			
-
-#define	RIGHT_TXDDR DDRB
-#define	RIGHT_TXPORT PORTB
-#define RIGHT_TXPINNumber  PB1			
-		
-#define	RIGHT_RXDDR  DDRB
-#define	RIGHT_RXPORT PORTB
-#define	RIGHT_RXPIN  PINB
-#define	RIGHT_RXPINNumber PB0			
-	
-
-#define	UP_TXDDR DDRB
-#define	UP_TXPORT PORTB
-#define UP_TXPINNumber  PB2			
-		
-#define	UP_RXDDR  DDRA
-#define	UP_RXPORT PORTA
-#define	UP_RXPIN  PINA
-#define	UP_RXPINNumber PA7
-
-#define	DOWN_TXDDR DDRA
-#define	DOWN_TXPORT PORTA
-#define DOWN_TXPINNumber  PA1			
-		
-#define	DOWN_RXDDR  DDRA
-#define	DOWN_RXPORT PORTA
-#define	DOWN_RXPIN  PINA
-#define	DOWN_RXPINNumber PA0			
-
-;***** Global register variables
-
-;bit counter
-#define	bitcnt r16
-
-;temporary storage register
-#define	temp r17
-
-
-
-;***************************************************************************
-;*
-;* uart_initASM
-;*
-.global COM_initASM
-.func COM_initASM
-COM_initASM:		
-	sbi _SFR_IO_ADDR(LEFT_TXDDR),LEFT_TXPINNumber
-	sbi _SFR_IO_ADDR(LEFT_TXPORT),LEFT_TXPINNumber
-	cbi _SFR_IO_ADDR(LEFT_RXDDR),LEFT_RXPINNumber
-	
-	sbi _SFR_IO_ADDR(RIGHT_TXDDR),RIGHT_TXPINNumber
-	sbi _SFR_IO_ADDR(RIGHT_TXPORT),RIGHT_TXPINNumber
-	cbi _SFR_IO_ADDR(RIGHT_RXDDR),RIGHT_RXPINNumber
-	
-	sbi _SFR_IO_ADDR(UP_TXDDR),UP_TXPINNumber
-	sbi _SFR_IO_ADDR(UP_TXPORT),UP_TXPINNumber
-	cbi _SFR_IO_ADDR(UP_RXDDR),UP_RXPINNumber
-	
-	sbi _SFR_IO_ADDR(DOWN_TXDDR),DOWN_TXPINNumber
-	sbi _SFR_IO_ADDR(DOWN_TXPORT),DOWN_TXPINNumber
-	cbi _SFR_IO_ADDR(DOWN_RXDDR),DOWN_RXPINNumber
-	
-	ret		
-.endfunc
-
-
-;***************************************************************************
-;*
-;* LEFT_putcASM
-;*
-.global LEFT_putcASM
-.func LEFT_putcASM
-LEFT_putcASM:	
-	ldi	bitcnt,10	;put 10 bits (start+stop+payload
-	com	r24		;Inverte everything
-	sec			;Start bit
-
-LEFT_putchar0:	
-	brcc	LEFT_putchar1	;If carry set
-	cbi	_SFR_IO_ADDR(LEFT_TXPORT),LEFT_TXPINNumber	;    send a '0'
-	rjmp	LEFT_putchar2	;else	
-
-LEFT_putchar1:	
-	sbi	_SFR_IO_ADDR(LEFT_TXPORT),LEFT_TXPINNumber	;    send a '1'
-	nop
-
-LEFT_putchar2:	
-	rcall UART_delay	;One bit delay
-	rcall UART_delay
-	lsr	r24		;Get next bit
-	dec	bitcnt		;If not all bit sent
-	brne	LEFT_putchar0	;   send next
-				;else
-	ret			;   return
-.endfunc
-
-;***************************************************************************
-;*
-;* LEFT_getcASM
-.global LEFT_getcASM
-.func LEFT_getcASM
-LEFT_getcASM:	
-	ldi 	bitcnt,9	;8 data bit + 1 stop bit
-
-LEFT_getchar1:	
-	sbic 	_SFR_IO_ADDR(LEFT_RXPIN),LEFT_RXPINNumber	;Wait for start bit
-	rjmp 	LEFT_getchar1
-	rcall UART_delay	;0.5 bit delay
-
-LEFT_getchar2:	
-	rcall UART_delay	;1 bit delay
-	rcall UART_delay		
-	clc			;clear carry
-	sbic 	_SFR_IO_ADDR(LEFT_RXPIN),LEFT_RXPINNumber	;if RX pin high
-	sec			;
-	dec 	bitcnt		;If bit is stop bit
-	breq 	LEFT_getchar3	;   return
-				;else
-	ror 	r24		;   shift bit into Rxbyte
-	rjmp 	LEFT_getchar2	;   go get next
-
-LEFT_getchar3:	
-	ret
-.endfunc
-
-
-
-
-
-;***************************************************************************
-;*
-;* RIGHT_putcASM
-;*
-.global RIGHT_putcASM
-.func RIGHT_putcASM
-RIGHT_putcASM:	
-	ldi	bitcnt,10	;put 10 bits (start+stop+payload
-	com	r24		;Inverte everything
-	sec			;Start bit
-
-RIGHT_putchar0:	
-	brcc	RIGHT_putchar1	;If carry set
-	cbi	_SFR_IO_ADDR(RIGHT_TXPORT),RIGHT_TXPINNumber	;    send a '0'
-	rjmp	RIGHT_putchar2	;else	
-
-RIGHT_putchar1:	
-	sbi	_SFR_IO_ADDR(RIGHT_TXPORT),RIGHT_TXPINNumber	;    send a '1'
-	nop
-
-RIGHT_putchar2:	
-	rcall UART_delay	;One bit delay
-	rcall UART_delay
-	lsr	r24		;Get next bit
-	dec	bitcnt		;If not all bit sent
-	brne	RIGHT_putchar0	;   send next
-				;else
-	ret			;   return
-.endfunc
-
-;***************************************************************************
-;*
-;* RIGHT_getcASM
-.global RIGHT_getcASM
-.func RIGHT_getcASM
-RIGHT_getcASM:	
-	ldi 	bitcnt,9	;8 data bit + 1 stop bit
-
-RIGHT_getchar1:	
-	sbic 	_SFR_IO_ADDR(RIGHT_RXPIN),RIGHT_RXPINNumber	;Wait for start bit
-	rjmp 	RIGHT_getchar1
-	rcall UART_delay	;0.5 bit delay
-
-RIGHT_getchar2:	
-	rcall UART_delay	;1 bit delay
-	rcall UART_delay		
-	clc			;clear carry
-	sbic 	_SFR_IO_ADDR(RIGHT_RXPIN),RIGHT_RXPINNumber	;if RX pin high
-	sec			;
-	dec 	bitcnt		;If bit is stop bit
-	breq 	RIGHT_getchar3	;   return
-				;else
-	ror 	r24		;   shift bit into Rxbyte
-	rjmp 	RIGHT_getchar2	;   go get next
-
-RIGHT_getchar3:	
-	ret
-.endfunc
-
-
-
-
-
-;***************************************************************************
-;*
-;* UP_putcASM
-;*
-.global UP_putcASM
-.func UP_putcASM
-UP_putcASM:	
-	ldi	bitcnt,10	;put 10 bits (start+stop+payload
-	com	r24		;Inverte everything
-	sec			;Start bit
-
-UP_putchar0:	
-	brcc	UP_putchar1	;If carry set
-	cbi	_SFR_IO_ADDR(UP_TXPORT),UP_TXPINNumber	;    send a '0'
-	rjmp	UP_putchar2	;else	
-
-UP_putchar1:	
-	sbi	_SFR_IO_ADDR(UP_TXPORT),UP_TXPINNumber	;    send a '1'
-	nop
-
-UP_putchar2:	
-	rcall UART_delay	;One bit delay
-	rcall UART_delay
-	lsr	r24		;Get next bit
-	dec	bitcnt		;If not all bit sent
-	brne	UP_putchar0	;   send next
-				;else
-	ret			;   return
-.endfunc
-
-;***************************************************************************
-;*
-;* UP_getcASM
-.global UP_getcASM
-.func UP_getcASM
-UP_getcASM:	
-	ldi 	bitcnt,9	;8 data bit + 1 stop bit
-
-UP_getchar1:	
-	sbic 	_SFR_IO_ADDR(UP_RXPIN),UP_RXPINNumber	;Wait for start bit
-	rjmp 	UP_getchar1
-	rcall UART_delay	;0.5 bit delay
-
-UP_getchar2:	
-	rcall UART_delay	;1 bit delay
-	rcall UART_delay		
-	clc			;clear carry
-	sbic 	_SFR_IO_ADDR(UP_RXPIN),UP_RXPINNumber	;if RX pin high
-	sec			;
-	dec 	bitcnt		;If bit is stop bit
-	breq 	UP_getchar3	;   return
-				;else
-	ror 	r24		;   shift bit into Rxbyte
-	rjmp 	UP_getchar2	;   go get next
-
-UP_getchar3:	
-	ret
-.endfunc
-
-
-
-;***************************************************************************
-;*
-;* DOWN_putcASM
-;*
-.global DOWN_putcASM
-.func DOWN_putcASM
-DOWN_putcASM:	
-	ldi	bitcnt,10	;put 10 bits (start+stop+payload
-	com	r24		;Inverte everything
-	sec			;Start bit
-
-DOWN_putchar0:	
-	brcc	DOWN_putchar1	;If carry set
-	cbi	_SFR_IO_ADDR(DOWN_TXPORT),DOWN_TXPINNumber	;    send a '0'
-	rjmp	DOWN_putchar2	;else	
-
-DOWN_putchar1:	
-	sbi	_SFR_IO_ADDR(DOWN_TXPORT),DOWN_TXPINNumber	;    send a '1'
-	nop
-
-DOWN_putchar2:	
-	rcall UART_delay	;One bit delay
-	rcall UART_delay
-	lsr	r24		;Get next bit
-	dec	bitcnt		;If not all bit sent
-	brne	DOWN_putchar0	;   send next
-				;else
-	ret			;   return
-.endfunc
-
-;***************************************************************************
-;*
-;* DOWN_getc
-.global DOWN_getcASM
-.func DOWN_getcASM
-DOWN_getcASM:	
-	ldi 	bitcnt,9	;8 data bit + 1 stop bit
-
-DOWN_getchar1:	
-	sbic 	_SFR_IO_ADDR(DOWN_RXPIN),DOWN_RXPINNumber	;Wait for start bit
-	rjmp 	DOWN_getchar1
-	rcall UART_delay	;0.5 bit delay
-
-DOWN_getchar2:	
-	rcall UART_delay	;1 bit delay
-	rcall UART_delay		
-	clc			;clear carry
-	sbic 	_SFR_IO_ADDR(DOWN_RXPIN),DOWN_RXPINNumber	;if RX pin high
-	sec			;
-	dec 	bitcnt		;If bit is stop bit
-	breq 	DOWN_getchar3	;   return
-				;else
-	ror 	r24		;   shift bit into Rxbyte
-	rjmp 	DOWN_getchar2	;   go get next
-
-DOWN_getchar3:	
-	ret
-.endfunc
-
-
-;***************************************************************************
-;*
-;* "UART_delay"
-;***************************************************************************
-; Some b values: 	(See also table in Appnote documentation)
-;
-; 1 MHz crystal:
-;   9600 bps - b=14
-;  19200 bps - b=5
-;  28800 bps - b=2
-;
-; 2 MHz crystal:
-;  19200 bps - b=14
-;  28800 bps - b=8
-;  57600 bps - b=2
-
-; 4 MHz crystal:
-;  19200 bps - b=31
-;  28800 bps - b=19
-;  57600 bps - b=8
-; 115200 bps - b=2
-
-;.equ	b	=31	;19200 bps @ 4 MHz crystal
-b	=14	;9600 bps @ 1 MHz crystal
-;b	=8	;115000 bps @ 8 MHz crystal
-	
-
-
-UART_delay:	
-	ldi	temp,b
-UART_delay1:	
-	dec	temp
-	brne	UART_delay1
-	ret
-
-
-
-

+ 0 - 62
optiboot/cores/luminet/HardwareSerial.cpp

@@ -1,62 +0,0 @@
-/*
-  HarwareSerial.cpp - Hardware serial library for Wiring
-  Copyright (c) 2006 Nicholas Zambetti.  All right reserved.
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public
-  License along with this library; if not, write to the Free Software
-  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-  
-  Modified 23 November 2006 by David A. Mellis
-*/
-
-#include <stdio.h>
-#include <string.h>
-#include <inttypes.h>
-#include "wiring.h"
-
-#include "HardwareSerial.h"
-
-// Public Methods //////////////////////////////////////////////////////////////
-
-void HardwareSerial::begin(long speed)
-{
-  beginSerial(speed);
-}
-
-uint8_t HardwareSerial::available(void)
-{
-  return serialAvailable();
-}
-
-int HardwareSerial::read(void)
-{
-  return serialRead();
-}
-
-void HardwareSerial::flush()
-{
-  serialFlush();
-}
-
-void HardwareSerial::write(uint8_t b) {
-  serialWrite(b);
-}
-
-void HardwareSerial::selectDirection(uint8_t b) {
-  selectDirectionSerial(b);
-}
-
-// Preinstantiate Objects //////////////////////////////////////////////////////
-
-HardwareSerial Serial = HardwareSerial();
-

+ 0 - 41
optiboot/cores/luminet/HardwareSerial.h

@@ -1,41 +0,0 @@
-/*
-  HardwareSerial.h - Hardware serial library for Wiring
-  Copyright (c) 2006 Nicholas Zambetti.  All right reserved.
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public
-  License along with this library; if not, write to the Free Software
-  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-*/
-
-#ifndef HardwareSerial_h
-#define HardwareSerial_h
-
-#include <inttypes.h>
-
-#include "Print.h"
-
-class HardwareSerial : public Print
-{
-  public:
-    void begin(long);
-    uint8_t available(void);
-    int read(void);
-    void flush(void);
-    virtual void write(uint8_t);
-    void selectDirection(uint8_t);
-};
-
-extern HardwareSerial Serial;
-
-#endif
-

+ 0 - 14
optiboot/cores/luminet/LEDExtensions.c

@@ -1,14 +0,0 @@
-#include "LEDExtensions.h"
-
-
-void setRGB(uint8_t r, uint8_t g, uint8_t b)
-{
-	bynase_registerPin(8, BYNASE_OUTPUT);
-	bynase_registerPin(9, BYNASE_OUTPUT);
-	bynase_registerPin(10, BYNASE_OUTPUT);
-
-	bynase_write(8, r);
-	bynase_write(9, g);
-	bynase_write(10, b);	
-	
-}

+ 0 - 17
optiboot/cores/luminet/LEDExtensions.h

@@ -1,17 +0,0 @@
-#ifndef _LEDEXTENSIONS_H
-#define _LEDEXTENSIONS_H
-
-#include "WProgram.h"
-
-#ifdef __cplusplus
-extern "C"{
-#endif
-
-void setRGB(uint8_t r, uint8_t g, uint8_t b);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-
-#endif

+ 0 - 253
optiboot/cores/luminet/Makefile

@@ -1,253 +0,0 @@
-# Arduino 0011 Makefile
-# Arduino adaptation by mellis, eighthave, oli.keller
-#
-# This makefile allows you to build sketches from the command line
-# without the Arduino environment (or Java).
-#
-# Detailed instructions for using the makefile:
-#
-#  1. Copy this file into the folder with your sketch. There should be a
-#     file with the same name as the folder and with the extension .pde
-#     (e.g. foo.pde in the foo/ folder).
-#
-#  2. Modify the line containg "INSTALL_DIR" to point to the directory that
-#     contains the Arduino installation (for example, under Mac OS X, this
-#     might be /Applications/arduino-0012).
-#
-#  3. Modify the line containing "PORT" to refer to the filename
-#     representing the USB or serial connection to your Arduino board
-#     (e.g. PORT = /dev/tty.USB0).  If the exact name of this file
-#     changes, you can use * as a wildcard (e.g. PORT = /dev/tty.usb*).
-#
-#  4. Set the line containing "MCU" to match your board's processor. 
-#     Older one's are atmega8 based, newer ones like Arduino Mini, Bluetooth
-#     or Diecimila have the atmega168.  If you're using a LilyPad Arduino,
-#     change F_CPU to 8000000.
-#
-#  5. At the command line, change to the directory containing your
-#     program's file and the makefile.
-#
-#  6. Type "make" and press enter to compile/verify your program.
-#
-#  7. Type "make upload", reset your Arduino board, and press enter to
-#     upload your program to the Arduino board.
-#
-# $Id$
-
-TARGET = $(notdir $(CURDIR))
-INSTALL_DIR = E:/arduino_trunk/build/windows/work
-PORT = COM1
-UPLOAD_RATE = 19200
-AVRDUDE_PROGRAMMER = stk500v2
-MCU = attiny84
-F_CPU = 1000000
-
-############################################################################
-# Below here nothing should be changed...
-
-ARDUINO = $(INSTALL_DIR)/hardware/cores/luminet
-AVR_TOOLS_PATH = $(INSTALL_DIR)/hardware/tools/avr/bin
-SRC = $(ARDUINO)/topology.c $(ARDUINO)/bynase.c $(ARDUINO)/pins_arduino.c $(ARDUINO)/wiring.c \
-$(ARDUINO)/wiring_analog.c $(ARDUINO)/wiring_digital.c \
-$(ARDUINO)/wiring_pulse.c $(ARDUINO)/wiring_serial.c \
-$(ARDUINO)/wiring_shift.c $(ARDUINO)/WInterrupts.c \
-CXXSRC = $(ARDUINO)/HardwareSerial.cpp $(ARDUINO)/WMath.cpp 
-FORMAT = ihex
-
-
-# Name of this Makefile (used for "make depend").
-MAKEFILE = Makefile
-
-# Debugging format.
-# Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.
-# AVR (extended) COFF requires stabs, plus an avr-objcopy run.
-DEBUG = stabs
-
-OPT = s
-
-# Place -D or -U options here
-CDEFS = -DF_CPU=$(F_CPU)
-CXXDEFS = -DF_CPU=$(F_CPU)
-
-# Place -I options here
-CINCS = -I$(ARDUINO)
-CXXINCS = -I$(ARDUINO)
-
-# 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
-CDEBUG = -g$(DEBUG)
-CWARN = -Wall -Wstrict-prototypes
-CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
-#CEXTRA = -Wa,-adhlns=$(<:.c=.lst)
-
-CFLAGS = $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CSTANDARD) $(CEXTRA)
-CXXFLAGS = $(CDEFS) $(CINCS) -O$(OPT)
-#ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs 
-LDFLAGS = -lm
-
-
-# Programming support using avrdude. Settings and variables.
-AVRDUDE_PORT = $(PORT)
-AVRDUDE_WRITE_FLASH = -U flash:w:applet/$(TARGET).hex
-AVRDUDE_FLAGS = -V -F -C $(INSTALL_DIR)/hardware/tools/avr/etc/avrdude.conf \
--p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) \
--b $(UPLOAD_RATE)
-
-# Program settings
-CC = $(AVR_TOOLS_PATH)/avr-gcc
-CXX = $(AVR_TOOLS_PATH)/avr-g++
-OBJCOPY = $(AVR_TOOLS_PATH)/avr-objcopy
-OBJDUMP = $(AVR_TOOLS_PATH)/avr-objdump
-AR  = $(AVR_TOOLS_PATH)/avr-ar
-SIZE = $(AVR_TOOLS_PATH)/avr-size
-NM = $(AVR_TOOLS_PATH)/avr-nm
-AVRDUDE = $(AVR_TOOLS_PATH)/avrdude
-REMOVE = rm -f
-MV = mv -f
-
-# Define all object files.
-OBJ = $(SRC:.c=.o) $(CXXSRC:.cpp=.o) $(ASRC:.S=.o) 
-
-# Define all listing files.
-LST = $(ASRC:.S=.lst) $(CXXSRC:.cpp=.lst) $(SRC:.c=.lst)
-
-# Combine all necessary flags and optional flags.
-# Add target processor to flags.
-ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
-ALL_CXXFLAGS = -mmcu=$(MCU) -I. $(CXXFLAGS)
-ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
-
-
-# Default target.
-all: applet_files build sizeafter
-
-build: elf hex lss sym
-
-applet_files: $(TARGET).pde
-	# Here is the "preprocessing".
-	# It creates a .cpp file based with the same name as the .pde file.
-	# On top of the new .cpp file comes the WProgram.h header.
-	# At the end there is a generic main() function attached.
-	# Then the .cpp file will be compiled. Errors during compile will
-	# refer to this new, automatically generated, file. 
-	# Not the original .pde file you actually edit...
-	test -d applet || mkdir applet
-	echo '#include "WProgram.h"' > applet/$(TARGET).cpp
-	cat $(TARGET).pde >> applet/$(TARGET).cpp
-	cat $(ARDUINO)/main.cxx >> applet/$(TARGET).cpp
-
-elf: applet/$(TARGET).elf
-hex: applet/$(TARGET).hex
-eep: applet/$(TARGET).eep
-lss: applet/$(TARGET).lss 
-sym: applet/$(TARGET).sym
-
-# Program the device.  
-upload: applet/$(TARGET).hex
-	$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
-
-
-	# Display size of file.
-HEXSIZE = $(SIZE) --target=$(FORMAT) applet/$(TARGET).hex
-ELFSIZE = $(SIZE)  applet/$(TARGET).elf
-sizebefore:
-	@if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(HEXSIZE); echo; fi
-
-sizeafter:
-	@if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(HEXSIZE); echo; fi
-
-
-# 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: applet/$(TARGET).elf
-	$(COFFCONVERT) -O coff-avr applet/$(TARGET).elf $(TARGET).cof
-
-
-extcoff: $(TARGET).elf
-	$(COFFCONVERT) -O coff-ext-avr applet/$(TARGET).elf $(TARGET).cof
-
-
-.SUFFIXES: .elf .hex .eep .lss .sym
-
-.elf.hex:
-	$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
-
-.elf.eep:
-	-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
-	--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
-
-# Create extended listing file from ELF output file.
-.elf.lss:
-	$(OBJDUMP) -h -S $< > $@
-
-# Create a symbol table from ELF output file.
-.elf.sym:
-	$(NM) -n $< > $@
-	
-
-# Create extended listing file from ELF output file.
-%.lss: %.elf
-	$(OBJDUMP) -h -S $< > $@
-
-# Create a symbol table from ELF output file.
-%.sym: %.elf
-	$(NM) -n $< > $@
-
-
-	# Link: create ELF output file from library.
-applet/$(TARGET).elf: $(TARGET).pde applet/core.a 
-	$(CC) $(ALL_CFLAGS) -o $@ applet/$(TARGET).cpp -L. applet/core.a $(LDFLAGS)
-
-applet/core.a: $(OBJ)
-	@for i in $(OBJ); do echo $(AR) rcs applet/core.a $$i; $(AR) rcs applet/core.a $$i; done
-
-
-
-# Compile: create object files from C++ source files.
-.cpp.o:
-	$(CXX) -c $(ALL_CXXFLAGS) $< -o $@ 
-
-# Compile: create object files from C source files.
-.c.o:
-	$(CC) -c $(ALL_CFLAGS) $< -o $@ 
-
-
-# Compile: create assembler files from C source files.
-.c.s:
-	$(CC) -S $(ALL_CFLAGS) $< -o $@
-
-
-# Assemble: create object files from assembler source files.
-.S.o:
-	$(CC) -c $(ALL_ASFLAGS) $< -o $@
-
-
-
-# Target: clean project.
-clean:
-	$(REMOVE) applet/$(TARGET).hex applet/$(TARGET).eep applet/$(TARGET).cof applet/$(TARGET).elf \
-	applet/$(TARGET).map applet/$(TARGET).sym applet/$(TARGET).lss applet/core.a \
-	$(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(CXXSRC:.cpp=.s) $(CXXSRC:.cpp=.d)
-
-depend:
-	if grep '^# DO NOT DELETE' $(MAKEFILE) >/dev/null; \
-	then \
-		sed -e '/^# DO NOT DELETE/,$$d' $(MAKEFILE) > \
-			$(MAKEFILE).$$$$ && \
-		$(MV) $(MAKEFILE).$$$$ $(MAKEFILE); \
-	fi
-	echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' \
-		>> $(MAKEFILE); \
-	$(CC) -M -mmcu=$(MCU) $(CDEFS) $(CINCS) $(SRC) $(ASRC) >> $(MAKEFILE)
-
-.PHONY:	all build elf hex eep lss sym program coff extcoff clean depend applet_files sizebefore sizeafter

+ 0 - 213
optiboot/cores/luminet/Print.cpp

@@ -1,213 +0,0 @@
-/*
- Print.cpp - Base class that provides print() and println()
- Copyright (c) 2008 David A. Mellis.  All right reserved.
- 
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
- 
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- Lesser General Public License for more details.
- 
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- 
- Modified 23 November 2006 by David A. Mellis
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <inttypes.h>
-#include <math.h>
-#include <avr/delay.h>
-#include "wiring.h"
-
-#include "Print.h"
-
-// Public Methods //////////////////////////////////////////////////////////////
-
-void Print::print(uint8_t b)
-{
-  this->write(b);
-  _delay_loop_2(50);//short delay helps the line to recover (become IDLE)
-}
-
-void Print::print(char c)
-{
-  print((byte) c);
-}
-
-void Print::print(const char c[])
-{
-  uint8_t volatile len = strlen(c);
-  for(uint8_t z=0; z<len; z++)
-  {
-    print((uint8_t) c[z]);
-  }
-}
-
-void Print::print(int n)
-{
-  print((long) n);
-}
-
-void Print::print(unsigned int n)
-{
-  print((unsigned long) n);
-}
-
-void Print::print(long n)
-{
-  if (n < 0) {
-    print('-');
-    n = -n;
-  }
-  printNumber(n, 10);
-}
-
-void Print::print(unsigned long n)
-{
-  printNumber(n, 10);
-}
-
-void Print::print(long n, int base)
-{
-  if (base == 0)
-    print((char) n);
-  else if (base == DEC)
-    print((long) n);
-  else
-    printNumber(n, base);
-}
-
-void Print::print(double n)
-{
-  printFloat(n, 2);
-}
-
-void Print::println(void)
-{
-  print((uint8_t) '\r');
-  print((uint8_t) '\n');  
-}
-
-void Print::println(char c)
-{
-  print(c);
-  println();  
-}
-
-void Print::println(const char c[])
-{
-  uint8_t volatile len = strlen(c);
-  for(uint8_t z=0; z<len; z++)
-  {
-    print((uint8_t) c[z]);
-  }
-  print((uint8_t) '\r');
-  print((uint8_t) '\n');  
-}
-
-void Print::println(uint8_t b)
-{
-  print(b);
-  println();
-}
-
-void Print::println(int n)
-{
-  print(n);
-  println();
-}
-
-void Print::println(unsigned int n)
-{
-  print(n);
-  println();
-}
-
-void Print::println(long n)
-{
-  print(n);
-  println();  
-}
-
-void Print::println(unsigned long n)
-{
-  print(n);
-  println();  
-}
-
-void Print::println(long n, int base)
-{
-  print(n, base);
-  println();
-}
-
-void Print::println(double n)
-{
-  print(n);
-  println();
-}
-
-// Private Methods /////////////////////////////////////////////////////////////
-
-void Print::printNumber(unsigned long n, uint8_t base)
-{
-  unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars. 
-  unsigned long i = 0;
-
-  if (n == 0) {
-    print('0');
-    return;
-  } 
-
-  while (n > 0) {
-    buf[i++] = n % base;
-    n /= base;
-  }
-
-  for (; i > 0; i--)
-    print((char) (buf[i - 1] < 10 ?
-      '0' + buf[i - 1] :
-      'A' + buf[i - 1] - 10));
-}
-
-void Print::printFloat(double number, uint8_t digits) 
-{ 
-  // Handle negative numbers
-  if (number < 0.0)
-  {
-     print('-');
-     number = -number;
-  }
-
-  // Round correctly so that print(1.999, 2) prints as "2.00"
-  double rounding = 0.5;
-  for (uint8_t i=0; i<digits; ++i)
-    rounding /= 10.0;
-  
-  number += rounding;
-
-  // Extract the integer part of the number and print it
-  unsigned long int_part = (unsigned long)number;
-  double remainder = number - (double)int_part;
-  print(int_part);
-
-  // Print the decimal point, but only if there are digits beyond
-  if (digits > 0)
-    print("."); 
-
-  // Extract digits from the remainder one at a time
-  while (digits-- > 0)
-  {
-    remainder *= 10.0;
-    int toPrint = int(remainder);
-    print(toPrint);
-    remainder -= toPrint; 
-  } 
-}

+ 0 - 59
optiboot/cores/luminet/Print.h

@@ -1,59 +0,0 @@
-/*
-  Print.h - Base class that provides print() and println()
-  Copyright (c) 2008 David A. Mellis.  All right reserved.
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public
-  License along with this library; if not, write to the Free Software
-  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-*/
-
-#ifndef Print_h
-#define Print_h
-
-#include <inttypes.h>
-
-#define DEC 10
-#define HEX 16
-#define OCT 8
-#define BIN 2
-#define BYTE 0
-
-class Print
-{
-  private:
-    void printNumber(unsigned long, uint8_t);
-    void printFloat(double, uint8_t);
-  public:
-    virtual void write(uint8_t);
-    void print(char);
-    void print(const char[]);
-    void print(uint8_t);
-    void print(int);
-    void print(unsigned int);
-    void print(long);
-    void print(unsigned long);
-    void print(long, int);
-    void print(double);
-    void println(void);
-    void println(char);
-    void println(const char[]);
-    void println(uint8_t);
-    void println(int);
-    void println(unsigned int);
-    void println(long);
-    void println(unsigned long);
-    void println(long, int);
-    void println(double);
-};
-
-#endif

+ 0 - 1
optiboot/cores/luminet/WConstants.h

@@ -1 +0,0 @@
-#include "wiring.h"

+ 0 - 106
optiboot/cores/luminet/WInterrupts.c

@@ -1,106 +0,0 @@
-/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
-
-/*
-  Part of the Wiring project - http://wiring.uniandes.edu.co
-
-  Copyright (c) 2004-05 Hernando Barragan
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General
-  Public License along with this library; if not, write to the
-  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
-  Boston, MA  02111-1307  USA
-  
-  Modified 24 November 2006 by David A. Mellis
-*/
-
-#include <inttypes.h>
-#include <avr/io.h>
-#include <avr/interrupt.h>
-#include <avr/pgmspace.h>
-#include <stdio.h>
-
-#include "WConstants.h"
-#include "wiring_private.h"
-
-volatile static voidFuncPtr intFunc[EXTERNAL_NUM_INTERRUPTS];
-// volatile static voidFuncPtr twiIntFunc;
-
-
-#define EICRA MCUCR
-#define EIMSK GICR
-
-
-void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), int mode) {
-	
-	/*
-  if(interruptNum < EXTERNAL_NUM_INTERRUPTS) {
-    intFunc[interruptNum] = userFunc;
-    
-    if (interruptNum == 0) {
-      // Configure the interrupt mode (trigger on low input, any change, rising
-      // edge, or falling edge).  The mode constants were chosen to correspond
-      // to the configuration bits in the hardware register, so we simply shift
-      // the mode into place.
-      EICRA = (EICRA & ~((1 << ISC00) | (1 << ISC01))) | (mode << ISC00);
-      
-      // Enable the interrupt.
-      EIMSK |= (1 << INT0);
-    } else {
-      EICRA = (EICRA & ~((1 << ISC10) | (1 << ISC11))) | (mode << ISC10);
-      EIMSK |= (1 << INT1);
-    }
-  }
-  */
-}
-
-void detachInterrupt(uint8_t interruptNum) {
-	/*
-  if(interruptNum < EXTERNAL_NUM_INTERRUPTS) {
-    if (interruptNum == 0)
-      // Disable the interrupt.
-      EIMSK &= ~(1 << INT0);
-    else
-      EIMSK &= ~(1 << INT1);
-      
-    intFunc[interruptNum] = 0;
-  }
-  */
-}
-
-/*
-void attachInterruptTwi(void (*userFunc)(void) ) {
-  twiIntFunc = userFunc;
-}
-*/
-
-/*
-SIGNAL(INT0_vect) {
-  if(intFunc[EXTERNAL_INT_0])
-    intFunc[EXTERNAL_INT_0]();
-}
-*/
-
-/*
-SIGNAL(INT1_vect) {
-  if(intFunc[EXTERNAL_INT_1])
-    intFunc[EXTERNAL_INT_1]();
-}
-*/
-
-/*
-SIGNAL(SIG_2WIRE_SERIAL) {
-  if(twiIntFunc)
-    twiIntFunc();
-}
-*/
-

+ 0 - 60
optiboot/cores/luminet/WMath.cpp

@@ -1,60 +0,0 @@
-/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
-
-/*
-  Part of the Wiring project - http://wiring.org.co
-  Copyright (c) 2004-06 Hernando Barragan
-  Modified 13 August 2006, David A. Mellis for Arduino - http://www.arduino.cc/
-  
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General
-  Public License along with this library; if not, write to the
-  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
-  Boston, MA  02111-1307  USA
-  
-  $Id$
-*/
-
-extern "C" {
-  #include "stdlib.h"
-}
-
-void randomSeed(unsigned int seed)
-{
-  if (seed != 0) {
-    srandom(seed);
-  }
-}
-
-long random(long howbig)
-{
-  if (howbig == 0) {
-    return 0;
-  }
-  return random() % howbig;
-}
-
-long random(long howsmall, long howbig)
-{
-  if (howsmall >= howbig) {
-    return howsmall;
-  }
-  long diff = howbig - howsmall;
-  return random(diff) + howsmall;
-}
-
-long map(long x, long in_min, long in_max, long out_min, long out_max)
-{
-  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
-}
-
-unsigned int makeWord(unsigned int w) { return w; }
-unsigned int makeWord(unsigned char h, unsigned char l) { return (h << 8) | l; }

+ 0 - 37
optiboot/cores/luminet/WProgram.h

@@ -1,37 +0,0 @@
-#ifndef WProgram_h
-#define WProgram_h
-
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-
-#include <avr/interrupt.h>
-
-#include "topology.h"
-#include "bynase.h"
-#include "LEDExtensions.h"
-#include "COM.h"
-
-#include "wiring.h"
-
-uint8_t mainconnections;
-
-
-#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);
-
-// WMath prototypes
-long random(long);
-long random(long, long);
-void randomSeed(unsigned int);
-long map(long, long, long, long, long);
-#endif
-
-#endif

+ 0 - 515
optiboot/cores/luminet/binary.h

@@ -1,515 +0,0 @@
-#ifndef Binary_h
-#define Binary_h
-
-#define B0 0
-#define B00 0
-#define B000 0
-#define B0000 0
-#define B00000 0
-#define B000000 0
-#define B0000000 0
-#define B00000000 0
-#define B1 1
-#define B01 1
-#define B001 1
-#define B0001 1
-#define B00001 1
-#define B000001 1
-#define B0000001 1
-#define B00000001 1
-#define B10 2
-#define B010 2
-#define B0010 2
-#define B00010 2
-#define B000010 2
-#define B0000010 2
-#define B00000010 2
-#define B11 3
-#define B011 3
-#define B0011 3
-#define B00011 3
-#define B000011 3
-#define B0000011 3
-#define B00000011 3
-#define B100 4
-#define B0100 4
-#define B00100 4
-#define B000100 4
-#define B0000100 4
-#define B00000100 4
-#define B101 5
-#define B0101 5
-#define B00101 5
-#define B000101 5
-#define B0000101 5
-#define B00000101 5
-#define B110 6
-#define B0110 6
-#define B00110 6
-#define B000110 6
-#define B0000110 6
-#define B00000110 6
-#define B111 7
-#define B0111 7
-#define B00111 7
-#define B000111 7
-#define B0000111 7
-#define B00000111 7
-#define B1000 8
-#define B01000 8
-#define B001000 8
-#define B0001000 8
-#define B00001000 8
-#define B1001 9
-#define B01001 9
-#define B001001 9
-#define B0001001 9
-#define B00001001 9
-#define B1010 10
-#define B01010 10
-#define B001010 10
-#define B0001010 10
-#define B00001010 10
-#define B1011 11
-#define B01011 11
-#define B001011 11
-#define B0001011 11
-#define B00001011 11
-#define B1100 12
-#define B01100 12
-#define B001100 12
-#define B0001100 12
-#define B00001100 12
-#define B1101 13
-#define B01101 13
-#define B001101 13
-#define B0001101 13
-#define B00001101 13
-#define B1110 14
-#define B01110 14
-#define B001110 14
-#define B0001110 14
-#define B00001110 14
-#define B1111 15
-#define B01111 15
-#define B001111 15
-#define B0001111 15
-#define B00001111 15
-#define B10000 16
-#define B010000 16
-#define B0010000 16
-#define B00010000 16
-#define B10001 17
-#define B010001 17
-#define B0010001 17
-#define B00010001 17
-#define B10010 18
-#define B010010 18
-#define B0010010 18
-#define B00010010 18
-#define B10011 19
-#define B010011 19
-#define B0010011 19
-#define B00010011 19
-#define B10100 20
-#define B010100 20
-#define B0010100 20
-#define B00010100 20
-#define B10101 21
-#define B010101 21
-#define B0010101 21
-#define B00010101 21
-#define B10110 22
-#define B010110 22
-#define B0010110 22
-#define B00010110 22
-#define B10111 23
-#define B010111 23
-#define B0010111 23
-#define B00010111 23
-#define B11000 24
-#define B011000 24
-#define B0011000 24
-#define B00011000 24
-#define B11001 25
-#define B011001 25
-#define B0011001 25
-#define B00011001 25
-#define B11010 26
-#define B011010 26
-#define B0011010 26
-#define B00011010 26
-#define B11011 27
-#define B011011 27
-#define B0011011 27
-#define B00011011 27
-#define B11100 28
-#define B011100 28
-#define B0011100 28
-#define B00011100 28
-#define B11101 29
-#define B011101 29
-#define B0011101 29
-#define B00011101 29
-#define B11110 30
-#define B011110 30
-#define B0011110 30
-#define B00011110 30
-#define B11111 31
-#define B011111 31
-#define B0011111 31
-#define B00011111 31
-#define B100000 32
-#define B0100000 32
-#define B00100000 32
-#define B100001 33
-#define B0100001 33
-#define B00100001 33
-#define B100010 34
-#define B0100010 34
-#define B00100010 34
-#define B100011 35
-#define B0100011 35
-#define B00100011 35
-#define B100100 36
-#define B0100100 36
-#define B00100100 36
-#define B100101 37
-#define B0100101 37
-#define B00100101 37
-#define B100110 38
-#define B0100110 38
-#define B00100110 38
-#define B100111 39
-#define B0100111 39
-#define B00100111 39
-#define B101000 40
-#define B0101000 40
-#define B00101000 40
-#define B101001 41
-#define B0101001 41
-#define B00101001 41
-#define B101010 42
-#define B0101010 42
-#define B00101010 42
-#define B101011 43
-#define B0101011 43
-#define B00101011 43
-#define B101100 44
-#define B0101100 44
-#define B00101100 44
-#define B101101 45
-#define B0101101 45
-#define B00101101 45
-#define B101110 46
-#define B0101110 46
-#define B00101110 46
-#define B101111 47
-#define B0101111 47
-#define B00101111 47
-#define B110000 48
-#define B0110000 48
-#define B00110000 48
-#define B110001 49
-#define B0110001 49
-#define B00110001 49
-#define B110010 50
-#define B0110010 50
-#define B00110010 50
-#define B110011 51
-#define B0110011 51
-#define B00110011 51
-#define B110100 52
-#define B0110100 52
-#define B00110100 52
-#define B110101 53
-#define B0110101 53
-#define B00110101 53
-#define B110110 54
-#define B0110110 54
-#define B00110110 54
-#define B110111 55
-#define B0110111 55
-#define B00110111 55
-#define B111000 56
-#define B0111000 56
-#define B00111000 56
-#define B111001 57
-#define B0111001 57
-#define B00111001 57
-#define B111010 58
-#define B0111010 58
-#define B00111010 58
-#define B111011 59
-#define B0111011 59
-#define B00111011 59
-#define B111100 60
-#define B0111100 60
-#define B00111100 60
-#define B111101 61
-#define B0111101 61
-#define B00111101 61
-#define B111110 62
-#define B0111110 62
-#define B00111110 62
-#define B111111 63
-#define B0111111 63
-#define B00111111 63
-#define B1000000 64
-#define B01000000 64
-#define B1000001 65
-#define B01000001 65
-#define B1000010 66
-#define B01000010 66
-#define B1000011 67
-#define B01000011 67
-#define B1000100 68
-#define B01000100 68
-#define B1000101 69
-#define B01000101 69
-#define B1000110 70
-#define B01000110 70
-#define B1000111 71
-#define B01000111 71
-#define B1001000 72
-#define B01001000 72
-#define B1001001 73
-#define B01001001 73
-#define B1001010 74
-#define B01001010 74
-#define B1001011 75
-#define B01001011 75
-#define B1001100 76
-#define B01001100 76
-#define B1001101 77
-#define B01001101 77
-#define B1001110 78
-#define B01001110 78
-#define B1001111 79
-#define B01001111 79
-#define B1010000 80
-#define B01010000 80
-#define B1010001 81
-#define B01010001 81
-#define B1010010 82
-#define B01010010 82
-#define B1010011 83
-#define B01010011 83
-#define B1010100 84
-#define B01010100 84
-#define B1010101 85
-#define B01010101 85
-#define B1010110 86
-#define B01010110 86
-#define B1010111 87
-#define B01010111 87
-#define B1011000 88
-#define B01011000 88
-#define B1011001 89
-#define B01011001 89
-#define B1011010 90
-#define B01011010 90
-#define B1011011 91
-#define B01011011 91
-#define B1011100 92
-#define B01011100 92
-#define B1011101 93
-#define B01011101 93
-#define B1011110 94
-#define B01011110 94
-#define B1011111 95
-#define B01011111 95
-#define B1100000 96
-#define B01100000 96
-#define B1100001 97
-#define B01100001 97
-#define B1100010 98
-#define B01100010 98
-#define B1100011 99
-#define B01100011 99
-#define B1100100 100
-#define B01100100 100
-#define B1100101 101
-#define B01100101 101
-#define B1100110 102
-#define B01100110 102
-#define B1100111 103
-#define B01100111 103
-#define B1101000 104
-#define B01101000 104
-#define B1101001 105
-#define B01101001 105
-#define B1101010 106
-#define B01101010 106
-#define B1101011 107
-#define B01101011 107
-#define B1101100 108
-#define B01101100 108
-#define B1101101 109
-#define B01101101 109
-#define B1101110 110
-#define B01101110 110
-#define B1101111 111
-#define B01101111 111
-#define B1110000 112
-#define B01110000 112
-#define B1110001 113
-#define B01110001 113
-#define B1110010 114
-#define B01110010 114
-#define B1110011 115
-#define B01110011 115
-#define B1110100 116
-#define B01110100 116
-#define B1110101 117
-#define B01110101 117
-#define B1110110 118
-#define B01110110 118
-#define B1110111 119
-#define B01110111 119
-#define B1111000 120
-#define B01111000 120
-#define B1111001 121
-#define B01111001 121
-#define B1111010 122
-#define B01111010 122
-#define B1111011 123
-#define B01111011 123
-#define B1111100 124
-#define B01111100 124
-#define B1111101 125
-#define B01111101 125
-#define B1111110 126
-#define B01111110 126
-#define B1111111 127
-#define B01111111 127
-#define B10000000 128
-#define B10000001 129
-#define B10000010 130
-#define B10000011 131
-#define B10000100 132
-#define B10000101 133
-#define B10000110 134
-#define B10000111 135
-#define B10001000 136
-#define B10001001 137
-#define B10001010 138
-#define B10001011 139
-#define B10001100 140
-#define B10001101 141
-#define B10001110 142
-#define B10001111 143
-#define B10010000 144
-#define B10010001 145
-#define B10010010 146
-#define B10010011 147
-#define B10010100 148
-#define B10010101 149
-#define B10010110 150
-#define B10010111 151
-#define B10011000 152
-#define B10011001 153
-#define B10011010 154
-#define B10011011 155
-#define B10011100 156
-#define B10011101 157
-#define B10011110 158
-#define B10011111 159
-#define B10100000 160
-#define B10100001 161
-#define B10100010 162
-#define B10100011 163
-#define B10100100 164
-#define B10100101 165
-#define B10100110 166
-#define B10100111 167
-#define B10101000 168
-#define B10101001 169
-#define B10101010 170
-#define B10101011 171
-#define B10101100 172
-#define B10101101 173
-#define B10101110 174
-#define B10101111 175
-#define B10110000 176
-#define B10110001 177
-#define B10110010 178
-#define B10110011 179
-#define B10110100 180
-#define B10110101 181
-#define B10110110 182
-#define B10110111 183
-#define B10111000 184
-#define B10111001 185
-#define B10111010 186
-#define B10111011 187
-#define B10111100 188
-#define B10111101 189
-#define B10111110 190
-#define B10111111 191
-#define B11000000 192
-#define B11000001 193
-#define B11000010 194
-#define B11000011 195
-#define B11000100 196
-#define B11000101 197
-#define B11000110 198
-#define B11000111 199
-#define B11001000 200
-#define B11001001 201
-#define B11001010 202
-#define B11001011 203
-#define B11001100 204
-#define B11001101 205
-#define B11001110 206
-#define B11001111 207
-#define B11010000 208
-#define B11010001 209
-#define B11010010 210
-#define B11010011 211
-#define B11010100 212
-#define B11010101 213
-#define B11010110 214
-#define B11010111 215
-#define B11011000 216
-#define B11011001 217
-#define B11011010 218
-#define B11011011 219
-#define B11011100 220
-#define B11011101 221
-#define B11011110 222
-#define B11011111 223
-#define B11100000 224
-#define B11100001 225
-#define B11100010 226
-#define B11100011 227
-#define B11100100 228
-#define B11100101 229
-#define B11100110 230
-#define B11100111 231
-#define B11101000 232
-#define B11101001 233
-#define B11101010 234
-#define B11101011 235
-#define B11101100 236
-#define B11101101 237
-#define B11101110 238
-#define B11101111 239
-#define B11110000 240
-#define B11110001 241
-#define B11110010 242
-#define B11110011 243
-#define B11110100 244
-#define B11110101 245
-#define B11110110 246
-#define B11110111 247
-#define B11111000 248
-#define B11111001 249
-#define B11111010 250
-#define B11111011 251
-#define B11111100 252
-#define B11111101 253
-#define B11111110 254
-#define B11111111 255
-
-#endif

+ 0 - 304
optiboot/cores/luminet/bynase.c

@@ -1,304 +0,0 @@
-#include "bynase.h"
-#include <avr/io.h>
-
-//number of samples simple_byin should take
-#define NUMBER_OF_SAMPLES 200
-
-#define NUMBER_OF_BYNASE_PINS 19
-
-uint8_t outPinsA;//Arduino Pins 7..0
-uint8_t outPinsB;//Arduino Pins 15..8
-uint8_t outPinsC;//Arduino Pins 19..16
-
-uint8_t inPinsA;//Arduino Pins 7..0
-uint8_t inPinsB;//Arduino Pins 15..8
-uint8_t inPinsC;//Arduino Pins 19..16
-
-uint8_t byval_out[NUMBER_OF_BYNASE_PINS];//byvals for up to 19 output pins
-uint8_t byval_in[NUMBER_OF_BYNASE_PINS];//byvals for up to 19 input pins
-
-uint16_t total_in[NUMBER_OF_BYNASE_PINS];
-uint8_t count_in[NUMBER_OF_BYNASE_PINS];
-
-uint8_t timerSpeed;
-
-uint8_t byrandValue;//for random
-
-
-uint8_t byrand(void)
-{
- uint8_t v = byrandValue++;
- uint8_t r = 0;
- uint8_t q = 255;
- while(q) {
- r = (r << 1) | (v & 1);
- v >>= 1;
- q >>= 1;
- }
- return r;
-}
-
-void _byin(uint8_t pinNumber)
-{
-	if(pinNumber < 8)
-	{
-		if(! (inPinsA & (1 <<(pinNumber))) )
-		{
-			return;//pin is not registered for bynase output
-		}
-	}
-	else if(pinNumber < 15)
-	{
-		if(! (inPinsB & (1 <<(pinNumber-8))) )
-		{
-			return;//pin is not registered for bynase output
-		}
-	}
-	else
-	{
-		if(! (inPinsC & (1 <<(pinNumber-15))) )
-		{
-			return;//pin is not registered for bynase output
-		}
-	}
-	
-	count_in[pinNumber]++;
-	if(count_in[pinNumber] >= NUMBER_OF_SAMPLES)
-	{
-		byval_in[pinNumber] = (total_in[pinNumber] * 100) / count_in[pinNumber];
-		count_in[pinNumber] = 0;
-		total_in[pinNumber] = 0;
-	}
-	else
-	{
-		if(digitalRead(pinNumber) == HIGH)
-		{
-			total_in[pinNumber]++;
-		}
-		
-	}	
-}
-
-void byin(void) 
-{
-	uint8_t z;
-	for(z=0; z<NUMBER_OF_BYNASE_PINS; z++)
-	{
-		_byin(z);
-	}
-}
-
-void _byout(uint8_t pinNumber, uint8_t random_value) 
-{
-	if(pinNumber < 8)
-	{
-		if(! (outPinsA & (1 <<pinNumber)) )
-		{
-			return;//pin is not registered for bynase input
-		}
-	}
-	else if(pinNumber < 15)
-	{
-		if(! (outPinsB & (1 <<(pinNumber-8))) )
-		{
-			return;//pin is not registered for bynase input
-		}
-	}
-	else
-	{
-		if(! (outPinsC & (1 <<(pinNumber-15))) )
-		{
-			return;//pin is not registered for bynase input
-		}
-	}
-	
-	
-	if (byval_out[pinNumber] >= random_value) 
-	{
-		digitalWrite(pinNumber, HIGH);
-	} 
-	else 
-	{
-		digitalWrite(pinNumber, LOW);
-	}
-}
-
-void byout(void) 
-{
-	uint8_t random_value;//only one random value for all ports
-	random_value = ((byrand() % 99)+1);//random value between 1 and 100
-	uint8_t z;
-	for(z=0; z<NUMBER_OF_BYNASE_PINS; z++)
-	{
-		_byout(z, random_value);
-	}
-	
-}
-
-void bynase_init(uint8_t speed)
-{
-	uint8_t z;
-	uint8_t oldSREG = SREG;
-	
-	if(timerSpeed != speed)
-	{
-		for(z=0; z<NUMBER_OF_BYNASE_PINS; z++)
-		{
-			byval_out[z] = 0;
-			byval_in[z] = 0;
-			total_in[z] = 0;
-			count_in[z] = 0;
-		}
-		timerSpeed = speed;
-		
-		cli();	
-		//INIT TIMER1
-		TCCR1A = 0x00;
-	  TCCR1B = 0b00000001; //no prescaler
-	  TIMSK1 = 0b00000001;//enable timer overflow interrupt
-	  
-	 // byrandValue=0;
-		
-		// reenable interrupts.
-		SREG = oldSREG;
-	}
-}
-
-void bynase_write(uint8_t pinNumber, uint8_t value)
-{
-	byval_out[pinNumber] = value;
-}
-
-
-uint8_t bynase_read(uint8_t pinNumber)
-{
-	
-	return byval_in[pinNumber];
-}
-
-
-
-void bynase_registerPin(uint8_t pinNumber, uint8_t mode)
-{
-	if(pinNumber > (NUMBER_OF_BYNASE_PINS-1))
-	{
-		return;
-	}
-	
-	if(mode == BYNASE_INPUT)
-	{
-		pinMode(pinNumber, INPUT);
-		digitalWrite(pinNumber, LOW);		
-
-		if(pinNumber < 8)
-		{
-			inPinsA |= (1<<pinNumber);
-			outPinsA &= (uint8_t)~(1<<pinNumber);
-		}
-		else if(pinNumber < 15)
-		{
-			inPinsB |= (1<<(pinNumber-8));
-			outPinsB &= (uint8_t)~(1<<(pinNumber-8));
-		}
-		else
-		{
-			inPinsC |= (1<<(pinNumber-15));
-			outPinsC &= (uint8_t)~(1<<(pinNumber-15));
-		}
-		
-	}
-	else if(mode == BYNASE_OUTPUT)
-	{
-		pinMode(pinNumber, OUTPUT);
-		digitalWrite(pinNumber, LOW);
-		
-		if(pinNumber < 8)
-		{
-			outPinsA |= (1<<pinNumber);
-			inPinsA &= (uint8_t)~(1<<pinNumber);
-		}
-		else if(pinNumber < 15)
-		{
-			outPinsB |= (1<<(pinNumber-8));
-			inPinsB &= (uint8_t)~(1<<(pinNumber-8));
-		}
-		else
-		{
-			outPinsC |= (1<<(pinNumber-15));
-			inPinsC &= (uint8_t)~(1<<(pinNumber-15));
-		}
-		
-		
-	}
-	else if(mode == BYNASE_BOTH)
-	{
-		if(pinNumber < 8)
-		{
-			outPinsA |= (1<<pinNumber);
-			inPinsA |= (1<<pinNumber);
-		}
-		else if(pinNumber < 15)
-		{
-			outPinsB |= (1<<(pinNumber-8));
-			inPinsB |= (1<<(pinNumber-8));
-		}
-		else
-		{
-			outPinsC |= (1<<(pinNumber-15));
-			inPinsC |= (1<<(pinNumber-15));
-		}
-	}
-	
-	else if(mode == BYNASE_NONE)
-	{
-		if(pinNumber < 8)
-		{
-			inPinsA &= (uint8_t)~(1<<pinNumber);
-			outPinsA &= (uint8_t)~(1<<pinNumber);
-		}
-		else if(pinNumber < 15)
-		{
-			inPinsB &= (uint8_t)~(1<<(pinNumber-8));
-			outPinsB &= (uint8_t)~(1<<(pinNumber-8));
-		}
-		else
-		{
-			inPinsC &= (uint8_t)~(1<<(pinNumber-15));
-			outPinsC &= (uint8_t)~(1<<(pinNumber-15));
-		}
-	}
-}
-
-void bynase_unregisterPin(uint8_t pinNumber)
-{
-	bynase_registerPin(pinNumber, BYNASE_NONE);
-}
-
-#if defined (__AVR_ATtiny84__)
-ISR(TIM1_OVF_vect)
-#elif defined(__AVR_ATmega8__)
-ISR(TIMER1_OVF_vect)
-#elif defined (__AVR_ATmega168__)
-ISR(TIMER1_OVF_vect)
-#elif defined (__AVR_ATmega328P__)
-ISR(TIMER1_OVF_vect)
-#endif
-{
-	uint8_t oldSREG = SREG;
-	cli();
-	if( (inPinsA | inPinsB | inPinsC) >0)
-	{
-		byin();
-	}
-	
-	if( (outPinsA |outPinsB | outPinsC) >0)
-	{
-		byout();
-	}
-	
-	TCNT1 = 0xFFFF - (255-timerSpeed);//count 255-timerspeed times from now on at 1Mhz 
-	TIFR1 = 0xFF;//clear all pending interrups for timer1
-	
-	// reenable interrupts.
-	SREG = oldSREG;
-}

+ 0 - 30
optiboot/cores/luminet/bynase.h

@@ -1,30 +0,0 @@
-#ifndef _BYNASE_H
-#define _BYNASE_H
-
-
-#include "WProgram.h"
-
-#ifdef __cplusplus
-extern "C"{
-#endif
-
-
-
-#define BYNASE_INPUT 0
-#define BYNASE_OUTPUT 1
-#define BYNASE_BOTH 2
-#define BYNASE_NONE 3
-
-void bynase_init(uint8_t speed);
-void byout(void);
-void byin(void);
-void bynase_write(uint8_t, uint8_t);
-uint8_t bynase_read(uint8_t);
-void bynase_registerPin(uint8_t pinNumber, uint8_t mode);
-void bynase_unregisterPin(uint8_t pinNumber);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif

BIN
optiboot/cores/luminet/cmd.exe.lnk


+ 0 - 72
optiboot/cores/luminet/digitalWriteASM.S

@@ -1,72 +0,0 @@
-#include <avr/io.h>
-
-#define	temp r17
-#define	temptwo r16
-#define pin r24
-#define value r22
-
-;***************************************************************************
-;*
-;* digitalWriteASM
-;* r24 is pin
-;* r22 is value
-;*
-.global digitalWriteASM
-.func digitalWriteASM
-digitalWriteASM:
-	ldi temptwo,0
-calcpin:
-	cpi pin,0
-	brne notPinZero
-	ldi pin,11
-notPinZero:
-	cpi pin,4
-	brlt isPortB
-isPortA:
-	subi pin,4
-	rjmp endcalcpin
-isPortB:
-	ldi temptwo,1
-	ldi temp,3
-	sub temp,pin
-	mov pin,temp
-endcalcpin:
-	nop
-calcmask:
-	ldi temp,1
-	cpi pin,0
-	breq endcalcmask
-shiftLeft:
-	lsl temp
-	dec pin
-	brne shiftLeft
-endcalcmask:
-	cpi temptwo,1
-	brne doitForA
-doitForB:
-	in temptwo, PORTB
-	cpi value,1
-	brne doandb
-	OR temptwo, temp
-	rjmp setb
-doandb:
-	com temp
-	AND temptwo,temp
-setb:
-	sts PORTB, temptwo
-	rjmp enddigitalwrite
-doitForA:
-	in temptwo, PORTA
-	cpi value,1
-	brne doanda
-	OR temptwo, temp
-	rjmp seta
-doanda:
-	com temp
-	AND temptwo,temp
-seta:
-	sts PORTA, temptwo
-enddigitalwrite:
-	ret
-.endfunc
-

+ 0 - 6
optiboot/cores/luminet/fastDigital.c

@@ -1,6 +0,0 @@
-#include "fastDigital.h"
-
-void fastDigitalWrite(uint8_t pin, uint8_t value)
-{
-	digitalWriteASM(pin, value);
-}

+ 0 - 20
optiboot/cores/luminet/fastDigital.h

@@ -1,20 +0,0 @@
-#ifndef _ASSEMBLERTEST_H_
-#define _ASSEMBLERTEST_H_
-
-#include "WProgram.h"
-
-#ifdef __cplusplus
-extern "C"{
-#endif
-
-extern void digitalWriteASM(uint8_t pin, uint8_t value);
-
-void fastDigitalWrite(uint8_t pin, uint8_t value);
-
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-
-#endif /* _ASSEMBLERTEST_H_ */

+ 0 - 152
optiboot/cores/luminet/luminet.h

@@ -1,152 +0,0 @@
-#ifndef _LUMINET_H_
-#define _LUMINET_H_
-
-
-//#define IS_VECTOR_NODE 1
-
-//#define VECTOR_MESSAGE 0x04
-
-#define EEPROM_VECTOR_ADDRESS 228
-
-#include <avr/io.h>
-#include <avr/boot.h>
-#include <avr/pgmspace.h>
-#include <avr/interrupt.h>
-#include <util/delay_basic.h>
-
-
-//define this if you want to see the result of the topologyscan (blinking for each SNEW direction)
-#define SHOW_TOPOLOGY_RESULT 1
-
-#define MAX_PAGENUMBER 87
-
-#define PAYLOAD_FLASH_ADDRESS 0
-
-///////MAGIC KEYS
-#define START 0xA0
-#define RESET 0xA1
-#define DATA 0xB0
-#define RETRANSMISSION 0xB1
-#define END 0xC0
-
-#define RED_ON (PORTA  |= (1 << RED_LED) ) 
-#define RED_ON (PORTA  |= (1 << RED_LED) ) 
-#define GREEN_ON (PORTA  |= (1 << GREEN_LED) )
-#define BLUE_ON (PORTA  |= (1 << BLUE_LED) )
-
-#define RED_OFF (PORTA  &= ~(1 << RED_LED) ) 
-#define GREEN_OFF (PORTA  &= ~(1 << GREEN_LED) )
-#define BLUE_OFF (PORTA  &= ~(1 << BLUE_LED) )
-
-#define RED   (1<<PA4)
-#define GREEN (1<<PA5)
-#define BLUE  (1<<PA6)
-#define WHITE (RED | GREEN | BLUE)
-
-#define RED_LED PA4
-#define GREEN_LED PA5
-#define BLUE_LED PA6
-
-#define RED_ON (PORTA  |= (1 << RED_LED) ) 
-#define RED_ON (PORTA  |= (1 << RED_LED) ) 
-#define GREEN_ON (PORTA  |= (1 << GREEN_LED) )
-#define BLUE_ON (PORTA  |= (1 << BLUE_LED) )
-#define WHITE_ON (PORTA |= WHITE)
-
-#define RED_OFF (PORTA  &= ~(1 << RED_LED) ) 
-#define GREEN_OFF (PORTA  &= ~(1 << GREEN_LED) )
-#define BLUE_OFF (PORTA  &= ~(1 << BLUE_LED) )
-#define WHITE_OFF (PORTA &= ~WHITE)
-
-
-#define WEST 0
-#define EAST 1
-#define NORTH 2
-#define SOUTH 3
-#define DESTINATION_WEST 0
-#define DESTINATION_EAST 1
-#define DESTINATION_NORTH 2
-#define DESTINATION_SOUTH 3
-#define DESTINATION_GREEN 4
-#define DESTINATION_RED 5
-#define DESTINATION_BLUE 6
-
-
-#ifndef BOOTADR
-#define BOOTADR 0x1600
-#endif
-
-#define	LEFT_TXDDR DDRA
-#define	LEFT_TXPORT PORTA
-#define	LEFT_TXPIN PINA
-#define LEFT_TXPINNumber  PA2			
-		
-#define	LEFT_RXDDR  DDRA
-#define	LEFT_RXPORT PORTA
-#define	LEFT_RXPIN  PINA
-#define	LEFT_RXPINNumber PA3			
-
-#define	RIGHT_TXDDR DDRB
-#define	RIGHT_TXPORT PORTB
-#define	RIGHT_TXPIN PINB
-#define RIGHT_TXPINNumber  PB1			
-		
-#define	RIGHT_RXDDR  DDRB
-#define	RIGHT_RXPORT PORTB
-#define	RIGHT_RXPIN  PINB
-#define	RIGHT_RXPINNumber PB0			
-	
-
-#define	UP_TXDDR DDRB
-#define	UP_TXPORT PORTB
-#define	UP_TXPIN PINB
-#define UP_TXPINNumber  PB2			
-		
-#define	UP_RXDDR  DDRA
-#define	UP_RXPORT PORTA
-#define	UP_RXPIN  PINA
-#define	UP_RXPINNumber PA7
-
-#define	DOWN_TXDDR DDRA
-#define	DOWN_TXPORT PORTA
-#define	DOWN_TXPIN PINA
-#define DOWN_TXPINNumber  PA1			
-		
-#define	DOWN_RXDDR  DDRA
-#define	DOWN_RXPORT PORTA
-#define	DOWN_RXPIN  PINA
-#define	DOWN_RXPINNumber PA0			
-
-#define NORTH_TX (1<<PB2)
-#define NORTH_RX (1<<PA7)
-#define EAST_TX  (1<<PB1)
-#define EAST_RX  (1<<PB0)
-#define SOUTH_TX (1<<PA1)
-#define SOUTH_RX (1<<PA0)
-#define WEST_TX  (1<<PA2)
-#define WEST_RX  (1<<PA3)
-
-#define NORTH_LOW (PORTB &= ~NORTH_TX)
-#define  EAST_LOW (PORTB &= ~EAST_TX)
-#define SOUTH_LOW (PORTA &= ~SOUTH_TX)
-#define  WEST_LOW (PORTA &= ~WEST_TX)
-
-#define NORTH_HIGH (PORTB |= NORTH_TX)
-#define  EAST_HIGH (PORTB |= EAST_TX)
-#define SOUTH_HIGH (PORTA |= SOUTH_TX)
-#define  WEST_HIGH (PORTA |= WEST_TX)
-
-#define GET_NORTH (PINA & NORTH_RX)
-#define GET_EAST  (PINB & EAST_RX)
-#define GET_SOUTH (PINA & SOUTH_RX)
-#define GET_WEST  (PINA & WEST_RX)
-
-#define NORTH_PULLUP (PORTA |= NORTH_RX)
-#define EAST_PULLUP (PORTB |= EAST_RX)
-#define SOUTH_PULLUP (PORTA |= SOUTH_RX)
-#define WEST_PULLUP (PORTA |= WEST_RX)
-
-
-
-#endif
-

+ 0 - 39
optiboot/cores/luminet/main.cxx

@@ -1,39 +0,0 @@
-//void (*startBootloader)( void ) = (void(*)(void))(0x1600);
-
-
-
-
-int main(void)
-{
-	//startBootloader();
-	
-	
-	mainconnections = 0;
-	topology_scan(&mainconnections);//luminet needs to perform topology scan at the beginning of every payload
-	
-	//cli();
-	//CLKPR = (1 << CLKPCE);
-	//CLKPR = 0x00;//8MHz
-	
-		if(mainconnections >= 16)
-		{
-			//startBootloader();
-				__asm__ __volatile
-			 (
-			      "ldi r30,0x00"  "\n\t"
-			      "ldi r31,0x0b"  "\n\t"
-			      "icall" "\n\t"
-			 );
-		}
-	
-		
-	init();
-
-	setup();
-    
-	for (;;)
-		loop();
-        
-	return 0;
-}
-

+ 0 - 154
optiboot/cores/luminet/pins_arduino.c

@@ -1,154 +0,0 @@
-/*
-  pins_arduino.c - pin definitions for the Arduino board
-  Part of Arduino / Wiring Lite
-
-  Copyright (c) 2005 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: pins_arduino.c 522 2008-11-01 22:06:13Z mellis $
-*/
-
-#include <avr/io.h>
-#include "wiring_private.h"
-#include "pins_arduino.h"
-
-// On the Arduino board, digital pins are also used
-// for the analog output (software PWM).  Analog input
-// pins are a separate set.
-
-
-
-
-
-// Luminet board
-//                *   *
-//                D0  D1
-//						VCC PA7 PB2 GND
-//             |   |   |   |
-//             |   |   |   |
-//    VCC---                   ---VCC
-//D7  PA3---                   ---PB1  D2
-//D6  PA2---                   ---PB0  D3
-//    GND---                   ---GND
-//             |   |   |   |
-//             |   |   |   |
-//            VCC PA1 PA0 GND
-//                D5  D4
-//
-// red   led:   PA4 (d8) -- pin available if jumper is not connected
-// green led: * PA5 (d9)  -- pin available if jumper is not connected
-// blue  led: * PA6 (d10)  -- pin available if jumper is not connected
-// reset:       PB3 (d11)
-//
-// * indicates the PWM pins on the attiny84
-
-#define PA 2
-#define PB 3
-
-
-// these arrays map port names (e.g. port B) to the
-// appropriate addresses for various functions (e.g. reading
-// and writing)
-const uint8_t PROGMEM port_to_mode_PGM[] = {
-	NOT_A_PORT,
-	NOT_A_PORT,
-	&DDRA,
-	&DDRB,
-};
-
-const uint8_t PROGMEM port_to_output_PGM[] = {
-	NOT_A_PORT,
-	NOT_A_PORT,
-	&PORTA,
-	&PORTB,
-};
-
-const uint8_t PROGMEM port_to_input_PGM[] = {
-	NOT_A_PORT,
-	NOT_A_PORT,
-	&PINA,
-	&PINB,
-};
-
-const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
-	PA, /* 0 */
-	PB,
-	PB,
-	PB,
-	PA,
-	PA,
-	PA,
-	PA,
-	PA, /* 8 */
-	PA,
-	PA,
-	PB,
-	PA,
-	PA,
-	PA, /* 14 */
-	PA,
-	PA,
-	PA,
-	PA,
-	PA,
-};
-
-const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = {
-	_BV(7), /* 0, port D */
-	_BV(2),
-	_BV(1),
-	_BV(0),
-	_BV(0),
-	_BV(1),
-	_BV(2),
-	_BV(3),
-	_BV(4), /* 8 */
-	_BV(5),
-	_BV(6),
-	_BV(3),
-	_BV(4),
-	_BV(6),
-	_BV(0), /* 14 */
-	_BV(1),
-	_BV(2),
-	_BV(3),
-	_BV(4),
-	_BV(5),
-};
-
-const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {
-	NOT_ON_TIMER, /* 0 - port D */
-	NOT_ON_TIMER,
-	NOT_ON_TIMER,
-	NOT_ON_TIMER,
-	NOT_ON_TIMER,
-	NOT_ON_TIMER,
-	NOT_ON_TIMER,
-	NOT_ON_TIMER,
-	NOT_ON_TIMER, /* 8 - port B */
-	NOT_ON_TIMER,
-	NOT_ON_TIMER,
-	NOT_ON_TIMER,
-	NOT_ON_TIMER,
-	NOT_ON_TIMER,
-	NOT_ON_TIMER, /* 14 - port C */
-	NOT_ON_TIMER,
-	NOT_ON_TIMER,
-	NOT_ON_TIMER,
-	NOT_ON_TIMER,
-};
-

+ 0 - 65
optiboot/cores/luminet/pins_arduino.h

@@ -1,65 +0,0 @@
-/*
-  pins_arduino.h - Pin definition functions for Arduino
-  Part of Arduino - http://www.arduino.cc/
-
-  Copyright (c) 2007 David A. Mellis
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General
-  Public License along with this library; if not, write to the
-  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
-  Boston, MA  02111-1307  USA
-
-  $Id: wiring.h 249 2007-02-03 16:52:51Z mellis $
-*/
-
-#ifndef Pins_Arduino_h
-#define Pins_Arduino_h
-
-#include <avr/pgmspace.h>
-
-#define NOT_A_PIN 0
-#define NOT_A_PORT 0
-
-#define NOT_ON_TIMER 0
-#define TIMER0A 1
-#define TIMER0B 2
-#define TIMER1A 3
-#define TIMER1B 4
-#define TIMER2  5
-#define TIMER2A 6
-#define TIMER2B 7
-
-extern const uint8_t PROGMEM port_to_mode_PGM[];
-extern const uint8_t PROGMEM port_to_input_PGM[];
-extern const uint8_t PROGMEM port_to_output_PGM[];
-
-extern const uint8_t PROGMEM digital_pin_to_port_PGM[];
-extern const uint8_t PROGMEM digital_pin_to_bit_PGM[];
-extern const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[];
-
-extern const uint8_t PROGMEM digital_pin_to_timer_PGM[];
-
-// Get the bit location within the hardware port of the given virtual pin.
-// This comes from the pins_*.c file for the active board configuration.
-// 
-// These perform slightly better as macros compared to inline functions
-//
-#define digitalPinToPort(P) ( pgm_read_byte( digital_pin_to_port_PGM + (P) ) )
-#define digitalPinToBitMask(P) ( pgm_read_byte( digital_pin_to_bit_mask_PGM + (P) ) )
-#define digitalPinToTimer(P) ( pgm_read_byte( digital_pin_to_timer_PGM + (P) ) )
-#define analogInPinToBit(P) (P)
-#define portOutputRegister(P) ( (volatile uint8_t *)( pgm_read_byte( port_to_output_PGM + (P))) )
-#define portInputRegister(P) ( (volatile uint8_t *)( pgm_read_byte( port_to_input_PGM + (P))) )
-#define portModeRegister(P) ( (volatile uint8_t *)( pgm_read_byte( port_to_mode_PGM + (P))) )
-
-#endif

+ 0 - 268
optiboot/cores/luminet/topology.c

@@ -1,268 +0,0 @@
-#include "topology.h"
-
-//#define BOOTADR 0x1600
-
-
-#ifndef EEPROM_VECTOR_ADDRESS
-#define EEPROM_VECTOR_ADDRESS 228
-#endif
-
-//void (*startBootloader)( void ) = (void *)BOOTADR;  // pointer to the bootloader start address
-
-//performs a topology scan and vector detection 
-//returns: connections variable: SNEWSNEW - first nibble is vector path, second nibble is connection indicator
-//this function only returns connections if no vector node is present
-//otherwise it loops forever, sending the vector_message
-void topology_scan(uint8_t *connections)
-{
-
-	uint16_t z;
-	//uint8_t connections;//bit7..0: SNEWSNEW - first nibble says: vector present, second says: normal neighbour present
-	
-	uint8_t c;
-	uint8_t d;
-	
-	uint8_t r;
-	
-	uint8_t destination;
-	
-	uint8_t address = EEPROM_VECTOR_ADDRESS;
-	
-	void (*ptr_putc) (uint8_t data);
-	uint8_t (*ptr_getc) (void);
-	
-	//CLKPR = 0x80;//set CLKPCE bit -> next step: set prescaler
-	//CLKPR = 0x02;//prescaler=2 --> 2MHz
-		
-	*connections = 0;
-
-	//activate outputs, rise pull-ups. set outputs to high level
-	DDRA = 0x76;
-	PORTA = 0x89;
-	DDRB= 0x06;
-	PORTB = 0x01;
-	
-	//OUTPUTS TO LOW
-	PORTA &= (uint8_t)~(0x06);
-	PORTB &= (uint8_t)~(0x06);
-	
-	
-	//say that the cable is ok, before we have a burning man...
-	RED_ON;
-	
-	
-  
-
-		
-		_delay_loop_2(62510); // 250ms
-   
-   
-   for(z=0;z<250;z++)//check for connections
-   {
-		if(! (PINA & (1<<PA3) ) )
-		{	
-			*connections |= (1 << WEST);
-		}
-		
-		if(! (PINA & (1<<PA7) ) )
-		{	
-			*connections |= (1 << NORTH);
-		}
-		
-		if(! (PINA & (1<<PA0) ) )
-		{	
-			*connections |= (1 << SOUTH);
-		}
-		
-		if(! (PINB & (1<<PB0) ) )
-		{	
-			*connections |= (1 << EAST);
-		}
-		_delay_loop_2(250); //1ms
-	}//loop: 250*1ms = 250ms
-
-   _delay_loop_2(62510); // 250ms
-	   
-	//OUTPUTS NOW HAVE BEEN LOW FOR 3*250ms = 750ms
-		
-		
-		#ifdef IS_VECTOR_NODE
-		//OUTPUTS TO LOW
-		PORTA &= (uint8_t)~(0x06);
-		PORTB &= (uint8_t)~(0x06);
-	#else 
-		//OUTPUTS HIGH
-		PORTA |= (0x06);
-		PORTB |= (0x06);
-		
-	#endif
-
-	   _delay_loop_2(62510); // 250ms
-	   _delay_loop_2(62510); // 250ms
-	   
-	   
-	   
-	#ifndef IS_VECTOR_NODE   
-	   	
-	   	for(z=0; z<500; z++)
-	   {
-		
-			if(! (PINA & (1<<PA3) ) )
-			{	
-				if(*connections & (1 << WEST) )
-				{
-					//REMAINING OUTPUTS TO LOW
-					PORTA &= (uint8_t)~(0x02);
-					PORTB &= (uint8_t)~(0x06);				
-					*connections |= (16 << WEST);
-				}
-			}
-			if(! (PINA & (1<<PA7) ) )
-			{	
-				if(*connections & (1 << NORTH) )
-				{			
-					//REMAINING OUTPUTS TO LOW
-					PORTA &= (uint8_t)~(0x06);
-					PORTB &= (uint8_t)~(0x02);
-					*connections |= (16 << NORTH);
-				}
-			}
-			if(! (PINA & (1<<PA0) ) )
-			{	
-				if(*connections & (1 << SOUTH) )
-				{				
-					//REMAINING OUTPUTS TO LOW
-					PORTA &= (uint8_t)~(0x04);
-					PORTB &= (uint8_t)~(0x06);					
-					*connections |= (16 << SOUTH);
-				}
-			}
-			if(! (PINB & (1<<PB0) ) )
-			{	
-				if(*connections & (1 << EAST) )
-				{							
-					//REMAINING OUTPUTS TO LOW
-					PORTA &= (uint8_t)~(0x06);
-					PORTB &= (uint8_t)~(0x04);
-					*connections |= (16 << EAST);
-				}
-			}
-		
-			_delay_loop_2(250); // 1ms
-		}
-		
-		
-		//only one vector path allowed
-		if(*connections & (16 << WEST) )
-		{
-			*connections &= (uint8_t)~(16 << SOUTH);
-			*connections &= (uint8_t)~(16 << NORTH);
-			*connections &= (uint8_t)~(16 << EAST);
-		}
-		else if(*connections & (16 << NORTH) )
-		{
-			*connections &= (uint8_t)~(16 << SOUTH);
-			*connections &= (uint8_t)~(16 << WEST);
-			*connections &= (uint8_t)~(16 << EAST);
-		}
-		else if(*connections & (16 << SOUTH) )
-		{
-			*connections &= (uint8_t)~(16 << NORTH);
-			*connections &= (uint8_t)~(16 << WEST);
-			*connections &= (uint8_t)~(16 << EAST);
-		}
-		else if(*connections & (16 << EAST) )
-		{
-			*connections &= (uint8_t)~(16 << SOUTH);
-			*connections &= (uint8_t)~(16 << WEST);
-			*connections &= (uint8_t)~(16 << NORTH);
-		}
-	   	
-		#else
-	   //Vector node does not loop so we have to add the 500ms loop duration here
-	   _delay_loop_2(62510); // 250ms
-	   _delay_loop_2(62510); // 250ms
-
-	#endif
-	
-	RED_OFF;
-	GREEN_OFF;
-	BLUE_OFF;
-
-		
-	   _delay_loop_2(62510); // 250ms
-	   _delay_loop_2(62510); // 250ms
-
-	//tx lines now have been HIGH (normal node) / LOW (vector node) for 1500ms
-
-		//tx lines high again
-		PORTA |= (0x06);
-		PORTB |= (0x06);
-			
-		_delay_loop_2(62510); // 250ms
-			
-		
-#ifdef SHOW_TOPOLOGY_RESULT
-		//show the result of the topology scan by blinking LEDs
-		for(z=0;z<4;z++)
-		{
-			if(*connections & (16 << z) )
-			{
-				BLUE_ON;//a connection to a node on the vector path
-				
-			}
-			else if(*connections & (1 << z) )
-			{
-				GREEN_ON;//a simple connection to another node
-			}
-			else
-			{
-				RED_ON;//no connection in this direction
-			}
-			
-			_delay_loop_2(62510); // 250ms
-			_delay_loop_2(62510); // 250ms
-			RED_OFF;
-			GREEN_OFF;
-			BLUE_OFF;
-		   _delay_loop_2(62510); // 250ms
-		   _delay_loop_2(62510); // 250ms
-		   	
-		}
-#endif
-	
-	//function only returns connections if no vector node is present
-	//otherwise it starts the bootloader
-	
-
-	eeprom_write_byte(address, *connections);//write vector message to eeprom
-	_delay_loop_2(400);
-	
-	if(*connections >=16)
-	{
-		cli();
-		//startBootloader();
-		//asm("call 0x1600");
-	}
-		
-
-
-
-}
-
-//If a vector is present, it sends a message to the vector path. This message is a single byte
-//the byte is stored in the eeprom at address 228 and returned by this function
-/*
-uint8_t topology_getVectorMessage(void)
-{
-	uint8_t *address = EEPROM_VECTOR_ADDRESS; //adress to read from
-	uint8_t data;
-	data = eeprom_read_byte(address);
-	return data;
-	
-	
-	
-
-
-}
-*/

+ 0 - 26
optiboot/cores/luminet/topology.h

@@ -1,26 +0,0 @@
-#ifndef _TOPOLOGY_H
-#define _TOPOLOGY_H
-
-#ifdef __cplusplus
-extern "C"{
-#endif
-
-
-#include "luminet.h"
-
-
-//performs a topology scan and vector detection 
-//returns: connections variable: SNEWSNEW - first nibble is vector path, second nibble is connection indicator
-//example: 01000001 means: a vector path is in the north and so I have two connections: one in the West and one (the vector path connection) in the North
-void topology_scan(uint8_t*);
-
-//If a vector is present, it sends a message to the vector path. This message is a single byte
-//the byte is stored in the eeprom at address 228 and returned by this function
-//uint8_t topology_getVectorMessage(void);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif
-

+ 0 - 224
optiboot/cores/luminet/wiring.c

@@ -1,224 +0,0 @@
-/*
-  wiring.c - Partial implementation of the Wiring API for the ATmega8.
-  Part of Arduino - http://www.arduino.cc/
-
-  Copyright (c) 2005-2006 David A. Mellis
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General
-  Public License along with this library; if not, write to the
-  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
-  Boston, MA  02111-1307  USA
-
-  $Id: wiring.c 539 2008-12-23 00:17:14Z mellis $
-*/
-
-#include "wiring_private.h"
-
-volatile unsigned long timer0_overflow_count = 0;
-volatile unsigned long timer0_clock_cycles = 0;
-volatile unsigned long timer0_millis = 0;
-
-//SIGNAL(TIM0_OVF_vect)
-ISR(TIM0_OVF_vect)
-{
-	timer0_overflow_count++;
-	// timer 0 prescale factor is 64 and the timer overflows at 256
-	timer0_clock_cycles += 64UL * 256UL;
-	while (timer0_clock_cycles > clockCyclesPerMicrosecond() * 1000UL) {
-		timer0_clock_cycles -= clockCyclesPerMicrosecond() * 1000UL;
-		timer0_millis++;
-	}
-}
-
-unsigned long millis()
-{
-	unsigned long m;
-	uint8_t oldSREG = SREG;
-	
-	// disable interrupts while we read timer0_millis or we might get an
-	// inconsistent value (e.g. in the middle of the timer0_millis++)
-	cli();
-	m = timer0_millis;
-	SREG = oldSREG;
-	
-	return m;
-}
-
-unsigned long micros() {
-	unsigned long m, t;
-	uint8_t oldSREG = SREG;
-	
-	cli();	
-	t = TCNT0;
-  
-#ifdef TIFR0
-	if ((TIFR0 & _BV(TOV0)) && (t == 0))
-		t = 256;
-#else
-	if ((TIFR & _BV(TOV0)) && (t == 0))
-		t = 256;
-#endif
-
-	m = timer0_overflow_count;
-	SREG = oldSREG;
-	
-	return ((m << 8) + t) * (64 / clockCyclesPerMicrosecond());
-}
-
-void delay(unsigned long ms)
-{
-	unsigned long start = millis();
-	
-	while (millis() - start <= ms)
-		;
-}
-
-/* Delay for the given number of microseconds.  Assumes a 8 or 16 MHz clock. 
- * Disables interrupts, which will disrupt the millis() function if used
- * too frequently. */
-void delayMicroseconds(unsigned int us)
-{
-	uint8_t oldSREG;
-
-	// calling avrlib's delay_us() function with low values (e.g. 1 or
-	// 2 microseconds) gives delays longer than desired.
-	//delay_us(us);
-
-#if F_CPU >= 16000000L
-	// for the 16 MHz clock on most Arduino boards
-
-	// for a one-microsecond delay, simply return.  the overhead
-	// of the function call yields a delay of approximately 1 1/8 us.
-	if (--us == 0)
-		return;
-
-	// the following loop takes a quarter of a microsecond (4 cycles)
-	// per iteration, so execute it four times for each microsecond of
-	// delay requested.
-	us <<= 2;
-
-	// account for the time taken in the preceeding commands.
-	us -= 2;
-#else
-	// for the 8 MHz internal clock on the ATmega168
-
-	// for a one- or two-microsecond delay, simply return.  the overhead of
-	// the function calls takes more than two microseconds.  can't just
-	// subtract two, since us is unsigned; we'd overflow.
-	if (--us == 0)
-		return;
-	if (--us == 0)
-		return;
-
-	// the following loop takes half of a microsecond (4 cycles)
-	// per iteration, so execute it twice for each microsecond of
-	// delay requested.
-	us <<= 1;
-    
-	// partially compensate for the time taken by the preceeding commands.
-	// we can't subtract any more than this or we'd overflow w/ small delays.
-	us--;
-#endif
-
-	// disable interrupts, otherwise the timer 0 overflow interrupt that
-	// tracks milliseconds will make us delay longer than we want.
-	oldSREG = SREG;
-	cli();
-
-	// busy wait
-	__asm__ __volatile__ (
-		"1: sbiw %0,1" "\n\t" // 2 cycles
-		"brne 1b" : "=w" (us) : "0" (us) // 2 cycles
-	);
-
-	// reenable interrupts.
-	SREG = oldSREG;
-}
-
-void init()
-{
-	// this needs to be called before setup() or some functions won't
-	// work there
-	sei();
-	
-	// on the ATmega168, timer 0 is also used for fast hardware pwm
-	// (using phase-correct PWM would mean that timer 0 overflowed half as often
-	// resulting in different millis() behavior on the ATmega8 and ATmega168)
-#if !defined(__AVR_ATmega8__)
-	sbi(TCCR0A, WGM01);
-	sbi(TCCR0A, WGM00);
-#endif  
-	// set timer 0 prescale factor to 64
-#if defined(__AVR_ATmega8__)
-	sbi(TCCR0, CS01);
-	sbi(TCCR0, CS00);
-#else
-	sbi(TCCR0B, CS01);
-	sbi(TCCR0B, CS00);
-#endif
-	// enable timer 0 overflow interrupt
-#if defined(__AVR_ATmega8__)
-	sbi(TIMSK, TOIE0);
-#else
-	sbi(TIMSK0, TOIE0);
-#endif
-
-	// timers 1 and 2 are used for phase-correct hardware pwm
-	// this is better for motors as it ensures an even waveform
-	// note, however, that fast pwm mode can achieve a frequency of up
-	// 8 MHz (with a 16 MHz clock) at 50% duty cycle
-
-	// set timer 1 prescale factor to 64
-	//sbi(TCCR1B, CS11);
-	//sbi(TCCR1B, CS10);
-	// put timer 1 in 8-bit phase correct pwm mode
-	//sbi(TCCR1A, WGM10);
-
-	// set timer 2 prescale factor to 64
-	/*
-#if defined(__AVR_ATmega8__)
-	sbi(TCCR2, CS22);
-#else
-	sbi(TCCR2B, CS22);
-#endif
-
-	// configure timer 2 for phase correct pwm (8-bit)
-#if defined(__AVR_ATmega8__)
-	sbi(TCCR2, WGM20);
-#else
-	sbi(TCCR2A, WGM20);
-#endif
-*/
-
-	// set a2d prescale factor to 128
-	// 16 MHz / 128 = 125 KHz, inside the desired 50-200 KHz range.
-	// XXX: this will not work properly for other clock speeds, and
-	// this code should use F_CPU to determine the prescale factor.
-	//sbi(ADCSRA, ADPS2);
-	//luminet runs at 1MHz -> prescaler 8 for 125kHz
-	ADCSRA = ( (1 << ADPS1) | (1 << ADPS0) );
-
-	// enable a2d conversions
-	ADCSRA |= (1 << ADEN);
-
-	// 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__)
-	UCSRB = 0;
-#else
-	UCSR0B = 0;
-#endif
-*/
-}

+ 0 - 134
optiboot/cores/luminet/wiring.h

@@ -1,134 +0,0 @@
-/*
-  wiring.h - Partial implementation of the Wiring API for the ATmega8.
-  Part of Arduino - http://www.arduino.cc/
-
-  Copyright (c) 2005-2006 David A. Mellis
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General
-  Public License along with this library; if not, write to the
-  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
-  Boston, MA  02111-1307  USA
-
-  $Id: wiring.h 534 2008-11-26 14:14:59Z mellis $
-*/
-
-#ifndef Wiring_h
-#define Wiring_h
-
-#include <avr/io.h>
-#include "binary.h"
-
-#ifdef __cplusplus
-extern "C"{
-#endif
-
-#define HIGH 0x1
-#define LOW  0x0
-
-#define INPUT 0x0
-#define OUTPUT 0x1
-
-#define true 0x1
-#define false 0x0
-
-#define PI 3.14159265
-#define HALF_PI 1.57079
-#define TWO_PI 6.283185
-#define DEG_TO_RAD 0.01745329
-#define RAD_TO_DEG 57.2957786
-
-#define SERIAL  0x0
-#define DISPLAY 0x1
-
-#define LSBFIRST 0
-#define MSBFIRST 1
-
-#define CHANGE 1
-#define FALLING 2
-#define RISING 3
-
-#define INTERNAL 3
-#define DEFAULT 1
-#define EXTERNAL 0
-
-// undefine stdlib's abs if encountered
-#ifdef abs
-#undef abs
-#endif
-
-#define min(a,b) ((a)<(b)?(a):(b))
-#define max(a,b) ((a)>(b)?(a):(b))
-#define abs(x) ((x)>0?(x):-(x))
-#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
-#define round(x)     ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
-#define radians(deg) ((deg)*DEG_TO_RAD)
-#define degrees(rad) ((rad)*RAD_TO_DEG)
-#define sq(x) ((x)*(x))
-
-#define interrupts() sei()
-#define noInterrupts() cli()
-
-#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L )
-#define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() )
-#define microsecondsToClockCycles(a) ( (a) * clockCyclesPerMicrosecond() )
-
-#define lowByte(w) ((w) & 0xff)
-#define highByte(w) ((w) >> 8)
-
-#define bitRead(value, bit) (((value) >> (bit)) & 0x01)
-#define bitSet(value, bit) ((value) |= (1UL << (bit)))
-#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
-#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))
-
-typedef unsigned int word;
-
-#define bit(b) (1 << (b))
-
-typedef uint8_t boolean;
-typedef uint8_t byte;
-
-void init(void);
-
-void pinMode(uint8_t, uint8_t);
-void digitalWrite(uint8_t, uint8_t);
-int digitalRead(uint8_t);
-int analogRead(uint8_t);
-void analogReference(uint8_t mode);
-void analogWrite(uint8_t, int);
-
-void beginSerial(long);
-void serialWrite(unsigned char);
-int serialAvailable(void);
-int serialRead(void);
-void serialFlush(void);
-void selectDirectionSerial(uint8_t);
-
-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 attachInterrupt(uint8_t, void (*)(void), int mode);
-void detachInterrupt(uint8_t);
-
-void setup(void);
-void loop(void);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif

+ 0 - 184
optiboot/cores/luminet/wiring_analog.c

@@ -1,184 +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 "bynase.h"
-
-#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;
-}
-
-/*
-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;
-}
-*/
-
-
-int analogRead(uint8_t pin)
-{
-	uint8_t low, high;
-	
-	
-	ADMUX = pin;
-	
-	if(pin == 0b100010)//temperature sensor
-	{
-		ADMUX |= 0x80; //enable 1,1V reference voltage
-	}
-	
-	// without a delay, we seem to read from the wrong channel
-	//_delay_loop_2(10000);
-
-	// start the first conversion
-	ADCSRA |= (1 << ADSC);
-
-	// ADSC is cleared when the conversion finishes
-	while (ADCSRA & (1 << ADSC))
-	{
-		asm volatile("nop");
-	}
-
-	// 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;
-	
-	//the first conversion should not be used...
-	
-	
-	/*
-	// start the second 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;
-	*/
-	
-	
-	
-	if(pin == 0b100010)//temperature sensor
-	{
-		ADMUX &= (uint8_t)~(0x80); //use VCC as reference voltage
-	}
-
-	// 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 > 255)
-	{
-		val = _map(val, 0, 1023, 0, 100);
-	}
-	else
-	{
-  	val = _map(val, 0, 255, 0, 100);
-  }
-  */
-  
-	//luminet uses bynase for analog output. pwm is not used!
-	bynase_init(200);
-	bynase_registerPin(pin, BYNASE_OUTPUT);
-	bynase_write(pin, val);
-	
-	
-	/*
-	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;
-	} 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 (val < 128)
-		digitalWrite(pin, LOW);
-	else
-		digitalWrite(pin, HIGH);
-	*/
-	
-	
-	
-
-
-	
-		
-}

+ 0 - 93
optiboot/cores/luminet/wiring_digital.c

@@ -1,93 +0,0 @@
-/*
-  wiring_digital.c - digital input and output functions
-  Part of Arduino - http://www.arduino.cc/
-
-  Copyright (c) 2005-2006 David A. Mellis
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General
-  Public License along with this library; if not, write to the
-  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
-  Boston, MA  02111-1307  USA
-
-  $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $
-*/
-
-#include "wiring_private.h"
-#include "pins_arduino.h"
-
-void pinMode(uint8_t pin, uint8_t mode)
-{
-	uint8_t bit = digitalPinToBitMask(pin);
-	uint8_t port = digitalPinToPort(pin);
-	volatile uint8_t *reg;
-
-	if (port == NOT_A_PIN) return;
-
-	// JWS: can I let the optimizer do this?
-	reg = portModeRegister(port);
-
-	if (mode == INPUT) *reg &= (uint8_t)~bit;
-	else *reg |= bit;
-}
-
-// Forcing this inline keeps the callers from having to push their own stuff
-// on the stack. It is a good performance win and only takes 1 more byte per
-// user than calling. (It will take more bytes on the 168.)
-//
-// But shouldn't this be moved into pinMode? Seems silly to check and do on
-// each digitalread or write.
-//
-static inline void turnOffPWM(uint8_t timer) __attribute__ ((always_inline));
-static inline void turnOffPWM(uint8_t timer)
-{
-	//if (timer == TIMER1A) cbi(TCCR1A, COM1A1);//timer1 used for bynase on luminet
-	//if (timer == TIMER1B) cbi(TCCR1A, COM1B1);//timer1 used for bynase on luminet
-	if (timer == TIMER0A) cbi(TCCR0A, COM0A1);
-	if (timer == TIMER0B) cbi(TCCR0A, COM0B1);
-	
-}
-
-void digitalWrite(uint8_t pin, uint8_t val)
-{
-	uint8_t timer = digitalPinToTimer(pin);
-	uint8_t bit = digitalPinToBitMask(pin);
-	uint8_t port = digitalPinToPort(pin);
-	volatile uint8_t *out;
-
-	if (port == NOT_A_PIN) return;
-
-	// If the pin that support PWM output, we need to turn it off
-	// before doing a digital write.
-	if (timer != NOT_ON_TIMER) turnOffPWM(timer);
-
-	out = portOutputRegister(port);
-
-	if (val == LOW) *out &= (uint8_t)~bit;
-	else *out |= bit;
-}
-
-int digitalRead(uint8_t pin)
-{
-	uint8_t timer = digitalPinToTimer(pin);
-	uint8_t bit = digitalPinToBitMask(pin);
-	uint8_t port = digitalPinToPort(pin);
-
-	if (port == NOT_A_PIN) return LOW;
-
-	// If the pin that support PWM output, we need to turn it off
-	// before getting a digital reading.
-	if (timer != NOT_ON_TIMER) turnOffPWM(timer);
-
-	if (*portInputRegister(port) & bit) return HIGH;
-	return LOW;
-}

+ 0 - 58
optiboot/cores/luminet/wiring_private.h

@@ -1,58 +0,0 @@
-/*
-  wiring_private.h - Internal header file.
-  Part of Arduino - http://www.arduino.cc/
-
-  Copyright (c) 2005-2006 David A. Mellis
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General
-  Public License along with this library; if not, write to the
-  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
-  Boston, MA  02111-1307  USA
-
-  $Id: wiring.h 239 2007-01-12 17:58:39Z mellis $
-*/
-
-#ifndef WiringPrivate_h
-#define WiringPrivate_h
-
-#include <avr/io.h>
-#include <avr/interrupt.h>
-#include <avr/delay.h>
-#include <stdio.h>
-#include <stdarg.h>
-
-#include "wiring.h"
-
-#ifdef __cplusplus
-extern "C"{
-#endif
-
-#ifndef cbi
-#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
-#endif
-#ifndef sbi
-#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
-#endif
-
-#define EXTERNAL_INT_0 0
-#define EXTERNAL_INT_1 1
-
-#define EXTERNAL_NUM_INTERRUPTS 2
-
-typedef void (*voidFuncPtr)(void);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif

+ 0 - 66
optiboot/cores/luminet/wiring_pulse.c

@@ -1,66 +0,0 @@
-/*
-  wiring_pulse.c - pulseIn() function
-  Part of Arduino - http://www.arduino.cc/
-
-  Copyright (c) 2005-2006 David A. Mellis
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General
-  Public License along with this library; if not, write to the
-  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
-  Boston, MA  02111-1307  USA
-
-  $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $
-*/
-
-#include "wiring_private.h"
-#include "pins_arduino.h"
-
-/* Measures the length (in microseconds) of a pulse on the pin; state is HIGH
- * or LOW, the type of pulse to measure.  Works on pulses from 2-3 microseconds
- * to 3 minutes in length, but must be called at least a few dozen microseconds
- * before the start of the pulse. */
-unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout)
-{
-	// cache the port and bit of the pin in order to speed up the
-	// pulse width measuring loop and achieve finer resolution.  calling
-	// digitalRead() instead yields much coarser resolution.
-	uint8_t bit = digitalPinToBitMask(pin);
-	uint8_t port = digitalPinToPort(pin);
-	uint8_t stateMask = (state ? bit : 0);
-	unsigned long width = 0; // keep initialization out of time critical area
-	
-	// convert the timeout from microseconds to a number of times through
-	// the initial loop; it takes 16 clock cycles per iteration.
-	unsigned long numloops = 0;
-	unsigned long maxloops = microsecondsToClockCycles(timeout) / 16;
-	
-	// wait for any previous pulse to end
-	while ((*portInputRegister(port) & bit) == stateMask)
-		if (numloops++ == maxloops)
-			return 0;
-	
-	// wait for the pulse to start
-	while ((*portInputRegister(port) & bit) != stateMask)
-		if (numloops++ == maxloops)
-			return 0;
-	
-	// wait for the pulse to stop
-	while ((*portInputRegister(port) & bit) == stateMask)
-		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
-	// and the start of the loop. There will be some error introduced by
-	// the interrupt handlers.
-	return clockCyclesToMicroseconds(width * 10 + 16); 
-}

+ 0 - 135
optiboot/cores/luminet/wiring_serial.c

@@ -1,135 +0,0 @@
-/*
-  wiring_serial.c - serial functions.
-  Part of Arduino - http://www.arduino.cc/
-
-  Copyright (c) 2005-2006 David A. Mellis
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General
-  Public License along with this library; if not, write to the
-  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
-  Boston, MA  02111-1307  USA
-
-  $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $
-*/
-
-#include "COM.h"
-#include "wiring_private.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//NOT SUPPORTED
-
-//unsigned char rx_buffer[RX_BUFFER_SIZE];//NOT SUPPORTED
-
-//int rx_buffer_head = 0;//NOT SUPPORTED
-//int rx_buffer_tail = 0;//NOT SUPPORTED
-
-///////////////////////////////////////////////////////////////////
-/// Luminet does not support hardware serial
-///////////////////////////////////////////////////////////////////
-
-	void (*ptr_putc) (uint8_t data);
-	uint8_t (*ptr_getc) (void);
-
-
-void beginSerial(long baud)
-{
- //baud NOT SUPPORTED... always 9600baud at 1MHz
- ptr_putc = LEFT_putc;
- ptr_getc = LEFT_getc;
- COM_init();
-}
-
-void selectDirectionSerial(uint8_t direction)
-{
-	if(direction == WEST)
-	{
-		ptr_putc = LEFT_putc;
- 		ptr_getc = LEFT_getc;
-	}
-	else if(direction == EAST)
-	{
-		ptr_putc = RIGHT_putc;
- 		ptr_getc = RIGHT_getc;
-	}
-	else if(direction == NORTH)
-	{
-		ptr_putc = UP_putc;
- 		ptr_getc = UP_getc;
-	}
-	else if(direction == SOUTH)
-	{
-		ptr_putc = DOWN_putc;
- 		ptr_getc = DOWN_getc;
-	}
-	
-}
-
-void serialWrite(unsigned char c)
-{
-	//NOT SUPPORTED
-	ptr_putc(c);
-}
-
-int serialAvailable()
-{
-	//NOT SUPPORTED
-	return 1;
-}
-
-int serialRead()
-{
-	//NOT SUPPORTED
-	return ptr_getc();
-}
-
-void serialFlush()
-{
-	// don't reverse this or there may be problems if the RX interrupt
-	// occurs after reading the value of rx_buffer_head but before writing
-	// the value to rx_buffer_tail; the previous value of rx_buffer_head
-	// may be written to rx_buffer_tail, making it appear as if the buffer
-	// were full, not empty.
-	//rx_buffer_head = rx_buffer_tail;
-}
-
-/*
-//NOT SUPPORTED
-
-#if defined(__AVR_ATmega8__)
-SIGNAL(SIG_UART_RECV)
-#else
-SIGNAL(USART_RX_vect)
-#endif
-{
-#if defined(__AVR_ATmega8__)
-	unsigned char c = UDR;
-#else
-	unsigned char c = UDR0;
-#endif
-
-	int i = (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
-	// current location of the tail), we're about to overflow the buffer
-	// and so we don't write the character or advance the head.
-	if (i != rx_buffer_tail) {
-		rx_buffer[rx_buffer_head] = c;
-		rx_buffer_head = i;
-	}
-}
-*/

+ 0 - 40
optiboot/cores/luminet/wiring_shift.c

@@ -1,40 +0,0 @@
-/*
-  wiring_shift.c - shiftOut() function
-  Part of Arduino - http://www.arduino.cc/
-
-  Copyright (c) 2005-2006 David A. Mellis
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General
-  Public License along with this library; if not, write to the
-  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
-  Boston, MA  02111-1307  USA
-
-  $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $
-*/
-
-#include "wiring_private.h"
-
-void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, byte val)
-{
-	int i;
-
-	for (i = 0; i < 8; i++)  {
-		if (bitOrder == LSBFIRST)
-			digitalWrite(dataPin, !!(val & (1 << i)));
-		else	
-			digitalWrite(dataPin, !!(val & (1 << (7 - i))));
-			
-		digitalWrite(clockPin, HIGH);
-		digitalWrite(clockPin, LOW);		
-	}
-}

+ 0 - 218
optiboot/cores/sanguino/HardwareSerial.cpp

@@ -1,218 +0,0 @@
-/*
-  HardwareSerial.cpp - Hardware serial library for Wiring
-  Copyright (c) 2006 Nicholas Zambetti.  All right reserved.
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public
-  License along with this library; if not, write to the Free Software
-  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-  
-  Modified 23 November 2006 by David A. Mellis
-*/
-
-#include <stdio.h>
-#include <string.h>
-#include <inttypes.h>
-#include "wiring.h"
-#include "wiring_private.h"
-
-#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
-
-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 };
-#endif
-
-#if defined(__AVR_ATmega644P__)
-ring_buffer rx_buffer1 = { { 0 }, 0, 0 };
-#endif
-
-inline void store_char(unsigned char c, ring_buffer *rx_buffer)
-{
-  int i = (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
-  // current location of the tail), we're about to overflow the buffer
-  // and so we don't write the character or advance the head.
-  if (i != rx_buffer->tail) {
-    rx_buffer->buffer[rx_buffer->head] = c;
-    rx_buffer->head = i;
-  }
-}
-
-#if defined(__AVR_ATmega644P__)
-
-
-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);
-}
-
-#else
-
-#if defined(__AVR_ATmega8__)
-SIGNAL(SIG_UART_RECV)
-#else
-SIGNAL(USART_RX_vect)
-#endif
-{
-#if defined(__AVR_ATmega8__)
-  unsigned char c = UDR;
-#else
-  unsigned char c = UDR0;
-#endif
-  store_char(c, &rx_buffer);
-}
-
-#endif
-
-// Constructors ////////////////////////////////////////////////////////////////
-
-HardwareSerial::HardwareSerial(ring_buffer *rx_buffer,
-  volatile uint8_t *ubrrh, volatile uint8_t *ubrrl,
-  volatile uint8_t *ucsra, volatile uint8_t *ucsrb,
-  volatile uint8_t *udr,
-  uint8_t rxen, uint8_t txen, uint8_t rxcie, uint8_t udre, uint8_t u2x)
-{
-  _rx_buffer = rx_buffer;
-  _ubrrh = ubrrh;
-  _ubrrl = ubrrl;
-  _ucsra = ucsra;
-  _ucsrb = ucsrb;
-  _udr = udr;
-  _rxen = rxen;
-  _txen = txen;
-  _rxcie = rxcie;
-  _udre = udre;
-  _u2x = u2x;
-}
-
-// Public Methods //////////////////////////////////////////////////////////////
-
-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);
-  }
-  
-  if (use_u2x) {
-    *_ucsra = 1 << _u2x;
-    baud_setting = (F_CPU / 4 / baud - 1) / 2;
-  } else {
-    *_ucsra = 0;
-    baud_setting = (F_CPU / 8 / baud - 1) / 2;
-  }
-
-  // assign the baud_setting, a.k.a. ubbr (USART Baud Rate Register)
-  *_ubrrh = baud_setting >> 8;
-  *_ubrrl = baud_setting;
-
-  sbi(*_ucsrb, _rxen);
-  sbi(*_ucsrb, _txen);
-  sbi(*_ucsrb, _rxcie);
-}
-
-void HardwareSerial::end()
-{
-  cbi(*_ucsrb, _rxen);
-  cbi(*_ucsrb, _txen);
-  cbi(*_ucsrb, _rxcie);  
-}
-
-uint8_t HardwareSerial::available(void)
-{
-  return (RX_BUFFER_SIZE + _rx_buffer->head - _rx_buffer->tail) % RX_BUFFER_SIZE;
-}
-
-int HardwareSerial::read(void)
-{
-  // if the head isn't ahead of the tail, we don't have any characters
-  if (_rx_buffer->head == _rx_buffer->tail) {
-    return -1;
-  } else {
-    unsigned char c = _rx_buffer->buffer[_rx_buffer->tail];
-    _rx_buffer->tail = (_rx_buffer->tail + 1) % RX_BUFFER_SIZE;
-    return c;
-  }
-}
-
-void HardwareSerial::flush()
-{
-  // don't reverse this or there may be problems if the RX interrupt
-  // occurs after reading the value of rx_buffer_head but before writing
-  // the value to rx_buffer_tail; the previous value of rx_buffer_head
-  // may be written to rx_buffer_tail, making it appear as if the buffer
-  // don't reverse this or there may be problems if the RX interrupt
-  // occurs after reading the value of rx_buffer_head but before writing
-  // the value to rx_buffer_tail; the previous value of rx_buffer_head
-  // may be written to rx_buffer_tail, making it appear as if the buffer
-  // were full, not empty.
-  _rx_buffer->head = _rx_buffer->tail;
-}
-
-void HardwareSerial::write(uint8_t c)
-{
-  while (!((*_ucsra) & (1 << _udre)))
-    ;
-
-  *_udr = c;
-}
-
-// Preinstantiate Objects //////////////////////////////////////////////////////
-
-#if defined(__AVR_ATmega8__)
-HardwareSerial Serial(&rx_buffer, &UBRRH, &UBRRL, &UCSRA, &UCSRB, &UDR, RXEN, TXEN, RXCIE, UDRE, U2X);
-#else
-HardwareSerial Serial(&rx_buffer, &UBRR0H, &UBRR0L, &UCSR0A, &UCSR0B, &UDR0, RXEN0, TXEN0, RXCIE0, UDRE0, U2X0);
-#endif
-
-#if defined(__AVR_ATmega644P__)
-HardwareSerial Serial1(&rx_buffer1, &UBRR1H, &UBRR1L, &UCSR1A, &UCSR1B, &UDR1, RXEN1, TXEN1, RXCIE1, UDRE1, U2X1);
-#endif

+ 0 - 65
optiboot/cores/sanguino/HardwareSerial.h

@@ -1,65 +0,0 @@
-/*
-  HardwareSerial.h - Hardware serial library for Wiring
-  Copyright (c) 2006 Nicholas Zambetti.  All right reserved.
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public
-  License along with this library; if not, write to the Free Software
-  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-*/
-
-#ifndef HardwareSerial_h
-#define HardwareSerial_h
-
-#include <inttypes.h>
-
-#include "Print.h"
-
-struct ring_buffer;
-
-class HardwareSerial : public Print
-{
-  private:
-    ring_buffer *_rx_buffer;
-    volatile uint8_t *_ubrrh;
-    volatile uint8_t *_ubrrl;
-    volatile uint8_t *_ucsra;
-    volatile uint8_t *_ucsrb;
-    volatile uint8_t *_udr;
-    uint8_t _rxen;
-    uint8_t _txen;
-    uint8_t _rxcie;
-    uint8_t _udre;
-    uint8_t _u2x;
-  public:
-    HardwareSerial(ring_buffer *rx_buffer,
-      volatile uint8_t *ubrrh, volatile uint8_t *ubrrl,
-      volatile uint8_t *ucsra, volatile uint8_t *ucsrb,
-      volatile uint8_t *udr,
-      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 void write(uint8_t);
-    using Print::write; // pull in write(str) and write(buf, size) from Print
-};
-
-extern HardwareSerial Serial;
-
-#if defined(__AVR_ATmega644P__)
-extern HardwareSerial Serial1;
-
-#endif
-
-#endif

+ 0 - 243
optiboot/cores/sanguino/Makefile

@@ -1,243 +0,0 @@
-# Arduino 0011 Makefile
-# Arduino adaptation by mellis, eighthave, oli.keller
-#
-# This makefile allows you to build sketches from the command line
-# without the Arduino environment (or Java).
-#
-# Detailed instructions for using the makefile:
-#
-#  1. Copy this file into the folder with your sketch. There should be a
-#     file with the same name as the folder and with the extension .pde
-#     (e.g. foo.pde in the foo/ folder).
-#
-#  2. Modify the line containg "INSTALL_DIR" to point to the directory that
-#     contains the Arduino installation (for example, under Mac OS X, this
-#     might be /Applications/arduino-0012).
-#
-#  3. Modify the line containing "PORT" to refer to the filename
-#     representing the USB or serial connection to your Arduino board
-#     (e.g. PORT = /dev/tty.USB0).  If the exact name of this file
-#     changes, you can use * as a wildcard (e.g. PORT = /dev/tty.usb*).
-#
-#  4. Set the line containing "MCU" to match your board's processor. 
-#     Older one's are atmega8 based, newer ones like Arduino Mini, Bluetooth
-#     or Diecimila have the atmega168.  If you're using a LilyPad Arduino,
-#     change F_CPU to 8000000.
-#
-#  5. At the command line, change to the directory containing your
-#     program's file and the makefile.
-#
-#  6. Type "make" and press enter to compile/verify your program.
-#
-#  7. Type "make upload", reset your Arduino board, and press enter to
-#     upload your program to the Arduino board.
-#
-# $Id$
-
-TARGET = $(notdir $(CURDIR))
-INSTALL_DIR = /Users/dmellis/Source/arduino/trunk/build/macosx/build/work
-PORT = /dev/tty.usb*
-UPLOAD_RATE = 19200
-AVRDUDE_PROGRAMMER = stk500v1
-MCU = atmega168
-F_CPU = 16000000
-
-############################################################################
-# Below here nothing should be changed...
-
-ARDUINO = $(INSTALL_DIR)/hardware/cores/arduino
-AVR_TOOLS_PATH = $(INSTALL_DIR)/hardware/tools/avr/bin
-SRC =  $(ARDUINO)/pins_arduino.c $(ARDUINO)/wiring.c \
-$(ARDUINO)/wiring_analog.c $(ARDUINO)/wiring_digital.c \
-$(ARDUINO)/wiring_pulse.c $(ARDUINO)/wiring_serial.c \
-$(ARDUINO)/wiring_shift.c $(ARDUINO)/WInterrupts.c
-CXXSRC = $(ARDUINO)/HardwareSerial.cpp $(ARDUINO)/WMath.cpp
-FORMAT = ihex
-
-
-# Name of this Makefile (used for "make depend").
-MAKEFILE = Makefile
-
-# Debugging format.
-# Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.
-# AVR (extended) COFF requires stabs, plus an avr-objcopy run.
-DEBUG = stabs
-
-OPT = s
-
-# Place -D or -U options here
-CDEFS = -DF_CPU=$(F_CPU)
-CXXDEFS = -DF_CPU=$(F_CPU)
-
-# Place -I options here
-CINCS = -I$(ARDUINO)
-CXXINCS = -I$(ARDUINO)
-
-# 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
-CDEBUG = -g$(DEBUG)
-CWARN = -Wall -Wstrict-prototypes
-CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
-#CEXTRA = -Wa,-adhlns=$(<:.c=.lst)
-
-CFLAGS = $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CSTANDARD) $(CEXTRA)
-CXXFLAGS = $(CDEFS) $(CINCS) -O$(OPT)
-#ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs 
-LDFLAGS = -lm
-
-
-# Programming support using avrdude. Settings and variables.
-AVRDUDE_PORT = $(PORT)
-AVRDUDE_WRITE_FLASH = -U flash:w:applet/$(TARGET).hex
-AVRDUDE_FLAGS = -V -F -C $(INSTALL_DIR)/hardware/tools/avr/etc/avrdude.conf \
--p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) \
--b $(UPLOAD_RATE)
-
-# Program settings
-CC = $(AVR_TOOLS_PATH)/avr-gcc
-CXX = $(AVR_TOOLS_PATH)/avr-g++
-OBJCOPY = $(AVR_TOOLS_PATH)/avr-objcopy
-OBJDUMP = $(AVR_TOOLS_PATH)/avr-objdump
-AR  = $(AVR_TOOLS_PATH)/avr-ar
-SIZE = $(AVR_TOOLS_PATH)/avr-size
-NM = $(AVR_TOOLS_PATH)/avr-nm
-AVRDUDE = $(AVR_TOOLS_PATH)/avrdude
-REMOVE = rm -f
-MV = mv -f
-
-# Define all object files.
-OBJ = $(SRC:.c=.o) $(CXXSRC:.cpp=.o) $(ASRC:.S=.o) 
-
-# Define all listing files.
-LST = $(ASRC:.S=.lst) $(CXXSRC:.cpp=.lst) $(SRC:.c=.lst)
-
-# Combine all necessary flags and optional flags.
-# Add target processor to flags.
-ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
-ALL_CXXFLAGS = -mmcu=$(MCU) -I. $(CXXFLAGS)
-ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
-
-
-# Default target.
-all: applet_files build sizeafter
-
-build: elf hex 
-
-applet_files: $(TARGET).pde
-	# Here is the "preprocessing".
-	# It creates a .cpp file based with the same name as the .pde file.
-	# On top of the new .cpp file comes the WProgram.h header.
-	# At the end there is a generic main() function attached.
-	# Then the .cpp file will be compiled. Errors during compile will
-	# refer to this new, automatically generated, file. 
-	# Not the original .pde file you actually edit...
-	test -d applet || mkdir applet
-	echo '#include "WProgram.h"' > applet/$(TARGET).cpp
-	cat $(TARGET).pde >> applet/$(TARGET).cpp
-	cat $(ARDUINO)/main.cxx >> applet/$(TARGET).cpp
-
-elf: applet/$(TARGET).elf
-hex: applet/$(TARGET).hex
-eep: applet/$(TARGET).eep
-lss: applet/$(TARGET).lss 
-sym: applet/$(TARGET).sym
-
-# Program the device.  
-upload: applet/$(TARGET).hex
-	$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
-
-
-	# Display size of file.
-HEXSIZE = $(SIZE) --target=$(FORMAT) applet/$(TARGET).hex
-ELFSIZE = $(SIZE)  applet/$(TARGET).elf
-sizebefore:
-	@if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(HEXSIZE); echo; fi
-
-sizeafter:
-	@if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(HEXSIZE); echo; fi
-
-
-# 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: applet/$(TARGET).elf
-	$(COFFCONVERT) -O coff-avr applet/$(TARGET).elf $(TARGET).cof
-
-
-extcoff: $(TARGET).elf
-	$(COFFCONVERT) -O coff-ext-avr applet/$(TARGET).elf $(TARGET).cof
-
-
-.SUFFIXES: .elf .hex .eep .lss .sym
-
-.elf.hex:
-	$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
-
-.elf.eep:
-	-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
-	--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
-
-# Create extended listing file from ELF output file.
-.elf.lss:
-	$(OBJDUMP) -h -S $< > $@
-
-# Create a symbol table from ELF output file.
-.elf.sym:
-	$(NM) -n $< > $@
-
-	# Link: create ELF output file from library.
-applet/$(TARGET).elf: $(TARGET).pde applet/core.a 
-	$(CC) $(ALL_CFLAGS) -o $@ applet/$(TARGET).cpp -L. applet/core.a $(LDFLAGS)
-
-applet/core.a: $(OBJ)
-	@for i in $(OBJ); do echo $(AR) rcs applet/core.a $$i; $(AR) rcs applet/core.a $$i; done
-
-
-
-# Compile: create object files from C++ source files.
-.cpp.o:
-	$(CXX) -c $(ALL_CXXFLAGS) $< -o $@ 
-
-# Compile: create object files from C source files.
-.c.o:
-	$(CC) -c $(ALL_CFLAGS) $< -o $@ 
-
-
-# Compile: create assembler files from C source files.
-.c.s:
-	$(CC) -S $(ALL_CFLAGS) $< -o $@
-
-
-# Assemble: create object files from assembler source files.
-.S.o:
-	$(CC) -c $(ALL_ASFLAGS) $< -o $@
-
-
-
-# Target: clean project.
-clean:
-	$(REMOVE) applet/$(TARGET).hex applet/$(TARGET).eep applet/$(TARGET).cof applet/$(TARGET).elf \
-	applet/$(TARGET).map applet/$(TARGET).sym applet/$(TARGET).lss applet/core.a \
-	$(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(CXXSRC:.cpp=.s) $(CXXSRC:.cpp=.d)
-
-depend:
-	if grep '^# DO NOT DELETE' $(MAKEFILE) >/dev/null; \
-	then \
-		sed -e '/^# DO NOT DELETE/,$$d' $(MAKEFILE) > \
-			$(MAKEFILE).$$$$ && \
-		$(MV) $(MAKEFILE).$$$$ $(MAKEFILE); \
-	fi
-	echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' \
-		>> $(MAKEFILE); \
-	$(CC) -M -mmcu=$(MCU) $(CDEFS) $(CINCS) $(SRC) $(ASRC) >> $(MAKEFILE)
-
-.PHONY:	all build elf hex eep lss sym program coff extcoff clean depend applet_files sizebefore sizeafter

+ 0 - 206
optiboot/cores/sanguino/Print.cpp

@@ -1,206 +0,0 @@
-/*
- Print.cpp - Base class that provides print() and println()
- Copyright (c) 2008 David A. Mellis.  All right reserved.
- 
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
- 
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- Lesser General Public License for more details.
- 
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- 
- Modified 23 November 2006 by David A. Mellis
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <math.h>
-#include "wiring.h"
-
-#include "Print.h"
-
-// Public Methods //////////////////////////////////////////////////////////////
-
-/* default implementation: may be overridden */
-void Print::write(const char *str)
-{
-  while (*str)
-    write(*str++);
-}
-
-/* default implementation: may be overridden */
-void Print::write(const uint8_t *buffer, size_t size)
-{
-  while (size--)
-    write(*buffer++);
-}
-
-void Print::print(const char str[])
-{
-  write(str);
-}
-
-void Print::print(char c, int base)
-{
-  print((long) c, base);
-}
-
-void Print::print(unsigned char b, int base)
-{
-  print((unsigned long) b, base);
-}
-
-void Print::print(int n, int base)
-{
-  print((long) n, base);
-}
-
-void Print::print(unsigned int n, int base)
-{
-  print((unsigned long) n, base);
-}
-
-void Print::print(long n, int base)
-{
-  if (base == 0) {
-    write(n);
-  } else if (base == 10) {
-    if (n < 0) {
-      print('-');
-      n = -n;
-    }
-    printNumber(n, 10);
-  } else {
-    printNumber(n, base);
-  }
-}
-
-void Print::print(unsigned long n, int base)
-{
-  if (base == 0) write(n);
-  else printNumber(n, base);
-}
-
-void Print::print(double n, int digits)
-{
-  printFloat(n, digits);
-}
-
-void Print::println(void)
-{
-  print('\r');
-  print('\n');  
-}
-
-void Print::println(const char c[])
-{
-  print(c);
-  println();
-}
-
-void Print::println(char c, int base)
-{
-  print(c, base);
-  println();
-}
-
-void Print::println(unsigned char b, int base)
-{
-  print(b, base);
-  println();
-}
-
-void Print::println(int n, int base)
-{
-  print(n, base);
-  println();
-}
-
-void Print::println(unsigned int n, int base)
-{
-  print(n, base);
-  println();
-}
-
-void Print::println(long n, int base)
-{
-  print(n, base);
-  println();
-}
-
-void Print::println(unsigned long n, int base)
-{
-  print(n, base);
-  println();
-}
-
-void Print::println(double n, int digits)
-{
-  print(n, digits);
-  println();
-}
-
-// Private Methods /////////////////////////////////////////////////////////////
-
-void Print::printNumber(unsigned long n, uint8_t base)
-{
-  unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars. 
-  unsigned long i = 0;
-
-  if (n == 0) {
-    print('0');
-    return;
-  } 
-
-  while (n > 0) {
-    buf[i++] = n % base;
-    n /= base;
-  }
-
-  for (; i > 0; i--)
-    print((char) (buf[i - 1] < 10 ?
-      '0' + buf[i - 1] :
-      'A' + buf[i - 1] - 10));
-}
-
-void Print::printFloat(double number, uint8_t digits) 
-{ 
-  // Handle negative numbers
-  if (number < 0.0)
-  {
-     print('-');
-     number = -number;
-  }
-
-  // Round correctly so that print(1.999, 2) prints as "2.00"
-  double rounding = 0.5;
-  for (uint8_t i=0; i<digits; ++i)
-    rounding /= 10.0;
-  
-  number += rounding;
-
-  // Extract the integer part of the number and print it
-  unsigned long int_part = (unsigned long)number;
-  double remainder = number - (double)int_part;
-  print(int_part);
-
-  // Print the decimal point, but only if there are digits beyond
-  if (digits > 0)
-    print("."); 
-
-  // Extract digits from the remainder one at a time
-  while (digits-- > 0)
-  {
-    remainder *= 10.0;
-    int toPrint = int(remainder);
-    print(toPrint);
-    remainder -= toPrint; 
-  } 
-}

+ 0 - 62
optiboot/cores/sanguino/Print.h

@@ -1,62 +0,0 @@
-/*
-  Print.h - Base class that provides print() and println()
-  Copyright (c) 2008 David A. Mellis.  All right reserved.
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public
-  License along with this library; if not, write to the Free Software
-  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-*/
-
-#ifndef Print_h
-#define Print_h
-
-#include <inttypes.h>
-#include <stdio.h> // for size_t
-
-#define DEC 10
-#define HEX 16
-#define OCT 8
-#define BIN 2
-#define BYTE 0
-
-class Print
-{
-  private:
-    void printNumber(unsigned long, uint8_t);
-    void printFloat(double, uint8_t);
-  public:
-    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 char[]);
-    void print(char, int = BYTE);
-    void print(unsigned char, int = BYTE);
-    void print(int, int = DEC);
-    void print(unsigned int, int = DEC);
-    void print(long, int = DEC);
-    void print(unsigned long, int = DEC);
-    void print(double, int = 2);
-
-    void println(const char[]);
-    void println(char, int = BYTE);
-    void println(unsigned char, int = BYTE);
-    void println(int, int = DEC);
-    void println(unsigned int, int = DEC);
-    void println(long, int = DEC);
-    void println(unsigned long, int = DEC);
-    void println(double, int = 2);
-    void println(void);
-};
-
-#endif

+ 0 - 515
optiboot/cores/sanguino/Tone.cpp

@@ -1,515 +0,0 @@
-/* Tone.cpp
-
-  A Tone Generator Library
-
-  Written by Brett Hagman
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public
-  License along with this library; if not, write to the Free Software
-  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-Version Modified By Date     Comments
-------- ----------- -------- --------
-0001    B Hagman    09/08/02 Initial coding
-0002    B Hagman    09/08/18 Multiple pins
-0003    B Hagman    09/08/18 Moved initialization from constructor to begin()
-0004    B Hagman    09/09/26 Fixed problems with ATmega8
-0005    B Hagman    09/11/23 Scanned prescalars for best fit on 8 bit timers
-                    09/11/25 Changed pin toggle method to XOR
-                    09/11/25 Fixed timer0 from being excluded
-0006    D Mellis    09/12/29 Replaced objects with functions
-
-*************************************************/
-
-#include <avr/interrupt.h>
-#include <avr/pgmspace.h>
-#include <wiring.h>
-#include <pins_arduino.h>
-
-#if defined(__AVR_ATmega8__)
-#define TCCR2A TCCR2
-#define TCCR2B TCCR2
-#define COM2A1 COM21
-#define COM2A0 COM20
-#define OCR2A OCR2
-#define TIMSK2 TIMSK
-#define OCIE2A OCIE2
-#define TIMER2_COMPA_vect TIMER2_COMP_vect
-#define TIMSK1 TIMSK
-#endif
-
-// timerx_toggle_count:
-//  > 0 - duration specified
-//  = 0 - stopped
-//  < 0 - infinitely (until stop() method called, or new play() called)
-
-#if !defined(__AVR_ATmega8__)
-volatile long timer0_toggle_count;
-volatile uint8_t *timer0_pin_port;
-volatile uint8_t timer0_pin_mask;
-#endif
-
-volatile long timer1_toggle_count;
-volatile uint8_t *timer1_pin_port;
-volatile uint8_t timer1_pin_mask;
-volatile long timer2_toggle_count;
-volatile uint8_t *timer2_pin_port;
-volatile uint8_t timer2_pin_mask;
-
-#if defined(__AVR_ATmega1280__)
-volatile long timer3_toggle_count;
-volatile uint8_t *timer3_pin_port;
-volatile uint8_t timer3_pin_mask;
-volatile long timer4_toggle_count;
-volatile uint8_t *timer4_pin_port;
-volatile uint8_t timer4_pin_mask;
-volatile long timer5_toggle_count;
-volatile uint8_t *timer5_pin_port;
-volatile uint8_t timer5_pin_mask;
-#endif
-
-
-#if defined(__AVR_ATmega1280__)
-
-#define AVAILABLE_TONE_PINS 1
-
-const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 3, 4, 5, 1, 0 */ };
-static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255, 255, 255, 255, 255 */ };
-
-#elif defined(__AVR_ATmega8__)
-
-#define AVAILABLE_TONE_PINS 1
-
-const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 1 */ };
-static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255 */ };
-
-#else
-
-#define AVAILABLE_TONE_PINS 1
-
-// Leave timer 0 to last.
-const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 1, 0 */ };
-static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255, 255 */ };
-
-#endif
-
-
-
-static int8_t toneBegin(uint8_t _pin)
-{
-  int8_t _timer = -1;
-
-  // if we're already using the pin, the timer should be configured.  
-  for (int i = 0; i < AVAILABLE_TONE_PINS; i++) {
-    if (tone_pins[i] == _pin) {
-      return pgm_read_byte(tone_pin_to_timer_PGM + i);
-    }
-  }
-  
-  // search for an unused timer.
-  for (int i = 0; i < AVAILABLE_TONE_PINS; i++) {
-    if (tone_pins[i] == 255) {
-      tone_pins[i] = _pin;
-      _timer = pgm_read_byte(tone_pin_to_timer_PGM + i);
-      break;
-    }
-  }
-  
-  if (_timer != -1)
-  {
-    // Set timer specific stuff
-    // All timers in CTC mode
-    // 8 bit timers will require changing prescalar values,
-    // whereas 16 bit timers are set to either ck/1 or ck/64 prescalar
-    switch (_timer)
-    {
-#if !defined(__AVR_ATmega8__)
-      case 0:
-        // 8 bit timer
-        TCCR0A = 0;
-        TCCR0B = 0;
-        bitWrite(TCCR0A, WGM01, 1);
-        bitWrite(TCCR0B, CS00, 1);
-        timer0_pin_port = portOutputRegister(digitalPinToPort(_pin));
-        timer0_pin_mask = digitalPinToBitMask(_pin);
-        break;
-#endif
-
-      case 1:
-        // 16 bit timer
-        TCCR1A = 0;
-        TCCR1B = 0;
-        bitWrite(TCCR1B, WGM12, 1);
-        bitWrite(TCCR1B, CS10, 1);
-        timer1_pin_port = portOutputRegister(digitalPinToPort(_pin));
-        timer1_pin_mask = digitalPinToBitMask(_pin);
-        break;
-      case 2:
-        // 8 bit timer
-        TCCR2A = 0;
-        TCCR2B = 0;
-        bitWrite(TCCR2A, WGM21, 1);
-        bitWrite(TCCR2B, CS20, 1);
-        timer2_pin_port = portOutputRegister(digitalPinToPort(_pin));
-        timer2_pin_mask = digitalPinToBitMask(_pin);
-        break;
-
-#if defined(__AVR_ATmega1280__)
-      case 3:
-        // 16 bit timer
-        TCCR3A = 0;
-        TCCR3B = 0;
-        bitWrite(TCCR3B, WGM32, 1);
-        bitWrite(TCCR3B, CS30, 1);
-        timer3_pin_port = portOutputRegister(digitalPinToPort(_pin));
-        timer3_pin_mask = digitalPinToBitMask(_pin);
-        break;
-      case 4:
-        // 16 bit timer
-        TCCR4A = 0;
-        TCCR4B = 0;
-        bitWrite(TCCR4B, WGM42, 1);
-        bitWrite(TCCR4B, CS40, 1);
-        timer4_pin_port = portOutputRegister(digitalPinToPort(_pin));
-        timer4_pin_mask = digitalPinToBitMask(_pin);
-        break;
-      case 5:
-        // 16 bit timer
-        TCCR5A = 0;
-        TCCR5B = 0;
-        bitWrite(TCCR5B, WGM52, 1);
-        bitWrite(TCCR5B, CS50, 1);
-        timer5_pin_port = portOutputRegister(digitalPinToPort(_pin));
-        timer5_pin_mask = digitalPinToBitMask(_pin);
-        break;
-#endif
-    }
-  }
-
-  return _timer;
-}
-
-
-
-// frequency (in hertz) and duration (in milliseconds).
-
-void tone(uint8_t _pin, unsigned int frequency, unsigned long duration)
-{
-  uint8_t prescalarbits = 0b001;
-  long toggle_count = 0;
-  uint32_t ocr = 0;
-  int8_t _timer;
-
-  _timer = toneBegin(_pin);
-
-  if (_timer >= 0)
-  {
-    // Set the pinMode as OUTPUT
-    pinMode(_pin, OUTPUT);
-    
-    // if we are using an 8 bit timer, scan through prescalars to find the best fit
-    if (_timer == 0 || _timer == 2)
-    {
-      ocr = F_CPU / frequency / 2 - 1;
-      prescalarbits = 0b001;  // ck/1: same for both timers
-      if (ocr > 255)
-      {
-        ocr = F_CPU / frequency / 2 / 8 - 1;
-        prescalarbits = 0b010;  // ck/8: same for both timers
-
-        if (_timer == 2 && ocr > 255)
-        {
-          ocr = F_CPU / frequency / 2 / 32 - 1;
-          prescalarbits = 0b011;
-        }
-
-        if (ocr > 255)
-        {
-          ocr = F_CPU / frequency / 2 / 64 - 1;
-          prescalarbits = _timer == 0 ? 0b011 : 0b100;
-
-          if (_timer == 2 && ocr > 255)
-          {
-            ocr = F_CPU / frequency / 2 / 128 - 1;
-            prescalarbits = 0b101;
-          }
-
-          if (ocr > 255)
-          {
-            ocr = F_CPU / frequency / 2 / 256 - 1;
-            prescalarbits = _timer == 0 ? 0b100 : 0b110;
-            if (ocr > 255)
-            {
-              // can't do any better than /1024
-              ocr = F_CPU / frequency / 2 / 1024 - 1;
-              prescalarbits = _timer == 0 ? 0b101 : 0b111;
-            }
-          }
-        }
-      }
-
-#if !defined(__AVR_ATmega8__)
-      if (_timer == 0)
-        TCCR0B = prescalarbits;
-      else
-#endif
-        TCCR2B = prescalarbits;
-    }
-    else
-    {
-      // two choices for the 16 bit timers: ck/1 or ck/64
-      ocr = F_CPU / frequency / 2 - 1;
-
-      prescalarbits = 0b001;
-      if (ocr > 0xffff)
-      {
-        ocr = F_CPU / frequency / 2 / 64 - 1;
-        prescalarbits = 0b011;
-      }
-
-      if (_timer == 1)
-        TCCR1B = (TCCR1B & 0b11111000) | prescalarbits;
-#if defined(__AVR_ATmega1280__)
-      else if (_timer == 3)
-        TCCR3B = (TCCR3B & 0b11111000) | prescalarbits;
-      else if (_timer == 4)
-        TCCR4B = (TCCR4B & 0b11111000) | prescalarbits;
-      else if (_timer == 5)
-        TCCR5B = (TCCR5B & 0b11111000) | prescalarbits;
-#endif
-
-    }
-    
-
-    // Calculate the toggle count
-    if (duration > 0)
-    {
-      toggle_count = 2 * frequency * duration / 1000;
-    }
-    else
-    {
-      toggle_count = -1;
-    }
-
-    // Set the OCR for the given timer,
-    // set the toggle count,
-    // then turn on the interrupts
-    switch (_timer)
-    {
-
-#if !defined(__AVR_ATmega8__)
-      case 0:
-        OCR0A = ocr;
-        timer0_toggle_count = toggle_count;
-        bitWrite(TIMSK0, OCIE0A, 1);
-        break;
-#endif
-
-      case 1:
-        OCR1A = ocr;
-        timer1_toggle_count = toggle_count;
-        bitWrite(TIMSK1, OCIE1A, 1);
-        break;
-      case 2:
-        OCR2A = ocr;
-        timer2_toggle_count = toggle_count;
-        bitWrite(TIMSK2, OCIE2A, 1);
-        break;
-
-#if defined(__AVR_ATmega1280__)
-      case 3:
-        OCR3A = ocr;
-        timer3_toggle_count = toggle_count;
-        bitWrite(TIMSK3, OCIE3A, 1);
-        break;
-      case 4:
-        OCR4A = ocr;
-        timer4_toggle_count = toggle_count;
-        bitWrite(TIMSK4, OCIE4A, 1);
-        break;
-      case 5:
-        OCR5A = ocr;
-        timer5_toggle_count = toggle_count;
-        bitWrite(TIMSK5, OCIE5A, 1);
-        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;
-    }
-  }
-  
-  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;
-      break;
-    case 1:
-      TIMSK1 = 0;
-      break;
-    case 2:
-      TIMSK2 = 0;
-      break;
-#endif
-
-#if defined(__AVR_ATmega1280__)
-    case 3:
-      TIMSK3 = 0;
-      break;
-    case 4:
-      TIMSK4 = 0;
-      break;
-    case 5:
-      TIMSK5 = 0;
-      break;
-#endif
-  }
-
-  digitalWrite(_pin, 0);
-}
-
-#if 0
-#if !defined(__AVR_ATmega8__)
-ISR(TIMER0_COMPA_vect)
-{
-  if (timer0_toggle_count != 0)
-  {
-    // toggle the pin
-    *timer0_pin_port ^= timer0_pin_mask;
-
-    if (timer0_toggle_count > 0)
-      timer0_toggle_count--;
-  }
-  else
-  {
-    TIMSK0 = 0;   // disable the interrupt
-    *timer0_pin_port &= ~(timer0_pin_mask);  // keep pin low after stop
-  }
-}
-#endif
-
-
-ISR(TIMER1_COMPA_vect)
-{
-  if (timer1_toggle_count != 0)
-  {
-    // toggle the pin
-    *timer1_pin_port ^= timer1_pin_mask;
-
-    if (timer1_toggle_count > 0)
-      timer1_toggle_count--;
-  }
-  else
-  {
-    TIMSK1 = 0;   // disable the interrupt
-    *timer1_pin_port &= ~(timer1_pin_mask);  // keep pin low after stop
-  }
-}
-#endif
-
-
-ISR(TIMER2_COMPA_vect)
-{
-
-  if (timer2_toggle_count != 0)
-  {
-    // toggle the pin
-    *timer2_pin_port ^= timer2_pin_mask;
-
-    if (timer2_toggle_count > 0)
-      timer2_toggle_count--;
-  }
-  else
-  {
-    TIMSK2 = 0;   // disable the interrupt
-    *timer2_pin_port &= ~(timer2_pin_mask);  // keep pin low after stop
-  }
-}
-
-
-
-//#if defined(__AVR_ATmega1280__)
-#if 0
-
-ISR(TIMER3_COMPA_vect)
-{
-  if (timer3_toggle_count != 0)
-  {
-    // toggle the pin
-    *timer3_pin_port ^= timer3_pin_mask;
-
-    if (timer3_toggle_count > 0)
-      timer3_toggle_count--;
-  }
-  else
-  {
-    TIMSK3 = 0;   // disable the interrupt
-    *timer3_pin_port &= ~(timer3_pin_mask);  // keep pin low after stop
-  }
-}
-
-ISR(TIMER4_COMPA_vect)
-{
-  if (timer4_toggle_count != 0)
-  {
-    // toggle the pin
-    *timer4_pin_port ^= timer4_pin_mask;
-
-    if (timer4_toggle_count > 0)
-      timer4_toggle_count--;
-  }
-  else
-  {
-    TIMSK4 = 0;   // disable the interrupt
-    *timer4_pin_port &= ~(timer4_pin_mask);  // keep pin low after stop
-  }
-}
-
-ISR(TIMER5_COMPA_vect)
-{
-  if (timer5_toggle_count != 0)
-  {
-    // toggle the pin
-    *timer5_pin_port ^= timer5_pin_mask;
-
-    if (timer5_toggle_count > 0)
-      timer5_toggle_count--;
-  }
-  else
-  {
-    TIMSK5 = 0;   // disable the interrupt
-    *timer5_pin_port &= ~(timer5_pin_mask);  // keep pin low after stop
-  }
-}
-
-#endif

+ 0 - 1
optiboot/cores/sanguino/WConstants.h

@@ -1 +0,0 @@
-#include "wiring.h"

+ 0 - 215
optiboot/cores/sanguino/WInterrupts.c

@@ -1,215 +0,0 @@
-/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
-
-/*
-  Part of the Wiring project - http://wiring.uniandes.edu.co
-
-  Copyright (c) 2004-05 Hernando Barragan
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General
-  Public License along with this library; if not, write to the
-  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
-  Boston, MA  02111-1307  USA
-  
-  Modified 24 November 2006 by David A. Mellis
-*/
-
-#include <inttypes.h>
-#include <avr/io.h>
-#include <avr/interrupt.h>
-#include <avr/pgmspace.h>
-#include <stdio.h>
-
-#include "WConstants.h"
-#include "wiring_private.h"
-
-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;
-    
-    // Configure the interrupt mode (trigger on low input, any change, rising
-    // edge, or falling edge).  The mode constants were chosen to correspond
-    // to the configuration bits in the hardware register, so we simply shift
-    // the mode into place.
-      
-    // Enable the interrupt.
-      
-    switch (interruptNum) {
-#if defined(__AVR_ATmega1280__)
-    case 2:
-      EICRA = (EICRA & ~((1 << ISC00) | (1 << ISC01))) | (mode << ISC00);
-      EIMSK |= (1 << INT0);
-      break;
-    case 3:
-      EICRA = (EICRA & ~((1 << ISC10) | (1 << ISC11))) | (mode << ISC10);
-      EIMSK |= (1 << INT1);
-      break;
-    case 4:
-      EICRA = (EICRA & ~((1 << ISC20) | (1 << ISC21))) | (mode << ISC20);
-      EIMSK |= (1 << INT2);
-      break;
-    case 5:
-      EICRA = (EICRA & ~((1 << ISC30) | (1 << ISC31))) | (mode << ISC30);
-      EIMSK |= (1 << INT3);
-      break;
-    case 0:
-      EICRB = (EICRB & ~((1 << ISC40) | (1 << ISC41))) | (mode << ISC40);
-      EIMSK |= (1 << INT4);
-      break;
-    case 1:
-      EICRB = (EICRB & ~((1 << ISC50) | (1 << ISC51))) | (mode << ISC50);
-      EIMSK |= (1 << INT5);
-      break;
-    case 6:
-      EICRB = (EICRB & ~((1 << ISC60) | (1 << ISC61))) | (mode << ISC60);
-      EIMSK |= (1 << INT6);
-      break;
-    case 7:
-      EICRB = (EICRB & ~((1 << ISC70) | (1 << ISC71))) | (mode << ISC70);
-      EIMSK |= (1 << INT7);
-      break;
-#else
-    case 0:
-      EICRA = (EICRA & ~((1 << ISC00) | (1 << ISC01))) | (mode << ISC00);
-      EIMSK |= (1 << INT0);
-      break;
-    case 1:
-      EICRA = (EICRA & ~((1 << ISC10) | (1 << ISC11))) | (mode << ISC10);
-      EIMSK |= (1 << INT1);
-      break;
-#endif
-    }
-  }
-}
-
-void detachInterrupt(uint8_t interruptNum) {
-  if(interruptNum < EXTERNAL_NUM_INTERRUPTS) {
-    // Disable the interrupt.  (We can't assume that interruptNum is equal
-    // to the number of the EIMSK bit to clear, as this isn't true on the 
-    // ATmega8.  There, INT0 is 6 and INT1 is 7.)
-    switch (interruptNum) {
-#if defined(__AVR_ATmega1280__)
-    case 2:
-      EIMSK &= ~(1 << INT0);
-      break;
-    case 3:
-      EIMSK &= ~(1 << INT1);
-      break;
-    case 4:
-      EIMSK &= ~(1 << INT2);
-      break;
-    case 5:
-      EIMSK &= ~(1 << INT3);
-      break;
-    case 0:
-      EIMSK &= ~(1 << INT4);
-      break;
-    case 1:
-      EIMSK &= ~(1 << INT5);
-      break;
-    case 6:
-      EIMSK &= ~(1 << INT6);
-      break;
-    case 7:
-      EIMSK &= ~(1 << INT7);
-      break;
-#else
-    case 0:
-      EIMSK &= ~(1 << INT0);
-      break;
-    case 1:
-      EIMSK &= ~(1 << INT1);
-      break;
-#endif
-    }
-      
-    intFunc[interruptNum] = 0;
-  }
-}
-
-/*
-void attachInterruptTwi(void (*userFunc)(void) ) {
-  twiIntFunc = userFunc;
-}
-*/
-
-#if defined(__AVR_ATmega1280__)
-
-SIGNAL(INT0_vect) {
-  if(intFunc[EXTERNAL_INT_2])
-    intFunc[EXTERNAL_INT_2]();
-}
-
-SIGNAL(INT1_vect) {
-  if(intFunc[EXTERNAL_INT_3])
-    intFunc[EXTERNAL_INT_3]();
-}
-
-SIGNAL(INT2_vect) {
-  if(intFunc[EXTERNAL_INT_4])
-    intFunc[EXTERNAL_INT_4]();
-}
-
-SIGNAL(INT3_vect) {
-  if(intFunc[EXTERNAL_INT_5])
-    intFunc[EXTERNAL_INT_5]();
-}
-
-SIGNAL(INT4_vect) {
-  if(intFunc[EXTERNAL_INT_0])
-    intFunc[EXTERNAL_INT_0]();
-}
-
-SIGNAL(INT5_vect) {
-  if(intFunc[EXTERNAL_INT_1])
-    intFunc[EXTERNAL_INT_1]();
-}
-
-SIGNAL(INT6_vect) {
-  if(intFunc[EXTERNAL_INT_6])
-    intFunc[EXTERNAL_INT_6]();
-}
-
-SIGNAL(INT7_vect) {
-  if(intFunc[EXTERNAL_INT_7])
-    intFunc[EXTERNAL_INT_7]();
-}
-
-#else
-
-SIGNAL(INT0_vect) {
-  if(intFunc[EXTERNAL_INT_0])
-    intFunc[EXTERNAL_INT_0]();
-}
-
-SIGNAL(INT1_vect) {
-  if(intFunc[EXTERNAL_INT_1])
-    intFunc[EXTERNAL_INT_1]();
-}
-
-#endif
-
-/*
-SIGNAL(SIG_2WIRE_SERIAL) {
-  if(twiIntFunc)
-    twiIntFunc();
-}
-*/
-

+ 0 - 60
optiboot/cores/sanguino/WMath.cpp

@@ -1,60 +0,0 @@
-/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
-
-/*
-  Part of the Wiring project - http://wiring.org.co
-  Copyright (c) 2004-06 Hernando Barragan
-  Modified 13 August 2006, David A. Mellis for Arduino - http://www.arduino.cc/
-  
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General
-  Public License along with this library; if not, write to the
-  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
-  Boston, MA  02111-1307  USA
-  
-  $Id$
-*/
-
-extern "C" {
-  #include "stdlib.h"
-}
-
-void randomSeed(unsigned int seed)
-{
-  if (seed != 0) {
-    srandom(seed);
-  }
-}
-
-long random(long howbig)
-{
-  if (howbig == 0) {
-    return 0;
-  }
-  return random() % howbig;
-}
-
-long random(long howsmall, long howbig)
-{
-  if (howsmall >= howbig) {
-    return howsmall;
-  }
-  long diff = howbig - howsmall;
-  return random(diff) + howsmall;
-}
-
-long map(long x, long in_min, long in_max, long out_min, long out_max)
-{
-  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
-}
-
-unsigned int makeWord(unsigned int w) { return w; }
-unsigned int makeWord(unsigned char h, unsigned char l) { return (h << 8) | l; }

+ 0 - 32
optiboot/cores/sanguino/WProgram.h

@@ -1,32 +0,0 @@
-#ifndef WProgram_h
-#define WProgram_h
-
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-
-#include <avr/interrupt.h>
-
-#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

+ 0 - 5
optiboot/cores/sanguino/_ReadMe.txt

@@ -1,5 +0,0 @@
-Arduino does not currently allow additional hardware directories to share the
-Sanguino core. So a copy of the Sanguino 18 core is included here. No changes
-have been made.
-
-Sanguino source is from http://sanguino.cc

+ 0 - 515
optiboot/cores/sanguino/binary.h

@@ -1,515 +0,0 @@
-#ifndef Binary_h
-#define Binary_h
-
-#define B0 0
-#define B00 0
-#define B000 0
-#define B0000 0
-#define B00000 0
-#define B000000 0
-#define B0000000 0
-#define B00000000 0
-#define B1 1
-#define B01 1
-#define B001 1
-#define B0001 1
-#define B00001 1
-#define B000001 1
-#define B0000001 1
-#define B00000001 1
-#define B10 2
-#define B010 2
-#define B0010 2
-#define B00010 2
-#define B000010 2
-#define B0000010 2
-#define B00000010 2
-#define B11 3
-#define B011 3
-#define B0011 3
-#define B00011 3
-#define B000011 3
-#define B0000011 3
-#define B00000011 3
-#define B100 4
-#define B0100 4
-#define B00100 4
-#define B000100 4
-#define B0000100 4
-#define B00000100 4
-#define B101 5
-#define B0101 5
-#define B00101 5
-#define B000101 5
-#define B0000101 5
-#define B00000101 5
-#define B110 6
-#define B0110 6
-#define B00110 6
-#define B000110 6
-#define B0000110 6
-#define B00000110 6
-#define B111 7
-#define B0111 7
-#define B00111 7
-#define B000111 7
-#define B0000111 7
-#define B00000111 7
-#define B1000 8
-#define B01000 8
-#define B001000 8
-#define B0001000 8
-#define B00001000 8
-#define B1001 9
-#define B01001 9
-#define B001001 9
-#define B0001001 9
-#define B00001001 9
-#define B1010 10
-#define B01010 10
-#define B001010 10
-#define B0001010 10
-#define B00001010 10
-#define B1011 11
-#define B01011 11
-#define B001011 11
-#define B0001011 11
-#define B00001011 11
-#define B1100 12
-#define B01100 12
-#define B001100 12
-#define B0001100 12
-#define B00001100 12
-#define B1101 13
-#define B01101 13
-#define B001101 13
-#define B0001101 13
-#define B00001101 13
-#define B1110 14
-#define B01110 14
-#define B001110 14
-#define B0001110 14
-#define B00001110 14
-#define B1111 15
-#define B01111 15
-#define B001111 15
-#define B0001111 15
-#define B00001111 15
-#define B10000 16
-#define B010000 16
-#define B0010000 16
-#define B00010000 16
-#define B10001 17
-#define B010001 17
-#define B0010001 17
-#define B00010001 17
-#define B10010 18
-#define B010010 18
-#define B0010010 18
-#define B00010010 18
-#define B10011 19
-#define B010011 19
-#define B0010011 19
-#define B00010011 19
-#define B10100 20
-#define B010100 20
-#define B0010100 20
-#define B00010100 20
-#define B10101 21
-#define B010101 21
-#define B0010101 21
-#define B00010101 21
-#define B10110 22
-#define B010110 22
-#define B0010110 22
-#define B00010110 22
-#define B10111 23
-#define B010111 23
-#define B0010111 23
-#define B00010111 23
-#define B11000 24
-#define B011000 24
-#define B0011000 24
-#define B00011000 24
-#define B11001 25
-#define B011001 25
-#define B0011001 25
-#define B00011001 25
-#define B11010 26
-#define B011010 26
-#define B0011010 26
-#define B00011010 26
-#define B11011 27
-#define B011011 27
-#define B0011011 27
-#define B00011011 27
-#define B11100 28
-#define B011100 28
-#define B0011100 28
-#define B00011100 28
-#define B11101 29
-#define B011101 29
-#define B0011101 29
-#define B00011101 29
-#define B11110 30
-#define B011110 30
-#define B0011110 30
-#define B00011110 30
-#define B11111 31
-#define B011111 31
-#define B0011111 31
-#define B00011111 31
-#define B100000 32
-#define B0100000 32
-#define B00100000 32
-#define B100001 33
-#define B0100001 33
-#define B00100001 33
-#define B100010 34
-#define B0100010 34
-#define B00100010 34
-#define B100011 35
-#define B0100011 35
-#define B00100011 35
-#define B100100 36
-#define B0100100 36
-#define B00100100 36
-#define B100101 37
-#define B0100101 37
-#define B00100101 37
-#define B100110 38
-#define B0100110 38
-#define B00100110 38
-#define B100111 39
-#define B0100111 39
-#define B00100111 39
-#define B101000 40
-#define B0101000 40
-#define B00101000 40
-#define B101001 41
-#define B0101001 41
-#define B00101001 41
-#define B101010 42
-#define B0101010 42
-#define B00101010 42
-#define B101011 43
-#define B0101011 43
-#define B00101011 43
-#define B101100 44
-#define B0101100 44
-#define B00101100 44
-#define B101101 45
-#define B0101101 45
-#define B00101101 45
-#define B101110 46
-#define B0101110 46
-#define B00101110 46
-#define B101111 47
-#define B0101111 47
-#define B00101111 47
-#define B110000 48
-#define B0110000 48
-#define B00110000 48
-#define B110001 49
-#define B0110001 49
-#define B00110001 49
-#define B110010 50
-#define B0110010 50
-#define B00110010 50
-#define B110011 51
-#define B0110011 51
-#define B00110011 51
-#define B110100 52
-#define B0110100 52
-#define B00110100 52
-#define B110101 53
-#define B0110101 53
-#define B00110101 53
-#define B110110 54
-#define B0110110 54
-#define B00110110 54
-#define B110111 55
-#define B0110111 55
-#define B00110111 55
-#define B111000 56
-#define B0111000 56
-#define B00111000 56
-#define B111001 57
-#define B0111001 57
-#define B00111001 57
-#define B111010 58
-#define B0111010 58
-#define B00111010 58
-#define B111011 59
-#define B0111011 59
-#define B00111011 59
-#define B111100 60
-#define B0111100 60
-#define B00111100 60
-#define B111101 61
-#define B0111101 61
-#define B00111101 61
-#define B111110 62
-#define B0111110 62
-#define B00111110 62
-#define B111111 63
-#define B0111111 63
-#define B00111111 63
-#define B1000000 64
-#define B01000000 64
-#define B1000001 65
-#define B01000001 65
-#define B1000010 66
-#define B01000010 66
-#define B1000011 67
-#define B01000011 67
-#define B1000100 68
-#define B01000100 68
-#define B1000101 69
-#define B01000101 69
-#define B1000110 70
-#define B01000110 70
-#define B1000111 71
-#define B01000111 71
-#define B1001000 72
-#define B01001000 72
-#define B1001001 73
-#define B01001001 73
-#define B1001010 74
-#define B01001010 74
-#define B1001011 75
-#define B01001011 75
-#define B1001100 76
-#define B01001100 76
-#define B1001101 77
-#define B01001101 77
-#define B1001110 78
-#define B01001110 78
-#define B1001111 79
-#define B01001111 79
-#define B1010000 80
-#define B01010000 80
-#define B1010001 81
-#define B01010001 81
-#define B1010010 82
-#define B01010010 82
-#define B1010011 83
-#define B01010011 83
-#define B1010100 84
-#define B01010100 84
-#define B1010101 85
-#define B01010101 85
-#define B1010110 86
-#define B01010110 86
-#define B1010111 87
-#define B01010111 87
-#define B1011000 88
-#define B01011000 88
-#define B1011001 89
-#define B01011001 89
-#define B1011010 90
-#define B01011010 90
-#define B1011011 91
-#define B01011011 91
-#define B1011100 92
-#define B01011100 92
-#define B1011101 93
-#define B01011101 93
-#define B1011110 94
-#define B01011110 94
-#define B1011111 95
-#define B01011111 95
-#define B1100000 96
-#define B01100000 96
-#define B1100001 97
-#define B01100001 97
-#define B1100010 98
-#define B01100010 98
-#define B1100011 99
-#define B01100011 99
-#define B1100100 100
-#define B01100100 100
-#define B1100101 101
-#define B01100101 101
-#define B1100110 102
-#define B01100110 102
-#define B1100111 103
-#define B01100111 103
-#define B1101000 104
-#define B01101000 104
-#define B1101001 105
-#define B01101001 105
-#define B1101010 106
-#define B01101010 106
-#define B1101011 107
-#define B01101011 107
-#define B1101100 108
-#define B01101100 108
-#define B1101101 109
-#define B01101101 109
-#define B1101110 110
-#define B01101110 110
-#define B1101111 111
-#define B01101111 111
-#define B1110000 112
-#define B01110000 112
-#define B1110001 113
-#define B01110001 113
-#define B1110010 114
-#define B01110010 114
-#define B1110011 115
-#define B01110011 115
-#define B1110100 116
-#define B01110100 116
-#define B1110101 117
-#define B01110101 117
-#define B1110110 118
-#define B01110110 118
-#define B1110111 119
-#define B01110111 119
-#define B1111000 120
-#define B01111000 120
-#define B1111001 121
-#define B01111001 121
-#define B1111010 122
-#define B01111010 122
-#define B1111011 123
-#define B01111011 123
-#define B1111100 124
-#define B01111100 124
-#define B1111101 125
-#define B01111101 125
-#define B1111110 126
-#define B01111110 126
-#define B1111111 127
-#define B01111111 127
-#define B10000000 128
-#define B10000001 129
-#define B10000010 130
-#define B10000011 131
-#define B10000100 132
-#define B10000101 133
-#define B10000110 134
-#define B10000111 135
-#define B10001000 136
-#define B10001001 137
-#define B10001010 138
-#define B10001011 139
-#define B10001100 140
-#define B10001101 141
-#define B10001110 142
-#define B10001111 143
-#define B10010000 144
-#define B10010001 145
-#define B10010010 146
-#define B10010011 147
-#define B10010100 148
-#define B10010101 149
-#define B10010110 150
-#define B10010111 151
-#define B10011000 152
-#define B10011001 153
-#define B10011010 154
-#define B10011011 155
-#define B10011100 156
-#define B10011101 157
-#define B10011110 158
-#define B10011111 159
-#define B10100000 160
-#define B10100001 161
-#define B10100010 162
-#define B10100011 163
-#define B10100100 164
-#define B10100101 165
-#define B10100110 166
-#define B10100111 167
-#define B10101000 168
-#define B10101001 169
-#define B10101010 170
-#define B10101011 171
-#define B10101100 172
-#define B10101101 173
-#define B10101110 174
-#define B10101111 175
-#define B10110000 176
-#define B10110001 177
-#define B10110010 178
-#define B10110011 179
-#define B10110100 180
-#define B10110101 181
-#define B10110110 182
-#define B10110111 183
-#define B10111000 184
-#define B10111001 185
-#define B10111010 186
-#define B10111011 187
-#define B10111100 188
-#define B10111101 189
-#define B10111110 190
-#define B10111111 191
-#define B11000000 192
-#define B11000001 193
-#define B11000010 194
-#define B11000011 195
-#define B11000100 196
-#define B11000101 197
-#define B11000110 198
-#define B11000111 199
-#define B11001000 200
-#define B11001001 201
-#define B11001010 202
-#define B11001011 203
-#define B11001100 204
-#define B11001101 205
-#define B11001110 206
-#define B11001111 207
-#define B11010000 208
-#define B11010001 209
-#define B11010010 210
-#define B11010011 211
-#define B11010100 212
-#define B11010101 213
-#define B11010110 214
-#define B11010111 215
-#define B11011000 216
-#define B11011001 217
-#define B11011010 218
-#define B11011011 219
-#define B11011100 220
-#define B11011101 221
-#define B11011110 222
-#define B11011111 223
-#define B11100000 224
-#define B11100001 225
-#define B11100010 226
-#define B11100011 227
-#define B11100100 228
-#define B11100101 229
-#define B11100110 230
-#define B11100111 231
-#define B11101000 232
-#define B11101001 233
-#define B11101010 234
-#define B11101011 235
-#define B11101100 236
-#define B11101101 237
-#define B11101110 238
-#define B11101111 239
-#define B11110000 240
-#define B11110001 241
-#define B11110010 242
-#define B11110011 243
-#define B11110100 244
-#define B11110101 245
-#define B11110110 246
-#define B11110111 247
-#define B11111000 248
-#define B11111001 249
-#define B11111010 250
-#define B11111011 251
-#define B11111100 252
-#define B11111101 253
-#define B11111110 254
-#define B11111111 255
-
-#endif

+ 0 - 14
optiboot/cores/sanguino/main.cpp

@@ -1,14 +0,0 @@
-#include <WProgram.h>
-
-int main(void)
-{
-	init();
-
-	setup();
-    
-	for (;;)
-		loop();
-        
-	return 0;
-}
-

+ 0 - 12
optiboot/cores/sanguino/main.cxx

@@ -1,12 +0,0 @@
-int main(void)
-{
-	init();
-
-	setup();
-    
-	for (;;)
-		loop();
-        
-	return 0;
-}
-

+ 0 - 200
optiboot/cores/sanguino/pins_arduino.c

@@ -1,200 +0,0 @@
-/*
-  pins_arduino.c - pin definitions for the Arduino board
-  Part of Arduino / Wiring Lite
-
-  Copyright (c) 2005 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: pins_arduino.c 254 2007-04-20 23:17:38Z mellis $
-*/
-
-#include <avr/io.h>
-#include "wiring_private.h"
-#include "pins_arduino.h"
-
-// On the Sanguino board, digital pins are also used
-// for the analog output (software PWM).  Analog input
-// pins are a separate set.
-
-// ATMEL ATMEGA644P / SANGUINO
-//
-//                   +---\/---+
-//  INT0 (D 0) PB0  1|        |40  PA0 (AI 0 / D31)
-//  INT1 (D 1) PB1  2|        |39  PA1 (AI 1 / D30)
-//  INT2 (D 2) PB2  3|        |38  PA2 (AI 2 / D29)
-//   PWM (D 3) PB3  4|        |37  PA3 (AI 3 / D28)
-//   PWM (D 4) PB4  5|        |36  PA4 (AI 4 / D27)
-//  MOSI (D 5) PB5  6|        |35  PA5 (AI 5 / D26)
-//  MISO (D 6) PB6  7|        |34  PA6 (AI 6 / D25)
-//   SCK (D 7) PB7  8|        |33  PA7 (AI 7 / D24)
-//             RST  9|        |32  AREF
-//             VCC 10|        |31  GND 
-//             GND 11|        |30  AVCC
-//           XTAL2 12|        |29  PC7 (D 23)
-//           XTAL1 13|        |28  PC6 (D 22)
-//  RX0 (D 8)  PD0 14|        |27  PC5 (D 21) TDI
-//  TX0 (D 9)  PD1 15|        |26  PC4 (D 20) TDO
-//  RX1 (D 10) PD2 16|        |25  PC3 (D 19) TMS
-//  TX1 (D 11) PD3 17|        |24  PC2 (D 18) TCK
-//  PWM (D 12) PD4 18|        |23  PC1 (D 17) SDA
-//  PWM (D 13) PD5 19|        |22  PC0 (D 16) SCL
-//  PWM (D 14) PD6 20|        |21  PD7 (D 15) PWM
-//                   +--------+
-//
-
-#define PA 1
-#define PB 2
-#define PC 3
-#define PD 4
-
-// these arrays map port names (e.g. port B) to the
-// appropriate addresses for various functions (e.g. reading
-// and writing)
-const uint8_t PROGMEM port_to_mode_PGM[] =
-{
-	NOT_A_PORT,
-    &DDRA,
-	&DDRB,
-	&DDRC,
-	&DDRD,
-};
-
-const uint8_t PROGMEM port_to_output_PGM[] =
-{
-	NOT_A_PORT,
-	&PORTA,
-	&PORTB,
-	&PORTC,
-	&PORTD,
-};
-
-const uint8_t PROGMEM port_to_input_PGM[] =
-{
-	NOT_A_PORT,
-	&PINA,
-	&PINB,
-	&PINC,
-	&PIND,
-};
-
-const uint8_t PROGMEM digital_pin_to_port_PGM[] =
-{
-	PB, /* 0 */
-	PB,
-	PB,
-	PB,
-	PB,
-	PB,
-	PB,
-	PB,
-	PD, /* 8 */
-	PD,
-	PD,
-	PD,
-	PD,
-	PD,
-	PD,
-	PD,
-	PC, /* 16 */
-	PC,
-	PC,
-	PC,
-	PC,
-	PC,
-   	PC,
-	PC,
-	PA, /* 24 */
-	PA,
-	PA,
-	PA,
-	PA,
-	PA,
-	PA,
-	PA  /* 31 */
-};
-
-const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] =
-{
-	_BV(0), /* 0, port B */
-	_BV(1),
-	_BV(2),
-	_BV(3),
-	_BV(4),
-	_BV(5),
-	_BV(6),
-	_BV(7),
-	_BV(0), /* 8, port D */
-	_BV(1),
-	_BV(2),
-	_BV(3),
-	_BV(4),
-	_BV(5),
-	_BV(6),
-	_BV(7),
-	_BV(0), /* 16, port C */
-	_BV(1),
-	_BV(2),
-	_BV(3),
-	_BV(4),
-	_BV(5),
-	_BV(6),
-	_BV(7),
-	_BV(7), /* 24, port A */
-	_BV(6),
-	_BV(5),
-	_BV(4),
-	_BV(3),
-	_BV(2),
-	_BV(1),
-	_BV(0)
-};
-
-const uint8_t PROGMEM digital_pin_to_timer_PGM[] =
-{
-	NOT_ON_TIMER, 	/* 0  - PB0 */
-	NOT_ON_TIMER, 	/* 1  - PB1 */
-	NOT_ON_TIMER, 	/* 2  - PB2 */
-	TIMER0A,     	/* 3  - PB3 */
-	TIMER0B, 		/* 4  - PB4 */
-	NOT_ON_TIMER, 	/* 5  - PB5 */
-	NOT_ON_TIMER, 	/* 6  - PB6 */
-	NOT_ON_TIMER,	/* 7  - PB7 */
-	NOT_ON_TIMER, 	/* 8  - PD0 */
-	NOT_ON_TIMER, 	/* 9  - PD1 */
-	NOT_ON_TIMER, 	/* 10 - PD2 */
-	NOT_ON_TIMER, 	/* 11 - PD3 */
-	TIMER1B,     	/* 12 - PD4 */
-	TIMER1A,     	/* 13 - PD5 */
-	TIMER2B,     	/* 14 - PD6 */
-	TIMER2A,     	/* 15 - PD7 */
-	NOT_ON_TIMER, 	/* 16 - PC0 */
-	NOT_ON_TIMER,   /* 17 - PC1 */
-	NOT_ON_TIMER,   /* 18 - PC2 */
-	NOT_ON_TIMER,   /* 19 - PC3 */
-	NOT_ON_TIMER,   /* 20 - PC4 */
-	NOT_ON_TIMER,   /* 21 - PC5 */
-	NOT_ON_TIMER,   /* 22 - PC6 */
-	NOT_ON_TIMER,   /* 23 - PC7 */
-	NOT_ON_TIMER,   /* 24 - PA0 */
-	NOT_ON_TIMER,   /* 25 - PA1 */
-	NOT_ON_TIMER,   /* 26 - PA2 */
-	NOT_ON_TIMER,   /* 27 - PA3 */
-	NOT_ON_TIMER,   /* 28 - PA4 */
-	NOT_ON_TIMER,   /* 29 - PA5 */
-	NOT_ON_TIMER,   /* 30 - PA6 */
-	NOT_ON_TIMER   /* 31 - PA7 */
-};

+ 0 - 65
optiboot/cores/sanguino/pins_arduino.h

@@ -1,65 +0,0 @@
-/*
-  pins_arduino.h - Pin definition functions for Arduino
-  Part of Arduino - http://www.arduino.cc/
-
-  Copyright (c) 2007 David A. Mellis
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General
-  Public License along with this library; if not, write to the
-  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
-  Boston, MA  02111-1307  USA
-
-  $Id: wiring.h 249 2007-02-03 16:52:51Z mellis $
-*/
-
-#ifndef Pins_Arduino_h
-#define Pins_Arduino_h
-
-#include <avr/pgmspace.h>
-
-#define NOT_A_PIN 0
-#define NOT_A_PORT 0
-
-#define NOT_ON_TIMER 0
-#define TIMER0A 1
-#define TIMER0B 2
-#define TIMER1A 3
-#define TIMER1B 4
-#define TIMER2  5
-#define TIMER2A 6
-#define TIMER2B 7
-
-extern const uint8_t PROGMEM port_to_mode_PGM[];
-extern const uint8_t PROGMEM port_to_input_PGM[];
-extern const uint8_t PROGMEM port_to_output_PGM[];
-
-extern const uint8_t PROGMEM digital_pin_to_port_PGM[];
-extern const uint8_t PROGMEM digital_pin_to_bit_PGM[];
-extern const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[];
-
-extern const uint8_t PROGMEM digital_pin_to_timer_PGM[];
-
-// Get the bit location within the hardware port of the given virtual pin.
-// This comes from the pins_*.c file for the active board configuration.
-// 
-// These perform slightly better as macros compared to inline functions
-//
-#define digitalPinToPort(P) ( pgm_read_byte( digital_pin_to_port_PGM + (P) ) )
-#define digitalPinToBitMask(P) ( pgm_read_byte( digital_pin_to_bit_mask_PGM + (P) ) )
-#define digitalPinToTimer(P) ( pgm_read_byte( digital_pin_to_timer_PGM + (P) ) )
-#define analogInPinToBit(P) (P)
-#define portOutputRegister(P) ( (volatile uint8_t *)( pgm_read_byte( port_to_output_PGM + (P))) )
-#define portInputRegister(P) ( (volatile uint8_t *)( pgm_read_byte( port_to_input_PGM + (P))) )
-#define portModeRegister(P) ( (volatile uint8_t *)( pgm_read_byte( port_to_mode_PGM + (P))) )
-
-#endif

+ 0 - 238
optiboot/cores/sanguino/wiring.c

@@ -1,238 +0,0 @@
-/*
-  wiring.c - Partial implementation of the Wiring API for the ATmega8.
-  Part of Arduino - http://www.arduino.cc/
-
-  Copyright (c) 2005-2006 David A. Mellis
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General
-  Public License along with this library; if not, write to the
-  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
-  Boston, MA  02111-1307  USA
-
-  $Id: wiring.c 808 2009-12-18 17:44:08Z dmellis $
-*/
-
-#include "wiring_private.h"
-
-// the prescaler is set so that timer0 ticks every 64 clock cycles, and the
-// the overflow handler is called every 256 ticks.
-#define MICROSECONDS_PER_TIMER0_OVERFLOW (clockCyclesToMicroseconds(64 * 256))
-
-// the whole number of milliseconds per timer0 overflow
-#define MILLIS_INC (MICROSECONDS_PER_TIMER0_OVERFLOW / 1000)
-
-// the fractional number of milliseconds per timer0 overflow. we shift right
-// by three to fit these numbers into a byte. (for the clock speeds we care
-// about - 8 and 16 MHz - this doesn't lose precision.)
-#define FRACT_INC ((MICROSECONDS_PER_TIMER0_OVERFLOW % 1000) >> 3)
-#define FRACT_MAX (1000 >> 3)
-
-volatile unsigned long timer0_overflow_count = 0;
-volatile unsigned long timer0_millis = 0;
-static unsigned char timer0_fract = 0;
-
-SIGNAL(TIMER0_OVF_vect)
-{
-	// copy these to local variables so they can be stored in registers
-	// (volatile variables must be read from memory on every access)
-	unsigned long m = timer0_millis;
-	unsigned char f = timer0_fract;
-
-	m += MILLIS_INC;
-	f += FRACT_INC;
-	if (f >= FRACT_MAX) {
-		f -= FRACT_MAX;
-		m += 1;
-	}
-
-	timer0_fract = f;
-	timer0_millis = m;
-	timer0_overflow_count++;
-}
-
-unsigned long millis()
-{
-	unsigned long m;
-	uint8_t oldSREG = SREG;
-
-	// disable interrupts while we read timer0_millis or we might get an
-	// inconsistent value (e.g. in the middle of a write to timer0_millis)
-	cli();
-	m = timer0_millis;
-	SREG = oldSREG;
-
-	return m;
-}
-
-unsigned long micros() {
-	unsigned long m;
-	uint8_t oldSREG = SREG, t;
-	
-	cli();
-	m = timer0_overflow_count;
-	t = TCNT0;
-  
-#ifdef TIFR0
-	if ((TIFR0 & _BV(TOV0)) && (t < 255))
-		m++;
-#else
-	if ((TIFR & _BV(TOV0)) && (t < 255))
-		m++;
-#endif
-
-	SREG = oldSREG;
-	
-	return ((m << 8) + t) * (64 / clockCyclesPerMicrosecond());
-}
-
-void delay(unsigned long ms)
-{
-	unsigned long start = millis();
-	
-	while (millis() - start <= ms)
-		;
-}
-
-/* Delay for the given number of microseconds.  Assumes a 8 or 16 MHz clock. */
-void delayMicroseconds(unsigned int us)
-{
-	// calling avrlib's delay_us() function with low values (e.g. 1 or
-	// 2 microseconds) gives delays longer than desired.
-	//delay_us(us);
-
-#if F_CPU >= 16000000L
-	// for the 16 MHz clock on most Arduino boards
-
-	// for a one-microsecond delay, simply return.  the overhead
-	// of the function call yields a delay of approximately 1 1/8 us.
-	if (--us == 0)
-		return;
-
-	// the following loop takes a quarter of a microsecond (4 cycles)
-	// per iteration, so execute it four times for each microsecond of
-	// delay requested.
-	us <<= 2;
-
-	// account for the time taken in the preceeding commands.
-	us -= 2;
-#else
-	// for the 8 MHz internal clock on the ATmega168
-
-	// for a one- or two-microsecond delay, simply return.  the overhead of
-	// the function calls takes more than two microseconds.  can't just
-	// subtract two, since us is unsigned; we'd overflow.
-	if (--us == 0)
-		return;
-	if (--us == 0)
-		return;
-
-	// the following loop takes half of a microsecond (4 cycles)
-	// per iteration, so execute it twice for each microsecond of
-	// delay requested.
-	us <<= 1;
-    
-	// partially compensate for the time taken by the preceeding commands.
-	// we can't subtract any more than this or we'd overflow w/ small delays.
-	us--;
-#endif
-
-	// busy wait
-	__asm__ __volatile__ (
-		"1: sbiw %0,1" "\n\t" // 2 cycles
-		"brne 1b" : "=w" (us) : "0" (us) // 2 cycles
-	);
-}
-
-void init()
-{
-	// this needs to be called before setup() or some functions won't
-	// work there
-	sei();
-	
-	// on the ATmega168, timer 0 is also used for fast hardware pwm
-	// (using phase-correct PWM would mean that timer 0 overflowed half as often
-	// resulting in different millis() behavior on the ATmega8 and ATmega168)
-#if !defined(__AVR_ATmega8__)
-	sbi(TCCR0A, WGM01);
-	sbi(TCCR0A, WGM00);
-#endif  
-	// set timer 0 prescale factor to 64
-#if defined(__AVR_ATmega8__)
-	sbi(TCCR0, CS01);
-	sbi(TCCR0, CS00);
-#else
-	sbi(TCCR0B, CS01);
-	sbi(TCCR0B, CS00);
-#endif
-	// enable timer 0 overflow interrupt
-#if defined(__AVR_ATmega8__)
-	sbi(TIMSK, TOIE0);
-#else
-	sbi(TIMSK0, TOIE0);
-#endif
-
-	// timers 1 and 2 are used for phase-correct hardware pwm
-	// this is better for motors as it ensures an even waveform
-	// note, however, that fast pwm mode can achieve a frequency of up
-	// 8 MHz (with a 16 MHz clock) at 50% duty cycle
-
-	// set timer 1 prescale factor to 64
-	sbi(TCCR1B, CS11);
-	sbi(TCCR1B, CS10);
-	// put timer 1 in 8-bit phase correct pwm mode
-	sbi(TCCR1A, WGM10);
-
-	// set timer 2 prescale factor to 64
-#if defined(__AVR_ATmega8__)
-	sbi(TCCR2, CS22);
-#else
-	sbi(TCCR2B, CS22);
-#endif
-	// configure timer 2 for phase correct pwm (8-bit)
-#if defined(__AVR_ATmega8__)
-	sbi(TCCR2, WGM20);
-#else
-	sbi(TCCR2A, WGM20);
-#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);
-#endif
-
-	// set a2d prescale factor to 128
-	// 16 MHz / 128 = 125 KHz, inside the desired 50-200 KHz range.
-	// XXX: this will not work properly for other clock speeds, and
-	// this code should use F_CPU to determine the prescale factor.
-	sbi(ADCSRA, ADPS2);
-	sbi(ADCSRA, ADPS1);
-	sbi(ADCSRA, ADPS0);
-
-	// enable a2d conversions
-	sbi(ADCSRA, ADEN);
-
-	// 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__)
-	UCSRB = 0;
-#else
-	UCSR0B = 0;
-#endif
-}

+ 0 - 133
optiboot/cores/sanguino/wiring.h

@@ -1,133 +0,0 @@
-/*
-  wiring.h - Partial implementation of the Wiring API for the ATmega8.
-  Part of Arduino - http://www.arduino.cc/
-
-  Copyright (c) 2005-2006 David A. Mellis
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General
-  Public License along with this library; if not, write to the
-  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
-  Boston, MA  02111-1307  USA
-
-  $Id: wiring.h 804 2009-12-18 16:05:52Z dmellis $
-*/
-
-#ifndef Wiring_h
-#define Wiring_h
-
-#include <avr/io.h>
-#include "binary.h"
-
-#ifdef __cplusplus
-extern "C"{
-#endif
-
-#define HIGH 0x1
-#define LOW  0x0
-
-#define INPUT 0x0
-#define OUTPUT 0x1
-
-#define true 0x1
-#define false 0x0
-
-#define PI 3.1415926535897932384626433832795
-#define HALF_PI 1.5707963267948966192313216916398
-#define TWO_PI 6.283185307179586476925286766559
-#define DEG_TO_RAD 0.017453292519943295769236907684886
-#define RAD_TO_DEG 57.295779513082320876798154814105
-
-#define SERIAL  0x0
-#define DISPLAY 0x1
-
-#define LSBFIRST 0
-#define MSBFIRST 1
-
-#define CHANGE 1
-#define FALLING 2
-#define RISING 3
-
-#define INTERNAL 3
-#define DEFAULT 1
-#define EXTERNAL 0
-
-// undefine stdlib's abs if encountered
-#ifdef abs
-#undef abs
-#endif
-
-#define min(a,b) ((a)<(b)?(a):(b))
-#define max(a,b) ((a)>(b)?(a):(b))
-#define abs(x) ((x)>0?(x):-(x))
-#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
-#define round(x)     ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
-#define radians(deg) ((deg)*DEG_TO_RAD)
-#define degrees(rad) ((rad)*RAD_TO_DEG)
-#define sq(x) ((x)*(x))
-
-#define interrupts() sei()
-#define noInterrupts() cli()
-
-#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L )
-#define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() )
-#define microsecondsToClockCycles(a) ( (a) * clockCyclesPerMicrosecond() )
-
-#define lowByte(w) ((uint8_t) ((w) & 0xff))
-#define highByte(w) ((uint8_t) ((w) >> 8))
-
-#define bitRead(value, bit) (((value) >> (bit)) & 0x01)
-#define bitSet(value, bit) ((value) |= (1UL << (bit)))
-#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
-#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))
-
-typedef unsigned int word;
-
-#define bit(b) (1UL << (b))
-
-typedef uint8_t boolean;
-typedef uint8_t byte;
-
-void init(void);
-
-void pinMode(uint8_t, uint8_t);
-void digitalWrite(uint8_t, uint8_t);
-int digitalRead(uint8_t);
-int analogRead(uint8_t);
-void analogReference(uint8_t mode);
-void analogWrite(uint8_t, int);
-
-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 attachInterrupt(uint8_t, void (*)(void), int mode);
-void detachInterrupt(uint8_t);
-
-void setup(void);
-void loop(void);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif

+ 0 - 179
optiboot/cores/sanguino/wiring_analog.c

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

+ 0 - 111
optiboot/cores/sanguino/wiring_digital.c

@@ -1,111 +0,0 @@
-/*
-  wiring_digital.c - digital input and output functions
-  Part of Arduino - http://www.arduino.cc/
-
-  Copyright (c) 2005-2006 David A. Mellis
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General
-  Public License along with this library; if not, write to the
-  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
-  Boston, MA  02111-1307  USA
-
-  $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $
-*/
-
-#include "wiring_private.h"
-#include "pins_arduino.h"
-
-void pinMode(uint8_t pin, uint8_t mode)
-{
-	uint8_t bit = digitalPinToBitMask(pin);
-	uint8_t port = digitalPinToPort(pin);
-	volatile uint8_t *reg;
-
-	if (port == NOT_A_PIN) return;
-
-	// JWS: can I let the optimizer do this?
-	reg = portModeRegister(port);
-
-	if (mode == INPUT) *reg &= ~bit;
-	else *reg |= bit;
-}
-
-// Forcing this inline keeps the callers from having to push their own stuff
-// on the stack. It is a good performance win and only takes 1 more byte per
-// user than calling. (It will take more bytes on the 168.)
-//
-// But shouldn't this be moved into pinMode? Seems silly to check and do on
-// each digitalread or write.
-//
-static inline void turnOffPWM(uint8_t timer) __attribute__ ((always_inline));
-static inline 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
-}
-
-void digitalWrite(uint8_t pin, uint8_t val)
-{
-	uint8_t timer = digitalPinToTimer(pin);
-	uint8_t bit = digitalPinToBitMask(pin);
-	uint8_t port = digitalPinToPort(pin);
-	volatile uint8_t *out;
-
-	if (port == NOT_A_PIN) return;
-
-	// If the pin that support PWM output, we need to turn it off
-	// before doing a digital write.
-	if (timer != NOT_ON_TIMER) turnOffPWM(timer);
-
-	out = portOutputRegister(port);
-
-	if (val == LOW) *out &= ~bit;
-	else *out |= bit;
-}
-
-int digitalRead(uint8_t pin)
-{
-	uint8_t timer = digitalPinToTimer(pin);
-	uint8_t bit = digitalPinToBitMask(pin);
-	uint8_t port = digitalPinToPort(pin);
-
-	if (port == NOT_A_PIN) return LOW;
-
-	// If the pin that support PWM output, we need to turn it off
-	// before getting a digital reading.
-	if (timer != NOT_ON_TIMER) turnOffPWM(timer);
-
-	if (*portInputRegister(port) & bit) return HIGH;
-	return LOW;
-}

+ 0 - 68
optiboot/cores/sanguino/wiring_private.h

@@ -1,68 +0,0 @@
-/*
-  wiring_private.h - Internal header file.
-  Part of Arduino - http://www.arduino.cc/
-
-  Copyright (c) 2005-2006 David A. Mellis
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General
-  Public License along with this library; if not, write to the
-  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
-  Boston, MA  02111-1307  USA
-
-  $Id: wiring.h 239 2007-01-12 17:58:39Z mellis $
-*/
-
-#ifndef WiringPrivate_h
-#define WiringPrivate_h
-
-#include <avr/io.h>
-#include <avr/interrupt.h>
-#include <avr/delay.h>
-#include <stdio.h>
-#include <stdarg.h>
-
-#include "wiring.h"
-
-#ifdef __cplusplus
-extern "C"{
-#endif
-
-#ifndef cbi
-#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
-#endif
-#ifndef sbi
-#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
-#endif
-
-#define EXTERNAL_INT_0 0
-#define EXTERNAL_INT_1 1
-#define EXTERNAL_INT_2 2
-#define EXTERNAL_INT_3 3
-#define EXTERNAL_INT_4 4
-#define EXTERNAL_INT_5 5
-#define EXTERNAL_INT_6 6
-#define EXTERNAL_INT_7 7
-
-#if defined(__AVR_ATmega1280__)
-#define EXTERNAL_NUM_INTERRUPTS 8
-#else
-#define EXTERNAL_NUM_INTERRUPTS 2
-#endif
-
-typedef void (*voidFuncPtr)(void);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif

+ 0 - 66
optiboot/cores/sanguino/wiring_pulse.c

@@ -1,66 +0,0 @@
-/*
-  wiring_pulse.c - pulseIn() function
-  Part of Arduino - http://www.arduino.cc/
-
-  Copyright (c) 2005-2006 David A. Mellis
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General
-  Public License along with this library; if not, write to the
-  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
-  Boston, MA  02111-1307  USA
-
-  $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $
-*/
-
-#include "wiring_private.h"
-#include "pins_arduino.h"
-
-/* Measures the length (in microseconds) of a pulse on the pin; state is HIGH
- * or LOW, the type of pulse to measure.  Works on pulses from 2-3 microseconds
- * to 3 minutes in length, but must be called at least a few dozen microseconds
- * before the start of the pulse. */
-unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout)
-{
-	// cache the port and bit of the pin in order to speed up the
-	// pulse width measuring loop and achieve finer resolution.  calling
-	// digitalRead() instead yields much coarser resolution.
-	uint8_t bit = digitalPinToBitMask(pin);
-	uint8_t port = digitalPinToPort(pin);
-	uint8_t stateMask = (state ? bit : 0);
-	unsigned long width = 0; // keep initialization out of time critical area
-	
-	// convert the timeout from microseconds to a number of times through
-	// the initial loop; it takes 16 clock cycles per iteration.
-	unsigned long numloops = 0;
-	unsigned long maxloops = microsecondsToClockCycles(timeout) / 16;
-	
-	// wait for any previous pulse to end
-	while ((*portInputRegister(port) & bit) == stateMask)
-		if (numloops++ == maxloops)
-			return 0;
-	
-	// wait for the pulse to start
-	while ((*portInputRegister(port) & bit) != stateMask)
-		if (numloops++ == maxloops)
-			return 0;
-	
-	// wait for the pulse to stop
-	while ((*portInputRegister(port) & bit) == stateMask)
-		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
-	// and the start of the loop. There will be some error introduced by
-	// the interrupt handlers.
-	return clockCyclesToMicroseconds(width * 10 + 16); 
-}

+ 0 - 138
optiboot/cores/sanguino/wiring_serial.c

@@ -1,138 +0,0 @@
-/*
-  wiring_serial.c - serial functions.
-  Part of Arduino - http://www.arduino.cc/
-
-  Copyright (c) 2005-2006 David A. Mellis
-  Modified 29 January 2009, Marius Kintel for Sanguino - http://www.sanguino.cc/
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General
-  Public License along with this library; if not, write to the
-  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
-  Boston, MA  02111-1307  USA
-
-  $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $
-*/
-
-
-#include "wiring_private.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 defined(__AVR_ATmega644P__)
-unsigned char rx_buffer[2][RX_BUFFER_SIZE];
-int rx_buffer_head[2] = {0, 0};
-int rx_buffer_tail[2] = {0, 0};
-#else
-unsigned char rx_buffer[1][RX_BUFFER_SIZE];
-int rx_buffer_head[1] = {0};
-int rx_buffer_tail[1] = {0};
-#endif
-
-
-#define BEGIN_SERIAL(uart_, baud_) \
-{ \
-    UBRR##uart_##H = ((F_CPU / 16 + baud / 2) / baud - 1) >> 8; \
-    UBRR##uart_##L = ((F_CPU / 16 + baud / 2) / baud - 1); \
-    \
-    /* reset config for UART */ \
-    UCSR##uart_##A = 0; \
-    UCSR##uart_##B = 0; \
-    UCSR##uart_##C = 0; \
-    \
-    /* enable rx and tx */ \
-    sbi(UCSR##uart_##B, RXEN##uart_);\
-    sbi(UCSR##uart_##B, TXEN##uart_);\
-    \
-    /* enable interrupt on complete reception of a byte */ \
-    sbi(UCSR##uart_##B, RXCIE##uart_); \
-    UCSR##uart_##C = _BV(UCSZ##uart_##1)|_BV(UCSZ##uart_##0); \
-    /* defaults to 8-bit, no parity, 1 stop bit */ \
-}
-
-void beginSerial(uint8_t uart, long baud)
-{
-  if (uart == 0) BEGIN_SERIAL(0, baud)
-#if defined(__AVR_ATmega644P__)
-  else BEGIN_SERIAL(1, baud)
-#endif
-}
-
-#define SERIAL_WRITE(uart_, c_) \
-    while (!(UCSR##uart_##A & (1 << UDRE##uart_))) \
-      ; \
-    UDR##uart_ = c
-
-void serialWrite(uint8_t uart, unsigned char c)
-{
-  if (uart == 0) {
-    SERIAL_WRITE(0, c);
-  }
-#if defined(__AVR_ATmega644P__)
-  else {
-    SERIAL_WRITE(1, c);
-  }
-#endif
-}
-
-int serialAvailable(uint8_t uart)
-{
-  return (RX_BUFFER_SIZE + rx_buffer_head[uart] - rx_buffer_tail[uart]) % RX_BUFFER_SIZE;
-}
-
-int serialRead(uint8_t uart)
-{
-  // if the head isn't ahead of the tail, we don't have any characters
-  if (rx_buffer_head[uart] == rx_buffer_tail[uart]) {
-    return -1;
-  } else {
-    unsigned char c = rx_buffer[uart][rx_buffer_tail[uart]];
-    rx_buffer_tail[uart] = (rx_buffer_tail[uart] + 1) % RX_BUFFER_SIZE;
-    return c;
-  }
-}
-
-void serialFlush(uint8_t uart)
-{
-  // don't reverse this or there may be problems if the RX interrupt
-  // occurs after reading the value of rx_buffer_head but before writing
-  // the value to rx_buffer_tail; the previous value of rx_buffer_head
-  // may be written to rx_buffer_tail, making it appear as if the buffer
-  // were full, not empty.
-  rx_buffer_head[uart] = rx_buffer_tail[uart];
-}
-
-#define UART_ISR(uart_) \
-ISR(USART##uart_##_RX_vect) \
-{ \
-  unsigned char c = UDR##uart_; \
-  \
-  int i = (rx_buffer_head[uart_] + 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 \
-     current location of the tail), we're about to overflow the buffer \
-     and so we don't write the character or advance the head. */ \
-  if (i != rx_buffer_tail[uart_]) { \
-    rx_buffer[uart_][rx_buffer_head[uart_]] = c; \
-    rx_buffer_head[uart_] = i; \
-  } \
-}
-
-UART_ISR(0)
-#if defined(__AVR_ATmega644P__) 
-UART_ISR(1)
-#endif

+ 0 - 40
optiboot/cores/sanguino/wiring_shift.c

@@ -1,40 +0,0 @@
-/*
-  wiring_shift.c - shiftOut() function
-  Part of Arduino - http://www.arduino.cc/
-
-  Copyright (c) 2005-2006 David A. Mellis
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General
-  Public License along with this library; if not, write to the
-  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
-  Boston, MA  02111-1307  USA
-
-  $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $
-*/
-
-#include "wiring_private.h"
-
-void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, byte val)
-{
-	int i;
-
-	for (i = 0; i < 8; i++)  {
-		if (bitOrder == LSBFIRST)
-			digitalWrite(dataPin, !!(val & (1 << i)));
-		else	
-			digitalWrite(dataPin, !!(val & (1 << (7 - i))));
-			
-		digitalWrite(clockPin, HIGH);
-		digitalWrite(clockPin, LOW);		
-	}
-}