From 17b62545e2aeee0889f294def474861a21f19354 Mon Sep 17 00:00:00 2001 From: drowe67 Date: Fri, 6 Nov 2015 06:06:51 +0000 Subject: [PATCH] first pass as USB recording working at Fs=16 kHz git-svn-id: https://svn.code.sf.net/p/freetel/code@2483 01035d8c-6547-0410-b346-abe4f91aad63 --- codec2-dev/stm32/src/adc_rec_usb.c | 83 ++++++++++++++++++++++++++++++ codec2-dev/stm32/src/dac_ut_fast.c | 37 +++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 codec2-dev/stm32/src/adc_rec_usb.c create mode 100644 codec2-dev/stm32/src/dac_ut_fast.c diff --git a/codec2-dev/stm32/src/adc_rec_usb.c b/codec2-dev/stm32/src/adc_rec_usb.c new file mode 100644 index 00000000..ef82fc49 --- /dev/null +++ b/codec2-dev/stm32/src/adc_rec_usb.c @@ -0,0 +1,83 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: adc_rec_usb.c + AUTHOR......: David Rowe + DATE CREATED: Nov 2015 + + Records a 16 kHz sample rate raw file from one of the ADC channels, + which are connected to pins PA1 (ADC1) and PA2 (ADC2). Uploads to the + host PC via the STM32F4 USB port, which appears as /dev/ttyACM0. + + On the SM1000: + ADC1 -> PA1 -> "from radio" + ADC2 -> PA2 -> "mic amp" + + I used this to record: + $ sudo dd if=/dev/ttyACM0 of=test.raw count=100 + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2015 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 "stm32f4_adc.h" +#include "gdb_stdio.h" +#include "stm32f4xx_gpio.h" + +#define N (ADC_BUF_SZ*6) + +/* test tone parameters */ + +#define FREQ 999.0 /* make sure no alignment with frame boundaries */ +#define FS 16000.0 +#define AMP 10000.0 + +extern int adc_overflow1; +extern int adc_overflow2; + +int main(void){ + short buf[N]; + float phase = 0.0; + float sam; + int i; + + usb_vcp_init(); + adc_open(4*N); + sm1000_leds_switches_init(); + + /* set up test buffer, lets us test USB comms indep of ADC, record to a file + then play back/examine waveform to make sure no clicks */ + + while(1) { + while(adc1_read(buf, N) == -1); + + #ifdef TEST_TONE + for(i=0; i. +*/ + +#include +#include "stm32f4_dac.h" + + +int main(void) { + dac_open(4*DAC_BUF_SZ); + while (1); +} + -- 2.25.1