1 /* ----------------------------------------------------------------------
2 * Project: CMSIS DSP Library
3 * Title: arm_biquad_cascade_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 @ingroup groupFilters
34 */
35
36 /**
37 @addtogroup BiquadCascadeDF2T
38 @{
39 */
40
41 /**
42 @brief Initialization function for the floating-point transposed direct form II Biquad cascade filter.
43 @param[in,out] S points to an instance of the filter data structure.
44 @param[in] numStages number of 2nd order stages in the filter.
45 @param[in] pCoeffs points to the filter coefficients.
46 @param[in] pState points to the state buffer.
47
48 @par Coefficient and State Ordering
49 The coefficients are stored in the array <code>pCoeffs</code> in the following order
50 in the not Neon version.
51 <pre>
52 {b10, b11, b12, a11, a12, b20, b21, b22, a21, a22, ...}
53 </pre>
54
55 @par
56 where <code>b1x</code> and <code>a1x</code> are the coefficients for the first stage,
57 <code>b2x</code> and <code>a2x</code> are the coefficients for the second stage,
58 and so on. The <code>pCoeffs</code> array contains a total of <code>5*numStages</code> values.
59
60 For Neon version, this array is bigger. If numstages = 4x + y, then the array has size:
61 32*x + 5*y
62 and it must be initialized using the function
63 arm_biquad_cascade_df2T_compute_coefs_f16 which is taking the
64 standard array coefficient as parameters.
65
66 But, an array of 8*numstages is a good approximation.
67
68 Then, the initialization can be done with:
69 <pre>
70 arm_biquad_cascade_df2T_init_f16(&SNeon, nbCascade, neonCoefs, stateNeon);
71 arm_biquad_cascade_df2T_compute_coefs_f16(&SNeon,nbCascade,coefs);
72 </pre>
73
74 @par In this example, neonCoefs is a bigger array of size 8 * numStages.
75 coefs is the standard array:
76
77 <pre>
78 {b10, b11, b12, a11, a12, b20, b21, b22, a21, a22, ...}
79 </pre>
80
81
82 @par
83 The <code>pState</code> is a pointer to state array.
84 Each Biquad stage has 2 state variables <code>d1,</code> and <code>d2</code>.
85 The 2 state variables for stage 1 are first, then the 2 state variables for stage 2, and so on.
86 The state array has a total length of <code>2*numStages</code> values.
87 The state variables are updated after each block of data is processed; the coefficients are untouched.
88 */
89
arm_biquad_cascade_df2T_init_f16(arm_biquad_cascade_df2T_instance_f16 * S,uint8_t numStages,const float16_t * pCoeffs,float16_t * pState)90 ARM_DSP_ATTRIBUTE void arm_biquad_cascade_df2T_init_f16(
91 arm_biquad_cascade_df2T_instance_f16 * S,
92 uint8_t numStages,
93 const float16_t * pCoeffs,
94 float16_t * pState)
95 {
96 /* Assign filter stages */
97 S->numStages = numStages;
98
99 /* Assign coefficient pointer */
100 S->pCoeffs = pCoeffs;
101
102 /* Clear state buffer and size is always 2 * numStages */
103 memset(pState, 0, (2U * (uint32_t) numStages) * sizeof(float16_t));
104
105 /* Assign state pointer */
106 S->pState = pState;
107 }
108
109 /**
110 @} end of BiquadCascadeDF2T group
111 */
112
113 #endif /* #if defined(ARM_FLOAT16_SUPPORTED) */
114