V4.0.1 of the ARM CMSIS DSP libraries. Note that arm_bitreversal2.s, arm_cfft_f32.c and arm_rfft_fast_f32.c had to be removed. arm_bitreversal2.s will not assemble with the online tools. So, the fast f32 FFT functions are not yet available. All the other FFT functions are available.
Dependents: MPU9150_Example fir_f32 fir_f32 MPU9150_nucleo_noni2cdev ... more
FilteringFunctions/arm_fir_interpolate_f32.c@0:3d9c67d97d6f, 2014-07-28 (annotated)
- Committer:
- emh203
- Date:
- Mon Jul 28 15:03:15 2014 +0000
- Revision:
- 0:3d9c67d97d6f
1st working commit. Had to remove arm_bitreversal2.s arm_cfft_f32.c and arm_rfft_fast_f32.c. The .s will not assemble. For now I removed these functions so we could at least have a library for the other functions.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
emh203 | 0:3d9c67d97d6f | 1 | /* ---------------------------------------------------------------------- |
emh203 | 0:3d9c67d97d6f | 2 | * Copyright (C) 2010-2014 ARM Limited. All rights reserved. |
emh203 | 0:3d9c67d97d6f | 3 | * |
emh203 | 0:3d9c67d97d6f | 4 | * $Date: 12. March 2014 |
emh203 | 0:3d9c67d97d6f | 5 | * $Revision: V1.4.3 |
emh203 | 0:3d9c67d97d6f | 6 | * |
emh203 | 0:3d9c67d97d6f | 7 | * Project: CMSIS DSP Library |
emh203 | 0:3d9c67d97d6f | 8 | * Title: arm_fir_interpolate_f32.c |
emh203 | 0:3d9c67d97d6f | 9 | * |
emh203 | 0:3d9c67d97d6f | 10 | * Description: FIR interpolation for floating-point sequences. |
emh203 | 0:3d9c67d97d6f | 11 | * |
emh203 | 0:3d9c67d97d6f | 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 |
emh203 | 0:3d9c67d97d6f | 13 | * |
emh203 | 0:3d9c67d97d6f | 14 | * Redistribution and use in source and binary forms, with or without |
emh203 | 0:3d9c67d97d6f | 15 | * modification, are permitted provided that the following conditions |
emh203 | 0:3d9c67d97d6f | 16 | * are met: |
emh203 | 0:3d9c67d97d6f | 17 | * - Redistributions of source code must retain the above copyright |
emh203 | 0:3d9c67d97d6f | 18 | * notice, this list of conditions and the following disclaimer. |
emh203 | 0:3d9c67d97d6f | 19 | * - Redistributions in binary form must reproduce the above copyright |
emh203 | 0:3d9c67d97d6f | 20 | * notice, this list of conditions and the following disclaimer in |
emh203 | 0:3d9c67d97d6f | 21 | * the documentation and/or other materials provided with the |
emh203 | 0:3d9c67d97d6f | 22 | * distribution. |
emh203 | 0:3d9c67d97d6f | 23 | * - Neither the name of ARM LIMITED nor the names of its contributors |
emh203 | 0:3d9c67d97d6f | 24 | * may be used to endorse or promote products derived from this |
emh203 | 0:3d9c67d97d6f | 25 | * software without specific prior written permission. |
emh203 | 0:3d9c67d97d6f | 26 | * |
emh203 | 0:3d9c67d97d6f | 27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
emh203 | 0:3d9c67d97d6f | 28 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
emh203 | 0:3d9c67d97d6f | 29 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
emh203 | 0:3d9c67d97d6f | 30 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
emh203 | 0:3d9c67d97d6f | 31 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
emh203 | 0:3d9c67d97d6f | 32 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
emh203 | 0:3d9c67d97d6f | 33 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
emh203 | 0:3d9c67d97d6f | 34 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
emh203 | 0:3d9c67d97d6f | 35 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
emh203 | 0:3d9c67d97d6f | 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
emh203 | 0:3d9c67d97d6f | 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
emh203 | 0:3d9c67d97d6f | 38 | * POSSIBILITY OF SUCH DAMAGE. |
emh203 | 0:3d9c67d97d6f | 39 | * -------------------------------------------------------------------- */ |
emh203 | 0:3d9c67d97d6f | 40 | |
emh203 | 0:3d9c67d97d6f | 41 | #include "arm_math.h" |
emh203 | 0:3d9c67d97d6f | 42 | |
emh203 | 0:3d9c67d97d6f | 43 | /** |
emh203 | 0:3d9c67d97d6f | 44 | * @defgroup FIR_Interpolate Finite Impulse Response (FIR) Interpolator |
emh203 | 0:3d9c67d97d6f | 45 | * |
emh203 | 0:3d9c67d97d6f | 46 | * These functions combine an upsampler (zero stuffer) and an FIR filter. |
emh203 | 0:3d9c67d97d6f | 47 | * They are used in multirate systems for increasing the sample rate of a signal without introducing high frequency images. |
emh203 | 0:3d9c67d97d6f | 48 | * Conceptually, the functions are equivalent to the block diagram below: |
emh203 | 0:3d9c67d97d6f | 49 | * \image html FIRInterpolator.gif "Components included in the FIR Interpolator functions" |
emh203 | 0:3d9c67d97d6f | 50 | * After upsampling by a factor of <code>L</code>, the signal should be filtered by a lowpass filter with a normalized |
emh203 | 0:3d9c67d97d6f | 51 | * cutoff frequency of <code>1/L</code> in order to eliminate high frequency copies of the spectrum. |
emh203 | 0:3d9c67d97d6f | 52 | * The user of the function is responsible for providing the filter coefficients. |
emh203 | 0:3d9c67d97d6f | 53 | * |
emh203 | 0:3d9c67d97d6f | 54 | * The FIR interpolator functions provided in the CMSIS DSP Library combine the upsampler and FIR filter in an efficient manner. |
emh203 | 0:3d9c67d97d6f | 55 | * The upsampler inserts <code>L-1</code> zeros between each sample. |
emh203 | 0:3d9c67d97d6f | 56 | * Instead of multiplying by these zero values, the FIR filter is designed to skip them. |
emh203 | 0:3d9c67d97d6f | 57 | * This leads to an efficient implementation without any wasted effort. |
emh203 | 0:3d9c67d97d6f | 58 | * The functions operate on blocks of input and output data. |
emh203 | 0:3d9c67d97d6f | 59 | * <code>pSrc</code> points to an array of <code>blockSize</code> input values and |
emh203 | 0:3d9c67d97d6f | 60 | * <code>pDst</code> points to an array of <code>blockSize*L</code> output values. |
emh203 | 0:3d9c67d97d6f | 61 | * |
emh203 | 0:3d9c67d97d6f | 62 | * The library provides separate functions for Q15, Q31, and floating-point data types. |
emh203 | 0:3d9c67d97d6f | 63 | * |
emh203 | 0:3d9c67d97d6f | 64 | * \par Algorithm: |
emh203 | 0:3d9c67d97d6f | 65 | * The functions use a polyphase filter structure: |
emh203 | 0:3d9c67d97d6f | 66 | * <pre> |
emh203 | 0:3d9c67d97d6f | 67 | * y[n] = b[0] * x[n] + b[L] * x[n-1] + ... + b[L*(phaseLength-1)] * x[n-phaseLength+1] |
emh203 | 0:3d9c67d97d6f | 68 | * y[n+1] = b[1] * x[n] + b[L+1] * x[n-1] + ... + b[L*(phaseLength-1)+1] * x[n-phaseLength+1] |
emh203 | 0:3d9c67d97d6f | 69 | * ... |
emh203 | 0:3d9c67d97d6f | 70 | * y[n+(L-1)] = b[L-1] * x[n] + b[2*L-1] * x[n-1] + ....+ b[L*(phaseLength-1)+(L-1)] * x[n-phaseLength+1] |
emh203 | 0:3d9c67d97d6f | 71 | * </pre> |
emh203 | 0:3d9c67d97d6f | 72 | * This approach is more efficient than straightforward upsample-then-filter algorithms. |
emh203 | 0:3d9c67d97d6f | 73 | * With this method the computation is reduced by a factor of <code>1/L</code> when compared to using a standard FIR filter. |
emh203 | 0:3d9c67d97d6f | 74 | * \par |
emh203 | 0:3d9c67d97d6f | 75 | * <code>pCoeffs</code> points to a coefficient array of size <code>numTaps</code>. |
emh203 | 0:3d9c67d97d6f | 76 | * <code>numTaps</code> must be a multiple of the interpolation factor <code>L</code> and this is checked by the |
emh203 | 0:3d9c67d97d6f | 77 | * initialization functions. |
emh203 | 0:3d9c67d97d6f | 78 | * Internally, the function divides the FIR filter's impulse response into shorter filters of length |
emh203 | 0:3d9c67d97d6f | 79 | * <code>phaseLength=numTaps/L</code>. |
emh203 | 0:3d9c67d97d6f | 80 | * Coefficients are stored in time reversed order. |
emh203 | 0:3d9c67d97d6f | 81 | * \par |
emh203 | 0:3d9c67d97d6f | 82 | * <pre> |
emh203 | 0:3d9c67d97d6f | 83 | * {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]} |
emh203 | 0:3d9c67d97d6f | 84 | * </pre> |
emh203 | 0:3d9c67d97d6f | 85 | * \par |
emh203 | 0:3d9c67d97d6f | 86 | * <code>pState</code> points to a state array of size <code>blockSize + phaseLength - 1</code>. |
emh203 | 0:3d9c67d97d6f | 87 | * Samples in the state buffer are stored in the order: |
emh203 | 0:3d9c67d97d6f | 88 | * \par |
emh203 | 0:3d9c67d97d6f | 89 | * <pre> |
emh203 | 0:3d9c67d97d6f | 90 | * {x[n-phaseLength+1], x[n-phaseLength], x[n-phaseLength-1], x[n-phaseLength-2]....x[0], x[1], ..., x[blockSize-1]} |
emh203 | 0:3d9c67d97d6f | 91 | * </pre> |
emh203 | 0:3d9c67d97d6f | 92 | * The state variables are updated after each block of data is processed, the coefficients are untouched. |
emh203 | 0:3d9c67d97d6f | 93 | * |
emh203 | 0:3d9c67d97d6f | 94 | * \par Instance Structure |
emh203 | 0:3d9c67d97d6f | 95 | * The coefficients and state variables for a filter are stored together in an instance data structure. |
emh203 | 0:3d9c67d97d6f | 96 | * A separate instance structure must be defined for each filter. |
emh203 | 0:3d9c67d97d6f | 97 | * Coefficient arrays may be shared among several instances while state variable array should be allocated separately. |
emh203 | 0:3d9c67d97d6f | 98 | * There are separate instance structure declarations for each of the 3 supported data types. |
emh203 | 0:3d9c67d97d6f | 99 | * |
emh203 | 0:3d9c67d97d6f | 100 | * \par Initialization Functions |
emh203 | 0:3d9c67d97d6f | 101 | * There is also an associated initialization function for each data type. |
emh203 | 0:3d9c67d97d6f | 102 | * The initialization function performs the following operations: |
emh203 | 0:3d9c67d97d6f | 103 | * - Sets the values of the internal structure fields. |
emh203 | 0:3d9c67d97d6f | 104 | * - Zeros out the values in the state buffer. |
emh203 | 0:3d9c67d97d6f | 105 | * - Checks to make sure that the length of the filter is a multiple of the interpolation factor. |
emh203 | 0:3d9c67d97d6f | 106 | * To do this manually without calling the init function, assign the follow subfields of the instance structure: |
emh203 | 0:3d9c67d97d6f | 107 | * L (interpolation factor), pCoeffs, phaseLength (numTaps / L), pState. Also set all of the values in pState to zero. |
emh203 | 0:3d9c67d97d6f | 108 | * |
emh203 | 0:3d9c67d97d6f | 109 | * \par |
emh203 | 0:3d9c67d97d6f | 110 | * Use of the initialization function is optional. |
emh203 | 0:3d9c67d97d6f | 111 | * However, if the initialization function is used, then the instance structure cannot be placed into a const data section. |
emh203 | 0:3d9c67d97d6f | 112 | * To place an instance structure into a const data section, the instance structure must be manually initialized. |
emh203 | 0:3d9c67d97d6f | 113 | * The code below statically initializes each of the 3 different data type filter instance structures |
emh203 | 0:3d9c67d97d6f | 114 | * <pre> |
emh203 | 0:3d9c67d97d6f | 115 | * arm_fir_interpolate_instance_f32 S = {L, phaseLength, pCoeffs, pState}; |
emh203 | 0:3d9c67d97d6f | 116 | * arm_fir_interpolate_instance_q31 S = {L, phaseLength, pCoeffs, pState}; |
emh203 | 0:3d9c67d97d6f | 117 | * arm_fir_interpolate_instance_q15 S = {L, phaseLength, pCoeffs, pState}; |
emh203 | 0:3d9c67d97d6f | 118 | * </pre> |
emh203 | 0:3d9c67d97d6f | 119 | * where <code>L</code> is the interpolation factor; <code>phaseLength=numTaps/L</code> is the |
emh203 | 0:3d9c67d97d6f | 120 | * length of each of the shorter FIR filters used internally, |
emh203 | 0:3d9c67d97d6f | 121 | * <code>pCoeffs</code> is the address of the coefficient buffer; |
emh203 | 0:3d9c67d97d6f | 122 | * <code>pState</code> is the address of the state buffer. |
emh203 | 0:3d9c67d97d6f | 123 | * Be sure to set the values in the state buffer to zeros when doing static initialization. |
emh203 | 0:3d9c67d97d6f | 124 | * |
emh203 | 0:3d9c67d97d6f | 125 | * \par Fixed-Point Behavior |
emh203 | 0:3d9c67d97d6f | 126 | * Care must be taken when using the fixed-point versions of the FIR interpolate filter functions. |
emh203 | 0:3d9c67d97d6f | 127 | * In particular, the overflow and saturation behavior of the accumulator used in each function must be considered. |
emh203 | 0:3d9c67d97d6f | 128 | * Refer to the function specific documentation below for usage guidelines. |
emh203 | 0:3d9c67d97d6f | 129 | */ |
emh203 | 0:3d9c67d97d6f | 130 | |
emh203 | 0:3d9c67d97d6f | 131 | /** |
emh203 | 0:3d9c67d97d6f | 132 | * @addtogroup FIR_Interpolate |
emh203 | 0:3d9c67d97d6f | 133 | * @{ |
emh203 | 0:3d9c67d97d6f | 134 | */ |
emh203 | 0:3d9c67d97d6f | 135 | |
emh203 | 0:3d9c67d97d6f | 136 | /** |
emh203 | 0:3d9c67d97d6f | 137 | * @brief Processing function for the floating-point FIR interpolator. |
emh203 | 0:3d9c67d97d6f | 138 | * @param[in] *S points to an instance of the floating-point FIR interpolator structure. |
emh203 | 0:3d9c67d97d6f | 139 | * @param[in] *pSrc points to the block of input data. |
emh203 | 0:3d9c67d97d6f | 140 | * @param[out] *pDst points to the block of output data. |
emh203 | 0:3d9c67d97d6f | 141 | * @param[in] blockSize number of input samples to process per call. |
emh203 | 0:3d9c67d97d6f | 142 | * @return none. |
emh203 | 0:3d9c67d97d6f | 143 | */ |
emh203 | 0:3d9c67d97d6f | 144 | #ifndef ARM_MATH_CM0_FAMILY |
emh203 | 0:3d9c67d97d6f | 145 | |
emh203 | 0:3d9c67d97d6f | 146 | /* Run the below code for Cortex-M4 and Cortex-M3 */ |
emh203 | 0:3d9c67d97d6f | 147 | |
emh203 | 0:3d9c67d97d6f | 148 | void arm_fir_interpolate_f32( |
emh203 | 0:3d9c67d97d6f | 149 | const arm_fir_interpolate_instance_f32 * S, |
emh203 | 0:3d9c67d97d6f | 150 | float32_t * pSrc, |
emh203 | 0:3d9c67d97d6f | 151 | float32_t * pDst, |
emh203 | 0:3d9c67d97d6f | 152 | uint32_t blockSize) |
emh203 | 0:3d9c67d97d6f | 153 | { |
emh203 | 0:3d9c67d97d6f | 154 | float32_t *pState = S->pState; /* State pointer */ |
emh203 | 0:3d9c67d97d6f | 155 | float32_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ |
emh203 | 0:3d9c67d97d6f | 156 | float32_t *pStateCurnt; /* Points to the current sample of the state */ |
emh203 | 0:3d9c67d97d6f | 157 | float32_t *ptr1, *ptr2; /* Temporary pointers for state and coefficient buffers */ |
emh203 | 0:3d9c67d97d6f | 158 | float32_t sum0; /* Accumulators */ |
emh203 | 0:3d9c67d97d6f | 159 | float32_t x0, c0; /* Temporary variables to hold state and coefficient values */ |
emh203 | 0:3d9c67d97d6f | 160 | uint32_t i, blkCnt, j; /* Loop counters */ |
emh203 | 0:3d9c67d97d6f | 161 | uint16_t phaseLen = S->phaseLength, tapCnt; /* Length of each polyphase filter component */ |
emh203 | 0:3d9c67d97d6f | 162 | float32_t acc0, acc1, acc2, acc3; |
emh203 | 0:3d9c67d97d6f | 163 | float32_t x1, x2, x3; |
emh203 | 0:3d9c67d97d6f | 164 | uint32_t blkCntN4; |
emh203 | 0:3d9c67d97d6f | 165 | float32_t c1, c2, c3; |
emh203 | 0:3d9c67d97d6f | 166 | |
emh203 | 0:3d9c67d97d6f | 167 | /* S->pState buffer contains previous frame (phaseLen - 1) samples */ |
emh203 | 0:3d9c67d97d6f | 168 | /* pStateCurnt points to the location where the new input data should be written */ |
emh203 | 0:3d9c67d97d6f | 169 | pStateCurnt = S->pState + (phaseLen - 1u); |
emh203 | 0:3d9c67d97d6f | 170 | |
emh203 | 0:3d9c67d97d6f | 171 | /* Initialise blkCnt */ |
emh203 | 0:3d9c67d97d6f | 172 | blkCnt = blockSize / 4; |
emh203 | 0:3d9c67d97d6f | 173 | blkCntN4 = blockSize - (4 * blkCnt); |
emh203 | 0:3d9c67d97d6f | 174 | |
emh203 | 0:3d9c67d97d6f | 175 | /* Samples loop unrolled by 4 */ |
emh203 | 0:3d9c67d97d6f | 176 | while(blkCnt > 0u) |
emh203 | 0:3d9c67d97d6f | 177 | { |
emh203 | 0:3d9c67d97d6f | 178 | /* Copy new input sample into the state buffer */ |
emh203 | 0:3d9c67d97d6f | 179 | *pStateCurnt++ = *pSrc++; |
emh203 | 0:3d9c67d97d6f | 180 | *pStateCurnt++ = *pSrc++; |
emh203 | 0:3d9c67d97d6f | 181 | *pStateCurnt++ = *pSrc++; |
emh203 | 0:3d9c67d97d6f | 182 | *pStateCurnt++ = *pSrc++; |
emh203 | 0:3d9c67d97d6f | 183 | |
emh203 | 0:3d9c67d97d6f | 184 | /* Address modifier index of coefficient buffer */ |
emh203 | 0:3d9c67d97d6f | 185 | j = 1u; |
emh203 | 0:3d9c67d97d6f | 186 | |
emh203 | 0:3d9c67d97d6f | 187 | /* Loop over the Interpolation factor. */ |
emh203 | 0:3d9c67d97d6f | 188 | i = (S->L); |
emh203 | 0:3d9c67d97d6f | 189 | |
emh203 | 0:3d9c67d97d6f | 190 | while(i > 0u) |
emh203 | 0:3d9c67d97d6f | 191 | { |
emh203 | 0:3d9c67d97d6f | 192 | /* Set accumulator to zero */ |
emh203 | 0:3d9c67d97d6f | 193 | acc0 = 0.0f; |
emh203 | 0:3d9c67d97d6f | 194 | acc1 = 0.0f; |
emh203 | 0:3d9c67d97d6f | 195 | acc2 = 0.0f; |
emh203 | 0:3d9c67d97d6f | 196 | acc3 = 0.0f; |
emh203 | 0:3d9c67d97d6f | 197 | |
emh203 | 0:3d9c67d97d6f | 198 | /* Initialize state pointer */ |
emh203 | 0:3d9c67d97d6f | 199 | ptr1 = pState; |
emh203 | 0:3d9c67d97d6f | 200 | |
emh203 | 0:3d9c67d97d6f | 201 | /* Initialize coefficient pointer */ |
emh203 | 0:3d9c67d97d6f | 202 | ptr2 = pCoeffs + (S->L - j); |
emh203 | 0:3d9c67d97d6f | 203 | |
emh203 | 0:3d9c67d97d6f | 204 | /* Loop over the polyPhase length. Unroll by a factor of 4. |
emh203 | 0:3d9c67d97d6f | 205 | ** Repeat until we've computed numTaps-(4*S->L) coefficients. */ |
emh203 | 0:3d9c67d97d6f | 206 | tapCnt = phaseLen >> 2u; |
emh203 | 0:3d9c67d97d6f | 207 | |
emh203 | 0:3d9c67d97d6f | 208 | x0 = *(ptr1++); |
emh203 | 0:3d9c67d97d6f | 209 | x1 = *(ptr1++); |
emh203 | 0:3d9c67d97d6f | 210 | x2 = *(ptr1++); |
emh203 | 0:3d9c67d97d6f | 211 | |
emh203 | 0:3d9c67d97d6f | 212 | while(tapCnt > 0u) |
emh203 | 0:3d9c67d97d6f | 213 | { |
emh203 | 0:3d9c67d97d6f | 214 | |
emh203 | 0:3d9c67d97d6f | 215 | /* Read the input sample */ |
emh203 | 0:3d9c67d97d6f | 216 | x3 = *(ptr1++); |
emh203 | 0:3d9c67d97d6f | 217 | |
emh203 | 0:3d9c67d97d6f | 218 | /* Read the coefficient */ |
emh203 | 0:3d9c67d97d6f | 219 | c0 = *(ptr2); |
emh203 | 0:3d9c67d97d6f | 220 | |
emh203 | 0:3d9c67d97d6f | 221 | /* Perform the multiply-accumulate */ |
emh203 | 0:3d9c67d97d6f | 222 | acc0 += x0 * c0; |
emh203 | 0:3d9c67d97d6f | 223 | acc1 += x1 * c0; |
emh203 | 0:3d9c67d97d6f | 224 | acc2 += x2 * c0; |
emh203 | 0:3d9c67d97d6f | 225 | acc3 += x3 * c0; |
emh203 | 0:3d9c67d97d6f | 226 | |
emh203 | 0:3d9c67d97d6f | 227 | /* Read the coefficient */ |
emh203 | 0:3d9c67d97d6f | 228 | c1 = *(ptr2 + S->L); |
emh203 | 0:3d9c67d97d6f | 229 | |
emh203 | 0:3d9c67d97d6f | 230 | /* Read the input sample */ |
emh203 | 0:3d9c67d97d6f | 231 | x0 = *(ptr1++); |
emh203 | 0:3d9c67d97d6f | 232 | |
emh203 | 0:3d9c67d97d6f | 233 | /* Perform the multiply-accumulate */ |
emh203 | 0:3d9c67d97d6f | 234 | acc0 += x1 * c1; |
emh203 | 0:3d9c67d97d6f | 235 | acc1 += x2 * c1; |
emh203 | 0:3d9c67d97d6f | 236 | acc2 += x3 * c1; |
emh203 | 0:3d9c67d97d6f | 237 | acc3 += x0 * c1; |
emh203 | 0:3d9c67d97d6f | 238 | |
emh203 | 0:3d9c67d97d6f | 239 | /* Read the coefficient */ |
emh203 | 0:3d9c67d97d6f | 240 | c2 = *(ptr2 + S->L * 2); |
emh203 | 0:3d9c67d97d6f | 241 | |
emh203 | 0:3d9c67d97d6f | 242 | /* Read the input sample */ |
emh203 | 0:3d9c67d97d6f | 243 | x1 = *(ptr1++); |
emh203 | 0:3d9c67d97d6f | 244 | |
emh203 | 0:3d9c67d97d6f | 245 | /* Perform the multiply-accumulate */ |
emh203 | 0:3d9c67d97d6f | 246 | acc0 += x2 * c2; |
emh203 | 0:3d9c67d97d6f | 247 | acc1 += x3 * c2; |
emh203 | 0:3d9c67d97d6f | 248 | acc2 += x0 * c2; |
emh203 | 0:3d9c67d97d6f | 249 | acc3 += x1 * c2; |
emh203 | 0:3d9c67d97d6f | 250 | |
emh203 | 0:3d9c67d97d6f | 251 | /* Read the coefficient */ |
emh203 | 0:3d9c67d97d6f | 252 | c3 = *(ptr2 + S->L * 3); |
emh203 | 0:3d9c67d97d6f | 253 | |
emh203 | 0:3d9c67d97d6f | 254 | /* Read the input sample */ |
emh203 | 0:3d9c67d97d6f | 255 | x2 = *(ptr1++); |
emh203 | 0:3d9c67d97d6f | 256 | |
emh203 | 0:3d9c67d97d6f | 257 | /* Perform the multiply-accumulate */ |
emh203 | 0:3d9c67d97d6f | 258 | acc0 += x3 * c3; |
emh203 | 0:3d9c67d97d6f | 259 | acc1 += x0 * c3; |
emh203 | 0:3d9c67d97d6f | 260 | acc2 += x1 * c3; |
emh203 | 0:3d9c67d97d6f | 261 | acc3 += x2 * c3; |
emh203 | 0:3d9c67d97d6f | 262 | |
emh203 | 0:3d9c67d97d6f | 263 | |
emh203 | 0:3d9c67d97d6f | 264 | /* Upsampling is done by stuffing L-1 zeros between each sample. |
emh203 | 0:3d9c67d97d6f | 265 | * So instead of multiplying zeros with coefficients, |
emh203 | 0:3d9c67d97d6f | 266 | * Increment the coefficient pointer by interpolation factor times. */ |
emh203 | 0:3d9c67d97d6f | 267 | ptr2 += 4 * S->L; |
emh203 | 0:3d9c67d97d6f | 268 | |
emh203 | 0:3d9c67d97d6f | 269 | /* Decrement the loop counter */ |
emh203 | 0:3d9c67d97d6f | 270 | tapCnt--; |
emh203 | 0:3d9c67d97d6f | 271 | } |
emh203 | 0:3d9c67d97d6f | 272 | |
emh203 | 0:3d9c67d97d6f | 273 | /* If the polyPhase length is not a multiple of 4, compute the remaining filter taps */ |
emh203 | 0:3d9c67d97d6f | 274 | tapCnt = phaseLen % 0x4u; |
emh203 | 0:3d9c67d97d6f | 275 | |
emh203 | 0:3d9c67d97d6f | 276 | while(tapCnt > 0u) |
emh203 | 0:3d9c67d97d6f | 277 | { |
emh203 | 0:3d9c67d97d6f | 278 | |
emh203 | 0:3d9c67d97d6f | 279 | /* Read the input sample */ |
emh203 | 0:3d9c67d97d6f | 280 | x3 = *(ptr1++); |
emh203 | 0:3d9c67d97d6f | 281 | |
emh203 | 0:3d9c67d97d6f | 282 | /* Read the coefficient */ |
emh203 | 0:3d9c67d97d6f | 283 | c0 = *(ptr2); |
emh203 | 0:3d9c67d97d6f | 284 | |
emh203 | 0:3d9c67d97d6f | 285 | /* Perform the multiply-accumulate */ |
emh203 | 0:3d9c67d97d6f | 286 | acc0 += x0 * c0; |
emh203 | 0:3d9c67d97d6f | 287 | acc1 += x1 * c0; |
emh203 | 0:3d9c67d97d6f | 288 | acc2 += x2 * c0; |
emh203 | 0:3d9c67d97d6f | 289 | acc3 += x3 * c0; |
emh203 | 0:3d9c67d97d6f | 290 | |
emh203 | 0:3d9c67d97d6f | 291 | /* Increment the coefficient pointer by interpolation factor times. */ |
emh203 | 0:3d9c67d97d6f | 292 | ptr2 += S->L; |
emh203 | 0:3d9c67d97d6f | 293 | |
emh203 | 0:3d9c67d97d6f | 294 | /* update states for next sample processing */ |
emh203 | 0:3d9c67d97d6f | 295 | x0 = x1; |
emh203 | 0:3d9c67d97d6f | 296 | x1 = x2; |
emh203 | 0:3d9c67d97d6f | 297 | x2 = x3; |
emh203 | 0:3d9c67d97d6f | 298 | |
emh203 | 0:3d9c67d97d6f | 299 | /* Decrement the loop counter */ |
emh203 | 0:3d9c67d97d6f | 300 | tapCnt--; |
emh203 | 0:3d9c67d97d6f | 301 | } |
emh203 | 0:3d9c67d97d6f | 302 | |
emh203 | 0:3d9c67d97d6f | 303 | /* The result is in the accumulator, store in the destination buffer. */ |
emh203 | 0:3d9c67d97d6f | 304 | *pDst = acc0; |
emh203 | 0:3d9c67d97d6f | 305 | *(pDst + S->L) = acc1; |
emh203 | 0:3d9c67d97d6f | 306 | *(pDst + 2 * S->L) = acc2; |
emh203 | 0:3d9c67d97d6f | 307 | *(pDst + 3 * S->L) = acc3; |
emh203 | 0:3d9c67d97d6f | 308 | |
emh203 | 0:3d9c67d97d6f | 309 | pDst++; |
emh203 | 0:3d9c67d97d6f | 310 | |
emh203 | 0:3d9c67d97d6f | 311 | /* Increment the address modifier index of coefficient buffer */ |
emh203 | 0:3d9c67d97d6f | 312 | j++; |
emh203 | 0:3d9c67d97d6f | 313 | |
emh203 | 0:3d9c67d97d6f | 314 | /* Decrement the loop counter */ |
emh203 | 0:3d9c67d97d6f | 315 | i--; |
emh203 | 0:3d9c67d97d6f | 316 | } |
emh203 | 0:3d9c67d97d6f | 317 | |
emh203 | 0:3d9c67d97d6f | 318 | /* Advance the state pointer by 1 |
emh203 | 0:3d9c67d97d6f | 319 | * to process the next group of interpolation factor number samples */ |
emh203 | 0:3d9c67d97d6f | 320 | pState = pState + 4; |
emh203 | 0:3d9c67d97d6f | 321 | |
emh203 | 0:3d9c67d97d6f | 322 | pDst += S->L * 3; |
emh203 | 0:3d9c67d97d6f | 323 | |
emh203 | 0:3d9c67d97d6f | 324 | /* Decrement the loop counter */ |
emh203 | 0:3d9c67d97d6f | 325 | blkCnt--; |
emh203 | 0:3d9c67d97d6f | 326 | } |
emh203 | 0:3d9c67d97d6f | 327 | |
emh203 | 0:3d9c67d97d6f | 328 | /* If the blockSize is not a multiple of 4, compute any remaining output samples here. |
emh203 | 0:3d9c67d97d6f | 329 | ** No loop unrolling is used. */ |
emh203 | 0:3d9c67d97d6f | 330 | |
emh203 | 0:3d9c67d97d6f | 331 | while(blkCntN4 > 0u) |
emh203 | 0:3d9c67d97d6f | 332 | { |
emh203 | 0:3d9c67d97d6f | 333 | /* Copy new input sample into the state buffer */ |
emh203 | 0:3d9c67d97d6f | 334 | *pStateCurnt++ = *pSrc++; |
emh203 | 0:3d9c67d97d6f | 335 | |
emh203 | 0:3d9c67d97d6f | 336 | /* Address modifier index of coefficient buffer */ |
emh203 | 0:3d9c67d97d6f | 337 | j = 1u; |
emh203 | 0:3d9c67d97d6f | 338 | |
emh203 | 0:3d9c67d97d6f | 339 | /* Loop over the Interpolation factor. */ |
emh203 | 0:3d9c67d97d6f | 340 | i = S->L; |
emh203 | 0:3d9c67d97d6f | 341 | while(i > 0u) |
emh203 | 0:3d9c67d97d6f | 342 | { |
emh203 | 0:3d9c67d97d6f | 343 | /* Set accumulator to zero */ |
emh203 | 0:3d9c67d97d6f | 344 | sum0 = 0.0f; |
emh203 | 0:3d9c67d97d6f | 345 | |
emh203 | 0:3d9c67d97d6f | 346 | /* Initialize state pointer */ |
emh203 | 0:3d9c67d97d6f | 347 | ptr1 = pState; |
emh203 | 0:3d9c67d97d6f | 348 | |
emh203 | 0:3d9c67d97d6f | 349 | /* Initialize coefficient pointer */ |
emh203 | 0:3d9c67d97d6f | 350 | ptr2 = pCoeffs + (S->L - j); |
emh203 | 0:3d9c67d97d6f | 351 | |
emh203 | 0:3d9c67d97d6f | 352 | /* Loop over the polyPhase length. Unroll by a factor of 4. |
emh203 | 0:3d9c67d97d6f | 353 | ** Repeat until we've computed numTaps-(4*S->L) coefficients. */ |
emh203 | 0:3d9c67d97d6f | 354 | tapCnt = phaseLen >> 2u; |
emh203 | 0:3d9c67d97d6f | 355 | while(tapCnt > 0u) |
emh203 | 0:3d9c67d97d6f | 356 | { |
emh203 | 0:3d9c67d97d6f | 357 | |
emh203 | 0:3d9c67d97d6f | 358 | /* Read the coefficient */ |
emh203 | 0:3d9c67d97d6f | 359 | c0 = *(ptr2); |
emh203 | 0:3d9c67d97d6f | 360 | |
emh203 | 0:3d9c67d97d6f | 361 | /* Upsampling is done by stuffing L-1 zeros between each sample. |
emh203 | 0:3d9c67d97d6f | 362 | * So instead of multiplying zeros with coefficients, |
emh203 | 0:3d9c67d97d6f | 363 | * Increment the coefficient pointer by interpolation factor times. */ |
emh203 | 0:3d9c67d97d6f | 364 | ptr2 += S->L; |
emh203 | 0:3d9c67d97d6f | 365 | |
emh203 | 0:3d9c67d97d6f | 366 | /* Read the input sample */ |
emh203 | 0:3d9c67d97d6f | 367 | x0 = *(ptr1++); |
emh203 | 0:3d9c67d97d6f | 368 | |
emh203 | 0:3d9c67d97d6f | 369 | /* Perform the multiply-accumulate */ |
emh203 | 0:3d9c67d97d6f | 370 | sum0 += x0 * c0; |
emh203 | 0:3d9c67d97d6f | 371 | |
emh203 | 0:3d9c67d97d6f | 372 | /* Read the coefficient */ |
emh203 | 0:3d9c67d97d6f | 373 | c0 = *(ptr2); |
emh203 | 0:3d9c67d97d6f | 374 | |
emh203 | 0:3d9c67d97d6f | 375 | /* Increment the coefficient pointer by interpolation factor times. */ |
emh203 | 0:3d9c67d97d6f | 376 | ptr2 += S->L; |
emh203 | 0:3d9c67d97d6f | 377 | |
emh203 | 0:3d9c67d97d6f | 378 | /* Read the input sample */ |
emh203 | 0:3d9c67d97d6f | 379 | x0 = *(ptr1++); |
emh203 | 0:3d9c67d97d6f | 380 | |
emh203 | 0:3d9c67d97d6f | 381 | /* Perform the multiply-accumulate */ |
emh203 | 0:3d9c67d97d6f | 382 | sum0 += x0 * c0; |
emh203 | 0:3d9c67d97d6f | 383 | |
emh203 | 0:3d9c67d97d6f | 384 | /* Read the coefficient */ |
emh203 | 0:3d9c67d97d6f | 385 | c0 = *(ptr2); |
emh203 | 0:3d9c67d97d6f | 386 | |
emh203 | 0:3d9c67d97d6f | 387 | /* Increment the coefficient pointer by interpolation factor times. */ |
emh203 | 0:3d9c67d97d6f | 388 | ptr2 += S->L; |
emh203 | 0:3d9c67d97d6f | 389 | |
emh203 | 0:3d9c67d97d6f | 390 | /* Read the input sample */ |
emh203 | 0:3d9c67d97d6f | 391 | x0 = *(ptr1++); |
emh203 | 0:3d9c67d97d6f | 392 | |
emh203 | 0:3d9c67d97d6f | 393 | /* Perform the multiply-accumulate */ |
emh203 | 0:3d9c67d97d6f | 394 | sum0 += x0 * c0; |
emh203 | 0:3d9c67d97d6f | 395 | |
emh203 | 0:3d9c67d97d6f | 396 | /* Read the coefficient */ |
emh203 | 0:3d9c67d97d6f | 397 | c0 = *(ptr2); |
emh203 | 0:3d9c67d97d6f | 398 | |
emh203 | 0:3d9c67d97d6f | 399 | /* Increment the coefficient pointer by interpolation factor times. */ |
emh203 | 0:3d9c67d97d6f | 400 | ptr2 += S->L; |
emh203 | 0:3d9c67d97d6f | 401 | |
emh203 | 0:3d9c67d97d6f | 402 | /* Read the input sample */ |
emh203 | 0:3d9c67d97d6f | 403 | x0 = *(ptr1++); |
emh203 | 0:3d9c67d97d6f | 404 | |
emh203 | 0:3d9c67d97d6f | 405 | /* Perform the multiply-accumulate */ |
emh203 | 0:3d9c67d97d6f | 406 | sum0 += x0 * c0; |
emh203 | 0:3d9c67d97d6f | 407 | |
emh203 | 0:3d9c67d97d6f | 408 | /* Decrement the loop counter */ |
emh203 | 0:3d9c67d97d6f | 409 | tapCnt--; |
emh203 | 0:3d9c67d97d6f | 410 | } |
emh203 | 0:3d9c67d97d6f | 411 | |
emh203 | 0:3d9c67d97d6f | 412 | /* If the polyPhase length is not a multiple of 4, compute the remaining filter taps */ |
emh203 | 0:3d9c67d97d6f | 413 | tapCnt = phaseLen % 0x4u; |
emh203 | 0:3d9c67d97d6f | 414 | |
emh203 | 0:3d9c67d97d6f | 415 | while(tapCnt > 0u) |
emh203 | 0:3d9c67d97d6f | 416 | { |
emh203 | 0:3d9c67d97d6f | 417 | /* Perform the multiply-accumulate */ |
emh203 | 0:3d9c67d97d6f | 418 | sum0 += *(ptr1++) * (*ptr2); |
emh203 | 0:3d9c67d97d6f | 419 | |
emh203 | 0:3d9c67d97d6f | 420 | /* Increment the coefficient pointer by interpolation factor times. */ |
emh203 | 0:3d9c67d97d6f | 421 | ptr2 += S->L; |
emh203 | 0:3d9c67d97d6f | 422 | |
emh203 | 0:3d9c67d97d6f | 423 | /* Decrement the loop counter */ |
emh203 | 0:3d9c67d97d6f | 424 | tapCnt--; |
emh203 | 0:3d9c67d97d6f | 425 | } |
emh203 | 0:3d9c67d97d6f | 426 | |
emh203 | 0:3d9c67d97d6f | 427 | /* The result is in the accumulator, store in the destination buffer. */ |
emh203 | 0:3d9c67d97d6f | 428 | *pDst++ = sum0; |
emh203 | 0:3d9c67d97d6f | 429 | |
emh203 | 0:3d9c67d97d6f | 430 | /* Increment the address modifier index of coefficient buffer */ |
emh203 | 0:3d9c67d97d6f | 431 | j++; |
emh203 | 0:3d9c67d97d6f | 432 | |
emh203 | 0:3d9c67d97d6f | 433 | /* Decrement the loop counter */ |
emh203 | 0:3d9c67d97d6f | 434 | i--; |
emh203 | 0:3d9c67d97d6f | 435 | } |
emh203 | 0:3d9c67d97d6f | 436 | |
emh203 | 0:3d9c67d97d6f | 437 | /* Advance the state pointer by 1 |
emh203 | 0:3d9c67d97d6f | 438 | * to process the next group of interpolation factor number samples */ |
emh203 | 0:3d9c67d97d6f | 439 | pState = pState + 1; |
emh203 | 0:3d9c67d97d6f | 440 | |
emh203 | 0:3d9c67d97d6f | 441 | /* Decrement the loop counter */ |
emh203 | 0:3d9c67d97d6f | 442 | blkCntN4--; |
emh203 | 0:3d9c67d97d6f | 443 | } |
emh203 | 0:3d9c67d97d6f | 444 | |
emh203 | 0:3d9c67d97d6f | 445 | /* Processing is complete. |
emh203 | 0:3d9c67d97d6f | 446 | ** Now copy the last phaseLen - 1 samples to the satrt of the state buffer. |
emh203 | 0:3d9c67d97d6f | 447 | ** This prepares the state buffer for the next function call. */ |
emh203 | 0:3d9c67d97d6f | 448 | |
emh203 | 0:3d9c67d97d6f | 449 | /* Points to the start of the state buffer */ |
emh203 | 0:3d9c67d97d6f | 450 | pStateCurnt = S->pState; |
emh203 | 0:3d9c67d97d6f | 451 | |
emh203 | 0:3d9c67d97d6f | 452 | tapCnt = (phaseLen - 1u) >> 2u; |
emh203 | 0:3d9c67d97d6f | 453 | |
emh203 | 0:3d9c67d97d6f | 454 | /* copy data */ |
emh203 | 0:3d9c67d97d6f | 455 | while(tapCnt > 0u) |
emh203 | 0:3d9c67d97d6f | 456 | { |
emh203 | 0:3d9c67d97d6f | 457 | *pStateCurnt++ = *pState++; |
emh203 | 0:3d9c67d97d6f | 458 | *pStateCurnt++ = *pState++; |
emh203 | 0:3d9c67d97d6f | 459 | *pStateCurnt++ = *pState++; |
emh203 | 0:3d9c67d97d6f | 460 | *pStateCurnt++ = *pState++; |
emh203 | 0:3d9c67d97d6f | 461 | |
emh203 | 0:3d9c67d97d6f | 462 | /* Decrement the loop counter */ |
emh203 | 0:3d9c67d97d6f | 463 | tapCnt--; |
emh203 | 0:3d9c67d97d6f | 464 | } |
emh203 | 0:3d9c67d97d6f | 465 | |
emh203 | 0:3d9c67d97d6f | 466 | tapCnt = (phaseLen - 1u) % 0x04u; |
emh203 | 0:3d9c67d97d6f | 467 | |
emh203 | 0:3d9c67d97d6f | 468 | /* copy data */ |
emh203 | 0:3d9c67d97d6f | 469 | while(tapCnt > 0u) |
emh203 | 0:3d9c67d97d6f | 470 | { |
emh203 | 0:3d9c67d97d6f | 471 | *pStateCurnt++ = *pState++; |
emh203 | 0:3d9c67d97d6f | 472 | |
emh203 | 0:3d9c67d97d6f | 473 | /* Decrement the loop counter */ |
emh203 | 0:3d9c67d97d6f | 474 | tapCnt--; |
emh203 | 0:3d9c67d97d6f | 475 | } |
emh203 | 0:3d9c67d97d6f | 476 | } |
emh203 | 0:3d9c67d97d6f | 477 | |
emh203 | 0:3d9c67d97d6f | 478 | #else |
emh203 | 0:3d9c67d97d6f | 479 | |
emh203 | 0:3d9c67d97d6f | 480 | /* Run the below code for Cortex-M0 */ |
emh203 | 0:3d9c67d97d6f | 481 | |
emh203 | 0:3d9c67d97d6f | 482 | void arm_fir_interpolate_f32( |
emh203 | 0:3d9c67d97d6f | 483 | const arm_fir_interpolate_instance_f32 * S, |
emh203 | 0:3d9c67d97d6f | 484 | float32_t * pSrc, |
emh203 | 0:3d9c67d97d6f | 485 | float32_t * pDst, |
emh203 | 0:3d9c67d97d6f | 486 | uint32_t blockSize) |
emh203 | 0:3d9c67d97d6f | 487 | { |
emh203 | 0:3d9c67d97d6f | 488 | float32_t *pState = S->pState; /* State pointer */ |
emh203 | 0:3d9c67d97d6f | 489 | float32_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */ |
emh203 | 0:3d9c67d97d6f | 490 | float32_t *pStateCurnt; /* Points to the current sample of the state */ |
emh203 | 0:3d9c67d97d6f | 491 | float32_t *ptr1, *ptr2; /* Temporary pointers for state and coefficient buffers */ |
emh203 | 0:3d9c67d97d6f | 492 | |
emh203 | 0:3d9c67d97d6f | 493 | |
emh203 | 0:3d9c67d97d6f | 494 | float32_t sum; /* Accumulator */ |
emh203 | 0:3d9c67d97d6f | 495 | uint32_t i, blkCnt; /* Loop counters */ |
emh203 | 0:3d9c67d97d6f | 496 | uint16_t phaseLen = S->phaseLength, tapCnt; /* Length of each polyphase filter component */ |
emh203 | 0:3d9c67d97d6f | 497 | |
emh203 | 0:3d9c67d97d6f | 498 | |
emh203 | 0:3d9c67d97d6f | 499 | /* S->pState buffer contains previous frame (phaseLen - 1) samples */ |
emh203 | 0:3d9c67d97d6f | 500 | /* pStateCurnt points to the location where the new input data should be written */ |
emh203 | 0:3d9c67d97d6f | 501 | pStateCurnt = S->pState + (phaseLen - 1u); |
emh203 | 0:3d9c67d97d6f | 502 | |
emh203 | 0:3d9c67d97d6f | 503 | /* Total number of intput samples */ |
emh203 | 0:3d9c67d97d6f | 504 | blkCnt = blockSize; |
emh203 | 0:3d9c67d97d6f | 505 | |
emh203 | 0:3d9c67d97d6f | 506 | /* Loop over the blockSize. */ |
emh203 | 0:3d9c67d97d6f | 507 | while(blkCnt > 0u) |
emh203 | 0:3d9c67d97d6f | 508 | { |
emh203 | 0:3d9c67d97d6f | 509 | /* Copy new input sample into the state buffer */ |
emh203 | 0:3d9c67d97d6f | 510 | *pStateCurnt++ = *pSrc++; |
emh203 | 0:3d9c67d97d6f | 511 | |
emh203 | 0:3d9c67d97d6f | 512 | /* Loop over the Interpolation factor. */ |
emh203 | 0:3d9c67d97d6f | 513 | i = S->L; |
emh203 | 0:3d9c67d97d6f | 514 | |
emh203 | 0:3d9c67d97d6f | 515 | while(i > 0u) |
emh203 | 0:3d9c67d97d6f | 516 | { |
emh203 | 0:3d9c67d97d6f | 517 | /* Set accumulator to zero */ |
emh203 | 0:3d9c67d97d6f | 518 | sum = 0.0f; |
emh203 | 0:3d9c67d97d6f | 519 | |
emh203 | 0:3d9c67d97d6f | 520 | /* Initialize state pointer */ |
emh203 | 0:3d9c67d97d6f | 521 | ptr1 = pState; |
emh203 | 0:3d9c67d97d6f | 522 | |
emh203 | 0:3d9c67d97d6f | 523 | /* Initialize coefficient pointer */ |
emh203 | 0:3d9c67d97d6f | 524 | ptr2 = pCoeffs + (i - 1u); |
emh203 | 0:3d9c67d97d6f | 525 | |
emh203 | 0:3d9c67d97d6f | 526 | /* Loop over the polyPhase length */ |
emh203 | 0:3d9c67d97d6f | 527 | tapCnt = phaseLen; |
emh203 | 0:3d9c67d97d6f | 528 | |
emh203 | 0:3d9c67d97d6f | 529 | while(tapCnt > 0u) |
emh203 | 0:3d9c67d97d6f | 530 | { |
emh203 | 0:3d9c67d97d6f | 531 | /* Perform the multiply-accumulate */ |
emh203 | 0:3d9c67d97d6f | 532 | sum += *ptr1++ * *ptr2; |
emh203 | 0:3d9c67d97d6f | 533 | |
emh203 | 0:3d9c67d97d6f | 534 | /* Increment the coefficient pointer by interpolation factor times. */ |
emh203 | 0:3d9c67d97d6f | 535 | ptr2 += S->L; |
emh203 | 0:3d9c67d97d6f | 536 | |
emh203 | 0:3d9c67d97d6f | 537 | /* Decrement the loop counter */ |
emh203 | 0:3d9c67d97d6f | 538 | tapCnt--; |
emh203 | 0:3d9c67d97d6f | 539 | } |
emh203 | 0:3d9c67d97d6f | 540 | |
emh203 | 0:3d9c67d97d6f | 541 | /* The result is in the accumulator, store in the destination buffer. */ |
emh203 | 0:3d9c67d97d6f | 542 | *pDst++ = sum; |
emh203 | 0:3d9c67d97d6f | 543 | |
emh203 | 0:3d9c67d97d6f | 544 | /* Decrement the loop counter */ |
emh203 | 0:3d9c67d97d6f | 545 | i--; |
emh203 | 0:3d9c67d97d6f | 546 | } |
emh203 | 0:3d9c67d97d6f | 547 | |
emh203 | 0:3d9c67d97d6f | 548 | /* Advance the state pointer by 1 |
emh203 | 0:3d9c67d97d6f | 549 | * to process the next group of interpolation factor number samples */ |
emh203 | 0:3d9c67d97d6f | 550 | pState = pState + 1; |
emh203 | 0:3d9c67d97d6f | 551 | |
emh203 | 0:3d9c67d97d6f | 552 | /* Decrement the loop counter */ |
emh203 | 0:3d9c67d97d6f | 553 | blkCnt--; |
emh203 | 0:3d9c67d97d6f | 554 | } |
emh203 | 0:3d9c67d97d6f | 555 | |
emh203 | 0:3d9c67d97d6f | 556 | /* Processing is complete. |
emh203 | 0:3d9c67d97d6f | 557 | ** Now copy the last phaseLen - 1 samples to the start of the state buffer. |
emh203 | 0:3d9c67d97d6f | 558 | ** This prepares the state buffer for the next function call. */ |
emh203 | 0:3d9c67d97d6f | 559 | |
emh203 | 0:3d9c67d97d6f | 560 | /* Points to the start of the state buffer */ |
emh203 | 0:3d9c67d97d6f | 561 | pStateCurnt = S->pState; |
emh203 | 0:3d9c67d97d6f | 562 | |
emh203 | 0:3d9c67d97d6f | 563 | tapCnt = phaseLen - 1u; |
emh203 | 0:3d9c67d97d6f | 564 | |
emh203 | 0:3d9c67d97d6f | 565 | while(tapCnt > 0u) |
emh203 | 0:3d9c67d97d6f | 566 | { |
emh203 | 0:3d9c67d97d6f | 567 | *pStateCurnt++ = *pState++; |
emh203 | 0:3d9c67d97d6f | 568 | |
emh203 | 0:3d9c67d97d6f | 569 | /* Decrement the loop counter */ |
emh203 | 0:3d9c67d97d6f | 570 | tapCnt--; |
emh203 | 0:3d9c67d97d6f | 571 | } |
emh203 | 0:3d9c67d97d6f | 572 | |
emh203 | 0:3d9c67d97d6f | 573 | } |
emh203 | 0:3d9c67d97d6f | 574 | |
emh203 | 0:3d9c67d97d6f | 575 | #endif /* #ifndef ARM_MATH_CM0_FAMILY */ |
emh203 | 0:3d9c67d97d6f | 576 | |
emh203 | 0:3d9c67d97d6f | 577 | |
emh203 | 0:3d9c67d97d6f | 578 | |
emh203 | 0:3d9c67d97d6f | 579 | /** |
emh203 | 0:3d9c67d97d6f | 580 | * @} end of FIR_Interpolate group |
emh203 | 0:3d9c67d97d6f | 581 | */ |