<fcd>

  <device file="Arduino clone_pro_micro_V13"
          name="ATMEGA32U4"
          namealt="m32u4"
          product="AVR"
          family="ATMEGA"
          bits="8" >

    <clock max_speed="16000000"
           master_divider="1"
           fixed="16000000" />

    <memory>
      <flash bytes="28672" /> 
      <ram bytes="2560" />
    </memory>

    <configuration address="0x0000"
                   mult="1" >
      <format>
      </format>

      <setting>
      </setting>

    </configuration>

    <pins sides="4" smd="1" >
        <pin name="(Digital 7) PE6" port="4" bit="6" />
        <pin name="UVCC" />
        <pin name="D-" />
        <pin name="D+" />
        <pin name="UGND" />
        <pin name="UCAP" />
        <pin name="VBUS" />
        <pin name="(SS/RxLed) PB0" port="1" bit="0" />
        <pin name="(SCLK1) PB1" port="1" bit="1" />
        <pin name="(MOSI) PB2" port="1" bit="2" />
        <pin name="(MISO) PB3" port="1" bit="3" />
        <pin name="(Digital 11 PWM) PB7" port="1" bit="7" />
        <pin name="/RESET" />
        <pin name="" />
        <pin name="" />
        <pin name="" />
        <pin name="" />
        <pin name="(SCL/Digital 3) PD0" port="3" bit="0" />
        <pin name="(SDA/Digital 2) PD1" port="3" bit="1" />
        <pin name="(RX/Digital 0) PD2" port="3" bit="2" />
        <pin name="(TX/Digital 1) PD3" port="3" bit="3" />
        <pin name="(TxLed) PD5" port="3" bit="5" />
        <pin name="" />
        <pin name="" />
        <pin name="PD4 (Digital 4/ANALOG IN 6)" port="3" bit="4" />
        <pin name="PD6 (Digital 12/ANALOG IN 7)" port="3" bit="6" />
        <pin name="PD7 (Digital 6/PWM/ANALOG IN 8)" port="3" bit="7" />
        <pin name="PB4 (Digital 8/ANALOG IN 9)" port="1" bit="4" />
        <pin name="PB5 (Digital 9/PWM/ANALOG IN 10)" port="1" bit="5" />
        <pin name="PB6 (Digital 10/PWM/ANALOG IN 11)" port="1" bit="6" />
        <pin name="PC6 (Digital 5/PWM)" port="2" bit="6" />
        <pin name="PC7 (Digital 13/PWM/LED)" port="2" bit="7" />
        <pin name="" />
        <pin name="" />
        <pin name="" />
        <pin name="PF7 (ANALOG IN 0)" port="5" bit="7" adc="7" />
        <pin name="PF6 (ANALOG IN 1)" port="5" bit="6" adc="6" />
        <pin name="PF5 (ANALOG IN 2)" port="5" bit="5" adc="5" />
        <pin name="PF4 (ANALOG IN 3)" port="5" bit="4" adc="4" />
        <pin name="PF1 (ANALOG IN 4)" port="5" bit="1" adc="1" />
        <pin name="PF0 (ANALOG IN 5)" port="5" bit="0" adc="0" />
        <pin name="AREF" />
        <pin name="" />
        <pin name="" />
    </pins>

    <adc type="3" bits="10" >
      <speed>
        <option name="Fosc / 2" value="1" />
        <option name="Fosc / 4" value="2" />
        <option name="Fosc / 8" value="3" />
        <option name="Fosc / 16" value="4" />
        <option name="Fosc / 32" value="5" />
        <option name="Fosc / 64" value="6" />
        <option name="Fosc / 128" value="7" />
      </speed>
    </adc>

    <eeprom type="1" bytes="1024" />

    <spi>
      <miso port="1" pin="3" />
      <mosi port="1" pin="2" />
      <clk port="1" pin="1" />
      <ss port="1" pin="0" />
    </spi>

    <uart>
      <tx port="3" pin="3" />
      <rx port="3" pin="2" />
    </uart>

    <i2c master="1" >
      <sda port="3" pin="1" />
      <scl port="3" pin="0" />
    </i2c>

    <pwm type="1" >
      <timer>
        <option name="timer0" count="2" />
        <option name="timer1" count="3" />
        <option name="timer2" count="0" />
        <option name="timer3" count="1" />
        <option name="timer4" count="3" />
        <option name="timer5" count="0" />
      </timer>
      <prescaler>
        <option name="1" value="1" />
        <option name="8" value="8" />
        <option name="64" value="64" />
        <option name="256" value="256" />
        <option name="1024" value="1024" />
      </prescaler>
      <out port="1" pin="7" />
      <out port="3" pin="0" />
      <out port="1" pin="5" />
      <out port="1" pin="6" />
      <out port="1" pin="7" />
      <out port="2" pin="6" />
      <out port="2" pin="7" />
      <out port="1" pin="6" />
      <out port="3" pin="7" />
    </pwm>

    <interrupts>

      <interrupt
          ident="TMR0"
          type="timer8"
          name="Timer 0"
          handler='#ifndef MX_TIMER0OVF_HANDLER\n#define MX_TIMER0OVF_HANDLER\nISR(TIMER0_OVF_vect)\n{\n\tFCM_%n();\n}\n#else\n#warning The <TIMER0 OVF> interrupt has previously been enabled, so the macro <%n> may never get called.\n#endif\n'
          enable="TIMSK0 |= (1 << TOIE0);\n"
          disable="TIMSK0 &= ~(1 << TOIE0);\n" >
        <timer overflow="256" extrange="0" />
        <options>
          <prescale name="Prescaler Rate">
            <entry name="no clock" value ="TCCR0B &= 0xf8;\n" />
            <entry name="1:1" value ="TCCR0B &= 0xf8;\nTCCR0B |= 0x01;\n" />
            <entry name="1:8" value ="TCCR0B &= 0xf8;\nTCCR0B |= 0x02;\n" />
            <entry name="1:64" value ="TCCR0B &= 0xf8;\nTCCR0B |= 0x03;\n" />
            <entry name="1:256" value ="TCCR0B &= 0xf8;\nTCCR0B |= 0x04;\n" />
            <entry name="1:1024" value ="TCCR0B &= 0xf8;\nTCCR0B |= 0x05;\n" />
            <entry name="T0 pin, -ve edge" value ="TCCR0B &= 0xf8;\nTCCR0B |= 0x06;\n" />
            <entry name="T0 pin, +ve edge" value ="TCCR0B &= 0xf8;\nTCCR0B |= 0x07;\n" />
          </prescale>
        </options>
      </interrupt>

      <interrupt
          ident="TMR1"
          type="timer16"
          name="Timer 1"
          handler='#ifndef MX_TIMER1OVF_HANDLER\n#define MX_TIMER1OVF_HANDLER\nISR(TIMER1_OVF_vect)\n{\n\tFCM_%n();\n}\n#else\n#warning The <TIMER1 OVF> interrupt has previously been enabled, so the macro <%n> may never get called.\n#endif\n'
          enable="TIMSK1 |= (1 << TOIE1);\n"
          disable="TIMSK1 &= ~(1 << TOIE1);\n" >
        <timer overflow="65536" extrange="0" />
        <options>
          <prescale name="Prescaler Rate">
            <entry name="no clock" value ="TCCR1B &= 0xf8;\n" />
            <entry name="1:1" value ="TCCR1B &= 0xf8;\nTCCR1B |= 0x01;\n" />
            <entry name="1:8" value ="TCCR1B &= 0xf8;\nTCCR1B |= 0x02;\n" />
            <entry name="1:64" value ="TCCR1B &= 0xf8;\nTCCR1B |= 0x03;\n" />
            <entry name="1:256" value ="TCCR1B &= 0xf8;\nTCCR1B |= 0x04;\n" />
            <entry name="1:1024" value ="TCCR1B &= 0xf8;\nTCCR1B |= 0x05;\n" />
            <entry name="T0 pin, -ve edge" value ="TCCR1B &= 0xf8;\nTCCR1B |= 0x06;\n" />
            <entry name="T0 pin, +ve edge" value ="TCCR1B &= 0xf8;\nTCCR1B |= 0x07;\n" />
          </prescale>
        </options>
      </interrupt>

      <interrupt
          ident="TMR3"
          type="timer16"
          name="Timer 3"
          handler='#ifndef MX_TIMER3OVF_HANDLER\n#define MX_TIMER3OVF_HANDLER\nISR(TIMER3_OVF_vect)\n{\n\tFCM_%n();\n}\n#else\n#warning The <TIMER3 OVF> interrupt has previously been enabled, so the macro <%n> may never get called.\n#endif\n'
          enable="TIMSK3 |= (1 << TOIE3);\n"
          disable="TIMSK3 &= ~(1 << TOIE3);\n" >
        <timer overflow="65536" extrange="0" />
        <options>
          <prescale name="Prescaler Rate">
            <entry name="no clock" value ="TCCR3B &= 0xf8;\n" />
            <entry name="1:1" value ="TCCR3B &= 0xf8;\nTCCR3B |= 0x01;\n" />
            <entry name="1:8" value ="TCCR3B &= 0xf8;\nTCCR3B |= 0x02;\n" />
            <entry name="1:64" value ="TCCR3B &= 0xf8;\nTCCR3B |= 0x03;\n" />
            <entry name="1:256" value ="TCCR3B &= 0xf8;\nTCCR3B |= 0x04;\n" />
            <entry name="1:1024" value ="TCCR3B &= 0xf8;\nTCCR3B |= 0x05;\n" />
            <entry name="T0 pin, -ve edge" value ="TCCR3B &= 0xf8;\nTCCR3B |= 0x06;\n" />
            <entry name="T0 pin, +ve edge" value ="TCCR3B &= 0xf8;\nTCCR3B |= 0x07;\n" />
          </prescale>
        </options>
      </interrupt>

      <interrupt
          ident="IOCB0"
          type="multipin"
          name="IOC PORT B"
          handler='#ifndef MX_PCINT0_HANDLER\n#define MX_PCINT0_HANDLER\nISR(PCINT0_vect)\n{\n\tFCM_%n();\n}\n#else\n#warning The <PORTB Change> interrupt has previously been enabled, so the macro <%n> may never get called.\n#endif\n'
          enable="PCMSK0 = %pB*v;\nPCICR |= (1 << PCIE0);\n"
          disable="PCICR &= ~(1 << PCIE0);\n" >
        <ioc config="0x0C">
          <rising port="1" mask="0xFF" />
          <falling port="1" mask="0xFF" />
        </ioc>
      </interrupt>

      <interrupt
          ident="INT0"
          type="pin"
          name="INT0 Input"
          handler="#ifndef MX_INT0_HANDLER\n#define MX_INT0_HANDLER\nISR(INT0_vect)\n{\n\tFCM_%n();\n}\n#else\n#warning The <INT0 Input> interrupt has previously been enabled, so the macro <%n> may never get called.\n#endif\n"
          enable="EIMSK |= (1 << INT0);\n"
          disable="EIMSK &= ~(1 << INT0);\n" >
        <ioc config="3">
          <rising port="3" mask="1" />
          <falling port="3" mask="1" />
        </ioc>
        <options>
          <edge name="Interrupt Edge Select">
            <entry name="Rising edge of INT" value="EICRA |= (1 << ISC01) | (1 << ISC00);\n" />
            <entry name="Falling edge of INT" value="EICRA |= (1 << ISC01);\nEICRA &= ~(1 << ISC00);\n" />
          </edge>
        </options>
      </interrupt>

      <interrupt
          ident="INT1"
          type="pin"
          name="INT1 Input"
          handler="#ifndef MX_INT1_HANDLER\n#define MX_INT1_HANDLER\nISR(INT1_vect)\n{\n\tFCM_%n();\n}\n#else\n#warning The <INT1 Input> interrupt has previously been enabled, so the macro <%n> may never get called.\n#endif\n"
          enable="EIMSK |= (1 << INT1);\n"
          disable="EIMSK &= ~(1 << INT1);\n" >
        <ioc config="3">
          <rising port="3" mask="2" />
          <falling port="3" mask="2" />
        </ioc>
        <options>
          <edge name="Interrupt Edge Select">
            <entry name="Rising edge of INT" value="EICRA |= (1 << ISC11) | (1 << ISC10);\n" />
            <entry name="Falling edge of INT" value="EICRA |= (1 << ISC11);\nEICRA &= ~(1 << ISC10);\n" />
          </edge>
        </options>
      </interrupt>

      <interrupt
          ident="INT2"
          type="pin"
          name="INT2 Input"
          handler="#ifndef MX_INT2_HANDLER\n#define MX_INT2_HANDLER\nISR(INT2_vect)\n{\n\tFCM_%n();\n}\n#else\n#warning The <INT2 Input> interrupt has previously been enabled, so the macro <%n> may never get called.\n#endif\n"
          enable="EIMSK |= (1 << INT2);\n"
          disable="EIMSK &= ~(1 << INT2);\n" >
        <ioc config="3">
          <rising port="3" mask="4" />
          <falling port="3" mask="4" />
        </ioc>
        <options>
          <edge name="Interrupt Edge Select">
            <entry name="Rising edge of INT" value="EICRA |= (1 << ISC21) | (1 << ISC20);\n" />
            <entry name="Falling edge of INT" value="EICRA |= (1 << ISC21);\nEICRA &= ~(1 << ISC20);\n" />
          </edge>
        </options>
      </interrupt>

      <interrupt
          ident="INT3"
          type="pin"
          name="INT3 Input"
          handler="#ifndef MX_INT3_HANDLER\n#define MX_INT3_HANDLER\nISR(INT3_vect)\n{\n\tFCM_%n();\n}\n#else\n#warning The <INT3 Input> interrupt has previously been enabled, so the macro <%n> may never get called.\n#endif\n"
          enable="EIMSK |= (1 << INT3);\n"
          disable="EIMSK &= ~(1 << INT3);\n" >
        <ioc config="3">
          <rising port="3" mask="8" />
          <falling port="3" mask="8" />
        </ioc>
        <options>
          <edge name="Interrupt Edge Select">
            <entry name="Rising edge of INT" value="EICRA |= (1 << ISC31) | (1 << ISC30);\n" />
            <entry name="Falling edge of INT" value="EICRA |= (1 << ISC31);\nEICRA &= ~(1 << ISC30);\n" />
          </edge>
        </options>
      </interrupt>

      <interrupt
          ident="INT6"
          type="pin"
          name="INT6 Input"
          handler="#ifndef MX_INT6_HANDLER\n#define MX_INT6_HANDLER\nISR(INT6_vect)\n{\n\tFCM_%n();\n}\n#else\n#warning The <INT6 Input> interrupt has previously been enabled, so the macro <%n> may never get called.\n#endif\n"
          enable="EIMSK |= (1 << INT6);\n"
          disable="EIMSK &= ~(1 << INT6);\n" >
        <ioc config="3">
          <rising port="4" mask="64" />
          <falling port="4" mask="64" />
        </ioc>
        <options>
          <edge name="Interrupt Edge Select">
            <entry name="Rising edge of INT" value="EICRB |= (1 << ISC61) | (1 << ISC60);\n" />
            <entry name="Falling edge of INT" value="EICRB |= (1 << ISC61);\nEICRB &= ~(1 << ISC60);\n" />
          </edge>
        </options>
      </interrupt>

      <interrupt
          ident="RXINT0"
          type="comms"
          name="UART0 RX"
          handler="#ifndef MX_UART0_RX_HANDLER\n#define MX_UART0_RX_HANDLER\nISR(USART0_RX_vect)\n{\n\tFCM_%n();\n}\n#else\n#warning The <UART0 RX> interrupt has previously been enabled, so the macro <%n> may never get called.\n#endif\n"
          enable="UCSR0B |= (1 << RXCIE0);\n"
          disable="UCSR0B &=  ~(1 << RXCIE0);\n" >
      </interrupt>


    </interrupts>

  </device>

  <inline>

    <defines code="#define MX_UART_ID\n#define MX_UART_UCSRC\n\n#include <stdlib.h>\n#include <stdio.h>\n#include <math.h>\n#include <avr\io.h>\n#include <avr\interrupt.h>\n#include <avr\eeprom.h>\n#include <avr\wdt.h>\n\n" />
    <directives code="" />

    <main>
      <start code="int main()\n{\n" />
      <end code="\tmainendloop: goto mainendloop;\n}\n\n" />
      <init code="\tMCUCR=0x00;\n\tMCUSR=0x00;\n\twdt_disable();\n" />
    </main>

    <interrupt>
      <enable code="sei();\n" />
      <start code="" />
      <end code="" />
      <init code="" />
    </interrupt>

    <config>
      <start code='//Configuration Start\n' /> 
      <body code='' /> 
      <end code='//Configuration End\n\n' />
    </config>

  </inline>

  <test>

    <icd>
      <clock port="1" pin="6" />
      <data port="1" pin="7" />
    </icd>

  </test>

</fcd>
