diff options
Diffstat (limited to 'variants')
| -rw-r--r-- | variants/ethernet/pins_arduino.h | 236 | ||||
| -rw-r--r-- | variants/leonardo/pins_arduino.h | 24 | ||||
| -rw-r--r-- | variants/mega/pins_arduino.h | 30 | ||||
| -rw-r--r-- | variants/robot_control/pins_arduino.h | 22 | ||||
| -rw-r--r-- | variants/robot_motor/pins_arduino.h | 22 | ||||
| -rw-r--r-- | variants/standard/pins_arduino.h | 22 | ||||
| -rw-r--r-- | variants/yun/pins_arduino.h | 24 | 
7 files changed, 377 insertions, 3 deletions
| diff --git a/variants/ethernet/pins_arduino.h b/variants/ethernet/pins_arduino.h new file mode 100644 index 0000000..cdcb0ed --- /dev/null +++ b/variants/ethernet/pins_arduino.h @@ -0,0 +1,236 @@ +/* +  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 NUM_DIGITAL_PINS            20 +#define NUM_ANALOG_INPUTS           6 +#define analogInputToDigitalPin(p)  ((p < 6) ? (p) + 14 : -1) + +#if defined(__AVR_ATmega8__) +#define digitalPinHasPWM(p)         ((p) == 9 || (p) == 10 || (p) == 11) +#else +#define digitalPinHasPWM(p)         ((p) == 3 || (p) == 5 || (p) == 6 || (p) == 9 || (p) == 10 || (p) == 11) +#endif + +static const uint8_t SS   = 10; +static const uint8_t MOSI = 11; +static const uint8_t MISO = 12; +static const uint8_t SCK  = 13; + +static const uint8_t SDA = 18; +static const uint8_t SCL = 19; +#define LED_BUILTIN 9 + +static const uint8_t A0 = 14; +static const uint8_t A1 = 15; +static const uint8_t A2 = 16; +static const uint8_t A3 = 17; +static const uint8_t A4 = 18; +static const uint8_t A5 = 19; +static const uint8_t A6 = 20; +static const uint8_t A7 = 21; + +#define digitalPinToPCICR(p)    (((p) >= 0 && (p) <= 21) ? (&PCICR) : ((uint8_t *)0)) +#define digitalPinToPCICRbit(p) (((p) <= 7) ? 2 : (((p) <= 13) ? 0 : 1)) +#define digitalPinToPCMSK(p)    (((p) <= 7) ? (&PCMSK2) : (((p) <= 13) ? (&PCMSK0) : (((p) <= 21) ? (&PCMSK1) : ((uint8_t *)0)))) +#define digitalPinToPCMSKbit(p) (((p) <= 7) ? (p) : (((p) <= 13) ? ((p) - 8) : ((p) - 14))) + +#ifdef ARDUINO_MAIN + +// 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 + + +// 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, +	(uint16_t) &DDRB, +	(uint16_t) &DDRC, +	(uint16_t) &DDRD, +}; + +const uint16_t PROGMEM port_to_output_PGM[] = { +	NOT_A_PORT, +	NOT_A_PORT, +	(uint16_t) &PORTB, +	(uint16_t) &PORTC, +	(uint16_t) &PORTD, +}; + +const uint16_t PROGMEM port_to_input_PGM[] = { +	NOT_A_PORT, +	NOT_A_PORT, +	(uint16_t) &PINB, +	(uint16_t) &PINC, +	(uint16_t) &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 + +// 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_HARDWARE       Serial +#define SERIAL_PORT_HARDWARE_OPEN  Serial + +#endif diff --git a/variants/leonardo/pins_arduino.h b/variants/leonardo/pins_arduino.h index 2c7f837..fd75373 100644 --- a/variants/leonardo/pins_arduino.h +++ b/variants/leonardo/pins_arduino.h @@ -101,6 +101,7 @@  static const uint8_t SDA = 2;  static const uint8_t SCL = 3; +#define LED_BUILTIN 13  // Map SPI port to 'new' pins D14..D17  static const uint8_t SS   = 17; @@ -132,6 +133,8 @@ static const uint8_t A11 = 29;	// D12  extern const uint8_t PROGMEM analog_pin_to_channel_PGM[];  #define analogPinToChannel(P)  ( pgm_read_byte( analog_pin_to_channel_PGM + (P) ) ) +#define digitalPinToInterrupt(p) ((p) == 0 ? 2 : ((p) == 1 ? 3 : ((p) == 2 ? 1 : ((p) == 3 ? 0 : ((p) == 7 ? 4 : NOT_AN_INTERRUPT))))) +  #ifdef ARDUINO_MAIN  // On the Arduino board, digital pins are also used @@ -334,4 +337,25 @@ const uint8_t PROGMEM analog_pin_to_channel_PGM[] = {  };  #endif /* ARDUINO_MAIN */ + +// 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_USBVIRTUAL     Serial +#define SERIAL_PORT_HARDWARE       Serial1 +#define SERIAL_PORT_HARDWARE_OPEN  Serial1 +  #endif /* Pins_Arduino_h */ diff --git a/variants/mega/pins_arduino.h b/variants/mega/pins_arduino.h index 5a9b4cb..a80991b 100644 --- a/variants/mega/pins_arduino.h +++ b/variants/mega/pins_arduino.h @@ -39,7 +39,7 @@ static const uint8_t SCK  = 52;  static const uint8_t SDA = 20;  static const uint8_t SCL = 21; -static const uint8_t LED_BUILTIN = 13; +#define LED_BUILTIN 13  static const uint8_t A0 = 54;  static const uint8_t A1 = 55; @@ -83,6 +83,8 @@ static const uint8_t A15 = 69;                                  ( (((p) >= 62) && ((p) <= 69)) ? ((p) - 62) : \                                  0 ) ) ) ) ) ) +#define digitalPinToInterrupt(p) ((p) == 2 ? 0 : ((p) == 3 ? 1 : ((p) >= 18 && (p) <= 21 ? 23 - (p) : NOT_AN_INTERRUPT))) +  #ifdef ARDUINO_MAIN  const uint16_t PROGMEM port_to_mode_PGM[] = { @@ -360,4 +362,28 @@ const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {  #endif -#endif
\ No newline at end of file +// 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_HARDWARE2       Serial2 +#define SERIAL_PORT_HARDWARE3       Serial3 +#define SERIAL_PORT_HARDWARE_OPEN   Serial1 +#define SERIAL_PORT_HARDWARE_OPEN1  Serial2 +#define SERIAL_PORT_HARDWARE_OPEN2  Serial3 + +#endif diff --git a/variants/robot_control/pins_arduino.h b/variants/robot_control/pins_arduino.h index 1967845..b868064 100644 --- a/variants/robot_control/pins_arduino.h +++ b/variants/robot_control/pins_arduino.h @@ -94,6 +94,8 @@ static const uint8_t LED1	 = 17;  // D17 - RX_Led  extern const uint8_t PROGMEM analog_pin_to_channel_PGM[];  #define analogPinToChannel(P)  ( pgm_read_byte( analog_pin_to_channel_PGM + (P) ) ) +#define digitalPinToInterrupt(p) ((p) == 0 ? 2 : ((p) == 1 ? 3 : ((p) == 2 ? 1 : ((p) == 3 ? 0 : ((p) == 7 ? 4 : NOT_AN_INTERRUPT))))) +  #ifdef ARDUINO_MAIN  // On the Arduino board, digital pins are also used @@ -278,4 +280,24 @@ const uint8_t PROGMEM analog_pin_to_channel_PGM[12] = {  };  #endif /* ARDUINO_MAIN */ + +// 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_USBVIRTUAL     Serial +#define SERIAL_PORT_HARDWARE       Serial1 +  #endif /* Pins_Arduino_h */ diff --git a/variants/robot_motor/pins_arduino.h b/variants/robot_motor/pins_arduino.h index 36d2742..7dc4a79 100644 --- a/variants/robot_motor/pins_arduino.h +++ b/variants/robot_motor/pins_arduino.h @@ -89,6 +89,8 @@ static const uint8_t TK4 = 12;   	// A11  extern const uint8_t PROGMEM analog_pin_to_channel_PGM[];  #define analogPinToChannel(P)  ( pgm_read_byte( analog_pin_to_channel_PGM + (P) ) ) +#define digitalPinToInterrupt(p) ((p) == 0 ? 2 : ((p) == 1 ? 3 : ((p) == 2 ? 1 : ((p) == 3 ? 0 : ((p) == 7 ? 4 : NOT_AN_INTERRUPT))))) +  #ifdef ARDUINO_MAIN  // On the Arduino board, digital pins are also used @@ -273,4 +275,24 @@ const uint8_t PROGMEM analog_pin_to_channel_PGM[12] = {  };  #endif /* ARDUINO_MAIN */ + +// 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_USBVIRTUAL     Serial +#define SERIAL_PORT_HARDWARE       Serial1 +  #endif /* Pins_Arduino_h */ diff --git a/variants/standard/pins_arduino.h b/variants/standard/pins_arduino.h index 30b4266..3d4a9f6 100644 --- a/variants/standard/pins_arduino.h +++ b/variants/standard/pins_arduino.h @@ -44,7 +44,7 @@ static const uint8_t SCK  = 13;  static const uint8_t SDA = 18;  static const uint8_t SCL = 19; -static const uint8_t LED_BUILTIN = 13; +#define LED_BUILTIN 13  static const uint8_t A0 = 14;  static const uint8_t A1 = 15; @@ -60,6 +60,8 @@ static const uint8_t A7 = 21;  #define digitalPinToPCMSK(p)    (((p) <= 7) ? (&PCMSK2) : (((p) <= 13) ? (&PCMSK0) : (((p) <= 21) ? (&PCMSK1) : ((uint8_t *)0))))  #define digitalPinToPCMSKbit(p) (((p) <= 7) ? (p) : (((p) <= 13) ? ((p) - 8) : ((p) - 14))) +#define digitalPinToInterrupt(p)  ((p) == 2 ? 0 : ((p) == 3 ? 1 : NOT_AN_INTERRUPT)) +  #ifdef ARDUINO_MAIN  // On the Arduino board, digital pins are also used @@ -215,4 +217,22 @@ const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {  #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 +  #endif diff --git a/variants/yun/pins_arduino.h b/variants/yun/pins_arduino.h index 43912e7..ba0570b 100644 --- a/variants/yun/pins_arduino.h +++ b/variants/yun/pins_arduino.h @@ -25,3 +25,27 @@  #include "../leonardo/pins_arduino.h"  #define LED_BUILTIN 13 + +// 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_USBVIRTUAL     Serial +#define SERIAL_PORT_HARDWARE       Serial1 +#define SERIAL_PORT_LINUXBRIDGE    Serial1 + +// this is defined in the Leonardo variant +#undef  SERIAL_PORT_HARDWARE_OPEN + | 
