]> git.gag.com Git - fw/stlink/blob - exampleF4/CMSIS/DSP_Lib/Source/FilteringFunctions/arm_biquad_cascade_df1_32x64_init_q31.c
Added all the F4 libraries to the project
[fw/stlink] / exampleF4 / CMSIS / DSP_Lib / Source / FilteringFunctions / arm_biquad_cascade_df1_32x64_init_q31.c
1 /* ----------------------------------------------------------------------   
2 * Copyright (C) 2010 ARM Limited. All rights reserved.   
3 *   
4 * $Date:        15. July 2011  
5 * $Revision:    V1.0.10  
6 *   
7 * Project:          CMSIS DSP Library   
8 * Title:            arm_biquad_cascade_df1_32x64_init_q31.c   
9 *   
10 * Description:  High precision Q31 Biquad cascade filter initialization function.   
11 *   
12 * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
13 *  
14 * Version 1.0.10 2011/7/15 
15 *    Big Endian support added and Merged M0 and M3/M4 Source code.  
16 *   
17 * Version 1.0.3 2010/11/29  
18 *    Re-organized the CMSIS folders and updated documentation.   
19 *    
20 * Version 1.0.2 2010/11/11   
21 *    Documentation updated.    
22 *   
23 * Version 1.0.1 2010/10/05    
24 *    Production release and review comments incorporated.   
25 *   
26 * Version 1.0.0 2010/09/20    
27 *    Production release and review comments incorporated.   
28 *   
29 * Version 0.0.7  2010/06/10    
30 *    Misra-C changes done   
31 * -------------------------------------------------------------------- */
32
33 #include "arm_math.h"
34
35 /**   
36  * @ingroup groupFilters   
37  */
38
39 /**   
40  * @addtogroup BiquadCascadeDF1_32x64   
41  * @{   
42  */
43
44 /**   
45  * @details   
46  *   
47  * @param[in,out] *S            points to an instance of the high precision Q31 Biquad cascade filter structure.   
48  * @param[in]     numStages     number of 2nd order stages in the filter.   
49  * @param[in]     *pCoeffs      points to the filter coefficients.   
50  * @param[in]     *pState       points to the state buffer.   
51  * @param[in]     postShift     Shift to be applied after the accumulator.  Varies according to the coefficients format.   
52  * @return        none   
53  *   
54  * <b>Coefficient and State Ordering:</b>   
55  *   
56  * \par   
57  * The coefficients are stored in the array <code>pCoeffs</code> in the following order:   
58  * <pre>   
59  *     {b10, b11, b12, a11, a12, b20, b21, b22, a21, a22, ...}   
60  * </pre>   
61  * where <code>b1x</code> and <code>a1x</code> are the coefficients for the first stage,   
62  * <code>b2x</code> and <code>a2x</code> are the coefficients for the second stage,   
63  * and so on.  The <code>pCoeffs</code> array contains a total of <code>5*numStages</code> values.   
64  *   
65  * \par   
66  * The <code>pState</code> points to state variables array and size of each state variable is 1.63 format.   
67  * Each Biquad stage has 4 state variables <code>x[n-1], x[n-2], y[n-1],</code> and <code>y[n-2]</code>.   
68  * The state variables are arranged in the state array as:   
69  * <pre>   
70  *     {x[n-1], x[n-2], y[n-1], y[n-2]}   
71  * </pre>   
72  * The 4 state variables for stage 1 are first, then the 4 state variables for stage 2, and so on.   
73  * The state array has a total length of <code>4*numStages</code> values.   
74  * The state variables are updated after each block of data is processed; the coefficients are untouched.   
75  */
76
77 void arm_biquad_cas_df1_32x64_init_q31(
78   arm_biquad_cas_df1_32x64_ins_q31 * S,
79   uint8_t numStages,
80   q31_t * pCoeffs,
81   q63_t * pState,
82   uint8_t postShift)
83 {
84   /* Assign filter stages */
85   S->numStages = numStages;
86
87   /* Assign postShift to be applied to the output */
88   S->postShift = postShift;
89
90   /* Assign coefficient pointer */
91   S->pCoeffs = pCoeffs;
92
93   /* Clear state buffer and size is always 4 * numStages */
94   memset(pState, 0, (4u * (uint32_t) numStages) * sizeof(q63_t));
95
96   /* Assign state pointer */
97   S->pState = pState;
98 }
99
100 /**   
101  * @} end of BiquadCascadeDF1_32x64 group   
102  */