<airframe name="BETH">

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

  <section name="SUPERVISION" prefix="SUPERVISION_">
    <define name="MIN_MOTOR" value="2"/>
    <define name="MAX_MOTOR" value="210"/>
    <define name="TRIM_A" value="0"/>
    <define name="TRIM_E" value="0"/>
    <define name="TRIM_R" value="0"/>
  </section>

  <servos>
    <servo name="THROTTLE" no="0" min="1290" neutral="1290" max="1810"/>
    <servo name="ELEVATOR" no="1" min="1770" neutral="1457" max="970"/>
    <servo name="RUDDER" no="3" min="1040" neutral="1595" max="2040"/>
    <servo name="AILERON_LEFT" no="4" min="1000" neutral="1508" max="2000"/>
    <servo name="AILERON_RIGHT" no="5" min="1000" neutral="1527" max="2000"/>
  </servos>



 <!-- this is my crista -->
  <section name="IMU" prefix="IMU_">

    <define name="GYRO_P_SIGN" value="-1"/>
    <define name="GYRO_Q_SIGN" value="1"/>
    <define name="GYRO_R_SIGN" value="1"/>

    <define name="GYRO_P_NEUTRAL" value="31288"/>
    <define name="GYRO_Q_NEUTRAL" value="32593"/>
    <define name="GYRO_R_NEUTRAL" value="32709"/>

    <define name="GYRO_P_SENS" value=" 0.943560" integer="16"/>
    <define name="GYRO_Q_SENS" value=" 0.926199" integer="16"/>
    <define name="GYRO_R_SENS" value=" 0.931912" integer="16"/>


    <define name="ACCEL_X_SIGN" value="1"/>
    <define name="ACCEL_Y_SIGN" value="1"/>
    <define name="ACCEL_Z_SIGN" value="1"/>

    <define name="ACCEL_X_NEUTRAL" value="32857"/>
    <define name="ACCEL_Y_NEUTRAL" value="32429"/>
    <define name="ACCEL_Z_NEUTRAL" value="32593"/>

    <define name="ACCEL_X_SENS" value="-2.58273701242" integer="16"/>
    <define name="ACCEL_Y_SENS" value="-2.54076215332" integer="16"/>
    <define name="ACCEL_Z_SENS" value="-2.57633620646" integer="16"/>


    <define name="MAG_X_SIGN" value="-43"/>
    <define name="MAG_Y_SIGN" value=" 49"/>
    <define name="MAG_Z_SIGN" value="-66"/>

    <define name="MAG_X_NEUTRAL" value="-43"/>
    <define name="MAG_Y_NEUTRAL" value=" 49"/>
    <define name="MAG_Z_NEUTRAL" value="-66"/>

    <define name="MAG_X_SENS" value=" 5.32718104135" integer="16"/>
    <define name="MAG_Y_SENS" value="-4.87857821202" integer="16"/>
    <define name="MAG_Z_SENS" value="-3.11986612709" integer="16"/>


    <define name="BODY_TO_IMU_PHI"   value="0." unit="deg"/>
    <define name="BODY_TO_IMU_THETA" value="0." unit="deg"/>
    <define name="BODY_TO_IMU_PSI"   value="45." unit="deg"/>

<!--  3  -->
    <define name="GYRO_P_CHAN" value="0"/>
    <define name="GYRO_Q_CHAN" value="4"/>
    <define name="GYRO_R_CHAN" value="1"/>
    <define name="ACCEL_X_CHAN" value="5"/>
    <define name="ACCEL_Y_CHAN" value="2"/>
    <define name="ACCEL_Z_CHAN" value="6"/>

  </section>

  <makefile>


#
# main STM32
#

ARCH=stm32
#BOARD_CFG = \"boards/lisa_l_1.0.h\"
FLASH_MODE = JTAG

SRC_ARCH = $(ARCH)
SRC_BETH=firmwares/beth
SRC_BOOZ=booz
SRC_BOOZ_ARCH=$(SRC_BOOZ)/arch/$(ARCH)
SRC_LISA=lisa
SRC_LISA_ARCH=$(SRC_LISA)/arch/$(ARCH)
SRC_FIRMWARE=subsystems

main_stm32.ARCHDIR = stm32
#main_stm32.LDSCRIPT = $(SRC_ARCH)/stm32f103re_flash.ld
main_stm32.CFLAGS += -I$(SRC_LISA) -I$(SRC_BOOZ) -I$(SRC_BOOZ_ARCH) -I$(SRC_LISA_ARCH) -DPERIPHERALS_AUTO_INIT
main_stm32.CFLAGS += -DBOARD_CONFIG=\"boards/lisa_l_1.0.h\"
main_stm32.srcs = $(SRC_BETH)/main_stm32.c
main_stm32.CFLAGS += -DUSE_LED
main_stm32.srcs += $(SRC_ARCH)/led_hw.c
main_stm32.CFLAGS += -DUSE_SYS_TIME -DSYS_TIME_LED=1
main_stm32.CFLAGS += -DPERIODIC_FREQUENCY='512.'
main_stm32.srcs += sys_time.c $(SRC_ARCH)/sys_time_hw.c

