+/*\r
+ pins_arduino.h - Pin definition functions for Arduino\r
+ Part of Arduino - http://www.arduino.cc/\r
+\r
+ Copyright (c) 2007 David A. Mellis\r
+\r
+ This library is free software; you can redistribute it and/or\r
+ modify it under the terms of the GNU Lesser General Public\r
+ License as published by the Free Software Foundation; either\r
+ version 2.1 of the License, or (at your option) any later version.\r
+\r
+ This library is distributed in the hope that it will be useful,\r
+ but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+ Lesser General Public License for more details.\r
+\r
+ You should have received a copy of the GNU Lesser General\r
+ Public License along with this library; if not, write to the\r
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330,\r
+ Boston, MA 02111-1307 USA\r
+\r
+ $Id: wiring.h 249 2007-02-03 16:52:51Z mellis $\r
+*/\r
+\r
+#ifndef Pins_Arduino_h\r
+#define Pins_Arduino_h\r
+\r
+#include <avr/pgmspace.h>\r
+\r
+// Workaround for wrong definitions in "iom32u4.h".\r
+// This should be fixed in the AVR toolchain.\r
+#undef UHCON\r
+#undef UHINT\r
+#undef UHIEN\r
+#undef UHADDR\r
+#undef UHFNUM\r
+#undef UHFNUML\r
+#undef UHFNUMH\r
+#undef UHFLEN\r
+#undef UPINRQX\r
+#undef UPINTX\r
+#undef UPNUM\r
+#undef UPRST\r
+#undef UPCONX\r
+#undef UPCFG0X\r
+#undef UPCFG1X\r
+#undef UPSTAX\r
+#undef UPCFG2X\r
+#undef UPIENX\r
+#undef UPDATX\r
+#undef TCCR2A\r
+#undef WGM20\r
+#undef WGM21\r
+#undef COM2B0\r
+#undef COM2B1\r
+#undef COM2A0\r
+#undef COM2A1\r
+#undef TCCR2B\r
+#undef CS20\r
+#undef CS21\r
+#undef CS22\r
+#undef WGM22\r
+#undef FOC2B\r
+#undef FOC2A\r
+#undef TCNT2\r
+#undef TCNT2_0\r
+#undef TCNT2_1\r
+#undef TCNT2_2\r
+#undef TCNT2_3\r
+#undef TCNT2_4\r
+#undef TCNT2_5\r
+#undef TCNT2_6\r
+#undef TCNT2_7\r
+#undef OCR2A\r
+#undef OCR2_0\r
+#undef OCR2_1\r
+#undef OCR2_2\r
+#undef OCR2_3\r
+#undef OCR2_4\r
+#undef OCR2_5\r
+#undef OCR2_6\r
+#undef OCR2_7\r
+#undef OCR2B\r
+#undef OCR2_0\r
+#undef OCR2_1\r
+#undef OCR2_2\r
+#undef OCR2_3\r
+#undef OCR2_4\r
+#undef OCR2_5\r
+#undef OCR2_6\r
+#undef OCR2_7\r
+\r
+#define NUM_DIGITAL_PINS 30\r
+#define NUM_ANALOG_INPUTS 12\r
+\r
+#define TX_RX_LED_INIT DDRD |= (1<<5), DDRB |= (1<<0)\r
+#define TXLED0 PORTD |= (1<<5)\r
+#define TXLED1 PORTD &= ~(1<<5)\r
+#define RXLED0 PORTB |= (1<<0)\r
+#define RXLED1 PORTB &= ~(1<<0)\r
+\r
+static const uint8_t SDA = 2;\r
+static const uint8_t SCL = 3;\r
+#define LED_BUILTIN 13\r
+\r
+// Map SPI port to 'new' pins D14..D17\r
+static const uint8_t SS = 17;\r
+static const uint8_t MOSI = 16;\r
+static const uint8_t MISO = 14;\r
+static const uint8_t SCK = 15;\r
+\r
+// Mapping of analog pins as digital I/O\r
+// A6-A11 share with digital pins\r
+static const uint8_t ADC0 = 18;\r
+static const uint8_t ADC1 = 19;\r
+static const uint8_t ADC2 = 20;\r
+static const uint8_t ADC3 = 21;\r
+static const uint8_t ADC4 = 22;\r
+static const uint8_t ADC5 = 23;\r
+static const uint8_t ADC6 = 24; // D4\r
+static const uint8_t ADC7 = 25; // D6\r
+static const uint8_t ADC8 = 26; // D8\r
+static const uint8_t ADC9 = 27; // D9\r
+static const uint8_t ADC10 = 28; // D10\r
+static const uint8_t ADC11 = 29; // D12\r
+\r
+#define digitalPinToPCICR(p) ((((p) >= 8 && (p) <= 11) || ((p) >= 14 && (p) <= 17) || ((p) >= A8 && (p) <= A10)) ? (&PCICR) : ((uint8_t *)0))\r
+#define digitalPinToPCICRbit(p) 0\r
+#define digitalPinToPCMSK(p) ((((p) >= 8 && (p) <= 11) || ((p) >= 14 && (p) <= 17) || ((p) >= A8 && (p) <= A10)) ? (&PCMSK0) : ((uint8_t *)0))\r
+#define digitalPinToPCMSKbit(p) ( ((p) >= 8 && (p) <= 11) ? (p) - 4 : ((p) == 14 ? 3 : ((p) == 15 ? 1 : ((p) == 16 ? 2 : ((p) == 17 ? 0 : (p - A8 + 4))))))\r
+\r
+// __AVR_ATmega32U4__ has an unusual mapping of pins to channels\r
+extern const uint8_t PROGMEM analog_pin_to_channel_PGM[];\r
+#define analogPinToChannel(P) ( pgm_read_byte( analog_pin_to_channel_PGM + (P) ) )\r
+\r
+#define digitalPinToInterrupt(p) ((p) == 0 ? 2 : ((p) == 1 ? 3 : ((p) == 2 ? 1 : ((p) == 3 ? 0 : ((p) == 7 ? 4 : NOT_AN_INTERRUPT)))))\r
+\r
+#ifdef ARDUINO_MAIN\r
+\r
+// On the Arduino board, digital pins are also used\r
+// for the analog output (software PWM). Analog input\r
+// pins are a separate set.\r
+\r
+// ATMEL ATMEGA32U4 / ARDUINO LEONARDO\r
+//\r
+// D0 PD2 RXD1/INT2\r
+// D1 PD3 TXD1/INT3\r
+// D2 PD1 SDA SDA/INT1\r
+// D3# PD0 PWM8/SCL OC0B/SCL/INT0\r
+// D4 A6 PD4 ADC8\r
+// D5# PC6 ??? OC3A/#OC4A\r
+// D6# A7 PD7 FastPWM #OC4D/ADC10\r
+// D7 PE6 INT6/AIN0\r
+//\r
+// D8 A8 PB4 ADC11/PCINT4\r
+// D9# A9 PB5 PWM16 OC1A/#OC4B/ADC12/PCINT5\r
+// D10# A10 PB6 PWM16 OC1B/0c4B/ADC13/PCINT6\r
+// D11# PB7 PWM8/16 0C0A/OC1C/#RTS/PCINT7\r
+// D12 A11 PD6 T1/#OC4D/ADC9\r
+// D13# PC7 PWM10 CLK0/OC4A\r
+//\r
+// A0 D18 PF7 ADC7\r
+// A1 D19 PF6 ADC6\r
+// A2 D20 PF5 ADC5\r
+// A3 D21 PF4 ADC4\r
+// A4 D22 PF1 ADC1\r
+// A5 D23 PF0 ADC0\r
+//\r
+// New pins D14..D17 to map SPI port to digital pins\r
+//\r
+// MISO D14 PB3 MISO,PCINT3\r
+// SCK D15 PB1 SCK,PCINT1\r
+// MOSI D16 PB2 MOSI,PCINT2\r
+// SS D17 PB0 RXLED,SS/PCINT0\r
+//\r
+// Connected LEDs on board for TX and RX\r
+// TXLED D24 PD5 XCK1\r
+// RXLED D17 PB0\r
+// HWB PE2 HWB\r
+\r
+// these arrays map port names (e.g. port B) to the\r
+// appropriate addresses for various functions (e.g. reading\r
+// and writing)\r
+const uint16_t PROGMEM port_to_mode_PGM[] = {\r
+ NOT_A_PORT,\r
+ NOT_A_PORT,\r
+ (uint16_t) &DDRB,\r
+ (uint16_t) &DDRC,\r
+ (uint16_t) &DDRD,\r
+ (uint16_t) &DDRE,\r
+ (uint16_t) &DDRF,\r
+};\r
+\r
+const uint16_t PROGMEM port_to_output_PGM[] = {\r
+ NOT_A_PORT,\r
+ NOT_A_PORT,\r
+ (uint16_t) &PORTB,\r
+ (uint16_t) &PORTC,\r
+ (uint16_t) &PORTD,\r
+ (uint16_t) &PORTE,\r
+ (uint16_t) &PORTF,\r
+};\r
+\r
+const uint16_t PROGMEM port_to_input_PGM[] = {\r
+ NOT_A_PORT,\r
+ NOT_A_PORT,\r
+ (uint16_t) &PINB,\r
+ (uint16_t) &PINC,\r
+ (uint16_t) &PIND,\r
+ (uint16_t) &PINE,\r
+ (uint16_t) &PINF,\r
+};\r
+\r
+const uint8_t PROGMEM digital_pin_to_port_PGM[] = {\r
+ PD, // D0 - PD2\r
+ PD, // D1 - PD3\r
+ PD, // D2 - PD1\r
+ PD, // D3 - PD0\r
+ PD, // D4 - PD4\r
+ PC, // D5 - PC6\r
+ PD, // D6 - PD7\r
+ PE, // D7 - PE6\r
+\r
+ PB, // D8 - PB4\r
+ PB, // D9 - PB5\r
+ PB, // D10 - PB6\r
+ PB, // D11 - PB7\r
+ PD, // D12 - PD6\r
+ PC, // D13 - PC7\r
+\r
+ PB, // D14 - MISO - PB3\r
+ PB, // D15 - SCK - PB1\r
+ PB, // D16 - MOSI - PB2\r
+ PB, // D17 - SS - PB0\r
+\r
+ PF, // D18 - A0 - PF7\r
+ PF, // D19 - A1 - PF6\r
+ PF, // D20 - A2 - PF5\r
+ PF, // D21 - A3 - PF4\r
+ PF, // D22 - A4 - PF1\r
+ PF, // D23 - A5 - PF0\r
+\r
+ PD, // D24 - PD5\r
+ PD, // D25 / D6 - A7 - PD7\r
+ PB, // D26 / D8 - A8 - PB4\r
+ PB, // D27 / D9 - A9 - PB5\r
+ PB, // D28 / D10 - A10 - PB6\r
+ PD, // D29 / D12 - A11 - PD6\r
+};\r
+\r
+const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = {\r
+ _BV(2), // D0 - PD2\r
+ _BV(3), // D1 - PD3\r
+ _BV(1), // D2 - PD1\r
+ _BV(0), // D3 - PD0\r
+ _BV(4), // D4 - PD4\r
+ _BV(6), // D5 - PC6\r
+ _BV(7), // D6 - PD7\r
+ _BV(6), // D7 - PE6\r
+\r
+ _BV(4), // D8 - PB4\r
+ _BV(5), // D9 - PB5\r
+ _BV(6), // D10 - PB6\r
+ _BV(7), // D11 - PB7\r
+ _BV(6), // D12 - PD6\r
+ _BV(7), // D13 - PC7\r
+\r
+ _BV(3), // D14 - MISO - PB3\r
+ _BV(1), // D15 - SCK - PB1\r
+ _BV(2), // D16 - MOSI - PB2\r
+ _BV(0), // D17 - SS - PB0\r
+\r
+ _BV(7), // D18 - A0 - PF7\r
+ _BV(6), // D19 - A1 - PF6\r
+ _BV(5), // D20 - A2 - PF5\r
+ _BV(4), // D21 - A3 - PF4\r
+ _BV(1), // D22 - A4 - PF1\r
+ _BV(0), // D23 - A5 - PF0\r
+\r
+ _BV(5), // D24 - PD5\r
+ _BV(7), // D25 / D6 - A7 - PD7\r
+ _BV(4), // D26 / D8 - A8 - PB4\r
+ _BV(5), // D27 / D9 - A9 - PB5\r
+ _BV(6), // D28 / D10 - A10 - PB6\r
+ _BV(6), // D29 / D12 - A11 - PD6\r
+};\r
+\r
+const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {\r
+ NOT_ON_TIMER,\r
+ NOT_ON_TIMER,\r
+ NOT_ON_TIMER,\r
+ TIMER0B, /* 3 */\r
+ NOT_ON_TIMER,\r
+ TIMER3A, /* 5 */\r
+ TIMER4D, /* 6 */\r
+ NOT_ON_TIMER,\r
+\r
+ NOT_ON_TIMER,\r
+ TIMER1A, /* 9 */\r
+ TIMER1B, /* 10 */\r
+ TIMER0A, /* 11 */\r
+\r
+ NOT_ON_TIMER,\r
+ TIMER4A, /* 13 */\r
+\r
+ NOT_ON_TIMER,\r
+ NOT_ON_TIMER,\r
+ NOT_ON_TIMER,\r
+ NOT_ON_TIMER,\r
+ NOT_ON_TIMER,\r
+ NOT_ON_TIMER,\r
+\r
+ NOT_ON_TIMER,\r
+ NOT_ON_TIMER,\r
+ NOT_ON_TIMER,\r
+ NOT_ON_TIMER,\r
+ NOT_ON_TIMER,\r
+ NOT_ON_TIMER,\r
+ NOT_ON_TIMER,\r
+ NOT_ON_TIMER,\r
+ NOT_ON_TIMER,\r
+ NOT_ON_TIMER,\r
+};\r
+\r
+const uint8_t PROGMEM analog_pin_to_channel_PGM[] = {\r
+ 7, // A0 PF7 ADC7\r
+ 6, // A1 PF6 ADC6\r
+ 5, // A2 PF5 ADC5\r
+ 4, // A3 PF4 ADC4\r
+ 1, // A4 PF1 ADC1\r
+ 0, // A5 PF0 ADC0\r
+ 8, // A6 D4 PD4 ADC8\r
+ 10, // A7 D6 PD7 ADC10\r
+ 11, // A8 D8 PB4 ADC11\r
+ 12, // A9 D9 PB5 ADC12\r
+ 13, // A10 D10 PB6 ADC13\r
+ 9 // A11 D12 PD6 ADC9\r
+};\r
+\r
+#endif /* ARDUINO_MAIN */\r
+\r
+// These serial port names are intended to allow libraries and architecture-neutral\r
+// sketches to automatically default to the correct port name for a particular type\r
+// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,\r
+// the first hardware serial port whose RX/TX pins are not dedicated to another use.\r
+//\r
+// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor\r
+//\r
+// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial\r
+//\r
+// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library\r
+//\r
+// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins.\r
+//\r
+// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX\r
+// pins are NOT connected to anything by default.\r
+#define SERIAL_PORT_MONITOR Serial\r
+#define SERIAL_PORT_USBVIRTUAL Serial\r
+#define SERIAL_PORT_HARDWARE Serial1\r
+#define SERIAL_PORT_HARDWARE_OPEN Serial1\r
+\r
+#endif /* Pins_Arduino_h */\r