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

iom16.h

00001 /* Copyright (c) 2002, Magnus Johansson
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/iom16.h - definitions for ATmega16 */
00027 
00028 #ifndef _AVR_IOM16_H_
00029 #define _AVR_IOM16_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_ "iom16.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 
00058 #define ADCSR   _SFR_IO8(0x06)
00059 #define ADCSRA  _SFR_IO8(0x06)
00060 
00061 #define ADMUX   _SFR_IO8(0x07)
00062 
00063 /* analog comparator */
00064 #define ACSR    _SFR_IO8(0x08)
00065 
00066 /* USART */
00067 #define UBRRL   _SFR_IO8(0x09)
00068 #define UCSRB   _SFR_IO8(0x0A)
00069 #define UCSRA   _SFR_IO8(0x0B)
00070 #define UDR     _SFR_IO8(0x0C)
00071 
00072 /* SPI */
00073 #define SPCR    _SFR_IO8(0x0D)
00074 #define SPSR    _SFR_IO8(0x0E)
00075 #define SPDR    _SFR_IO8(0x0F)
00076 
00077 /* Port D */
00078 #define PIND    _SFR_IO8(0x10)
00079 #define DDRD    _SFR_IO8(0x11)
00080 #define PORTD   _SFR_IO8(0x12)
00081 
00082 /* Port C */
00083 #define PINC    _SFR_IO8(0x13)
00084 #define DDRC    _SFR_IO8(0x14)
00085 #define PORTC   _SFR_IO8(0x15)
00086 
00087 /* Port B */
00088 #define PINB    _SFR_IO8(0x16)
00089 #define DDRB    _SFR_IO8(0x17)
00090 #define PORTB   _SFR_IO8(0x18)
00091 
00092 /* Port A */
00093 #define PINA    _SFR_IO8(0x19)
00094 #define DDRA    _SFR_IO8(0x1A)
00095 #define PORTA   _SFR_IO8(0x1B)
00096 
00097 /* EEPROM */
00098 #define EECR    _SFR_IO8(0x1C)
00099 #define EEDR    _SFR_IO8(0x1D)
00100 #define EEAR    _SFR_IO16(0x1E)
00101 #define EEARL   _SFR_IO8(0x1E)
00102 #define EEARH   _SFR_IO8(0x1F)
00103 
00104 #define UCSRC   _SFR_IO8(0x20)
00105 #define UBRRH   _SFR_IO8(0x20)
00106 
00107 #define WDTCR   _SFR_IO8(0x21)
00108 #define ASSR    _SFR_IO8(0x22)
00109 
00110 /* Timer 2 */
00111 #define OCR2    _SFR_IO8(0x23)
00112 #define TCNT2   _SFR_IO8(0x24)
00113 #define TCCR2   _SFR_IO8(0x25)
00114 
00115 /* Timer 1 */
00116 #define ICR1    _SFR_IO16(0x26)
00117 #define ICR1L   _SFR_IO8(0x26)
00118 #define ICR1H   _SFR_IO8(0x27)
00119 #define OCR1B   _SFR_IO16(0x28)
00120 #define OCR1BL  _SFR_IO8(0x28)
00121 #define OCR1BH  _SFR_IO8(0x29)
00122 #define OCR1A   _SFR_IO16(0x2A)
00123 #define OCR1AL  _SFR_IO8(0x2A)
00124 #define OCR1AH  _SFR_IO8(0x2B)
00125 #define TCNT1   _SFR_IO16(0x2C)
00126 #define TCNT1L  _SFR_IO8(0x2C)
00127 #define TCNT1H  _SFR_IO8(0x2D)
00128 #define TCCR1B  _SFR_IO8(0x2E)
00129 #define TCCR1A  _SFR_IO8(0x2F)
00130 
00131 #define SFIOR   _SFR_IO8(0x30)
00132 
00133 #define OSCCAL  _SFR_IO8(0x31)
00134 #define OCDR    _SFR_IO8(0x31)
00135 
00136 /* Timer 0 */
00137 #define TCNT0   _SFR_IO8(0x32)
00138 #define TCCR0   _SFR_IO8(0x33)
00139 
00140 #define MCUCSR  _SFR_IO8(0x34)
00141 #define MCUCR   _SFR_IO8(0x35)
00142 
00143 #define TWCR    _SFR_IO8(0x36)
00144 
00145 #define SPMCR   _SFR_IO8(0x37)
00146 
00147 #define TIFR    _SFR_IO8(0x38)
00148 #define TIMSK   _SFR_IO8(0x39)
00149 
00150 #define GIFR    _SFR_IO8(0x3A)
00151 #define GIMSK   _SFR_IO8(0x3B)
00152 #define GICR    _SFR_IO8(0x3B)
00153 
00154 #define OCR0    _SFR_IO8(0x3C)
00155 
00156 #define SP      _SFR_IO16(0x3D)
00157 #define SPL     _SFR_IO8(0x3D)
00158 #define SPH     _SFR_IO8(0x3E)
00159 #define SREG    _SFR_IO8(0x3F)
00160 
00161 /* Interrupt vectors */
00162 
00163 #define SIG_INTERRUPT0          _VECTOR(1)
00164 #define SIG_INTERRUPT1          _VECTOR(2)
00165 #define SIG_OUTPUT_COMPARE2     _VECTOR(3)
00166 #define SIG_OVERFLOW2           _VECTOR(4)
00167 #define SIG_INPUT_CAPTURE1      _VECTOR(5)
00168 #define SIG_OUTPUT_COMPARE1A    _VECTOR(6)
00169 #define SIG_OUTPUT_COMPARE1B    _VECTOR(7)
00170 #define SIG_OVERFLOW1           _VECTOR(8)
00171 #define SIG_OVERFLOW0           _VECTOR(9)
00172 #define SIG_SPI                 _VECTOR(10)
00173 #define SIG_UART_RECV           _VECTOR(11)
00174 #define SIG_UART_DATA           _VECTOR(12)
00175 #define SIG_UART_TRANS          _VECTOR(13)
00176 #define SIG_ADC                 _VECTOR(14)
00177 #define SIG_EEPROM_READY        _VECTOR(15)
00178 #define SIG_COMPARATOR          _VECTOR(16)
00179 #define SIG_2WIRE_SERIAL        _VECTOR(17)
00180 #define SIG_INTERRUPT2          _VECTOR(18)
00181 #define SIG_OUTPUT_COMPARE0     _VECTOR(19)
00182 #define SIG_SPM_READY           _VECTOR(20)
00183 
00184 #define _VECTORS_SIZE 84
00185 
00186 /* Bit numbers */
00187 
00188 /* GIMSK (GICR) */
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 RWWSB   6
00223 /* bit 5 reserved */
00224 #define RWWSRE  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 /* bit 1 reserved (TWI_TST?) */
00238 #define TWIE    0
00239 
00240 /* TWAR */
00241 #define TWGCE   0
00242 
00243 /* TWSR */
00244 #define TWS7    7
00245 #define TWS6    6
00246 #define TWS5    5
00247 #define TWS4    4
00248 #define TWS3    3
00249 /* bit 2 reserved */
00250 #define TWPS1   1
00251 #define TWPS0   0
00252 
00253 /* MCUCR */
00254 #define SM2     7
00255 #define SE      6
00256 #define SM1     5
00257 #define SM0     4
00258 #define ISC11   3
00259 #define ISC10   2
00260 #define ISC01   1
00261 #define ISC00   0
00262 
00263 /* MCUCSR */
00264 #define JTD     7
00265 #define ISC2    6
00266 /* bit 5 reserved */
00267 #define JTRF    4
00268 #define WDRF    3
00269 #define BORF    2
00270 #define EXTRF   1
00271 #define PORF    0
00272 
00273 /* SFIOR */
00274 #define ADTS2   7
00275 #define ADTS1   6
00276 #define ADTS0   5
00277 #define ADHSM   4
00278 #define ACME    3
00279 #define PUD     2
00280 #define PSR2    1
00281 #define PSR10   0
00282 
00283 /* TCCR0 */
00284 #define FOC0    7
00285 #define WGM00   6
00286 #define COM01   5
00287 #define COM00   4
00288 #define WGM01   3
00289 #define CS02    2
00290 #define CS01    1
00291 #define CS00    0
00292 
00293 /* TCCR2 */
00294 #define FOC2    7
00295 #define WGM20   6
00296 #define COM21   5
00297 #define COM20   4
00298 #define WGM21   3
00299 #define CS22    2
00300 #define CS21    1
00301 #define CS20    0
00302 
00303 /* ASSR */
00304 /* bits 7-4 reserved */
00305 #define AS2     3
00306 #define TCN2UB  2
00307 #define OCR2UB  1
00308 #define TCR2UB  0
00309 
00310 /* TCCR1A */
00311 #define COM1A1  7
00312 #define COM1A0  6
00313 #define COM1B1  5
00314 #define COM1B0  4
00315 #define FOC1A   3
00316 #define FOC1B   2
00317 #define WGM11   1
00318 #define WGM10   0
00319 
00320 /* TCCR1B */
00321 #define ICNC1   7
00322 #define ICES1   6
00323 /* bit 5 reserved */
00324 #define WGM13   4
00325 #define WGM12   3
00326 #define CS12    2
00327 #define CS11    1
00328 #define CS10    0
00329 
00330 /* WDTCR */
00331 /* bits 7-5 reserved */
00332 #define WDTOE   4
00333 #define WDE     3
00334 #define WDP2    2
00335 #define WDP1    1
00336 #define WDP0    0
00337 
00338 /* UBRRH */
00339 #define URSEL   7
00340 
00341 /* UCSRC */
00342 #define URSEL   7
00343 #define UMSEL   6
00344 #define UPM1    5
00345 #define UPM0    4
00346 #define USBS    3
00347 #define UCSZ1   2
00348 #define UCSZ0   1
00349 #define UCPOL   0
00350 
00351 /* EECR */
00352 /* bits 7-4 reserved */
00353 #define EERIE   3
00354 #define EEMWE   2
00355 #define EEWE    1
00356 #define EERE    0
00357 
00358 
00359 /* PORTA */
00360 #define PA7     7
00361 #define PA6     6
00362 #define PA5     5
00363 #define PA4     4
00364 #define PA3     3
00365 #define PA2     2
00366 #define PA1     1
00367 #define PA0     0
00368 
00369 /* DDRB */
00370 #define DDA7    7
00371 #define DDA6    6
00372 #define DDA5    5
00373 #define DDA4    4
00374 #define DDA3    3
00375 #define DDA2    2
00376 #define DDA1    1
00377 #define DDA0    0
00378 
00379 /* PINB */
00380 #define PINA7   7
00381 #define PINA6   6
00382 #define PINA5   5
00383 #define PINA4   4
00384 #define PINA3   3
00385 #define PINA2   2
00386 #define PINA1   1
00387 #define PINA0   0
00388 
00389 /* PORTB */
00390 #define PB7     7
00391 #define PB6     6
00392 #define PB5     5
00393 #define PB4     4
00394 #define PB3     3
00395 #define PB2     2
00396 #define PB1     1
00397 #define PB0     0
00398 
00399 /* DDRB */
00400 #define DDB7    7
00401 #define DDB6    6
00402 #define DDB5    5
00403 #define DDB4    4
00404 #define DDB3    3
00405 #define DDB2    2
00406 #define DDB1    1
00407 #define DDB0    0
00408 
00409 /* PINB */
00410 #define PINB7   7
00411 #define PINB6   6
00412 #define PINB5   5
00413 #define PINB4   4
00414 #define PINB3   3
00415 #define PINB2   2
00416 #define PINB1   1
00417 #define PINB0   0
00418 
00419 /* PORTC */
00420 #define PC7     7
00421 #define PC6     6
00422 #define PC5     5
00423 #define PC4     4
00424 #define PC3     3
00425 #define PC2     2
00426 #define PC1     1
00427 #define PC0     0
00428 
00429 /* DDRC */
00430 #define DDC7    7
00431 #define DDC6    6
00432 #define DDC5    5
00433 #define DDC4    4
00434 #define DDC3    3
00435 #define DDC2    2
00436 #define DDC1    1
00437 #define DDC0    0
00438 
00439 /* PINC */
00440 #define PINC7   7
00441 #define PINC6   6
00442 #define PINC5   5
00443 #define PINC4   4
00444 #define PINC3   3
00445 #define PINC2   2
00446 #define PINC1   1
00447 #define PINC0   0
00448 
00449 /* PORTD */
00450 #define PD7     7
00451 #define PD6     6
00452 #define PD5     5
00453 #define PD4     4
00454 #define PD3     3
00455 #define PD2     2
00456 #define PD1     1
00457 #define PD0     0
00458 
00459 /* DDRD */
00460 #define DDD7    7
00461 #define DDD6    6
00462 #define DDD5    5
00463 #define DDD4    4
00464 #define DDD3    3
00465 #define DDD2    2
00466 #define DDD1    1
00467 #define DDD0    0
00468 
00469 /* PIND */
00470 #define PIND7   7
00471 #define PIND6   6
00472 #define PIND5   5
00473 #define PIND4   4
00474 #define PIND3   3
00475 #define PIND2   2
00476 #define PIND1   1
00477 #define PIND0   0
00478 
00479 /* SPSR */
00480 #define SPIF    7
00481 #define WCOL    6
00482 #define SPI2X   0
00483 
00484 /* SPCR */
00485 #define SPIE    7
00486 #define SPE     6
00487 #define DORD    5
00488 #define MSTR    4
00489 #define CPOL    3
00490 #define CPHA    2
00491 #define SPR1    1
00492 #define SPR0    0
00493 
00494 /* UCSRA */
00495 #define RXC     7
00496 #define TXC     6
00497 #define UDRE    5
00498 #define FE      4
00499 #define DOR     3
00500 #define PE      2
00501 #define U2X     1
00502 #define MPCM    0
00503 
00504 /* UCSRB */
00505 #define RXCIE   7
00506 #define TXCIE   6
00507 #define UDRIE   5
00508 #define RXEN    4
00509 #define TXEN    3
00510 #define UCSZ2   2
00511 #define RXB8    1
00512 #define TXB8    0
00513 
00514 /* ACSR */
00515 #define ACD     7
00516 #define ACBG    6
00517 #define ACO     5
00518 #define ACI     4
00519 #define ACIE    3
00520 #define ACIC    2
00521 #define ACIS1   1
00522 #define ACIS0   0
00523 
00524 /* ADCSR (ADCSRA) */
00525 #define ADEN    7
00526 #define ADSC    6
00527 #define ADATE   5
00528 #define ADIF    4
00529 #define ADIE    3
00530 #define ADPS2   2
00531 #define ADPS1   1
00532 #define ADPS0   0
00533 
00534 /* ADMUX */
00535 #define REFS1   7
00536 #define REFS0   6
00537 #define ADLAR   5
00538 #define MUX4    4
00539 #define MUX3    3
00540 #define MUX2    2
00541 #define MUX1    1
00542 #define MUX0    0
00543 
00544 /* Pointer registers (same for all AVR devices so far) */
00545 #define XL r26
00546 #define XH r27
00547 #define YL r28
00548 #define YH r29
00549 #define ZL r30
00550 #define ZH r31
00551 
00552 /* Last memory addresses */
00553 #define RAMEND          0x45F
00554 #define XRAMEND         0x45F
00555 #define E2END           0x1FF
00556 #define FLASHEND        0x3FFF
00557 
00558 #endif /* _AVR_IOM16_H_ */

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