1 /* ----------------------------------------------------------------------
2 * Project: CMSIS DSP Library
3 * Title: arm_rfft_init_f32.c
4 * Description: RFFT & RIFFT Floating point initialisation 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 RealFFT
35 @{
36 */
37
38 /**
39 @brief Initialization function for the floating-point RFFT/RIFFT.
40 @deprecated Do not use this function. It has been superceded by \ref arm_rfft_fast_init_f32 and will be removed in the future.
41 @param[in,out] S points to an instance of the floating-point RFFT/RIFFT structure
42 @param[in,out] S_CFFT points to an instance of the floating-point CFFT/CIFFT structure
43 @param[in] fftLenReal length of the FFT.
44 @param[in] ifftFlagR 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>fftLenReal</code> is not a supported length
53
54 @par Description
55 The parameter <code>fftLenReal</code>specifies length of RFFT/RIFFT Process.
56 Supported FFT Lengths are 128, 512, 2048.
57 @par
58 The parameter <code>ifftFlagR</code> controls whether a forward or inverse transform is computed.
59 Set(=1) ifftFlagR to calculate RIFFT, otherwise RFFT is calculated.
60 @par
61 The parameter <code>bitReverseFlag</code> controls whether output is in normal order or bit reversed order.
62 Set(=1) bitReverseFlag for output to be in normal order otherwise output is in bit reversed order.
63 @par
64 This function also initializes Twiddle factor table.
65 */
66
arm_rfft_init_f32(arm_rfft_instance_f32 * S,arm_cfft_radix4_instance_f32 * S_CFFT,uint32_t fftLenReal,uint32_t ifftFlagR,uint32_t bitReverseFlag)67 arm_status arm_rfft_init_f32(
68 arm_rfft_instance_f32 * S,
69 arm_cfft_radix4_instance_f32 * S_CFFT,
70 uint32_t fftLenReal,
71 uint32_t ifftFlagR,
72 uint32_t bitReverseFlag)
73 {
74 /* Initialise the default arm status */
75 arm_status status = ARM_MATH_ARGUMENT_ERROR;
76
77 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_FFT_ALLOW_TABLES)
78
79 #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_REALCOEF_F32)
80
81 /* Initialise the default arm status */
82 status = ARM_MATH_SUCCESS;
83
84 /* Initialize the Real FFT length */
85 S->fftLenReal = (uint16_t) fftLenReal;
86
87 /* Initialize the Complex FFT length */
88 S->fftLenBy2 = (uint16_t) fftLenReal / 2U;
89
90 /* Initialize the Twiddle coefficientA pointer */
91 S->pTwiddleAReal = (float32_t *) realCoefA;
92
93 /* Initialize the Twiddle coefficientB pointer */
94 S->pTwiddleBReal = (float32_t *) realCoefB;
95
96 /* Initialize the Flag for selection of RFFT or RIFFT */
97 S->ifftFlagR = (uint8_t) ifftFlagR;
98
99 /* Initialize the Flag for calculation Bit reversal or not */
100 S->bitReverseFlagR = (uint8_t) bitReverseFlag;
101
102 /* Initializations of structure parameters depending on the FFT length */
103 switch (S->fftLenReal)
104 {
105 /* Init table modifier value */
106 case 8192U:
107 S->twidCoefRModifier = 1U;
108 break;
109 case 2048U:
110 S->twidCoefRModifier = 4U;
111 break;
112 case 512U:
113 S->twidCoefRModifier = 16U;
114 break;
115 case 128U:
116 S->twidCoefRModifier = 64U;
117 break;
118 default:
119 /* Reporting argument error if rfftSize is not valid value */
120 status = ARM_MATH_ARGUMENT_ERROR;
121 break;
122 }
123
124 /* Init Complex FFT Instance */
125 S->pCfft = S_CFFT;
126
127 if (S->ifftFlagR)
128 {
129 /* Initializes the CIFFT Module for fftLenreal/2 length */
130 arm_cfft_radix4_init_f32(S->pCfft, S->fftLenBy2, 1U, 0U);
131 }
132 else
133 {
134 /* Initializes the CFFT Module for fftLenreal/2 length */
135 arm_cfft_radix4_init_f32(S->pCfft, S->fftLenBy2, 0U, 0U);
136 }
137
138 #endif
139 #endif
140 /* return the status of RFFT Init function */
141 return (status);
142
143 }
144
145 /**
146 @} end of RealFFT group
147 */
148