STIMA  3
pin_defs.h
1 /*
2  * pin_defs.h
3  * optiboot helper defining the default pin assignments (LED, SOFT_UART)
4  * for the various chips that are supported. This also has some ugly macros
5  * for selecting among various UARTs and LED possibilities using command-line
6  * defines like "UART=2 LED=B5"
7  *
8  * Copyright 2013-2015 by Bill Westfield.
9  * Copyright 2010 by Peter Knight.
10  * This software is licensed under version 2 of the Gnu Public Licence.
11  * See optiboot.c for details.
12  */
13 
14 /*------------------------------------------------------------------------ */
15 #if defined(__AVR_ATmega168__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega88) || defined(__AVR_ATmega8__) || defined(__AVR_ATmega88__)
16 /*------------------------------------------------------------------------ */
17 
18 /* Onboard LED is connected to pin PB5 in Arduino NG, Diecimila, and Duemilanove
19  */
20 #if !defined(LED)
21 #define LED B5
22 #endif
23 
24 /* Ports for soft UART */
25 #ifdef SOFT_UART
26 #define UART_PORT PORTD
27 #define UART_PIN PIND
28 #define UART_DDR DDRD
29 #define UART_TX_BIT 1
30 #define UART_RX_BIT 0
31 #endif
32 #endif
33 
34 /*
35  * Handle devices with up to 4 uarts (eg m1280.) Rather inelegantly.
36  * Note that mega8/m32 still needs special handling, because ubrr is handled
37  * differently.
38  */
39 #if UART == 0
40 # define UART_SRA UCSR0A
41 # define UART_SRB UCSR0B
42 # define UART_SRC UCSR0C
43 # define UART_SRL UBRR0L
44 # define UART_UDR UDR0
45 #elif UART == 1
46 #if !defined(UDR1)
47 #error UART == 1, but no UART1 on device
48 #endif
49 # define UART_SRA UCSR1A
50 # define UART_SRB UCSR1B
51 # define UART_SRC UCSR1C
52 # define UART_SRL UBRR1L
53 # define UART_UDR UDR1
54 #elif UART == 2
55 #if !defined(UDR2)
56 #error UART == 2, but no UART2 on device
57 #endif
58 # define UART_SRA UCSR2A
59 # define UART_SRB UCSR2B
60 # define UART_SRC UCSR2C
61 # define UART_SRL UBRR2L
62 # define UART_UDR UDR2
63 #elif UART == 3
64 #if !defined(UDR3)
65 #error UART == 3, but no UART3 on device
66 #endif
67 # define UART_SRA UCSR3A
68 # define UART_SRB UCSR3B
69 # define UART_SRC UCSR3C
70 # define UART_SRL UBRR3L
71 # define UART_UDR UDR3
72 #endif
73 
74 #if defined(__AVR_ATmega8__) || defined (__AVR_ATmega32__) || defined (__AVR_ATmega16__)
75  //Name conversion R.Wiersma
76  #define UCSR0A UCSRA
77  #define UDR0 UDR
78  #define UDRE0 UDRE
79  #define RXC0 RXC
80  #define FE0 FE
81  #define TIFR1 TIFR
82  #define WDTCSR WDTCR
83 #endif
84 #if defined (__AVR_ATmega32__) || defined (__AVR_ATmega16__)
85  #define WDCE WDTOE
86 #endif
87 
88 /* Luminet support */
89 /*------------------------------------------------------------------------ */
90 #if defined(__AVR_ATtiny84__)
91 /*------------------------------------------------------------------------ */
92 /* Red LED is connected to pin PA4 */
93 #if !defined(LED)
94 #define LED A4
95 #endif
96 
97 /* Ports for soft UART - left port only for now. TX/RX on PA2/PA3 */
98 #ifdef SOFT_UART
99 #define UART_PORT PORTA
100 #define UART_PIN PINA
101 #define UART_DDR DDRA
102 #define UART_TX_BIT 2
103 #define UART_RX_BIT 3
104 #endif
105 #endif
106 
107 /*------------------------------------------------------------------------ */
108 /* Sanguino support (and other 40pin DIP cpus) */
109 #if defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega32__) || defined (__AVR_ATmega16__)
110 /*------------------------------------------------------------------------ */
111 /* Onboard LED is connected to pin PB0 on Sanguino */
112 #if !defined(LED)
113 #define LED B0
114 #endif
115 
116 /* Ports for soft UART */
117 #ifdef SOFT_UART
118 #define UART_PORT PORTD
119 #define UART_PIN PIND
120 #define UART_DDR DDRD
121 #define UART_TX_BIT 1
122 #define UART_RX_BIT 0
123 #endif
124 #endif
125 
126 /*------------------------------------------------------------------------ */
127 /* Mega support */
128 #if defined(__AVR_ATmega1280__)
129 /*------------------------------------------------------------------------ */
130 /* Onboard LED is connected to pin PB7 on Arduino Mega */
131 #if !defined(LED)
132 #define LED B7
133 #endif
134 
135 /* Ports for soft UART */
136 #ifdef SOFT_UART
137 #define UART_PORT PORTE
138 #define UART_PIN PINE
139 #define UART_DDR DDRE
140 #define UART_TX_BIT 1
141 #define UART_RX_BIT 0
142 #endif
143 #endif
144 
145 /*
146  * ------------------------------------------------------------------------
147  * A bunch of macros to enable the LED to be specifed as "B5" for bit 5
148  * of port B, and similar.
149  */
150 
151 #define A0 0x100
152 #define A1 0x101
153 #define A2 0x102
154 #define A3 0x103
155 #define A4 0x104
156 #define A5 0x105
157 #define A6 0x106
158 #define A7 0x107
159 
160 #define B0 0x200
161 #define B1 0x201
162 #define B2 0x202
163 #define B3 0x203
164 #define B4 0x204
165 #define B5 0x205
166 #define B6 0x206
167 #define B7 0x207
168 
169 #define C0 0x300
170 #define C1 0x301
171 #define C2 0x302
172 #define C3 0x303
173 #define C4 0x304
174 #define C5 0x305
175 #define C6 0x306
176 #define C7 0x307
177 
178 #define D0 0x400
179 #define D1 0x401
180 #define D2 0x402
181 #define D3 0x403
182 #define D4 0x404
183 #define D5 0x405
184 #define D6 0x406
185 #define D7 0x407
186 
187 #define E0 0x500
188 #define E1 0x501
189 #define E2 0x502
190 #define E3 0x503
191 #define E4 0x504
192 #define E5 0x505
193 #define E6 0x506
194 #define E7 0x507
195 
196 #define F0 0x600
197 #define F1 0x601
198 #define F2 0x602
199 #define F3 0x603
200 #define F4 0x604
201 #define F5 0x605
202 #define F6 0x606
203 #define F7 0x607
204 
205 #define G0 0x700
206 #define G1 0x701
207 #define G2 0x702
208 #define G3 0x703
209 #define G4 0x704
210 #define G5 0x705
211 #define G6 0x706
212 #define G7 0x707
213 
214 #define H0 0x800
215 #define H1 0x801
216 #define H2 0x802
217 #define H3 0x803
218 #define H4 0x804
219 #define H5 0x805
220 #define H6 0x806
221 #define H7 0x807
222 
223 #define J0 0xA00
224 #define J1 0xA01
225 #define J2 0xA02
226 #define J3 0xA03
227 #define J4 0xA04
228 #define J5 0xA05
229 #define J6 0xA06
230 #define J7 0xA07
231 
232 #define K0 0xB00
233 #define K1 0xB01
234 #define K2 0xB02
235 #define K3 0xB03
236 #define K4 0xB04
237 #define K5 0xB05
238 #define K6 0xB06
239 #define K7 0xB07
240 
241 #define L0 0xC00
242 #define L1 0xC01
243 #define L2 0xC02
244 #define L3 0xC03
245 #define L4 0xC04
246 #define L5 0xC05
247 #define L6 0xC06
248 #define L7 0xC07
249 
250 
251 
252 #if LED == B0
253 #undef LED
254 #define LED_DDR DDRB
255 #define LED_PORT PORTB
256 #define LED_PIN PINB
257 #define LED PINB0
258 #elif LED == B1
259 #undef LED
260 #define LED_DDR DDRB
261 #define LED_PORT PORTB
262 #define LED_PIN PINB
263 #define LED PINB1
264 #elif LED == B2
265 #undef LED
266 #define LED_DDR DDRB
267 #define LED_PORT PORTB
268 #define LED_PIN PINB
269 #define LED PINB2
270 #elif LED == B3
271 #undef LED
272 #define LED_DDR DDRB
273 #define LED_PORT PORTB
274 #define LED_PIN PINB
275 #define LED PINB3
276 #elif LED == B4
277 #undef LED
278 #define LED_DDR DDRB
279 #define LED_PORT PORTB
280 #define LED_PIN PINB
281 #define LED PINB4
282 #elif LED == B5
283 #undef LED
284 #define LED_DDR DDRB
285 #define LED_PORT PORTB
286 #define LED_PIN PINB
287 #define LED PINB5
288 #elif LED == B6
289 #undef LED
290 #define LED_DDR DDRB
291 #define LED_PORT PORTB
292 #define LED_PIN PINB
293 #define LED PINB6
294 #elif LED == B7
295 #undef LED
296 #define LED_DDR DDRB
297 #define LED_PORT PORTB
298 #define LED_PIN PINB
299 #define LED PINB7
300 
301 #elif LED == C0
302 #undef LED
303 #define LED_DDR DDRC
304 #define LED_PORT PORTC
305 #define LED_PIN PINC
306 #define LED PINC0
307 #elif LED == C1
308 #undef LED
309 #define LED_DDR DDRC
310 #define LED_PORT PORTC
311 #define LED_PIN PINC
312 #define LED PINC1
313 #elif LED == C2
314 #undef LED
315 #define LED_DDR DDRC
316 #define LED_PORT PORTC
317 #define LED_PIN PINC
318 #define LED PINC2
319 #elif LED == C3
320 #undef LED
321 #define LED_DDR DDRC
322 #define LED_PORT PORTC
323 #define LED_PIN PINC
324 #define LED PINC3
325 #elif LED == C4
326 #undef LED
327 #define LED_DDR DDRC
328 #define LED_PORT PORTC
329 #define LED_PIN PINC
330 #define LED PINC4
331 #elif LED == C5
332 #undef LED
333 #define LED_DDR DDRC
334 #define LED_PORT PORTC
335 #define LED_PIN PINC
336 #define LED PINC5
337 #elif LED == C6
338 #undef LED
339 #define LED_DDR DDRC
340 #define LED_PORT PORTC
341 #define LED_PIN PINC
342 #define LED PINC6
343 #elif LED == C7
344 #undef LED
345 #define LED_DDR DDRC
346 #define LED_PORT PORTC
347 #define LED_PIN PINC
348 #define LED PINC7
349 
350 #elif LED == D0
351 #undef LED
352 #define LED_DDR DDRD
353 #define LED_PORT PORTD
354 #define LED_PIN PIND
355 #define LED PIND0
356 #elif LED == D1
357 #undef LED
358 #define LED_DDR DDRD
359 #define LED_PORT PORTD
360 #define LED_PIN PIND
361 #define LED PIND1
362 #elif LED == D2
363 #undef LED
364 #define LED_DDR DDRD
365 #define LED_PORT PORTD
366 #define LED_PIN PIND
367 #define LED PIND2
368 #elif LED == D3
369 #undef LED
370 #define LED_DDR DDRD
371 #define LED_PORT PORTD
372 #define LED_PIN PIND
373 #define LED PIND3
374 #elif LED == D4
375 #undef LED
376 #define LED_DDR DDRD
377 #define LED_PORT PORTD
378 #define LED_PIN PIND
379 #define LED PIND4
380 #elif LED == D5
381 #undef LED
382 #define LED_DDR DDRD
383 #define LED_PORT PORTD
384 #define LED_PIN PIND
385 #define LED PIND5
386 #elif LED == D6
387 #undef LED
388 #define LED_DDR DDRD
389 #define LED_PORT PORTD
390 #define LED_PIN PIND
391 #define LED PIND6
392 #elif LED == D7
393 #undef LED
394 #define LED_DDR DDRD
395 #define LED_PORT PORTD
396 #define LED_PIN PIND
397 #define LED PIND7
398 
399 #elif LED == E0
400 #undef LED
401 #define LED_DDR DDRE
402 #define LED_PORT PORTE
403 #define LED_PIN PINE
404 #define LED PINE0
405 #elif LED == E1
406 #undef LED
407 #define LED_DDR DDRE
408 #define LED_PORT PORTE
409 #define LED_PIN PINE
410 #define LED PINE1
411 #elif LED == E2
412 #undef LED
413 #define LED_DDR DDRE
414 #define LED_PORT PORTE
415 #define LED_PIN PINE
416 #define LED PINE2
417 #elif LED == E3
418 #undef LED
419 #define LED_DDR DDRE
420 #define LED_PORT PORTE
421 #define LED_PIN PINE
422 #define LED PINE3
423 #elif LED == E4
424 #undef LED
425 #define LED_DDR DDRE
426 #define LED_PORT PORTE
427 #define LED_PIN PINE
428 #define LED PINE4
429 #elif LED == E5
430 #undef LED
431 #define LED_DDR DDRE
432 #define LED_PORT PORTE
433 #define LED_PIN PINE
434 #define LED PINE5
435 #elif LED == E6
436 #undef LED
437 #define LED_DDR DDRE
438 #define LED_PORT PORTE
439 #define LED_PIN PINE
440 #define LED PINE6
441 #elif LED == E7
442 #undef LED
443 #define LED_DDR DDRE
444 #define LED_PORT PORTE
445 #define LED_PIN PINE
446 #define LED PINE7
447 
448 #elif LED == F0
449 #undef LED
450 #define LED_DDR DDRF
451 #define LED_PORT PORTF
452 #define LED_PIN PINF
453 #define LED PINF0
454 #elif LED == F1
455 #undef LED
456 #define LED_DDR DDRF
457 #define LED_PORT PORTF
458 #define LED_PIN PINF
459 #define LED PINF1
460 #elif LED == F2
461 #undef LED
462 #define LED_DDR DDRF
463 #define LED_PORT PORTF
464 #define LED_PIN PINF
465 #define LED PINF2
466 #elif LED == F3
467 #undef LED
468 #define LED_DDR DDRF
469 #define LED_PORT PORTF
470 #define LED_PIN PINF
471 #define LED PINF3
472 #elif LED == F4
473 #undef LED
474 #define LED_DDR DDRF
475 #define LED_PORT PORTF
476 #define LED_PIN PINF
477 #define LED PINF4
478 #elif LED == F5
479 #undef LED
480 #define LED_DDR DDRF
481 #define LED_PORT PORTF
482 #define LED_PIN PINF
483 #define LED PINF5
484 #elif LED == F6
485 #undef LED
486 #define LED_DDR DDRF
487 #define LED_PORT PORTF
488 #define LED_PIN PINF
489 #define LED PINF6
490 #elif LED == F7
491 #undef LED
492 #define LED_DDR DDRF
493 #define LED_PORT PORTF
494 #define LED_PIN PINF
495 #define LED PINF7
496 
497 #elif LED == G0
498 #undef LED
499 #define LED_DDR DDRG
500 #define LED_PORT PORTG
501 #define LED_PIN PING
502 #define LED PING0
503 #elif LED == G1
504 #undef LED
505 #define LED_DDR DDRG
506 #define LED_PORT PORTG
507 #define LED_PIN PING
508 #define LED PING1
509 #elif LED == G2
510 #undef LED
511 #define LED_DDR DDRG
512 #define LED_PORT PORTG
513 #define LED_PIN PING
514 #define LED PING2
515 #elif LED == G3
516 #undef LED
517 #define LED_DDR DDRG
518 #define LED_PORT PORTG
519 #define LED_PIN PING
520 #define LED PING3
521 #elif LED == G4
522 #undef LED
523 #define LED_DDR DDRG
524 #define LED_PORT PORTG
525 #define LED_PIN PING
526 #define LED PING4
527 #elif LED == G5
528 #undef LED
529 #define LED_DDR DDRG
530 #define LED_PORT PORTG
531 #define LED_PIN PING
532 #define LED PING5
533 #elif LED == G6
534 #undef LED
535 #define LED_DDR DDRG
536 #define LED_PORT PORTG
537 #define LED_PIN PING
538 #define LED PING6
539 #elif LED == G7
540 #undef LED
541 #define LED_DDR DDRG
542 #define LED_PORT PORTG
543 #define LED_PIN PING
544 #define LED PING7
545 
546 #elif LED == H0
547 #undef LED
548 #define LED_DDR DDRH
549 #define LED_PORT PORTH
550 #define LED_PIN PINH
551 #define LED PINH0
552 #elif LED == H1
553 #undef LED
554 #define LED_DDR DDRH
555 #define LED_PORT PORTH
556 #define LED_PIN PINH
557 #define LED PINH1
558 #elif LED == H2
559 #undef LED
560 #define LED_DDR DDRH
561 #define LED_PORT PORTH
562 #define LED_PIN PINH
563 #define LED PINH2
564 #elif LED == H3
565 #undef LED
566 #define LED_DDR DDRH
567 #define LED_PORT PORTH
568 #define LED_PIN PINH
569 #define LED PINH3
570 #elif LED == H4
571 #undef LED
572 #define LED_DDR DDRH
573 #define LED_PORT PORTH
574 #define LED_PIN PINH
575 #define LED PINH4
576 #elif LED == H5
577 #undef LED
578 #define LED_DDR DDRH
579 #define LED_PORT PORTH
580 #define LED_PIN PINH
581 #define LED PINH5
582 #elif LED == H6
583 #undef LED
584 #define LED_DDR DDRH
585 #define LED_PORT PORTH
586 #define LED_PIN PINH
587 #define LED PINH6
588 #elif LED == H7
589 #undef LED
590 #define LED_DDR DDRH
591 #define LED_PORT PORTH
592 #define LED_PIN PINH
593 #define LED PINH7
594 
595 #elif LED == J0
596 #undef LED
597 #define LED_DDR DDRJ
598 #define LED_PORT PORTJ
599 #define LED_PIN PINJ
600 #define LED PINJ0
601 #elif LED == J1
602 #undef LED
603 #define LED_DDR DDRJ
604 #define LED_PORT PORTJ
605 #define LED_PIN PINJ
606 #define LED PINJ1
607 #elif LED == J2
608 #undef LED
609 #define LED_DDR DDRJ
610 #define LED_PORT PORTJ
611 #define LED_PIN PINJ
612 #define LED PINJ2
613 #elif LED == J3
614 #undef LED
615 #define LED_DDR DDRJ
616 #define LED_PORT PORTJ
617 #define LED_PIN PINJ
618 #define LED PINJ3
619 #elif LED == J4
620 #undef LED
621 #define LED_DDR DDRJ
622 #define LED_PORT PORTJ
623 #define LED_PIN PINJ
624 #define LED PINJ4
625 #elif LED == J5
626 #undef LED
627 #define LED_DDR DDRJ
628 #define LED_PORT PORTJ
629 #define LED_PIN PINJ
630 #define LED PINJ5
631 #elif LED == J6
632 #undef LED
633 #define LED_DDR DDRJ
634 #define LED_PORT PORTJ
635 #define LED_PIN PINJ
636 #define LED PINJ6
637 #elif LED == J7
638 #undef LED
639 #define LED_DDR DDRJ
640 #define LED_PORT PORTJ
641 #define LED_PIN PINJ
642 #define LED PINJ7
643 
644 #elif LED == K0
645 #undef LED
646 #define LED_DDR DDRK
647 #define LED_PORT PORTK
648 #define LED_PIN PINK
649 #define LED PINK0
650 #elif LED == K1
651 #undef LED
652 #define LED_DDR DDRK
653 #define LED_PORT PORTK
654 #define LED_PIN PINK
655 #define LED PINK1
656 #elif LED == K2
657 #undef LED
658 #define LED_DDR DDRK
659 #define LED_PORT PORTK
660 #define LED_PIN PINK
661 #define LED PINK2
662 #elif LED == K3
663 #undef LED
664 #define LED_DDR DDRK
665 #define LED_PORT PORTK
666 #define LED_PIN PINK
667 #define LED PINK3
668 #elif LED == K4
669 #undef LED
670 #define LED_DDR DDRK
671 #define LED_PORT PORTK
672 #define LED_PIN PINK
673 #define LED PINK4
674 #elif LED == K5
675 #undef LED
676 #define LED_DDR DDRK
677 #define LED_PORT PORTK
678 #define LED_PIN PINK
679 #define LED PINK5
680 #elif LED == K6
681 #undef LED
682 #define LED_DDR DDRK
683 #define LED_PORT PORTK
684 #define LED_PIN PINK
685 #define LED PINK6
686 #elif LED == K7
687 #undef LED
688 #define LED_DDR DDRK
689 #define LED_PORT PORTK
690 #define LED_PIN PINK
691 #define LED PINK7
692 
693 #elif LED == L0
694 #undef LED
695 #define LED_DDR DDRL
696 #define LED_PORT PORTL
697 #define LED_PIN PINL
698 #define LED PINL0
699 #elif LED == L1
700 #undef LED
701 #define LED_DDR DDRL
702 #define LED_PORT PORTL
703 #define LED_PIN PINL
704 #define LED PINL1
705 #elif LED == L2
706 #undef LED
707 #define LED_DDR DDRL
708 #define LED_PORT PORTL
709 #define LED_PIN PINL
710 #define LED PINL2
711 #elif LED == L3
712 #undef LED
713 #define LED_DDR DDRL
714 #define LED_PORT PORTL
715 #define LED_PIN PINL
716 #define LED PINL3
717 #elif LED == L4
718 #undef LED
719 #define LED_DDR DDRL
720 #define LED_PORT PORTL
721 #define LED_PIN PINL
722 #define LED PINL4
723 #elif LED == L5
724 #undef LED
725 #define LED_DDR DDRL
726 #define LED_PORT PORTL
727 #define LED_PIN PINL
728 #define LED PINL5
729 #elif LED == L6
730 #undef LED
731 #define LED_DDR DDRL
732 #define LED_PORT PORTL
733 #define LED_PIN PINL
734 #define LED PINL6
735 #elif LED == L7
736 #undef LED
737 #define LED_DDR DDRL
738 #define LED_PORT PORTL
739 #define LED_PIN PINL
740 #define LED PINL7
741 
742 #elif LED == A0
743 #undef LED
744 #define LED_DDR DDRA
745 #define LED_PORT PORTA
746 #define LED_PIN PINA
747 #define LED PINA0
748 #elif LED == A1
749 #undef LED
750 #define LED_DDR DDRA
751 #define LED_PORT PORTA
752 #define LED_PIN PINA
753 #define LED PINA1
754 #elif LED == A2
755 #undef LED
756 #define LED_DDR DDRA
757 #define LED_PORT PORTA
758 #define LED_PIN PINA
759 #define LED PINA2
760 #elif LED == A3
761 #undef LED
762 #define LED_DDR DDRA
763 #define LED_PORT PORTA
764 #define LED_PIN PINA
765 #define LED PINA3
766 #elif LED == A4
767 #undef LED
768 #define LED_DDR DDRA
769 #define LED_PORT PORTA
770 #define LED_PIN PINA
771 #define LED PINA4
772 #elif LED == A5
773 #undef LED
774 #define LED_DDR DDRA
775 #define LED_PORT PORTA
776 #define LED_PIN PINA
777 #define LED PINA5
778 #elif LED == A6
779 #undef LED
780 #define LED_DDR DDRA
781 #define LED_PORT PORTA
782 #define LED_PIN PINA
783 #define LED PINA6
784 #elif LED == A7
785 #undef LED
786 #define LED_DDR DDRA
787 #define LED_PORT PORTA
788 #define LED_PIN PINA
789 #define LED PINA7
790 
791 #else
792 #error -------------------------------------------
793 #error Unrecognized LED name. Should be like "B5"
794 #error -------------------------------------------
795 #endif