Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 56 | mjames | 1 | /* ---------------------------------------------------------------------- |
| 2 | * Project: CMSIS DSP Library |
||
| 3 | * Title: arm_rfft_init_f32.c |
||
| 4 | * Description: RFFT & RIFFT Floating point initialisation 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 | |||
| 31 | /** |
||
| 32 | * @ingroup RealFFT |
||
| 33 | */ |
||
| 34 | |||
| 35 | /** |
||
| 36 | * @addtogroup RealFFT_Table Real FFT Tables |
||
| 37 | * @{ |
||
| 38 | */ |
||
| 39 | |||
| 40 | /** |
||
| 41 | * \par |
||
| 42 | * Generation of realCoefA array: |
||
| 43 | * \par |
||
| 44 | * n = 4096 |
||
| 45 | * <pre>for (i = 0; i < n; i++) |
||
| 46 | * { |
||
| 47 | * pATable[2 * i] = 0.5 * (1.0 - sin (2 * PI / (double) (2 * n) * (double) i)); |
||
| 48 | * pATable[2 * i + 1] = 0.5 * (-1.0 * cos (2 * PI / (double) (2 * n) * (double) i)); |
||
| 49 | * } </pre> |
||
| 50 | *//** |
||
| 51 | * \par |
||
| 52 | * Generation of realCoefB array: |
||
| 53 | * \par |
||
| 54 | * n = 4096 |
||
| 55 | * <pre>for (i = 0; i < n; i++) |
||
| 56 | * { |
||
| 57 | * pBTable[2 * i] = 0.5 * (1.0 + sin (2 * PI / (double) (2 * n) * (double) i)); |
||
| 58 | * pBTable[2 * i + 1] = 0.5 * (1.0 * cos (2 * PI / (double) (2 * n) * (double) i)); |
||
| 59 | * } </pre> |
||
| 60 | * |
||
| 61 | *//** |
||
| 62 | * @brief Initialization function for the floating-point RFFT/RIFFT. |
||
| 63 | * @deprecated Do not use this function. It has been superceded by \ref arm_rfft_fast_init_f32 and will be removed |
||
| 64 | * in the future. |
||
| 65 | * @param[in,out] *S points to an instance of the floating-point RFFT/RIFFT structure. |
||
| 66 | * @param[in,out] *S_CFFT points to an instance of the floating-point CFFT/CIFFT structure. |
||
| 67 | * @param[in] fftLenReal length of the FFT. |
||
| 68 | * @param[in] ifftFlagR flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. |
||
| 69 | * @param[in] bitReverseFlag flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. |
||
| 70 | * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if <code>fftLenReal</code> is not a supported value. |
||
| 71 | * |
||
| 72 | * \par Description: |
||
| 73 | * \par |
||
| 74 | * The parameter <code>fftLenReal</code> Specifies length of RFFT/RIFFT Process. Supported FFT Lengths are 128, 512, 2048. |
||
| 75 | * \par |
||
| 76 | * The parameter <code>ifftFlagR</code> controls whether a forward or inverse transform is computed. |
||
| 77 | * Set(=1) ifftFlagR to calculate RIFFT, otherwise RFFT is calculated. |
||
| 78 | * \par |
||
| 79 | * The parameter <code>bitReverseFlag</code> controls whether output is in normal order or bit reversed order. |
||
| 80 | * Set(=1) bitReverseFlag for output to be in normal order otherwise output is in bit reversed order. |
||
| 81 | * \par |
||
| 82 | * This function also initializes Twiddle factor table. |
||
| 83 | */ |
||
| 84 | |||
| 85 | /** |
||
| 86 | * @} end of RealFFT_Table group |
||
| 87 | */ |
||
| 88 | |||
| 89 | /** |
||
| 90 | * @addtogroup RealFFT |
||
| 91 | * @{ |
||
| 92 | */ |
||
| 93 | |||
| 94 | arm_status arm_rfft_init_f32( |
||
| 95 | arm_rfft_instance_f32 * S, |
||
| 96 | arm_cfft_radix4_instance_f32 * S_CFFT, |
||
| 97 | uint32_t fftLenReal, |
||
| 98 | uint32_t ifftFlagR, |
||
| 99 | uint32_t bitReverseFlag) |
||
| 100 | { |
||
| 101 | |||
| 102 | /* Initialise the default arm status */ |
||
| 103 | arm_status status = ARM_MATH_SUCCESS; |
||
| 104 | |||
| 105 | /* Initialize the Real FFT length */ |
||
| 106 | S->fftLenReal = (uint16_t) fftLenReal; |
||
| 107 | |||
| 108 | /* Initialize the Complex FFT length */ |
||
| 109 | S->fftLenBy2 = (uint16_t) fftLenReal / 2U; |
||
| 110 | |||
| 111 | /* Initialize the Twiddle coefficientA pointer */ |
||
| 112 | S->pTwiddleAReal = (float32_t *) realCoefA; |
||
| 113 | |||
| 114 | /* Initialize the Twiddle coefficientB pointer */ |
||
| 115 | S->pTwiddleBReal = (float32_t *) realCoefB; |
||
| 116 | |||
| 117 | /* Initialize the Flag for selection of RFFT or RIFFT */ |
||
| 118 | S->ifftFlagR = (uint8_t) ifftFlagR; |
||
| 119 | |||
| 120 | /* Initialize the Flag for calculation Bit reversal or not */ |
||
| 121 | S->bitReverseFlagR = (uint8_t) bitReverseFlag; |
||
| 122 | |||
| 123 | /* Initializations of structure parameters depending on the FFT length */ |
||
| 124 | switch (S->fftLenReal) |
||
| 125 | { |
||
| 126 | /* Init table modifier value */ |
||
| 127 | case 8192U: |
||
| 128 | S->twidCoefRModifier = 1U; |
||
| 129 | break; |
||
| 130 | case 2048U: |
||
| 131 | S->twidCoefRModifier = 4U; |
||
| 132 | break; |
||
| 133 | case 512U: |
||
| 134 | S->twidCoefRModifier = 16U; |
||
| 135 | break; |
||
| 136 | case 128U: |
||
| 137 | S->twidCoefRModifier = 64U; |
||
| 138 | break; |
||
| 139 | default: |
||
| 140 | /* Reporting argument error if rfftSize is not valid value */ |
||
| 141 | status = ARM_MATH_ARGUMENT_ERROR; |
||
| 142 | break; |
||
| 143 | } |
||
| 144 | |||
| 145 | /* Init Complex FFT Instance */ |
||
| 146 | S->pCfft = S_CFFT; |
||
| 147 | |||
| 148 | if (S->ifftFlagR) |
||
| 149 | { |
||
| 150 | /* Initializes the CIFFT Module for fftLenreal/2 length */ |
||
| 151 | arm_cfft_radix4_init_f32(S->pCfft, S->fftLenBy2, 1U, 0U); |
||
| 152 | } |
||
| 153 | else |
||
| 154 | { |
||
| 155 | /* Initializes the CFFT Module for fftLenreal/2 length */ |
||
| 156 | arm_cfft_radix4_init_f32(S->pCfft, S->fftLenBy2, 0U, 0U); |
||
| 157 | } |
||
| 158 | |||
| 159 | /* return the status of RFFT Init function */ |
||
| 160 | return (status); |
||
| 161 | |||
| 162 | } |
||
| 163 | |||
| 164 | /** |
||
| 165 | * @} end of RealFFT group |
||
| 166 | */ |
||
| 167 | |||
| 168 |