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

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

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