-
Notifications
You must be signed in to change notification settings - Fork 12
/
pin_to_avr.h
executable file
·405 lines (395 loc) · 10.7 KB
/
pin_to_avr.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
/* Arduino WaveRP Library
* Copyright (C) 2009 by William Greiman
*
* This file is part of the Arduino WaveRP Library
*
* This Library is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This Library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the Arduino WaveRP Library. If not, see
* <http://www.gnu.org/licenses/>.
*/
#ifndef pin_to_avr_h
#define pin_to_avr_h
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
// Mega Arduino
// bit number for all pins
#define PIN0_BITNUM 0
#define PIN1_BITNUM 1
#define PIN2_BITNUM 4
#define PIN3_BITNUM 5
#define PIN4_BITNUM 5
#define PIN5_BITNUM 3
#define PIN6_BITNUM 3
#define PIN7_BITNUM 4
#define PIN8_BITNUM 5
#define PIN9_BITNUM 6
#define PIN10_BITNUM 4
#define PIN11_BITNUM 5
#define PIN12_BITNUM 6
#define PIN13_BITNUM 7
#define PIN14_BITNUM 1
#define PIN15_BITNUM 0
#define PIN16_BITNUM 1
#define PIN17_BITNUM 0
#define PIN18_BITNUM 3
#define PIN19_BITNUM 2
#define PIN20_BITNUM 1
#define PIN21_BITNUM 0
#define PIN22_BITNUM 0
#define PIN23_BITNUM 1
#define PIN24_BITNUM 2
#define PIN25_BITNUM 3
#define PIN26_BITNUM 4
#define PIN27_BITNUM 5
#define PIN28_BITNUM 6
#define PIN29_BITNUM 7
#define PIN30_BITNUM 7
#define PIN31_BITNUM 6
#define PIN32_BITNUM 5
#define PIN33_BITNUM 4
#define PIN34_BITNUM 3
#define PIN35_BITNUM 2
#define PIN36_BITNUM 1
#define PIN37_BITNUM 0
#define PIN38_BITNUM 7
#define PIN39_BITNUM 2
#define PIN40_BITNUM 1
#define PIN41_BITNUM 0
#define PIN42_BITNUM 7
#define PIN43_BITNUM 6
#define PIN44_BITNUM 5
#define PIN45_BITNUM 4
#define PIN46_BITNUM 3
#define PIN47_BITNUM 2
#define PIN48_BITNUM 1
#define PIN49_BITNUM 0
#define PIN50_BITNUM 3
#define PIN51_BITNUM 2
#define PIN52_BITNUM 1
#define PIN53_BITNUM 0
#define PIN54_BITNUM 0
#define PIN55_BITNUM 1
#define PIN56_BITNUM 2
#define PIN57_BITNUM 3
#define PIN58_BITNUM 4
#define PIN59_BITNUM 5
#define PIN60_BITNUM 6
#define PIN61_BITNUM 7
#define PIN62_BITNUM 0
#define PIN63_BITNUM 1
#define PIN64_BITNUM 2
#define PIN65_BITNUM 3
#define PIN66_BITNUM 4
#define PIN67_BITNUM 5
#define PIN68_BITNUM 6
#define PIN69_BITNUM 7
// output register for all pins
#define PIN0_PORTREG PORTE
#define PIN1_PORTREG PORTE
#define PIN2_PORTREG PORTE
#define PIN3_PORTREG PORTE
#define PIN4_PORTREG PORTG
#define PIN5_PORTREG PORTE
#define PIN6_PORTREG PORTH
#define PIN7_PORTREG PORTH
#define PIN8_PORTREG PORTH
#define PIN9_PORTREG PORTH
#define PIN10_PORTREG PORTB
#define PIN11_PORTREG PORTB
#define PIN12_PORTREG PORTB
#define PIN13_PORTREG PORTB
#define PIN14_PORTREG PORTJ
#define PIN15_PORTREG PORTJ
#define PIN16_PORTREG PORTH
#define PIN17_PORTREG PORTH
#define PIN18_PORTREG PORTD
#define PIN19_PORTREG PORTD
#define PIN20_PORTREG PORTD
#define PIN21_PORTREG PORTD
#define PIN22_PORTREG PORTA
#define PIN23_PORTREG PORTA
#define PIN24_PORTREG PORTA
#define PIN25_PORTREG PORTA
#define PIN26_PORTREG PORTA
#define PIN27_PORTREG PORTA
#define PIN28_PORTREG PORTA
#define PIN29_PORTREG PORTA
#define PIN30_PORTREG PORTC
#define PIN31_PORTREG PORTC
#define PIN32_PORTREG PORTC
#define PIN33_PORTREG PORTC
#define PIN34_PORTREG PORTC
#define PIN35_PORTREG PORTC
#define PIN36_PORTREG PORTC
#define PIN37_PORTREG PORTC
#define PIN38_PORTREG PORTD
#define PIN39_PORTREG PORTG
#define PIN40_PORTREG PORTG
#define PIN41_PORTREG PORTG
#define PIN42_PORTREG PORTL
#define PIN43_PORTREG PORTL
#define PIN44_PORTREG PORTL
#define PIN45_PORTREG PORTL
#define PIN46_PORTREG PORTL
#define PIN47_PORTREG PORTL
#define PIN48_PORTREG PORTL
#define PIN49_PORTREG PORTL
#define PIN50_PORTREG PORTB
#define PIN51_PORTREG PORTB
#define PIN52_PORTREG PORTB
#define PIN53_PORTREG PORTB
#define PIN54_PORTREG PORTF
#define PIN55_PORTREG PORTF
#define PIN56_PORTREG PORTF
#define PIN57_PORTREG PORTF
#define PIN58_PORTREG PORTF
#define PIN59_PORTREG PORTF
#define PIN60_PORTREG PORTF
#define PIN61_PORTREG PORTF
#define PIN62_PORTREG PORTK
#define PIN63_PORTREG PORTK
#define PIN64_PORTREG PORTK
#define PIN65_PORTREG PORTK
#define PIN66_PORTREG PORTK
#define PIN67_PORTREG PORTK
#define PIN68_PORTREG PORTK
#define PIN69_PORTREG PORTK
// direction control register for all pins
#define PIN0_DDRREG DDRE
#define PIN1_DDRREG DDRE
#define PIN2_DDRREG DDRE
#define PIN3_DDRREG DDRE
#define PIN4_DDRREG DDRG
#define PIN5_DDRREG DDRE
#define PIN6_DDRREG DDRH
#define PIN7_DDRREG DDRH
#define PIN8_DDRREG DDRH
#define PIN9_DDRREG DDRH
#define PIN10_DDRREG DDRB
#define PIN11_DDRREG DDRB
#define PIN12_DDRREG DDRB
#define PIN13_DDRREG DDRB
#define PIN14_DDRREG DDRJ
#define PIN15_DDRREG DDRJ
#define PIN16_DDRREG DDRH
#define PIN17_DDRREG DDRH
#define PIN18_DDRREG DDRD
#define PIN19_DDRREG DDRD
#define PIN20_DDRREG DDRD
#define PIN21_DDRREG DDRD
#define PIN22_DDRREG DDRA
#define PIN23_DDRREG DDRA
#define PIN24_DDRREG DDRA
#define PIN25_DDRREG DDRA
#define PIN26_DDRREG DDRA
#define PIN27_DDRREG DDRA
#define PIN28_DDRREG DDRA
#define PIN29_DDRREG DDRA
#define PIN30_DDRREG DDRC
#define PIN31_DDRREG DDRC
#define PIN32_DDRREG DDRC
#define PIN33_DDRREG DDRC
#define PIN34_DDRREG DDRC
#define PIN35_DDRREG DDRC
#define PIN36_DDRREG DDRC
#define PIN37_DDRREG DDRC
#define PIN38_DDRREG DDRD
#define PIN39_DDRREG DDRG
#define PIN40_DDRREG DDRG
#define PIN41_DDRREG DDRG
#define PIN42_DDRREG DDRL
#define PIN43_DDRREG DDRL
#define PIN44_DDRREG DDRL
#define PIN45_DDRREG DDRL
#define PIN46_DDRREG DDRL
#define PIN47_DDRREG DDRL
#define PIN48_DDRREG DDRL
#define PIN49_DDRREG DDRL
#define PIN50_DDRREG DDRB
#define PIN51_DDRREG DDRB
#define PIN52_DDRREG DDRB
#define PIN53_DDRREG DDRB
#define PIN54_DDRREG DDRF
#define PIN55_DDRREG DDRF
#define PIN56_DDRREG DDRF
#define PIN57_DDRREG DDRF
#define PIN58_DDRREG DDRF
#define PIN59_DDRREG DDRF
#define PIN60_DDRREG DDRF
#define PIN61_DDRREG DDRF
#define PIN62_DDRREG DDRK
#define PIN63_DDRREG DDRK
#define PIN64_DDRREG DDRK
#define PIN65_DDRREG DDRK
#define PIN66_DDRREG DDRK
#define PIN67_DDRREG DDRK
#define PIN68_DDRREG DDRK
#define PIN69_DDRREG DDRK
// input register for all pins
#define PIN0_PINREG PINE
#define PIN1_PINREG PINE
#define PIN2_PINREG PINE
#define PIN3_PINREG PINE
#define PIN4_PINREG PING
#define PIN5_PINREG PINE
#define PIN6_PINREG PINH
#define PIN7_PINREG PINH
#define PIN8_PINREG PINH
#define PIN9_PINREG PINH
#define PIN10_PINREG PINB
#define PIN11_PINREG PINB
#define PIN12_PINREG PINB
#define PIN13_PINREG PINB
#define PIN14_PINREG PINJ
#define PIN15_PINREG PINJ
#define PIN16_PINREG PINH
#define PIN17_PINREG PINH
#define PIN18_PINREG PIND
#define PIN19_PINREG PIND
#define PIN20_PINREG PIND
#define PIN21_PINREG PIND
#define PIN22_PINREG PINA
#define PIN23_PINREG PINA
#define PIN24_PINREG PINA
#define PIN25_PINREG PINA
#define PIN26_PINREG PINA
#define PIN27_PINREG PINA
#define PIN28_PINREG PINA
#define PIN29_PINREG PINA
#define PIN30_PINREG PINC
#define PIN31_PINREG PINC
#define PIN32_PINREG PINC
#define PIN33_PINREG PINC
#define PIN34_PINREG PINC
#define PIN35_PINREG PINC
#define PIN36_PINREG PINC
#define PIN37_PINREG PINC
#define PIN38_PINREG PIND
#define PIN39_PINREG PING
#define PIN40_PINREG PING
#define PIN41_PINREG PING
#define PIN42_PINREG PINL
#define PIN43_PINREG PINL
#define PIN44_PINREG PINL
#define PIN45_PINREG PINL
#define PIN46_PINREG PINL
#define PIN47_PINREG PINL
#define PIN48_PINREG PINL
#define PIN49_PINREG PINL
#define PIN50_PINREG PINB
#define PIN51_PINREG PINB
#define PIN52_PINREG PINB
#define PIN53_PINREG PINB
#define PIN54_PINREG PINF
#define PIN55_PINREG PINF
#define PIN56_PINREG PINF
#define PIN57_PINREG PINF
#define PIN58_PINREG PINF
#define PIN59_PINREG PINF
#define PIN60_PINREG PINF
#define PIN61_PINREG PINF
#define PIN62_PINREG PINK
#define PIN63_PINREG PINK
#define PIN64_PINREG PINK
#define PIN65_PINREG PINK
#define PIN66_PINREG PINK
#define PIN67_PINREG PINK
#define PIN68_PINREG PINK
#define PIN69_PINREG PINK
#else // defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
// 168 and 328 Arduinos
// bit number for all pins
#define PIN0_BITNUM 0
#define PIN1_BITNUM 1
#define PIN2_BITNUM 2
#define PIN3_BITNUM 3
#define PIN4_BITNUM 4
#define PIN5_BITNUM 5
#define PIN6_BITNUM 6
#define PIN7_BITNUM 7
#define PIN8_BITNUM 0
#define PIN9_BITNUM 1
#define PIN10_BITNUM 2
#define PIN11_BITNUM 3
#define PIN12_BITNUM 4
#define PIN13_BITNUM 5
#define PIN14_BITNUM 0
#define PIN15_BITNUM 1
#define PIN16_BITNUM 2
#define PIN17_BITNUM 3
#define PIN18_BITNUM 4
#define PIN19_BITNUM 5
// output register for all pins
#define PIN0_PORTREG PORTD
#define PIN1_PORTREG PORTD
#define PIN2_PORTREG PORTD
#define PIN3_PORTREG PORTD
#define PIN4_PORTREG PORTD
#define PIN5_PORTREG PORTD
#define PIN6_PORTREG PORTD
#define PIN7_PORTREG PORTD
#define PIN8_PORTREG PORTB
#define PIN9_PORTREG PORTB
#define PIN10_PORTREG PORTB
#define PIN11_PORTREG PORTB
#define PIN12_PORTREG PORTB
#define PIN13_PORTREG PORTB
#define PIN14_PORTREG PORTC
#define PIN15_PORTREG PORTC
#define PIN16_PORTREG PORTC
#define PIN17_PORTREG PORTC
#define PIN18_PORTREG PORTC
#define PIN19_PORTREG PORTC
// direction control register for all pins
#define PIN0_DDRREG DDRD
#define PIN1_DDRREG DDRD
#define PIN2_DDRREG DDRD
#define PIN3_DDRREG DDRD
#define PIN4_DDRREG DDRD
#define PIN5_DDRREG DDRD
#define PIN6_DDRREG DDRD
#define PIN7_DDRREG DDRD
#define PIN8_DDRREG DDRB
#define PIN9_DDRREG DDRB
#define PIN10_DDRREG DDRB
#define PIN11_DDRREG DDRB
#define PIN12_DDRREG DDRB
#define PIN13_DDRREG DDRB
#define PIN14_DDRREG DDRC
#define PIN15_DDRREG DDRC
#define PIN16_DDRREG DDRC
#define PIN17_DDRREG DDRC
#define PIN18_DDRREG DDRC
#define PIN19_DDRREG DDRC
// input register for all pins
#define PIN0_PINREG PIND
#define PIN1_PINREG PIND
#define PIN2_PINREG PIND
#define PIN3_PINREG PIND
#define PIN4_PINREG PIND
#define PIN5_PINREG PIND
#define PIN6_PINREG PIND
#define PIN7_PINREG PIND
#define PIN8_PINREG PINB
#define PIN9_PINREG PINB
#define PIN10_PINREG PINB
#define PIN11_PINREG PINB
#define PIN12_PINREG PINB
#define PIN13_PINREG PINB
#define PIN14_PINREG PINC
#define PIN15_PINREG PINC
#define PIN16_PINREG PINC
#define PIN17_PINREG PINC
#define PIN18_PINREG PINC
#define PIN19_PINREG PINC
#endif // defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
#endif // pin_to_avr_h