From f4ee42821d2670293ae7617f29134fb2d910b88b Mon Sep 17 00:00:00 2001 From: drowe67 Date: Sat, 18 Jun 2016 00:18:13 +0000 Subject: [PATCH] sm2000 set to work test program, in teh middle of modifiying for DAC play git-svn-id: https://svn.code.sf.net/p/freetel/code@2828 01035d8c-6547-0410-b346-abe4f91aad63 --- codec2-dev/stm32/Makefile | 37 ++++++++++- codec2-dev/stm32/src/sm2000_stw.c | 105 ++++++++++++++++++++++++++++++ 2 files changed, 141 insertions(+), 1 deletion(-) create mode 100644 codec2-dev/stm32/src/sm2000_stw.c diff --git a/codec2-dev/stm32/Makefile b/codec2-dev/stm32/Makefile index 5a8dd7ed..90bd63b2 100644 --- a/codec2-dev/stm32/Makefile +++ b/codec2-dev/stm32/Makefile @@ -436,7 +436,7 @@ SRCS += src/startup_stm32f4xx.s src/init.c OBJS = $(SRCS:.c=.o) -all: libstm32f4.a codec2_profile.bin fft_test.bin dac_ut.bin dac_play.bin adc_rec.bin pwm_ut.bin fdmdv_profile.bin sm1000_leds_switches_ut.bin sm1000.bin adcdac_ut.bin freedv_tx_profile.bin freedv_rx_profile.bin adc_sd.bin usb_vcp_ut.bin tuner_ut.bin fast_dac_ut.bin adc_sfdr_ut.bin adc_rec_usb.bin si5351_ut.bin +all: libstm32f4.a codec2_profile.bin fft_test.bin dac_ut.bin dac_play.bin adc_rec.bin pwm_ut.bin fdmdv_profile.bin sm1000_leds_switches_ut.bin sm1000.bin adcdac_ut.bin freedv_tx_profile.bin freedv_rx_profile.bin adc_sd.bin usb_vcp_ut.bin tuner_ut.bin fast_dac_ut.bin adc_sfdr_ut.bin adc_rec_usb.bin si5351_ut.bin mco_ut.bin sm2000_stw.bin # Rule for making directories automatically. # Note we don't use -p as it's a GNU extension. @@ -821,6 +821,41 @@ si5351_ut.elf: $(SI5351_UT_SRCS:.c=.o) libstm32f4.a # --------------------------------------------------------------------------------- +MCO_UT_SRCS=\ +src/mco_ut.c \ +src/tm_stm32f4_mco_output.c \ +src/tm_stm32f4_gpio.c \ +src/system_stm32f4xx.c \ +src/startup_stm32f4xx.s \ +src/init.c \ + +mco_ut.elf: $(MCO_UT_SRCS:.c=.o) libstm32f4.a + $(CC) $(CFLAGS) $^ -o $@ $(LIBPATHS) $(LIBS) + +# --------------------------------------------------------------------------------- + +# --------------------------------------------------------------------------------- + +SM2000_STW_SRCS=\ +src/sm2000_stw.c \ +src/sm1000_leds_switches.c \ +src/debugblinky.c \ +src/new_i2c.c \ +src/si53xx.c \ +src/stm32f4_dac.c \ +../src/fifo.c \ +src/stm32f4_usb_vcp.c \ +src/system_stm32f4xx.c \ +src/startup_stm32f4xx.s \ +src/init.c \ + +SM2000_STW_SRCS+=$(USB_VCP) + +sm2000_stw.elf: $(SM2000_STW_SRCS:.c=.o) libstm32f4.a + $(CC) $(CFLAGS) $^ -o $@ $(LIBPATHS) $(LIBS) + +# --------------------------------------------------------------------------------- + # Objects that require the peripheral library src/sm1000_main.o: $(PERIPHLIBDIR)/.unpack src/codec2_profile.o: $(PERIPHLIBDIR)/.unpack diff --git a/codec2-dev/stm32/src/sm2000_stw.c b/codec2-dev/stm32/src/sm2000_stw.c new file mode 100644 index 00000000..df74e807 --- /dev/null +++ b/codec2-dev/stm32/src/sm2000_stw.c @@ -0,0 +1,105 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: sm2000_stw.c + AUTHOR......: David Rowe + DATE CREATED: June 2016 + + Test program to support SM2000 "set to work" - tetsing and bring up. + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2016 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 "new_i2c.h" +#include "si53xx.h" +#include "debugblinky.h" +#include "sm1000_leds_switches.h" +#include "stm32f4_dac.h" +#include "stm32f4_usb_vcp.h" + +#define SINE_SAMPLES 24 + +/* 32 sample sine wave which at Fs=16kHz will be 500Hz. Note samples + are 16 bit 2's complement, the DAC driver convertsto 12 bit + unsigned. */ + +short aSine[] = { + 5000, -2500, -2500, 5000, -2500, -2500, + 5000, -2500, -2500, 5000, -2500, -2500, + 5000, -2500, -2500, 5000, -2500, -2500, + 5000, -2500, -2500, 5000, -2500, -2500 +}; +short zeros[SINE_SAMPLES]; + +int main(void) { + int ret, ptt, i; + uint64_t freq_in_Hz_times_100; + + for(i=0; i