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