]> git.gir.st - tmk_keyboard.git/blob - tmk_core/tool/mbed/mbed-sdk/libraries/dsp/cmsis_dsp/TransformFunctions/arm_rfft_fast_init_f32.c
Merge commit '1fe4406f374291ab2e86e95a97341fd9c475fcb8'
[tmk_keyboard.git] / tmk_core / tool / mbed / mbed-sdk / libraries / dsp / cmsis_dsp / TransformFunctions / arm_rfft_fast_init_f32.c
1 /* ----------------------------------------------------------------------
2 * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
3 *
4 * $Date: 17. January 2013
5 * $Revision: V1.4.1
6 *
7 * Project: CMSIS DSP Library
8 * Title: arm_cfft_init_f32.c
9 *
10 * Description: Split Radix Decimation in Frequency CFFT Floating point processing function
11 *
12 * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 * - Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 * - Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in
21 * the documentation and/or other materials provided with the
22 * distribution.
23 * - Neither the name of ARM LIMITED nor the names of its contributors
24 * may be used to endorse or promote products derived from this
25 * software without specific prior written permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
30 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
31 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
32 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
33 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
34 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
35 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
37 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 * POSSIBILITY OF SUCH DAMAGE.
39 * -------------------------------------------------------------------- */
40
41 #include "arm_math.h"
42 #include "arm_common_tables.h"
43
44 /**
45 * @ingroup groupTransforms
46 */
47
48 /**
49 * @addtogroup RealFFT
50 * @{
51 */
52
53 /**
54 * @brief Initialization function for the floating-point real FFT.
55 * @param[in,out] *S points to an arm_rfft_fast_instance_f32 structure.
56 * @param[in] fftLen length of the Real Sequence.
57 * @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.
58 *
59 * \par Description:
60 * \par
61 * The parameter <code>ifftFlag</code> controls whether a forward or inverse transform is computed.
62 * Set(=1) ifftFlag for calculation of CIFFT otherwise RFFT is calculated
63 * \par
64 * The parameter <code>bitReverseFlag</code> controls whether output is in normal order or bit reversed order.
65 * Set(=1) bitReverseFlag for output to be in normal order otherwise output is in bit reversed order.
66 * \par
67 * The parameter <code>fftLen</code> Specifies length of RFFT/CIFFT process. Supported FFT Lengths are 16, 32, 64, 128, 256, 512, 1024, 2048, 4096.
68 * \par
69 * This Function also initializes Twiddle factor table pointer and Bit reversal table pointer.
70 */
71 arm_status arm_rfft_fast_init_f32(
72 arm_rfft_fast_instance_f32 * S,
73 uint16_t fftLen)
74 {
75 arm_cfft_instance_f32 * Sint;
76 /* Initialise the default arm status */
77 arm_status status = ARM_MATH_SUCCESS;
78 /* Initialise the FFT length */
79 Sint = &(S->Sint);
80 Sint->fftLen = fftLen/2;
81 S->fftLenRFFT = fftLen;
82 /* Initialise the Twiddle coefficient pointer */
83 // S->pTwiddle = (float32_t *) twiddleCoef;
84
85 /* Initializations of structure parameters depending on the FFT length */
86 switch (Sint->fftLen)
87 {
88 case 4096u:
89 /* Initializations of structure parameters for 4096 point FFT */
90 /* Initialise the bit reversal table length */
91 Sint->bitRevLength = ARMBITREVINDEXTABLE4096_TABLE_LENGTH;
92 /* Initialise the bit reversal table pointer */
93 Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable4096;
94 /* Initialise the 1/fftLen Value */
95 break;
96 case 2048u:
97 Sint->bitRevLength = ARMBITREVINDEXTABLE2048_TABLE_LENGTH;
98 Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable2048;
99 break;
100 case 1024u:
101 Sint->bitRevLength = ARMBITREVINDEXTABLE1024_TABLE_LENGTH;
102 Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable1024;
103 break;
104 case 512u:
105 Sint->bitRevLength = ARMBITREVINDEXTABLE_512_TABLE_LENGTH;
106 Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable512;
107 break;
108 case 256u:
109 Sint->bitRevLength = ARMBITREVINDEXTABLE_256_TABLE_LENGTH;
110 Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable256;
111 break;
112 case 128u:
113 Sint->bitRevLength = ARMBITREVINDEXTABLE_128_TABLE_LENGTH;
114 Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable128;
115 break;
116 case 64u:
117 Sint->bitRevLength = ARMBITREVINDEXTABLE__64_TABLE_LENGTH;
118 Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable64;
119 break;
120 case 32u:
121 Sint->bitRevLength = ARMBITREVINDEXTABLE__32_TABLE_LENGTH;
122 Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable32;
123 break;
124 case 16u:
125 Sint->bitRevLength = ARMBITREVINDEXTABLE__16_TABLE_LENGTH;
126 Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable16;
127 break;
128 default:
129 /* Reporting argument error if fftSize is not valid value */
130 status = ARM_MATH_ARGUMENT_ERROR;
131 break;
132 }
133
134 return (status);
135 }
136
137 /**
138 * @} end of RealFFT group
139 */
Imprint / Impressum