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 @addtogroup ComplexFFT
36 @{
37 */
38
39 /**
40 @brief Initialization function for the cfft f64 function
41 @param[in,out] S points to an instance of the floating-point CFFT structure
42 @param[in] fftLen fft length (number of complex samples)
43 @return execution status
44 - \ref ARM_MATH_SUCCESS : Operation successful
45 - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
46
47 @par Use of this function is mandatory only for the MVE version of the FFT.
48 Other versions can still initialize directly the data structure using
49 variables declared in arm_const_structs.h
50 */
51
52 #include "dsp/transform_functions.h"
53 #include "arm_common_tables.h"
54 #include "arm_const_structs.h"
55
56
arm_cfft_init_f64(arm_cfft_instance_f64 * S,uint16_t fftLen)57 arm_status arm_cfft_init_f64(
58 arm_cfft_instance_f64 * S,
59 uint16_t fftLen)
60 {
61 /* Initialise the default arm status */
62 arm_status status = ARM_MATH_SUCCESS;
63
64 /* Initialise the FFT length */
65 S->fftLen = fftLen;
66
67 /* Initialise the Twiddle coefficient pointer */
68 S->pTwiddle = NULL;
69
70
71 /* Initializations of Instance structure depending on the FFT length */
72 switch (S->fftLen) {
73 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_f64_4096) && defined(ARM_TABLE_BITREVIDX_FLT_4096))
74 /* Initializations of structure parameters for 4096 point FFT */
75 case 4096U:
76 /* Initialise the bit reversal table modifier */
77 FFTINIT(f64,4096);
78 break;
79 #endif
80
81 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_f64_2048) && defined(ARM_TABLE_BITREVIDX_FLT_2048))
82 /* Initializations of structure parameters for 2048 point FFT */
83 case 2048U:
84 /* Initialise the bit reversal table modifier */
85 FFTINIT(f64,2048);
86
87 break;
88 #endif
89
90 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_f64_1024) && defined(ARM_TABLE_BITREVIDX_FLT_1024))
91 /* Initializations of structure parameters for 1024 point FFT */
92 case 1024U:
93 /* Initialise the bit reversal table modifier */
94 FFTINIT(f64,1024);
95
96 break;
97 #endif
98
99 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_f64_512) && defined(ARM_TABLE_BITREVIDX_FLT_512))
100 /* Initializations of structure parameters for 512 point FFT */
101 case 512U:
102 /* Initialise the bit reversal table modifier */
103 FFTINIT(f64,512);
104 break;
105 #endif
106
107 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_f64_256) && defined(ARM_TABLE_BITREVIDX_FLT_256))
108 case 256U:
109 FFTINIT(f64,256);
110 break;
111 #endif
112
113 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_f64_128) && defined(ARM_TABLE_BITREVIDX_FLT_128))
114 case 128U:
115 FFTINIT(f64,128);
116 break;
117 #endif
118
119 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_f64_64) && defined(ARM_TABLE_BITREVIDX_FLT_64))
120 case 64U:
121 FFTINIT(f64,64);
122 break;
123 #endif
124
125 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_f64_32) && defined(ARM_TABLE_BITREVIDX_FLT_32))
126 case 32U:
127 FFTINIT(f64,32);
128 break;
129 #endif
130
131 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_f64_16) && defined(ARM_TABLE_BITREVIDX_FLT_16))
132 case 16U:
133 /* Initializations of structure parameters for 16 point FFT */
134 FFTINIT(f64,16);
135 break;
136 #endif
137
138 default:
139 /* Reporting argument error if fftSize is not valid value */
140 status = ARM_MATH_ARGUMENT_ERROR;
141 break;
142 }
143
144
145 return (status);
146 }
147
148 /**
149 @} end of ComplexFFT group
150 */
151