From 5b0dbb97437305c20525f558b6a74bb25190c9d1 Mon Sep 17 00:00:00 2001 From: Max Regan Date: Mon, 13 Apr 2020 19:47:33 -0700 Subject: [PATCH] Add lightweight printf support For now, printf() isn't hooked up to anything, but snprintf() can be used to create a string to pass off to usart.tx_blocking(). --- .gitmodules | 3 +++ firmware/Makefile | 6 +++++- firmware/ThirdParty/printf | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 .gitmodules create mode 160000 firmware/ThirdParty/printf diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..fb39347 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "firmware/ThirdParty/printf"] + path = firmware/ThirdParty/printf + url = https://github.com/mpaland/printf.git diff --git a/firmware/Makefile b/firmware/Makefile index 592fce7..5852a84 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -69,7 +69,7 @@ endif # Ignores dotfiles and other garbage some tools leave behind define find_important - $(shell find $(1) -type f -and -name $(2) -and -not -iname "*~" -and -not -iname "*#*" -and -not \( -path "*.cquery_cached_index*" \) -and -not \( -path "*build*" \) ) + $(shell find $(1) -type f -and -name $(2) -and -not -iname "*~" -and -not -iname "*#*" -and -not \( -path "*.cquery_cached_index*" \) -and -not \( -path "*build*" \) -and -not \( -path "*ThirdParty/printf/test/*" \) ) endef FONTS := small large_digits @@ -118,10 +118,14 @@ CFLAGS += -ffreestanding CFLAGS += -fstack-usage -Wstack-usage=128 # Defines CFLAGS += -D$(DEVICE_FAMILY_DEFINE) -D$(DEVICE_TYPE_DEFINE) -D$(DEVICE_LINE_DEFINE) +CFLAGS += -DPRINTF_DISABLE_SUPPORT_FLOAT -DPRINTF_DISABLE_SUPPORT_EXPONENTIAL -DPRINTF_DISABLE_SUPPORT_PTRDIFF_T +# Consider this one if we are running short on flash, it saved about 1K +#CFLAGS += -DPRINTF_DISABLE_SUPPORT_LONG_LONG # Includes CFLAGS += -I./Bsp/Mcu/ CFLAGS += -I./ThirdParty/stm32/$(DEVICE_LINE)/Include CFLAGS += -I./ThirdParty/CMSIS/Core/Include +CFLAGS += -I./ThirdParty/printf CFLAGS += -I./build/gen/ CFLAGS += -I. diff --git a/firmware/ThirdParty/printf b/firmware/ThirdParty/printf new file mode 160000 index 0000000..d3b9846 --- /dev/null +++ b/firmware/ThirdParty/printf @@ -0,0 +1 @@ +Subproject commit d3b984684bb8a8bdc48cc7a1abecb93ce59bbe3e