Huge refactoring for C++ and low-power mode

The display currently shows the time, with hours and minutes, and is
capable of receiving input with buttons (though does nothing). It
sleeps during intervals where nothing is happening. The display task
runs once per second, and RTC alarm A is used for periodic alarms to
update the system time.
This commit is contained in:
2019-04-17 21:51:35 -07:00
parent 6747d6c831
commit a7f1ffc1b5
22 changed files with 1051 additions and 231 deletions

View File

@@ -24,14 +24,14 @@
# Tools
#
TOOL_PREFIX ?= arm-eabi-
TOOL_PREFIX ?= arm-none-eabi-
CC = $(TOOL_PREFIX)gcc
CXX = $(TOOL_PREFIX)g++
CPP = $(TOOL_PREFIX)cpp
AS = $(TOOL_PREFIX)as
LD = $(TOOL_PREFIX)gcc
LD = $(TOOL_PREFIX)g++
OBJCOPY = $(TOOL_PREFIX)objcopy
STM32_PROG = STM32_Programmer.sh
#
# Device Variables
#
@@ -73,13 +73,15 @@ OUTPUT_ELF ?= $(OUTPUT_NAME).elf
DEVICE_DEFINE = $(subst XX,xx,$(shell echo $(DEVICE_FAMILY) | tr '[:lower:]' '[:upper:]'))
CPU_FLAGS = -mthumb -mcpu=cortex-m0 -mfloat-abi=soft
# C pedantism
CFLAGS = -Wall -Wextra -Wpedantic
# Debug/optimization
CFLAGS += -ggdb -g3
CFLAGS += -ggdb -g3 -Os
CFLAGS += -fdata-sections -ffunction-sections
# Architecture
CFLAGS += -mthumb -mcpu=cortex-m0plus
CFLAGS += $(CPU_FLAGS)
CFLAGS += -ffreestanding
# Defines
CFLAGS += -D$(DEVICE_DEFINE)
@@ -91,12 +93,14 @@ CFLAGS += -I./lib/fonts/
CXX_FLAGS = -std=c++14 -fno-exceptions -fno-rtti
# Startup Definitions
ASFLAGS += $(CPU_FLAGS)
ASFLAGS += -D__STARTUP_CLEAR_BSS
ASFLAGS += -D__HEAP_SIZE=0 # No heap- let the linker decide it all
LDFLAGS += -lc -lstdc++ -nostdinc -lnosys -Wl,--gc-sections -Wl,--build-id=None
LDFLAGS += -Wl,--wrap=malloc -Wl,--wrap=free # Fail to compile if dynamic allocation is sneaking through
LDFLAGS += -mthumb -mcpu=cortex-m0plus
LDFLAGS += $(CPU_FLAGS)
LDFLAGS += -Wl,--gc-sections -Wl,--build-id=none -static
LDFLAGS += -Wl,--wrap=malloc -Wl,--wrap=free # Fail to link if dynamic allocation is sneaking through
LDFLAGS += -Wl,-print-memory-usage
#
# Default Target
@@ -126,7 +130,7 @@ $(OUTPUT_BIN): $(OUTPUT_ELF)
$(OUTPUT_ELF): $(LINKER_SCRIPT) $(OBJS)
@echo "LD $@"
@$(LD) $(LDFLAGS) -T $(LINKER_SCRIPT) -o $(OUTPUT_ELF) $(OBJS)
$(LD) -T $(LINKER_SCRIPT) $(LDFLAGS) -o $(OUTPUT_ELF) $(OBJS)
#
# Utilities
@@ -137,8 +141,7 @@ STM32FLASH_DEVICE = /dev/ttyUSB0
.PHONY: flash
flash: $(OUTPUT_BIN)
@echo "FLASH $(OUTPUT_BIN)"
@st-flash write $(OUTPUT_BIN) 0x8000000
$(STM32_PROG) --connect port=SWD reset=Hwrst -w $(OUTPUT_BIN) 0x8000000 -v --go
.PHONY: clean
clean: