From: drowe67 Date: Fri, 30 May 2014 06:17:49 +0000 (+0000) Subject: Created and ran power UT to estimate current consumption of smartmic uC, only 60mA X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=3744d4476d22a8cfc48d1ef1daf2d00942b9723b;p=freetel-svn-tracking.git Created and ran power UT to estimate current consumption of smartmic uC, only 60mA git-svn-id: https://svn.code.sf.net/p/freetel/code@1617 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/codec2-dev/stm32/Makefile b/codec2-dev/stm32/Makefile index 583105e3..0288407a 100644 --- a/codec2-dev/stm32/Makefile +++ b/codec2-dev/stm32/Makefile @@ -110,7 +110,7 @@ OBJS = $(SRCS:.c=.o) ################################################### -all: libstm32f4.a $(PROJ_NAME).elf fft_test.elf dac_ut.elf dac_play.elf adc_ut.elf timer_ut.elf +all: libstm32f4.a $(PROJ_NAME).elf fft_test.elf dac_ut.elf dac_play.elf adc_rec.elf pwm_ut.elf power_ut.elf dl/$(PERIPHLIBZIP): mkdir -p dl @@ -155,7 +155,8 @@ src/init.c dac_play.elf: $(DAC_PLAY_SRCS) $(CC) $(CFLAGS) -O0 $^ -o $@ $(LIBPATHS) $(LIBS) -ADC_UT_SRCS=\ +ADC_REC_SRCS=\ +src/adc_rec.c \ ../src/fifo.c \ gdb_stdio.c \ src/stm32f4_adc.c \ @@ -163,17 +164,48 @@ src/system_stm32f4xx.c \ src/startup_stm32f4xx.s \ src/init.c -adc_ut.elf: $(ADC_UT_SRCS) +adc_rec.elf: $(ADC_REC_SRCS) $(CC) $(CFLAGS) $^ -o $@ $(LIBPATHS) $(LIBS) -TIMER_UT_SRCS=\ -gdb_stdio.c \ -src/timer_ut.c \ +PWM_UT_SRCS=\ +src/stm32f4_pwm.c \ src/system_stm32f4xx.c \ src/startup_stm32f4xx.s \ src/init.c -timer_ut.elf: $(TIMER_UT_SRCS) +pwm_ut.elf: $(PWM_UT_SRCS) + $(CC) $(CFLAGS) $^ -o $@ $(LIBPATHS) $(LIBS) + +POWER_UT_SRCS=\ +src/power_ut.c \ +gdb_stdio.c \ +../src/fifo.c \ +src/stm32f4_adc.c \ +src/stm32f4_dac.c \ +src/system_stm32f4xx.c \ +src/startup_stm32f4xx.s \ +src/init.c \ +src/stm32f4_timer.c \ + +POWER_UT_SRCS += \ +$(CODEC2_SRC)/lpc.c \ +$(CODEC2_SRC)/nlp.c \ +$(CODEC2_SRC)/postfilter.c \ +$(CODEC2_SRC)/sine.c \ +$(CODEC2_SRC)/codec2.c \ +$(CODEC2_SRC)/kiss_fft.c \ +$(CODEC2_SRC)/interp.c \ +$(CODEC2_SRC)/lsp.c \ +$(CODEC2_SRC)/phase.c \ +$(CODEC2_SRC)/quantise.c \ +$(CODEC2_SRC)/pack.c \ +$(CODEC2_SRC)/codebook.c \ +$(CODEC2_SRC)/codebookd.c \ +$(CODEC2_SRC)/codebookjvm.c \ +$(CODEC2_SRC)/codebookge.c \ +$(CODEC2_SRC)/dump.c + +power_ut.elf: $(POWER_UT_SRCS) $(CC) $(CFLAGS) $^ -o $@ $(LIBPATHS) $(LIBS) clean: diff --git a/codec2-dev/stm32/inc/stm32f4_adc.h b/codec2-dev/stm32/inc/stm32f4_adc.h new file mode 100644 index 00000000..b14110cb --- /dev/null +++ b/codec2-dev/stm32/inc/stm32f4_adc.h @@ -0,0 +1,34 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: stm32f4_adc.h + AUTHOR......: David Rowe + DATE CREATED: 30 May 2014 + + ADC driver module for STM32F4. + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2014 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 . +*/ + +#ifndef __STM32F4_ADC__ +#define __STM32F4_ADC__ + +void adc_open(void); +int adc_read(short buf[], int n); + +#endif diff --git a/codec2-dev/stm32/src/adc_rec.c b/codec2-dev/stm32/src/adc_rec.c new file mode 100644 index 00000000..3d5992f9 --- /dev/null +++ b/codec2-dev/stm32/src/adc_rec.c @@ -0,0 +1,58 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: adc_rec.c + AUTHOR......: David Rowe + DATE CREATED: 30 May 2014 + + Recordss a 16 kHz sample rate raw file from the STM32F4 ADC. + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2014 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 "stm32f4_adc.h" +#include "gdb_stdio.h" + +#define REC_TIME_SECS 10 +#define N 2000 +#define FS 16000 + +int main(void){ + short buf[N]; + FILE *frec; + int i, bufs; + + adc_open(); + + frec = fopen("stm_out.raw", "wb"); + if (frec == NULL) { + printf("Error opening input file: stm_out.raw\n\nTerminating....\n"); + exit(1); + } + bufs = FS*REC_TIME_SECS/N; + + printf("Starting!\n"); + for(i=0; i