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

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

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

# CMSIS
STM32F0xx_OBJS = $(LIBDIR)/CMSIS/Device/ST/STM32F0xx/Source/Templates/system_stm32f0xx.o
# Standard Peripheral Library
STM32F0xx_OBJSR = stm32f0xx_adc.o stm32f0xx_cec.o stm32f0xx_comp.o \
	stm32f0xx_crc.o stm32f0xx_dac.o stm32f0xx_dbgmcu.o \
	stm32f0xx_dma.o stm32f0xx_exti.o stm32f0xx_flash.o \
	stm32f0xx_gpio.o stm32f0xx_i2c.o stm32f0xx_iwdg.o \
	stm32f0xx_misc.o stm32f0xx_pwr.o stm32f0xx_rcc.o \
	stm32f0xx_rtc.o stm32f0xx_spi.o stm32f0xx_syscfg.o \
	stm32f0xx_tim.o stm32f0xx_usart.o stm32f0xx_wwdg.o

STM32F0xx_OBJS += $(addprefix $(LIBDIR)/STM32F0xx_StdPeriph_Driver/src/,$(STM32F0xx_OBJSR))

# Bookkeeping
MCU_LIBS_OBJS += $(STM32F0xx_OBJS)

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

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

