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
50 @par Details
51 <code>pCoeffs</code> holds the filter coefficients and has length <code>numTaps</code>.
52 <code>pState</code> holds the filter's state variables and must be of length
53 <code>maxDelay + blockSize</code>, where <code>maxDelay</code>
54 is the maximum number of delay line values.
55 <code>blockSize</code> is the
56 number of samples processed by the <code>arm_fir_sparse_q7()</code> function.
57 */
58
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)59 void arm_fir_sparse_init_q7(
60 arm_fir_sparse_instance_q7 * S,
61 uint16_t numTaps,
62 const q7_t * pCoeffs,
63 q7_t * pState,
64 int32_t * pTapDelay,
65 uint16_t maxDelay,
66 uint32_t blockSize)
67 {
68 /* Assign filter taps */
69 S->numTaps = numTaps;
70
71 /* Assign coefficient pointer */
72 S->pCoeffs = pCoeffs;
73
74 /* Assign TapDelay pointer */
75 S->pTapDelay = pTapDelay;
76
77 /* Assign MaxDelay */
78 S->maxDelay = maxDelay;
79
80 /* reset the stateIndex to 0 */
81 S->stateIndex = 0U;
82
83 /* Clear state buffer and size is always maxDelay + blockSize */
84 memset(pState, 0, (maxDelay + blockSize) * sizeof(q7_t));
85
86 /* Assign state pointer */
87 S->pState = pState;
88 }
89
90 /**
91 @} end of FIR_Sparse group
92 */
93