<!DOCTYPE airframe SYSTEM "../../airframe.dtd">

<!--

    Connects a microSD card to the SPI port of the Paparazzi Tiny. Keep cables
    short, microSD card can be directly soldered to Molex cable. For now only
    non SDHC SD cards (<= 2GB) are supported. martinmm@pfump.org

    microSD         TinyV2 SPI J3
    8 nc
    7 DO            5 MISO
    6 GND           1 GND
    5 CLK           7 SCK
    4 Vcc           2 +3V3
    3 DI            4 MOSI
    2 CS            3 SSEL
    1 nc

    Looking onto the gold plated connector side of the microSD card:

    ###############
    I 8
    I 7
    I 6
    I 5
    I 4
    I 3
    I 2
    I 1
    ######    ##
          \  I  \
           ##    ##

    Also logs data from MAX11040 connected to SPI.

-->

<airframe name="Logger">

  <section name="MAX11040">

    <define name="MAXM_SS_PIN" value="20"/>
    <define name="MAXM_SS_IODIR" value="IO0DIR"/>
    <define name="MAXM_SS_IOSET" value="IO0SET"/>
    <define name="MAXM_SS_IOCLR" value="IO0CLR"/>

    <define name="MAXM_DRDY_PINSEL" value="PINSEL1"/>
    <define name="MAXM_DRDY_PINSEL_BIT" value="0"/>
    <define name="MAXM_DRDY_PINSEL_VAL" value="1"/>
    <define name="MAXM_DRDY_EINT" value="0"/>
    <define name="MAXM_DRDY_VIC_IT" value="VIC_EINT0"/>

  </section>

 <makefile>

CONFIG = \"tiny_2_1_1_usb.h\"

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

FLASH_MODE=IAP

ap.CFLAGS += -DBOARD_CONFIG=$(CONFIG) -DUSE_LED -DLOGGER
ap.srcs = sys_time.c $(SRC_ARCH)/sys_time_hw.c $(SRC_ARCH)/armVIC.c main_logger.c

#choose one
ap.CFLAGS += -DLOG_XBEE
#ap.CFLAGS += -DLOG_PPRZ

#set the speed
ap.CFLAGS += -DUSE_UART0 -DUART0_BAUD=B57600 -DUSE_UART0_RX_ONLY
ap.CFLAGS += -DUSE_UART1 -DUART1_BAUD=B57600 -DUSE_UART1_RX_ONLY
ap.srcs += $(SRC_ARCH)/mcu_periph/uart_arch.c

#set SPI interface for SD card (0 or 1)
ap.CFLAGS += -DHW_ENDPOINT_LPC2000_SPINUM=0

#set the logger stop key to P0.13
ap.CFLAGS += -DLOG_STOP_KEY=13

#efsl
ap.CFLAGS += -I $(SRC_ARCH)/efsl/inc -I $(SRC_ARCH)/efsl/conf

ap.srcs += $(SRC_ARCH)/efsl/src/efs.c $(SRC_ARCH)/efsl/src/plibc.c
ap.srcs += $(SRC_ARCH)/efsl/src/disc.c $(SRC_ARCH)/efsl/src/partition.c
ap.srcs += $(SRC_ARCH)/efsl/src/time.c $(SRC_ARCH)/efsl/src/fs.c
ap.srcs += $(SRC_ARCH)/efsl/src/fat.c $(SRC_ARCH)/efsl/src/file.c
ap.srcs += $(SRC_ARCH)/efsl/src/dir.c $(SRC_ARCH)/efsl/src/ls.c
ap.srcs += $(SRC_ARCH)/efsl/src/mkfs.c $(SRC_ARCH)/efsl/src/debug.c
ap.srcs += $(SRC_ARCH)/efsl/src/ioman.c $(SRC_ARCH)/efsl/src/ui.c
ap.srcs += $(SRC_ARCH)/efsl/src/extract.c
ap.srcs += $(SRC_ARCH)/efsl/src/interfaces/lpc2000_spi.c
ap.srcs += $(SRC_ARCH)/efsl/src/interfaces/sd.c
#ap.srcs += $(SRC_ARCH)/efsl/src/interfaces/lpc2000_dbg_printf.c

#usb mass storage
ap.CFLAGS += -DUSE_USB_MSC
ap.CFLAGS += -I $(SRC_ARCH)/lpcusb -I $(SRC_ARCH)/lpcusb/examples

ap.srcs += $(SRC_ARCH)/usb_msc_hw.c
ap.srcs += $(SRC_ARCH)/lpcusb/usbhw_lpc.c $(SRC_ARCH)/lpcusb/usbcontrol.c $(SRC_ARCH)/lpcusb/usbstdreq.c $(SRC_ARCH)/lpcusb/usbinit.c
ap.srcs += $(SRC_ARCH)/lpcusb/examples/msc_bot.c $(SRC_ARCH)/lpcusb/examples/msc_scsi.c $(SRC_ARCH)/lpcusb/examples/blockdev_sd.c $(SRC_ARCH)/lpcusb/examples/lpc2000_spi0.c

ap.CFLAGS += -DMAX11040_DRDY_VIC_SLOT=12 -DSSP_VIC_SLOT=11 -DUSE_MAX11040
ap.srcs += max11040.c $(SRC_ARCH)/max11040_hw.c

  </makefile>

</airframe>

