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 @par
261 This Function also initializes Twiddle factor table pointer and Bit reversal table pointer.
262
263 @par
264 This function should be used only if you don't know the FFT sizes that
265 you'll need at build time. The use of this function will prevent the
266 linker from removing the FFT tables that are not needed and the library
267 code size will be bigger than needed.
268
269 @par
270 If you use CMSIS-DSP as a static library, and if you know the FFT sizes
271 that you need at build time, then it is better to use the initialization
272 functions defined for each FFT size.
273
274 */
275
arm_rfft_fast_init_f32(arm_rfft_fast_instance_f32 * S,uint16_t fftLen)276 arm_status arm_rfft_fast_init_f32(
277 arm_rfft_fast_instance_f32 * S,
278 uint16_t fftLen)
279 {
280 arm_status status;
281
282
283 switch (fftLen)
284 {
285 case 4096U:
286 status = arm_rfft_fast_init_4096_f32(S);
287 break;
288 case 2048U:
289 status = arm_rfft_fast_init_2048_f32(S);
290 break;
291 case 1024U:
292 status = arm_rfft_fast_init_1024_f32(S);
293 break;
294 case 512U:
295 status = arm_rfft_fast_init_512_f32(S);
296 break;
297 case 256U:
298 status = arm_rfft_fast_init_256_f32(S);
299 break;
300 case 128U:
301 status = arm_rfft_fast_init_128_f32(S);
302 break;
303 case 64U:
304 status = arm_rfft_fast_init_64_f32(S);
305 break;
306 case 32U:
307 status = arm_rfft_fast_init_32_f32(S);
308 break;
309 default:
310 return(ARM_MATH_ARGUMENT_ERROR);
311 break;
312 }
313
314 return(status);
315
316 }
317
318 /**
319 @} end of RealFFTF32 group
320 */
321