Robert Lopez / CMSIS5
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers arm_cfft_radix2_init_q31.c Source File

arm_cfft_radix2_init_q31.c

00001 /* ----------------------------------------------------------------------
00002  * Project:      CMSIS DSP Library
00003  * Title:        arm_cfft_radix2_init_q31.c
00004  * Description:  Radix-2 Decimation in Frequency Fixed-point CFFT & CIFFT Initialization function
00005  *
00006  * $Date:        27. January 2017
00007  * $Revision:    V.1.5.1
00008  *
00009  * Target Processor: Cortex-M cores
00010  * -------------------------------------------------------------------- */
00011 /*
00012  * Copyright (C) 2010-2017 ARM Limited or its affiliates. All rights reserved.
00013  *
00014  * SPDX-License-Identifier: Apache-2.0
00015  *
00016  * Licensed under the Apache License, Version 2.0 (the License); you may
00017  * not use this file except in compliance with the License.
00018  * You may obtain a copy of the License at
00019  *
00020  * www.apache.org/licenses/LICENSE-2.0
00021  *
00022  * Unless required by applicable law or agreed to in writing, software
00023  * distributed under the License is distributed on an AS IS BASIS, WITHOUT
00024  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00025  * See the License for the specific language governing permissions and
00026  * limitations under the License.
00027  */
00028 
00029 #include "arm_math.h"
00030 #include "arm_common_tables.h"
00031 
00032 /**
00033  * @ingroup groupTransforms
00034  */
00035 
00036 /**
00037  * @addtogroup ComplexFFT
00038  * @{
00039  */
00040 
00041 
00042 /**
00043 *
00044 * @brief  Initialization function for the Q31 CFFT/CIFFT.
00045 * @deprecated Do not use this function.  It has been superseded by \ref arm_cfft_q31 and will be removed
00046 * @param[in,out] *S             points to an instance of the Q31 CFFT/CIFFT structure.
00047 * @param[in]     fftLen         length of the FFT.
00048 * @param[in]     ifftFlag       flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform.
00049 * @param[in]     bitReverseFlag flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output.
00050 * @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.
00051 *
00052 * \par Description:
00053 * \par
00054 * The parameter <code>ifftFlag</code> controls whether a forward or inverse transform is computed.
00055 * Set(=1) ifftFlag for calculation of CIFFT otherwise  CFFT is calculated
00056 * \par
00057 * The parameter <code>bitReverseFlag</code> controls whether output is in normal order or bit reversed order.
00058 * Set(=1) bitReverseFlag for output to be in normal order otherwise output is in bit reversed order.
00059 * \par
00060 * The parameter <code>fftLen</code> Specifies length of CFFT/CIFFT process. Supported FFT Lengths are 16, 64, 256, 1024.
00061 * \par
00062 * This Function also initializes Twiddle factor table pointer and Bit reversal table pointer.
00063 */
00064 
00065 arm_status arm_cfft_radix2_init_q31(
00066   arm_cfft_radix2_instance_q31 * S,
00067   uint16_t fftLen,
00068   uint8_t ifftFlag,
00069   uint8_t bitReverseFlag)
00070 {
00071   /*  Initialise the default arm status */
00072   arm_status status = ARM_MATH_SUCCESS;
00073 
00074   /*  Initialise the FFT length */
00075   S->fftLen = fftLen;
00076 
00077   /*  Initialise the Twiddle coefficient pointer */
00078   S->pTwiddle = (q31_t *) twiddleCoef_4096_q31 ;
00079   /*  Initialise the Flag for selection of CFFT or CIFFT */
00080   S->ifftFlag = ifftFlag;
00081   /*  Initialise the Flag for calculation Bit reversal or not */
00082   S->bitReverseFlag = bitReverseFlag;
00083 
00084   /*  Initializations of Instance structure depending on the FFT length */
00085   switch (S->fftLen)
00086   {
00087     /*  Initializations of structure parameters for 4096 point FFT */
00088   case 4096U:
00089     /*  Initialise the twiddle coef modifier value */
00090     S->twidCoefModifier = 1U;
00091     /*  Initialise the bit reversal table modifier */
00092     S->bitRevFactor = 1U;
00093     /*  Initialise the bit reversal table pointer */
00094     S->pBitRevTable = (uint16_t *) armBitRevTable ;
00095     break;
00096 
00097     /*  Initializations of structure parameters for 2048 point FFT */
00098   case 2048U:
00099     /*  Initialise the twiddle coef modifier value */
00100     S->twidCoefModifier = 2U;
00101     /*  Initialise the bit reversal table modifier */
00102     S->bitRevFactor = 2U;
00103     /*  Initialise the bit reversal table pointer */
00104     S->pBitRevTable = (uint16_t *) & armBitRevTable [1];
00105     break;
00106 
00107     /*  Initializations of structure parameters for 1024 point FFT */
00108   case 1024U:
00109     /*  Initialise the twiddle coef modifier value */
00110     S->twidCoefModifier = 4U;
00111     /*  Initialise the bit reversal table modifier */
00112     S->bitRevFactor = 4U;
00113     /*  Initialise the bit reversal table pointer */
00114     S->pBitRevTable = (uint16_t *) & armBitRevTable [3];
00115     break;
00116 
00117     /*  Initializations of structure parameters for 512 point FFT */
00118   case 512U:
00119     /*  Initialise the twiddle coef modifier value */
00120     S->twidCoefModifier = 8U;
00121     /*  Initialise the bit reversal table modifier */
00122     S->bitRevFactor = 8U;
00123     /*  Initialise the bit reversal table pointer */
00124     S->pBitRevTable = (uint16_t *) & armBitRevTable [7];
00125     break;
00126 
00127   case 256U:
00128     /*  Initializations of structure parameters for 256 point FFT */
00129     S->twidCoefModifier = 16U;
00130     S->bitRevFactor = 16U;
00131     S->pBitRevTable = (uint16_t *) & armBitRevTable [15];
00132     break;
00133 
00134   case 128U:
00135     /*  Initializations of structure parameters for 128 point FFT */
00136     S->twidCoefModifier = 32U;
00137     S->bitRevFactor = 32U;
00138     S->pBitRevTable = (uint16_t *) & armBitRevTable [31];
00139     break;
00140 
00141   case 64U:
00142     /*  Initializations of structure parameters for 64 point FFT */
00143     S->twidCoefModifier = 64U;
00144     S->bitRevFactor = 64U;
00145     S->pBitRevTable = (uint16_t *) & armBitRevTable [63];
00146     break;
00147 
00148   case 32U:
00149     /*  Initializations of structure parameters for 32 point FFT */
00150     S->twidCoefModifier = 128U;
00151     S->bitRevFactor = 128U;
00152     S->pBitRevTable = (uint16_t *) & armBitRevTable [127];
00153     break;
00154 
00155   case 16U:
00156     /*  Initializations of structure parameters for 16 point FFT */
00157     S->twidCoefModifier = 256U;
00158     S->bitRevFactor = 256U;
00159     S->pBitRevTable = (uint16_t *) & armBitRevTable [255];
00160     break;
00161 
00162 
00163   default:
00164     /*  Reporting argument error if fftSize is not valid value */
00165     status = ARM_MATH_ARGUMENT_ERROR;
00166     break;
00167   }
00168 
00169   return (status);
00170 }
00171 
00172 /**
00173  * @} end of ComplexFFT group
00174  */
00175