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