RTEMS CPU Kit with SuperCore  4.11.3
iom163.h
Go to the documentation of this file.
1 
9 /*
10  * Copyright (c) 2007 Anatoly Sokolov
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_IOM163_H_
42 #define _AVR_IOM163_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_ "iom163.h"
57 #else
58 # error "Attempt to include more than one <avr/ioXXX.h> file."
59 #endif
60 
61 /* I/O registers */
62 
63 #define TWBR _SFR_IO8(0x00)
64 #define TWSR _SFR_IO8(0x01)
65 #define TWAR _SFR_IO8(0x02)
66 #define TWDR _SFR_IO8(0x03)
67 
68 /* ADC */
69 #ifndef __ASSEMBLER__
70 #define ADC _SFR_IO16(0x04)
71 #endif
72 #define ADCW _SFR_IO16(0x04)
73 #define ADCL _SFR_IO8(0x04)
74 #define ADCH _SFR_IO8(0x05)
75 #define ADCSR _SFR_IO8(0x06)
76 #define ADMUX _SFR_IO8(0x07)
77 
78 /* analog comparator */
79 #define ACSR _SFR_IO8(0x08)
80 
81 /* UART */
82 #define UBRR _SFR_IO8(0x09)
83 #define UCSRB _SFR_IO8(0x0A)
84 #define UCSRA _SFR_IO8(0x0B)
85 #define UDR _SFR_IO8(0x0C)
86 
87 /* SPI */
88 #define SPCR _SFR_IO8(0x0D)
89 #define SPSR _SFR_IO8(0x0E)
90 #define SPDR _SFR_IO8(0x0F)
91 
92 /* Port D */
93 #define PIND _SFR_IO8(0x10)
94 #define DDRD _SFR_IO8(0x11)
95 #define PORTD _SFR_IO8(0x12)
96 
97 /* Port C */
98 #define PINC _SFR_IO8(0x13)
99 #define DDRC _SFR_IO8(0x14)
100 #define PORTC _SFR_IO8(0x15)
101 
102 /* Port B */
103 #define PINB _SFR_IO8(0x16)
104 #define DDRB _SFR_IO8(0x17)
105 #define PORTB _SFR_IO8(0x18)
106 
107 /* Port A */
108 #define PINA _SFR_IO8(0x19)
109 #define DDRA _SFR_IO8(0x1A)
110 #define PORTA _SFR_IO8(0x1B)
111 
112 /* EEPROM Control Register */
113 #define EECR _SFR_IO8(0x1C)
114 
115 /* EEPROM Data Register */
116 #define EEDR _SFR_IO8(0x1D)
117 
118 /* EEPROM Address Register */
119 #define EEAR _SFR_IO16(0x1E)
120 #define EEARL _SFR_IO8(0x1E)
121 #define EEARH _SFR_IO8(0x1F)
122 
123 #define UBRRHI _SFR_IO8(0x20)
124 
125 #define WDTCR _SFR_IO8(0x21)
126 
127 #define ASSR _SFR_IO8(0x22)
128 
129 /* Timer 2 */
130 #define OCR2 _SFR_IO8(0x23)
131 #define TCNT2 _SFR_IO8(0x24)
132 #define TCCR2 _SFR_IO8(0x25)
133 
134 /* Timer 1 */
135 #define ICR1 _SFR_IO16(0x26)
136 #define ICR1L _SFR_IO8(0x26)
137 #define ICR1H _SFR_IO8(0x27)
138 #define OCR1B _SFR_IO16(0x28)
139 #define OCR1BL _SFR_IO8(0x28)
140 #define OCR1BH _SFR_IO8(0x29)
141 #define OCR1A _SFR_IO16(0x2A)
142 #define OCR1AL _SFR_IO8(0x2A)
143 #define OCR1AH _SFR_IO8(0x2B)
144 #define TCNT1 _SFR_IO16(0x2C)
145 #define TCNT1L _SFR_IO8(0x2C)
146 #define TCNT1H _SFR_IO8(0x2D)
147 #define TCCR1B _SFR_IO8(0x2E)
148 #define TCCR1A _SFR_IO8(0x2F)
149 
150 #define SFIOR _SFR_IO8(0x30)
151 
152 #define OSCCAL _SFR_IO8(0x31)
153 
154 /* Timer 0 */
155 #define TCNT0 _SFR_IO8(0x32)
156 #define TCCR0 _SFR_IO8(0x33)
157 
158 #define MCUSR _SFR_IO8(0x34)
159 #define MCUCR _SFR_IO8(0x35)
160 
161 #define TWCR _SFR_IO8(0x36)
162 
163 #define SPMCR _SFR_IO8(0x37)
164 
165 #define TIFR _SFR_IO8(0x38)
166 #define TIMSK _SFR_IO8(0x39)
167 
168 #define GIFR _SFR_IO8(0x3A)
169 #define GIMSK _SFR_IO8(0x3B)
170 
171 /* 0x3C reserved */
172 
173 /* 0x3D..0x3E SP */
174 
175 /* 0x3F SREG */
176 
177 /* Interrupt vectors */
178 
179 /* External Interrupt 0 */
180 #define INT0_vect _VECTOR(1)
181 #define SIG_INTERRUPT0 _VECTOR(1)
182 
183 /* External Interrupt 1 */
184 #define INT1_vect _VECTOR(2)
185 #define SIG_INTERRUPT1 _VECTOR(2)
186 
187 /* Timer/Counter2 Compare Match */
188 #define TIMER2_COMP_vect _VECTOR(3)
189 #define SIG_OUTPUT_COMPARE2 _VECTOR(3)
190 
191 /* Timer/Counter2 Overflow */
192 #define TIMER2_OVF_vect _VECTOR(4)
193 #define SIG_OVERFLOW2 _VECTOR(4)
194 
195 /* Timer/Counter1 Capture Event */
196 #define TIMER1_CAPT_vect _VECTOR(5)
197 #define SIG_INPUT_CAPTURE1 _VECTOR(5)
198 
199 /* Timer/Counter1 Compare Match A */
200 #define TIMER1_COMPA_vect _VECTOR(6)
201 #define SIG_OUTPUT_COMPARE1A _VECTOR(6)
202 
203 /* Timer/Counter1 Compare Match B */
204 #define TIMER1_COMPB_vect _VECTOR(7)
205 #define SIG_OUTPUT_COMPARE1B _VECTOR(7)
206 
207 /* Timer/Counter1 Overflow */
208 #define TIMER1_OVF_vect _VECTOR(8)
209 #define SIG_OVERFLOW1 _VECTOR(8)
210 
211 /* Timer/Counter0 Overflow */
212 #define TIMER0_OVF_vect _VECTOR(9)
213 #define SIG_OVERFLOW0 _VECTOR(9)
214 
215 /* SPI Serial Transfer Complete */
216 #define SPI_STC_vect _VECTOR(10)
217 #define SIG_SPI _VECTOR(10)
218 
219 /* UART, RX Complete */
220 #define UART_RX_vect _VECTOR(11)
221 #define SIG_UART_RECV _VECTOR(11)
222 
223 /* UART Data Register Empty */
224 #define UART_UDRE_vect _VECTOR(12)
225 #define SIG_UART_DATA _VECTOR(12)
226 
227 /* UART, TX Complete */
228 #define UART_TX_vect _VECTOR(13)
229 #define SIG_UART_TRANS _VECTOR(13)
230 
231 /* ADC Conversion Complete */
232 #define ADC_vect _VECTOR(14)
233 #define SIG_ADC _VECTOR(14)
234 
235 /* EEPROM Ready */
236 #define EE_RDY_vect _VECTOR(15)
237 #define SIG_EEPROM_READY _VECTOR(15)
238 
239 /* Analog Comparator */
240 #define ANA_COMP_vect _VECTOR(16)
241 #define SIG_COMPARATOR _VECTOR(16)
242 
243 /* 2-Wire Serial Interface */
244 #define TWI_vect _VECTOR(17)
245 #define SIG_2WIRE_SERIAL _VECTOR(17)
246 
247 #define _VECTORS_SIZE 72
248 
249 /* Bit numbers */
250 
251 /* GIMSK */
252 #define INT1 7
253 #define INT0 6
254 /* bit 5 reserved, undefined */
255 /* bits 4-0 reserved */
256 
257 /* GIFR */
258 #define INTF1 7
259 #define INTF0 6
260 /* bits 5-0 reserved */
261 
262 /* TIMSK */
263 #define OCIE2 7
264 #define TOIE2 6
265 #define TICIE1 5
266 #define OCIE1A 4
267 #define OCIE1B 3
268 #define TOIE1 2
269 /* bit 1 reserved */
270 #define TOIE0 0
271 
272 /* TIFR */
273 #define OCF2 7
274 #define TOV2 6
275 #define ICF1 5
276 #define OCF1A 4
277 #define OCF1B 3
278 #define TOV1 2
279 /* bit 1 reserved, undefined */
280 #define TOV0 0
281 
282 /* SPMCR */
283 /* bit 7 reserved */
284 #define ASB 6
285 /* bit 5 reserved */
286 #define ASRE 4
287 #define BLBSET 3
288 #define PGWRT 2
289 #define PGERS 1
290 #define SPMEN 0
291 
292 /* TWCR */
293 #define TWINT 7
294 #define TWEA 6
295 #define TWSTA 5
296 #define TWSTO 4
297 #define TWWC 3
298 #define TWEN 2
299 /* bit 1 reserved */
300 #define TWIE 0
301 
302 /* TWAR */
303 #define TWGCE 0
304 
305 /* TWSR */
306 #define TWS7 7
307 #define TWS6 6
308 #define TWS5 5
309 #define TWS4 4
310 #define TWS3 3
311 /* bits 2-0 reserved */
312 
313 /* MCUCR */
314 /* bit 7 reserved */
315 #define SE 6
316 #define SM1 5
317 #define SM0 4
318 #define ISC11 3
319 #define ISC10 2
320 #define ISC01 1
321 #define ISC00 0
322 
323 /* MCUSR */
324 /* bits 7-4 reserved */
325 #define WDRF 3
326 #define BORF 2
327 #define EXTRF 1
328 #define PORF 0
329 
330 /* SFIOR */
331 /* bits 7-4 reserved */
332 #define ACME 3
333 #define PUD 2
334 #define PSR2 1
335 #define PSR10 0
336 
337 /* TCCR0 */
338 /* bits 7-3 reserved */
339 #define CS02 2
340 #define CS01 1
341 #define CS00 0
342 
343 /* TCCR2 */
344 #define FOC2 7
345 #define PWM2 6
346 #define COM21 5
347 #define COM20 4
348 #define CTC2 3
349 #define CS22 2
350 #define CS21 1
351 #define CS20 0
352 
353 /* ASSR */
354 /* bits 7-4 reserved */
355 #define AS2 3
356 #define TCN2UB 2
357 #define OCR2UB 1
358 #define TCR2UB 0
359 
360 /* TCCR1A */
361 #define COM1A1 7
362 #define COM1A0 6
363 #define COM1B1 5
364 #define COM1B0 4
365 #define FOC1A 3
366 #define FOC1B 2
367 #define PWM11 1
368 #define PWM10 0
369 
370 /* TCCR1B */
371 #define ICNC1 7
372 #define ICES1 6
373 /* bits 5-4 reserved */
374 #define CTC1 3
375 #define CS12 2
376 #define CS11 1
377 #define CS10 0
378 
379 /* WDTCR */
380 /* bits 7-5 reserved */
381 #define WDTOE 4
382 #define WDE 3
383 #define WDP2 2
384 #define WDP1 1
385 #define WDP0 0
386 
387 /* PA7-PA0 = ADC7-ADC0 */
388 /* PORTA */
389 #define PA7 7
390 #define PA6 6
391 #define PA5 5
392 #define PA4 4
393 #define PA3 3
394 #define PA2 2
395 #define PA1 1
396 #define PA0 0
397 
398 /* DDRA */
399 #define DDA7 7
400 #define DDA6 6
401 #define DDA5 5
402 #define DDA4 4
403 #define DDA3 3
404 #define DDA2 2
405 #define DDA1 1
406 #define DDA0 0
407 
408 /* PINA */
409 #define PINA7 7
410 #define PINA6 6
411 #define PINA5 5
412 #define PINA4 4
413 #define PINA3 3
414 #define PINA2 2
415 #define PINA1 1
416 #define PINA0 0
417 
418 /*
419  PB7 = SCK
420  PB6 = MISO
421  PB5 = MOSI
422  PB4 = SS#
423  PB3 = AIN1
424  PB2 = AIN0
425  PB1 = T1
426  PB0 = T0
427  */
428 
429 /* PORTB */
430 #define PB7 7
431 #define PB6 6
432 #define PB5 5
433 #define PB4 4
434 #define PB3 3
435 #define PB2 2
436 #define PB1 1
437 #define PB0 0
438 
439 /* DDRB */
440 #define DDB7 7
441 #define DDB6 6
442 #define DDB5 5
443 #define DDB4 4
444 #define DDB3 3
445 #define DDB2 2
446 #define DDB1 1
447 #define DDB0 0
448 
449 /* PINB */
450 #define PINB7 7
451 #define PINB6 6
452 #define PINB5 5
453 #define PINB4 4
454 #define PINB3 3
455 #define PINB2 2
456 #define PINB1 1
457 #define PINB0 0
458 
459 /*
460  PC7 = TOSC2
461  PC6 = TOSC1
462  PC1 = SDA
463  PC0 = SCL
464  */
465 /* PORTC */
466 #define PC7 7
467 #define PC6 6
468 #define PC5 5
469 #define PC4 4
470 #define PC3 3
471 #define PC2 2
472 #define PC1 1
473 #define PC0 0
474 
475 /* DDRC */
476 #define DDC7 7
477 #define DDC6 6
478 #define DDC5 5
479 #define DDC4 4
480 #define DDC3 3
481 #define DDC2 2
482 #define DDC1 1
483 #define DDC0 0
484 
485 /* PINC */
486 #define PINC7 7
487 #define PINC6 6
488 #define PINC5 5
489 #define PINC4 4
490 #define PINC3 3
491 #define PINC2 2
492 #define PINC1 1
493 #define PINC0 0
494 
495 /*
496  PD7 = OC2
497  PD6 = ICP
498  PD5 = OC1A
499  PD4 = OC1B
500  PD3 = INT1
501  PD2 = INT0
502  PD1 = TXD
503  PD0 = RXD
504  */
505 
506 /* PORTD */
507 #define PD7 7
508 #define PD6 6
509 #define PD5 5
510 #define PD4 4
511 #define PD3 3
512 #define PD2 2
513 #define PD1 1
514 #define PD0 0
515 
516 /* DDRD */
517 #define DDD7 7
518 #define DDD6 6
519 #define DDD5 5
520 #define DDD4 4
521 #define DDD3 3
522 #define DDD2 2
523 #define DDD1 1
524 #define DDD0 0
525 
526 /* PIND */
527 #define PIND7 7
528 #define PIND6 6
529 #define PIND5 5
530 #define PIND4 4
531 #define PIND3 3
532 #define PIND2 2
533 #define PIND1 1
534 #define PIND0 0
535 
536 /* SPSR */
537 #define SPIF 7
538 #define WCOL 6
539 /* bits 5-1 reserved */
540 #define SPI2X 0
541 
542 /* SPCR */
543 #define SPIE 7
544 #define SPE 6
545 #define DORD 5
546 #define MSTR 4
547 #define CPOL 3
548 #define CPHA 2
549 #define SPR1 1
550 #define SPR0 0
551 
552 /* UCSRA */
553 #define RXC 7
554 #define TXC 6
555 #define UDRE 5
556 #define FE 4
557 #define DOR 3
558 /* bit 2 reserved */
559 #define U2X 1
560 #define MPCM 0
561 
562 /* UCSRB */
563 #define RXCIE 7
564 #define TXCIE 6
565 #define UDRIE 5
566 #define RXEN 4
567 #define TXEN 3
568 #define CHR9 2
569 #define RXB8 1
570 #define TXB8 0
571 
572 /* ACSR */
573 #define ACD 7
574 #define AINBG 6
575 #define ACO 5
576 #define ACI 4
577 #define ACIE 3
578 #define ACIC 2
579 #define ACIS1 1
580 #define ACIS0 0
581 
582 /* ADCSR */
583 #define ADEN 7
584 #define ADSC 6
585 #define ADFR 5
586 #define ADIF 4
587 #define ADIE 3
588 #define ADPS2 2
589 #define ADPS1 1
590 #define ADPS0 0
591 
592 /* ADMUX */
593 #define REFS1 7
594 #define REFS0 6
595 #define ADLAR 5
596 #define MUX4 4
597 #define MUX3 3
598 #define MUX2 2
599 #define MUX1 1
600 #define MUX0 0
601 
602 /* EEPROM Control Register */
603 #define EERIE 3
604 #define EEMWE 2
605 #define EEWE 1
606 #define EERE 0
607 
608 /* Constants */
609 #define SPM_PAGESIZE 128
610 #define RAMEND 0x45F
611 #define XRAMEND RAMEND
612 #define E2END 0x1FF
613 #define E2PAGESIZE 0
614 #define FLASHEND 0x3FFF
615 
616 
617 /* Fuses */
618 
619 #define FUSE_MEMORY_SIZE 2
620 
621 /* Low Fuse Byte */
622 #define FUSE_CKSEL0 (unsigned char)~_BV(0)
623 #define FUSE_CKSEL1 (unsigned char)~_BV(1)
624 #define FUSE_CKSEL2 (unsigned char)~_BV(2)
625 #define FUSE_CKSEL3 (unsigned char)~_BV(3)
626 #define FUSE_SPIEN (unsigned char)~_BV(5)
627 #define FUSE_BODEN (unsigned char)~_BV(6)
628 #define FUSE_BODLEVEL (unsigned char)~_BV(7)
629 #define LFUSE_DEFAULT (FUSE_CKSEL0 & FUSE_CKSEL2 & FUSE_CKSEL3 & FUSE_SPIEN)
630 
631 /* High Fuse Byte */
632 #define FUSE_BOOTRST (unsigned char)~_BV(0)
633 #define FUSE_BOOTSZ0 (unsigned char)~_BV(1)
634 #define FUSE_BOOTSZ1 (unsigned char)~_BV(2)
635 #define HFUSE_DEFAULT (0xFF)
636 
637 
638 /* Lock Bits */
639 #define __LOCK_BITS_EXIST
640 #define __BOOT_LOCK_BITS_0_EXIST
641 #define __BOOT_LOCK_BITS_1_EXIST
642 
643 
644 /* Signature */
645 #define SIGNATURE_0 0x1E
646 #define SIGNATURE_1 0x94
647 #define SIGNATURE_2 0x02
648 
649 
651 #endif /* _AVR_IOM163_H_ */