Added all the F4 libraries to the project
[fw/stlink] / exampleF4 / CMSIS / DSP_Lib / Source / FilteringFunctions / arm_biquad_cascade_df1_init_q15.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_q15.c   
9 *   
10 * Description:  Q15 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  *   
50  * @param[in,out] *S           points to an instance of the Q15 Biquad cascade structure.   
51  * @param[in]     numStages    number of 2nd order stages in the filter.   
52  * @param[in]     *pCoeffs     points to the filter coefficients.   
53  * @param[in]     *pState      points to the state buffer.   
54  * @param[in]     postShift    Shift to be applied to the accumulator result. Varies according to the coefficients format   
55  * @return        none   
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, 0, b11, b12, a11, a12, b20, 0, b21, b22, a21, a22, ...}   
63  * </pre>   
64  * where <code>b1x</code> and <code>a1x</code> are the coefficients for the first stage,   
65  * <code>b2x</code> and <code>a2x</code> are the coefficients for the second stage,   
66  * and so on.  The <code>pCoeffs</code> array contains a total of <code>6*numStages</code> values.   
67  * The zero coefficient between <code>b1</code> and <code>b2</code> facilities  use of 16-bit SIMD instructions on the Cortex-M4.   
68  *   
69  * \par   
70  * The state variables are stored in the array <code>pState</code>.   
71  * Each Biquad stage has 4 state variables <code>x[n-1], x[n-2], y[n-1],</code> and <code>y[n-2]</code>.   
72  * The state variables are arranged in the <code>pState</code> array as:   
73  * <pre>   
74  *     {x[n-1], x[n-2], y[n-1], y[n-2]}   
75  * </pre>   
76  * The 4 state variables for stage 1 are first, then the 4 state variables for stage 2, and so on.   
77  * The state array has a total length of <code>4*numStages</code> values.   
78  * The state variables are updated after each block of data is processed; the coefficients are untouched.   
79  */
80
81 void arm_biquad_cascade_df1_init_q15(
82   arm_biquad_casd_df1_inst_q15 * S,
83   uint8_t numStages,
84   q15_t * pCoeffs,
85   q15_t * pState,
86   int8_t postShift)
87 {
88   /* Assign filter stages */
89   S->numStages = numStages;
90
91   /* Assign postShift to be applied to the output */
92   S->postShift = postShift;
93
94   /* Assign coefficient pointer */
95   S->pCoeffs = pCoeffs;
96
97   /* Clear state buffer and size is always 4 * numStages */
98   memset(pState, 0, (4u * (uint32_t) numStages) * sizeof(q15_t));
99
100   /* Assign state pointer */
101   S->pState = pState;
102 }
103
104 /**   
105  * @} end of BiquadCascadeDF1 group   
106  */