main_stm32.CFLAGS += -DUSE_UART2 -DUART2_BAUD=B57600
main_stm32.srcs += $(SRC_ARCH)/mcu_periph/uart_arch.c
main_stm32.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_DEVICE=Uart2
main_stm32.srcs += subsystems/datalink/downlink.c subsystems/datalink/pprz_transport.c


main_stm32.CFLAGS += -DUSE_OVERO_LINK
main_stm32.CFLAGS += -DOVERO_LINK_MSG_UP=AutopilotMessageBethUp -DOVERO_LINK_MSG_DOWN=AutopilotMessageBethDown
main_stm32.CFLAGS += -DOVERO_LINK_LED_OK=3 -DOVERO_LINK_LED_KO=4 -DUSE_DMA1_C2_IRQ
main_stm32.srcs += lisa/lisa_overo_link.c lisa/arch/stm32/lisa_overo_link_arch.c

#booz IMU
#main_stm32.CFLAGS += -DIMU_TYPE_H=\"imu/imu_b2.h\"
#main_stm32.CFLAGS += -DIMU_B2_MAG_TYPE=IMU_B2_MAG_MS2100
#main_stm32.srcs += $(SRC_FIRMWARE)/imu.c
#main_stm32.CFLAGS += -DUSE_SPI2 -DUSE_DMA1_C4_IRQ -DUSE_EXTI2_IRQ -DUSE_SPI2_IRQ
#main_stm32.srcs += $(SRC_FIRMWARE)/imu/imu_b2.c
#main_stm32.srcs += peripherals/max1168.c $(SRC_ARCH)/peripherals/max1168_arch.c
#main_stm32.srcs += peripherals/ms2100.c  $(SRC_ARCH)/peripherals/ms2100_arch.c
#main_stm32.srcs += math/pprz_trig_int.c

#crista IMU
main_stm32.srcs += math/pprz_trig_int.c
main_stm32.CFLAGS += -DIMU_TYPE_H=\"imu/imu_crista.h\"
main_stm32.srcs += subsystems/imu.c             \
                        subsystems/imu/imu_crista.c \
                        arch/$(ARCH)/subsystems/imu/imu_crista_arch.c
main_stm32.CFLAGS += -DUSE_DMA1_C4_IRQ

main_stm32.srcs += $(SRC_FIRMWARE)/commands.c
main_stm32.srcs += firmwares/rotorcraft/actuators/actuators_asctec.c
#\
#                             $(SRC_BOOZ_ARCH)/actuators/actuators_asctec_arch.c
main_stm32.CFLAGS += -DACTUATORS_ASCTEC_DEVICE=i2c1
# -DACTUATORS_START_DELAY=3  -DUSE_TIM2_IRQ
main_stm32.CFLAGS += -DUSE_I2C1
main_stm32.srcs += i2c.c $(SRC_ARCH)/i2c_hw.c

#main_stm32.CFLAGS += -DUSE_I2C2
#main_stm32.srcs += $(SRC_BETH)/bench_sensors_i2c.c

main_stm32.CFLAGS += -DUSE_CAN1 -DUSE_USB_LP_CAN1_RX0_IRQ -DUSE_CAN_EXT_ID
main_stm32.CFLAGS += \
	-DCAN_PRESCALER=11 \
	-DCAN_SJW_TQ=CAN_SJW_1tq \
	-DCAN_BS1_TQ=CAN_BS1_3tq \
	-DCAN_BS2_TQ=CAN_BS2_5tq \
	-DCAN_ERR_RESUME=DISABLE
main_stm32.srcs += can.c $(SRC_ARCH)/can_hw.c
main_stm32.srcs += $(SRC_BETH)/bench_sensors_can.c

#
# Coders handled by a Olimex stm32h103 dev board
#

main_coders.ARCHDIR = stm32
main_coders.LDSCRIPT = $(SRC_ARCH)/stm32f103rb_flash.ld
main_coders.OOCD_INTERFACE = olimex-arm-usb-ocd
main_coders.OOCD_BOARD = olimex_stm32_h103
#main_coders.CFLAGS += -DBOARD_CONFIG=\"boards/olimex_stm32-h103.h\"
main_coders.CFLAGS += -DBOARD_CONFIG=\"boards/beth.h\"

