2
pins_arduino.h - Pin definition functions for Arduino
3
Part of Arduino - http://www.arduino.cc/
5
Copyright (c) 2007 David A. Mellis
7
This library is free software; you can redistribute it and/or
8
modify it under the terms of the GNU Lesser General Public
9
License as published by the Free Software Foundation; either
10
version 2.1 of the License, or (at your option) any later version.
12
This library is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
Lesser General Public License for more details.
17
You should have received a copy of the GNU Lesser General
18
Public License along with this library; if not, write to the
19
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
Boston, MA 02111-1307 USA
22
$Id: wiring.h 249 2007-02-03 16:52:51Z mellis $
25
#ifndef Pins_Arduino_h
26
#define Pins_Arduino_h
28
#include <avr/pgmspace.h>
30
#define ARDUINO_MODEL_USB_PID 0x0034
32
#define TX_RX_LED_INIT DDRD |= (1<<5), DDRB |= (1<<0)
33
#define TXLED0 PORTD |= (1<<5)
34
#define TXLED1 PORTD &= ~(1<<5)
35
#define RXLED0 PORTB |= (1<<0)
36
#define RXLED1 PORTB &= ~(1<<0)
38
static const uint8_t SDA = 2;
39
static const uint8_t SCL = 3;
41
// Map SPI port to 'new' pins D14..D17
42
static const uint8_t SS = 17;
43
static const uint8_t MOSI = 16;
44
static const uint8_t MISO = 14;
45
static const uint8_t SCK = 15;
47
// Mapping of analog pins as digital I/O
48
// A6-A11 share with digital pins
49
static const uint8_t A0 = 18;
50
static const uint8_t A1 = 19;
51
static const uint8_t A2 = 20;
52
static const uint8_t A3 = 21;
53
static const uint8_t A4 = 22;
54
static const uint8_t A5 = 23;
55
static const uint8_t A6 = 24; // D4
56
static const uint8_t A7 = 25; // D6
57
static const uint8_t A8 = 26; // D8
58
static const uint8_t A9 = 27; // D9
59
static const uint8_t A10 = 28; // D10
60
static const uint8_t A11 = 29; // D12
62
// __AVR_ATmega32U4__ has an unusual mapping of pins to channels
63
extern const uint8_t PROGMEM analog_pin_to_channel_PGM[];
64
#define analogPinToChannel(P) ( pgm_read_byte( analog_pin_to_channel_PGM + (P) ) )
68
// On the Arduino board, digital pins are also used
69
// for the analog output (software PWM). Analog input
70
// pins are a separate set.
72
// ATMEL ATMEGA32U4 / ARDUINO LEONARDO
76
// D2 PD1 SDA SDA/INT1
77
// D3# PD0 PWM8/SCL OC0B/SCL/INT0
79
// D5# PC6 ??? OC3A/#OC4A
80
// D6# A7 PD7 FastPWM #OC4D/ADC10
83
// D8 A8 PB4 ADC11/PCINT4
84
// D9# A9 PB5 PWM16 OC1A/#OC4B/ADC12/PCINT5
85
// D10# A10 PB6 PWM16 OC1B/0c4B/ADC13/PCINT6
86
// D11# PB7 PWM8/16 0C0A/OC1C/#RTS/PCINT7
87
// D12 A11 PD6 T1/#OC4D/ADC9
88
// D13# PC7 PWM10 CLK0/OC4A
97
// New pins D14..D17 to map SPI port to digital pins
99
// MISO D14 PB3 MISO,PCINT3
100
// SCK D15 PB1 SCK,PCINT1
101
// MOSI D16 PB2 MOSI,PCINT2
102
// SS D17 PB0 RXLED,SS/PCINT0
108
// these arrays map port names (e.g. port B) to the
109
// appropriate addresses for various functions (e.g. reading
111
const uint16_t PROGMEM port_to_mode_PGM[] = {
121
const uint16_t PROGMEM port_to_output_PGM[] = {
131
const uint16_t PROGMEM port_to_input_PGM[] = {
141
const uint8_t PROGMEM digital_pin_to_port_PGM[30] = {
158
PB, // D14 - MISO - PB3
159
PB, // D15 - SCK - PB1
160
PB, // D16 - MOSI - PB2
161
PB, // D17 - SS - PB0
163
PF, // D18 - A0 - PF7
164
PF, // D19 - A1 - PF6
165
PF, // D20 - A2 - PF5
166
PF, // D21 - A3 - PF4
167
PF, // D22 - A4 - PF1
168
PF, // D23 - A5 - PF0
170
PD, // D24 / D4 - A6 - PD4
171
PD, // D25 / D6 - A7 - PD7
172
PB, // D26 / D8 - A8 - PB4
173
PB, // D27 / D9 - A9 - PB5
174
PB, // D28 / D10 - A10 - PB6
175
PD, // D29 / D12 - A11 - PD6
178
const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[30] = {
195
_BV(3), // D14 - MISO - PB3
196
_BV(1), // D15 - SCK - PB1
197
_BV(2), // D16 - MOSI - PB2
198
_BV(0), // D17 - SS - PB0
200
_BV(7), // D18 - A0 - PF7
201
_BV(6), // D19 - A1 - PF6
202
_BV(5), // D20 - A2 - PF5
203
_BV(4), // D21 - A3 - PF4
204
_BV(1), // D22 - A4 - PF1
205
_BV(0), // D23 - A5 - PF0
207
_BV(4), // D24 / D4 - A6 - PD4
208
_BV(7), // D25 / D6 - A7 - PD7
209
_BV(4), // D26 / D8 - A8 - PB4
210
_BV(5), // D27 / D9 - A9 - PB5
211
_BV(6), // D28 / D10 - A10 - PB6
212
_BV(6), // D29 / D12 - A11 - PD6
215
const uint8_t PROGMEM digital_pin_to_timer_PGM[18] = {
237
const uint8_t PROGMEM analog_pin_to_channel_PGM[12] = {
245
10, // A7 D6 PD7 ADC10
246
11, // A8 D8 PB4 ADC11
247
12, // A9 D9 PB5 ADC12
248
13, // A10 D10 PB6 ADC13
249
9 // A11 D12 PD6 ADC9
252
#endif /* ARDUINO_MAIN */
253
#endif /* Pins_Arduino_h */