annotate f103c8/Drivers/CMSIS/DSP_Lib/Source/TransformFunctions/arm_bitreversal.c @ 2:0c59e7a7782a

Working on GPIO and RCC
author cin
date Mon, 16 Jan 2017 11:04:47 +0300
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
1 /* ----------------------------------------------------------------------
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
2 * Copyright (C) 2010-2014 ARM Limited. All rights reserved.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
3 *
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
4 * $Date: 19. March 2015
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
5 * $Revision: V.1.4.5
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
6 *
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
7 * Project: CMSIS DSP Library
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
8 * Title: arm_bitreversal.c
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
9 *
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
10 * Description: This file has common tables like Bitreverse, reciprocal etc which are used across different functions
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
11 *
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
12 * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
13 *
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
14 * Redistribution and use in source and binary forms, with or without
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
15 * modification, are permitted provided that the following conditions
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
16 * are met:
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
17 * - Redistributions of source code must retain the above copyright
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
18 * notice, this list of conditions and the following disclaimer.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
19 * - Redistributions in binary form must reproduce the above copyright
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
20 * notice, this list of conditions and the following disclaimer in
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
21 * the documentation and/or other materials provided with the
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
22 * distribution.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
23 * - Neither the name of ARM LIMITED nor the names of its contributors
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
24 * may be used to endorse or promote products derived from this
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
25 * software without specific prior written permission.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
26 *
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
28 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
29 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
30 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
31 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
32 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
33 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
34 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
35 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
37 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
38 * POSSIBILITY OF SUCH DAMAGE.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
39 * -------------------------------------------------------------------- */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
40
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
41 #include "arm_math.h"
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
42 #include "arm_common_tables.h"
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
43
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
44 /*
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
45 * @brief In-place bit reversal function.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
46 * @param[in, out] *pSrc points to the in-place buffer of floating-point data type.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
47 * @param[in] fftSize length of the FFT.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
48 * @param[in] bitRevFactor bit reversal modifier that supports different size FFTs with the same bit reversal table.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
49 * @param[in] *pBitRevTab points to the bit reversal table.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
50 * @return none.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
51 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
52
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
53 void arm_bitreversal_f32(
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
54 float32_t * pSrc,
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
55 uint16_t fftSize,
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
56 uint16_t bitRevFactor,
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
57 uint16_t * pBitRevTab)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
58 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
59 uint16_t fftLenBy2, fftLenBy2p1;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
60 uint16_t i, j;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
61 float32_t in;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
62
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
63 /* Initializations */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
64 j = 0u;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
65 fftLenBy2 = fftSize >> 1u;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
66 fftLenBy2p1 = (fftSize >> 1u) + 1u;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
67
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
68 /* Bit Reversal Implementation */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
69 for (i = 0u; i <= (fftLenBy2 - 2u); i += 2u)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
70 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
71 if(i < j)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
72 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
73 /* pSrc[i] <-> pSrc[j]; */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
74 in = pSrc[2u * i];
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
75 pSrc[2u * i] = pSrc[2u * j];
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
76 pSrc[2u * j] = in;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
77
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
78 /* pSrc[i+1u] <-> pSrc[j+1u] */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
79 in = pSrc[(2u * i) + 1u];
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
80 pSrc[(2u * i) + 1u] = pSrc[(2u * j) + 1u];
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
81 pSrc[(2u * j) + 1u] = in;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
82
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
83 /* pSrc[i+fftLenBy2p1] <-> pSrc[j+fftLenBy2p1] */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
84 in = pSrc[2u * (i + fftLenBy2p1)];
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
85 pSrc[2u * (i + fftLenBy2p1)] = pSrc[2u * (j + fftLenBy2p1)];
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
86 pSrc[2u * (j + fftLenBy2p1)] = in;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
87
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
88 /* pSrc[i+fftLenBy2p1+1u] <-> pSrc[j+fftLenBy2p1+1u] */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
89 in = pSrc[(2u * (i + fftLenBy2p1)) + 1u];
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
90 pSrc[(2u * (i + fftLenBy2p1)) + 1u] =
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
91 pSrc[(2u * (j + fftLenBy2p1)) + 1u];
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
92 pSrc[(2u * (j + fftLenBy2p1)) + 1u] = in;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
93
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
94 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
95
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
96 /* pSrc[i+1u] <-> pSrc[j+1u] */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
97 in = pSrc[2u * (i + 1u)];
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
98 pSrc[2u * (i + 1u)] = pSrc[2u * (j + fftLenBy2)];
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
99 pSrc[2u * (j + fftLenBy2)] = in;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
100
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
101 /* pSrc[i+2u] <-> pSrc[j+2u] */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
102 in = pSrc[(2u * (i + 1u)) + 1u];
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
103 pSrc[(2u * (i + 1u)) + 1u] = pSrc[(2u * (j + fftLenBy2)) + 1u];
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
104 pSrc[(2u * (j + fftLenBy2)) + 1u] = in;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
105
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
106 /* Reading the index for the bit reversal */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
107 j = *pBitRevTab;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
108
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
109 /* Updating the bit reversal index depending on the fft length */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
110 pBitRevTab += bitRevFactor;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
111 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
112 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
113
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
114
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
115
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
116 /*
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
117 * @brief In-place bit reversal function.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
118 * @param[in, out] *pSrc points to the in-place buffer of Q31 data type.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
119 * @param[in] fftLen length of the FFT.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
120 * @param[in] bitRevFactor bit reversal modifier that supports different size FFTs with the same bit reversal table
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
121 * @param[in] *pBitRevTab points to bit reversal table.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
122 * @return none.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
123 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
124
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
125 void arm_bitreversal_q31(
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
126 q31_t * pSrc,
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
127 uint32_t fftLen,
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
128 uint16_t bitRevFactor,
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
129 uint16_t * pBitRevTable)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
130 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
131 uint32_t fftLenBy2, fftLenBy2p1, i, j;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
132 q31_t in;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
133
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
134 /* Initializations */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
135 j = 0u;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
136 fftLenBy2 = fftLen / 2u;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
137 fftLenBy2p1 = (fftLen / 2u) + 1u;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
138
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
139 /* Bit Reversal Implementation */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
140 for (i = 0u; i <= (fftLenBy2 - 2u); i += 2u)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
141 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
142 if(i < j)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
143 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
144 /* pSrc[i] <-> pSrc[j]; */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
145 in = pSrc[2u * i];
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
146 pSrc[2u * i] = pSrc[2u * j];
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
147 pSrc[2u * j] = in;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
148
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
149 /* pSrc[i+1u] <-> pSrc[j+1u] */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
150 in = pSrc[(2u * i) + 1u];
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
151 pSrc[(2u * i) + 1u] = pSrc[(2u * j) + 1u];
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
152 pSrc[(2u * j) + 1u] = in;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
153
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
154 /* pSrc[i+fftLenBy2p1] <-> pSrc[j+fftLenBy2p1] */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
155 in = pSrc[2u * (i + fftLenBy2p1)];
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
156 pSrc[2u * (i + fftLenBy2p1)] = pSrc[2u * (j + fftLenBy2p1)];
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
157 pSrc[2u * (j + fftLenBy2p1)] = in;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
158
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
159 /* pSrc[i+fftLenBy2p1+1u] <-> pSrc[j+fftLenBy2p1+1u] */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
160 in = pSrc[(2u * (i + fftLenBy2p1)) + 1u];
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
161 pSrc[(2u * (i + fftLenBy2p1)) + 1u] =
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
162 pSrc[(2u * (j + fftLenBy2p1)) + 1u];
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
163 pSrc[(2u * (j + fftLenBy2p1)) + 1u] = in;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
164
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
165 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
166
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
167 /* pSrc[i+1u] <-> pSrc[j+1u] */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
168 in = pSrc[2u * (i + 1u)];
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
169 pSrc[2u * (i + 1u)] = pSrc[2u * (j + fftLenBy2)];
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
170 pSrc[2u * (j + fftLenBy2)] = in;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
171
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
172 /* pSrc[i+2u] <-> pSrc[j+2u] */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
173 in = pSrc[(2u * (i + 1u)) + 1u];
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
174 pSrc[(2u * (i + 1u)) + 1u] = pSrc[(2u * (j + fftLenBy2)) + 1u];
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
175 pSrc[(2u * (j + fftLenBy2)) + 1u] = in;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
176
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
177 /* Reading the index for the bit reversal */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
178 j = *pBitRevTable;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
179
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
180 /* Updating the bit reversal index depending on the fft length */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
181 pBitRevTable += bitRevFactor;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
182 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
183 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
184
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
185
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
186
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
187 /*
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
188 * @brief In-place bit reversal function.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
189 * @param[in, out] *pSrc points to the in-place buffer of Q15 data type.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
190 * @param[in] fftLen length of the FFT.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
191 * @param[in] bitRevFactor bit reversal modifier that supports different size FFTs with the same bit reversal table
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
192 * @param[in] *pBitRevTab points to bit reversal table.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
193 * @return none.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
194 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
195
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
196 void arm_bitreversal_q15(
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
197 q15_t * pSrc16,
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
198 uint32_t fftLen,
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
199 uint16_t bitRevFactor,
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
200 uint16_t * pBitRevTab)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
201 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
202 q31_t *pSrc = (q31_t *) pSrc16;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
203 q31_t in;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
204 uint32_t fftLenBy2, fftLenBy2p1;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
205 uint32_t i, j;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
206
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
207 /* Initializations */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
208 j = 0u;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
209 fftLenBy2 = fftLen / 2u;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
210 fftLenBy2p1 = (fftLen / 2u) + 1u;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
211
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
212 /* Bit Reversal Implementation */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
213 for (i = 0u; i <= (fftLenBy2 - 2u); i += 2u)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
214 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
215 if(i < j)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
216 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
217 /* pSrc[i] <-> pSrc[j]; */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
218 /* pSrc[i+1u] <-> pSrc[j+1u] */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
219 in = pSrc[i];
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
220 pSrc[i] = pSrc[j];
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
221 pSrc[j] = in;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
222
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
223 /* pSrc[i + fftLenBy2p1] <-> pSrc[j + fftLenBy2p1]; */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
224 /* pSrc[i + fftLenBy2p1+1u] <-> pSrc[j + fftLenBy2p1+1u] */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
225 in = pSrc[i + fftLenBy2p1];
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
226 pSrc[i + fftLenBy2p1] = pSrc[j + fftLenBy2p1];
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
227 pSrc[j + fftLenBy2p1] = in;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
228 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
229
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
230 /* pSrc[i+1u] <-> pSrc[j+fftLenBy2]; */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
231 /* pSrc[i+2] <-> pSrc[j+fftLenBy2+1u] */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
232 in = pSrc[i + 1u];
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
233 pSrc[i + 1u] = pSrc[j + fftLenBy2];
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
234 pSrc[j + fftLenBy2] = in;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
235
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
236 /* Reading the index for the bit reversal */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
237 j = *pBitRevTab;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
238
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
239 /* Updating the bit reversal index depending on the fft length */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
240 pBitRevTab += bitRevFactor;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
241 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
242 }