From c814df567156a59dc0070872df85809c38bea65f Mon Sep 17 00:00:00 2001 From: drowe67 Date: Fri, 18 Jul 2014 05:24:55 +0000 Subject: [PATCH] first pass at stm modem profiling UT, untested git-svn-id: https://svn.code.sf.net/p/freetel/code@1765 01035d8c-6547-0410-b346-abe4f91aad63 --- codec2-dev/stm32/Makefile | 56 ++++++----- .../stm32/src/{main.c => codec2_profile.c} | 28 +++++- codec2-dev/stm32/src/fdmdv_profile.c | 98 +++++++++++++++++++ codec2-dev/stm32/src/stm32f4_timer.c | 7 +- 4 files changed, 160 insertions(+), 29 deletions(-) rename codec2-dev/stm32/src/{main.c => codec2_profile.c} (78%) create mode 100644 codec2-dev/stm32/src/fdmdv_profile.c diff --git a/codec2-dev/stm32/Makefile b/codec2-dev/stm32/Makefile index 917e1ae2..661b21aa 100644 --- a/codec2-dev/stm32/Makefile +++ b/codec2-dev/stm32/Makefile @@ -2,7 +2,6 @@ ################################################### -PROJ_NAME=stm32f4_codec2 FLOAT_TYPE=hard ################################################### @@ -45,14 +44,10 @@ CFLAGS += -DARM_MATH_CM4 ################################################### -# Sources - -SRCS = main.c gdb_stdio.c stm32f4_timer.c system_stm32f4xx.c - # Codec 2 CODEC2_SRC=../src -SRCS += \ +CODEC2_SRCS=\ $(CODEC2_SRC)/lpc.c \ $(CODEC2_SRC)/nlp.c \ $(CODEC2_SRC)/postfilter.c \ @@ -68,7 +63,8 @@ $(CODEC2_SRC)/codebook.c \ $(CODEC2_SRC)/codebookd.c \ $(CODEC2_SRC)/codebookjvm.c \ $(CODEC2_SRC)/codebookge.c \ -$(CODEC2_SRC)/dump.c +$(CODEC2_SRC)/dump.c \ +$(CODEC2_SRC)/fdmdv.c CFLAGS += -D__EMBEDDED__ -DTIMER @@ -110,7 +106,7 @@ OBJS = $(SRCS:.c=.o) ################################################### -all: libstm32f4.a $(PROJ_NAME).elf fft_test.elf dac_ut.elf dac_play.elf adc_rec.elf pwm_ut.elf power_ut.elf +all: libstm32f4.a codec2_profile.elf fft_test.elf dac_ut.elf dac_play.elf adc_rec.elf pwm_ut.elf power_ut.elf fdmdv_profile.elf dl/$(PERIPHLIBZIP): mkdir -p dl @@ -126,7 +122,18 @@ libstm32f4.a: $(PERIPHLIBDIR) for F in $(CMSIS)/DSP_Lib/Source/*/*.c ; do $(MAKE) $${F%.c}.o ; done find $(PERIPHLIBDIR) -type f -name '*.o' -exec $(AR) crs libstm32f4.a {} ";" -$(PROJ_NAME).elf: $(SRCS) +#################################################### + +CODEC2_PROFILE_SRCS=\ +src/codec2_profile.c \ +src/gdb_stdio.c \ +src/stm32f4_timer.c \ +src/startup_stm32f4xx.s \ +src/init.c \ +src/system_stm32f4xx.c +CODEC2_PROFILE_SRCS += $(CODEC2_SRCS) + +codec2_profile.elf: $(CODEC2_PROFILE_SRCS) $(CC) $(CFLAGS) $^ -o $@ $(LIBPATHS) $(LIBS) fft_test.elf: $(FFT_TEST_SRCS) @@ -188,27 +195,24 @@ src/startup_stm32f4xx.s \ src/init.c \ src/stm32f4_timer.c \ -POWER_UT_SRCS += \ -$(CODEC2_SRC)/lpc.c \ -$(CODEC2_SRC)/nlp.c \ -$(CODEC2_SRC)/postfilter.c \ -$(CODEC2_SRC)/sine.c \ -$(CODEC2_SRC)/codec2.c \ -$(CODEC2_SRC)/kiss_fft.c \ -$(CODEC2_SRC)/interp.c \ -$(CODEC2_SRC)/lsp.c \ -$(CODEC2_SRC)/phase.c \ -$(CODEC2_SRC)/quantise.c \ -$(CODEC2_SRC)/pack.c \ -$(CODEC2_SRC)/codebook.c \ -$(CODEC2_SRC)/codebookd.c \ -$(CODEC2_SRC)/codebookjvm.c \ -$(CODEC2_SRC)/codebookge.c \ -$(CODEC2_SRC)/dump.c +POWER_UT_SRCS += $(CODEC2_SRCS) power_ut.elf: $(POWER_UT_SRCS) $(CC) $(CFLAGS) $^ -o $@ $(LIBPATHS) $(LIBS) +FDMDV_PROFILE_SRCS=\ +src/fdmdv_profile.c \ +gdb_stdio.c \ +src/system_stm32f4xx.c \ +src/startup_stm32f4xx.s \ +src/init.c \ +src/stm32f4_timer.c + +FDMDV_PROFILE_SRCS += $(CODEC2_SRCS) + +fdmdv_profile.elf: $(FDMDV_PROFILE_SRCS) + $(CC) $(CFLAGS) $^ -o $@ $(LIBPATHS) $(LIBS) + clean: rm -f *.o rm -f *.elf diff --git a/codec2-dev/stm32/src/main.c b/codec2-dev/stm32/src/codec2_profile.c similarity index 78% rename from codec2-dev/stm32/src/main.c rename to codec2-dev/stm32/src/codec2_profile.c index 28d8ba75..7a6a28c0 100644 --- a/codec2-dev/stm32/src/main.c +++ b/codec2-dev/stm32/src/codec2_profile.c @@ -1,3 +1,30 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: codec2_profile.c + AUTHOR......: David Rowe + DATE CREATED: 30 May 2013 + + Profiling Codec 2 operation on the STM32F4. + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2014 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. This program is + distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program; if not, see . +*/ + #include #include #include @@ -131,7 +158,6 @@ void gpio_init() { } int main(int argc, char *argv[]) { - SystemInit(); gpio_init(); machdep_timer_init (); diff --git a/codec2-dev/stm32/src/fdmdv_profile.c b/codec2-dev/stm32/src/fdmdv_profile.c new file mode 100644 index 00000000..0e4e765f --- /dev/null +++ b/codec2-dev/stm32/src/fdmdv_profile.c @@ -0,0 +1,98 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: fdmdv_profile.c + AUTHOR......: David Rowe + DATE CREATED: 18 July 2014 + + Profiling Codec 2 operation on the STM32F4. + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2014 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. This program is + distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program; if not, see . +*/ + +#include +#include +#include +#include +#include + +#include "stm32f4xx_conf.h" +#include "stm32f4xx.h" +#include "gdb_stdio.h" +#include "codec2_fdmdv.h" +#include "dump.h" +#include "sine.h" +#include "machdep.h" + +#ifdef __EMBEDDED__ +#define printf gdb_stdio_printf +#define fopen gdb_stdio_fopen +#define fclose gdb_stdio_fclose +#define fread gdb_stdio_fread +#define fwrite gdb_stdio_fwrite +#endif + +#define TEST_FRAMES 25 + +int main(int argc, char *argv[]) { + struct FDMDV *fdmdv; + int bits_per_fdmdv_frame, bits_per_codec_frame; + int *tx_bits; + int *rx_bits; + COMP tx_fdm[2*FDMDV_NOM_SAMPLES_PER_FRAME]; + int i, nin, reliable_sync_bit, sync_bit; + struct FDMDV_STATS stats; + TIMER_VAR(mod_start, demod_start); + + fdmdv = fdmdv_create(FDMDV_NC); + + bits_per_fdmdv_frame = fdmdv_bits_per_frame(fdmdv); + bits_per_codec_frame = 2*fdmdv_bits_per_frame(fdmdv); + tx_bits = (int*)malloc(sizeof(int)*bits_per_codec_frame); assert(tx_bits != NULL); + rx_bits = (int*)malloc(sizeof(int)*bits_per_codec_frame); assert(rx_bits != NULL); + + nin = FDMDV_NOM_SAMPLES_PER_FRAME; + + for(i=0; i