arm_rfft_fast_init_f16.c 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. /* ----------------------------------------------------------------------
  2. * Project: CMSIS DSP Library
  3. * Title: arm_rfft_fast_init_f16.c
  4. * Description: Split Radix Decimation in Frequency CFFT Floating point processing 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-2023 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_f16.h"
  29. #include "arm_common_tables_f16.h"
  30. #include "arm_const_structs_f16.h"
  31. #if defined(ARM_FLOAT16_SUPPORTED)
  32. /**
  33. @ingroup RealFFT
  34. */
  35. /**
  36. @addtogroup RealFFTF16
  37. @{
  38. */
  39. /**
  40. @brief Initialization function for the 32pt floating-point real FFT.
  41. @param[in,out] S points to an arm_rfft_fast_instance_f16 structure
  42. @return execution status
  43. - \ref ARM_MATH_SUCCESS : Operation successful
  44. - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
  45. */
  46. arm_status arm_rfft_fast_init_32_f16( arm_rfft_fast_instance_f16 * S ) {
  47. arm_status status;
  48. if( !S ) return ARM_MATH_ARGUMENT_ERROR;
  49. status=arm_cfft_init_16_f16(&(S->Sint));
  50. if (status != ARM_MATH_SUCCESS)
  51. {
  52. return(status);
  53. }
  54. S->fftLenRFFT = 32U;
  55. S->pTwiddleRFFT = (float16_t *) twiddleCoefF16_rfft_32;
  56. return ARM_MATH_SUCCESS;
  57. }
  58. /**
  59. @brief Initialization function for the 64pt floating-point real FFT.
  60. @param[in,out] S points to an arm_rfft_fast_instance_f16 structure
  61. @return execution status
  62. - \ref ARM_MATH_SUCCESS : Operation successful
  63. - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
  64. */
  65. arm_status arm_rfft_fast_init_64_f16( arm_rfft_fast_instance_f16 * S ) {
  66. arm_status status;
  67. if( !S ) return ARM_MATH_ARGUMENT_ERROR;
  68. status=arm_cfft_init_32_f16(&(S->Sint));
  69. if (status != ARM_MATH_SUCCESS)
  70. {
  71. return(status);
  72. }
  73. S->fftLenRFFT = 64U;
  74. S->pTwiddleRFFT = (float16_t *) twiddleCoefF16_rfft_64;
  75. return ARM_MATH_SUCCESS;
  76. }
  77. /**
  78. @brief Initialization function for the 128pt floating-point real FFT.
  79. @param[in,out] S points to an arm_rfft_fast_instance_f16 structure
  80. @return execution status
  81. - \ref ARM_MATH_SUCCESS : Operation successful
  82. - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
  83. */
  84. arm_status arm_rfft_fast_init_128_f16( arm_rfft_fast_instance_f16 * S ) {
  85. arm_status status;
  86. if( !S ) return ARM_MATH_ARGUMENT_ERROR;
  87. status=arm_cfft_init_64_f16(&(S->Sint));
  88. if (status != ARM_MATH_SUCCESS)
  89. {
  90. return(status);
  91. }
  92. S->fftLenRFFT = 128;
  93. S->pTwiddleRFFT = (float16_t *) twiddleCoefF16_rfft_128;
  94. return ARM_MATH_SUCCESS;
  95. }
  96. /**
  97. @brief Initialization function for the 256pt floating-point real FFT.
  98. @param[in,out] S points to an arm_rfft_fast_instance_f16 structure
  99. @return execution status
  100. - \ref ARM_MATH_SUCCESS : Operation successful
  101. - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
  102. */
  103. arm_status arm_rfft_fast_init_256_f16( arm_rfft_fast_instance_f16 * S ) {
  104. arm_status status;
  105. if( !S ) return ARM_MATH_ARGUMENT_ERROR;
  106. status=arm_cfft_init_128_f16(&(S->Sint));
  107. if (status != ARM_MATH_SUCCESS)
  108. {
  109. return(status);
  110. }
  111. S->fftLenRFFT = 256U;
  112. S->pTwiddleRFFT = (float16_t *) twiddleCoefF16_rfft_256;
  113. return ARM_MATH_SUCCESS;
  114. }
  115. /**
  116. @brief Initialization function for the 512pt floating-point real FFT.
  117. @param[in,out] S points to an arm_rfft_fast_instance_f16 structure
  118. @return execution status
  119. - \ref ARM_MATH_SUCCESS : Operation successful
  120. - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
  121. */
  122. arm_status arm_rfft_fast_init_512_f16( arm_rfft_fast_instance_f16 * S ) {
  123. arm_status status;
  124. if( !S ) return ARM_MATH_ARGUMENT_ERROR;
  125. status=arm_cfft_init_256_f16(&(S->Sint));
  126. if (status != ARM_MATH_SUCCESS)
  127. {
  128. return(status);
  129. }
  130. S->fftLenRFFT = 512U;
  131. S->pTwiddleRFFT = (float16_t *) twiddleCoefF16_rfft_512;
  132. return ARM_MATH_SUCCESS;
  133. }
  134. /**
  135. @brief Initialization function for the 1024pt floating-point real FFT.
  136. @param[in,out] S points to an arm_rfft_fast_instance_f16 structure
  137. @return execution status
  138. - \ref ARM_MATH_SUCCESS : Operation successful
  139. - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
  140. */
  141. arm_status arm_rfft_fast_init_1024_f16( arm_rfft_fast_instance_f16 * S ) {
  142. arm_status status;
  143. if( !S ) return ARM_MATH_ARGUMENT_ERROR;
  144. status=arm_cfft_init_512_f16(&(S->Sint));
  145. if (status != ARM_MATH_SUCCESS)
  146. {
  147. return(status);
  148. }
  149. S->fftLenRFFT = 1024U;
  150. S->pTwiddleRFFT = (float16_t *) twiddleCoefF16_rfft_1024;
  151. return ARM_MATH_SUCCESS;
  152. }
  153. /**
  154. @brief Initialization function for the 2048pt floating-point real FFT.
  155. @param[in,out] S points to an arm_rfft_fast_instance_f16 structure
  156. @return execution status
  157. - \ref ARM_MATH_SUCCESS : Operation successful
  158. - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
  159. */
  160. arm_status arm_rfft_fast_init_2048_f16( arm_rfft_fast_instance_f16 * S ) {
  161. arm_status status;
  162. if( !S ) return ARM_MATH_ARGUMENT_ERROR;
  163. status=arm_cfft_init_1024_f16(&(S->Sint));
  164. if (status != ARM_MATH_SUCCESS)
  165. {
  166. return(status);
  167. }
  168. S->fftLenRFFT = 2048U;
  169. S->pTwiddleRFFT = (float16_t *) twiddleCoefF16_rfft_2048;
  170. return ARM_MATH_SUCCESS;
  171. }
  172. /**
  173. * @brief Initialization function for the 4096pt floating-point real FFT.
  174. * @param[in,out] S points to an arm_rfft_fast_instance_f16 structure
  175. @return execution status
  176. - \ref ARM_MATH_SUCCESS : Operation successful
  177. - \ref ARM_MATH_ARGUMENT_ERROR : an error is detected
  178. */
  179. arm_status arm_rfft_fast_init_4096_f16( arm_rfft_fast_instance_f16 * S ) {
  180. arm_status status;
  181. if( !S ) return ARM_MATH_ARGUMENT_ERROR;
  182. status=arm_cfft_init_2048_f16(&(S->Sint));
  183. if (status != ARM_MATH_SUCCESS)
  184. {
  185. return(status);
  186. }
  187. S->fftLenRFFT = 4096U;
  188. S->pTwiddleRFFT = (float16_t *) twiddleCoefF16_rfft_4096;
  189. return ARM_MATH_SUCCESS;
  190. }
  191. /**
  192. @brief Generic initialization function for the floating-point real FFT.
  193. @param[in,out] S points to an arm_rfft_fast_instance_f16 structure
  194. @param[in] fftLen length of the Real Sequence
  195. @return execution status
  196. - \ref ARM_MATH_SUCCESS : Operation successful
  197. - \ref ARM_MATH_ARGUMENT_ERROR : <code>fftLen</code> is not a supported length
  198. @par Description
  199. The parameter <code>fftLen</code> specifies the length of RFFT/CIFFT process.
  200. Supported FFT Lengths are 32, 64, 128, 256, 512, 1024, 2048, 4096.
  201. @par
  202. This Function also initializes Twiddle factor table pointer and Bit reversal table pointer.
  203. @par
  204. This function should be used only if you don't know the FFT sizes that
  205. you'll need at build time. The use of this function will prevent the
  206. linker from removing the FFT tables that are not needed and the library
  207. code size will be bigger than needed.
  208. @par
  209. If you use CMSIS-DSP as a static library, and if you know the FFT sizes
  210. that you need at build time, then it is better to use the initialization
  211. functions defined for each FFT size.
  212. */
  213. arm_status arm_rfft_fast_init_f16(
  214. arm_rfft_fast_instance_f16 * S,
  215. uint16_t fftLen)
  216. {
  217. arm_status status;
  218. switch (fftLen)
  219. {
  220. case 4096U:
  221. status = arm_rfft_fast_init_4096_f16(S);
  222. break;
  223. case 2048U:
  224. status = arm_rfft_fast_init_2048_f16(S);
  225. break;
  226. case 1024U:
  227. status = arm_rfft_fast_init_1024_f16(S);
  228. break;
  229. case 512U:
  230. status = arm_rfft_fast_init_512_f16(S);
  231. break;
  232. case 256U:
  233. status = arm_rfft_fast_init_256_f16(S);
  234. break;
  235. case 128U:
  236. status = arm_rfft_fast_init_128_f16(S);
  237. break;
  238. case 64U:
  239. status = arm_rfft_fast_init_64_f16(S);
  240. break;
  241. case 32U:
  242. status = arm_rfft_fast_init_32_f16(S);
  243. break;
  244. default:
  245. return(ARM_MATH_ARGUMENT_ERROR);
  246. break;
  247. }
  248. return(status);
  249. }
  250. /**
  251. @} end of RealFFTF16 group
  252. */
  253. #endif /* #if defined(ARM_FLOAT16_SUPPORTED) */