Drive motor IN1-IN4 from TIM4/TIM5 compare outputs (P23=TIM4_CHA, P24=TIM4_CHB, P25=TIM5_CHA, P26=TIM5_CHB) on a 15.625 kHz carrier derived at init from the actual PCLK (PCLK/2, 128-tick period; MCU boots on the 4 MHz internal RCH). Each half-step writes the four compare registers: an energized coil gets the speed level's duty cycle (85/90/95/100%), a de-energized coil gets a compare value above the period so its output stays static low. The advanced timers stop (outputs low) at standstill and power-off; coils stay energized at the level duty while parked for a reversal. No forced-output conditions are used, and the half-step sequencing and trapezoidal ramp are unchanged. Docs updated: FR19 in FIRMWARE_REQUIREMENTS.md, README.md, STATE_MACHINE.md.
96 lines
2.1 KiB
Makefile
96 lines
2.1 KiB
Makefile
# Makefile for the HC32F005C6PA turning-table firmware
|
|
# Toolchain: ARM GCC (arm-none-eabi-gcc)
|
|
|
|
TARGET := turntable
|
|
CROSS := arm-none-eabi-
|
|
CC := $(CROSS)gcc
|
|
AS := $(CROSS)gcc
|
|
LD := $(CROSS)gcc
|
|
OBJCOPY := $(CROSS)objcopy
|
|
OBJDUMP := $(CROSS)objdump
|
|
SIZE := $(CROSS)size
|
|
|
|
BUILD := build
|
|
|
|
# ---- source selection (keep only the DDL modules in use, NFR3) ----
|
|
APP_SRCS := \
|
|
src/app/main.c \
|
|
src/app/button.c \
|
|
src/app/led.c \
|
|
src/app/motor.c \
|
|
src/app/power.c
|
|
|
|
DDL_SRCS := \
|
|
src/driver/src/gpio.c \
|
|
src/driver/src/bt.c \
|
|
src/driver/src/sysctrl.c \
|
|
src/driver/src/adt.c \
|
|
src/driver/src/ddl.c
|
|
|
|
SYS_SRCS := \
|
|
src/common/system_hc32f005.c \
|
|
src/common/interrupts_hc32f005.c
|
|
|
|
ASM_SRCS := \
|
|
src/gcc/startup_hc32f005.S
|
|
|
|
SRCS := $(APP_SRCS) $(DDL_SRCS) $(SYS_SRCS)
|
|
|
|
# ---- includes ----
|
|
INCS := \
|
|
-Isrc/app \
|
|
-Isrc/common \
|
|
-Isrc/driver/inc \
|
|
-Isrc/cmsis
|
|
|
|
# ---- flags ----
|
|
CPU := -mcpu=cortex-m0plus -mthumb
|
|
# vendor DDL expects the external-crystal frequencies to be user-defined
|
|
# (see sysctrl.h note); defaults match the vendor documentation
|
|
DEFS := -DSYSTEM_XTH=32000000 -DSYSTEM_XTL=32768
|
|
CFLAGS := $(CPU) -Os -Wall -Wextra -std=c11 -Wno-main -Wno-unused-parameter \
|
|
-ffunction-sections -fdata-sections $(DEFS) $(INCS)
|
|
ASFLAGS := $(CPU)
|
|
LDFLAGS := $(CPU) -specs=nano.specs \
|
|
-Tsrc/gcc/hc32f005_flash.ld \
|
|
-Wl,--gc-sections \
|
|
-Wl,-Map=$(BUILD)/$(TARGET).map
|
|
|
|
OBJS := $(SRCS:%.c=$(BUILD)/%.o) $(ASM_SRCS:%.S=$(BUILD)/%.o)
|
|
DEPS := $(OBJS:.o=.d)
|
|
|
|
ELF := $(BUILD)/$(TARGET).elf
|
|
BIN := $(BUILD)/$(TARGET).bin
|
|
HEX := $(BUILD)/$(TARGET).hex
|
|
|
|
.PHONY: all clean size
|
|
|
|
all: $(ELF) $(BIN) $(HEX)
|
|
|
|
$(ELF): $(OBJS)
|
|
@mkdir -p $(dir $@)
|
|
$(LD) $(OBJS) $(LDFLAGS) -o $@
|
|
$(SIZE) $@
|
|
|
|
$(BUILD)/%.o: %.c
|
|
@mkdir -p $(dir $@)
|
|
$(CC) -c $(CFLAGS) -MMD -MP $< -o $@
|
|
|
|
$(BUILD)/%.o: %.S
|
|
@mkdir -p $(dir $@)
|
|
$(AS) -c $(ASFLAGS) $< -o $@
|
|
|
|
$(BIN): $(ELF)
|
|
$(OBJCOPY) -O binary $< $@
|
|
|
|
$(HEX): $(ELF)
|
|
$(OBJCOPY) -O ihex $< $@
|
|
|
|
size: $(ELF)
|
|
$(SIZE) $@
|
|
|
|
clean:
|
|
rm -rf $(BUILD)
|
|
|
|
-include $(DEPS)
|