• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* ----------------------------------------------------------------------
2  * Project:      CMSIS DSP Library
3  * Title:        arm_rfft_init_f32.c
4  * Description:  RFFT & RIFFT Floating point initialisation function
5  *
6  * $Date:        18. March 2019
7  * $Revision:    V1.6.0
8  *
9  * Target Processor: Cortex-M cores
10  * -------------------------------------------------------------------- */
11 /*
12  * Copyright (C) 2010-2019 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 /**
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 
75   /*  Initialise the default arm status */
76   arm_status status = ARM_MATH_SUCCESS;
77 
78   /*  Initialize the Real FFT length */
79   S->fftLenReal = (uint16_t) fftLenReal;
80 
81   /*  Initialize the Complex FFT length */
82   S->fftLenBy2 = (uint16_t) fftLenReal / 2U;
83 
84   /*  Initialize the Twiddle coefficientA pointer */
85   S->pTwiddleAReal = (float32_t *) realCoefA;
86 
87   /*  Initialize the Twiddle coefficientB pointer */
88   S->pTwiddleBReal = (float32_t *) realCoefB;
89 
90   /*  Initialize the Flag for selection of RFFT or RIFFT */
91   S->ifftFlagR = (uint8_t) ifftFlagR;
92 
93   /*  Initialize the Flag for calculation Bit reversal or not */
94   S->bitReverseFlagR = (uint8_t) bitReverseFlag;
95 
96   /*  Initializations of structure parameters depending on the FFT length */
97   switch (S->fftLenReal)
98   {
99     /* Init table modifier value */
100   case 8192U:
101     S->twidCoefRModifier = 1U;
102     break;
103   case 2048U:
104     S->twidCoefRModifier = 4U;
105     break;
106   case 512U:
107     S->twidCoefRModifier = 16U;
108     break;
109   case 128U:
110     S->twidCoefRModifier = 64U;
111     break;
112   default:
113     /*  Reporting argument error if rfftSize is not valid value */
114     status = ARM_MATH_ARGUMENT_ERROR;
115     break;
116   }
117 
118   /* Init Complex FFT Instance */
119   S->pCfft = S_CFFT;
120 
121   if (S->ifftFlagR)
122   {
123     /* Initializes the CIFFT Module for fftLenreal/2 length */
124     arm_cfft_radix4_init_f32(S->pCfft, S->fftLenBy2, 1U, 0U);
125   }
126   else
127   {
128     /* Initializes the CFFT Module for fftLenreal/2 length */
129     arm_cfft_radix4_init_f32(S->pCfft, S->fftLenBy2, 0U, 0U);
130   }
131 
132   /* return the status of RFFT Init function */
133   return (status);
134 
135 }
136 
137 /**
138   @} end of RealFFT group
139  */
140