1 /* ----------------------------------------------------------------------
2 * Project: CMSIS DSP Library
3 * Title: arm_cfft_radix4_init_q15.c
4 * Description: Radix-4 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 /**
40 @brief Initialization function for the Q15 CFFT/CIFFT.
41 @deprecated Do not use this function. It has been superseded by \ref arm_cfft_q15 and will be removed in the future.
42 @param[in,out] S points to an instance of the Q15 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
arm_cfft_radix4_init_q15(arm_cfft_radix4_instance_q15 * S,uint16_t fftLen,uint8_t ifftFlag,uint8_t bitReverseFlag)66 arm_status arm_cfft_radix4_init_q15(
67 arm_cfft_radix4_instance_q15 * S,
68 uint16_t fftLen,
69 uint8_t ifftFlag,
70 uint8_t bitReverseFlag)
71 {
72 /* Initialise the default arm status */
73 arm_status status = ARM_MATH_ARGUMENT_ERROR;
74
75 /* Initialise the default arm status */
76 status = ARM_MATH_SUCCESS;
77 /* Initialise the FFT length */
78 S->fftLen = fftLen;
79 /* Initialise the Twiddle coefficient pointer */
80 S->pTwiddle = (q15_t *) twiddleCoef_4096_q15;
81 /* Initialise the Flag for selection of CFFT or CIFFT */
82 S->ifftFlag = ifftFlag;
83 /* Initialise the Flag for calculation Bit reversal or not */
84 S->bitReverseFlag = bitReverseFlag;
85
86 /* Initializations of structure parameters depending on the FFT length */
87 switch (S->fftLen)
88 {
89 case 4096U:
90 /* Initializations of structure parameters for 4096 point FFT */
91
92 /* Initialise the twiddle coef modifier value */
93 S->twidCoefModifier = 1U;
94 /* Initialise the bit reversal table modifier */
95 S->bitRevFactor = 1U;
96 /* Initialise the bit reversal table pointer */
97 S->pBitRevTable = (uint16_t *) armBitRevTable;
98
99 break;
100
101 case 1024U:
102 /* Initializations of structure parameters for 1024 point FFT */
103 S->twidCoefModifier = 4U;
104 S->bitRevFactor = 4U;
105 S->pBitRevTable = (uint16_t *) & armBitRevTable[3];
106
107 break;
108
109 case 256U:
110 /* Initializations of structure parameters for 256 point FFT */
111 S->twidCoefModifier = 16U;
112 S->bitRevFactor = 16U;
113 S->pBitRevTable = (uint16_t *) & armBitRevTable[15];
114
115 break;
116
117 case 64U:
118 /* Initializations of structure parameters for 64 point FFT */
119 S->twidCoefModifier = 64U;
120 S->bitRevFactor = 64U;
121 S->pBitRevTable = (uint16_t *) & armBitRevTable[63];
122
123 break;
124
125 case 16U:
126 /* Initializations of structure parameters for 16 point FFT */
127 S->twidCoefModifier = 256U;
128 S->bitRevFactor = 256U;
129 S->pBitRevTable = (uint16_t *) & armBitRevTable[255];
130
131 break;
132
133 default:
134 /* Reporting argument error if fftSize is not valid value */
135 status = ARM_MATH_ARGUMENT_ERROR;
136 break;
137 }
138
139 return (status);
140 }
141
142 /**
143 @} end of ComplexFFTDeprecated group
144 */
145