Debian Codegraph @

app/testdata/libraries/SD_1.1.1/SD/src/utility/Sd2PinMap.h

raw symbols SCIP
1 /* Arduino SdFat Library
2 * Copyright (C) 2010 by William Greiman
3 *
4 * This file is part of the Arduino SdFat Library
5 *
6 * This Library is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This Library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with the Arduino SdFat Library. If not, see
18 * <http://www.gnu.org/licenses/>.
19 */
20 #if defined(__arm__) // Arduino Due Board follows
21
22 #ifndef Sd2PinMap_h
23 #define Sd2PinMap_h
24
25 #include <Arduino.h>
26
27 uint8_t const SS_PIN = SS;
28 uint8_t const MOSI_PIN = MOSI;
29 uint8_t const MISO_PIN = MISO;
30 uint8_t const SCK_PIN = SCK;
31
32 #endif // Sd2PinMap_h
33
34 #elif defined(__AVR__) // Other AVR based Boards follows
35
36 // Warning this file was generated by a program.
37 #ifndef Sd2PinMap_h
38 #define Sd2PinMap_h
39 #include <avr/io.h>
40
41 //------------------------------------------------------------------------------
42 /** struct for mapping digital pins */
43 struct pin_map_t {
44 volatile uint8_t* ddr;
45 volatile uint8_t* pin;
46 volatile uint8_t* port;
47 uint8_t bit;
48 };
49 //------------------------------------------------------------------------------
50 #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
51 // Mega
52
53 // Two Wire (aka I2C) ports
54 uint8_t const SDA_PIN = 20;
55 uint8_t const SCL_PIN = 21;
56
57 // SPI port
58 uint8_t const SS_PIN = 53;
59 uint8_t const MOSI_PIN = 51;
60 uint8_t const MISO_PIN = 50;
61 uint8_t const SCK_PIN = 52;
62
63 static const pin_map_t digitalPinMap[] = {
64 {&DDRE, &PINE, &PORTE, 0}, // E0 0
65 {&DDRE, &PINE, &PORTE, 1}, // E1 1
66 {&DDRE, &PINE, &PORTE, 4}, // E4 2
67 {&DDRE, &PINE, &PORTE, 5}, // E5 3
68 {&DDRG, &PING, &PORTG, 5}, // G5 4
69 {&DDRE, &PINE, &PORTE, 3}, // E3 5
70 {&DDRH, &PINH, &PORTH, 3}, // H3 6
71 {&DDRH, &PINH, &PORTH, 4}, // H4 7
72 {&DDRH, &PINH, &PORTH, 5}, // H5 8
73 {&DDRH, &PINH, &PORTH, 6}, // H6 9
74 {&DDRB, &PINB, &PORTB, 4}, // B4 10
75 {&DDRB, &PINB, &PORTB, 5}, // B5 11
76 {&DDRB, &PINB, &PORTB, 6}, // B6 12
77 {&DDRB, &PINB, &PORTB, 7}, // B7 13
78 {&DDRJ, &PINJ, &PORTJ, 1}, // J1 14
79 {&DDRJ, &PINJ, &PORTJ, 0}, // J0 15
80 {&DDRH, &PINH, &PORTH, 1}, // H1 16
81 {&DDRH, &PINH, &PORTH, 0}, // H0 17
82 {&DDRD, &PIND, &PORTD, 3}, // D3 18
83 {&DDRD, &PIND, &PORTD, 2}, // D2 19
84 {&DDRD, &PIND, &PORTD, 1}, // D1 20
85 {&DDRD, &PIND, &PORTD, 0}, // D0 21
86 {&DDRA, &PINA, &PORTA, 0}, // A0 22
87 {&DDRA, &PINA, &PORTA, 1}, // A1 23
88 {&DDRA, &PINA, &PORTA, 2}, // A2 24
89 {&DDRA, &PINA, &PORTA, 3}, // A3 25
90 {&DDRA, &PINA, &PORTA, 4}, // A4 26
91 {&DDRA, &PINA, &PORTA, 5}, // A5 27
92 {&DDRA, &PINA, &PORTA, 6}, // A6 28
93 {&DDRA, &PINA, &PORTA, 7}, // A7 29
94 {&DDRC, &PINC, &PORTC, 7}, // C7 30
95 {&DDRC, &PINC, &PORTC, 6}, // C6 31
96 {&DDRC, &PINC, &PORTC, 5}, // C5 32
97 {&DDRC, &PINC, &PORTC, 4}, // C4 33
98 {&DDRC, &PINC, &PORTC, 3}, // C3 34
99 {&DDRC, &PINC, &PORTC, 2}, // C2 35
100 {&DDRC, &PINC, &PORTC, 1}, // C1 36
101 {&DDRC, &PINC, &PORTC, 0}, // C0 37
102 {&DDRD, &PIND, &PORTD, 7}, // D7 38
103 {&DDRG, &PING, &PORTG, 2}, // G2 39
104 {&DDRG, &PING, &PORTG, 1}, // G1 40
105 {&DDRG, &PING, &PORTG, 0}, // G0 41
106 {&DDRL, &PINL, &PORTL, 7}, // L7 42
107 {&DDRL, &PINL, &PORTL, 6}, // L6 43
108 {&DDRL, &PINL, &PORTL, 5}, // L5 44
109 {&DDRL, &PINL, &PORTL, 4}, // L4 45
110 {&DDRL, &PINL, &PORTL, 3}, // L3 46
111 {&DDRL, &PINL, &PORTL, 2}, // L2 47
112 {&DDRL, &PINL, &PORTL, 1}, // L1 48
113 {&DDRL, &PINL, &PORTL, 0}, // L0 49
114 {&DDRB, &PINB, &PORTB, 3}, // B3 50
115 {&DDRB, &PINB, &PORTB, 2}, // B2 51
116 {&DDRB, &PINB, &PORTB, 1}, // B1 52
117 {&DDRB, &PINB, &PORTB, 0}, // B0 53
118 {&DDRF, &PINF, &PORTF, 0}, // F0 54
119 {&DDRF, &PINF, &PORTF, 1}, // F1 55
120 {&DDRF, &PINF, &PORTF, 2}, // F2 56
121 {&DDRF, &PINF, &PORTF, 3}, // F3 57
122 {&DDRF, &PINF, &PORTF, 4}, // F4 58
123 {&DDRF, &PINF, &PORTF, 5}, // F5 59
124 {&DDRF, &PINF, &PORTF, 6}, // F6 60
125 {&DDRF, &PINF, &PORTF, 7}, // F7 61
126 {&DDRK, &PINK, &PORTK, 0}, // K0 62
127 {&DDRK, &PINK, &PORTK, 1}, // K1 63
128 {&DDRK, &PINK, &PORTK, 2}, // K2 64
129 {&DDRK, &PINK, &PORTK, 3}, // K3 65
130 {&DDRK, &PINK, &PORTK, 4}, // K4 66
131 {&DDRK, &PINK, &PORTK, 5}, // K5 67
132 {&DDRK, &PINK, &PORTK, 6}, // K6 68
133 {&DDRK, &PINK, &PORTK, 7} // K7 69
134 };
135 //------------------------------------------------------------------------------
136 #elif (defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)) && defined(CORE_MICRODUINO)
137 // Microduino Core+
138
139 // Two Wire (aka I2C) ports
140 uint8_t const SDA_PIN = 20;
141 uint8_t const SCL_PIN = 21;
142
143 // SPI port
144 uint8_t const SS_PIN = 10;
145 uint8_t const MOSI_PIN = 11;
146 uint8_t const MISO_PIN = 12;
147 uint8_t const SCK_PIN = 13;
148
149 static const pin_map_t digitalPinMap[] = {
150 {&DDRD, &PIND, &PORTD, 0}, // D0 PD0
151 {&DDRD, &PIND, &PORTD, 1}, // D1 PD1
152 {&DDRD, &PIND, &PORTD, 2}, // D2 PD2
153 {&DDRD, &PIND, &PORTD, 3}, // D3 PD3
154 {&DDRB, &PINB, &PORTB, 0}, // D4 PB0
155 {&DDRB, &PINB, &PORTB, 1}, // D5 PB1
156 {&DDRB, &PINB, &PORTB, 2}, // D6 PB2
157 {&DDRB, &PINB, &PORTB, 3}, // D7 PB3
158 {&DDRD, &PIND, &PORTD, 6}, // D8 PD6
159 {&DDRD, &PIND, &PORTD, 5}, // D9 PD5
160 {&DDRB, &PINB, &PORTB, 4}, // D10 PB4
161 {&DDRB, &PINB, &PORTB, 5}, // D11 PB5
162 {&DDRB, &PINB, &PORTB, 6}, // D12 PB6
163 {&DDRB, &PINB, &PORTB, 7}, // D13 PB7
164 {&DDRC, &PINC, &PORTC, 7}, // D14 PC7
165 {&DDRC, &PINC, &PORTC, 6}, // D15 PC6
166 {&DDRC, &PINC, &PORTC, 5}, // D16 PC5
167 {&DDRC, &PINC, &PORTC, 4}, // D17 PC4
168 {&DDRC, &PINC, &PORTC, 3}, // D18 PC3
169 {&DDRC, &PINC, &PORTC, 2}, // D19 PC2
170 {&DDRC, &PINC, &PORTC, 1}, // D20 PC1
171 {&DDRC, &PINC, &PORTC, 0}, // D21 PC0
172 {&DDRD, &PIND, &PORTD, 4}, // D22 PD4
173 {&DDRD, &PIND, &PORTD, 7}, // D23 PD7
174 {&DDRA, &PINA, &PORTA, 7}, // D24 PA7
175 {&DDRA, &PINA, &PORTA, 6}, // D25 PA6
176 {&DDRA, &PINA, &PORTA, 5}, // D26 PA5
177 {&DDRA, &PINA, &PORTA, 4}, // D27 PA4
178 {&DDRA, &PINA, &PORTA, 3}, // D28 PA3
179 {&DDRA, &PINA, &PORTA, 2}, // D29 PA2
180 {&DDRA, &PINA, &PORTA, 1}, // D30 PA1
181 {&DDRA, &PINA, &PORTA, 0} // D31 PA0
182 };
183 //------------------------------------------------------------------------------
184 #elif defined(__AVR_ATmega128RFA1__) && defined(CORE_MICRODUINO)
185 // Microduino Core RF
186
187 // Two Wire (aka I2C) ports
188 uint8_t const SDA_PIN = 18;
189 uint8_t const SCL_PIN = 19;
190
191 // SPI port
192 uint8_t const SS_PIN = 10;
193 uint8_t const MOSI_PIN = 11;
194 uint8_t const MISO_PIN = 12;
195 uint8_t const SCK_PIN = 13;
196
197 static const pin_map_t digitalPinMap[] = {
198 {&DDRD, &PINE, &PORTE, 0}, // D0 PE0
199 {&DDRD, &PINE, &PORTE, 1}, // D1 PE1
200 {&DDRD, &PIND, &PORTD, 2}, // D2 PD2
201 {&DDRD, &PIND, &PORTD, 3}, // D3 PD3
202 {&DDRB, &PINE, &PORTE, 3}, // D4 PE3
203 {&DDRB, &PINE, &PORTE, 4}, // D5 PE4
204 {&DDRB, &PINE, &PORTE, 5}, // D6 PE5
205 {&DDRB, &PINB, &PORTB, 7}, // D7 PB7
206 {&DDRD, &PINB, &PORTB, 6}, // D8 PB6
207 {&DDRD, &PINB, &PORTB, 5}, // D9 PB5
208 {&DDRB, &PINB, &PORTB, 4}, // D10 PB4
209 {&DDRB, &PINB, &PORTB, 2}, // D11 PB2
210 {&DDRB, &PINB, &PORTB, 3}, // D12 PB3
211 {&DDRB, &PINB, &PORTB, 1}, // D13 PB1
212 {&DDRF, &PINF, &PORTF, 7}, // D14 PF7
213 {&DDRF, &PINF, &PORTF, 6}, // D15 PF6
214 {&DDRF, &PINF, &PORTF, 5}, // D16 PF5
215 {&DDRF, &PINF, &PORTF, 4}, // D17 PF4
216 {&DDRD, &PIND, &PORTD, 1}, // D18 PD1
217 {&DDRD, &PIND, &PORTD, 0}, // D19 PD0
218 {&DDRF, &PINF, &PORTF, 3}, // D20 PF3
219 {&DDRF, &PINF, &PORTF, 2}, // D21 PF2
220 };
221 //------------------------------------------------------------------------------
222 #elif defined(__AVR_ATmega32U4__) && defined(CORE_MICRODUINO)
223 // Microduino Core USB
224
225 // Two Wire (aka I2C) ports
226 uint8_t const SDA_PIN = 18;
227 uint8_t const SCL_PIN = 19;
228
229 // SPI port
230 uint8_t const SS_PIN = 10;
231 uint8_t const MOSI_PIN = 11;
232 uint8_t const MISO_PIN = 12;
233 uint8_t const SCK_PIN = 13;
234
235 static const pin_map_t digitalPinMap[] = {
236 {&DDRD, &PIND, &PORTD, 2}, // D0 - PD2
237 {&DDRD, &PIND, &PORTD, 3}, // D1 - PD3
238 {&DDRE, &PINE, &PORTE, 6}, // D2 - PE6
239 {&DDRD, &PIND, &PORTD, 6}, // D3 - PD6
240 {&DDRD, &PIND, &PORTD, 7}, // D4 - PD7
241 {&DDRC, &PINC, &PORTC, 6}, // D5 - PC6
242 {&DDRC, &PINC, &PORTC, 7}, // D6 - PC7
243 {&DDRE, &PINE, &PORTE, 7}, // D7 - PE7
244 {&DDRB, &PINB, &PORTB, 6}, // D8 - PB6
245 {&DDRB, &PINB, &PORTB, 5}, // D9 - PB5
246 {&DDRB, &PINB, &PORTB, 0}, // D10 - PB0
247 {&DDRB, &PINB, &PORTB, 2}, // D11 - MOSI - PB2
248 {&DDRB, &PINB, &PORTB, 3}, // D12 -MISO - PB3
249 {&DDRB, &PINB, &PORTB, 1}, // D13 -SCK - PB1
250 {&DDRF, &PINF, &PORTF, 7}, // D14 - A0 - PF7
251 {&DDRF, &PINF, &PORTF, 6}, // D15 - A1 - PF6
252 {&DDRF, &PINF, &PORTF, 5}, // D16 - A2 - PF5
253 {&DDRF, &PINF, &PORTF, 4}, // D17 - A3 - PF4
254 {&DDRD, &PIND, &PORTD, 1}, // D18 - PD1
255 {&DDRD, &PIND, &PORTD, 0}, // D19 - PD0
256 {&DDRF, &PINF, &PORTF, 1}, // D20 - A6 - PF1
257 {&DDRF, &PINF, &PORTF, 0}, // D21 - A7 - PF0
258 };
259 //------------------------------------------------------------------------------
260 #elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__)
261 // Sanguino
262
263 // Two Wire (aka I2C) ports
264 uint8_t const SDA_PIN = 17;
265 uint8_t const SCL_PIN = 18;
266
267 // SPI port
268 uint8_t const SS_PIN = 4;
269 uint8_t const MOSI_PIN = 5;
270 uint8_t const MISO_PIN = 6;
271 uint8_t const SCK_PIN = 7;
272
273 static const pin_map_t digitalPinMap[] = {
274 {&DDRB, &PINB, &PORTB, 0}, // B0 0
275 {&DDRB, &PINB, &PORTB, 1}, // B1 1
276 {&DDRB, &PINB, &PORTB, 2}, // B2 2
277 {&DDRB, &PINB, &PORTB, 3}, // B3 3
278 {&DDRB, &PINB, &PORTB, 4}, // B4 4
279 {&DDRB, &PINB, &PORTB, 5}, // B5 5
280 {&DDRB, &PINB, &PORTB, 6}, // B6 6
281 {&DDRB, &PINB, &PORTB, 7}, // B7 7
282 {&DDRD, &PIND, &PORTD, 0}, // D0 8
283 {&DDRD, &PIND, &PORTD, 1}, // D1 9
284 {&DDRD, &PIND, &PORTD, 2}, // D2 10
285 {&DDRD, &PIND, &PORTD, 3}, // D3 11
286 {&DDRD, &PIND, &PORTD, 4}, // D4 12
287 {&DDRD, &PIND, &PORTD, 5}, // D5 13
288 {&DDRD, &PIND, &PORTD, 6}, // D6 14
289 {&DDRD, &PIND, &PORTD, 7}, // D7 15
290 {&DDRC, &PINC, &PORTC, 0}, // C0 16
291 {&DDRC, &PINC, &PORTC, 1}, // C1 17
292 {&DDRC, &PINC, &PORTC, 2}, // C2 18
293 {&DDRC, &PINC, &PORTC, 3}, // C3 19
294 {&DDRC, &PINC, &PORTC, 4}, // C4 20
295 {&DDRC, &PINC, &PORTC, 5}, // C5 21
296 {&DDRC, &PINC, &PORTC, 6}, // C6 22
297 {&DDRC, &PINC, &PORTC, 7}, // C7 23
298 {&DDRA, &PINA, &PORTA, 7}, // A7 24
299 {&DDRA, &PINA, &PORTA, 6}, // A6 25
300 {&DDRA, &PINA, &PORTA, 5}, // A5 26
301 {&DDRA, &PINA, &PORTA, 4}, // A4 27
302 {&DDRA, &PINA, &PORTA, 3}, // A3 28
303 {&DDRA, &PINA, &PORTA, 2}, // A2 29
304 {&DDRA, &PINA, &PORTA, 1}, // A1 30
305 {&DDRA, &PINA, &PORTA, 0} // A0 31
306 };
307 //------------------------------------------------------------------------------
308 #elif defined(__AVR_ATmega32U4__)
309 // Leonardo
310
311 // Two Wire (aka I2C) ports
312 uint8_t const SDA_PIN = 2;
313 uint8_t const SCL_PIN = 3;
314
315 // SPI port
316 uint8_t const SS_PIN = 17;
317 uint8_t const MOSI_PIN = 16;
318 uint8_t const MISO_PIN = 14;
319 uint8_t const SCK_PIN = 15;
320
321 static const pin_map_t digitalPinMap[] = {
322 {&DDRD, &PIND, &PORTD, 2}, // D2 0
323 {&DDRD, &PIND, &PORTD, 3}, // D3 1
324 {&DDRD, &PIND, &PORTD, 1}, // D1 2
325 {&DDRD, &PIND, &PORTD, 0}, // D0 3
326 {&DDRD, &PIND, &PORTD, 4}, // D4 4
327 {&DDRC, &PINC, &PORTC, 6}, // C6 5
328 {&DDRD, &PIND, &PORTD, 7}, // D7 6
329 {&DDRE, &PINE, &PORTE, 6}, // E6 7
330 {&DDRB, &PINB, &PORTB, 4}, // B4 8
331 {&DDRB, &PINB, &PORTB, 5}, // B5 9
332 {&DDRB, &PINB, &PORTB, 6}, // B6 10
333 {&DDRB, &PINB, &PORTB, 7}, // B7 11
334 {&DDRD, &PIND, &PORTD, 6}, // D6 12
335 {&DDRC, &PINC, &PORTC, 7}, // C7 13
336 {&DDRB, &PINB, &PORTB, 3}, // B3 14
337 {&DDRB, &PINB, &PORTB, 1}, // B1 15
338 {&DDRB, &PINB, &PORTB, 2}, // B2 16
339 {&DDRB, &PINB, &PORTB, 0}, // B0 17
340 {&DDRF, &PINF, &PORTF, 7}, // F7 18
341 {&DDRF, &PINF, &PORTF, 6}, // F6 19
342 {&DDRF, &PINF, &PORTF, 5}, // F5 20
343 {&DDRF, &PINF, &PORTF, 4}, // F4 21
344 {&DDRF, &PINF, &PORTF, 1}, // F1 22
345 {&DDRF, &PINF, &PORTF, 0}, // F0 23
346 };
347 //------------------------------------------------------------------------------
348 #elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
349 // Teensy++ 1.0 & 2.0
350
351 // Two Wire (aka I2C) ports
352 uint8_t const SDA_PIN = 1;
353 uint8_t const SCL_PIN = 0;
354
355 // SPI port
356 uint8_t const SS_PIN = 20;
357 uint8_t const MOSI_PIN = 22;
358 uint8_t const MISO_PIN = 23;
359 uint8_t const SCK_PIN = 21;
360
361 static const pin_map_t digitalPinMap[] = {
362 {&DDRD, &PIND, &PORTD, 0}, // D0 0
363 {&DDRD, &PIND, &PORTD, 1}, // D1 1
364 {&DDRD, &PIND, &PORTD, 2}, // D2 2
365 {&DDRD, &PIND, &PORTD, 3}, // D3 3
366 {&DDRD, &PIND, &PORTD, 4}, // D4 4
367 {&DDRD, &PIND, &PORTD, 5}, // D5 5
368 {&DDRD, &PIND, &PORTD, 6}, // D6 6
369 {&DDRD, &PIND, &PORTD, 7}, // D7 7
370 {&DDRE, &PINE, &PORTE, 0}, // E0 8
371 {&DDRE, &PINE, &PORTE, 1}, // E1 9
372 {&DDRC, &PINC, &PORTC, 0}, // C0 10
373 {&DDRC, &PINC, &PORTC, 1}, // C1 11
374 {&DDRC, &PINC, &PORTC, 2}, // C2 12
375 {&DDRC, &PINC, &PORTC, 3}, // C3 13
376 {&DDRC, &PINC, &PORTC, 4}, // C4 14
377 {&DDRC, &PINC, &PORTC, 5}, // C5 15
378 {&DDRC, &PINC, &PORTC, 6}, // C6 16
379 {&DDRC, &PINC, &PORTC, 7}, // C7 17
380 {&DDRE, &PINE, &PORTE, 6}, // E6 18
381 {&DDRE, &PINE, &PORTE, 7}, // E7 19
382 {&DDRB, &PINB, &PORTB, 0}, // B0 20
383 {&DDRB, &PINB, &PORTB, 1}, // B1 21
384 {&DDRB, &PINB, &PORTB, 2}, // B2 22
385 {&DDRB, &PINB, &PORTB, 3}, // B3 23
386 {&DDRB, &PINB, &PORTB, 4}, // B4 24
387 {&DDRB, &PINB, &PORTB, 5}, // B5 25
388 {&DDRB, &PINB, &PORTB, 6}, // B6 26
389 {&DDRB, &PINB, &PORTB, 7}, // B7 27
390 {&DDRA, &PINA, &PORTA, 0}, // A0 28
391 {&DDRA, &PINA, &PORTA, 1}, // A1 29
392 {&DDRA, &PINA, &PORTA, 2}, // A2 30
393 {&DDRA, &PINA, &PORTA, 3}, // A3 31
394 {&DDRA, &PINA, &PORTA, 4}, // A4 32
395 {&DDRA, &PINA, &PORTA, 5}, // A5 33
396 {&DDRA, &PINA, &PORTA, 6}, // A6 34
397 {&DDRA, &PINA, &PORTA, 7}, // A7 35
398 {&DDRE, &PINE, &PORTE, 4}, // E4 36
399 {&DDRE, &PINE, &PORTE, 5}, // E5 37
400 {&DDRF, &PINF, &PORTF, 0}, // F0 38
401 {&DDRF, &PINF, &PORTF, 1}, // F1 39
402 {&DDRF, &PINF, &PORTF, 2}, // F2 40
403 {&DDRF, &PINF, &PORTF, 3}, // F3 41
404 {&DDRF, &PINF, &PORTF, 4}, // F4 42
405 {&DDRF, &PINF, &PORTF, 5}, // F5 43
406 {&DDRF, &PINF, &PORTF, 6}, // F6 44
407 {&DDRF, &PINF, &PORTF, 7} // F7 45
408 };
409 //------------------------------------------------------------------------------
410 #else // defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
411 // 168 and 328 Arduinos
412
413 // Two Wire (aka I2C) ports
414 uint8_t const SDA_PIN = 18;
415 uint8_t const SCL_PIN = 19;
416
417 // SPI port
418 uint8_t const SS_PIN = 10;
419 uint8_t const MOSI_PIN = 11;
420 uint8_t const MISO_PIN = 12;
421 uint8_t const SCK_PIN = 13;
422
423 static const pin_map_t digitalPinMap[] = {
424 {&DDRD, &PIND, &PORTD, 0}, // D0 0
425 {&DDRD, &PIND, &PORTD, 1}, // D1 1
426 {&DDRD, &PIND, &PORTD, 2}, // D2 2
427 {&DDRD, &PIND, &PORTD, 3}, // D3 3
428 {&DDRD, &PIND, &PORTD, 4}, // D4 4
429 {&DDRD, &PIND, &PORTD, 5}, // D5 5
430 {&DDRD, &PIND, &PORTD, 6}, // D6 6
431 {&DDRD, &PIND, &PORTD, 7}, // D7 7
432 {&DDRB, &PINB, &PORTB, 0}, // B0 8
433 {&DDRB, &PINB, &PORTB, 1}, // B1 9
434 {&DDRB, &PINB, &PORTB, 2}, // B2 10
435 {&DDRB, &PINB, &PORTB, 3}, // B3 11
436 {&DDRB, &PINB, &PORTB, 4}, // B4 12
437 {&DDRB, &PINB, &PORTB, 5}, // B5 13
438 {&DDRC, &PINC, &PORTC, 0}, // C0 14
439 {&DDRC, &PINC, &PORTC, 1}, // C1 15
440 {&DDRC, &PINC, &PORTC, 2}, // C2 16
441 {&DDRC, &PINC, &PORTC, 3}, // C3 17
442 {&DDRC, &PINC, &PORTC, 4}, // C4 18
443 {&DDRC, &PINC, &PORTC, 5} // C5 19
444 };
445 #endif // defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
446 //------------------------------------------------------------------------------
447 static const uint8_t digitalPinCount = sizeof(digitalPinMap)/sizeof(pin_map_t);
448
449 uint8_t badPinNumber(void)
450 __attribute__((error("Pin number is too large or not a constant")));
451
452 static inline __attribute__((always_inline))
453 uint8_t getPinMode(uint8_t pin) {
454 if (__builtin_constant_p(pin) && pin < digitalPinCount) {
455 return (*digitalPinMap[pin].ddr >> digitalPinMap[pin].bit) & 1;
456 } else {
457 return badPinNumber();
458 }
459 }
460 static inline __attribute__((always_inline))
461 void setPinMode(uint8_t pin, uint8_t mode) {
462 if (__builtin_constant_p(pin) && pin < digitalPinCount) {
463 if (mode) {
464 *digitalPinMap[pin].ddr |= 1 << digitalPinMap[pin].bit;
465 } else {
466 *digitalPinMap[pin].ddr &= ~(1 << digitalPinMap[pin].bit);
467 }
468 } else {
469 badPinNumber();
470 }
471 }
472 static inline __attribute__((always_inline))
473 uint8_t fastDigitalRead(uint8_t pin) {
474 if (__builtin_constant_p(pin) && pin < digitalPinCount) {
475 return (*digitalPinMap[pin].pin >> digitalPinMap[pin].bit) & 1;
476 } else {
477 return badPinNumber();
478 }
479 }
480 static inline __attribute__((always_inline))
481 void fastDigitalWrite(uint8_t pin, uint8_t value) {
482 if (__builtin_constant_p(pin) && pin < digitalPinCount) {
483 if (value) {
484 *digitalPinMap[pin].port |= 1 << digitalPinMap[pin].bit;
485 } else {
486 *digitalPinMap[pin].port &= ~(1 << digitalPinMap[pin].bit);
487 }
488 } else {
489 badPinNumber();
490 }
491 }
492 #endif // Sd2PinMap_h
493
494 #elif defined (__CPU_ARC__)
495
496 #if defined (__ARDUINO_ARC__)
497 // Two Wire (aka I2C) ports
498 uint8_t const SDA_PIN = 18;
499 uint8_t const SCL_PIN = 19;
500
501 // SPI port
502 uint8_t const SS_PIN = 10;
503 uint8_t const MOSI_PIN = 11;
504 uint8_t const MISO_PIN = 12;
505 uint8_t const SCK_PIN = 13;
506
507 #endif // Arduino ARC
508
509 #else
510 #error Architecture or board not supported.
511 #endif