You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

arm_rfft_fast_init_f32.c 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /* ----------------------------------------------------------------------
  2. * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
  3. *
  4. * $Date: 17. January 2013
  5. * $Revision: V1.4.1
  6. *
  7. * Project: CMSIS DSP Library
  8. * Title: arm_cfft_init_f32.c
  9. *
  10. * Description: Split Radix Decimation in Frequency CFFT Floating point processing function
  11. *
  12. * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
  13. *
  14. * Redistribution and use in source and binary forms, with or without
  15. * modification, are permitted provided that the following conditions
  16. * are met:
  17. * - Redistributions of source code must retain the above copyright
  18. * notice, this list of conditions and the following disclaimer.
  19. * - Redistributions in binary form must reproduce the above copyright
  20. * notice, this list of conditions and the following disclaimer in
  21. * the documentation and/or other materials provided with the
  22. * distribution.
  23. * - Neither the name of ARM LIMITED nor the names of its contributors
  24. * may be used to endorse or promote products derived from this
  25. * software without specific prior written permission.
  26. *
  27. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  28. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  29. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  30. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  31. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  32. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  33. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  34. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  35. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  36. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  37. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  38. * POSSIBILITY OF SUCH DAMAGE.
  39. * -------------------------------------------------------------------- */
  40. #include "arm_math.h"
  41. #include "arm_common_tables.h"
  42. /**
  43. * @ingroup groupTransforms
  44. */
  45. /**
  46. * @addtogroup RealFFT
  47. * @{
  48. */
  49. /**
  50. * @brief Initialization function for the floating-point real FFT.
  51. * @param[in,out] *S points to an arm_rfft_fast_instance_f32 structure.
  52. * @param[in] fftLen length of the Real Sequence.
  53. * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if <code>fftLen</code> is not a supported value.
  54. *
  55. * \par Description:
  56. * \par
  57. * The parameter <code>ifftFlag</code> controls whether a forward or inverse transform is computed.
  58. * Set(=1) ifftFlag for calculation of CIFFT otherwise RFFT is calculated
  59. * \par
  60. * The parameter <code>bitReverseFlag</code> controls whether output is in normal order or bit reversed order.
  61. * Set(=1) bitReverseFlag for output to be in normal order otherwise output is in bit reversed order.
  62. * \par
  63. * The parameter <code>fftLen</code> Specifies length of RFFT/CIFFT process. Supported FFT Lengths are 16, 32, 64, 128, 256, 512, 1024, 2048, 4096.
  64. * \par
  65. * This Function also initializes Twiddle factor table pointer and Bit reversal table pointer.
  66. */
  67. arm_status arm_rfft_fast_init_f32(
  68. arm_rfft_fast_instance_f32 * S,
  69. uint16_t fftLen)
  70. {
  71. arm_cfft_instance_f32 * Sint;
  72. /* Initialise the default arm status */
  73. arm_status status = ARM_MATH_SUCCESS;
  74. /* Initialise the FFT length */
  75. Sint = &(S->Sint);
  76. Sint->fftLen = fftLen/2;
  77. S->fftLenRFFT = fftLen;
  78. /* Initialise the Twiddle coefficient pointer */
  79. // S->pTwiddle = (float32_t *) twiddleCoef;
  80. /* Initializations of structure parameters depending on the FFT length */
  81. switch (Sint->fftLen)
  82. {
  83. case 4096u:
  84. /* Initializations of structure parameters for 4096 point FFT */
  85. /* Initialise the bit reversal table length */
  86. Sint->bitRevLength = ARMBITREVINDEXTABLE4096_TABLE_LENGTH;
  87. /* Initialise the bit reversal table pointer */
  88. Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable4096;
  89. /* Initialise the 1/fftLen Value */
  90. break;
  91. case 2048u:
  92. Sint->bitRevLength = ARMBITREVINDEXTABLE2048_TABLE_LENGTH;
  93. Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable2048;
  94. break;
  95. case 1024u:
  96. Sint->bitRevLength = ARMBITREVINDEXTABLE1024_TABLE_LENGTH;
  97. Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable1024;
  98. break;
  99. case 512u:
  100. Sint->bitRevLength = ARMBITREVINDEXTABLE_512_TABLE_LENGTH;
  101. Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable512;
  102. break;
  103. case 256u:
  104. Sint->bitRevLength = ARMBITREVINDEXTABLE_256_TABLE_LENGTH;
  105. Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable256;
  106. break;
  107. case 128u:
  108. Sint->bitRevLength = ARMBITREVINDEXTABLE_128_TABLE_LENGTH;
  109. Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable128;
  110. break;
  111. case 64u:
  112. Sint->bitRevLength = ARMBITREVINDEXTABLE__64_TABLE_LENGTH;
  113. Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable64;
  114. break;
  115. case 32u:
  116. Sint->bitRevLength = ARMBITREVINDEXTABLE__32_TABLE_LENGTH;
  117. Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable32;
  118. break;
  119. case 16u:
  120. Sint->bitRevLength = ARMBITREVINDEXTABLE__16_TABLE_LENGTH;
  121. Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable16;
  122. break;
  123. default:
  124. /* Reporting argument error if fftSize is not valid value */
  125. status = ARM_MATH_ARGUMENT_ERROR;
  126. break;
  127. }
  128. return (status);
  129. }
  130. /**
  131. * @} end of RealFFT group
  132. */