<!DOCTYPE SimulIDE>

<parts>
  <port name="PORTA" pins="8" outreg="PORTA" inreg="PINA" dirreg="DDRA">
    <interrupt name="PCINT0" mask="PCMSK0"/>
  </port>
  <port name="PORTB" pins="8" outreg="PORTB" inreg="PINB" dirreg="DDRB">
      <extint name="INT2" pin="PORTB2" configbits="ISC20,ISC21"/>
    <interrupt name="PCINT1" mask="PCMSK1"/>
  </port>
  <port name="PORTC" pins="8" outreg="PORTC" inreg="PINC" dirreg="DDRC">
    <interrupt name="PCINT2" mask="PCMSK2"/>
  </port>
  <port name="PORTD" pins="8" outreg="PORTD" inreg="PIND" dirreg="DDRD">
    <extint name="INT0" pin="PORTD2" configbits="ISC00,ISC01"/>
    <extint name="INT1" pin="PORTD3" configbits="ISC10,ISC11"/>
    <interrupt name="PCINT3" mask="PCMSK3"/>
  </port>

  <timer name="TIMER0" type="800" counter="TCNT0" configregsA="TCCR0A" configregsB="TCCR0B"
                       clockpin="PORTB0"
                       interrupt="T0_OVF"
                       prescalers="0,1,8,64,256,1024,EXT_F,EXT_R" 
                       prselect="CS00,CS01,CS02" >
    
    <ocunit name="OC0A" pin="PORTB3" ocreg="OCR0A" bits="COM0A0,COM0A1" interrupt="T0COA" />
    <ocunit name="OC0B" pin="PORTB4" ocreg="OCR0B" bits="COM0B0,COM0B1" interrupt="T0COB" />
  </timer>

  <timer name="TIMER1" type="160" counter="TCNT1L,TCNT1H" configregsA="TCCR1A" configregsB="TCCR1B"
                       clockpin="PORTB1"
                       interrupt="T1_OVF"
                       prescalers="0,1,8,64,256,1024,EXT_F,EXT_R" 
                       prselect="CS10,CS11,CS12" >
    
    <ocunit name="OC1A" pin="PORTD4" ocreg="OCR1AL,OCR1AH" bits="COM1A0,COM1A1" interrupt="T1COA" />
    <ocunit name="OC1B" pin="PORTD5" ocreg="OCR1BL,OCR1BH" bits="COM1B0,COM1B1" interrupt="T1COB" />
    <icunit name="IC1"  pin="PORTD6" icreg="ICR1L,ICR1H"   bits="ICES1,ICNC1"   interrupt="T1CAP" />
  </timer>

  <timer name="TIMER2" type="820" counter="TCNT2" configregsA="TCCR2A" configregsB="TCCR2B"
                       interrupt="T2_OVF"
                       prescalers="0,1,8,32,64,128,256,1024" 
                       prselect="CS20,CS21,CS22" >
    
    <ocunit name="OC2A" pin="PORTD7" ocreg="OCR2A" bits="COM2A0,COM2A1" interrupt="T2COA" />
    <ocunit name="OC2B" pin="PORTD6" ocreg="OCR2B" bits="COM2B0,COM2B1" interrupt="T2COB" />
  </timer>

  <timer name="TIMER3" type="160" counter="TCNT3L,TCNT3H" configregsA="TCCR3A" configregsB="TCCR3B"
                       clockpin="PORTD0" 
                       interrupt="T3_OVF"
                       prescalers="0,1,8,64,256,1024,EXT_F,EXT_R" 
                       prselect="CS30,CS31,CS32" >
    
    <ocunit name="OC3A" pin="PORTB6" ocreg="OCR3AL,OCR3AH" bits="COM3A0,COM3A1" interrupt="T3COA" />
    <ocunit name="OC3B" pin="PORTB7" ocreg="OCR3BL,OCR3BH" bits="COM3B0,COM3B1" interrupt="T3COB" />
  </timer>

  <usart name="USART0" number="1" configregsA="UCSR0A" configregsB="UCSR0B" configregsC="UCSR0C"
                       interrupt="USART0_U">
                     
    <trunit type="tx" pin="PORTD1" register="UDR0" interrupt="USART0_T" />
    <trunit type="rx" pin="PORTD0"                 interrupt="USART0_R" />
  </usart>

  <usart name="USART1" number="2" configregsA="UCSR1A" configregsB="UCSR1B" configregsC="UCSR1C"
                       interrupt="USART1_U">
                     
    <trunit type="tx" pin="PORTD3" register="UDR1" interrupt="USART1_T" />
    <trunit type="rx" pin="PORTD2"                 interrupt="USART1_R" />
  </usart>

  <port name="PORTV" pins="2"/> <!-- Fake Port for aVcc and aRef -->
  <adc name="ADC" type="00" bits="10" dataregs="ADCL,ADCH" configregsA="ADCSRA" configregsB="ADCSRB"
                  multiplex="ADMUX"
                  interrupt="ADC"
                  prescalers="2,2,4,8,16,32,64,128"
                  adcpins="PORTA0,PORTA1,PORTA2,PORTA3,PORTA4,PORTA5,PORTA6,PORTA7"/>

  <twi name="TWI" dataregs="TWDR" addressreg="TWAR" statusreg="TWSR"
                   configregsA="TWCR" configregsB="TWBR"
                   interrupt="TWI"
                   prescalers="1,4,16,64"
                   pins="PORTC1,PORTC0" /><!-- "SDA,SCL" -->

  <spi name="SPI" dataregs="SPDR" statusreg="SPSR" configregsA="SPCR"
                   interrupt="SPI"
                   prescalers="4,16,64,128,2,8,32,64"
                   pins="PORTB5,PORTB6,PORTB7,PORTB4" /><!-- "MOSI,MISO,SCK,SS" -->
    
  <wdt name="WDT00" configregsA="WDTCSR" interrupt="WDT"
                    prescalers="512,256,128,64,32,16,8,4,2,1,1,1,1,1,1,1"/>

  <rom  name="ROM"  dataregs="EEDR" addressreg="EEARL,EEARH" configregsA="EECR"
                    interrupt="EEPR" />

  <comp name="COMP" configregsA="ACSR" configbitsB="AIN0D,AIN1D" 
                    interrupt="ACOMP"
                    pins="PORTB2,PORTB3"/>
</parts>
