|
@@ -0,0 +1,278 @@
|
|
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
|
+ Modified 2012 by Fredrik Hubinette
|
|
7
|
+ Modified 2014-2015 by Matthew Wilson
|
|
8
|
+
|
|
9
|
+ This library is free software; you can redistribute it and/or
|
|
10
|
+ modify it under the terms of the GNU Lesser General Public
|
|
11
|
+ License as published by the Free Software Foundation; either
|
|
12
|
+ version 2.1 of the License, or (at your option) any later version.
|
|
13
|
+
|
|
14
|
+ This library is distributed in the hope that it will be useful,
|
|
15
|
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16
|
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
17
|
+ Lesser General Public License for more details.
|
|
18
|
+
|
|
19
|
+ You should have received a copy of the GNU Lesser General
|
|
20
|
+ Public License along with this library; if not, write to the
|
|
21
|
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
|
22
|
+ Boston, MA 02111-1307 USA
|
|
23
|
+
|
|
24
|
+ $Id: wiring.h 249 2007-02-03 16:52:51Z mellis $
|
|
25
|
+*/
|
|
26
|
+
|
|
27
|
+#ifndef Pins_Arduino_h
|
|
28
|
+#define Pins_Arduino_h
|
|
29
|
+
|
|
30
|
+#include <avr/pgmspace.h>
|
|
31
|
+
|
|
32
|
+#define NUM_DIGITAL_PINS 48
|
|
33
|
+#define NUM_ANALOG_INPUTS 8
|
|
34
|
+
|
|
35
|
+// PE7 is our status LED
|
|
36
|
+#define TX_RX_LED_INIT DDRE |= (1<<7)
|
|
37
|
+#define TXLED0 0
|
|
38
|
+#define TXLED1 0
|
|
39
|
+#define RXLED0 PORTE |= (1<<7)
|
|
40
|
+#define RXLED1 PORTE &= ~(1<<7)
|
|
41
|
+
|
|
42
|
+static const uint8_t SDA = 1;
|
|
43
|
+static const uint8_t SCL = 0;
|
|
44
|
+
|
|
45
|
+// Map SPI port to 'new' pins D14..D17
|
|
46
|
+static const uint8_t SS = 20;
|
|
47
|
+static const uint8_t MOSI = 22;
|
|
48
|
+static const uint8_t MISO = 23;
|
|
49
|
+static const uint8_t SCK = 21;
|
|
50
|
+
|
|
51
|
+// Mapping of analog pins as digital I/O
|
|
52
|
+// A6-A11 share with digital pins
|
|
53
|
+static const uint8_t A0 = 38; // F0
|
|
54
|
+static const uint8_t A1 = 39; // F1
|
|
55
|
+static const uint8_t A2 = 40; // F2
|
|
56
|
+static const uint8_t A3 = 41; // F3
|
|
57
|
+static const uint8_t A4 = 42; // F4
|
|
58
|
+static const uint8_t A5 = 43; // F5
|
|
59
|
+static const uint8_t A6 = 44; // F6
|
|
60
|
+static const uint8_t A7 = 45; // F7
|
|
61
|
+
|
|
62
|
+#define analogInputToDigitalPin(p) ((p < 8) ? (p) + 38 : -1)
|
|
63
|
+
|
|
64
|
+// Pins below still needs to be configured - Hubbe.
|
|
65
|
+
|
|
66
|
+#define digitalPinToPCICR(p) ((((p) >= 0 && (p) <= 3) || ((p) >= 18 && (p) <= 19) || ((p) >= 36 && (p) <= 37)) ? (&PCICR) : ((uint8_t *)0))
|
|
67
|
+#define digitalPinToPCICRbit(p) 0
|
|
68
|
+#define digitalPinToPCMSK(p) ((((p) >= 0 && (p) <= 3) || ((p) >= 18 && (p) <= 19) || ((p) >= 36 && (p) <= 37)) ? (&PCMSK0) : ((uint8_t *)0))
|
|
69
|
+#define digitalPinToPCMSKbit(p) ( ((p) >= 0 && (p) <= 3) ? (p) : ((p) == 18 ? 6 : ((p) == 19 ? 7 : ((p) == 36 ? 4 : ((p) == 37 ? 5 : (-1))))))
|
|
70
|
+
|
|
71
|
+#define digitalPinHasPWM(p) ((p) == 0 || (p) == 1 || (p) == 14 || (p) == 15 || (p) == 16 || (p) == 24 || (p) == 25 || (p) == 26 || (p) == 27)
|
|
72
|
+
|
|
73
|
+// __AVR_ATmega32U4__ has an unusual mapping of pins to channels
|
|
74
|
+extern const uint8_t PROGMEM analog_pin_to_channel_PGM[];
|
|
75
|
+#define analogPinToChannel(P) ( pgm_read_byte( analog_pin_to_channel_PGM + (P) ) )
|
|
76
|
+
|
|
77
|
+#ifdef ARDUINO_MAIN
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+// these arrays map port names (e.g. port B) to the
|
|
81
|
+// appropriate addresses for various functions (e.g. reading
|
|
82
|
+// and writing)
|
|
83
|
+// Note PA == 1, PB == 2, etc. (GAH!)
|
|
84
|
+const uint16_t PROGMEM port_to_mode_PGM[] = {
|
|
85
|
+ NOT_A_PORT,
|
|
86
|
+ (uint16_t) &DDRA,
|
|
87
|
+ (uint16_t) &DDRB,
|
|
88
|
+ (uint16_t) &DDRC,
|
|
89
|
+ (uint16_t) &DDRD,
|
|
90
|
+ (uint16_t) &DDRE,
|
|
91
|
+};
|
|
92
|
+
|
|
93
|
+const uint16_t PROGMEM port_to_output_PGM[] = {
|
|
94
|
+ NOT_A_PORT,
|
|
95
|
+ (uint16_t) &PORTA,
|
|
96
|
+ (uint16_t) &PORTB,
|
|
97
|
+ (uint16_t) &PORTC,
|
|
98
|
+ (uint16_t) &PORTD,
|
|
99
|
+ (uint16_t) &PORTE,
|
|
100
|
+};
|
|
101
|
+
|
|
102
|
+const uint16_t PROGMEM port_to_input_PGM[] = {
|
|
103
|
+ NOT_A_PORT,
|
|
104
|
+ (uint16_t) &PINA,
|
|
105
|
+ (uint16_t) &PINB,
|
|
106
|
+ (uint16_t) &PINC,
|
|
107
|
+ (uint16_t) &PIND,
|
|
108
|
+ (uint16_t) &PINE,
|
|
109
|
+};
|
|
110
|
+
|
|
111
|
+const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
|
|
112
|
+ PD, // 0 - PD0 - INT0 - PWM
|
|
113
|
+ PD, // 1 - PD1 - INT1 - PWM
|
|
114
|
+ PD, // 2 - PD2 - INT2 - RX
|
|
115
|
+ PD, // 3 - PD3 - INT3 - TX
|
|
116
|
+ PD, // 4 - PD4
|
|
117
|
+ PD, // 5 - PD5
|
|
118
|
+ PD, // 6 - PD6
|
|
119
|
+ PD, // 7 - PD7
|
|
120
|
+ PE, // 8 - PE0
|
|
121
|
+ PE, // 9 - PE1
|
|
122
|
+ PC, // 10 - PC0
|
|
123
|
+ PC, // 11 - PC1
|
|
124
|
+ PC, // 12 - PC2
|
|
125
|
+ PC, // 13 - PC3
|
|
126
|
+ PC, // 14 - PC4 - PWM
|
|
127
|
+ PC, // 15 - PC5 - PWM
|
|
128
|
+ PC, // 16 - PC6 - PWM
|
|
129
|
+ PC, // 17 - PC7
|
|
130
|
+ PE, // 18 - PE6 - INT6
|
|
131
|
+ PE, // 19 - PE7 - INT7
|
|
132
|
+ PB, // 20 - PB0
|
|
133
|
+ PB, // 21 - PB1
|
|
134
|
+ PB, // 22 - PB2
|
|
135
|
+ PB, // 23 - PB3
|
|
136
|
+ PB, // 24 - PB4 - PWM
|
|
137
|
+ PB, // 25 - PB5 - PWM
|
|
138
|
+ PB, // 26 - PB6 - PWM
|
|
139
|
+ PB, // 27 - PB7 - PWM
|
|
140
|
+ PA, // 28 - PA0
|
|
141
|
+ PA, // 29 - PA1
|
|
142
|
+ PA, // 30 - PA2
|
|
143
|
+ PA, // 31 - PA3
|
|
144
|
+ PA, // 32 - PA4
|
|
145
|
+ PA, // 33 - PA5
|
|
146
|
+ PA, // 34 - PA6
|
|
147
|
+ PA, // 35 - PA7
|
|
148
|
+ PE, // 36 - PE4 - INT4
|
|
149
|
+ PE, // 37 - PE5 - INT5
|
|
150
|
+ PF, // 38 - PF0 - A0
|
|
151
|
+ PF, // 39 - PF1 - A1
|
|
152
|
+ PF, // 40 - PF2 - A2
|
|
153
|
+ PF, // 41 - PF3 - A3
|
|
154
|
+ PF, // 42 - PF4 - A4
|
|
155
|
+ PF, // 43 - PF5 - A5
|
|
156
|
+ PF, // 44 - PF6 - A6
|
|
157
|
+ PF, // 45 - PF7 - A7
|
|
158
|
+ PE, // 46 - PE2 (not defined in teensy)
|
|
159
|
+ PE, // 47 - PE3 (not defined in teensy)
|
|
160
|
+};
|
|
161
|
+
|
|
162
|
+const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = {
|
|
163
|
+ _BV(0), // 0 - PD0 - INT0 - PWM
|
|
164
|
+ _BV(1), // 1 - PD1 - INT1 - PWM
|
|
165
|
+ _BV(2), // 2 - PD2 - INT2 - RX
|
|
166
|
+ _BV(3), // 3 - PD3 - INT3 - TX
|
|
167
|
+ _BV(4), // 4 - PD4
|
|
168
|
+ _BV(5), // 5 - PD5
|
|
169
|
+ _BV(6), // 6 - PD6
|
|
170
|
+ _BV(7), // 7 - PD7
|
|
171
|
+ _BV(0), // 8 - PE0
|
|
172
|
+ _BV(1), // 9 - PE1
|
|
173
|
+ _BV(0), // 10 - PC0
|
|
174
|
+ _BV(1), // 11 - PC1
|
|
175
|
+ _BV(2), // 12 - PC2
|
|
176
|
+ _BV(3), // 13 - PC3
|
|
177
|
+ _BV(4), // 14 - PC4 - PWM
|
|
178
|
+ _BV(5), // 15 - PC5 - PWM
|
|
179
|
+ _BV(6), // 16 - PC6 - PWM
|
|
180
|
+ _BV(7), // 17 - PC7
|
|
181
|
+ _BV(6), // 18 - PE6 - INT6
|
|
182
|
+ _BV(7), // 19 - PE7 - INT7
|
|
183
|
+ _BV(0), // 20 - PB0
|
|
184
|
+ _BV(1), // 21 - PB1
|
|
185
|
+ _BV(2), // 22 - PB2
|
|
186
|
+ _BV(3), // 23 - PB3
|
|
187
|
+ _BV(4), // 24 - PB4 - PWM
|
|
188
|
+ _BV(5), // 25 - PB5 - PWM
|
|
189
|
+ _BV(6), // 26 - PB6 - PWM
|
|
190
|
+ _BV(7), // 27 - PB7 - PWM
|
|
191
|
+ _BV(0), // 28 - PA0
|
|
192
|
+ _BV(1), // 29 - PA1
|
|
193
|
+ _BV(2), // 30 - PA2
|
|
194
|
+ _BV(3), // 31 - PA3
|
|
195
|
+ _BV(4), // 32 - PA4
|
|
196
|
+ _BV(5), // 33 - PA5
|
|
197
|
+ _BV(6), // 34 - PA6
|
|
198
|
+ _BV(7), // 35 - PA7
|
|
199
|
+ _BV(4), // 36 - PE4 - INT4
|
|
200
|
+ _BV(5), // 37 - PE5 - INT5
|
|
201
|
+ _BV(0), // 38 - PF0 - A0
|
|
202
|
+ _BV(1), // 39 - PF1 - A1
|
|
203
|
+ _BV(2), // 40 - PF2 - A2
|
|
204
|
+ _BV(3), // 41 - PF3 - A3
|
|
205
|
+ _BV(4), // 42 - PF4 - A4
|
|
206
|
+ _BV(5), // 43 - PF5 - A5
|
|
207
|
+ _BV(6), // 44 - PF6 - A6
|
|
208
|
+ _BV(7), // 45 - PF7 - A7
|
|
209
|
+ _BV(2), // 46 - PE2 (not defined in teensy)
|
|
210
|
+ _BV(3), // 47 - PE3 (not defined in teensy)
|
|
211
|
+};
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+// TODO(unrepentantgeek) complete this map of PWM capable pins
|
|
215
|
+const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {
|
|
216
|
+ TIMER0A, // 0 - PD0 - INT0 - PWM
|
|
217
|
+ TIMER2B, // 1 - PD1 - INT1 - PWM
|
|
218
|
+ NOT_ON_TIMER, // 2 - PD2 - INT2 - RX
|
|
219
|
+ NOT_ON_TIMER, // 3 - PD3 - INT3 - TX
|
|
220
|
+ NOT_ON_TIMER, // 4 - PD4
|
|
221
|
+ NOT_ON_TIMER, // 5 - PD5
|
|
222
|
+ NOT_ON_TIMER, // 6 - PD6
|
|
223
|
+ NOT_ON_TIMER, // 7 - PD7
|
|
224
|
+ NOT_ON_TIMER, // 8 - PE0
|
|
225
|
+ NOT_ON_TIMER, // 9 - PE1
|
|
226
|
+ NOT_ON_TIMER, // 10 - PC0
|
|
227
|
+ NOT_ON_TIMER, // 11 - PC1
|
|
228
|
+ NOT_ON_TIMER, // 12 - PC2
|
|
229
|
+ NOT_ON_TIMER, // 13 - PC3
|
|
230
|
+ TIMER3C, // 14 - PC4 - PWM
|
|
231
|
+ TIMER3B, // 15 - PC5 - PWM
|
|
232
|
+ TIMER3A, // 16 - PC6 - PWM
|
|
233
|
+ NOT_ON_TIMER, // 17 - PC7
|
|
234
|
+ NOT_ON_TIMER, // 18 - PE6 - INT6
|
|
235
|
+ NOT_ON_TIMER, // 19 - PE7 - INT7
|
|
236
|
+ NOT_ON_TIMER, // 20 - PB0
|
|
237
|
+ NOT_ON_TIMER, // 21 - PB1
|
|
238
|
+ NOT_ON_TIMER, // 22 - PB2
|
|
239
|
+ NOT_ON_TIMER, // 23 - PB3
|
|
240
|
+ TIMER2A, // 24 - PB4 - PWM
|
|
241
|
+ TIMER1A, // 25 - PB5 - PWM
|
|
242
|
+ TIMER1B, // 26 - PB6 - PWM
|
|
243
|
+ NOT_ON_TIMER, // 27 - PB7 - PWM // This should be on TIMER1C
|
|
244
|
+ NOT_ON_TIMER, // 28 - PA0
|
|
245
|
+ NOT_ON_TIMER, // 29 - PA1
|
|
246
|
+ NOT_ON_TIMER, // 30 - PA2
|
|
247
|
+ NOT_ON_TIMER, // 31 - PA3
|
|
248
|
+ NOT_ON_TIMER, // 32 - PA4
|
|
249
|
+ NOT_ON_TIMER, // 33 - PA5
|
|
250
|
+ NOT_ON_TIMER, // 34 - PA6
|
|
251
|
+ NOT_ON_TIMER, // 35 - PA7
|
|
252
|
+ NOT_ON_TIMER, // 36 - PE4 - INT4
|
|
253
|
+ NOT_ON_TIMER, // 37 - PE5 - INT5
|
|
254
|
+ NOT_ON_TIMER, // 38 - PF0 - A0
|
|
255
|
+ NOT_ON_TIMER, // 39 - PF1 - A1
|
|
256
|
+ NOT_ON_TIMER, // 40 - PF2 - A2
|
|
257
|
+ NOT_ON_TIMER, // 41 - PF3 - A3
|
|
258
|
+ NOT_ON_TIMER, // 42 - PF4 - A4
|
|
259
|
+ NOT_ON_TIMER, // 43 - PF5 - A5
|
|
260
|
+ NOT_ON_TIMER, // 44 - PF6 - A6
|
|
261
|
+ NOT_ON_TIMER, // 45 - PF7 - A7
|
|
262
|
+ NOT_ON_TIMER, // 46 - PE2 (not defined in teensy)
|
|
263
|
+ NOT_ON_TIMER, // 47 - PE3 (not defined in teensy)
|
|
264
|
+};
|
|
265
|
+
|
|
266
|
+const uint8_t PROGMEM analog_pin_to_channel_PGM[8] = {
|
|
267
|
+ 0, // A0 PF0 ADC0
|
|
268
|
+ 1, // A1 PF1 ADC1
|
|
269
|
+ 2, // A2 PF2 ADC2
|
|
270
|
+ 3, // A3 PF3 ADC3
|
|
271
|
+ 4, // A4 PF4 ADC4
|
|
272
|
+ 5, // A5 PF5 ADC5
|
|
273
|
+ 6, // A6 PD6 ADC6
|
|
274
|
+ 7, // A7 PD7 ADC7
|
|
275
|
+};
|
|
276
|
+
|
|
277
|
+#endif /* ARDUINO_MAIN */
|
|
278
|
+#endif /* Pins_Arduino_h */
|