1 /* ----------------------------------------------------------------------
2 * Project: CMSIS DSP Library
3 * Title: arm_rfft_fast_init_f32.c
4 * Description: Split Radix Decimation in Frequency CFFT Floating point processing 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 RealFFT
34 */
35
36 /**
37 @addtogroup RealFFTF32
38 @{
39 */
40
41
42 /**
43 @brief Initialization function for the 32pt floating-point real FFT.
44 @param[in,out] S points to an arm_rfft_fast_instance_f32 structure
45 @return execution status
46 - \ref ARM_MATH_SUCCESS : Operation successful
47 - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
48 */
49
arm_rfft_fast_init_32_f32(arm_rfft_fast_instance_f32 * S)50 arm_status arm_rfft_fast_init_32_f32( arm_rfft_fast_instance_f32 * S ) {
51
52 arm_status status;
53
54 if( !S ) return ARM_MATH_ARGUMENT_ERROR;
55
56 status=arm_cfft_init_16_f32(&(S->Sint));
57 if (status != ARM_MATH_SUCCESS)
58 {
59 return(status);
60 }
61
62 S->fftLenRFFT = 32U;
63 S->pTwiddleRFFT = (float32_t *) twiddleCoef_rfft_32;
64
65 return ARM_MATH_SUCCESS;
66 }
67
68 /**
69 @brief Initialization function for the 64pt floating-point real FFT.
70 @param[in,out] S points to an arm_rfft_fast_instance_f32 structure
71 @return execution status
72 - \ref ARM_MATH_SUCCESS : Operation successful
73 - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
74 */
75
arm_rfft_fast_init_64_f32(arm_rfft_fast_instance_f32 * S)76 arm_status arm_rfft_fast_init_64_f32( arm_rfft_fast_instance_f32 * S ) {
77
78 arm_status status;
79
80 if( !S ) return ARM_MATH_ARGUMENT_ERROR;
81
82 status=arm_cfft_init_32_f32(&(S->Sint));
83 if (status != ARM_MATH_SUCCESS)
84 {
85 return(status);
86 }
87 S->fftLenRFFT = 64U;
88
89 S->pTwiddleRFFT = (float32_t *) twiddleCoef_rfft_64;
90
91 return ARM_MATH_SUCCESS;
92 }
93
94 /**
95 @brief Initialization function for the 128pt floating-point real FFT.
96 @param[in,out] S points to an arm_rfft_fast_instance_f32 structure
97 @return execution status
98 - \ref ARM_MATH_SUCCESS : Operation successful
99 - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
100 */
101
arm_rfft_fast_init_128_f32(arm_rfft_fast_instance_f32 * S)102 arm_status arm_rfft_fast_init_128_f32( arm_rfft_fast_instance_f32 * S ) {
103
104 arm_status status;
105
106 if( !S ) return ARM_MATH_ARGUMENT_ERROR;
107
108 status=arm_cfft_init_64_f32(&(S->Sint));
109 if (status != ARM_MATH_SUCCESS)
110 {
111 return(status);
112 }
113 S->fftLenRFFT = 128;
114
115 S->pTwiddleRFFT = (float32_t *) twiddleCoef_rfft_128;
116
117 return ARM_MATH_SUCCESS;
118 }
119
120 /**
121 @brief Initialization function for the 256pt floating-point real FFT.
122 @param[in,out] S points to an arm_rfft_fast_instance_f32 structure
123 @return execution status
124 - \ref ARM_MATH_SUCCESS : Operation successful
125 - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
126 */
127
arm_rfft_fast_init_256_f32(arm_rfft_fast_instance_f32 * S)128 arm_status arm_rfft_fast_init_256_f32( arm_rfft_fast_instance_f32 * S ) {
129
130 arm_status status;
131
132 if( !S ) return ARM_MATH_ARGUMENT_ERROR;
133
134 status=arm_cfft_init_128_f32(&(S->Sint));
135 if (status != ARM_MATH_SUCCESS)
136 {
137 return(status);
138 }
139 S->fftLenRFFT = 256U;
140
141 S->pTwiddleRFFT = (float32_t *) twiddleCoef_rfft_256;
142
143 return ARM_MATH_SUCCESS;
144 }
145
146 /**
147 @brief Initialization function for the 512pt floating-point real FFT.
148 @param[in,out] S points to an arm_rfft_fast_instance_f32 structure
149 @return execution status
150 - \ref ARM_MATH_SUCCESS : Operation successful
151 - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
152 */
153
arm_rfft_fast_init_512_f32(arm_rfft_fast_instance_f32 * S)154 arm_status arm_rfft_fast_init_512_f32( arm_rfft_fast_instance_f32 * S ) {
155
156 arm_status status;
157
158 if( !S ) return ARM_MATH_ARGUMENT_ERROR;
159
160 status=arm_cfft_init_256_f32(&(S->Sint));
161 if (status != ARM_MATH_SUCCESS)
162 {
163 return(status);
164 }
165 S->fftLenRFFT = 512U;
166
167 S->pTwiddleRFFT = (float32_t *) twiddleCoef_rfft_512;
168
169 return ARM_MATH_SUCCESS;
170 }
171
172 /**
173 @brief Initialization function for the 1024pt floating-point real FFT.
174 @param[in,out] S points to an arm_rfft_fast_instance_f32 structure
175 @return execution status
176 - \ref ARM_MATH_SUCCESS : Operation successful
177 - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
178 */
179
arm_rfft_fast_init_1024_f32(arm_rfft_fast_instance_f32 * S)180 arm_status arm_rfft_fast_init_1024_f32( arm_rfft_fast_instance_f32 * S ) {
181
182 arm_status status;
183
184 if( !S ) return ARM_MATH_ARGUMENT_ERROR;
185
186 status=arm_cfft_init_512_f32(&(S->Sint));
187 if (status != ARM_MATH_SUCCESS)
188 {
189 return(status);
190 }
191 S->fftLenRFFT = 1024U;
192
193 S->pTwiddleRFFT = (float32_t *) twiddleCoef_rfft_1024;
194
195 return ARM_MATH_SUCCESS;
196 }
197
198 /**
199 @brief Initialization function for the 2048pt floating-point real FFT.
200 @param[in,out] S points to an arm_rfft_fast_instance_f32 structure
201 @return execution status
202 - \ref ARM_MATH_SUCCESS : Operation successful
203 - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
204 */
arm_rfft_fast_init_2048_f32(arm_rfft_fast_instance_f32 * S)205 arm_status arm_rfft_fast_init_2048_f32( arm_rfft_fast_instance_f32 * S ) {
206
207 arm_status status;
208
209 if( !S ) return ARM_MATH_ARGUMENT_ERROR;
210
211 status=arm_cfft_init_1024_f32(&(S->Sint));
212 if (status != ARM_MATH_SUCCESS)
213 {
214 return(status);
215 }
216 S->fftLenRFFT = 2048U;
217
218 S->pTwiddleRFFT = (float32_t *) twiddleCoef_rfft_2048;
219
220 return ARM_MATH_SUCCESS;
221 }
222
223 /**
224 * @brief Initialization function for the 4096pt floating-point real FFT.
225 * @param[in,out] S points to an arm_rfft_fast_instance_f32 structure
226 @return execution status
227 - \ref ARM_MATH_SUCCESS : Operation successful
228 - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
229 */
230
arm_rfft_fast_init_4096_f32(arm_rfft_fast_instance_f32 * S)231 arm_status arm_rfft_fast_init_4096_f32( arm_rfft_fast_instance_f32 * S ) {
232
233 arm_status status;
234
235 if( !S ) return ARM_MATH_ARGUMENT_ERROR;
236
237 status=arm_cfft_init_2048_f32(&(S->Sint));
238 if (status != ARM_MATH_SUCCESS)
239 {
240 return(status);
241 }
242 S->fftLenRFFT = 4096U;
243
244 S->pTwiddleRFFT = (float32_t *) twiddleCoef_rfft_4096;
245
246 return ARM_MATH_SUCCESS;
247 }
248
249 /**
250 @brief Generic initialization function for the floating-point real FFT.
251 @param[in,out] S points to an arm_rfft_fast_instance_f32 structure
252 @param[in] fftLen length of the Real Sequence
253 @return execution status
254 - \ref ARM_MATH_SUCCESS : Operation successful
255 - \ref ARM_MATH_ARGUMENT_ERROR : <code>fftLen</code> is not a supported length
256
257 @par Description
258 The parameter <code>fftLen</code> specifies the length of RFFT/CIFFT process.
259 Supported FFT Lengths are 32, 64, 128, 256, 512, 1024, 2048, 4096.
260
261 @par
262 This Function also initializes Twiddle factor table pointer and Bit reversal table pointer.
263
264 @par
265 This function should be used only if you don't know the FFT sizes that
266 you'll need at build time. The use of this function will prevent the
267 linker from removing the FFT tables that are not needed and the library
268 code size will be bigger than needed.
269
270 @par
271 If you use CMSIS-DSP as a static library, and if you know the FFT sizes
272 that you need at build time, then it is better to use the initialization
273 functions defined for each FFT size.
274
275 */
276
arm_rfft_fast_init_f32(arm_rfft_fast_instance_f32 * S,uint16_t fftLen)277 arm_status arm_rfft_fast_init_f32(
278 arm_rfft_fast_instance_f32 * S,
279 uint16_t fftLen)
280 {
281 arm_status status;
282
283
284 switch (fftLen)
285 {
286 case 4096U:
287 status = arm_rfft_fast_init_4096_f32(S);
288 break;
289 case 2048U:
290 status = arm_rfft_fast_init_2048_f32(S);
291 break;
292 case 1024U:
293 status = arm_rfft_fast_init_1024_f32(S);
294 break;
295 case 512U:
296 status = arm_rfft_fast_init_512_f32(S);
297 break;
298 case 256U:
299 status = arm_rfft_fast_init_256_f32(S);
300 break;
301 case 128U:
302 status = arm_rfft_fast_init_128_f32(S);
303 break;
304 case 64U:
305 status = arm_rfft_fast_init_64_f32(S);
306 break;
307 case 32U:
308 status = arm_rfft_fast_init_32_f32(S);
309 break;
310 default:
311 return(ARM_MATH_ARGUMENT_ERROR);
312 break;
313 }
314
315 return(status);
316
317 }
318
319 /**
320 @} end of RealFFTF32 group
321 */
322