PROJECT = sphere
PROJECT_CSRC = main.c board.c libc_glue.c debug.c usb_usart.c motor.c control.c \
	rf_task.c lsm303.c sphere_shell.c sensor_task.c ahrs_task.c kalman.c \
	parameters.c \
	libfixmath/fix16.c libfixmath/fix16_sqrt.c libfixmath/fix16_trig.c \
	libfixmatrix/fixmatrix.c

USE_OPT = -O1 -g -gdwarf-2 -g3 \
	-fno-omit-frame-pointer -fno-common -std=gnu99 \
	-DFIXMATH_NO_CACHE -DFIXMATRIX_MAX_SIZE=8

UDEFS =
UADEFS =

UINCDIR = baselibc/include libfixmath libfixmatrix
ULIBDIR =
ULIBS = baselibc/libc.a -lgcc -nodefaultlibs

include Makefile.chibios

deploy: all
	arm-none-eabi-objcopy -Obinary build/sphere.elf build/sphere.bin
	echo -n '    ' >> build/sphere.bin
	swdflash write /dev/sg1 build/sphere.bin 0x08000000

debug: all
#	swdserver -1 -v0 -d /dev/sg1 2>/dev/null >/dev/null &
	arm-none-eabi-gdb build/sphere.elf -x gdb-target-def
	killall swdserver

build/obj/fixmatrix.o: CFLAGS+=-O2
