1 /* ----------------------------------------------------------------------
2 * Project: CMSIS DSP Library
3 * Title: arm_cfft_init_f64.c
4 * Description: Initialization function for cfft f64 instance
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 #define FFTINIT(EXT,SIZE) \
30 S->bitRevLength = arm_cfft_sR_##EXT##_len##SIZE.bitRevLength; \
31 S->pBitRevTable = arm_cfft_sR_##EXT##_len##SIZE.pBitRevTable; \
32 S->pTwiddle = arm_cfft_sR_##EXT##_len##SIZE.pTwiddle;
33
34 /**
35 * @defgroup ComplexFFTF64 Complex FFT F64
36 */
37
38 /**
39 @ingroup groupTransforms
40 */
41
42 /**
43 @addtogroup ComplexFFT
44 @{
45 */
46
47 /**
48 @addtogroup ComplexFFTF64
49 @{
50 */
51
52
53 #include "dsp/transform_functions.h"
54 #include "arm_common_tables.h"
55 #include "arm_const_structs.h"
56
57
58 #define CFFTINIT_F64(LEN) \
59 arm_status arm_cfft_init_##LEN##_f64(arm_cfft_instance_f64 * S)\
60 { \
61 /* Initialise the default arm status */ \
62 arm_status status = ARM_MATH_SUCCESS; \
63 \
64 /* Initialise the FFT length */ \
65 S->fftLen = LEN; \
66 \
67 /* Initialise the Twiddle coefficient pointer */ \
68 S->pTwiddle = NULL; \
69 \
70 FFTINIT(f64,LEN); \
71 \
72 return (status); \
73 };
74
75 /**
76 @brief Initialization function for the cfft f64 function with 4096 samples
77 @param[in,out] S points to an instance of the floating-point CFFT structure
78 @return execution status
79 - \ref ARM_MATH_SUCCESS : Operation successful
80 - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
81
82 @par Use of this function is mandatory only for the MVE version of the FFT.
83 Other versions can still initialize directly the data structure using
84 variables declared in arm_const_structs.h
85 */
86 CFFTINIT_F64(4096);
87
88 /**
89 @brief Initialization function for the cfft f64 function with 2048 samples
90 @param[in,out] S points to an instance of the floating-point CFFT structure
91 @return execution status
92 - \ref ARM_MATH_SUCCESS : Operation successful
93 - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
94
95 @par Use of this function is mandatory only for the MVE version of the FFT.
96 Other versions can still initialize directly the data structure using
97 variables declared in arm_const_structs.h
98 */
99 CFFTINIT_F64(2048);
100
101
102 /**
103 @brief Initialization function for the cfft f64 function with 1024 samples
104 @param[in,out] S points to an instance of the floating-point CFFT structure
105 @return execution status
106 - \ref ARM_MATH_SUCCESS : Operation successful
107 - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
108
109 @par Use of this function is mandatory only for the MVE version of the FFT.
110 Other versions can still initialize directly the data structure using
111 variables declared in arm_const_structs.h
112 */
113 CFFTINIT_F64(1024);
114
115 /**
116 @brief Initialization function for the cfft f64 function with 512 samples
117 @param[in,out] S points to an instance of the floating-point CFFT structure
118 @return execution status
119 - \ref ARM_MATH_SUCCESS : Operation successful
120 - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
121
122 @par Use of this function is mandatory only for the MVE version of the FFT.
123 Other versions can still initialize directly the data structure using
124 variables declared in arm_const_structs.h
125 */
126 CFFTINIT_F64(512);
127
128 /**
129 @brief Initialization function for the cfft f64 function with 256 samples
130 @param[in,out] S points to an instance of the floating-point CFFT structure
131 @return execution status
132 - \ref ARM_MATH_SUCCESS : Operation successful
133 - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
134
135 @par Use of this function is mandatory only for the MVE version of the FFT.
136 Other versions can still initialize directly the data structure using
137 variables declared in arm_const_structs.h
138 */
139 CFFTINIT_F64(256);
140
141 /**
142 @brief Initialization function for the cfft f64 function with 128 samples
143 @param[in,out] S points to an instance of the floating-point CFFT structure
144 @return execution status
145 - \ref ARM_MATH_SUCCESS : Operation successful
146 - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
147
148 @par Use of this function is mandatory only for the MVE version of the FFT.
149 Other versions can still initialize directly the data structure using
150 variables declared in arm_const_structs.h
151 */
152 CFFTINIT_F64(128);
153
154 /**
155 @brief Initialization function for the cfft f64 function with 64 samples
156 @param[in,out] S points to an instance of the floating-point CFFT structure
157 @return execution status
158 - \ref ARM_MATH_SUCCESS : Operation successful
159 - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
160
161 @par Use of this function is mandatory only for the MVE version of the FFT.
162 Other versions can still initialize directly the data structure using
163 variables declared in arm_const_structs.h
164 */
165 CFFTINIT_F64(64);
166
167 /**
168 @brief Initialization function for the cfft f64 function with 32 samples
169 @param[in,out] S points to an instance of the floating-point CFFT structure
170 @return execution status
171 - \ref ARM_MATH_SUCCESS : Operation successful
172 - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
173
174 @par Use of this function is mandatory only for the MVE version of the FFT.
175 Other versions can still initialize directly the data structure using
176 variables declared in arm_const_structs.h
177 */
178 CFFTINIT_F64(32);
179
180 /**
181 @brief Initialization function for the cfft f64 function with 16 samples
182 @param[in,out] S points to an instance of the floating-point CFFT structure
183 @return execution status
184 - \ref ARM_MATH_SUCCESS : Operation successful
185 - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
186
187 @par Use of this function is mandatory only for the MVE version of the FFT.
188 Other versions can still initialize directly the data structure using
189 variables declared in arm_const_structs.h
190 */
191 CFFTINIT_F64(16);
192
193 /**
194 @brief Generic initialization function for the cfft f64 function
195 @param[in,out] S points to an instance of the floating-point CFFT structure
196 @param[in] fftLen fft length (number of complex samples)
197 @return execution status
198 - \ref ARM_MATH_SUCCESS : Operation successful
199 - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
200
201 @par Use of this function is mandatory only for the MVE version of the FFT.
202 Other versions can still initialize directly the data structure using
203 variables declared in arm_const_structs.h
204
205 @par This function should be used only if you don't know the FFT sizes that
206 you'll need at build time. The use of this function will prevent the
207 linker from removing the FFT tables that are not needed and the library
208 code size will be bigger than needed.
209
210 @par If you use CMSIS-DSP as a static library, and if you know the FFT sizes
211 that you need at build time, then it is better to use the initialization
212 functions defined for each FFT size.
213
214 */
arm_cfft_init_f64(arm_cfft_instance_f64 * S,uint16_t fftLen)215 arm_status arm_cfft_init_f64(
216 arm_cfft_instance_f64 * S,
217 uint16_t fftLen)
218 {
219 /* Initialise the default arm status */
220 arm_status status = ARM_MATH_SUCCESS;
221
222 /* Initializations of Instance structure depending on the FFT length */
223 switch (fftLen) {
224 /* Initializations of structure parameters for 4096 point FFT */
225 case 4096U:
226 /* Initialise the bit reversal table modifier */
227 status = arm_cfft_init_4096_f64(S);
228 break;
229
230 /* Initializations of structure parameters for 2048 point FFT */
231 case 2048U:
232 /* Initialise the bit reversal table modifier */
233 status = arm_cfft_init_2048_f64(S);
234
235 break;
236
237 /* Initializations of structure parameters for 1024 point FFT */
238 case 1024U:
239 /* Initialise the bit reversal table modifier */
240 status = arm_cfft_init_1024_f64(S);
241
242 break;
243
244 /* Initializations of structure parameters for 512 point FFT */
245 case 512U:
246 /* Initialise the bit reversal table modifier */
247 status = arm_cfft_init_512_f64(S);
248 break;
249
250 case 256U:
251 status = arm_cfft_init_256_f64(S);
252 break;
253
254 case 128U:
255 status = arm_cfft_init_128_f64(S);
256 break;
257
258 case 64U:
259 status = arm_cfft_init_64_f64(S);
260 break;
261
262 case 32U:
263 status = arm_cfft_init_32_f64(S);
264 break;
265
266 case 16U:
267 /* Initializations of structure parameters for 16 point FFT */
268 status = arm_cfft_init_16_f64(S);
269 break;
270
271 default:
272 /* Reporting argument error if fftSize is not valid value */
273 status = ARM_MATH_ARGUMENT_ERROR;
274 break;
275 }
276
277
278 return (status);
279 }
280 /**
281 @} end of ComplexFFTF64 group
282 */
283
284 /**
285 @} end of ComplexFFT group
286 */