• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* ----------------------------------------------------------------------
2  * Project:      CMSIS DSP Library
3  * Title:        arm_cfft_radix2_init_f32.c
4  * Description:  Radix-2 Decimation in Frequency Floating-point CFFT & CIFFT Initialization function
5  *
6  * $Date:        23 April 2021
7  * $Revision:    V1.9.0
8  *
9  * Target Processor: Cortex-M and Cortex-A cores
10  * -------------------------------------------------------------------- */
11 /*
12  * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved.
13  *
14  * SPDX-License-Identifier: Apache-2.0
15  *
16  * Licensed under the Apache License, Version 2.0 (the License); you may
17  * not use this file except in compliance with the License.
18  * You may obtain a copy of the License at
19  *
20  * www.apache.org/licenses/LICENSE-2.0
21  *
22  * Unless required by applicable law or agreed to in writing, software
23  * distributed under the License is distributed on an AS IS BASIS, WITHOUT
24  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25  * See the License for the specific language governing permissions and
26  * limitations under the License.
27  */
28 
29 #include "dsp/transform_functions.h"
30 #include "arm_common_tables.h"
31 
32 /**
33   @ingroup groupTransforms
34  */
35 
36 /**
37   @addtogroup ComplexFFT
38   @{
39  */
40 
41 /**
42   @brief         Initialization function for the floating-point CFFT/CIFFT.
43   @deprecated    Do not use this function. It has been superseded by \ref arm_cfft_f32 and will be removed in the future.
44   @param[in,out] S              points to an instance of the floating-point CFFT/CIFFT structure
45   @param[in]     fftLen         length of the FFT
46   @param[in]     ifftFlag       flag that selects transform direction
47                    - value = 0: forward transform
48                    - value = 1: inverse transform
49   @param[in]     bitReverseFlag flag that enables / disables bit reversal of output
50                    - value = 0: disables bit reversal of output
51                    - value = 1: enables bit reversal of output
52   @return        execution status
53                    - \ref ARM_MATH_SUCCESS        : Operation successful
54                    - \ref ARM_MATH_ARGUMENT_ERROR : <code>fftLen</code> is not a supported length
55 
56   @par           Details
57                    The parameter <code>ifftFlag</code> controls whether a forward or inverse transform is computed.
58                    Set(=1) ifftFlag for calculation of CIFFT otherwise  CFFT is calculated
59   @par
60                    The parameter <code>bitReverseFlag</code> controls whether output is in normal order or bit reversed order.
61                    Set(=1) bitReverseFlag for output to be in normal order otherwise output is in bit reversed order.
62   @par
63                    The parameter <code>fftLen</code> Specifies length of CFFT/CIFFT process. Supported FFT Lengths are 16, 64, 256, 1024.
64   @par
65                    This Function also initializes Twiddle factor table pointer and Bit reversal table pointer.
66 */
67 
arm_cfft_radix2_init_f32(arm_cfft_radix2_instance_f32 * S,uint16_t fftLen,uint8_t ifftFlag,uint8_t bitReverseFlag)68 arm_status arm_cfft_radix2_init_f32(
69   arm_cfft_radix2_instance_f32 * S,
70   uint16_t fftLen,
71   uint8_t ifftFlag,
72   uint8_t bitReverseFlag)
73 {
74    /*  Initialise the default arm status */
75   arm_status status = ARM_MATH_ARGUMENT_ERROR;
76 
77 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_FFT_ALLOW_TABLES)
78 
79 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_F32_4096)
80 
81   /*  Initialise the default arm status */
82   status = ARM_MATH_SUCCESS;
83 
84   /*  Initialise the FFT length */
85   S->fftLen = fftLen;
86 
87   /*  Initialise the Twiddle coefficient pointer */
88   S->pTwiddle = (float32_t *) twiddleCoef;
89 
90   /*  Initialise the Flag for selection of CFFT or CIFFT */
91   S->ifftFlag = ifftFlag;
92 
93   /*  Initialise the Flag for calculation Bit reversal or not */
94   S->bitReverseFlag = bitReverseFlag;
95 
96 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_F32_4096)
97 
98   /*  Initializations of structure parameters depending on the FFT length */
99   switch (S->fftLen)
100   {
101 
102   case 4096U:
103     /*  Initializations of structure parameters for 4096 point FFT */
104 
105     /*  Initialise the twiddle coef modifier value */
106     S->twidCoefModifier = 1U;
107     /*  Initialise the bit reversal table modifier */
108     S->bitRevFactor = 1U;
109     /*  Initialise the bit reversal table pointer */
110     S->pBitRevTable = (uint16_t *) armBitRevTable;
111     /*  Initialise the 1/fftLen Value */
112     S->onebyfftLen = 0.000244140625;
113     break;
114 
115   case 2048U:
116     /*  Initializations of structure parameters for 2048 point FFT */
117 
118     /*  Initialise the twiddle coef modifier value */
119     S->twidCoefModifier = 2U;
120     /*  Initialise the bit reversal table modifier */
121     S->bitRevFactor = 2U;
122     /*  Initialise the bit reversal table pointer */
123     S->pBitRevTable = (uint16_t *) & armBitRevTable[1];
124     /*  Initialise the 1/fftLen Value */
125     S->onebyfftLen = 0.00048828125;
126     break;
127 
128   case 1024U:
129     /*  Initializations of structure parameters for 1024 point FFT */
130 
131     /*  Initialise the twiddle coef modifier value */
132     S->twidCoefModifier = 4U;
133     /*  Initialise the bit reversal table modifier */
134     S->bitRevFactor = 4U;
135     /*  Initialise the bit reversal table pointer */
136     S->pBitRevTable = (uint16_t *) & armBitRevTable[3];
137     /*  Initialise the 1/fftLen Value */
138     S->onebyfftLen = 0.0009765625f;
139     break;
140 
141   case 512U:
142     /*  Initializations of structure parameters for 512 point FFT */
143 
144     /*  Initialise the twiddle coef modifier value */
145     S->twidCoefModifier = 8U;
146     /*  Initialise the bit reversal table modifier */
147     S->bitRevFactor = 8U;
148     /*  Initialise the bit reversal table pointer */
149     S->pBitRevTable = (uint16_t *) & armBitRevTable[7];
150     /*  Initialise the 1/fftLen Value */
151     S->onebyfftLen = 0.001953125;
152     break;
153 
154   case 256U:
155     /*  Initializations of structure parameters for 256 point FFT */
156     S->twidCoefModifier = 16U;
157     S->bitRevFactor = 16U;
158     S->pBitRevTable = (uint16_t *) & armBitRevTable[15];
159     S->onebyfftLen = 0.00390625f;
160     break;
161 
162   case 128U:
163     /*  Initializations of structure parameters for 128 point FFT */
164     S->twidCoefModifier = 32U;
165     S->bitRevFactor = 32U;
166     S->pBitRevTable = (uint16_t *) & armBitRevTable[31];
167     S->onebyfftLen = 0.0078125;
168     break;
169 
170   case 64U:
171     /*  Initializations of structure parameters for 64 point FFT */
172     S->twidCoefModifier = 64U;
173     S->bitRevFactor = 64U;
174     S->pBitRevTable = (uint16_t *) & armBitRevTable[63];
175     S->onebyfftLen = 0.015625f;
176     break;
177 
178   case 32U:
179     /*  Initializations of structure parameters for 64 point FFT */
180     S->twidCoefModifier = 128U;
181     S->bitRevFactor = 128U;
182     S->pBitRevTable = (uint16_t *) & armBitRevTable[127];
183     S->onebyfftLen = 0.03125;
184     break;
185 
186   case 16U:
187     /*  Initializations of structure parameters for 16 point FFT */
188     S->twidCoefModifier = 256U;
189     S->bitRevFactor = 256U;
190     S->pBitRevTable = (uint16_t *) & armBitRevTable[255];
191     S->onebyfftLen = 0.0625f;
192     break;
193 
194 
195   default:
196     /*  Reporting argument error if fftSize is not valid value */
197     status = ARM_MATH_ARGUMENT_ERROR;
198     break;
199   }
200 
201 #endif
202 #endif
203 #endif
204   return (status);
205 }
206 
207 /**
208   @} end of ComplexFFT group
209  */
210