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_cfft_radix2_init_q31.c
xorjoep 1:24714b45cd1b 4 * Description: Radix-2 Decimation in Frequency Fixed-point CFFT & CIFFT 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 * @ingroup groupTransforms
xorjoep 1:24714b45cd1b 34 */
xorjoep 1:24714b45cd1b 35
xorjoep 1:24714b45cd1b 36 /**
xorjoep 1:24714b45cd1b 37 * @addtogroup ComplexFFT
xorjoep 1:24714b45cd1b 38 * @{
xorjoep 1:24714b45cd1b 39 */
xorjoep 1:24714b45cd1b 40
xorjoep 1:24714b45cd1b 41
xorjoep 1:24714b45cd1b 42 /**
xorjoep 1:24714b45cd1b 43 *
xorjoep 1:24714b45cd1b 44 * @brief Initialization function for the Q31 CFFT/CIFFT.
xorjoep 1:24714b45cd1b 45 * @deprecated Do not use this function. It has been superseded by \ref arm_cfft_q31 and will be removed
xorjoep 1:24714b45cd1b 46 * @param[in,out] *S points to an instance of the Q31 CFFT/CIFFT structure.
xorjoep 1:24714b45cd1b 47 * @param[in] fftLen length of the FFT.
xorjoep 1:24714b45cd1b 48 * @param[in] ifftFlag flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform.
xorjoep 1:24714b45cd1b 49 * @param[in] bitReverseFlag flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output.
xorjoep 1:24714b45cd1b 50 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if <code>fftLen</code> is not a supported value.
xorjoep 1:24714b45cd1b 51 *
xorjoep 1:24714b45cd1b 52 * \par Description:
xorjoep 1:24714b45cd1b 53 * \par
xorjoep 1:24714b45cd1b 54 * The parameter <code>ifftFlag</code> controls whether a forward or inverse transform is computed.
xorjoep 1:24714b45cd1b 55 * Set(=1) ifftFlag for calculation of CIFFT otherwise CFFT is calculated
xorjoep 1:24714b45cd1b 56 * \par
xorjoep 1:24714b45cd1b 57 * The parameter <code>bitReverseFlag</code> controls whether output is in normal order or bit reversed order.
xorjoep 1:24714b45cd1b 58 * Set(=1) bitReverseFlag for output to be in normal order otherwise output is in bit reversed order.
xorjoep 1:24714b45cd1b 59 * \par
xorjoep 1:24714b45cd1b 60 * The parameter <code>fftLen</code> Specifies length of CFFT/CIFFT process. Supported FFT Lengths are 16, 64, 256, 1024.
xorjoep 1:24714b45cd1b 61 * \par
xorjoep 1:24714b45cd1b 62 * This Function also initializes Twiddle factor table pointer and Bit reversal table pointer.
xorjoep 1:24714b45cd1b 63 */
xorjoep 1:24714b45cd1b 64
xorjoep 1:24714b45cd1b 65 arm_status arm_cfft_radix2_init_q31(
xorjoep 1:24714b45cd1b 66 arm_cfft_radix2_instance_q31 * S,
xorjoep 1:24714b45cd1b 67 uint16_t fftLen,
xorjoep 1:24714b45cd1b 68 uint8_t ifftFlag,
xorjoep 1:24714b45cd1b 69 uint8_t bitReverseFlag)
xorjoep 1:24714b45cd1b 70 {
xorjoep 1:24714b45cd1b 71 /* Initialise the default arm status */
xorjoep 1:24714b45cd1b 72 arm_status status = ARM_MATH_SUCCESS;
xorjoep 1:24714b45cd1b 73
xorjoep 1:24714b45cd1b 74 /* Initialise the FFT length */
xorjoep 1:24714b45cd1b 75 S->fftLen = fftLen;
xorjoep 1:24714b45cd1b 76
xorjoep 1:24714b45cd1b 77 /* Initialise the Twiddle coefficient pointer */
xorjoep 1:24714b45cd1b 78 S->pTwiddle = (q31_t *) twiddleCoef_4096_q31;
xorjoep 1:24714b45cd1b 79 /* Initialise the Flag for selection of CFFT or CIFFT */
xorjoep 1:24714b45cd1b 80 S->ifftFlag = ifftFlag;
xorjoep 1:24714b45cd1b 81 /* Initialise the Flag for calculation Bit reversal or not */
xorjoep 1:24714b45cd1b 82 S->bitReverseFlag = bitReverseFlag;
xorjoep 1:24714b45cd1b 83
xorjoep 1:24714b45cd1b 84 /* Initializations of Instance structure depending on the FFT length */
xorjoep 1:24714b45cd1b 85 switch (S->fftLen)
xorjoep 1:24714b45cd1b 86 {
xorjoep 1:24714b45cd1b 87 /* Initializations of structure parameters for 4096 point FFT */
xorjoep 1:24714b45cd1b 88 case 4096U:
xorjoep 1:24714b45cd1b 89 /* Initialise the twiddle coef modifier value */
xorjoep 1:24714b45cd1b 90 S->twidCoefModifier = 1U;
xorjoep 1:24714b45cd1b 91 /* Initialise the bit reversal table modifier */
xorjoep 1:24714b45cd1b 92 S->bitRevFactor = 1U;
xorjoep 1:24714b45cd1b 93 /* Initialise the bit reversal table pointer */
xorjoep 1:24714b45cd1b 94 S->pBitRevTable = (uint16_t *) armBitRevTable;
xorjoep 1:24714b45cd1b 95 break;
xorjoep 1:24714b45cd1b 96
xorjoep 1:24714b45cd1b 97 /* Initializations of structure parameters for 2048 point FFT */
xorjoep 1:24714b45cd1b 98 case 2048U:
xorjoep 1:24714b45cd1b 99 /* Initialise the twiddle coef modifier value */
xorjoep 1:24714b45cd1b 100 S->twidCoefModifier = 2U;
xorjoep 1:24714b45cd1b 101 /* Initialise the bit reversal table modifier */
xorjoep 1:24714b45cd1b 102 S->bitRevFactor = 2U;
xorjoep 1:24714b45cd1b 103 /* Initialise the bit reversal table pointer */
xorjoep 1:24714b45cd1b 104 S->pBitRevTable = (uint16_t *) & armBitRevTable[1];
xorjoep 1:24714b45cd1b 105 break;
xorjoep 1:24714b45cd1b 106
xorjoep 1:24714b45cd1b 107 /* Initializations of structure parameters for 1024 point FFT */
xorjoep 1:24714b45cd1b 108 case 1024U:
xorjoep 1:24714b45cd1b 109 /* Initialise the twiddle coef modifier value */
xorjoep 1:24714b45cd1b 110 S->twidCoefModifier = 4U;
xorjoep 1:24714b45cd1b 111 /* Initialise the bit reversal table modifier */
xorjoep 1:24714b45cd1b 112 S->bitRevFactor = 4U;
xorjoep 1:24714b45cd1b 113 /* Initialise the bit reversal table pointer */
xorjoep 1:24714b45cd1b 114 S->pBitRevTable = (uint16_t *) & armBitRevTable[3];
xorjoep 1:24714b45cd1b 115 break;
xorjoep 1:24714b45cd1b 116
xorjoep 1:24714b45cd1b 117 /* Initializations of structure parameters for 512 point FFT */
xorjoep 1:24714b45cd1b 118 case 512U:
xorjoep 1:24714b45cd1b 119 /* Initialise the twiddle coef modifier value */
xorjoep 1:24714b45cd1b 120 S->twidCoefModifier = 8U;
xorjoep 1:24714b45cd1b 121 /* Initialise the bit reversal table modifier */
xorjoep 1:24714b45cd1b 122 S->bitRevFactor = 8U;
xorjoep 1:24714b45cd1b 123 /* Initialise the bit reversal table pointer */
xorjoep 1:24714b45cd1b 124 S->pBitRevTable = (uint16_t *) & armBitRevTable[7];
xorjoep 1:24714b45cd1b 125 break;
xorjoep 1:24714b45cd1b 126
xorjoep 1:24714b45cd1b 127 case 256U:
xorjoep 1:24714b45cd1b 128 /* Initializations of structure parameters for 256 point FFT */
xorjoep 1:24714b45cd1b 129 S->twidCoefModifier = 16U;
xorjoep 1:24714b45cd1b 130 S->bitRevFactor = 16U;
xorjoep 1:24714b45cd1b 131 S->pBitRevTable = (uint16_t *) & armBitRevTable[15];
xorjoep 1:24714b45cd1b 132 break;
xorjoep 1:24714b45cd1b 133
xorjoep 1:24714b45cd1b 134 case 128U:
xorjoep 1:24714b45cd1b 135 /* Initializations of structure parameters for 128 point FFT */
xorjoep 1:24714b45cd1b 136 S->twidCoefModifier = 32U;
xorjoep 1:24714b45cd1b 137 S->bitRevFactor = 32U;
xorjoep 1:24714b45cd1b 138 S->pBitRevTable = (uint16_t *) & armBitRevTable[31];
xorjoep 1:24714b45cd1b 139 break;
xorjoep 1:24714b45cd1b 140
xorjoep 1:24714b45cd1b 141 case 64U:
xorjoep 1:24714b45cd1b 142 /* Initializations of structure parameters for 64 point FFT */
xorjoep 1:24714b45cd1b 143 S->twidCoefModifier = 64U;
xorjoep 1:24714b45cd1b 144 S->bitRevFactor = 64U;
xorjoep 1:24714b45cd1b 145 S->pBitRevTable = (uint16_t *) & armBitRevTable[63];
xorjoep 1:24714b45cd1b 146 break;
xorjoep 1:24714b45cd1b 147
xorjoep 1:24714b45cd1b 148 case 32U:
xorjoep 1:24714b45cd1b 149 /* Initializations of structure parameters for 32 point FFT */
xorjoep 1:24714b45cd1b 150 S->twidCoefModifier = 128U;
xorjoep 1:24714b45cd1b 151 S->bitRevFactor = 128U;
xorjoep 1:24714b45cd1b 152 S->pBitRevTable = (uint16_t *) & armBitRevTable[127];
xorjoep 1:24714b45cd1b 153 break;
xorjoep 1:24714b45cd1b 154
xorjoep 1:24714b45cd1b 155 case 16U:
xorjoep 1:24714b45cd1b 156 /* Initializations of structure parameters for 16 point FFT */
xorjoep 1:24714b45cd1b 157 S->twidCoefModifier = 256U;
xorjoep 1:24714b45cd1b 158 S->bitRevFactor = 256U;
xorjoep 1:24714b45cd1b 159 S->pBitRevTable = (uint16_t *) & armBitRevTable[255];
xorjoep 1:24714b45cd1b 160 break;
xorjoep 1:24714b45cd1b 161
xorjoep 1:24714b45cd1b 162
xorjoep 1:24714b45cd1b 163 default:
xorjoep 1:24714b45cd1b 164 /* Reporting argument error if fftSize is not valid value */
xorjoep 1:24714b45cd1b 165 status = ARM_MATH_ARGUMENT_ERROR;
xorjoep 1:24714b45cd1b 166 break;
xorjoep 1:24714b45cd1b 167 }
xorjoep 1:24714b45cd1b 168
xorjoep 1:24714b45cd1b 169 return (status);
xorjoep 1:24714b45cd1b 170 }
xorjoep 1:24714b45cd1b 171
xorjoep 1:24714b45cd1b 172 /**
xorjoep 1:24714b45cd1b 173 * @} end of ComplexFFT group
xorjoep 1:24714b45cd1b 174 */