CMSIS DSP library
Dependents: KL25Z_FFT_Demo Hat_Board_v5_1 KL25Z_FFT_Demo_tony KL25Z_FFT_Demo_tony ... more
Fork of mbed-dsp by
arm_cfft_radix4_init_q31.c
00001 /* ---------------------------------------------------------------------- 00002 * Copyright (C) 2010-2013 ARM Limited. All rights reserved. 00003 * 00004 * $Date: 17. January 2013 00005 * $Revision: V1.4.1 00006 * 00007 * Project: CMSIS DSP Library 00008 * Title: arm_cfft_radix4_init_q31.c 00009 * 00010 * Description: Radix-4 Decimation in Frequency Q31 FFT & IFFT initialization function 00011 * 00012 * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 00013 * 00014 * Redistribution and use in source and binary forms, with or without 00015 * modification, are permitted provided that the following conditions 00016 * are met: 00017 * - Redistributions of source code must retain the above copyright 00018 * notice, this list of conditions and the following disclaimer. 00019 * - Redistributions in binary form must reproduce the above copyright 00020 * notice, this list of conditions and the following disclaimer in 00021 * the documentation and/or other materials provided with the 00022 * distribution. 00023 * - Neither the name of ARM LIMITED nor the names of its contributors 00024 * may be used to endorse or promote products derived from this 00025 * software without specific prior written permission. 00026 * 00027 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00028 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00029 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00030 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00031 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00032 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00033 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00034 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00035 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00036 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00037 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00038 * POSSIBILITY OF SUCH DAMAGE. 00039 * -------------------------------------------------------------------- */ 00040 00041 #include "arm_math.h" 00042 #include "arm_common_tables.h" 00043 00044 /** 00045 * @ingroup groupTransforms 00046 */ 00047 00048 /** 00049 * @addtogroup ComplexFFT 00050 * @{ 00051 */ 00052 00053 /** 00054 * 00055 * @brief Initialization function for the Q31 CFFT/CIFFT. 00056 * @param[in,out] *S points to an instance of the Q31 CFFT/CIFFT structure. 00057 * @param[in] fftLen length of the FFT. 00058 * @param[in] ifftFlag flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. 00059 * @param[in] bitReverseFlag flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. 00060 * @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. 00061 * 00062 * \par Description: 00063 * \par 00064 * The parameter <code>ifftFlag</code> controls whether a forward or inverse transform is computed. 00065 * Set(=1) ifftFlag for calculation of CIFFT otherwise CFFT is calculated 00066 * \par 00067 * The parameter <code>bitReverseFlag</code> controls whether output is in normal order or bit reversed order. 00068 * Set(=1) bitReverseFlag for output to be in normal order otherwise output is in bit reversed order. 00069 * \par 00070 * The parameter <code>fftLen</code> Specifies length of CFFT/CIFFT process. Supported FFT Lengths are 16, 64, 256, 1024. 00071 * \par 00072 * This Function also initializes Twiddle factor table pointer and Bit reversal table pointer. 00073 */ 00074 00075 arm_status arm_cfft_radix4_init_q31( 00076 arm_cfft_radix4_instance_q31 * S, 00077 uint16_t fftLen, 00078 uint8_t ifftFlag, 00079 uint8_t bitReverseFlag) 00080 { 00081 /* Initialise the default arm status */ 00082 arm_status status = ARM_MATH_SUCCESS; 00083 /* Initialise the FFT length */ 00084 S->fftLen = fftLen; 00085 /* Initialise the Twiddle coefficient pointer */ 00086 S->pTwiddle = (q31_t *) twiddleCoefQ31 ; 00087 /* Initialise the Flag for selection of CFFT or CIFFT */ 00088 S->ifftFlag = ifftFlag; 00089 /* Initialise the Flag for calculation Bit reversal or not */ 00090 S->bitReverseFlag = bitReverseFlag; 00091 00092 /* Initializations of Instance structure depending on the FFT length */ 00093 switch (S->fftLen) 00094 { 00095 /* Initializations of structure parameters for 4096 point FFT */ 00096 case 4096u: 00097 /* Initialise the twiddle coef modifier value */ 00098 S->twidCoefModifier = 1u; 00099 /* Initialise the bit reversal table modifier */ 00100 S->bitRevFactor = 1u; 00101 /* Initialise the bit reversal table pointer */ 00102 S->pBitRevTable = (uint16_t *) armBitRevTable ; 00103 break; 00104 00105 /* Initializations of structure parameters for 1024 point FFT */ 00106 case 1024u: 00107 /* Initialise the twiddle coef modifier value */ 00108 S->twidCoefModifier = 4u; 00109 /* Initialise the bit reversal table modifier */ 00110 S->bitRevFactor = 4u; 00111 /* Initialise the bit reversal table pointer */ 00112 S->pBitRevTable = (uint16_t *) & armBitRevTable [3]; 00113 break; 00114 00115 case 256u: 00116 /* Initializations of structure parameters for 256 point FFT */ 00117 S->twidCoefModifier = 16u; 00118 S->bitRevFactor = 16u; 00119 S->pBitRevTable = (uint16_t *) & armBitRevTable [15]; 00120 break; 00121 00122 case 64u: 00123 /* Initializations of structure parameters for 64 point FFT */ 00124 S->twidCoefModifier = 64u; 00125 S->bitRevFactor = 64u; 00126 S->pBitRevTable = (uint16_t *) & armBitRevTable [63]; 00127 break; 00128 00129 case 16u: 00130 /* Initializations of structure parameters for 16 point FFT */ 00131 S->twidCoefModifier = 256u; 00132 S->bitRevFactor = 256u; 00133 S->pBitRevTable = (uint16_t *) & armBitRevTable [255]; 00134 break; 00135 00136 default: 00137 /* Reporting argument error if fftSize is not valid value */ 00138 status = ARM_MATH_ARGUMENT_ERROR; 00139 break; 00140 } 00141 00142 return (status); 00143 } 00144 00145 /** 00146 * @} end of ComplexFFT group 00147 */
Generated on Tue Jul 12 2022 12:36:53 by 1.7.2