123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- TARGET = MNC-IN12x5
- DEBUG = 0
- OPT = -Os
- OPT += -ffunction-sections -fdata-sections
- OPT += -fno-strict-aliasing
- OPT += -ffast-math -msoft-float -mfloat-abi=soft
- BUILD_DIR = build
- C_SOURCES = \
- Src/main.c \
- Src/board.c \
- Src/sensor.c \
- Src/clock.c \
- Src/stm32g0xx_it.c \
- Src/i2c.c \
- Src/ds3231.c \
- Src/bme280.c \
- Src/rtos.c \
- Src/event-system.c \
- Src/system_stm32g0xx.c
- ASM_SOURCES = \
- Drivers/startup_stm32g030xx.s
- PREFIX = arm-none-eabi-
- ifdef GCC_PATH
- CC = $(GCC_PATH)/$(PREFIX)gcc
- AS = $(GCC_PATH)/$(PREFIX)gcc -x assembler-with-cpp
- CP = $(GCC_PATH)/$(PREFIX)objcopy
- SZ = $(GCC_PATH)/$(PREFIX)size
- else
- CC = $(PREFIX)gcc
- AS = $(PREFIX)gcc -x assembler-with-cpp
- CP = $(PREFIX)objcopy
- SZ = $(PREFIX)size
- endif
- HEX = $(CP) -O ihex
- BIN = $(CP) -O binary -S
-
- CPU = -mcpu=cortex-m0plus
- MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)
- AS_DEFS =
- C_DEFS = \
- -DUSE_FULL_LL_DRIVER \
- -DHSE_VALUE=8000000 \
- -DHSE_STARTUP_TIMEOUT=100 \
- -DLSE_STARTUP_TIMEOUT=5000 \
- -DLSE_VALUE=32768 \
- -DEXTERNAL_CLOCK_VALUE=12288000 \
- -DHSI_VALUE=16000000 \
- -DLSI_VALUE=32000 \
- -DVDD_VALUE=3300 \
- -DPREFETCH_ENABLE=0 \
- -DINSTRUCTION_CACHE_ENABLE=1 \
- -DDATA_CACHE_ENABLE=1 \
- -DSTM32G030xx
- AS_INCLUDES =
- C_INCLUDES = \
- -IInc \
- -IDrivers/STM32G0xx_HAL_Driver/Inc \
- -IDrivers/CMSIS/Device/ST/STM32G0xx/Include \
- -IDrivers/CMSIS/Include
- ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall
- CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall
- ifeq ($(DEBUG), 1)
- CFLAGS += -g -gdwarf-2
- endif
- CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"
- CFLAGS += -std=gnu11 -pedantic
- LDSCRIPT = Drivers/STM32G030K8Tx_FLASH.ld
- LIBS = -lc -lm -lnosys
- LIBDIR =
- LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
- all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex
- OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
- vpath %.c $(sort $(dir $(C_SOURCES)))
- OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
- vpath %.s $(sort $(dir $(ASM_SOURCES)))
- $(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
- @echo Compiling $<
- @$(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
- $(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
- @echo Compiling $<
- @$(AS) -c $(CFLAGS) $< -o $@
- $(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
- @echo Linking...
- @$(CC) $(OBJECTS) $(LDFLAGS) -o $@
- @echo Size:
- @$(SZ) $@
- $(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
- @echo Make HEX...
- @$(HEX) $< $@
-
-
- $(BUILD_DIR):
- mkdir $@
- clean:
- -rm -fR $(BUILD_DIR)
-
- -include $(wildcard $(BUILD_DIR)/*.d)
- flash: all
- @flash.cmd
- default: all
|