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
###################################################
-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
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
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:
}
/* 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;
struct FIFO *adc1_fifo;
unsigned short adc_buf[ADC_TUNER_BUF_SZ];
-float y_2, y_1;
int adc_overflow1;
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);
*/
void DMA2_Stream0_IRQHandler(void) {
- short dec_buf[ADC_TUNER_N/2];
+ float dec_buf[ADC_TUNER_N/2];
GPIOE->ODR = (1 << 0);
/* 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++;
}
/* 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++;
}
--- /dev/null
+/*---------------------------------------------------------------------------*\\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