1
/* Copyright (c) 2010 Atmel Corporation
4
Redistribution and use in source and binary forms, with or without
5
modification, are permitted provided that the following conditions are met:
7
* Redistributions of source code must retain the above copyright
8
notice, this list of conditions and the following disclaimer.
10
* Redistributions in binary form must reproduce the above copyright
11
notice, this list of conditions and the following disclaimer in
12
the documentation and/or other materials provided with the
15
* Neither the name of the copyright holders nor the names of
16
contributors may be used to endorse or promote products derived
17
from this software without specific prior written permission.
19
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
POSSIBILITY OF SUCH DAMAGE. */
33
/* avr/iotn20.h - definitions for ATtiny20 */
35
/* This file should only be included from <avr/io.h>, never directly. */
38
# error "Include <avr/io.h> instead of this file."
42
# define _AVR_IOXXX_H_ "iotn20.h"
44
# error "Attempt to include more than one <avr/ioXXX.h> file."
48
#ifndef _AVR_ATtiny20_H_
49
#define _AVR_ATtiny20_H_ 1
52
/* Registers and associated bit numbers. */
54
#define PINA _SFR_IO8(0x00)
64
#define DDRA _SFR_IO8(0x01)
74
#define PORTA _SFR_IO8(0x02)
84
#define PUEA _SFR_IO8(0x03)
94
#define PINB _SFR_IO8(0x04)
100
#define DDRB _SFR_IO8(0x05)
106
#define PORTB _SFR_IO8(0x06)
112
#define PUEB _SFR_IO8(0x07)
118
#define PORTCR _SFR_IO8(0x08)
122
#define PCMSK0 _SFR_IO8(0x09)
132
#define PCMSK1 _SFR_IO8(0x0A)
138
#define GIFR _SFR_IO8(0x0B)
143
#define GIMSK _SFR_IO8(0x0C)
148
#define DIDR0 _SFR_IO8(0x0D)
158
#ifndef __ASSEMBLER__
159
#define ADC _SFR_IO16(0x0E)
161
#define ADCW _SFR_IO16(0x0E)
163
#define ADCL _SFR_IO8(0x0E)
173
#define ADCH _SFR_IO8(0x0F)
183
#define ADMUX _SFR_IO8(0x10)
190
#define ADCSRB _SFR_IO8(0x11)
196
#define ADCSRA _SFR_IO8(0x12)
206
#define ACSRB _SFR_IO8(0x13)
211
#define ACSRA _SFR_IO8(0x14)
221
#define OCR0B _SFR_IO8(0x15)
231
#define OCR0A _SFR_IO8(0x16)
241
#define TCNT0 _SFR_IO8(0x17)
251
#define TCCR0B _SFR_IO8(0x18)
259
#define TCCR0A _SFR_IO8(0x19)
267
#define ICR1 _SFR_IO16(0x1A)
269
#define ICR1L _SFR_IO8(0x1A)
279
#define ICR1H _SFR_IO8(0x1B)
289
#define OCR1B _SFR_IO16(0x1C)
291
#define OCR1BL _SFR_IO8(0x1C)
301
#define OCR1BH _SFR_IO8(0x1D)
311
#define OCR1A _SFR_IO16(0x1E)
313
#define OCR1AL _SFR_IO8(0x1E)
323
#define OCR1AH _SFR_IO8(0x1F)
333
#define TCNT1 _SFR_IO16(0x20)
335
#define TCNT1L _SFR_IO8(0x20)
345
#define TCNT1H _SFR_IO8(0x21)
355
#define TCCR1C _SFR_IO8(0x22)
359
#define TCCR1B _SFR_IO8(0x23)
368
#define TCCR1A _SFR_IO8(0x24)
376
#define TIFR _SFR_IO8(0x25)
385
#define TIMSK _SFR_IO8(0x26)
394
#define GTCCR _SFR_IO8(0x27)
398
#define TWSD _SFR_IO8(0x28)
408
#define TWSAM _SFR_IO8(0x29)
418
#define TWSA _SFR_IO8(0x2A)
428
#define TWSSRA _SFR_IO8(0x2B)
438
#define TWSCRB _SFR_IO8(0x2C)
443
#define TWSCRA _SFR_IO8(0x2D)
452
#define SPDR _SFR_IO8(0x2E)
462
#define SPSR _SFR_IO8(0x2F)
467
#define SPCR _SFR_IO8(0x30)
477
#define WDTCSR _SFR_IO8(0x31)
486
#define NVMCSR _SFR_IO8(0x32)
489
#define NVMCMD _SFR_IO8(0x33)
497
#define QTCSR _SFR_IO8(0x34)
499
#define PRR _SFR_IO8(0x35)
506
#define CLKPSR _SFR_IO8(0x36)
512
#define CLKMSR _SFR_IO8(0x37)
516
#define OSCCAL _SFR_IO8(0x39)
526
#define MCUCR _SFR_IO8(0x3A)
535
#define RSTFLR _SFR_IO8(0x3B)
540
#define CCP _SFR_IO8(0x3C)
551
/* Interrupt vectors */
552
/* Vector 0 is the reset vector */
553
#define INT0_vect_num 1
554
#define INT0_vect _VECTOR(1) /* External Interrupt Request 0 */
555
#define PCINT0_vect_num 2
556
#define PCINT0_vect _VECTOR(2) /* Pin Change Interrupt Request 0 */
557
#define PCINT1_vect_num 3
558
#define PCINT1_vect _VECTOR(3) /* Pin Change Interrupt Request 1 */
559
#define WDT_vect_num 4
560
#define WDT_vect _VECTOR(4) /* Watchdog Time-out */
561
#define TIM1_CAPT_vect_num 5
562
#define TIM1_CAPT_vect _VECTOR(5) /* Timer/Counter1 Input Capture */
563
#define TIM1_COMPA_vect_num 6
564
#define TIM1_COMPA_vect _VECTOR(6) /* Timer/Counter1 Compare Match A */
565
#define TIM1_COMPB_vect_num 7
566
#define TIM1_COMPB_vect _VECTOR(7) /* Timer/Counter1 Compare Match B */
567
#define TIM1_OVF_vect_num 8
568
#define TIM1_OVF_vect _VECTOR(8) /* Timer/Counter1 Overflow */
569
#define TIM0_COMPA_vect_num 9
570
#define TIM0_COMPA_vect _VECTOR(9) /* Timer/Counter0 Compare Match A */
571
#define TIM0_COMPB_vect_num 10
572
#define TIM0_COMPB_vect _VECTOR(10) /* Timer/Counter0 Compare Match B */
573
#define TIM0_OVF_vect_num 11
574
#define TIM0_OVF_vect _VECTOR(11) /* Timer/Counter0 Overflow */
575
#define ANA_COMP_vect_num 12
576
#define ANA_COMP_vect _VECTOR(12) /* Analog Comparator */
577
#define ADC_ADC_vect_num 13
578
#define ADC_ADC_vect _VECTOR(13) /* Conversion Complete */
579
#define TWI_SLAVE_vect_num 14
580
#define TWI_SLAVE_vect _VECTOR(14) /* Two-Wire Interface */
581
#define SPI_vect_num 15
582
#define SPI_vect _VECTOR(15) /* Serial Peripheral Interface */
583
#define QTRIP_vect_num 16
584
#define QTRIP_vect _VECTOR(16) /* Touch Sensing */
586
#define _VECTOR_SIZE 2 /* Size of individual vector. */
587
#define _VECTORS_SIZE (17 * _VECTOR_SIZE)
591
#define SPM_PAGESIZE (64)
592
#define RAMSTART (0x40)
593
#define RAMSIZE (128)
594
#define RAMEND (RAMSTART + RAMSIZE - 1)
595
#define XRAMSTART (NA)
597
#define XRAMEND (RAMEND)
599
#define E2PAGESIZE (0)
600
#define FLASHEND (0x7FF)
604
#define FUSE_MEMORY_SIZE 0
608
#define __LOCK_BITS_EXIST
612
#define SIGNATURE_0 0x1E
613
#define SIGNATURE_1 0x91
614
#define SIGNATURE_2 0x0F
617
/* Device Pin Definitions */
618
#define ADC4_DDR DDRCINT
619
#define ADC4_PORT PORTCINT
620
#define ADC4_PIN PINCINT
621
#define ADC4_BIT INT4
623
#define ADC3_DDR DDRCINT
624
#define ADC3_PORT PORTCINT
625
#define ADC3_PIN PINCINT
626
#define ADC3_BIT INT3
628
#define AIN1_DDR DDRCINT
629
#define AIN1_PORT PORTCINT
630
#define AIN1_PIN PINCINT
631
#define AIN1_BIT INT2
633
#define ADC2_DDR DDRCINT
634
#define ADC2_PORT PORTCINT
635
#define ADC2_PIN PINCINT
636
#define ADC2_BIT INT2
638
#define AIN0_DDR DDRCINT
639
#define AIN0_PORT PORTCINT
640
#define AIN0_PIN PINCINT
641
#define AIN0_BIT INT1
643
#define ADC1_DDR DDRCINT
644
#define ADC1_PORT PORTCINT
645
#define ADC1_PIN PINCINT
646
#define ADC1_BIT INT1
648
#define ADC0_DDR DDRCINT
649
#define ADC0_PORT PORTCINT
650
#define ADC0_PIN PINCINT
651
#define ADC0_BIT INT0
653
#define T0_DDR DDRCLKI
654
#define T0_PORT PORTCLKI
655
#define T0_PIN PINCLKI
658
#define TPICLK_DDR DDRCLKI
659
#define TPICLK_PORT PORTCLKI
660
#define TPICLK_PIN PINCLKI
661
#define TPICLK_BIT CLKI
663
#define PCINT8_DDR DDRCLKI
664
#define PCINT8_PORT PORTCLKI
665
#define PCINT8_PIN PINCLKI
666
#define PCINT8_BIT CLKI
668
#define SDA_DDR DDROC1A
669
#define SDA_PORT PORTOC1A
670
#define SDA_PIN PINOC1A
673
#define MOSI_DDR DDROC1A
674
#define MOSI_PORT PORTOC1A
675
#define MOSI_PIN PINOC1A
676
#define MOSI_BIT OC1A
678
#define TPIDATA_DDR DDROC1A
679
#define TPIDATA_PORT PORTOC1A
680
#define TPIDATA_PIN PINOC1A
681
#define TPIDATA_BIT OC1A
683
#define PCINT9_DDR DDROC1A
684
#define PCINT9_PORT PORTOC1A
685
#define PCINT9_PIN PINOC1A
686
#define PCINT9_BIT OC1A
688
#define PCINT11_DDR DDRRESET
689
#define PCINT11_PORT PORTRESET
690
#define PCINT11_PIN PINRESET
691
#define PCINT11_BIT RESET
693
#define OC0A_DDR DDRCKOUT
694
#define OC0A_PORT PORTCKOUT
695
#define OC0A_PIN PINCKOUT
696
#define OC0A_BIT CKOUT
698
#define OC1B_DDR DDRCKOUT
699
#define OC1B_PORT PORTCKOUT
700
#define OC1B_PIN PINCKOUT
701
#define OC1B_BIT CKOUT
703
#define MISO_DDR DDRCKOUT
704
#define MISO_PORT PORTCKOUT
705
#define MISO_PIN PINCKOUT
706
#define MISO_BIT CKOUT
708
#define INT0_DDR DDRCKOUT
709
#define INT0_PORT PORTCKOUT
710
#define INT0_PIN PINCKOUT
711
#define INT0_BIT CKOUT
713
#define PCINT10_DDR DDRCKOUT
714
#define PCINT10_PORT PORTCKOUT
715
#define PCINT10_PIN PINCKOUT
716
#define PCINT10_BIT CKOUT
718
#define OC0B_DDR DDR(ADC
719
#define OC0B_PORT PORT(ADC
720
#define OC0B_PIN PIN(ADC
721
#define OC0B_BIT (ADC7
723
#define ICP1_DDR DDR(ADC
724
#define ICP1_PORT PORT(ADC
725
#define ICP1_PIN PIN(ADC
726
#define ICP1_BIT (ADC7
728
#define T1_DDR DDR(ADC
729
#define T1_PORT PORT(ADC
730
#define T1_PIN PIN(ADC
733
#define SCL_DDR DDR(ADC
734
#define SCL_PORT PORT(ADC
735
#define SCL_PIN PIN(ADC
736
#define SCL_BIT (ADC7
738
#define SCK_DDR DDR(ADC
739
#define SCK_PORT PORT(ADC
740
#define SCK_PIN PIN(ADC
741
#define SCK_BIT (ADC7
743
#define PCINT7_DDR DDR(ADC
744
#define PCINT7_PORT PORT(ADC
745
#define PCINT7_PIN PIN(ADC
746
#define PCINT7_BIT (ADC7
748
#define SS_DDR DDRADC
749
#define SS_PORT PORTADC
750
#define SS_PIN PINADC
753
#define PCINT6_DDR DDRADC
754
#define PCINT6_PORT PORTADC
755
#define PCINT6_PIN PINADC
756
#define PCINT6_BIT ADC6
758
#define PCINT5_DDR DDRADC
759
#define PCINT5_PORT PORTADC
760
#define PCINT5_PIN PINADC
761
#define PCINT5_BIT ADC5
763
#endif /* _AVR_ATtiny20_H_ */