freedv tx and rx unittests both running on SM1000 with file I/O. rx speed borderline
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Fri, 15 Aug 2014 01:47:06 +0000 (01:47 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Fri, 15 Aug 2014 01:47:06 +0000 (01:47 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@1803 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/stm32/Makefile
codec2-dev/stm32/src/freedv_rx_profile.c [new file with mode: 0644]
codec2-dev/stm32/src/freedv_tx_profile.c [new file with mode: 0644]
codec2-dev/stm32/src/sm1000_main.c

index d8c69c3217929306ddcd61b7d80afc84bddcf5b1..e33b8b9e2e0a236d60a0d92b1330dbea7f63e927 100644 (file)
@@ -13,7 +13,7 @@ SIZE=$(BINPATH)/arm-none-eabi-size
 
 ###################################################
 
-CFLAGS  = -std=gnu99 -g -Wall -Tstm32_flash.ld -DSTM32F4XX -DCORTEX_M4
+CFLAGS  = -std=gnu99 -O3 -g -Wall -Tstm32_flash.ld -DSTM32F4XX -DCORTEX_M4
 CFLAGS += -mlittle-endian -mthumb -mthumb-interwork -nostartfiles -mcpu=cortex-m4
 
 ifeq ($(FLOAT_TYPE), hard)
@@ -109,7 +109,7 @@ OBJS = $(SRCS:.c=.o)
 
 ###################################################
 
-all: libstm32f4.a codec2_profile.elf fft_test.elf dac_ut.elf dac_play.elf adc_rec.elf pwm_ut.elf fdmdv_profile.elf sm1000_leds_switches_ut.elf sm1000.elf adcdac_ut.elf freedv_profile.elf
+all: libstm32f4.a codec2_profile.elf fft_test.elf dac_ut.elf dac_play.elf adc_rec.elf pwm_ut.elf fdmdv_profile.elf sm1000_leds_switches_ut.elf sm1000.elf adcdac_ut.elf freedv_tx_profile.elf freedv_rx_profile.elf 
 
 dl/$(PERIPHLIBZIP):
        mkdir -p dl
@@ -263,18 +263,31 @@ src/stm32f4_adc.o: src/stm32f4_adc.c
 sm1000.elf: $(SM1000_SRCS) src/stm32f4_dac.o src/stm32f4_adc.o
        $(CC) $(CFLAGS) -O3 $^ -o $@ $(LIBPATHS) $(LIBS)
 
-FREEDV_PROFILE_SRCS=\
-src/freedv_profile.c \
+FREEDV_TX_PROFILE_SRCS=\
+src/freedv_tx_profile.c \
 src/stm32f4_machdep.c \
 gdb_stdio.c \
 src/system_stm32f4xx.c \
 src/startup_stm32f4xx.s \
 src/init.c 
 
-FREEDV_PROFILE_SRCS += $(CODEC2_SRCS)
+FREEDV_TX_PROFILE_SRCS += $(CODEC2_SRCS)
 
-freedv_profile.elf: $(FREEDV_PROFILE_SRCS)
-       $(CC) $(CFLAGS) $^ -o $@ $(LIBPATHS) $(LIBS)
+freedv_tx_profile.elf: $(FREEDV_TX_PROFILE_SRCS)
+       $(CC) $(CFLAGS) -DPROFILE $^ -o $@ $(LIBPATHS) $(LIBS)
+
+FREEDV_RX_PROFILE_SRCS=\
+src/freedv_rx_profile.c \
+src/stm32f4_machdep.c \
+gdb_stdio.c \
+src/system_stm32f4xx.c \
+src/startup_stm32f4xx.s \
+src/init.c 
+
+FREEDV_RX_PROFILE_SRCS += $(CODEC2_SRCS)
+
+freedv_rx_profile.elf: $(FREEDV_RX_PROFILE_SRCS)
+       $(CC) $(CFLAGS) -DPROFILE $^ -o $@ $(LIBPATHS) $(LIBS)
 
 clean:
        rm -f *.o
diff --git a/codec2-dev/stm32/src/freedv_rx_profile.c b/codec2-dev/stm32/src/freedv_rx_profile.c
new file mode 100644 (file)
index 0000000..c116c7f
--- /dev/null
@@ -0,0 +1,91 @@
+/*---------------------------------------------------------------------------*\\r
+\r
+  FILE........: freedv_rx_profile.c\r
+  AUTHOR......: David Rowe\r
+  DATE CREATED: 13 August 2014\r
+\r
+  Profiling freedv_rx() operation on the STM32F4.\r
+\r
+\*---------------------------------------------------------------------------*/\r
+\r
+/*\r
+  Copyright (C) 2014 David Rowe\r
+\r
+  All rights reserved.\r
+\r
+  This program is free software; you can redistribute it and/or modify\r
+  it under the terms of the GNU Lesser General Public License version 2.1, as\r
+  published by the Free Software Foundation.  This program is\r
+  distributed in the hope that it will be useful, but WITHOUT ANY\r
+  WARRANTY; without even the implied warranty of MERCHANTABILITY or\r
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public\r
+  License for more details.\r
+\r
+  You should have received a copy of the GNU Lesser General Public License\r
+  along with this program; if not, see <http://www.gnu.org/licenses/>.\r
+*/\r
+\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <stdint.h>\r
+#include <math.h>\r
+\r
+#include "stm32f4xx_conf.h"\r
+#include "stm32f4xx.h"\r
+#include "gdb_stdio.h"\r
+#include "freedv_api.h"\r
+#include "machdep.h"\r
+\r
+#ifdef __EMBEDDED__\r
+#define printf gdb_stdio_printf\r
+#define fopen gdb_stdio_fopen\r
+#define fclose gdb_stdio_fclose\r
+#define fread gdb_stdio_fread\r
+#define fwrite gdb_stdio_fwrite\r
+#endif\r
+\r
+int main(int argc, char *argv[]) {\r
+    struct freedv *f;\r
+    short          inbuf[FREEDV_NSAMPLES], outbuf[FREEDV_NSAMPLES];\r
+    FILE          *fin, *fout;\r
+    int            frame, nin, nout = 0;\r
+    PROFILE_VAR(freedv_start);\r
+\r
+    machdep_profile_init();\r
+\r
+    f = freedv_open(FREEDV_MODE_1600);\r
+\r
+    // Transmit ---------------------------------------------------------------------\r
+\r
+    frame = 0;\r
+\r
+    fin = fopen("mod.raw", "rb");\r
+    if (fin == NULL) {\r
+        printf("Error opening input file\n");\r
+        exit(1);\r
+    }\r
+\r
+    fout = fopen("stm_out.raw", "wb");\r
+    if (fout == NULL) {\r
+        printf("Error opening output file\n");\r
+        exit(1);\r
+    }\r
+\r
+    nin = freedv_nin(f);\r
+    while (fread(inbuf, sizeof(short), nin, fin) == nin) {\r
+        PROFILE_SAMPLE(freedv_start);\r
+        nout = freedv_rx(f, outbuf, inbuf);\r
+        nin = freedv_nin(f);\r
+        PROFILE_SAMPLE_AND_LOG2(freedv_start, "  demod");     \r
+\r
+        machdep_profile_print_logged_samples();\r
+        fwrite(outbuf, sizeof(short), nout, fout);\r
+        printf("frame: %d\n", ++frame);\r
+    }\r
+\r
+    fclose(fin);\r
+    fclose(fout);\r
+\r
+    return 0;\r
+}\r
+\r
diff --git a/codec2-dev/stm32/src/freedv_tx_profile.c b/codec2-dev/stm32/src/freedv_tx_profile.c
new file mode 100644 (file)
index 0000000..7391c52
--- /dev/null
@@ -0,0 +1,89 @@
+/*---------------------------------------------------------------------------*\\r
+\r
+  FILE........: freedv_tx_profile.c\r
+  AUTHOR......: David Rowe\r
+  DATE CREATED: 13 August 2014\r
+\r
+  Profiling freedv_tx() operation on the STM32F4.\r
+\r
+\*---------------------------------------------------------------------------*/\r
+\r
+/*\r
+  Copyright (C) 2014 David Rowe\r
+\r
+  All rights reserved.\r
+\r
+  This program is free software; you can redistribute it and/or modify\r
+  it under the terms of the GNU Lesser General Public License version 2.1, as\r
+  published by the Free Software Foundation.  This program is\r
+  distributed in the hope that it will be useful, but WITHOUT ANY\r
+  WARRANTY; without even the implied warranty of MERCHANTABILITY or\r
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public\r
+  License for more details.\r
+\r
+  You should have received a copy of the GNU Lesser General Public License\r
+  along with this program; if not, see <http://www.gnu.org/licenses/>.\r
+*/\r
+\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <stdint.h>\r
+#include <math.h>\r
+\r
+#include "stm32f4xx_conf.h"\r
+#include "stm32f4xx.h"\r
+#include "gdb_stdio.h"\r
+#include "freedv_api.h"\r
+#include "machdep.h"\r
+\r
+#ifdef __EMBEDDED__\r
+#define printf gdb_stdio_printf\r
+#define fopen gdb_stdio_fopen\r
+#define fclose gdb_stdio_fclose\r
+#define fread gdb_stdio_fread\r
+#define fwrite gdb_stdio_fwrite\r
+#endif\r
+\r
+int main(int argc, char *argv[]) {\r
+    struct freedv *f;\r
+    short          inbuf[FREEDV_NSAMPLES], outbuf[FREEDV_NSAMPLES];\r
+    FILE          *fin, *fout;\r
+    int            frame;\r
+    PROFILE_VAR(freedv_start);\r
+\r
+    machdep_profile_init();\r
+\r
+    f = freedv_open(FREEDV_MODE_1600);\r
+\r
+    // Transmit ---------------------------------------------------------------------\r
+\r
+    fin = fopen("stm_in.raw", "rb");\r
+    if (fin == NULL) {\r
+        printf("Error opening input file\n");\r
+        exit(1);\r
+    }\r
+\r
+    fout = fopen("mod.raw", "wb");\r
+    if (fout == NULL) {\r
+        printf("Error opening output file\n");\r
+        exit(1);\r
+    }\r
+\r
+    frame = 0;\r
+\r
+    while (fread(inbuf, sizeof(short), FREEDV_NSAMPLES, fin) == FREEDV_NSAMPLES) {\r
+        PROFILE_SAMPLE(freedv_start);\r
+        freedv_tx(f, outbuf, inbuf);\r
+        PROFILE_SAMPLE_AND_LOG2(freedv_start, "  freedv_tx");     \r
+       \r
+        fwrite(outbuf, sizeof(short), FREEDV_NSAMPLES, fout);\r
+        printf("frame: %d\n", ++frame);\r
+        machdep_profile_print_logged_samples();\r
+   }\r
+\r
+    fclose(fin);\r
+    fclose(fout);\r
+\r
+    return 0;\r
+}\r
+\r
index 9b6cbbdd1e89f42e26e39a32aea6f22b2795e0ee..5aaabe9b4a0780e3466b3f1c3c3e916b0eee2121 100644 (file)
@@ -122,6 +122,7 @@ int main(void) {
                 nout = freedv_rx(f, buf, buf);\r
                 dac2_write(buf, nout);\r
                 led_ptt(0); led_rt(f->fdmdv_stats.sync); led_err(f->total_bit_errors);\r
+                nin = freedv_nin(f);\r
             }\r
 \r
         }\r