CMSIS DSP library

Dependents:   performance_timer Surfboard_ gps2rtty Capstone ... more

Legacy Warning

This is an mbed 2 library. To learn more about mbed OS 5, visit the docs.

Committer:
emilmont
Date:
Wed Nov 28 12:30:09 2012 +0000
Revision:
1:fdd22bb7aa52
Child:
2:da51fb522205
DSP library code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
emilmont 1:fdd22bb7aa52 1 /*-----------------------------------------------------------------------------
emilmont 1:fdd22bb7aa52 2 * Copyright (C) 2010 ARM Limited. All rights reserved.
emilmont 1:fdd22bb7aa52 3 *
emilmont 1:fdd22bb7aa52 4 * $Date: 15. February 2012
emilmont 1:fdd22bb7aa52 5 * $Revision: V1.1.0
emilmont 1:fdd22bb7aa52 6 *
emilmont 1:fdd22bb7aa52 7 * Project: CMSIS DSP Library
emilmont 1:fdd22bb7aa52 8 * Title: arm_biquad_cascade_df2T_init_f32.c
emilmont 1:fdd22bb7aa52 9 *
emilmont 1:fdd22bb7aa52 10 * Description: Initialization function for the floating-point transposed
emilmont 1:fdd22bb7aa52 11 * direct form II Biquad cascade filter.
emilmont 1:fdd22bb7aa52 12 *
emilmont 1:fdd22bb7aa52 13 * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
emilmont 1:fdd22bb7aa52 14 *
emilmont 1:fdd22bb7aa52 15 * Version 1.1.0 2012/02/15
emilmont 1:fdd22bb7aa52 16 * Updated with more optimizations, bug fixes and minor API changes.
emilmont 1:fdd22bb7aa52 17 *
emilmont 1:fdd22bb7aa52 18 * Version 1.0.10 2011/7/15
emilmont 1:fdd22bb7aa52 19 * Big Endian support added and Merged M0 and M3/M4 Source code.
emilmont 1:fdd22bb7aa52 20 *
emilmont 1:fdd22bb7aa52 21 * Version 1.0.3 2010/11/29
emilmont 1:fdd22bb7aa52 22 * Re-organized the CMSIS folders and updated documentation.
emilmont 1:fdd22bb7aa52 23 *
emilmont 1:fdd22bb7aa52 24 * Version 1.0.2 2010/11/11
emilmont 1:fdd22bb7aa52 25 * Documentation updated.
emilmont 1:fdd22bb7aa52 26 *
emilmont 1:fdd22bb7aa52 27 * Version 1.0.1 2010/10/05
emilmont 1:fdd22bb7aa52 28 * Production release and review comments incorporated.
emilmont 1:fdd22bb7aa52 29 *
emilmont 1:fdd22bb7aa52 30 * Version 1.0.0 2010/09/20
emilmont 1:fdd22bb7aa52 31 * Production release and review comments incorporated
emilmont 1:fdd22bb7aa52 32 *
emilmont 1:fdd22bb7aa52 33 * Version 0.0.7 2010/06/10
emilmont 1:fdd22bb7aa52 34 * Misra-C changes done
emilmont 1:fdd22bb7aa52 35 * ---------------------------------------------------------------------------*/
emilmont 1:fdd22bb7aa52 36
emilmont 1:fdd22bb7aa52 37 #include "arm_math.h"
emilmont 1:fdd22bb7aa52 38
emilmont 1:fdd22bb7aa52 39 /**
emilmont 1:fdd22bb7aa52 40 * @ingroup groupFilters
emilmont 1:fdd22bb7aa52 41 */
emilmont 1:fdd22bb7aa52 42
emilmont 1:fdd22bb7aa52 43 /**
emilmont 1:fdd22bb7aa52 44 * @addtogroup BiquadCascadeDF2T
emilmont 1:fdd22bb7aa52 45 * @{
emilmont 1:fdd22bb7aa52 46 */
emilmont 1:fdd22bb7aa52 47
emilmont 1:fdd22bb7aa52 48 /**
emilmont 1:fdd22bb7aa52 49 * @brief Initialization function for the floating-point transposed direct form II Biquad cascade filter.
emilmont 1:fdd22bb7aa52 50 * @param[in,out] *S points to an instance of the filter data structure.
emilmont 1:fdd22bb7aa52 51 * @param[in] numStages number of 2nd order stages in the filter.
emilmont 1:fdd22bb7aa52 52 * @param[in] *pCoeffs points to the filter coefficients.
emilmont 1:fdd22bb7aa52 53 * @param[in] *pState points to the state buffer.
emilmont 1:fdd22bb7aa52 54 * @return none
emilmont 1:fdd22bb7aa52 55 *
emilmont 1:fdd22bb7aa52 56 * <b>Coefficient and State Ordering:</b>
emilmont 1:fdd22bb7aa52 57 * \par
emilmont 1:fdd22bb7aa52 58 * The coefficients are stored in the array <code>pCoeffs</code> in the following order:
emilmont 1:fdd22bb7aa52 59 * <pre>
emilmont 1:fdd22bb7aa52 60 * {b10, b11, b12, a11, a12, b20, b21, b22, a21, a22, ...}
emilmont 1:fdd22bb7aa52 61 * </pre>
emilmont 1:fdd22bb7aa52 62 *
emilmont 1:fdd22bb7aa52 63 * \par
emilmont 1:fdd22bb7aa52 64 * where <code>b1x</code> and <code>a1x</code> are the coefficients for the first stage,
emilmont 1:fdd22bb7aa52 65 * <code>b2x</code> and <code>a2x</code> are the coefficients for the second stage,
emilmont 1:fdd22bb7aa52 66 * and so on. The <code>pCoeffs</code> array contains a total of <code>5*numStages</code> values.
emilmont 1:fdd22bb7aa52 67 *
emilmont 1:fdd22bb7aa52 68 * \par
emilmont 1:fdd22bb7aa52 69 * The <code>pState</code> is a pointer to state array.
emilmont 1:fdd22bb7aa52 70 * Each Biquad stage has 2 state variables <code>d1,</code> and <code>d2</code>.
emilmont 1:fdd22bb7aa52 71 * The 2 state variables for stage 1 are first, then the 2 state variables for stage 2, and so on.
emilmont 1:fdd22bb7aa52 72 * The state array has a total length of <code>2*numStages</code> values.
emilmont 1:fdd22bb7aa52 73 * The state variables are updated after each block of data is processed; the coefficients are untouched.
emilmont 1:fdd22bb7aa52 74 */
emilmont 1:fdd22bb7aa52 75
emilmont 1:fdd22bb7aa52 76 void arm_biquad_cascade_df2T_init_f32(
emilmont 1:fdd22bb7aa52 77 arm_biquad_cascade_df2T_instance_f32 * S,
emilmont 1:fdd22bb7aa52 78 uint8_t numStages,
emilmont 1:fdd22bb7aa52 79 float32_t * pCoeffs,
emilmont 1:fdd22bb7aa52 80 float32_t * pState)
emilmont 1:fdd22bb7aa52 81 {
emilmont 1:fdd22bb7aa52 82 /* Assign filter stages */
emilmont 1:fdd22bb7aa52 83 S->numStages = numStages;
emilmont 1:fdd22bb7aa52 84
emilmont 1:fdd22bb7aa52 85 /* Assign coefficient pointer */
emilmont 1:fdd22bb7aa52 86 S->pCoeffs = pCoeffs;
emilmont 1:fdd22bb7aa52 87
emilmont 1:fdd22bb7aa52 88 /* Clear state buffer and size is always 2 * numStages */
emilmont 1:fdd22bb7aa52 89 memset(pState, 0, (2u * (uint32_t) numStages) * sizeof(float32_t));
emilmont 1:fdd22bb7aa52 90
emilmont 1:fdd22bb7aa52 91 /* Assign state pointer */
emilmont 1:fdd22bb7aa52 92 S->pState = pState;
emilmont 1:fdd22bb7aa52 93 }
emilmont 1:fdd22bb7aa52 94
emilmont 1:fdd22bb7aa52 95 /**
emilmont 1:fdd22bb7aa52 96 * @} end of BiquadCascadeDF2T group
emilmont 1:fdd22bb7aa52 97 */