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

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?

UserRevisionLine numberNew 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_q31.c
emh203 0:3d9c67d97d6f 9 *
emh203 0:3d9c67d97d6f 10 * Description: Q31 FIR interpolation.
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 * @ingroup groupFilters
emh203 0:3d9c67d97d6f 45 */
emh203 0:3d9c67d97d6f 46
emh203 0:3d9c67d97d6f 47 /**
emh203 0:3d9c67d97d6f 48 * @addtogroup FIR_Interpolate
emh203 0:3d9c67d97d6f 49 * @{
emh203 0:3d9c67d97d6f 50 */
emh203 0:3d9c67d97d6f 51
emh203 0:3d9c67d97d6f 52 /**
emh203 0:3d9c67d97d6f 53 * @brief Processing function for the Q31 FIR interpolator.
emh203 0:3d9c67d97d6f 54 * @param[in] *S points to an instance of the Q31 FIR interpolator structure.
emh203 0:3d9c67d97d6f 55 * @param[in] *pSrc points to the block of input data.
emh203 0:3d9c67d97d6f 56 * @param[out] *pDst points to the block of output data.
emh203 0:3d9c67d97d6f 57 * @param[in] blockSize number of input samples to process per call.
emh203 0:3d9c67d97d6f 58 * @return none.
emh203 0:3d9c67d97d6f 59 *
emh203 0:3d9c67d97d6f 60 * <b>Scaling and Overflow Behavior:</b>
emh203 0:3d9c67d97d6f 61 * \par
emh203 0:3d9c67d97d6f 62 * The function is implemented using an internal 64-bit accumulator.
emh203 0:3d9c67d97d6f 63 * The accumulator has a 2.62 format and maintains full precision of the intermediate multiplication results but provides only a single guard bit.
emh203 0:3d9c67d97d6f 64 * Thus, if the accumulator result overflows it wraps around rather than clip.
emh203 0:3d9c67d97d6f 65 * In order to avoid overflows completely the input signal must be scaled down by <code>1/(numTaps/L)</code>.
emh203 0:3d9c67d97d6f 66 * since <code>numTaps/L</code> additions occur per output sample.
emh203 0:3d9c67d97d6f 67 * After all multiply-accumulates are performed, the 2.62 accumulator is truncated to 1.32 format and then saturated to 1.31 format.
emh203 0:3d9c67d97d6f 68 */
emh203 0:3d9c67d97d6f 69
emh203 0:3d9c67d97d6f 70 #ifndef ARM_MATH_CM0_FAMILY
emh203 0:3d9c67d97d6f 71
emh203 0:3d9c67d97d6f 72 /* Run the below code for Cortex-M4 and Cortex-M3 */
emh203 0:3d9c67d97d6f 73
emh203 0:3d9c67d97d6f 74 void arm_fir_interpolate_q31(
emh203 0:3d9c67d97d6f 75 const arm_fir_interpolate_instance_q31 * S,
emh203 0:3d9c67d97d6f 76 q31_t * pSrc,
emh203 0:3d9c67d97d6f 77 q31_t * pDst,
emh203 0:3d9c67d97d6f 78 uint32_t blockSize)
emh203 0:3d9c67d97d6f 79 {
emh203 0:3d9c67d97d6f 80 q31_t *pState = S->pState; /* State pointer */
emh203 0:3d9c67d97d6f 81 q31_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */
emh203 0:3d9c67d97d6f 82 q31_t *pStateCurnt; /* Points to the current sample of the state */
emh203 0:3d9c67d97d6f 83 q31_t *ptr1, *ptr2; /* Temporary pointers for state and coefficient buffers */
emh203 0:3d9c67d97d6f 84 q63_t sum0; /* Accumulators */
emh203 0:3d9c67d97d6f 85 q31_t x0, c0; /* Temporary variables to hold state and coefficient values */
emh203 0:3d9c67d97d6f 86 uint32_t i, blkCnt, j; /* Loop counters */
emh203 0:3d9c67d97d6f 87 uint16_t phaseLen = S->phaseLength, tapCnt; /* Length of each polyphase filter component */
emh203 0:3d9c67d97d6f 88
emh203 0:3d9c67d97d6f 89 uint32_t blkCntN2;
emh203 0:3d9c67d97d6f 90 q63_t acc0, acc1;
emh203 0:3d9c67d97d6f 91 q31_t x1;
emh203 0:3d9c67d97d6f 92
emh203 0:3d9c67d97d6f 93 /* S->pState buffer contains previous frame (phaseLen - 1) samples */
emh203 0:3d9c67d97d6f 94 /* pStateCurnt points to the location where the new input data should be written */
emh203 0:3d9c67d97d6f 95 pStateCurnt = S->pState + ((q31_t) phaseLen - 1);
emh203 0:3d9c67d97d6f 96
emh203 0:3d9c67d97d6f 97 /* Initialise blkCnt */
emh203 0:3d9c67d97d6f 98 blkCnt = blockSize / 2;
emh203 0:3d9c67d97d6f 99 blkCntN2 = blockSize - (2 * blkCnt);
emh203 0:3d9c67d97d6f 100
emh203 0:3d9c67d97d6f 101 /* Samples loop unrolled by 2 */
emh203 0:3d9c67d97d6f 102 while(blkCnt > 0u)
emh203 0:3d9c67d97d6f 103 {
emh203 0:3d9c67d97d6f 104 /* Copy new input sample into the state buffer */
emh203 0:3d9c67d97d6f 105 *pStateCurnt++ = *pSrc++;
emh203 0:3d9c67d97d6f 106 *pStateCurnt++ = *pSrc++;
emh203 0:3d9c67d97d6f 107
emh203 0:3d9c67d97d6f 108 /* Address modifier index of coefficient buffer */
emh203 0:3d9c67d97d6f 109 j = 1u;
emh203 0:3d9c67d97d6f 110
emh203 0:3d9c67d97d6f 111 /* Loop over the Interpolation factor. */
emh203 0:3d9c67d97d6f 112 i = (S->L);
emh203 0:3d9c67d97d6f 113
emh203 0:3d9c67d97d6f 114 while(i > 0u)
emh203 0:3d9c67d97d6f 115 {
emh203 0:3d9c67d97d6f 116 /* Set accumulator to zero */
emh203 0:3d9c67d97d6f 117 acc0 = 0;
emh203 0:3d9c67d97d6f 118 acc1 = 0;
emh203 0:3d9c67d97d6f 119
emh203 0:3d9c67d97d6f 120 /* Initialize state pointer */
emh203 0:3d9c67d97d6f 121 ptr1 = pState;
emh203 0:3d9c67d97d6f 122
emh203 0:3d9c67d97d6f 123 /* Initialize coefficient pointer */
emh203 0:3d9c67d97d6f 124 ptr2 = pCoeffs + (S->L - j);
emh203 0:3d9c67d97d6f 125
emh203 0:3d9c67d97d6f 126 /* Loop over the polyPhase length. Unroll by a factor of 4.
emh203 0:3d9c67d97d6f 127 ** Repeat until we've computed numTaps-(4*S->L) coefficients. */
emh203 0:3d9c67d97d6f 128 tapCnt = phaseLen >> 2u;
emh203 0:3d9c67d97d6f 129
emh203 0:3d9c67d97d6f 130 x0 = *(ptr1++);
emh203 0:3d9c67d97d6f 131
emh203 0:3d9c67d97d6f 132 while(tapCnt > 0u)
emh203 0:3d9c67d97d6f 133 {
emh203 0:3d9c67d97d6f 134
emh203 0:3d9c67d97d6f 135 /* Read the input sample */
emh203 0:3d9c67d97d6f 136 x1 = *(ptr1++);
emh203 0:3d9c67d97d6f 137
emh203 0:3d9c67d97d6f 138 /* Read the coefficient */
emh203 0:3d9c67d97d6f 139 c0 = *(ptr2);
emh203 0:3d9c67d97d6f 140
emh203 0:3d9c67d97d6f 141 /* Perform the multiply-accumulate */
emh203 0:3d9c67d97d6f 142 acc0 += (q63_t) x0 *c0;
emh203 0:3d9c67d97d6f 143 acc1 += (q63_t) x1 *c0;
emh203 0:3d9c67d97d6f 144
emh203 0:3d9c67d97d6f 145
emh203 0:3d9c67d97d6f 146 /* Read the coefficient */
emh203 0:3d9c67d97d6f 147 c0 = *(ptr2 + S->L);
emh203 0:3d9c67d97d6f 148
emh203 0:3d9c67d97d6f 149 /* Read the input sample */
emh203 0:3d9c67d97d6f 150 x0 = *(ptr1++);
emh203 0:3d9c67d97d6f 151
emh203 0:3d9c67d97d6f 152 /* Perform the multiply-accumulate */
emh203 0:3d9c67d97d6f 153 acc0 += (q63_t) x1 *c0;
emh203 0:3d9c67d97d6f 154 acc1 += (q63_t) x0 *c0;
emh203 0:3d9c67d97d6f 155
emh203 0:3d9c67d97d6f 156
emh203 0:3d9c67d97d6f 157 /* Read the coefficient */
emh203 0:3d9c67d97d6f 158 c0 = *(ptr2 + S->L * 2);
emh203 0:3d9c67d97d6f 159
emh203 0:3d9c67d97d6f 160 /* Read the input sample */
emh203 0:3d9c67d97d6f 161 x1 = *(ptr1++);
emh203 0:3d9c67d97d6f 162
emh203 0:3d9c67d97d6f 163 /* Perform the multiply-accumulate */
emh203 0:3d9c67d97d6f 164 acc0 += (q63_t) x0 *c0;
emh203 0:3d9c67d97d6f 165 acc1 += (q63_t) x1 *c0;
emh203 0:3d9c67d97d6f 166
emh203 0:3d9c67d97d6f 167 /* Read the coefficient */
emh203 0:3d9c67d97d6f 168 c0 = *(ptr2 + S->L * 3);
emh203 0:3d9c67d97d6f 169
emh203 0:3d9c67d97d6f 170 /* Read the input sample */
emh203 0:3d9c67d97d6f 171 x0 = *(ptr1++);
emh203 0:3d9c67d97d6f 172
emh203 0:3d9c67d97d6f 173 /* Perform the multiply-accumulate */
emh203 0:3d9c67d97d6f 174 acc0 += (q63_t) x1 *c0;
emh203 0:3d9c67d97d6f 175 acc1 += (q63_t) x0 *c0;
emh203 0:3d9c67d97d6f 176
emh203 0:3d9c67d97d6f 177
emh203 0:3d9c67d97d6f 178 /* Upsampling is done by stuffing L-1 zeros between each sample.
emh203 0:3d9c67d97d6f 179 * So instead of multiplying zeros with coefficients,
emh203 0:3d9c67d97d6f 180 * Increment the coefficient pointer by interpolation factor times. */
emh203 0:3d9c67d97d6f 181 ptr2 += 4 * S->L;
emh203 0:3d9c67d97d6f 182
emh203 0:3d9c67d97d6f 183 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 184 tapCnt--;
emh203 0:3d9c67d97d6f 185 }
emh203 0:3d9c67d97d6f 186
emh203 0:3d9c67d97d6f 187 /* If the polyPhase length is not a multiple of 4, compute the remaining filter taps */
emh203 0:3d9c67d97d6f 188 tapCnt = phaseLen % 0x4u;
emh203 0:3d9c67d97d6f 189
emh203 0:3d9c67d97d6f 190 while(tapCnt > 0u)
emh203 0:3d9c67d97d6f 191 {
emh203 0:3d9c67d97d6f 192
emh203 0:3d9c67d97d6f 193 /* Read the input sample */
emh203 0:3d9c67d97d6f 194 x1 = *(ptr1++);
emh203 0:3d9c67d97d6f 195
emh203 0:3d9c67d97d6f 196 /* Read the coefficient */
emh203 0:3d9c67d97d6f 197 c0 = *(ptr2);
emh203 0:3d9c67d97d6f 198
emh203 0:3d9c67d97d6f 199 /* Perform the multiply-accumulate */
emh203 0:3d9c67d97d6f 200 acc0 += (q63_t) x0 *c0;
emh203 0:3d9c67d97d6f 201 acc1 += (q63_t) x1 *c0;
emh203 0:3d9c67d97d6f 202
emh203 0:3d9c67d97d6f 203 /* Increment the coefficient pointer by interpolation factor times. */
emh203 0:3d9c67d97d6f 204 ptr2 += S->L;
emh203 0:3d9c67d97d6f 205
emh203 0:3d9c67d97d6f 206 /* update states for next sample processing */
emh203 0:3d9c67d97d6f 207 x0 = x1;
emh203 0:3d9c67d97d6f 208
emh203 0:3d9c67d97d6f 209 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 210 tapCnt--;
emh203 0:3d9c67d97d6f 211 }
emh203 0:3d9c67d97d6f 212
emh203 0:3d9c67d97d6f 213 /* The result is in the accumulator, store in the destination buffer. */
emh203 0:3d9c67d97d6f 214 *pDst = (q31_t) (acc0 >> 31);
emh203 0:3d9c67d97d6f 215 *(pDst + S->L) = (q31_t) (acc1 >> 31);
emh203 0:3d9c67d97d6f 216
emh203 0:3d9c67d97d6f 217
emh203 0:3d9c67d97d6f 218 pDst++;
emh203 0:3d9c67d97d6f 219
emh203 0:3d9c67d97d6f 220 /* Increment the address modifier index of coefficient buffer */
emh203 0:3d9c67d97d6f 221 j++;
emh203 0:3d9c67d97d6f 222
emh203 0:3d9c67d97d6f 223 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 224 i--;
emh203 0:3d9c67d97d6f 225 }
emh203 0:3d9c67d97d6f 226
emh203 0:3d9c67d97d6f 227 /* Advance the state pointer by 1
emh203 0:3d9c67d97d6f 228 * to process the next group of interpolation factor number samples */
emh203 0:3d9c67d97d6f 229 pState = pState + 2;
emh203 0:3d9c67d97d6f 230
emh203 0:3d9c67d97d6f 231 pDst += S->L;
emh203 0:3d9c67d97d6f 232
emh203 0:3d9c67d97d6f 233 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 234 blkCnt--;
emh203 0:3d9c67d97d6f 235 }
emh203 0:3d9c67d97d6f 236
emh203 0:3d9c67d97d6f 237 /* If the blockSize is not a multiple of 2, compute any remaining output samples here.
emh203 0:3d9c67d97d6f 238 ** No loop unrolling is used. */
emh203 0:3d9c67d97d6f 239 blkCnt = blkCntN2;
emh203 0:3d9c67d97d6f 240
emh203 0:3d9c67d97d6f 241 /* Loop over the blockSize. */
emh203 0:3d9c67d97d6f 242 while(blkCnt > 0u)
emh203 0:3d9c67d97d6f 243 {
emh203 0:3d9c67d97d6f 244 /* Copy new input sample into the state buffer */
emh203 0:3d9c67d97d6f 245 *pStateCurnt++ = *pSrc++;
emh203 0:3d9c67d97d6f 246
emh203 0:3d9c67d97d6f 247 /* Address modifier index of coefficient buffer */
emh203 0:3d9c67d97d6f 248 j = 1u;
emh203 0:3d9c67d97d6f 249
emh203 0:3d9c67d97d6f 250 /* Loop over the Interpolation factor. */
emh203 0:3d9c67d97d6f 251 i = S->L;
emh203 0:3d9c67d97d6f 252 while(i > 0u)
emh203 0:3d9c67d97d6f 253 {
emh203 0:3d9c67d97d6f 254 /* Set accumulator to zero */
emh203 0:3d9c67d97d6f 255 sum0 = 0;
emh203 0:3d9c67d97d6f 256
emh203 0:3d9c67d97d6f 257 /* Initialize state pointer */
emh203 0:3d9c67d97d6f 258 ptr1 = pState;
emh203 0:3d9c67d97d6f 259
emh203 0:3d9c67d97d6f 260 /* Initialize coefficient pointer */
emh203 0:3d9c67d97d6f 261 ptr2 = pCoeffs + (S->L - j);
emh203 0:3d9c67d97d6f 262
emh203 0:3d9c67d97d6f 263 /* Loop over the polyPhase length. Unroll by a factor of 4.
emh203 0:3d9c67d97d6f 264 ** Repeat until we've computed numTaps-(4*S->L) coefficients. */
emh203 0:3d9c67d97d6f 265 tapCnt = phaseLen >> 2;
emh203 0:3d9c67d97d6f 266 while(tapCnt > 0u)
emh203 0:3d9c67d97d6f 267 {
emh203 0:3d9c67d97d6f 268
emh203 0:3d9c67d97d6f 269 /* Read the coefficient */
emh203 0:3d9c67d97d6f 270 c0 = *(ptr2);
emh203 0:3d9c67d97d6f 271
emh203 0:3d9c67d97d6f 272 /* Upsampling is done by stuffing L-1 zeros between each sample.
emh203 0:3d9c67d97d6f 273 * So instead of multiplying zeros with coefficients,
emh203 0:3d9c67d97d6f 274 * Increment the coefficient pointer by interpolation factor times. */
emh203 0:3d9c67d97d6f 275 ptr2 += S->L;
emh203 0:3d9c67d97d6f 276
emh203 0:3d9c67d97d6f 277 /* Read the input sample */
emh203 0:3d9c67d97d6f 278 x0 = *(ptr1++);
emh203 0:3d9c67d97d6f 279
emh203 0:3d9c67d97d6f 280 /* Perform the multiply-accumulate */
emh203 0:3d9c67d97d6f 281 sum0 += (q63_t) x0 *c0;
emh203 0:3d9c67d97d6f 282
emh203 0:3d9c67d97d6f 283 /* Read the coefficient */
emh203 0:3d9c67d97d6f 284 c0 = *(ptr2);
emh203 0:3d9c67d97d6f 285
emh203 0:3d9c67d97d6f 286 /* Increment the coefficient pointer by interpolation factor times. */
emh203 0:3d9c67d97d6f 287 ptr2 += S->L;
emh203 0:3d9c67d97d6f 288
emh203 0:3d9c67d97d6f 289 /* Read the input sample */
emh203 0:3d9c67d97d6f 290 x0 = *(ptr1++);
emh203 0:3d9c67d97d6f 291
emh203 0:3d9c67d97d6f 292 /* Perform the multiply-accumulate */
emh203 0:3d9c67d97d6f 293 sum0 += (q63_t) x0 *c0;
emh203 0:3d9c67d97d6f 294
emh203 0:3d9c67d97d6f 295 /* Read the coefficient */
emh203 0:3d9c67d97d6f 296 c0 = *(ptr2);
emh203 0:3d9c67d97d6f 297
emh203 0:3d9c67d97d6f 298 /* Increment the coefficient pointer by interpolation factor times. */
emh203 0:3d9c67d97d6f 299 ptr2 += S->L;
emh203 0:3d9c67d97d6f 300
emh203 0:3d9c67d97d6f 301 /* Read the input sample */
emh203 0:3d9c67d97d6f 302 x0 = *(ptr1++);
emh203 0:3d9c67d97d6f 303
emh203 0:3d9c67d97d6f 304 /* Perform the multiply-accumulate */
emh203 0:3d9c67d97d6f 305 sum0 += (q63_t) x0 *c0;
emh203 0:3d9c67d97d6f 306
emh203 0:3d9c67d97d6f 307 /* Read the coefficient */
emh203 0:3d9c67d97d6f 308 c0 = *(ptr2);
emh203 0:3d9c67d97d6f 309
emh203 0:3d9c67d97d6f 310 /* Increment the coefficient pointer by interpolation factor times. */
emh203 0:3d9c67d97d6f 311 ptr2 += S->L;
emh203 0:3d9c67d97d6f 312
emh203 0:3d9c67d97d6f 313 /* Read the input sample */
emh203 0:3d9c67d97d6f 314 x0 = *(ptr1++);
emh203 0:3d9c67d97d6f 315
emh203 0:3d9c67d97d6f 316 /* Perform the multiply-accumulate */
emh203 0:3d9c67d97d6f 317 sum0 += (q63_t) x0 *c0;
emh203 0:3d9c67d97d6f 318
emh203 0:3d9c67d97d6f 319 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 320 tapCnt--;
emh203 0:3d9c67d97d6f 321 }
emh203 0:3d9c67d97d6f 322
emh203 0:3d9c67d97d6f 323 /* If the polyPhase length is not a multiple of 4, compute the remaining filter taps */
emh203 0:3d9c67d97d6f 324 tapCnt = phaseLen & 0x3u;
emh203 0:3d9c67d97d6f 325
emh203 0:3d9c67d97d6f 326 while(tapCnt > 0u)
emh203 0:3d9c67d97d6f 327 {
emh203 0:3d9c67d97d6f 328 /* Read the coefficient */
emh203 0:3d9c67d97d6f 329 c0 = *(ptr2);
emh203 0:3d9c67d97d6f 330
emh203 0:3d9c67d97d6f 331 /* Increment the coefficient pointer by interpolation factor times. */
emh203 0:3d9c67d97d6f 332 ptr2 += S->L;
emh203 0:3d9c67d97d6f 333
emh203 0:3d9c67d97d6f 334 /* Read the input sample */
emh203 0:3d9c67d97d6f 335 x0 = *(ptr1++);
emh203 0:3d9c67d97d6f 336
emh203 0:3d9c67d97d6f 337 /* Perform the multiply-accumulate */
emh203 0:3d9c67d97d6f 338 sum0 += (q63_t) x0 *c0;
emh203 0:3d9c67d97d6f 339
emh203 0:3d9c67d97d6f 340 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 341 tapCnt--;
emh203 0:3d9c67d97d6f 342 }
emh203 0:3d9c67d97d6f 343
emh203 0:3d9c67d97d6f 344 /* The result is in the accumulator, store in the destination buffer. */
emh203 0:3d9c67d97d6f 345 *pDst++ = (q31_t) (sum0 >> 31);
emh203 0:3d9c67d97d6f 346
emh203 0:3d9c67d97d6f 347 /* Increment the address modifier index of coefficient buffer */
emh203 0:3d9c67d97d6f 348 j++;
emh203 0:3d9c67d97d6f 349
emh203 0:3d9c67d97d6f 350 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 351 i--;
emh203 0:3d9c67d97d6f 352 }
emh203 0:3d9c67d97d6f 353
emh203 0:3d9c67d97d6f 354 /* Advance the state pointer by 1
emh203 0:3d9c67d97d6f 355 * to process the next group of interpolation factor number samples */
emh203 0:3d9c67d97d6f 356 pState = pState + 1;
emh203 0:3d9c67d97d6f 357
emh203 0:3d9c67d97d6f 358 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 359 blkCnt--;
emh203 0:3d9c67d97d6f 360 }
emh203 0:3d9c67d97d6f 361
emh203 0:3d9c67d97d6f 362 /* Processing is complete.
emh203 0:3d9c67d97d6f 363 ** Now copy the last phaseLen - 1 samples to the satrt of the state buffer.
emh203 0:3d9c67d97d6f 364 ** This prepares the state buffer for the next function call. */
emh203 0:3d9c67d97d6f 365
emh203 0:3d9c67d97d6f 366 /* Points to the start of the state buffer */
emh203 0:3d9c67d97d6f 367 pStateCurnt = S->pState;
emh203 0:3d9c67d97d6f 368
emh203 0:3d9c67d97d6f 369 tapCnt = (phaseLen - 1u) >> 2u;
emh203 0:3d9c67d97d6f 370
emh203 0:3d9c67d97d6f 371 /* copy data */
emh203 0:3d9c67d97d6f 372 while(tapCnt > 0u)
emh203 0:3d9c67d97d6f 373 {
emh203 0:3d9c67d97d6f 374 *pStateCurnt++ = *pState++;
emh203 0:3d9c67d97d6f 375 *pStateCurnt++ = *pState++;
emh203 0:3d9c67d97d6f 376 *pStateCurnt++ = *pState++;
emh203 0:3d9c67d97d6f 377 *pStateCurnt++ = *pState++;
emh203 0:3d9c67d97d6f 378
emh203 0:3d9c67d97d6f 379 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 380 tapCnt--;
emh203 0:3d9c67d97d6f 381 }
emh203 0:3d9c67d97d6f 382
emh203 0:3d9c67d97d6f 383 tapCnt = (phaseLen - 1u) % 0x04u;
emh203 0:3d9c67d97d6f 384
emh203 0:3d9c67d97d6f 385 /* copy data */
emh203 0:3d9c67d97d6f 386 while(tapCnt > 0u)
emh203 0:3d9c67d97d6f 387 {
emh203 0:3d9c67d97d6f 388 *pStateCurnt++ = *pState++;
emh203 0:3d9c67d97d6f 389
emh203 0:3d9c67d97d6f 390 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 391 tapCnt--;
emh203 0:3d9c67d97d6f 392 }
emh203 0:3d9c67d97d6f 393
emh203 0:3d9c67d97d6f 394 }
emh203 0:3d9c67d97d6f 395
emh203 0:3d9c67d97d6f 396
emh203 0:3d9c67d97d6f 397 #else
emh203 0:3d9c67d97d6f 398
emh203 0:3d9c67d97d6f 399 void arm_fir_interpolate_q31(
emh203 0:3d9c67d97d6f 400 const arm_fir_interpolate_instance_q31 * S,
emh203 0:3d9c67d97d6f 401 q31_t * pSrc,
emh203 0:3d9c67d97d6f 402 q31_t * pDst,
emh203 0:3d9c67d97d6f 403 uint32_t blockSize)
emh203 0:3d9c67d97d6f 404 {
emh203 0:3d9c67d97d6f 405 q31_t *pState = S->pState; /* State pointer */
emh203 0:3d9c67d97d6f 406 q31_t *pCoeffs = S->pCoeffs; /* Coefficient pointer */
emh203 0:3d9c67d97d6f 407 q31_t *pStateCurnt; /* Points to the current sample of the state */
emh203 0:3d9c67d97d6f 408 q31_t *ptr1, *ptr2; /* Temporary pointers for state and coefficient buffers */
emh203 0:3d9c67d97d6f 409
emh203 0:3d9c67d97d6f 410 /* Run the below code for Cortex-M0 */
emh203 0:3d9c67d97d6f 411
emh203 0:3d9c67d97d6f 412 q63_t sum; /* Accumulator */
emh203 0:3d9c67d97d6f 413 q31_t x0, c0; /* Temporary variables to hold state and coefficient values */
emh203 0:3d9c67d97d6f 414 uint32_t i, blkCnt; /* Loop counters */
emh203 0:3d9c67d97d6f 415 uint16_t phaseLen = S->phaseLength, tapCnt; /* Length of each polyphase filter component */
emh203 0:3d9c67d97d6f 416
emh203 0:3d9c67d97d6f 417
emh203 0:3d9c67d97d6f 418 /* S->pState buffer contains previous frame (phaseLen - 1) samples */
emh203 0:3d9c67d97d6f 419 /* pStateCurnt points to the location where the new input data should be written */
emh203 0:3d9c67d97d6f 420 pStateCurnt = S->pState + ((q31_t) phaseLen - 1);
emh203 0:3d9c67d97d6f 421
emh203 0:3d9c67d97d6f 422 /* Total number of intput samples */
emh203 0:3d9c67d97d6f 423 blkCnt = blockSize;
emh203 0:3d9c67d97d6f 424
emh203 0:3d9c67d97d6f 425 /* Loop over the blockSize. */
emh203 0:3d9c67d97d6f 426 while(blkCnt > 0u)
emh203 0:3d9c67d97d6f 427 {
emh203 0:3d9c67d97d6f 428 /* Copy new input sample into the state buffer */
emh203 0:3d9c67d97d6f 429 *pStateCurnt++ = *pSrc++;
emh203 0:3d9c67d97d6f 430
emh203 0:3d9c67d97d6f 431 /* Loop over the Interpolation factor. */
emh203 0:3d9c67d97d6f 432 i = S->L;
emh203 0:3d9c67d97d6f 433
emh203 0:3d9c67d97d6f 434 while(i > 0u)
emh203 0:3d9c67d97d6f 435 {
emh203 0:3d9c67d97d6f 436 /* Set accumulator to zero */
emh203 0:3d9c67d97d6f 437 sum = 0;
emh203 0:3d9c67d97d6f 438
emh203 0:3d9c67d97d6f 439 /* Initialize state pointer */
emh203 0:3d9c67d97d6f 440 ptr1 = pState;
emh203 0:3d9c67d97d6f 441
emh203 0:3d9c67d97d6f 442 /* Initialize coefficient pointer */
emh203 0:3d9c67d97d6f 443 ptr2 = pCoeffs + (i - 1u);
emh203 0:3d9c67d97d6f 444
emh203 0:3d9c67d97d6f 445 tapCnt = phaseLen;
emh203 0:3d9c67d97d6f 446
emh203 0:3d9c67d97d6f 447 while(tapCnt > 0u)
emh203 0:3d9c67d97d6f 448 {
emh203 0:3d9c67d97d6f 449 /* Read the coefficient */
emh203 0:3d9c67d97d6f 450 c0 = *(ptr2);
emh203 0:3d9c67d97d6f 451
emh203 0:3d9c67d97d6f 452 /* Increment the coefficient pointer by interpolation factor times. */
emh203 0:3d9c67d97d6f 453 ptr2 += S->L;
emh203 0:3d9c67d97d6f 454
emh203 0:3d9c67d97d6f 455 /* Read the input sample */
emh203 0:3d9c67d97d6f 456 x0 = *ptr1++;
emh203 0:3d9c67d97d6f 457
emh203 0:3d9c67d97d6f 458 /* Perform the multiply-accumulate */
emh203 0:3d9c67d97d6f 459 sum += (q63_t) x0 *c0;
emh203 0:3d9c67d97d6f 460
emh203 0:3d9c67d97d6f 461 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 462 tapCnt--;
emh203 0:3d9c67d97d6f 463 }
emh203 0:3d9c67d97d6f 464
emh203 0:3d9c67d97d6f 465 /* The result is in the accumulator, store in the destination buffer. */
emh203 0:3d9c67d97d6f 466 *pDst++ = (q31_t) (sum >> 31);
emh203 0:3d9c67d97d6f 467
emh203 0:3d9c67d97d6f 468 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 469 i--;
emh203 0:3d9c67d97d6f 470 }
emh203 0:3d9c67d97d6f 471
emh203 0:3d9c67d97d6f 472 /* Advance the state pointer by 1
emh203 0:3d9c67d97d6f 473 * to process the next group of interpolation factor number samples */
emh203 0:3d9c67d97d6f 474 pState = pState + 1;
emh203 0:3d9c67d97d6f 475
emh203 0:3d9c67d97d6f 476 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 477 blkCnt--;
emh203 0:3d9c67d97d6f 478 }
emh203 0:3d9c67d97d6f 479
emh203 0:3d9c67d97d6f 480 /* Processing is complete.
emh203 0:3d9c67d97d6f 481 ** Now copy the last phaseLen - 1 samples to the satrt of the state buffer.
emh203 0:3d9c67d97d6f 482 ** This prepares the state buffer for the next function call. */
emh203 0:3d9c67d97d6f 483
emh203 0:3d9c67d97d6f 484 /* Points to the start of the state buffer */
emh203 0:3d9c67d97d6f 485 pStateCurnt = S->pState;
emh203 0:3d9c67d97d6f 486
emh203 0:3d9c67d97d6f 487 tapCnt = phaseLen - 1u;
emh203 0:3d9c67d97d6f 488
emh203 0:3d9c67d97d6f 489 /* copy data */
emh203 0:3d9c67d97d6f 490 while(tapCnt > 0u)
emh203 0:3d9c67d97d6f 491 {
emh203 0:3d9c67d97d6f 492 *pStateCurnt++ = *pState++;
emh203 0:3d9c67d97d6f 493
emh203 0:3d9c67d97d6f 494 /* Decrement the loop counter */
emh203 0:3d9c67d97d6f 495 tapCnt--;
emh203 0:3d9c67d97d6f 496 }
emh203 0:3d9c67d97d6f 497
emh203 0:3d9c67d97d6f 498 }
emh203 0:3d9c67d97d6f 499
emh203 0:3d9c67d97d6f 500 #endif /* #ifndef ARM_MATH_CM0_FAMILY */
emh203 0:3d9c67d97d6f 501
emh203 0:3d9c67d97d6f 502 /**
emh203 0:3d9c67d97d6f 503 * @} end of FIR_Interpolate group
emh203 0:3d9c67d97d6f 504 */