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