arm_rfft_init_f32.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. #include "arm_math.h"
  29. #include "arm_common_tables.h"
  30. /**
  31. @addtogroup RealFFT
  32. @{
  33. */
  34. /**
  35. @brief Initialization function for the floating-point RFFT/RIFFT.
  36. @deprecated Do not use this function. It has been superceded by \ref arm_rfft_fast_init_f32 and will be removed in the future.
  37. @param[in,out] S points to an instance of the floating-point RFFT/RIFFT structure
  38. @param[in,out] S_CFFT points to an instance of the floating-point CFFT/CIFFT structure
  39. @param[in] fftLenReal length of the FFT.
  40. @param[in] ifftFlagR flag that selects transform direction
  41. - value = 0: forward transform
  42. - value = 1: inverse transform
  43. @param[in] bitReverseFlag flag that enables / disables bit reversal of output
  44. - value = 0: disables bit reversal of output
  45. - value = 1: enables bit reversal of output
  46. @return execution status
  47. - \ref ARM_MATH_SUCCESS : Operation successful
  48. - \ref ARM_MATH_ARGUMENT_ERROR : <code>fftLenReal</code> is not a supported length
  49. @par Description
  50. The parameter <code>fftLenReal</code>specifies length of RFFT/RIFFT Process.
  51. Supported FFT Lengths are 128, 512, 2048.
  52. @par
  53. The parameter <code>ifftFlagR</code> controls whether a forward or inverse transform is computed.
  54. Set(=1) ifftFlagR to calculate RIFFT, otherwise RFFT is calculated.
  55. @par
  56. The parameter <code>bitReverseFlag</code> controls whether output is in normal order or bit reversed order.
  57. Set(=1) bitReverseFlag for output to be in normal order otherwise output is in bit reversed order.
  58. @par
  59. This function also initializes Twiddle factor table.
  60. */
  61. arm_status arm_rfft_init_f32(
  62. arm_rfft_instance_f32 * S,
  63. arm_cfft_radix4_instance_f32 * S_CFFT,
  64. uint32_t fftLenReal,
  65. uint32_t ifftFlagR,
  66. uint32_t bitReverseFlag)
  67. {
  68. /* Initialise the default arm status */
  69. arm_status status = ARM_MATH_SUCCESS;
  70. /* Initialize the Real FFT length */
  71. S->fftLenReal = (uint16_t) fftLenReal;
  72. /* Initialize the Complex FFT length */
  73. S->fftLenBy2 = (uint16_t) fftLenReal / 2U;
  74. /* Initialize the Twiddle coefficientA pointer */
  75. S->pTwiddleAReal = (float32_t *) realCoefA;
  76. /* Initialize the Twiddle coefficientB pointer */
  77. S->pTwiddleBReal = (float32_t *) realCoefB;
  78. /* Initialize the Flag for selection of RFFT or RIFFT */
  79. S->ifftFlagR = (uint8_t) ifftFlagR;
  80. /* Initialize the Flag for calculation Bit reversal or not */
  81. S->bitReverseFlagR = (uint8_t) bitReverseFlag;
  82. /* Initializations of structure parameters depending on the FFT length */
  83. switch (S->fftLenReal)
  84. {
  85. /* Init table modifier value */
  86. case 8192U:
  87. S->twidCoefRModifier = 1U;
  88. break;
  89. case 2048U:
  90. S->twidCoefRModifier = 4U;
  91. break;
  92. case 512U:
  93. S->twidCoefRModifier = 16U;
  94. break;
  95. case 128U:
  96. S->twidCoefRModifier = 64U;
  97. break;
  98. default:
  99. /* Reporting argument error if rfftSize is not valid value */
  100. status = ARM_MATH_ARGUMENT_ERROR;
  101. break;
  102. }
  103. /* Init Complex FFT Instance */
  104. S->pCfft = S_CFFT;
  105. if (S->ifftFlagR)
  106. {
  107. /* Initializes the CIFFT Module for fftLenreal/2 length */
  108. arm_cfft_radix4_init_f32(S->pCfft, S->fftLenBy2, 1U, 0U);
  109. }
  110. else
  111. {
  112. /* Initializes the CFFT Module for fftLenreal/2 length */
  113. arm_cfft_radix4_init_f32(S->pCfft, S->fftLenBy2, 0U, 0U);
  114. }
  115. /* return the status of RFFT Init function */
  116. return (status);
  117. }
  118. /**
  119. @} end of RealFFT group
  120. */