<!DOCTYPE SimulIDE>

<parts>
  <port name="PORTB" pins="8" outreg="PORTB" inreg="PINB" dirreg="DDRB">
    <interrupt name="PCINT0" mask="PCMSK0"/>
  </port>

  <port name="PORTC" pins="7" outreg="PORTC" inreg="PINC" dirreg="DDRC">
    <interrupt name="PCINT1" mask="PCMSK1"/>
  </port>

  <port name="PORTD" pins="8" outreg="PORTD" inreg="PIND" dirreg="DDRD">
    <interrupt name="PCINT2" mask="PCMSK2"/>
    <extint    name="INT0" pin="PORTD2" configbits="ISC00,ISC01"/>
    <extint    name="INT1" pin="PORTD3" configbits="ISC10,ISC11"/>
  </port>

 <port name="PORTE" pins="4" outreg="PORTE" inreg="PINE" dirreg="DDRE">
    <interrupt name="PCINT3" mask="PCMSK3"/>
  </port>

  <timer name="TIMER0" type="800" configregsA="TCCR0A" configregsB="TCCR0B" 
                       counter="TCNT0" 
                       clockpin="PORTD4"
                       interrupt="T0_OVF"
                       prescalers="0,1,8,64,256,1024,EXT_F,EXT_R" prselect="CS00,CS01,CS02" >

    <ocunit name="OC0A" pin="PORTD6" ocreg="OCR0A" bits="COM0A0,COM0A1" interrupt="T0COA" />
    <ocunit name="OC0B" pin="PORTD5" ocreg="OCR0B" bits="COM0B0,COM0B1" interrupt="T0COB" />
  </timer>

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

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

  <timer name="TIMER3" type="160" configregsA="TCCR3A" configregsB="TCCR3B"
                       counter="TCNT3L,TCNT3H" 
                       clockpin="PORTE3"
                       interrupt="T3_OVF"
                       prescalers="0,1,8,64,256,1024,EXT_F,EXT_R" prselect="CS30,CS31,CS32" >

    <ocunit name="OC3A" pin="PORTD0" ocreg="OCR3AL,OCR3AH" bits="COM3A0,COM3A1" interrupt="T3COA" />
    <ocunit name="OC3B" pin="PORTD2" ocreg="OCR3BL,OCR3BH" bits="COM3B0,COM3B1" interrupt="T3COB" />
    <icunit name="IC3"  pin="PORTB0" icreg="ICR3L,ICR3H"   bits="ICES3,ICNC3"   interrupt="T3CAP" />
  </timer>

  <timer name="TIMER4" type="160" configregsA="TCCR4A" configregsB="TCCR4B"
                       counter="TCNT4L,TCNT4H" 
                       clockpin="PORTE1"
                       interrupt="T4_OVF"
                       prescalers="0,1,8,64,256,1024,EXT_F,EXT_R" prselect="CS40,CS41,CS42" >

    <ocunit name="OC4A" pin="PORTD1" ocreg="OCR4AL,OCR4AH" bits="COM4A0,COM4A1" interrupt="T4COA" />
    <ocunit name="OC4B" pin="PORTD2" ocreg="OCR4AL,OCR4AH" bits="COM4B0,COM4B1" interrupt="T4COB" />
    <icunit name="IC4"  pin="PORTB0" icreg="ICR4L,ICR4H"   bits="ICES4,ICNC4"   interrupt="T4CAP" />
  </timer>

  <ocm name="OCM0" ocunits="OC3B,OC4B" configbitsA="PORTD2"/>
      
  <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="PORTB3" register="UDR1" interrupt="USART1_T" />
    <trunit type="rx" pin="PORTB4"                 interrupt="USART1_R" />
  </usart>

  <port name="PORTV" pins="2"/> <!-- Fake Port for aVcc, aRef -->
  <adc name="ADC" type="00" bits="10" configregsA="ADCSRA" configregsB="ADCSRB"
                  dataregs="ADCL,ADCH"
                  multiplex="ADMUX"
                  interrupt="ADC"
                  prescalers="2,2,4,8,16,32,64,128"
                  adcpins="PORTC0,PORTC1,PORTC2,PORTC3,PORTC4,PORTC5,PORTE2,PORTE3" />

  <twi name="TWI0" configregsA="TWCR0" configregsB="TWBR0"
                   dataregs="TWDR0" 
                   addressreg="TWAR0" 
                   statusreg="TWSR0" 
                   prescalers="1,4,16,64"
                   interrupt="TWI0" 
                   pins="PORTC4,PORTC5" /><!-- "SDA,SCL" -->

  <twi name="TWI1" configregsA="TWCR1" configregsB="TWBR1"
                   dataregs="TWDR1" 
                   addressreg="TWAR1" 
                   statusreg="TWSR1" 
                   prescalers="1,4,16,64"
                   interrupt="TWI1"
                   pins="PORTE0,PORTE1" /><!-- "SDA,SCL" -->

  <spi name="SPI0" configregsA="SPCR0"
                   dataregs="SPDR0" 
                   statusreg="SPSR0" 
                   interrupt="SPI0"
                   prescalers="4,16,64,128,2,8,32,64"
                   pins="PORTB3,PORTB4,PORTB5,PORTB2" /><!-- "MOSI,MISO,SCK,SS" -->

  <spi name="SPI1" configregsA="SPCR1"
                   dataregs="SPDR1" 
                   statusreg="SPSR1" 
                   interrupt="SPI1"
                   prescalers="4,16,64,128,2,8,32,64"
                   pins="PORTE2,PORTC0,PORTC1,PORTE3" /><!-- "MOSI,MISO,SCK,SS" -->


  <wdt name="WDT"  configregsA="WDTCSR" 
                   interrupt="WDT"
                   prescalers="512,256,128,64,32,16,8,4,2,1,1,1,1,1,1,1"/>

  <rom name="ROM"  configregsA="EECR"
                   dataregs="EEDR" 
                   addressreg="EEARL,EEARH" 
                   interrupt="EEPR" />
          
  <comp name="Comp" configregsA="ACSR" configbitsB="AIN0D,AIN1D"
                    interrupt="ACOMP" 
                    pins="PORTD6,PORTD7,PORTE0"/>
</parts>
