The CMSIS DSP 5 library
Dependents: Nucleo-Heart-Rate ejercicioVrms2 PROYECTOFINAL ejercicioVrms ... more
functions/FilteringFunctions/arm_biquad_cascade_df1_32x64_init_q31.c@3:4098b9d3d571, 2018-06-21 (annotated)
- Committer:
- xorjoep
- Date:
- Thu Jun 21 11:56:27 2018 +0000
- Revision:
- 3:4098b9d3d571
- Parent:
- 1:24714b45cd1b
headers is a folder not a library
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
xorjoep | 1:24714b45cd1b | 1 | /* ---------------------------------------------------------------------- |
xorjoep | 1:24714b45cd1b | 2 | * Project: CMSIS DSP Library |
xorjoep | 1:24714b45cd1b | 3 | * Title: arm_biquad_cascade_df1_32x64_init_q31.c |
xorjoep | 1:24714b45cd1b | 4 | * Description: High precision Q31 Biquad cascade filter initialization function |
xorjoep | 1:24714b45cd1b | 5 | * |
xorjoep | 1:24714b45cd1b | 6 | * $Date: 27. January 2017 |
xorjoep | 1:24714b45cd1b | 7 | * $Revision: V.1.5.1 |
xorjoep | 1:24714b45cd1b | 8 | * |
xorjoep | 1:24714b45cd1b | 9 | * Target Processor: Cortex-M cores |
xorjoep | 1:24714b45cd1b | 10 | * -------------------------------------------------------------------- */ |
xorjoep | 1:24714b45cd1b | 11 | /* |
xorjoep | 1:24714b45cd1b | 12 | * Copyright (C) 2010-2017 ARM Limited or its affiliates. All rights reserved. |
xorjoep | 1:24714b45cd1b | 13 | * |
xorjoep | 1:24714b45cd1b | 14 | * SPDX-License-Identifier: Apache-2.0 |
xorjoep | 1:24714b45cd1b | 15 | * |
xorjoep | 1:24714b45cd1b | 16 | * Licensed under the Apache License, Version 2.0 (the License); you may |
xorjoep | 1:24714b45cd1b | 17 | * not use this file except in compliance with the License. |
xorjoep | 1:24714b45cd1b | 18 | * You may obtain a copy of the License at |
xorjoep | 1:24714b45cd1b | 19 | * |
xorjoep | 1:24714b45cd1b | 20 | * www.apache.org/licenses/LICENSE-2.0 |
xorjoep | 1:24714b45cd1b | 21 | * |
xorjoep | 1:24714b45cd1b | 22 | * Unless required by applicable law or agreed to in writing, software |
xorjoep | 1:24714b45cd1b | 23 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT |
xorjoep | 1:24714b45cd1b | 24 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
xorjoep | 1:24714b45cd1b | 25 | * See the License for the specific language governing permissions and |
xorjoep | 1:24714b45cd1b | 26 | * limitations under the License. |
xorjoep | 1:24714b45cd1b | 27 | */ |
xorjoep | 1:24714b45cd1b | 28 | |
xorjoep | 1:24714b45cd1b | 29 | #include "arm_math.h" |
xorjoep | 1:24714b45cd1b | 30 | |
xorjoep | 1:24714b45cd1b | 31 | /** |
xorjoep | 1:24714b45cd1b | 32 | * @ingroup groupFilters |
xorjoep | 1:24714b45cd1b | 33 | */ |
xorjoep | 1:24714b45cd1b | 34 | |
xorjoep | 1:24714b45cd1b | 35 | /** |
xorjoep | 1:24714b45cd1b | 36 | * @addtogroup BiquadCascadeDF1_32x64 |
xorjoep | 1:24714b45cd1b | 37 | * @{ |
xorjoep | 1:24714b45cd1b | 38 | */ |
xorjoep | 1:24714b45cd1b | 39 | |
xorjoep | 1:24714b45cd1b | 40 | /** |
xorjoep | 1:24714b45cd1b | 41 | * @details |
xorjoep | 1:24714b45cd1b | 42 | * |
xorjoep | 1:24714b45cd1b | 43 | * @param[in,out] *S points to an instance of the high precision Q31 Biquad cascade filter structure. |
xorjoep | 1:24714b45cd1b | 44 | * @param[in] numStages number of 2nd order stages in the filter. |
xorjoep | 1:24714b45cd1b | 45 | * @param[in] *pCoeffs points to the filter coefficients. |
xorjoep | 1:24714b45cd1b | 46 | * @param[in] *pState points to the state buffer. |
xorjoep | 1:24714b45cd1b | 47 | * @param[in] postShift Shift to be applied after the accumulator. Varies according to the coefficients format. |
xorjoep | 1:24714b45cd1b | 48 | * @return none |
xorjoep | 1:24714b45cd1b | 49 | * |
xorjoep | 1:24714b45cd1b | 50 | * <b>Coefficient and State Ordering:</b> |
xorjoep | 1:24714b45cd1b | 51 | * |
xorjoep | 1:24714b45cd1b | 52 | * \par |
xorjoep | 1:24714b45cd1b | 53 | * The coefficients are stored in the array <code>pCoeffs</code> in the following order: |
xorjoep | 1:24714b45cd1b | 54 | * <pre> |
xorjoep | 1:24714b45cd1b | 55 | * {b10, b11, b12, a11, a12, b20, b21, b22, a21, a22, ...} |
xorjoep | 1:24714b45cd1b | 56 | * </pre> |
xorjoep | 1:24714b45cd1b | 57 | * where <code>b1x</code> and <code>a1x</code> are the coefficients for the first stage, |
xorjoep | 1:24714b45cd1b | 58 | * <code>b2x</code> and <code>a2x</code> are the coefficients for the second stage, |
xorjoep | 1:24714b45cd1b | 59 | * and so on. The <code>pCoeffs</code> array contains a total of <code>5*numStages</code> values. |
xorjoep | 1:24714b45cd1b | 60 | * |
xorjoep | 1:24714b45cd1b | 61 | * \par |
xorjoep | 1:24714b45cd1b | 62 | * The <code>pState</code> points to state variables array and size of each state variable is 1.63 format. |
xorjoep | 1:24714b45cd1b | 63 | * Each Biquad stage has 4 state variables <code>x[n-1], x[n-2], y[n-1],</code> and <code>y[n-2]</code>. |
xorjoep | 1:24714b45cd1b | 64 | * The state variables are arranged in the state array as: |
xorjoep | 1:24714b45cd1b | 65 | * <pre> |
xorjoep | 1:24714b45cd1b | 66 | * {x[n-1], x[n-2], y[n-1], y[n-2]} |
xorjoep | 1:24714b45cd1b | 67 | * </pre> |
xorjoep | 1:24714b45cd1b | 68 | * The 4 state variables for stage 1 are first, then the 4 state variables for stage 2, and so on. |
xorjoep | 1:24714b45cd1b | 69 | * The state array has a total length of <code>4*numStages</code> values. |
xorjoep | 1:24714b45cd1b | 70 | * The state variables are updated after each block of data is processed; the coefficients are untouched. |
xorjoep | 1:24714b45cd1b | 71 | */ |
xorjoep | 1:24714b45cd1b | 72 | |
xorjoep | 1:24714b45cd1b | 73 | void arm_biquad_cas_df1_32x64_init_q31( |
xorjoep | 1:24714b45cd1b | 74 | arm_biquad_cas_df1_32x64_ins_q31 * S, |
xorjoep | 1:24714b45cd1b | 75 | uint8_t numStages, |
xorjoep | 1:24714b45cd1b | 76 | q31_t * pCoeffs, |
xorjoep | 1:24714b45cd1b | 77 | q63_t * pState, |
xorjoep | 1:24714b45cd1b | 78 | uint8_t postShift) |
xorjoep | 1:24714b45cd1b | 79 | { |
xorjoep | 1:24714b45cd1b | 80 | /* Assign filter stages */ |
xorjoep | 1:24714b45cd1b | 81 | S->numStages = numStages; |
xorjoep | 1:24714b45cd1b | 82 | |
xorjoep | 1:24714b45cd1b | 83 | /* Assign postShift to be applied to the output */ |
xorjoep | 1:24714b45cd1b | 84 | S->postShift = postShift; |
xorjoep | 1:24714b45cd1b | 85 | |
xorjoep | 1:24714b45cd1b | 86 | /* Assign coefficient pointer */ |
xorjoep | 1:24714b45cd1b | 87 | S->pCoeffs = pCoeffs; |
xorjoep | 1:24714b45cd1b | 88 | |
xorjoep | 1:24714b45cd1b | 89 | /* Clear state buffer and size is always 4 * numStages */ |
xorjoep | 1:24714b45cd1b | 90 | memset(pState, 0, (4U * (uint32_t) numStages) * sizeof(q63_t)); |
xorjoep | 1:24714b45cd1b | 91 | |
xorjoep | 1:24714b45cd1b | 92 | /* Assign state pointer */ |
xorjoep | 1:24714b45cd1b | 93 | S->pState = pState; |
xorjoep | 1:24714b45cd1b | 94 | } |
xorjoep | 1:24714b45cd1b | 95 | |
xorjoep | 1:24714b45cd1b | 96 | /** |
xorjoep | 1:24714b45cd1b | 97 | * @} end of BiquadCascadeDF1_32x64 group |
xorjoep | 1:24714b45cd1b | 98 | */ |