Hack in support for other boards/microcontrollers, add GpioDriver

There's definitely plenty of cleanup work to be done (see:
"ifdefs").
This commit is contained in:
2020-04-11 11:03:17 -07:00
parent 385402e7aa
commit 99317eb99b
17 changed files with 1156 additions and 99 deletions

View File

@@ -37,6 +37,10 @@ STM32_PROG = STM32_Programmer.sh
# Device Variables
#
BOARD ?= watch
ifeq ($(BOARD), watch)
DEVICE_TYPE ?= stm32l031k6
DEVICE_FAMILY = stm32l031xx
DEVICE_LINE = stm32l0xx
@@ -44,6 +48,21 @@ DEVICE_LINE = stm32l0xx
STACK_SIZE ?= 768
HEAP_SIZE ?= 0
else ifeq ($(BOARD), devboard)
DEVICE_TYPE ?= stm32l412rb
DEVICE_FAMILY = stm32l412xx
DEVICE_LINE = stm32l4xx
STACK_SIZE ?= 768
HEAP_SIZE ?= 0
else
$(error Unsupported board: $(BOARD))
endif
#
# Filenames and paths
#
@@ -81,7 +100,9 @@ OUTPUT_MAP ?= $(OUTPUT_NAME).map
# Flags
#
DEVICE_DEFINE = $(subst XX,xx,$(shell echo $(DEVICE_FAMILY) | tr '[:lower:]' '[:upper:]'))
DEVICE_FAMILY_DEFINE = $(subst XX,xx,$(shell echo $(DEVICE_FAMILY) | tr '[:lower:]' '[:upper:]'))
DEVICE_TYPE_DEFINE = $(shell echo $(DEVICE_TYPE) | tr '[:lower:]' '[:upper:]')
DEVICE_LINE_DEFINE = $(shell echo $(DEVICE_LINE) | tr '[:lower:]' '[:upper:]')
CPU_FLAGS = -mthumb -mcpu=cortex-m0plus -mfloat-abi=soft
@@ -96,8 +117,9 @@ CFLAGS += $(CPU_FLAGS)
CFLAGS += -ffreestanding
CFLAGS += -fstack-usage -Wstack-usage=128
# Defines
CFLAGS += -D$(DEVICE_DEFINE)
CFLAGS += -D$(DEVICE_FAMILY_DEFINE) -D$(DEVICE_TYPE_DEFINE) -D$(DEVICE_LINE_DEFINE)
# Includes
CFLAGS += -I./Bsp/Mcu/
CFLAGS += -I./ThirdParty/stm32/$(DEVICE_LINE)/Include
CFLAGS += -I./ThirdParty/CMSIS/Core/Include
CFLAGS += -I./build/gen/
@@ -118,6 +140,23 @@ LDFLAGS += -Wl,-print-memory-usage
# LDFLAGS += -lstdc++ -latomic
LDFLAGS += -nostartfiles
#
# Build info
#
$(info ================================)
$(info Build Parameters)
$(info Board: $(BOARD))
$(info Device: $(DEVICE_TYPE))
$(info Device define: $(DEVICE_TYPE_DEFINE))
$(info Device type define: $(DEVICE_FAMILY_DEFINE))
$(info Device line define: $(DEVICE_LINE_DEFINE))
$(info Stack size: $(STACK_SIZE))
$(info Heap size: $(HEAP_SIZE))
$(info ================================)
#
# Default Target
#
@@ -144,7 +183,7 @@ SMALL_FONT=ThirdParty/fonts/roboto_mono/RobotoMono-Regular.ttf
$(FONT_GEN_DIR)/small.h $(FONT_GEN_DIR)/small.c: Gen/fixedfont-to-c.py Gen/font.py
@echo "GEN $@"
@mkdir -p $(FONT_GEN_DIR)
@Gen/fixedfont-to-c.py $(patsubst .%,%,$(suffix $@)) $(SMALL_FONT) "$@" -s 24 --header-dir "Bsp/" --name font_small
@Gen/fixedfont-to-c.py $(patsubst .%,%,$(suffix $@)) $(SMALL_FONT) "$@" -s 20 --header-dir "Bsp/" --name font_small
LARGE_FONT=ThirdParty/fonts/roboto_mono/RobotoMono-Bold.ttf
$(FONT_GEN_DIR)/large_digits.h $(FONT_GEN_DIR)/large_digits.c: Gen/fixedfont-to-c.py Gen/font.py
@@ -171,6 +210,12 @@ flash: $(OUTPUT_BIN)
@echo "FLASH $(OUTPUT_BIN)"
$(STM32_PROG) --connect port=SWD reset=Hwrst -w $(OUTPUT_BIN) 0x8000000 -v --go
jlink: $(OUTPUT_BIN)
@echo "FLASH $(OUTPUT_BIN)"
JLinkExe -device $$(echo $(DEVICE_TYPE) | tr '[:lower:]' '[:upper:]') -if SWD \
-speed auto -autoconnect 1 -CommanderScript cmd.jlink
.PHONY: clean
clean:
rm -f $(OBJS) $(OUTPUT_BIN) $(OUTPUT_ELF) $(FONT_C_FILES) $(FONT_H_FILES) $(OUTPUT_MAP) $(addsuffix .su,$(basename $(OBJS)))