1
+ /*
2
+ pins_arduino.h - Pin definition functions for Arduino
3
+ Part of Arduino - http://www.arduino.cc/
4
+
5
+ Copyright (c) 2007 David A. Mellis
6
+
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.
11
+
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.
16
+
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
21
+
22
+ $Id: wiring.h 249 2007-02-03 16:52:51Z mellis $
23
+ */
24
+
25
+ #ifndef Pins_Arduino_h
26
+ #define Pins_Arduino_h
27
+
28
+ #include <avr/pgmspace.h>
29
+
30
+ // Map SPI port to 'new' pins D14..D17
31
+ // D14 PB0 RXLED,SS/PCINT0
32
+ // D15 PB1 SCK,PCINT1
33
+ // D16 PB2 MOSI,PCINT2
34
+ // D17 PB3 MISO,PCINT3
35
+ const static uint8_t SS = 14 ;
36
+ const static uint8_t MOSI = 16 ;
37
+ const static uint8_t MISO = 17 ;
38
+ const static uint8_t SCK = 15 ;
39
+
40
+ const static uint8_t A0 = 14 ;
41
+ const static uint8_t A1 = 15 ;
42
+ const static uint8_t A2 = 16 ;
43
+ const static uint8_t A3 = 17 ;
44
+ const static uint8_t A4 = 18 ;
45
+ const static uint8_t A5 = 19 ;
46
+ const static uint8_t A6 = 20 ;
47
+ const static uint8_t A7 = 21 ;
48
+
49
+ #ifdef ARDUINO_MAIN
50
+
51
+ // On the Arduino board, digital pins are also used
52
+ // for the analog output (software PWM). Analog input
53
+ // pins are a separate set.
54
+
55
+ // ATMEL ATMEGA8 & 168 / ARDUINO
56
+ //
57
+ // +-\/-+
58
+ // PC6 1| |28 PC5 (AI 5)
59
+ // (D 0) PD0 2| |27 PC4 (AI 4)
60
+ // (D 1) PD1 3| |26 PC3 (AI 3)
61
+ // (D 2) PD2 4| |25 PC2 (AI 2)
62
+ // PWM+ (D 3) PD3 5| |24 PC1 (AI 1)
63
+ // (D 4) PD4 6| |23 PC0 (AI 0)
64
+ // VCC 7| |22 GND
65
+ // GND 8| |21 AREF
66
+ // PB6 9| |20 AVCC
67
+ // PB7 10| |19 PB5 (D 13)
68
+ // PWM+ (D 5) PD5 11| |18 PB4 (D 12)
69
+ // PWM+ (D 6) PD6 12| |17 PB3 (D 11) PWM
70
+ // (D 7) PD7 13| |16 PB2 (D 10) PWM
71
+ // (D 8) PB0 14| |15 PB1 (D 9) PWM
72
+ // +----+
73
+ //
74
+ // (PWM+ indicates the additional PWM pins on the ATmega168.)
75
+
76
+ // ATMEL ATMEGA1280 / ARDUINO
77
+ //
78
+ // 0-7 PE0-PE7 works
79
+ // 8-13 PB0-PB5 works
80
+ // 14-21 PA0-PA7 works
81
+ // 22-29 PH0-PH7 works
82
+ // 30-35 PG5-PG0 works
83
+ // 36-43 PC7-PC0 works
84
+ // 44-51 PJ7-PJ0 works
85
+ // 52-59 PL7-PL0 works
86
+ // 60-67 PD7-PD0 works
87
+ // A0-A7 PF0-PF7
88
+ // A8-A15 PK0-PK7
89
+
90
+ // ATMEL ATMEGA32U4 / ARDUINO LEONARDO
91
+ //
92
+ // D0 PD2 RXD1/INT2
93
+ // D1 PD3 TXD1/INT3
94
+ // D2 PD1 SDA SDA/INT1
95
+ // D3# PD0 PWM8/SCL OC0B/SCL/INT0
96
+ // D4 A6 PD4 ADC8
97
+ // D5# A7 PD6 FastPWM OC4D/ADC9
98
+ // D6# A8 PD7 FastPWM #OC4D/ADC10
99
+ // D7 PD5 #CTS
100
+ //
101
+ // D8 PB4 ADC11/PCINT4
102
+ // D9# A9 PB5 PWM16 OC1A/#OC4B/ADC13/PCINT5
103
+ // D10# A10 PB6 PWM16 OC1B/0c4B/ADC12/PCINT6
104
+ // D11# PB7 PWM8/16 0C0A/OC1C/#RTS/PCINT7
105
+ // D12# PC6 PWM16 0C3A/#OC4A
106
+ // D13# PC7 PWM10 CLK0/OC4A
107
+ //
108
+ // A0 PF7 ADC7
109
+ // A1 PF6 ADC6
110
+ // A2 PF5 ADC5
111
+ // A3 PF4 ADC4
112
+ // A4 PF1 ADC1
113
+ // A5 PF0 ADC0
114
+ //
115
+ // New pins D14..D17 to map SPI port to digitial pins
116
+ //
117
+ // D14 PB0 RXLED,SS/PCINT0
118
+ // D15 PB1 SCK,PCINT1
119
+ // D16 PB2 MOSI,PCINT2
120
+ // D17 PB3 MISO,PCINT3
121
+ //
122
+ // TXLED PE6 INT6
123
+ // HWB PE2 HWB
124
+
125
+
126
+ // these arrays map port names (e.g. port B) to the
127
+ // appropriate addresses for various functions (e.g. reading
128
+ // and writing)
129
+ const uint16_t PROGMEM port_to_mode_PGM [] = {
130
+ NOT_A_PORT ,
131
+ NOT_A_PORT ,
132
+ & DDRB ,
133
+ & DDRC ,
134
+ & DDRD ,
135
+ & DDRE ,
136
+ & DDRF ,
137
+ };
138
+
139
+ const uint16_t PROGMEM port_to_output_PGM [] = {
140
+ NOT_A_PORT ,
141
+ NOT_A_PORT ,
142
+ & PORTB ,
143
+ & PORTC ,
144
+ & PORTD ,
145
+ & PORTE ,
146
+ & PORTF ,
147
+ };
148
+
149
+ const uint16_t PROGMEM port_to_input_PGM [] = {
150
+ NOT_A_PORT ,
151
+ NOT_A_PORT ,
152
+ & PINB ,
153
+ & PINC ,
154
+ & PIND ,
155
+ & PINE ,
156
+ & PINF ,
157
+ };
158
+
159
+ const uint8_t PROGMEM digital_pin_to_port_PGM [18 ] = {
160
+ PD , /* 0 */
161
+ PD ,
162
+ PD ,
163
+ PD ,
164
+ PD ,
165
+ PD ,
166
+ PD ,
167
+ PD ,
168
+
169
+ PB , /* 8 */
170
+ PB ,
171
+ PB ,
172
+ PB ,
173
+
174
+ PC , /* 12 */
175
+ PC , /* 13 */
176
+
177
+ PB , /* 14 */
178
+ PB , /* 15 */
179
+ PB , /* 16 */
180
+ PB , /* 17 */
181
+ };
182
+
183
+ const uint8_t PROGMEM digital_pin_to_bit_mask_PGM [18 ] = {
184
+ _BV (2 ), /* 0, port D */
185
+ _BV (3 ),
186
+ _BV (1 ),
187
+ _BV (0 ),
188
+ _BV (4 ),
189
+ _BV (6 ),
190
+ _BV (7 ),
191
+ _BV (5 ),
192
+
193
+ _BV (4 ), /* 8, port B */
194
+ _BV (5 ),
195
+ _BV (6 ),
196
+ _BV (7 ),
197
+
198
+ _BV (6 ), /* 12 port C */
199
+ _BV (7 ),
200
+
201
+ _BV (0 ), /* 14, port B */
202
+ _BV (1 ),
203
+ _BV (2 ),
204
+ _BV (3 ),
205
+ };
206
+
207
+ const uint8_t PROGMEM digital_pin_to_timer_PGM [18 ] = {
208
+ NOT_ON_TIMER , /* 0, port D */
209
+ NOT_ON_TIMER ,
210
+ NOT_ON_TIMER ,
211
+ TIMER0B ,
212
+ NOT_ON_TIMER ,
213
+ TIMER4D ,
214
+ NOT_ON_TIMER , // TIMER4D_NOT TODO. Complementary output of TIMER4D on Digital Pin 6. Not sure this was intended.
215
+ NOT_ON_TIMER ,
216
+
217
+ NOT_ON_TIMER , /* 8 port B */
218
+ TIMER1A ,
219
+ TIMER1B ,
220
+ TIMER0A ,
221
+
222
+ TIMER3A , /* 12 port C */
223
+ TIMER4A ,
224
+
225
+ NOT_ON_TIMER , /* 14 port B */
226
+ NOT_ON_TIMER ,
227
+ };
228
+
229
+ #endif
230
+
231
+ #endif
0 commit comments