<!DOCTYPE module SYSTEM "module.dtd">

<module name="ins_vectornav" dir="ins">
  <doc>
    <description>
      Vectornav INS Driver.
    </description>
    <configure name="VN_PORT" value="uart3" description="UART to use"/>
    <configure name="VN_BAUD" value="B921600" description="UART baudrate"/>
  </doc>
  <autoload name="gps"/>
  <autoload name="ins_sim"/>
  <autoload name="ins_nps"/>
  <header>
    <file name="ins.h" dir="subsystems"/>
  </header>
  <init fun="ins_vectornav_init()"/>
  <periodic fun="ins_vectornav_monitor()" freq="1.0" autorun="TRUE"/>
  <event fun="ins_vectornav_event()"/>
  <makefile target="ap">
    <configure name="VN_PORT" default="uart3" case="upper|lower"/>
    <configure name="VN_BAUD" default="B921600"/>
    <define name="USE_$(VN_PORT_UPPER)"/>
    <define name="VN_PORT" value="$(VN_PORT_LOWER)"/>
    <define name="$(VN_PORT_UPPER)_BAUD" value="$(VN_BAUD)"/>

    <define name="GPS_NB_CHANNELS" value="1" description="define a single GPS channel to show pacc on GCS GPS page"/>

    <file name="vn200_serial.c" dir="peripherals"/>

    <file name="ins.c" dir="subsystems"/>
    <file name="ins_vectornav.c" dir="subsystems/ins"/>
    <file name="ins_vectornav_wrapper.c" dir="subsystems/ins"/>
    <define name="INS_TYPE_H" value="subsystems/ins/ins_vectornav_wrapper.h" type="string"/>

    <file name="gps.c" dir="subsystems"/>
    <define name="USE_GPS"/>
    <raw>
      ifdef SECONDARY_GPS
      ifneq (,$(findstring $(SECONDARY_GPS), vectornav))
      # this is the secondary GPS
      ap.CFLAGS += -DGPS_SECONDARY_TYPE_H=\"subsystems/ins/ins_vectornav_wrapper.h\"
      ap.CFLAGS += -DSECONDARY_GPS=GPS_VECTORNAV
      else
      ap.CFLAGS += -DGPS_TYPE_H=\"subsystems/ins/ins_vectornav_wrapper.h\"
      ap.CFLAGS += -DPRIMARY_GPS=GPS_VECTORNAV
      endif
      else
      # plain old single GPS usage
      ap.CFLAGS += -DGPS_TYPE_H=\"subsystems/gps/gps_ubx.h\"
      endif
    </raw>
  </makefile>

  <!-- TODO: make this dynamically loadable - will hopefully work better
  once nps and HITL are separate targets -->
  <!--makefile target="hitl">
    <file name="nps_ins_vectornav.c" dir="nps"/>
  </makefile-->
</module>
