Subversion Repositories dashGPS

Rev

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_f32.c
4
 * Description:  Radix-2 Decimation in Frequency Floating-point CFFT & CIFFT 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
 * @addtogroup ComplexFFT
38
 * @{
39
 */
40
 
41
/**
42
* @brief  Initialization function for the floating-point CFFT/CIFFT.
43
* @deprecated Do not use this function.  It has been superseded by \ref arm_cfft_f32 and will be removed
44
* in the future.
45
* @param[in,out] *S             points to an instance of the floating-point 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
arm_status arm_cfft_radix2_init_f32(
64
  arm_cfft_radix2_instance_f32 * S,
65
  uint16_t fftLen,
66
  uint8_t ifftFlag,
67
  uint8_t bitReverseFlag)
68
{
69
  /*  Initialise the default arm status */
70
  arm_status status = ARM_MATH_SUCCESS;
71
 
72
  /*  Initialise the FFT length */
73
  S->fftLen = fftLen;
74
 
75
  /*  Initialise the Twiddle coefficient pointer */
76
  S->pTwiddle = (float32_t *) twiddleCoef;
77
 
78
  /*  Initialise the Flag for selection of CFFT or CIFFT */
79
  S->ifftFlag = ifftFlag;
80
 
81
  /*  Initialise the Flag for calculation Bit reversal or not */
82
  S->bitReverseFlag = bitReverseFlag;
83
 
84
  /*  Initializations of structure parameters depending on the FFT length */
85
  switch (S->fftLen)
86
  {
87
 
88
  case 4096U:
89
    /*  Initializations of structure parameters for 4096 point FFT */
90
 
91
    /*  Initialise the twiddle coef modifier value */
92
    S->twidCoefModifier = 1U;
93
    /*  Initialise the bit reversal table modifier */
94
    S->bitRevFactor = 1U;
95
    /*  Initialise the bit reversal table pointer */
96
    S->pBitRevTable = (uint16_t *) armBitRevTable;
97
    /*  Initialise the 1/fftLen Value */
98
    S->onebyfftLen = 0.000244140625;
99
    break;
100
 
101
  case 2048U:
102
    /*  Initializations of structure parameters for 2048 point FFT */
103
 
104
    /*  Initialise the twiddle coef modifier value */
105
    S->twidCoefModifier = 2U;
106
    /*  Initialise the bit reversal table modifier */
107
    S->bitRevFactor = 2U;
108
    /*  Initialise the bit reversal table pointer */
109
    S->pBitRevTable = (uint16_t *) & armBitRevTable[1];
110
    /*  Initialise the 1/fftLen Value */
111
    S->onebyfftLen = 0.00048828125;
112
    break;
113
 
114
  case 1024U:
115
    /*  Initializations of structure parameters for 1024 point FFT */
116
 
117
    /*  Initialise the twiddle coef modifier value */
118
    S->twidCoefModifier = 4U;
119
    /*  Initialise the bit reversal table modifier */
120
    S->bitRevFactor = 4U;
121
    /*  Initialise the bit reversal table pointer */
122
    S->pBitRevTable = (uint16_t *) & armBitRevTable[3];
123
    /*  Initialise the 1/fftLen Value */
124
    S->onebyfftLen = 0.0009765625f;
125
    break;
126
 
127
  case 512U:
128
    /*  Initializations of structure parameters for 512 point FFT */
129
 
130
    /*  Initialise the twiddle coef modifier value */
131
    S->twidCoefModifier = 8U;
132
    /*  Initialise the bit reversal table modifier */
133
    S->bitRevFactor = 8U;
134
    /*  Initialise the bit reversal table pointer */
135
    S->pBitRevTable = (uint16_t *) & armBitRevTable[7];
136
    /*  Initialise the 1/fftLen Value */
137
    S->onebyfftLen = 0.001953125;
138
    break;
139
 
140
  case 256U:
141
    /*  Initializations of structure parameters for 256 point FFT */
142
    S->twidCoefModifier = 16U;
143
    S->bitRevFactor = 16U;
144
    S->pBitRevTable = (uint16_t *) & armBitRevTable[15];
145
    S->onebyfftLen = 0.00390625f;
146
    break;
147
 
148
  case 128U:
149
    /*  Initializations of structure parameters for 128 point FFT */
150
    S->twidCoefModifier = 32U;
151
    S->bitRevFactor = 32U;
152
    S->pBitRevTable = (uint16_t *) & armBitRevTable[31];
153
    S->onebyfftLen = 0.0078125;
154
    break;
155
 
156
  case 64U:
157
    /*  Initializations of structure parameters for 64 point FFT */
158
    S->twidCoefModifier = 64U;
159
    S->bitRevFactor = 64U;
160
    S->pBitRevTable = (uint16_t *) & armBitRevTable[63];
161
    S->onebyfftLen = 0.015625f;
162
    break;
163
 
164
  case 32U:
165
    /*  Initializations of structure parameters for 64 point FFT */
166
    S->twidCoefModifier = 128U;
167
    S->bitRevFactor = 128U;
168
    S->pBitRevTable = (uint16_t *) & armBitRevTable[127];
169
    S->onebyfftLen = 0.03125;
170
    break;
171
 
172
  case 16U:
173
    /*  Initializations of structure parameters for 16 point FFT */
174
    S->twidCoefModifier = 256U;
175
    S->bitRevFactor = 256U;
176
    S->pBitRevTable = (uint16_t *) & armBitRevTable[255];
177
    S->onebyfftLen = 0.0625f;
178
    break;
179
 
180
 
181
  default:
182
    /*  Reporting argument error if fftSize is not valid value */
183
    status = ARM_MATH_ARGUMENT_ERROR;
184
    break;
185
  }
186
 
187
  return (status);
188
}
189
 
190
/**
191
 * @} end of ComplexFFT group
192
 */