1 /* ----------------------------------------------------------------------
2  * Project:      CMSIS DSP Library
3  * Title:        arm_fir_sparse_init_q31.c
4  * Description:  Q31 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 Q31 sparse FIR filter.
42   @param[in,out] S          points to an instance of the Q31 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 number of words processed by <code>arm_fir_sparse_q31()</code> function.
56  */
57 
arm_fir_sparse_init_q31(arm_fir_sparse_instance_q31 * S,uint16_t numTaps,const q31_t * pCoeffs,q31_t * pState,int32_t * pTapDelay,uint16_t maxDelay,uint32_t blockSize)58 ARM_DSP_ATTRIBUTE void arm_fir_sparse_init_q31(
59         arm_fir_sparse_instance_q31 * S,
60         uint16_t numTaps,
61   const q31_t * pCoeffs,
62         q31_t * pState,
63         int32_t * pTapDelay,
64         uint16_t maxDelay,
65         uint32_t blockSize)
66 {
67   /* Assign filter taps */
68   S->numTaps = numTaps;
69 
70   /* Assign coefficient pointer */
71   S->pCoeffs = pCoeffs;
72 
73   /* Assign TapDelay pointer */
74   S->pTapDelay = pTapDelay;
75 
76   /* Assign MaxDelay */
77   S->maxDelay = maxDelay;
78 
79   /* reset the stateIndex to 0 */
80   S->stateIndex = 0U;
81 
82   /* Clear state buffer and size is always maxDelay + blockSize */
83   memset(pState, 0, (maxDelay + blockSize) * sizeof(q31_t));
84 
85   /* Assign state pointer */
86   S->pState = pState;
87 }
88 
89 /**
90   @} end of FIR_Sparse group
91  */
92