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