root / arduino-1.0 / hardware / arduino / variants / mega / pins_arduino.h @ 58d82c77
History | View | Annotate | Download (11.5 KB)
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 |
#define NUM_DIGITAL_PINS 70 |
31 |
#define NUM_ANALOG_INPUTS 16 |
32 |
#define analogInputToDigitalPin(p) ((p < 16) ? (p) + 54 : -1) |
33 |
#define digitalPinHasPWM(p) (((p) >= 2 && (p) <= 13) || ((p) >= 44 && (p)<= 46)) |
34 |
|
35 |
const static uint8_t SS = 53; |
36 |
const static uint8_t MOSI = 51; |
37 |
const static uint8_t MISO = 50; |
38 |
const static uint8_t SCK = 52; |
39 |
|
40 |
const static uint8_t SDA = 20; |
41 |
const static uint8_t SCL = 21; |
42 |
const static uint8_t LED_BUILTIN = 13; |
43 |
|
44 |
const static uint8_t A0 = 54; |
45 |
const static uint8_t A1 = 55; |
46 |
const static uint8_t A2 = 56; |
47 |
const static uint8_t A3 = 57; |
48 |
const static uint8_t A4 = 58; |
49 |
const static uint8_t A5 = 59; |
50 |
const static uint8_t A6 = 60; |
51 |
const static uint8_t A7 = 61; |
52 |
const static uint8_t A8 = 62; |
53 |
const static uint8_t A9 = 63; |
54 |
const static uint8_t A10 = 64; |
55 |
const static uint8_t A11 = 65; |
56 |
const static uint8_t A12 = 66; |
57 |
const static uint8_t A13 = 67; |
58 |
const static uint8_t A14 = 68; |
59 |
const static uint8_t A15 = 69; |
60 |
|
61 |
// A majority of the pins are NOT PCINTs, SO BE WARNED (i.e. you cannot use them as receive pins)
|
62 |
// Only pins available for RECEIVE (TRANSMIT can be on any pin):
|
63 |
// (I've deliberately left out pin mapping to the Hardware USARTs - seems senseless to me)
|
64 |
// Pins: 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69
|
65 |
|
66 |
#define digitalPinToPCICR(p) ( (((p) >= 10) && ((p) <= 13)) || \ |
67 |
(((p) >= 50) && ((p) <= 53)) || \ |
68 |
(((p) >= 62) && ((p) <= 69)) ? (&PCICR) : ((uint8_t *)0) ) |
69 |
|
70 |
#define digitalPinToPCICRbit(p) ( (((p) >= 10) && ((p) <= 13)) || (((p) >= 50) && ((p) <= 53)) ? 0 : \ |
71 |
( (((p) >= 62) && ((p) <= 69)) ? 2 : \ |
72 |
0 ) )
|
73 |
|
74 |
#define digitalPinToPCMSK(p) ( (((p) >= 10) && ((p) <= 13)) || (((p) >= 50) && ((p) <= 53)) ? (&PCMSK0) : \ |
75 |
( (((p) >= 62) && ((p) <= 69)) ? (&PCMSK2) : \ |
76 |
((uint8_t *)0) ) )
|
77 |
|
78 |
#define digitalPinToPCMSKbit(p) ( (((p) >= 10) && ((p) <= 13)) ? ((p) - 6) : \ |
79 |
( ((p) == 50) ? 3 : \ |
80 |
( ((p) == 51) ? 2 : \ |
81 |
( ((p) == 52) ? 1 : \ |
82 |
( ((p) == 53) ? 0 : \ |
83 |
( (((p) >= 62) && ((p) <= 69)) ? ((p) - 62) : \ |
84 |
0 ) ) ) ) ) )
|
85 |
|
86 |
#ifdef ARDUINO_MAIN
|
87 |
|
88 |
const uint16_t PROGMEM port_to_mode_PGM[] = {
|
89 |
NOT_A_PORT, |
90 |
(uint16_t) &DDRA, |
91 |
(uint16_t) &DDRB, |
92 |
(uint16_t) &DDRC, |
93 |
(uint16_t) &DDRD, |
94 |
(uint16_t) &DDRE, |
95 |
(uint16_t) &DDRF, |
96 |
(uint16_t) &DDRG, |
97 |
(uint16_t) &DDRH, |
98 |
NOT_A_PORT, |
99 |
(uint16_t) &DDRJ, |
100 |
(uint16_t) &DDRK, |
101 |
(uint16_t) &DDRL, |
102 |
}; |
103 |
|
104 |
const uint16_t PROGMEM port_to_output_PGM[] = {
|
105 |
NOT_A_PORT, |
106 |
(uint16_t) &PORTA, |
107 |
(uint16_t) &PORTB, |
108 |
(uint16_t) &PORTC, |
109 |
(uint16_t) &PORTD, |
110 |
(uint16_t) &PORTE, |
111 |
(uint16_t) &PORTF, |
112 |
(uint16_t) &PORTG, |
113 |
(uint16_t) &PORTH, |
114 |
NOT_A_PORT, |
115 |
(uint16_t) &PORTJ, |
116 |
(uint16_t) &PORTK, |
117 |
(uint16_t) &PORTL, |
118 |
}; |
119 |
|
120 |
const uint16_t PROGMEM port_to_input_PGM[] = {
|
121 |
NOT_A_PIN, |
122 |
(uint16_t) &PINA, |
123 |
(uint16_t) &PINB, |
124 |
(uint16_t) &PINC, |
125 |
(uint16_t) &PIND, |
126 |
(uint16_t) &PINE, |
127 |
(uint16_t) &PINF, |
128 |
(uint16_t) &PING, |
129 |
(uint16_t) &PINH, |
130 |
NOT_A_PIN, |
131 |
(uint16_t) &PINJ, |
132 |
(uint16_t) &PINK, |
133 |
(uint16_t) &PINL, |
134 |
}; |
135 |
|
136 |
const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
|
137 |
// PORTLIST
|
138 |
// -------------------------------------------
|
139 |
PE , // PE 0 ** 0 ** USART0_RX
|
140 |
PE , // PE 1 ** 1 ** USART0_TX
|
141 |
PE , // PE 4 ** 2 ** PWM2
|
142 |
PE , // PE 5 ** 3 ** PWM3
|
143 |
PG , // PG 5 ** 4 ** PWM4
|
144 |
PE , // PE 3 ** 5 ** PWM5
|
145 |
PH , // PH 3 ** 6 ** PWM6
|
146 |
PH , // PH 4 ** 7 ** PWM7
|
147 |
PH , // PH 5 ** 8 ** PWM8
|
148 |
PH , // PH 6 ** 9 ** PWM9
|
149 |
PB , // PB 4 ** 10 ** PWM10
|
150 |
PB , // PB 5 ** 11 ** PWM11
|
151 |
PB , // PB 6 ** 12 ** PWM12
|
152 |
PB , // PB 7 ** 13 ** PWM13
|
153 |
PJ , // PJ 1 ** 14 ** USART3_TX
|
154 |
PJ , // PJ 0 ** 15 ** USART3_RX
|
155 |
PH , // PH 1 ** 16 ** USART2_TX
|
156 |
PH , // PH 0 ** 17 ** USART2_RX
|
157 |
PD , // PD 3 ** 18 ** USART1_TX
|
158 |
PD , // PD 2 ** 19 ** USART1_RX
|
159 |
PD , // PD 1 ** 20 ** I2C_SDA
|
160 |
PD , // PD 0 ** 21 ** I2C_SCL
|
161 |
PA , // PA 0 ** 22 ** D22
|
162 |
PA , // PA 1 ** 23 ** D23
|
163 |
PA , // PA 2 ** 24 ** D24
|
164 |
PA , // PA 3 ** 25 ** D25
|
165 |
PA , // PA 4 ** 26 ** D26
|
166 |
PA , // PA 5 ** 27 ** D27
|
167 |
PA , // PA 6 ** 28 ** D28
|
168 |
PA , // PA 7 ** 29 ** D29
|
169 |
PC , // PC 7 ** 30 ** D30
|
170 |
PC , // PC 6 ** 31 ** D31
|
171 |
PC , // PC 5 ** 32 ** D32
|
172 |
PC , // PC 4 ** 33 ** D33
|
173 |
PC , // PC 3 ** 34 ** D34
|
174 |
PC , // PC 2 ** 35 ** D35
|
175 |
PC , // PC 1 ** 36 ** D36
|
176 |
PC , // PC 0 ** 37 ** D37
|
177 |
PD , // PD 7 ** 38 ** D38
|
178 |
PG , // PG 2 ** 39 ** D39
|
179 |
PG , // PG 1 ** 40 ** D40
|
180 |
PG , // PG 0 ** 41 ** D41
|
181 |
PL , // PL 7 ** 42 ** D42
|
182 |
PL , // PL 6 ** 43 ** D43
|
183 |
PL , // PL 5 ** 44 ** D44
|
184 |
PL , // PL 4 ** 45 ** D45
|
185 |
PL , // PL 3 ** 46 ** D46
|
186 |
PL , // PL 2 ** 47 ** D47
|
187 |
PL , // PL 1 ** 48 ** D48
|
188 |
PL , // PL 0 ** 49 ** D49
|
189 |
PB , // PB 3 ** 50 ** SPI_MISO
|
190 |
PB , // PB 2 ** 51 ** SPI_MOSI
|
191 |
PB , // PB 1 ** 52 ** SPI_SCK
|
192 |
PB , // PB 0 ** 53 ** SPI_SS
|
193 |
PF , // PF 0 ** 54 ** A0
|
194 |
PF , // PF 1 ** 55 ** A1
|
195 |
PF , // PF 2 ** 56 ** A2
|
196 |
PF , // PF 3 ** 57 ** A3
|
197 |
PF , // PF 4 ** 58 ** A4
|
198 |
PF , // PF 5 ** 59 ** A5
|
199 |
PF , // PF 6 ** 60 ** A6
|
200 |
PF , // PF 7 ** 61 ** A7
|
201 |
PK , // PK 0 ** 62 ** A8
|
202 |
PK , // PK 1 ** 63 ** A9
|
203 |
PK , // PK 2 ** 64 ** A10
|
204 |
PK , // PK 3 ** 65 ** A11
|
205 |
PK , // PK 4 ** 66 ** A12
|
206 |
PK , // PK 5 ** 67 ** A13
|
207 |
PK , // PK 6 ** 68 ** A14
|
208 |
PK , // PK 7 ** 69 ** A15
|
209 |
}; |
210 |
|
211 |
const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = {
|
212 |
// PIN IN PORT
|
213 |
// -------------------------------------------
|
214 |
_BV( 0 ) , // PE 0 ** 0 ** USART0_RX |
215 |
_BV( 1 ) , // PE 1 ** 1 ** USART0_TX |
216 |
_BV( 4 ) , // PE 4 ** 2 ** PWM2 |
217 |
_BV( 5 ) , // PE 5 ** 3 ** PWM3 |
218 |
_BV( 5 ) , // PG 5 ** 4 ** PWM4 |
219 |
_BV( 3 ) , // PE 3 ** 5 ** PWM5 |
220 |
_BV( 3 ) , // PH 3 ** 6 ** PWM6 |
221 |
_BV( 4 ) , // PH 4 ** 7 ** PWM7 |
222 |
_BV( 5 ) , // PH 5 ** 8 ** PWM8 |
223 |
_BV( 6 ) , // PH 6 ** 9 ** PWM9 |
224 |
_BV( 4 ) , // PB 4 ** 10 ** PWM10 |
225 |
_BV( 5 ) , // PB 5 ** 11 ** PWM11 |
226 |
_BV( 6 ) , // PB 6 ** 12 ** PWM12 |
227 |
_BV( 7 ) , // PB 7 ** 13 ** PWM13 |
228 |
_BV( 1 ) , // PJ 1 ** 14 ** USART3_TX |
229 |
_BV( 0 ) , // PJ 0 ** 15 ** USART3_RX |
230 |
_BV( 1 ) , // PH 1 ** 16 ** USART2_TX |
231 |
_BV( 0 ) , // PH 0 ** 17 ** USART2_RX |
232 |
_BV( 3 ) , // PD 3 ** 18 ** USART1_TX |
233 |
_BV( 2 ) , // PD 2 ** 19 ** USART1_RX |
234 |
_BV( 1 ) , // PD 1 ** 20 ** I2C_SDA |
235 |
_BV( 0 ) , // PD 0 ** 21 ** I2C_SCL |
236 |
_BV( 0 ) , // PA 0 ** 22 ** D22 |
237 |
_BV( 1 ) , // PA 1 ** 23 ** D23 |
238 |
_BV( 2 ) , // PA 2 ** 24 ** D24 |
239 |
_BV( 3 ) , // PA 3 ** 25 ** D25 |
240 |
_BV( 4 ) , // PA 4 ** 26 ** D26 |
241 |
_BV( 5 ) , // PA 5 ** 27 ** D27 |
242 |
_BV( 6 ) , // PA 6 ** 28 ** D28 |
243 |
_BV( 7 ) , // PA 7 ** 29 ** D29 |
244 |
_BV( 7 ) , // PC 7 ** 30 ** D30 |
245 |
_BV( 6 ) , // PC 6 ** 31 ** D31 |
246 |
_BV( 5 ) , // PC 5 ** 32 ** D32 |
247 |
_BV( 4 ) , // PC 4 ** 33 ** D33 |
248 |
_BV( 3 ) , // PC 3 ** 34 ** D34 |
249 |
_BV( 2 ) , // PC 2 ** 35 ** D35 |
250 |
_BV( 1 ) , // PC 1 ** 36 ** D36 |
251 |
_BV( 0 ) , // PC 0 ** 37 ** D37 |
252 |
_BV( 7 ) , // PD 7 ** 38 ** D38 |
253 |
_BV( 2 ) , // PG 2 ** 39 ** D39 |
254 |
_BV( 1 ) , // PG 1 ** 40 ** D40 |
255 |
_BV( 0 ) , // PG 0 ** 41 ** D41 |
256 |
_BV( 7 ) , // PL 7 ** 42 ** D42 |
257 |
_BV( 6 ) , // PL 6 ** 43 ** D43 |
258 |
_BV( 5 ) , // PL 5 ** 44 ** D44 |
259 |
_BV( 4 ) , // PL 4 ** 45 ** D45 |
260 |
_BV( 3 ) , // PL 3 ** 46 ** D46 |
261 |
_BV( 2 ) , // PL 2 ** 47 ** D47 |
262 |
_BV( 1 ) , // PL 1 ** 48 ** D48 |
263 |
_BV( 0 ) , // PL 0 ** 49 ** D49 |
264 |
_BV( 3 ) , // PB 3 ** 50 ** SPI_MISO |
265 |
_BV( 2 ) , // PB 2 ** 51 ** SPI_MOSI |
266 |
_BV( 1 ) , // PB 1 ** 52 ** SPI_SCK |
267 |
_BV( 0 ) , // PB 0 ** 53 ** SPI_SS |
268 |
_BV( 0 ) , // PF 0 ** 54 ** A0 |
269 |
_BV( 1 ) , // PF 1 ** 55 ** A1 |
270 |
_BV( 2 ) , // PF 2 ** 56 ** A2 |
271 |
_BV( 3 ) , // PF 3 ** 57 ** A3 |
272 |
_BV( 4 ) , // PF 4 ** 58 ** A4 |
273 |
_BV( 5 ) , // PF 5 ** 59 ** A5 |
274 |
_BV( 6 ) , // PF 6 ** 60 ** A6 |
275 |
_BV( 7 ) , // PF 7 ** 61 ** A7 |
276 |
_BV( 0 ) , // PK 0 ** 62 ** A8 |
277 |
_BV( 1 ) , // PK 1 ** 63 ** A9 |
278 |
_BV( 2 ) , // PK 2 ** 64 ** A10 |
279 |
_BV( 3 ) , // PK 3 ** 65 ** A11 |
280 |
_BV( 4 ) , // PK 4 ** 66 ** A12 |
281 |
_BV( 5 ) , // PK 5 ** 67 ** A13 |
282 |
_BV( 6 ) , // PK 6 ** 68 ** A14 |
283 |
_BV( 7 ) , // PK 7 ** 69 ** A15 |
284 |
}; |
285 |
|
286 |
const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {
|
287 |
// TIMERS
|
288 |
// -------------------------------------------
|
289 |
NOT_ON_TIMER , // PE 0 ** 0 ** USART0_RX
|
290 |
NOT_ON_TIMER , // PE 1 ** 1 ** USART0_TX
|
291 |
TIMER3B , // PE 4 ** 2 ** PWM2
|
292 |
TIMER3C , // PE 5 ** 3 ** PWM3
|
293 |
TIMER0B , // PG 5 ** 4 ** PWM4
|
294 |
TIMER3A , // PE 3 ** 5 ** PWM5
|
295 |
TIMER4A , // PH 3 ** 6 ** PWM6
|
296 |
TIMER4B , // PH 4 ** 7 ** PWM7
|
297 |
TIMER4C , // PH 5 ** 8 ** PWM8
|
298 |
TIMER2B , // PH 6 ** 9 ** PWM9
|
299 |
TIMER2A , // PB 4 ** 10 ** PWM10
|
300 |
TIMER1A , // PB 5 ** 11 ** PWM11
|
301 |
TIMER1B , // PB 6 ** 12 ** PWM12
|
302 |
TIMER0A , // PB 7 ** 13 ** PWM13
|
303 |
NOT_ON_TIMER , // PJ 1 ** 14 ** USART3_TX
|
304 |
NOT_ON_TIMER , // PJ 0 ** 15 ** USART3_RX
|
305 |
NOT_ON_TIMER , // PH 1 ** 16 ** USART2_TX
|
306 |
NOT_ON_TIMER , // PH 0 ** 17 ** USART2_RX
|
307 |
NOT_ON_TIMER , // PD 3 ** 18 ** USART1_TX
|
308 |
NOT_ON_TIMER , // PD 2 ** 19 ** USART1_RX
|
309 |
NOT_ON_TIMER , // PD 1 ** 20 ** I2C_SDA
|
310 |
NOT_ON_TIMER , // PD 0 ** 21 ** I2C_SCL
|
311 |
NOT_ON_TIMER , // PA 0 ** 22 ** D22
|
312 |
NOT_ON_TIMER , // PA 1 ** 23 ** D23
|
313 |
NOT_ON_TIMER , // PA 2 ** 24 ** D24
|
314 |
NOT_ON_TIMER , // PA 3 ** 25 ** D25
|
315 |
NOT_ON_TIMER , // PA 4 ** 26 ** D26
|
316 |
NOT_ON_TIMER , // PA 5 ** 27 ** D27
|
317 |
NOT_ON_TIMER , // PA 6 ** 28 ** D28
|
318 |
NOT_ON_TIMER , // PA 7 ** 29 ** D29
|
319 |
NOT_ON_TIMER , // PC 7 ** 30 ** D30
|
320 |
NOT_ON_TIMER , // PC 6 ** 31 ** D31
|
321 |
NOT_ON_TIMER , // PC 5 ** 32 ** D32
|
322 |
NOT_ON_TIMER , // PC 4 ** 33 ** D33
|
323 |
NOT_ON_TIMER , // PC 3 ** 34 ** D34
|
324 |
NOT_ON_TIMER , // PC 2 ** 35 ** D35
|
325 |
NOT_ON_TIMER , // PC 1 ** 36 ** D36
|
326 |
NOT_ON_TIMER , // PC 0 ** 37 ** D37
|
327 |
NOT_ON_TIMER , // PD 7 ** 38 ** D38
|
328 |
NOT_ON_TIMER , // PG 2 ** 39 ** D39
|
329 |
NOT_ON_TIMER , // PG 1 ** 40 ** D40
|
330 |
NOT_ON_TIMER , // PG 0 ** 41 ** D41
|
331 |
NOT_ON_TIMER , // PL 7 ** 42 ** D42
|
332 |
NOT_ON_TIMER , // PL 6 ** 43 ** D43
|
333 |
TIMER5C , // PL 5 ** 44 ** D44
|
334 |
TIMER5B , // PL 4 ** 45 ** D45
|
335 |
TIMER5A , // PL 3 ** 46 ** D46
|
336 |
NOT_ON_TIMER , // PL 2 ** 47 ** D47
|
337 |
NOT_ON_TIMER , // PL 1 ** 48 ** D48
|
338 |
NOT_ON_TIMER , // PL 0 ** 49 ** D49
|
339 |
NOT_ON_TIMER , // PB 3 ** 50 ** SPI_MISO
|
340 |
NOT_ON_TIMER , // PB 2 ** 51 ** SPI_MOSI
|
341 |
NOT_ON_TIMER , // PB 1 ** 52 ** SPI_SCK
|
342 |
NOT_ON_TIMER , // PB 0 ** 53 ** SPI_SS
|
343 |
NOT_ON_TIMER , // PF 0 ** 54 ** A0
|
344 |
NOT_ON_TIMER , // PF 1 ** 55 ** A1
|
345 |
NOT_ON_TIMER , // PF 2 ** 56 ** A2
|
346 |
NOT_ON_TIMER , // PF 3 ** 57 ** A3
|
347 |
NOT_ON_TIMER , // PF 4 ** 58 ** A4
|
348 |
NOT_ON_TIMER , // PF 5 ** 59 ** A5
|
349 |
NOT_ON_TIMER , // PF 6 ** 60 ** A6
|
350 |
NOT_ON_TIMER , // PF 7 ** 61 ** A7
|
351 |
NOT_ON_TIMER , // PK 0 ** 62 ** A8
|
352 |
NOT_ON_TIMER , // PK 1 ** 63 ** A9
|
353 |
NOT_ON_TIMER , // PK 2 ** 64 ** A10
|
354 |
NOT_ON_TIMER , // PK 3 ** 65 ** A11
|
355 |
NOT_ON_TIMER , // PK 4 ** 66 ** A12
|
356 |
NOT_ON_TIMER , // PK 5 ** 67 ** A13
|
357 |
NOT_ON_TIMER , // PK 6 ** 68 ** A14
|
358 |
NOT_ON_TIMER , // PK 7 ** 69 ** A15
|
359 |
}; |
360 |
|
361 |
#endif
|
362 |
|
363 |
#endif
|