RTEMS CPU Kit with SuperCore  4.11.3
iom32.h
Go to the documentation of this file.
1 
9 /*
10  * Copyright (c) 2002, Steinar Haugen
11  * All rights reserved.
12  *
13  * Redistribution and use in source and binary forms, with or without
14  * modification, are permitted provided that the following conditions are met:
15  *
16  * * Redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer.
18  *
19  * * Redistributions in binary form must reproduce the above copyright
20  * notice, this list of conditions and the following disclaimer in
21  * the documentation and/or other materials provided with the
22  * distribution.
23  *
24  * * Neither the name of the copyright holders nor the names of
25  * contributors may be used to endorse or promote products derived
26  * from this software without specific prior written permission.
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
29  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
32  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
36  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38  * POSSIBILITY OF SUCH DAMAGE.
39  */
40 
41 #ifndef _AVR_IOM32_H_
42 #define _AVR_IOM32_H_ 1
43 
51 #ifndef _AVR_IO_H_
52 # error "Include <avr/io.h> instead of this file."
53 #endif
54 
55 #ifndef _AVR_IOXXX_H_
56 # define _AVR_IOXXX_H_ "iom32.h"
57 #else
58 # error "Attempt to include more than one <avr/ioXXX.h> file."
59 #endif
60 
61 /* I/O registers */
62 
63 /* TWI stands for "Two Wire Interface" or "TWI Was I2C(tm)" */
64 #define TWBR _SFR_IO8(0x00)
65 #define TWSR _SFR_IO8(0x01)
66 #define TWAR _SFR_IO8(0x02)
67 #define TWDR _SFR_IO8(0x03)
68 
69 /* ADC */
70 #ifndef __ASSEMBLER__
71 #define ADC _SFR_IO16(0x04)
72 #endif
73 #define ADCW _SFR_IO16(0x04)
74 #define ADCL _SFR_IO8(0x04)
75 #define ADCH _SFR_IO8(0x05)
76 #define ADCSRA _SFR_IO8(0x06)
77 #define ADMUX _SFR_IO8(0x07)
78 
79 /* analog comparator */
80 #define ACSR _SFR_IO8(0x08)
81 
82 /* USART */
83 #define UBRRL _SFR_IO8(0x09)
84 #define UCSRB _SFR_IO8(0x0A)
85 #define UCSRA _SFR_IO8(0x0B)
86 #define UDR _SFR_IO8(0x0C)
87 
88 /* SPI */
89 #define SPCR _SFR_IO8(0x0D)
90 #define SPSR _SFR_IO8(0x0E)
91 #define SPDR _SFR_IO8(0x0F)
92 
93 /* Port D */
94 #define PIND _SFR_IO8(0x10)
95 #define DDRD _SFR_IO8(0x11)
96 #define PORTD _SFR_IO8(0x12)
97 
98 /* Port C */
99 #define PINC _SFR_IO8(0x13)
100 #define DDRC _SFR_IO8(0x14)
101 #define PORTC _SFR_IO8(0x15)
102 
103 /* Port B */
104 #define PINB _SFR_IO8(0x16)
105 #define DDRB _SFR_IO8(0x17)
106 #define PORTB _SFR_IO8(0x18)
107 
108 /* Port A */
109 #define PINA _SFR_IO8(0x19)
110 #define DDRA _SFR_IO8(0x1A)
111 #define PORTA _SFR_IO8(0x1B)
112 
113 /* EEPROM Control Register */
114 #define EECR _SFR_IO8(0x1C)
115 
116 /* EEPROM Data Register */
117 #define EEDR _SFR_IO8(0x1D)
118 
119 /* EEPROM Address Register */
120 #define EEAR _SFR_IO16(0x1E)
121 #define EEARL _SFR_IO8(0x1E)
122 #define EEARH _SFR_IO8(0x1F)
123 
124 #define UBRRH _SFR_IO8(0x20)
125 #define UCSRC UBRRH
126 
127 #define WDTCR _SFR_IO8(0x21)
128 
129 #define ASSR _SFR_IO8(0x22)
130 
131 /* Timer 2 */
132 #define OCR2 _SFR_IO8(0x23)
133 #define TCNT2 _SFR_IO8(0x24)
134 #define TCCR2 _SFR_IO8(0x25)
135 
136 /* Timer 1 */
137 #define ICR1 _SFR_IO16(0x26)
138 #define ICR1L _SFR_IO8(0x26)
139 #define ICR1H _SFR_IO8(0x27)
140 #define OCR1B _SFR_IO16(0x28)
141 #define OCR1BL _SFR_IO8(0x28)
142 #define OCR1BH _SFR_IO8(0x29)
143 #define OCR1A _SFR_IO16(0x2A)
144 #define OCR1AL _SFR_IO8(0x2A)
145 #define OCR1AH _SFR_IO8(0x2B)
146 #define TCNT1 _SFR_IO16(0x2C)
147 #define TCNT1L _SFR_IO8(0x2C)
148 #define TCNT1H _SFR_IO8(0x2D)
149 #define TCCR1B _SFR_IO8(0x2E)
150 #define TCCR1A _SFR_IO8(0x2F)
151 
152 #define SFIOR _SFR_IO8(0x30)
153 
154 #define OSCCAL _SFR_IO8(0x31)
155 #define OCDR OSCCAL
156 
157 /* Timer 0 */
158 #define TCNT0 _SFR_IO8(0x32)
159 #define TCCR0 _SFR_IO8(0x33)
160 
161 #define MCUSR _SFR_IO8(0x34)
162 #define MCUCSR MCUSR
163 #define MCUCR _SFR_IO8(0x35)
164 
165 #define TWCR _SFR_IO8(0x36)
166 
167 #define SPMCR _SFR_IO8(0x37)
168 
169 #define TIFR _SFR_IO8(0x38)
170 #define TIMSK _SFR_IO8(0x39)
171 
172 #define GIFR _SFR_IO8(0x3A)
173 #define GIMSK _SFR_IO8(0x3B)
174 #define GICR GIMSK
175 
176 #define OCR0 _SFR_IO8(0x3C)
177 
178 /* 0x3D..0x3E SP */
179 
180 /* 0x3F SREG */
181 
182 /* Interrupt vectors */
183 
184 /* External Interrupt Request 0 */
185 #define INT0_vect _VECTOR(1)
186 #define SIG_INTERRUPT0 _VECTOR(1)
187 
188 /* External Interrupt Request 1 */
189 #define INT1_vect _VECTOR(2)
190 #define SIG_INTERRUPT1 _VECTOR(2)
191 
192 /* External Interrupt Request 2 */
193 #define INT2_vect _VECTOR(3)
194 #define SIG_INTERRUPT2 _VECTOR(3)
195 
196 /* Timer/Counter2 Compare Match */
197 #define TIMER2_COMP_vect _VECTOR(4)
198 #define SIG_OUTPUT_COMPARE2 _VECTOR(4)
199 
200 /* Timer/Counter2 Overflow */
201 #define TIMER2_OVF_vect _VECTOR(5)
202 #define SIG_OVERFLOW2 _VECTOR(5)
203 
204 /* Timer/Counter1 Capture Event */
205 #define TIMER1_CAPT_vect _VECTOR(6)
206 #define SIG_INPUT_CAPTURE1 _VECTOR(6)
207 
208 /* Timer/Counter1 Compare Match A */
209 #define TIMER1_COMPA_vect _VECTOR(7)
210 #define SIG_OUTPUT_COMPARE1A _VECTOR(7)
211 
212 /* Timer/Counter1 Compare Match B */
213 #define TIMER1_COMPB_vect _VECTOR(8)
214 #define SIG_OUTPUT_COMPARE1B _VECTOR(8)
215 
216 /* Timer/Counter1 Overflow */
217 #define TIMER1_OVF_vect _VECTOR(9)
218 #define SIG_OVERFLOW1 _VECTOR(9)
219 
220 /* Timer/Counter0 Compare Match */
221 #define TIMER0_COMP_vect _VECTOR(10)
222 #define SIG_OUTPUT_COMPARE0 _VECTOR(10)
223 
224 /* Timer/Counter0 Overflow */
225 #define TIMER0_OVF_vect _VECTOR(11)
226 #define SIG_OVERFLOW0 _VECTOR(11)
227 
228 /* Serial Transfer Complete */
229 #define SPI_STC_vect _VECTOR(12)
230 #define SIG_SPI _VECTOR(12)
231 
232 /* USART, Rx Complete */
233 #define USART_RXC_vect _VECTOR(13)
234 #define SIG_USART_RECV _VECTOR(13)
235 #define SIG_UART_RECV _VECTOR(13)
236 
237 /* USART Data Register Empty */
238 #define USART_UDRE_vect _VECTOR(14)
239 #define SIG_USART_DATA _VECTOR(14)
240 #define SIG_UART_DATA _VECTOR(14)
241 
242 /* USART, Tx Complete */
243 #define USART_TXC_vect _VECTOR(15)
244 #define SIG_USART_TRANS _VECTOR(15)
245 #define SIG_UART_TRANS _VECTOR(15)
246 
247 /* ADC Conversion Complete */
248 #define ADC_vect _VECTOR(16)
249 #define SIG_ADC _VECTOR(16)
250 
251 /* EEPROM Ready */
252 #define EE_RDY_vect _VECTOR(17)
253 #define SIG_EEPROM_READY _VECTOR(17)
254 
255 /* Analog Comparator */
256 #define ANA_COMP_vect _VECTOR(18)
257 #define SIG_COMPARATOR _VECTOR(18)
258 
259 /* 2-wire Serial Interface */
260 #define TWI_vect _VECTOR(19)
261 #define SIG_2WIRE_SERIAL _VECTOR(19)
262 
263 /* Store Program Memory Ready */
264 #define SPM_RDY_vect _VECTOR(20)
265 #define SIG_SPM_READY _VECTOR(20)
266 
267 #define _VECTORS_SIZE 84
268 
269 /* Bit numbers */
270 
271 /* GICR */
272 #define INT1 7
273 #define INT0 6
274 #define INT2 5
275 #define IVSEL 1
276 #define IVCE 0
277 
278 /* GIFR */
279 #define INTF1 7
280 #define INTF0 6
281 #define INTF2 5
282 
283 /* TIMSK */
284 #define OCIE2 7
285 #define TOIE2 6
286 #define TICIE1 5
287 #define OCIE1A 4
288 #define OCIE1B 3
289 #define TOIE1 2
290 #define OCIE0 1
291 #define TOIE0 0
292 
293 /* TIFR */
294 #define OCF2 7
295 #define TOV2 6
296 #define ICF1 5
297 #define OCF1A 4
298 #define OCF1B 3
299 #define TOV1 2
300 #define OCF0 1
301 #define TOV0 0
302 
303 /* SPMCR */
304 #define SPMIE 7
305 #define RWWSB 6
306 /* bit 5 reserved */
307 #define RWWSRE 4
308 #define BLBSET 3
309 #define PGWRT 2
310 #define PGERS 1
311 #define SPMEN 0
312 
313 /* TWCR */
314 #define TWINT 7
315 #define TWEA 6
316 #define TWSTA 5
317 #define TWSTO 4
318 #define TWWC 3
319 #define TWEN 2
320 /* bit 1 reserved */
321 #define TWIE 0
322 
323 /* TWAR */
324 #define TWA6 7
325 #define TWA5 6
326 #define TWA4 5
327 #define TWA3 4
328 #define TWA2 3
329 #define TWA1 2
330 #define TWA0 1
331 #define TWGCE 0
332 
333 /* TWSR */
334 #define TWS7 7
335 #define TWS6 6
336 #define TWS5 5
337 #define TWS4 4
338 #define TWS3 3
339 /* bit 2 reserved */
340 #define TWPS1 1
341 #define TWPS0 0
342 
343 /* MCUCR */
344 #define SE 7
345 #define SM2 6
346 #define SM1 5
347 #define SM0 4
348 #define ISC11 3
349 #define ISC10 2
350 #define ISC01 1
351 #define ISC00 0
352 
353 /* MCUCSR */
354 #define JTD 7
355 #define ISC2 6
356 /* bit 5 reserved */
357 #define JTRF 4
358 #define WDRF 3
359 #define BORF 2
360 #define EXTRF 1
361 #define PORF 0
362 
363 /* SFIOR */
364 #define ADTS2 7
365 #define ADTS1 6
366 #define ADTS0 5
367 /* bit 4 reserved */
368 #define ACME 3
369 #define PUD 2
370 #define PSR2 1
371 #define PSR10 0
372 
373 /* TCCR0 */
374 #define FOC0 7
375 #define WGM00 6
376 #define COM01 5
377 #define COM00 4
378 #define WGM01 3
379 #define CS02 2
380 #define CS01 1
381 #define CS00 0
382 
383 /* TCCR2 */
384 #define FOC2 7
385 #define WGM20 6
386 #define COM21 5
387 #define COM20 4
388 #define WGM21 3
389 #define CS22 2
390 #define CS21 1
391 #define CS20 0
392 
393 /* ASSR */
394 /* bits 7-4 reserved */
395 #define AS2 3
396 #define TCN2UB 2
397 #define OCR2UB 1
398 #define TCR2UB 0
399 
400 /* TCCR1A */
401 #define COM1A1 7
402 #define COM1A0 6
403 #define COM1B1 5
404 #define COM1B0 4
405 #define FOC1A 3
406 #define FOC1B 2
407 #define WGM11 1
408 #define WGM10 0
409 
410 /* TCCR1B */
411 #define ICNC1 7
412 #define ICES1 6
413 /* bit 5 reserved */
414 #define WGM13 4
415 #define WGM12 3
416 #define CS12 2
417 #define CS11 1
418 #define CS10 0
419 
420 /* WDTCR */
421 /* bits 7-5 reserved */
422 #define WDTOE 4
423 #define WDE 3
424 #define WDP2 2
425 #define WDP1 1
426 #define WDP0 0
427 
428 /* PA7-PA0 = ADC7-ADC0 */
429 /* PORTA */
430 #define PA7 7
431 #define PA6 6
432 #define PA5 5
433 #define PA4 4
434 #define PA3 3
435 #define PA2 2
436 #define PA1 1
437 #define PA0 0
438 
439 /* DDRA */
440 #define DDA7 7
441 #define DDA6 6
442 #define DDA5 5
443 #define DDA4 4
444 #define DDA3 3
445 #define DDA2 2
446 #define DDA1 1
447 #define DDA0 0
448 
449 /* PINA */
450 #define PINA7 7
451 #define PINA6 6
452 #define PINA5 5
453 #define PINA4 4
454 #define PINA3 3
455 #define PINA2 2
456 #define PINA1 1
457 #define PINA0 0
458 
459 /*
460  PB7 = SCK
461  PB6 = MISO
462  PB5 = MOSI
463  PB4 = SS#
464  PB3 = OC0/AIN1
465  PB2 = INT2/AIN0
466  PB1 = T1
467  PB0 = XCK/T0
468  */
469 
470 /* PORTB */
471 #define PB7 7
472 #define PB6 6
473 #define PB5 5
474 #define PB4 4
475 #define PB3 3
476 #define PB2 2
477 #define PB1 1
478 #define PB0 0
479 
480 /* DDRB */
481 #define DDB7 7
482 #define DDB6 6
483 #define DDB5 5
484 #define DDB4 4
485 #define DDB3 3
486 #define DDB2 2
487 #define DDB1 1
488 #define DDB0 0
489 
490 /* PINB */
491 #define PINB7 7
492 #define PINB6 6
493 #define PINB5 5
494 #define PINB4 4
495 #define PINB3 3
496 #define PINB2 2
497 #define PINB1 1
498 #define PINB0 0
499 
500 /*
501  PC7 = TOSC2
502  PC6 = TOSC1
503  PC1 = SDA
504  PC0 = SCL
505  */
506 /* PORTC */
507 #define PC7 7
508 #define PC6 6
509 #define PC5 5
510 #define PC4 4
511 #define PC3 3
512 #define PC2 2
513 #define PC1 1
514 #define PC0 0
515 
516 /* DDRC */
517 #define DDC7 7
518 #define DDC6 6
519 #define DDC5 5
520 #define DDC4 4
521 #define DDC3 3
522 #define DDC2 2
523 #define DDC1 1
524 #define DDC0 0
525 
526 /* PINC */
527 #define PINC7 7
528 #define PINC6 6
529 #define PINC5 5
530 #define PINC4 4
531 #define PINC3 3
532 #define PINC2 2
533 #define PINC1 1
534 #define PINC0 0
535 
536 /*
537  PD7 = OC2
538  PD6 = ICP
539  PD5 = OC1A
540  PD4 = OC1B
541  PD3 = INT1
542  PD2 = INT0
543  PD1 = TXD
544  PD0 = RXD
545  */
546 
547 /* PORTD */
548 #define PD7 7
549 #define PD6 6
550 #define PD5 5
551 #define PD4 4
552 #define PD3 3
553 #define PD2 2
554 #define PD1 1
555 #define PD0 0
556 
557 /* DDRD */
558 #define DDD7 7
559 #define DDD6 6
560 #define DDD5 5
561 #define DDD4 4
562 #define DDD3 3
563 #define DDD2 2
564 #define DDD1 1
565 #define DDD0 0
566 
567 /* PIND */
568 #define PIND7 7
569 #define PIND6 6
570 #define PIND5 5
571 #define PIND4 4
572 #define PIND3 3
573 #define PIND2 2
574 #define PIND1 1
575 #define PIND0 0
576 
577 /* SPSR */
578 #define SPIF 7
579 #define WCOL 6
580 /* bits 5-1 reserved */
581 #define SPI2X 0
582 
583 /* SPCR */
584 #define SPIE 7
585 #define SPE 6
586 #define DORD 5
587 #define MSTR 4
588 #define CPOL 3
589 #define CPHA 2
590 #define SPR1 1
591 #define SPR0 0
592 
593 /* UCSRA */
594 #define RXC 7
595 #define TXC 6
596 #define UDRE 5
597 #define FE 4
598 #define DOR 3
599 #define PE 2
600 #define U2X 1
601 #define MPCM 0
602 
603 /* UCSRB */
604 #define RXCIE 7
605 #define TXCIE 6
606 #define UDRIE 5
607 #define RXEN 4
608 #define TXEN 3
609 #define UCSZ2 2
610 #define RXB8 1
611 #define TXB8 0
612 
613 /* UCSRC */
614 #define URSEL 7
615 #define UMSEL 6
616 #define UPM1 5
617 #define UPM0 4
618 #define USBS 3
619 #define UCSZ1 2
620 #define UCSZ0 1
621 #define UCPOL 0
622 
623 /* ACSR */
624 #define ACD 7
625 #define ACBG 6
626 #define ACO 5
627 #define ACI 4
628 #define ACIE 3
629 #define ACIC 2
630 #define ACIS1 1
631 #define ACIS0 0
632 
633 /* ADCSRA */
634 #define ADEN 7
635 #define ADSC 6
636 #define ADATE 5
637 #define ADIF 4
638 #define ADIE 3
639 #define ADPS2 2
640 #define ADPS1 1
641 #define ADPS0 0
642 
643 /* ADMUX */
644 #define REFS1 7
645 #define REFS0 6
646 #define ADLAR 5
647 #define MUX4 4
648 #define MUX3 3
649 #define MUX2 2
650 #define MUX1 1
651 #define MUX0 0
652 
653 /* EEPROM Control Register */
654 #define EERIE 3
655 #define EEMWE 2
656 #define EEWE 1
657 #define EERE 0
658 
659 /* Constants */
660 #define SPM_PAGESIZE 128
661 #define RAMEND 0x85F
662 #define XRAMEND RAMEND
663 #define E2END 0x3FF
664 #define E2PAGESIZE 4
665 #define FLASHEND 0x7FFF
666 
667 
668 /* Fuses */
669 
670 #define FUSE_MEMORY_SIZE 2
671 
672 /* Low Fuse Byte */
673 #define FUSE_CKSEL0 (unsigned char)~_BV(0)
674 #define FUSE_CKSEL1 (unsigned char)~_BV(1)
675 #define FUSE_CKSEL2 (unsigned char)~_BV(2)
676 #define FUSE_CKSEL3 (unsigned char)~_BV(3)
677 #define FUSE_SUT0 (unsigned char)~_BV(4)
678 #define FUSE_SUT1 (unsigned char)~_BV(5)
679 #define FUSE_BODEN (unsigned char)~_BV(6)
680 #define FUSE_BODLEVEL (unsigned char)~_BV(7)
681 #define LFUSE_DEFAULT (FUSE_CKSEL1 & FUSE_CKSEL2 & FUSE_CKSEL3 & FUSE_SUT0)
682 
683 /* High Fuse Byte */
684 #define FUSE_BOOTRST (unsigned char)~_BV(0)
685 #define FUSE_BOOTSZ0 (unsigned char)~_BV(1)
686 #define FUSE_BOOTSZ1 (unsigned char)~_BV(2)
687 #define FUSE_EESAVE (unsigned char)~_BV(3)
688 #define FUSE_CKOPT (unsigned char)~_BV(4)
689 #define FUSE_SPIEN (unsigned char)~_BV(5)
690 #define FUSE_JTAGEN (unsigned char)~_BV(6)
691 #define FUSE_OCDEN (unsigned char)~_BV(7)
692 #define HFUSE_DEFAULT (FUSE_BOOTSZ0 & FUSE_BOOTSZ1 & FUSE_SPIEN & FUSE_JTAGEN)
693 
694 
695 /* Lock Bits */
696 #define __LOCK_BITS_EXIST
697 #define __BOOT_LOCK_BITS_0_EXIST
698 #define __BOOT_LOCK_BITS_1_EXIST
699 
700 
701 /* Signature */
702 #define SIGNATURE_0 0x1E
703 #define SIGNATURE_1 0x95
704 #define SIGNATURE_2 0x02
705 
707 #endif /* _AVR_IOM32_H_ */