CMSIS DSP Library from CMSIS 2.0. See http://www.onarm.com/cmsis/ for full details

Dependents:   K22F_DSP_Matrix_least_square BNO055-ELEC3810 1BNO055 ECE4180Project--Slave2 ... more

Committer:
simon
Date:
Thu Mar 10 15:07:50 2011 +0000
Revision:
0:1014af42efd9

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
simon 0:1014af42efd9 1 /*-----------------------------------------------------------------------------
simon 0:1014af42efd9 2 * Copyright (C) 2010 ARM Limited. All rights reserved.
simon 0:1014af42efd9 3 *
simon 0:1014af42efd9 4 * $Date: 29. November 2010
simon 0:1014af42efd9 5 * $Revision: V1.0.3
simon 0:1014af42efd9 6 *
simon 0:1014af42efd9 7 * Project: CMSIS DSP Library
simon 0:1014af42efd9 8 * Title: arm_fir_interpolate_init_f32.c
simon 0:1014af42efd9 9 *
simon 0:1014af42efd9 10 * Description: Floating-point FIR interpolator initialization function
simon 0:1014af42efd9 11 *
simon 0:1014af42efd9 12 * Target Processor: Cortex-M4/Cortex-M3
simon 0:1014af42efd9 13 *
simon 0:1014af42efd9 14 * Version 1.0.3 2010/11/29
simon 0:1014af42efd9 15 * Re-organized the CMSIS folders and updated documentation.
simon 0:1014af42efd9 16 *
simon 0:1014af42efd9 17 * Version 1.0.2 2010/11/11
simon 0:1014af42efd9 18 * Documentation updated.
simon 0:1014af42efd9 19 *
simon 0:1014af42efd9 20 * Version 1.0.1 2010/10/05
simon 0:1014af42efd9 21 * Production release and review comments incorporated.
simon 0:1014af42efd9 22 *
simon 0:1014af42efd9 23 * Version 1.0.0 2010/09/20
simon 0:1014af42efd9 24 * Production release and review comments incorporated
simon 0:1014af42efd9 25 *
simon 0:1014af42efd9 26 * Version 0.0.7 2010/06/10
simon 0:1014af42efd9 27 * Misra-C changes done
simon 0:1014af42efd9 28 * ---------------------------------------------------------------------------*/
simon 0:1014af42efd9 29
simon 0:1014af42efd9 30 #include "arm_math.h"
simon 0:1014af42efd9 31
simon 0:1014af42efd9 32 /**
simon 0:1014af42efd9 33 * @ingroup groupFilters
simon 0:1014af42efd9 34 */
simon 0:1014af42efd9 35
simon 0:1014af42efd9 36 /**
simon 0:1014af42efd9 37 * @addtogroup FIR_Interpolate
simon 0:1014af42efd9 38 * @{
simon 0:1014af42efd9 39 */
simon 0:1014af42efd9 40
simon 0:1014af42efd9 41 /**
simon 0:1014af42efd9 42 * @brief Initialization function for the floating-point FIR interpolator.
simon 0:1014af42efd9 43 * @param[in,out] *S points to an instance of the floating-point FIR interpolator structure.
simon 0:1014af42efd9 44 * @param[in] L upsample factor.
simon 0:1014af42efd9 45 * @param[in] numTaps number of filter coefficients in the filter.
simon 0:1014af42efd9 46 * @param[in] *pCoeffs points to the filter coefficient buffer.
simon 0:1014af42efd9 47 * @param[in] *pState points to the state buffer.
simon 0:1014af42efd9 48 * @param[in] blockSize number of input samples to process per call.
simon 0:1014af42efd9 49 * @return The function returns ARM_MATH_SUCCESS if initialization was successful or ARM_MATH_LENGTH_ERROR if
simon 0:1014af42efd9 50 * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>.
simon 0:1014af42efd9 51 *
simon 0:1014af42efd9 52 * <b>Description:</b>
simon 0:1014af42efd9 53 * \par
simon 0:1014af42efd9 54 * <code>pCoeffs</code> points to the array of filter coefficients stored in time reversed order:
simon 0:1014af42efd9 55 * <pre>
simon 0:1014af42efd9 56 * {b[numTaps-1], b[numTaps-2], b[numTaps-2], ..., b[1], b[0]}
simon 0:1014af42efd9 57 * </pre>
simon 0:1014af42efd9 58 * The length of the filter <code>numTaps</code> must be a multiple of the interpolation factor <code>L</code>.
simon 0:1014af42efd9 59 * \par
simon 0:1014af42efd9 60 * <code>pState</code> points to the array of state variables.
simon 0:1014af42efd9 61 * <code>pState</code> is of length <code>(numTaps/L)+blockSize-1</code> words
simon 0:1014af42efd9 62 * where <code>blockSize</code> is the number of input samples processed by each call to <code>arm_fir_interpolate_f32()</code>.
simon 0:1014af42efd9 63 */
simon 0:1014af42efd9 64
simon 0:1014af42efd9 65 arm_status arm_fir_interpolate_init_f32(
simon 0:1014af42efd9 66 arm_fir_interpolate_instance_f32 * S,
simon 0:1014af42efd9 67 uint8_t L,
simon 0:1014af42efd9 68 uint16_t numTaps,
simon 0:1014af42efd9 69 float32_t * pCoeffs,
simon 0:1014af42efd9 70 float32_t * pState,
simon 0:1014af42efd9 71 uint32_t blockSize)
simon 0:1014af42efd9 72 {
simon 0:1014af42efd9 73 arm_status status;
simon 0:1014af42efd9 74
simon 0:1014af42efd9 75 /* The filter length must be a multiple of the interpolation factor */
simon 0:1014af42efd9 76 if((numTaps % L) != 0u)
simon 0:1014af42efd9 77 {
simon 0:1014af42efd9 78 /* Set status as ARM_MATH_LENGTH_ERROR */
simon 0:1014af42efd9 79 status = ARM_MATH_LENGTH_ERROR;
simon 0:1014af42efd9 80 }
simon 0:1014af42efd9 81 else
simon 0:1014af42efd9 82 {
simon 0:1014af42efd9 83
simon 0:1014af42efd9 84 /* Assign coefficient pointer */
simon 0:1014af42efd9 85 S->pCoeffs = pCoeffs;
simon 0:1014af42efd9 86
simon 0:1014af42efd9 87 /* Assign Interpolation factor */
simon 0:1014af42efd9 88 S->L = L;
simon 0:1014af42efd9 89
simon 0:1014af42efd9 90 /* Assign polyPhaseLength */
simon 0:1014af42efd9 91 S->phaseLength = numTaps / L;
simon 0:1014af42efd9 92
simon 0:1014af42efd9 93 /* Clear state buffer and size of state array is always phaseLength + blockSize - 1 */
simon 0:1014af42efd9 94 memset(pState, 0,
simon 0:1014af42efd9 95 (blockSize +
simon 0:1014af42efd9 96 ((uint32_t) S->phaseLength - 1u)) * sizeof(float32_t));
simon 0:1014af42efd9 97
simon 0:1014af42efd9 98 /* Assign state pointer */
simon 0:1014af42efd9 99 S->pState = pState;
simon 0:1014af42efd9 100
simon 0:1014af42efd9 101 status = ARM_MATH_SUCCESS;
simon 0:1014af42efd9 102 }
simon 0:1014af42efd9 103
simon 0:1014af42efd9 104 return (status);
simon 0:1014af42efd9 105
simon 0:1014af42efd9 106 }
simon 0:1014af42efd9 107
simon 0:1014af42efd9 108 /**
simon 0:1014af42efd9 109 * @} end of FIR_Interpolate group
simon 0:1014af42efd9 110 */