summaryrefslogtreecommitdiff
path: root/controller/fw/Makefile
diff options
context:
space:
mode:
authorjaseg <git-bigdata-wsl-arch@jaseg.de>2020-03-02 19:42:36 +0100
committerjaseg <git-bigdata-wsl-arch@jaseg.de>2020-03-02 19:42:36 +0100
commitca01d52a8658ed01301f14a4d294097d4db533cf (patch)
tree28b32499b6a849beda66c6ebc70239fbd9f21530 /controller/fw/Makefile
parent5effadcbaf66f476c8fffefa2c349676f41c3f52 (diff)
downloadmaster-thesis-ca01d52a8658ed01301f14a4d294097d4db533cf.tar.gz
master-thesis-ca01d52a8658ed01301f14a4d294097d4db533cf.tar.bz2
master-thesis-ca01d52a8658ed01301f14a4d294097d4db533cf.zip
Finishing up freq meas
Diffstat (limited to 'controller/fw/Makefile')
-rw-r--r--controller/fw/Makefile46
1 files changed, 41 insertions, 5 deletions
diff --git a/controller/fw/Makefile b/controller/fw/Makefile
index 291f840..c01b01c 100644
--- a/controller/fw/Makefile
+++ b/controller/fw/Makefile
@@ -6,13 +6,17 @@ LIBSODIUM_DIR ?= libsodium
TINYAES_DIR ?= tinyaes
MUSL_DIR ?= musl
-C_SOURCES := src/main.c src/mspdebug_wrapper.c src/spi_flash.c
+C_SOURCES := src/main.c src/mspdebug_wrapper.c src/spi_flash.c src/freq_meas.c
C_SOURCES += $(MSPDEBUG_DIR)/drivers/jtaglib.c
C_SOURCES += $(CMSIS_DIR)/CMSIS/DSP/Source/TransformFunctions/arm_rfft_f32.c
C_SOURCES += $(CMSIS_DIR)/CMSIS/DSP/Source/TransformFunctions/arm_bitreversal.c
C_SOURCES += $(CMSIS_DIR)/CMSIS/DSP/Source/TransformFunctions/arm_cfft_radix4_f32.c
C_SOURCES += $(MUSL_DIR)/src/math/tanhf.c $(MUSL_DIR)/src/math/atanhf.c
C_SOURCES += $(MUSL_DIR)/src/math/expm1f.c $(MUSL_DIR)/src/math/log1pf.c
+C_SOURCES += $(MUSL_DIR)/src/math/expf.c $(MUSL_DIR)/src/math/exp2f_data.c
+C_SOURCES += $(MUSL_DIR)/src/math/__math_oflowf.c
+C_SOURCES += $(MUSL_DIR)/src/math/__math_uflowf.c
+C_SOURCES += $(MUSL_DIR)/src/math/__math_xflowf.c
CXX_SOURCES += src/ldpc_wrapper.cpp
@@ -24,6 +28,14 @@ OPENCM3_LIB := opencm3_stm32f4
PREFIX ?= arm-none-eabi-
+GOLD_CODE_NBITS ?= 5
+FMEAS_ADC_SAMPLING_RATE ?= 1000
+FMEAS_ADC_MAX ?= 4096
+FMEAS_FFT_LEN ?= 256
+FMEAS_FFT_WINDOW ?= gaussian
+FMEAS_FFT_WINDOW_SIGMA ?= 8.0
+
+
CC := $(PREFIX)gcc
CXX := $(PREFIX)g++
LD := $(PREFIX)gcc
@@ -32,6 +44,7 @@ AS := $(PREFIX)as
OBJCOPY := $(PREFIX)objcopy
OBJDUMP := $(PREFIX)objdump
GDB := $(PREFIX)gdb
+PYTHON3 ?= python3
OPENCM3_DIR_ABS := $(abspath $(OPENCM3_DIR))
CMSIS_DIR_ABS := $(abspath $(CMSIS_DIR))
@@ -41,14 +54,17 @@ TINYAES_DIR_ABS := $(abspath $(TINYAES_DIR))
MUSL_DIR_ABS := $(abspath $(MUSL_DIR))
CFLAGS += -I$(OPENCM3_DIR_ABS)/include -Imspdebug/util -Imspdebug/drivers
-CFLAGS += -I$(CMSIS_DIR_ABS)/CMSIS/DSP/Include -I$(CMSIS_DIR_ABS)/CMSIS/Core/Include
-CFLAGS += -I$(abspath musl_include_shims)
+CFLAGS += -I$(CMSIS_DIR_ABS)/CMSIS/DSP/Include -I$(CMSIS_DIR_ABS)/CMSIS/Core/Include -Dhidden=
+CFLAGS += -I$(abspath musl_include_shims) -Ilevmarq -D
CFLAGS += -Os -std=gnu11 -g -DSTM32F4
# Note: libopencm3 requires some standard libc definitions from stdint.h and stdbool.h, so we don't pass -nostdinc here.
CFLAGS += -nostdlib -ffreestanding
CFLAGS += -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16
CFLAGS += -fno-common -ffunction-sections -fdata-sections
+CFLAGS += -DGOLD_CODE_NBITS=$(GOLD_CODE_NBITS) -DFMEAS_FFT_LEN=$(FMEAS_FFT_LEN) -DFMEAS_ADC_MAX=$(FMEAS_ADC_MAX)
+CFLAGS += -DFMEAS_ADC_SAMPLING_RATE=$(FMEAS_ADC_SAMPLING_RATE) -DFMEAS_FFT_WINDOW=$(FMEAS_FFT_WINDOW)
+CFLAGS += -DFMEAS_FFT_WINDOW_SIGMA=$(FMEAS_FFT_WINDOW_SIGMA)
INT_CFLAGS += -Wall -Wextra -Wpedantic -Wshadow -Wimplicit-function-declaration -Wundef
INT_CFLAGS += -Wredundant-decls -Wmissing-prototypes -Wstrict-prototypes
@@ -71,7 +87,13 @@ all: $(BUILDDIR)/$(BINARY)
OBJS := $(addprefix $(BUILDDIR)/,$(C_SOURCES:.c=.o) $(CXX_SOURCES:.cpp=.o))
-$(BUILDDIR)/$(BINARY): $(OBJS) $(OPENCM3_DIR)/lib/lib$(OPENCM3_LIB).a $(BUILDDIR)/libsodium/src/libsodium/.libs/libsodium.a $(BUILDDIR)/tinyaes/aes.o
+$(BUILDDIR)/$(BINARY): $(OBJS) \
+ $(OPENCM3_DIR)/lib/lib$(OPENCM3_LIB).a \
+ $(BUILDDIR)/libsodium/src/libsodium/.libs/libsodium.a \
+ $(BUILDDIR)/tinyaes/aes.o \
+ $(BUILDDIR)/levmarq/levmarq.o \
+ $(BUILDDIR)/generated/gold_code_$(GOLD_CODE_NBITS).o \
+ $(BUILDDIR)/generated/fmeas_fft_window.o
$(LD) -T$(LDSCRIPT) $(LDFLAGS) -o $@ -Wl,-Map=$(BUILDDIR)/src/$*.map $^
$(BUILDDIR)/src/%.o: src/%.c
@@ -82,6 +104,10 @@ $(BUILDDIR)/src/%.o: src/%.cpp
mkdir -p $(@D)
$(CXX) $(CXXFLAGS) -o $@ -c $<
+$(BUILDDIR)/generated/%.o: $(BUILDDIR)/generated/%.c
+ mkdir -p $(@D)
+ $(CC) $(CFLAGS) $(INT_CFLAGS) -o $@ -c $<
+
$(BUILDDIR)/%.o: %.c
mkdir -p $(@D)
$(CC) $(CFLAGS) $(EXT_CFLAGS) -o $@ -c $<
@@ -97,11 +123,21 @@ $(BUILDDIR)/tinyaes/aes.o:
mkdir -p $(@D)
make -C $(@D) -f $(TINYAES_DIR_ABS)/Makefile VPATH=$(TINYAES_DIR_ABS) CFLAGS="$(CFLAGS) -c" CC=$(CC) LD=$(LD) AR=$(AR) aes.o
-ldpc_decoder_test.so: ldpc_decoder.c
+$(BUILDDIR)/generated/gold_code_%.c:
+ mkdir -p $(@D)
+ $(PYTHON3) tools/gold_code_header_gen.py $* > $@
+
+$(BUILDDIR)/generated/fmeas_fft_window.c:
+ mkdir -p $(@D)
+ $(PYTHON3) tools/fft_window_header_gen.py -v fmeas_fft_window_table $(FMEAS_FFT_WINDOW) $(FMEAS_FFT_LEN) $(FMEAS_FFT_WINDOW_SIGMA) > $@
+
+
+build/ldpc_decoder_test.so: src/ldpc_decoder.c
gcc -fPIC -shared -Wall -Wextra -Wpedantic -std=gnu11 -O0 -g -o $@ $^
clean:
-rm -r $(BUILDDIR)/src
+ -rm -r $(BUILDDIR)/generated
-rm $(BUILDDIR)/$(BINARY)
mrproper: clean