arm_cfft_radix2_init_f32.c 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. /* ----------------------------------------------------------------------
  2. * Project: CMSIS DSP Library
  3. * Title: arm_cfft_radix2_init_f32.c
  4. * Description: Radix-2 Decimation in Frequency Floating-point CFFT & CIFFT Initialization 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. #include "dsp/transform_functions.h"
  29. #include "arm_common_tables.h"
  30. /**
  31. @addtogroup ComplexFFTDeprecated
  32. @{
  33. */
  34. /**
  35. @brief Initialization function for the floating-point CFFT/CIFFT.
  36. @deprecated Do not use this function. It has been superseded by \ref arm_cfft_f32 and will be removed in the future.
  37. @param[in,out] S points to an instance of the floating-point CFFT/CIFFT structure
  38. @param[in] fftLen length of the FFT
  39. @param[in] ifftFlag flag that selects transform direction
  40. - value = 0: forward transform
  41. - value = 1: inverse transform
  42. @param[in] bitReverseFlag flag that enables / disables bit reversal of output
  43. - value = 0: disables bit reversal of output
  44. - value = 1: enables bit reversal of output
  45. @return execution status
  46. - \ref ARM_MATH_SUCCESS : Operation successful
  47. - \ref ARM_MATH_ARGUMENT_ERROR : <code>fftLen</code> is not a supported length
  48. @par Details
  49. The parameter <code>ifftFlag</code> controls whether a forward or inverse transform is computed.
  50. Set(=1) ifftFlag for calculation of CIFFT otherwise CFFT is calculated
  51. @par
  52. The parameter <code>bitReverseFlag</code> controls whether output is in normal order or bit reversed order.
  53. Set(=1) bitReverseFlag for output to be in normal order otherwise output is in bit reversed order.
  54. @par
  55. The parameter <code>fftLen</code> Specifies length of CFFT/CIFFT process. Supported FFT Lengths are 16, 64, 256, 1024.
  56. @par
  57. This Function also initializes Twiddle factor table pointer and Bit reversal table pointer.
  58. */
  59. arm_status arm_cfft_radix2_init_f32(
  60. arm_cfft_radix2_instance_f32 * S,
  61. uint16_t fftLen,
  62. uint8_t ifftFlag,
  63. uint8_t bitReverseFlag)
  64. {
  65. /* Initialise the default arm status */
  66. arm_status status = ARM_MATH_ARGUMENT_ERROR;
  67. /* Initialise the default arm status */
  68. status = ARM_MATH_SUCCESS;
  69. /* Initialise the FFT length */
  70. S->fftLen = fftLen;
  71. /* Initialise the Twiddle coefficient pointer */
  72. S->pTwiddle = (float32_t *) twiddleCoef;
  73. /* Initialise the Flag for selection of CFFT or CIFFT */
  74. S->ifftFlag = ifftFlag;
  75. /* Initialise the Flag for calculation Bit reversal or not */
  76. S->bitReverseFlag = bitReverseFlag;
  77. /* Initializations of structure parameters depending on the FFT length */
  78. switch (S->fftLen)
  79. {
  80. case 4096U:
  81. /* Initializations of structure parameters for 4096 point FFT */
  82. /* Initialise the twiddle coef modifier value */
  83. S->twidCoefModifier = 1U;
  84. /* Initialise the bit reversal table modifier */
  85. S->bitRevFactor = 1U;
  86. /* Initialise the bit reversal table pointer */
  87. S->pBitRevTable = (uint16_t *) armBitRevTable;
  88. /* Initialise the 1/fftLen Value */
  89. S->onebyfftLen = 0.000244140625;
  90. break;
  91. case 2048U:
  92. /* Initializations of structure parameters for 2048 point FFT */
  93. /* Initialise the twiddle coef modifier value */
  94. S->twidCoefModifier = 2U;
  95. /* Initialise the bit reversal table modifier */
  96. S->bitRevFactor = 2U;
  97. /* Initialise the bit reversal table pointer */
  98. S->pBitRevTable = (uint16_t *) & armBitRevTable[1];
  99. /* Initialise the 1/fftLen Value */
  100. S->onebyfftLen = 0.00048828125;
  101. break;
  102. case 1024U:
  103. /* Initializations of structure parameters for 1024 point FFT */
  104. /* Initialise the twiddle coef modifier value */
  105. S->twidCoefModifier = 4U;
  106. /* Initialise the bit reversal table modifier */
  107. S->bitRevFactor = 4U;
  108. /* Initialise the bit reversal table pointer */
  109. S->pBitRevTable = (uint16_t *) & armBitRevTable[3];
  110. /* Initialise the 1/fftLen Value */
  111. S->onebyfftLen = 0.0009765625f;
  112. break;
  113. case 512U:
  114. /* Initializations of structure parameters for 512 point FFT */
  115. /* Initialise the twiddle coef modifier value */
  116. S->twidCoefModifier = 8U;
  117. /* Initialise the bit reversal table modifier */
  118. S->bitRevFactor = 8U;
  119. /* Initialise the bit reversal table pointer */
  120. S->pBitRevTable = (uint16_t *) & armBitRevTable[7];
  121. /* Initialise the 1/fftLen Value */
  122. S->onebyfftLen = 0.001953125;
  123. break;
  124. case 256U:
  125. /* Initializations of structure parameters for 256 point FFT */
  126. S->twidCoefModifier = 16U;
  127. S->bitRevFactor = 16U;
  128. S->pBitRevTable = (uint16_t *) & armBitRevTable[15];
  129. S->onebyfftLen = 0.00390625f;
  130. break;
  131. case 128U:
  132. /* Initializations of structure parameters for 128 point FFT */
  133. S->twidCoefModifier = 32U;
  134. S->bitRevFactor = 32U;
  135. S->pBitRevTable = (uint16_t *) & armBitRevTable[31];
  136. S->onebyfftLen = 0.0078125;
  137. break;
  138. case 64U:
  139. /* Initializations of structure parameters for 64 point FFT */
  140. S->twidCoefModifier = 64U;
  141. S->bitRevFactor = 64U;
  142. S->pBitRevTable = (uint16_t *) & armBitRevTable[63];
  143. S->onebyfftLen = 0.015625f;
  144. break;
  145. case 32U:
  146. /* Initializations of structure parameters for 64 point FFT */
  147. S->twidCoefModifier = 128U;
  148. S->bitRevFactor = 128U;
  149. S->pBitRevTable = (uint16_t *) & armBitRevTable[127];
  150. S->onebyfftLen = 0.03125;
  151. break;
  152. case 16U:
  153. /* Initializations of structure parameters for 16 point FFT */
  154. S->twidCoefModifier = 256U;
  155. S->bitRevFactor = 256U;
  156. S->pBitRevTable = (uint16_t *) & armBitRevTable[255];
  157. S->onebyfftLen = 0.0625f;
  158. break;
  159. default:
  160. /* Reporting argument error if fftSize is not valid value */
  161. status = ARM_MATH_ARGUMENT_ERROR;
  162. break;
  163. }
  164. return (status);
  165. }
  166. /**
  167. @} end of ComplexFFTDeprecated group
  168. */