代码拉取完成,页面将自动刷新
######################################
# target
######################################
TARGET = CH32V103C8T6
######################################
# building variables
######################################
# debug build?
DEBUG = 1
# optimization
OPT =
#-Og
#######################################
# paths
#######################################
# Build path
BUILD_DIR = build
######################################
# source
######################################
# C sources
C_SOURCES = \
User/main.c \
User/system_ch32v10x.c \
User/ch32v10x_it.c \
Core/core_riscv.c \
Debug/debug.c \
Peripheral/src/ch32v10x_dbgmcu.c \
Peripheral/src/ch32v10x_gpio.c \
Peripheral/src/ch32v10x_misc.c \
Peripheral/src/ch32v10x_pwr.c \
Peripheral/src/ch32v10x_rcc.c \
Peripheral/src/ch32v10x_usart.c \
Peripheral/src/ch32v10x_rtc.c \
Peripheral/src/ch32v10x_spi.c \
Peripheral/src/ch32v10x_tim.c \
Peripheral/src/ch32v10x_i2c.c \
Peripheral/src/ch32v10x_iwdg.c \
Peripheral/src/ch32v10x_usb_host.c \
Peripheral/src/ch32v10x_usb.c \
Peripheral/src/ch32v10x_wwdg.c \
Peripheral/src/ch32v10x_adc.c \
Peripheral/src/ch32v10x_bkp.c \
Peripheral/src/ch32v10x_crc.c \
Peripheral/src/ch32v10x_dma.c \
Peripheral/src/ch32v10x_exti.c \
Peripheral/src/ch32v10x_flash.c \
# ASM sources
ASM_SOURCES = \
Startup/startup_ch32v10x.s
#######################################
# binaries
#######################################
PREFIX = riscv-none-embed-
CC = $(PREFIX)gcc
AS = $(PREFIX)gcc -x assembler-with-cpp
CP = $(PREFIX)objcopy
SZ = $(PREFIX)size
HEX = $(CP) -O ihex
BIN = $(CP) -O binary -S
#######################################
# CFLAGS
#######################################
# cpu
CPU = -march=rv32imac -mabi=ilp32 -msmall-data-limit=8
# fpu
#FPU = -mfpu=fpv5-d16
# float-abi
#FLOAT-ABI = -mfloat-abi=hard
# mcu
MCU = $(CPU) #-mthumb $(FPU) $(FLOAT-ABI)
# AS includes
AS_INCLUDES =
# C includes
C_INCLUDES = \
-IUser \
-IPeripheral/inc \
-IDebug \
-ICore \
# compile gcc flags
ASFLAGS = $(MCU) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
CFLAGS = $(MCU) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
ifeq ($(DEBUG), 1)
CFLAGS += -g -gdwarf-2
endif
# Generate dependency information
CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"
#######################################
# LDFLAGS
#######################################
# link script
LDSCRIPT = .ld
# libraries
LIBS = -lc -lm
LIBDIR =
LDFLAGS = $(MCU) -mno-save-restore -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -Wunused -Wuninitialized -g -T $(LDSCRIPT) -nostartfiles -Xlinker --gc-sections -L"../" -Wl,-Map=$(BUILD_DIR)/$(TARGET).map --specs=nano.specs --specs=nosys.specs -o "SWDTest.elf" $(LIBS)
# default action: build all
all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin
#######################################
# build the application
#######################################
# list of objects
OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
vpath %.c $(sort $(dir $(C_SOURCES)))
# list of ASM program objects
OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
vpath %.s $(sort $(dir $(ASM_SOURCES)))
$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
$(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
$(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
$(AS) -c $(CFLAGS) $< -o $@
#$(LUAOBJECTS) $(OBJECTS)
$(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
$(CC) $(OBJECTS) $(LDFLAGS) -o $@
$(SZ) $@
$(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
$(HEX) $< $@
$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
$(BIN) $< $@
$(BUILD_DIR):
mkdir $@
#######################################
# clean up
#######################################
clean:
-rm -fR $(BUILD_DIR)
#######################################
# dependencies
#######################################
-include $(wildcard $(BUILD_DIR)/*.d)
# *** EOF ***
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。