From 316d5d433b5ba8c08aedb7166f36ff2f81ed7778 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Thu, 31 Dec 2015 10:52:28 -0800 Subject: [PATCH] Move IIR code into .cpp file. A few hundred more text section bytes saved. --- firmware/baseband/Makefile | 1 + firmware/baseband/dsp_iir.cpp | 50 +++++++++++++++++++++++++++++++++++ firmware/baseband/dsp_iir.hpp | 27 +++---------------- 3 files changed, 54 insertions(+), 24 deletions(-) create mode 100644 firmware/baseband/dsp_iir.cpp diff --git a/firmware/baseband/Makefile b/firmware/baseband/Makefile index baec0653..2970d145 100755 --- a/firmware/baseband/Makefile +++ b/firmware/baseband/Makefile @@ -148,6 +148,7 @@ CPPSRC = main.cpp \ packet_builder.cpp \ dsp_fft.cpp \ dsp_fir_taps.cpp \ + dsp_iir.cpp \ fxpt_atan2.cpp \ rssi.cpp \ rssi_dma.cpp \ diff --git a/firmware/baseband/dsp_iir.cpp b/firmware/baseband/dsp_iir.cpp new file mode 100644 index 00000000..e8367a76 --- /dev/null +++ b/firmware/baseband/dsp_iir.cpp @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc. + * + * This file is part of PortaPack. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * 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 General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include "dsp_iir.hpp" + +#include + +void IIRBiquadFilter::execute(buffer_s16_t buffer_in, buffer_s16_t buffer_out) { + // TODO: Assert that buffer_out.count == buffer_in.count. + for(size_t i=0; i x { { 0.0f, 0.0f, 0.0f } }; std::array y { { 0.0f, 0.0f, 0.0f } }; - float execute_sample(const float in) { - x[0] = x[1]; - x[1] = x[2]; - x[2] = in; - - y[0] = y[1]; - y[1] = y[2]; - y[2] = config.b[0] * x[2] + config.b[1] * x[1] + config.b[2] * x[0] - - config.a[1] * y[1] - config.a[2] * y[0]; - - return y[2]; - } + float execute_sample(const float in); }; #endif/*__DSP_IIR_H__*/