From b17b8583afc3cf43a048c6209bd56492794fa107 Mon Sep 17 00:00:00 2001 From: Bo Herrmannsen Date: Wed, 17 Dec 2014 23:01:30 +0100 Subject: [PATCH] adding hardware files for OMC for ide 1.0.6 --- .../Arduino_1.0.x/hardware/OMC_tkj/boards.txt | 23 + .../bootloaders/OMC/bootloader-644-20MHz.hex | 75 ++ .../bootloaders/atmega644p/ATmegaBOOT.c | 713 ++++++++++++++++++ .../atmega644p/ATmegaBOOT_324P.hex | 121 +++ .../bootloaders/atmega644p/ATmegaBOOT_644.hex | 120 +++ .../atmega644p/ATmegaBOOT_644P.hex | 121 +++ .../OMC_tkj/bootloaders/atmega644p/Makefile | 56 ++ .../OMC_tkj/bootloaders/atmega644p/README.txt | 3 + .../OMC_tkj/variants/sanguino/pins_arduino.h | 269 +++++++ 9 files changed, 1501 insertions(+) create mode 100644 ArduinoAddons/Arduino_1.0.x/hardware/OMC_tkj/boards.txt create mode 100644 ArduinoAddons/Arduino_1.0.x/hardware/OMC_tkj/bootloaders/OMC/bootloader-644-20MHz.hex create mode 100644 ArduinoAddons/Arduino_1.0.x/hardware/OMC_tkj/bootloaders/atmega644p/ATmegaBOOT.c create mode 100644 ArduinoAddons/Arduino_1.0.x/hardware/OMC_tkj/bootloaders/atmega644p/ATmegaBOOT_324P.hex create mode 100644 ArduinoAddons/Arduino_1.0.x/hardware/OMC_tkj/bootloaders/atmega644p/ATmegaBOOT_644.hex create mode 100644 ArduinoAddons/Arduino_1.0.x/hardware/OMC_tkj/bootloaders/atmega644p/ATmegaBOOT_644P.hex create mode 100644 ArduinoAddons/Arduino_1.0.x/hardware/OMC_tkj/bootloaders/atmega644p/Makefile create mode 100644 ArduinoAddons/Arduino_1.0.x/hardware/OMC_tkj/bootloaders/atmega644p/README.txt create mode 100644 ArduinoAddons/Arduino_1.0.x/hardware/OMC_tkj/variants/sanguino/pins_arduino.h diff --git a/ArduinoAddons/Arduino_1.0.x/hardware/OMC_tkj/boards.txt b/ArduinoAddons/Arduino_1.0.x/hardware/OMC_tkj/boards.txt new file mode 100644 index 0000000000..363d615529 --- /dev/null +++ b/ArduinoAddons/Arduino_1.0.x/hardware/OMC_tkj/boards.txt @@ -0,0 +1,23 @@ +############################################################## + +omc.name=OMC with Atmega644 at 20Mhz + +omc.upload.maximum_size=63488 +omc.upload.maximum_data_size=4096 + +omc.upload.protocol=stk500v2 +omc.upload.speed=115200 +omc.bootloader.path=OMC +omc.bootloader.file=bootloader-644-20MHz.hex + +omc.bootloader.low_fuses=0xE7 +omc.bootloader.high_fuses=0xD4 +omc.bootloader.extended_fuses=0xFC +omc.bootloader.unlock_bits=0x3F +omc.bootloader.lock_bits=0x0F + +omc.build.mcu=atmega644 +omc.build.f_cpu=20000000L +omc.build.board=AVR_OMC +omc.build.core=arduino:arduino +omc.build.variant=sanguino \ No newline at end of file diff --git a/ArduinoAddons/Arduino_1.0.x/hardware/OMC_tkj/bootloaders/OMC/bootloader-644-20MHz.hex b/ArduinoAddons/Arduino_1.0.x/hardware/OMC_tkj/bootloaders/OMC/bootloader-644-20MHz.hex new file mode 100644 index 0000000000..d216c65f9b --- /dev/null +++ b/ArduinoAddons/Arduino_1.0.x/hardware/OMC_tkj/bootloaders/OMC/bootloader-644-20MHz.hex @@ -0,0 +1,75 @@ +:10F800008FEF90E19EBF8DBF11241FBE5A9A00C09A +:10F81000CDB7DEB7CD51D140DEBFCDBF1092C50010 +:10F820008AE08093C40088E18093C100EE24FF2425 +:10F8300020E0552400E010E039E0432E9BE0292E23 +:10F84000312C2C0E3D1ECFC14150504060407040C5 +:10F8500011F43FE206C08091C00087FFF5CF3091E0 +:10F86000C600933021F1943028F4913099F0923011 +:10F87000C8F407C0953049F1953000F19630D1F5C4 +:10F8800035C03B3119F491E02BE134C03F3291F5A2 +:10F890003983BBC1313011F0351559F52327532E6B +:10F8A00092E028C0B32FA0E0232793E023C0832F4A +:10F8B00090E0A82BB92B232794E01CC03E30C9F45C +:10F8C000232795E0EE24FF2415C0E1E0F0E0EC0FE3 +:10F8D000FD1FEE0DFF1D30830894E11CF11C232752 +:10F8E000EA16FB0639F4D70196E004C0321709F492 +:10F8F0008CC190E041ED5AE363E570E0ACCF90E05D +:10F9000044C08D81803311F090E00AC08F8188233C +:10F9100011F49EE105C0813011F099E001C096E933 +:10F920001A821B828D818C838E818D839E831F82A0 +:10F9300047E050E0F4C01A8288E08B8381E48C8336 +:10F9400086E58D8382E58E8389E48F8383E58887CE +:10F9500080E589878FE58A8782E38B874BE050E0DB +:10F96000DEC08A81813941F0823941F0803911F459 +:10F970008FE005C080E003C082E001C08AE01A8207 +:10F980008B8343E050E0CBC091E01A8242E050E02C +:10F99000C7C08D81882311F48EE124C0813011F01D +:10F9A00089E020C086E91EC01A82E1E0F0E04092C2 +:10F9B0005700849118C08B81803579F48C81883010 +:10F9C00031F4E2E0F0E04092570084910BC0E0E0B7 +:10F9D000F0E040925700849105C0E3E0F0E04092EF +:10F9E000570084911A828B831C8244E050E097C0B8 +:10F9F000BC80AA248D81082F10E00A291B29000F42 +:10FA0000111F1A828AC09A8088248B81682F70E027 +:10FA100068297929933109F033C0F7EF0F3F1F07A9 +:10FA200010F0A8013FC023E0F80120935700E895AB +:10FA300007B600FCFDCFA801D1018C9111962C9145 +:10FA400011971296D22ECC2490E08C299D2921E08A +:10FA5000FA010C0120935700E89511244E5F5F4F87 +:10FA60006250704051F725E0F80120935700E89567 +:10FA700007B600FCFDCF81E180935700E89512C0E6 +:10FA8000A801FB01D10141BD52BD4F5F5F4F8D9178 +:10FA900080BDFA9AF99AF999FECF3197A1F7A8019A +:10FAA000460F571F1A828A0138C07A8066248B81DC +:10FAB000A82FB0E0A629B7291A828981843191F450 +:10FAC000BD019E012D5F3F4FF80185919491F90191 +:10FAD000808391832E5F3F4F0E5F1F4F62507040B7 +:10FAE00099F713C0A801BD019E012D5F3F4F41BD95 +:10FAF00052BD4F5F5F4FF89A80B5F90181939F0126 +:10FB000061507040A1F70A0F1B1FAD014D5F5F4FA1 +:10FB1000F901108204C080EC8A8342E050E090E05A +:10FB2000FBE1F093C6008091C00086FFFCCF80917E +:10FB3000C00080648093C0005092C6008091C000D5 +:10FB400086FFFCCF8091C00080648093C000652F49 +:10FB50005093C6008091C00086FFFCCF8091C0000A +:10FB600080648093C000342F4093C6008091C00011 +:10FB700086FFFCCF8091C00080648093C0008EE03F +:10FB80008093C6008091C00086FFFCCF8091C000AA +:10FB900080648093C00025E1252523272627FE01C8 +:10FBA000319610C030813093C6008091C00086FF2E +:10FBB000FCCF31968091C00080648093C0002327E1 +:10FBC000415050404115510569F72093C60080917E +:10FBD000C00086FFFCCF8091C00080648093C0008D +:10FBE000992349F4539441ED5AE363E570E090E0C2 +:10FBF000A0E0B0E030CE5A9881E180935700E895BC +:10FC000011241F921F920895FFCF9981933109F417 +:10FC1000FACE9431C8F4963009F4EACE973050F415 +:10FC2000923009F46CCE933009F49BCE913009F0F8 +:10FC300072CF81CE913109F4A7CE923108F0E1CE96 +:10FC4000903109F068CF5BCE983109F4B4CE993188 +:10FC500050F4953109F4D7CE953108F426CF96317A +:10FC600009F059CF22CF9B3109F493CE9C3120F477 +:10FC70009A3109F050CF98CE9D3109F442CE9F328F +:06FC800009F049CFB8CFE6 +:040000030000F80001 +:00000001FF diff --git a/ArduinoAddons/Arduino_1.0.x/hardware/OMC_tkj/bootloaders/atmega644p/ATmegaBOOT.c b/ArduinoAddons/Arduino_1.0.x/hardware/OMC_tkj/bootloaders/atmega644p/ATmegaBOOT.c new file mode 100644 index 0000000000..1711014459 --- /dev/null +++ b/ArduinoAddons/Arduino_1.0.x/hardware/OMC_tkj/bootloaders/atmega644p/ATmegaBOOT.c @@ -0,0 +1,713 @@ +/**********************************************************/ +/* Serial Bootloader for Atmel megaAVR Controllers */ +/* */ +/* tested with ATmega644 and ATmega644P */ +/* should work with other mega's, see code for details */ +/* */ +/* ATmegaBOOT.c */ +/* */ +/* 20090131: Added 324P support from Alex Leone */ +/* Marius Kintel */ +/* 20080915: applied ADABoot mods for Sanguino 644P */ +/* Brian Riley */ +/* 20080711: hacked for Sanguino by Zach Smith */ +/* and Justin Day */ +/* 20070626: hacked for Arduino Diecimila (which auto- */ +/* resets when a USB connection is made to it) */ +/* by D. Mellis */ +/* 20060802: hacked for Arduino by D. Cuartielles */ +/* based on a previous hack by D. Mellis */ +/* and D. Cuartielles */ +/* */ +/* Monitor and debug functions were added to the original */ +/* code by Dr. Erik Lins, chip45.com. (See below) */ +/* */ +/* Thanks to Karl Pitrich for fixing a bootloader pin */ +/* problem and more informative LED blinking! */ +/* */ +/* For the latest version see: */ +/* http://www.chip45.com/ */ +/* */ +/* ------------------------------------------------------ */ +/* */ +/* based on stk500boot.c */ +/* Copyright (c) 2003, Jason P. Kyle */ +/* All rights reserved. */ +/* see avr1.org for original file and information */ +/* */ +/* This program is free software; you can redistribute it */ +/* and/or modify it under the terms of the GNU General */ +/* Public License as published by the Free Software */ +/* Foundation; either version 2 of the License, or */ +/* (at your option) any later version. */ +/* */ +/* This program is distributed in the hope that it will */ +/* be useful, but WITHOUT ANY WARRANTY; without even the */ +/* implied warranty of MERCHANTABILITY or FITNESS FOR A */ +/* PARTICULAR PURPOSE. See the GNU General Public */ +/* License for more details. */ +/* */ +/* You should have received a copy of the GNU General */ +/* Public License along with this program; if not, write */ +/* to the Free Software Foundation, Inc., */ +/* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +/* */ +/* Licence can be viewed at */ +/* http://www.fsf.org/licenses/gpl.txt */ +/* */ +/* Target = Atmel AVR m128,m64,m32,m16,m8,m162,m163,m169, */ +/* m8515,m8535. ATmega161 has a very small boot block so */ +/* isn't supported. */ +/* */ +/* Tested with m168 */ +/**********************************************************/ + +/* $Id$ */ + + +/* some includes */ +#include +#include +#include +#include +#include +#include + +#ifdef ADABOOT + #define NUM_LED_FLASHES 3 + #define ADABOOT_VER 1 +#endif + + +/* 20070707: hacked by David A. Mellis - after this many errors give up and launch application */ +#define MAX_ERROR_COUNT 5 + +/* set the UART baud rate */ +/* 20080711: hack by Zach Hoeken */ +#define BAUD_RATE 38400 + +/* SW_MAJOR and MINOR needs to be updated from time to time to avoid warning message from AVR Studio */ +/* never allow AVR Studio to do an update !!!! */ +#define HW_VER 0x02 +#define SW_MAJOR 0x01 +#define SW_MINOR 0x10 + +/* onboard LED is used to indicate, that the bootloader was entered (3x flashing) */ +/* if monitor functions are included, LED goes on after monitor was entered */ +#define LED_DDR DDRB +#define LED_PORT PORTB +#define LED_PIN PINB +#define LED PINB0 + +/* define various device id's */ +/* manufacturer byte is always the same */ +#define SIG1 0x1E // Yep, Atmel is the only manufacturer of AVR micros. Single source :( +#if defined(__AVR_ATmega644P__) +#define SIG2 0x96 +#define SIG3 0x0A +#elif defined(__AVR_ATmega644__) +#define SIG2 0x96 +#define SIG3 0x09 +#elif defined(__AVR_ATmega324P__) +#define SIG2 0x95 +#define SIG3 0x08 +#endif +#define PAGE_SIZE 0x080U //128 words +#define PAGE_SIZE_BYTES 0x100U //256 bytes + +/* function prototypes */ +void putch(char); +char getch(void); +void getNch(uint8_t); +void byte_response(uint8_t); +void nothing_response(void); +char gethex(void); +void puthex(char); +void flash_led(uint8_t); + +/* some variables */ +union address_union +{ + uint16_t word; + uint8_t byte[2]; +} address; + +union length_union +{ + uint16_t word; + uint8_t byte[2]; +} length; + +struct flags_struct +{ + unsigned eeprom : 1; + unsigned rampz : 1; +} flags; + +uint8_t buff[256]; + +uint8_t error_count = 0; +uint8_t sreg; + +void (*app_start)(void) = 0x0000; + +/* main program starts here */ +int main(void) +{ + uint8_t ch,ch2; + uint16_t w; + uint16_t i; + + asm volatile("nop\n\t"); + +#ifdef ADABOOT // BBR/LF 10/8/2007 & 9/13/2008 + ch = MCUSR; + MCUSR = 0; + + WDTCSR |= _BV(WDCE) | _BV(WDE); + WDTCSR = 0; + + // Check if the WDT was used to reset, in which case we dont bootload and skip straight to the code. woot. + if (! (ch & _BV(EXTRF))) // if its a not an external reset... + app_start(); // skip bootloader +#endif + + + //initialize our serial port. + UBRR0L = (uint8_t)(F_CPU/(BAUD_RATE*16L)-1); + UBRR0H = (F_CPU/(BAUD_RATE*16L)-1) >> 8; + UCSR0B = (1< 0x85) + getch(); + nothing_response(); + } + + + /* AVR ISP/STK500 board requests */ + else if(ch=='A') + { + ch2 = getch(); + if(ch2 == 0x80) + byte_response(HW_VER); // Hardware version + else if(ch2==0x81) + byte_response(SW_MAJOR); // Software major version + else if(ch2==0x82) + byte_response(SW_MINOR); // Software minor version + else if(ch2==0x98) + byte_response(0x03); // Unknown but seems to be required by avr studio 3.56 + else + byte_response(0x00); // Covers various unnecessary responses we don't care about + } + + + /* Device Parameters DON'T CARE, DEVICE IS FIXED */ + else if(ch=='B') + { + getNch(20); + nothing_response(); + } + + + /* Parallel programming stuff DON'T CARE */ + else if(ch=='E') + { + getNch(5); + nothing_response(); + } + + + /* Enter programming mode */ + else if(ch=='P') + { + nothing_response(); + } + + + /* Leave programming mode */ + else if(ch=='Q') + { + nothing_response(); +#ifdef ADABOOT + // autoreset via watchdog (sneaky!) BBR/LF 9/13/2008 + WDTCSR = _BV(WDE); + while (1); // 16 ms +#endif + } + + + /* Erase device, don't care as we will erase one page at a time anyway. */ + else if(ch=='R') + { + nothing_response(); + } + + + /* Set address, little endian. EEPROM in bytes, FLASH in words */ + /* Perhaps extra address bytes may be added in future to support > 128kB FLASH. */ + /* This might explain why little endian was used here, big endian used everywhere else. */ + else if(ch=='U') + { + address.byte[0] = getch(); + address.byte[1] = getch(); + nothing_response(); + } + + + /* Universal SPI programming command, disabled. Would be used for fuses and lock bits. */ + else if(ch=='V') + { + getNch(4); + byte_response(0x00); + } + + + /* Write memory, length is big endian and is in bytes */ + else if(ch=='d') + { + length.byte[1] = getch(); + length.byte[0] = getch(); + + flags.eeprom = 0; + if (getch() == 'E') + flags.eeprom = 1; + + for (i=0; i byte location + address.word = address.word << 1; + + //Even up an odd number of bytes + if ((length.byte[0] & 0x01)) + length.word++; + + // HACKME: EEPE used to be EEWE + //Wait for previous EEPROM writes to complete + //while(bit_is_set(EECR,EEPE)); + while(EECR & (1< byte location + } + + // Command terminator + if (getch() == ' ') + { + putch(0x14); + for (w=0; w= 'a') + ah = ah - 'a' + 0x0a; + else if(ah >= '0') + ah -= '0'; + if(al >= 'a') + al = al - 'a' + 0x0a; + else if(al >= '0') + al -= '0'; + + return (ah << 4) + al; +} + + +void puthex(char ch) +{ + char ah,al; + + ah = (ch & 0xf0) >> 4; + if(ah >= 0x0a) + ah = ah - 0x0a + 'a'; + else + ah += '0'; + + al = (ch & 0x0f); + if(al >= 0x0a) + al = al - 0x0a + 'a'; + else + al += '0'; + + putch(ah); + putch(al); +} + + +void putch(char ch) +{ + while (!(UCSR0A & _BV(UDRE0))); + UDR0 = ch; +} + + + + +char getch(void) +{ + uint32_t count = 0; + +#ifdef ADABOOT + LED_PORT &= ~_BV(LED); // toggle LED to show activity - BBR/LF 10/3/2007 & 9/13/2008 +#endif + + while(!(UCSR0A & _BV(RXC0))) + { + /* 20060803 DojoCorp:: Addon coming from the previous Bootloader*/ + /* HACKME:: here is a good place to count times*/ + count++; + if (count > MAX_TIME_COUNT) + app_start(); + } + +#ifdef ADABOOT + LED_PORT |= _BV(LED); // toggle LED to show activity - BBR/LF 10/3/2007 & 9/13/2008 +#endif + + return UDR0; +} + + +void getNch(uint8_t count) +{ + uint8_t i; + for(i=0;i $@ + +%.srec: %.elf + $(OBJCOPY) -j .text -j .data -O srec $< $@ + +%.bin: %.elf + $(OBJCOPY) -j .text -j .data -O binary $< $@ + +clean: + rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep *.srec *.bin *.hex + \ No newline at end of file diff --git a/ArduinoAddons/Arduino_1.0.x/hardware/OMC_tkj/bootloaders/atmega644p/README.txt b/ArduinoAddons/Arduino_1.0.x/hardware/OMC_tkj/bootloaders/atmega644p/README.txt new file mode 100644 index 0000000000..8286007851 --- /dev/null +++ b/ArduinoAddons/Arduino_1.0.x/hardware/OMC_tkj/bootloaders/atmega644p/README.txt @@ -0,0 +1,3 @@ +Note: This bootloader support ATmega644, ATmega644P and ATmega324P. +To build, set PROGRAM and MCU_TARGET in the Makefile according to your target device. + diff --git a/ArduinoAddons/Arduino_1.0.x/hardware/OMC_tkj/variants/sanguino/pins_arduino.h b/ArduinoAddons/Arduino_1.0.x/hardware/OMC_tkj/variants/sanguino/pins_arduino.h new file mode 100644 index 0000000000..f4298d8682 --- /dev/null +++ b/ArduinoAddons/Arduino_1.0.x/hardware/OMC_tkj/variants/sanguino/pins_arduino.h @@ -0,0 +1,269 @@ +/* + 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 $ + + Changelog + ----------- + 11/25/11 - ryan@ryanmsutton.com - Add pins for Sanguino 644P and 1284P + 07/15/12 - ryan@ryanmsutton.com - Updated for arduino0101 + + Improvements by Kristian Lauszus, kristianl@tkjelectronics.dk +*/ + +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include + +const static uint8_t SS = 4; +const static uint8_t MOSI = 5; +const static uint8_t MISO = 6; +const static uint8_t SCK = 7; + +static const uint8_t SDA = 17; +static const uint8_t SCL = 16; + +#define LED_BUILTIN 0 + +static const uint8_t A0 = 31; +static const uint8_t A1 = 30; +static const uint8_t A2 = 29; +static const uint8_t A3 = 28; +static const uint8_t A4 = 27; +static const uint8_t A5 = 26; +static const uint8_t A6 = 25; +static const uint8_t A7 = 24; + +// ATMEL ATMEGA644/ATMEGA1284 / SANGUINO +// +// +---\/---+ +// (D 0) PB0 1| |40 PA0 (AI 0 / D31) +// (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) +// SS 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 +// INT0 RX1 (D 10) PD2 16| |25 PC3 (D 19) TMS +// INT1 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 NUM_DIGITAL_PINS 24 +#define NUM_ANALOG_INPUTS 8 + +#define analogInputToDigitalPin(p) ((p < 8) ? 31 - (p): -1) +#define analogPinToChannel(p) ((p < 8) ? (p) : 31 - (p)) + +#define digitalPinHasPWM(p) ((p) == 3 || (p) == 4 || (p) == 12 || (p) == 13 || (p) == 14 || (p) == 15 ) + +#define digitalPinToPCICR(p) ( (((p) >= 0) && ((p) <= 31)) ? (&PCICR) : ((uint8_t *)0) ) + +#define digitalPinToPCICRbit(p) ( (((p) >= 24) && ((p) <= 31)) ? 0 : \ + ( (((p) >= 0) && ((p) <= 7)) ? 1 : \ + ( (((p) >= 16) && ((p) <= 23)) ? 2 : \ + ( (((p) >= 8) && ((p) <= 15)) ? 3 : \ + 0 ) ) ) ) + +#define digitalPinToPCMSK(p) ( (((p) >= 24) && ((p) <= 31)) ? (&PCMSK0) : \ + ( (((p) >= 0) && ((p) <= 7)) ? (&PCMSK1) : \ + ( (((p) >= 16) && ((p) <= 23)) ? (&PCMSK2) : \ + ( (((p) >= 8) && ((p) <= 15)) ? (&PCMSK3) : \ + ((uint8_t *)0) ) ) ) ) + + +#define digitalPinToPCMSKbit(p) ( (((p) >= 24) && ((p) <= 31)) ? (31 - (p)) : \ + ( (((p) >= 0) && ((p) <= 7)) ? (p) : \ + ( (((p) >= 16) && ((p) <= 23)) ? ((p) - 16) : \ + ( (((p) >= 8) && ((p) <= 15)) ? ((p) - 8) : \ + 0 ) ) ) ) + +#define digitalPinToInterrupt(p) ((p) == 10 ? 0 : ((p) == 11 ? 1 : ((p) == 2 ? 2 : NOT_AN_INTERRUPT))) + +#ifdef ARDUINO_MAIN +// 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, + (uint16_t) &DDRA, + (uint16_t) &DDRB, + (uint16_t) &DDRC, + (uint16_t) &DDRD, +}; + +const uint16_t PROGMEM port_to_output_PGM[] = +{ + NOT_A_PORT, + (uint16_t) &PORTA, + (uint16_t) &PORTB, + (uint16_t) &PORTC, + (uint16_t) &PORTD, +}; +const uint16_t PROGMEM port_to_input_PGM[] = +{ + NOT_A_PORT, + (uint16_t) &PINA, + (uint16_t) &PINB, + (uint16_t) &PINC, + (uint16_t) &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 */ +}; +#endif + +// These serial port names are intended to allow libraries and architecture-neutral +// sketches to automatically default to the correct port name for a particular type +// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, +// the first hardware serial port whose RX/TX pins are not dedicated to another use. +// +// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor +// +// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial +// +// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library +// +// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. +// +// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX +// pins are NOT connected to anything by default. + +#define SERIAL_PORT_MONITOR Serial +#define SERIAL_PORT_HARDWARE Serial +#define SERIAL_PORT_HARDWARE1 Serial1 +#define SERIAL_PORT_HARDWARE_OPEN Serial1 + +#endif