diff --git a/.gitignore b/.gitignore index 024f413..6bbc107 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .cache compile_commands.json build -obj \ No newline at end of file +obj +asm \ No newline at end of file diff --git a/Makefile b/Makefile index 2e5bef1..899e948 100644 --- a/Makefile +++ b/Makefile @@ -50,7 +50,6 @@ PROJ_SRCS=$(shell find $(SRC_DIR) -name "*.c") OBJS=$(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.o,$(PROJ_SRCS)) ASMS=$(patsubst $(SRC_DIR)/%.c,$(ASM_DIR)/%.S,$(PROJ_SRCS)) - ifneq (, $(filter $(PLATFORM), $(BUILD_CONFIGS_MK))) include build_config/$(PLATFORM).mk else diff --git a/build_config/ch32.mk b/build_config/ch32.mk index 3e9144c..76612db 100644 --- a/build_config/ch32.mk +++ b/build_config/ch32.mk @@ -1,5 +1,6 @@ # === Directories path ============================================================================= EVT_DIR=/opt/wch/CH32V003EVT/EVT/EXAM/SRC +PLATFORM_DIR=platform/ch32v00x # ================================================================================================== @@ -19,6 +20,7 @@ CC_FLAGS+=-march=rv32ec_zicsr CC_FLAGS+=-mabi=ilp32e CC_FLAGS+=-I$(EVT_DIR)/Core CC_FLAGS+=-I$(EVT_DIR)/Peripheral/inc +CC_FLAGS+=-I./platform/ch32v00x # ================================================================================================== @@ -28,11 +30,15 @@ LDSCRIPT+=./ld/Link.ld LD_FLAGS+=-T$(LDSCRIPT) # ================================================================================================== + + # Adds WCH SDK to compile flow -STARTUP_SRC=./startup_ch32v00x.S +STARTUP_SRC=$(PLATFORM_DIR)/startup_ch32v00x.S +PLATFORM_SRCS=$(shell find platform/ch32v00x -name "*.c") EVT_SRCS=$(shell find $(EVT_DIR)/Core -name "*.c") EVT_SRCS+=$(shell find $(EVT_DIR)/Peripheral -name "*.c") OBJS+=$(patsubst $(EVT_DIR)/%.c,$(OBJ_DIR)/evt/%.o,$(EVT_SRCS)) +OBJS+=$(patsubst $(PLATFORM_DIR)/%.c,$(OBJ_DIR)/$(PLATFORM_DIR)/%.o,$(PLATFORM_SRCS)) OBJS+=$(OBJ_DIR)/startup_ch32v00x.o prog_flash: $(OUT_DIR)/$(TARGET).bin @@ -47,6 +53,10 @@ $(OBJ_DIR)/evt/%.o: $(EVT_DIR)/%.c @mkdir -p $(dir $@) $(CC) $(CC_FLAGS) -c $< -o $@ +$(OBJ_DIR)/$(PLATFORM_DIR)/%.o: $(PLATFORM_DIR)/%.c + @mkdir -p $(dir $@) + $(CC) $(CC_FLAGS) -c $< -o $@ + $(OBJ_DIR)/startup_ch32v00x.o: $(STARTUP_SRC) @mkdir -p $(dir $@) $(CC) $(CC_FLAGS) -c $< -o $@ \ No newline at end of file diff --git a/src/ch32v00x_conf.h b/platform/ch32v00x/ch32v00x_conf.h similarity index 100% rename from src/ch32v00x_conf.h rename to platform/ch32v00x/ch32v00x_conf.h diff --git a/src/ch32v00x_it.c b/platform/ch32v00x/ch32v00x_it.c similarity index 100% rename from src/ch32v00x_it.c rename to platform/ch32v00x/ch32v00x_it.c diff --git a/src/ch32v00x_it.h b/platform/ch32v00x/ch32v00x_it.h similarity index 100% rename from src/ch32v00x_it.h rename to platform/ch32v00x/ch32v00x_it.h diff --git a/src/debug.c b/platform/ch32v00x/debug.c similarity index 100% rename from src/debug.c rename to platform/ch32v00x/debug.c diff --git a/src/debug.h b/platform/ch32v00x/debug.h similarity index 100% rename from src/debug.h rename to platform/ch32v00x/debug.h diff --git a/startup_ch32v00x.S b/platform/ch32v00x/startup_ch32v00x.S similarity index 100% rename from startup_ch32v00x.S rename to platform/ch32v00x/startup_ch32v00x.S diff --git a/src/system_ch32v00x.c b/platform/ch32v00x/system_ch32v00x.c similarity index 100% rename from src/system_ch32v00x.c rename to platform/ch32v00x/system_ch32v00x.c diff --git a/src/system_ch32v00x.h b/platform/ch32v00x/system_ch32v00x.h similarity index 100% rename from src/system_ch32v00x.h rename to platform/ch32v00x/system_ch32v00x.h diff --git a/src/main.c b/src/main.c index 55014b7..0d4e0ec 100644 --- a/src/main.c +++ b/src/main.c @@ -1,4 +1,4 @@ -#include "debug.h" +#include "../platform/ch32v00x/debug.h" int main(void) { GPIO_InitTypeDef GPIO_InitStructure = {0};