TARGET := tdk_noise_test

GPS_SYSTEM_DIR ?= ../gps_system

# The production driver is compiled in directly so the sensor is configured
# exactly as the flight build configures it.
vpath %.c $(GPS_SYSTEM_DIR)/src/drivers/imu

APP_SRCS := \
	main.c \
	tdk_icm42688.c

BSP_SRCS := init.c uart.c plic.c irq.c pmod_spi.c

# Genesys2 fabric/UART and CLINT defaults, matching the gps_system app.
BSP_UART_CLOCK_HZ ?= 50000000
BSP_UART_BAUDRATE ?= 460800
BSP_CLINT_TIMEBASE_HZ ?= 500000

# Mirrors gps_system IMU_ODR_HZ; override together with it.
NOISE_ODR_HZ ?= 50
NOISE_DISCARD_SAMPLES ?= 100
NOISE_BIAS_SAMPLES ?= 1000
NOISE_MEASURE_SAMPLES ?= 3000
# Set to 1 to refuse the polled fallback, so a broken INT1 route fails loudly.
NOISE_REQUIRE_IRQ ?= 0
# Set to 1 to run only the INT1 -> PLIC continuity test and exit.
NOISE_PIN_TEST ?= 0

include ../common/app.mk

CFLAGS += -I$(GPS_SYSTEM_DIR)/header
CFLAGS += -DNOISE_ODR_HZ=$(NOISE_ODR_HZ)u \
	-DNOISE_DISCARD_SAMPLES=$(NOISE_DISCARD_SAMPLES)u \
	-DNOISE_BIAS_SAMPLES=$(NOISE_BIAS_SAMPLES)u \
	-DNOISE_MEASURE_SAMPLES=$(NOISE_MEASURE_SAMPLES)u \
	-DNOISE_REQUIRE_IRQ=$(NOISE_REQUIRE_IRQ) \
	-DNOISE_PIN_TEST=$(NOISE_PIN_TEST)
LDLIBS += -lm
