1 /* ----------------------------------------------------------------------
2 * Project: CMSIS DSP Library
3 * Title: arm_fir_sparse_init_q7.c
4 * Description: Q7 sparse FIR filter initialization function
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.h"
30
31 /**
32 @ingroup groupFilters
33 */
34
35 /**
36 @addtogroup FIR_Sparse
37 @{
38 */
39
40 /**
41 @brief Initialization function for the Q7 sparse FIR filter.
42 @param[in,out] S points to an instance of the Q7 sparse FIR structure
43 @param[in] numTaps number of nonzero coefficients in the filter
44 @param[in] pCoeffs points to the array of filter coefficients
45 @param[in] pState points to the state buffer
46 @param[in] pTapDelay points to the array of offset times
47 @param[in] maxDelay maximum offset time supported
48 @param[in] blockSize number of samples that will be processed per block
49 @return none
50
51 @par Details
52 <code>pCoeffs</code> holds the filter coefficients and has length <code>numTaps</code>.
53 <code>pState</code> holds the filter's state variables and must be of length
54 <code>maxDelay + blockSize</code>, where <code>maxDelay</code>
55 is the maximum number of delay line values.
56 <code>blockSize</code> is the
57 number of samples processed by the <code>arm_fir_sparse_q7()</code> function.
58 */
59
arm_fir_sparse_init_q7(arm_fir_sparse_instance_q7 * S,uint16_t numTaps,const q7_t * pCoeffs,q7_t * pState,int32_t * pTapDelay,uint16_t maxDelay,uint32_t blockSize)60 void arm_fir_sparse_init_q7(
61 arm_fir_sparse_instance_q7 * S,
62 uint16_t numTaps,
63 const q7_t * pCoeffs,
64 q7_t * pState,
65 int32_t * pTapDelay,
66 uint16_t maxDelay,
67 uint32_t blockSize)
68 {
69 /* Assign filter taps */
70 S->numTaps = numTaps;
71
72 /* Assign coefficient pointer */
73 S->pCoeffs = pCoeffs;
74
75 /* Assign TapDelay pointer */
76 S->pTapDelay = pTapDelay;
77
78 /* Assign MaxDelay */
79 S->maxDelay = maxDelay;
80
81 /* reset the stateIndex to 0 */
82 S->stateIndex = 0U;
83
84 /* Clear state buffer and size is always maxDelay + blockSize */
85 memset(pState, 0, (maxDelay + blockSize) * sizeof(q7_t));
86
87 /* Assign state pointer */
88 S->pState = pState;
89 }
90
91 /**
92 @} end of FIR_Sparse group
93 */
94