Added all the F4 libraries to the project
[fw/stlink] / exampleF4 / CMSIS / DSP_Lib / Source / FilteringFunctions / arm_biquad_cascade_df1_init_f32.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_init_f32.c   
9 *   
10 * Description:  floating-point Biquad cascade DirectFormI(DF1) 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.5  2010/04/26    
30 *        incorporated review comments and updated with latest CMSIS layer   
31 *   
32 * Version 0.0.3  2010/03/10    
33 *    Initial version   
34 * ---------------------------------------------------------------------------*/
35
36 #include "arm_math.h"
37
38 /**   
39  * @ingroup groupFilters   
40  */
41
42 /**   
43  * @addtogroup BiquadCascadeDF1   
44  * @{   
45  */
46
47 /**   
48  * @details   
49  * @brief  Initialization function for the floating-point Biquad cascade filter.   
50  * @param[in,out] *S           points to an instance of the floating-point Biquad cascade structure.   
51  * @param[in]     numStages    number of 2nd order stages in the filter.   
52  * @param[in]     *pCoeffs     points to the filter coefficients array.   
53  * @param[in]     *pState      points to the state array.   
54  * @return        none   
55  *   
56  *   
57  * <b>Coefficient and State Ordering:</b>   
58  *   
59  * \par   
60  * The coefficients are stored in the array <code>pCoeffs</code> in the following order:   
61  * <pre>   
62  *     {b10, b11, b12, a11, a12, b20, b21, b22, a21, a22, ...}   
63  * </pre>   
64  *   
65  * \par   
66  * where <code>b1x</code> and <code>a1x</code> are the coefficients for the first stage,   
67  * <code>b2x</code> and <code>a2x</code> are the coefficients for the second stage,   
68  * and so on.  The <code>pCoeffs</code> array contains a total of <code>5*numStages</code> values.   
69  *   
70  * \par   
71  * The <code>pState</code> is a pointer to state array.   
72  * Each Biquad stage has 4 state variables <code>x[n-1], x[n-2], y[n-1],</code> and <code>y[n-2]</code>.   
73  * The state variables are arranged in the <code>pState</code> array as:   
74  * <pre>   
75  *     {x[n-1], x[n-2], y[n-1], y[n-2]}   
76  * </pre>   
77  * The 4 state variables for stage 1 are first, then the 4 state variables for stage 2, and so on.   
78  * The state array has a total length of <code>4*numStages</code> values.   
79  * The state variables are updated after each block of data is processed; the coefficients are untouched.   
80  *   
81  */
82
83 void arm_biquad_cascade_df1_init_f32(
84   arm_biquad_casd_df1_inst_f32 * S,
85   uint8_t numStages,
86   float32_t * pCoeffs,
87   float32_t * pState)
88 {
89   /* Assign filter stages */
90   S->numStages = numStages;
91
92   /* Assign coefficient pointer */
93   S->pCoeffs = pCoeffs;
94
95   /* Clear state buffer and size is always 4 * numStages */
96   memset(pState, 0, (4u * (uint32_t) numStages) * sizeof(float32_t));
97
98   /* Assign state pointer */
99   S->pState = pState;
100 }
101
102 /**   
103  * @} end of BiquadCascadeDF1 group   
104  */