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

iom161.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/iom161.h - definitions for ATmega161 */
00027 
00028 #ifndef _AVR_IOM161_H_
00029 #define _AVR_IOM161_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_ "iom161.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 /* UART1 Baud Rate Register */
00048 #define UBRR1   _SFR_IO8(0x00)
00049 
00050 /* UART1 Control and Status Registers */
00051 #define UCSR1B  _SFR_IO8(0x01)
00052 #define UCSR1A  _SFR_IO8(0x02)
00053 
00054 /* UART1 I/O Data Register */
00055 #define UDR1    _SFR_IO8(0x03)
00056 
00057 /* 0x04 reserved */
00058 
00059 /* Input Pins, Port E */
00060 #define PINE    _SFR_IO8(0x05)
00061 
00062 /* Data Direction Register, Port E */
00063 #define DDRE    _SFR_IO8(0x06)
00064 
00065 /* Data Register, Port E */
00066 #define PORTE   _SFR_IO8(0x07)
00067 
00068 /* Analog Comparator Control and Status Register */
00069 #define ACSR    _SFR_IO8(0x08)
00070 
00071 /* UART0 Baud Rate Register */
00072 #define UBRR0   _SFR_IO8(0x09)
00073 
00074 /* UART0 Control and Status Registers */
00075 #define UCSR0B  _SFR_IO8(0x0A)
00076 #define UCSR0A  _SFR_IO8(0x0B)
00077 
00078 /* UART0 I/O Data Register */
00079 #define UDR0    _SFR_IO8(0x0C)
00080 
00081 /* SPI Control Register */
00082 #define SPCR    _SFR_IO8(0x0D)
00083 
00084 /* SPI Status Register */
00085 #define SPSR    _SFR_IO8(0x0E)
00086 
00087 /* SPI I/O Data Register */
00088 #define SPDR    _SFR_IO8(0x0F)
00089 
00090 /* Input Pins, Port D */
00091 #define PIND    _SFR_IO8(0x10)
00092 
00093 /* Data Direction Register, Port D */
00094 #define DDRD    _SFR_IO8(0x11)
00095 
00096 /* Data Register, Port D */
00097 #define PORTD   _SFR_IO8(0x12)
00098 
00099 /* Input Pins, Port C */
00100 #define PINC    _SFR_IO8(0x13)
00101 
00102 /* Data Direction Register, Port C */
00103 #define DDRC    _SFR_IO8(0x14)
00104 
00105 /* Data Register, Port C */
00106 #define PORTC   _SFR_IO8(0x15)
00107 
00108 /* Input Pins, Port B */
00109 #define PINB    _SFR_IO8(0x16)
00110 
00111 /* Data Direction Register, Port B */
00112 #define DDRB    _SFR_IO8(0x17)
00113 
00114 /* Data Register, Port B */
00115 #define PORTB   _SFR_IO8(0x18)
00116 
00117 /* Input Pins, Port A */
00118 #define PINA    _SFR_IO8(0x19)
00119 
00120 /* Data Direction Register, Port A */
00121 #define DDRA    _SFR_IO8(0x1A)
00122 
00123 /* Data Register, Port A */
00124 #define PORTA   _SFR_IO8(0x1B)
00125 
00126 /* EEPROM Control Register */
00127 #define EECR    _SFR_IO8(0x1C)
00128 
00129 /* EEPROM Data Register */
00130 #define EEDR    _SFR_IO8(0x1D)
00131 
00132 /* EEPROM Address Register */
00133 #define EEAR    _SFR_IO16(0x1E)
00134 #define EEARL   _SFR_IO8(0x1E)
00135 #define EEARH   _SFR_IO8(0x1F)
00136 
00137 /* UART Baud Register HIgh */
00138 #define UBRRH   _SFR_IO8(0x20)
00139 
00140 /* Watchdog Timer Control Register */
00141 #define WDTCR   _SFR_IO8(0x21)
00142 
00143 /* Timer/Counter2 Output Compare Register */
00144 #define OCR2    _SFR_IO8(0x22)
00145 
00146 /* Timer/Counter2 (8-bit) */
00147 #define TCNT2   _SFR_IO8(0x23)
00148 
00149 /* Timer/Counter1 Input Capture Register */
00150 #define ICR1    _SFR_IO16(0x24)
00151 #define ICR1L   _SFR_IO8(0x24)
00152 #define ICR1H   _SFR_IO8(0x25)
00153 
00154 /* ASynchronous mode Status Register */
00155 #define ASSR    _SFR_IO8(0x26)
00156 
00157 /* Timer/Counter2 Control Register */
00158 #define TCCR2   _SFR_IO8(0x27)
00159 
00160 /* Timer/Counter1 Output Compare RegisterB */
00161 #define OCR1B   _SFR_IO16(0x28)
00162 #define OCR1BL  _SFR_IO8(0x28)
00163 #define OCR1BH  _SFR_IO8(0x29)
00164 
00165 /* Timer/Counter1 Output Compare RegisterA */
00166 #define OCR1A   _SFR_IO16(0x2A)
00167 #define OCR1AL  _SFR_IO8(0x2A)
00168 #define OCR1AH  _SFR_IO8(0x2B)
00169 
00170 /* Timer/Counter1 */
00171 #define TCNT1   _SFR_IO16(0x2C)
00172 #define TCNT1L  _SFR_IO8(0x2C)
00173 #define TCNT1H  _SFR_IO8(0x2D)
00174 
00175 /* Timer/Counter1 Control Register B */
00176 #define TCCR1B  _SFR_IO8(0x2E)
00177 
00178 /* Timer/Counter1 Control Register A */
00179 #define TCCR1A  _SFR_IO8(0x2F)
00180 
00181 /* Special Function IO Register */
00182 #define SFIOR   _SFR_IO8(0x30)
00183 
00184 /* Timer/Counter0 Output Compare Register */
00185 #define OCR0    _SFR_IO8(0x31)
00186 
00187 /* Timer/Counter0 (8-bit) */
00188 #define TCNT0   _SFR_IO8(0x32)
00189 
00190 /* Timer/Counter0 Control Register */
00191 #define TCCR0   _SFR_IO8(0x33)
00192 
00193 /* MCU general Status Register */
00194 #define MCUSR   _SFR_IO8(0x34)
00195 
00196 /* MCU general Control Register */
00197 #define MCUCR   _SFR_IO8(0x35)
00198 
00199 /* Extended MCU general Control Register */
00200 #define EMCUCR  _SFR_IO8(0x36)
00201 
00202 /* Store Program Memory Control Register */
00203 #define SPMCR   _SFR_IO8(0x37)
00204 
00205 /* Timer/Counter Interrupt Flag Register */
00206 #define TIFR    _SFR_IO8(0x38)
00207 
00208 /* Timer/Counter Interrupt MaSK Register */
00209 #define TIMSK   _SFR_IO8(0x39)
00210 
00211 /* General Interrupt Flag Register */
00212 #define GIFR    _SFR_IO8(0x3A)
00213 
00214 /* General Interrupt MaSK register */
00215 #define GIMSK   _SFR_IO8(0x3B)
00216 
00217 /* 0x3C reserved */
00218 
00219 /* Stack Pointer */
00220 #define SP      _SFR_IO16(0x3D)
00221 #define SPL     _SFR_IO8(0x3D)
00222 #define SPH     _SFR_IO8(0x3E)
00223 
00224 /* Status REGister */
00225 #define SREG    _SFR_IO8(0x3F)
00226 
00227 /* Interrupt vectors */
00228 
00229 #define SIG_INTERRUPT0          _VECTOR(1)
00230 #define SIG_INTERRUPT1          _VECTOR(2)
00231 #define SIG_INTERRUPT2          _VECTOR(3)
00232 #define SIG_OUTPUT_COMPARE2     _VECTOR(4)
00233 #define SIG_OVERFLOW2           _VECTOR(5)
00234 #define SIG_INPUT_CAPTURE1      _VECTOR(6)
00235 #define SIG_OUTPUT_COMPARE1A    _VECTOR(7)
00236 #define SIG_OUTPUT_COMPARE1B    _VECTOR(8)
00237 #define SIG_OVERFLOW1           _VECTOR(9)
00238 #define SIG_OUTPUT_COMPARE0     _VECTOR(10)
00239 #define SIG_OVERFLOW0           _VECTOR(11)
00240 #define SIG_SPI                 _VECTOR(12)
00241 #define SIG_UART0_RECV          _VECTOR(13)
00242 #define SIG_UART1_RECV          _VECTOR(14)
00243 #define SIG_UART0_DATA          _VECTOR(15)
00244 #define SIG_UART1_DATA          _VECTOR(16)
00245 #define SIG_UART0_TRANS         _VECTOR(17)
00246 #define SIG_UART1_TRANS         _VECTOR(18)
00247 #define SIG_EEPROM_READY        _VECTOR(19)
00248 #define SIG_COMPARATOR          _VECTOR(20)
00249 
00250 #define _VECTORS_SIZE 84
00251 
00252 /* Bit numbers */
00253 
00254 /* GIMSK */
00255 #define INT1    7
00256 #define INT0    6
00257 #define INT2    5
00258 
00259 /* GIFR */
00260 #define INTF1   7
00261 #define INTF0   6
00262 #define INTF2   5
00263 
00264 /* TIMSK */
00265 #define TOIE1   7
00266 #define OCIE1A  6
00267 #define OCIE1B  5
00268 #define TOIE2   4
00269 #define TICIE1  3
00270 #define OCIE2   2
00271 #define TOIE0   1
00272 #define OCIE0   0
00273 
00274 /* TIFR */
00275 #define TOV1    7
00276 #define OCF1A   6
00277 #define OCF1B   5
00278 #define TOV2    4
00279 #define ICF1    3
00280 #define OCF2    2
00281 #define TOV0    1
00282 #define OCF0    0
00283 
00284 /* MCUCR */
00285 #define SRE     7
00286 #define SRW10   6
00287 #define SE      5
00288 #define SM1     4
00289 #define ISC11   3
00290 #define ISC10   2
00291 #define ISC01   1
00292 #define ISC00   0
00293 
00294 /* EMCUCR */
00295 #define SM0     7
00296 #define SRL2    6
00297 #define SRL1    5
00298 #define SRL0    4
00299 #define SRW01   3
00300 #define SRW00   2
00301 #define SRW11   1
00302 #define ISC2    0
00303 
00304 /* SPMCR */
00305 #define BLBSET  3
00306 #define PGWRT   2
00307 #define PGERS   1
00308 #define SPMEN   0
00309 
00310 /* SFIOR */
00311 #define PSR2    1
00312 #define PSR10   0
00313 
00314 /* TCCR0 */
00315 #define FOC0    7
00316 #define PWM0    6
00317 #define COM01   5
00318 #define COM00   4
00319 #define CTC0    3
00320 #define CS02    2
00321 #define CS01    1
00322 #define CS00    0
00323 
00324 /* TCCR2 */
00325 #define FOC2    7
00326 #define PWM2    6
00327 #define COM21   5
00328 #define COM20   4
00329 #define CTC2    3
00330 #define CS22    2
00331 #define CS21    1
00332 #define CS20    0
00333 
00334 /* ASSR */
00335 #define AS2     3
00336 #define TCN2UB  2
00337 #define OCR2UB  1
00338 #define TCR2UB  0
00339 
00340 /* TCCR1A */
00341 #define COM1A1  7
00342 #define COM1A0  6
00343 #define COM1B1  5
00344 #define COM1B0  4
00345 #define FOC1A   3
00346 #define FOC1B   2
00347 #define PWM11   1
00348 #define PWM10   0
00349 
00350 /* TCCR1B */
00351 #define ICNC1   7
00352 #define ICES1   6
00353 #define CTC1    3
00354 #define CS12    2
00355 #define CS11    1
00356 #define CS10    0
00357 
00358 /* WDTCR */
00359 #define WDTOE   4
00360 #define WDE     3
00361 #define WDP2    2
00362 #define WDP1    1
00363 #define WDP0    0
00364 
00365 /* EECR */
00366 #define EERIE   3
00367 #define EEMWE   2
00368 #define EEWE    1
00369 #define EERE    0
00370 
00371 /* PORTA */
00372 #define PA7     7
00373 #define PA6     6
00374 #define PA5     5
00375 #define PA4     4
00376 #define PA3     3
00377 #define PA2     2
00378 #define PA1     1
00379 #define PA0     0
00380 
00381 /* DDRA */
00382 #define DDA7    7
00383 #define DDA6    6
00384 #define DDA5    5
00385 #define DDA4    4
00386 #define DDA3    3
00387 #define DDA2    2
00388 #define DDA1    1
00389 #define DDA0    0
00390 
00391 /* PINA */
00392 #define PINA7   7
00393 #define PINA6   6
00394 #define PINA5   5
00395 #define PINA4   4
00396 #define PINA3   3
00397 #define PINA2   2
00398 #define PINA1   1
00399 #define PINA0   0
00400 
00401 /*
00402    PB7 = SCK
00403    PB6 = MISO
00404    PB5 = MOSI
00405    PB4 = SS#
00406    PB3 = TXD1 / AIN1
00407    PB2 = RXD1 / AIN0
00408    PB1 = OC2 / T1
00409    PB0 = OC0 / T0
00410  */
00411 
00412 /* PORTB */
00413 #define PB7     7
00414 #define PB6     6
00415 #define PB5     5
00416 #define PB4     4
00417 #define PB3     3
00418 #define PB2     2
00419 #define PB1     1
00420 #define PB0     0
00421 
00422 /* DDRB */
00423 #define DDB7    7
00424 #define DDB6    6
00425 #define DDB5    5
00426 #define DDB4    4
00427 #define DDB3    3
00428 #define DDB2    2
00429 #define DDB1    1
00430 #define DDB0    0
00431 
00432 /* PINB */
00433 #define PINB7   7
00434 #define PINB6   6
00435 #define PINB5   5
00436 #define PINB4   4
00437 #define PINB3   3
00438 #define PINB2   2
00439 #define PINB1   1
00440 #define PINB0   0
00441 
00442 /* PORTC */
00443 #define PC7      7
00444 #define PC6      6
00445 #define PC5      5
00446 #define PC4      4
00447 #define PC3      3
00448 #define PC2      2
00449 #define PC1      1
00450 #define PC0      0
00451 
00452 /* DDRC */
00453 #define DDC7    7
00454 #define DDC6    6
00455 #define DDC5    5
00456 #define DDC4    4
00457 #define DDC3    3
00458 #define DDC2    2
00459 #define DDC1    1
00460 #define DDC0    0
00461 
00462 /* PINC */
00463 #define PINC7   7
00464 #define PINC6   6
00465 #define PINC5   5
00466 #define PINC4   4
00467 #define PINC3   3
00468 #define PINC2   2
00469 #define PINC1   1
00470 #define PINC0   0
00471 
00472 /*
00473    PD7 = RD#
00474    PD6 = WR#
00475    PD5 = TOSC2 / OC1A
00476    PD4 = TOSC1
00477    PD3 = INT1
00478    PD2 = INT0
00479    PD1 = TXD0
00480    PD0 = RXD0
00481  */
00482 
00483 /* PORTD */
00484 #define PD7      7
00485 #define PD6      6
00486 #define PD5      5
00487 #define PD4      4
00488 #define PD3      3
00489 #define PD2      2
00490 #define PD1      1
00491 #define PD0      0
00492 
00493 /* DDRD */
00494 #define DDD7    7
00495 #define DDD6    6
00496 #define DDD5    5
00497 #define DDD4    4
00498 #define DDD3    3
00499 #define DDD2    2
00500 #define DDD1    1
00501 #define DDD0    0
00502 
00503 /* PIND */
00504 #define PIND7   7
00505 #define PIND6   6
00506 #define PIND5   5
00507 #define PIND4   4
00508 #define PIND3   3
00509 #define PIND2   2
00510 #define PIND1   1
00511 #define PIND0   0
00512 
00513 /*
00514    PE2 = ALE
00515    PE1 = OC1B
00516    PE0 = ICP / INT2
00517  */
00518 
00519 /* PORTE */
00520 #define PE2     2
00521 #define PE1     1
00522 #define PE0     0
00523 
00524 /* DDRE */
00525 #define DDE2    2
00526 #define DDE1    1
00527 #define DDE0    0
00528 
00529 /* PINE */
00530 #define PINE2   2
00531 #define PINE1   1
00532 #define PINE0   0
00533 
00534 /* SPSR */
00535 #define SPIF    7
00536 #define WCOL    6
00537 #define SPI2X   0
00538 
00539 /* SPCR */
00540 #define SPIE    7
00541 #define SPE     6
00542 #define DORD    5
00543 #define MSTR    4
00544 #define CPOL    3
00545 #define CPHA    2
00546 #define SPR1    1
00547 #define SPR0    0
00548 
00549 /* UCSR0A, UCSR1A */
00550 #define RXC     7
00551 #define TXC     6
00552 #define UDRE    5
00553 #define FE      4
00554 #define DOR     3
00555 #define U2X     1
00556 #define MPCM    0
00557 
00558 /* UCSR0B, UCSR1B */
00559 #define RXCIE   7
00560 #define TXCIE   6
00561 #define UDRIE   5
00562 #define RXEN    4
00563 #define TXEN    3
00564 #define CHR9    2
00565 #define RXB8    1
00566 #define TXB8    0
00567 
00568 /* ACSR */
00569 #define ACD     7
00570 #define AINBG   6
00571 #define ACO     5
00572 #define ACI     4
00573 #define ACIE    3
00574 #define ACIC    2
00575 #define ACIS1   1
00576 #define ACIS0   0
00577 
00578 /* Pointer registers (same for all AVR devices so far) */
00579 #define XL r26
00580 #define XH r27
00581 #define YL r28
00582 #define YH r29
00583 #define ZL r30
00584 #define ZH r31
00585 
00586 /* Last memory addresses */
00587 #define RAMEND          0x45F
00588 #define XRAMEND         0xFFFF
00589 #define E2END           0x1FF
00590 #define FLASHEND        0x3FFF
00591 
00592 #endif /* _AVR_IOM161_H_ */

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