A bundled STM32F10x Std Periph and CMSIS library
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.
 
 
 
 
 

7539 lines
238 KiB

  1. /* ----------------------------------------------------------------------
  2. * Copyright (C) 2010-2014 ARM Limited. All rights reserved.
  3. *
  4. * $Date: 12. March 2014
  5. * $Revision: V1.4.4
  6. *
  7. * Project: CMSIS DSP Library
  8. * Title: arm_math.h
  9. *
  10. * Description: Public header file for CMSIS DSP Library
  11. *
  12. * Target Processor: Cortex-M7/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. /**
  41. \mainpage CMSIS DSP Software Library
  42. *
  43. * Introduction
  44. * ------------
  45. *
  46. * This user manual describes the CMSIS DSP software library,
  47. * a suite of common signal processing functions for use on Cortex-M processor based devices.
  48. *
  49. * The library is divided into a number of functions each covering a specific category:
  50. * - Basic math functions
  51. * - Fast math functions
  52. * - Complex math functions
  53. * - Filters
  54. * - Matrix functions
  55. * - Transforms
  56. * - Motor control functions
  57. * - Statistical functions
  58. * - Support functions
  59. * - Interpolation functions
  60. *
  61. * The library has separate functions for operating on 8-bit integers, 16-bit integers,
  62. * 32-bit integer and 32-bit floating-point values.
  63. *
  64. * Using the Library
  65. * ------------
  66. *
  67. * The library installer contains prebuilt versions of the libraries in the <code>Lib</code> folder.
  68. * - arm_cortexM4lf_math.lib (Little endian and Floating Point Unit on Cortex-M4)
  69. * - arm_cortexM4bf_math.lib (Big endian and Floating Point Unit on Cortex-M4)
  70. * - arm_cortexM4l_math.lib (Little endian on Cortex-M4)
  71. * - arm_cortexM4b_math.lib (Big endian on Cortex-M4)
  72. * - arm_cortexM3l_math.lib (Little endian on Cortex-M3)
  73. * - arm_cortexM3b_math.lib (Big endian on Cortex-M3)
  74. * - arm_cortexM0l_math.lib (Little endian on Cortex-M0)
  75. * - arm_cortexM0b_math.lib (Big endian on Cortex-M3)
  76. *
  77. * The library functions are declared in the public file <code>arm_math.h</code> which is placed in the <code>Include</code> folder.
  78. * Simply include this file and link the appropriate library in the application and begin calling the library functions. The Library supports single
  79. * public header file <code> arm_math.h</code> for Cortex-M4/M3/M0 with little endian and big endian. Same header file will be used for floating point unit(FPU) variants.
  80. * Define the appropriate pre processor MACRO ARM_MATH_CM4 or ARM_MATH_CM3 or
  81. * ARM_MATH_CM0 or ARM_MATH_CM0PLUS depending on the target processor in the application.
  82. *
  83. * Examples
  84. * --------
  85. *
  86. * The library ships with a number of examples which demonstrate how to use the library functions.
  87. *
  88. * Toolchain Support
  89. * ------------
  90. *
  91. * The library has been developed and tested with MDK-ARM version 4.60.
  92. * The library is being tested in GCC and IAR toolchains and updates on this activity will be made available shortly.
  93. *
  94. * Building the Library
  95. * ------------
  96. *
  97. * The library installer contains a project file to re build libraries on MDK-ARM Tool chain in the <code>CMSIS\\DSP_Lib\\Source\\ARM</code> folder.
  98. * - arm_cortexM_math.uvproj
  99. *
  100. *
  101. * The libraries can be built by opening the arm_cortexM_math.uvproj project in MDK-ARM, selecting a specific target, and defining the optional pre processor MACROs detailed above.
  102. *
  103. * Pre-processor Macros
  104. * ------------
  105. *
  106. * Each library project have differant pre-processor macros.
  107. *
  108. * - UNALIGNED_SUPPORT_DISABLE:
  109. *
  110. * Define macro UNALIGNED_SUPPORT_DISABLE, If the silicon does not support unaligned memory access
  111. *
  112. * - ARM_MATH_BIG_ENDIAN:
  113. *
  114. * Define macro ARM_MATH_BIG_ENDIAN to build the library for big endian targets. By default library builds for little endian targets.
  115. *
  116. * - ARM_MATH_MATRIX_CHECK:
  117. *
  118. * Define macro ARM_MATH_MATRIX_CHECK for checking on the input and output sizes of matrices
  119. *
  120. * - ARM_MATH_ROUNDING:
  121. *
  122. * Define macro ARM_MATH_ROUNDING for rounding on support functions
  123. *
  124. * - ARM_MATH_CMx:
  125. *
  126. * Define macro ARM_MATH_CM4 for building the library on Cortex-M4 target, ARM_MATH_CM3 for building library on Cortex-M3 target
  127. * and ARM_MATH_CM0 for building library on cortex-M0 target, ARM_MATH_CM0PLUS for building library on cortex-M0+ target.
  128. *
  129. * - __FPU_PRESENT:
  130. *
  131. * Initialize macro __FPU_PRESENT = 1 when building on FPU supported Targets. Enable this macro for M4bf and M4lf libraries
  132. *
  133. * <hr>
  134. * CMSIS-DSP in ARM::CMSIS Pack
  135. * -----------------------------
  136. *
  137. * The following files relevant to CMSIS-DSP are present in the <b>ARM::CMSIS</b> Pack directories:
  138. * |File/Folder |Content |
  139. * |------------------------------|------------------------------------------------------------------------|
  140. * |\b CMSIS\\Documentation\\DSP | This documentation |
  141. * |\b CMSIS\\DSP_Lib | Software license agreement (license.txt) |
  142. * |\b CMSIS\\DSP_Lib\\Examples | Example projects demonstrating the usage of the library functions |
  143. * |\b CMSIS\\DSP_Lib\\Source | Source files for rebuilding the library |
  144. *
  145. * <hr>
  146. * Revision History of CMSIS-DSP
  147. * ------------
  148. * Please refer to \ref ChangeLog_pg.
  149. *
  150. * Copyright Notice
  151. * ------------
  152. *
  153. * Copyright (C) 2010-2014 ARM Limited. All rights reserved.
  154. */
  155. /**
  156. * @defgroup groupMath Basic Math Functions
  157. */
  158. /**
  159. * @defgroup groupFastMath Fast Math Functions
  160. * This set of functions provides a fast approximation to sine, cosine, and square root.
  161. * As compared to most of the other functions in the CMSIS math library, the fast math functions
  162. * operate on individual values and not arrays.
  163. * There are separate functions for Q15, Q31, and floating-point data.
  164. *
  165. */
  166. /**
  167. * @defgroup groupCmplxMath Complex Math Functions
  168. * This set of functions operates on complex data vectors.
  169. * The data in the complex arrays is stored in an interleaved fashion
  170. * (real, imag, real, imag, ...).
  171. * In the API functions, the number of samples in a complex array refers
  172. * to the number of complex values; the array contains twice this number of
  173. * real values.
  174. */
  175. /**
  176. * @defgroup groupFilters Filtering Functions
  177. */
  178. /**
  179. * @defgroup groupMatrix Matrix Functions
  180. *
  181. * This set of functions provides basic matrix math operations.
  182. * The functions operate on matrix data structures. For example,
  183. * the type
  184. * definition for the floating-point matrix structure is shown
  185. * below:
  186. * <pre>
  187. * typedef struct
  188. * {
  189. * uint16_t numRows; // number of rows of the matrix.
  190. * uint16_t numCols; // number of columns of the matrix.
  191. * float32_t *pData; // points to the data of the matrix.
  192. * } arm_matrix_instance_f32;
  193. * </pre>
  194. * There are similar definitions for Q15 and Q31 data types.
  195. *
  196. * The structure specifies the size of the matrix and then points to
  197. * an array of data. The array is of size <code>numRows X numCols</code>
  198. * and the values are arranged in row order. That is, the
  199. * matrix element (i, j) is stored at:
  200. * <pre>
  201. * pData[i*numCols + j]
  202. * </pre>
  203. *
  204. * \par Init Functions
  205. * There is an associated initialization function for each type of matrix
  206. * data structure.
  207. * The initialization function sets the values of the internal structure fields.
  208. * Refer to the function <code>arm_mat_init_f32()</code>, <code>arm_mat_init_q31()</code>
  209. * and <code>arm_mat_init_q15()</code> for floating-point, Q31 and Q15 types, respectively.
  210. *
  211. * \par
  212. * Use of the initialization function is optional. However, if initialization function is used
  213. * then the instance structure cannot be placed into a const data section.
  214. * To place the instance structure in a const data
  215. * section, manually initialize the data structure. For example:
  216. * <pre>
  217. * <code>arm_matrix_instance_f32 S = {nRows, nColumns, pData};</code>
  218. * <code>arm_matrix_instance_q31 S = {nRows, nColumns, pData};</code>
  219. * <code>arm_matrix_instance_q15 S = {nRows, nColumns, pData};</code>
  220. * </pre>
  221. * where <code>nRows</code> specifies the number of rows, <code>nColumns</code>
  222. * specifies the number of columns, and <code>pData</code> points to the
  223. * data array.
  224. *
  225. * \par Size Checking
  226. * By default all of the matrix functions perform size checking on the input and
  227. * output matrices. For example, the matrix addition function verifies that the
  228. * two input matrices and the output matrix all have the same number of rows and
  229. * columns. If the size check fails the functions return:
  230. * <pre>
  231. * ARM_MATH_SIZE_MISMATCH
  232. * </pre>
  233. * Otherwise the functions return
  234. * <pre>
  235. * ARM_MATH_SUCCESS
  236. * </pre>
  237. * There is some overhead associated with this matrix size checking.
  238. * The matrix size checking is enabled via the \#define
  239. * <pre>
  240. * ARM_MATH_MATRIX_CHECK
  241. * </pre>
  242. * within the library project settings. By default this macro is defined
  243. * and size checking is enabled. By changing the project settings and
  244. * undefining this macro size checking is eliminated and the functions
  245. * run a bit faster. With size checking disabled the functions always
  246. * return <code>ARM_MATH_SUCCESS</code>.
  247. */
  248. /**
  249. * @defgroup groupTransforms Transform Functions
  250. */
  251. /**
  252. * @defgroup groupController Controller Functions
  253. */
  254. /**
  255. * @defgroup groupStats Statistics Functions
  256. */
  257. /**
  258. * @defgroup groupSupport Support Functions
  259. */
  260. /**
  261. * @defgroup groupInterpolation Interpolation Functions
  262. * These functions perform 1- and 2-dimensional interpolation of data.
  263. * Linear interpolation is used for 1-dimensional data and
  264. * bilinear interpolation is used for 2-dimensional data.
  265. */
  266. /**
  267. * @defgroup groupExamples Examples
  268. */
  269. #ifndef _ARM_MATH_H
  270. #define _ARM_MATH_H
  271. #define __CMSIS_GENERIC /* disable NVIC and Systick functions */
  272. #if defined(ARM_MATH_CM7)
  273. #include "core_cm7.h"
  274. #elif defined (ARM_MATH_CM4)
  275. #include "core_cm4.h"
  276. #elif defined (ARM_MATH_CM3)
  277. #include "core_cm3.h"
  278. #elif defined (ARM_MATH_CM0)
  279. #include "core_cm0.h"
  280. #define ARM_MATH_CM0_FAMILY
  281. #elif defined (ARM_MATH_CM0PLUS)
  282. #include "core_cm0plus.h"
  283. #define ARM_MATH_CM0_FAMILY
  284. #else
  285. #error "Define according the used Cortex core ARM_MATH_CM7, ARM_MATH_CM4, ARM_MATH_CM3, ARM_MATH_CM0PLUS or ARM_MATH_CM0"
  286. #endif
  287. #undef __CMSIS_GENERIC /* enable NVIC and Systick functions */
  288. #include "string.h"
  289. #include "math.h"
  290. #ifdef __cplusplus
  291. extern "C"
  292. {
  293. #endif
  294. /**
  295. * @brief Macros required for reciprocal calculation in Normalized LMS
  296. */
  297. #define DELTA_Q31 (0x100)
  298. #define DELTA_Q15 0x5
  299. #define INDEX_MASK 0x0000003F
  300. #ifndef PI
  301. #define PI 3.14159265358979f
  302. #endif
  303. /**
  304. * @brief Macros required for SINE and COSINE Fast math approximations
  305. */
  306. #define FAST_MATH_TABLE_SIZE 512
  307. #define FAST_MATH_Q31_SHIFT (32 - 10)
  308. #define FAST_MATH_Q15_SHIFT (16 - 10)
  309. #define CONTROLLER_Q31_SHIFT (32 - 9)
  310. #define TABLE_SIZE 256
  311. #define TABLE_SPACING_Q31 0x400000
  312. #define TABLE_SPACING_Q15 0x80
  313. /**
  314. * @brief Macros required for SINE and COSINE Controller functions
  315. */
  316. /* 1.31(q31) Fixed value of 2/360 */
  317. /* -1 to +1 is divided into 360 values so total spacing is (2/360) */
  318. #define INPUT_SPACING 0xB60B61
  319. /**
  320. * @brief Macro for Unaligned Support
  321. */
  322. #ifndef UNALIGNED_SUPPORT_DISABLE
  323. #define ALIGN4
  324. #else
  325. #if defined (__GNUC__)
  326. #define ALIGN4 __attribute__((aligned(4)))
  327. #else
  328. #define ALIGN4 __align(4)
  329. #endif
  330. #endif /* #ifndef UNALIGNED_SUPPORT_DISABLE */
  331. /**
  332. * @brief Error status returned by some functions in the library.
  333. */
  334. typedef enum
  335. {
  336. ARM_MATH_SUCCESS = 0, /**< No error */
  337. ARM_MATH_ARGUMENT_ERROR = -1, /**< One or more arguments are incorrect */
  338. ARM_MATH_LENGTH_ERROR = -2, /**< Length of data buffer is incorrect */
  339. ARM_MATH_SIZE_MISMATCH = -3, /**< Size of matrices is not compatible with the operation. */
  340. ARM_MATH_NANINF = -4, /**< Not-a-number (NaN) or infinity is generated */
  341. ARM_MATH_SINGULAR = -5, /**< Generated by matrix inversion if the input matrix is singular and cannot be inverted. */
  342. ARM_MATH_TEST_FAILURE = -6 /**< Test Failed */
  343. } arm_status;
  344. /**
  345. * @brief 8-bit fractional data type in 1.7 format.
  346. */
  347. typedef int8_t q7_t;
  348. /**
  349. * @brief 16-bit fractional data type in 1.15 format.
  350. */
  351. typedef int16_t q15_t;
  352. /**
  353. * @brief 32-bit fractional data type in 1.31 format.
  354. */
  355. typedef int32_t q31_t;
  356. /**
  357. * @brief 64-bit fractional data type in 1.63 format.
  358. */
  359. typedef int64_t q63_t;
  360. /**
  361. * @brief 32-bit floating-point type definition.
  362. */
  363. typedef float float32_t;
  364. /**
  365. * @brief 64-bit floating-point type definition.
  366. */
  367. typedef double float64_t;
  368. /**
  369. * @brief definition to read/write two 16 bit values.
  370. */
  371. #if defined __CC_ARM
  372. #define __SIMD32_TYPE int32_t __packed
  373. #define CMSIS_UNUSED __attribute__((unused))
  374. #elif defined __ICCARM__
  375. #define CMSIS_UNUSED
  376. #define __SIMD32_TYPE int32_t __packed
  377. #elif defined __GNUC__
  378. #define __SIMD32_TYPE int32_t
  379. #define CMSIS_UNUSED __attribute__((unused))
  380. #elif defined __CSMC__ /* Cosmic */
  381. #define CMSIS_UNUSED
  382. #define __SIMD32_TYPE int32_t
  383. #else
  384. #error Unknown compiler
  385. #endif
  386. #define __SIMD32(addr) (*(__SIMD32_TYPE **) & (addr))
  387. #define __SIMD32_CONST(addr) ((__SIMD32_TYPE *)(addr))
  388. #define _SIMD32_OFFSET(addr) (*(__SIMD32_TYPE *) (addr))
  389. #define __SIMD64(addr) (*(int64_t **) & (addr))
  390. #if defined (ARM_MATH_CM3) || defined (ARM_MATH_CM0_FAMILY)
  391. /**
  392. * @brief definition to pack two 16 bit values.
  393. */
  394. #define __PKHBT(ARG1, ARG2, ARG3) ( (((int32_t)(ARG1) << 0) & (int32_t)0x0000FFFF) | \
  395. (((int32_t)(ARG2) << ARG3) & (int32_t)0xFFFF0000) )
  396. #define __PKHTB(ARG1, ARG2, ARG3) ( (((int32_t)(ARG1) << 0) & (int32_t)0xFFFF0000) | \
  397. (((int32_t)(ARG2) >> ARG3) & (int32_t)0x0000FFFF) )
  398. #endif
  399. /**
  400. * @brief definition to pack four 8 bit values.
  401. */
  402. #ifndef ARM_MATH_BIG_ENDIAN
  403. #define __PACKq7(v0,v1,v2,v3) ( (((int32_t)(v0) << 0) & (int32_t)0x000000FF) | \
  404. (((int32_t)(v1) << 8) & (int32_t)0x0000FF00) | \
  405. (((int32_t)(v2) << 16) & (int32_t)0x00FF0000) | \
  406. (((int32_t)(v3) << 24) & (int32_t)0xFF000000) )
  407. #else
  408. #define __PACKq7(v0,v1,v2,v3) ( (((int32_t)(v3) << 0) & (int32_t)0x000000FF) | \
  409. (((int32_t)(v2) << 8) & (int32_t)0x0000FF00) | \
  410. (((int32_t)(v1) << 16) & (int32_t)0x00FF0000) | \
  411. (((int32_t)(v0) << 24) & (int32_t)0xFF000000) )
  412. #endif
  413. /**
  414. * @brief Clips Q63 to Q31 values.
  415. */
  416. static __INLINE q31_t clip_q63_to_q31(
  417. q63_t x)
  418. {
  419. return ((q31_t) (x >> 32) != ((q31_t) x >> 31)) ?
  420. ((0x7FFFFFFF ^ ((q31_t) (x >> 63)))) : (q31_t) x;
  421. }
  422. /**
  423. * @brief Clips Q63 to Q15 values.
  424. */
  425. static __INLINE q15_t clip_q63_to_q15(
  426. q63_t x)
  427. {
  428. return ((q31_t) (x >> 32) != ((q31_t) x >> 31)) ?
  429. ((0x7FFF ^ ((q15_t) (x >> 63)))) : (q15_t) (x >> 15);
  430. }
  431. /**
  432. * @brief Clips Q31 to Q7 values.
  433. */
  434. static __INLINE q7_t clip_q31_to_q7(
  435. q31_t x)
  436. {
  437. return ((q31_t) (x >> 24) != ((q31_t) x >> 23)) ?
  438. ((0x7F ^ ((q7_t) (x >> 31)))) : (q7_t) x;
  439. }
  440. /**
  441. * @brief Clips Q31 to Q15 values.
  442. */
  443. static __INLINE q15_t clip_q31_to_q15(
  444. q31_t x)
  445. {
  446. return ((q31_t) (x >> 16) != ((q31_t) x >> 15)) ?
  447. ((0x7FFF ^ ((q15_t) (x >> 31)))) : (q15_t) x;
  448. }
  449. /**
  450. * @brief Multiplies 32 X 64 and returns 32 bit result in 2.30 format.
  451. */
  452. static __INLINE q63_t mult32x64(
  453. q63_t x,
  454. q31_t y)
  455. {
  456. return ((((q63_t) (x & 0x00000000FFFFFFFF) * y) >> 32) +
  457. (((q63_t) (x >> 32) * y)));
  458. }
  459. #if defined (ARM_MATH_CM0_FAMILY) && defined ( __CC_ARM )
  460. #define __CLZ __clz
  461. #endif
  462. #if defined (ARM_MATH_CM0_FAMILY) && ((defined (__ICCARM__)) ||(defined (__GNUC__)) || defined (__TASKING__) )
  463. static __INLINE uint32_t __CLZ(
  464. q31_t data);
  465. static __INLINE uint32_t __CLZ(
  466. q31_t data)
  467. {
  468. uint32_t count = 0;
  469. uint32_t mask = 0x80000000;
  470. while((data & mask) == 0)
  471. {
  472. count += 1u;
  473. mask = mask >> 1u;
  474. }
  475. return (count);
  476. }
  477. #endif
  478. /**
  479. * @brief Function to Calculates 1/in (reciprocal) value of Q31 Data type.
  480. */
  481. static __INLINE uint32_t arm_recip_q31(
  482. q31_t in,
  483. q31_t * dst,
  484. q31_t * pRecipTable)
  485. {
  486. uint32_t out, tempVal;
  487. uint32_t index, i;
  488. uint32_t signBits;
  489. if(in > 0)
  490. {
  491. signBits = __CLZ(in) - 1;
  492. }
  493. else
  494. {
  495. signBits = __CLZ(-in) - 1;
  496. }
  497. /* Convert input sample to 1.31 format */
  498. in = in << signBits;
  499. /* calculation of index for initial approximated Val */
  500. index = (uint32_t) (in >> 24u);
  501. index = (index & INDEX_MASK);
  502. /* 1.31 with exp 1 */
  503. out = pRecipTable[index];
  504. /* calculation of reciprocal value */
  505. /* running approximation for two iterations */
  506. for (i = 0u; i < 2u; i++)
  507. {
  508. tempVal = (q31_t) (((q63_t) in * out) >> 31u);
  509. tempVal = 0x7FFFFFFF - tempVal;
  510. /* 1.31 with exp 1 */
  511. //out = (q31_t) (((q63_t) out * tempVal) >> 30u);
  512. out = (q31_t) clip_q63_to_q31(((q63_t) out * tempVal) >> 30u);
  513. }
  514. /* write output */
  515. *dst = out;
  516. /* return num of signbits of out = 1/in value */
  517. return (signBits + 1u);
  518. }
  519. /**
  520. * @brief Function to Calculates 1/in (reciprocal) value of Q15 Data type.
  521. */
  522. static __INLINE uint32_t arm_recip_q15(
  523. q15_t in,
  524. q15_t * dst,
  525. q15_t * pRecipTable)
  526. {
  527. uint32_t out = 0, tempVal = 0;
  528. uint32_t index = 0, i = 0;
  529. uint32_t signBits = 0;
  530. if(in > 0)
  531. {
  532. signBits = __CLZ(in) - 17;
  533. }
  534. else
  535. {
  536. signBits = __CLZ(-in) - 17;
  537. }
  538. /* Convert input sample to 1.15 format */
  539. in = in << signBits;
  540. /* calculation of index for initial approximated Val */
  541. index = in >> 8;
  542. index = (index & INDEX_MASK);
  543. /* 1.15 with exp 1 */
  544. out = pRecipTable[index];
  545. /* calculation of reciprocal value */
  546. /* running approximation for two iterations */
  547. for (i = 0; i < 2; i++)
  548. {
  549. tempVal = (q15_t) (((q31_t) in * out) >> 15);
  550. tempVal = 0x7FFF - tempVal;
  551. /* 1.15 with exp 1 */
  552. out = (q15_t) (((q31_t) out * tempVal) >> 14);
  553. }
  554. /* write output */
  555. *dst = out;
  556. /* return num of signbits of out = 1/in value */
  557. return (signBits + 1);
  558. }
  559. /*
  560. * @brief C custom defined intrinisic function for only M0 processors
  561. */
  562. #if defined(ARM_MATH_CM0_FAMILY)
  563. static __INLINE q31_t __SSAT(
  564. q31_t x,
  565. uint32_t y)
  566. {
  567. int32_t posMax, negMin;
  568. uint32_t i;
  569. posMax = 1;
  570. for (i = 0; i < (y - 1); i++)
  571. {
  572. posMax = posMax * 2;
  573. }
  574. if(x > 0)
  575. {
  576. posMax = (posMax - 1);
  577. if(x > posMax)
  578. {
  579. x = posMax;
  580. }
  581. }
  582. else
  583. {
  584. negMin = -posMax;
  585. if(x < negMin)
  586. {
  587. x = negMin;
  588. }
  589. }
  590. return (x);
  591. }
  592. #endif /* end of ARM_MATH_CM0_FAMILY */
  593. /*
  594. * @brief C custom defined intrinsic function for M3 and M0 processors
  595. */
  596. #if defined (ARM_MATH_CM3) || defined (ARM_MATH_CM0_FAMILY)
  597. /*
  598. * @brief C custom defined QADD8 for M3 and M0 processors
  599. */
  600. static __INLINE q31_t __QADD8(
  601. q31_t x,
  602. q31_t y)
  603. {
  604. q31_t sum;
  605. q7_t r, s, t, u;
  606. r = (q7_t) x;
  607. s = (q7_t) y;
  608. r = __SSAT((q31_t) (r + s), 8);
  609. s = __SSAT(((q31_t) (((x << 16) >> 24) + ((y << 16) >> 24))), 8);
  610. t = __SSAT(((q31_t) (((x << 8) >> 24) + ((y << 8) >> 24))), 8);
  611. u = __SSAT(((q31_t) ((x >> 24) + (y >> 24))), 8);
  612. sum =
  613. (((q31_t) u << 24) & 0xFF000000) | (((q31_t) t << 16) & 0x00FF0000) |
  614. (((q31_t) s << 8) & 0x0000FF00) | (r & 0x000000FF);
  615. return sum;
  616. }
  617. /*
  618. * @brief C custom defined QSUB8 for M3 and M0 processors
  619. */
  620. static __INLINE q31_t __QSUB8(
  621. q31_t x,
  622. q31_t y)
  623. {
  624. q31_t sum;
  625. q31_t r, s, t, u;
  626. r = (q7_t) x;
  627. s = (q7_t) y;
  628. r = __SSAT((r - s), 8);
  629. s = __SSAT(((q31_t) (((x << 16) >> 24) - ((y << 16) >> 24))), 8) << 8;
  630. t = __SSAT(((q31_t) (((x << 8) >> 24) - ((y << 8) >> 24))), 8) << 16;
  631. u = __SSAT(((q31_t) ((x >> 24) - (y >> 24))), 8) << 24;
  632. sum =
  633. (u & 0xFF000000) | (t & 0x00FF0000) | (s & 0x0000FF00) | (r &
  634. 0x000000FF);
  635. return sum;
  636. }
  637. /*
  638. * @brief C custom defined QADD16 for M3 and M0 processors
  639. */
  640. /*
  641. * @brief C custom defined QADD16 for M3 and M0 processors
  642. */
  643. static __INLINE q31_t __QADD16(
  644. q31_t x,
  645. q31_t y)
  646. {
  647. q31_t sum;
  648. q31_t r, s;
  649. r = (q15_t) x;
  650. s = (q15_t) y;
  651. r = __SSAT(r + s, 16);
  652. s = __SSAT(((q31_t) ((x >> 16) + (y >> 16))), 16) << 16;
  653. sum = (s & 0xFFFF0000) | (r & 0x0000FFFF);
  654. return sum;
  655. }
  656. /*
  657. * @brief C custom defined SHADD16 for M3 and M0 processors
  658. */
  659. static __INLINE q31_t __SHADD16(
  660. q31_t x,
  661. q31_t y)
  662. {
  663. q31_t sum;
  664. q31_t r, s;
  665. r = (q15_t) x;
  666. s = (q15_t) y;
  667. r = ((r >> 1) + (s >> 1));
  668. s = ((q31_t) ((x >> 17) + (y >> 17))) << 16;
  669. sum = (s & 0xFFFF0000) | (r & 0x0000FFFF);
  670. return sum;
  671. }
  672. /*
  673. * @brief C custom defined QSUB16 for M3 and M0 processors
  674. */
  675. static __INLINE q31_t __QSUB16(
  676. q31_t x,
  677. q31_t y)
  678. {
  679. q31_t sum;
  680. q31_t r, s;
  681. r = (q15_t) x;
  682. s = (q15_t) y;
  683. r = __SSAT(r - s, 16);
  684. s = __SSAT(((q31_t) ((x >> 16) - (y >> 16))), 16) << 16;
  685. sum = (s & 0xFFFF0000) | (r & 0x0000FFFF);
  686. return sum;
  687. }
  688. /*
  689. * @brief C custom defined SHSUB16 for M3 and M0 processors
  690. */
  691. static __INLINE q31_t __SHSUB16(
  692. q31_t x,
  693. q31_t y)
  694. {
  695. q31_t diff;
  696. q31_t r, s;
  697. r = (q15_t) x;
  698. s = (q15_t) y;
  699. r = ((r >> 1) - (s >> 1));
  700. s = (((x >> 17) - (y >> 17)) << 16);
  701. diff = (s & 0xFFFF0000) | (r & 0x0000FFFF);
  702. return diff;
  703. }
  704. /*
  705. * @brief C custom defined QASX for M3 and M0 processors
  706. */
  707. static __INLINE q31_t __QASX(
  708. q31_t x,
  709. q31_t y)
  710. {
  711. q31_t sum = 0;
  712. sum =
  713. ((sum +
  714. clip_q31_to_q15((q31_t) ((q15_t) (x >> 16) + (q15_t) y))) << 16) +
  715. clip_q31_to_q15((q31_t) ((q15_t) x - (q15_t) (y >> 16)));
  716. return sum;
  717. }
  718. /*
  719. * @brief C custom defined SHASX for M3 and M0 processors
  720. */
  721. static __INLINE q31_t __SHASX(
  722. q31_t x,
  723. q31_t y)
  724. {
  725. q31_t sum;
  726. q31_t r, s;
  727. r = (q15_t) x;
  728. s = (q15_t) y;
  729. r = ((r >> 1) - (y >> 17));
  730. s = (((x >> 17) + (s >> 1)) << 16);
  731. sum = (s & 0xFFFF0000) | (r & 0x0000FFFF);
  732. return sum;
  733. }
  734. /*
  735. * @brief C custom defined QSAX for M3 and M0 processors
  736. */
  737. static __INLINE q31_t __QSAX(
  738. q31_t x,
  739. q31_t y)
  740. {
  741. q31_t sum = 0;
  742. sum =
  743. ((sum +
  744. clip_q31_to_q15((q31_t) ((q15_t) (x >> 16) - (q15_t) y))) << 16) +
  745. clip_q31_to_q15((q31_t) ((q15_t) x + (q15_t) (y >> 16)));
  746. return sum;
  747. }
  748. /*
  749. * @brief C custom defined SHSAX for M3 and M0 processors
  750. */
  751. static __INLINE q31_t __SHSAX(
  752. q31_t x,
  753. q31_t y)
  754. {
  755. q31_t sum;
  756. q31_t r, s;
  757. r = (q15_t) x;
  758. s = (q15_t) y;
  759. r = ((r >> 1) + (y >> 17));
  760. s = (((x >> 17) - (s >> 1)) << 16);
  761. sum = (s & 0xFFFF0000) | (r & 0x0000FFFF);
  762. return sum;
  763. }
  764. /*
  765. * @brief C custom defined SMUSDX for M3 and M0 processors
  766. */
  767. static __INLINE q31_t __SMUSDX(
  768. q31_t x,
  769. q31_t y)
  770. {
  771. return ((q31_t) (((q15_t) x * (q15_t) (y >> 16)) -
  772. ((q15_t) (x >> 16) * (q15_t) y)));
  773. }
  774. /*
  775. * @brief C custom defined SMUADX for M3 and M0 processors
  776. */
  777. static __INLINE q31_t __SMUADX(
  778. q31_t x,
  779. q31_t y)
  780. {
  781. return ((q31_t) (((q15_t) x * (q15_t) (y >> 16)) +
  782. ((q15_t) (x >> 16) * (q15_t) y)));
  783. }
  784. /*
  785. * @brief C custom defined QADD for M3 and M0 processors
  786. */
  787. static __INLINE q31_t __QADD(
  788. q31_t x,
  789. q31_t y)
  790. {
  791. return clip_q63_to_q31((q63_t) x + y);
  792. }
  793. /*
  794. * @brief C custom defined QSUB for M3 and M0 processors
  795. */
  796. static __INLINE q31_t __QSUB(
  797. q31_t x,
  798. q31_t y)
  799. {
  800. return clip_q63_to_q31((q63_t) x - y);
  801. }
  802. /*
  803. * @brief C custom defined SMLAD for M3 and M0 processors
  804. */
  805. static __INLINE q31_t __SMLAD(
  806. q31_t x,
  807. q31_t y,
  808. q31_t sum)
  809. {
  810. return (sum + ((q15_t) (x >> 16) * (q15_t) (y >> 16)) +
  811. ((q15_t) x * (q15_t) y));
  812. }
  813. /*
  814. * @brief C custom defined SMLADX for M3 and M0 processors
  815. */
  816. static __INLINE q31_t __SMLADX(
  817. q31_t x,
  818. q31_t y,
  819. q31_t sum)
  820. {
  821. return (sum + ((q15_t) (x >> 16) * (q15_t) (y)) +
  822. ((q15_t) x * (q15_t) (y >> 16)));
  823. }
  824. /*
  825. * @brief C custom defined SMLSDX for M3 and M0 processors
  826. */
  827. static __INLINE q31_t __SMLSDX(
  828. q31_t x,
  829. q31_t y,
  830. q31_t sum)
  831. {
  832. return (sum - ((q15_t) (x >> 16) * (q15_t) (y)) +
  833. ((q15_t) x * (q15_t) (y >> 16)));
  834. }
  835. /*
  836. * @brief C custom defined SMLALD for M3 and M0 processors
  837. */
  838. static __INLINE q63_t __SMLALD(
  839. q31_t x,
  840. q31_t y,
  841. q63_t sum)
  842. {
  843. return (sum + ((q15_t) (x >> 16) * (q15_t) (y >> 16)) +
  844. ((q15_t) x * (q15_t) y));
  845. }
  846. /*
  847. * @brief C custom defined SMLALDX for M3 and M0 processors
  848. */
  849. static __INLINE q63_t __SMLALDX(
  850. q31_t x,
  851. q31_t y,
  852. q63_t sum)
  853. {
  854. return (sum + ((q15_t) (x >> 16) * (q15_t) y)) +
  855. ((q15_t) x * (q15_t) (y >> 16));
  856. }
  857. /*
  858. * @brief C custom defined SMUAD for M3 and M0 processors
  859. */
  860. static __INLINE q31_t __SMUAD(
  861. q31_t x,
  862. q31_t y)
  863. {
  864. return (((x >> 16) * (y >> 16)) +
  865. (((x << 16) >> 16) * ((y << 16) >> 16)));
  866. }
  867. /*
  868. * @brief C custom defined SMUSD for M3 and M0 processors
  869. */
  870. static __INLINE q31_t __SMUSD(
  871. q31_t x,
  872. q31_t y)
  873. {
  874. return (-((x >> 16) * (y >> 16)) +
  875. (((x << 16) >> 16) * ((y << 16) >> 16)));
  876. }
  877. /*
  878. * @brief C custom defined SXTB16 for M3 and M0 processors
  879. */
  880. static __INLINE q31_t __SXTB16(
  881. q31_t x)
  882. {
  883. return ((((x << 24) >> 24) & 0x0000FFFF) |
  884. (((x << 8) >> 8) & 0xFFFF0000));
  885. }
  886. #endif /* defined (ARM_MATH_CM3) || defined (ARM_MATH_CM0_FAMILY) */
  887. /**
  888. * @brief Instance structure for the Q7 FIR filter.
  889. */
  890. typedef struct
  891. {
  892. uint16_t numTaps; /**< number of filter coefficients in the filter. */
  893. q7_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  894. q7_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
  895. } arm_fir_instance_q7;
  896. /**
  897. * @brief Instance structure for the Q15 FIR filter.
  898. */
  899. typedef struct
  900. {
  901. uint16_t numTaps; /**< number of filter coefficients in the filter. */
  902. q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  903. q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
  904. } arm_fir_instance_q15;
  905. /**
  906. * @brief Instance structure for the Q31 FIR filter.
  907. */
  908. typedef struct
  909. {
  910. uint16_t numTaps; /**< number of filter coefficients in the filter. */
  911. q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  912. q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
  913. } arm_fir_instance_q31;
  914. /**
  915. * @brief Instance structure for the floating-point FIR filter.
  916. */
  917. typedef struct
  918. {
  919. uint16_t numTaps; /**< number of filter coefficients in the filter. */
  920. float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  921. float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
  922. } arm_fir_instance_f32;
  923. /**
  924. * @brief Processing function for the Q7 FIR filter.
  925. * @param[in] *S points to an instance of the Q7 FIR filter structure.
  926. * @param[in] *pSrc points to the block of input data.
  927. * @param[out] *pDst points to the block of output data.
  928. * @param[in] blockSize number of samples to process.
  929. * @return none.
  930. */
  931. void arm_fir_q7(
  932. const arm_fir_instance_q7 * S,
  933. q7_t * pSrc,
  934. q7_t * pDst,
  935. uint32_t blockSize);
  936. /**
  937. * @brief Initialization function for the Q7 FIR filter.
  938. * @param[in,out] *S points to an instance of the Q7 FIR structure.
  939. * @param[in] numTaps Number of filter coefficients in the filter.
  940. * @param[in] *pCoeffs points to the filter coefficients.
  941. * @param[in] *pState points to the state buffer.
  942. * @param[in] blockSize number of samples that are processed.
  943. * @return none
  944. */
  945. void arm_fir_init_q7(
  946. arm_fir_instance_q7 * S,
  947. uint16_t numTaps,
  948. q7_t * pCoeffs,
  949. q7_t * pState,
  950. uint32_t blockSize);
  951. /**
  952. * @brief Processing function for the Q15 FIR filter.
  953. * @param[in] *S points to an instance of the Q15 FIR structure.
  954. * @param[in] *pSrc points to the block of input data.
  955. * @param[out] *pDst points to the block of output data.
  956. * @param[in] blockSize number of samples to process.
  957. * @return none.
  958. */
  959. void arm_fir_q15(
  960. const arm_fir_instance_q15 * S,
  961. q15_t * pSrc,
  962. q15_t * pDst,
  963. uint32_t blockSize);
  964. /**
  965. * @brief Processing function for the fast Q15 FIR filter for Cortex-M3 and Cortex-M4.
  966. * @param[in] *S points to an instance of the Q15 FIR filter structure.
  967. * @param[in] *pSrc points to the block of input data.
  968. * @param[out] *pDst points to the block of output data.
  969. * @param[in] blockSize number of samples to process.
  970. * @return none.
  971. */
  972. void arm_fir_fast_q15(
  973. const arm_fir_instance_q15 * S,
  974. q15_t * pSrc,
  975. q15_t * pDst,
  976. uint32_t blockSize);
  977. /**
  978. * @brief Initialization function for the Q15 FIR filter.
  979. * @param[in,out] *S points to an instance of the Q15 FIR filter structure.
  980. * @param[in] numTaps Number of filter coefficients in the filter. Must be even and greater than or equal to 4.
  981. * @param[in] *pCoeffs points to the filter coefficients.
  982. * @param[in] *pState points to the state buffer.
  983. * @param[in] blockSize number of samples that are processed at a time.
  984. * @return The function returns ARM_MATH_SUCCESS if initialization was successful or ARM_MATH_ARGUMENT_ERROR if
  985. * <code>numTaps</code> is not a supported value.
  986. */
  987. arm_status arm_fir_init_q15(
  988. arm_fir_instance_q15 * S,
  989. uint16_t numTaps,
  990. q15_t * pCoeffs,
  991. q15_t * pState,
  992. uint32_t blockSize);
  993. /**
  994. * @brief Processing function for the Q31 FIR filter.
  995. * @param[in] *S points to an instance of the Q31 FIR filter structure.
  996. * @param[in] *pSrc points to the block of input data.
  997. * @param[out] *pDst points to the block of output data.
  998. * @param[in] blockSize number of samples to process.
  999. * @return none.
  1000. */
  1001. void arm_fir_q31(
  1002. const arm_fir_instance_q31 * S,
  1003. q31_t * pSrc,
  1004. q31_t * pDst,
  1005. uint32_t blockSize);
  1006. /**
  1007. * @brief Processing function for the fast Q31 FIR filter for Cortex-M3 and Cortex-M4.
  1008. * @param[in] *S points to an instance of the Q31 FIR structure.
  1009. * @param[in] *pSrc points to the block of input data.
  1010. * @param[out] *pDst points to the block of output data.
  1011. * @param[in] blockSize number of samples to process.
  1012. * @return none.
  1013. */
  1014. void arm_fir_fast_q31(
  1015. const arm_fir_instance_q31 * S,
  1016. q31_t * pSrc,
  1017. q31_t * pDst,
  1018. uint32_t blockSize);
  1019. /**
  1020. * @brief Initialization function for the Q31 FIR filter.
  1021. * @param[in,out] *S points to an instance of the Q31 FIR structure.
  1022. * @param[in] numTaps Number of filter coefficients in the filter.
  1023. * @param[in] *pCoeffs points to the filter coefficients.
  1024. * @param[in] *pState points to the state buffer.
  1025. * @param[in] blockSize number of samples that are processed at a time.
  1026. * @return none.
  1027. */
  1028. void arm_fir_init_q31(
  1029. arm_fir_instance_q31 * S,
  1030. uint16_t numTaps,
  1031. q31_t * pCoeffs,
  1032. q31_t * pState,
  1033. uint32_t blockSize);
  1034. /**
  1035. * @brief Processing function for the floating-point FIR filter.
  1036. * @param[in] *S points to an instance of the floating-point FIR structure.
  1037. * @param[in] *pSrc points to the block of input data.
  1038. * @param[out] *pDst points to the block of output data.
  1039. * @param[in] blockSize number of samples to process.
  1040. * @return none.
  1041. */
  1042. void arm_fir_f32(
  1043. const arm_fir_instance_f32 * S,
  1044. float32_t * pSrc,
  1045. float32_t * pDst,
  1046. uint32_t blockSize);
  1047. /**
  1048. * @brief Initialization function for the floating-point FIR filter.
  1049. * @param[in,out] *S points to an instance of the floating-point FIR filter structure.
  1050. * @param[in] numTaps Number of filter coefficients in the filter.
  1051. * @param[in] *pCoeffs points to the filter coefficients.
  1052. * @param[in] *pState points to the state buffer.
  1053. * @param[in] blockSize number of samples that are processed at a time.
  1054. * @return none.
  1055. */
  1056. void arm_fir_init_f32(
  1057. arm_fir_instance_f32 * S,
  1058. uint16_t numTaps,
  1059. float32_t * pCoeffs,
  1060. float32_t * pState,
  1061. uint32_t blockSize);
  1062. /**
  1063. * @brief Instance structure for the Q15 Biquad cascade filter.
  1064. */
  1065. typedef struct
  1066. {
  1067. int8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
  1068. q15_t *pState; /**< Points to the array of state coefficients. The array is of length 4*numStages. */
  1069. q15_t *pCoeffs; /**< Points to the array of coefficients. The array is of length 5*numStages. */
  1070. int8_t postShift; /**< Additional shift, in bits, applied to each output sample. */
  1071. } arm_biquad_casd_df1_inst_q15;
  1072. /**
  1073. * @brief Instance structure for the Q31 Biquad cascade filter.
  1074. */
  1075. typedef struct
  1076. {
  1077. uint32_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
  1078. q31_t *pState; /**< Points to the array of state coefficients. The array is of length 4*numStages. */
  1079. q31_t *pCoeffs; /**< Points to the array of coefficients. The array is of length 5*numStages. */
  1080. uint8_t postShift; /**< Additional shift, in bits, applied to each output sample. */
  1081. } arm_biquad_casd_df1_inst_q31;
  1082. /**
  1083. * @brief Instance structure for the floating-point Biquad cascade filter.
  1084. */
  1085. typedef struct
  1086. {
  1087. uint32_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
  1088. float32_t *pState; /**< Points to the array of state coefficients. The array is of length 4*numStages. */
  1089. float32_t *pCoeffs; /**< Points to the array of coefficients. The array is of length 5*numStages. */
  1090. } arm_biquad_casd_df1_inst_f32;
  1091. /**
  1092. * @brief Processing function for the Q15 Biquad cascade filter.
  1093. * @param[in] *S points to an instance of the Q15 Biquad cascade structure.
  1094. * @param[in] *pSrc points to the block of input data.
  1095. * @param[out] *pDst points to the block of output data.
  1096. * @param[in] blockSize number of samples to process.
  1097. * @return none.
  1098. */
  1099. void arm_biquad_cascade_df1_q15(
  1100. const arm_biquad_casd_df1_inst_q15 * S,
  1101. q15_t * pSrc,
  1102. q15_t * pDst,
  1103. uint32_t blockSize);
  1104. /**
  1105. * @brief Initialization function for the Q15 Biquad cascade filter.
  1106. * @param[in,out] *S points to an instance of the Q15 Biquad cascade structure.
  1107. * @param[in] numStages number of 2nd order stages in the filter.
  1108. * @param[in] *pCoeffs points to the filter coefficients.
  1109. * @param[in] *pState points to the state buffer.
  1110. * @param[in] postShift Shift to be applied to the output. Varies according to the coefficients format
  1111. * @return none
  1112. */
  1113. void arm_biquad_cascade_df1_init_q15(
  1114. arm_biquad_casd_df1_inst_q15 * S,
  1115. uint8_t numStages,
  1116. q15_t * pCoeffs,
  1117. q15_t * pState,
  1118. int8_t postShift);
  1119. /**
  1120. * @brief Fast but less precise processing function for the Q15 Biquad cascade filter for Cortex-M3 and Cortex-M4.
  1121. * @param[in] *S points to an instance of the Q15 Biquad cascade structure.
  1122. * @param[in] *pSrc points to the block of input data.
  1123. * @param[out] *pDst points to the block of output data.
  1124. * @param[in] blockSize number of samples to process.
  1125. * @return none.
  1126. */
  1127. void arm_biquad_cascade_df1_fast_q15(
  1128. const arm_biquad_casd_df1_inst_q15 * S,
  1129. q15_t * pSrc,
  1130. q15_t * pDst,
  1131. uint32_t blockSize);
  1132. /**
  1133. * @brief Processing function for the Q31 Biquad cascade filter
  1134. * @param[in] *S points to an instance of the Q31 Biquad cascade structure.
  1135. * @param[in] *pSrc points to the block of input data.
  1136. * @param[out] *pDst points to the block of output data.
  1137. * @param[in] blockSize number of samples to process.
  1138. * @return none.
  1139. */
  1140. void arm_biquad_cascade_df1_q31(
  1141. const arm_biquad_casd_df1_inst_q31 * S,
  1142. q31_t * pSrc,
  1143. q31_t * pDst,
  1144. uint32_t blockSize);
  1145. /**
  1146. * @brief Fast but less precise processing function for the Q31 Biquad cascade filter for Cortex-M3 and Cortex-M4.
  1147. * @param[in] *S points to an instance of the Q31 Biquad cascade structure.
  1148. * @param[in] *pSrc points to the block of input data.
  1149. * @param[out] *pDst points to the block of output data.
  1150. * @param[in] blockSize number of samples to process.
  1151. * @return none.
  1152. */
  1153. void arm_biquad_cascade_df1_fast_q31(
  1154. const arm_biquad_casd_df1_inst_q31 * S,
  1155. q31_t * pSrc,
  1156. q31_t * pDst,
  1157. uint32_t blockSize);
  1158. /**
  1159. * @brief Initialization function for the Q31 Biquad cascade filter.
  1160. * @param[in,out] *S points to an instance of the Q31 Biquad cascade structure.
  1161. * @param[in] numStages number of 2nd order stages in the filter.
  1162. * @param[in] *pCoeffs points to the filter coefficients.
  1163. * @param[in] *pState points to the state buffer.
  1164. * @param[in] postShift Shift to be applied to the output. Varies according to the coefficients format
  1165. * @return none
  1166. */
  1167. void arm_biquad_cascade_df1_init_q31(
  1168. arm_biquad_casd_df1_inst_q31 * S,
  1169. uint8_t numStages,
  1170. q31_t * pCoeffs,
  1171. q31_t * pState,
  1172. int8_t postShift);
  1173. /**
  1174. * @brief Processing function for the floating-point Biquad cascade filter.
  1175. * @param[in] *S points to an instance of the floating-point Biquad cascade structure.
  1176. * @param[in] *pSrc points to the block of input data.
  1177. * @param[out] *pDst points to the block of output data.
  1178. * @param[in] blockSize number of samples to process.
  1179. * @return none.
  1180. */
  1181. void arm_biquad_cascade_df1_f32(
  1182. const arm_biquad_casd_df1_inst_f32 * S,
  1183. float32_t * pSrc,
  1184. float32_t * pDst,
  1185. uint32_t blockSize);
  1186. /**
  1187. * @brief Initialization function for the floating-point Biquad cascade filter.
  1188. * @param[in,out] *S points to an instance of the floating-point Biquad cascade structure.
  1189. * @param[in] numStages number of 2nd order stages in the filter.
  1190. * @param[in] *pCoeffs points to the filter coefficients.
  1191. * @param[in] *pState points to the state buffer.
  1192. * @return none
  1193. */
  1194. void arm_biquad_cascade_df1_init_f32(
  1195. arm_biquad_casd_df1_inst_f32 * S,
  1196. uint8_t numStages,
  1197. float32_t * pCoeffs,
  1198. float32_t * pState);
  1199. /**
  1200. * @brief Instance structure for the floating-point matrix structure.
  1201. */
  1202. typedef struct
  1203. {
  1204. uint16_t numRows; /**< number of rows of the matrix. */
  1205. uint16_t numCols; /**< number of columns of the matrix. */
  1206. float32_t *pData; /**< points to the data of the matrix. */
  1207. } arm_matrix_instance_f32;
  1208. /**
  1209. * @brief Instance structure for the floating-point matrix structure.
  1210. */
  1211. typedef struct
  1212. {
  1213. uint16_t numRows; /**< number of rows of the matrix. */
  1214. uint16_t numCols; /**< number of columns of the matrix. */
  1215. float64_t *pData; /**< points to the data of the matrix. */
  1216. } arm_matrix_instance_f64;
  1217. /**
  1218. * @brief Instance structure for the Q15 matrix structure.
  1219. */
  1220. typedef struct
  1221. {
  1222. uint16_t numRows; /**< number of rows of the matrix. */
  1223. uint16_t numCols; /**< number of columns of the matrix. */
  1224. q15_t *pData; /**< points to the data of the matrix. */
  1225. } arm_matrix_instance_q15;
  1226. /**
  1227. * @brief Instance structure for the Q31 matrix structure.
  1228. */
  1229. typedef struct
  1230. {
  1231. uint16_t numRows; /**< number of rows of the matrix. */
  1232. uint16_t numCols; /**< number of columns of the matrix. */
  1233. q31_t *pData; /**< points to the data of the matrix. */
  1234. } arm_matrix_instance_q31;
  1235. /**
  1236. * @brief Floating-point matrix addition.
  1237. * @param[in] *pSrcA points to the first input matrix structure
  1238. * @param[in] *pSrcB points to the second input matrix structure
  1239. * @param[out] *pDst points to output matrix structure
  1240. * @return The function returns either
  1241. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1242. */
  1243. arm_status arm_mat_add_f32(
  1244. const arm_matrix_instance_f32 * pSrcA,
  1245. const arm_matrix_instance_f32 * pSrcB,
  1246. arm_matrix_instance_f32 * pDst);
  1247. /**
  1248. * @brief Q15 matrix addition.
  1249. * @param[in] *pSrcA points to the first input matrix structure
  1250. * @param[in] *pSrcB points to the second input matrix structure
  1251. * @param[out] *pDst points to output matrix structure
  1252. * @return The function returns either
  1253. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1254. */
  1255. arm_status arm_mat_add_q15(
  1256. const arm_matrix_instance_q15 * pSrcA,
  1257. const arm_matrix_instance_q15 * pSrcB,
  1258. arm_matrix_instance_q15 * pDst);
  1259. /**
  1260. * @brief Q31 matrix addition.
  1261. * @param[in] *pSrcA points to the first input matrix structure
  1262. * @param[in] *pSrcB points to the second input matrix structure
  1263. * @param[out] *pDst points to output matrix structure
  1264. * @return The function returns either
  1265. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1266. */
  1267. arm_status arm_mat_add_q31(
  1268. const arm_matrix_instance_q31 * pSrcA,
  1269. const arm_matrix_instance_q31 * pSrcB,
  1270. arm_matrix_instance_q31 * pDst);
  1271. /**
  1272. * @brief Floating-point, complex, matrix multiplication.
  1273. * @param[in] *pSrcA points to the first input matrix structure
  1274. * @param[in] *pSrcB points to the second input matrix structure
  1275. * @param[out] *pDst points to output matrix structure
  1276. * @return The function returns either
  1277. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1278. */
  1279. arm_status arm_mat_cmplx_mult_f32(
  1280. const arm_matrix_instance_f32 * pSrcA,
  1281. const arm_matrix_instance_f32 * pSrcB,
  1282. arm_matrix_instance_f32 * pDst);
  1283. /**
  1284. * @brief Q15, complex, matrix multiplication.
  1285. * @param[in] *pSrcA points to the first input matrix structure
  1286. * @param[in] *pSrcB points to the second input matrix structure
  1287. * @param[out] *pDst points to output matrix structure
  1288. * @return The function returns either
  1289. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1290. */
  1291. arm_status arm_mat_cmplx_mult_q15(
  1292. const arm_matrix_instance_q15 * pSrcA,
  1293. const arm_matrix_instance_q15 * pSrcB,
  1294. arm_matrix_instance_q15 * pDst,
  1295. q15_t * pScratch);
  1296. /**
  1297. * @brief Q31, complex, matrix multiplication.
  1298. * @param[in] *pSrcA points to the first input matrix structure
  1299. * @param[in] *pSrcB points to the second input matrix structure
  1300. * @param[out] *pDst points to output matrix structure
  1301. * @return The function returns either
  1302. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1303. */
  1304. arm_status arm_mat_cmplx_mult_q31(
  1305. const arm_matrix_instance_q31 * pSrcA,
  1306. const arm_matrix_instance_q31 * pSrcB,
  1307. arm_matrix_instance_q31 * pDst);
  1308. /**
  1309. * @brief Floating-point matrix transpose.
  1310. * @param[in] *pSrc points to the input matrix
  1311. * @param[out] *pDst points to the output matrix
  1312. * @return The function returns either <code>ARM_MATH_SIZE_MISMATCH</code>
  1313. * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1314. */
  1315. arm_status arm_mat_trans_f32(
  1316. const arm_matrix_instance_f32 * pSrc,
  1317. arm_matrix_instance_f32 * pDst);
  1318. /**
  1319. * @brief Q15 matrix transpose.
  1320. * @param[in] *pSrc points to the input matrix
  1321. * @param[out] *pDst points to the output matrix
  1322. * @return The function returns either <code>ARM_MATH_SIZE_MISMATCH</code>
  1323. * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1324. */
  1325. arm_status arm_mat_trans_q15(
  1326. const arm_matrix_instance_q15 * pSrc,
  1327. arm_matrix_instance_q15 * pDst);
  1328. /**
  1329. * @brief Q31 matrix transpose.
  1330. * @param[in] *pSrc points to the input matrix
  1331. * @param[out] *pDst points to the output matrix
  1332. * @return The function returns either <code>ARM_MATH_SIZE_MISMATCH</code>
  1333. * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1334. */
  1335. arm_status arm_mat_trans_q31(
  1336. const arm_matrix_instance_q31 * pSrc,
  1337. arm_matrix_instance_q31 * pDst);
  1338. /**
  1339. * @brief Floating-point matrix multiplication
  1340. * @param[in] *pSrcA points to the first input matrix structure
  1341. * @param[in] *pSrcB points to the second input matrix structure
  1342. * @param[out] *pDst points to output matrix structure
  1343. * @return The function returns either
  1344. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1345. */
  1346. arm_status arm_mat_mult_f32(
  1347. const arm_matrix_instance_f32 * pSrcA,
  1348. const arm_matrix_instance_f32 * pSrcB,
  1349. arm_matrix_instance_f32 * pDst);
  1350. /**
  1351. * @brief Q15 matrix multiplication
  1352. * @param[in] *pSrcA points to the first input matrix structure
  1353. * @param[in] *pSrcB points to the second input matrix structure
  1354. * @param[out] *pDst points to output matrix structure
  1355. * @param[in] *pState points to the array for storing intermediate results
  1356. * @return The function returns either
  1357. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1358. */
  1359. arm_status arm_mat_mult_q15(
  1360. const arm_matrix_instance_q15 * pSrcA,
  1361. const arm_matrix_instance_q15 * pSrcB,
  1362. arm_matrix_instance_q15 * pDst,
  1363. q15_t * pState);
  1364. /**
  1365. * @brief Q15 matrix multiplication (fast variant) for Cortex-M3 and Cortex-M4
  1366. * @param[in] *pSrcA points to the first input matrix structure
  1367. * @param[in] *pSrcB points to the second input matrix structure
  1368. * @param[out] *pDst points to output matrix structure
  1369. * @param[in] *pState points to the array for storing intermediate results
  1370. * @return The function returns either
  1371. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1372. */
  1373. arm_status arm_mat_mult_fast_q15(
  1374. const arm_matrix_instance_q15 * pSrcA,
  1375. const arm_matrix_instance_q15 * pSrcB,
  1376. arm_matrix_instance_q15 * pDst,
  1377. q15_t * pState);
  1378. /**
  1379. * @brief Q31 matrix multiplication
  1380. * @param[in] *pSrcA points to the first input matrix structure
  1381. * @param[in] *pSrcB points to the second input matrix structure
  1382. * @param[out] *pDst points to output matrix structure
  1383. * @return The function returns either
  1384. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1385. */
  1386. arm_status arm_mat_mult_q31(
  1387. const arm_matrix_instance_q31 * pSrcA,
  1388. const arm_matrix_instance_q31 * pSrcB,
  1389. arm_matrix_instance_q31 * pDst);
  1390. /**
  1391. * @brief Q31 matrix multiplication (fast variant) for Cortex-M3 and Cortex-M4
  1392. * @param[in] *pSrcA points to the first input matrix structure
  1393. * @param[in] *pSrcB points to the second input matrix structure
  1394. * @param[out] *pDst points to output matrix structure
  1395. * @return The function returns either
  1396. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1397. */
  1398. arm_status arm_mat_mult_fast_q31(
  1399. const arm_matrix_instance_q31 * pSrcA,
  1400. const arm_matrix_instance_q31 * pSrcB,
  1401. arm_matrix_instance_q31 * pDst);
  1402. /**
  1403. * @brief Floating-point matrix subtraction
  1404. * @param[in] *pSrcA points to the first input matrix structure
  1405. * @param[in] *pSrcB points to the second input matrix structure
  1406. * @param[out] *pDst points to output matrix structure
  1407. * @return The function returns either
  1408. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1409. */
  1410. arm_status arm_mat_sub_f32(
  1411. const arm_matrix_instance_f32 * pSrcA,
  1412. const arm_matrix_instance_f32 * pSrcB,
  1413. arm_matrix_instance_f32 * pDst);
  1414. /**
  1415. * @brief Q15 matrix subtraction
  1416. * @param[in] *pSrcA points to the first input matrix structure
  1417. * @param[in] *pSrcB points to the second input matrix structure
  1418. * @param[out] *pDst points to output matrix structure
  1419. * @return The function returns either
  1420. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1421. */
  1422. arm_status arm_mat_sub_q15(
  1423. const arm_matrix_instance_q15 * pSrcA,
  1424. const arm_matrix_instance_q15 * pSrcB,
  1425. arm_matrix_instance_q15 * pDst);
  1426. /**
  1427. * @brief Q31 matrix subtraction
  1428. * @param[in] *pSrcA points to the first input matrix structure
  1429. * @param[in] *pSrcB points to the second input matrix structure
  1430. * @param[out] *pDst points to output matrix structure
  1431. * @return The function returns either
  1432. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1433. */
  1434. arm_status arm_mat_sub_q31(
  1435. const arm_matrix_instance_q31 * pSrcA,
  1436. const arm_matrix_instance_q31 * pSrcB,
  1437. arm_matrix_instance_q31 * pDst);
  1438. /**
  1439. * @brief Floating-point matrix scaling.
  1440. * @param[in] *pSrc points to the input matrix
  1441. * @param[in] scale scale factor
  1442. * @param[out] *pDst points to the output matrix
  1443. * @return The function returns either
  1444. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1445. */
  1446. arm_status arm_mat_scale_f32(
  1447. const arm_matrix_instance_f32 * pSrc,
  1448. float32_t scale,
  1449. arm_matrix_instance_f32 * pDst);
  1450. /**
  1451. * @brief Q15 matrix scaling.
  1452. * @param[in] *pSrc points to input matrix
  1453. * @param[in] scaleFract fractional portion of the scale factor
  1454. * @param[in] shift number of bits to shift the result by
  1455. * @param[out] *pDst points to output matrix
  1456. * @return The function returns either
  1457. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1458. */
  1459. arm_status arm_mat_scale_q15(
  1460. const arm_matrix_instance_q15 * pSrc,
  1461. q15_t scaleFract,
  1462. int32_t shift,
  1463. arm_matrix_instance_q15 * pDst);
  1464. /**
  1465. * @brief Q31 matrix scaling.
  1466. * @param[in] *pSrc points to input matrix
  1467. * @param[in] scaleFract fractional portion of the scale factor
  1468. * @param[in] shift number of bits to shift the result by
  1469. * @param[out] *pDst points to output matrix structure
  1470. * @return The function returns either
  1471. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1472. */
  1473. arm_status arm_mat_scale_q31(
  1474. const arm_matrix_instance_q31 * pSrc,
  1475. q31_t scaleFract,
  1476. int32_t shift,
  1477. arm_matrix_instance_q31 * pDst);
  1478. /**
  1479. * @brief Q31 matrix initialization.
  1480. * @param[in,out] *S points to an instance of the floating-point matrix structure.
  1481. * @param[in] nRows number of rows in the matrix.
  1482. * @param[in] nColumns number of columns in the matrix.
  1483. * @param[in] *pData points to the matrix data array.
  1484. * @return none
  1485. */
  1486. void arm_mat_init_q31(
  1487. arm_matrix_instance_q31 * S,
  1488. uint16_t nRows,
  1489. uint16_t nColumns,
  1490. q31_t * pData);
  1491. /**
  1492. * @brief Q15 matrix initialization.
  1493. * @param[in,out] *S points to an instance of the floating-point matrix structure.
  1494. * @param[in] nRows number of rows in the matrix.
  1495. * @param[in] nColumns number of columns in the matrix.
  1496. * @param[in] *pData points to the matrix data array.
  1497. * @return none
  1498. */
  1499. void arm_mat_init_q15(
  1500. arm_matrix_instance_q15 * S,
  1501. uint16_t nRows,
  1502. uint16_t nColumns,
  1503. q15_t * pData);
  1504. /**
  1505. * @brief Floating-point matrix initialization.
  1506. * @param[in,out] *S points to an instance of the floating-point matrix structure.
  1507. * @param[in] nRows number of rows in the matrix.
  1508. * @param[in] nColumns number of columns in the matrix.
  1509. * @param[in] *pData points to the matrix data array.
  1510. * @return none
  1511. */
  1512. void arm_mat_init_f32(
  1513. arm_matrix_instance_f32 * S,
  1514. uint16_t nRows,
  1515. uint16_t nColumns,
  1516. float32_t * pData);
  1517. /**
  1518. * @brief Instance structure for the Q15 PID Control.
  1519. */
  1520. typedef struct
  1521. {
  1522. q15_t A0; /**< The derived gain, A0 = Kp + Ki + Kd . */
  1523. #ifdef ARM_MATH_CM0_FAMILY
  1524. q15_t A1;
  1525. q15_t A2;
  1526. #else
  1527. q31_t A1; /**< The derived gain A1 = -Kp - 2Kd | Kd.*/
  1528. #endif
  1529. q15_t state[3]; /**< The state array of length 3. */
  1530. q15_t Kp; /**< The proportional gain. */
  1531. q15_t Ki; /**< The integral gain. */
  1532. q15_t Kd; /**< The derivative gain. */
  1533. } arm_pid_instance_q15;
  1534. /**
  1535. * @brief Instance structure for the Q31 PID Control.
  1536. */
  1537. typedef struct
  1538. {
  1539. q31_t A0; /**< The derived gain, A0 = Kp + Ki + Kd . */
  1540. q31_t A1; /**< The derived gain, A1 = -Kp - 2Kd. */
  1541. q31_t A2; /**< The derived gain, A2 = Kd . */
  1542. q31_t state[3]; /**< The state array of length 3. */
  1543. q31_t Kp; /**< The proportional gain. */
  1544. q31_t Ki; /**< The integral gain. */
  1545. q31_t Kd; /**< The derivative gain. */
  1546. } arm_pid_instance_q31;
  1547. /**
  1548. * @brief Instance structure for the floating-point PID Control.
  1549. */
  1550. typedef struct
  1551. {
  1552. float32_t A0; /**< The derived gain, A0 = Kp + Ki + Kd . */
  1553. float32_t A1; /**< The derived gain, A1 = -Kp - 2Kd. */
  1554. float32_t A2; /**< The derived gain, A2 = Kd . */
  1555. float32_t state[3]; /**< The state array of length 3. */
  1556. float32_t Kp; /**< The proportional gain. */
  1557. float32_t Ki; /**< The integral gain. */
  1558. float32_t Kd; /**< The derivative gain. */
  1559. } arm_pid_instance_f32;
  1560. /**
  1561. * @brief Initialization function for the floating-point PID Control.
  1562. * @param[in,out] *S points to an instance of the PID structure.
  1563. * @param[in] resetStateFlag flag to reset the state. 0 = no change in state 1 = reset the state.
  1564. * @return none.
  1565. */
  1566. void arm_pid_init_f32(
  1567. arm_pid_instance_f32 * S,
  1568. int32_t resetStateFlag);
  1569. /**
  1570. * @brief Reset function for the floating-point PID Control.
  1571. * @param[in,out] *S is an instance of the floating-point PID Control structure
  1572. * @return none
  1573. */
  1574. void arm_pid_reset_f32(
  1575. arm_pid_instance_f32 * S);
  1576. /**
  1577. * @brief Initialization function for the Q31 PID Control.
  1578. * @param[in,out] *S points to an instance of the Q15 PID structure.
  1579. * @param[in] resetStateFlag flag to reset the state. 0 = no change in state 1 = reset the state.
  1580. * @return none.
  1581. */
  1582. void arm_pid_init_q31(
  1583. arm_pid_instance_q31 * S,
  1584. int32_t resetStateFlag);
  1585. /**
  1586. * @brief Reset function for the Q31 PID Control.
  1587. * @param[in,out] *S points to an instance of the Q31 PID Control structure
  1588. * @return none
  1589. */
  1590. void arm_pid_reset_q31(
  1591. arm_pid_instance_q31 * S);
  1592. /**
  1593. * @brief Initialization function for the Q15 PID Control.
  1594. * @param[in,out] *S points to an instance of the Q15 PID structure.
  1595. * @param[in] resetStateFlag flag to reset the state. 0 = no change in state 1 = reset the state.
  1596. * @return none.
  1597. */
  1598. void arm_pid_init_q15(
  1599. arm_pid_instance_q15 * S,
  1600. int32_t resetStateFlag);
  1601. /**
  1602. * @brief Reset function for the Q15 PID Control.
  1603. * @param[in,out] *S points to an instance of the q15 PID Control structure
  1604. * @return none
  1605. */
  1606. void arm_pid_reset_q15(
  1607. arm_pid_instance_q15 * S);
  1608. /**
  1609. * @brief Instance structure for the floating-point Linear Interpolate function.
  1610. */
  1611. typedef struct
  1612. {
  1613. uint32_t nValues; /**< nValues */
  1614. float32_t x1; /**< x1 */
  1615. float32_t xSpacing; /**< xSpacing */
  1616. float32_t *pYData; /**< pointer to the table of Y values */
  1617. } arm_linear_interp_instance_f32;
  1618. /**
  1619. * @brief Instance structure for the floating-point bilinear interpolation function.
  1620. */
  1621. typedef struct
  1622. {
  1623. uint16_t numRows; /**< number of rows in the data table. */
  1624. uint16_t numCols; /**< number of columns in the data table. */
  1625. float32_t *pData; /**< points to the data table. */
  1626. } arm_bilinear_interp_instance_f32;
  1627. /**
  1628. * @brief Instance structure for the Q31 bilinear interpolation function.
  1629. */
  1630. typedef struct
  1631. {
  1632. uint16_t numRows; /**< number of rows in the data table. */
  1633. uint16_t numCols; /**< number of columns in the data table. */
  1634. q31_t *pData; /**< points to the data table. */
  1635. } arm_bilinear_interp_instance_q31;
  1636. /**
  1637. * @brief Instance structure for the Q15 bilinear interpolation function.
  1638. */
  1639. typedef struct
  1640. {
  1641. uint16_t numRows; /**< number of rows in the data table. */
  1642. uint16_t numCols; /**< number of columns in the data table. */
  1643. q15_t *pData; /**< points to the data table. */
  1644. } arm_bilinear_interp_instance_q15;
  1645. /**
  1646. * @brief Instance structure for the Q15 bilinear interpolation function.
  1647. */
  1648. typedef struct
  1649. {
  1650. uint16_t numRows; /**< number of rows in the data table. */
  1651. uint16_t numCols; /**< number of columns in the data table. */
  1652. q7_t *pData; /**< points to the data table. */
  1653. } arm_bilinear_interp_instance_q7;
  1654. /**
  1655. * @brief Q7 vector multiplication.
  1656. * @param[in] *pSrcA points to the first input vector
  1657. * @param[in] *pSrcB points to the second input vector
  1658. * @param[out] *pDst points to the output vector
  1659. * @param[in] blockSize number of samples in each vector
  1660. * @return none.
  1661. */
  1662. void arm_mult_q7(
  1663. q7_t * pSrcA,
  1664. q7_t * pSrcB,
  1665. q7_t * pDst,
  1666. uint32_t blockSize);
  1667. /**
  1668. * @brief Q15 vector multiplication.
  1669. * @param[in] *pSrcA points to the first input vector
  1670. * @param[in] *pSrcB points to the second input vector
  1671. * @param[out] *pDst points to the output vector
  1672. * @param[in] blockSize number of samples in each vector
  1673. * @return none.
  1674. */
  1675. void arm_mult_q15(
  1676. q15_t * pSrcA,
  1677. q15_t * pSrcB,
  1678. q15_t * pDst,
  1679. uint32_t blockSize);
  1680. /**
  1681. * @brief Q31 vector multiplication.
  1682. * @param[in] *pSrcA points to the first input vector
  1683. * @param[in] *pSrcB points to the second input vector
  1684. * @param[out] *pDst points to the output vector
  1685. * @param[in] blockSize number of samples in each vector
  1686. * @return none.
  1687. */
  1688. void arm_mult_q31(
  1689. q31_t * pSrcA,
  1690. q31_t * pSrcB,
  1691. q31_t * pDst,
  1692. uint32_t blockSize);
  1693. /**
  1694. * @brief Floating-point vector multiplication.
  1695. * @param[in] *pSrcA points to the first input vector
  1696. * @param[in] *pSrcB points to the second input vector
  1697. * @param[out] *pDst points to the output vector
  1698. * @param[in] blockSize number of samples in each vector
  1699. * @return none.
  1700. */
  1701. void arm_mult_f32(
  1702. float32_t * pSrcA,
  1703. float32_t * pSrcB,
  1704. float32_t * pDst,
  1705. uint32_t blockSize);
  1706. /**
  1707. * @brief Instance structure for the Q15 CFFT/CIFFT function.
  1708. */
  1709. typedef struct
  1710. {
  1711. uint16_t fftLen; /**< length of the FFT. */
  1712. uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
  1713. uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
  1714. q15_t *pTwiddle; /**< points to the Sin twiddle factor table. */
  1715. uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  1716. uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  1717. uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
  1718. } arm_cfft_radix2_instance_q15;
  1719. /* Deprecated */
  1720. arm_status arm_cfft_radix2_init_q15(
  1721. arm_cfft_radix2_instance_q15 * S,
  1722. uint16_t fftLen,
  1723. uint8_t ifftFlag,
  1724. uint8_t bitReverseFlag);
  1725. /* Deprecated */
  1726. void arm_cfft_radix2_q15(
  1727. const arm_cfft_radix2_instance_q15 * S,
  1728. q15_t * pSrc);
  1729. /**
  1730. * @brief Instance structure for the Q15 CFFT/CIFFT function.
  1731. */
  1732. typedef struct
  1733. {
  1734. uint16_t fftLen; /**< length of the FFT. */
  1735. uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
  1736. uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
  1737. q15_t *pTwiddle; /**< points to the twiddle factor table. */
  1738. uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  1739. uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  1740. uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
  1741. } arm_cfft_radix4_instance_q15;
  1742. /* Deprecated */
  1743. arm_status arm_cfft_radix4_init_q15(
  1744. arm_cfft_radix4_instance_q15 * S,
  1745. uint16_t fftLen,
  1746. uint8_t ifftFlag,
  1747. uint8_t bitReverseFlag);
  1748. /* Deprecated */
  1749. void arm_cfft_radix4_q15(
  1750. const arm_cfft_radix4_instance_q15 * S,
  1751. q15_t * pSrc);
  1752. /**
  1753. * @brief Instance structure for the Radix-2 Q31 CFFT/CIFFT function.
  1754. */
  1755. typedef struct
  1756. {
  1757. uint16_t fftLen; /**< length of the FFT. */
  1758. uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
  1759. uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
  1760. q31_t *pTwiddle; /**< points to the Twiddle factor table. */
  1761. uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  1762. uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  1763. uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
  1764. } arm_cfft_radix2_instance_q31;
  1765. /* Deprecated */
  1766. arm_status arm_cfft_radix2_init_q31(
  1767. arm_cfft_radix2_instance_q31 * S,
  1768. uint16_t fftLen,
  1769. uint8_t ifftFlag,
  1770. uint8_t bitReverseFlag);
  1771. /* Deprecated */
  1772. void arm_cfft_radix2_q31(
  1773. const arm_cfft_radix2_instance_q31 * S,
  1774. q31_t * pSrc);
  1775. /**
  1776. * @brief Instance structure for the Q31 CFFT/CIFFT function.
  1777. */
  1778. typedef struct
  1779. {
  1780. uint16_t fftLen; /**< length of the FFT. */
  1781. uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
  1782. uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
  1783. q31_t *pTwiddle; /**< points to the twiddle factor table. */
  1784. uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  1785. uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  1786. uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
  1787. } arm_cfft_radix4_instance_q31;
  1788. /* Deprecated */
  1789. void arm_cfft_radix4_q31(
  1790. const arm_cfft_radix4_instance_q31 * S,
  1791. q31_t * pSrc);
  1792. /* Deprecated */
  1793. arm_status arm_cfft_radix4_init_q31(
  1794. arm_cfft_radix4_instance_q31 * S,
  1795. uint16_t fftLen,
  1796. uint8_t ifftFlag,
  1797. uint8_t bitReverseFlag);
  1798. /**
  1799. * @brief Instance structure for the floating-point CFFT/CIFFT function.
  1800. */
  1801. typedef struct
  1802. {
  1803. uint16_t fftLen; /**< length of the FFT. */
  1804. uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
  1805. uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
  1806. float32_t *pTwiddle; /**< points to the Twiddle factor table. */
  1807. uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  1808. uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  1809. uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
  1810. float32_t onebyfftLen; /**< value of 1/fftLen. */
  1811. } arm_cfft_radix2_instance_f32;
  1812. /* Deprecated */
  1813. arm_status arm_cfft_radix2_init_f32(
  1814. arm_cfft_radix2_instance_f32 * S,
  1815. uint16_t fftLen,
  1816. uint8_t ifftFlag,
  1817. uint8_t bitReverseFlag);
  1818. /* Deprecated */
  1819. void arm_cfft_radix2_f32(
  1820. const arm_cfft_radix2_instance_f32 * S,
  1821. float32_t * pSrc);
  1822. /**
  1823. * @brief Instance structure for the floating-point CFFT/CIFFT function.
  1824. */
  1825. typedef struct
  1826. {
  1827. uint16_t fftLen; /**< length of the FFT. */
  1828. uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
  1829. uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
  1830. float32_t *pTwiddle; /**< points to the Twiddle factor table. */
  1831. uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  1832. uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  1833. uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
  1834. float32_t onebyfftLen; /**< value of 1/fftLen. */
  1835. } arm_cfft_radix4_instance_f32;
  1836. /* Deprecated */
  1837. arm_status arm_cfft_radix4_init_f32(
  1838. arm_cfft_radix4_instance_f32 * S,
  1839. uint16_t fftLen,
  1840. uint8_t ifftFlag,
  1841. uint8_t bitReverseFlag);
  1842. /* Deprecated */
  1843. void arm_cfft_radix4_f32(
  1844. const arm_cfft_radix4_instance_f32 * S,
  1845. float32_t * pSrc);
  1846. /**
  1847. * @brief Instance structure for the fixed-point CFFT/CIFFT function.
  1848. */
  1849. typedef struct
  1850. {
  1851. uint16_t fftLen; /**< length of the FFT. */
  1852. const q15_t *pTwiddle; /**< points to the Twiddle factor table. */
  1853. const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  1854. uint16_t bitRevLength; /**< bit reversal table length. */
  1855. } arm_cfft_instance_q15;
  1856. void arm_cfft_q15(
  1857. const arm_cfft_instance_q15 * S,
  1858. q15_t * p1,
  1859. uint8_t ifftFlag,
  1860. uint8_t bitReverseFlag);
  1861. /**
  1862. * @brief Instance structure for the fixed-point CFFT/CIFFT function.
  1863. */
  1864. typedef struct
  1865. {
  1866. uint16_t fftLen; /**< length of the FFT. */
  1867. const q31_t *pTwiddle; /**< points to the Twiddle factor table. */
  1868. const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  1869. uint16_t bitRevLength; /**< bit reversal table length. */
  1870. } arm_cfft_instance_q31;
  1871. void arm_cfft_q31(
  1872. const arm_cfft_instance_q31 * S,
  1873. q31_t * p1,
  1874. uint8_t ifftFlag,
  1875. uint8_t bitReverseFlag);
  1876. /**
  1877. * @brief Instance structure for the floating-point CFFT/CIFFT function.
  1878. */
  1879. typedef struct
  1880. {
  1881. uint16_t fftLen; /**< length of the FFT. */
  1882. const float32_t *pTwiddle; /**< points to the Twiddle factor table. */
  1883. const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  1884. uint16_t bitRevLength; /**< bit reversal table length. */
  1885. } arm_cfft_instance_f32;
  1886. void arm_cfft_f32(
  1887. const arm_cfft_instance_f32 * S,
  1888. float32_t * p1,
  1889. uint8_t ifftFlag,
  1890. uint8_t bitReverseFlag);
  1891. /**
  1892. * @brief Instance structure for the Q15 RFFT/RIFFT function.
  1893. */
  1894. typedef struct
  1895. {
  1896. uint32_t fftLenReal; /**< length of the real FFT. */
  1897. uint8_t ifftFlagR; /**< flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. */
  1898. uint8_t bitReverseFlagR; /**< flag that enables (bitReverseFlagR=1) or disables (bitReverseFlagR=0) bit reversal of output. */
  1899. uint32_t twidCoefRModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  1900. q15_t *pTwiddleAReal; /**< points to the real twiddle factor table. */
  1901. q15_t *pTwiddleBReal; /**< points to the imag twiddle factor table. */
  1902. const arm_cfft_instance_q15 *pCfft; /**< points to the complex FFT instance. */
  1903. } arm_rfft_instance_q15;
  1904. arm_status arm_rfft_init_q15(
  1905. arm_rfft_instance_q15 * S,
  1906. uint32_t fftLenReal,
  1907. uint32_t ifftFlagR,
  1908. uint32_t bitReverseFlag);
  1909. void arm_rfft_q15(
  1910. const arm_rfft_instance_q15 * S,
  1911. q15_t * pSrc,
  1912. q15_t * pDst);
  1913. /**
  1914. * @brief Instance structure for the Q31 RFFT/RIFFT function.
  1915. */
  1916. typedef struct
  1917. {
  1918. uint32_t fftLenReal; /**< length of the real FFT. */
  1919. uint8_t ifftFlagR; /**< flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. */
  1920. uint8_t bitReverseFlagR; /**< flag that enables (bitReverseFlagR=1) or disables (bitReverseFlagR=0) bit reversal of output. */
  1921. uint32_t twidCoefRModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  1922. q31_t *pTwiddleAReal; /**< points to the real twiddle factor table. */
  1923. q31_t *pTwiddleBReal; /**< points to the imag twiddle factor table. */
  1924. const arm_cfft_instance_q31 *pCfft; /**< points to the complex FFT instance. */
  1925. } arm_rfft_instance_q31;
  1926. arm_status arm_rfft_init_q31(
  1927. arm_rfft_instance_q31 * S,
  1928. uint32_t fftLenReal,
  1929. uint32_t ifftFlagR,
  1930. uint32_t bitReverseFlag);
  1931. void arm_rfft_q31(
  1932. const arm_rfft_instance_q31 * S,
  1933. q31_t * pSrc,
  1934. q31_t * pDst);
  1935. /**
  1936. * @brief Instance structure for the floating-point RFFT/RIFFT function.
  1937. */
  1938. typedef struct
  1939. {
  1940. uint32_t fftLenReal; /**< length of the real FFT. */
  1941. uint16_t fftLenBy2; /**< length of the complex FFT. */
  1942. uint8_t ifftFlagR; /**< flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. */
  1943. uint8_t bitReverseFlagR; /**< flag that enables (bitReverseFlagR=1) or disables (bitReverseFlagR=0) bit reversal of output. */
  1944. uint32_t twidCoefRModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  1945. float32_t *pTwiddleAReal; /**< points to the real twiddle factor table. */
  1946. float32_t *pTwiddleBReal; /**< points to the imag twiddle factor table. */
  1947. arm_cfft_radix4_instance_f32 *pCfft; /**< points to the complex FFT instance. */
  1948. } arm_rfft_instance_f32;
  1949. arm_status arm_rfft_init_f32(
  1950. arm_rfft_instance_f32 * S,
  1951. arm_cfft_radix4_instance_f32 * S_CFFT,
  1952. uint32_t fftLenReal,
  1953. uint32_t ifftFlagR,
  1954. uint32_t bitReverseFlag);
  1955. void arm_rfft_f32(
  1956. const arm_rfft_instance_f32 * S,
  1957. float32_t * pSrc,
  1958. float32_t * pDst);
  1959. /**
  1960. * @brief Instance structure for the floating-point RFFT/RIFFT function.
  1961. */
  1962. typedef struct
  1963. {
  1964. arm_cfft_instance_f32 Sint; /**< Internal CFFT structure. */
  1965. uint16_t fftLenRFFT; /**< length of the real sequence */
  1966. float32_t * pTwiddleRFFT; /**< Twiddle factors real stage */
  1967. } arm_rfft_fast_instance_f32 ;
  1968. arm_status arm_rfft_fast_init_f32 (
  1969. arm_rfft_fast_instance_f32 * S,
  1970. uint16_t fftLen);
  1971. void arm_rfft_fast_f32(
  1972. arm_rfft_fast_instance_f32 * S,
  1973. float32_t * p, float32_t * pOut,
  1974. uint8_t ifftFlag);
  1975. /**
  1976. * @brief Instance structure for the floating-point DCT4/IDCT4 function.
  1977. */
  1978. typedef struct
  1979. {
  1980. uint16_t N; /**< length of the DCT4. */
  1981. uint16_t Nby2; /**< half of the length of the DCT4. */
  1982. float32_t normalize; /**< normalizing factor. */
  1983. float32_t *pTwiddle; /**< points to the twiddle factor table. */
  1984. float32_t *pCosFactor; /**< points to the cosFactor table. */
  1985. arm_rfft_instance_f32 *pRfft; /**< points to the real FFT instance. */
  1986. arm_cfft_radix4_instance_f32 *pCfft; /**< points to the complex FFT instance. */
  1987. } arm_dct4_instance_f32;
  1988. /**
  1989. * @brief Initialization function for the floating-point DCT4/IDCT4.
  1990. * @param[in,out] *S points to an instance of floating-point DCT4/IDCT4 structure.
  1991. * @param[in] *S_RFFT points to an instance of floating-point RFFT/RIFFT structure.
  1992. * @param[in] *S_CFFT points to an instance of floating-point CFFT/CIFFT structure.
  1993. * @param[in] N length of the DCT4.
  1994. * @param[in] Nby2 half of the length of the DCT4.
  1995. * @param[in] normalize normalizing factor.
  1996. * @return arm_status function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if <code>fftLenReal</code> is not a supported transform length.
  1997. */
  1998. arm_status arm_dct4_init_f32(
  1999. arm_dct4_instance_f32 * S,
  2000. arm_rfft_instance_f32 * S_RFFT,
  2001. arm_cfft_radix4_instance_f32 * S_CFFT,
  2002. uint16_t N,
  2003. uint16_t Nby2,
  2004. float32_t normalize);
  2005. /**
  2006. * @brief Processing function for the floating-point DCT4/IDCT4.
  2007. * @param[in] *S points to an instance of the floating-point DCT4/IDCT4 structure.
  2008. * @param[in] *pState points to state buffer.
  2009. * @param[in,out] *pInlineBuffer points to the in-place input and output buffer.
  2010. * @return none.
  2011. */
  2012. void arm_dct4_f32(
  2013. const arm_dct4_instance_f32 * S,
  2014. float32_t * pState,
  2015. float32_t * pInlineBuffer);
  2016. /**
  2017. * @brief Instance structure for the Q31 DCT4/IDCT4 function.
  2018. */
  2019. typedef struct
  2020. {
  2021. uint16_t N; /**< length of the DCT4. */
  2022. uint16_t Nby2; /**< half of the length of the DCT4. */
  2023. q31_t normalize; /**< normalizing factor. */
  2024. q31_t *pTwiddle; /**< points to the twiddle factor table. */
  2025. q31_t *pCosFactor; /**< points to the cosFactor table. */
  2026. arm_rfft_instance_q31 *pRfft; /**< points to the real FFT instance. */
  2027. arm_cfft_radix4_instance_q31 *pCfft; /**< points to the complex FFT instance. */
  2028. } arm_dct4_instance_q31;
  2029. /**
  2030. * @brief Initialization function for the Q31 DCT4/IDCT4.
  2031. * @param[in,out] *S points to an instance of Q31 DCT4/IDCT4 structure.
  2032. * @param[in] *S_RFFT points to an instance of Q31 RFFT/RIFFT structure
  2033. * @param[in] *S_CFFT points to an instance of Q31 CFFT/CIFFT structure
  2034. * @param[in] N length of the DCT4.
  2035. * @param[in] Nby2 half of the length of the DCT4.
  2036. * @param[in] normalize normalizing factor.
  2037. * @return arm_status function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if <code>N</code> is not a supported transform length.
  2038. */
  2039. arm_status arm_dct4_init_q31(
  2040. arm_dct4_instance_q31 * S,
  2041. arm_rfft_instance_q31 * S_RFFT,
  2042. arm_cfft_radix4_instance_q31 * S_CFFT,
  2043. uint16_t N,
  2044. uint16_t Nby2,
  2045. q31_t normalize);
  2046. /**
  2047. * @brief Processing function for the Q31 DCT4/IDCT4.
  2048. * @param[in] *S points to an instance of the Q31 DCT4 structure.
  2049. * @param[in] *pState points to state buffer.
  2050. * @param[in,out] *pInlineBuffer points to the in-place input and output buffer.
  2051. * @return none.
  2052. */
  2053. void arm_dct4_q31(
  2054. const arm_dct4_instance_q31 * S,
  2055. q31_t * pState,
  2056. q31_t * pInlineBuffer);
  2057. /**
  2058. * @brief Instance structure for the Q15 DCT4/IDCT4 function.
  2059. */
  2060. typedef struct
  2061. {
  2062. uint16_t N; /**< length of the DCT4. */
  2063. uint16_t Nby2; /**< half of the length of the DCT4. */
  2064. q15_t normalize; /**< normalizing factor. */
  2065. q15_t *pTwiddle; /**< points to the twiddle factor table. */
  2066. q15_t *pCosFactor; /**< points to the cosFactor table. */
  2067. arm_rfft_instance_q15 *pRfft; /**< points to the real FFT instance. */
  2068. arm_cfft_radix4_instance_q15 *pCfft; /**< points to the complex FFT instance. */
  2069. } arm_dct4_instance_q15;
  2070. /**
  2071. * @brief Initialization function for the Q15 DCT4/IDCT4.
  2072. * @param[in,out] *S points to an instance of Q15 DCT4/IDCT4 structure.
  2073. * @param[in] *S_RFFT points to an instance of Q15 RFFT/RIFFT structure.
  2074. * @param[in] *S_CFFT points to an instance of Q15 CFFT/CIFFT structure.
  2075. * @param[in] N length of the DCT4.
  2076. * @param[in] Nby2 half of the length of the DCT4.
  2077. * @param[in] normalize normalizing factor.
  2078. * @return arm_status function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if <code>N</code> is not a supported transform length.
  2079. */
  2080. arm_status arm_dct4_init_q15(
  2081. arm_dct4_instance_q15 * S,
  2082. arm_rfft_instance_q15 * S_RFFT,
  2083. arm_cfft_radix4_instance_q15 * S_CFFT,
  2084. uint16_t N,
  2085. uint16_t Nby2,
  2086. q15_t normalize);
  2087. /**
  2088. * @brief Processing function for the Q15 DCT4/IDCT4.
  2089. * @param[in] *S points to an instance of the Q15 DCT4 structure.
  2090. * @param[in] *pState points to state buffer.
  2091. * @param[in,out] *pInlineBuffer points to the in-place input and output buffer.
  2092. * @return none.
  2093. */
  2094. void arm_dct4_q15(
  2095. const arm_dct4_instance_q15 * S,
  2096. q15_t * pState,
  2097. q15_t * pInlineBuffer);
  2098. /**
  2099. * @brief Floating-point vector addition.
  2100. * @param[in] *pSrcA points to the first input vector
  2101. * @param[in] *pSrcB points to the second input vector
  2102. * @param[out] *pDst points to the output vector
  2103. * @param[in] blockSize number of samples in each vector
  2104. * @return none.
  2105. */
  2106. void arm_add_f32(
  2107. float32_t * pSrcA,
  2108. float32_t * pSrcB,
  2109. float32_t * pDst,
  2110. uint32_t blockSize);
  2111. /**
  2112. * @brief Q7 vector addition.
  2113. * @param[in] *pSrcA points to the first input vector
  2114. * @param[in] *pSrcB points to the second input vector
  2115. * @param[out] *pDst points to the output vector
  2116. * @param[in] blockSize number of samples in each vector
  2117. * @return none.
  2118. */
  2119. void arm_add_q7(
  2120. q7_t * pSrcA,
  2121. q7_t * pSrcB,
  2122. q7_t * pDst,
  2123. uint32_t blockSize);
  2124. /**
  2125. * @brief Q15 vector addition.
  2126. * @param[in] *pSrcA points to the first input vector
  2127. * @param[in] *pSrcB points to the second input vector
  2128. * @param[out] *pDst points to the output vector
  2129. * @param[in] blockSize number of samples in each vector
  2130. * @return none.
  2131. */
  2132. void arm_add_q15(
  2133. q15_t * pSrcA,
  2134. q15_t * pSrcB,
  2135. q15_t * pDst,
  2136. uint32_t blockSize);
  2137. /**
  2138. * @brief Q31 vector addition.
  2139. * @param[in] *pSrcA points to the first input vector
  2140. * @param[in] *pSrcB points to the second input vector
  2141. * @param[out] *pDst points to the output vector
  2142. * @param[in] blockSize number of samples in each vector
  2143. * @return none.
  2144. */
  2145. void arm_add_q31(
  2146. q31_t * pSrcA,
  2147. q31_t * pSrcB,
  2148. q31_t * pDst,
  2149. uint32_t blockSize);
  2150. /**
  2151. * @brief Floating-point vector subtraction.
  2152. * @param[in] *pSrcA points to the first input vector
  2153. * @param[in] *pSrcB points to the second input vector
  2154. * @param[out] *pDst points to the output vector
  2155. * @param[in] blockSize number of samples in each vector
  2156. * @return none.
  2157. */
  2158. void arm_sub_f32(
  2159. float32_t * pSrcA,
  2160. float32_t * pSrcB,
  2161. float32_t * pDst,
  2162. uint32_t blockSize);
  2163. /**
  2164. * @brief Q7 vector subtraction.
  2165. * @param[in] *pSrcA points to the first input vector
  2166. * @param[in] *pSrcB points to the second input vector
  2167. * @param[out] *pDst points to the output vector
  2168. * @param[in] blockSize number of samples in each vector
  2169. * @return none.
  2170. */
  2171. void arm_sub_q7(
  2172. q7_t * pSrcA,
  2173. q7_t * pSrcB,
  2174. q7_t * pDst,
  2175. uint32_t blockSize);
  2176. /**
  2177. * @brief Q15 vector subtraction.
  2178. * @param[in] *pSrcA points to the first input vector
  2179. * @param[in] *pSrcB points to the second input vector
  2180. * @param[out] *pDst points to the output vector
  2181. * @param[in] blockSize number of samples in each vector
  2182. * @return none.
  2183. */
  2184. void arm_sub_q15(
  2185. q15_t * pSrcA,
  2186. q15_t * pSrcB,
  2187. q15_t * pDst,
  2188. uint32_t blockSize);
  2189. /**
  2190. * @brief Q31 vector subtraction.
  2191. * @param[in] *pSrcA points to the first input vector
  2192. * @param[in] *pSrcB points to the second input vector
  2193. * @param[out] *pDst points to the output vector
  2194. * @param[in] blockSize number of samples in each vector
  2195. * @return none.
  2196. */
  2197. void arm_sub_q31(
  2198. q31_t * pSrcA,
  2199. q31_t * pSrcB,
  2200. q31_t * pDst,
  2201. uint32_t blockSize);
  2202. /**
  2203. * @brief Multiplies a floating-point vector by a scalar.
  2204. * @param[in] *pSrc points to the input vector
  2205. * @param[in] scale scale factor to be applied
  2206. * @param[out] *pDst points to the output vector
  2207. * @param[in] blockSize number of samples in the vector
  2208. * @return none.
  2209. */
  2210. void arm_scale_f32(
  2211. float32_t * pSrc,
  2212. float32_t scale,
  2213. float32_t * pDst,
  2214. uint32_t blockSize);
  2215. /**
  2216. * @brief Multiplies a Q7 vector by a scalar.
  2217. * @param[in] *pSrc points to the input vector
  2218. * @param[in] scaleFract fractional portion of the scale value
  2219. * @param[in] shift number of bits to shift the result by
  2220. * @param[out] *pDst points to the output vector
  2221. * @param[in] blockSize number of samples in the vector
  2222. * @return none.
  2223. */
  2224. void arm_scale_q7(
  2225. q7_t * pSrc,
  2226. q7_t scaleFract,
  2227. int8_t shift,
  2228. q7_t * pDst,
  2229. uint32_t blockSize);
  2230. /**
  2231. * @brief Multiplies a Q15 vector by a scalar.
  2232. * @param[in] *pSrc points to the input vector
  2233. * @param[in] scaleFract fractional portion of the scale value
  2234. * @param[in] shift number of bits to shift the result by
  2235. * @param[out] *pDst points to the output vector
  2236. * @param[in] blockSize number of samples in the vector
  2237. * @return none.
  2238. */
  2239. void arm_scale_q15(
  2240. q15_t * pSrc,
  2241. q15_t scaleFract,
  2242. int8_t shift,
  2243. q15_t * pDst,
  2244. uint32_t blockSize);
  2245. /**
  2246. * @brief Multiplies a Q31 vector by a scalar.
  2247. * @param[in] *pSrc points to the input vector
  2248. * @param[in] scaleFract fractional portion of the scale value
  2249. * @param[in] shift number of bits to shift the result by
  2250. * @param[out] *pDst points to the output vector
  2251. * @param[in] blockSize number of samples in the vector
  2252. * @return none.
  2253. */
  2254. void arm_scale_q31(
  2255. q31_t * pSrc,
  2256. q31_t scaleFract,
  2257. int8_t shift,
  2258. q31_t * pDst,
  2259. uint32_t blockSize);
  2260. /**
  2261. * @brief Q7 vector absolute value.
  2262. * @param[in] *pSrc points to the input buffer
  2263. * @param[out] *pDst points to the output buffer
  2264. * @param[in] blockSize number of samples in each vector
  2265. * @return none.
  2266. */
  2267. void arm_abs_q7(
  2268. q7_t * pSrc,
  2269. q7_t * pDst,
  2270. uint32_t blockSize);
  2271. /**
  2272. * @brief Floating-point vector absolute value.
  2273. * @param[in] *pSrc points to the input buffer
  2274. * @param[out] *pDst points to the output buffer
  2275. * @param[in] blockSize number of samples in each vector
  2276. * @return none.
  2277. */
  2278. void arm_abs_f32(
  2279. float32_t * pSrc,
  2280. float32_t * pDst,
  2281. uint32_t blockSize);
  2282. /**
  2283. * @brief Q15 vector absolute value.
  2284. * @param[in] *pSrc points to the input buffer
  2285. * @param[out] *pDst points to the output buffer
  2286. * @param[in] blockSize number of samples in each vector
  2287. * @return none.
  2288. */
  2289. void arm_abs_q15(
  2290. q15_t * pSrc,
  2291. q15_t * pDst,
  2292. uint32_t blockSize);
  2293. /**
  2294. * @brief Q31 vector absolute value.
  2295. * @param[in] *pSrc points to the input buffer
  2296. * @param[out] *pDst points to the output buffer
  2297. * @param[in] blockSize number of samples in each vector
  2298. * @return none.
  2299. */
  2300. void arm_abs_q31(
  2301. q31_t * pSrc,
  2302. q31_t * pDst,
  2303. uint32_t blockSize);
  2304. /**
  2305. * @brief Dot product of floating-point vectors.
  2306. * @param[in] *pSrcA points to the first input vector
  2307. * @param[in] *pSrcB points to the second input vector
  2308. * @param[in] blockSize number of samples in each vector
  2309. * @param[out] *result output result returned here
  2310. * @return none.
  2311. */
  2312. void arm_dot_prod_f32(
  2313. float32_t * pSrcA,
  2314. float32_t * pSrcB,
  2315. uint32_t blockSize,
  2316. float32_t * result);
  2317. /**
  2318. * @brief Dot product of Q7 vectors.
  2319. * @param[in] *pSrcA points to the first input vector
  2320. * @param[in] *pSrcB points to the second input vector
  2321. * @param[in] blockSize number of samples in each vector
  2322. * @param[out] *result output result returned here
  2323. * @return none.
  2324. */
  2325. void arm_dot_prod_q7(
  2326. q7_t * pSrcA,
  2327. q7_t * pSrcB,
  2328. uint32_t blockSize,
  2329. q31_t * result);
  2330. /**
  2331. * @brief Dot product of Q15 vectors.
  2332. * @param[in] *pSrcA points to the first input vector
  2333. * @param[in] *pSrcB points to the second input vector
  2334. * @param[in] blockSize number of samples in each vector
  2335. * @param[out] *result output result returned here
  2336. * @return none.
  2337. */
  2338. void arm_dot_prod_q15(
  2339. q15_t * pSrcA,
  2340. q15_t * pSrcB,
  2341. uint32_t blockSize,
  2342. q63_t * result);
  2343. /**
  2344. * @brief Dot product of Q31 vectors.
  2345. * @param[in] *pSrcA points to the first input vector
  2346. * @param[in] *pSrcB points to the second input vector
  2347. * @param[in] blockSize number of samples in each vector
  2348. * @param[out] *result output result returned here
  2349. * @return none.
  2350. */
  2351. void arm_dot_prod_q31(
  2352. q31_t * pSrcA,
  2353. q31_t * pSrcB,
  2354. uint32_t blockSize,
  2355. q63_t * result);
  2356. /**
  2357. * @brief Shifts the elements of a Q7 vector a specified number of bits.
  2358. * @param[in] *pSrc points to the input vector
  2359. * @param[in] shiftBits number of bits to shift. A positive value shifts left; a negative value shifts right.
  2360. * @param[out] *pDst points to the output vector
  2361. * @param[in] blockSize number of samples in the vector
  2362. * @return none.
  2363. */
  2364. void arm_shift_q7(
  2365. q7_t * pSrc,
  2366. int8_t shiftBits,
  2367. q7_t * pDst,
  2368. uint32_t blockSize);
  2369. /**
  2370. * @brief Shifts the elements of a Q15 vector a specified number of bits.
  2371. * @param[in] *pSrc points to the input vector
  2372. * @param[in] shiftBits number of bits to shift. A positive value shifts left; a negative value shifts right.
  2373. * @param[out] *pDst points to the output vector
  2374. * @param[in] blockSize number of samples in the vector
  2375. * @return none.
  2376. */
  2377. void arm_shift_q15(
  2378. q15_t * pSrc,
  2379. int8_t shiftBits,
  2380. q15_t * pDst,
  2381. uint32_t blockSize);
  2382. /**
  2383. * @brief Shifts the elements of a Q31 vector a specified number of bits.
  2384. * @param[in] *pSrc points to the input vector
  2385. * @param[in] shiftBits number of bits to shift. A positive value shifts left; a negative value shifts right.
  2386. * @param[out] *pDst points to the output vector
  2387. * @param[in] blockSize number of samples in the vector
  2388. * @return none.
  2389. */
  2390. void arm_shift_q31(
  2391. q31_t * pSrc,
  2392. int8_t shiftBits,
  2393. q31_t * pDst,
  2394. uint32_t blockSize);
  2395. /**
  2396. * @brief Adds a constant offset to a floating-point vector.
  2397. * @param[in] *pSrc points to the input vector
  2398. * @param[in] offset is the offset to be added
  2399. * @param[out] *pDst points to the output vector
  2400. * @param[in] blockSize number of samples in the vector
  2401. * @return none.
  2402. */
  2403. void arm_offset_f32(
  2404. float32_t * pSrc,
  2405. float32_t offset,
  2406. float32_t * pDst,
  2407. uint32_t blockSize);
  2408. /**
  2409. * @brief Adds a constant offset to a Q7 vector.
  2410. * @param[in] *pSrc points to the input vector
  2411. * @param[in] offset is the offset to be added
  2412. * @param[out] *pDst points to the output vector
  2413. * @param[in] blockSize number of samples in the vector
  2414. * @return none.
  2415. */
  2416. void arm_offset_q7(
  2417. q7_t * pSrc,
  2418. q7_t offset,
  2419. q7_t * pDst,
  2420. uint32_t blockSize);
  2421. /**
  2422. * @brief Adds a constant offset to a Q15 vector.
  2423. * @param[in] *pSrc points to the input vector
  2424. * @param[in] offset is the offset to be added
  2425. * @param[out] *pDst points to the output vector
  2426. * @param[in] blockSize number of samples in the vector
  2427. * @return none.
  2428. */
  2429. void arm_offset_q15(
  2430. q15_t * pSrc,
  2431. q15_t offset,
  2432. q15_t * pDst,
  2433. uint32_t blockSize);
  2434. /**
  2435. * @brief Adds a constant offset to a Q31 vector.
  2436. * @param[in] *pSrc points to the input vector
  2437. * @param[in] offset is the offset to be added
  2438. * @param[out] *pDst points to the output vector
  2439. * @param[in] blockSize number of samples in the vector
  2440. * @return none.
  2441. */
  2442. void arm_offset_q31(
  2443. q31_t * pSrc,
  2444. q31_t offset,
  2445. q31_t * pDst,
  2446. uint32_t blockSize);
  2447. /**
  2448. * @brief Negates the elements of a floating-point vector.
  2449. * @param[in] *pSrc points to the input vector
  2450. * @param[out] *pDst points to the output vector
  2451. * @param[in] blockSize number of samples in the vector
  2452. * @return none.
  2453. */
  2454. void arm_negate_f32(
  2455. float32_t * pSrc,
  2456. float32_t * pDst,
  2457. uint32_t blockSize);
  2458. /**
  2459. * @brief Negates the elements of a Q7 vector.
  2460. * @param[in] *pSrc points to the input vector
  2461. * @param[out] *pDst points to the output vector
  2462. * @param[in] blockSize number of samples in the vector
  2463. * @return none.
  2464. */
  2465. void arm_negate_q7(
  2466. q7_t * pSrc,
  2467. q7_t * pDst,
  2468. uint32_t blockSize);
  2469. /**
  2470. * @brief Negates the elements of a Q15 vector.
  2471. * @param[in] *pSrc points to the input vector
  2472. * @param[out] *pDst points to the output vector
  2473. * @param[in] blockSize number of samples in the vector
  2474. * @return none.
  2475. */
  2476. void arm_negate_q15(
  2477. q15_t * pSrc,
  2478. q15_t * pDst,
  2479. uint32_t blockSize);
  2480. /**
  2481. * @brief Negates the elements of a Q31 vector.
  2482. * @param[in] *pSrc points to the input vector
  2483. * @param[out] *pDst points to the output vector
  2484. * @param[in] blockSize number of samples in the vector
  2485. * @return none.
  2486. */
  2487. void arm_negate_q31(
  2488. q31_t * pSrc,
  2489. q31_t * pDst,
  2490. uint32_t blockSize);
  2491. /**
  2492. * @brief Copies the elements of a floating-point vector.
  2493. * @param[in] *pSrc input pointer
  2494. * @param[out] *pDst output pointer
  2495. * @param[in] blockSize number of samples to process
  2496. * @return none.
  2497. */
  2498. void arm_copy_f32(
  2499. float32_t * pSrc,
  2500. float32_t * pDst,
  2501. uint32_t blockSize);
  2502. /**
  2503. * @brief Copies the elements of a Q7 vector.
  2504. * @param[in] *pSrc input pointer
  2505. * @param[out] *pDst output pointer
  2506. * @param[in] blockSize number of samples to process
  2507. * @return none.
  2508. */
  2509. void arm_copy_q7(
  2510. q7_t * pSrc,
  2511. q7_t * pDst,
  2512. uint32_t blockSize);
  2513. /**
  2514. * @brief Copies the elements of a Q15 vector.
  2515. * @param[in] *pSrc input pointer
  2516. * @param[out] *pDst output pointer
  2517. * @param[in] blockSize number of samples to process
  2518. * @return none.
  2519. */
  2520. void arm_copy_q15(
  2521. q15_t * pSrc,
  2522. q15_t * pDst,
  2523. uint32_t blockSize);
  2524. /**
  2525. * @brief Copies the elements of a Q31 vector.
  2526. * @param[in] *pSrc input pointer
  2527. * @param[out] *pDst output pointer
  2528. * @param[in] blockSize number of samples to process
  2529. * @return none.
  2530. */
  2531. void arm_copy_q31(
  2532. q31_t * pSrc,
  2533. q31_t * pDst,
  2534. uint32_t blockSize);
  2535. /**
  2536. * @brief Fills a constant value into a floating-point vector.
  2537. * @param[in] value input value to be filled
  2538. * @param[out] *pDst output pointer
  2539. * @param[in] blockSize number of samples to process
  2540. * @return none.
  2541. */
  2542. void arm_fill_f32(
  2543. float32_t value,
  2544. float32_t * pDst,
  2545. uint32_t blockSize);
  2546. /**
  2547. * @brief Fills a constant value into a Q7 vector.
  2548. * @param[in] value input value to be filled
  2549. * @param[out] *pDst output pointer
  2550. * @param[in] blockSize number of samples to process
  2551. * @return none.
  2552. */
  2553. void arm_fill_q7(
  2554. q7_t value,
  2555. q7_t * pDst,
  2556. uint32_t blockSize);
  2557. /**
  2558. * @brief Fills a constant value into a Q15 vector.
  2559. * @param[in] value input value to be filled
  2560. * @param[out] *pDst output pointer
  2561. * @param[in] blockSize number of samples to process
  2562. * @return none.
  2563. */
  2564. void arm_fill_q15(
  2565. q15_t value,
  2566. q15_t * pDst,
  2567. uint32_t blockSize);
  2568. /**
  2569. * @brief Fills a constant value into a Q31 vector.
  2570. * @param[in] value input value to be filled
  2571. * @param[out] *pDst output pointer
  2572. * @param[in] blockSize number of samples to process
  2573. * @return none.
  2574. */
  2575. void arm_fill_q31(
  2576. q31_t value,
  2577. q31_t * pDst,
  2578. uint32_t blockSize);
  2579. /**
  2580. * @brief Convolution of floating-point sequences.
  2581. * @param[in] *pSrcA points to the first input sequence.
  2582. * @param[in] srcALen length of the first input sequence.
  2583. * @param[in] *pSrcB points to the second input sequence.
  2584. * @param[in] srcBLen length of the second input sequence.
  2585. * @param[out] *pDst points to the location where the output result is written. Length srcALen+srcBLen-1.
  2586. * @return none.
  2587. */
  2588. void arm_conv_f32(
  2589. float32_t * pSrcA,
  2590. uint32_t srcALen,
  2591. float32_t * pSrcB,
  2592. uint32_t srcBLen,
  2593. float32_t * pDst);
  2594. /**
  2595. * @brief Convolution of Q15 sequences.
  2596. * @param[in] *pSrcA points to the first input sequence.
  2597. * @param[in] srcALen length of the first input sequence.
  2598. * @param[in] *pSrcB points to the second input sequence.
  2599. * @param[in] srcBLen length of the second input sequence.
  2600. * @param[out] *pDst points to the block of output data Length srcALen+srcBLen-1.
  2601. * @param[in] *pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  2602. * @param[in] *pScratch2 points to scratch buffer of size min(srcALen, srcBLen).
  2603. * @return none.
  2604. */
  2605. void arm_conv_opt_q15(
  2606. q15_t * pSrcA,
  2607. uint32_t srcALen,
  2608. q15_t * pSrcB,
  2609. uint32_t srcBLen,
  2610. q15_t * pDst,
  2611. q15_t * pScratch1,
  2612. q15_t * pScratch2);
  2613. /**
  2614. * @brief Convolution of Q15 sequences.
  2615. * @param[in] *pSrcA points to the first input sequence.
  2616. * @param[in] srcALen length of the first input sequence.
  2617. * @param[in] *pSrcB points to the second input sequence.
  2618. * @param[in] srcBLen length of the second input sequence.
  2619. * @param[out] *pDst points to the location where the output result is written. Length srcALen+srcBLen-1.
  2620. * @return none.
  2621. */
  2622. void arm_conv_q15(
  2623. q15_t * pSrcA,
  2624. uint32_t srcALen,
  2625. q15_t * pSrcB,
  2626. uint32_t srcBLen,
  2627. q15_t * pDst);
  2628. /**
  2629. * @brief Convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4
  2630. * @param[in] *pSrcA points to the first input sequence.
  2631. * @param[in] srcALen length of the first input sequence.
  2632. * @param[in] *pSrcB points to the second input sequence.
  2633. * @param[in] srcBLen length of the second input sequence.
  2634. * @param[out] *pDst points to the block of output data Length srcALen+srcBLen-1.
  2635. * @return none.
  2636. */
  2637. void arm_conv_fast_q15(
  2638. q15_t * pSrcA,
  2639. uint32_t srcALen,
  2640. q15_t * pSrcB,
  2641. uint32_t srcBLen,
  2642. q15_t * pDst);
  2643. /**
  2644. * @brief Convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4
  2645. * @param[in] *pSrcA points to the first input sequence.
  2646. * @param[in] srcALen length of the first input sequence.
  2647. * @param[in] *pSrcB points to the second input sequence.
  2648. * @param[in] srcBLen length of the second input sequence.
  2649. * @param[out] *pDst points to the block of output data Length srcALen+srcBLen-1.
  2650. * @param[in] *pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  2651. * @param[in] *pScratch2 points to scratch buffer of size min(srcALen, srcBLen).
  2652. * @return none.
  2653. */
  2654. void arm_conv_fast_opt_q15(
  2655. q15_t * pSrcA,
  2656. uint32_t srcALen,
  2657. q15_t * pSrcB,
  2658. uint32_t srcBLen,
  2659. q15_t * pDst,
  2660. q15_t * pScratch1,
  2661. q15_t * pScratch2);
  2662. /**
  2663. * @brief Convolution of Q31 sequences.
  2664. * @param[in] *pSrcA points to the first input sequence.
  2665. * @param[in] srcALen length of the first input sequence.
  2666. * @param[in] *pSrcB points to the second input sequence.
  2667. * @param[in] srcBLen length of the second input sequence.
  2668. * @param[out] *pDst points to the block of output data Length srcALen+srcBLen-1.
  2669. * @return none.
  2670. */
  2671. void arm_conv_q31(
  2672. q31_t * pSrcA,
  2673. uint32_t srcALen,
  2674. q31_t * pSrcB,
  2675. uint32_t srcBLen,
  2676. q31_t * pDst);
  2677. /**
  2678. * @brief Convolution of Q31 sequences (fast version) for Cortex-M3 and Cortex-M4
  2679. * @param[in] *pSrcA points to the first input sequence.
  2680. * @param[in] srcALen length of the first input sequence.
  2681. * @param[in] *pSrcB points to the second input sequence.
  2682. * @param[in] srcBLen length of the second input sequence.
  2683. * @param[out] *pDst points to the block of output data Length srcALen+srcBLen-1.
  2684. * @return none.
  2685. */
  2686. void arm_conv_fast_q31(
  2687. q31_t * pSrcA,
  2688. uint32_t srcALen,
  2689. q31_t * pSrcB,
  2690. uint32_t srcBLen,
  2691. q31_t * pDst);
  2692. /**
  2693. * @brief Convolution of Q7 sequences.
  2694. * @param[in] *pSrcA points to the first input sequence.
  2695. * @param[in] srcALen length of the first input sequence.
  2696. * @param[in] *pSrcB points to the second input sequence.
  2697. * @param[in] srcBLen length of the second input sequence.
  2698. * @param[out] *pDst points to the block of output data Length srcALen+srcBLen-1.
  2699. * @param[in] *pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  2700. * @param[in] *pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen).
  2701. * @return none.
  2702. */
  2703. void arm_conv_opt_q7(
  2704. q7_t * pSrcA,
  2705. uint32_t srcALen,
  2706. q7_t * pSrcB,
  2707. uint32_t srcBLen,
  2708. q7_t * pDst,
  2709. q15_t * pScratch1,
  2710. q15_t * pScratch2);
  2711. /**
  2712. * @brief Convolution of Q7 sequences.
  2713. * @param[in] *pSrcA points to the first input sequence.
  2714. * @param[in] srcALen length of the first input sequence.
  2715. * @param[in] *pSrcB points to the second input sequence.
  2716. * @param[in] srcBLen length of the second input sequence.
  2717. * @param[out] *pDst points to the block of output data Length srcALen+srcBLen-1.
  2718. * @return none.
  2719. */
  2720. void arm_conv_q7(
  2721. q7_t * pSrcA,
  2722. uint32_t srcALen,
  2723. q7_t * pSrcB,
  2724. uint32_t srcBLen,
  2725. q7_t * pDst);
  2726. /**
  2727. * @brief Partial convolution of floating-point sequences.
  2728. * @param[in] *pSrcA points to the first input sequence.
  2729. * @param[in] srcALen length of the first input sequence.
  2730. * @param[in] *pSrcB points to the second input sequence.
  2731. * @param[in] srcBLen length of the second input sequence.
  2732. * @param[out] *pDst points to the block of output data
  2733. * @param[in] firstIndex is the first output sample to start with.
  2734. * @param[in] numPoints is the number of output points to be computed.
  2735. * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2].
  2736. */
  2737. arm_status arm_conv_partial_f32(
  2738. float32_t * pSrcA,
  2739. uint32_t srcALen,
  2740. float32_t * pSrcB,
  2741. uint32_t srcBLen,
  2742. float32_t * pDst,
  2743. uint32_t firstIndex,
  2744. uint32_t numPoints);
  2745. /**
  2746. * @brief Partial convolution of Q15 sequences.
  2747. * @param[in] *pSrcA points to the first input sequence.
  2748. * @param[in] srcALen length of the first input sequence.
  2749. * @param[in] *pSrcB points to the second input sequence.
  2750. * @param[in] srcBLen length of the second input sequence.
  2751. * @param[out] *pDst points to the block of output data
  2752. * @param[in] firstIndex is the first output sample to start with.
  2753. * @param[in] numPoints is the number of output points to be computed.
  2754. * @param[in] * pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  2755. * @param[in] * pScratch2 points to scratch buffer of size min(srcALen, srcBLen).
  2756. * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2].
  2757. */
  2758. arm_status arm_conv_partial_opt_q15(
  2759. q15_t * pSrcA,
  2760. uint32_t srcALen,
  2761. q15_t * pSrcB,
  2762. uint32_t srcBLen,
  2763. q15_t * pDst,
  2764. uint32_t firstIndex,
  2765. uint32_t numPoints,
  2766. q15_t * pScratch1,
  2767. q15_t * pScratch2);
  2768. /**
  2769. * @brief Partial convolution of Q15 sequences.
  2770. * @param[in] *pSrcA points to the first input sequence.
  2771. * @param[in] srcALen length of the first input sequence.
  2772. * @param[in] *pSrcB points to the second input sequence.
  2773. * @param[in] srcBLen length of the second input sequence.
  2774. * @param[out] *pDst points to the block of output data
  2775. * @param[in] firstIndex is the first output sample to start with.
  2776. * @param[in] numPoints is the number of output points to be computed.
  2777. * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2].
  2778. */
  2779. arm_status arm_conv_partial_q15(
  2780. q15_t * pSrcA,
  2781. uint32_t srcALen,
  2782. q15_t * pSrcB,
  2783. uint32_t srcBLen,
  2784. q15_t * pDst,
  2785. uint32_t firstIndex,
  2786. uint32_t numPoints);
  2787. /**
  2788. * @brief Partial convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4
  2789. * @param[in] *pSrcA points to the first input sequence.
  2790. * @param[in] srcALen length of the first input sequence.
  2791. * @param[in] *pSrcB points to the second input sequence.
  2792. * @param[in] srcBLen length of the second input sequence.
  2793. * @param[out] *pDst points to the block of output data
  2794. * @param[in] firstIndex is the first output sample to start with.
  2795. * @param[in] numPoints is the number of output points to be computed.
  2796. * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2].
  2797. */
  2798. arm_status arm_conv_partial_fast_q15(
  2799. q15_t * pSrcA,
  2800. uint32_t srcALen,
  2801. q15_t * pSrcB,
  2802. uint32_t srcBLen,
  2803. q15_t * pDst,
  2804. uint32_t firstIndex,
  2805. uint32_t numPoints);
  2806. /**
  2807. * @brief Partial convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4
  2808. * @param[in] *pSrcA points to the first input sequence.
  2809. * @param[in] srcALen length of the first input sequence.
  2810. * @param[in] *pSrcB points to the second input sequence.
  2811. * @param[in] srcBLen length of the second input sequence.
  2812. * @param[out] *pDst points to the block of output data
  2813. * @param[in] firstIndex is the first output sample to start with.
  2814. * @param[in] numPoints is the number of output points to be computed.
  2815. * @param[in] * pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  2816. * @param[in] * pScratch2 points to scratch buffer of size min(srcALen, srcBLen).
  2817. * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2].
  2818. */
  2819. arm_status arm_conv_partial_fast_opt_q15(
  2820. q15_t * pSrcA,
  2821. uint32_t srcALen,
  2822. q15_t * pSrcB,
  2823. uint32_t srcBLen,
  2824. q15_t * pDst,
  2825. uint32_t firstIndex,
  2826. uint32_t numPoints,
  2827. q15_t * pScratch1,
  2828. q15_t * pScratch2);
  2829. /**
  2830. * @brief Partial convolution of Q31 sequences.
  2831. * @param[in] *pSrcA points to the first input sequence.
  2832. * @param[in] srcALen length of the first input sequence.
  2833. * @param[in] *pSrcB points to the second input sequence.
  2834. * @param[in] srcBLen length of the second input sequence.
  2835. * @param[out] *pDst points to the block of output data
  2836. * @param[in] firstIndex is the first output sample to start with.
  2837. * @param[in] numPoints is the number of output points to be computed.
  2838. * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2].
  2839. */
  2840. arm_status arm_conv_partial_q31(
  2841. q31_t * pSrcA,
  2842. uint32_t srcALen,
  2843. q31_t * pSrcB,
  2844. uint32_t srcBLen,
  2845. q31_t * pDst,
  2846. uint32_t firstIndex,
  2847. uint32_t numPoints);
  2848. /**
  2849. * @brief Partial convolution of Q31 sequences (fast version) for Cortex-M3 and Cortex-M4
  2850. * @param[in] *pSrcA points to the first input sequence.
  2851. * @param[in] srcALen length of the first input sequence.
  2852. * @param[in] *pSrcB points to the second input sequence.
  2853. * @param[in] srcBLen length of the second input sequence.
  2854. * @param[out] *pDst points to the block of output data
  2855. * @param[in] firstIndex is the first output sample to start with.
  2856. * @param[in] numPoints is the number of output points to be computed.
  2857. * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2].
  2858. */
  2859. arm_status arm_conv_partial_fast_q31(
  2860. q31_t * pSrcA,
  2861. uint32_t srcALen,
  2862. q31_t * pSrcB,
  2863. uint32_t srcBLen,
  2864. q31_t * pDst,
  2865. uint32_t firstIndex,
  2866. uint32_t numPoints);
  2867. /**
  2868. * @brief Partial convolution of Q7 sequences
  2869. * @param[in] *pSrcA points to the first input sequence.
  2870. * @param[in] srcALen length of the first input sequence.
  2871. * @param[in] *pSrcB points to the second input sequence.
  2872. * @param[in] srcBLen length of the second input sequence.
  2873. * @param[out] *pDst points to the block of output data
  2874. * @param[in] firstIndex is the first output sample to start with.
  2875. * @param[in] numPoints is the number of output points to be computed.
  2876. * @param[in] *pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  2877. * @param[in] *pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen).
  2878. * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2].
  2879. */
  2880. arm_status arm_conv_partial_opt_q7(
  2881. q7_t * pSrcA,
  2882. uint32_t srcALen,
  2883. q7_t * pSrcB,
  2884. uint32_t srcBLen,
  2885. q7_t * pDst,
  2886. uint32_t firstIndex,
  2887. uint32_t numPoints,
  2888. q15_t * pScratch1,
  2889. q15_t * pScratch2);
  2890. /**
  2891. * @brief Partial convolution of Q7 sequences.
  2892. * @param[in] *pSrcA points to the first input sequence.
  2893. * @param[in] srcALen length of the first input sequence.
  2894. * @param[in] *pSrcB points to the second input sequence.
  2895. * @param[in] srcBLen length of the second input sequence.
  2896. * @param[out] *pDst points to the block of output data
  2897. * @param[in] firstIndex is the first output sample to start with.
  2898. * @param[in] numPoints is the number of output points to be computed.
  2899. * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2].
  2900. */
  2901. arm_status arm_conv_partial_q7(
  2902. q7_t * pSrcA,
  2903. uint32_t srcALen,
  2904. q7_t * pSrcB,
  2905. uint32_t srcBLen,
  2906. q7_t * pDst,
  2907. uint32_t firstIndex,
  2908. uint32_t numPoints);
  2909. /**
  2910. * @brief Instance structure for the Q15 FIR decimator.
  2911. */
  2912. typedef struct
  2913. {
  2914. uint8_t M; /**< decimation factor. */
  2915. uint16_t numTaps; /**< number of coefficients in the filter. */
  2916. q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
  2917. q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  2918. } arm_fir_decimate_instance_q15;
  2919. /**
  2920. * @brief Instance structure for the Q31 FIR decimator.
  2921. */
  2922. typedef struct
  2923. {
  2924. uint8_t M; /**< decimation factor. */
  2925. uint16_t numTaps; /**< number of coefficients in the filter. */
  2926. q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
  2927. q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  2928. } arm_fir_decimate_instance_q31;
  2929. /**
  2930. * @brief Instance structure for the floating-point FIR decimator.
  2931. */
  2932. typedef struct
  2933. {
  2934. uint8_t M; /**< decimation factor. */
  2935. uint16_t numTaps; /**< number of coefficients in the filter. */
  2936. float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
  2937. float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  2938. } arm_fir_decimate_instance_f32;
  2939. /**
  2940. * @brief Processing function for the floating-point FIR decimator.
  2941. * @param[in] *S points to an instance of the floating-point FIR decimator structure.
  2942. * @param[in] *pSrc points to the block of input data.
  2943. * @param[out] *pDst points to the block of output data
  2944. * @param[in] blockSize number of input samples to process per call.
  2945. * @return none
  2946. */
  2947. void arm_fir_decimate_f32(
  2948. const arm_fir_decimate_instance_f32 * S,
  2949. float32_t * pSrc,
  2950. float32_t * pDst,
  2951. uint32_t blockSize);
  2952. /**
  2953. * @brief Initialization function for the floating-point FIR decimator.
  2954. * @param[in,out] *S points to an instance of the floating-point FIR decimator structure.
  2955. * @param[in] numTaps number of coefficients in the filter.
  2956. * @param[in] M decimation factor.
  2957. * @param[in] *pCoeffs points to the filter coefficients.
  2958. * @param[in] *pState points to the state buffer.
  2959. * @param[in] blockSize number of input samples to process per call.
  2960. * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
  2961. * <code>blockSize</code> is not a multiple of <code>M</code>.
  2962. */
  2963. arm_status arm_fir_decimate_init_f32(
  2964. arm_fir_decimate_instance_f32 * S,
  2965. uint16_t numTaps,
  2966. uint8_t M,
  2967. float32_t * pCoeffs,
  2968. float32_t * pState,
  2969. uint32_t blockSize);
  2970. /**
  2971. * @brief Processing function for the Q15 FIR decimator.
  2972. * @param[in] *S points to an instance of the Q15 FIR decimator structure.
  2973. * @param[in] *pSrc points to the block of input data.
  2974. * @param[out] *pDst points to the block of output data
  2975. * @param[in] blockSize number of input samples to process per call.
  2976. * @return none
  2977. */
  2978. void arm_fir_decimate_q15(
  2979. const arm_fir_decimate_instance_q15 * S,
  2980. q15_t * pSrc,
  2981. q15_t * pDst,
  2982. uint32_t blockSize);
  2983. /**
  2984. * @brief Processing function for the Q15 FIR decimator (fast variant) for Cortex-M3 and Cortex-M4.
  2985. * @param[in] *S points to an instance of the Q15 FIR decimator structure.
  2986. * @param[in] *pSrc points to the block of input data.
  2987. * @param[out] *pDst points to the block of output data
  2988. * @param[in] blockSize number of input samples to process per call.
  2989. * @return none
  2990. */
  2991. void arm_fir_decimate_fast_q15(
  2992. const arm_fir_decimate_instance_q15 * S,
  2993. q15_t * pSrc,
  2994. q15_t * pDst,
  2995. uint32_t blockSize);
  2996. /**
  2997. * @brief Initialization function for the Q15 FIR decimator.
  2998. * @param[in,out] *S points to an instance of the Q15 FIR decimator structure.
  2999. * @param[in] numTaps number of coefficients in the filter.
  3000. * @param[in] M decimation factor.
  3001. * @param[in] *pCoeffs points to the filter coefficients.
  3002. * @param[in] *pState points to the state buffer.
  3003. * @param[in] blockSize number of input samples to process per call.
  3004. * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
  3005. * <code>blockSize</code> is not a multiple of <code>M</code>.
  3006. */
  3007. arm_status arm_fir_decimate_init_q15(
  3008. arm_fir_decimate_instance_q15 * S,
  3009. uint16_t numTaps,
  3010. uint8_t M,
  3011. q15_t * pCoeffs,
  3012. q15_t * pState,
  3013. uint32_t blockSize);
  3014. /**
  3015. * @brief Processing function for the Q31 FIR decimator.
  3016. * @param[in] *S points to an instance of the Q31 FIR decimator structure.
  3017. * @param[in] *pSrc points to the block of input data.
  3018. * @param[out] *pDst points to the block of output data
  3019. * @param[in] blockSize number of input samples to process per call.
  3020. * @return none
  3021. */
  3022. void arm_fir_decimate_q31(
  3023. const arm_fir_decimate_instance_q31 * S,
  3024. q31_t * pSrc,
  3025. q31_t * pDst,
  3026. uint32_t blockSize);
  3027. /**
  3028. * @brief Processing function for the Q31 FIR decimator (fast variant) for Cortex-M3 and Cortex-M4.
  3029. * @param[in] *S points to an instance of the Q31 FIR decimator structure.
  3030. * @param[in] *pSrc points to the block of input data.
  3031. * @param[out] *pDst points to the block of output data
  3032. * @param[in] blockSize number of input samples to process per call.
  3033. * @return none
  3034. */
  3035. void arm_fir_decimate_fast_q31(
  3036. arm_fir_decimate_instance_q31 * S,
  3037. q31_t * pSrc,
  3038. q31_t * pDst,
  3039. uint32_t blockSize);
  3040. /**
  3041. * @brief Initialization function for the Q31 FIR decimator.
  3042. * @param[in,out] *S points to an instance of the Q31 FIR decimator structure.
  3043. * @param[in] numTaps number of coefficients in the filter.
  3044. * @param[in] M decimation factor.
  3045. * @param[in] *pCoeffs points to the filter coefficients.
  3046. * @param[in] *pState points to the state buffer.
  3047. * @param[in] blockSize number of input samples to process per call.
  3048. * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
  3049. * <code>blockSize</code> is not a multiple of <code>M</code>.
  3050. */
  3051. arm_status arm_fir_decimate_init_q31(
  3052. arm_fir_decimate_instance_q31 * S,
  3053. uint16_t numTaps,
  3054. uint8_t M,
  3055. q31_t * pCoeffs,
  3056. q31_t * pState,
  3057. uint32_t blockSize);
  3058. /**
  3059. * @brief Instance structure for the Q15 FIR interpolator.
  3060. */
  3061. typedef struct
  3062. {
  3063. uint8_t L; /**< upsample factor. */
  3064. uint16_t phaseLength; /**< length of each polyphase filter component. */
  3065. q15_t *pCoeffs; /**< points to the coefficient array. The array is of length L*phaseLength. */
  3066. q15_t *pState; /**< points to the state variable array. The array is of length blockSize+phaseLength-1. */
  3067. } arm_fir_interpolate_instance_q15;
  3068. /**
  3069. * @brief Instance structure for the Q31 FIR interpolator.
  3070. */
  3071. typedef struct
  3072. {
  3073. uint8_t L; /**< upsample factor. */
  3074. uint16_t phaseLength; /**< length of each polyphase filter component. */
  3075. q31_t *pCoeffs; /**< points to the coefficient array. The array is of length L*phaseLength. */
  3076. q31_t *pState; /**< points to the state variable array. The array is of length blockSize+phaseLength-1. */
  3077. } arm_fir_interpolate_instance_q31;
  3078. /**
  3079. * @brief Instance structure for the floating-point FIR interpolator.
  3080. */
  3081. typedef struct
  3082. {
  3083. uint8_t L; /**< upsample factor. */
  3084. uint16_t phaseLength; /**< length of each polyphase filter component. */
  3085. float32_t *pCoeffs; /**< points to the coefficient array. The array is of length L*phaseLength. */
  3086. float32_t *pState; /**< points to the state variable array. The array is of length phaseLength+numTaps-1. */
  3087. } arm_fir_interpolate_instance_f32;
  3088. /**
  3089. * @brief Processing function for the Q15 FIR interpolator.
  3090. * @param[in] *S points to an instance of the Q15 FIR interpolator structure.
  3091. * @param[in] *pSrc points to the block of input data.
  3092. * @param[out] *pDst points to the block of output data.
  3093. * @param[in] blockSize number of input samples to process per call.
  3094. * @return none.
  3095. */
  3096. void arm_fir_interpolate_q15(
  3097. const arm_fir_interpolate_instance_q15 * S,
  3098. q15_t * pSrc,
  3099. q15_t * pDst,
  3100. uint32_t blockSize);
  3101. /**
  3102. * @brief Initialization function for the Q15 FIR interpolator.
  3103. * @param[in,out] *S points to an instance of the Q15 FIR interpolator structure.
  3104. * @param[in] L upsample factor.
  3105. * @param[in] numTaps number of filter coefficients in the filter.
  3106. * @param[in] *pCoeffs points to the filter coefficient buffer.
  3107. * @param[in] *pState points to the state buffer.
  3108. * @param[in] blockSize number of input samples to process per call.
  3109. * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
  3110. * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>.
  3111. */
  3112. arm_status arm_fir_interpolate_init_q15(
  3113. arm_fir_interpolate_instance_q15 * S,
  3114. uint8_t L,
  3115. uint16_t numTaps,
  3116. q15_t * pCoeffs,
  3117. q15_t * pState,
  3118. uint32_t blockSize);
  3119. /**
  3120. * @brief Processing function for the Q31 FIR interpolator.
  3121. * @param[in] *S points to an instance of the Q15 FIR interpolator structure.
  3122. * @param[in] *pSrc points to the block of input data.
  3123. * @param[out] *pDst points to the block of output data.
  3124. * @param[in] blockSize number of input samples to process per call.
  3125. * @return none.
  3126. */
  3127. void arm_fir_interpolate_q31(
  3128. const arm_fir_interpolate_instance_q31 * S,
  3129. q31_t * pSrc,
  3130. q31_t * pDst,
  3131. uint32_t blockSize);
  3132. /**
  3133. * @brief Initialization function for the Q31 FIR interpolator.
  3134. * @param[in,out] *S points to an instance of the Q31 FIR interpolator structure.
  3135. * @param[in] L upsample factor.
  3136. * @param[in] numTaps number of filter coefficients in the filter.
  3137. * @param[in] *pCoeffs points to the filter coefficient buffer.
  3138. * @param[in] *pState points to the state buffer.
  3139. * @param[in] blockSize number of input samples to process per call.
  3140. * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
  3141. * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>.
  3142. */
  3143. arm_status arm_fir_interpolate_init_q31(
  3144. arm_fir_interpolate_instance_q31 * S,
  3145. uint8_t L,
  3146. uint16_t numTaps,
  3147. q31_t * pCoeffs,
  3148. q31_t * pState,
  3149. uint32_t blockSize);
  3150. /**
  3151. * @brief Processing function for the floating-point FIR interpolator.
  3152. * @param[in] *S points to an instance of the floating-point FIR interpolator structure.
  3153. * @param[in] *pSrc points to the block of input data.
  3154. * @param[out] *pDst points to the block of output data.
  3155. * @param[in] blockSize number of input samples to process per call.
  3156. * @return none.
  3157. */
  3158. void arm_fir_interpolate_f32(
  3159. const arm_fir_interpolate_instance_f32 * S,
  3160. float32_t * pSrc,
  3161. float32_t * pDst,
  3162. uint32_t blockSize);
  3163. /**
  3164. * @brief Initialization function for the floating-point FIR interpolator.
  3165. * @param[in,out] *S points to an instance of the floating-point FIR interpolator structure.
  3166. * @param[in] L upsample factor.
  3167. * @param[in] numTaps number of filter coefficients in the filter.
  3168. * @param[in] *pCoeffs points to the filter coefficient buffer.
  3169. * @param[in] *pState points to the state buffer.
  3170. * @param[in] blockSize number of input samples to process per call.
  3171. * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
  3172. * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>.
  3173. */
  3174. arm_status arm_fir_interpolate_init_f32(
  3175. arm_fir_interpolate_instance_f32 * S,
  3176. uint8_t L,
  3177. uint16_t numTaps,
  3178. float32_t * pCoeffs,
  3179. float32_t * pState,
  3180. uint32_t blockSize);
  3181. /**
  3182. * @brief Instance structure for the high precision Q31 Biquad cascade filter.
  3183. */
  3184. typedef struct
  3185. {
  3186. uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
  3187. q63_t *pState; /**< points to the array of state coefficients. The array is of length 4*numStages. */
  3188. q31_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */
  3189. uint8_t postShift; /**< additional shift, in bits, applied to each output sample. */
  3190. } arm_biquad_cas_df1_32x64_ins_q31;
  3191. /**
  3192. * @param[in] *S points to an instance of the high precision Q31 Biquad cascade filter structure.
  3193. * @param[in] *pSrc points to the block of input data.
  3194. * @param[out] *pDst points to the block of output data
  3195. * @param[in] blockSize number of samples to process.
  3196. * @return none.
  3197. */
  3198. void arm_biquad_cas_df1_32x64_q31(
  3199. const arm_biquad_cas_df1_32x64_ins_q31 * S,
  3200. q31_t * pSrc,
  3201. q31_t * pDst,
  3202. uint32_t blockSize);
  3203. /**
  3204. * @param[in,out] *S points to an instance of the high precision Q31 Biquad cascade filter structure.
  3205. * @param[in] numStages number of 2nd order stages in the filter.
  3206. * @param[in] *pCoeffs points to the filter coefficients.
  3207. * @param[in] *pState points to the state buffer.
  3208. * @param[in] postShift shift to be applied to the output. Varies according to the coefficients format
  3209. * @return none
  3210. */
  3211. void arm_biquad_cas_df1_32x64_init_q31(
  3212. arm_biquad_cas_df1_32x64_ins_q31 * S,
  3213. uint8_t numStages,
  3214. q31_t * pCoeffs,
  3215. q63_t * pState,
  3216. uint8_t postShift);
  3217. /**
  3218. * @brief Instance structure for the floating-point transposed direct form II Biquad cascade filter.
  3219. */
  3220. typedef struct
  3221. {
  3222. uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
  3223. float32_t *pState; /**< points to the array of state coefficients. The array is of length 2*numStages. */
  3224. float32_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */
  3225. } arm_biquad_cascade_df2T_instance_f32;
  3226. /**
  3227. * @brief Instance structure for the floating-point transposed direct form II Biquad cascade filter.
  3228. */
  3229. typedef struct
  3230. {
  3231. uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
  3232. float32_t *pState; /**< points to the array of state coefficients. The array is of length 4*numStages. */
  3233. float32_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */
  3234. } arm_biquad_cascade_stereo_df2T_instance_f32;
  3235. /**
  3236. * @brief Instance structure for the floating-point transposed direct form II Biquad cascade filter.
  3237. */
  3238. typedef struct
  3239. {
  3240. uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
  3241. float64_t *pState; /**< points to the array of state coefficients. The array is of length 2*numStages. */
  3242. float64_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */
  3243. } arm_biquad_cascade_df2T_instance_f64;
  3244. /**
  3245. * @brief Processing function for the floating-point transposed direct form II Biquad cascade filter.
  3246. * @param[in] *S points to an instance of the filter data structure.
  3247. * @param[in] *pSrc points to the block of input data.
  3248. * @param[out] *pDst points to the block of output data
  3249. * @param[in] blockSize number of samples to process.
  3250. * @return none.
  3251. */
  3252. void arm_biquad_cascade_df2T_f32(
  3253. const arm_biquad_cascade_df2T_instance_f32 * S,
  3254. float32_t * pSrc,
  3255. float32_t * pDst,
  3256. uint32_t blockSize);
  3257. /**
  3258. * @brief Processing function for the floating-point transposed direct form II Biquad cascade filter. 2 channels
  3259. * @param[in] *S points to an instance of the filter data structure.
  3260. * @param[in] *pSrc points to the block of input data.
  3261. * @param[out] *pDst points to the block of output data
  3262. * @param[in] blockSize number of samples to process.
  3263. * @return none.
  3264. */
  3265. void arm_biquad_cascade_stereo_df2T_f32(
  3266. const arm_biquad_cascade_stereo_df2T_instance_f32 * S,
  3267. float32_t * pSrc,
  3268. float32_t * pDst,
  3269. uint32_t blockSize);
  3270. /**
  3271. * @brief Processing function for the floating-point transposed direct form II Biquad cascade filter.
  3272. * @param[in] *S points to an instance of the filter data structure.
  3273. * @param[in] *pSrc points to the block of input data.
  3274. * @param[out] *pDst points to the block of output data
  3275. * @param[in] blockSize number of samples to process.
  3276. * @return none.
  3277. */
  3278. void arm_biquad_cascade_df2T_f64(
  3279. const arm_biquad_cascade_df2T_instance_f64 * S,
  3280. float64_t * pSrc,
  3281. float64_t * pDst,
  3282. uint32_t blockSize);
  3283. /**
  3284. * @brief Initialization function for the floating-point transposed direct form II Biquad cascade filter.
  3285. * @param[in,out] *S points to an instance of the filter data structure.
  3286. * @param[in] numStages number of 2nd order stages in the filter.
  3287. * @param[in] *pCoeffs points to the filter coefficients.
  3288. * @param[in] *pState points to the state buffer.
  3289. * @return none
  3290. */
  3291. void arm_biquad_cascade_df2T_init_f32(
  3292. arm_biquad_cascade_df2T_instance_f32 * S,
  3293. uint8_t numStages,
  3294. float32_t * pCoeffs,
  3295. float32_t * pState);
  3296. /**
  3297. * @brief Initialization function for the floating-point transposed direct form II Biquad cascade filter.
  3298. * @param[in,out] *S points to an instance of the filter data structure.
  3299. * @param[in] numStages number of 2nd order stages in the filter.
  3300. * @param[in] *pCoeffs points to the filter coefficients.
  3301. * @param[in] *pState points to the state buffer.
  3302. * @return none
  3303. */
  3304. void arm_biquad_cascade_stereo_df2T_init_f32(
  3305. arm_biquad_cascade_stereo_df2T_instance_f32 * S,
  3306. uint8_t numStages,
  3307. float32_t * pCoeffs,
  3308. float32_t * pState);
  3309. /**
  3310. * @brief Initialization function for the floating-point transposed direct form II Biquad cascade filter.
  3311. * @param[in,out] *S points to an instance of the filter data structure.
  3312. * @param[in] numStages number of 2nd order stages in the filter.
  3313. * @param[in] *pCoeffs points to the filter coefficients.
  3314. * @param[in] *pState points to the state buffer.
  3315. * @return none
  3316. */
  3317. void arm_biquad_cascade_df2T_init_f64(
  3318. arm_biquad_cascade_df2T_instance_f64 * S,
  3319. uint8_t numStages,
  3320. float64_t * pCoeffs,
  3321. float64_t * pState);
  3322. /**
  3323. * @brief Instance structure for the Q15 FIR lattice filter.
  3324. */
  3325. typedef struct
  3326. {
  3327. uint16_t numStages; /**< number of filter stages. */
  3328. q15_t *pState; /**< points to the state variable array. The array is of length numStages. */
  3329. q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numStages. */
  3330. } arm_fir_lattice_instance_q15;
  3331. /**
  3332. * @brief Instance structure for the Q31 FIR lattice filter.
  3333. */
  3334. typedef struct
  3335. {
  3336. uint16_t numStages; /**< number of filter stages. */
  3337. q31_t *pState; /**< points to the state variable array. The array is of length numStages. */
  3338. q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numStages. */
  3339. } arm_fir_lattice_instance_q31;
  3340. /**
  3341. * @brief Instance structure for the floating-point FIR lattice filter.
  3342. */
  3343. typedef struct
  3344. {
  3345. uint16_t numStages; /**< number of filter stages. */
  3346. float32_t *pState; /**< points to the state variable array. The array is of length numStages. */
  3347. float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numStages. */
  3348. } arm_fir_lattice_instance_f32;
  3349. /**
  3350. * @brief Initialization function for the Q15 FIR lattice filter.
  3351. * @param[in] *S points to an instance of the Q15 FIR lattice structure.
  3352. * @param[in] numStages number of filter stages.
  3353. * @param[in] *pCoeffs points to the coefficient buffer. The array is of length numStages.
  3354. * @param[in] *pState points to the state buffer. The array is of length numStages.
  3355. * @return none.
  3356. */
  3357. void arm_fir_lattice_init_q15(
  3358. arm_fir_lattice_instance_q15 * S,
  3359. uint16_t numStages,
  3360. q15_t * pCoeffs,
  3361. q15_t * pState);
  3362. /**
  3363. * @brief Processing function for the Q15 FIR lattice filter.
  3364. * @param[in] *S points to an instance of the Q15 FIR lattice structure.
  3365. * @param[in] *pSrc points to the block of input data.
  3366. * @param[out] *pDst points to the block of output data.
  3367. * @param[in] blockSize number of samples to process.
  3368. * @return none.
  3369. */
  3370. void arm_fir_lattice_q15(
  3371. const arm_fir_lattice_instance_q15 * S,
  3372. q15_t * pSrc,
  3373. q15_t * pDst,
  3374. uint32_t blockSize);
  3375. /**
  3376. * @brief Initialization function for the Q31 FIR lattice filter.
  3377. * @param[in] *S points to an instance of the Q31 FIR lattice structure.
  3378. * @param[in] numStages number of filter stages.
  3379. * @param[in] *pCoeffs points to the coefficient buffer. The array is of length numStages.
  3380. * @param[in] *pState points to the state buffer. The array is of length numStages.
  3381. * @return none.
  3382. */
  3383. void arm_fir_lattice_init_q31(
  3384. arm_fir_lattice_instance_q31 * S,
  3385. uint16_t numStages,
  3386. q31_t * pCoeffs,
  3387. q31_t * pState);
  3388. /**
  3389. * @brief Processing function for the Q31 FIR lattice filter.
  3390. * @param[in] *S points to an instance of the Q31 FIR lattice structure.
  3391. * @param[in] *pSrc points to the block of input data.
  3392. * @param[out] *pDst points to the block of output data
  3393. * @param[in] blockSize number of samples to process.
  3394. * @return none.
  3395. */
  3396. void arm_fir_lattice_q31(
  3397. const arm_fir_lattice_instance_q31 * S,
  3398. q31_t * pSrc,
  3399. q31_t * pDst,
  3400. uint32_t blockSize);
  3401. /**
  3402. * @brief Initialization function for the floating-point FIR lattice filter.
  3403. * @param[in] *S points to an instance of the floating-point FIR lattice structure.
  3404. * @param[in] numStages number of filter stages.
  3405. * @param[in] *pCoeffs points to the coefficient buffer. The array is of length numStages.
  3406. * @param[in] *pState points to the state buffer. The array is of length numStages.
  3407. * @return none.
  3408. */
  3409. void arm_fir_lattice_init_f32(
  3410. arm_fir_lattice_instance_f32 * S,
  3411. uint16_t numStages,
  3412. float32_t * pCoeffs,
  3413. float32_t * pState);
  3414. /**
  3415. * @brief Processing function for the floating-point FIR lattice filter.
  3416. * @param[in] *S points to an instance of the floating-point FIR lattice structure.
  3417. * @param[in] *pSrc points to the block of input data.
  3418. * @param[out] *pDst points to the block of output data
  3419. * @param[in] blockSize number of samples to process.
  3420. * @return none.
  3421. */
  3422. void arm_fir_lattice_f32(
  3423. const arm_fir_lattice_instance_f32 * S,
  3424. float32_t * pSrc,
  3425. float32_t * pDst,
  3426. uint32_t blockSize);
  3427. /**
  3428. * @brief Instance structure for the Q15 IIR lattice filter.
  3429. */
  3430. typedef struct
  3431. {
  3432. uint16_t numStages; /**< number of stages in the filter. */
  3433. q15_t *pState; /**< points to the state variable array. The array is of length numStages+blockSize. */
  3434. q15_t *pkCoeffs; /**< points to the reflection coefficient array. The array is of length numStages. */
  3435. q15_t *pvCoeffs; /**< points to the ladder coefficient array. The array is of length numStages+1. */
  3436. } arm_iir_lattice_instance_q15;
  3437. /**
  3438. * @brief Instance structure for the Q31 IIR lattice filter.
  3439. */
  3440. typedef struct
  3441. {
  3442. uint16_t numStages; /**< number of stages in the filter. */
  3443. q31_t *pState; /**< points to the state variable array. The array is of length numStages+blockSize. */
  3444. q31_t *pkCoeffs; /**< points to the reflection coefficient array. The array is of length numStages. */
  3445. q31_t *pvCoeffs; /**< points to the ladder coefficient array. The array is of length numStages+1. */
  3446. } arm_iir_lattice_instance_q31;
  3447. /**
  3448. * @brief Instance structure for the floating-point IIR lattice filter.
  3449. */
  3450. typedef struct
  3451. {
  3452. uint16_t numStages; /**< number of stages in the filter. */
  3453. float32_t *pState; /**< points to the state variable array. The array is of length numStages+blockSize. */
  3454. float32_t *pkCoeffs; /**< points to the reflection coefficient array. The array is of length numStages. */
  3455. float32_t *pvCoeffs; /**< points to the ladder coefficient array. The array is of length numStages+1. */
  3456. } arm_iir_lattice_instance_f32;
  3457. /**
  3458. * @brief Processing function for the floating-point IIR lattice filter.
  3459. * @param[in] *S points to an instance of the floating-point IIR lattice structure.
  3460. * @param[in] *pSrc points to the block of input data.
  3461. * @param[out] *pDst points to the block of output data.
  3462. * @param[in] blockSize number of samples to process.
  3463. * @return none.
  3464. */
  3465. void arm_iir_lattice_f32(
  3466. const arm_iir_lattice_instance_f32 * S,
  3467. float32_t * pSrc,
  3468. float32_t * pDst,
  3469. uint32_t blockSize);
  3470. /**
  3471. * @brief Initialization function for the floating-point IIR lattice filter.
  3472. * @param[in] *S points to an instance of the floating-point IIR lattice structure.
  3473. * @param[in] numStages number of stages in the filter.
  3474. * @param[in] *pkCoeffs points to the reflection coefficient buffer. The array is of length numStages.
  3475. * @param[in] *pvCoeffs points to the ladder coefficient buffer. The array is of length numStages+1.
  3476. * @param[in] *pState points to the state buffer. The array is of length numStages+blockSize-1.
  3477. * @param[in] blockSize number of samples to process.
  3478. * @return none.
  3479. */
  3480. void arm_iir_lattice_init_f32(
  3481. arm_iir_lattice_instance_f32 * S,
  3482. uint16_t numStages,
  3483. float32_t * pkCoeffs,
  3484. float32_t * pvCoeffs,
  3485. float32_t * pState,
  3486. uint32_t blockSize);
  3487. /**
  3488. * @brief Processing function for the Q31 IIR lattice filter.
  3489. * @param[in] *S points to an instance of the Q31 IIR lattice structure.
  3490. * @param[in] *pSrc points to the block of input data.
  3491. * @param[out] *pDst points to the block of output data.
  3492. * @param[in] blockSize number of samples to process.
  3493. * @return none.
  3494. */
  3495. void arm_iir_lattice_q31(
  3496. const arm_iir_lattice_instance_q31 * S,
  3497. q31_t * pSrc,
  3498. q31_t * pDst,
  3499. uint32_t blockSize);
  3500. /**
  3501. * @brief Initialization function for the Q31 IIR lattice filter.
  3502. * @param[in] *S points to an instance of the Q31 IIR lattice structure.
  3503. * @param[in] numStages number of stages in the filter.
  3504. * @param[in] *pkCoeffs points to the reflection coefficient buffer. The array is of length numStages.
  3505. * @param[in] *pvCoeffs points to the ladder coefficient buffer. The array is of length numStages+1.
  3506. * @param[in] *pState points to the state buffer. The array is of length numStages+blockSize.
  3507. * @param[in] blockSize number of samples to process.
  3508. * @return none.
  3509. */
  3510. void arm_iir_lattice_init_q31(
  3511. arm_iir_lattice_instance_q31 * S,
  3512. uint16_t numStages,
  3513. q31_t * pkCoeffs,
  3514. q31_t * pvCoeffs,
  3515. q31_t * pState,
  3516. uint32_t blockSize);
  3517. /**
  3518. * @brief Processing function for the Q15 IIR lattice filter.
  3519. * @param[in] *S points to an instance of the Q15 IIR lattice structure.
  3520. * @param[in] *pSrc points to the block of input data.
  3521. * @param[out] *pDst points to the block of output data.
  3522. * @param[in] blockSize number of samples to process.
  3523. * @return none.
  3524. */
  3525. void arm_iir_lattice_q15(
  3526. const arm_iir_lattice_instance_q15 * S,
  3527. q15_t * pSrc,
  3528. q15_t * pDst,
  3529. uint32_t blockSize);
  3530. /**
  3531. * @brief Initialization function for the Q15 IIR lattice filter.
  3532. * @param[in] *S points to an instance of the fixed-point Q15 IIR lattice structure.
  3533. * @param[in] numStages number of stages in the filter.
  3534. * @param[in] *pkCoeffs points to reflection coefficient buffer. The array is of length numStages.
  3535. * @param[in] *pvCoeffs points to ladder coefficient buffer. The array is of length numStages+1.
  3536. * @param[in] *pState points to state buffer. The array is of length numStages+blockSize.
  3537. * @param[in] blockSize number of samples to process per call.
  3538. * @return none.
  3539. */
  3540. void arm_iir_lattice_init_q15(
  3541. arm_iir_lattice_instance_q15 * S,
  3542. uint16_t numStages,
  3543. q15_t * pkCoeffs,
  3544. q15_t * pvCoeffs,
  3545. q15_t * pState,
  3546. uint32_t blockSize);
  3547. /**
  3548. * @brief Instance structure for the floating-point LMS filter.
  3549. */
  3550. typedef struct
  3551. {
  3552. uint16_t numTaps; /**< number of coefficients in the filter. */
  3553. float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  3554. float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
  3555. float32_t mu; /**< step size that controls filter coefficient updates. */
  3556. } arm_lms_instance_f32;
  3557. /**
  3558. * @brief Processing function for floating-point LMS filter.
  3559. * @param[in] *S points to an instance of the floating-point LMS filter structure.
  3560. * @param[in] *pSrc points to the block of input data.
  3561. * @param[in] *pRef points to the block of reference data.
  3562. * @param[out] *pOut points to the block of output data.
  3563. * @param[out] *pErr points to the block of error data.
  3564. * @param[in] blockSize number of samples to process.
  3565. * @return none.
  3566. */
  3567. void arm_lms_f32(
  3568. const arm_lms_instance_f32 * S,
  3569. float32_t * pSrc,
  3570. float32_t * pRef,
  3571. float32_t * pOut,
  3572. float32_t * pErr,
  3573. uint32_t blockSize);
  3574. /**
  3575. * @brief Initialization function for floating-point LMS filter.
  3576. * @param[in] *S points to an instance of the floating-point LMS filter structure.
  3577. * @param[in] numTaps number of filter coefficients.
  3578. * @param[in] *pCoeffs points to the coefficient buffer.
  3579. * @param[in] *pState points to state buffer.
  3580. * @param[in] mu step size that controls filter coefficient updates.
  3581. * @param[in] blockSize number of samples to process.
  3582. * @return none.
  3583. */
  3584. void arm_lms_init_f32(
  3585. arm_lms_instance_f32 * S,
  3586. uint16_t numTaps,
  3587. float32_t * pCoeffs,
  3588. float32_t * pState,
  3589. float32_t mu,
  3590. uint32_t blockSize);
  3591. /**
  3592. * @brief Instance structure for the Q15 LMS filter.
  3593. */
  3594. typedef struct
  3595. {
  3596. uint16_t numTaps; /**< number of coefficients in the filter. */
  3597. q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  3598. q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
  3599. q15_t mu; /**< step size that controls filter coefficient updates. */
  3600. uint32_t postShift; /**< bit shift applied to coefficients. */
  3601. } arm_lms_instance_q15;
  3602. /**
  3603. * @brief Initialization function for the Q15 LMS filter.
  3604. * @param[in] *S points to an instance of the Q15 LMS filter structure.
  3605. * @param[in] numTaps number of filter coefficients.
  3606. * @param[in] *pCoeffs points to the coefficient buffer.
  3607. * @param[in] *pState points to the state buffer.
  3608. * @param[in] mu step size that controls filter coefficient updates.
  3609. * @param[in] blockSize number of samples to process.
  3610. * @param[in] postShift bit shift applied to coefficients.
  3611. * @return none.
  3612. */
  3613. void arm_lms_init_q15(
  3614. arm_lms_instance_q15 * S,
  3615. uint16_t numTaps,
  3616. q15_t * pCoeffs,
  3617. q15_t * pState,
  3618. q15_t mu,
  3619. uint32_t blockSize,
  3620. uint32_t postShift);
  3621. /**
  3622. * @brief Processing function for Q15 LMS filter.
  3623. * @param[in] *S points to an instance of the Q15 LMS filter structure.
  3624. * @param[in] *pSrc points to the block of input data.
  3625. * @param[in] *pRef points to the block of reference data.
  3626. * @param[out] *pOut points to the block of output data.
  3627. * @param[out] *pErr points to the block of error data.
  3628. * @param[in] blockSize number of samples to process.
  3629. * @return none.
  3630. */
  3631. void arm_lms_q15(
  3632. const arm_lms_instance_q15 * S,
  3633. q15_t * pSrc,
  3634. q15_t * pRef,
  3635. q15_t * pOut,
  3636. q15_t * pErr,
  3637. uint32_t blockSize);
  3638. /**
  3639. * @brief Instance structure for the Q31 LMS filter.
  3640. */
  3641. typedef struct
  3642. {
  3643. uint16_t numTaps; /**< number of coefficients in the filter. */
  3644. q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  3645. q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
  3646. q31_t mu; /**< step size that controls filter coefficient updates. */
  3647. uint32_t postShift; /**< bit shift applied to coefficients. */
  3648. } arm_lms_instance_q31;
  3649. /**
  3650. * @brief Processing function for Q31 LMS filter.
  3651. * @param[in] *S points to an instance of the Q15 LMS filter structure.
  3652. * @param[in] *pSrc points to the block of input data.
  3653. * @param[in] *pRef points to the block of reference data.
  3654. * @param[out] *pOut points to the block of output data.
  3655. * @param[out] *pErr points to the block of error data.
  3656. * @param[in] blockSize number of samples to process.
  3657. * @return none.
  3658. */
  3659. void arm_lms_q31(
  3660. const arm_lms_instance_q31 * S,
  3661. q31_t * pSrc,
  3662. q31_t * pRef,
  3663. q31_t * pOut,
  3664. q31_t * pErr,
  3665. uint32_t blockSize);
  3666. /**
  3667. * @brief Initialization function for Q31 LMS filter.
  3668. * @param[in] *S points to an instance of the Q31 LMS filter structure.
  3669. * @param[in] numTaps number of filter coefficients.
  3670. * @param[in] *pCoeffs points to coefficient buffer.
  3671. * @param[in] *pState points to state buffer.
  3672. * @param[in] mu step size that controls filter coefficient updates.
  3673. * @param[in] blockSize number of samples to process.
  3674. * @param[in] postShift bit shift applied to coefficients.
  3675. * @return none.
  3676. */
  3677. void arm_lms_init_q31(
  3678. arm_lms_instance_q31 * S,
  3679. uint16_t numTaps,
  3680. q31_t * pCoeffs,
  3681. q31_t * pState,
  3682. q31_t mu,
  3683. uint32_t blockSize,
  3684. uint32_t postShift);
  3685. /**
  3686. * @brief Instance structure for the floating-point normalized LMS filter.
  3687. */
  3688. typedef struct
  3689. {
  3690. uint16_t numTaps; /**< number of coefficients in the filter. */
  3691. float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  3692. float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
  3693. float32_t mu; /**< step size that control filter coefficient updates. */
  3694. float32_t energy; /**< saves previous frame energy. */
  3695. float32_t x0; /**< saves previous input sample. */
  3696. } arm_lms_norm_instance_f32;
  3697. /**
  3698. * @brief Processing function for floating-point normalized LMS filter.
  3699. * @param[in] *S points to an instance of the floating-point normalized LMS filter structure.
  3700. * @param[in] *pSrc points to the block of input data.
  3701. * @param[in] *pRef points to the block of reference data.
  3702. * @param[out] *pOut points to the block of output data.
  3703. * @param[out] *pErr points to the block of error data.
  3704. * @param[in] blockSize number of samples to process.
  3705. * @return none.
  3706. */
  3707. void arm_lms_norm_f32(
  3708. arm_lms_norm_instance_f32 * S,
  3709. float32_t * pSrc,
  3710. float32_t * pRef,
  3711. float32_t * pOut,
  3712. float32_t * pErr,
  3713. uint32_t blockSize);
  3714. /**
  3715. * @brief Initialization function for floating-point normalized LMS filter.
  3716. * @param[in] *S points to an instance of the floating-point LMS filter structure.
  3717. * @param[in] numTaps number of filter coefficients.
  3718. * @param[in] *pCoeffs points to coefficient buffer.
  3719. * @param[in] *pState points to state buffer.
  3720. * @param[in] mu step size that controls filter coefficient updates.
  3721. * @param[in] blockSize number of samples to process.
  3722. * @return none.
  3723. */
  3724. void arm_lms_norm_init_f32(
  3725. arm_lms_norm_instance_f32 * S,
  3726. uint16_t numTaps,
  3727. float32_t * pCoeffs,
  3728. float32_t * pState,
  3729. float32_t mu,
  3730. uint32_t blockSize);
  3731. /**
  3732. * @brief Instance structure for the Q31 normalized LMS filter.
  3733. */
  3734. typedef struct
  3735. {
  3736. uint16_t numTaps; /**< number of coefficients in the filter. */
  3737. q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  3738. q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
  3739. q31_t mu; /**< step size that controls filter coefficient updates. */
  3740. uint8_t postShift; /**< bit shift applied to coefficients. */
  3741. q31_t *recipTable; /**< points to the reciprocal initial value table. */
  3742. q31_t energy; /**< saves previous frame energy. */
  3743. q31_t x0; /**< saves previous input sample. */
  3744. } arm_lms_norm_instance_q31;
  3745. /**
  3746. * @brief Processing function for Q31 normalized LMS filter.
  3747. * @param[in] *S points to an instance of the Q31 normalized LMS filter structure.
  3748. * @param[in] *pSrc points to the block of input data.
  3749. * @param[in] *pRef points to the block of reference data.
  3750. * @param[out] *pOut points to the block of output data.
  3751. * @param[out] *pErr points to the block of error data.
  3752. * @param[in] blockSize number of samples to process.
  3753. * @return none.
  3754. */
  3755. void arm_lms_norm_q31(
  3756. arm_lms_norm_instance_q31 * S,
  3757. q31_t * pSrc,
  3758. q31_t * pRef,
  3759. q31_t * pOut,
  3760. q31_t * pErr,
  3761. uint32_t blockSize);
  3762. /**
  3763. * @brief Initialization function for Q31 normalized LMS filter.
  3764. * @param[in] *S points to an instance of the Q31 normalized LMS filter structure.
  3765. * @param[in] numTaps number of filter coefficients.
  3766. * @param[in] *pCoeffs points to coefficient buffer.
  3767. * @param[in] *pState points to state buffer.
  3768. * @param[in] mu step size that controls filter coefficient updates.
  3769. * @param[in] blockSize number of samples to process.
  3770. * @param[in] postShift bit shift applied to coefficients.
  3771. * @return none.
  3772. */
  3773. void arm_lms_norm_init_q31(
  3774. arm_lms_norm_instance_q31 * S,
  3775. uint16_t numTaps,
  3776. q31_t * pCoeffs,
  3777. q31_t * pState,
  3778. q31_t mu,
  3779. uint32_t blockSize,
  3780. uint8_t postShift);
  3781. /**
  3782. * @brief Instance structure for the Q15 normalized LMS filter.
  3783. */
  3784. typedef struct
  3785. {
  3786. uint16_t numTaps; /**< Number of coefficients in the filter. */
  3787. q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  3788. q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
  3789. q15_t mu; /**< step size that controls filter coefficient updates. */
  3790. uint8_t postShift; /**< bit shift applied to coefficients. */
  3791. q15_t *recipTable; /**< Points to the reciprocal initial value table. */
  3792. q15_t energy; /**< saves previous frame energy. */
  3793. q15_t x0; /**< saves previous input sample. */
  3794. } arm_lms_norm_instance_q15;
  3795. /**
  3796. * @brief Processing function for Q15 normalized LMS filter.
  3797. * @param[in] *S points to an instance of the Q15 normalized LMS filter structure.
  3798. * @param[in] *pSrc points to the block of input data.
  3799. * @param[in] *pRef points to the block of reference data.
  3800. * @param[out] *pOut points to the block of output data.
  3801. * @param[out] *pErr points to the block of error data.
  3802. * @param[in] blockSize number of samples to process.
  3803. * @return none.
  3804. */
  3805. void arm_lms_norm_q15(
  3806. arm_lms_norm_instance_q15 * S,
  3807. q15_t * pSrc,
  3808. q15_t * pRef,
  3809. q15_t * pOut,
  3810. q15_t * pErr,
  3811. uint32_t blockSize);
  3812. /**
  3813. * @brief Initialization function for Q15 normalized LMS filter.
  3814. * @param[in] *S points to an instance of the Q15 normalized LMS filter structure.
  3815. * @param[in] numTaps number of filter coefficients.
  3816. * @param[in] *pCoeffs points to coefficient buffer.
  3817. * @param[in] *pState points to state buffer.
  3818. * @param[in] mu step size that controls filter coefficient updates.
  3819. * @param[in] blockSize number of samples to process.
  3820. * @param[in] postShift bit shift applied to coefficients.
  3821. * @return none.
  3822. */
  3823. void arm_lms_norm_init_q15(
  3824. arm_lms_norm_instance_q15 * S,
  3825. uint16_t numTaps,
  3826. q15_t * pCoeffs,
  3827. q15_t * pState,
  3828. q15_t mu,
  3829. uint32_t blockSize,
  3830. uint8_t postShift);
  3831. /**
  3832. * @brief Correlation of floating-point sequences.
  3833. * @param[in] *pSrcA points to the first input sequence.
  3834. * @param[in] srcALen length of the first input sequence.
  3835. * @param[in] *pSrcB points to the second input sequence.
  3836. * @param[in] srcBLen length of the second input sequence.
  3837. * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
  3838. * @return none.
  3839. */
  3840. void arm_correlate_f32(
  3841. float32_t * pSrcA,
  3842. uint32_t srcALen,
  3843. float32_t * pSrcB,
  3844. uint32_t srcBLen,
  3845. float32_t * pDst);
  3846. /**
  3847. * @brief Correlation of Q15 sequences
  3848. * @param[in] *pSrcA points to the first input sequence.
  3849. * @param[in] srcALen length of the first input sequence.
  3850. * @param[in] *pSrcB points to the second input sequence.
  3851. * @param[in] srcBLen length of the second input sequence.
  3852. * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
  3853. * @param[in] *pScratch points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  3854. * @return none.
  3855. */
  3856. void arm_correlate_opt_q15(
  3857. q15_t * pSrcA,
  3858. uint32_t srcALen,
  3859. q15_t * pSrcB,
  3860. uint32_t srcBLen,
  3861. q15_t * pDst,
  3862. q15_t * pScratch);
  3863. /**
  3864. * @brief Correlation of Q15 sequences.
  3865. * @param[in] *pSrcA points to the first input sequence.
  3866. * @param[in] srcALen length of the first input sequence.
  3867. * @param[in] *pSrcB points to the second input sequence.
  3868. * @param[in] srcBLen length of the second input sequence.
  3869. * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
  3870. * @return none.
  3871. */
  3872. void arm_correlate_q15(
  3873. q15_t * pSrcA,
  3874. uint32_t srcALen,
  3875. q15_t * pSrcB,
  3876. uint32_t srcBLen,
  3877. q15_t * pDst);
  3878. /**
  3879. * @brief Correlation of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4.
  3880. * @param[in] *pSrcA points to the first input sequence.
  3881. * @param[in] srcALen length of the first input sequence.
  3882. * @param[in] *pSrcB points to the second input sequence.
  3883. * @param[in] srcBLen length of the second input sequence.
  3884. * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
  3885. * @return none.
  3886. */
  3887. void arm_correlate_fast_q15(
  3888. q15_t * pSrcA,
  3889. uint32_t srcALen,
  3890. q15_t * pSrcB,
  3891. uint32_t srcBLen,
  3892. q15_t * pDst);
  3893. /**
  3894. * @brief Correlation of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4.
  3895. * @param[in] *pSrcA points to the first input sequence.
  3896. * @param[in] srcALen length of the first input sequence.
  3897. * @param[in] *pSrcB points to the second input sequence.
  3898. * @param[in] srcBLen length of the second input sequence.
  3899. * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
  3900. * @param[in] *pScratch points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  3901. * @return none.
  3902. */
  3903. void arm_correlate_fast_opt_q15(
  3904. q15_t * pSrcA,
  3905. uint32_t srcALen,
  3906. q15_t * pSrcB,
  3907. uint32_t srcBLen,
  3908. q15_t * pDst,
  3909. q15_t * pScratch);
  3910. /**
  3911. * @brief Correlation of Q31 sequences.
  3912. * @param[in] *pSrcA points to the first input sequence.
  3913. * @param[in] srcALen length of the first input sequence.
  3914. * @param[in] *pSrcB points to the second input sequence.
  3915. * @param[in] srcBLen length of the second input sequence.
  3916. * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
  3917. * @return none.
  3918. */
  3919. void arm_correlate_q31(
  3920. q31_t * pSrcA,
  3921. uint32_t srcALen,
  3922. q31_t * pSrcB,
  3923. uint32_t srcBLen,
  3924. q31_t * pDst);
  3925. /**
  3926. * @brief Correlation of Q31 sequences (fast version) for Cortex-M3 and Cortex-M4
  3927. * @param[in] *pSrcA points to the first input sequence.
  3928. * @param[in] srcALen length of the first input sequence.
  3929. * @param[in] *pSrcB points to the second input sequence.
  3930. * @param[in] srcBLen length of the second input sequence.
  3931. * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
  3932. * @return none.
  3933. */
  3934. void arm_correlate_fast_q31(
  3935. q31_t * pSrcA,
  3936. uint32_t srcALen,
  3937. q31_t * pSrcB,
  3938. uint32_t srcBLen,
  3939. q31_t * pDst);
  3940. /**
  3941. * @brief Correlation of Q7 sequences.
  3942. * @param[in] *pSrcA points to the first input sequence.
  3943. * @param[in] srcALen length of the first input sequence.
  3944. * @param[in] *pSrcB points to the second input sequence.
  3945. * @param[in] srcBLen length of the second input sequence.
  3946. * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
  3947. * @param[in] *pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  3948. * @param[in] *pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen).
  3949. * @return none.
  3950. */
  3951. void arm_correlate_opt_q7(
  3952. q7_t * pSrcA,
  3953. uint32_t srcALen,
  3954. q7_t * pSrcB,
  3955. uint32_t srcBLen,
  3956. q7_t * pDst,
  3957. q15_t * pScratch1,
  3958. q15_t * pScratch2);
  3959. /**
  3960. * @brief Correlation of Q7 sequences.
  3961. * @param[in] *pSrcA points to the first input sequence.
  3962. * @param[in] srcALen length of the first input sequence.
  3963. * @param[in] *pSrcB points to the second input sequence.
  3964. * @param[in] srcBLen length of the second input sequence.
  3965. * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
  3966. * @return none.
  3967. */
  3968. void arm_correlate_q7(
  3969. q7_t * pSrcA,
  3970. uint32_t srcALen,
  3971. q7_t * pSrcB,
  3972. uint32_t srcBLen,
  3973. q7_t * pDst);
  3974. /**
  3975. * @brief Instance structure for the floating-point sparse FIR filter.
  3976. */
  3977. typedef struct
  3978. {
  3979. uint16_t numTaps; /**< number of coefficients in the filter. */
  3980. uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */
  3981. float32_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */
  3982. float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
  3983. uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */
  3984. int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */
  3985. } arm_fir_sparse_instance_f32;
  3986. /**
  3987. * @brief Instance structure for the Q31 sparse FIR filter.
  3988. */
  3989. typedef struct
  3990. {
  3991. uint16_t numTaps; /**< number of coefficients in the filter. */
  3992. uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */
  3993. q31_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */
  3994. q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
  3995. uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */
  3996. int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */
  3997. } arm_fir_sparse_instance_q31;
  3998. /**
  3999. * @brief Instance structure for the Q15 sparse FIR filter.
  4000. */
  4001. typedef struct
  4002. {
  4003. uint16_t numTaps; /**< number of coefficients in the filter. */
  4004. uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */
  4005. q15_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */
  4006. q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
  4007. uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */
  4008. int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */
  4009. } arm_fir_sparse_instance_q15;
  4010. /**
  4011. * @brief Instance structure for the Q7 sparse FIR filter.
  4012. */
  4013. typedef struct
  4014. {
  4015. uint16_t numTaps; /**< number of coefficients in the filter. */
  4016. uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */
  4017. q7_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */
  4018. q7_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
  4019. uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */
  4020. int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */
  4021. } arm_fir_sparse_instance_q7;
  4022. /**
  4023. * @brief Processing function for the floating-point sparse FIR filter.
  4024. * @param[in] *S points to an instance of the floating-point sparse FIR structure.
  4025. * @param[in] *pSrc points to the block of input data.
  4026. * @param[out] *pDst points to the block of output data
  4027. * @param[in] *pScratchIn points to a temporary buffer of size blockSize.
  4028. * @param[in] blockSize number of input samples to process per call.
  4029. * @return none.
  4030. */
  4031. void arm_fir_sparse_f32(
  4032. arm_fir_sparse_instance_f32 * S,
  4033. float32_t * pSrc,
  4034. float32_t * pDst,
  4035. float32_t * pScratchIn,
  4036. uint32_t blockSize);
  4037. /**
  4038. * @brief Initialization function for the floating-point sparse FIR filter.
  4039. * @param[in,out] *S points to an instance of the floating-point sparse FIR structure.
  4040. * @param[in] numTaps number of nonzero coefficients in the filter.
  4041. * @param[in] *pCoeffs points to the array of filter coefficients.
  4042. * @param[in] *pState points to the state buffer.
  4043. * @param[in] *pTapDelay points to the array of offset times.
  4044. * @param[in] maxDelay maximum offset time supported.
  4045. * @param[in] blockSize number of samples that will be processed per block.
  4046. * @return none
  4047. */
  4048. void arm_fir_sparse_init_f32(
  4049. arm_fir_sparse_instance_f32 * S,
  4050. uint16_t numTaps,
  4051. float32_t * pCoeffs,
  4052. float32_t * pState,
  4053. int32_t * pTapDelay,
  4054. uint16_t maxDelay,
  4055. uint32_t blockSize);
  4056. /**
  4057. * @brief Processing function for the Q31 sparse FIR filter.
  4058. * @param[in] *S points to an instance of the Q31 sparse FIR structure.
  4059. * @param[in] *pSrc points to the block of input data.
  4060. * @param[out] *pDst points to the block of output data
  4061. * @param[in] *pScratchIn points to a temporary buffer of size blockSize.
  4062. * @param[in] blockSize number of input samples to process per call.
  4063. * @return none.
  4064. */
  4065. void arm_fir_sparse_q31(
  4066. arm_fir_sparse_instance_q31 * S,
  4067. q31_t * pSrc,
  4068. q31_t * pDst,
  4069. q31_t * pScratchIn,
  4070. uint32_t blockSize);
  4071. /**
  4072. * @brief Initialization function for the Q31 sparse FIR filter.
  4073. * @param[in,out] *S points to an instance of the Q31 sparse FIR structure.
  4074. * @param[in] numTaps number of nonzero coefficients in the filter.
  4075. * @param[in] *pCoeffs points to the array of filter coefficients.
  4076. * @param[in] *pState points to the state buffer.
  4077. * @param[in] *pTapDelay points to the array of offset times.
  4078. * @param[in] maxDelay maximum offset time supported.
  4079. * @param[in] blockSize number of samples that will be processed per block.
  4080. * @return none
  4081. */
  4082. void arm_fir_sparse_init_q31(
  4083. arm_fir_sparse_instance_q31 * S,
  4084. uint16_t numTaps,
  4085. q31_t * pCoeffs,
  4086. q31_t * pState,
  4087. int32_t * pTapDelay,
  4088. uint16_t maxDelay,
  4089. uint32_t blockSize);
  4090. /**
  4091. * @brief Processing function for the Q15 sparse FIR filter.
  4092. * @param[in] *S points to an instance of the Q15 sparse FIR structure.
  4093. * @param[in] *pSrc points to the block of input data.
  4094. * @param[out] *pDst points to the block of output data
  4095. * @param[in] *pScratchIn points to a temporary buffer of size blockSize.
  4096. * @param[in] *pScratchOut points to a temporary buffer of size blockSize.
  4097. * @param[in] blockSize number of input samples to process per call.
  4098. * @return none.
  4099. */
  4100. void arm_fir_sparse_q15(
  4101. arm_fir_sparse_instance_q15 * S,
  4102. q15_t * pSrc,
  4103. q15_t * pDst,
  4104. q15_t * pScratchIn,
  4105. q31_t * pScratchOut,
  4106. uint32_t blockSize);
  4107. /**
  4108. * @brief Initialization function for the Q15 sparse FIR filter.
  4109. * @param[in,out] *S points to an instance of the Q15 sparse FIR structure.
  4110. * @param[in] numTaps number of nonzero coefficients in the filter.
  4111. * @param[in] *pCoeffs points to the array of filter coefficients.
  4112. * @param[in] *pState points to the state buffer.
  4113. * @param[in] *pTapDelay points to the array of offset times.
  4114. * @param[in] maxDelay maximum offset time supported.
  4115. * @param[in] blockSize number of samples that will be processed per block.
  4116. * @return none
  4117. */
  4118. void arm_fir_sparse_init_q15(
  4119. arm_fir_sparse_instance_q15 * S,
  4120. uint16_t numTaps,
  4121. q15_t * pCoeffs,
  4122. q15_t * pState,
  4123. int32_t * pTapDelay,
  4124. uint16_t maxDelay,
  4125. uint32_t blockSize);
  4126. /**
  4127. * @brief Processing function for the Q7 sparse FIR filter.
  4128. * @param[in] *S points to an instance of the Q7 sparse FIR structure.
  4129. * @param[in] *pSrc points to the block of input data.
  4130. * @param[out] *pDst points to the block of output data
  4131. * @param[in] *pScratchIn points to a temporary buffer of size blockSize.
  4132. * @param[in] *pScratchOut points to a temporary buffer of size blockSize.
  4133. * @param[in] blockSize number of input samples to process per call.
  4134. * @return none.
  4135. */
  4136. void arm_fir_sparse_q7(
  4137. arm_fir_sparse_instance_q7 * S,
  4138. q7_t * pSrc,
  4139. q7_t * pDst,
  4140. q7_t * pScratchIn,
  4141. q31_t * pScratchOut,
  4142. uint32_t blockSize);
  4143. /**
  4144. * @brief Initialization function for the Q7 sparse FIR filter.
  4145. * @param[in,out] *S points to an instance of the Q7 sparse FIR structure.
  4146. * @param[in] numTaps number of nonzero coefficients in the filter.
  4147. * @param[in] *pCoeffs points to the array of filter coefficients.
  4148. * @param[in] *pState points to the state buffer.
  4149. * @param[in] *pTapDelay points to the array of offset times.
  4150. * @param[in] maxDelay maximum offset time supported.
  4151. * @param[in] blockSize number of samples that will be processed per block.
  4152. * @return none
  4153. */
  4154. void arm_fir_sparse_init_q7(
  4155. arm_fir_sparse_instance_q7 * S,
  4156. uint16_t numTaps,
  4157. q7_t * pCoeffs,
  4158. q7_t * pState,
  4159. int32_t * pTapDelay,
  4160. uint16_t maxDelay,
  4161. uint32_t blockSize);
  4162. /*
  4163. * @brief Floating-point sin_cos function.
  4164. * @param[in] theta input value in degrees
  4165. * @param[out] *pSinVal points to the processed sine output.
  4166. * @param[out] *pCosVal points to the processed cos output.
  4167. * @return none.
  4168. */
  4169. void arm_sin_cos_f32(
  4170. float32_t theta,
  4171. float32_t * pSinVal,
  4172. float32_t * pCcosVal);
  4173. /*
  4174. * @brief Q31 sin_cos function.
  4175. * @param[in] theta scaled input value in degrees
  4176. * @param[out] *pSinVal points to the processed sine output.
  4177. * @param[out] *pCosVal points to the processed cosine output.
  4178. * @return none.
  4179. */
  4180. void arm_sin_cos_q31(
  4181. q31_t theta,
  4182. q31_t * pSinVal,
  4183. q31_t * pCosVal);
  4184. /**
  4185. * @brief Floating-point complex conjugate.
  4186. * @param[in] *pSrc points to the input vector
  4187. * @param[out] *pDst points to the output vector
  4188. * @param[in] numSamples number of complex samples in each vector
  4189. * @return none.
  4190. */
  4191. void arm_cmplx_conj_f32(
  4192. float32_t * pSrc,
  4193. float32_t * pDst,
  4194. uint32_t numSamples);
  4195. /**
  4196. * @brief Q31 complex conjugate.
  4197. * @param[in] *pSrc points to the input vector
  4198. * @param[out] *pDst points to the output vector
  4199. * @param[in] numSamples number of complex samples in each vector
  4200. * @return none.
  4201. */
  4202. void arm_cmplx_conj_q31(
  4203. q31_t * pSrc,
  4204. q31_t * pDst,
  4205. uint32_t numSamples);
  4206. /**
  4207. * @brief Q15 complex conjugate.
  4208. * @param[in] *pSrc points to the input vector
  4209. * @param[out] *pDst points to the output vector
  4210. * @param[in] numSamples number of complex samples in each vector
  4211. * @return none.
  4212. */
  4213. void arm_cmplx_conj_q15(
  4214. q15_t * pSrc,
  4215. q15_t * pDst,
  4216. uint32_t numSamples);
  4217. /**
  4218. * @brief Floating-point complex magnitude squared
  4219. * @param[in] *pSrc points to the complex input vector
  4220. * @param[out] *pDst points to the real output vector
  4221. * @param[in] numSamples number of complex samples in the input vector
  4222. * @return none.
  4223. */
  4224. void arm_cmplx_mag_squared_f32(
  4225. float32_t * pSrc,
  4226. float32_t * pDst,
  4227. uint32_t numSamples);
  4228. /**
  4229. * @brief Q31 complex magnitude squared
  4230. * @param[in] *pSrc points to the complex input vector
  4231. * @param[out] *pDst points to the real output vector
  4232. * @param[in] numSamples number of complex samples in the input vector
  4233. * @return none.
  4234. */
  4235. void arm_cmplx_mag_squared_q31(
  4236. q31_t * pSrc,
  4237. q31_t * pDst,
  4238. uint32_t numSamples);
  4239. /**
  4240. * @brief Q15 complex magnitude squared
  4241. * @param[in] *pSrc points to the complex input vector
  4242. * @param[out] *pDst points to the real output vector
  4243. * @param[in] numSamples number of complex samples in the input vector
  4244. * @return none.
  4245. */
  4246. void arm_cmplx_mag_squared_q15(
  4247. q15_t * pSrc,
  4248. q15_t * pDst,
  4249. uint32_t numSamples);
  4250. /**
  4251. * @ingroup groupController
  4252. */
  4253. /**
  4254. * @defgroup PID PID Motor Control
  4255. *
  4256. * A Proportional Integral Derivative (PID) controller is a generic feedback control
  4257. * loop mechanism widely used in industrial control systems.
  4258. * A PID controller is the most commonly used type of feedback controller.
  4259. *
  4260. * This set of functions implements (PID) controllers
  4261. * for Q15, Q31, and floating-point data types. The functions operate on a single sample
  4262. * of data and each call to the function returns a single processed value.
  4263. * <code>S</code> points to an instance of the PID control data structure. <code>in</code>
  4264. * is the input sample value. The functions return the output value.
  4265. *
  4266. * \par Algorithm:
  4267. * <pre>
  4268. * y[n] = y[n-1] + A0 * x[n] + A1 * x[n-1] + A2 * x[n-2]
  4269. * A0 = Kp + Ki + Kd
  4270. * A1 = (-Kp ) - (2 * Kd )
  4271. * A2 = Kd </pre>
  4272. *
  4273. * \par
  4274. * where \c Kp is proportional constant, \c Ki is Integral constant and \c Kd is Derivative constant
  4275. *
  4276. * \par
  4277. * \image html PID.gif "Proportional Integral Derivative Controller"
  4278. *
  4279. * \par
  4280. * The PID controller calculates an "error" value as the difference between
  4281. * the measured output and the reference input.
  4282. * The controller attempts to minimize the error by adjusting the process control inputs.
  4283. * The proportional value determines the reaction to the current error,
  4284. * the integral value determines the reaction based on the sum of recent errors,
  4285. * and the derivative value determines the reaction based on the rate at which the error has been changing.
  4286. *
  4287. * \par Instance Structure
  4288. * The Gains A0, A1, A2 and state variables for a PID controller are stored together in an instance data structure.
  4289. * A separate instance structure must be defined for each PID Controller.
  4290. * There are separate instance structure declarations for each of the 3 supported data types.
  4291. *
  4292. * \par Reset Functions
  4293. * There is also an associated reset function for each data type which clears the state array.
  4294. *
  4295. * \par Initialization Functions
  4296. * There is also an associated initialization function for each data type.
  4297. * The initialization function performs the following operations:
  4298. * - Initializes the Gains A0, A1, A2 from Kp,Ki, Kd gains.
  4299. * - Zeros out the values in the state buffer.
  4300. *
  4301. * \par
  4302. * Instance structure cannot be placed into a const data section and it is recommended to use the initialization function.
  4303. *
  4304. * \par Fixed-Point Behavior
  4305. * Care must be taken when using the fixed-point versions of the PID Controller functions.
  4306. * In particular, the overflow and saturation behavior of the accumulator used in each function must be considered.
  4307. * Refer to the function specific documentation below for usage guidelines.
  4308. */
  4309. /**
  4310. * @addtogroup PID
  4311. * @{
  4312. */
  4313. /**
  4314. * @brief Process function for the floating-point PID Control.
  4315. * @param[in,out] *S is an instance of the floating-point PID Control structure
  4316. * @param[in] in input sample to process
  4317. * @return out processed output sample.
  4318. */
  4319. static __INLINE float32_t arm_pid_f32(
  4320. arm_pid_instance_f32 * S,
  4321. float32_t in)
  4322. {
  4323. float32_t out;
  4324. /* y[n] = y[n-1] + A0 * x[n] + A1 * x[n-1] + A2 * x[n-2] */
  4325. out = (S->A0 * in) +
  4326. (S->A1 * S->state[0]) + (S->A2 * S->state[1]) + (S->state[2]);
  4327. /* Update state */
  4328. S->state[1] = S->state[0];
  4329. S->state[0] = in;
  4330. S->state[2] = out;
  4331. /* return to application */
  4332. return (out);
  4333. }
  4334. /**
  4335. * @brief Process function for the Q31 PID Control.
  4336. * @param[in,out] *S points to an instance of the Q31 PID Control structure
  4337. * @param[in] in input sample to process
  4338. * @return out processed output sample.
  4339. *
  4340. * <b>Scaling and Overflow Behavior:</b>
  4341. * \par
  4342. * The function is implemented using an internal 64-bit accumulator.
  4343. * The accumulator has a 2.62 format and maintains full precision of the intermediate multiplication results but provides only a single guard bit.
  4344. * Thus, if the accumulator result overflows it wraps around rather than clip.
  4345. * In order to avoid overflows completely the input signal must be scaled down by 2 bits as there are four additions.
  4346. * After all multiply-accumulates are performed, the 2.62 accumulator is truncated to 1.32 format and then saturated to 1.31 format.
  4347. */
  4348. static __INLINE q31_t arm_pid_q31(
  4349. arm_pid_instance_q31 * S,
  4350. q31_t in)
  4351. {
  4352. q63_t acc;
  4353. q31_t out;
  4354. /* acc = A0 * x[n] */
  4355. acc = (q63_t) S->A0 * in;
  4356. /* acc += A1 * x[n-1] */
  4357. acc += (q63_t) S->A1 * S->state[0];
  4358. /* acc += A2 * x[n-2] */
  4359. acc += (q63_t) S->A2 * S->state[1];
  4360. /* convert output to 1.31 format to add y[n-1] */
  4361. out = (q31_t) (acc >> 31u);
  4362. /* out += y[n-1] */
  4363. out += S->state[2];
  4364. /* Update state */
  4365. S->state[1] = S->state[0];
  4366. S->state[0] = in;
  4367. S->state[2] = out;
  4368. /* return to application */
  4369. return (out);
  4370. }
  4371. /**
  4372. * @brief Process function for the Q15 PID Control.
  4373. * @param[in,out] *S points to an instance of the Q15 PID Control structure
  4374. * @param[in] in input sample to process
  4375. * @return out processed output sample.
  4376. *
  4377. * <b>Scaling and Overflow Behavior:</b>
  4378. * \par
  4379. * The function is implemented using a 64-bit internal accumulator.
  4380. * Both Gains and state variables are represented in 1.15 format and multiplications yield a 2.30 result.
  4381. * The 2.30 intermediate results are accumulated in a 64-bit accumulator in 34.30 format.
  4382. * There is no risk of internal overflow with this approach and the full precision of intermediate multiplications is preserved.
  4383. * After all additions have been performed, the accumulator is truncated to 34.15 format by discarding low 15 bits.
  4384. * Lastly, the accumulator is saturated to yield a result in 1.15 format.
  4385. */
  4386. static __INLINE q15_t arm_pid_q15(
  4387. arm_pid_instance_q15 * S,
  4388. q15_t in)
  4389. {
  4390. q63_t acc;
  4391. q15_t out;
  4392. #ifndef ARM_MATH_CM0_FAMILY
  4393. __SIMD32_TYPE *vstate;
  4394. /* Implementation of PID controller */
  4395. /* acc = A0 * x[n] */
  4396. acc = (q31_t) __SMUAD(S->A0, in);
  4397. /* acc += A1 * x[n-1] + A2 * x[n-2] */
  4398. vstate = __SIMD32_CONST(S->state);
  4399. acc = __SMLALD(S->A1, (q31_t) *vstate, acc);
  4400. #else
  4401. /* acc = A0 * x[n] */
  4402. acc = ((q31_t) S->A0) * in;
  4403. /* acc += A1 * x[n-1] + A2 * x[n-2] */
  4404. acc += (q31_t) S->A1 * S->state[0];
  4405. acc += (q31_t) S->A2 * S->state[1];
  4406. #endif
  4407. /* acc += y[n-1] */
  4408. acc += (q31_t) S->state[2] << 15;
  4409. /* saturate the output */
  4410. out = (q15_t) (__SSAT((acc >> 15), 16));
  4411. /* Update state */
  4412. S->state[1] = S->state[0];
  4413. S->state[0] = in;
  4414. S->state[2] = out;
  4415. /* return to application */
  4416. return (out);
  4417. }
  4418. /**
  4419. * @} end of PID group
  4420. */
  4421. /**
  4422. * @brief Floating-point matrix inverse.
  4423. * @param[in] *src points to the instance of the input floating-point matrix structure.
  4424. * @param[out] *dst points to the instance of the output floating-point matrix structure.
  4425. * @return The function returns ARM_MATH_SIZE_MISMATCH, if the dimensions do not match.
  4426. * If the input matrix is singular (does not have an inverse), then the algorithm terminates and returns error status ARM_MATH_SINGULAR.
  4427. */
  4428. arm_status arm_mat_inverse_f32(
  4429. const arm_matrix_instance_f32 * src,
  4430. arm_matrix_instance_f32 * dst);
  4431. /**
  4432. * @brief Floating-point matrix inverse.
  4433. * @param[in] *src points to the instance of the input floating-point matrix structure.
  4434. * @param[out] *dst points to the instance of the output floating-point matrix structure.
  4435. * @return The function returns ARM_MATH_SIZE_MISMATCH, if the dimensions do not match.
  4436. * If the input matrix is singular (does not have an inverse), then the algorithm terminates and returns error status ARM_MATH_SINGULAR.
  4437. */
  4438. arm_status arm_mat_inverse_f64(
  4439. const arm_matrix_instance_f64 * src,
  4440. arm_matrix_instance_f64 * dst);
  4441. /**
  4442. * @ingroup groupController
  4443. */
  4444. /**
  4445. * @defgroup clarke Vector Clarke Transform
  4446. * Forward Clarke transform converts the instantaneous stator phases into a two-coordinate time invariant vector.
  4447. * Generally the Clarke transform uses three-phase currents <code>Ia, Ib and Ic</code> to calculate currents
  4448. * in the two-phase orthogonal stator axis <code>Ialpha</code> and <code>Ibeta</code>.
  4449. * When <code>Ialpha</code> is superposed with <code>Ia</code> as shown in the figure below
  4450. * \image html clarke.gif Stator current space vector and its components in (a,b).
  4451. * and <code>Ia + Ib + Ic = 0</code>, in this condition <code>Ialpha</code> and <code>Ibeta</code>
  4452. * can be calculated using only <code>Ia</code> and <code>Ib</code>.
  4453. *
  4454. * The function operates on a single sample of data and each call to the function returns the processed output.
  4455. * The library provides separate functions for Q31 and floating-point data types.
  4456. * \par Algorithm
  4457. * \image html clarkeFormula.gif
  4458. * where <code>Ia</code> and <code>Ib</code> are the instantaneous stator phases and
  4459. * <code>pIalpha</code> and <code>pIbeta</code> are the two coordinates of time invariant vector.
  4460. * \par Fixed-Point Behavior
  4461. * Care must be taken when using the Q31 version of the Clarke transform.
  4462. * In particular, the overflow and saturation behavior of the accumulator used must be considered.
  4463. * Refer to the function specific documentation below for usage guidelines.
  4464. */
  4465. /**
  4466. * @addtogroup clarke
  4467. * @{
  4468. */
  4469. /**
  4470. *
  4471. * @brief Floating-point Clarke transform
  4472. * @param[in] Ia input three-phase coordinate <code>a</code>
  4473. * @param[in] Ib input three-phase coordinate <code>b</code>
  4474. * @param[out] *pIalpha points to output two-phase orthogonal vector axis alpha
  4475. * @param[out] *pIbeta points to output two-phase orthogonal vector axis beta
  4476. * @return none.
  4477. */
  4478. static __INLINE void arm_clarke_f32(
  4479. float32_t Ia,
  4480. float32_t Ib,
  4481. float32_t * pIalpha,
  4482. float32_t * pIbeta)
  4483. {
  4484. /* Calculate pIalpha using the equation, pIalpha = Ia */
  4485. *pIalpha = Ia;
  4486. /* Calculate pIbeta using the equation, pIbeta = (1/sqrt(3)) * Ia + (2/sqrt(3)) * Ib */
  4487. *pIbeta =
  4488. ((float32_t) 0.57735026919 * Ia + (float32_t) 1.15470053838 * Ib);
  4489. }
  4490. /**
  4491. * @brief Clarke transform for Q31 version
  4492. * @param[in] Ia input three-phase coordinate <code>a</code>
  4493. * @param[in] Ib input three-phase coordinate <code>b</code>
  4494. * @param[out] *pIalpha points to output two-phase orthogonal vector axis alpha
  4495. * @param[out] *pIbeta points to output two-phase orthogonal vector axis beta
  4496. * @return none.
  4497. *
  4498. * <b>Scaling and Overflow Behavior:</b>
  4499. * \par
  4500. * The function is implemented using an internal 32-bit accumulator.
  4501. * The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format.
  4502. * There is saturation on the addition, hence there is no risk of overflow.
  4503. */
  4504. static __INLINE void arm_clarke_q31(
  4505. q31_t Ia,
  4506. q31_t Ib,
  4507. q31_t * pIalpha,
  4508. q31_t * pIbeta)
  4509. {
  4510. q31_t product1, product2; /* Temporary variables used to store intermediate results */
  4511. /* Calculating pIalpha from Ia by equation pIalpha = Ia */
  4512. *pIalpha = Ia;
  4513. /* Intermediate product is calculated by (1/(sqrt(3)) * Ia) */
  4514. product1 = (q31_t) (((q63_t) Ia * 0x24F34E8B) >> 30);
  4515. /* Intermediate product is calculated by (2/sqrt(3) * Ib) */
  4516. product2 = (q31_t) (((q63_t) Ib * 0x49E69D16) >> 30);
  4517. /* pIbeta is calculated by adding the intermediate products */
  4518. *pIbeta = __QADD(product1, product2);
  4519. }
  4520. /**
  4521. * @} end of clarke group
  4522. */
  4523. /**
  4524. * @brief Converts the elements of the Q7 vector to Q31 vector.
  4525. * @param[in] *pSrc input pointer
  4526. * @param[out] *pDst output pointer
  4527. * @param[in] blockSize number of samples to process
  4528. * @return none.
  4529. */
  4530. void arm_q7_to_q31(
  4531. q7_t * pSrc,
  4532. q31_t * pDst,
  4533. uint32_t blockSize);
  4534. /**
  4535. * @ingroup groupController
  4536. */
  4537. /**
  4538. * @defgroup inv_clarke Vector Inverse Clarke Transform
  4539. * Inverse Clarke transform converts the two-coordinate time invariant vector into instantaneous stator phases.
  4540. *
  4541. * The function operates on a single sample of data and each call to the function returns the processed output.
  4542. * The library provides separate functions for Q31 and floating-point data types.
  4543. * \par Algorithm
  4544. * \image html clarkeInvFormula.gif
  4545. * where <code>pIa</code> and <code>pIb</code> are the instantaneous stator phases and
  4546. * <code>Ialpha</code> and <code>Ibeta</code> are the two coordinates of time invariant vector.
  4547. * \par Fixed-Point Behavior
  4548. * Care must be taken when using the Q31 version of the Clarke transform.
  4549. * In particular, the overflow and saturation behavior of the accumulator used must be considered.
  4550. * Refer to the function specific documentation below for usage guidelines.
  4551. */
  4552. /**
  4553. * @addtogroup inv_clarke
  4554. * @{
  4555. */
  4556. /**
  4557. * @brief Floating-point Inverse Clarke transform
  4558. * @param[in] Ialpha input two-phase orthogonal vector axis alpha
  4559. * @param[in] Ibeta input two-phase orthogonal vector axis beta
  4560. * @param[out] *pIa points to output three-phase coordinate <code>a</code>
  4561. * @param[out] *pIb points to output three-phase coordinate <code>b</code>
  4562. * @return none.
  4563. */
  4564. static __INLINE void arm_inv_clarke_f32(
  4565. float32_t Ialpha,
  4566. float32_t Ibeta,
  4567. float32_t * pIa,
  4568. float32_t * pIb)
  4569. {
  4570. /* Calculating pIa from Ialpha by equation pIa = Ialpha */
  4571. *pIa = Ialpha;
  4572. /* Calculating pIb from Ialpha and Ibeta by equation pIb = -(1/2) * Ialpha + (sqrt(3)/2) * Ibeta */
  4573. *pIb = -0.5 * Ialpha + (float32_t) 0.8660254039 *Ibeta;
  4574. }
  4575. /**
  4576. * @brief Inverse Clarke transform for Q31 version
  4577. * @param[in] Ialpha input two-phase orthogonal vector axis alpha
  4578. * @param[in] Ibeta input two-phase orthogonal vector axis beta
  4579. * @param[out] *pIa points to output three-phase coordinate <code>a</code>
  4580. * @param[out] *pIb points to output three-phase coordinate <code>b</code>
  4581. * @return none.
  4582. *
  4583. * <b>Scaling and Overflow Behavior:</b>
  4584. * \par
  4585. * The function is implemented using an internal 32-bit accumulator.
  4586. * The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format.
  4587. * There is saturation on the subtraction, hence there is no risk of overflow.
  4588. */
  4589. static __INLINE void arm_inv_clarke_q31(
  4590. q31_t Ialpha,
  4591. q31_t Ibeta,
  4592. q31_t * pIa,
  4593. q31_t * pIb)
  4594. {
  4595. q31_t product1, product2; /* Temporary variables used to store intermediate results */
  4596. /* Calculating pIa from Ialpha by equation pIa = Ialpha */
  4597. *pIa = Ialpha;
  4598. /* Intermediate product is calculated by (1/(2*sqrt(3)) * Ia) */
  4599. product1 = (q31_t) (((q63_t) (Ialpha) * (0x40000000)) >> 31);
  4600. /* Intermediate product is calculated by (1/sqrt(3) * pIb) */
  4601. product2 = (q31_t) (((q63_t) (Ibeta) * (0x6ED9EBA1)) >> 31);
  4602. /* pIb is calculated by subtracting the products */
  4603. *pIb = __QSUB(product2, product1);
  4604. }
  4605. /**
  4606. * @} end of inv_clarke group
  4607. */
  4608. /**
  4609. * @brief Converts the elements of the Q7 vector to Q15 vector.
  4610. * @param[in] *pSrc input pointer
  4611. * @param[out] *pDst output pointer
  4612. * @param[in] blockSize number of samples to process
  4613. * @return none.
  4614. */
  4615. void arm_q7_to_q15(
  4616. q7_t * pSrc,
  4617. q15_t * pDst,
  4618. uint32_t blockSize);
  4619. /**
  4620. * @ingroup groupController
  4621. */
  4622. /**
  4623. * @defgroup park Vector Park Transform
  4624. *
  4625. * Forward Park transform converts the input two-coordinate vector to flux and torque components.
  4626. * The Park transform can be used to realize the transformation of the <code>Ialpha</code> and the <code>Ibeta</code> currents
  4627. * from the stationary to the moving reference frame and control the spatial relationship between
  4628. * the stator vector current and rotor flux vector.
  4629. * If we consider the d axis aligned with the rotor flux, the diagram below shows the
  4630. * current vector and the relationship from the two reference frames:
  4631. * \image html park.gif "Stator current space vector and its component in (a,b) and in the d,q rotating reference frame"
  4632. *
  4633. * The function operates on a single sample of data and each call to the function returns the processed output.
  4634. * The library provides separate functions for Q31 and floating-point data types.
  4635. * \par Algorithm
  4636. * \image html parkFormula.gif
  4637. * where <code>Ialpha</code> and <code>Ibeta</code> are the stator vector components,
  4638. * <code>pId</code> and <code>pIq</code> are rotor vector components and <code>cosVal</code> and <code>sinVal</code> are the
  4639. * cosine and sine values of theta (rotor flux position).
  4640. * \par Fixed-Point Behavior
  4641. * Care must be taken when using the Q31 version of the Park transform.
  4642. * In particular, the overflow and saturation behavior of the accumulator used must be considered.
  4643. * Refer to the function specific documentation below for usage guidelines.
  4644. */
  4645. /**
  4646. * @addtogroup park
  4647. * @{
  4648. */
  4649. /**
  4650. * @brief Floating-point Park transform
  4651. * @param[in] Ialpha input two-phase vector coordinate alpha
  4652. * @param[in] Ibeta input two-phase vector coordinate beta
  4653. * @param[out] *pId points to output rotor reference frame d
  4654. * @param[out] *pIq points to output rotor reference frame q
  4655. * @param[in] sinVal sine value of rotation angle theta
  4656. * @param[in] cosVal cosine value of rotation angle theta
  4657. * @return none.
  4658. *
  4659. * The function implements the forward Park transform.
  4660. *
  4661. */
  4662. static __INLINE void arm_park_f32(
  4663. float32_t Ialpha,
  4664. float32_t Ibeta,
  4665. float32_t * pId,
  4666. float32_t * pIq,
  4667. float32_t sinVal,
  4668. float32_t cosVal)
  4669. {
  4670. /* Calculate pId using the equation, pId = Ialpha * cosVal + Ibeta * sinVal */
  4671. *pId = Ialpha * cosVal + Ibeta * sinVal;
  4672. /* Calculate pIq using the equation, pIq = - Ialpha * sinVal + Ibeta * cosVal */
  4673. *pIq = -Ialpha * sinVal + Ibeta * cosVal;
  4674. }
  4675. /**
  4676. * @brief Park transform for Q31 version
  4677. * @param[in] Ialpha input two-phase vector coordinate alpha
  4678. * @param[in] Ibeta input two-phase vector coordinate beta
  4679. * @param[out] *pId points to output rotor reference frame d
  4680. * @param[out] *pIq points to output rotor reference frame q
  4681. * @param[in] sinVal sine value of rotation angle theta
  4682. * @param[in] cosVal cosine value of rotation angle theta
  4683. * @return none.
  4684. *
  4685. * <b>Scaling and Overflow Behavior:</b>
  4686. * \par
  4687. * The function is implemented using an internal 32-bit accumulator.
  4688. * The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format.
  4689. * There is saturation on the addition and subtraction, hence there is no risk of overflow.
  4690. */
  4691. static __INLINE void arm_park_q31(
  4692. q31_t Ialpha,
  4693. q31_t Ibeta,
  4694. q31_t * pId,
  4695. q31_t * pIq,
  4696. q31_t sinVal,
  4697. q31_t cosVal)
  4698. {
  4699. q31_t product1, product2; /* Temporary variables used to store intermediate results */
  4700. q31_t product3, product4; /* Temporary variables used to store intermediate results */
  4701. /* Intermediate product is calculated by (Ialpha * cosVal) */
  4702. product1 = (q31_t) (((q63_t) (Ialpha) * (cosVal)) >> 31);
  4703. /* Intermediate product is calculated by (Ibeta * sinVal) */
  4704. product2 = (q31_t) (((q63_t) (Ibeta) * (sinVal)) >> 31);
  4705. /* Intermediate product is calculated by (Ialpha * sinVal) */
  4706. product3 = (q31_t) (((q63_t) (Ialpha) * (sinVal)) >> 31);
  4707. /* Intermediate product is calculated by (Ibeta * cosVal) */
  4708. product4 = (q31_t) (((q63_t) (Ibeta) * (cosVal)) >> 31);
  4709. /* Calculate pId by adding the two intermediate products 1 and 2 */
  4710. *pId = __QADD(product1, product2);
  4711. /* Calculate pIq by subtracting the two intermediate products 3 from 4 */
  4712. *pIq = __QSUB(product4, product3);
  4713. }
  4714. /**
  4715. * @} end of park group
  4716. */
  4717. /**
  4718. * @brief Converts the elements of the Q7 vector to floating-point vector.
  4719. * @param[in] *pSrc is input pointer
  4720. * @param[out] *pDst is output pointer
  4721. * @param[in] blockSize is the number of samples to process
  4722. * @return none.
  4723. */
  4724. void arm_q7_to_float(
  4725. q7_t * pSrc,
  4726. float32_t * pDst,
  4727. uint32_t blockSize);
  4728. /**
  4729. * @ingroup groupController
  4730. */
  4731. /**
  4732. * @defgroup inv_park Vector Inverse Park transform
  4733. * Inverse Park transform converts the input flux and torque components to two-coordinate vector.
  4734. *
  4735. * The function operates on a single sample of data and each call to the function returns the processed output.
  4736. * The library provides separate functions for Q31 and floating-point data types.
  4737. * \par Algorithm
  4738. * \image html parkInvFormula.gif
  4739. * where <code>pIalpha</code> and <code>pIbeta</code> are the stator vector components,
  4740. * <code>Id</code> and <code>Iq</code> are rotor vector components and <code>cosVal</code> and <code>sinVal</code> are the
  4741. * cosine and sine values of theta (rotor flux position).
  4742. * \par Fixed-Point Behavior
  4743. * Care must be taken when using the Q31 version of the Park transform.
  4744. * In particular, the overflow and saturation behavior of the accumulator used must be considered.
  4745. * Refer to the function specific documentation below for usage guidelines.
  4746. */
  4747. /**
  4748. * @addtogroup inv_park
  4749. * @{
  4750. */
  4751. /**
  4752. * @brief Floating-point Inverse Park transform
  4753. * @param[in] Id input coordinate of rotor reference frame d
  4754. * @param[in] Iq input coordinate of rotor reference frame q
  4755. * @param[out] *pIalpha points to output two-phase orthogonal vector axis alpha
  4756. * @param[out] *pIbeta points to output two-phase orthogonal vector axis beta
  4757. * @param[in] sinVal sine value of rotation angle theta
  4758. * @param[in] cosVal cosine value of rotation angle theta
  4759. * @return none.
  4760. */
  4761. static __INLINE void arm_inv_park_f32(
  4762. float32_t Id,
  4763. float32_t Iq,
  4764. float32_t * pIalpha,
  4765. float32_t * pIbeta,
  4766. float32_t sinVal,
  4767. float32_t cosVal)
  4768. {
  4769. /* Calculate pIalpha using the equation, pIalpha = Id * cosVal - Iq * sinVal */
  4770. *pIalpha = Id * cosVal - Iq * sinVal;
  4771. /* Calculate pIbeta using the equation, pIbeta = Id * sinVal + Iq * cosVal */
  4772. *pIbeta = Id * sinVal + Iq * cosVal;
  4773. }
  4774. /**
  4775. * @brief Inverse Park transform for Q31 version
  4776. * @param[in] Id input coordinate of rotor reference frame d
  4777. * @param[in] Iq input coordinate of rotor reference frame q
  4778. * @param[out] *pIalpha points to output two-phase orthogonal vector axis alpha
  4779. * @param[out] *pIbeta points to output two-phase orthogonal vector axis beta
  4780. * @param[in] sinVal sine value of rotation angle theta
  4781. * @param[in] cosVal cosine value of rotation angle theta
  4782. * @return none.
  4783. *
  4784. * <b>Scaling and Overflow Behavior:</b>
  4785. * \par
  4786. * The function is implemented using an internal 32-bit accumulator.
  4787. * The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format.
  4788. * There is saturation on the addition, hence there is no risk of overflow.
  4789. */
  4790. static __INLINE void arm_inv_park_q31(
  4791. q31_t Id,
  4792. q31_t Iq,
  4793. q31_t * pIalpha,
  4794. q31_t * pIbeta,
  4795. q31_t sinVal,
  4796. q31_t cosVal)
  4797. {
  4798. q31_t product1, product2; /* Temporary variables used to store intermediate results */
  4799. q31_t product3, product4; /* Temporary variables used to store intermediate results */
  4800. /* Intermediate product is calculated by (Id * cosVal) */
  4801. product1 = (q31_t) (((q63_t) (Id) * (cosVal)) >> 31);
  4802. /* Intermediate product is calculated by (Iq * sinVal) */
  4803. product2 = (q31_t) (((q63_t) (Iq) * (sinVal)) >> 31);
  4804. /* Intermediate product is calculated by (Id * sinVal) */
  4805. product3 = (q31_t) (((q63_t) (Id) * (sinVal)) >> 31);
  4806. /* Intermediate product is calculated by (Iq * cosVal) */
  4807. product4 = (q31_t) (((q63_t) (Iq) * (cosVal)) >> 31);
  4808. /* Calculate pIalpha by using the two intermediate products 1 and 2 */
  4809. *pIalpha = __QSUB(product1, product2);
  4810. /* Calculate pIbeta by using the two intermediate products 3 and 4 */
  4811. *pIbeta = __QADD(product4, product3);
  4812. }
  4813. /**
  4814. * @} end of Inverse park group
  4815. */
  4816. /**
  4817. * @brief Converts the elements of the Q31 vector to floating-point vector.
  4818. * @param[in] *pSrc is input pointer
  4819. * @param[out] *pDst is output pointer
  4820. * @param[in] blockSize is the number of samples to process
  4821. * @return none.
  4822. */
  4823. void arm_q31_to_float(
  4824. q31_t * pSrc,
  4825. float32_t * pDst,
  4826. uint32_t blockSize);
  4827. /**
  4828. * @ingroup groupInterpolation
  4829. */
  4830. /**
  4831. * @defgroup LinearInterpolate Linear Interpolation
  4832. *
  4833. * Linear interpolation is a method of curve fitting using linear polynomials.
  4834. * Linear interpolation works by effectively drawing a straight line between two neighboring samples and returning the appropriate point along that line
  4835. *
  4836. * \par
  4837. * \image html LinearInterp.gif "Linear interpolation"
  4838. *
  4839. * \par
  4840. * A Linear Interpolate function calculates an output value(y), for the input(x)
  4841. * using linear interpolation of the input values x0, x1( nearest input values) and the output values y0 and y1(nearest output values)
  4842. *
  4843. * \par Algorithm:
  4844. * <pre>
  4845. * y = y0 + (x - x0) * ((y1 - y0)/(x1-x0))
  4846. * where x0, x1 are nearest values of input x
  4847. * y0, y1 are nearest values to output y
  4848. * </pre>
  4849. *
  4850. * \par
  4851. * This set of functions implements Linear interpolation process
  4852. * for Q7, Q15, Q31, and floating-point data types. The functions operate on a single
  4853. * sample of data and each call to the function returns a single processed value.
  4854. * <code>S</code> points to an instance of the Linear Interpolate function data structure.
  4855. * <code>x</code> is the input sample value. The functions returns the output value.
  4856. *
  4857. * \par
  4858. * if x is outside of the table boundary, Linear interpolation returns first value of the table
  4859. * if x is below input range and returns last value of table if x is above range.
  4860. */
  4861. /**
  4862. * @addtogroup LinearInterpolate
  4863. * @{
  4864. */
  4865. /**
  4866. * @brief Process function for the floating-point Linear Interpolation Function.
  4867. * @param[in,out] *S is an instance of the floating-point Linear Interpolation structure
  4868. * @param[in] x input sample to process
  4869. * @return y processed output sample.
  4870. *
  4871. */
  4872. static __INLINE float32_t arm_linear_interp_f32(
  4873. arm_linear_interp_instance_f32 * S,
  4874. float32_t x)
  4875. {
  4876. float32_t y;
  4877. float32_t x0, x1; /* Nearest input values */
  4878. float32_t y0, y1; /* Nearest output values */
  4879. float32_t xSpacing = S->xSpacing; /* spacing between input values */
  4880. int32_t i; /* Index variable */
  4881. float32_t *pYData = S->pYData; /* pointer to output table */
  4882. /* Calculation of index */
  4883. i = (int32_t) ((x - S->x1) / xSpacing);
  4884. if(i < 0)
  4885. {
  4886. /* Iniatilize output for below specified range as least output value of table */
  4887. y = pYData[0];
  4888. }
  4889. else if((uint32_t)i >= S->nValues)
  4890. {
  4891. /* Iniatilize output for above specified range as last output value of table */
  4892. y = pYData[S->nValues - 1];
  4893. }
  4894. else
  4895. {
  4896. /* Calculation of nearest input values */
  4897. x0 = S->x1 + i * xSpacing;
  4898. x1 = S->x1 + (i + 1) * xSpacing;
  4899. /* Read of nearest output values */
  4900. y0 = pYData[i];
  4901. y1 = pYData[i + 1];
  4902. /* Calculation of output */
  4903. y = y0 + (x - x0) * ((y1 - y0) / (x1 - x0));
  4904. }
  4905. /* returns output value */
  4906. return (y);
  4907. }
  4908. /**
  4909. *
  4910. * @brief Process function for the Q31 Linear Interpolation Function.
  4911. * @param[in] *pYData pointer to Q31 Linear Interpolation table
  4912. * @param[in] x input sample to process
  4913. * @param[in] nValues number of table values
  4914. * @return y processed output sample.
  4915. *
  4916. * \par
  4917. * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part.
  4918. * This function can support maximum of table size 2^12.
  4919. *
  4920. */
  4921. static __INLINE q31_t arm_linear_interp_q31(
  4922. q31_t * pYData,
  4923. q31_t x,
  4924. uint32_t nValues)
  4925. {
  4926. q31_t y; /* output */
  4927. q31_t y0, y1; /* Nearest output values */
  4928. q31_t fract; /* fractional part */
  4929. int32_t index; /* Index to read nearest output values */
  4930. /* Input is in 12.20 format */
  4931. /* 12 bits for the table index */
  4932. /* Index value calculation */
  4933. index = ((x & 0xFFF00000) >> 20);
  4934. if(index >= (int32_t)(nValues - 1))
  4935. {
  4936. return (pYData[nValues - 1]);
  4937. }
  4938. else if(index < 0)
  4939. {
  4940. return (pYData[0]);
  4941. }
  4942. else
  4943. {
  4944. /* 20 bits for the fractional part */
  4945. /* shift left by 11 to keep fract in 1.31 format */
  4946. fract = (x & 0x000FFFFF) << 11;
  4947. /* Read two nearest output values from the index in 1.31(q31) format */
  4948. y0 = pYData[index];
  4949. y1 = pYData[index + 1u];
  4950. /* Calculation of y0 * (1-fract) and y is in 2.30 format */
  4951. y = ((q31_t) ((q63_t) y0 * (0x7FFFFFFF - fract) >> 32));
  4952. /* Calculation of y0 * (1-fract) + y1 *fract and y is in 2.30 format */
  4953. y += ((q31_t) (((q63_t) y1 * fract) >> 32));
  4954. /* Convert y to 1.31 format */
  4955. return (y << 1u);
  4956. }
  4957. }
  4958. /**
  4959. *
  4960. * @brief Process function for the Q15 Linear Interpolation Function.
  4961. * @param[in] *pYData pointer to Q15 Linear Interpolation table
  4962. * @param[in] x input sample to process
  4963. * @param[in] nValues number of table values
  4964. * @return y processed output sample.
  4965. *
  4966. * \par
  4967. * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part.
  4968. * This function can support maximum of table size 2^12.
  4969. *
  4970. */
  4971. static __INLINE q15_t arm_linear_interp_q15(
  4972. q15_t * pYData,
  4973. q31_t x,
  4974. uint32_t nValues)
  4975. {
  4976. q63_t y; /* output */
  4977. q15_t y0, y1; /* Nearest output values */
  4978. q31_t fract; /* fractional part */
  4979. int32_t index; /* Index to read nearest output values */
  4980. /* Input is in 12.20 format */
  4981. /* 12 bits for the table index */
  4982. /* Index value calculation */
  4983. index = ((x & 0xFFF00000) >> 20u);
  4984. if(index >= (int32_t)(nValues - 1))
  4985. {
  4986. return (pYData[nValues - 1]);
  4987. }
  4988. else if(index < 0)
  4989. {
  4990. return (pYData[0]);
  4991. }
  4992. else
  4993. {
  4994. /* 20 bits for the fractional part */
  4995. /* fract is in 12.20 format */
  4996. fract = (x & 0x000FFFFF);
  4997. /* Read two nearest output values from the index */
  4998. y0 = pYData[index];
  4999. y1 = pYData[index + 1u];
  5000. /* Calculation of y0 * (1-fract) and y is in 13.35 format */
  5001. y = ((q63_t) y0 * (0xFFFFF - fract));
  5002. /* Calculation of (y0 * (1-fract) + y1 * fract) and y is in 13.35 format */
  5003. y += ((q63_t) y1 * (fract));
  5004. /* convert y to 1.15 format */
  5005. return (y >> 20);
  5006. }
  5007. }
  5008. /**
  5009. *
  5010. * @brief Process function for the Q7 Linear Interpolation Function.
  5011. * @param[in] *pYData pointer to Q7 Linear Interpolation table
  5012. * @param[in] x input sample to process
  5013. * @param[in] nValues number of table values
  5014. * @return y processed output sample.
  5015. *
  5016. * \par
  5017. * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part.
  5018. * This function can support maximum of table size 2^12.
  5019. */
  5020. static __INLINE q7_t arm_linear_interp_q7(
  5021. q7_t * pYData,
  5022. q31_t x,
  5023. uint32_t nValues)
  5024. {
  5025. q31_t y; /* output */
  5026. q7_t y0, y1; /* Nearest output values */
  5027. q31_t fract; /* fractional part */
  5028. uint32_t index; /* Index to read nearest output values */
  5029. /* Input is in 12.20 format */
  5030. /* 12 bits for the table index */
  5031. /* Index value calculation */
  5032. if (x < 0)
  5033. {
  5034. return (pYData[0]);
  5035. }
  5036. index = (x >> 20) & 0xfff;
  5037. if(index >= (nValues - 1))
  5038. {
  5039. return (pYData[nValues - 1]);
  5040. }
  5041. else
  5042. {
  5043. /* 20 bits for the fractional part */
  5044. /* fract is in 12.20 format */
  5045. fract = (x & 0x000FFFFF);
  5046. /* Read two nearest output values from the index and are in 1.7(q7) format */
  5047. y0 = pYData[index];
  5048. y1 = pYData[index + 1u];
  5049. /* Calculation of y0 * (1-fract ) and y is in 13.27(q27) format */
  5050. y = ((y0 * (0xFFFFF - fract)));
  5051. /* Calculation of y1 * fract + y0 * (1-fract) and y is in 13.27(q27) format */
  5052. y += (y1 * fract);
  5053. /* convert y to 1.7(q7) format */
  5054. return (y >> 20u);
  5055. }
  5056. }
  5057. /**
  5058. * @} end of LinearInterpolate group
  5059. */
  5060. /**
  5061. * @brief Fast approximation to the trigonometric sine function for floating-point data.
  5062. * @param[in] x input value in radians.
  5063. * @return sin(x).
  5064. */
  5065. float32_t arm_sin_f32(
  5066. float32_t x);
  5067. /**
  5068. * @brief Fast approximation to the trigonometric sine function for Q31 data.
  5069. * @param[in] x Scaled input value in radians.
  5070. * @return sin(x).
  5071. */
  5072. q31_t arm_sin_q31(
  5073. q31_t x);
  5074. /**
  5075. * @brief Fast approximation to the trigonometric sine function for Q15 data.
  5076. * @param[in] x Scaled input value in radians.
  5077. * @return sin(x).
  5078. */
  5079. q15_t arm_sin_q15(
  5080. q15_t x);
  5081. /**
  5082. * @brief Fast approximation to the trigonometric cosine function for floating-point data.
  5083. * @param[in] x input value in radians.
  5084. * @return cos(x).
  5085. */
  5086. float32_t arm_cos_f32(
  5087. float32_t x);
  5088. /**
  5089. * @brief Fast approximation to the trigonometric cosine function for Q31 data.
  5090. * @param[in] x Scaled input value in radians.
  5091. * @return cos(x).
  5092. */
  5093. q31_t arm_cos_q31(
  5094. q31_t x);
  5095. /**
  5096. * @brief Fast approximation to the trigonometric cosine function for Q15 data.
  5097. * @param[in] x Scaled input value in radians.
  5098. * @return cos(x).
  5099. */
  5100. q15_t arm_cos_q15(
  5101. q15_t x);
  5102. /**
  5103. * @ingroup groupFastMath
  5104. */
  5105. /**
  5106. * @defgroup SQRT Square Root
  5107. *
  5108. * Computes the square root of a number.
  5109. * There are separate functions for Q15, Q31, and floating-point data types.
  5110. * The square root function is computed using the Newton-Raphson algorithm.
  5111. * This is an iterative algorithm of the form:
  5112. * <pre>
  5113. * x1 = x0 - f(x0)/f'(x0)
  5114. * </pre>
  5115. * where <code>x1</code> is the current estimate,
  5116. * <code>x0</code> is the previous estimate, and
  5117. * <code>f'(x0)</code> is the derivative of <code>f()</code> evaluated at <code>x0</code>.
  5118. * For the square root function, the algorithm reduces to:
  5119. * <pre>
  5120. * x0 = in/2 [initial guess]
  5121. * x1 = 1/2 * ( x0 + in / x0) [each iteration]
  5122. * </pre>
  5123. */
  5124. /**
  5125. * @addtogroup SQRT
  5126. * @{
  5127. */
  5128. /**
  5129. * @brief Floating-point square root function.
  5130. * @param[in] in input value.
  5131. * @param[out] *pOut square root of input value.
  5132. * @return The function returns ARM_MATH_SUCCESS if input value is positive value or ARM_MATH_ARGUMENT_ERROR if
  5133. * <code>in</code> is negative value and returns zero output for negative values.
  5134. */
  5135. static __INLINE arm_status arm_sqrt_f32(
  5136. float32_t in,
  5137. float32_t * pOut)
  5138. {
  5139. if(in > 0)
  5140. {
  5141. // #if __FPU_USED
  5142. #if (__FPU_USED == 1) && defined ( __CC_ARM )
  5143. *pOut = __sqrtf(in);
  5144. #else
  5145. *pOut = sqrtf(in);
  5146. #endif
  5147. return (ARM_MATH_SUCCESS);
  5148. }
  5149. else
  5150. {
  5151. *pOut = 0.0f;
  5152. return (ARM_MATH_ARGUMENT_ERROR);
  5153. }
  5154. }
  5155. /**
  5156. * @brief Q31 square root function.
  5157. * @param[in] in input value. The range of the input value is [0 +1) or 0x00000000 to 0x7FFFFFFF.
  5158. * @param[out] *pOut square root of input value.
  5159. * @return The function returns ARM_MATH_SUCCESS if input value is positive value or ARM_MATH_ARGUMENT_ERROR if
  5160. * <code>in</code> is negative value and returns zero output for negative values.
  5161. */
  5162. arm_status arm_sqrt_q31(
  5163. q31_t in,
  5164. q31_t * pOut);
  5165. /**
  5166. * @brief Q15 square root function.
  5167. * @param[in] in input value. The range of the input value is [0 +1) or 0x0000 to 0x7FFF.
  5168. * @param[out] *pOut square root of input value.
  5169. * @return The function returns ARM_MATH_SUCCESS if input value is positive value or ARM_MATH_ARGUMENT_ERROR if
  5170. * <code>in</code> is negative value and returns zero output for negative values.
  5171. */
  5172. arm_status arm_sqrt_q15(
  5173. q15_t in,
  5174. q15_t * pOut);
  5175. /**
  5176. * @} end of SQRT group
  5177. */
  5178. /**
  5179. * @brief floating-point Circular write function.
  5180. */
  5181. static __INLINE void arm_circularWrite_f32(
  5182. int32_t * circBuffer,
  5183. int32_t L,
  5184. uint16_t * writeOffset,
  5185. int32_t bufferInc,
  5186. const int32_t * src,
  5187. int32_t srcInc,
  5188. uint32_t blockSize)
  5189. {
  5190. uint32_t i = 0u;
  5191. int32_t wOffset;
  5192. /* Copy the value of Index pointer that points
  5193. * to the current location where the input samples to be copied */
  5194. wOffset = *writeOffset;
  5195. /* Loop over the blockSize */
  5196. i = blockSize;
  5197. while(i > 0u)
  5198. {
  5199. /* copy the input sample to the circular buffer */
  5200. circBuffer[wOffset] = *src;
  5201. /* Update the input pointer */
  5202. src += srcInc;
  5203. /* Circularly update wOffset. Watch out for positive and negative value */
  5204. wOffset += bufferInc;
  5205. if(wOffset >= L)
  5206. wOffset -= L;
  5207. /* Decrement the loop counter */
  5208. i--;
  5209. }
  5210. /* Update the index pointer */
  5211. *writeOffset = wOffset;
  5212. }
  5213. /**
  5214. * @brief floating-point Circular Read function.
  5215. */
  5216. static __INLINE void arm_circularRead_f32(
  5217. int32_t * circBuffer,
  5218. int32_t L,
  5219. int32_t * readOffset,
  5220. int32_t bufferInc,
  5221. int32_t * dst,
  5222. int32_t * dst_base,
  5223. int32_t dst_length,
  5224. int32_t dstInc,
  5225. uint32_t blockSize)
  5226. {
  5227. uint32_t i = 0u;
  5228. int32_t rOffset, dst_end;
  5229. /* Copy the value of Index pointer that points
  5230. * to the current location from where the input samples to be read */
  5231. rOffset = *readOffset;
  5232. dst_end = (int32_t) (dst_base + dst_length);
  5233. /* Loop over the blockSize */
  5234. i = blockSize;
  5235. while(i > 0u)
  5236. {
  5237. /* copy the sample from the circular buffer to the destination buffer */
  5238. *dst = circBuffer[rOffset];
  5239. /* Update the input pointer */
  5240. dst += dstInc;
  5241. if(dst == (int32_t *) dst_end)
  5242. {
  5243. dst = dst_base;
  5244. }
  5245. /* Circularly update rOffset. Watch out for positive and negative value */
  5246. rOffset += bufferInc;
  5247. if(rOffset >= L)
  5248. {
  5249. rOffset -= L;
  5250. }
  5251. /* Decrement the loop counter */
  5252. i--;
  5253. }
  5254. /* Update the index pointer */
  5255. *readOffset = rOffset;
  5256. }
  5257. /**
  5258. * @brief Q15 Circular write function.
  5259. */
  5260. static __INLINE void arm_circularWrite_q15(
  5261. q15_t * circBuffer,
  5262. int32_t L,
  5263. uint16_t * writeOffset,
  5264. int32_t bufferInc,
  5265. const q15_t * src,
  5266. int32_t srcInc,
  5267. uint32_t blockSize)
  5268. {
  5269. uint32_t i = 0u;
  5270. int32_t wOffset;
  5271. /* Copy the value of Index pointer that points
  5272. * to the current location where the input samples to be copied */
  5273. wOffset = *writeOffset;
  5274. /* Loop over the blockSize */
  5275. i = blockSize;
  5276. while(i > 0u)
  5277. {
  5278. /* copy the input sample to the circular buffer */
  5279. circBuffer[wOffset] = *src;
  5280. /* Update the input pointer */
  5281. src += srcInc;
  5282. /* Circularly update wOffset. Watch out for positive and negative value */
  5283. wOffset += bufferInc;
  5284. if(wOffset >= L)
  5285. wOffset -= L;
  5286. /* Decrement the loop counter */
  5287. i--;
  5288. }
  5289. /* Update the index pointer */
  5290. *writeOffset = wOffset;
  5291. }
  5292. /**
  5293. * @brief Q15 Circular Read function.
  5294. */
  5295. static __INLINE void arm_circularRead_q15(
  5296. q15_t * circBuffer,
  5297. int32_t L,
  5298. int32_t * readOffset,
  5299. int32_t bufferInc,
  5300. q15_t * dst,
  5301. q15_t * dst_base,
  5302. int32_t dst_length,
  5303. int32_t dstInc,
  5304. uint32_t blockSize)
  5305. {
  5306. uint32_t i = 0;
  5307. int32_t rOffset, dst_end;
  5308. /* Copy the value of Index pointer that points
  5309. * to the current location from where the input samples to be read */
  5310. rOffset = *readOffset;
  5311. dst_end = (int32_t) (dst_base + dst_length);
  5312. /* Loop over the blockSize */
  5313. i = blockSize;
  5314. while(i > 0u)
  5315. {
  5316. /* copy the sample from the circular buffer to the destination buffer */
  5317. *dst = circBuffer[rOffset];
  5318. /* Update the input pointer */
  5319. dst += dstInc;
  5320. if(dst == (q15_t *) dst_end)
  5321. {
  5322. dst = dst_base;
  5323. }
  5324. /* Circularly update wOffset. Watch out for positive and negative value */
  5325. rOffset += bufferInc;
  5326. if(rOffset >= L)
  5327. {
  5328. rOffset -= L;
  5329. }
  5330. /* Decrement the loop counter */
  5331. i--;
  5332. }
  5333. /* Update the index pointer */
  5334. *readOffset = rOffset;
  5335. }
  5336. /**
  5337. * @brief Q7 Circular write function.
  5338. */
  5339. static __INLINE void arm_circularWrite_q7(
  5340. q7_t * circBuffer,
  5341. int32_t L,
  5342. uint16_t * writeOffset,
  5343. int32_t bufferInc,
  5344. const q7_t * src,
  5345. int32_t srcInc,
  5346. uint32_t blockSize)
  5347. {
  5348. uint32_t i = 0u;
  5349. int32_t wOffset;
  5350. /* Copy the value of Index pointer that points
  5351. * to the current location where the input samples to be copied */
  5352. wOffset = *writeOffset;
  5353. /* Loop over the blockSize */
  5354. i = blockSize;
  5355. while(i > 0u)
  5356. {
  5357. /* copy the input sample to the circular buffer */
  5358. circBuffer[wOffset] = *src;
  5359. /* Update the input pointer */
  5360. src += srcInc;
  5361. /* Circularly update wOffset. Watch out for positive and negative value */
  5362. wOffset += bufferInc;
  5363. if(wOffset >= L)
  5364. wOffset -= L;
  5365. /* Decrement the loop counter */
  5366. i--;
  5367. }
  5368. /* Update the index pointer */
  5369. *writeOffset = wOffset;
  5370. }
  5371. /**
  5372. * @brief Q7 Circular Read function.
  5373. */
  5374. static __INLINE void arm_circularRead_q7(
  5375. q7_t * circBuffer,
  5376. int32_t L,
  5377. int32_t * readOffset,
  5378. int32_t bufferInc,
  5379. q7_t * dst,
  5380. q7_t * dst_base,
  5381. int32_t dst_length,
  5382. int32_t dstInc,
  5383. uint32_t blockSize)
  5384. {
  5385. uint32_t i = 0;
  5386. int32_t rOffset, dst_end;
  5387. /* Copy the value of Index pointer that points
  5388. * to the current location from where the input samples to be read */
  5389. rOffset = *readOffset;
  5390. dst_end = (int32_t) (dst_base + dst_length);
  5391. /* Loop over the blockSize */
  5392. i = blockSize;
  5393. while(i > 0u)
  5394. {
  5395. /* copy the sample from the circular buffer to the destination buffer */
  5396. *dst = circBuffer[rOffset];
  5397. /* Update the input pointer */
  5398. dst += dstInc;
  5399. if(dst == (q7_t *) dst_end)
  5400. {
  5401. dst = dst_base;
  5402. }
  5403. /* Circularly update rOffset. Watch out for positive and negative value */
  5404. rOffset += bufferInc;
  5405. if(rOffset >= L)
  5406. {
  5407. rOffset -= L;
  5408. }
  5409. /* Decrement the loop counter */
  5410. i--;
  5411. }
  5412. /* Update the index pointer */
  5413. *readOffset = rOffset;
  5414. }
  5415. /**
  5416. * @brief Sum of the squares of the elements of a Q31 vector.
  5417. * @param[in] *pSrc is input pointer
  5418. * @param[in] blockSize is the number of samples to process
  5419. * @param[out] *pResult is output value.
  5420. * @return none.
  5421. */
  5422. void arm_power_q31(
  5423. q31_t * pSrc,
  5424. uint32_t blockSize,
  5425. q63_t * pResult);
  5426. /**
  5427. * @brief Sum of the squares of the elements of a floating-point vector.
  5428. * @param[in] *pSrc is input pointer
  5429. * @param[in] blockSize is the number of samples to process
  5430. * @param[out] *pResult is output value.
  5431. * @return none.
  5432. */
  5433. void arm_power_f32(
  5434. float32_t * pSrc,
  5435. uint32_t blockSize,
  5436. float32_t * pResult);
  5437. /**
  5438. * @brief Sum of the squares of the elements of a Q15 vector.
  5439. * @param[in] *pSrc is input pointer
  5440. * @param[in] blockSize is the number of samples to process
  5441. * @param[out] *pResult is output value.
  5442. * @return none.
  5443. */
  5444. void arm_power_q15(
  5445. q15_t * pSrc,
  5446. uint32_t blockSize,
  5447. q63_t * pResult);
  5448. /**
  5449. * @brief Sum of the squares of the elements of a Q7 vector.
  5450. * @param[in] *pSrc is input pointer
  5451. * @param[in] blockSize is the number of samples to process
  5452. * @param[out] *pResult is output value.
  5453. * @return none.
  5454. */
  5455. void arm_power_q7(
  5456. q7_t * pSrc,
  5457. uint32_t blockSize,
  5458. q31_t * pResult);
  5459. /**
  5460. * @brief Mean value of a Q7 vector.
  5461. * @param[in] *pSrc is input pointer
  5462. * @param[in] blockSize is the number of samples to process
  5463. * @param[out] *pResult is output value.
  5464. * @return none.
  5465. */
  5466. void arm_mean_q7(
  5467. q7_t * pSrc,
  5468. uint32_t blockSize,
  5469. q7_t * pResult);
  5470. /**
  5471. * @brief Mean value of a Q15 vector.
  5472. * @param[in] *pSrc is input pointer
  5473. * @param[in] blockSize is the number of samples to process
  5474. * @param[out] *pResult is output value.
  5475. * @return none.
  5476. */
  5477. void arm_mean_q15(
  5478. q15_t * pSrc,
  5479. uint32_t blockSize,
  5480. q15_t * pResult);
  5481. /**
  5482. * @brief Mean value of a Q31 vector.
  5483. * @param[in] *pSrc is input pointer
  5484. * @param[in] blockSize is the number of samples to process
  5485. * @param[out] *pResult is output value.
  5486. * @return none.
  5487. */
  5488. void arm_mean_q31(
  5489. q31_t * pSrc,
  5490. uint32_t blockSize,
  5491. q31_t * pResult);
  5492. /**
  5493. * @brief Mean value of a floating-point vector.
  5494. * @param[in] *pSrc is input pointer
  5495. * @param[in] blockSize is the number of samples to process
  5496. * @param[out] *pResult is output value.
  5497. * @return none.
  5498. */
  5499. void arm_mean_f32(
  5500. float32_t * pSrc,
  5501. uint32_t blockSize,
  5502. float32_t * pResult);
  5503. /**
  5504. * @brief Variance of the elements of a floating-point vector.
  5505. * @param[in] *pSrc is input pointer
  5506. * @param[in] blockSize is the number of samples to process
  5507. * @param[out] *pResult is output value.
  5508. * @return none.
  5509. */
  5510. void arm_var_f32(
  5511. float32_t * pSrc,
  5512. uint32_t blockSize,
  5513. float32_t * pResult);
  5514. /**
  5515. * @brief Variance of the elements of a Q31 vector.
  5516. * @param[in] *pSrc is input pointer
  5517. * @param[in] blockSize is the number of samples to process
  5518. * @param[out] *pResult is output value.
  5519. * @return none.
  5520. */
  5521. void arm_var_q31(
  5522. q31_t * pSrc,
  5523. uint32_t blockSize,
  5524. q31_t * pResult);
  5525. /**
  5526. * @brief Variance of the elements of a Q15 vector.
  5527. * @param[in] *pSrc is input pointer
  5528. * @param[in] blockSize is the number of samples to process
  5529. * @param[out] *pResult is output value.
  5530. * @return none.
  5531. */
  5532. void arm_var_q15(
  5533. q15_t * pSrc,
  5534. uint32_t blockSize,
  5535. q15_t * pResult);
  5536. /**
  5537. * @brief Root Mean Square of the elements of a floating-point vector.
  5538. * @param[in] *pSrc is input pointer
  5539. * @param[in] blockSize is the number of samples to process
  5540. * @param[out] *pResult is output value.
  5541. * @return none.
  5542. */
  5543. void arm_rms_f32(
  5544. float32_t * pSrc,
  5545. uint32_t blockSize,
  5546. float32_t * pResult);
  5547. /**
  5548. * @brief Root Mean Square of the elements of a Q31 vector.
  5549. * @param[in] *pSrc is input pointer
  5550. * @param[in] blockSize is the number of samples to process
  5551. * @param[out] *pResult is output value.
  5552. * @return none.
  5553. */
  5554. void arm_rms_q31(
  5555. q31_t * pSrc,
  5556. uint32_t blockSize,
  5557. q31_t * pResult);
  5558. /**
  5559. * @brief Root Mean Square of the elements of a Q15 vector.
  5560. * @param[in] *pSrc is input pointer
  5561. * @param[in] blockSize is the number of samples to process
  5562. * @param[out] *pResult is output value.
  5563. * @return none.
  5564. */
  5565. void arm_rms_q15(
  5566. q15_t * pSrc,
  5567. uint32_t blockSize,
  5568. q15_t * pResult);
  5569. /**
  5570. * @brief Standard deviation of the elements of a floating-point vector.
  5571. * @param[in] *pSrc is input pointer
  5572. * @param[in] blockSize is the number of samples to process
  5573. * @param[out] *pResult is output value.
  5574. * @return none.
  5575. */
  5576. void arm_std_f32(
  5577. float32_t * pSrc,
  5578. uint32_t blockSize,
  5579. float32_t * pResult);
  5580. /**
  5581. * @brief Standard deviation of the elements of a Q31 vector.
  5582. * @param[in] *pSrc is input pointer
  5583. * @param[in] blockSize is the number of samples to process
  5584. * @param[out] *pResult is output value.
  5585. * @return none.
  5586. */
  5587. void arm_std_q31(
  5588. q31_t * pSrc,
  5589. uint32_t blockSize,
  5590. q31_t * pResult);
  5591. /**
  5592. * @brief Standard deviation of the elements of a Q15 vector.
  5593. * @param[in] *pSrc is input pointer
  5594. * @param[in] blockSize is the number of samples to process
  5595. * @param[out] *pResult is output value.
  5596. * @return none.
  5597. */
  5598. void arm_std_q15(
  5599. q15_t * pSrc,
  5600. uint32_t blockSize,
  5601. q15_t * pResult);
  5602. /**
  5603. * @brief Floating-point complex magnitude
  5604. * @param[in] *pSrc points to the complex input vector
  5605. * @param[out] *pDst points to the real output vector
  5606. * @param[in] numSamples number of complex samples in the input vector
  5607. * @return none.
  5608. */
  5609. void arm_cmplx_mag_f32(
  5610. float32_t * pSrc,
  5611. float32_t * pDst,
  5612. uint32_t numSamples);
  5613. /**
  5614. * @brief Q31 complex magnitude
  5615. * @param[in] *pSrc points to the complex input vector
  5616. * @param[out] *pDst points to the real output vector
  5617. * @param[in] numSamples number of complex samples in the input vector
  5618. * @return none.
  5619. */
  5620. void arm_cmplx_mag_q31(
  5621. q31_t * pSrc,
  5622. q31_t * pDst,
  5623. uint32_t numSamples);
  5624. /**
  5625. * @brief Q15 complex magnitude
  5626. * @param[in] *pSrc points to the complex input vector
  5627. * @param[out] *pDst points to the real output vector
  5628. * @param[in] numSamples number of complex samples in the input vector
  5629. * @return none.
  5630. */
  5631. void arm_cmplx_mag_q15(
  5632. q15_t * pSrc,
  5633. q15_t * pDst,
  5634. uint32_t numSamples);
  5635. /**
  5636. * @brief Q15 complex dot product
  5637. * @param[in] *pSrcA points to the first input vector
  5638. * @param[in] *pSrcB points to the second input vector
  5639. * @param[in] numSamples number of complex samples in each vector
  5640. * @param[out] *realResult real part of the result returned here
  5641. * @param[out] *imagResult imaginary part of the result returned here
  5642. * @return none.
  5643. */
  5644. void arm_cmplx_dot_prod_q15(
  5645. q15_t * pSrcA,
  5646. q15_t * pSrcB,
  5647. uint32_t numSamples,
  5648. q31_t * realResult,
  5649. q31_t * imagResult);
  5650. /**
  5651. * @brief Q31 complex dot product
  5652. * @param[in] *pSrcA points to the first input vector
  5653. * @param[in] *pSrcB points to the second input vector
  5654. * @param[in] numSamples number of complex samples in each vector
  5655. * @param[out] *realResult real part of the result returned here
  5656. * @param[out] *imagResult imaginary part of the result returned here
  5657. * @return none.
  5658. */
  5659. void arm_cmplx_dot_prod_q31(
  5660. q31_t * pSrcA,
  5661. q31_t * pSrcB,
  5662. uint32_t numSamples,
  5663. q63_t * realResult,
  5664. q63_t * imagResult);
  5665. /**
  5666. * @brief Floating-point complex dot product
  5667. * @param[in] *pSrcA points to the first input vector
  5668. * @param[in] *pSrcB points to the second input vector
  5669. * @param[in] numSamples number of complex samples in each vector
  5670. * @param[out] *realResult real part of the result returned here
  5671. * @param[out] *imagResult imaginary part of the result returned here
  5672. * @return none.
  5673. */
  5674. void arm_cmplx_dot_prod_f32(
  5675. float32_t * pSrcA,
  5676. float32_t * pSrcB,
  5677. uint32_t numSamples,
  5678. float32_t * realResult,
  5679. float32_t * imagResult);
  5680. /**
  5681. * @brief Q15 complex-by-real multiplication
  5682. * @param[in] *pSrcCmplx points to the complex input vector
  5683. * @param[in] *pSrcReal points to the real input vector
  5684. * @param[out] *pCmplxDst points to the complex output vector
  5685. * @param[in] numSamples number of samples in each vector
  5686. * @return none.
  5687. */
  5688. void arm_cmplx_mult_real_q15(
  5689. q15_t * pSrcCmplx,
  5690. q15_t * pSrcReal,
  5691. q15_t * pCmplxDst,
  5692. uint32_t numSamples);
  5693. /**
  5694. * @brief Q31 complex-by-real multiplication
  5695. * @param[in] *pSrcCmplx points to the complex input vector
  5696. * @param[in] *pSrcReal points to the real input vector
  5697. * @param[out] *pCmplxDst points to the complex output vector
  5698. * @param[in] numSamples number of samples in each vector
  5699. * @return none.
  5700. */
  5701. void arm_cmplx_mult_real_q31(
  5702. q31_t * pSrcCmplx,
  5703. q31_t * pSrcReal,
  5704. q31_t * pCmplxDst,
  5705. uint32_t numSamples);
  5706. /**
  5707. * @brief Floating-point complex-by-real multiplication
  5708. * @param[in] *pSrcCmplx points to the complex input vector
  5709. * @param[in] *pSrcReal points to the real input vector
  5710. * @param[out] *pCmplxDst points to the complex output vector
  5711. * @param[in] numSamples number of samples in each vector
  5712. * @return none.
  5713. */
  5714. void arm_cmplx_mult_real_f32(
  5715. float32_t * pSrcCmplx,
  5716. float32_t * pSrcReal,
  5717. float32_t * pCmplxDst,
  5718. uint32_t numSamples);
  5719. /**
  5720. * @brief Minimum value of a Q7 vector.
  5721. * @param[in] *pSrc is input pointer
  5722. * @param[in] blockSize is the number of samples to process
  5723. * @param[out] *result is output pointer
  5724. * @param[in] index is the array index of the minimum value in the input buffer.
  5725. * @return none.
  5726. */
  5727. void arm_min_q7(
  5728. q7_t * pSrc,
  5729. uint32_t blockSize,
  5730. q7_t * result,
  5731. uint32_t * index);
  5732. /**
  5733. * @brief Minimum value of a Q15 vector.
  5734. * @param[in] *pSrc is input pointer
  5735. * @param[in] blockSize is the number of samples to process
  5736. * @param[out] *pResult is output pointer
  5737. * @param[in] *pIndex is the array index of the minimum value in the input buffer.
  5738. * @return none.
  5739. */
  5740. void arm_min_q15(
  5741. q15_t * pSrc,
  5742. uint32_t blockSize,
  5743. q15_t * pResult,
  5744. uint32_t * pIndex);
  5745. /**
  5746. * @brief Minimum value of a Q31 vector.
  5747. * @param[in] *pSrc is input pointer
  5748. * @param[in] blockSize is the number of samples to process
  5749. * @param[out] *pResult is output pointer
  5750. * @param[out] *pIndex is the array index of the minimum value in the input buffer.
  5751. * @return none.
  5752. */
  5753. void arm_min_q31(
  5754. q31_t * pSrc,
  5755. uint32_t blockSize,
  5756. q31_t * pResult,
  5757. uint32_t * pIndex);
  5758. /**
  5759. * @brief Minimum value of a floating-point vector.
  5760. * @param[in] *pSrc is input pointer
  5761. * @param[in] blockSize is the number of samples to process
  5762. * @param[out] *pResult is output pointer
  5763. * @param[out] *pIndex is the array index of the minimum value in the input buffer.
  5764. * @return none.
  5765. */
  5766. void arm_min_f32(
  5767. float32_t * pSrc,
  5768. uint32_t blockSize,
  5769. float32_t * pResult,
  5770. uint32_t * pIndex);
  5771. /**
  5772. * @brief Maximum value of a Q7 vector.
  5773. * @param[in] *pSrc points to the input buffer
  5774. * @param[in] blockSize length of the input vector
  5775. * @param[out] *pResult maximum value returned here
  5776. * @param[out] *pIndex index of maximum value returned here
  5777. * @return none.
  5778. */
  5779. void arm_max_q7(
  5780. q7_t * pSrc,
  5781. uint32_t blockSize,
  5782. q7_t * pResult,
  5783. uint32_t * pIndex);
  5784. /**
  5785. * @brief Maximum value of a Q15 vector.
  5786. * @param[in] *pSrc points to the input buffer
  5787. * @param[in] blockSize length of the input vector
  5788. * @param[out] *pResult maximum value returned here
  5789. * @param[out] *pIndex index of maximum value returned here
  5790. * @return none.
  5791. */
  5792. void arm_max_q15(
  5793. q15_t * pSrc,
  5794. uint32_t blockSize,
  5795. q15_t * pResult,
  5796. uint32_t * pIndex);
  5797. /**
  5798. * @brief Maximum value of a Q31 vector.
  5799. * @param[in] *pSrc points to the input buffer
  5800. * @param[in] blockSize length of the input vector
  5801. * @param[out] *pResult maximum value returned here
  5802. * @param[out] *pIndex index of maximum value returned here
  5803. * @return none.
  5804. */
  5805. void arm_max_q31(
  5806. q31_t * pSrc,
  5807. uint32_t blockSize,
  5808. q31_t * pResult,
  5809. uint32_t * pIndex);
  5810. /**
  5811. * @brief Maximum value of a floating-point vector.
  5812. * @param[in] *pSrc points to the input buffer
  5813. * @param[in] blockSize length of the input vector
  5814. * @param[out] *pResult maximum value returned here
  5815. * @param[out] *pIndex index of maximum value returned here
  5816. * @return none.
  5817. */
  5818. void arm_max_f32(
  5819. float32_t * pSrc,
  5820. uint32_t blockSize,
  5821. float32_t * pResult,
  5822. uint32_t * pIndex);
  5823. /**
  5824. * @brief Q15 complex-by-complex multiplication
  5825. * @param[in] *pSrcA points to the first input vector
  5826. * @param[in] *pSrcB points to the second input vector
  5827. * @param[out] *pDst points to the output vector
  5828. * @param[in] numSamples number of complex samples in each vector
  5829. * @return none.
  5830. */
  5831. void arm_cmplx_mult_cmplx_q15(
  5832. q15_t * pSrcA,
  5833. q15_t * pSrcB,
  5834. q15_t * pDst,
  5835. uint32_t numSamples);
  5836. /**
  5837. * @brief Q31 complex-by-complex multiplication
  5838. * @param[in] *pSrcA points to the first input vector
  5839. * @param[in] *pSrcB points to the second input vector
  5840. * @param[out] *pDst points to the output vector
  5841. * @param[in] numSamples number of complex samples in each vector
  5842. * @return none.
  5843. */
  5844. void arm_cmplx_mult_cmplx_q31(
  5845. q31_t * pSrcA,
  5846. q31_t * pSrcB,
  5847. q31_t * pDst,
  5848. uint32_t numSamples);
  5849. /**
  5850. * @brief Floating-point complex-by-complex multiplication
  5851. * @param[in] *pSrcA points to the first input vector
  5852. * @param[in] *pSrcB points to the second input vector
  5853. * @param[out] *pDst points to the output vector
  5854. * @param[in] numSamples number of complex samples in each vector
  5855. * @return none.
  5856. */
  5857. void arm_cmplx_mult_cmplx_f32(
  5858. float32_t * pSrcA,
  5859. float32_t * pSrcB,
  5860. float32_t * pDst,
  5861. uint32_t numSamples);
  5862. /**
  5863. * @brief Converts the elements of the floating-point vector to Q31 vector.
  5864. * @param[in] *pSrc points to the floating-point input vector
  5865. * @param[out] *pDst points to the Q31 output vector
  5866. * @param[in] blockSize length of the input vector
  5867. * @return none.
  5868. */
  5869. void arm_float_to_q31(
  5870. float32_t * pSrc,
  5871. q31_t * pDst,
  5872. uint32_t blockSize);
  5873. /**
  5874. * @brief Converts the elements of the floating-point vector to Q15 vector.
  5875. * @param[in] *pSrc points to the floating-point input vector
  5876. * @param[out] *pDst points to the Q15 output vector
  5877. * @param[in] blockSize length of the input vector
  5878. * @return none
  5879. */
  5880. void arm_float_to_q15(
  5881. float32_t * pSrc,
  5882. q15_t * pDst,
  5883. uint32_t blockSize);
  5884. /**
  5885. * @brief Converts the elements of the floating-point vector to Q7 vector.
  5886. * @param[in] *pSrc points to the floating-point input vector
  5887. * @param[out] *pDst points to the Q7 output vector
  5888. * @param[in] blockSize length of the input vector
  5889. * @return none
  5890. */
  5891. void arm_float_to_q7(
  5892. float32_t * pSrc,
  5893. q7_t * pDst,
  5894. uint32_t blockSize);
  5895. /**
  5896. * @brief Converts the elements of the Q31 vector to Q15 vector.
  5897. * @param[in] *pSrc is input pointer
  5898. * @param[out] *pDst is output pointer
  5899. * @param[in] blockSize is the number of samples to process
  5900. * @return none.
  5901. */
  5902. void arm_q31_to_q15(
  5903. q31_t * pSrc,
  5904. q15_t * pDst,
  5905. uint32_t blockSize);
  5906. /**
  5907. * @brief Converts the elements of the Q31 vector to Q7 vector.
  5908. * @param[in] *pSrc is input pointer
  5909. * @param[out] *pDst is output pointer
  5910. * @param[in] blockSize is the number of samples to process
  5911. * @return none.
  5912. */
  5913. void arm_q31_to_q7(
  5914. q31_t * pSrc,
  5915. q7_t * pDst,
  5916. uint32_t blockSize);
  5917. /**
  5918. * @brief Converts the elements of the Q15 vector to floating-point vector.
  5919. * @param[in] *pSrc is input pointer
  5920. * @param[out] *pDst is output pointer
  5921. * @param[in] blockSize is the number of samples to process
  5922. * @return none.
  5923. */
  5924. void arm_q15_to_float(
  5925. q15_t * pSrc,
  5926. float32_t * pDst,
  5927. uint32_t blockSize);
  5928. /**
  5929. * @brief Converts the elements of the Q15 vector to Q31 vector.
  5930. * @param[in] *pSrc is input pointer
  5931. * @param[out] *pDst is output pointer
  5932. * @param[in] blockSize is the number of samples to process
  5933. * @return none.
  5934. */
  5935. void arm_q15_to_q31(
  5936. q15_t * pSrc,
  5937. q31_t * pDst,
  5938. uint32_t blockSize);
  5939. /**
  5940. * @brief Converts the elements of the Q15 vector to Q7 vector.
  5941. * @param[in] *pSrc is input pointer
  5942. * @param[out] *pDst is output pointer
  5943. * @param[in] blockSize is the number of samples to process
  5944. * @return none.
  5945. */
  5946. void arm_q15_to_q7(
  5947. q15_t * pSrc,
  5948. q7_t * pDst,
  5949. uint32_t blockSize);
  5950. /**
  5951. * @ingroup groupInterpolation
  5952. */
  5953. /**
  5954. * @defgroup BilinearInterpolate Bilinear Interpolation
  5955. *
  5956. * Bilinear interpolation is an extension of linear interpolation applied to a two dimensional grid.
  5957. * The underlying function <code>f(x, y)</code> is sampled on a regular grid and the interpolation process
  5958. * determines values between the grid points.
  5959. * Bilinear interpolation is equivalent to two step linear interpolation, first in the x-dimension and then in the y-dimension.
  5960. * Bilinear interpolation is often used in image processing to rescale images.
  5961. * The CMSIS DSP library provides bilinear interpolation functions for Q7, Q15, Q31, and floating-point data types.
  5962. *
  5963. * <b>Algorithm</b>
  5964. * \par
  5965. * The instance structure used by the bilinear interpolation functions describes a two dimensional data table.
  5966. * For floating-point, the instance structure is defined as:
  5967. * <pre>
  5968. * typedef struct
  5969. * {
  5970. * uint16_t numRows;
  5971. * uint16_t numCols;
  5972. * float32_t *pData;
  5973. * } arm_bilinear_interp_instance_f32;
  5974. * </pre>
  5975. *
  5976. * \par
  5977. * where <code>numRows</code> specifies the number of rows in the table;
  5978. * <code>numCols</code> specifies the number of columns in the table;
  5979. * and <code>pData</code> points to an array of size <code>numRows*numCols</code> values.
  5980. * The data table <code>pTable</code> is organized in row order and the supplied data values fall on integer indexes.
  5981. * That is, table element (x,y) is located at <code>pTable[x + y*numCols]</code> where x and y are integers.
  5982. *
  5983. * \par
  5984. * Let <code>(x, y)</code> specify the desired interpolation point. Then define:
  5985. * <pre>
  5986. * XF = floor(x)
  5987. * YF = floor(y)
  5988. * </pre>
  5989. * \par
  5990. * The interpolated output point is computed as:
  5991. * <pre>
  5992. * f(x, y) = f(XF, YF) * (1-(x-XF)) * (1-(y-YF))
  5993. * + f(XF+1, YF) * (x-XF)*(1-(y-YF))
  5994. * + f(XF, YF+1) * (1-(x-XF))*(y-YF)
  5995. * + f(XF+1, YF+1) * (x-XF)*(y-YF)
  5996. * </pre>
  5997. * Note that the coordinates (x, y) contain integer and fractional components.
  5998. * The integer components specify which portion of the table to use while the
  5999. * fractional components control the interpolation processor.
  6000. *
  6001. * \par
  6002. * if (x,y) are outside of the table boundary, Bilinear interpolation returns zero output.
  6003. */
  6004. /**
  6005. * @addtogroup BilinearInterpolate
  6006. * @{
  6007. */
  6008. /**
  6009. *
  6010. * @brief Floating-point bilinear interpolation.
  6011. * @param[in,out] *S points to an instance of the interpolation structure.
  6012. * @param[in] X interpolation coordinate.
  6013. * @param[in] Y interpolation coordinate.
  6014. * @return out interpolated value.
  6015. */
  6016. static __INLINE float32_t arm_bilinear_interp_f32(
  6017. const arm_bilinear_interp_instance_f32 * S,
  6018. float32_t X,
  6019. float32_t Y)
  6020. {
  6021. float32_t out;
  6022. float32_t f00, f01, f10, f11;
  6023. float32_t *pData = S->pData;
  6024. int32_t xIndex, yIndex, index;
  6025. float32_t xdiff, ydiff;
  6026. float32_t b1, b2, b3, b4;
  6027. xIndex = (int32_t) X;
  6028. yIndex = (int32_t) Y;
  6029. /* Care taken for table outside boundary */
  6030. /* Returns zero output when values are outside table boundary */
  6031. if(xIndex < 0 || xIndex > (S->numRows - 1) || yIndex < 0
  6032. || yIndex > (S->numCols - 1))
  6033. {
  6034. return (0);
  6035. }
  6036. /* Calculation of index for two nearest points in X-direction */
  6037. index = (xIndex - 1) + (yIndex - 1) * S->numCols;
  6038. /* Read two nearest points in X-direction */
  6039. f00 = pData[index];
  6040. f01 = pData[index + 1];
  6041. /* Calculation of index for two nearest points in Y-direction */
  6042. index = (xIndex - 1) + (yIndex) * S->numCols;
  6043. /* Read two nearest points in Y-direction */
  6044. f10 = pData[index];
  6045. f11 = pData[index + 1];
  6046. /* Calculation of intermediate values */
  6047. b1 = f00;
  6048. b2 = f01 - f00;
  6049. b3 = f10 - f00;
  6050. b4 = f00 - f01 - f10 + f11;
  6051. /* Calculation of fractional part in X */
  6052. xdiff = X - xIndex;
  6053. /* Calculation of fractional part in Y */
  6054. ydiff = Y - yIndex;
  6055. /* Calculation of bi-linear interpolated output */
  6056. out = b1 + b2 * xdiff + b3 * ydiff + b4 * xdiff * ydiff;
  6057. /* return to application */
  6058. return (out);
  6059. }
  6060. /**
  6061. *
  6062. * @brief Q31 bilinear interpolation.
  6063. * @param[in,out] *S points to an instance of the interpolation structure.
  6064. * @param[in] X interpolation coordinate in 12.20 format.
  6065. * @param[in] Y interpolation coordinate in 12.20 format.
  6066. * @return out interpolated value.
  6067. */
  6068. static __INLINE q31_t arm_bilinear_interp_q31(
  6069. arm_bilinear_interp_instance_q31 * S,
  6070. q31_t X,
  6071. q31_t Y)
  6072. {
  6073. q31_t out; /* Temporary output */
  6074. q31_t acc = 0; /* output */
  6075. q31_t xfract, yfract; /* X, Y fractional parts */
  6076. q31_t x1, x2, y1, y2; /* Nearest output values */
  6077. int32_t rI, cI; /* Row and column indices */
  6078. q31_t *pYData = S->pData; /* pointer to output table values */
  6079. uint32_t nCols = S->numCols; /* num of rows */
  6080. /* Input is in 12.20 format */
  6081. /* 12 bits for the table index */
  6082. /* Index value calculation */
  6083. rI = ((X & 0xFFF00000) >> 20u);
  6084. /* Input is in 12.20 format */
  6085. /* 12 bits for the table index */
  6086. /* Index value calculation */
  6087. cI = ((Y & 0xFFF00000) >> 20u);
  6088. /* Care taken for table outside boundary */
  6089. /* Returns zero output when values are outside table boundary */
  6090. if(rI < 0 || rI > (S->numRows - 1) || cI < 0 || cI > (S->numCols - 1))
  6091. {
  6092. return (0);
  6093. }
  6094. /* 20 bits for the fractional part */
  6095. /* shift left xfract by 11 to keep 1.31 format */
  6096. xfract = (X & 0x000FFFFF) << 11u;
  6097. /* Read two nearest output values from the index */
  6098. x1 = pYData[(rI) + nCols * (cI)];
  6099. x2 = pYData[(rI) + nCols * (cI) + 1u];
  6100. /* 20 bits for the fractional part */
  6101. /* shift left yfract by 11 to keep 1.31 format */
  6102. yfract = (Y & 0x000FFFFF) << 11u;
  6103. /* Read two nearest output values from the index */
  6104. y1 = pYData[(rI) + nCols * (cI + 1)];
  6105. y2 = pYData[(rI) + nCols * (cI + 1) + 1u];
  6106. /* Calculation of x1 * (1-xfract ) * (1-yfract) and acc is in 3.29(q29) format */
  6107. out = ((q31_t) (((q63_t) x1 * (0x7FFFFFFF - xfract)) >> 32));
  6108. acc = ((q31_t) (((q63_t) out * (0x7FFFFFFF - yfract)) >> 32));
  6109. /* x2 * (xfract) * (1-yfract) in 3.29(q29) and adding to acc */
  6110. out = ((q31_t) ((q63_t) x2 * (0x7FFFFFFF - yfract) >> 32));
  6111. acc += ((q31_t) ((q63_t) out * (xfract) >> 32));
  6112. /* y1 * (1 - xfract) * (yfract) in 3.29(q29) and adding to acc */
  6113. out = ((q31_t) ((q63_t) y1 * (0x7FFFFFFF - xfract) >> 32));
  6114. acc += ((q31_t) ((q63_t) out * (yfract) >> 32));
  6115. /* y2 * (xfract) * (yfract) in 3.29(q29) and adding to acc */
  6116. out = ((q31_t) ((q63_t) y2 * (xfract) >> 32));
  6117. acc += ((q31_t) ((q63_t) out * (yfract) >> 32));
  6118. /* Convert acc to 1.31(q31) format */
  6119. return (acc << 2u);
  6120. }
  6121. /**
  6122. * @brief Q15 bilinear interpolation.
  6123. * @param[in,out] *S points to an instance of the interpolation structure.
  6124. * @param[in] X interpolation coordinate in 12.20 format.
  6125. * @param[in] Y interpolation coordinate in 12.20 format.
  6126. * @return out interpolated value.
  6127. */
  6128. static __INLINE q15_t arm_bilinear_interp_q15(
  6129. arm_bilinear_interp_instance_q15 * S,
  6130. q31_t X,
  6131. q31_t Y)
  6132. {
  6133. q63_t acc = 0; /* output */
  6134. q31_t out; /* Temporary output */
  6135. q15_t x1, x2, y1, y2; /* Nearest output values */
  6136. q31_t xfract, yfract; /* X, Y fractional parts */
  6137. int32_t rI, cI; /* Row and column indices */
  6138. q15_t *pYData = S->pData; /* pointer to output table values */
  6139. uint32_t nCols = S->numCols; /* num of rows */
  6140. /* Input is in 12.20 format */
  6141. /* 12 bits for the table index */
  6142. /* Index value calculation */
  6143. rI = ((X & 0xFFF00000) >> 20);
  6144. /* Input is in 12.20 format */
  6145. /* 12 bits for the table index */
  6146. /* Index value calculation */
  6147. cI = ((Y & 0xFFF00000) >> 20);
  6148. /* Care taken for table outside boundary */
  6149. /* Returns zero output when values are outside table boundary */
  6150. if(rI < 0 || rI > (S->numRows - 1) || cI < 0 || cI > (S->numCols - 1))
  6151. {
  6152. return (0);
  6153. }
  6154. /* 20 bits for the fractional part */
  6155. /* xfract should be in 12.20 format */
  6156. xfract = (X & 0x000FFFFF);
  6157. /* Read two nearest output values from the index */
  6158. x1 = pYData[(rI) + nCols * (cI)];
  6159. x2 = pYData[(rI) + nCols * (cI) + 1u];
  6160. /* 20 bits for the fractional part */
  6161. /* yfract should be in 12.20 format */
  6162. yfract = (Y & 0x000FFFFF);
  6163. /* Read two nearest output values from the index */
  6164. y1 = pYData[(rI) + nCols * (cI + 1)];
  6165. y2 = pYData[(rI) + nCols * (cI + 1) + 1u];
  6166. /* Calculation of x1 * (1-xfract ) * (1-yfract) and acc is in 13.51 format */
  6167. /* x1 is in 1.15(q15), xfract in 12.20 format and out is in 13.35 format */
  6168. /* convert 13.35 to 13.31 by right shifting and out is in 1.31 */
  6169. out = (q31_t) (((q63_t) x1 * (0xFFFFF - xfract)) >> 4u);
  6170. acc = ((q63_t) out * (0xFFFFF - yfract));
  6171. /* x2 * (xfract) * (1-yfract) in 1.51 and adding to acc */
  6172. out = (q31_t) (((q63_t) x2 * (0xFFFFF - yfract)) >> 4u);
  6173. acc += ((q63_t) out * (xfract));
  6174. /* y1 * (1 - xfract) * (yfract) in 1.51 and adding to acc */
  6175. out = (q31_t) (((q63_t) y1 * (0xFFFFF - xfract)) >> 4u);
  6176. acc += ((q63_t) out * (yfract));
  6177. /* y2 * (xfract) * (yfract) in 1.51 and adding to acc */
  6178. out = (q31_t) (((q63_t) y2 * (xfract)) >> 4u);
  6179. acc += ((q63_t) out * (yfract));
  6180. /* acc is in 13.51 format and down shift acc by 36 times */
  6181. /* Convert out to 1.15 format */
  6182. return (acc >> 36);
  6183. }
  6184. /**
  6185. * @brief Q7 bilinear interpolation.
  6186. * @param[in,out] *S points to an instance of the interpolation structure.
  6187. * @param[in] X interpolation coordinate in 12.20 format.
  6188. * @param[in] Y interpolation coordinate in 12.20 format.
  6189. * @return out interpolated value.
  6190. */
  6191. static __INLINE q7_t arm_bilinear_interp_q7(
  6192. arm_bilinear_interp_instance_q7 * S,
  6193. q31_t X,
  6194. q31_t Y)
  6195. {
  6196. q63_t acc = 0; /* output */
  6197. q31_t out; /* Temporary output */
  6198. q31_t xfract, yfract; /* X, Y fractional parts */
  6199. q7_t x1, x2, y1, y2; /* Nearest output values */
  6200. int32_t rI, cI; /* Row and column indices */
  6201. q7_t *pYData = S->pData; /* pointer to output table values */
  6202. uint32_t nCols = S->numCols; /* num of rows */
  6203. /* Input is in 12.20 format */
  6204. /* 12 bits for the table index */
  6205. /* Index value calculation */
  6206. rI = ((X & 0xFFF00000) >> 20);
  6207. /* Input is in 12.20 format */
  6208. /* 12 bits for the table index */
  6209. /* Index value calculation */
  6210. cI = ((Y & 0xFFF00000) >> 20);
  6211. /* Care taken for table outside boundary */
  6212. /* Returns zero output when values are outside table boundary */
  6213. if(rI < 0 || rI > (S->numRows - 1) || cI < 0 || cI > (S->numCols - 1))
  6214. {
  6215. return (0);
  6216. }
  6217. /* 20 bits for the fractional part */
  6218. /* xfract should be in 12.20 format */
  6219. xfract = (X & 0x000FFFFF);
  6220. /* Read two nearest output values from the index */
  6221. x1 = pYData[(rI) + nCols * (cI)];
  6222. x2 = pYData[(rI) + nCols * (cI) + 1u];
  6223. /* 20 bits for the fractional part */
  6224. /* yfract should be in 12.20 format */
  6225. yfract = (Y & 0x000FFFFF);
  6226. /* Read two nearest output values from the index */
  6227. y1 = pYData[(rI) + nCols * (cI + 1)];
  6228. y2 = pYData[(rI) + nCols * (cI + 1) + 1u];
  6229. /* Calculation of x1 * (1-xfract ) * (1-yfract) and acc is in 16.47 format */
  6230. out = ((x1 * (0xFFFFF - xfract)));
  6231. acc = (((q63_t) out * (0xFFFFF - yfract)));
  6232. /* x2 * (xfract) * (1-yfract) in 2.22 and adding to acc */
  6233. out = ((x2 * (0xFFFFF - yfract)));
  6234. acc += (((q63_t) out * (xfract)));
  6235. /* y1 * (1 - xfract) * (yfract) in 2.22 and adding to acc */
  6236. out = ((y1 * (0xFFFFF - xfract)));
  6237. acc += (((q63_t) out * (yfract)));
  6238. /* y2 * (xfract) * (yfract) in 2.22 and adding to acc */
  6239. out = ((y2 * (yfract)));
  6240. acc += (((q63_t) out * (xfract)));
  6241. /* acc in 16.47 format and down shift by 40 to convert to 1.7 format */
  6242. return (acc >> 40);
  6243. }
  6244. /**
  6245. * @} end of BilinearInterpolate group
  6246. */
  6247. //SMMLAR
  6248. #define multAcc_32x32_keep32_R(a, x, y) \
  6249. a = (q31_t) (((((q63_t) a) << 32) + ((q63_t) x * y) + 0x80000000LL ) >> 32)
  6250. //SMMLSR
  6251. #define multSub_32x32_keep32_R(a, x, y) \
  6252. a = (q31_t) (((((q63_t) a) << 32) - ((q63_t) x * y) + 0x80000000LL ) >> 32)
  6253. //SMMULR
  6254. #define mult_32x32_keep32_R(a, x, y) \
  6255. a = (q31_t) (((q63_t) x * y + 0x80000000LL ) >> 32)
  6256. //SMMLA
  6257. #define multAcc_32x32_keep32(a, x, y) \
  6258. a += (q31_t) (((q63_t) x * y) >> 32)
  6259. //SMMLS
  6260. #define multSub_32x32_keep32(a, x, y) \
  6261. a -= (q31_t) (((q63_t) x * y) >> 32)
  6262. //SMMUL
  6263. #define mult_32x32_keep32(a, x, y) \
  6264. a = (q31_t) (((q63_t) x * y ) >> 32)
  6265. #if defined ( __CC_ARM ) //Keil
  6266. //Enter low optimization region - place directly above function definition
  6267. #ifdef ARM_MATH_CM4
  6268. #define LOW_OPTIMIZATION_ENTER \
  6269. _Pragma ("push") \
  6270. _Pragma ("O1")
  6271. #else
  6272. #define LOW_OPTIMIZATION_ENTER
  6273. #endif
  6274. //Exit low optimization region - place directly after end of function definition
  6275. #ifdef ARM_MATH_CM4
  6276. #define LOW_OPTIMIZATION_EXIT \
  6277. _Pragma ("pop")
  6278. #else
  6279. #define LOW_OPTIMIZATION_EXIT
  6280. #endif
  6281. //Enter low optimization region - place directly above function definition
  6282. #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
  6283. //Exit low optimization region - place directly after end of function definition
  6284. #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
  6285. #elif defined(__ICCARM__) //IAR
  6286. //Enter low optimization region - place directly above function definition
  6287. #ifdef ARM_MATH_CM4
  6288. #define LOW_OPTIMIZATION_ENTER \
  6289. _Pragma ("optimize=low")
  6290. #else
  6291. #define LOW_OPTIMIZATION_ENTER
  6292. #endif
  6293. //Exit low optimization region - place directly after end of function definition
  6294. #define LOW_OPTIMIZATION_EXIT
  6295. //Enter low optimization region - place directly above function definition
  6296. #ifdef ARM_MATH_CM4
  6297. #define IAR_ONLY_LOW_OPTIMIZATION_ENTER \
  6298. _Pragma ("optimize=low")
  6299. #else
  6300. #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
  6301. #endif
  6302. //Exit low optimization region - place directly after end of function definition
  6303. #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
  6304. #elif defined(__GNUC__)
  6305. #define LOW_OPTIMIZATION_ENTER __attribute__(( optimize("-O1") ))
  6306. #define LOW_OPTIMIZATION_EXIT
  6307. #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
  6308. #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
  6309. #elif defined(__CSMC__) // Cosmic
  6310. #define LOW_OPTIMIZATION_ENTER
  6311. #define LOW_OPTIMIZATION_EXIT
  6312. #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
  6313. #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
  6314. #endif
  6315. #ifdef __cplusplus
  6316. }
  6317. #endif
  6318. #endif /* _ARM_MATH_H */
  6319. /**
  6320. *
  6321. * End of file.
  6322. */