arm_cfft_radix2_init_q31.c 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /* ----------------------------------------------------------------------
  2. * Project: CMSIS DSP Library
  3. * Title: arm_cfft_radix2_init_q31.c
  4. * Description: Radix-2 Decimation in Frequency Fixed-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 Q31 CFFT/CIFFT.
  36. @deprecated Do not use this function. It has been superseded by \ref arm_cfft_q31 and will be removed in the future.
  37. @param[in,out] S points to an instance of the Q31 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_q31(
  60. arm_cfft_radix2_instance_q31 * 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 = (q31_t *) twiddleCoef_4096_q31;
  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 Instance structure depending on the FFT length */
  78. switch (S->fftLen)
  79. {
  80. /* Initializations of structure parameters for 4096 point FFT */
  81. case 4096U:
  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. break;
  89. /* Initializations of structure parameters for 2048 point FFT */
  90. case 2048U:
  91. /* Initialise the twiddle coef modifier value */
  92. S->twidCoefModifier = 2U;
  93. /* Initialise the bit reversal table modifier */
  94. S->bitRevFactor = 2U;
  95. /* Initialise the bit reversal table pointer */
  96. S->pBitRevTable = (uint16_t *) & armBitRevTable[1];
  97. break;
  98. /* Initializations of structure parameters for 1024 point FFT */
  99. case 1024U:
  100. /* Initialise the twiddle coef modifier value */
  101. S->twidCoefModifier = 4U;
  102. /* Initialise the bit reversal table modifier */
  103. S->bitRevFactor = 4U;
  104. /* Initialise the bit reversal table pointer */
  105. S->pBitRevTable = (uint16_t *) & armBitRevTable[3];
  106. break;
  107. /* Initializations of structure parameters for 512 point FFT */
  108. case 512U:
  109. /* Initialise the twiddle coef modifier value */
  110. S->twidCoefModifier = 8U;
  111. /* Initialise the bit reversal table modifier */
  112. S->bitRevFactor = 8U;
  113. /* Initialise the bit reversal table pointer */
  114. S->pBitRevTable = (uint16_t *) & armBitRevTable[7];
  115. break;
  116. case 256U:
  117. /* Initializations of structure parameters for 256 point FFT */
  118. S->twidCoefModifier = 16U;
  119. S->bitRevFactor = 16U;
  120. S->pBitRevTable = (uint16_t *) & armBitRevTable[15];
  121. break;
  122. case 128U:
  123. /* Initializations of structure parameters for 128 point FFT */
  124. S->twidCoefModifier = 32U;
  125. S->bitRevFactor = 32U;
  126. S->pBitRevTable = (uint16_t *) & armBitRevTable[31];
  127. break;
  128. case 64U:
  129. /* Initializations of structure parameters for 64 point FFT */
  130. S->twidCoefModifier = 64U;
  131. S->bitRevFactor = 64U;
  132. S->pBitRevTable = (uint16_t *) & armBitRevTable[63];
  133. break;
  134. case 32U:
  135. /* Initializations of structure parameters for 32 point FFT */
  136. S->twidCoefModifier = 128U;
  137. S->bitRevFactor = 128U;
  138. S->pBitRevTable = (uint16_t *) & armBitRevTable[127];
  139. break;
  140. case 16U:
  141. /* Initializations of structure parameters for 16 point FFT */
  142. S->twidCoefModifier = 256U;
  143. S->bitRevFactor = 256U;
  144. S->pBitRevTable = (uint16_t *) & armBitRevTable[255];
  145. break;
  146. default:
  147. /* Reporting argument error if fftSize is not valid value */
  148. status = ARM_MATH_ARGUMENT_ERROR;
  149. break;
  150. }
  151. return (status);
  152. }
  153. /**
  154. @} end of ComplexFFTDeprecated group
  155. */