Main Page   Modules   Data Structures   File List   Data Fields   Globals   Related Pages   Examples  

iom323.h

00001 /* Copyright (c) 2002, Marek Michalkiewicz
00002    All rights reserved.
00003 
00004    Redistribution and use in source and binary forms, with or without
00005    modification, are permitted provided that the following conditions are met:
00006 
00007    * Redistributions of source code must retain the above copyright
00008      notice, this list of conditions and the following disclaimer.
00009    * Redistributions in binary form must reproduce the above copyright
00010      notice, this list of conditions and the following disclaimer in
00011      the documentation and/or other materials provided with the
00012      distribution.
00013 
00014   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00015   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00016   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00017   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00018   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00019   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00020   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00021   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00022   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00023   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00024   POSSIBILITY OF SUCH DAMAGE. */
00025 
00026 /* avr/iom323.h - definitions for ATmega323 */
00027 
00028 #ifndef _AVR_IOM323_H_
00029 #define _AVR_IOM323_H_ 1
00030 
00031 /* This file should only be included from <avr/io.h>, never directly. */
00032 
00033 #ifndef _AVR_IO_H_
00034 #  error "Include <avr/io.h> instead of this file."
00035 #endif
00036 
00037 #ifndef _AVR_IOXXX_H_
00038 #  define _AVR_IOXXX_H_ "iom323.h"
00039 #else
00040 #  error "Attempt to include more than one <avr/ioXXX.h> file."
00041 #endif 
00042 
00043 #include <avr/sfr_defs.h>
00044 
00045 /* I/O registers */
00046 
00047 /* TWI stands for "Two Wire Interface" or "TWI Was I2C(tm)" */
00048 #define TWBR    _SFR_IO8(0x00)
00049 #define TWSR    _SFR_IO8(0x01)
00050 #define TWAR    _SFR_IO8(0x02)
00051 #define TWDR    _SFR_IO8(0x03)
00052 
00053 /* ADC */
00054 #define ADCW    _SFR_IO16(0x04)
00055 #define ADCL    _SFR_IO8(0x04)
00056 #define ADCH    _SFR_IO8(0x05)
00057 #define ADCSR   _SFR_IO8(0x06)
00058 #define ADMUX   _SFR_IO8(0x07)
00059 
00060 /* analog comparator */
00061 #define ACSR    _SFR_IO8(0x08)
00062 
00063 /* UART */
00064 #define UBRR    _SFR_IO8(0x09)
00065 #define UBRRL   UBRR
00066 #define UCSRB   _SFR_IO8(0x0A)
00067 #define UCSRA   _SFR_IO8(0x0B)
00068 #define UDR     _SFR_IO8(0x0C)
00069 
00070 /* SPI */
00071 #define SPCR    _SFR_IO8(0x0D)
00072 #define SPSR    _SFR_IO8(0x0E)
00073 #define SPDR    _SFR_IO8(0x0F)
00074 
00075 /* Port D */
00076 #define PIND    _SFR_IO8(0x10)
00077 #define DDRD    _SFR_IO8(0x11)
00078 #define PORTD   _SFR_IO8(0x12)
00079 
00080 /* Port C */
00081 #define PINC    _SFR_IO8(0x13)
00082 #define DDRC    _SFR_IO8(0x14)
00083 #define PORTC   _SFR_IO8(0x15)
00084 
00085 /* Port B */
00086 #define PINB    _SFR_IO8(0x16)
00087 #define DDRB    _SFR_IO8(0x17)
00088 #define PORTB   _SFR_IO8(0x18)
00089 
00090 /* Port A */
00091 #define PINA    _SFR_IO8(0x19)
00092 #define DDRA    _SFR_IO8(0x1A)
00093 #define PORTA   _SFR_IO8(0x1B)
00094 
00095 /* EEPROM */
00096 #define EECR    _SFR_IO8(0x1C)
00097 #define EEDR    _SFR_IO8(0x1D)
00098 #define EEAR    _SFR_IO16(0x1E)
00099 #define EEARL   _SFR_IO8(0x1E)
00100 #define EEARH   _SFR_IO8(0x1F)
00101 
00102 #define UBRRH   _SFR_IO8(0x20)
00103 #define UCSRC   UBRRH
00104 
00105 #define WDTCR   _SFR_IO8(0x21)
00106 
00107 #define ASSR    _SFR_IO8(0x22)
00108 
00109 /* Timer 2 */
00110 #define OCR2    _SFR_IO8(0x23)
00111 #define TCNT2   _SFR_IO8(0x24)
00112 #define TCCR2   _SFR_IO8(0x25)
00113 
00114 /* Timer 1 */
00115 #define ICR1    _SFR_IO16(0x26)
00116 #define ICR1L   _SFR_IO8(0x26)
00117 #define ICR1H   _SFR_IO8(0x27)
00118 #define OCR1B   _SFR_IO16(0x28)
00119 #define OCR1BL  _SFR_IO8(0x28)
00120 #define OCR1BH  _SFR_IO8(0x29)
00121 #define OCR1A   _SFR_IO16(0x2A)
00122 #define OCR1AL  _SFR_IO8(0x2A)
00123 #define OCR1AH  _SFR_IO8(0x2B)
00124 #define TCNT1   _SFR_IO16(0x2C)
00125 #define TCNT1L  _SFR_IO8(0x2C)
00126 #define TCNT1H  _SFR_IO8(0x2D)
00127 #define TCCR1B  _SFR_IO8(0x2E)
00128 #define TCCR1A  _SFR_IO8(0x2F)
00129 
00130 #define SFIOR   _SFR_IO8(0x30)
00131 
00132 #define OSCCAL  _SFR_IO8(0x31)
00133 
00134 /* Timer 0 */
00135 #define TCNT0   _SFR_IO8(0x32)
00136 #define TCCR0   _SFR_IO8(0x33)
00137 
00138 #define MCUSR   _SFR_IO8(0x34)
00139 #define MCUCSR  MCUSR
00140 #define MCUCR   _SFR_IO8(0x35)
00141 
00142 #define TWCR    _SFR_IO8(0x36)
00143 
00144 #define SPMCR   _SFR_IO8(0x37)
00145 
00146 #define TIFR    _SFR_IO8(0x38)
00147 #define TIMSK   _SFR_IO8(0x39)
00148 
00149 #define GIFR    _SFR_IO8(0x3A)
00150 #define GIMSK   _SFR_IO8(0x3B)
00151 #define GICR    GIMSK
00152 
00153 #define OCR0    _SFR_IO8(0x3C)
00154 
00155 #define SP      _SFR_IO16(0x3D)
00156 #define SPL     _SFR_IO8(0x3D)
00157 #define SPH     _SFR_IO8(0x3E)
00158 #define SREG    _SFR_IO8(0x3F)
00159 
00160 
00161 /* Interrupt vectors */
00162 
00163 #define SIG_INTERRUPT0          _VECTOR(1)
00164 #define SIG_INTERRUPT1          _VECTOR(2)
00165 #define SIG_INTERRUPT2          _VECTOR(3)
00166 #define SIG_OUTPUT_COMPARE2     _VECTOR(4)
00167 #define SIG_OVERFLOW2           _VECTOR(5)
00168 #define SIG_INPUT_CAPTURE1      _VECTOR(6)
00169 #define SIG_OUTPUT_COMPARE1A    _VECTOR(7)
00170 #define SIG_OUTPUT_COMPARE1B    _VECTOR(8)
00171 #define SIG_OVERFLOW1           _VECTOR(9)
00172 #define SIG_OUTPUT_COMPARE0     _VECTOR(10)
00173 #define SIG_OVERFLOW0           _VECTOR(11)
00174 #define SIG_SPI                 _VECTOR(12)
00175 #define SIG_UART_RECV           _VECTOR(13)
00176 #define SIG_UART_DATA           _VECTOR(14)
00177 #define SIG_UART_TRANS          _VECTOR(15)
00178 #define SIG_ADC                 _VECTOR(16)
00179 #define SIG_EEPROM_READY        _VECTOR(17)
00180 #define SIG_COMPARATOR          _VECTOR(18)
00181 #define SIG_2WIRE_SERIAL        _VECTOR(19)
00182 
00183 #define _VECTORS_SIZE 80
00184 
00185 
00186 /* Bit numbers */
00187 
00188 /* GIMSK */
00189 #define INT1    7
00190 #define INT0    6
00191 #define INT2    5
00192 #define IVSEL   1
00193 #define IVCE    0
00194 
00195 /* GIFR */
00196 #define INTF1   7
00197 #define INTF0   6
00198 #define INTF2   5
00199 
00200 /* TIMSK */
00201 #define OCIE2   7
00202 #define TOIE2   6
00203 #define TICIE1  5
00204 #define OCIE1A  4
00205 #define OCIE1B  3
00206 #define TOIE1   2
00207 #define OCIE0   1
00208 #define TOIE0   0
00209 
00210 /* TIFR */
00211 #define OCF2    7
00212 #define TOV2    6
00213 #define ICF1    5
00214 #define OCF1A   4
00215 #define OCF1B   3
00216 #define TOV1    2
00217 #define OCF0    1
00218 #define TOV0    0
00219 
00220 /* SPMCR */
00221 #define SPMIE   7
00222 #define ASB     6
00223 /* bit 5 reserved */
00224 #define ASRE    4
00225 #define BLBSET  3
00226 #define PGWRT   2
00227 #define PGERS   1
00228 #define SPMEN   0
00229 
00230 /* TWCR */
00231 #define TWINT   7
00232 #define TWEA    6
00233 #define TWSTA   5
00234 #define TWSTO   4
00235 #define TWWC    3
00236 #define TWEN    2
00237 #define TWI_TST 1
00238 #define TWIE    0
00239 
00240 /* TWAR */
00241 #define TWGCE   0
00242 
00243 /* MCUCR */
00244 /* bit 7 reserved (SM2?) */
00245 #define SE      7
00246 #define SM2     6
00247 #define SM1     5
00248 #define SM0     4
00249 #define ISC11   3
00250 #define ISC10   2
00251 #define ISC01   1
00252 #define ISC00   0
00253 
00254 /* MCUCSR */
00255 #define JTD     7
00256 #define ISC2    6
00257 #define EIH     5
00258 #define JTRF    4
00259 #define WDRF    3
00260 #define BORF    2
00261 #define EXTRF   1
00262 #define PORF    0
00263 
00264 /* SFIOR */
00265 #define RPDD    7
00266 #define RPDC    6
00267 #define RPDB    5
00268 #define RPDA    4
00269 #define ACME    3
00270 #define PUD     2
00271 #define PSR2    1
00272 #define PSR10   0
00273 
00274 /* TCCR0 */
00275 #define FOC0    7
00276 #define PWM0    6
00277 #define COM01   5
00278 #define COM00   4
00279 #define CTC0    3
00280 #define CS02    2
00281 #define CS01    1
00282 #define CS00    0
00283 
00284 /* TCCR2 */
00285 #define FOC2    7
00286 #define PWM2    6
00287 #define COM21   5
00288 #define COM20   4
00289 #define CTC2    3
00290 #define CS22    2
00291 #define CS21    1
00292 #define CS20    0
00293 
00294 /* ASSR */
00295 /* bits 7-4 reserved */
00296 #define AS2     3
00297 #define TCN2UB  2
00298 #define OCR2UB  1
00299 #define TCR2UB  0
00300 
00301 /* TCCR1A */
00302 #define COM1A1  7
00303 #define COM1A0  6
00304 #define COM1B1  5
00305 #define COM1B0  4
00306 #define FOC1A   3
00307 #define FOC1B   2
00308 #define PWM11   1
00309 #define PWM10   0
00310 
00311 /* TCCR1B */
00312 #define ICNC1   7
00313 #define ICES1   6
00314 /* bit 5 reserved */
00315 #define CTC11   4
00316 #define CTC10   3
00317 #define CS12    2
00318 #define CS11    1
00319 #define CS10    0
00320 
00321 /* WDTCR */
00322 /* bits 7-5 reserved */
00323 #define WDTOE   4
00324 #define WDE     3
00325 #define WDP2    2
00326 #define WDP1    1
00327 #define WDP0    0
00328 
00329 /* EECR */
00330 /* bits 7-4 reserved */
00331 #define EERIE   3
00332 #define EEMWE   2
00333 #define EEWE    1
00334 #define EERE    0
00335 
00336 /* PA7-PA0 = ADC7-ADC0 */
00337 /* PORTA */
00338 #define PA7     7
00339 #define PA6     6
00340 #define PA5     5
00341 #define PA4     4
00342 #define PA3     3
00343 #define PA2     2
00344 #define PA1     1
00345 #define PA0     0
00346 
00347 /* DDRA */
00348 #define DDA7    7
00349 #define DDA6    6
00350 #define DDA5    5
00351 #define DDA4    4
00352 #define DDA3    3
00353 #define DDA2    2
00354 #define DDA1    1
00355 #define DDA0    0
00356 
00357 /* PINA */
00358 #define PINA7   7
00359 #define PINA6   6
00360 #define PINA5   5
00361 #define PINA4   4
00362 #define PINA3   3
00363 #define PINA2   2
00364 #define PINA1   1
00365 #define PINA0   0
00366 
00367 /*
00368    PB7 = SCK
00369    PB6 = MISO
00370    PB5 = MOSI
00371    PB4 = SS#
00372    PB3 = AIN1
00373    PB2 = AIN0
00374    PB1 = T1
00375    PB0 = T0
00376  */
00377 
00378 /* PORTB */
00379 #define PB7     7
00380 #define PB6     6
00381 #define PB5     5
00382 #define PB4     4
00383 #define PB3     3
00384 #define PB2     2
00385 #define PB1     1
00386 #define PB0     0
00387 
00388 /* DDRB */
00389 #define DDB7    7
00390 #define DDB6    6
00391 #define DDB5    5
00392 #define DDB4    4
00393 #define DDB3    3
00394 #define DDB2    2
00395 #define DDB1    1
00396 #define DDB0    0
00397 
00398 /* PINB */
00399 #define PINB7   7
00400 #define PINB6   6
00401 #define PINB5   5
00402 #define PINB4   4
00403 #define PINB3   3
00404 #define PINB2   2
00405 #define PINB1   1
00406 #define PINB0   0
00407 
00408 /*
00409    PC7 = TOSC2
00410    PC6 = TOSC1
00411    PC1 = SDA
00412    PC0 = SCL
00413  */
00414 /* PORTC */
00415 #define PC7      7
00416 #define PC6      6
00417 #define PC5      5
00418 #define PC4      4
00419 #define PC3      3
00420 #define PC2      2
00421 #define PC1      1
00422 #define PC0      0
00423 
00424 /* DDRC */
00425 #define DDC7    7
00426 #define DDC6    6
00427 #define DDC5    5
00428 #define DDC4    4
00429 #define DDC3    3
00430 #define DDC2    2
00431 #define DDC1    1
00432 #define DDC0    0
00433 
00434 /* PINC */
00435 #define PINC7   7
00436 #define PINC6   6
00437 #define PINC5   5
00438 #define PINC4   4
00439 #define PINC3   3
00440 #define PINC2   2
00441 #define PINC1   1
00442 #define PINC0   0
00443 
00444 /*
00445    PD7 = OC2
00446    PD6 = ICP
00447    PD5 = OC1A
00448    PD4 = OC1B
00449    PD3 = INT1
00450    PD2 = INT0
00451    PD1 = TXD
00452    PD0 = RXD
00453  */
00454 
00455 /* PORTD */
00456 #define PD7      7
00457 #define PD6      6
00458 #define PD5      5
00459 #define PD4      4
00460 #define PD3      3
00461 #define PD2      2
00462 #define PD1      1
00463 #define PD0      0
00464 
00465 /* DDRD */
00466 #define DDD7    7
00467 #define DDD6    6
00468 #define DDD5    5
00469 #define DDD4    4
00470 #define DDD3    3
00471 #define DDD2    2
00472 #define DDD1    1
00473 #define DDD0    0
00474 
00475 /* PIND */
00476 #define PIND7   7
00477 #define PIND6   6
00478 #define PIND5   5
00479 #define PIND4   4
00480 #define PIND3   3
00481 #define PIND2   2
00482 #define PIND1   1
00483 #define PIND0   0
00484 
00485 /*
00486    PE2 = ALE
00487    PE1 = OC1B
00488    PE0 = ICP / INT2
00489  */
00490 
00491 /* SPSR */
00492 #define SPIF    7
00493 #define WCOL    6
00494 #define SPI2X   0
00495 
00496 /* SPCR */
00497 #define SPIE    7
00498 #define SPE     6
00499 #define DORD    5
00500 #define MSTR    4
00501 #define CPOL    3
00502 #define CPHA    2
00503 #define SPR1    1
00504 #define SPR0    0
00505 
00506 /* UCSRA */
00507 #define RXC     7
00508 #define TXC     6
00509 #define UDRE    5
00510 #define FE      4
00511 #define DOR     3
00512 #define PE      2
00513 #define U2X     1
00514 #define MPCM    0
00515 
00516 /* UCSRB */
00517 #define RXCIE   7
00518 #define TXCIE   6
00519 #define UDRIE   5
00520 #define RXEN    4
00521 #define TXEN    3
00522 #define UCSZ2   2
00523 #define CHR9    2
00524 #define RXB8    1
00525 #define TXB8    0
00526 
00527 /* UCSRC */
00528 #define URSEL   7
00529 #define UMSEL   6
00530 #define UPM1    5
00531 #define UPM0    4
00532 #define USBS    3
00533 #define UCSZ1   2
00534 #define UCSZ0   1
00535 #define UCPOL   0
00536 
00537 /* ACSR */
00538 #define ACD     7
00539 #define AINBG   6
00540 #define ACO     5
00541 #define ACI     4
00542 #define ACIE    3
00543 #define ACIC    2
00544 #define ACIS1   1
00545 #define ACIS0   0
00546 
00547 /* ADCSR */
00548 #define ADEN    7
00549 #define ADSC    6
00550 #define ADFR    5
00551 #define ADIF    4
00552 #define ADIE    3
00553 #define ADPS2   2
00554 #define ADPS1   1
00555 #define ADPS0   0
00556 
00557 /* ADMUX */
00558 #define REFS1   7
00559 #define REFS0   6
00560 #define ADLAR   5
00561 #define MUX4    4
00562 #define MUX3    3
00563 #define MUX2    2
00564 #define MUX1    1
00565 #define MUX0    0
00566 
00567 /* Pointer registers (same for all AVR devices so far) */
00568 #define XL r26
00569 #define XH r27
00570 #define YL r28
00571 #define YH r29
00572 #define ZL r30
00573 #define ZH r31
00574 
00575 /* Last memory addresses */
00576 #define RAMEND          0x85F
00577 #define XRAMEND         0x85F
00578 #define E2END           0x3FF
00579 #define FLASHEND        0x7FFF
00580 
00581 #endif /* _AVR_IOM323_H_ */

Generated on Thu Jan 30 22:30:49 2003 for EduNet by doxygen1.2.18