source: rtems/cpukit/score/cpu/avr/avr/iom323.h @ b10825c

4.115
Last change on this file since b10825c was b10825c, checked in by Joel Sherrill <joel.sherrill@…>, on 01/10/13 at 19:29:41

cpukit: Add EOL on files missing EOL at EOF

  • Property mode set to 100644
File size: 12.8 KB
Line 
1/**
2 * @file avr/iom323.h
3 *
4 * @brief Definitions for ATmega323
5 *
6 * This file should only be included from <avr/io.h>, never directly.
7 */
8
9/*
10 *  Copyright (c) 2002 Marek Michalkiewicz
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_IOM323_H_
42#define _AVR_IOM323_H_ 1
43
44/**
45 *  @defgroup Avr_iom323 ATmega323 Definitions
46 *
47 *  @ingroup avr
48 */
49/**@{*/
50
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_ "iom323.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 ADCSR   _SFR_IO8(0x06)
77#define ADMUX   _SFR_IO8(0x07)
78
79/* analog comparator */
80#define ACSR    _SFR_IO8(0x08)
81
82/* UART */
83#define UBRR    _SFR_IO8(0x09)
84#define UBRRL   UBRR
85#define UCSRB   _SFR_IO8(0x0A)
86#define UCSRA   _SFR_IO8(0x0B)
87#define UDR     _SFR_IO8(0x0C)
88
89/* SPI */
90#define SPCR    _SFR_IO8(0x0D)
91#define SPSR    _SFR_IO8(0x0E)
92#define SPDR    _SFR_IO8(0x0F)
93
94/* Port D */
95#define PIND    _SFR_IO8(0x10)
96#define DDRD    _SFR_IO8(0x11)
97#define PORTD   _SFR_IO8(0x12)
98
99/* Port C */
100#define PINC    _SFR_IO8(0x13)
101#define DDRC    _SFR_IO8(0x14)
102#define PORTC   _SFR_IO8(0x15)
103
104/* Port B */
105#define PINB    _SFR_IO8(0x16)
106#define DDRB    _SFR_IO8(0x17)
107#define PORTB   _SFR_IO8(0x18)
108
109/* Port A */
110#define PINA    _SFR_IO8(0x19)
111#define DDRA    _SFR_IO8(0x1A)
112#define PORTA   _SFR_IO8(0x1B)
113
114/* EEPROM Control Register */
115#define EECR    _SFR_IO8(0x1C)
116
117/* EEPROM Data Register */
118#define EEDR    _SFR_IO8(0x1D)
119
120/* EEPROM Address Register */
121#define EEAR    _SFR_IO16(0x1E)
122#define EEARL   _SFR_IO8(0x1E)
123#define EEARH   _SFR_IO8(0x1F)
124
125#define UBRRH   _SFR_IO8(0x20)
126#define UCSRC   UBRRH
127
128#define WDTCR   _SFR_IO8(0x21)
129
130#define ASSR    _SFR_IO8(0x22)
131
132/* Timer 2 */
133#define OCR2    _SFR_IO8(0x23)
134#define TCNT2   _SFR_IO8(0x24)
135#define TCCR2   _SFR_IO8(0x25)
136
137/* Timer 1 */
138#define ICR1    _SFR_IO16(0x26)
139#define ICR1L   _SFR_IO8(0x26)
140#define ICR1H   _SFR_IO8(0x27)
141#define OCR1B   _SFR_IO16(0x28)
142#define OCR1BL  _SFR_IO8(0x28)
143#define OCR1BH  _SFR_IO8(0x29)
144#define OCR1A   _SFR_IO16(0x2A)
145#define OCR1AL  _SFR_IO8(0x2A)
146#define OCR1AH  _SFR_IO8(0x2B)
147#define TCNT1   _SFR_IO16(0x2C)
148#define TCNT1L  _SFR_IO8(0x2C)
149#define TCNT1H  _SFR_IO8(0x2D)
150#define TCCR1B  _SFR_IO8(0x2E)
151#define TCCR1A  _SFR_IO8(0x2F)
152
153#define SFIOR   _SFR_IO8(0x30)
154
155#define OSCCAL  _SFR_IO8(0x31)
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_UART_RECV                   _VECTOR(13)
235
236/* USART Data Register Empty */
237#define USART_UDRE_vect                 _VECTOR(14)
238#define SIG_UART_DATA                   _VECTOR(14)
239
240/* USART, Tx Complete */
241#define USART_TXC_vect                  _VECTOR(15)
242#define SIG_UART_TRANS                  _VECTOR(15)
243
244/* ADC Conversion Complete */
245#define ADC_vect                        _VECTOR(16)
246#define SIG_ADC                         _VECTOR(16)
247
248/* EEPROM Ready */
249#define EE_RDY_vect                     _VECTOR(17)
250#define SIG_EEPROM_READY                _VECTOR(17)
251
252/* Analog Comparator */
253#define ANA_COMP_vect                   _VECTOR(18)
254#define SIG_COMPARATOR                  _VECTOR(18)
255
256/* 2-wire Serial Interface */
257#define TWI_vect                        _VECTOR(19)
258#define SIG_2WIRE_SERIAL                _VECTOR(19)
259
260/* Store Program Memory Ready */
261#define SPM_RDY_vect                    _VECTOR(20)
262
263#define _VECTORS_SIZE 80
264
265
266/* Bit numbers */
267
268/* GIMSK */
269#define INT1    7
270#define INT0    6
271#define INT2    5
272#define IVSEL   1
273#define IVCE    0
274
275/* GIFR */
276#define INTF1   7
277#define INTF0   6
278#define INTF2   5
279
280/* TIMSK */
281#define OCIE2   7
282#define TOIE2   6
283#define TICIE1  5
284#define OCIE1A  4
285#define OCIE1B  3
286#define TOIE1   2
287#define OCIE0   1
288#define TOIE0   0
289
290/* TIFR */
291#define OCF2    7
292#define TOV2    6
293#define ICF1    5
294#define OCF1A   4
295#define OCF1B   3
296#define TOV1    2
297#define OCF0    1
298#define TOV0    0
299
300/* SPMCR */
301#define SPMIE   7
302#define ASB     6
303/* bit 5 reserved */
304#define ASRE    4
305#define BLBSET  3
306#define PGWRT   2
307#define PGERS   1
308#define SPMEN   0
309
310/* TWCR */
311#define TWINT   7
312#define TWEA    6
313#define TWSTA   5
314#define TWSTO   4
315#define TWWC    3
316#define TWEN    2
317#define TWI_TST 1
318#define TWIE    0
319
320/* TWAR */
321#define TWGCE   0
322
323/* TWSR */
324#define    TWS7         7
325#define    TWS6         6
326#define    TWS5         5
327#define    TWS4         4
328#define    TWS3         3
329/* bits 2-0 reserved */
330
331/* MCUCR */
332/* bit 7 reserved (SM2?) */
333#define SE      7
334#define SM2     6
335#define SM1     5
336#define SM0     4
337#define ISC11   3
338#define ISC10   2
339#define ISC01   1
340#define ISC00   0
341
342/* MCUCSR */
343#define JTD     7
344#define ISC2    6
345#define EIH     5
346#define JTRF    4
347#define WDRF    3
348#define BORF    2
349#define EXTRF   1
350#define PORF    0
351
352/* SFIOR */
353#define RPDD    7
354#define RPDC    6
355#define RPDB    5
356#define RPDA    4
357#define ACME    3
358#define PUD     2
359#define PSR2    1
360#define PSR10   0
361
362/* TCCR0 */
363#define FOC0    7
364#define PWM0    6
365#define COM01   5
366#define COM00   4
367#define CTC0    3
368#define CS02    2
369#define CS01    1
370#define CS00    0
371
372/* TCCR2 */
373#define FOC2    7
374#define PWM2    6
375#define COM21   5
376#define COM20   4
377#define CTC2    3
378#define CS22    2
379#define CS21    1
380#define CS20    0
381
382/* ASSR */
383/* bits 7-4 reserved */
384#define AS2     3
385#define TCN2UB  2
386#define OCR2UB  1
387#define TCR2UB  0
388
389/* TCCR1A */
390#define COM1A1  7
391#define COM1A0  6
392#define COM1B1  5
393#define COM1B0  4
394#define FOC1A   3
395#define FOC1B   2
396#define PWM11   1
397#define PWM10   0
398
399/* TCCR1B */
400#define ICNC1   7
401#define ICES1   6
402/* bit 5 reserved */
403#define CTC11   4
404#define CTC10   3
405#define CS12    2
406#define CS11    1
407#define CS10    0
408
409/* WDTCR */
410/* bits 7-5 reserved */
411#define WDTOE   4
412#define WDE     3
413#define WDP2    2
414#define WDP1    1
415#define WDP0    0
416
417/* PA7-PA0 = ADC7-ADC0 */
418/* PORTA */
419#define PA7     7
420#define PA6     6
421#define PA5     5
422#define PA4     4
423#define PA3     3
424#define PA2     2
425#define PA1     1
426#define PA0     0
427
428/* DDRA */
429#define DDA7    7
430#define DDA6    6
431#define DDA5    5
432#define DDA4    4
433#define DDA3    3
434#define DDA2    2
435#define DDA1    1
436#define DDA0    0
437
438/* PINA */
439#define PINA7   7
440#define PINA6   6
441#define PINA5   5
442#define PINA4   4
443#define PINA3   3
444#define PINA2   2
445#define PINA1   1
446#define PINA0   0
447
448/*
449   PB7 = SCK
450   PB6 = MISO
451   PB5 = MOSI
452   PB4 = SS#
453   PB3 = AIN1
454   PB2 = AIN0
455   PB1 = T1
456   PB0 = T0
457 */
458
459/* PORTB */
460#define PB7     7
461#define PB6     6
462#define PB5     5
463#define PB4     4
464#define PB3     3
465#define PB2     2
466#define PB1     1
467#define PB0     0
468
469/* DDRB */
470#define DDB7    7
471#define DDB6    6
472#define DDB5    5
473#define DDB4    4
474#define DDB3    3
475#define DDB2    2
476#define DDB1    1
477#define DDB0    0
478
479/* PINB */
480#define PINB7   7
481#define PINB6   6
482#define PINB5   5
483#define PINB4   4
484#define PINB3   3
485#define PINB2   2
486#define PINB1   1
487#define PINB0   0
488
489/*
490   PC7 = TOSC2
491   PC6 = TOSC1
492   PC1 = SDA
493   PC0 = SCL
494 */
495/* PORTC */
496#define PC7      7
497#define PC6      6
498#define PC5      5
499#define PC4      4
500#define PC3      3
501#define PC2      2
502#define PC1      1
503#define PC0      0
504
505/* DDRC */
506#define DDC7    7
507#define DDC6    6
508#define DDC5    5
509#define DDC4    4
510#define DDC3    3
511#define DDC2    2
512#define DDC1    1
513#define DDC0    0
514
515/* PINC */
516#define PINC7   7
517#define PINC6   6
518#define PINC5   5
519#define PINC4   4
520#define PINC3   3
521#define PINC2   2
522#define PINC1   1
523#define PINC0   0
524
525/*
526   PD7 = OC2
527   PD6 = ICP
528   PD5 = OC1A
529   PD4 = OC1B
530   PD3 = INT1
531   PD2 = INT0
532   PD1 = TXD
533   PD0 = RXD
534 */
535
536/* PORTD */
537#define PD7      7
538#define PD6      6
539#define PD5      5
540#define PD4      4
541#define PD3      3
542#define PD2      2
543#define PD1      1
544#define PD0      0
545
546/* DDRD */
547#define DDD7    7
548#define DDD6    6
549#define DDD5    5
550#define DDD4    4
551#define DDD3    3
552#define DDD2    2
553#define DDD1    1
554#define DDD0    0
555
556/* PIND */
557#define PIND7   7
558#define PIND6   6
559#define PIND5   5
560#define PIND4   4
561#define PIND3   3
562#define PIND2   2
563#define PIND1   1
564#define PIND0   0
565
566/*
567   PE2 = ALE
568   PE1 = OC1B
569   PE0 = ICP / INT2
570 */
571
572/* SPSR */
573#define SPIF    7
574#define WCOL    6
575#define SPI2X   0
576
577/* SPCR */
578#define SPIE    7
579#define SPE     6
580#define DORD    5
581#define MSTR    4
582#define CPOL    3
583#define CPHA    2
584#define SPR1    1
585#define SPR0    0
586
587/* UCSRA */
588#define RXC     7
589#define TXC     6
590#define UDRE    5
591#define FE      4
592#define DOR     3
593#define PE      2
594#define U2X     1
595#define MPCM    0
596
597/* UCSRB */
598#define RXCIE   7
599#define TXCIE   6
600#define UDRIE   5
601#define RXEN    4
602#define TXEN    3
603#define UCSZ2   2
604#define CHR9    2
605#define RXB8    1
606#define TXB8    0
607
608/* UCSRC */
609#define URSEL   7
610#define UMSEL   6
611#define UPM1    5
612#define UPM0    4
613#define USBS    3
614#define UCSZ1   2
615#define UCSZ0   1
616#define UCPOL   0
617
618/* ACSR */
619#define ACD     7
620#define AINBG   6
621#define ACO     5
622#define ACI     4
623#define ACIE    3
624#define ACIC    2
625#define ACIS1   1
626#define ACIS0   0
627
628/* ADCSR */
629#define ADEN    7
630#define ADSC    6
631#define ADFR    5
632#define ADIF    4
633#define ADIE    3
634#define ADPS2   2
635#define ADPS1   1
636#define ADPS0   0
637
638/* ADMUX */
639#define REFS1   7
640#define REFS0   6
641#define ADLAR   5
642#define MUX4    4
643#define MUX3    3
644#define MUX2    2
645#define MUX1    1
646#define MUX0    0
647
648/* EEPROM Control Register */
649#define    EERIE        3
650#define    EEMWE        2
651#define    EEWE         1
652#define    EERE         0
653
654/* Constants */
655#define SPM_PAGESIZE 128
656#define RAMEND          0x85F
657#define XRAMEND         RAMEND
658#define E2END           0x3FF
659#define E2PAGESIZE  0
660#define FLASHEND        0x7FFF
661
662
663/* Fuses */
664
665#define FUSE_MEMORY_SIZE 2
666
667/* Low Fuse Byte */
668#define FUSE_CKSEL0      (unsigned char)~_BV(0)
669#define FUSE_CKSEL1      (unsigned char)~_BV(1)
670#define FUSE_CKSEL2      (unsigned char)~_BV(2)
671#define FUSE_CKSEL3      (unsigned char)~_BV(3)
672#define FUSE_BODEN       (unsigned char)~_BV(6)
673#define FUSE_BODLEVEL    (unsigned char)~_BV(7)
674#define LFUSE_DEFAULT (FUSE_CKSEL0 & FUSE_CKSEL2 & FUSE_CKSEL3)
675
676/* High Fuse Byte */
677#define FUSE_BOOTRST     (unsigned char)~_BV(0)
678#define FUSE_BOOTSZ0     (unsigned char)~_BV(1)
679#define FUSE_BOOTSZ1     (unsigned char)~_BV(2)
680#define FUSE_EESAVE      (unsigned char)~_BV(3)
681#define FUSE_SPIEN       (unsigned char)~_BV(5)
682#define FUSE_JTAGEN      (unsigned char)~_BV(6)
683#define FUSE_OCDEN       (unsigned char)~_BV(7)
684#define HFUSE_DEFAULT (FUSE_SPIEN & FUSE_JTAGEN)
685
686
687/* Lock Bits */
688#define __LOCK_BITS_EXIST
689#define __BOOT_LOCK_BITS_0_EXIST
690#define __BOOT_LOCK_BITS_1_EXIST
691
692
693/* Signature */
694#define SIGNATURE_0 0x1E
695#define SIGNATURE_1 0x95
696#define SIGNATURE_2 0x01
697
698/**@}*/
699#endif /* _AVR_IOM323_H_ */
Note: See TracBrowser for help on using the repository browser.