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

# Set up CFLAGS
MCU_CPPFLAGS += -D$(shell echo -n $(MCU_SUBTYPE) | tr a-z A-Z )
MCU_CPPFLAGS += -D"assert_param(expr)=((void)0)"
MCU_CFLAGS += -mcpu=cortex-m3 -mthumb -Wa,-mthumb 

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

# CMSIS
STM32W108xx_OBJS = $(LIBDIR)/CMSIS/Device/ST/STM32W108xx/Source/Templates/system_stm32w108xx.o
# Standard Peripheral Library
STM32W108xx_OBJSR = stm32w108xx_adc.o stm32w108xx_gpio.o stm32w108xx_sc.o \
	stm32w108xx_clk.o stm32w108xx_misc.o stm32w108xx_slptim.o \
	stm32w108xx_exti.o stm32w108xx_pwr.o stm32w108xx_tim.o \
	stm32w108xx_flash.o  stm32w108xx_rst.o stm32w108xx_wdg.o

STM32W108xx_OBJS += $(addprefix $(LIBDIR)/STM32W108xx_StdPeriph_Driver/src/,$(STM32W108xx_OBJSR))

# Bookkeeping
MCU_LIBS_OBJS += $(STM32W108xx_OBJS)

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

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

