first pass at tuner UT, some building issues
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Fri, 20 Feb 2015 06:35:11 +0000 (06:35 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Fri, 20 Feb 2015 06:35:11 +0000 (06:35 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@2041 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/stm32/Makefile
codec2-dev/stm32/src/iir_tuner.c
codec2-dev/stm32/src/stm32f4_adc_tuner.c
codec2-dev/stm32/src/tuner_ut.c [new file with mode: 0644]

index dd677e9cb98f7562ef0fabac55918d9c837a8cb1..70caba0d5c43a23720622ecd388c5a572117b9d7 100644 (file)
@@ -30,7 +30,7 @@ endif
 
 PERIPHLIBURL    = http://www.st.com/st-web-ui/static/active/en/st_prod_software_internet/resource/technical/software/firmware/
 PERIPHLIBZIP    = stm32f4_dsp_stdperiph_lib.zip
-PERIPHLIBVER   = V1.1.0
+PERIPHLIBVER   = V1.4.0
 PERIPHLIBNAME  = STM32F4xx_DSP_StdPeriph_Lib
 PERIPHLIBDIR   = $(PERIPHLIBNAME)_$(PERIPHLIBVER)
 CMSIS          = $(PERIPHLIBDIR)/Libraries/CMSIS
@@ -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_tx_profile.elf freedv_rx_profile.elf adc_sd.elf usb_vcp_ut.elf fdmdv_dump_rt.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 adc_sd.elf usb_vcp_ut.elf fdmdv_dump_rt.elf tuner_ut.elf
 
 dl/$(PERIPHLIBZIP):
        mkdir -p dl
@@ -350,6 +350,21 @@ FDMDV_DUMP_RT_SRCS += $(CODEC2_SRCS)
 fdmdv_dump_rt.elf: $(FDMDV_DUMP_RT_SRCS) src/stm32f4_dac.o src/stm32f4_adc.o
        $(CC) $(CFLAGS) -O3 $^ -o $@ $(LIBPATHS) $(LIBS)
 
+TUNER_UT_SRCS=\
+src/tuner_ut.c \
+../src/fifo.c \
+src/stm32f4_dac.c \
+src/stm32f4_adc_tuner.c \
+src/sm1000_leds_switches.c \
+src/debugblinky.c \
+src/system_stm32f4xx.c \
+src/startup_stm32f4xx.s \
+src/init.c
+
+tuner_ut.elf: $(ADCDAC_UT_SRCS)
+       $(CC) $(CFLAGS) -O0 $^ -o $@ $(LIBPATHS) $(LIBS)
+       $(OBJCOPY) -O binary tuner_ut.elf tuner_ut.bin
+
 clean:
        rm -f *.o
        rm -f *.elf
index 7e6fe1092394008411c9e2a1c8cbd0bd6678a0c2..5e13bc535a223ea5b936294103bc50fad7a59650 100644 (file)
@@ -4,7 +4,7 @@
   AUTHOR......: David Rowe
   DATE CREATED: 20 Feb 2015
 
-  Filter/decimator function, broken out to this filer so we can unit
+  Filter/decimator function, broken out to this file so we can unit
   test easily.  
 
   Unit testing:
@@ -72,7 +72,7 @@ void inline iir_tuner(float dec_buf[], unsigned short adc_buf[]) {
         }
 
         /* Equaliser FIR filter, notch at Fs/(4*ADC_TUNER_M) to smooth out 
-           IIR BF passband response */
+           IIR BPF passband response */
 
         z = y + BETA2*z_2;
         dec_buf[j] = z;
index ef7a46c0ba0c0521fe04c35ca5f6677ece64e50f..ff5b71db8bf47d5247d71a11ea958bbab38c820b 100644 (file)
@@ -43,7 +43,6 @@
 
 struct FIFO *adc1_fifo;
 unsigned short adc_buf[ADC_TUNER_BUF_SZ];
-float y_2, y_1;
 int adc_overflow1;
 int half,full;
 
@@ -52,9 +51,6 @@ int half,full;
 #define DMA_STREAMx              DMA2_Stream0
 #define ADCx                     ADC1
 
-#define BETA1                    0.999
-#define BETA2                    0.955
-
 void adc_configure();
 
 static void tim2_config(void);
@@ -204,7 +200,7 @@ void adc_configure(){
 */
 
 void DMA2_Stream0_IRQHandler(void) {
-    short dec_buf[ADC_TUNER_N/2];
+    float dec_buf[ADC_TUNER_N/2];
 
     GPIOE->ODR = (1 << 0);
 
@@ -217,7 +213,7 @@ void DMA2_Stream0_IRQHandler(void) {
 
         /* write first half to fifo */
 
-        if (fifo_write(adc1_fifo, dec_buf, ADC_TUNER_N/2) == -1) {
+        if (fifo_write(adc1_fifo, (short)dec_buf, ADC_TUNER_N) == -1) {
             adc_overflow1++;
         }
 
@@ -235,7 +231,7 @@ void DMA2_Stream0_IRQHandler(void) {
 
         /* write second half to fifo */
 
-        if (fifo_write(adc1_fifo, dec_buf, ADC_TUNER_N/2) == -1) {
+        if (fifo_write(adc1_fifo, (short)dec_buf, ADC_TUNER_N) == -1) {
             adc_overflow1++;
         }
 
diff --git a/codec2-dev/stm32/src/tuner_ut.c b/codec2-dev/stm32/src/tuner_ut.c
new file mode 100644 (file)
index 0000000..07818da
--- /dev/null
@@ -0,0 +1,56 @@
+/*---------------------------------------------------------------------------*\\r
+\r
+  FILE........: tuner_ut.c\r
+  AUTHOR......: David Rowe\r
+  DATE CREATED: 20 Feb 2015\r
+\r
+  Unit test for high speed ADC radio tuner.\r
+\r
+\*---------------------------------------------------------------------------*/\r
+\r
+/*\r
+  Copyright (C) 2015 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 <assert.h>\r
+#include "stm32f4_dac.h"\r
+#include "stm32f4_adc_tuner.h"\r
+#include "sm1000_leds_switches.h"\r
+\r
+int main(void) {\r
+    short buf[SINE_SAMPLES];\r
+    int   i;\r
+\r
+    dac_open(4*DAC_BUF_SZ);\r
+    adc_open(4*ADC_TUNER_N;\r
+    sm1000_leds_switches_init();\r
+\r
+    while (1) {\r
+\r
+        while(adc1_read(buf, ADC_TUNER_N) == -1);\r
+        \r
+        /*\r
+        if (switch_select()) {\r
+            for(i=0; i<SINE_SAMPLES; i++)\r
+                buf[i] = 0;\r
+        }\r
+            \r
+        dac1_write(buf, SINE_SAMPLES);\r
+        */\r
+    }\r
+   \r
+}\r
+\r