1 /* ----------------------------------------------------------------------
2  * Project:      CMSIS DSP Library
3  * Title:        arm_biquad_cascade_stereo_df2T_init_f16.c
4  * Description:  Initialization function for floating-point transposed direct form II Biquad cascade filter
5  *
6  * $Date:        23 April 2021
7  * $Revision:    V1.9.0
8  *
9  * Target Processor: Cortex-M and Cortex-A cores
10  * -------------------------------------------------------------------- */
11 /*
12  * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved.
13  *
14  * SPDX-License-Identifier: Apache-2.0
15  *
16  * Licensed under the Apache License, Version 2.0 (the License); you may
17  * not use this file except in compliance with the License.
18  * You may obtain a copy of the License at
19  *
20  * www.apache.org/licenses/LICENSE-2.0
21  *
22  * Unless required by applicable law or agreed to in writing, software
23  * distributed under the License is distributed on an AS IS BASIS, WITHOUT
24  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25  * See the License for the specific language governing permissions and
26  * limitations under the License.
27  */
28 
29 #include "dsp/filtering_functions_f16.h"
30 
31 #if defined(ARM_FLOAT16_SUPPORTED)
32 
33 /**
34   @ingroup groupFilters
35  */
36 
37 /**
38   @addtogroup BiquadCascadeDF2T
39   @{
40  */
41 
42 /**
43   @brief         Initialization function for the floating-point transposed direct form II Biquad cascade filter.
44   @param[in,out] S           points to an instance of the filter data structure.
45   @param[in]     numStages   number of 2nd order stages in the filter.
46   @param[in]     pCoeffs     points to the filter coefficients.
47   @param[in]     pState      points to the state buffer.
48 
49   @par           Coefficient and State Ordering
50                    The coefficients are stored in the array <code>pCoeffs</code> in the following order:
51   <pre>
52       {b10, b11, b12, a11, a12, b20, b21, b22, a21, a22, ...}
53   </pre>
54   @par
55                    where <code>b1x</code> and <code>a1x</code> are the coefficients for the first stage,
56                    <code>b2x</code> and <code>a2x</code> are the coefficients for the second stage,
57                    and so on.  The <code>pCoeffs</code> array contains a total of <code>5*numStages</code> values.
58   @par
59                    The <code>pState</code> is a pointer to state array.
60                    Each Biquad stage has 2 state variables <code>d1,</code> and <code>d2</code> for each channel.
61                    The 2 state variables for stage 1 are first, then the 2 state variables for stage 2, and so on.
62                    The state array has a total length of <code>2*numStages</code> values.
63                    The state variables are updated after each block of data is processed; the coefficients are untouched.
64  */
65 
arm_biquad_cascade_stereo_df2T_init_f16(arm_biquad_cascade_stereo_df2T_instance_f16 * S,uint8_t numStages,const float16_t * pCoeffs,float16_t * pState)66 ARM_DSP_ATTRIBUTE void arm_biquad_cascade_stereo_df2T_init_f16(
67         arm_biquad_cascade_stereo_df2T_instance_f16 * S,
68         uint8_t numStages,
69   const float16_t * pCoeffs,
70         float16_t * pState)
71 {
72   /* Assign filter stages */
73   S->numStages = numStages;
74 
75   /* Assign coefficient pointer */
76   S->pCoeffs = pCoeffs;
77 
78   /* Clear state buffer and size is always 4 * numStages */
79   memset(pState, 0, (4U * (uint32_t) numStages) * sizeof(float16_t));
80 
81   /* Assign state pointer */
82   S->pState = pState;
83 }
84 
85 /**
86   @} end of BiquadCascadeDF2T group
87  */
88 
89 #endif /* #if defined(ARM_FLOAT16_SUPPORTED) */
90