summaryrefslogtreecommitdiff
path: root/controller/fw/Makefile
diff options
context:
space:
mode:
authorjaseg <git-bigdata-wsl-arch@jaseg.de>2020-03-05 19:15:28 +0100
committerjaseg <git-bigdata-wsl-arch@jaseg.de>2020-03-05 19:15:28 +0100
commit4b419bd1ad9f22266e068341176f5ab665a26222 (patch)
treeec5ee9e379d4de3e15b33f0b640b700bef0750bc /controller/fw/Makefile
parentd9b26d16c063aec32b70287ff861a1f23642a9f2 (diff)
downloadmaster-thesis-4b419bd1ad9f22266e068341176f5ab665a26222.tar.gz
master-thesis-4b419bd1ad9f22266e068341176f5ab665a26222.tar.bz2
master-thesis-4b419bd1ad9f22266e068341176f5ab665a26222.zip
Working on DSSS demodulator sim
Diffstat (limited to 'controller/fw/Makefile')
-rw-r--r--controller/fw/Makefile64
1 files changed, 45 insertions, 19 deletions
diff --git a/controller/fw/Makefile b/controller/fw/Makefile
index 8dfcb1d..cc7d156 100644
--- a/controller/fw/Makefile
+++ b/controller/fw/Makefile
@@ -6,7 +6,7 @@ LIBSODIUM_DIR ?= libsodium
TINYAES_DIR ?= tinyaes
MUSL_DIR ?= musl
-C_SOURCES := src/main.c src/mspdebug_wrapper.c src/spi_flash.c src/freq_meas.c
+C_SOURCES := src/main.c src/mspdebug_wrapper.c src/spi_flash.c src/freq_meas.c src/dsss_demod.c
C_SOURCES += $(MSPDEBUG_DIR)/drivers/jtaglib.c
CMSIS_SOURCES += $(CMSIS_DIR)/CMSIS/DSP/Source/TransformFunctions/arm_rfft_fast_init_f32.c
@@ -41,13 +41,17 @@ 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 ?= 16.0
+DSSS_GOLD_CODE_NBITS ?= 5
+DSSS_DECIMATION ?= 10
+DSSS_THESHOLD_FACTOR ?= 4.0f
+DSSS_WAVELET_WIDTH ?= 7.3
+DSSS_WAVELET_LUT_SIZE ?= 69
CC := $(PREFIX)gcc
CXX := $(PREFIX)g++
@@ -78,6 +82,7 @@ MUSL_DIR_ABS := $(abspath $(MUSL_DIR))
COMMON_CFLAGS += -I$(OPENCM3_DIR_ABS)/include -Imspdebug/util -Imspdebug/drivers -Ilevmarq
COMMON_CFLAGS += -I$(CMSIS_DIR_ABS)/CMSIS/DSP/Include -I$(CMSIS_DIR_ABS)/CMSIS/Core/Include
CFLAGS += -I$(abspath musl_include_shims)
+COMMON_CFLAGS += -I$(BUILDDIR) -Isrc
COMMON_CFLAGS += -Os -std=gnu11 -g -DSTM32F4
CFLAGS += -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16
@@ -85,13 +90,18 @@ CFLAGS += -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16
# Note: libopencm3 requires some standard libc definitions from stdint.h and stdbool.h, so we don't pass -nostdinc here.
CFLAGS += -nostdlib -ffreestanding
CFLAGS += -fno-common -ffunction-sections -fdata-sections
-COMMON_CFLAGS += -DGOLD_CODE_NBITS=$(GOLD_CODE_NBITS) -DFMEAS_FFT_LEN=$(FMEAS_FFT_LEN) -DFMEAS_ADC_MAX=$(FMEAS_ADC_MAX)
+COMMON_CFLAGS += -DDSSS_GOLD_CODE_NBITS=$(DSSS_GOLD_CODE_NBITS) -DFMEAS_FFT_LEN=$(FMEAS_FFT_LEN) -DFMEAS_ADC_MAX=$(FMEAS_ADC_MAX)
COMMON_CFLAGS += -DFMEAS_ADC_SAMPLING_RATE=$(FMEAS_ADC_SAMPLING_RATE)
COMMON_CFLAGS += -DFMEAS_FFT_WINDOW_SIGMA=$(FMEAS_FFT_WINDOW_SIGMA)
+COMMON_CFLAGS += -DDSSS_DECIMATION=$(DSSS_DECIMATION)
+COMMON_CFLAGS += -DDSSS_THESHOLD_FACTOR=$(DSSS_THESHOLD_FACTOR)
+COMMON_CFLAGS += -DDSSS_WAVELET_WIDTH=$(DSSS_WAVELET_WIDTH)
+COMMON_CFLAGS += -DDSSS_WAVELET_LUT_SIZE=$(DSSS_WAVELET_LUT_SIZE)
+
# for musl
CFLAGS += -Dhidden=
-SIM_CFLAGS += -Isrc -lm -DSIMULATION
+SIM_CFLAGS += -lm -DSIMULATION
INT_CFLAGS += -Wall -Wextra -Wpedantic -Wshadow -Wimplicit-function-declaration -Wundef
INT_CFLAGS += -Wredundant-decls -Wmissing-prototypes -Wstrict-prototypes
@@ -112,7 +122,24 @@ LDFLAGS += -L$(OPENCM3_DIR_ABS)/lib -l$(OPENCM3_LIB) $(shell $(CC) -print-libg
all: $(BUILDDIR)/$(BINARY)
-tests: $(BUILDDIR)/tools/freq_meas_test
+src/dsss_demod.c: $(BUILDDIR)/generated/dsss_gold_code.h
+
+$(BUILDDIR)/generated/dsss_gold_code.h: $(BUILDDIR)/generated/gold_code_$(DSSS_GOLD_CODE_NBITS).h
+ ln -srf $< $@
+
+.PRECIOUS: $(BUILDDIR)/generated/gold_code_%.c
+$(BUILDDIR)/generated/gold_code_%.c $(BUILDDIR)/generated/gold_code_%.h: | $(BUILDDIR)/generated
+ $(PYTHON3) tools/gold_code_header_gen.py -v dsss_gold_code_table -$(patsubst .%,%,$(suffix $@)) $* > $@
+
+.PRECIOUS: $(BUILDDIR)/generated/fmeas_fft_window.c
+$(BUILDDIR)/generated/fmeas_fft_window.c: | $(BUILDDIR)/generated
+ $(PYTHON3) tools/fft_window_header_gen.py -v fmeas_fft_window_table $(FMEAS_FFT_WINDOW) $(FMEAS_FFT_LEN) $(FMEAS_FFT_WINDOW_SIGMA) > $@
+
+.PRECIOUS: $(BUILDDIR)/generated/dsss_cwt_wavelet.c
+$(BUILDDIR)/generated/dsss_cwt_wavelet.c: | $(BUILDDIR)/generated
+ $(PYTHON3) tools/cwt_wavelet_header_gen.py -v dsss_cwt_wavelet_table $(DSSS_WAVELET_LUT_SIZE) $(DSSS_WAVELET_WIDTH) > $@
+
+$(BUILDDIR)/generated: ; mkdir -p $@
OBJS := $(addprefix $(BUILDDIR)/,$(C_SOURCES:.c=.o) $(CXX_SOURCES:.cpp=.o))
@@ -121,16 +148,23 @@ ALL_OBJS += $(OPENCM3_DIR)/lib/lib$(OPENCM3_LIB).a
ALL_OBJS += $(BUILDDIR)/libsodium/src/libsodium/.libs/libsodium.a
ALL_OBJS += $(BUILDDIR)/tinyaes/aes.o
ALL_OBJS += $(BUILDDIR)/levmarq/levmarq.o
-ALL_OBJS += $(BUILDDIR)/generated/gold_code_$(GOLD_CODE_NBITS).o
+ALL_OBJS += $(BUILDDIR)/generated/gold_code_$(DSSS_GOLD_CODE_NBITS).o
ALL_OBJS += $(BUILDDIR)/generated/fmeas_fft_window.o
+ALL_OBJS += $(BUILDDIR)/generated/dsss_cwt_wavelet.o
$(BUILDDIR)/$(BINARY): $(ALL_OBJS)
$(LD) -T$(LDSCRIPT) $(COMMON_LDFLAGS) $(LDFLAGS) -o $@ -Wl,-Map=$(BUILDDIR)/src/$*.map $^
+tools: $(BUILDDIR)/tools/freq_meas_test
$(BUILDDIR)/tools/freq_meas_test: tools/freq_meas_test.c src/freq_meas.c levmarq/levmarq.c $(BUILDDIR)/generated/fmeas_fft_window.c $(CMSIS_SOURCES)
mkdir -p $(@D)
$(HOST_CC) $(COMMON_CFLAGS) $(SIM_CFLAGS) -o $@ $^
+tools: $(BUILDDIR)/tools/dsss_demod_test
+$(BUILDDIR)/tools/dsss_demod_test: tools/dsss_demod_test.c src/dsss_demod.c $(BUILDDIR)/generated/dsss_cwt_wavelet.c $(BUILDDIR)/generated/gold_code_$(DSSS_GOLD_CODE_NBITS).c
+ mkdir -p $(@D)
+ $(HOST_CC) $(COMMON_CFLAGS) $(SIM_CFLAGS) -o $@ $^
+
$(BUILDDIR)/src/%.o: src/%.c
mkdir -p $(@D)
$(CC) $(COMMON_CFLAGS) $(CFLAGS) $(INT_CFLAGS) -o $@ -c $<
@@ -158,14 +192,6 @@ $(BUILDDIR)/tinyaes/aes.o:
mkdir -p $(@D)
make -C $(@D) -f $(TINYAES_DIR_ABS)/Makefile VPATH=$(TINYAES_DIR_ABS) CFLAGS="$(COMMON_CFLAGS) $(CFLAGS) -c" CC=$(CC) LD=$(LD) AR=$(AR) aes.o
-$(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) > $@
-
$(BUILDDIR)/musl/lib/libc.a:
mkdir -p $(BUILDDIR)/musl
cd $(BUILDDIR)/musl && CFLAGS="$(SIM_CFLAGS) $(COMMON_CFLAGS)" CC=$(CC) LD=$(LD) AR=$(AR) $(MUSL_DIR_ABS)/configure && $(MAKE) TARGET=arm-linux-musleabihf GCC_CONFIG="-mcpu=cortex-m4 -mfloat-abi=soft" -j $(shell nproc)
@@ -174,13 +200,13 @@ 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)
- -rm $(BUILDDIR)/tools/freq_meas_test
+ rm -rf $(BUILDDIR)/src
+ rm -rf $(BUILDDIR)/generated
+ rm -f $(BUILDDIR)/$(BINARY)
+ rm -f $(BUILDDIR)/tools/freq_meas_test
mrproper: clean
- -rm -r build
+ rm -rf build
-$(MAKE) -C $(OPENCM3_DIR) clean
.PHONY: clean mrproper