1
/* Copyright (c) 2004,2005, Theodore A. Roth
2
Copyright (c) 2007 Anatoly Sokolov
5
Redistribution and use in source and binary forms, with or without
6
modification, are permitted provided that the following conditions are met:
8
* Redistributions of source code must retain the above copyright
9
notice, this list of conditions and the following disclaimer.
11
* Redistributions in binary form must reproduce the above copyright
12
notice, this list of conditions and the following disclaimer in
13
the documentation and/or other materials provided with the
16
* Neither the name of the copyright holders nor the names of
17
contributors may be used to endorse or promote products derived
18
from this software without specific prior written permission.
20
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
POSSIBILITY OF SUCH DAMAGE. */
32
/* $Id: iomx8p.h,v 1.1.2.2 2007/10/25 12:24:32 aesok Exp $ */
34
/* avr/iomx8p.h - definitions for ATmega48P, ATmega88P, ATmega168P and ATmega238P */
36
#ifndef _AVR_IOMX8P_H_
37
#define _AVR_IOMX8P_H_ 1
39
/* This file should only be included from <avr/io.h>, never directly. */
42
# error "Include <avr/io.h> instead of this file."
46
# define _AVR_IOXXX_H_ "iomx8p.h"
48
# error "Attempt to include more than one <avr/ioXXX.h> file."
55
#define PINB _SFR_IO8 (0x03)
66
#define DDRB _SFR_IO8 (0x04)
77
#define PORTB _SFR_IO8 (0x05)
90
#define PINC _SFR_IO8 (0x06)
100
#define DDRC _SFR_IO8 (0x07)
110
#define PORTC _SFR_IO8 (0x08)
122
#define PIND _SFR_IO8 (0x09)
133
#define DDRD _SFR_IO8 (0x0A)
144
#define PORTD _SFR_IO8 (0x0B)
155
#define TIFR0 _SFR_IO8 (0x15)
161
#define TIFR1 _SFR_IO8 (0x16)
168
#define TIFR2 _SFR_IO8 (0x17)
174
#define PCIFR _SFR_IO8 (0x1B)
180
#define EIFR _SFR_IO8 (0x1C)
185
#define EIMSK _SFR_IO8 (0x1D)
190
#define GPIOR0 _SFR_IO8 (0x1E)
192
#define EECR _SFR_IO8(0x1F)
193
/* EECT - EEPROM Control Register */
201
#define EEDR _SFR_IO8(0X20)
203
/* Combine EEARL and EEARH */
204
#define EEAR _SFR_IO16(0x21)
205
#define EEARL _SFR_IO8(0x21)
206
#define EEARH _SFR_IO8(0X22)
208
Even though EEARH is not used by the mega48, the EEAR8 bit in the register
209
must be written to 0, according to the datasheet, hence the EEARH register
210
must be defined for the mega48.
212
/* 6-char sequence denoting where to find the EEPROM registers in memory space.
213
Adresses denoted in hex syntax with uppercase letters. Used by the EEPROM
215
First two letters: EECR address.
216
Second two letters: EEDR address.
217
Last two letters: EEAR address. */
218
#define __EEPROM_REG_LOCATIONS__ 1F2021
221
#define GTCCR _SFR_IO8 (0x23)
227
#define TCCR0A _SFR_IO8 (0x24)
236
#define TCCR0B _SFR_IO8 (0x25)
245
#define TCNT0 _SFR_IO8 (0x26)
246
#define OCR0A _SFR_IO8 (0x27)
247
#define OCR0B _SFR_IO8 (0x28)
249
#define GPIOR1 _SFR_IO8 (0x2A)
250
#define GPIOR2 _SFR_IO8 (0x2B)
252
#define SPCR _SFR_IO8 (0x2C)
263
#define SPSR _SFR_IO8 (0x2D)
269
#define SPDR _SFR_IO8 (0x2E)
271
#define ACSR _SFR_IO8 (0x30)
282
#define MONDR _SFR_IO8 (0x31)
284
#define SMCR _SFR_IO8 (0x33)
291
#define MCUSR _SFR_IO8 (0x34)
298
#define MCUCR _SFR_IO8 (0x35)
306
#define SPMCSR _SFR_IO8 (0x37)
309
#if defined (__AVR_ATmega88__) || defined (__AVR_ATmega168__)
319
/* 0x3D..0x3E SP [defined in <avr/io.h>] */
320
/* 0x3F SREG [defined in <avr/io.h>] */
322
#define WDTCSR _SFR_MEM8 (0x60)
333
#define CLKPR _SFR_MEM8 (0x61)
341
#define PRR _SFR_MEM8 (0x64)
351
#define OSCCAL _SFR_MEM8 (0x66)
353
#define PCICR _SFR_MEM8 (0x68)
359
#define EICRA _SFR_MEM8 (0x69)
366
#define PCMSK0 _SFR_MEM8 (0x6B)
377
#define PCMSK1 _SFR_MEM8 (0x6C)
387
#define PCMSK2 _SFR_MEM8 (0x6D)
398
#define TIMSK0 _SFR_MEM8 (0x6E)
404
#define TIMSK1 _SFR_MEM8 (0x6F)
411
#define TIMSK2 _SFR_MEM8 (0x70)
417
#ifndef __ASSEMBLER__
418
#define ADC _SFR_MEM16 (0x78)
420
#define ADCW _SFR_MEM16 (0x78)
421
#define ADCL _SFR_MEM8 (0x78)
422
#define ADCH _SFR_MEM8 (0x79)
424
#define ADCSRA _SFR_MEM8 (0x7A)
435
#define ADCSRB _SFR_MEM8 (0x7B)
442
#define ADMUX _SFR_MEM8 (0x7C)
452
#define DIDR0 _SFR_MEM8 (0x7E)
461
#define DIDR1 _SFR_MEM8 (0x7F)
466
#define TCCR1A _SFR_MEM8 (0x80)
475
#define TCCR1B _SFR_MEM8 (0x81)
485
#define TCCR1C _SFR_MEM8 (0x82)
490
#define TCNT1 _SFR_MEM16 (0x84)
491
#define TCNT1L _SFR_MEM8 (0x84)
492
#define TCNT1H _SFR_MEM8 (0x85)
494
#define ICR1 _SFR_MEM16 (0x86)
495
#define ICR1L _SFR_MEM8 (0x86)
496
#define ICR1H _SFR_MEM8 (0x87)
498
#define OCR1A _SFR_MEM16 (0x88)
499
#define OCR1AL _SFR_MEM8 (0x88)
500
#define OCR1AH _SFR_MEM8 (0x89)
502
#define OCR1B _SFR_MEM16 (0x8A)
503
#define OCR1BL _SFR_MEM8 (0x8A)
504
#define OCR1BH _SFR_MEM8 (0x8B)
506
#define TCCR2A _SFR_MEM8 (0xB0)
515
#define TCCR2B _SFR_MEM8 (0xB1)
524
#define TCNT2 _SFR_MEM8 (0xB2)
525
#define OCR2A _SFR_MEM8 (0xB3)
526
#define OCR2B _SFR_MEM8 (0xB4)
528
#define ASSR _SFR_MEM8 (0xB6)
538
#define TWBR _SFR_MEM8 (0xB8)
540
#define TWSR _SFR_MEM8 (0xB9)
550
#define TWAR _SFR_MEM8 (0xBA)
561
#define TWDR _SFR_MEM8 (0xBB)
563
#define TWCR _SFR_MEM8 (0xBC)
573
#define TWAMR _SFR_MEM8 (0xBD)
583
#define UCSR0A _SFR_MEM8 (0xC0)
594
#define UCSR0B _SFR_MEM8 (0xC1)
605
#define UCSR0C _SFR_MEM8 (0xC2)
618
#define UBRR0 _SFR_MEM16 (0xC4)
619
#define UBRR0L _SFR_MEM8 (0xC4)
620
#define UBRR0H _SFR_MEM8 (0xC5)
621
#define UDR0 _SFR_MEM8 (0xC6)
623
/* Interrupt vectors */
625
/* External Interrupt Request 0 */
626
#define INT0_vect _VECTOR(1)
627
#define SIG_INTERRUPT0 _VECTOR(1)
629
/* External Interrupt Request 1 */
630
#define INT1_vect _VECTOR(2)
631
#define SIG_INTERRUPT1 _VECTOR(2)
633
/* Pin Change Interrupt Request 0 */
634
#define PCINT0_vect _VECTOR(3)
635
#define SIG_PIN_CHANGE0 _VECTOR(3)
637
/* Pin Change Interrupt Request 0 */
638
#define PCINT1_vect _VECTOR(4)
639
#define SIG_PIN_CHANGE1 _VECTOR(4)
641
/* Pin Change Interrupt Request 1 */
642
#define PCINT2_vect _VECTOR(5)
643
#define SIG_PIN_CHANGE2 _VECTOR(5)
645
/* Watchdog Time-out Interrupt */
646
#define WDT_vect _VECTOR(6)
647
#define SIG_WATCHDOG_TIMEOUT _VECTOR(6)
649
/* Timer/Counter2 Compare Match A */
650
#define TIMER2_COMPA_vect _VECTOR(7)
651
#define SIG_OUTPUT_COMPARE2A _VECTOR(7)
653
/* Timer/Counter2 Compare Match A */
654
#define TIMER2_COMPB_vect _VECTOR(8)
655
#define SIG_OUTPUT_COMPARE2B _VECTOR(8)
657
/* Timer/Counter2 Overflow */
658
#define TIMER2_OVF_vect _VECTOR(9)
659
#define SIG_OVERFLOW2 _VECTOR(9)
661
/* Timer/Counter1 Capture Event */
662
#define TIMER1_CAPT_vect _VECTOR(10)
663
#define SIG_INPUT_CAPTURE1 _VECTOR(10)
665
/* Timer/Counter1 Compare Match A */
666
#define TIMER1_COMPA_vect _VECTOR(11)
667
#define SIG_OUTPUT_COMPARE1A _VECTOR(11)
669
/* Timer/Counter1 Compare Match B */
670
#define TIMER1_COMPB_vect _VECTOR(12)
671
#define SIG_OUTPUT_COMPARE1B _VECTOR(12)
673
/* Timer/Counter1 Overflow */
674
#define TIMER1_OVF_vect _VECTOR(13)
675
#define SIG_OVERFLOW1 _VECTOR(13)
677
/* TimerCounter0 Compare Match A */
678
#define TIMER0_COMPA_vect _VECTOR(14)
679
#define SIG_OUTPUT_COMPARE0A _VECTOR(14)
681
/* TimerCounter0 Compare Match B */
682
#define TIMER0_COMPB_vect _VECTOR(15)
683
#define SIG_OUTPUT_COMPARE0B _VECTOR(15)
685
/* Timer/Couner0 Overflow */
686
#define TIMER0_OVF_vect _VECTOR(16)
687
#define SIG_OVERFLOW0 _VECTOR(16)
689
/* SPI Serial Transfer Complete */
690
#define SPI_STC_vect _VECTOR(17)
691
#define SIG_SPI _VECTOR(17)
693
/* USART Rx Complete */
694
#define USART_RX_vect _VECTOR(18)
695
#define SIG_USART_RECV _VECTOR(18)
697
/* USART, Data Register Empty */
698
#define USART_UDRE_vect _VECTOR(19)
699
#define SIG_USART_DATA _VECTOR(19)
701
/* USART Tx Complete */
702
#define USART_TX_vect _VECTOR(20)
703
#define SIG_USART_TRANS _VECTOR(20)
705
/* ADC Conversion Complete */
706
#define ADC_vect _VECTOR(21)
707
#define SIG_ADC _VECTOR(21)
710
#define EE_READY_vect _VECTOR(22)
711
#define SIG_EEPROM_READY _VECTOR(22)
713
/* Analog Comparator */
714
#define ANALOG_COMP_vect _VECTOR(23)
715
#define SIG_COMPARATOR _VECTOR(23)
717
/* Two-wire Serial Interface */
718
#define TWI_vect _VECTOR(24)
719
#define SIG_TWI _VECTOR(24)
720
#define SIG_2WIRE_SERIAL _VECTOR(24)
722
/* Store Program Memory Read */
723
#define SPM_READY_vect _VECTOR(25)
724
#define SIG_SPM_READY _VECTOR(25)
726
/* The mega48p and mega88p vector tables are single instruction entries
727
(16 bits per entry for an RJMP) while the mega168p and mega328p tables
728
has double instruction entries (32 bits per entry for a JMP). */
730
#if defined (__AVR_ATmega168P__) || defined(__AVR_ATmega328P__)
731
# define _VECTORS_SIZE 104
733
# define _VECTORS_SIZE 52
736
#endif /* _AVR_IOM8P_H_ */