# The processor!
MCU_CORE=cm4
# Set up include paths
MCU_INCLUDE += -I$(LIBDIR)/CMSIS/Include
MCU_INCLUDE += -I$(LIBDIR)/CMSIS/Device/ST/STM32F37x/Include
MCU_INCLUDE += -I$(LIBDIR)/STM32F37x_StdPeriph_Driver/inc

# Set up CFLAGS
MCU_CPPFLAGS += -D"assert_param(expr)=((void)0)"
MCU_CFLAGS += -mcpu=cortex-m3 -mthumb -Wa,-mthumb 

# Target Libraries
MCU_LIBS += $(LIBDIR)/libstm32f37x.a

# CMSIS
STM32F37x_OBJS = $(LIBDIR)/CMSIS/Device/ST/STM32F37x/Source/Templates/system_stm32f37x.o
# Standard Peripheral Library
STM32F37x_OBJSR = stm32f37x_misc.o stm32f37x_dma.o stm32f37x_rcc.o \
	stm32f37x_adc.o stm32f37x_exti.o \
	stm32f37x_can.o stm32f37x_flash.o stm32f37x_rtc.o \
	stm32f37x_crc.o stm32f37x_gpio.o stm32f37x_spi.o \
	stm32f37x_syscfg.o stm32f37x_tim.o stm32f37x_usart.o \
	stm32f37x_dac.o stm32f37x_i2c.o stm32f37x_wwdg.o \
	stm32f37x_dbgmcu.o stm32f37x_iwdg.o stm32f37x_sdadc.o \
	stm32f37x_pwr.o stm32f37x_cec.o stm32f37x_comp.o

STM32F37x_OBJS += $(addprefix $(LIBDIR)/STM32F37x_StdPeriph_Driver/src/,$(STM32F37x_OBJSR))

# Bookkeeping
MCU_LIBS_OBJS += $(STM32F37x_OBJS)

# Build Rules
$(LIBDIR)/startup_$(MCU).o: $(LIBDIR)/CMSIS/Device/ST/STM32F37x/Source/Templates/gcc_ride7/startup_$(MCU).s
	@$(E) "  AS " $@
	$(Q)$(AS) -c -o $@ $<

$(LIBDIR)/libstm32f37x.a:  $(STM32F37x_OBJS) $(LIBDIR)/startup_$(MCU).o
	@$(E) "  AR " $@
	$(Q)$(AR) cr $@ $(STM32F37x_OBJS) $(LIBDIR)/startup_$(MCU).o

