The CMSIS DSP 5 library

Dependents:   Nucleo-Heart-Rate ejercicioVrms2 PROYECTOFINAL ejercicioVrms ... more

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?

UserRevisionLine numberNew contents of line
xorjoep 1:24714b45cd1b 1 /* ----------------------------------------------------------------------
xorjoep 1:24714b45cd1b 2 * Project: CMSIS DSP Library
xorjoep 1:24714b45cd1b 3 * Title: arm_lms_norm_init_q15.c
xorjoep 1:24714b45cd1b 4 * Description: Q15 NLMS 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 #include "arm_common_tables.h"
xorjoep 1:24714b45cd1b 31
xorjoep 1:24714b45cd1b 32 /**
xorjoep 1:24714b45cd1b 33 * @addtogroup LMS_NORM
xorjoep 1:24714b45cd1b 34 * @{
xorjoep 1:24714b45cd1b 35 */
xorjoep 1:24714b45cd1b 36
xorjoep 1:24714b45cd1b 37 /**
xorjoep 1:24714b45cd1b 38 * @brief Initialization function for Q15 normalized LMS filter.
xorjoep 1:24714b45cd1b 39 * @param[in] *S points to an instance of the Q15 normalized LMS filter structure.
xorjoep 1:24714b45cd1b 40 * @param[in] numTaps number of filter coefficients.
xorjoep 1:24714b45cd1b 41 * @param[in] *pCoeffs points to coefficient buffer.
xorjoep 1:24714b45cd1b 42 * @param[in] *pState points to state buffer.
xorjoep 1:24714b45cd1b 43 * @param[in] mu step size that controls filter coefficient updates.
xorjoep 1:24714b45cd1b 44 * @param[in] blockSize number of samples to process.
xorjoep 1:24714b45cd1b 45 * @param[in] postShift bit shift applied to coefficients.
xorjoep 1:24714b45cd1b 46 * @return none.
xorjoep 1:24714b45cd1b 47 *
xorjoep 1:24714b45cd1b 48 * <b>Description:</b>
xorjoep 1:24714b45cd1b 49 * \par
xorjoep 1:24714b45cd1b 50 * <code>pCoeffs</code> points to the array of filter coefficients stored in time reversed order:
xorjoep 1:24714b45cd1b 51 * <pre>
xorjoep 1:24714b45cd1b 52 * {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]}
xorjoep 1:24714b45cd1b 53 * </pre>
xorjoep 1:24714b45cd1b 54 * The initial filter coefficients serve as a starting point for the adaptive filter.
xorjoep 1:24714b45cd1b 55 * <code>pState</code> points to the array of state variables and size of array is
xorjoep 1:24714b45cd1b 56 * <code>numTaps+blockSize-1</code> samples, where <code>blockSize</code> is the number of input samples processed
xorjoep 1:24714b45cd1b 57 * by each call to <code>arm_lms_norm_q15()</code>.
xorjoep 1:24714b45cd1b 58 */
xorjoep 1:24714b45cd1b 59
xorjoep 1:24714b45cd1b 60 void arm_lms_norm_init_q15(
xorjoep 1:24714b45cd1b 61 arm_lms_norm_instance_q15 * S,
xorjoep 1:24714b45cd1b 62 uint16_t numTaps,
xorjoep 1:24714b45cd1b 63 q15_t * pCoeffs,
xorjoep 1:24714b45cd1b 64 q15_t * pState,
xorjoep 1:24714b45cd1b 65 q15_t mu,
xorjoep 1:24714b45cd1b 66 uint32_t blockSize,
xorjoep 1:24714b45cd1b 67 uint8_t postShift)
xorjoep 1:24714b45cd1b 68 {
xorjoep 1:24714b45cd1b 69 /* Assign filter taps */
xorjoep 1:24714b45cd1b 70 S->numTaps = numTaps;
xorjoep 1:24714b45cd1b 71
xorjoep 1:24714b45cd1b 72 /* Assign coefficient pointer */
xorjoep 1:24714b45cd1b 73 S->pCoeffs = pCoeffs;
xorjoep 1:24714b45cd1b 74
xorjoep 1:24714b45cd1b 75 /* Clear state buffer and size is always blockSize + numTaps - 1 */
xorjoep 1:24714b45cd1b 76 memset(pState, 0, (numTaps + (blockSize - 1U)) * sizeof(q15_t));
xorjoep 1:24714b45cd1b 77
xorjoep 1:24714b45cd1b 78 /* Assign post Shift value applied to coefficients */
xorjoep 1:24714b45cd1b 79 S->postShift = postShift;
xorjoep 1:24714b45cd1b 80
xorjoep 1:24714b45cd1b 81 /* Assign state pointer */
xorjoep 1:24714b45cd1b 82 S->pState = pState;
xorjoep 1:24714b45cd1b 83
xorjoep 1:24714b45cd1b 84 /* Assign Step size value */
xorjoep 1:24714b45cd1b 85 S->mu = mu;
xorjoep 1:24714b45cd1b 86
xorjoep 1:24714b45cd1b 87 /* Initialize reciprocal pointer table */
xorjoep 1:24714b45cd1b 88 S->recipTable = (q15_t *) armRecipTableQ15;
xorjoep 1:24714b45cd1b 89
xorjoep 1:24714b45cd1b 90 /* Initialise Energy to zero */
xorjoep 1:24714b45cd1b 91 S->energy = 0;
xorjoep 1:24714b45cd1b 92
xorjoep 1:24714b45cd1b 93 /* Initialise x0 to zero */
xorjoep 1:24714b45cd1b 94 S->x0 = 0;
xorjoep 1:24714b45cd1b 95
xorjoep 1:24714b45cd1b 96 }
xorjoep 1:24714b45cd1b 97
xorjoep 1:24714b45cd1b 98 /**
xorjoep 1:24714b45cd1b 99 * @} end of LMS_NORM group
xorjoep 1:24714b45cd1b 100 */