main_coders.CFLAGS += -I$(SRC_LISA) -I$(SRC_BOOZ) -I$(SRC_BOOZ_ARCH) -DPERIPHERALS_AUTO_INIT
main_coders.srcs = $(SRC_BETH)/main_coders.c
main_coders.CFLAGS += -DUSE_LED
main_coders.srcs += $(SRC_ARCH)/led_hw.c
main_coders.CFLAGS += -DUSE_SYS_TIME -DSYS_TIME_LED=7
main_coders.CFLAGS += -DPERIODIC_FREQUENCY='512.'
main_coders.srcs += sys_time.c $(SRC_ARCH)/sys_time_hw.c

main_coders.CFLAGS += -DUSE_UART1 -DUART1_BAUD=B57600
main_coders.srcs += $(SRC_ARCH)/mcu_periph/uart_arch.c
main_coders.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_DEVICE=Uart1
main_coders.srcs += subsystems/datalink/downlink.c subsystems/datalink/pprz_transport.c

#main_coders.CFLAGS += -DUSE_I2C2
#main_coders.srcs += $(SRC_ARCH)/i2c_hw.c

main_coders.CFLAGS += -DUSE_CAN1 -DUSE_USB_LP_CAN1_RX0_IRQ  -DUSE_CAN_EXT_ID
main_coders.CFLAGS += \
	-DCAN_PRESCALER=11 \
	-DCAN_SJW_TQ=CAN_SJW_1tq \
	-DCAN_BS1_TQ=CAN_BS1_3tq \
	-DCAN_BS2_TQ=CAN_BS2_5tq \
	-DCAN_ERR_RESUME=DISABLE
main_coders.srcs += can.c $(SRC_ARCH)/can_hw.c
main_coders.srcs += $(SRC_BETH)/bench_sensors_can.c

#
# main Overo
#

USER =
#HOST = beth
#HOST = overo
#HOST = auto7
#HOST = 192.168.2.11
#HOST = 192.168.2.2
#HOST= regis
HOST = auto3
TARGET_DIR = ~
SRC_FMS=fms

main_overo.ARCHDIR = omap
main_overo.CFLAGS = -I. -I$(SRC_FMS)
main_overo.srcs  = $(SRC_BETH)/main_overo.c
main_overo.CFLAGS  += -DFMS_PERIODIC_FREQ=512
main_overo.srcs    += $(SRC_FMS)/fms_periodic.c
#main_overo.srcs    += $(SRC_FMS)/fms_serial_port.c
main_overo.LDFLAGS += -lrt
main_overo.srcs += $(SRC_FMS)/fms_spi_link.c
main_overo.CFLAGS += -DOVERO_LINK_MSG_UP=AutopilotMessageBethUp -DOVERO_LINK_MSG_DOWN=AutopilotMessageBethDown

main_overo.CFLAGS  += -DDOWNLINK -DDOWNLINK_TRANSPORT=UdpTransport
main_overo.srcs    += $(SRC_FMS)/udp_transport2.c subsystems/datalink/downlink.c
main_overo.srcs    += $(SRC_FMS)/fms_network.c
main_overo.LDFLAGS += -levent -lm

main_overo.srcs    += $(SRC_BETH)/overo_gcs_com.c
main_overo.srcs    += $(SRC_BETH)/overo_file_logger.c
main_overo.srcs    += $(SRC_BETH)/overo_estimator.c
main_overo.CFLAGS  += -DCONTROLLER_H=\"overo_controller.h\"
main_overo.srcs    += $(SRC_BETH)/overo_controller.c

#
# overo uart test
#

overo_test_uart.ARCHDIR = omap
overo_test_uart.CFLAGS = -I. -I$(SRC_FMS) -I$(SRC_BETH)
overo_test_uart.srcs  = $(SRC_BETH)/overo_test_uart.c

