<airframe name="Twisted Logic">
 <!-- tiny airframe -->

<!-- commands section -->
  <servos>
    <servo name="AILERON"  no="2" min="900" neutral="1500" max="2100"/>
    <servo name="ELEVATOR" no="1" min="900" neutral="1500" max="2100"/>
    <servo name="MOTOR_RIGHT"   no="6" min="1250" neutral="1250" max="1850"/>
    <servo name="MOTOR_LEFT"   no="3" min="1250" neutral="1250" max="1850"/>
  </servos>

  <commands>
    <axis name="THROTTLE" failsafe_value="0"/>
    <axis name="ROLL"     failsafe_value="0"/>
    <axis name="PITCH"    failsafe_value="0"/>
    <axis name="YAW"    failsafe_value="0"/>
  </commands>

  <rc_commands>
    <set command="THROTTLE" value="@THROTTLE"/>
    <set command="ROLL"     value="@ROLL"/>
    <set command="PITCH"    value="@PITCH"/>
    <set command="YAW"    value="@YAW"/>
  </rc_commands>

  <section name="MIXER">
    <define name="AILEVON_AILERON_RATE" value="0.8"/>
    <define name="AILEVON_ELEVATOR_RATE" value="0.8"/>
  </section>

    <command_laws>
	  <let var="roll"     value="1.0  * @ROLL"/>
          <let var="yawtoroll"     value="0.0001 * @YAW"/>
          <let var="pitchtoroll" value="0.0001 * @PITCH"/>
	  <let var="pitch"    value="1.0  * @PITCH"/>
	  <let var="yaw"      value="0.1 * @YAW"/>
	  <let var="throttle" value="1.0   * @THROTTLE"/>
	  <set servo="AILERON" value="$roll"/>
	  <set servo="ELEVATOR"  value="$pitch"/>
	  <set servo="MOTOR_LEFT"  value="$throttle - $yaw - .06*$throttle"/> <!-- add trim term for Right -->
	  <set servo="MOTOR_RIGHT" value="$throttle + $yaw + .06*$throttle"/> <!-- subtract trim term for Right -->
  </command_laws>

<makefile>
include $(PAPARAZZI_SRC)/conf/firmwares/tiny.makefile

FLASH_MODE=IAP

ap.CFLAGS +=  -DFBW -DAP -DBOARD_CONFIG=\"tiny_1_1.h\" -DUSE_LED -DTIME_LED=1
ap.srcs = sys_time.c $(SRC_ARCH)/sys_time_hw.c $(SRC_ARCH)/armVIC.c main_fbw.c main_coax.c main.c

ap.CFLAGS += -DACTUATORS=\"servos_4015_MAT_hw.h\" -DSERVOS_4015_MAT
ap.srcs += $(SRC_ARCH)/servos_4015_MAT_hw.c actuators.c commands.c

ap.CFLAGS += -DRADIO_CONTROL
ap.srcs += radio_control.c $(SRC_ARCH)/ppm_hw.c

ap.CFLAGS += -DDOWNLINK -DUSE_UART0 -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_FBW_DEVICE=Uart0 -DDOWNLINK_AP_DEVICE=Uart0 -DPPRZ_UART=Uart0 -DDATALINK=PPRZ -DUART0_BAUD=B19200
ap.srcs += subsystems/datalink/downlink.c $(SRC_ARCH)/mcu_periph/uart_arch.c datalink.c subsystems/datalink/pprz_transport.c

ap.CFLAGS += -DUSE_SPI -DSPI_MASTER -DUSE_SPI_SLAVE0 -DUSE_BARO_MS5534A
ap.srcs += spi.c $(SRC_ARCH)/spi_hw.c $(SRC_ARCH)/baro_MS5534A.c

ap.CFLAGS += -DALT_KALMAN
ap.srcs += estimator.c

</makefile>
</airframe>
