# The processor!
MCU_CORE=cm3
# Set up include paths
MCU_INCLUDE += -I$(LIBDIR)/CMSIS/Include
MCU_INCLUDE += -I$(LIBDIR)/CMSIS/Device/ST/STM32F2xx/Include
MCU_INCLUDE += -I$(LIBDIR)/STM32F2xx_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)/libstm32f2xx.a

# CMSIS
STM32F2xx_OBJS = $(LIBDIR)/CMSIS/Device/ST/STM32F2xx/Source/Templates/system_stm32f2xx.o
# Standard Peripheral Library
STM32F2xx_OBJSR = misc.o stm32f2xx_dma.o stm32f2xx_rcc.o \
	stm32f2xx_adc.o stm32f2xx_exti.o stm32f2xx_rng.o \
	stm32f2xx_can.o stm32f2xx_flash.o stm32f2xx_rtc.o \
	stm32f2xx_crc.o stm32f2xx_fsmc.o stm32f2xx_sdio.o \
	stm32f2xx_cryp_aes.o stm32f2xx_gpio.o stm32f2xx_spi.o \
	stm32f2xx_cryp.o stm32f2xx_hash.o stm32f2xx_syscfg.o \
	stm32f2xx_cryp_des.o stm32f2xx_hash_md5.o stm32f2xx_tim.o \
	stm32f2xx_cryp_tdes.o stm32f2xx_hash_sha1.o stm32f2xx_usart.o \
	stm32f2xx_dac.o stm32f2xx_i2c.o stm32f2xx_wwdg.o \
	stm32f2xx_dbgmcu.o stm32f2xx_iwdg.o stm32f2xx_dcmi.o \
	stm32f2xx_pwr.o

STM32F2xx_OBJS += $(addprefix $(LIBDIR)/STM32F2xx_StdPeriph_Driver/src/,$(STM32F2xx_OBJSR))

# Bookkeeping
MCU_LIBS_OBJS += $(STM32F2xx_OBJS)

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

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