overo_test_uart.CFLAGS  += -DFMS_PERIODIC_FREQ=500
overo_test_uart.srcs    += $(SRC_FMS)/fms_periodic.c
overo_test_uart.srcs    += $(SRC_FMS)/fms_serial_port.c
overo_test_uart.LDFLAGS += -lrt
overo_test_uart.CFLAGS  += -DDOWNLINK -DDOWNLINK_TRANSPORT=UdpTransport
overo_test_uart.srcs    += $(SRC_FMS)/udp_transport2.c subsystems/datalink/downlink.c
overo_test_uart.srcs    += $(SRC_FMS)/fms_network.c
overo_test_uart.LDFLAGS += -levent -lm
overo_test_uart.srcs    += $(SRC_BETH)/overo_gcs_com.c
#overo_test_uart.CFLAGS  += -DUBX -DUSE_GPS -DUSE_UART0 -DUART0_BAUD=B9600 -DGPS_CONFIGURE -DUSER_GPS_CONFIGURE=\"modules/gps_i2c/runtime_configure.h\" -DGPS_BAUD=B38400 -DGPS_LINK=Uart0 -DGPS_USE_LATLONG
#overo_test_uart.CFLAGS  += -DUBX -DUSE_GPS -DUSE_UART0 -DUART0_BAUD=B9600 -DGPS_CONFIGURE -DGPS_BAUD=B38400 -DGPS_LINK=Uart0 -DGPS_USE_LATLONG
overo_test_uart.CFLAGS  += -DUBX -DUSE_GPS -DUSE_UART0 -DUART0_BAUD=B38400 -DGPS_LINK=Uart0 -DGPS_USE_LATLONG
overo_test_uart.srcs    += gps_ubx.c gps.c latlong.c $(SRC_BETH)/uart_hw.c
overo_test_uart.CFLAGS  +=-DUSE_UART1 -DUART1_BAUD=B57600 -DDOWNLINK_DEVICE=Uart1 -DPPRZ_UART=Uart1 -DDATALINK=PPRZ
overo_test_uart.srcs    += subsystems/datalink/pprz_transport.c $(SRC_BETH)/rcv_telemetry.c

#
# Overo twisting
#

overo_twist.ARCHDIR = omap
overo_twist.CFLAGS = -I. -I$(SRC_FMS)
overo_twist.srcs  = $(SRC_BETH)/main_overo.c
overo_twist.CFLAGS  += -DFMS_PERIODIC_FREQ=512
overo_twist.srcs    += $(SRC_FMS)/fms_periodic.c
overo_twist.srcs    += $(SRC_FMS)/fms_serial_port.c
overo_twist.LDFLAGS += -lrt
overo_twist.srcs += $(SRC_FMS)/fms_spi_link.c
overo_twist.CFLAGS += -DOVERO_LINK_MSG_UP=AutopilotMessageBethUp -DOVERO_LINK_MSG_DOWN=AutopilotMessageBethDown

overo_twist.CFLAGS  += -DDOWNLINK -DDOWNLINK_TRANSPORT=UdpTransport
overo_twist.srcs    += $(SRC_FMS)/udp_transport2.c subsystems/datalink/downlink.c
overo_twist.srcs    += $(SRC_FMS)/fms_network.c
overo_twist.LDFLAGS += -levent -lm

overo_twist.srcs    += $(SRC_BETH)/overo_gcs_com.c
overo_twist.srcs    += $(SRC_BETH)/overo_file_logger.c
overo_twist.srcs    += $(SRC_BETH)/overo_estimator.c
overo_twist.CFLAGS  += -DCONTROLLER_H=\"overo_twist_controller.h\"
overo_twist.srcs    += $(SRC_BETH)/overo_twist_controller.c

#
# Overo state feedback
#


overo_sfb.ARCHDIR = omap
overo_sfb.CFLAGS = -I. -I$(SRC_FMS)
overo_sfb.srcs  = $(SRC_BETH)/main_overo.c
overo_sfb.CFLAGS  += -DFMS_PERIODIC_FREQ=512
overo_sfb.srcs    += $(SRC_FMS)/fms_periodic.c
overo_sfb.srcs    += $(SRC_FMS)/fms_serial_port.c
overo_sfb.LDFLAGS += -lrt
overo_sfb.srcs += $(SRC_FMS)/fms_spi_link.c
overo_sfb.CFLAGS += -DOVERO_LINK_MSG_UP=AutopilotMessageBethUp -DOVERO_LINK_MSG_DOWN=AutopilotMessageBethDown

overo_sfb.CFLAGS  += -DDOWNLINK -DDOWNLINK_TRANSPORT=UdpTransport
overo_sfb.srcs    += $(SRC_FMS)/udp_transport2.c subsystems/datalink/downlink.c
overo_sfb.srcs    += $(SRC_FMS)/fms_network.c
overo_sfb.LDFLAGS += -levent
overo_sfb.LDFLAGS += -lm

overo_sfb.srcs    += $(SRC_BETH)/overo_gcs_com.c
overo_sfb.srcs    += $(SRC_BETH)/overo_file_logger.c
overo_sfb.srcs    += $(SRC_BETH)/overo_estimator.c
overo_sfb.CFLAGS  += -DCONTROLLER_H=\"overo_sfb_controller.h\"
overo_sfb.srcs    += $(SRC_BETH)/overo_sfb_controller.c

#
#
#
include $(PAPARAZZI_SRC)/conf/firmwares/obsolete/lisa_test_progs.makefile

  </makefile>

</airframe>
