Files
TurningTable/Makefile
T
kyle 66f5bfbf1a Initial commit: HC32F005 turning table firmware
Firmware (src/app):
- system state machine: IDLE / ROTATING / POWER_OFF
- button: 20 ms debounce, short/double/long classification, boot hold-off
- LED: idle slow blink, solid, speed/direction feedback patterns
- motor: 8-phase half-step drive with trapezoidal acceleration,
  speed levels 2.5/5/7.5/10 RPM, reversal via standstill
- power latch on P33 (push-pull, high = hold, low = cut) with
  decelerate-to-stop sequence before power-off (FR18)
- base timer mode-2 reload semantics (interval = 0x10000 - ARR)

Build: Makefile for arm-none-eabi-gcc, selective DDL compile,
vendor startup + linker script under src/.

Docs: FIRMWARE_REQUIREMENTS.md, STATE_MACHINE.md, README.md.
Vendor datasheet/RM/DDL references under docs/ are kept locally and
tracked in a separate shared repo.
2026-11-06 08:14:55 +00:00

95 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/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)