# HG changeset patch # User Ethan Zonca # Date 2015-11-28 12:19:52 # Node ID 1900ee8afb4a94272b1d9d218303fdf9b08af7ce # Parent 235f584ead39a0872582013a0dba6f7a9f857c3b Rorganize diff --git a/Makefile b/Makefile --- a/Makefile +++ b/Makefile @@ -10,7 +10,8 @@ # SOURCES: list of sources in the user application -SOURCES = main.c usbd_conf.c usbd_cdc_if.c usb_device.c usbd_desc.c stm32f0xx_it.c system_stm32f0xx.c gpio.c spi.c ssd1306.c stringhelpers.c display.c syslib.c storage.c flash.c max31855.c max31865.c +SOURCES = main.c system/usbd_conf.c system/usbd_cdc_if.c system/usb_device.c system/usbd_desc.c system/interrupts.c system/system_stm32f0xx.c gpio.c spi.c ssd1306.c stringhelpers.c display.c system/syslib.c storage.c flash.c max31855.c max31865.c +#SRC = $(shell find . -name *.c) # TARGET: name of the user application TARGET = main @@ -24,7 +25,7 @@ LD_SCRIPT = stm32f042c6_flash.ld # USER_DEFS user defined macros USER_DEFS = -D HSI48_VALUE=48000000 -D HSE_VALUE=16000000 # USER_INCLUDES: user defined includes -USER_INCLUDES = +USER_INCLUDES = -Isystem # USB_INCLUDES: includes for the usb library USB_INCLUDES = -Imiddlewares/ST/STM32_USB_Device_Library/Core/Inc @@ -135,8 +136,11 @@ usb: $(USB_OBJECTS) # build the user application ####################################### +SYSTEM_BUILD_DIR = $(BUILD_DIR)/system + # list of user program objects -OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(SOURCES:.c=.o))) +#OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(SOURCES:.c=.o))) +OBJECTS = $(addprefix $(BUILD_DIR)/,$(SOURCES:.c=.o)) # add an object for the startup code OBJECTS += $(BUILD_DIR)/startup_stm32f042x6.o @@ -144,21 +148,25 @@ OBJECTS += $(BUILD_DIR)/startup_stm32f04 LIBS = -lstm32cube -lc -lm -lnosys LDFLAGS = -T $(LD_SCRIPT) -L $(CUBELIB_BUILD_DIR) $(LIBS) $(USER_LDFLAGS) -$(BUILD_DIR)/$(TARGET).hex: $(BUILD_DIR)/$(TARGET).elf +$(BUILD_DIR)/$(TARGET).hex: $(BUILD_DIR)/$(TARGET).elf | $(SYSTEM_BUILD_DIR) $(OBJCOPY) -O ihex $(BUILD_DIR)/$(TARGET).elf $@ $(OBJCOPY) -O binary $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).bin -$(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) $(USB_OBJECTS) $(CUBELIB) +$(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) $(USB_OBJECTS) $(CUBELIB) | $(SYSTEM_BUILD_DIR) $(CC) -o $@ $(CFLAGS) $(USER_LDFLAGS) $(OBJECTS) $(USB_OBJECTS) \ -L$(CUBELIB_BUILD_DIR) -static $(LIBS) -Xlinker \ -Map=$(BUILD_DIR)/$(TARGET).map \ -T $(LD_SCRIPT) $(SIZE) $@ -$(BUILD_DIR)/%.o: %.c | $(BUILD_DIR) +$(SYSTEM_BUILD_DIR): + @echo $(SYSTEM_BUILD_DIR) + $(MKDIR) $@ + +$(BUILD_DIR)/%.o: %.c | $(BUILD_DIR) $(SYSTEM_BUILD_DIR) $(CC) $(CFLAGS) -Os -c -o $@ $^ -$(BUILD_DIR)/%.o: %.s | $(BUILD_DIR) +$(BUILD_DIR)/%.o: %.s | $(BUILD_DIR) $(SYSTEM_BUILD_DIR) $(CC) $(CFLAGS) -c -o $@ $^ $(BUILD_DIR): diff --git a/stm32f0xx_it.c b/system/interrupts.c rename from stm32f0xx_it.c rename to system/interrupts.c --- a/stm32f0xx_it.c +++ b/system/interrupts.c @@ -34,7 +34,7 @@ /* Includes ------------------------------------------------------------------*/ #include "stm32f0xx_hal.h" #include "stm32f0xx.h" -#include "stm32f0xx_it.h" +#include "interrupts.h" /* USER CODE BEGIN 0 */ /* USER CODE END 0 */ diff --git a/stm32f0xx_it.h b/system/interrupts.h rename from stm32f0xx_it.h rename to system/interrupts.h diff --git a/startup_stm32f042x6.s b/system/startup_stm32f042x6.s rename from startup_stm32f042x6.s rename to system/startup_stm32f042x6.s diff --git a/syslib.c b/system/syslib.c rename from syslib.c rename to system/syslib.c diff --git a/syslib.h b/system/syslib.h rename from syslib.h rename to system/syslib.h diff --git a/usb_device.c b/system/usb_device.c rename from usb_device.c rename to system/usb_device.c diff --git a/usb_device.h b/system/usb_device.h rename from usb_device.h rename to system/usb_device.h diff --git a/usbd_cdc_if.c b/system/usbd_cdc_if.c rename from usbd_cdc_if.c rename to system/usbd_cdc_if.c diff --git a/usbd_cdc_if.h b/system/usbd_cdc_if.h rename from usbd_cdc_if.h rename to system/usbd_cdc_if.h diff --git a/usbd_conf.c b/system/usbd_conf.c rename from usbd_conf.c rename to system/usbd_conf.c diff --git a/usbd_conf.h b/system/usbd_conf.h rename from usbd_conf.h rename to system/usbd_conf.h diff --git a/usbd_desc.c b/system/usbd_desc.c rename from usbd_desc.c rename to system/usbd_desc.c diff --git a/usbd_desc.h b/system/usbd_desc.h rename from usbd_desc.h rename to system/usbd_desc.h