mbed 5 experimental branch
Fork of dsp by
Embed:
(wiki syntax)
Show/hide line numbers
arm_math.h
00001 /* ---------------------------------------------------------------------- 00002 * Copyright (C) 2010 ARM Limited. All rights reserved. 00003 * 00004 * $Date: 29. November 2010 00005 * $Revision: V1.0.3 00006 * 00007 * Project: CMSIS DSP Library 00008 * Title: arm_math.h 00009 * 00010 * Description: Public header file for CMSIS DSP Library 00011 * 00012 * Target Processor: Cortex-M4/Cortex-M3 00013 * 00014 * Version 1.0.3 2010/11/29 00015 * Re-organized the CMSIS folders and updated documentation. 00016 * 00017 * Version 1.0.2 2010/11/11 00018 * Documentation updated. 00019 * 00020 * Version 1.0.1 2010/10/05 00021 * Production release and review comments incorporated. 00022 * 00023 * Version 1.0.0 2010/09/20 00024 * Production release and review comments incorporated. 00025 *-------------------------------------------------------------------*/ 00026 00027 /** 00028 \mainpage CMSIS DSP Software Library 00029 * 00030 * <b>Introduction</b> 00031 * 00032 * This user manual describes the CMSIS DSP software library, 00033 * a suite of common signal processing functions for use on Cortex-M processor based devices. 00034 * 00035 * The library is divided into a number of modules each covering a specific category: 00036 * - Basic math functions 00037 * - Fast math functions 00038 * - Complex math functions 00039 * - Filters 00040 * - Matrix functions 00041 * - Transforms 00042 * - Motor control functions 00043 * - Statistical functions 00044 * - Support functions 00045 * - Interpolation functions 00046 * 00047 * The library has separate functions for operating on 8-bit integers, 16-bit integers, 00048 * 32-bit integer and 32-bit floating-point values. 00049 * 00050 * <b>Processor Support</b> 00051 * 00052 * The library is completely written in C and is fully CMSIS compliant. 00053 * High performance is achieved through maximum use of Cortex-M4 intrinsics. 00054 * 00055 * The supplied library source code also builds and runs on the Cortex-M3 processor, 00056 * with the DSP intrinsics being emulated through software. 00057 * 00058 * A Cortex-M0 version of the library is also being developed ; 00059 * updates on this activity will be made available shortly. 00060 00061 * 00062 * <b>Toolchain Support</b> 00063 * 00064 * The library has been developed and tested with MDK-ARM version 4.12. 00065 * The library is being tested in GCC and IAR toolchains and updates on this activity will be made available shortly. 00066 * 00067 * <b>Using the Library</b> 00068 * 00069 * The library installer contains prebuilt versions of the libraries in the <code>Lib</code> folder. 00070 * - arm_cortexM4_math.lib 00071 * - arm_cortexM3_math.lib 00072 * 00073 * The library functions are declared in the public file <code>arm_math.h</code> which is placed in the <code>Include</code> folder. 00074 * Simply include this file and link the appropriate library in the application and begin calling the library functions. The Library supports single 00075 * public header file <code> arm_math.h</code> for Cortex-M4, Cortex-M3 and Cortex-M0. Define the appropriate pre processor MACRO ARM_MATH_CM4 or ARM_MATH_CM3 or 00076 * ARM_MATH_CM0 depending on the target processor in the application. 00077 * 00078 * <b>Examples</b> 00079 * 00080 * The library ships with a number of examples which demonstrate how to use the library functions. 00081 * 00082 * <b>Building the Library</b> 00083 * 00084 * The library installer also contains project files to re build the library on MDK Tool chain in the <code>Lib</code> folder. 00085 * - arm_cortexM4_math.uvproj 00086 * - arm_cortexM3_math.uvproj 00087 * 00088 * The library supports size checking on the input and output matrices. To enable this feature, 00089 * define the MACRO ARM_MATH_MATRIX_CHECK in pre processor settings in project options. 00090 * The Library also supports rounding on support functions by using ARM_MATH_ROUNDING in pre processor settings 00091 * 00092 * The project can be built by opening the appropriate project in MDK-ARM 4.12 chain and defining the optional pre processor MACROs detailed above. 00093 * 00094 * <b>Copyright Notice</b> 00095 * 00096 * Copyright (C) 2010 ARM Limited. All rights reserved. 00097 */ 00098 00099 00100 /** 00101 * @defgroup groupMath Basic Math Functions 00102 */ 00103 00104 /** 00105 * @defgroup groupFastMath Fast Math Functions 00106 * This set of functions provides a fast approximation to sine, cosine, and square root. 00107 * As compared to most of the other functions in the CMSIS math library, the fast math functions 00108 * operate on individual values and not arrays. 00109 * There are separate functions for Q15, Q31, and floating-point data. 00110 * 00111 */ 00112 00113 /** 00114 * @defgroup groupCmplxMath Complex Math Functions 00115 * This set of functions operates on complex data vectors. 00116 * The data in the complex arrays is stored in an interleaved fashion 00117 * (real, imag, real, imag, ...). 00118 * In the API functions, the number of samples in a complex array refers 00119 * to the number of complex values; the array contains twice this number of 00120 * real values. 00121 */ 00122 00123 /** 00124 * @defgroup groupFilters Filtering Functions 00125 */ 00126 00127 /** 00128 * @defgroup groupMatrix Matrix Functions 00129 * 00130 * This set of functions provides basic matrix math operations. 00131 * The functions operate on matrix data structures. For example, 00132 * the type 00133 * definition for the floating-point matrix structure is shown 00134 * below: 00135 * <pre> 00136 * typedef struct 00137 * { 00138 * uint16_t numRows; // number of rows of the matrix. 00139 * uint16_t numCols; // number of columns of the matrix. 00140 * float32_t *pData; // points to the data of the matrix. 00141 * } arm_matrix_instance_f32; 00142 * </pre> 00143 * There are similar definitions for Q15 and Q31 data types. 00144 * 00145 * The structure specifies the size of the matrix and then points to 00146 * an array of data. The array is of size <code>numRows X numCols</code> 00147 * and the values are arranged in row order. That is, the 00148 * matrix element (i, j) is stored at: 00149 * <pre> 00150 * pData[i*numCols + j] 00151 * </pre> 00152 * 00153 * \par Init Functions 00154 * There is an associated initialization function for each type of matrix 00155 * data structure. 00156 * The initialization function sets the values of the internal structure fields. 00157 * Refer to the function <code>arm_mat_init_f32()</code>, <code>arm_mat_init_q31()</code> 00158 * and <code>arm_mat_init_q15()</code> for floating-point, Q31 and Q15 types, respectively. 00159 * 00160 * \par 00161 * Use of the initialization function is optional. However, if initialization function is used 00162 * then the instance structure cannot be placed into a const data section. 00163 * To place the instance structure in a const data 00164 * section, manually initialize the data structure. For example: 00165 * <pre> 00166 * <code>arm_matrix_instance_f32 S = {nRows, nColumns, pData};</code> 00167 * <code>arm_matrix_instance_q31 S = {nRows, nColumns, pData};</code> 00168 * <code>arm_matrix_instance_q15 S = {nRows, nColumns, pData};</code> 00169 * </pre> 00170 * where <code>nRows</code> specifies the number of rows, <code>nColumns</code> 00171 * specifies the number of columns, and <code>pData</code> points to the 00172 * data array. 00173 * 00174 * \par Size Checking 00175 * By default all of the matrix functions perform size checking on the input and 00176 * output matrices. For example, the matrix addition function verifies that the 00177 * two input matrices and the output matrix all have the same number of rows and 00178 * columns. If the size check fails the functions return: 00179 * <pre> 00180 * ARM_MATH_SIZE_MISMATCH 00181 * </pre> 00182 * Otherwise the functions return 00183 * <pre> 00184 * ARM_MATH_SUCCESS 00185 * </pre> 00186 * There is some overhead associated with this matrix size checking. 00187 * The matrix size checking is enabled via the #define 00188 * <pre> 00189 * ARM_MATH_MATRIX_CHECK 00190 * </pre> 00191 * within the library project settings. By default this macro is defined 00192 * and size checking is enabled. By changing the project settings and 00193 * undefining this macro size checking is eliminated and the functions 00194 * run a bit faster. With size checking disabled the functions always 00195 * return <code>ARM_MATH_SUCCESS</code>. 00196 */ 00197 00198 /** 00199 * @defgroup groupTransforms Transform Functions 00200 */ 00201 00202 /** 00203 * @defgroup groupController Controller Functions 00204 */ 00205 00206 /** 00207 * @defgroup groupStats Statistics Functions 00208 */ 00209 /** 00210 * @defgroup groupSupport Support Functions 00211 */ 00212 00213 /** 00214 * @defgroup groupInterpolation Interpolation Functions 00215 * These functions perform 1- and 2-dimensional interpolation of data. 00216 * Linear interpolation is used for 1-dimensional data and 00217 * bilinear interpolation is used for 2-dimensional data. 00218 */ 00219 00220 /** 00221 * @defgroup groupExamples Examples 00222 */ 00223 #ifndef _ARM_MATH_H 00224 #define _ARM_MATH_H 00225 00226 #define ARM_MATH_CM4 // mbed: set to CM� and include appropriate target cmsis library 00227 #include "cmsis.h" 00228 00229 // #define __CMSIS_GENERIC /* disable NVIC and Systick functions */ 00230 00231 /* 00232 #if defined (ARM_MATH_CM4) 00233 #include "core_cm4.h" 00234 #elif defined (ARM_MATH_CM3) 00235 #include "core_cm3.h" 00236 #elif defined (ARM_MATH_CM0) 00237 #include "core_cm0.h" 00238 #else 00239 #include "ARMCM4.h" 00240 #warning "Define either ARM_MATH_CM4 OR ARM_MATH_CM3...By Default building on ARM_MATH_CM4....." 00241 #endif 00242 */ 00243 00244 //#undef __CMSIS_GENERIC /* enable NVIC and Systick functions */ 00245 00246 #include "string.h" 00247 00248 #ifdef __cplusplus 00249 extern "C" 00250 { 00251 #endif 00252 00253 00254 /** 00255 * @brief Macros required for reciprocal calculation in Normalized LMS 00256 */ 00257 00258 #define DELTA_Q31 (0x100) 00259 #define DELTA_Q15 0x5 00260 #define INDEX_MASK 0x0000003F 00261 #define PI 3.14159265358979f 00262 00263 /** 00264 * @brief Macros required for SINE and COSINE Fast math approximations 00265 */ 00266 00267 #define TABLE_SIZE 256 00268 #define TABLE_SPACING_Q31 0x800000 00269 #define TABLE_SPACING_Q15 0x80 00270 00271 /** 00272 * @brief Macros required for SINE and COSINE Controller functions 00273 */ 00274 /* 1.31(q31) Fixed value of 2/360 */ 00275 /* -1 to +1 is divided into 360 values so total spacing is (2/360) */ 00276 #define INPUT_SPACING 0xB60B61 00277 00278 00279 /** 00280 * @brief Error status returned by some functions in the library. 00281 */ 00282 00283 typedef enum 00284 { 00285 ARM_MATH_SUCCESS = 0, /**< No error */ 00286 ARM_MATH_ARGUMENT_ERROR = -1, /**< One or more arguments are incorrect */ 00287 ARM_MATH_LENGTH_ERROR = -2, /**< Length of data buffer is incorrect */ 00288 ARM_MATH_SIZE_MISMATCH = -3, /**< Size of matrices is not compatible with the operation. */ 00289 ARM_MATH_NANINF = -4, /**< Not-a-number (NaN) or infinity is generated */ 00290 ARM_MATH_SINGULAR = -5, /**< Generated by matrix inversion if the input matrix is singular and cannot be inverted. */ 00291 ARM_MATH_TEST_FAILURE = -6 /**< Test Failed */ 00292 } arm_status; 00293 00294 /** 00295 * @brief 8-bit fractional data type in 1.7 format. 00296 */ 00297 typedef int8_t q7_t; 00298 00299 /** 00300 * @brief 16-bit fractional data type in 1.15 format. 00301 */ 00302 typedef int16_t q15_t; 00303 00304 /** 00305 * @brief 32-bit fractional data type in 1.31 format. 00306 */ 00307 typedef int32_t q31_t; 00308 00309 /** 00310 * @brief 64-bit fractional data type in 1.63 format. 00311 */ 00312 typedef int64_t q63_t; 00313 00314 /** 00315 * @brief 32-bit floating-point type definition. 00316 */ 00317 typedef float float32_t; 00318 00319 /** 00320 * @brief 64-bit floating-point type definition. 00321 */ 00322 typedef double float64_t; 00323 00324 /** 00325 * @brief definition to read/write two 16 bit values. 00326 */ 00327 #define __SIMD32(addr) (*(int32_t **) & (addr)) 00328 00329 #if defined (ARM_MATH_CM3) || defined (ARM_MATH_CM0) 00330 /** 00331 * @brief definition to pack two 16 bit values. 00332 */ 00333 #define __PKHBT(ARG1, ARG2, ARG3) ( (((int32_t)(ARG1) << 0) & (int32_t)0x0000FFFF) | \ 00334 (((int32_t)(ARG2) << ARG3) & (int32_t)0xFFFF0000) ) 00335 00336 #endif 00337 00338 /** 00339 * @brief definition to pack four 8 bit values. 00340 */ 00341 #define __PACKq7(v0,v1,v2,v3) ( (((int32_t)(v0) << 0) & (int32_t)0x000000FF) | \ 00342 (((int32_t)(v1) << 8) & (int32_t)0x0000FF00) | \ 00343 (((int32_t)(v2) << 16) & (int32_t)0x00FF0000) | \ 00344 (((int32_t)(v3) << 24) & (int32_t)0xFF000000) ) 00345 00346 00347 /** 00348 * @brief Clips Q63 to Q31 values. 00349 */ 00350 static __INLINE q31_t clip_q63_to_q31( 00351 q63_t x) 00352 { 00353 return ((q31_t) (x >> 32) != ((q31_t) x >> 31)) ? 00354 ((0x7FFFFFFF ^ ((q31_t) (x >> 62)))) : (q31_t) x; 00355 } 00356 00357 /** 00358 * @brief Clips Q63 to Q15 values. 00359 */ 00360 static __INLINE q15_t clip_q63_to_q15( 00361 q63_t x) 00362 { 00363 return ((q31_t) (x >> 32) != ((q31_t) x >> 31)) ? 00364 ((0x7FFF ^ ((q15_t) (x >> 63)))) : (q15_t) (x >> 15); 00365 } 00366 00367 /** 00368 * @brief Clips Q31 to Q7 values. 00369 */ 00370 static __INLINE q7_t clip_q31_to_q7( 00371 q31_t x) 00372 { 00373 return ((q31_t) (x >> 24) != ((q31_t) x >> 23)) ? 00374 ((0x7F ^ ((q7_t) (x >> 31)))) : (q7_t) x; 00375 } 00376 00377 /** 00378 * @brief Clips Q31 to Q15 values. 00379 */ 00380 static __INLINE q15_t clip_q31_to_q15( 00381 q31_t x) 00382 { 00383 return ((q31_t) (x >> 16) != ((q31_t) x >> 15)) ? 00384 ((0x7FFF ^ ((q15_t) (x >> 31)))) : (q15_t) x; 00385 } 00386 00387 /** 00388 * @brief Multiplies 32 X 64 and returns 32 bit result in 2.30 format. 00389 */ 00390 00391 static __INLINE q63_t mult32x64( 00392 q63_t x, 00393 q31_t y) 00394 { 00395 return ((((q63_t) (x & 0x00000000FFFFFFFF) * y) >> 32) + 00396 (((q63_t) (x >> 32) * y))); 00397 } 00398 00399 00400 /** 00401 * @brief Function to Calculates 1/in(reciprocal) value of Q31 Data type. 00402 */ 00403 00404 static __INLINE uint32_t arm_recip_q31( 00405 q31_t in, 00406 q31_t * dst, 00407 q31_t * pRecipTable) 00408 { 00409 00410 uint32_t out, tempVal; 00411 uint32_t index, i; 00412 uint32_t signBits; 00413 00414 if(in > 0) 00415 { 00416 signBits = __CLZ(in) - 1; 00417 } 00418 else 00419 { 00420 signBits = __CLZ(-in) - 1; 00421 } 00422 00423 /* Convert input sample to 1.31 format */ 00424 in = in << signBits; 00425 00426 /* calculation of index for initial approximated Val */ 00427 index = (uint32_t) (in >> 24u); 00428 index = (index & INDEX_MASK); 00429 00430 /* 1.31 with exp 1 */ 00431 out = pRecipTable[index]; 00432 00433 /* calculation of reciprocal value */ 00434 /* running approximation for two iterations */ 00435 for (i = 0u; i < 2u; i++) 00436 { 00437 tempVal = (q31_t) (((q63_t) in * out) >> 31u); 00438 tempVal = 0x7FFFFFFF - tempVal; 00439 /* 1.31 with exp 1 */ 00440 out = (q31_t) (((q63_t) out * tempVal) >> 30u); 00441 } 00442 00443 /* write output */ 00444 *dst = out; 00445 00446 /* return num of signbits of out = 1/in value */ 00447 return (signBits + 1u); 00448 00449 } 00450 00451 /** 00452 * @brief Function to Calculates 1/in(reciprocal) value of Q15 Data type. 00453 */ 00454 static __INLINE uint32_t arm_recip_q15( 00455 q15_t in, 00456 q15_t * dst, 00457 q15_t * pRecipTable) 00458 { 00459 00460 uint32_t out = 0, tempVal = 0; 00461 uint32_t index = 0, i = 0; 00462 uint32_t signBits = 0; 00463 00464 if(in > 0) 00465 { 00466 signBits = __CLZ(in) - 17; 00467 } 00468 else 00469 { 00470 signBits = __CLZ(-in) - 17; 00471 } 00472 00473 /* Convert input sample to 1.15 format */ 00474 in = in << signBits; 00475 00476 /* calculation of index for initial approximated Val */ 00477 index = in >> 8; 00478 index = (index & INDEX_MASK); 00479 00480 /* 1.15 with exp 1 */ 00481 out = pRecipTable[index]; 00482 00483 /* calculation of reciprocal value */ 00484 /* running approximation for two iterations */ 00485 for (i = 0; i < 2; i++) 00486 { 00487 tempVal = (q15_t) (((q31_t) in * out) >> 15); 00488 tempVal = 0x7FFF - tempVal; 00489 /* 1.15 with exp 1 */ 00490 out = (q15_t) (((q31_t) out * tempVal) >> 14); 00491 } 00492 00493 /* write output */ 00494 *dst = out; 00495 00496 /* return num of signbits of out = 1/in value */ 00497 return (signBits + 1); 00498 00499 } 00500 00501 00502 /* 00503 * @brief C custom defined intrinisic function for only M0 processors 00504 */ 00505 #if defined(ARM_MATH_CM0) 00506 00507 static __INLINE q31_t __SSAT( 00508 q31_t x, 00509 uint32_t y) 00510 { 00511 int32_t posMax, negMin; 00512 uint32_t i; 00513 00514 posMax = 1; 00515 for (i = 0; i < (y - 1); i++) 00516 { 00517 posMax = posMax * 2; 00518 } 00519 00520 if(x > 0) 00521 { 00522 posMax = (posMax - 1); 00523 00524 if(x > posMax) 00525 { 00526 x = posMax; 00527 } 00528 } 00529 else 00530 { 00531 negMin = -posMax; 00532 00533 if(x < negMin) 00534 { 00535 x = negMin; 00536 } 00537 } 00538 return (x); 00539 00540 00541 } 00542 00543 #endif /* end of ARM_MATH_CM0 */ 00544 00545 00546 00547 /* 00548 * @brief C custom defined intrinsic function for M3 and M0 processors 00549 */ 00550 #if defined (ARM_MATH_CM3) || defined (ARM_MATH_CM0) 00551 00552 /* 00553 * @brief C custom defined QADD8 for M3 and M0 processors 00554 */ 00555 static __INLINE q31_t __QADD8( 00556 q31_t x, 00557 q31_t y) 00558 { 00559 00560 q31_t sum; 00561 q7_t r, s, t, u; 00562 00563 r = (char) x; 00564 s = (char) y; 00565 00566 r = __SSAT((q31_t) (r + s), 8); 00567 s = __SSAT(((q31_t) (((x << 16) >> 24) + ((y << 16) >> 24))), 8); 00568 t = __SSAT(((q31_t) (((x << 8) >> 24) + ((y << 8) >> 24))), 8); 00569 u = __SSAT(((q31_t) ((x >> 24) + (y >> 24))), 8); 00570 00571 sum = (((q31_t) u << 24) & 0xFF000000) | (((q31_t) t << 16) & 0x00FF0000) | 00572 (((q31_t) s << 8) & 0x0000FF00) | (r & 0x000000FF); 00573 00574 return sum; 00575 00576 } 00577 00578 /* 00579 * @brief C custom defined QSUB8 for M3 and M0 processors 00580 */ 00581 static __INLINE q31_t __QSUB8( 00582 q31_t x, 00583 q31_t y) 00584 { 00585 00586 q31_t sum; 00587 q31_t r, s, t, u; 00588 00589 r = (char) x; 00590 s = (char) y; 00591 00592 r = __SSAT((r - s), 8); 00593 s = __SSAT(((q31_t) (((x << 16) >> 24) - ((y << 16) >> 24))), 8) << 8; 00594 t = __SSAT(((q31_t) (((x << 8) >> 24) - ((y << 8) >> 24))), 8) << 16; 00595 u = __SSAT(((q31_t) ((x >> 24) - (y >> 24))), 8) << 24; 00596 00597 sum = 00598 (u & 0xFF000000) | (t & 0x00FF0000) | (s & 0x0000FF00) | (r & 0x000000FF); 00599 00600 return sum; 00601 } 00602 00603 /* 00604 * @brief C custom defined QADD16 for M3 and M0 processors 00605 */ 00606 00607 /* 00608 * @brief C custom defined QADD16 for M3 and M0 processors 00609 */ 00610 static __INLINE q31_t __QADD16( 00611 q31_t x, 00612 q31_t y) 00613 { 00614 00615 q31_t sum; 00616 q31_t r, s; 00617 00618 r = (short) x; 00619 s = (short) y; 00620 00621 r = __SSAT(r + s, 16); 00622 s = __SSAT(((q31_t) ((x >> 16) + (y >> 16))), 16) << 16; 00623 00624 sum = (s & 0xFFFF0000) | (r & 0x0000FFFF); 00625 00626 return sum; 00627 00628 } 00629 00630 /* 00631 * @brief C custom defined SHADD16 for M3 and M0 processors 00632 */ 00633 static __INLINE q31_t __SHADD16( 00634 q31_t x, 00635 q31_t y) 00636 { 00637 00638 q31_t sum; 00639 q31_t r, s; 00640 00641 r = (short) x; 00642 s = (short) y; 00643 00644 r = ((r >> 1) + (s >> 1)); 00645 s = ((q31_t) ((x >> 17) + (y >> 17))) << 16; 00646 00647 sum = (s & 0xFFFF0000) | (r & 0x0000FFFF); 00648 00649 return sum; 00650 00651 } 00652 00653 /* 00654 * @brief C custom defined QSUB16 for M3 and M0 processors 00655 */ 00656 static __INLINE q31_t __QSUB16( 00657 q31_t x, 00658 q31_t y) 00659 { 00660 00661 q31_t sum; 00662 q31_t r, s; 00663 00664 r = (short) x; 00665 s = (short) y; 00666 00667 r = __SSAT(r - s, 16); 00668 s = __SSAT(((q31_t) ((x >> 16) - (y >> 16))), 16) << 16; 00669 00670 sum = (s & 0xFFFF0000) | (r & 0x0000FFFF); 00671 00672 return sum; 00673 } 00674 00675 /* 00676 * @brief C custom defined SHSUB16 for M3 and M0 processors 00677 */ 00678 static __INLINE q31_t __SHSUB16( 00679 q31_t x, 00680 q31_t y) 00681 { 00682 00683 q31_t diff; 00684 q31_t r, s; 00685 00686 r = (short) x; 00687 s = (short) y; 00688 00689 r = ((r >> 1) - (s >> 1)); 00690 s = (((x >> 17) - (y >> 17)) << 16); 00691 00692 diff = (s & 0xFFFF0000) | (r & 0x0000FFFF); 00693 00694 return diff; 00695 } 00696 00697 /* 00698 * @brief C custom defined QASX for M3 and M0 processors 00699 */ 00700 static __INLINE q31_t __QASX( 00701 q31_t x, 00702 q31_t y) 00703 { 00704 00705 q31_t sum = 0; 00706 00707 sum = ((sum + clip_q31_to_q15((q31_t) ((short) (x >> 16) + (short) y))) << 16) + 00708 clip_q31_to_q15((q31_t) ((short) x - (short) (y >> 16))); 00709 00710 return sum; 00711 } 00712 00713 /* 00714 * @brief C custom defined SHASX for M3 and M0 processors 00715 */ 00716 static __INLINE q31_t __SHASX( 00717 q31_t x, 00718 q31_t y) 00719 { 00720 00721 q31_t sum; 00722 q31_t r, s; 00723 00724 r = (short) x; 00725 s = (short) y; 00726 00727 r = ((r >> 1) - (y >> 17)); 00728 s = (((x >> 17) + (s >> 1)) << 16); 00729 00730 sum = (s & 0xFFFF0000) | (r & 0x0000FFFF); 00731 00732 return sum; 00733 } 00734 00735 00736 /* 00737 * @brief C custom defined QSAX for M3 and M0 processors 00738 */ 00739 static __INLINE q31_t __QSAX( 00740 q31_t x, 00741 q31_t y) 00742 { 00743 00744 q31_t sum = 0; 00745 00746 sum = ((sum + clip_q31_to_q15((q31_t) ((short) (x >> 16) - (short) y))) << 16) + 00747 clip_q31_to_q15((q31_t) ((short) x + (short) (y >> 16))); 00748 00749 return sum; 00750 } 00751 00752 /* 00753 * @brief C custom defined SHSAX for M3 and M0 processors 00754 */ 00755 static __INLINE q31_t __SHSAX( 00756 q31_t x, 00757 q31_t y) 00758 { 00759 00760 q31_t sum; 00761 q31_t r, s; 00762 00763 r = (short) x; 00764 s = (short) y; 00765 00766 r = ((r >> 1) + (y >> 17)); 00767 s = (((x >> 17) - (s >> 1)) << 16); 00768 00769 sum = (s & 0xFFFF0000) | (r & 0x0000FFFF); 00770 00771 return sum; 00772 } 00773 00774 /* 00775 * @brief C custom defined SMUSDX for M3 and M0 processors 00776 */ 00777 static __INLINE q31_t __SMUSDX( 00778 q31_t x, 00779 q31_t y) 00780 { 00781 00782 return ((q31_t)(((short) x * (short) (y >> 16)) - 00783 ((short) (x >> 16) * (short) y))); 00784 } 00785 00786 /* 00787 * @brief C custom defined SMUADX for M3 and M0 processors 00788 */ 00789 static __INLINE q31_t __SMUADX( 00790 q31_t x, 00791 q31_t y) 00792 { 00793 00794 return ((q31_t)(((short) x * (short) (y >> 16)) + 00795 ((short) (x >> 16) * (short) y))); 00796 } 00797 00798 /* 00799 * @brief C custom defined QADD for M3 and M0 processors 00800 */ 00801 static __INLINE q31_t __QADD( 00802 q31_t x, 00803 q31_t y) 00804 { 00805 return clip_q63_to_q31((q63_t) x + y); 00806 } 00807 00808 /* 00809 * @brief C custom defined QSUB for M3 and M0 processors 00810 */ 00811 static __INLINE q31_t __QSUB( 00812 q31_t x, 00813 q31_t y) 00814 { 00815 return clip_q63_to_q31((q63_t) x - y); 00816 } 00817 00818 /* 00819 * @brief C custom defined SMLAD for M3 and M0 processors 00820 */ 00821 static __INLINE q31_t __SMLAD( 00822 q31_t x, 00823 q31_t y, 00824 q31_t sum) 00825 { 00826 00827 return (sum + ((short) (x >> 16) * (short) (y >> 16)) + 00828 ((short) x * (short) y)); 00829 } 00830 00831 /* 00832 * @brief C custom defined SMLADX for M3 and M0 processors 00833 */ 00834 static __INLINE q31_t __SMLADX( 00835 q31_t x, 00836 q31_t y, 00837 q31_t sum) 00838 { 00839 00840 return (sum + ((short) (x >> 16) * (short) (y)) + 00841 ((short) x * (short) (y >> 16))); 00842 } 00843 00844 /* 00845 * @brief C custom defined SMLSDX for M3 and M0 processors 00846 */ 00847 static __INLINE q31_t __SMLSDX( 00848 q31_t x, 00849 q31_t y, 00850 q31_t sum) 00851 { 00852 00853 return (sum - ((short) (x >> 16) * (short) (y)) + 00854 ((short) x * (short) (y >> 16))); 00855 } 00856 00857 /* 00858 * @brief C custom defined SMLALD for M3 and M0 processors 00859 */ 00860 static __INLINE q63_t __SMLALD( 00861 q31_t x, 00862 q31_t y, 00863 q63_t sum) 00864 { 00865 00866 return (sum + ((short) (x >> 16) * (short) (y >> 16)) + 00867 ((short) x * (short) y)); 00868 } 00869 00870 /* 00871 * @brief C custom defined SMLALDX for M3 and M0 processors 00872 */ 00873 static __INLINE q63_t __SMLALDX( 00874 q31_t x, 00875 q31_t y, 00876 q63_t sum) 00877 { 00878 00879 return (sum + ((short) (x >> 16) * (short) y)) + 00880 ((short) x * (short) (y >> 16)); 00881 } 00882 00883 /* 00884 * @brief C custom defined SMUAD for M3 and M0 processors 00885 */ 00886 static __INLINE q31_t __SMUAD( 00887 q31_t x, 00888 q31_t y) 00889 { 00890 00891 return (((x >> 16) * (y >> 16)) + 00892 (((x << 16) >> 16) * ((y << 16) >> 16))); 00893 } 00894 00895 /* 00896 * @brief C custom defined SMUSD for M3 and M0 processors 00897 */ 00898 static __INLINE q31_t __SMUSD( 00899 q31_t x, 00900 q31_t y) 00901 { 00902 00903 return (-((x >> 16) * (y >> 16)) + 00904 (((x << 16) >> 16) * ((y << 16) >> 16))); 00905 } 00906 00907 00908 00909 00910 #endif /* (ARM_MATH_CM3) || defined (ARM_MATH_CM0) */ 00911 00912 00913 /** 00914 * @brief Instance structure for the Q7 FIR filter. 00915 */ 00916 typedef struct 00917 { 00918 uint16_t numTaps; /**< number of filter coefficients in the filter. */ 00919 q7_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 00920 q7_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ 00921 } arm_fir_instance_q7; 00922 00923 /** 00924 * @brief Instance structure for the Q15 FIR filter. 00925 */ 00926 typedef struct 00927 { 00928 uint16_t numTaps; /**< number of filter coefficients in the filter. */ 00929 q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 00930 q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ 00931 } arm_fir_instance_q15; 00932 00933 /** 00934 * @brief Instance structure for the Q31 FIR filter. 00935 */ 00936 typedef struct 00937 { 00938 uint16_t numTaps; /**< number of filter coefficients in the filter. */ 00939 q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 00940 q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ 00941 } arm_fir_instance_q31; 00942 00943 /** 00944 * @brief Instance structure for the floating-point FIR filter. 00945 */ 00946 typedef struct 00947 { 00948 uint16_t numTaps; /**< number of filter coefficients in the filter. */ 00949 float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 00950 float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ 00951 } arm_fir_instance_f32; 00952 00953 00954 /** 00955 * @brief Processing function for the Q7 FIR filter. 00956 * @param[in] *S points to an instance of the Q7 FIR filter structure. 00957 * @param[in] *pSrc points to the block of input data. 00958 * @param[out] *pDst points to the block of output data. 00959 * @param[in] blockSize number of samples to process. 00960 * @return none. 00961 */ 00962 void arm_fir_q7( 00963 const arm_fir_instance_q7 * S, 00964 q7_t * pSrc, 00965 q7_t * pDst, 00966 uint32_t blockSize); 00967 00968 00969 /** 00970 * @brief Initialization function for the Q7 FIR filter. 00971 * @param[in,out] *S points to an instance of the Q7 FIR structure. 00972 * @param[in] numTaps Number of filter coefficients in the filter. 00973 * @param[in] *pCoeffs points to the filter coefficients. 00974 * @param[in] *pState points to the state buffer. 00975 * @param[in] blockSize number of samples that are processed. 00976 * @return none 00977 */ 00978 void arm_fir_init_q7( 00979 arm_fir_instance_q7 * S, 00980 uint16_t numTaps, 00981 q7_t * pCoeffs, 00982 q7_t * pState, 00983 uint32_t blockSize); 00984 00985 00986 /** 00987 * @brief Processing function for the Q15 FIR filter. 00988 * @param[in] *S points to an instance of the Q15 FIR structure. 00989 * @param[in] *pSrc points to the block of input data. 00990 * @param[out] *pDst points to the block of output data. 00991 * @param[in] blockSize number of samples to process. 00992 * @return none. 00993 */ 00994 void arm_fir_q15( 00995 const arm_fir_instance_q15 * S, 00996 q15_t * pSrc, 00997 q15_t * pDst, 00998 uint32_t blockSize); 00999 01000 /** 01001 * @brief Processing function for the fast Q15 FIR filter. 01002 * @param[in] *S points to an instance of the Q15 FIR filter structure. 01003 * @param[in] *pSrc points to the block of input data. 01004 * @param[out] *pDst points to the block of output data. 01005 * @param[in] blockSize number of samples to process. 01006 * @return none. 01007 */ 01008 void arm_fir_fast_q15( 01009 const arm_fir_instance_q15 * S, 01010 q15_t * pSrc, 01011 q15_t * pDst, 01012 uint32_t blockSize); 01013 01014 /** 01015 * @brief Initialization function for the Q15 FIR filter. 01016 * @param[in,out] *S points to an instance of the Q15 FIR filter structure. 01017 * @param[in] numTaps Number of filter coefficients in the filter. Must be even and greater than or equal to 4. 01018 * @param[in] *pCoeffs points to the filter coefficients. 01019 * @param[in] *pState points to the state buffer. 01020 * @param[in] blockSize number of samples that are processed at a time. 01021 * @return The function returns ARM_MATH_SUCCESS if initialization was successful or ARM_MATH_ARGUMENT_ERROR if 01022 * <code>numTaps</code> is not a supported value. 01023 */ 01024 arm_status arm_fir_init_q15( 01025 arm_fir_instance_q15 * S, 01026 uint16_t numTaps, 01027 q15_t * pCoeffs, 01028 q15_t * pState, 01029 uint32_t blockSize); 01030 01031 01032 /** 01033 * @brief Processing function for the Q31 FIR filter. 01034 * @param[in] *S points to an instance of the Q31 FIR filter structure. 01035 * @param[in] *pSrc points to the block of input data. 01036 * @param[out] *pDst points to the block of output data. 01037 * @param[in] blockSize number of samples to process. 01038 * @return none. 01039 */ 01040 void arm_fir_q31( 01041 const arm_fir_instance_q31 * S, 01042 q31_t * pSrc, 01043 q31_t * pDst, 01044 uint32_t blockSize); 01045 01046 /** 01047 * @brief Processing function for the fast Q31 FIR filter. 01048 * @param[in] *S points to an instance of the Q31 FIR structure. 01049 * @param[in] *pSrc points to the block of input data. 01050 * @param[out] *pDst points to the block of output data. 01051 * @param[in] blockSize number of samples to process. 01052 * @return none. 01053 */ 01054 void arm_fir_fast_q31( 01055 const arm_fir_instance_q31 * S, 01056 q31_t * pSrc, 01057 q31_t * pDst, 01058 uint32_t blockSize); 01059 01060 /** 01061 * @brief Initialization function for the Q31 FIR filter. 01062 * @param[in,out] *S points to an instance of the Q31 FIR structure. 01063 * @param[in] numTaps Number of filter coefficients in the filter. 01064 * @param[in] *pCoeffs points to the filter coefficients. 01065 * @param[in] *pState points to the state buffer. 01066 * @param[in] blockSize number of samples that are processed at a time. 01067 * @return none. 01068 */ 01069 void arm_fir_init_q31( 01070 arm_fir_instance_q31 * S, 01071 uint16_t numTaps, 01072 q31_t * pCoeffs, 01073 q31_t * pState, 01074 uint32_t blockSize); 01075 01076 /** 01077 * @brief Processing function for the floating-point FIR filter. 01078 * @param[in] *S points to an instance of the floating-point FIR structure. 01079 * @param[in] *pSrc points to the block of input data. 01080 * @param[out] *pDst points to the block of output data. 01081 * @param[in] blockSize number of samples to process. 01082 * @return none. 01083 */ 01084 void arm_fir_f32( 01085 const arm_fir_instance_f32 * S, 01086 float32_t * pSrc, 01087 float32_t * pDst, 01088 uint32_t blockSize); 01089 01090 /** 01091 * @brief Initialization function for the floating-point FIR filter. 01092 * @param[in,out] *S points to an instance of the floating-point FIR filter structure. 01093 * @param[in] numTaps Number of filter coefficients in the filter. 01094 * @param[in] *pCoeffs points to the filter coefficients. 01095 * @param[in] *pState points to the state buffer. 01096 * @param[in] blockSize number of samples that are processed at a time. 01097 * @return none. 01098 */ 01099 void arm_fir_init_f32( 01100 arm_fir_instance_f32 * S, 01101 uint16_t numTaps, 01102 float32_t * pCoeffs, 01103 float32_t * pState, 01104 uint32_t blockSize); 01105 01106 01107 /** 01108 * @brief Instance structure for the Q15 Biquad cascade filter. 01109 */ 01110 typedef struct 01111 { 01112 int8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */ 01113 q15_t *pState; /**< Points to the array of state coefficients. The array is of length 4*numStages. */ 01114 q15_t *pCoeffs; /**< Points to the array of coefficients. The array is of length 5*numStages. */ 01115 int8_t postShift; /**< Additional shift, in bits, applied to each output sample. */ 01116 01117 } arm_biquad_casd_df1_inst_q15; 01118 01119 01120 /** 01121 * @brief Instance structure for the Q31 Biquad cascade filter. 01122 */ 01123 typedef struct 01124 { 01125 uint32_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */ 01126 q31_t *pState; /**< Points to the array of state coefficients. The array is of length 4*numStages. */ 01127 q31_t *pCoeffs; /**< Points to the array of coefficients. The array is of length 5*numStages. */ 01128 uint8_t postShift; /**< Additional shift, in bits, applied to each output sample. */ 01129 01130 } arm_biquad_casd_df1_inst_q31; 01131 01132 /** 01133 * @brief Instance structure for the floating-point Biquad cascade filter. 01134 */ 01135 typedef struct 01136 { 01137 uint32_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */ 01138 float32_t *pState; /**< Points to the array of state coefficients. The array is of length 4*numStages. */ 01139 float32_t *pCoeffs; /**< Points to the array of coefficients. The array is of length 5*numStages. */ 01140 01141 01142 } arm_biquad_casd_df1_inst_f32; 01143 01144 01145 01146 /** 01147 * @brief Processing function for the Q15 Biquad cascade filter. 01148 * @param[in] *S points to an instance of the Q15 Biquad cascade structure. 01149 * @param[in] *pSrc points to the block of input data. 01150 * @param[out] *pDst points to the block of output data. 01151 * @param[in] blockSize number of samples to process. 01152 * @return none. 01153 */ 01154 01155 void arm_biquad_cascade_df1_q15( 01156 const arm_biquad_casd_df1_inst_q15 * S, 01157 q15_t * pSrc, 01158 q15_t * pDst, 01159 uint32_t blockSize); 01160 01161 /** 01162 * @brief Initialization function for the Q15 Biquad cascade filter. 01163 * @param[in,out] *S points to an instance of the Q15 Biquad cascade structure. 01164 * @param[in] numStages number of 2nd order stages in the filter. 01165 * @param[in] *pCoeffs points to the filter coefficients. 01166 * @param[in] *pState points to the state buffer. 01167 * @param[in] postShift Shift to be applied to the output. Varies according to the coefficients format 01168 * @return none 01169 */ 01170 01171 void arm_biquad_cascade_df1_init_q15( 01172 arm_biquad_casd_df1_inst_q15 * S, 01173 uint8_t numStages, 01174 q15_t * pCoeffs, 01175 q15_t * pState, 01176 int8_t postShift); 01177 01178 01179 /** 01180 * @brief Fast but less precise processing function for the Q15 Biquad cascade filter. 01181 * @param[in] *S points to an instance of the Q15 Biquad cascade structure. 01182 * @param[in] *pSrc points to the block of input data. 01183 * @param[out] *pDst points to the block of output data. 01184 * @param[in] blockSize number of samples to process. 01185 * @return none. 01186 */ 01187 01188 void arm_biquad_cascade_df1_fast_q15( 01189 const arm_biquad_casd_df1_inst_q15 * S, 01190 q15_t * pSrc, 01191 q15_t * pDst, 01192 uint32_t blockSize); 01193 01194 01195 /** 01196 * @brief Processing function for the Q31 Biquad cascade filter 01197 * @param[in] *S points to an instance of the Q31 Biquad cascade structure. 01198 * @param[in] *pSrc points to the block of input data. 01199 * @param[out] *pDst points to the block of output data. 01200 * @param[in] blockSize number of samples to process. 01201 * @return none. 01202 */ 01203 01204 void arm_biquad_cascade_df1_q31( 01205 const arm_biquad_casd_df1_inst_q31 * S, 01206 q31_t * pSrc, 01207 q31_t * pDst, 01208 uint32_t blockSize); 01209 01210 /** 01211 * @brief Fast but less precise processing function for the Q31 Biquad cascade filter. 01212 * @param[in] *S points to an instance of the Q31 Biquad cascade structure. 01213 * @param[in] *pSrc points to the block of input data. 01214 * @param[out] *pDst points to the block of output data. 01215 * @param[in] blockSize number of samples to process. 01216 * @return none. 01217 */ 01218 01219 void arm_biquad_cascade_df1_fast_q31( 01220 const arm_biquad_casd_df1_inst_q31 * S, 01221 q31_t * pSrc, 01222 q31_t * pDst, 01223 uint32_t blockSize); 01224 01225 /** 01226 * @brief Initialization function for the Q31 Biquad cascade filter. 01227 * @param[in,out] *S points to an instance of the Q31 Biquad cascade structure. 01228 * @param[in] numStages number of 2nd order stages in the filter. 01229 * @param[in] *pCoeffs points to the filter coefficients. 01230 * @param[in] *pState points to the state buffer. 01231 * @param[in] postShift Shift to be applied to the output. Varies according to the coefficients format 01232 * @return none 01233 */ 01234 01235 void arm_biquad_cascade_df1_init_q31( 01236 arm_biquad_casd_df1_inst_q31 * S, 01237 uint8_t numStages, 01238 q31_t * pCoeffs, 01239 q31_t * pState, 01240 int8_t postShift); 01241 01242 /** 01243 * @brief Processing function for the floating-point Biquad cascade filter. 01244 * @param[in] *S points to an instance of the floating-point Biquad cascade structure. 01245 * @param[in] *pSrc points to the block of input data. 01246 * @param[out] *pDst points to the block of output data. 01247 * @param[in] blockSize number of samples to process. 01248 * @return none. 01249 */ 01250 01251 void arm_biquad_cascade_df1_f32( 01252 const arm_biquad_casd_df1_inst_f32 * S, 01253 float32_t * pSrc, 01254 float32_t * pDst, 01255 uint32_t blockSize); 01256 01257 /** 01258 * @brief Initialization function for the floating-point Biquad cascade filter. 01259 * @param[in,out] *S points to an instance of the floating-point Biquad cascade structure. 01260 * @param[in] numStages number of 2nd order stages in the filter. 01261 * @param[in] *pCoeffs points to the filter coefficients. 01262 * @param[in] *pState points to the state buffer. 01263 * @return none 01264 */ 01265 01266 void arm_biquad_cascade_df1_init_f32( 01267 arm_biquad_casd_df1_inst_f32 * S, 01268 uint8_t numStages, 01269 float32_t * pCoeffs, 01270 float32_t * pState); 01271 01272 01273 /** 01274 * @brief Instance structure for the floating-point matrix structure. 01275 */ 01276 01277 typedef struct 01278 { 01279 uint16_t numRows; /**< number of rows of the matrix. */ 01280 uint16_t numCols; /**< number of columns of the matrix. */ 01281 float32_t *pData; /**< points to the data of the matrix. */ 01282 } arm_matrix_instance_f32; 01283 01284 /** 01285 * @brief Instance structure for the Q15 matrix structure. 01286 */ 01287 01288 typedef struct 01289 { 01290 uint16_t numRows; /**< number of rows of the matrix. */ 01291 uint16_t numCols; /**< number of columns of the matrix. */ 01292 q15_t *pData; /**< points to the data of the matrix. */ 01293 01294 } arm_matrix_instance_q15; 01295 01296 /** 01297 * @brief Instance structure for the Q31 matrix structure. 01298 */ 01299 01300 typedef struct 01301 { 01302 uint16_t numRows; /**< number of rows of the matrix. */ 01303 uint16_t numCols; /**< number of columns of the matrix. */ 01304 q31_t *pData; /**< points to the data of the matrix. */ 01305 01306 } arm_matrix_instance_q31; 01307 01308 01309 01310 /** 01311 * @brief Floating-point matrix addition. 01312 * @param[in] *pSrcA points to the first input matrix structure 01313 * @param[in] *pSrcB points to the second input matrix structure 01314 * @param[out] *pDst points to output matrix structure 01315 * @return The function returns either 01316 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS based on the outcome of size checking. 01317 */ 01318 01319 arm_status arm_mat_add_f32( 01320 const arm_matrix_instance_f32 * pSrcA, 01321 const arm_matrix_instance_f32 * pSrcB, 01322 arm_matrix_instance_f32 * pDst); 01323 01324 /** 01325 * @brief Q15 matrix addition. 01326 * @param[in] *pSrcA points to the first input matrix structure 01327 * @param[in] *pSrcB points to the second input matrix structure 01328 * @param[out] *pDst points to output matrix structure 01329 * @return The function returns either 01330 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS based on the outcome of size checking. 01331 */ 01332 01333 arm_status arm_mat_add_q15( 01334 const arm_matrix_instance_q15 * pSrcA, 01335 const arm_matrix_instance_q15 * pSrcB, 01336 arm_matrix_instance_q15 * pDst); 01337 01338 /** 01339 * @brief Q31 matrix addition. 01340 * @param[in] *pSrcA points to the first input matrix structure 01341 * @param[in] *pSrcB points to the second input matrix structure 01342 * @param[out] *pDst points to output matrix structure 01343 * @return The function returns either 01344 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS based on the outcome of size checking. 01345 */ 01346 01347 arm_status arm_mat_add_q31( 01348 const arm_matrix_instance_q31 * pSrcA, 01349 const arm_matrix_instance_q31 * pSrcB, 01350 arm_matrix_instance_q31 * pDst); 01351 01352 01353 /** 01354 * @brief Floating-point matrix transpose. 01355 * @param[in] *pSrc points to the input matrix 01356 * @param[out] *pDst points to the output matrix 01357 * @return The function returns either <code>ARM_MATH_SIZE_MISMATCH</code> 01358 * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. 01359 */ 01360 01361 arm_status arm_mat_trans_f32( 01362 const arm_matrix_instance_f32 * pSrc, 01363 arm_matrix_instance_f32 * pDst); 01364 01365 01366 /** 01367 * @brief Q15 matrix transpose. 01368 * @param[in] *pSrc points to the input matrix 01369 * @param[out] *pDst points to the output matrix 01370 * @return The function returns either <code>ARM_MATH_SIZE_MISMATCH</code> 01371 * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. 01372 */ 01373 01374 arm_status arm_mat_trans_q15( 01375 const arm_matrix_instance_q15 * pSrc, 01376 arm_matrix_instance_q15 * pDst); 01377 01378 /** 01379 * @brief Q31 matrix transpose. 01380 * @param[in] *pSrc points to the input matrix 01381 * @param[out] *pDst points to the output matrix 01382 * @return The function returns either <code>ARM_MATH_SIZE_MISMATCH</code> 01383 * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. 01384 */ 01385 01386 arm_status arm_mat_trans_q31( 01387 const arm_matrix_instance_q31 * pSrc, 01388 arm_matrix_instance_q31 * pDst); 01389 01390 01391 /** 01392 * @brief Floating-point matrix multiplication 01393 * @param[in] *pSrcA points to the first input matrix structure 01394 * @param[in] *pSrcB points to the second input matrix structure 01395 * @param[out] *pDst points to output matrix structure 01396 * @return The function returns either 01397 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS based on the outcome of size checking. 01398 */ 01399 01400 arm_status arm_mat_mult_f32( 01401 const arm_matrix_instance_f32 * pSrcA, 01402 const arm_matrix_instance_f32 * pSrcB, 01403 arm_matrix_instance_f32 * pDst); 01404 01405 /** 01406 * @brief Q15 matrix multiplication 01407 * @param[in] *pSrcA points to the first input matrix structure 01408 * @param[in] *pSrcB points to the second input matrix structure 01409 * @param[out] *pDst points to output matrix structure 01410 * @return The function returns either 01411 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS based on the outcome of size checking. 01412 */ 01413 01414 arm_status arm_mat_mult_q15( 01415 const arm_matrix_instance_q15 * pSrcA, 01416 const arm_matrix_instance_q15 * pSrcB, 01417 arm_matrix_instance_q15 * pDst, 01418 q15_t * pState); 01419 01420 /** 01421 * @brief Q15 matrix multiplication (fast variant) 01422 * @param[in] *pSrcA points to the first input matrix structure 01423 * @param[in] *pSrcB points to the second input matrix structure 01424 * @param[out] *pDst points to output matrix structure 01425 * @return The function returns either 01426 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS based on the outcome of size checking. 01427 */ 01428 01429 arm_status arm_mat_mult_fast_q15( 01430 const arm_matrix_instance_q15 * pSrcA, 01431 const arm_matrix_instance_q15 * pSrcB, 01432 arm_matrix_instance_q15 * pDst, 01433 q15_t * pState); 01434 01435 /** 01436 * @brief Q31 matrix multiplication 01437 * @param[in] *pSrcA points to the first input matrix structure 01438 * @param[in] *pSrcB points to the second input matrix structure 01439 * @param[out] *pDst points to output matrix structure 01440 * @return The function returns either 01441 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS based on the outcome of size checking. 01442 */ 01443 01444 arm_status arm_mat_mult_q31( 01445 const arm_matrix_instance_q31 * pSrcA, 01446 const arm_matrix_instance_q31 * pSrcB, 01447 arm_matrix_instance_q31 * pDst); 01448 01449 /** 01450 * @brief Q31 matrix multiplication (fast variant) 01451 * @param[in] *pSrcA points to the first input matrix structure 01452 * @param[in] *pSrcB points to the second input matrix structure 01453 * @param[out] *pDst points to output matrix structure 01454 * @return The function returns either 01455 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS based on the outcome of size checking. 01456 */ 01457 01458 arm_status arm_mat_mult_fast_q31( 01459 const arm_matrix_instance_q31 * pSrcA, 01460 const arm_matrix_instance_q31 * pSrcB, 01461 arm_matrix_instance_q31 * pDst); 01462 01463 01464 /** 01465 * @brief Floating-point matrix subtraction 01466 * @param[in] *pSrcA points to the first input matrix structure 01467 * @param[in] *pSrcB points to the second input matrix structure 01468 * @param[out] *pDst points to output matrix structure 01469 * @return The function returns either 01470 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS based on the outcome of size checking. 01471 */ 01472 01473 arm_status arm_mat_sub_f32( 01474 const arm_matrix_instance_f32 * pSrcA, 01475 const arm_matrix_instance_f32 * pSrcB, 01476 arm_matrix_instance_f32 * pDst); 01477 01478 /** 01479 * @brief Q15 matrix subtraction 01480 * @param[in] *pSrcA points to the first input matrix structure 01481 * @param[in] *pSrcB points to the second input matrix structure 01482 * @param[out] *pDst points to output matrix structure 01483 * @return The function returns either 01484 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS based on the outcome of size checking. 01485 */ 01486 01487 arm_status arm_mat_sub_q15( 01488 const arm_matrix_instance_q15 * pSrcA, 01489 const arm_matrix_instance_q15 * pSrcB, 01490 arm_matrix_instance_q15 * pDst); 01491 01492 /** 01493 * @brief Q31 matrix subtraction 01494 * @param[in] *pSrcA points to the first input matrix structure 01495 * @param[in] *pSrcB points to the second input matrix structure 01496 * @param[out] *pDst points to output matrix structure 01497 * @return The function returns either 01498 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS based on the outcome of size checking. 01499 */ 01500 01501 arm_status arm_mat_sub_q31( 01502 const arm_matrix_instance_q31 * pSrcA, 01503 const arm_matrix_instance_q31 * pSrcB, 01504 arm_matrix_instance_q31 * pDst); 01505 01506 /** 01507 * @brief Floating-point matrix scaling. 01508 * @param[in] *pSrc points to the input matrix 01509 * @param[in] scale scale factor 01510 * @param[out] *pDst points to the output matrix 01511 * @return The function returns either 01512 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS based on the outcome of size checking. 01513 */ 01514 01515 arm_status arm_mat_scale_f32( 01516 const arm_matrix_instance_f32 * pSrc, 01517 float32_t scale, 01518 arm_matrix_instance_f32 * pDst); 01519 01520 /** 01521 * @brief Q15 matrix scaling. 01522 * @param[in] *pSrc points to input matrix 01523 * @param[in] scaleFract fractional portion of the scale factor 01524 * @param[in] shift number of bits to shift the result by 01525 * @param[out] *pDst points to output matrix 01526 * @return The function returns either 01527 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS based on the outcome of size checking. 01528 */ 01529 01530 arm_status arm_mat_scale_q15( 01531 const arm_matrix_instance_q15 * pSrc, 01532 q15_t scaleFract, 01533 int32_t shift, 01534 arm_matrix_instance_q15 * pDst); 01535 01536 /** 01537 * @brief Q31 matrix scaling. 01538 * @param[in] *pSrc points to input matrix 01539 * @param[in] scaleFract fractional portion of the scale factor 01540 * @param[in] shift number of bits to shift the result by 01541 * @param[out] *pDst points to output matrix structure 01542 * @return The function returns either 01543 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS based on the outcome of size checking. 01544 */ 01545 01546 arm_status arm_mat_scale_q31( 01547 const arm_matrix_instance_q31 * pSrc, 01548 q31_t scaleFract, 01549 int32_t shift, 01550 arm_matrix_instance_q31 * pDst); 01551 01552 01553 /** 01554 * @brief Q31 matrix initialization. 01555 * @param[in,out] *S points to an instance of the floating-point matrix structure. 01556 * @param[in] nRows number of rows in the matrix. 01557 * @param[in] nColumns number of columns in the matrix. 01558 * @param[in] *pData points to the matrix data array. 01559 * @return none 01560 */ 01561 01562 void arm_mat_init_q31( 01563 arm_matrix_instance_q31 * S, 01564 uint16_t nRows, 01565 uint16_t nColumns, 01566 q31_t *pData); 01567 01568 /** 01569 * @brief Q15 matrix initialization. 01570 * @param[in,out] *S points to an instance of the floating-point matrix structure. 01571 * @param[in] nRows number of rows in the matrix. 01572 * @param[in] nColumns number of columns in the matrix. 01573 * @param[in] *pData points to the matrix data array. 01574 * @return none 01575 */ 01576 01577 void arm_mat_init_q15( 01578 arm_matrix_instance_q15 * S, 01579 uint16_t nRows, 01580 uint16_t nColumns, 01581 q15_t *pData); 01582 01583 /** 01584 * @brief Floating-point matrix initialization. 01585 * @param[in,out] *S points to an instance of the floating-point matrix structure. 01586 * @param[in] nRows number of rows in the matrix. 01587 * @param[in] nColumns number of columns in the matrix. 01588 * @param[in] *pData points to the matrix data array. 01589 * @return none 01590 */ 01591 01592 void arm_mat_init_f32( 01593 arm_matrix_instance_f32 * S, 01594 uint16_t nRows, 01595 uint16_t nColumns, 01596 float32_t *pData); 01597 01598 01599 01600 /** 01601 * @brief Instance structure for the Q15 PID Control. 01602 */ 01603 typedef struct 01604 { 01605 q15_t A0; /**< The derived gain, A0 = Kp + Ki + Kd . */ 01606 q31_t A1; /**< The derived gain A1 = -Kp - 2Kd | Kd. */ 01607 q15_t state[3]; /**< The state array of length 3. */ 01608 q15_t Kp; /**< The proportional gain. */ 01609 q15_t Ki; /**< The integral gain. */ 01610 q15_t Kd; /**< The derivative gain. */ 01611 } arm_pid_instance_q15; 01612 01613 /** 01614 * @brief Instance structure for the Q31 PID Control. 01615 */ 01616 typedef struct 01617 { 01618 q31_t A0; /**< The derived gain, A0 = Kp + Ki + Kd . */ 01619 q31_t A1; /**< The derived gain, A1 = -Kp - 2Kd. */ 01620 q31_t A2; /**< The derived gain, A2 = Kd . */ 01621 q31_t state[3]; /**< The state array of length 3. */ 01622 q31_t Kp; /**< The proportional gain. */ 01623 q31_t Ki; /**< The integral gain. */ 01624 q31_t Kd; /**< The derivative gain. */ 01625 01626 } arm_pid_instance_q31; 01627 01628 /** 01629 * @brief Instance structure for the floating-point PID Control. 01630 */ 01631 typedef struct 01632 { 01633 float32_t A0; /**< The derived gain, A0 = Kp + Ki + Kd . */ 01634 float32_t A1; /**< The derived gain, A1 = -Kp - 2Kd. */ 01635 float32_t A2; /**< The derived gain, A2 = Kd . */ 01636 float32_t state[3]; /**< The state array of length 3. */ 01637 float32_t Kp; /**< The proportional gain. */ 01638 float32_t Ki; /**< The integral gain. */ 01639 float32_t Kd; /**< The derivative gain. */ 01640 } arm_pid_instance_f32; 01641 01642 01643 01644 /** 01645 * @brief Initialization function for the floating-point PID Control. 01646 * @param[in,out] *S points to an instance of the PID structure. 01647 * @param[in] resetStateFlag flag to reset the state. 0 = no change in state 1 = reset the state. 01648 * @return none. 01649 */ 01650 void arm_pid_init_f32( 01651 arm_pid_instance_f32 * S, 01652 int32_t resetStateFlag); 01653 01654 /** 01655 * @brief Reset function for the floating-point PID Control. 01656 * @param[in,out] *S is an instance of the floating-point PID Control structure 01657 * @return none 01658 */ 01659 void arm_pid_reset_f32( 01660 arm_pid_instance_f32 * S); 01661 01662 01663 /** 01664 * @brief Initialization function for the Q31 PID Control. 01665 * @param[in,out] *S points to an instance of the Q15 PID structure. 01666 * @param[in] resetStateFlag flag to reset the state. 0 = no change in state 1 = reset the state. 01667 * @return none. 01668 */ 01669 void arm_pid_init_q31( 01670 arm_pid_instance_q31 * S, 01671 int32_t resetStateFlag); 01672 01673 01674 /** 01675 * @brief Reset function for the Q31 PID Control. 01676 * @param[in,out] *S points to an instance of the Q31 PID Control structure 01677 * @return none 01678 */ 01679 01680 void arm_pid_reset_q31( 01681 arm_pid_instance_q31 * S); 01682 01683 /** 01684 * @brief Initialization function for the Q15 PID Control. 01685 * @param[in,out] *S points to an instance of the Q15 PID structure. 01686 * @param[in] resetStateFlag flag to reset the state. 0 = no change in state 1 = reset the state. 01687 * @return none. 01688 */ 01689 void arm_pid_init_q15( 01690 arm_pid_instance_q15 * S, 01691 int32_t resetStateFlag); 01692 01693 /** 01694 * @brief Reset function for the Q15 PID Control. 01695 * @param[in,out] *S points to an instance of the q15 PID Control structure 01696 * @return none 01697 */ 01698 void arm_pid_reset_q15( 01699 arm_pid_instance_q15 * S); 01700 01701 01702 /** 01703 * @brief Instance structure for the floating-point Linear Interpolate function. 01704 */ 01705 typedef struct 01706 { 01707 uint32_t nValues; 01708 float32_t x1; 01709 float32_t xSpacing; 01710 float32_t *pYData; /**< pointer to the table of Y values */ 01711 } arm_linear_interp_instance_f32; 01712 01713 /** 01714 * @brief Instance structure for the floating-point bilinear interpolation function. 01715 */ 01716 01717 typedef struct 01718 { 01719 uint16_t numRows; /**< number of rows in the data table. */ 01720 uint16_t numCols; /**< number of columns in the data table. */ 01721 float32_t *pData; /**< points to the data table. */ 01722 } arm_bilinear_interp_instance_f32; 01723 01724 /** 01725 * @brief Instance structure for the Q31 bilinear interpolation function. 01726 */ 01727 01728 typedef struct 01729 { 01730 uint16_t numRows; /**< number of rows in the data table. */ 01731 uint16_t numCols; /**< number of columns in the data table. */ 01732 q31_t *pData; /**< points to the data table. */ 01733 } arm_bilinear_interp_instance_q31; 01734 01735 /** 01736 * @brief Instance structure for the Q15 bilinear interpolation function. 01737 */ 01738 01739 typedef struct 01740 { 01741 uint16_t numRows; /**< number of rows in the data table. */ 01742 uint16_t numCols; /**< number of columns in the data table. */ 01743 q15_t *pData; /**< points to the data table. */ 01744 } arm_bilinear_interp_instance_q15; 01745 01746 /** 01747 * @brief Instance structure for the Q15 bilinear interpolation function. 01748 */ 01749 01750 typedef struct 01751 { 01752 uint16_t numRows; /**< number of rows in the data table. */ 01753 uint16_t numCols; /**< number of columns in the data table. */ 01754 q7_t *pData; /**< points to the data table. */ 01755 } arm_bilinear_interp_instance_q7; 01756 01757 01758 /** 01759 * @brief Q7 vector multiplication. 01760 * @param[in] *pSrcA points to the first input vector 01761 * @param[in] *pSrcB points to the second input vector 01762 * @param[out] *pDst points to the output vector 01763 * @param[in] blockSize number of samples in each vector 01764 * @return none. 01765 */ 01766 01767 void arm_mult_q7( 01768 q7_t * pSrcA, 01769 q7_t * pSrcB, 01770 q7_t * pDst, 01771 uint32_t blockSize); 01772 01773 /** 01774 * @brief Q15 vector multiplication. 01775 * @param[in] *pSrcA points to the first input vector 01776 * @param[in] *pSrcB points to the second input vector 01777 * @param[out] *pDst points to the output vector 01778 * @param[in] blockSize number of samples in each vector 01779 * @return none. 01780 */ 01781 01782 void arm_mult_q15( 01783 q15_t * pSrcA, 01784 q15_t * pSrcB, 01785 q15_t * pDst, 01786 uint32_t blockSize); 01787 01788 /** 01789 * @brief Q31 vector multiplication. 01790 * @param[in] *pSrcA points to the first input vector 01791 * @param[in] *pSrcB points to the second input vector 01792 * @param[out] *pDst points to the output vector 01793 * @param[in] blockSize number of samples in each vector 01794 * @return none. 01795 */ 01796 01797 void arm_mult_q31( 01798 q31_t * pSrcA, 01799 q31_t * pSrcB, 01800 q31_t * pDst, 01801 uint32_t blockSize); 01802 01803 /** 01804 * @brief Floating-point vector multiplication. 01805 * @param[in] *pSrcA points to the first input vector 01806 * @param[in] *pSrcB points to the second input vector 01807 * @param[out] *pDst points to the output vector 01808 * @param[in] blockSize number of samples in each vector 01809 * @return none. 01810 */ 01811 01812 void arm_mult_f32( 01813 float32_t * pSrcA, 01814 float32_t * pSrcB, 01815 float32_t * pDst, 01816 uint32_t blockSize); 01817 01818 01819 /** 01820 * @brief Instance structure for the Q15 CFFT/CIFFT function. 01821 */ 01822 01823 typedef struct 01824 { 01825 uint16_t fftLen; /**< length of the FFT. */ 01826 uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */ 01827 uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */ 01828 q15_t *pTwiddle; /**< points to the twiddle factor table. */ 01829 uint16_t *pBitRevTable; /**< points to the bit reversal table. */ 01830 uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */ 01831 uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */ 01832 } arm_cfft_radix4_instance_q15; 01833 01834 /** 01835 * @brief Instance structure for the Q31 CFFT/CIFFT function. 01836 */ 01837 01838 typedef struct 01839 { 01840 uint16_t fftLen; /**< length of the FFT. */ 01841 uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */ 01842 uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */ 01843 q31_t *pTwiddle; /**< points to the twiddle factor table. */ 01844 uint16_t *pBitRevTable; /**< points to the bit reversal table. */ 01845 uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */ 01846 uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */ 01847 } arm_cfft_radix4_instance_q31; 01848 01849 /** 01850 * @brief Instance structure for the floating-point CFFT/CIFFT function. 01851 */ 01852 01853 typedef struct 01854 { 01855 uint16_t fftLen; /**< length of the FFT. */ 01856 uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */ 01857 uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */ 01858 float32_t *pTwiddle; /**< points to the twiddle factor table. */ 01859 uint16_t *pBitRevTable; /**< points to the bit reversal table. */ 01860 uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */ 01861 uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */ 01862 float32_t onebyfftLen; /**< value of 1/fftLen. */ 01863 } arm_cfft_radix4_instance_f32; 01864 01865 /** 01866 * @brief Processing function for the Q15 CFFT/CIFFT. 01867 * @param[in] *S points to an instance of the Q15 CFFT/CIFFT structure. 01868 * @param[in, out] *pSrc points to the complex data buffer. Processing occurs in-place. 01869 * @return none. 01870 */ 01871 01872 void arm_cfft_radix4_q15( 01873 const arm_cfft_radix4_instance_q15 * S, 01874 q15_t * pSrc); 01875 01876 /** 01877 * @brief Initialization function for the Q15 CFFT/CIFFT. 01878 * @param[in,out] *S points to an instance of the Q15 CFFT/CIFFT structure. 01879 * @param[in] fftLen length of the FFT. 01880 * @param[in] ifftFlag flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. 01881 * @param[in] bitReverseFlag flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. 01882 * @return arm_status function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if <code>fftLen</code> is not a supported value. 01883 */ 01884 01885 arm_status arm_cfft_radix4_init_q15( 01886 arm_cfft_radix4_instance_q15 * S, 01887 uint16_t fftLen, 01888 uint8_t ifftFlag, 01889 uint8_t bitReverseFlag); 01890 01891 /** 01892 * @brief Processing function for the Q31 CFFT/CIFFT. 01893 * @param[in] *S points to an instance of the Q31 CFFT/CIFFT structure. 01894 * @param[in, out] *pSrc points to the complex data buffer. Processing occurs in-place. 01895 * @return none. 01896 */ 01897 01898 void arm_cfft_radix4_q31( 01899 const arm_cfft_radix4_instance_q31 * S, 01900 q31_t * pSrc); 01901 01902 /** 01903 * @brief Initialization function for the Q31 CFFT/CIFFT. 01904 * @param[in,out] *S points to an instance of the Q31 CFFT/CIFFT structure. 01905 * @param[in] fftLen length of the FFT. 01906 * @param[in] ifftFlag flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. 01907 * @param[in] bitReverseFlag flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. 01908 * @return arm_status function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if <code>fftLen</code> is not a supported value. 01909 */ 01910 01911 arm_status arm_cfft_radix4_init_q31( 01912 arm_cfft_radix4_instance_q31 * S, 01913 uint16_t fftLen, 01914 uint8_t ifftFlag, 01915 uint8_t bitReverseFlag); 01916 01917 /** 01918 * @brief Processing function for the floating-point CFFT/CIFFT. 01919 * @param[in] *S points to an instance of the floating-point CFFT/CIFFT structure. 01920 * @param[in, out] *pSrc points to the complex data buffer. Processing occurs in-place. 01921 * @return none. 01922 */ 01923 01924 void arm_cfft_radix4_f32( 01925 const arm_cfft_radix4_instance_f32 * S, 01926 float32_t * pSrc); 01927 01928 /** 01929 * @brief Initialization function for the floating-point CFFT/CIFFT. 01930 * @param[in,out] *S points to an instance of the floating-point CFFT/CIFFT structure. 01931 * @param[in] fftLen length of the FFT. 01932 * @param[in] ifftFlag flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. 01933 * @param[in] bitReverseFlag flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. 01934 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if <code>fftLen</code> is not a supported value. 01935 */ 01936 01937 arm_status arm_cfft_radix4_init_f32( 01938 arm_cfft_radix4_instance_f32 * S, 01939 uint16_t fftLen, 01940 uint8_t ifftFlag, 01941 uint8_t bitReverseFlag); 01942 01943 01944 01945 /*---------------------------------------------------------------------- 01946 * Internal functions prototypes FFT function 01947 ----------------------------------------------------------------------*/ 01948 01949 /** 01950 * @brief Core function for the floating-point CFFT butterfly process. 01951 * @param[in, out] *pSrc points to the in-place buffer of floating-point data type. 01952 * @param[in] fftLen length of the FFT. 01953 * @param[in] *pCoef points to the twiddle coefficient buffer. 01954 * @param[in] twidCoefModifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. 01955 * @return none. 01956 */ 01957 01958 void arm_radix4_butterfly_f32( 01959 float32_t * pSrc, 01960 uint16_t fftLen, 01961 float32_t * pCoef, 01962 uint16_t twidCoefModifier); 01963 01964 /** 01965 * @brief Core function for the floating-point CIFFT butterfly process. 01966 * @param[in, out] *pSrc points to the in-place buffer of floating-point data type. 01967 * @param[in] fftLen length of the FFT. 01968 * @param[in] *pCoef points to twiddle coefficient buffer. 01969 * @param[in] twidCoefModifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. 01970 * @param[in] onebyfftLen value of 1/fftLen. 01971 * @return none. 01972 */ 01973 01974 void arm_radix4_butterfly_inverse_f32( 01975 float32_t * pSrc, 01976 uint16_t fftLen, 01977 float32_t * pCoef, 01978 uint16_t twidCoefModifier, 01979 float32_t onebyfftLen); 01980 01981 /** 01982 * @brief In-place bit reversal function. 01983 * @param[in, out] *pSrc points to the in-place buffer of floating-point data type. 01984 * @param[in] fftSize length of the FFT. 01985 * @param[in] bitRevFactor bit reversal modifier that supports different size FFTs with the same bit reversal table. 01986 * @param[in] *pBitRevTab points to the bit reversal table. 01987 * @return none. 01988 */ 01989 01990 void arm_bitreversal_f32( 01991 float32_t *pSrc, 01992 uint16_t fftSize, 01993 uint16_t bitRevFactor, 01994 uint16_t *pBitRevTab); 01995 01996 /** 01997 * @brief Core function for the Q31 CFFT butterfly process. 01998 * @param[in, out] *pSrc points to the in-place buffer of Q31 data type. 01999 * @param[in] fftLen length of the FFT. 02000 * @param[in] *pCoef points to twiddle coefficient buffer. 02001 * @param[in] twidCoefModifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. 02002 * @return none. 02003 */ 02004 02005 void arm_radix4_butterfly_q31( 02006 q31_t *pSrc, 02007 uint32_t fftLen, 02008 q31_t *pCoef, 02009 uint32_t twidCoefModifier); 02010 02011 /** 02012 * @brief Core function for the Q31 CIFFT butterfly process. 02013 * @param[in, out] *pSrc points to the in-place buffer of Q31 data type. 02014 * @param[in] fftLen length of the FFT. 02015 * @param[in] *pCoef points to twiddle coefficient buffer. 02016 * @param[in] twidCoefModifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. 02017 * @return none. 02018 */ 02019 02020 void arm_radix4_butterfly_inverse_q31( 02021 q31_t * pSrc, 02022 uint32_t fftLen, 02023 q31_t * pCoef, 02024 uint32_t twidCoefModifier); 02025 02026 /** 02027 * @brief In-place bit reversal function. 02028 * @param[in, out] *pSrc points to the in-place buffer of Q31 data type. 02029 * @param[in] fftLen length of the FFT. 02030 * @param[in] bitRevFactor bit reversal modifier that supports different size FFTs with the same bit reversal table 02031 * @param[in] *pBitRevTab points to bit reversal table. 02032 * @return none. 02033 */ 02034 02035 void arm_bitreversal_q31( 02036 q31_t * pSrc, 02037 uint32_t fftLen, 02038 uint16_t bitRevFactor, 02039 uint16_t *pBitRevTab); 02040 02041 /** 02042 * @brief Core function for the Q15 CFFT butterfly process. 02043 * @param[in, out] *pSrc16 points to the in-place buffer of Q15 data type. 02044 * @param[in] fftLen length of the FFT. 02045 * @param[in] *pCoef16 points to twiddle coefficient buffer. 02046 * @param[in] twidCoefModifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. 02047 * @return none. 02048 */ 02049 02050 void arm_radix4_butterfly_q15( 02051 q15_t *pSrc16, 02052 uint32_t fftLen, 02053 q15_t *pCoef16, 02054 uint32_t twidCoefModifier); 02055 02056 /** 02057 * @brief Core function for the Q15 CIFFT butterfly process. 02058 * @param[in, out] *pSrc16 points to the in-place buffer of Q15 data type. 02059 * @param[in] fftLen length of the FFT. 02060 * @param[in] *pCoef16 points to twiddle coefficient buffer. 02061 * @param[in] twidCoefModifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. 02062 * @return none. 02063 */ 02064 02065 void arm_radix4_butterfly_inverse_q15( 02066 q15_t *pSrc16, 02067 uint32_t fftLen, 02068 q15_t *pCoef16, 02069 uint32_t twidCoefModifier); 02070 02071 /** 02072 * @brief In-place bit reversal function. 02073 * @param[in, out] *pSrc points to the in-place buffer of Q15 data type. 02074 * @param[in] fftLen length of the FFT. 02075 * @param[in] bitRevFactor bit reversal modifier that supports different size FFTs with the same bit reversal table 02076 * @param[in] *pBitRevTab points to bit reversal table. 02077 * @return none. 02078 */ 02079 02080 void arm_bitreversal_q15( 02081 q15_t * pSrc, 02082 uint32_t fftLen, 02083 uint16_t bitRevFactor, 02084 uint16_t *pBitRevTab); 02085 02086 /** 02087 * @brief Instance structure for the Q15 RFFT/RIFFT function. 02088 */ 02089 02090 typedef struct 02091 { 02092 uint32_t fftLenReal; /**< length of the real FFT. */ 02093 uint32_t fftLenBy2; /**< length of the complex FFT. */ 02094 uint8_t ifftFlagR; /**< flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. */ 02095 uint8_t bitReverseFlagR; /**< flag that enables (bitReverseFlagR=1) or disables (bitReverseFlagR=0) bit reversal of output. */ 02096 uint32_t twidCoefRModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */ 02097 q15_t *pTwiddleAReal; /**< points to the real twiddle factor table. */ 02098 q15_t *pTwiddleBReal; /**< points to the imag twiddle factor table. */ 02099 arm_cfft_radix4_instance_q15 *pCfft; /**< points to the complex FFT instance. */ 02100 } arm_rfft_instance_q15; 02101 02102 /** 02103 * @brief Instance structure for the Q31 RFFT/RIFFT function. 02104 */ 02105 02106 typedef struct 02107 { 02108 uint32_t fftLenReal; /**< length of the real FFT. */ 02109 uint32_t fftLenBy2; /**< length of the complex FFT. */ 02110 uint8_t ifftFlagR; /**< flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. */ 02111 uint8_t bitReverseFlagR; /**< flag that enables (bitReverseFlagR=1) or disables (bitReverseFlagR=0) bit reversal of output. */ 02112 uint32_t twidCoefRModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */ 02113 q31_t *pTwiddleAReal; /**< points to the real twiddle factor table. */ 02114 q31_t *pTwiddleBReal; /**< points to the imag twiddle factor table. */ 02115 arm_cfft_radix4_instance_q31 *pCfft; /**< points to the complex FFT instance. */ 02116 } arm_rfft_instance_q31; 02117 02118 /** 02119 * @brief Instance structure for the floating-point RFFT/RIFFT function. 02120 */ 02121 02122 typedef struct 02123 { 02124 uint32_t fftLenReal; /**< length of the real FFT. */ 02125 uint16_t fftLenBy2; /**< length of the complex FFT. */ 02126 uint8_t ifftFlagR; /**< flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. */ 02127 uint8_t bitReverseFlagR; /**< flag that enables (bitReverseFlagR=1) or disables (bitReverseFlagR=0) bit reversal of output. */ 02128 uint32_t twidCoefRModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */ 02129 float32_t *pTwiddleAReal; /**< points to the real twiddle factor table. */ 02130 float32_t *pTwiddleBReal; /**< points to the imag twiddle factor table. */ 02131 arm_cfft_radix4_instance_f32 *pCfft; /**< points to the complex FFT instance. */ 02132 } arm_rfft_instance_f32; 02133 02134 /** 02135 * @brief Processing function for the Q15 RFFT/RIFFT. 02136 * @param[in] *S points to an instance of the Q15 RFFT/RIFFT structure. 02137 * @param[in] *pSrc points to the input buffer. 02138 * @param[out] *pDst points to the output buffer. 02139 * @return none. 02140 */ 02141 #ifdef 0 02142 void arm_rfft_q15( 02143 const arm_rfft_instance_q15 * S, 02144 q15_t * pSrc, 02145 q15_t * pDst); 02146 02147 /** 02148 * @brief Initialization function for the Q15 RFFT/RIFFT. 02149 * @param[in, out] *S points to an instance of the Q15 RFFT/RIFFT structure. 02150 * @param[in] *S_CFFT points to an instance of the Q15 CFFT/CIFFT structure. 02151 * @param[in] fftLenReal length of the FFT. 02152 * @param[in] ifftFlagR flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. 02153 * @param[in] bitReverseFlag flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. 02154 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if <code>fftLenReal</code> is not a supported value. 02155 */ 02156 #endif 02157 arm_status arm_rfft_init_q15( 02158 arm_rfft_instance_q15 * S, 02159 arm_cfft_radix4_instance_q15 * S_CFFT, 02160 uint32_t fftLenReal, 02161 uint32_t ifftFlagR, 02162 uint32_t bitReverseFlag); 02163 02164 /** 02165 * @brief Processing function for the Q31 RFFT/RIFFT. 02166 * @param[in] *S points to an instance of the Q31 RFFT/RIFFT structure. 02167 * @param[in] *pSrc points to the input buffer. 02168 * @param[out] *pDst points to the output buffer. 02169 * @return none. 02170 */ 02171 #ifdef 0 02172 void arm_rfft_q31( 02173 const arm_rfft_instance_q31 * S, 02174 q31_t * pSrc, 02175 q31_t * pDst); 02176 #endif 02177 /** 02178 * @brief Initialization function for the Q31 RFFT/RIFFT. 02179 * @param[in, out] *S points to an instance of the Q31 RFFT/RIFFT structure. 02180 * @param[in, out] *S_CFFT points to an instance of the Q31 CFFT/CIFFT structure. 02181 * @param[in] fftLenReal length of the FFT. 02182 * @param[in] ifftFlagR flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. 02183 * @param[in] bitReverseFlag flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. 02184 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if <code>fftLenReal</code> is not a supported value. 02185 */ 02186 02187 arm_status arm_rfft_init_q31( 02188 arm_rfft_instance_q31 * S, 02189 arm_cfft_radix4_instance_q31 * S_CFFT, 02190 uint32_t fftLenReal, 02191 uint32_t ifftFlagR, 02192 uint32_t bitReverseFlag); 02193 02194 /** 02195 * @brief Initialization function for the floating-point RFFT/RIFFT. 02196 * @param[in,out] *S points to an instance of the floating-point RFFT/RIFFT structure. 02197 * @param[in,out] *S_CFFT points to an instance of the floating-point CFFT/CIFFT structure. 02198 * @param[in] fftLenReal length of the FFT. 02199 * @param[in] ifftFlagR flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. 02200 * @param[in] bitReverseFlag flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. 02201 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if <code>fftLenReal</code> is not a supported value. 02202 */ 02203 02204 arm_status arm_rfft_init_f32( 02205 arm_rfft_instance_f32 * S, 02206 arm_cfft_radix4_instance_f32 * S_CFFT, 02207 uint32_t fftLenReal, 02208 uint32_t ifftFlagR, 02209 uint32_t bitReverseFlag); 02210 02211 /** 02212 * @brief Processing function for the floating-point RFFT/RIFFT. 02213 * @param[in] *S points to an instance of the floating-point RFFT/RIFFT structure. 02214 * @param[in] *pSrc points to the input buffer. 02215 * @param[out] *pDst points to the output buffer. 02216 * @return none. 02217 */ 02218 02219 void arm_rfft_f32( 02220 const arm_rfft_instance_f32 * S, 02221 float32_t * pSrc, 02222 float32_t * pDst); 02223 02224 /** 02225 * @brief Instance structure for the floating-point DCT4/IDCT4 function. 02226 */ 02227 02228 typedef struct 02229 { 02230 uint16_t N; /**< length of the DCT4. */ 02231 uint16_t Nby2; /**< half of the length of the DCT4. */ 02232 float32_t normalize; /**< normalizing factor. */ 02233 float32_t *pTwiddle; /**< points to the twiddle factor table. */ 02234 float32_t *pCosFactor; /**< points to the cosFactor table. */ 02235 arm_rfft_instance_f32 *pRfft; /**< points to the real FFT instance. */ 02236 arm_cfft_radix4_instance_f32 *pCfft; /**< points to the complex FFT instance. */ 02237 } arm_dct4_instance_f32; 02238 02239 /** 02240 * @brief Initialization function for the floating-point DCT4/IDCT4. 02241 * @param[in,out] *S points to an instance of floating-point DCT4/IDCT4 structure. 02242 * @param[in] *S_RFFT points to an instance of floating-point RFFT/RIFFT structure. 02243 * @param[in] *S_CFFT points to an instance of floating-point CFFT/CIFFT structure. 02244 * @param[in] N length of the DCT4. 02245 * @param[in] Nby2 half of the length of the DCT4. 02246 * @param[in] normalize normalizing factor. 02247 * @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. 02248 */ 02249 02250 arm_status arm_dct4_init_f32( 02251 arm_dct4_instance_f32 * S, 02252 arm_rfft_instance_f32 * S_RFFT, 02253 arm_cfft_radix4_instance_f32 * S_CFFT, 02254 uint16_t N, 02255 uint16_t Nby2, 02256 float32_t normalize); 02257 02258 /** 02259 * @brief Processing function for the floating-point DCT4/IDCT4. 02260 * @param[in] *S points to an instance of the floating-point DCT4/IDCT4 structure. 02261 * @param[in] *pState points to state buffer. 02262 * @param[in,out] *pInlineBuffer points to the in-place input and output buffer. 02263 * @return none. 02264 */ 02265 02266 void arm_dct4_f32( 02267 const arm_dct4_instance_f32 * S, 02268 float32_t * pState, 02269 float32_t * pInlineBuffer); 02270 02271 /** 02272 * @brief Instance structure for the Q31 DCT4/IDCT4 function. 02273 */ 02274 02275 typedef struct 02276 { 02277 uint16_t N; /**< length of the DCT4. */ 02278 uint16_t Nby2; /**< half of the length of the DCT4. */ 02279 q31_t normalize; /**< normalizing factor. */ 02280 q31_t *pTwiddle; /**< points to the twiddle factor table. */ 02281 q31_t *pCosFactor; /**< points to the cosFactor table. */ 02282 arm_rfft_instance_q31 *pRfft; /**< points to the real FFT instance. */ 02283 arm_cfft_radix4_instance_q31 *pCfft; /**< points to the complex FFT instance. */ 02284 } arm_dct4_instance_q31; 02285 02286 /** 02287 * @brief Initialization function for the Q31 DCT4/IDCT4. 02288 * @param[in,out] *S points to an instance of Q31 DCT4/IDCT4 structure. 02289 * @param[in] *S_RFFT points to an instance of Q31 RFFT/RIFFT structure 02290 * @param[in] *S_CFFT points to an instance of Q31 CFFT/CIFFT structure 02291 * @param[in] N length of the DCT4. 02292 * @param[in] Nby2 half of the length of the DCT4. 02293 * @param[in] normalize normalizing factor. 02294 * @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. 02295 */ 02296 02297 arm_status arm_dct4_init_q31( 02298 arm_dct4_instance_q31 * S, 02299 arm_rfft_instance_q31 * S_RFFT, 02300 arm_cfft_radix4_instance_q31 * S_CFFT, 02301 uint16_t N, 02302 uint16_t Nby2, 02303 q31_t normalize); 02304 02305 /** 02306 * @brief Processing function for the Q31 DCT4/IDCT4. 02307 * @param[in] *S points to an instance of the Q31 DCT4 structure. 02308 * @param[in] *pState points to state buffer. 02309 * @param[in,out] *pInlineBuffer points to the in-place input and output buffer. 02310 * @return none. 02311 */ 02312 02313 void arm_dct4_q31( 02314 const arm_dct4_instance_q31 * S, 02315 q31_t * pState, 02316 q31_t * pInlineBuffer); 02317 02318 /** 02319 * @brief Instance structure for the Q15 DCT4/IDCT4 function. 02320 */ 02321 02322 typedef struct 02323 { 02324 uint16_t N; /**< length of the DCT4. */ 02325 uint16_t Nby2; /**< half of the length of the DCT4. */ 02326 q15_t normalize; /**< normalizing factor. */ 02327 q15_t *pTwiddle; /**< points to the twiddle factor table. */ 02328 q15_t *pCosFactor; /**< points to the cosFactor table. */ 02329 arm_rfft_instance_q15 *pRfft; /**< points to the real FFT instance. */ 02330 arm_cfft_radix4_instance_q15 *pCfft; /**< points to the complex FFT instance. */ 02331 } arm_dct4_instance_q15; 02332 02333 /** 02334 * @brief Initialization function for the Q15 DCT4/IDCT4. 02335 * @param[in,out] *S points to an instance of Q15 DCT4/IDCT4 structure. 02336 * @param[in] *S_RFFT points to an instance of Q15 RFFT/RIFFT structure. 02337 * @param[in] *S_CFFT points to an instance of Q15 CFFT/CIFFT structure. 02338 * @param[in] N length of the DCT4. 02339 * @param[in] Nby2 half of the length of the DCT4. 02340 * @param[in] normalize normalizing factor. 02341 * @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. 02342 */ 02343 02344 arm_status arm_dct4_init_q15( 02345 arm_dct4_instance_q15 * S, 02346 arm_rfft_instance_q15 * S_RFFT, 02347 arm_cfft_radix4_instance_q15 * S_CFFT, 02348 uint16_t N, 02349 uint16_t Nby2, 02350 q15_t normalize); 02351 02352 /** 02353 * @brief Processing function for the Q15 DCT4/IDCT4. 02354 * @param[in] *S points to an instance of the Q15 DCT4 structure. 02355 * @param[in] *pState points to state buffer. 02356 * @param[in,out] *pInlineBuffer points to the in-place input and output buffer. 02357 * @return none. 02358 */ 02359 02360 void arm_dct4_q15( 02361 const arm_dct4_instance_q15 * S, 02362 q15_t * pState, 02363 q15_t * pInlineBuffer); 02364 02365 /** 02366 * @brief Floating-point vector addition. 02367 * @param[in] *pSrcA points to the first input vector 02368 * @param[in] *pSrcB points to the second input vector 02369 * @param[out] *pDst points to the output vector 02370 * @param[in] blockSize number of samples in each vector 02371 * @return none. 02372 */ 02373 02374 void arm_add_f32( 02375 float32_t * pSrcA, 02376 float32_t * pSrcB, 02377 float32_t * pDst, 02378 uint32_t blockSize); 02379 02380 /** 02381 * @brief Q7 vector addition. 02382 * @param[in] *pSrcA points to the first input vector 02383 * @param[in] *pSrcB points to the second input vector 02384 * @param[out] *pDst points to the output vector 02385 * @param[in] blockSize number of samples in each vector 02386 * @return none. 02387 */ 02388 02389 void arm_add_q7( 02390 q7_t * pSrcA, 02391 q7_t * pSrcB, 02392 q7_t * pDst, 02393 uint32_t blockSize); 02394 02395 /** 02396 * @brief Q15 vector addition. 02397 * @param[in] *pSrcA points to the first input vector 02398 * @param[in] *pSrcB points to the second input vector 02399 * @param[out] *pDst points to the output vector 02400 * @param[in] blockSize number of samples in each vector 02401 * @return none. 02402 */ 02403 02404 void arm_add_q15( 02405 q15_t * pSrcA, 02406 q15_t * pSrcB, 02407 q15_t * pDst, 02408 uint32_t blockSize); 02409 02410 /** 02411 * @brief Q31 vector addition. 02412 * @param[in] *pSrcA points to the first input vector 02413 * @param[in] *pSrcB points to the second input vector 02414 * @param[out] *pDst points to the output vector 02415 * @param[in] blockSize number of samples in each vector 02416 * @return none. 02417 */ 02418 02419 void arm_add_q31( 02420 q31_t * pSrcA, 02421 q31_t * pSrcB, 02422 q31_t * pDst, 02423 uint32_t blockSize); 02424 02425 /** 02426 * @brief Floating-point vector subtraction. 02427 * @param[in] *pSrcA points to the first input vector 02428 * @param[in] *pSrcB points to the second input vector 02429 * @param[out] *pDst points to the output vector 02430 * @param[in] blockSize number of samples in each vector 02431 * @return none. 02432 */ 02433 02434 void arm_sub_f32( 02435 float32_t * pSrcA, 02436 float32_t * pSrcB, 02437 float32_t * pDst, 02438 uint32_t blockSize); 02439 02440 /** 02441 * @brief Q7 vector subtraction. 02442 * @param[in] *pSrcA points to the first input vector 02443 * @param[in] *pSrcB points to the second input vector 02444 * @param[out] *pDst points to the output vector 02445 * @param[in] blockSize number of samples in each vector 02446 * @return none. 02447 */ 02448 02449 void arm_sub_q7( 02450 q7_t * pSrcA, 02451 q7_t * pSrcB, 02452 q7_t * pDst, 02453 uint32_t blockSize); 02454 02455 /** 02456 * @brief Q15 vector subtraction. 02457 * @param[in] *pSrcA points to the first input vector 02458 * @param[in] *pSrcB points to the second input vector 02459 * @param[out] *pDst points to the output vector 02460 * @param[in] blockSize number of samples in each vector 02461 * @return none. 02462 */ 02463 02464 void arm_sub_q15( 02465 q15_t * pSrcA, 02466 q15_t * pSrcB, 02467 q15_t * pDst, 02468 uint32_t blockSize); 02469 02470 /** 02471 * @brief Q31 vector subtraction. 02472 * @param[in] *pSrcA points to the first input vector 02473 * @param[in] *pSrcB points to the second input vector 02474 * @param[out] *pDst points to the output vector 02475 * @param[in] blockSize number of samples in each vector 02476 * @return none. 02477 */ 02478 02479 void arm_sub_q31( 02480 q31_t * pSrcA, 02481 q31_t * pSrcB, 02482 q31_t * pDst, 02483 uint32_t blockSize); 02484 02485 /** 02486 * @brief Multiplies a floating-point vector by a scalar. 02487 * @param[in] *pSrc points to the input vector 02488 * @param[in] scale scale factor to be applied 02489 * @param[out] *pDst points to the output vector 02490 * @param[in] blockSize number of samples in the vector 02491 * @return none. 02492 */ 02493 02494 void arm_scale_f32( 02495 float32_t * pSrc, 02496 float32_t scale, 02497 float32_t * pDst, 02498 uint32_t blockSize); 02499 02500 /** 02501 * @brief Multiplies a Q7 vector by a scalar. 02502 * @param[in] *pSrc points to the input vector 02503 * @param[in] scaleFract fractional portion of the scale value 02504 * @param[in] shift number of bits to shift the result by 02505 * @param[out] *pDst points to the output vector 02506 * @param[in] blockSize number of samples in the vector 02507 * @return none. 02508 */ 02509 02510 void arm_scale_q7( 02511 q7_t * pSrc, 02512 q7_t scaleFract, 02513 int8_t shift, 02514 q7_t * pDst, 02515 uint32_t blockSize); 02516 02517 /** 02518 * @brief Multiplies a Q15 vector by a scalar. 02519 * @param[in] *pSrc points to the input vector 02520 * @param[in] scaleFract fractional portion of the scale value 02521 * @param[in] shift number of bits to shift the result by 02522 * @param[out] *pDst points to the output vector 02523 * @param[in] blockSize number of samples in the vector 02524 * @return none. 02525 */ 02526 02527 void arm_scale_q15( 02528 q15_t * pSrc, 02529 q15_t scaleFract, 02530 int8_t shift, 02531 q15_t * pDst, 02532 uint32_t blockSize); 02533 02534 /** 02535 * @brief Multiplies a Q31 vector by a scalar. 02536 * @param[in] *pSrc points to the input vector 02537 * @param[in] scaleFract fractional portion of the scale value 02538 * @param[in] shift number of bits to shift the result by 02539 * @param[out] *pDst points to the output vector 02540 * @param[in] blockSize number of samples in the vector 02541 * @return none. 02542 */ 02543 02544 void arm_scale_q31( 02545 q31_t * pSrc, 02546 q31_t scaleFract, 02547 int8_t shift, 02548 q31_t * pDst, 02549 uint32_t blockSize); 02550 02551 /** 02552 * @brief Q7 vector absolute value. 02553 * @param[in] *pSrc points to the input buffer 02554 * @param[out] *pDst points to the output buffer 02555 * @param[in] blockSize number of samples in each vector 02556 * @return none. 02557 */ 02558 02559 void arm_abs_q7( 02560 q7_t * pSrc, 02561 q7_t * pDst, 02562 uint32_t blockSize); 02563 02564 /** 02565 * @brief Floating-point vector absolute value. 02566 * @param[in] *pSrc points to the input buffer 02567 * @param[out] *pDst points to the output buffer 02568 * @param[in] blockSize number of samples in each vector 02569 * @return none. 02570 */ 02571 02572 void arm_abs_f32( 02573 float32_t * pSrc, 02574 float32_t * pDst, 02575 uint32_t blockSize); 02576 02577 /** 02578 * @brief Q15 vector absolute value. 02579 * @param[in] *pSrc points to the input buffer 02580 * @param[out] *pDst points to the output buffer 02581 * @param[in] blockSize number of samples in each vector 02582 * @return none. 02583 */ 02584 02585 void arm_abs_q15( 02586 q15_t * pSrc, 02587 q15_t * pDst, 02588 uint32_t blockSize); 02589 02590 /** 02591 * @brief Q31 vector absolute value. 02592 * @param[in] *pSrc points to the input buffer 02593 * @param[out] *pDst points to the output buffer 02594 * @param[in] blockSize number of samples in each vector 02595 * @return none. 02596 */ 02597 02598 void arm_abs_q31( 02599 q31_t * pSrc, 02600 q31_t * pDst, 02601 uint32_t blockSize); 02602 02603 /** 02604 * @brief Dot product of floating-point vectors. 02605 * @param[in] *pSrcA points to the first input vector 02606 * @param[in] *pSrcB points to the second input vector 02607 * @param[in] blockSize number of samples in each vector 02608 * @param[out] *result output result returned here 02609 * @return none. 02610 */ 02611 02612 void arm_dot_prod_f32( 02613 float32_t * pSrcA, 02614 float32_t * pSrcB, 02615 uint32_t blockSize, 02616 float32_t * result); 02617 02618 /** 02619 * @brief Dot product of Q7 vectors. 02620 * @param[in] *pSrcA points to the first input vector 02621 * @param[in] *pSrcB points to the second input vector 02622 * @param[in] blockSize number of samples in each vector 02623 * @param[out] *result output result returned here 02624 * @return none. 02625 */ 02626 02627 void arm_dot_prod_q7( 02628 q7_t * pSrcA, 02629 q7_t * pSrcB, 02630 uint32_t blockSize, 02631 q31_t * result); 02632 02633 /** 02634 * @brief Dot product of Q15 vectors. 02635 * @param[in] *pSrcA points to the first input vector 02636 * @param[in] *pSrcB points to the second input vector 02637 * @param[in] blockSize number of samples in each vector 02638 * @param[out] *result output result returned here 02639 * @return none. 02640 */ 02641 02642 void arm_dot_prod_q15( 02643 q15_t * pSrcA, 02644 q15_t * pSrcB, 02645 uint32_t blockSize, 02646 q63_t * result); 02647 02648 /** 02649 * @brief Dot product of Q31 vectors. 02650 * @param[in] *pSrcA points to the first input vector 02651 * @param[in] *pSrcB points to the second input vector 02652 * @param[in] blockSize number of samples in each vector 02653 * @param[out] *result output result returned here 02654 * @return none. 02655 */ 02656 02657 void arm_dot_prod_q31( 02658 q31_t * pSrcA, 02659 q31_t * pSrcB, 02660 uint32_t blockSize, 02661 q63_t * result); 02662 02663 /** 02664 * @brief Shifts the elements of a Q7 vector a specified number of bits. 02665 * @param[in] *pSrc points to the input vector 02666 * @param[in] shiftBits number of bits to shift. A positive value shifts left; a negative value shifts right. 02667 * @param[out] *pDst points to the output vector 02668 * @param[in] blockSize number of samples in the vector 02669 * @return none. 02670 */ 02671 02672 void arm_shift_q7( 02673 q7_t * pSrc, 02674 int8_t shiftBits, 02675 q7_t * pDst, 02676 uint32_t blockSize); 02677 02678 /** 02679 * @brief Shifts the elements of a Q15 vector a specified number of bits. 02680 * @param[in] *pSrc points to the input vector 02681 * @param[in] shiftBits number of bits to shift. A positive value shifts left; a negative value shifts right. 02682 * @param[out] *pDst points to the output vector 02683 * @param[in] blockSize number of samples in the vector 02684 * @return none. 02685 */ 02686 02687 void arm_shift_q15( 02688 q15_t * pSrc, 02689 int8_t shiftBits, 02690 q15_t * pDst, 02691 uint32_t blockSize); 02692 02693 /** 02694 * @brief Shifts the elements of a Q31 vector a specified number of bits. 02695 * @param[in] *pSrc points to the input vector 02696 * @param[in] shiftBits number of bits to shift. A positive value shifts left; a negative value shifts right. 02697 * @param[out] *pDst points to the output vector 02698 * @param[in] blockSize number of samples in the vector 02699 * @return none. 02700 */ 02701 02702 void arm_shift_q31( 02703 q31_t * pSrc, 02704 int8_t shiftBits, 02705 q31_t * pDst, 02706 uint32_t blockSize); 02707 02708 /** 02709 * @brief Adds a constant offset to a floating-point vector. 02710 * @param[in] *pSrc points to the input vector 02711 * @param[in] offset is the offset to be added 02712 * @param[out] *pDst points to the output vector 02713 * @param[in] blockSize number of samples in the vector 02714 * @return none. 02715 */ 02716 02717 void arm_offset_f32( 02718 float32_t * pSrc, 02719 float32_t offset, 02720 float32_t * pDst, 02721 uint32_t blockSize); 02722 02723 /** 02724 * @brief Adds a constant offset to a Q7 vector. 02725 * @param[in] *pSrc points to the input vector 02726 * @param[in] offset is the offset to be added 02727 * @param[out] *pDst points to the output vector 02728 * @param[in] blockSize number of samples in the vector 02729 * @return none. 02730 */ 02731 02732 void arm_offset_q7( 02733 q7_t * pSrc, 02734 q7_t offset, 02735 q7_t * pDst, 02736 uint32_t blockSize); 02737 02738 /** 02739 * @brief Adds a constant offset to a Q15 vector. 02740 * @param[in] *pSrc points to the input vector 02741 * @param[in] offset is the offset to be added 02742 * @param[out] *pDst points to the output vector 02743 * @param[in] blockSize number of samples in the vector 02744 * @return none. 02745 */ 02746 02747 void arm_offset_q15( 02748 q15_t * pSrc, 02749 q15_t offset, 02750 q15_t * pDst, 02751 uint32_t blockSize); 02752 02753 /** 02754 * @brief Adds a constant offset to a Q31 vector. 02755 * @param[in] *pSrc points to the input vector 02756 * @param[in] offset is the offset to be added 02757 * @param[out] *pDst points to the output vector 02758 * @param[in] blockSize number of samples in the vector 02759 * @return none. 02760 */ 02761 02762 void arm_offset_q31( 02763 q31_t * pSrc, 02764 q31_t offset, 02765 q31_t * pDst, 02766 uint32_t blockSize); 02767 02768 /** 02769 * @brief Negates the elements of a floating-point vector. 02770 * @param[in] *pSrc points to the input vector 02771 * @param[out] *pDst points to the output vector 02772 * @param[in] blockSize number of samples in the vector 02773 * @return none. 02774 */ 02775 02776 void arm_negate_f32( 02777 float32_t * pSrc, 02778 float32_t * pDst, 02779 uint32_t blockSize); 02780 02781 /** 02782 * @brief Negates the elements of a Q7 vector. 02783 * @param[in] *pSrc points to the input vector 02784 * @param[out] *pDst points to the output vector 02785 * @param[in] blockSize number of samples in the vector 02786 * @return none. 02787 */ 02788 02789 void arm_negate_q7( 02790 q7_t * pSrc, 02791 q7_t * pDst, 02792 uint32_t blockSize); 02793 02794 /** 02795 * @brief Negates the elements of a Q15 vector. 02796 * @param[in] *pSrc points to the input vector 02797 * @param[out] *pDst points to the output vector 02798 * @param[in] blockSize number of samples in the vector 02799 * @return none. 02800 */ 02801 02802 void arm_negate_q15( 02803 q15_t * pSrc, 02804 q15_t * pDst, 02805 uint32_t blockSize); 02806 02807 /** 02808 * @brief Negates the elements of a Q31 vector. 02809 * @param[in] *pSrc points to the input vector 02810 * @param[out] *pDst points to the output vector 02811 * @param[in] blockSize number of samples in the vector 02812 * @return none. 02813 */ 02814 02815 void arm_negate_q31( 02816 q31_t * pSrc, 02817 q31_t * pDst, 02818 uint32_t blockSize); 02819 /** 02820 * @brief Copies the elements of a floating-point vector. 02821 * @param[in] *pSrc input pointer 02822 * @param[out] *pDst output pointer 02823 * @param[in] blockSize number of samples to process 02824 * @return none. 02825 */ 02826 void arm_copy_f32( 02827 float32_t * pSrc, 02828 float32_t * pDst, 02829 uint32_t blockSize); 02830 02831 /** 02832 * @brief Copies the elements of a Q7 vector. 02833 * @param[in] *pSrc input pointer 02834 * @param[out] *pDst output pointer 02835 * @param[in] blockSize number of samples to process 02836 * @return none. 02837 */ 02838 void arm_copy_q7( 02839 q7_t * pSrc, 02840 q7_t * pDst, 02841 uint32_t blockSize); 02842 02843 /** 02844 * @brief Copies the elements of a Q15 vector. 02845 * @param[in] *pSrc input pointer 02846 * @param[out] *pDst output pointer 02847 * @param[in] blockSize number of samples to process 02848 * @return none. 02849 */ 02850 void arm_copy_q15( 02851 q15_t * pSrc, 02852 q15_t * pDst, 02853 uint32_t blockSize); 02854 02855 /** 02856 * @brief Copies the elements of a Q31 vector. 02857 * @param[in] *pSrc input pointer 02858 * @param[out] *pDst output pointer 02859 * @param[in] blockSize number of samples to process 02860 * @return none. 02861 */ 02862 void arm_copy_q31( 02863 q31_t * pSrc, 02864 q31_t * pDst, 02865 uint32_t blockSize); 02866 /** 02867 * @brief Fills a constant value into a floating-point vector. 02868 * @param[in] value input value to be filled 02869 * @param[out] *pDst output pointer 02870 * @param[in] blockSize number of samples to process 02871 * @return none. 02872 */ 02873 void arm_fill_f32( 02874 float32_t value, 02875 float32_t * pDst, 02876 uint32_t blockSize); 02877 02878 /** 02879 * @brief Fills a constant value into a Q7 vector. 02880 * @param[in] value input value to be filled 02881 * @param[out] *pDst output pointer 02882 * @param[in] blockSize number of samples to process 02883 * @return none. 02884 */ 02885 void arm_fill_q7( 02886 q7_t value, 02887 q7_t * pDst, 02888 uint32_t blockSize); 02889 02890 /** 02891 * @brief Fills a constant value into a Q15 vector. 02892 * @param[in] value input value to be filled 02893 * @param[out] *pDst output pointer 02894 * @param[in] blockSize number of samples to process 02895 * @return none. 02896 */ 02897 void arm_fill_q15( 02898 q15_t value, 02899 q15_t * pDst, 02900 uint32_t blockSize); 02901 02902 /** 02903 * @brief Fills a constant value into a Q31 vector. 02904 * @param[in] value input value to be filled 02905 * @param[out] *pDst output pointer 02906 * @param[in] blockSize number of samples to process 02907 * @return none. 02908 */ 02909 void arm_fill_q31( 02910 q31_t value, 02911 q31_t * pDst, 02912 uint32_t blockSize); 02913 02914 /** 02915 * @brief Convolution of floating-point sequences. 02916 * @param[in] *pSrcA points to the first input sequence. 02917 * @param[in] srcALen length of the first input sequence. 02918 * @param[in] *pSrcB points to the second input sequence. 02919 * @param[in] srcBLen length of the second input sequence. 02920 * @param[out] *pDst points to the block of output data Length srcALen+srcBLen-1. 02921 * @return none. 02922 */ 02923 02924 void arm_conv_f32( 02925 float32_t * pSrcA, 02926 uint32_t srcALen, 02927 float32_t * pSrcB, 02928 uint32_t srcBLen, 02929 float32_t * pDst); 02930 02931 /** 02932 * @brief Convolution of Q15 sequences. 02933 * @param[in] *pSrcA points to the first input sequence. 02934 * @param[in] srcALen length of the first input sequence. 02935 * @param[in] *pSrcB points to the second input sequence. 02936 * @param[in] srcBLen length of the second input sequence. 02937 * @param[out] *pDst points to the block of output data Length srcALen+srcBLen-1. 02938 * @return none. 02939 */ 02940 02941 void arm_conv_q15( 02942 q15_t * pSrcA, 02943 uint32_t srcALen, 02944 q15_t * pSrcB, 02945 uint32_t srcBLen, 02946 q15_t * pDst); 02947 02948 /** 02949 * @brief Convolution of Q15 sequences (fast version). 02950 * @param[in] *pSrcA points to the first input sequence. 02951 * @param[in] srcALen length of the first input sequence. 02952 * @param[in] *pSrcB points to the second input sequence. 02953 * @param[in] srcBLen length of the second input sequence. 02954 * @param[out] *pDst points to the block of output data Length srcALen+srcBLen-1. 02955 * @return none. 02956 */ 02957 02958 void arm_conv_fast_q15( 02959 q15_t * pSrcA, 02960 uint32_t srcALen, 02961 q15_t * pSrcB, 02962 uint32_t srcBLen, 02963 q15_t * pDst); 02964 02965 /** 02966 * @brief Convolution of Q31 sequences. 02967 * @param[in] *pSrcA points to the first input sequence. 02968 * @param[in] srcALen length of the first input sequence. 02969 * @param[in] *pSrcB points to the second input sequence. 02970 * @param[in] srcBLen length of the second input sequence. 02971 * @param[out] *pDst points to the block of output data Length srcALen+srcBLen-1. 02972 * @return none. 02973 */ 02974 02975 void arm_conv_q31( 02976 q31_t * pSrcA, 02977 uint32_t srcALen, 02978 q31_t * pSrcB, 02979 uint32_t srcBLen, 02980 q31_t * pDst); 02981 02982 /** 02983 * @brief Convolution of Q31 sequences (fast version). 02984 * @param[in] *pSrcA points to the first input sequence. 02985 * @param[in] srcALen length of the first input sequence. 02986 * @param[in] *pSrcB points to the second input sequence. 02987 * @param[in] srcBLen length of the second input sequence. 02988 * @param[out] *pDst points to the block of output data Length srcALen+srcBLen-1. 02989 * @return none. 02990 */ 02991 02992 void arm_conv_fast_q31( 02993 q31_t * pSrcA, 02994 uint32_t srcALen, 02995 q31_t * pSrcB, 02996 uint32_t srcBLen, 02997 q31_t * pDst); 02998 02999 /** 03000 * @brief Convolution of Q7 sequences. 03001 * @param[in] *pSrcA points to the first input sequence. 03002 * @param[in] srcALen length of the first input sequence. 03003 * @param[in] *pSrcB points to the second input sequence. 03004 * @param[in] srcBLen length of the second input sequence. 03005 * @param[out] *pDst points to the block of output data Length srcALen+srcBLen-1. 03006 * @return none. 03007 */ 03008 03009 void arm_conv_q7( 03010 q7_t * pSrcA, 03011 uint32_t srcALen, 03012 q7_t * pSrcB, 03013 uint32_t srcBLen, 03014 q7_t * pDst); 03015 03016 /** 03017 * @brief Partial convolution of floating-point sequences. 03018 * @param[in] *pSrcA points to the first input sequence. 03019 * @param[in] srcALen length of the first input sequence. 03020 * @param[in] *pSrcB points to the second input sequence. 03021 * @param[in] srcBLen length of the second input sequence. 03022 * @param[out] *pDst points to the block of output data 03023 * @param[in] firstIndex is the first output sample to start with. 03024 * @param[in] numPoints is the number of output points to be computed. 03025 * @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]. 03026 */ 03027 03028 arm_status arm_conv_partial_f32( 03029 float32_t * pSrcA, 03030 uint32_t srcALen, 03031 float32_t * pSrcB, 03032 uint32_t srcBLen, 03033 float32_t * pDst, 03034 uint32_t firstIndex, 03035 uint32_t numPoints); 03036 03037 /** 03038 * @brief Partial convolution of Q15 sequences. 03039 * @param[in] *pSrcA points to the first input sequence. 03040 * @param[in] srcALen length of the first input sequence. 03041 * @param[in] *pSrcB points to the second input sequence. 03042 * @param[in] srcBLen length of the second input sequence. 03043 * @param[out] *pDst points to the block of output data 03044 * @param[in] firstIndex is the first output sample to start with. 03045 * @param[in] numPoints is the number of output points to be computed. 03046 * @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]. 03047 */ 03048 03049 arm_status arm_conv_partial_q15( 03050 q15_t * pSrcA, 03051 uint32_t srcALen, 03052 q15_t * pSrcB, 03053 uint32_t srcBLen, 03054 q15_t * pDst, 03055 uint32_t firstIndex, 03056 uint32_t numPoints); 03057 03058 /** 03059 * @brief Partial convolution of Q15 sequences (fast version). 03060 * @param[in] *pSrcA points to the first input sequence. 03061 * @param[in] srcALen length of the first input sequence. 03062 * @param[in] *pSrcB points to the second input sequence. 03063 * @param[in] srcBLen length of the second input sequence. 03064 * @param[out] *pDst points to the block of output data 03065 * @param[in] firstIndex is the first output sample to start with. 03066 * @param[in] numPoints is the number of output points to be computed. 03067 * @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]. 03068 */ 03069 03070 arm_status arm_conv_partial_fast_q15( 03071 q15_t * pSrcA, 03072 uint32_t srcALen, 03073 q15_t * pSrcB, 03074 uint32_t srcBLen, 03075 q15_t * pDst, 03076 uint32_t firstIndex, 03077 uint32_t numPoints); 03078 03079 /** 03080 * @brief Partial convolution of Q31 sequences. 03081 * @param[in] *pSrcA points to the first input sequence. 03082 * @param[in] srcALen length of the first input sequence. 03083 * @param[in] *pSrcB points to the second input sequence. 03084 * @param[in] srcBLen length of the second input sequence. 03085 * @param[out] *pDst points to the block of output data 03086 * @param[in] firstIndex is the first output sample to start with. 03087 * @param[in] numPoints is the number of output points to be computed. 03088 * @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]. 03089 */ 03090 03091 arm_status arm_conv_partial_q31( 03092 q31_t * pSrcA, 03093 uint32_t srcALen, 03094 q31_t * pSrcB, 03095 uint32_t srcBLen, 03096 q31_t * pDst, 03097 uint32_t firstIndex, 03098 uint32_t numPoints); 03099 03100 03101 /** 03102 * @brief Partial convolution of Q31 sequences (fast version). 03103 * @param[in] *pSrcA points to the first input sequence. 03104 * @param[in] srcALen length of the first input sequence. 03105 * @param[in] *pSrcB points to the second input sequence. 03106 * @param[in] srcBLen length of the second input sequence. 03107 * @param[out] *pDst points to the block of output data 03108 * @param[in] firstIndex is the first output sample to start with. 03109 * @param[in] numPoints is the number of output points to be computed. 03110 * @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]. 03111 */ 03112 03113 arm_status arm_conv_partial_fast_q31( 03114 q31_t * pSrcA, 03115 uint32_t srcALen, 03116 q31_t * pSrcB, 03117 uint32_t srcBLen, 03118 q31_t * pDst, 03119 uint32_t firstIndex, 03120 uint32_t numPoints); 03121 03122 /** 03123 * @brief Partial convolution of Q7 sequences 03124 * @param[in] *pSrcA points to the first input sequence. 03125 * @param[in] srcALen length of the first input sequence. 03126 * @param[in] *pSrcB points to the second input sequence. 03127 * @param[in] srcBLen length of the second input sequence. 03128 * @param[out] *pDst points to the block of output data 03129 * @param[in] firstIndex is the first output sample to start with. 03130 * @param[in] numPoints is the number of output points to be computed. 03131 * @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]. 03132 */ 03133 03134 arm_status arm_conv_partial_q7( 03135 q7_t * pSrcA, 03136 uint32_t srcALen, 03137 q7_t * pSrcB, 03138 uint32_t srcBLen, 03139 q7_t * pDst, 03140 uint32_t firstIndex, 03141 uint32_t numPoints); 03142 03143 03144 /** 03145 * @brief Instance structure for the Q15 FIR decimator. 03146 */ 03147 03148 typedef struct 03149 { 03150 uint8_t M; /**< decimation factor. */ 03151 uint16_t numTaps; /**< number of coefficients in the filter. */ 03152 q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ 03153 q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 03154 } arm_fir_decimate_instance_q15; 03155 03156 /** 03157 * @brief Instance structure for the Q31 FIR decimator. 03158 */ 03159 03160 typedef struct 03161 { 03162 uint8_t M; /**< decimation factor. */ 03163 uint16_t numTaps; /**< number of coefficients in the filter. */ 03164 q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ 03165 q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 03166 03167 } arm_fir_decimate_instance_q31; 03168 03169 /** 03170 * @brief Instance structure for the floating-point FIR decimator. 03171 */ 03172 03173 typedef struct 03174 { 03175 uint8_t M; /**< decimation factor. */ 03176 uint16_t numTaps; /**< number of coefficients in the filter. */ 03177 float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ 03178 float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 03179 03180 } arm_fir_decimate_instance_f32; 03181 03182 03183 03184 /** 03185 * @brief Processing function for the floating-point FIR decimator. 03186 * @param[in] *S points to an instance of the floating-point FIR decimator structure. 03187 * @param[in] *pSrc points to the block of input data. 03188 * @param[out] *pDst points to the block of output data 03189 * @param[in] blockSize number of input samples to process per call. 03190 * @return none 03191 */ 03192 03193 void arm_fir_decimate_f32( 03194 const arm_fir_decimate_instance_f32 * S, 03195 float32_t * pSrc, 03196 float32_t * pDst, 03197 uint32_t blockSize); 03198 03199 03200 /** 03201 * @brief Initialization function for the floating-point FIR decimator. 03202 * @param[in,out] *S points to an instance of the floating-point FIR decimator structure. 03203 * @param[in] numTaps number of coefficients in the filter. 03204 * @param[in] M decimation factor. 03205 * @param[in] *pCoeffs points to the filter coefficients. 03206 * @param[in] *pState points to the state buffer. 03207 * @param[in] blockSize number of input samples to process per call. 03208 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if 03209 * <code>blockSize</code> is not a multiple of <code>M</code>. 03210 */ 03211 03212 arm_status arm_fir_decimate_init_f32( 03213 arm_fir_decimate_instance_f32 * S, 03214 uint16_t numTaps, 03215 uint8_t M, 03216 float32_t * pCoeffs, 03217 float32_t * pState, 03218 uint32_t blockSize); 03219 03220 /** 03221 * @brief Processing function for the Q15 FIR decimator. 03222 * @param[in] *S points to an instance of the Q15 FIR decimator structure. 03223 * @param[in] *pSrc points to the block of input data. 03224 * @param[out] *pDst points to the block of output data 03225 * @param[in] blockSize number of input samples to process per call. 03226 * @return none 03227 */ 03228 03229 void arm_fir_decimate_q15( 03230 const arm_fir_decimate_instance_q15 * S, 03231 q15_t * pSrc, 03232 q15_t * pDst, 03233 uint32_t blockSize); 03234 03235 /** 03236 * @brief Processing function for the Q15 FIR decimator (fast variant). 03237 * @param[in] *S points to an instance of the Q15 FIR decimator structure. 03238 * @param[in] *pSrc points to the block of input data. 03239 * @param[out] *pDst points to the block of output data 03240 * @param[in] blockSize number of input samples to process per call. 03241 * @return none 03242 */ 03243 03244 void arm_fir_decimate_fast_q15( 03245 const arm_fir_decimate_instance_q15 * S, 03246 q15_t * pSrc, 03247 q15_t * pDst, 03248 uint32_t blockSize); 03249 03250 03251 03252 /** 03253 * @brief Initialization function for the Q15 FIR decimator. 03254 * @param[in,out] *S points to an instance of the Q15 FIR decimator structure. 03255 * @param[in] numTaps number of coefficients in the filter. 03256 * @param[in] M decimation factor. 03257 * @param[in] *pCoeffs points to the filter coefficients. 03258 * @param[in] *pState points to the state buffer. 03259 * @param[in] blockSize number of input samples to process per call. 03260 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if 03261 * <code>blockSize</code> is not a multiple of <code>M</code>. 03262 */ 03263 03264 arm_status arm_fir_decimate_init_q15( 03265 arm_fir_decimate_instance_q15 * S, 03266 uint16_t numTaps, 03267 uint8_t M, 03268 q15_t * pCoeffs, 03269 q15_t * pState, 03270 uint32_t blockSize); 03271 03272 /** 03273 * @brief Processing function for the Q31 FIR decimator. 03274 * @param[in] *S points to an instance of the Q31 FIR decimator structure. 03275 * @param[in] *pSrc points to the block of input data. 03276 * @param[out] *pDst points to the block of output data 03277 * @param[in] blockSize number of input samples to process per call. 03278 * @return none 03279 */ 03280 03281 void arm_fir_decimate_q31( 03282 const arm_fir_decimate_instance_q31 * S, 03283 q31_t * pSrc, 03284 q31_t * pDst, 03285 uint32_t blockSize); 03286 03287 /** 03288 * @brief Processing function for the Q31 FIR decimator (fast variant). 03289 * @param[in] *S points to an instance of the Q31 FIR decimator structure. 03290 * @param[in] *pSrc points to the block of input data. 03291 * @param[out] *pDst points to the block of output data 03292 * @param[in] blockSize number of input samples to process per call. 03293 * @return none 03294 */ 03295 03296 void arm_fir_decimate_fast_q31( 03297 arm_fir_decimate_instance_q31 * S, 03298 q31_t * pSrc, 03299 q31_t * pDst, 03300 uint32_t blockSize); 03301 03302 03303 /** 03304 * @brief Initialization function for the Q31 FIR decimator. 03305 * @param[in,out] *S points to an instance of the Q31 FIR decimator structure. 03306 * @param[in] numTaps number of coefficients in the filter. 03307 * @param[in] M decimation factor. 03308 * @param[in] *pCoeffs points to the filter coefficients. 03309 * @param[in] *pState points to the state buffer. 03310 * @param[in] blockSize number of input samples to process per call. 03311 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if 03312 * <code>blockSize</code> is not a multiple of <code>M</code>. 03313 */ 03314 03315 arm_status arm_fir_decimate_init_q31( 03316 arm_fir_decimate_instance_q31 * S, 03317 uint16_t numTaps, 03318 uint8_t M, 03319 q31_t * pCoeffs, 03320 q31_t * pState, 03321 uint32_t blockSize); 03322 03323 03324 03325 /** 03326 * @brief Instance structure for the Q15 FIR interpolator. 03327 */ 03328 03329 typedef struct 03330 { 03331 uint8_t L; /**< upsample factor. */ 03332 uint16_t phaseLength; /**< length of each polyphase filter component. */ 03333 q15_t *pCoeffs; /**< points to the coefficient array. The array is of length L*phaseLength. */ 03334 q15_t *pState; /**< points to the state variable array. The array is of length blockSize+phaseLength-1. */ 03335 } arm_fir_interpolate_instance_q15; 03336 03337 /** 03338 * @brief Instance structure for the Q31 FIR interpolator. 03339 */ 03340 03341 typedef struct 03342 { 03343 uint8_t L; /**< upsample factor. */ 03344 uint16_t phaseLength; /**< length of each polyphase filter component. */ 03345 q31_t *pCoeffs; /**< points to the coefficient array. The array is of length L*phaseLength. */ 03346 q31_t *pState; /**< points to the state variable array. The array is of length blockSize+phaseLength-1. */ 03347 } arm_fir_interpolate_instance_q31; 03348 03349 /** 03350 * @brief Instance structure for the floating-point FIR interpolator. 03351 */ 03352 03353 typedef struct 03354 { 03355 uint8_t L; /**< upsample factor. */ 03356 uint16_t phaseLength; /**< length of each polyphase filter component. */ 03357 float32_t *pCoeffs; /**< points to the coefficient array. The array is of length L*phaseLength. */ 03358 float32_t *pState; /**< points to the state variable array. The array is of length phaseLength+numTaps-1. */ 03359 } arm_fir_interpolate_instance_f32; 03360 03361 03362 /** 03363 * @brief Processing function for the Q15 FIR interpolator. 03364 * @param[in] *S points to an instance of the Q15 FIR interpolator structure. 03365 * @param[in] *pSrc points to the block of input data. 03366 * @param[out] *pDst points to the block of output data. 03367 * @param[in] blockSize number of input samples to process per call. 03368 * @return none. 03369 */ 03370 03371 void arm_fir_interpolate_q15( 03372 const arm_fir_interpolate_instance_q15 * S, 03373 q15_t * pSrc, 03374 q15_t * pDst, 03375 uint32_t blockSize); 03376 03377 03378 /** 03379 * @brief Initialization function for the Q15 FIR interpolator. 03380 * @param[in,out] *S points to an instance of the Q15 FIR interpolator structure. 03381 * @param[in] L upsample factor. 03382 * @param[in] numTaps number of filter coefficients in the filter. 03383 * @param[in] *pCoeffs points to the filter coefficient buffer. 03384 * @param[in] *pState points to the state buffer. 03385 * @param[in] blockSize number of input samples to process per call. 03386 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if 03387 * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>. 03388 */ 03389 03390 arm_status arm_fir_interpolate_init_q15( 03391 arm_fir_interpolate_instance_q15 * S, 03392 uint8_t L, 03393 uint16_t numTaps, 03394 q15_t * pCoeffs, 03395 q15_t * pState, 03396 uint32_t blockSize); 03397 03398 /** 03399 * @brief Processing function for the Q31 FIR interpolator. 03400 * @param[in] *S points to an instance of the Q15 FIR interpolator structure. 03401 * @param[in] *pSrc points to the block of input data. 03402 * @param[out] *pDst points to the block of output data. 03403 * @param[in] blockSize number of input samples to process per call. 03404 * @return none. 03405 */ 03406 03407 void arm_fir_interpolate_q31( 03408 const arm_fir_interpolate_instance_q31 * S, 03409 q31_t * pSrc, 03410 q31_t * pDst, 03411 uint32_t blockSize); 03412 03413 /** 03414 * @brief Initialization function for the Q31 FIR interpolator. 03415 * @param[in,out] *S points to an instance of the Q31 FIR interpolator structure. 03416 * @param[in] L upsample factor. 03417 * @param[in] numTaps number of filter coefficients in the filter. 03418 * @param[in] *pCoeffs points to the filter coefficient buffer. 03419 * @param[in] *pState points to the state buffer. 03420 * @param[in] blockSize number of input samples to process per call. 03421 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if 03422 * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>. 03423 */ 03424 03425 arm_status arm_fir_interpolate_init_q31( 03426 arm_fir_interpolate_instance_q31 * S, 03427 uint8_t L, 03428 uint16_t numTaps, 03429 q31_t * pCoeffs, 03430 q31_t * pState, 03431 uint32_t blockSize); 03432 03433 03434 /** 03435 * @brief Processing function for the floating-point FIR interpolator. 03436 * @param[in] *S points to an instance of the floating-point FIR interpolator structure. 03437 * @param[in] *pSrc points to the block of input data. 03438 * @param[out] *pDst points to the block of output data. 03439 * @param[in] blockSize number of input samples to process per call. 03440 * @return none. 03441 */ 03442 03443 void arm_fir_interpolate_f32( 03444 const arm_fir_interpolate_instance_f32 * S, 03445 float32_t * pSrc, 03446 float32_t * pDst, 03447 uint32_t blockSize); 03448 03449 /** 03450 * @brief Initialization function for the floating-point FIR interpolator. 03451 * @param[in,out] *S points to an instance of the floating-point FIR interpolator structure. 03452 * @param[in] L upsample factor. 03453 * @param[in] numTaps number of filter coefficients in the filter. 03454 * @param[in] *pCoeffs points to the filter coefficient buffer. 03455 * @param[in] *pState points to the state buffer. 03456 * @param[in] blockSize number of input samples to process per call. 03457 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if 03458 * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>. 03459 */ 03460 03461 arm_status arm_fir_interpolate_init_f32( 03462 arm_fir_interpolate_instance_f32 * S, 03463 uint8_t L, 03464 uint16_t numTaps, 03465 float32_t * pCoeffs, 03466 float32_t * pState, 03467 uint32_t blockSize); 03468 03469 /** 03470 * @brief Instance structure for the high precision Q31 Biquad cascade filter. 03471 */ 03472 03473 typedef struct 03474 { 03475 uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */ 03476 q63_t *pState; /**< points to the array of state coefficients. The array is of length 4*numStages. */ 03477 q31_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */ 03478 uint8_t postShift; /**< additional shift, in bits, applied to each output sample. */ 03479 03480 } arm_biquad_cas_df1_32x64_ins_q31; 03481 03482 03483 /** 03484 * @param[in] *S points to an instance of the high precision Q31 Biquad cascade filter structure. 03485 * @param[in] *pSrc points to the block of input data. 03486 * @param[out] *pDst points to the block of output data 03487 * @param[in] blockSize number of samples to process. 03488 * @return none. 03489 */ 03490 03491 void arm_biquad_cas_df1_32x64_q31 ( 03492 const arm_biquad_cas_df1_32x64_ins_q31 * S, 03493 q31_t * pSrc, 03494 q31_t * pDst, 03495 uint32_t blockSize); 03496 03497 03498 /** 03499 * @param[in,out] *S points to an instance of the high precision Q31 Biquad cascade filter structure. 03500 * @param[in] numStages number of 2nd order stages in the filter. 03501 * @param[in] *pCoeffs points to the filter coefficients. 03502 * @param[in] *pState points to the state buffer. 03503 * @param[in] postShift shift to be applied to the output. Varies according to the coefficients format 03504 * @return none 03505 */ 03506 03507 void arm_biquad_cas_df1_32x64_init_q31 ( 03508 arm_biquad_cas_df1_32x64_ins_q31 * S, 03509 uint8_t numStages, 03510 q31_t * pCoeffs, 03511 q63_t * pState, 03512 uint8_t postShift); 03513 03514 03515 03516 /** 03517 * @brief Instance structure for the floating-point transposed direct form II Biquad cascade filter. 03518 */ 03519 03520 typedef struct 03521 { 03522 uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */ 03523 float32_t *pState; /**< points to the array of state coefficients. The array is of length 2*numStages. */ 03524 float32_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */ 03525 } arm_biquad_cascade_df2T_instance_f32; 03526 03527 03528 /** 03529 * @brief Processing function for the floating-point transposed direct form II Biquad cascade filter. 03530 * @param[in] *S points to an instance of the filter data structure. 03531 * @param[in] *pSrc points to the block of input data. 03532 * @param[out] *pDst points to the block of output data 03533 * @param[in] blockSize number of samples to process. 03534 * @return none. 03535 */ 03536 03537 void arm_biquad_cascade_df2T_f32( 03538 const arm_biquad_cascade_df2T_instance_f32 * S, 03539 float32_t * pSrc, 03540 float32_t * pDst, 03541 uint32_t blockSize); 03542 03543 03544 /** 03545 * @brief Initialization function for the floating-point transposed direct form II Biquad cascade filter. 03546 * @param[in,out] *S points to an instance of the filter data structure. 03547 * @param[in] numStages number of 2nd order stages in the filter. 03548 * @param[in] *pCoeffs points to the filter coefficients. 03549 * @param[in] *pState points to the state buffer. 03550 * @return none 03551 */ 03552 03553 void arm_biquad_cascade_df2T_init_f32( 03554 arm_biquad_cascade_df2T_instance_f32 * S, 03555 uint8_t numStages, 03556 float32_t * pCoeffs, 03557 float32_t * pState); 03558 03559 03560 03561 /** 03562 * @brief Instance structure for the Q15 FIR lattice filter. 03563 */ 03564 03565 typedef struct 03566 { 03567 uint16_t numStages; /**< number of filter stages. */ 03568 q15_t *pState; /**< points to the state variable array. The array is of length numStages. */ 03569 q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numStages. */ 03570 } arm_fir_lattice_instance_q15; 03571 03572 /** 03573 * @brief Instance structure for the Q31 FIR lattice filter. 03574 */ 03575 03576 typedef struct 03577 { 03578 uint16_t numStages; /**< number of filter stages. */ 03579 q31_t *pState; /**< points to the state variable array. The array is of length numStages. */ 03580 q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numStages. */ 03581 } arm_fir_lattice_instance_q31; 03582 03583 /** 03584 * @brief Instance structure for the floating-point FIR lattice filter. 03585 */ 03586 03587 typedef struct 03588 { 03589 uint16_t numStages; /**< number of filter stages. */ 03590 float32_t *pState; /**< points to the state variable array. The array is of length numStages. */ 03591 float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numStages. */ 03592 } arm_fir_lattice_instance_f32; 03593 03594 /** 03595 * @brief Initialization function for the Q15 FIR lattice filter. 03596 * @param[in] *S points to an instance of the Q15 FIR lattice structure. 03597 * @param[in] numStages number of filter stages. 03598 * @param[in] *pCoeffs points to the coefficient buffer. The array is of length numStages. 03599 * @param[in] *pState points to the state buffer. The array is of length numStages. 03600 * @return none. 03601 */ 03602 03603 void arm_fir_lattice_init_q15( 03604 arm_fir_lattice_instance_q15 * S, 03605 uint16_t numStages, 03606 q15_t * pCoeffs, 03607 q15_t * pState); 03608 03609 03610 /** 03611 * @brief Processing function for the Q15 FIR lattice filter. 03612 * @param[in] *S points to an instance of the Q15 FIR lattice structure. 03613 * @param[in] *pSrc points to the block of input data. 03614 * @param[out] *pDst points to the block of output data. 03615 * @param[in] blockSize number of samples to process. 03616 * @return none. 03617 */ 03618 void arm_fir_lattice_q15( 03619 const arm_fir_lattice_instance_q15 * S, 03620 q15_t * pSrc, 03621 q15_t * pDst, 03622 uint32_t blockSize); 03623 03624 /** 03625 * @brief Initialization function for the Q31 FIR lattice filter. 03626 * @param[in] *S points to an instance of the Q31 FIR lattice structure. 03627 * @param[in] numStages number of filter stages. 03628 * @param[in] *pCoeffs points to the coefficient buffer. The array is of length numStages. 03629 * @param[in] *pState points to the state buffer. The array is of length numStages. 03630 * @return none. 03631 */ 03632 03633 void arm_fir_lattice_init_q31( 03634 arm_fir_lattice_instance_q31 * S, 03635 uint16_t numStages, 03636 q31_t * pCoeffs, 03637 q31_t * pState); 03638 03639 03640 /** 03641 * @brief Processing function for the Q31 FIR lattice filter. 03642 * @param[in] *S points to an instance of the Q31 FIR lattice structure. 03643 * @param[in] *pSrc points to the block of input data. 03644 * @param[out] *pDst points to the block of output data 03645 * @param[in] blockSize number of samples to process. 03646 * @return none. 03647 */ 03648 03649 void arm_fir_lattice_q31( 03650 const arm_fir_lattice_instance_q31 * S, 03651 q31_t * pSrc, 03652 q31_t * pDst, 03653 uint32_t blockSize); 03654 03655 /** 03656 * @brief Initialization function for the floating-point FIR lattice filter. 03657 * @param[in] *S points to an instance of the floating-point FIR lattice structure. 03658 * @param[in] numStages number of filter stages. 03659 * @param[in] *pCoeffs points to the coefficient buffer. The array is of length numStages. 03660 * @param[in] *pState points to the state buffer. The array is of length numStages. 03661 * @return none. 03662 */ 03663 03664 void arm_fir_lattice_init_f32( 03665 arm_fir_lattice_instance_f32 * S, 03666 uint16_t numStages, 03667 float32_t * pCoeffs, 03668 float32_t * pState); 03669 03670 /** 03671 * @brief Processing function for the floating-point FIR lattice filter. 03672 * @param[in] *S points to an instance of the floating-point FIR lattice structure. 03673 * @param[in] *pSrc points to the block of input data. 03674 * @param[out] *pDst points to the block of output data 03675 * @param[in] blockSize number of samples to process. 03676 * @return none. 03677 */ 03678 03679 void arm_fir_lattice_f32( 03680 const arm_fir_lattice_instance_f32 * S, 03681 float32_t * pSrc, 03682 float32_t * pDst, 03683 uint32_t blockSize); 03684 03685 /** 03686 * @brief Instance structure for the Q15 IIR lattice filter. 03687 */ 03688 typedef struct 03689 { 03690 uint16_t numStages; /**< number of stages in the filter. */ 03691 q15_t *pState; /**< points to the state variable array. The array is of length numStages+blockSize. */ 03692 q15_t *pkCoeffs; /**< points to the reflection coefficient array. The array is of length numStages. */ 03693 q15_t *pvCoeffs; /**< points to the ladder coefficient array. The array is of length numStages+1. */ 03694 } arm_iir_lattice_instance_q15; 03695 03696 /** 03697 * @brief Instance structure for the Q31 IIR lattice filter. 03698 */ 03699 typedef struct 03700 { 03701 uint16_t numStages; /**< number of stages in the filter. */ 03702 q31_t *pState; /**< points to the state variable array. The array is of length numStages+blockSize. */ 03703 q31_t *pkCoeffs; /**< points to the reflection coefficient array. The array is of length numStages. */ 03704 q31_t *pvCoeffs; /**< points to the ladder coefficient array. The array is of length numStages+1. */ 03705 } arm_iir_lattice_instance_q31; 03706 03707 /** 03708 * @brief Instance structure for the floating-point IIR lattice filter. 03709 */ 03710 typedef struct 03711 { 03712 uint16_t numStages; /**< number of stages in the filter. */ 03713 float32_t *pState; /**< points to the state variable array. The array is of length numStages+blockSize. */ 03714 float32_t *pkCoeffs; /**< points to the reflection coefficient array. The array is of length numStages. */ 03715 float32_t *pvCoeffs; /**< points to the ladder coefficient array. The array is of length numStages+1. */ 03716 } arm_iir_lattice_instance_f32; 03717 03718 /** 03719 * @brief Processing function for the floating-point IIR lattice filter. 03720 * @param[in] *S points to an instance of the floating-point IIR lattice structure. 03721 * @param[in] *pSrc points to the block of input data. 03722 * @param[out] *pDst points to the block of output data. 03723 * @param[in] blockSize number of samples to process. 03724 * @return none. 03725 */ 03726 03727 void arm_iir_lattice_f32( 03728 const arm_iir_lattice_instance_f32 * S, 03729 float32_t * pSrc, 03730 float32_t * pDst, 03731 uint32_t blockSize); 03732 03733 /** 03734 * @brief Initialization function for the floating-point IIR lattice filter. 03735 * @param[in] *S points to an instance of the floating-point IIR lattice structure. 03736 * @param[in] numStages number of stages in the filter. 03737 * @param[in] *pkCoeffs points to the reflection coefficient buffer. The array is of length numStages. 03738 * @param[in] *pvCoeffs points to the ladder coefficient buffer. The array is of length numStages+1. 03739 * @param[in] *pState points to the state buffer. The array is of length numStages+blockSize-1. 03740 * @param[in] blockSize number of samples to process. 03741 * @return none. 03742 */ 03743 03744 void arm_iir_lattice_init_f32( 03745 arm_iir_lattice_instance_f32 * S, 03746 uint16_t numStages, 03747 float32_t *pkCoeffs, 03748 float32_t *pvCoeffs, 03749 float32_t *pState, 03750 uint32_t blockSize); 03751 03752 03753 /** 03754 * @brief Processing function for the Q31 IIR lattice filter. 03755 * @param[in] *S points to an instance of the Q31 IIR lattice structure. 03756 * @param[in] *pSrc points to the block of input data. 03757 * @param[out] *pDst points to the block of output data. 03758 * @param[in] blockSize number of samples to process. 03759 * @return none. 03760 */ 03761 03762 void arm_iir_lattice_q31( 03763 const arm_iir_lattice_instance_q31 * S, 03764 q31_t * pSrc, 03765 q31_t * pDst, 03766 uint32_t blockSize); 03767 03768 03769 /** 03770 * @brief Initialization function for the Q31 IIR lattice filter. 03771 * @param[in] *S points to an instance of the Q31 IIR lattice structure. 03772 * @param[in] numStages number of stages in the filter. 03773 * @param[in] *pkCoeffs points to the reflection coefficient buffer. The array is of length numStages. 03774 * @param[in] *pvCoeffs points to the ladder coefficient buffer. The array is of length numStages+1. 03775 * @param[in] *pState points to the state buffer. The array is of length numStages+blockSize. 03776 * @param[in] blockSize number of samples to process. 03777 * @return none. 03778 */ 03779 03780 void arm_iir_lattice_init_q31( 03781 arm_iir_lattice_instance_q31 * S, 03782 uint16_t numStages, 03783 q31_t *pkCoeffs, 03784 q31_t *pvCoeffs, 03785 q31_t *pState, 03786 uint32_t blockSize); 03787 03788 03789 /** 03790 * @brief Processing function for the Q15 IIR lattice filter. 03791 * @param[in] *S points to an instance of the Q15 IIR lattice structure. 03792 * @param[in] *pSrc points to the block of input data. 03793 * @param[out] *pDst points to the block of output data. 03794 * @param[in] blockSize number of samples to process. 03795 * @return none. 03796 */ 03797 03798 void arm_iir_lattice_q15( 03799 const arm_iir_lattice_instance_q15 * S, 03800 q15_t * pSrc, 03801 q15_t * pDst, 03802 uint32_t blockSize); 03803 03804 03805 /** 03806 * @brief Initialization function for the Q15 IIR lattice filter. 03807 * @param[in] *S points to an instance of the fixed-point Q15 IIR lattice structure. 03808 * @param[in] numStages number of stages in the filter. 03809 * @param[in] *pkCoeffs points to reflection coefficient buffer. The array is of length numStages. 03810 * @param[in] *pvCoeffs points to ladder coefficient buffer. The array is of length numStages+1. 03811 * @param[in] *pState points to state buffer. The array is of length numStages+blockSize. 03812 * @param[in] blockSize number of samples to process per call. 03813 * @return none. 03814 */ 03815 03816 void arm_iir_lattice_init_q15( 03817 arm_iir_lattice_instance_q15 * S, 03818 uint16_t numStages, 03819 q15_t *pkCoeffs, 03820 q15_t *pvCoeffs, 03821 q15_t *pState, 03822 uint32_t blockSize); 03823 03824 /** 03825 * @brief Instance structure for the floating-point LMS filter. 03826 */ 03827 03828 typedef struct 03829 { 03830 uint16_t numTaps; /**< number of coefficients in the filter. */ 03831 float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 03832 float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ 03833 float32_t mu; /**< step size that controls filter coefficient updates. */ 03834 } arm_lms_instance_f32; 03835 03836 /** 03837 * @brief Processing function for floating-point LMS filter. 03838 * @param[in] *S points to an instance of the floating-point LMS filter structure. 03839 * @param[in] *pSrc points to the block of input data. 03840 * @param[in] *pRef points to the block of reference data. 03841 * @param[out] *pOut points to the block of output data. 03842 * @param[out] *pErr points to the block of error data. 03843 * @param[in] blockSize number of samples to process. 03844 * @return none. 03845 */ 03846 03847 void arm_lms_f32( 03848 const arm_lms_instance_f32 * S, 03849 float32_t * pSrc, 03850 float32_t * pRef, 03851 float32_t * pOut, 03852 float32_t * pErr, 03853 uint32_t blockSize); 03854 03855 /** 03856 * @brief Initialization function for floating-point LMS filter. 03857 * @param[in] *S points to an instance of the floating-point LMS filter structure. 03858 * @param[in] numTaps number of filter coefficients. 03859 * @param[in] *pCoeffs points to the coefficient buffer. 03860 * @param[in] *pState points to state buffer. 03861 * @param[in] mu step size that controls filter coefficient updates. 03862 * @param[in] blockSize number of samples to process. 03863 * @return none. 03864 */ 03865 03866 void arm_lms_init_f32( 03867 arm_lms_instance_f32 * S, 03868 uint16_t numTaps, 03869 float32_t * pCoeffs, 03870 float32_t * pState, 03871 float32_t mu, 03872 uint32_t blockSize); 03873 03874 /** 03875 * @brief Instance structure for the Q15 LMS filter. 03876 */ 03877 03878 typedef struct 03879 { 03880 uint16_t numTaps; /**< number of coefficients in the filter. */ 03881 q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 03882 q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ 03883 q15_t mu; /**< step size that controls filter coefficient updates. */ 03884 uint32_t postShift; /**< bit shift applied to coefficients. */ 03885 } arm_lms_instance_q15; 03886 03887 03888 /** 03889 * @brief Initialization function for the Q15 LMS filter. 03890 * @param[in] *S points to an instance of the Q15 LMS filter structure. 03891 * @param[in] numTaps number of filter coefficients. 03892 * @param[in] *pCoeffs points to the coefficient buffer. 03893 * @param[in] *pState points to the state buffer. 03894 * @param[in] mu step size that controls filter coefficient updates. 03895 * @param[in] blockSize number of samples to process. 03896 * @param[in] postShift bit shift applied to coefficients. 03897 * @return none. 03898 */ 03899 03900 void arm_lms_init_q15( 03901 arm_lms_instance_q15 * S, 03902 uint16_t numTaps, 03903 q15_t * pCoeffs, 03904 q15_t * pState, 03905 q15_t mu, 03906 uint32_t blockSize, 03907 uint32_t postShift); 03908 03909 /** 03910 * @brief Processing function for Q15 LMS filter. 03911 * @param[in] *S points to an instance of the Q15 LMS filter structure. 03912 * @param[in] *pSrc points to the block of input data. 03913 * @param[in] *pRef points to the block of reference data. 03914 * @param[out] *pOut points to the block of output data. 03915 * @param[out] *pErr points to the block of error data. 03916 * @param[in] blockSize number of samples to process. 03917 * @return none. 03918 */ 03919 03920 void arm_lms_q15( 03921 const arm_lms_instance_q15 * S, 03922 q15_t * pSrc, 03923 q15_t * pRef, 03924 q15_t * pOut, 03925 q15_t * pErr, 03926 uint32_t blockSize); 03927 03928 03929 /** 03930 * @brief Instance structure for the Q31 LMS filter. 03931 */ 03932 03933 typedef struct 03934 { 03935 uint16_t numTaps; /**< number of coefficients in the filter. */ 03936 q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 03937 q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ 03938 q31_t mu; /**< step size that controls filter coefficient updates. */ 03939 uint32_t postShift; /**< bit shift applied to coefficients. */ 03940 03941 } arm_lms_instance_q31; 03942 03943 /** 03944 * @brief Processing function for Q31 LMS filter. 03945 * @param[in] *S points to an instance of the Q15 LMS filter structure. 03946 * @param[in] *pSrc points to the block of input data. 03947 * @param[in] *pRef points to the block of reference data. 03948 * @param[out] *pOut points to the block of output data. 03949 * @param[out] *pErr points to the block of error data. 03950 * @param[in] blockSize number of samples to process. 03951 * @return none. 03952 */ 03953 03954 void arm_lms_q31( 03955 const arm_lms_instance_q31 * S, 03956 q31_t * pSrc, 03957 q31_t * pRef, 03958 q31_t * pOut, 03959 q31_t * pErr, 03960 uint32_t blockSize); 03961 03962 /** 03963 * @brief Initialization function for Q31 LMS filter. 03964 * @param[in] *S points to an instance of the Q31 LMS filter structure. 03965 * @param[in] numTaps number of filter coefficients. 03966 * @param[in] *pCoeffs points to coefficient buffer. 03967 * @param[in] *pState points to state buffer. 03968 * @param[in] mu step size that controls filter coefficient updates. 03969 * @param[in] blockSize number of samples to process. 03970 * @param[in] postShift bit shift applied to coefficients. 03971 * @return none. 03972 */ 03973 03974 void arm_lms_init_q31( 03975 arm_lms_instance_q31 * S, 03976 uint16_t numTaps, 03977 q31_t *pCoeffs, 03978 q31_t *pState, 03979 q31_t mu, 03980 uint32_t blockSize, 03981 uint32_t postShift); 03982 03983 /** 03984 * @brief Instance structure for the floating-point normalized LMS filter. 03985 */ 03986 03987 typedef struct 03988 { 03989 uint16_t numTaps; /**< number of coefficients in the filter. */ 03990 float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 03991 float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ 03992 float32_t mu; /**< step size that control filter coefficient updates. */ 03993 float32_t energy; /**< saves previous frame energy. */ 03994 float32_t x0; /**< saves previous input sample. */ 03995 } arm_lms_norm_instance_f32; 03996 03997 /** 03998 * @brief Processing function for floating-point normalized LMS filter. 03999 * @param[in] *S points to an instance of the floating-point normalized LMS filter structure. 04000 * @param[in] *pSrc points to the block of input data. 04001 * @param[in] *pRef points to the block of reference data. 04002 * @param[out] *pOut points to the block of output data. 04003 * @param[out] *pErr points to the block of error data. 04004 * @param[in] blockSize number of samples to process. 04005 * @return none. 04006 */ 04007 04008 void arm_lms_norm_f32( 04009 arm_lms_norm_instance_f32 * S, 04010 float32_t * pSrc, 04011 float32_t * pRef, 04012 float32_t * pOut, 04013 float32_t * pErr, 04014 uint32_t blockSize); 04015 04016 /** 04017 * @brief Initialization function for floating-point normalized LMS filter. 04018 * @param[in] *S points to an instance of the floating-point LMS filter structure. 04019 * @param[in] numTaps number of filter coefficients. 04020 * @param[in] *pCoeffs points to coefficient buffer. 04021 * @param[in] *pState points to state buffer. 04022 * @param[in] mu step size that controls filter coefficient updates. 04023 * @param[in] blockSize number of samples to process. 04024 * @return none. 04025 */ 04026 04027 void arm_lms_norm_init_f32( 04028 arm_lms_norm_instance_f32 * S, 04029 uint16_t numTaps, 04030 float32_t * pCoeffs, 04031 float32_t * pState, 04032 float32_t mu, 04033 uint32_t blockSize); 04034 04035 04036 /** 04037 * @brief Instance structure for the Q31 normalized LMS filter. 04038 */ 04039 typedef struct 04040 { 04041 uint16_t numTaps; /**< number of coefficients in the filter. */ 04042 q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 04043 q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ 04044 q31_t mu; /**< step size that controls filter coefficient updates. */ 04045 uint8_t postShift; /**< bit shift applied to coefficients. */ 04046 q31_t *recipTable; /**< points to the reciprocal initial value table. */ 04047 q31_t energy; /**< saves previous frame energy. */ 04048 q31_t x0; /**< saves previous input sample. */ 04049 } arm_lms_norm_instance_q31; 04050 04051 /** 04052 * @brief Processing function for Q31 normalized LMS filter. 04053 * @param[in] *S points to an instance of the Q31 normalized LMS filter structure. 04054 * @param[in] *pSrc points to the block of input data. 04055 * @param[in] *pRef points to the block of reference data. 04056 * @param[out] *pOut points to the block of output data. 04057 * @param[out] *pErr points to the block of error data. 04058 * @param[in] blockSize number of samples to process. 04059 * @return none. 04060 */ 04061 04062 void arm_lms_norm_q31( 04063 arm_lms_norm_instance_q31 * S, 04064 q31_t * pSrc, 04065 q31_t * pRef, 04066 q31_t * pOut, 04067 q31_t * pErr, 04068 uint32_t blockSize); 04069 04070 /** 04071 * @brief Initialization function for Q31 normalized LMS filter. 04072 * @param[in] *S points to an instance of the Q31 normalized LMS filter structure. 04073 * @param[in] numTaps number of filter coefficients. 04074 * @param[in] *pCoeffs points to coefficient buffer. 04075 * @param[in] *pState points to state buffer. 04076 * @param[in] mu step size that controls filter coefficient updates. 04077 * @param[in] blockSize number of samples to process. 04078 * @param[in] postShift bit shift applied to coefficients. 04079 * @return none. 04080 */ 04081 04082 void arm_lms_norm_init_q31( 04083 arm_lms_norm_instance_q31 * S, 04084 uint16_t numTaps, 04085 q31_t * pCoeffs, 04086 q31_t * pState, 04087 q31_t mu, 04088 uint32_t blockSize, 04089 uint8_t postShift); 04090 04091 /** 04092 * @brief Instance structure for the Q15 normalized LMS filter. 04093 */ 04094 04095 typedef struct 04096 { 04097 uint16_t numTaps; /**< Number of coefficients in the filter. */ 04098 q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 04099 q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ 04100 q15_t mu; /**< step size that controls filter coefficient updates. */ 04101 uint8_t postShift; /**< bit shift applied to coefficients. */ 04102 q15_t *recipTable; /**< Points to the reciprocal initial value table. */ 04103 q15_t energy; /**< saves previous frame energy. */ 04104 q15_t x0; /**< saves previous input sample. */ 04105 } arm_lms_norm_instance_q15; 04106 04107 /** 04108 * @brief Processing function for Q15 normalized LMS filter. 04109 * @param[in] *S points to an instance of the Q15 normalized LMS filter structure. 04110 * @param[in] *pSrc points to the block of input data. 04111 * @param[in] *pRef points to the block of reference data. 04112 * @param[out] *pOut points to the block of output data. 04113 * @param[out] *pErr points to the block of error data. 04114 * @param[in] blockSize number of samples to process. 04115 * @return none. 04116 */ 04117 04118 void arm_lms_norm_q15( 04119 arm_lms_norm_instance_q15 * S, 04120 q15_t * pSrc, 04121 q15_t * pRef, 04122 q15_t * pOut, 04123 q15_t * pErr, 04124 uint32_t blockSize); 04125 04126 04127 /** 04128 * @brief Initialization function for Q15 normalized LMS filter. 04129 * @param[in] *S points to an instance of the Q15 normalized LMS filter structure. 04130 * @param[in] numTaps number of filter coefficients. 04131 * @param[in] *pCoeffs points to coefficient buffer. 04132 * @param[in] *pState points to state buffer. 04133 * @param[in] mu step size that controls filter coefficient updates. 04134 * @param[in] blockSize number of samples to process. 04135 * @param[in] postShift bit shift applied to coefficients. 04136 * @return none. 04137 */ 04138 04139 void arm_lms_norm_init_q15( 04140 arm_lms_norm_instance_q15 * S, 04141 uint16_t numTaps, 04142 q15_t * pCoeffs, 04143 q15_t * pState, 04144 q15_t mu, 04145 uint32_t blockSize, 04146 uint8_t postShift); 04147 04148 /** 04149 * @brief Correlation of floating-point sequences. 04150 * @param[in] *pSrcA points to the first input sequence. 04151 * @param[in] srcALen length of the first input sequence. 04152 * @param[in] *pSrcB points to the second input sequence. 04153 * @param[in] srcBLen length of the second input sequence. 04154 * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. 04155 * @return none. 04156 */ 04157 04158 void arm_correlate_f32( 04159 float32_t * pSrcA, 04160 uint32_t srcALen, 04161 float32_t * pSrcB, 04162 uint32_t srcBLen, 04163 float32_t * pDst); 04164 04165 /** 04166 * @brief Correlation of Q15 sequences 04167 * @param[in] *pSrcA points to the first input sequence. 04168 * @param[in] srcALen length of the first input sequence. 04169 * @param[in] *pSrcB points to the second input sequence. 04170 * @param[in] srcBLen length of the second input sequence. 04171 * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. 04172 * @return none. 04173 */ 04174 04175 void arm_correlate_q15( 04176 q15_t * pSrcA, 04177 uint32_t srcALen, 04178 q15_t * pSrcB, 04179 uint32_t srcBLen, 04180 q15_t * pDst); 04181 04182 /** 04183 * @brief Correlation of Q15 sequences (fast version). 04184 * @param[in] *pSrcA points to the first input sequence. 04185 * @param[in] srcALen length of the first input sequence. 04186 * @param[in] *pSrcB points to the second input sequence. 04187 * @param[in] srcBLen length of the second input sequence. 04188 * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. 04189 * @return none. 04190 */ 04191 04192 void arm_correlate_fast_q15( 04193 q15_t * pSrcA, 04194 uint32_t srcALen, 04195 q15_t * pSrcB, 04196 uint32_t srcBLen, 04197 q15_t * pDst); 04198 04199 /** 04200 * @brief Correlate Q31 sequences 04201 * @param[in] *pSrcA points to the first input sequence. 04202 * @param[in] srcALen length of the first input sequence. 04203 * @param[in] *pSrcB points to the second input sequence. 04204 * @param[in] srcBLen length of the second input sequence. 04205 * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. 04206 * @return none. 04207 */ 04208 04209 void arm_correlate_q31( 04210 q31_t * pSrcA, 04211 uint32_t srcALen, 04212 q31_t * pSrcB, 04213 uint32_t srcBLen, 04214 q31_t * pDst); 04215 04216 /** 04217 * @brief Correlate Q31 sequences (fast version) 04218 * @param[in] *pSrcA points to the first input sequence. 04219 * @param[in] srcALen length of the first input sequence. 04220 * @param[in] *pSrcB points to the second input sequence. 04221 * @param[in] srcBLen length of the second input sequence. 04222 * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. 04223 * @return none. 04224 */ 04225 04226 void arm_correlate_fast_q31( 04227 q31_t * pSrcA, 04228 uint32_t srcALen, 04229 q31_t * pSrcB, 04230 uint32_t srcBLen, 04231 q31_t * pDst); 04232 04233 /** 04234 * @brief Correlation of Q7 sequences. 04235 * @param[in] *pSrcA points to the first input sequence. 04236 * @param[in] srcALen length of the first input sequence. 04237 * @param[in] *pSrcB points to the second input sequence. 04238 * @param[in] srcBLen length of the second input sequence. 04239 * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. 04240 * @return none. 04241 */ 04242 04243 void arm_correlate_q7( 04244 q7_t * pSrcA, 04245 uint32_t srcALen, 04246 q7_t * pSrcB, 04247 uint32_t srcBLen, 04248 q7_t * pDst); 04249 04250 /** 04251 * @brief Instance structure for the floating-point sparse FIR filter. 04252 */ 04253 typedef struct 04254 { 04255 uint16_t numTaps; /**< number of coefficients in the filter. */ 04256 uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */ 04257 float32_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */ 04258 float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ 04259 uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */ 04260 int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */ 04261 } arm_fir_sparse_instance_f32; 04262 04263 /** 04264 * @brief Instance structure for the Q31 sparse FIR filter. 04265 */ 04266 04267 typedef struct 04268 { 04269 uint16_t numTaps; /**< number of coefficients in the filter. */ 04270 uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */ 04271 q31_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */ 04272 q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ 04273 uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */ 04274 int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */ 04275 } arm_fir_sparse_instance_q31; 04276 04277 /** 04278 * @brief Instance structure for the Q15 sparse FIR filter. 04279 */ 04280 04281 typedef struct 04282 { 04283 uint16_t numTaps; /**< number of coefficients in the filter. */ 04284 uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */ 04285 q15_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */ 04286 q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ 04287 uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */ 04288 int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */ 04289 } arm_fir_sparse_instance_q15; 04290 04291 /** 04292 * @brief Instance structure for the Q7 sparse FIR filter. 04293 */ 04294 04295 typedef struct 04296 { 04297 uint16_t numTaps; /**< number of coefficients in the filter. */ 04298 uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */ 04299 q7_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */ 04300 q7_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ 04301 uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */ 04302 int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */ 04303 } arm_fir_sparse_instance_q7; 04304 04305 /** 04306 * @brief Processing function for the floating-point sparse FIR filter. 04307 * @param[in] *S points to an instance of the floating-point sparse FIR structure. 04308 * @param[in] *pSrc points to the block of input data. 04309 * @param[out] *pDst points to the block of output data 04310 * @param[in] *pScratchIn points to a temporary buffer of size blockSize. 04311 * @param[in] blockSize number of input samples to process per call. 04312 * @return none. 04313 */ 04314 04315 void arm_fir_sparse_f32( 04316 arm_fir_sparse_instance_f32 * S, 04317 float32_t * pSrc, 04318 float32_t * pDst, 04319 float32_t * pScratchIn, 04320 uint32_t blockSize); 04321 04322 /** 04323 * @brief Initialization function for the floating-point sparse FIR filter. 04324 * @param[in,out] *S points to an instance of the floating-point sparse FIR structure. 04325 * @param[in] numTaps number of nonzero coefficients in the filter. 04326 * @param[in] *pCoeffs points to the array of filter coefficients. 04327 * @param[in] *pState points to the state buffer. 04328 * @param[in] *pTapDelay points to the array of offset times. 04329 * @param[in] maxDelay maximum offset time supported. 04330 * @param[in] blockSize number of samples that will be processed per block. 04331 * @return none 04332 */ 04333 04334 void arm_fir_sparse_init_f32( 04335 arm_fir_sparse_instance_f32 * S, 04336 uint16_t numTaps, 04337 float32_t * pCoeffs, 04338 float32_t * pState, 04339 int32_t * pTapDelay, 04340 uint16_t maxDelay, 04341 uint32_t blockSize); 04342 04343 /** 04344 * @brief Processing function for the Q31 sparse FIR filter. 04345 * @param[in] *S points to an instance of the Q31 sparse FIR structure. 04346 * @param[in] *pSrc points to the block of input data. 04347 * @param[out] *pDst points to the block of output data 04348 * @param[in] *pScratchIn points to a temporary buffer of size blockSize. 04349 * @param[in] blockSize number of input samples to process per call. 04350 * @return none. 04351 */ 04352 04353 void arm_fir_sparse_q31( 04354 arm_fir_sparse_instance_q31 * S, 04355 q31_t * pSrc, 04356 q31_t * pDst, 04357 q31_t * pScratchIn, 04358 uint32_t blockSize); 04359 04360 /** 04361 * @brief Initialization function for the Q31 sparse FIR filter. 04362 * @param[in,out] *S points to an instance of the Q31 sparse FIR structure. 04363 * @param[in] numTaps number of nonzero coefficients in the filter. 04364 * @param[in] *pCoeffs points to the array of filter coefficients. 04365 * @param[in] *pState points to the state buffer. 04366 * @param[in] *pTapDelay points to the array of offset times. 04367 * @param[in] maxDelay maximum offset time supported. 04368 * @param[in] blockSize number of samples that will be processed per block. 04369 * @return none 04370 */ 04371 04372 void arm_fir_sparse_init_q31( 04373 arm_fir_sparse_instance_q31 * S, 04374 uint16_t numTaps, 04375 q31_t * pCoeffs, 04376 q31_t * pState, 04377 int32_t * pTapDelay, 04378 uint16_t maxDelay, 04379 uint32_t blockSize); 04380 04381 /** 04382 * @brief Processing function for the Q15 sparse FIR filter. 04383 * @param[in] *S points to an instance of the Q15 sparse FIR structure. 04384 * @param[in] *pSrc points to the block of input data. 04385 * @param[out] *pDst points to the block of output data 04386 * @param[in] *pScratchIn points to a temporary buffer of size blockSize. 04387 * @param[in] *pScratchOut points to a temporary buffer of size blockSize. 04388 * @param[in] blockSize number of input samples to process per call. 04389 * @return none. 04390 */ 04391 04392 void arm_fir_sparse_q15( 04393 arm_fir_sparse_instance_q15 * S, 04394 q15_t * pSrc, 04395 q15_t * pDst, 04396 q15_t * pScratchIn, 04397 q31_t * pScratchOut, 04398 uint32_t blockSize); 04399 04400 04401 /** 04402 * @brief Initialization function for the Q15 sparse FIR filter. 04403 * @param[in,out] *S points to an instance of the Q15 sparse FIR structure. 04404 * @param[in] numTaps number of nonzero coefficients in the filter. 04405 * @param[in] *pCoeffs points to the array of filter coefficients. 04406 * @param[in] *pState points to the state buffer. 04407 * @param[in] *pTapDelay points to the array of offset times. 04408 * @param[in] maxDelay maximum offset time supported. 04409 * @param[in] blockSize number of samples that will be processed per block. 04410 * @return none 04411 */ 04412 04413 void arm_fir_sparse_init_q15( 04414 arm_fir_sparse_instance_q15 * S, 04415 uint16_t numTaps, 04416 q15_t * pCoeffs, 04417 q15_t * pState, 04418 int32_t * pTapDelay, 04419 uint16_t maxDelay, 04420 uint32_t blockSize); 04421 04422 /** 04423 * @brief Processing function for the Q7 sparse FIR filter. 04424 * @param[in] *S points to an instance of the Q7 sparse FIR structure. 04425 * @param[in] *pSrc points to the block of input data. 04426 * @param[out] *pDst points to the block of output data 04427 * @param[in] *pScratchIn points to a temporary buffer of size blockSize. 04428 * @param[in] *pScratchOut points to a temporary buffer of size blockSize. 04429 * @param[in] blockSize number of input samples to process per call. 04430 * @return none. 04431 */ 04432 04433 void arm_fir_sparse_q7( 04434 arm_fir_sparse_instance_q7 * S, 04435 q7_t * pSrc, 04436 q7_t * pDst, 04437 q7_t * pScratchIn, 04438 q31_t * pScratchOut, 04439 uint32_t blockSize); 04440 04441 /** 04442 * @brief Initialization function for the Q7 sparse FIR filter. 04443 * @param[in,out] *S points to an instance of the Q7 sparse FIR structure. 04444 * @param[in] numTaps number of nonzero coefficients in the filter. 04445 * @param[in] *pCoeffs points to the array of filter coefficients. 04446 * @param[in] *pState points to the state buffer. 04447 * @param[in] *pTapDelay points to the array of offset times. 04448 * @param[in] maxDelay maximum offset time supported. 04449 * @param[in] blockSize number of samples that will be processed per block. 04450 * @return none 04451 */ 04452 04453 void arm_fir_sparse_init_q7( 04454 arm_fir_sparse_instance_q7 * S, 04455 uint16_t numTaps, 04456 q7_t * pCoeffs, 04457 q7_t * pState, 04458 int32_t *pTapDelay, 04459 uint16_t maxDelay, 04460 uint32_t blockSize); 04461 04462 04463 /* 04464 * @brief Floating-point sin_cos function. 04465 * @param[in] theta input value in degrees 04466 * @param[out] *pSinVal points to the processed sine output. 04467 * @param[out] *pCosVal points to the processed cos output. 04468 * @return none. 04469 */ 04470 04471 void arm_sin_cos_f32( 04472 float32_t theta, 04473 float32_t *pSinVal, 04474 float32_t *pCcosVal); 04475 04476 /* 04477 * @brief Q31 sin_cos function. 04478 * @param[in] theta scaled input value in degrees 04479 * @param[out] *pSinVal points to the processed sine output. 04480 * @param[out] *pCosVal points to the processed cosine output. 04481 * @return none. 04482 */ 04483 04484 void arm_sin_cos_q31( 04485 q31_t theta, 04486 q31_t *pSinVal, 04487 q31_t *pCosVal); 04488 04489 04490 /** 04491 * @brief Floating-point complex conjugate. 04492 * @param[in] *pSrc points to the input vector 04493 * @param[out] *pDst points to the output vector 04494 * @param[in] numSamples number of complex samples in each vector 04495 * @return none. 04496 */ 04497 04498 void arm_cmplx_conj_f32( 04499 float32_t * pSrc, 04500 float32_t * pDst, 04501 uint32_t numSamples); 04502 04503 /** 04504 * @brief Q31 complex conjugate. 04505 * @param[in] *pSrc points to the input vector 04506 * @param[out] *pDst points to the output vector 04507 * @param[in] numSamples number of complex samples in each vector 04508 * @return none. 04509 */ 04510 04511 void arm_cmplx_conj_q31( 04512 q31_t * pSrc, 04513 q31_t * pDst, 04514 uint32_t numSamples); 04515 04516 /** 04517 * @brief Q15 complex conjugate. 04518 * @param[in] *pSrc points to the input vector 04519 * @param[out] *pDst points to the output vector 04520 * @param[in] numSamples number of complex samples in each vector 04521 * @return none. 04522 */ 04523 04524 void arm_cmplx_conj_q15( 04525 q15_t * pSrc, 04526 q15_t * pDst, 04527 uint32_t numSamples); 04528 04529 04530 04531 /** 04532 * @brief Floating-point complex magnitude squared 04533 * @param[in] *pSrc points to the complex input vector 04534 * @param[out] *pDst points to the real output vector 04535 * @param[in] numSamples number of complex samples in the input vector 04536 * @return none. 04537 */ 04538 04539 void arm_cmplx_mag_squared_f32( 04540 float32_t * pSrc, 04541 float32_t * pDst, 04542 uint32_t numSamples); 04543 04544 /** 04545 * @brief Q31 complex magnitude squared 04546 * @param[in] *pSrc points to the complex input vector 04547 * @param[out] *pDst points to the real output vector 04548 * @param[in] numSamples number of complex samples in the input vector 04549 * @return none. 04550 */ 04551 04552 void arm_cmplx_mag_squared_q31( 04553 q31_t * pSrc, 04554 q31_t * pDst, 04555 uint32_t numSamples); 04556 04557 /** 04558 * @brief Q15 complex magnitude squared 04559 * @param[in] *pSrc points to the complex input vector 04560 * @param[out] *pDst points to the real output vector 04561 * @param[in] numSamples number of complex samples in the input vector 04562 * @return none. 04563 */ 04564 04565 void arm_cmplx_mag_squared_q15( 04566 q15_t * pSrc, 04567 q15_t * pDst, 04568 uint32_t numSamples); 04569 04570 04571 /** 04572 * @ingroup groupController 04573 */ 04574 04575 /** 04576 * @defgroup PID PID Motor Control 04577 * 04578 * A Proportional Integral Derivative (PID) controller is a generic feedback control 04579 * loop mechanism widely used in industrial control systems. 04580 * A PID controller is the most commonly used type of feedback controller. 04581 * 04582 * This set of functions implements (PID) controllers 04583 * for Q15, Q31, and floating-point data types. The functions operate on a single sample 04584 * of data and each call to the function returns a single processed value. 04585 * <code>S</code> points to an instance of the PID control data structure. <code>in</code> 04586 * is the input sample value. The functions return the output value. 04587 * 04588 * \par Algorithm: 04589 * <pre> 04590 * y[n] = y[n-1] + A0 * x[n] + A1 * x[n-1] + A2 * x[n-2] 04591 * A0 = Kp + Ki + Kd 04592 * A1 = (-Kp ) - (2 * Kd ) 04593 * A2 = Kd </pre> 04594 * 04595 * \par 04596 * where \c Kp is proportional constant, \c Ki is Integral constant and \c Kd is Derivative constant 04597 * 04598 * \par 04599 * \image html PID.gif "Proportional Integral Derivative Controller" 04600 * 04601 * \par 04602 * The PID controller calculates an "error" value as the difference between 04603 * the measured output and the reference input. 04604 * The controller attempts to minimize the error by adjusting the process control inputs. 04605 * The proportional value determines the reaction to the current error, 04606 * the integral value determines the reaction based on the sum of recent errors, 04607 * and the derivative value determines the reaction based on the rate at which the error has been changing. 04608 * 04609 * \par Instance Structure 04610 * The Gains A0, A1, A2 and state variables for a PID controller are stored together in an instance data structure. 04611 * A separate instance structure must be defined for each PID Controller. 04612 * There are separate instance structure declarations for each of the 3 supported data types. 04613 * 04614 * \par Reset Functions 04615 * There is also an associated reset function for each data type which clears the state array. 04616 * 04617 * \par Initialization Functions 04618 * There is also an associated initialization function for each data type. 04619 * The initialization function performs the following operations: 04620 * - Initializes the Gains A0, A1, A2 from Kp,Ki, Kd gains. 04621 * - Zeros out the values in the state buffer. 04622 * 04623 * \par 04624 * Instance structure cannot be placed into a const data section and it is recommended to use the initialization function. 04625 * 04626 * \par Fixed-Point Behavior 04627 * Care must be taken when using the fixed-point versions of the PID Controller functions. 04628 * In particular, the overflow and saturation behavior of the accumulator used in each function must be considered. 04629 * Refer to the function specific documentation below for usage guidelines. 04630 */ 04631 04632 /** 04633 * @addtogroup PID 04634 * @{ 04635 */ 04636 04637 /** 04638 * @brief Process function for the floating-point PID Control. 04639 * @param[in,out] *S is an instance of the floating-point PID Control structure 04640 * @param[in] in input sample to process 04641 * @return out processed output sample. 04642 */ 04643 04644 04645 static __INLINE float32_t arm_pid_f32( 04646 arm_pid_instance_f32 * S, 04647 float32_t in) 04648 { 04649 float32_t out; 04650 04651 /* y[n] = y[n-1] + A0 * x[n] + A1 * x[n-1] + A2 * x[n-2] */ 04652 out = (S->A0 * in) + 04653 (S->A1 * S->state[0]) + (S->A2 * S->state[1]) + (S->state[2]); 04654 04655 /* Update state */ 04656 S->state[1] = S->state[0]; 04657 S->state[0] = in; 04658 S->state[2] = out; 04659 04660 /* return to application */ 04661 return (out); 04662 04663 } 04664 04665 /** 04666 * @brief Process function for the Q31 PID Control. 04667 * @param[in,out] *S points to an instance of the Q31 PID Control structure 04668 * @param[in] in input sample to process 04669 * @return out processed output sample. 04670 * 04671 * <b>Scaling and Overflow Behavior:</b> 04672 * \par 04673 * The function is implemented using an internal 64-bit accumulator. 04674 * The accumulator has a 2.62 format and maintains full precision of the intermediate multiplication results but provides only a single guard bit. 04675 * Thus, if the accumulator result overflows it wraps around rather than clip. 04676 * In order to avoid overflows completely the input signal must be scaled down by 2 bits as there are four additions. 04677 * After all multiply-accumulates are performed, the 2.62 accumulator is truncated to 1.32 format and then saturated to 1.31 format. 04678 */ 04679 04680 static __INLINE q31_t arm_pid_q31( 04681 arm_pid_instance_q31 * S, 04682 q31_t in) 04683 { 04684 q63_t acc; 04685 q31_t out; 04686 04687 /* acc = A0 * x[n] */ 04688 acc = (q63_t) S->A0 * in; 04689 04690 /* acc += A1 * x[n-1] */ 04691 acc += (q63_t) S->A1 * S->state[0]; 04692 04693 /* acc += A2 * x[n-2] */ 04694 acc += (q63_t) S->A2 * S->state[1]; 04695 04696 /* convert output to 1.31 format to add y[n-1] */ 04697 out = (q31_t) (acc >> 31u); 04698 04699 /* out += y[n-1] */ 04700 out += S->state[2]; 04701 04702 /* Update state */ 04703 S->state[1] = S->state[0]; 04704 S->state[0] = in; 04705 S->state[2] = out; 04706 04707 /* return to application */ 04708 return (out); 04709 04710 } 04711 04712 /** 04713 * @brief Process function for the Q15 PID Control. 04714 * @param[in,out] *S points to an instance of the Q15 PID Control structure 04715 * @param[in] in input sample to process 04716 * @return out processed output sample. 04717 * 04718 * <b>Scaling and Overflow Behavior:</b> 04719 * \par 04720 * The function is implemented using a 64-bit internal accumulator. 04721 * Both Gains and state variables are represented in 1.15 format and multiplications yield a 2.30 result. 04722 * The 2.30 intermediate results are accumulated in a 64-bit accumulator in 34.30 format. 04723 * There is no risk of internal overflow with this approach and the full precision of intermediate multiplications is preserved. 04724 * After all additions have been performed, the accumulator is truncated to 34.15 format by discarding low 15 bits. 04725 * Lastly, the accumulator is saturated to yield a result in 1.15 format. 04726 */ 04727 04728 static __INLINE q15_t arm_pid_q15( 04729 arm_pid_instance_q15 * S, 04730 q15_t in) 04731 { 04732 q63_t acc; 04733 q15_t out; 04734 04735 /* Implementation of PID controller */ 04736 04737 /* acc = A0 * x[n] */ 04738 acc = (q31_t) __SMUAD(S->A0, in); 04739 04740 /* acc += A1 * x[n-1] + A2 * x[n-2] */ 04741 acc = __SMLALD(S->A1, (q31_t)__SIMD32(S->state), acc); 04742 04743 /* acc += y[n-1] */ 04744 acc += (q31_t) S->state[2] << 15; 04745 04746 /* saturate the output */ 04747 out = (q15_t) (__SSAT((acc >> 15), 16)); 04748 04749 /* Update state */ 04750 S->state[1] = S->state[0]; 04751 S->state[0] = in; 04752 S->state[2] = out; 04753 04754 /* return to application */ 04755 return (out); 04756 04757 } 04758 04759 /** 04760 * @} end of PID group 04761 */ 04762 04763 04764 /** 04765 * @brief Floating-point matrix inverse. 04766 * @param[in] *src points to the instance of the input floating-point matrix structure. 04767 * @param[out] *dst points to the instance of the output floating-point matrix structure. 04768 * @return The function returns ARM_MATH_SIZE_MISMATCH, if the dimensions do not match. 04769 * If the input matrix is singular (does not have an inverse), then the algorithm terminates and returns error status ARM_MATH_SINGULAR. 04770 */ 04771 04772 arm_status arm_mat_inverse_f32( 04773 const arm_matrix_instance_f32 * src, 04774 arm_matrix_instance_f32 * dst); 04775 04776 04777 04778 /** 04779 * @ingroup groupController 04780 */ 04781 04782 04783 /** 04784 * @defgroup clarke Vector Clarke Transform 04785 * Forward Clarke transform converts the instantaneous stator phases into a two-coordinate time invariant vector. 04786 * Generally the Clarke transform uses three-phase currents <code>Ia, Ib and Ic</code> to calculate currents 04787 * in the two-phase orthogonal stator axis <code>Ialpha</code> and <code>Ibeta</code>. 04788 * When <code>Ialpha</code> is superposed with <code>Ia</code> as shown in the figure below 04789 * \image html clarke.gif Stator current space vector and its components in (a,b). 04790 * and <code>Ia + Ib + Ic = 0</code>, in this condition <code>Ialpha</code> and <code>Ibeta</code> 04791 * can be calculated using only <code>Ia</code> and <code>Ib</code>. 04792 * 04793 * The function operates on a single sample of data and each call to the function returns the processed output. 04794 * The library provides separate functions for Q31 and floating-point data types. 04795 * \par Algorithm 04796 * \image html clarkeFormula.gif 04797 * where <code>Ia</code> and <code>Ib</code> are the instantaneous stator phases and 04798 * <code>pIalpha</code> and <code>pIbeta</code> are the two coordinates of time invariant vector. 04799 * \par Fixed-Point Behavior 04800 * Care must be taken when using the Q31 version of the Clarke transform. 04801 * In particular, the overflow and saturation behavior of the accumulator used must be considered. 04802 * Refer to the function specific documentation below for usage guidelines. 04803 */ 04804 04805 /** 04806 * @addtogroup clarke 04807 * @{ 04808 */ 04809 04810 /** 04811 * 04812 * @brief Floating-point Clarke transform 04813 * @param[in] Ia input three-phase coordinate <code>a</code> 04814 * @param[in] Ib input three-phase coordinate <code>b</code> 04815 * @param[out] *pIalpha points to output two-phase orthogonal vector axis alpha 04816 * @param[out] *pIbeta points to output two-phase orthogonal vector axis beta 04817 * @return none. 04818 */ 04819 04820 static __INLINE void arm_clarke_f32( 04821 float32_t Ia, 04822 float32_t Ib, 04823 float32_t * pIalpha, 04824 float32_t * pIbeta) 04825 { 04826 /* Calculate pIalpha using the equation, pIalpha = Ia */ 04827 *pIalpha = Ia; 04828 04829 /* Calculate pIbeta using the equation, pIbeta = (1/sqrt(3)) * Ia + (2/sqrt(3)) * Ib */ 04830 *pIbeta = ((float32_t) 0.57735026919 * Ia + (float32_t) 1.15470053838 * Ib); 04831 04832 } 04833 04834 /** 04835 * @brief Clarke transform for Q31 version 04836 * @param[in] Ia input three-phase coordinate <code>a</code> 04837 * @param[in] Ib input three-phase coordinate <code>b</code> 04838 * @param[out] *pIalpha points to output two-phase orthogonal vector axis alpha 04839 * @param[out] *pIbeta points to output two-phase orthogonal vector axis beta 04840 * @return none. 04841 * 04842 * <b>Scaling and Overflow Behavior:</b> 04843 * \par 04844 * The function is implemented using an internal 32-bit accumulator. 04845 * The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format. 04846 * There is saturation on the addition, hence there is no risk of overflow. 04847 */ 04848 04849 static __INLINE void arm_clarke_q31( 04850 q31_t Ia, 04851 q31_t Ib, 04852 q31_t * pIalpha, 04853 q31_t * pIbeta) 04854 { 04855 q31_t product1, product2; /* Temporary variables used to store intermediate results */ 04856 04857 /* Calculating pIalpha from Ia by equation pIalpha = Ia */ 04858 *pIalpha = Ia; 04859 04860 /* Intermediate product is calculated by (1/(sqrt(3)) * Ia) */ 04861 product1 = (q31_t) (((q63_t) Ia * 0x24F34E8B) >> 30); 04862 04863 /* Intermediate product is calculated by (2/sqrt(3) * Ib) */ 04864 product2 = (q31_t) (((q63_t) Ib * 0x49E69D16) >> 30); 04865 04866 /* pIbeta is calculated by adding the intermediate products */ 04867 *pIbeta = __QADD(product1, product2); 04868 } 04869 04870 /** 04871 * @} end of clarke group 04872 */ 04873 04874 /** 04875 * @brief Converts the elements of the Q7 vector to Q31 vector. 04876 * @param[in] *pSrc input pointer 04877 * @param[out] *pDst output pointer 04878 * @param[in] blockSize number of samples to process 04879 * @return none. 04880 */ 04881 void arm_q7_to_q31( 04882 q7_t * pSrc, 04883 q31_t * pDst, 04884 uint32_t blockSize); 04885 04886 04887 04888 04889 /** 04890 * @ingroup groupController 04891 */ 04892 04893 /** 04894 * @defgroup inv_clarke Vector Inverse Clarke Transform 04895 * Inverse Clarke transform converts the two-coordinate time invariant vector into instantaneous stator phases. 04896 * 04897 * The function operates on a single sample of data and each call to the function returns the processed output. 04898 * The library provides separate functions for Q31 and floating-point data types. 04899 * \par Algorithm 04900 * \image html clarkeInvFormula.gif 04901 * where <code>pIa</code> and <code>pIb</code> are the instantaneous stator phases and 04902 * <code>Ialpha</code> and <code>Ibeta</code> are the two coordinates of time invariant vector. 04903 * \par Fixed-Point Behavior 04904 * Care must be taken when using the Q31 version of the Clarke transform. 04905 * In particular, the overflow and saturation behavior of the accumulator used must be considered. 04906 * Refer to the function specific documentation below for usage guidelines. 04907 */ 04908 04909 /** 04910 * @addtogroup inv_clarke 04911 * @{ 04912 */ 04913 04914 /** 04915 * @brief Floating-point Inverse Clarke transform 04916 * @param[in] Ialpha input two-phase orthogonal vector axis alpha 04917 * @param[in] Ibeta input two-phase orthogonal vector axis beta 04918 * @param[out] *pIa points to output three-phase coordinate <code>a</code> 04919 * @param[out] *pIb points to output three-phase coordinate <code>b</code> 04920 * @return none. 04921 */ 04922 04923 04924 static __INLINE void arm_inv_clarke_f32( 04925 float32_t Ialpha, 04926 float32_t Ibeta, 04927 float32_t * pIa, 04928 float32_t * pIb) 04929 { 04930 /* Calculating pIa from Ialpha by equation pIa = Ialpha */ 04931 *pIa = Ialpha; 04932 04933 /* Calculating pIb from Ialpha and Ibeta by equation pIb = -(1/2) * Ialpha + (sqrt(3)/2) * Ibeta */ 04934 *pIb = -0.5 * Ialpha + (float32_t) 0.8660254039 *Ibeta; 04935 04936 } 04937 04938 /** 04939 * @brief Inverse Clarke transform for Q31 version 04940 * @param[in] Ialpha input two-phase orthogonal vector axis alpha 04941 * @param[in] Ibeta input two-phase orthogonal vector axis beta 04942 * @param[out] *pIa points to output three-phase coordinate <code>a</code> 04943 * @param[out] *pIb points to output three-phase coordinate <code>b</code> 04944 * @return none. 04945 * 04946 * <b>Scaling and Overflow Behavior:</b> 04947 * \par 04948 * The function is implemented using an internal 32-bit accumulator. 04949 * The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format. 04950 * There is saturation on the subtraction, hence there is no risk of overflow. 04951 */ 04952 04953 static __INLINE void arm_inv_clarke_q31( 04954 q31_t Ialpha, 04955 q31_t Ibeta, 04956 q31_t * pIa, 04957 q31_t * pIb) 04958 { 04959 q31_t product1, product2; /* Temporary variables used to store intermediate results */ 04960 04961 /* Calculating pIa from Ialpha by equation pIa = Ialpha */ 04962 *pIa = Ialpha; 04963 04964 /* Intermediate product is calculated by (1/(2*sqrt(3)) * Ia) */ 04965 product1 = (q31_t) (((q63_t) (Ialpha) * (0x40000000)) >> 31); 04966 04967 /* Intermediate product is calculated by (1/sqrt(3) * pIb) */ 04968 product2 = (q31_t) (((q63_t) (Ibeta) * (0x6ED9EBA1)) >> 31); 04969 04970 /* pIb is calculated by subtracting the products */ 04971 *pIb = __QSUB(product2, product1); 04972 04973 } 04974 04975 /** 04976 * @} end of inv_clarke group 04977 */ 04978 04979 /** 04980 * @brief Converts the elements of the Q7 vector to Q15 vector. 04981 * @param[in] *pSrc input pointer 04982 * @param[out] *pDst output pointer 04983 * @param[in] blockSize number of samples to process 04984 * @return none. 04985 */ 04986 void arm_q7_to_q15( 04987 q7_t * pSrc, 04988 q15_t * pDst, 04989 uint32_t blockSize); 04990 04991 04992 04993 /** 04994 * @ingroup groupController 04995 */ 04996 04997 /** 04998 * @defgroup park Vector Park Transform 04999 * 05000 * Forward Park transform converts the input two-coordinate vector to flux and torque components. 05001 * The Park transform can be used to realize the transformation of the <code>Ialpha</code> and the <code>Ibeta</code> currents 05002 * from the stationary to the moving reference frame and control the spatial relationship between 05003 * the stator vector current and rotor flux vector. 05004 * If we consider the d axis aligned with the rotor flux, the diagram below shows the 05005 * current vector and the relationship from the two reference frames: 05006 * \image html park.gif "Stator current space vector and its component in (a,b) and in the d,q rotating reference frame" 05007 * 05008 * The function operates on a single sample of data and each call to the function returns the processed output. 05009 * The library provides separate functions for Q31 and floating-point data types. 05010 * \par Algorithm 05011 * \image html parkFormula.gif 05012 * where <code>Ialpha</code> and <code>Ibeta</code> are the stator vector components, 05013 * <code>pId</code> and <code>pIq</code> are rotor vector components and <code>cosVal</code> and <code>sinVal</code> are the 05014 * cosine and sine values of theta (rotor flux position). 05015 * \par Fixed-Point Behavior 05016 * Care must be taken when using the Q31 version of the Park transform. 05017 * In particular, the overflow and saturation behavior of the accumulator used must be considered. 05018 * Refer to the function specific documentation below for usage guidelines. 05019 */ 05020 05021 /** 05022 * @addtogroup park 05023 * @{ 05024 */ 05025 05026 /** 05027 * @brief Floating-point Park transform 05028 * @param[in] Ialpha input two-phase vector coordinate alpha 05029 * @param[in] Ibeta input two-phase vector coordinate beta 05030 * @param[out] *pId points to output rotor reference frame d 05031 * @param[out] *pIq points to output rotor reference frame q 05032 * @param[in] sinVal sine value of rotation angle theta 05033 * @param[in] cosVal cosine value of rotation angle theta 05034 * @return none. 05035 * 05036 * The function implements the forward Park transform. 05037 * 05038 */ 05039 05040 static __INLINE void arm_park_f32( 05041 float32_t Ialpha, 05042 float32_t Ibeta, 05043 float32_t * pId, 05044 float32_t * pIq, 05045 float32_t sinVal, 05046 float32_t cosVal) 05047 { 05048 /* Calculate pId using the equation, pId = Ialpha * cosVal + Ibeta * sinVal */ 05049 *pId = Ialpha * cosVal + Ibeta * sinVal; 05050 05051 /* Calculate pIq using the equation, pIq = - Ialpha * sinVal + Ibeta * cosVal */ 05052 *pIq = -Ialpha * sinVal + Ibeta * cosVal; 05053 05054 } 05055 05056 /** 05057 * @brief Park transform for Q31 version 05058 * @param[in] Ialpha input two-phase vector coordinate alpha 05059 * @param[in] Ibeta input two-phase vector coordinate beta 05060 * @param[out] *pId points to output rotor reference frame d 05061 * @param[out] *pIq points to output rotor reference frame q 05062 * @param[in] sinVal sine value of rotation angle theta 05063 * @param[in] cosVal cosine value of rotation angle theta 05064 * @return none. 05065 * 05066 * <b>Scaling and Overflow Behavior:</b> 05067 * \par 05068 * The function is implemented using an internal 32-bit accumulator. 05069 * The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format. 05070 * There is saturation on the addition and subtraction, hence there is no risk of overflow. 05071 */ 05072 05073 05074 static __INLINE void arm_park_q31( 05075 q31_t Ialpha, 05076 q31_t Ibeta, 05077 q31_t * pId, 05078 q31_t * pIq, 05079 q31_t sinVal, 05080 q31_t cosVal) 05081 { 05082 q31_t product1, product2; /* Temporary variables used to store intermediate results */ 05083 q31_t product3, product4; /* Temporary variables used to store intermediate results */ 05084 05085 /* Intermediate product is calculated by (Ialpha * cosVal) */ 05086 product1 = (q31_t) (((q63_t) (Ialpha) * (cosVal)) >> 31); 05087 05088 /* Intermediate product is calculated by (Ibeta * sinVal) */ 05089 product2 = (q31_t) (((q63_t) (Ibeta) * (sinVal)) >> 31); 05090 05091 05092 /* Intermediate product is calculated by (Ialpha * sinVal) */ 05093 product3 = (q31_t) (((q63_t) (Ialpha) * (sinVal)) >> 31); 05094 05095 /* Intermediate product is calculated by (Ibeta * cosVal) */ 05096 product4 = (q31_t) (((q63_t) (Ibeta) * (cosVal)) >> 31); 05097 05098 /* Calculate pId by adding the two intermediate products 1 and 2 */ 05099 *pId = __QADD(product1, product2); 05100 05101 /* Calculate pIq by subtracting the two intermediate products 3 from 4 */ 05102 *pIq = __QSUB(product4, product3); 05103 } 05104 05105 /** 05106 * @} end of park group 05107 */ 05108 05109 /** 05110 * @brief Converts the elements of the Q7 vector to floating-point vector. 05111 * @param[in] *pSrc is input pointer 05112 * @param[out] *pDst is output pointer 05113 * @param[in] blockSize is the number of samples to process 05114 * @return none. 05115 */ 05116 void arm_q7_to_float( 05117 q7_t * pSrc, 05118 float32_t * pDst, 05119 uint32_t blockSize); 05120 05121 05122 /** 05123 * @ingroup groupController 05124 */ 05125 05126 /** 05127 * @defgroup inv_park Vector Inverse Park transform 05128 * Inverse Park transform converts the input flux and torque components to two-coordinate vector. 05129 * 05130 * The function operates on a single sample of data and each call to the function returns the processed output. 05131 * The library provides separate functions for Q31 and floating-point data types. 05132 * \par Algorithm 05133 * \image html parkInvFormula.gif 05134 * where <code>pIalpha</code> and <code>pIbeta</code> are the stator vector components, 05135 * <code>Id</code> and <code>Iq</code> are rotor vector components and <code>cosVal</code> and <code>sinVal</code> are the 05136 * cosine and sine values of theta (rotor flux position). 05137 * \par Fixed-Point Behavior 05138 * Care must be taken when using the Q31 version of the Park transform. 05139 * In particular, the overflow and saturation behavior of the accumulator used must be considered. 05140 * Refer to the function specific documentation below for usage guidelines. 05141 */ 05142 05143 /** 05144 * @addtogroup inv_park 05145 * @{ 05146 */ 05147 05148 /** 05149 * @brief Floating-point Inverse Park transform 05150 * @param[in] Id input coordinate of rotor reference frame d 05151 * @param[in] Iq input coordinate of rotor reference frame q 05152 * @param[out] *pIalpha points to output two-phase orthogonal vector axis alpha 05153 * @param[out] *pIbeta points to output two-phase orthogonal vector axis beta 05154 * @param[in] sinVal sine value of rotation angle theta 05155 * @param[in] cosVal cosine value of rotation angle theta 05156 * @return none. 05157 */ 05158 05159 static __INLINE void arm_inv_park_f32( 05160 float32_t Id, 05161 float32_t Iq, 05162 float32_t * pIalpha, 05163 float32_t * pIbeta, 05164 float32_t sinVal, 05165 float32_t cosVal) 05166 { 05167 /* Calculate pIalpha using the equation, pIalpha = Id * cosVal - Iq * sinVal */ 05168 *pIalpha = Id * cosVal - Iq * sinVal; 05169 05170 /* Calculate pIbeta using the equation, pIbeta = Id * sinVal + Iq * cosVal */ 05171 *pIbeta = Id * sinVal + Iq * cosVal; 05172 05173 } 05174 05175 05176 /** 05177 * @brief Inverse Park transform for Q31 version 05178 * @param[in] Id input coordinate of rotor reference frame d 05179 * @param[in] Iq input coordinate of rotor reference frame q 05180 * @param[out] *pIalpha points to output two-phase orthogonal vector axis alpha 05181 * @param[out] *pIbeta points to output two-phase orthogonal vector axis beta 05182 * @param[in] sinVal sine value of rotation angle theta 05183 * @param[in] cosVal cosine value of rotation angle theta 05184 * @return none. 05185 * 05186 * <b>Scaling and Overflow Behavior:</b> 05187 * \par 05188 * The function is implemented using an internal 32-bit accumulator. 05189 * The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format. 05190 * There is saturation on the addition, hence there is no risk of overflow. 05191 */ 05192 05193 05194 static __INLINE void arm_inv_park_q31( 05195 q31_t Id, 05196 q31_t Iq, 05197 q31_t * pIalpha, 05198 q31_t * pIbeta, 05199 q31_t sinVal, 05200 q31_t cosVal) 05201 { 05202 q31_t product1, product2; /* Temporary variables used to store intermediate results */ 05203 q31_t product3, product4; /* Temporary variables used to store intermediate results */ 05204 05205 /* Intermediate product is calculated by (Id * cosVal) */ 05206 product1 = (q31_t) (((q63_t) (Id) * (cosVal)) >> 31); 05207 05208 /* Intermediate product is calculated by (Iq * sinVal) */ 05209 product2 = (q31_t) (((q63_t) (Iq) * (sinVal)) >> 31); 05210 05211 05212 /* Intermediate product is calculated by (Id * sinVal) */ 05213 product3 = (q31_t) (((q63_t) (Id) * (sinVal)) >> 31); 05214 05215 /* Intermediate product is calculated by (Iq * cosVal) */ 05216 product4 = (q31_t) (((q63_t) (Iq) * (cosVal)) >> 31); 05217 05218 /* Calculate pIalpha by using the two intermediate products 1 and 2 */ 05219 *pIalpha = __QSUB(product1, product2); 05220 05221 /* Calculate pIbeta by using the two intermediate products 3 and 4 */ 05222 *pIbeta = __QADD(product4, product3); 05223 05224 } 05225 05226 /** 05227 * @} end of Inverse park group 05228 */ 05229 05230 05231 /** 05232 * @brief Converts the elements of the Q31 vector to floating-point vector. 05233 * @param[in] *pSrc is input pointer 05234 * @param[out] *pDst is output pointer 05235 * @param[in] blockSize is the number of samples to process 05236 * @return none. 05237 */ 05238 void arm_q31_to_float( 05239 q31_t * pSrc, 05240 float32_t * pDst, 05241 uint32_t blockSize); 05242 05243 /** 05244 * @ingroup groupInterpolation 05245 */ 05246 05247 /** 05248 * @defgroup LinearInterpolate Linear Interpolation 05249 * 05250 * Linear interpolation is a method of curve fitting using linear polynomials. 05251 * Linear interpolation works by effectively drawing a straight line between two neighboring samples and returning the appropriate point along that line 05252 * 05253 * \par 05254 * \image html LinearInterp.gif "Linear interpolation" 05255 * 05256 * \par 05257 * A Linear Interpolate function calculates an output value(y), for the input(x) 05258 * using linear interpolation of the input values x0, x1( nearest input values) and the output values y0 and y1(nearest output values) 05259 * 05260 * \par Algorithm: 05261 * <pre> 05262 * y = y0 + (x - x0) * ((y1 - y0)/(x1-x0)) 05263 * where x0, x1 are nearest values of input x 05264 * y0, y1 are nearest values to output y 05265 * </pre> 05266 * 05267 * \par 05268 * This set of functions implements Linear interpolation process 05269 * for Q7, Q15, Q31, and floating-point data types. The functions operate on a single 05270 * sample of data and each call to the function returns a single processed value. 05271 * <code>S</code> points to an instance of the Linear Interpolate function data structure. 05272 * <code>x</code> is the input sample value. The functions returns the output value. 05273 * 05274 * \par 05275 * if x is outside of the table boundary, Linear interpolation returns first value of the table 05276 * if x is below input range and returns last value of table if x is above range. 05277 */ 05278 05279 /** 05280 * @addtogroup LinearInterpolate 05281 * @{ 05282 */ 05283 05284 /** 05285 * @brief Process function for the floating-point Linear Interpolation Function. 05286 * @param[in,out] *S is an instance of the floating-point Linear Interpolation structure 05287 * @param[in] x input sample to process 05288 * @return y processed output sample. 05289 * 05290 */ 05291 05292 static __INLINE float32_t arm_linear_interp_f32( 05293 arm_linear_interp_instance_f32 * S, 05294 float32_t x) 05295 { 05296 05297 float32_t y; 05298 float32_t x0, x1; /* Nearest input values */ 05299 float32_t y0, y1; /* Nearest output values */ 05300 float32_t xSpacing = S->xSpacing; /* spacing between input values */ 05301 int32_t i; /* Index variable */ 05302 float32_t *pYData = S->pYData; /* pointer to output table */ 05303 05304 /* Calculation of index */ 05305 i = (x - S->x1) / xSpacing; 05306 05307 if(i < 0) 05308 { 05309 /* Iniatilize output for below specified range as least output value of table */ 05310 y = pYData[0]; 05311 } 05312 else if(i >= S->nValues) 05313 { 05314 /* Iniatilize output for above specified range as last output value of table */ 05315 y = pYData[S->nValues-1]; 05316 } 05317 else 05318 { 05319 /* Calculation of nearest input values */ 05320 x0 = S->x1 + i * xSpacing; 05321 x1 = S->x1 + (i +1) * xSpacing; 05322 05323 /* Read of nearest output values */ 05324 y0 = pYData[i]; 05325 y1 = pYData[i + 1]; 05326 05327 /* Calculation of output */ 05328 y = y0 + (x - x0) * ((y1 - y0)/(x1-x0)); 05329 05330 } 05331 05332 /* returns output value */ 05333 return (y); 05334 } 05335 05336 /** 05337 * 05338 * @brief Process function for the Q31 Linear Interpolation Function. 05339 * @param[in] *pYData pointer to Q31 Linear Interpolation table 05340 * @param[in] x input sample to process 05341 * @param[in] nValues number of table values 05342 * @return y processed output sample. 05343 * 05344 * \par 05345 * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part. 05346 * This function can support maximum of table size 2^12. 05347 * 05348 */ 05349 05350 05351 static __INLINE q31_t arm_linear_interp_q31(q31_t *pYData, 05352 q31_t x, uint32_t nValues) 05353 { 05354 q31_t y; /* output */ 05355 q31_t y0, y1; /* Nearest output values */ 05356 q31_t fract; /* fractional part */ 05357 int32_t index; /* Index to read nearest output values */ 05358 05359 /* Input is in 12.20 format */ 05360 /* 12 bits for the table index */ 05361 /* Index value calculation */ 05362 index = ((x & 0xFFF00000) >> 20); 05363 05364 if(index >= (nValues - 1)) 05365 { 05366 return(pYData[nValues - 1]); 05367 } 05368 else if(index < 0) 05369 { 05370 return(pYData[0]); 05371 } 05372 else 05373 { 05374 05375 /* 20 bits for the fractional part */ 05376 /* shift left by 11 to keep fract in 1.31 format */ 05377 fract = (x & 0x000FFFFF) << 11; 05378 05379 /* Read two nearest output values from the index in 1.31(q31) format */ 05380 y0 = pYData[index]; 05381 y1 = pYData[index + 1u]; 05382 05383 /* Calculation of y0 * (1-fract) and y is in 2.30 format */ 05384 y = ((q31_t) ((q63_t) y0 * (0x7FFFFFFF - fract) >> 32)); 05385 05386 /* Calculation of y0 * (1-fract) + y1 *fract and y is in 2.30 format */ 05387 y += ((q31_t) (((q63_t) y1 * fract) >> 32)); 05388 05389 /* Convert y to 1.31 format */ 05390 return (y << 1u); 05391 05392 } 05393 05394 } 05395 05396 /** 05397 * 05398 * @brief Process function for the Q15 Linear Interpolation Function. 05399 * @param[in] *pYData pointer to Q15 Linear Interpolation table 05400 * @param[in] x input sample to process 05401 * @param[in] nValues number of table values 05402 * @return y processed output sample. 05403 * 05404 * \par 05405 * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part. 05406 * This function can support maximum of table size 2^12. 05407 * 05408 */ 05409 05410 05411 static __INLINE q15_t arm_linear_interp_q15(q15_t *pYData, q31_t x, uint32_t nValues) 05412 { 05413 q63_t y; /* output */ 05414 q15_t y0, y1; /* Nearest output values */ 05415 q31_t fract; /* fractional part */ 05416 int32_t index; /* Index to read nearest output values */ 05417 05418 /* Input is in 12.20 format */ 05419 /* 12 bits for the table index */ 05420 /* Index value calculation */ 05421 index = ((x & 0xFFF00000) >> 20u); 05422 05423 if(index >= (nValues - 1)) 05424 { 05425 return(pYData[nValues - 1]); 05426 } 05427 else if(index < 0) 05428 { 05429 return(pYData[0]); 05430 } 05431 else 05432 { 05433 /* 20 bits for the fractional part */ 05434 /* fract is in 12.20 format */ 05435 fract = (x & 0x000FFFFF); 05436 05437 /* Read two nearest output values from the index */ 05438 y0 = pYData[index]; 05439 y1 = pYData[index + 1u]; 05440 05441 /* Calculation of y0 * (1-fract) and y is in 13.35 format */ 05442 y = ((q63_t) y0 * (0xFFFFF - fract)); 05443 05444 /* Calculation of (y0 * (1-fract) + y1 * fract) and y is in 13.35 format */ 05445 y += ((q63_t) y1 * (fract)); 05446 05447 /* convert y to 1.15 format */ 05448 return (y >> 20); 05449 } 05450 05451 05452 } 05453 05454 /** 05455 * 05456 * @brief Process function for the Q7 Linear Interpolation Function. 05457 * @param[in] *pYData pointer to Q7 Linear Interpolation table 05458 * @param[in] x input sample to process 05459 * @param[in] nValues number of table values 05460 * @return y processed output sample. 05461 * 05462 * \par 05463 * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part. 05464 * This function can support maximum of table size 2^12. 05465 */ 05466 05467 05468 static __INLINE q7_t arm_linear_interp_q7(q7_t *pYData, q31_t x, uint32_t nValues) 05469 { 05470 q31_t y; /* output */ 05471 q7_t y0, y1; /* Nearest output values */ 05472 q31_t fract; /* fractional part */ 05473 int32_t index; /* Index to read nearest output values */ 05474 05475 /* Input is in 12.20 format */ 05476 /* 12 bits for the table index */ 05477 /* Index value calculation */ 05478 index = ((x & 0xFFF00000) >> 20u); 05479 05480 05481 if(index >= (nValues - 1)) 05482 { 05483 return(pYData[nValues - 1]); 05484 } 05485 else if(index < 0) 05486 { 05487 return(pYData[0]); 05488 } 05489 else 05490 { 05491 05492 /* 20 bits for the fractional part */ 05493 /* fract is in 12.20 format */ 05494 fract = (x & 0x000FFFFF); 05495 05496 /* Read two nearest output values from the index and are in 1.7(q7) format */ 05497 y0 = pYData[index]; 05498 y1 = pYData[index + 1u]; 05499 05500 /* Calculation of y0 * (1-fract ) and y is in 13.27(q27) format */ 05501 y = ((y0 * (0xFFFFF - fract))); 05502 05503 /* Calculation of y1 * fract + y0 * (1-fract) and y is in 13.27(q27) format */ 05504 y += (y1 * fract); 05505 05506 /* convert y to 1.7(q7) format */ 05507 return (y >> 20u); 05508 05509 } 05510 05511 } 05512 /** 05513 * @} end of LinearInterpolate group 05514 */ 05515 05516 /** 05517 * @brief Fast approximation to the trigonometric sine function for floating-point data. 05518 * @param[in] x input value in radians. 05519 * @return sin(x). 05520 */ 05521 05522 float32_t arm_sin_f32( 05523 float32_t x); 05524 05525 /** 05526 * @brief Fast approximation to the trigonometric sine function for Q31 data. 05527 * @param[in] x Scaled input value in radians. 05528 * @return sin(x). 05529 */ 05530 05531 q31_t arm_sin_q31( 05532 q31_t x); 05533 05534 /** 05535 * @brief Fast approximation to the trigonometric sine function for Q15 data. 05536 * @param[in] x Scaled input value in radians. 05537 * @return sin(x). 05538 */ 05539 05540 q15_t arm_sin_q15( 05541 q15_t x); 05542 05543 /** 05544 * @brief Fast approximation to the trigonometric cosine function for floating-point data. 05545 * @param[in] x input value in radians. 05546 * @return cos(x). 05547 */ 05548 05549 float32_t arm_cos_f32( 05550 float32_t x); 05551 05552 /** 05553 * @brief Fast approximation to the trigonometric cosine function for Q31 data. 05554 * @param[in] x Scaled input value in radians. 05555 * @return cos(x). 05556 */ 05557 05558 q31_t arm_cos_q31( 05559 q31_t x); 05560 05561 /** 05562 * @brief Fast approximation to the trigonometric cosine function for Q15 data. 05563 * @param[in] x Scaled input value in radians. 05564 * @return cos(x). 05565 */ 05566 05567 q15_t arm_cos_q15( 05568 q15_t x); 05569 05570 05571 /** 05572 * @ingroup groupFastMath 05573 */ 05574 05575 05576 /** 05577 * @defgroup SQRT Square Root 05578 * 05579 * Computes the square root of a number. 05580 * There are separate functions for Q15, Q31, and floating-point data types. 05581 * The square root function is computed using the Newton-Raphson algorithm. 05582 * This is an iterative algorithm of the form: 05583 * <pre> 05584 * x1 = x0 - f(x0)/f'(x0) 05585 * </pre> 05586 * where <code>x1</code> is the current estimate, 05587 * <code>x0</code> is the previous estimate and 05588 * <code>f'(x0)</code> is the derivative of <code>f()</code> evaluated at <code>x0</code>. 05589 * For the square root function, the algorithm reduces to: 05590 * <pre> 05591 * x0 = in/2 [initial guess] 05592 * x1 = 1/2 * ( x0 + in / x0) [each iteration] 05593 * </pre> 05594 */ 05595 05596 05597 /** 05598 * @addtogroup SQRT 05599 * @{ 05600 */ 05601 05602 /** 05603 * @brief Floating-point square root function. 05604 * @param[in] in input value. 05605 * @param[out] *pOut square root of input value. 05606 * @return The function returns ARM_MATH_SUCCESS if input value is positive value or ARM_MATH_ARGUMENT_ERROR if 05607 * <code>in</code> is negative value and returns zero output for negative values. 05608 */ 05609 05610 static __INLINE arm_status arm_sqrt_f32( 05611 float32_t in, float32_t *pOut) 05612 { 05613 float32_t out; 05614 float32_t prevOut; 05615 05616 if(in > 0) 05617 { 05618 /* Take initial guess as half the input */ 05619 prevOut = in / 2; 05620 05621 /* run for ten iterations */ 05622 out = 0.5f * (prevOut + (in / prevOut)); 05623 prevOut = 0.5f * (out + (in / out)); 05624 05625 /* Third iteration */ 05626 out = 0.5f * (prevOut + (in / prevOut)); 05627 prevOut = 0.5f * (out + (in / out)); 05628 05629 /* Fifth iteration */ 05630 out = 0.5f * (prevOut + (in / prevOut)); 05631 prevOut = 0.5f * (out + (in / out)); 05632 05633 /* Seventh iteration */ 05634 out = 0.5f * (prevOut + (in / prevOut)); 05635 prevOut = 0.5f * (out + (in / out)); 05636 out = 0.5f * (prevOut + (in / prevOut)); 05637 05638 /* tenth iteration */ 05639 *pOut = 0.5f * (out + (in / out)); 05640 return (ARM_MATH_SUCCESS); 05641 } 05642 else 05643 { 05644 *pOut = 0.0f; 05645 return (ARM_MATH_ARGUMENT_ERROR); 05646 } 05647 05648 } 05649 05650 05651 /** 05652 * @brief Q31 square root function. 05653 * @param[in] in input value. The range of the input value is [0 +1) or 0x00000000 to 0x7FFFFFFF. 05654 * @param[out] *pOut square root of input value. 05655 * @return The function returns ARM_MATH_SUCCESS if input value is positive value or ARM_MATH_ARGUMENT_ERROR if 05656 * <code>in</code> is negative value and returns zero output for negative values. 05657 */ 05658 arm_status arm_sqrt_q31( 05659 q31_t in, q31_t *pOut); 05660 05661 /** 05662 * @brief Q15 square root function. 05663 * @param[in] in input value. The range of the input value is [0 +1) or 0x0000 to 0x7FFF. 05664 * @param[out] *pOut square root of input value. 05665 * @return The function returns ARM_MATH_SUCCESS if input value is positive value or ARM_MATH_ARGUMENT_ERROR if 05666 * <code>in</code> is negative value and returns zero output for negative values. 05667 */ 05668 arm_status arm_sqrt_q15( 05669 q15_t in, q15_t *pOut); 05670 05671 /** 05672 * @} end of SQRT group 05673 */ 05674 05675 05676 05677 05678 05679 05680 /** 05681 * @brief floating-point Circular write function. 05682 */ 05683 05684 static __INLINE void arm_circularWrite_f32( 05685 int32_t * circBuffer, 05686 int32_t L, 05687 uint16_t * writeOffset, 05688 int32_t bufferInc, 05689 const int32_t * src, 05690 int32_t srcInc, 05691 uint32_t blockSize) 05692 { 05693 uint32_t i = 0u; 05694 int32_t wOffset; 05695 05696 /* Copy the value of Index pointer that points 05697 * to the current location where the input samples to be copied */ 05698 wOffset = *writeOffset; 05699 05700 /* Loop over the blockSize */ 05701 i = blockSize; 05702 05703 while(i > 0u) 05704 { 05705 /* copy the input sample to the circular buffer */ 05706 circBuffer[wOffset] = *src; 05707 05708 /* Update the input pointer */ 05709 src += srcInc; 05710 05711 /* Circularly update wOffset. Watch out for positive and negative value */ 05712 wOffset += bufferInc; 05713 if(wOffset >= L) 05714 wOffset -= L; 05715 05716 /* Decrement the loop counter */ 05717 i--; 05718 } 05719 05720 /* Update the index pointer */ 05721 *writeOffset = wOffset; 05722 } 05723 05724 05725 05726 /** 05727 * @brief floating-point Circular Read function. 05728 */ 05729 static __INLINE void arm_circularRead_f32( 05730 int32_t * circBuffer, 05731 int32_t L, 05732 int32_t * readOffset, 05733 int32_t bufferInc, 05734 int32_t * dst, 05735 int32_t * dst_base, 05736 int32_t dst_length, 05737 int32_t dstInc, 05738 uint32_t blockSize) 05739 { 05740 uint32_t i = 0u; 05741 int32_t rOffset, dst_end; 05742 05743 /* Copy the value of Index pointer that points 05744 * to the current location from where the input samples to be read */ 05745 rOffset = *readOffset; 05746 dst_end = (int32_t) (dst_base + dst_length); 05747 05748 /* Loop over the blockSize */ 05749 i = blockSize; 05750 05751 while(i > 0u) 05752 { 05753 /* copy the sample from the circular buffer to the destination buffer */ 05754 *dst = circBuffer[rOffset]; 05755 05756 /* Update the input pointer */ 05757 dst += dstInc; 05758 05759 if(dst == (int32_t *) dst_end) 05760 { 05761 dst = dst_base; 05762 } 05763 05764 /* Circularly update rOffset. Watch out for positive and negative value */ 05765 rOffset += bufferInc; 05766 05767 if(rOffset >= L) 05768 { 05769 rOffset -= L; 05770 } 05771 05772 /* Decrement the loop counter */ 05773 i--; 05774 } 05775 05776 /* Update the index pointer */ 05777 *readOffset = rOffset; 05778 } 05779 05780 /** 05781 * @brief Q15 Circular write function. 05782 */ 05783 05784 static __INLINE void arm_circularWrite_q15( 05785 q15_t * circBuffer, 05786 int32_t L, 05787 uint16_t * writeOffset, 05788 int32_t bufferInc, 05789 const q15_t * src, 05790 int32_t srcInc, 05791 uint32_t blockSize) 05792 { 05793 uint32_t i = 0u; 05794 int32_t wOffset; 05795 05796 /* Copy the value of Index pointer that points 05797 * to the current location where the input samples to be copied */ 05798 wOffset = *writeOffset; 05799 05800 /* Loop over the blockSize */ 05801 i = blockSize; 05802 05803 while(i > 0u) 05804 { 05805 /* copy the input sample to the circular buffer */ 05806 circBuffer[wOffset] = *src; 05807 05808 /* Update the input pointer */ 05809 src += srcInc; 05810 05811 /* Circularly update wOffset. Watch out for positive and negative value */ 05812 wOffset += bufferInc; 05813 if(wOffset >= L) 05814 wOffset -= L; 05815 05816 /* Decrement the loop counter */ 05817 i--; 05818 } 05819 05820 /* Update the index pointer */ 05821 *writeOffset = wOffset; 05822 } 05823 05824 05825 05826 /** 05827 * @brief Q15 Circular Read function. 05828 */ 05829 static __INLINE void arm_circularRead_q15( 05830 q15_t * circBuffer, 05831 int32_t L, 05832 int32_t * readOffset, 05833 int32_t bufferInc, 05834 q15_t * dst, 05835 q15_t * dst_base, 05836 int32_t dst_length, 05837 int32_t dstInc, 05838 uint32_t blockSize) 05839 { 05840 uint32_t i = 0; 05841 int32_t rOffset, dst_end; 05842 05843 /* Copy the value of Index pointer that points 05844 * to the current location from where the input samples to be read */ 05845 rOffset = *readOffset; 05846 05847 dst_end = (int32_t) (dst_base + dst_length); 05848 05849 /* Loop over the blockSize */ 05850 i = blockSize; 05851 05852 while(i > 0u) 05853 { 05854 /* copy the sample from the circular buffer to the destination buffer */ 05855 *dst = circBuffer[rOffset]; 05856 05857 /* Update the input pointer */ 05858 dst += dstInc; 05859 05860 if(dst == (q15_t *) dst_end) 05861 { 05862 dst = dst_base; 05863 } 05864 05865 /* Circularly update wOffset. Watch out for positive and negative value */ 05866 rOffset += bufferInc; 05867 05868 if(rOffset >= L) 05869 { 05870 rOffset -= L; 05871 } 05872 05873 /* Decrement the loop counter */ 05874 i--; 05875 } 05876 05877 /* Update the index pointer */ 05878 *readOffset = rOffset; 05879 } 05880 05881 05882 /** 05883 * @brief Q7 Circular write function. 05884 */ 05885 05886 static __INLINE void arm_circularWrite_q7( 05887 q7_t * circBuffer, 05888 int32_t L, 05889 uint16_t * writeOffset, 05890 int32_t bufferInc, 05891 const q7_t * src, 05892 int32_t srcInc, 05893 uint32_t blockSize) 05894 { 05895 uint32_t i = 0u; 05896 int32_t wOffset; 05897 05898 /* Copy the value of Index pointer that points 05899 * to the current location where the input samples to be copied */ 05900 wOffset = *writeOffset; 05901 05902 /* Loop over the blockSize */ 05903 i = blockSize; 05904 05905 while(i > 0u) 05906 { 05907 /* copy the input sample to the circular buffer */ 05908 circBuffer[wOffset] = *src; 05909 05910 /* Update the input pointer */ 05911 src += srcInc; 05912 05913 /* Circularly update wOffset. Watch out for positive and negative value */ 05914 wOffset += bufferInc; 05915 if(wOffset >= L) 05916 wOffset -= L; 05917 05918 /* Decrement the loop counter */ 05919 i--; 05920 } 05921 05922 /* Update the index pointer */ 05923 *writeOffset = wOffset; 05924 } 05925 05926 05927 05928 /** 05929 * @brief Q7 Circular Read function. 05930 */ 05931 static __INLINE void arm_circularRead_q7( 05932 q7_t * circBuffer, 05933 int32_t L, 05934 int32_t * readOffset, 05935 int32_t bufferInc, 05936 q7_t * dst, 05937 q7_t * dst_base, 05938 int32_t dst_length, 05939 int32_t dstInc, 05940 uint32_t blockSize) 05941 { 05942 uint32_t i = 0; 05943 int32_t rOffset, dst_end; 05944 05945 /* Copy the value of Index pointer that points 05946 * to the current location from where the input samples to be read */ 05947 rOffset = *readOffset; 05948 05949 dst_end = (int32_t) (dst_base + dst_length); 05950 05951 /* Loop over the blockSize */ 05952 i = blockSize; 05953 05954 while(i > 0u) 05955 { 05956 /* copy the sample from the circular buffer to the destination buffer */ 05957 *dst = circBuffer[rOffset]; 05958 05959 /* Update the input pointer */ 05960 dst += dstInc; 05961 05962 if(dst == (q7_t *) dst_end) 05963 { 05964 dst = dst_base; 05965 } 05966 05967 /* Circularly update rOffset. Watch out for positive and negative value */ 05968 rOffset += bufferInc; 05969 05970 if(rOffset >= L) 05971 { 05972 rOffset -= L; 05973 } 05974 05975 /* Decrement the loop counter */ 05976 i--; 05977 } 05978 05979 /* Update the index pointer */ 05980 *readOffset = rOffset; 05981 } 05982 05983 05984 /** 05985 * @brief Sum of the squares of the elements of a Q31 vector. 05986 * @param[in] *pSrc is input pointer 05987 * @param[in] blockSize is the number of samples to process 05988 * @param[out] *pResult is output value. 05989 * @return none. 05990 */ 05991 05992 void arm_power_q31( 05993 q31_t * pSrc, 05994 uint32_t blockSize, 05995 q63_t * pResult); 05996 05997 /** 05998 * @brief Sum of the squares of the elements of a floating-point vector. 05999 * @param[in] *pSrc is input pointer 06000 * @param[in] blockSize is the number of samples to process 06001 * @param[out] *pResult is output value. 06002 * @return none. 06003 */ 06004 06005 void arm_power_f32( 06006 float32_t * pSrc, 06007 uint32_t blockSize, 06008 float32_t * pResult); 06009 06010 /** 06011 * @brief Sum of the squares of the elements of a Q15 vector. 06012 * @param[in] *pSrc is input pointer 06013 * @param[in] blockSize is the number of samples to process 06014 * @param[out] *pResult is output value. 06015 * @return none. 06016 */ 06017 06018 void arm_power_q15( 06019 q15_t * pSrc, 06020 uint32_t blockSize, 06021 q63_t * pResult); 06022 06023 /** 06024 * @brief Sum of the squares of the elements of a Q7 vector. 06025 * @param[in] *pSrc is input pointer 06026 * @param[in] blockSize is the number of samples to process 06027 * @param[out] *pResult is output value. 06028 * @return none. 06029 */ 06030 06031 void arm_power_q7( 06032 q7_t * pSrc, 06033 uint32_t blockSize, 06034 q31_t * pResult); 06035 06036 /** 06037 * @brief Mean value of a Q7 vector. 06038 * @param[in] *pSrc is input pointer 06039 * @param[in] blockSize is the number of samples to process 06040 * @param[out] *pResult is output value. 06041 * @return none. 06042 */ 06043 06044 void arm_mean_q7( 06045 q7_t * pSrc, 06046 uint32_t blockSize, 06047 q7_t * pResult); 06048 06049 /** 06050 * @brief Mean value of a Q15 vector. 06051 * @param[in] *pSrc is input pointer 06052 * @param[in] blockSize is the number of samples to process 06053 * @param[out] *pResult is output value. 06054 * @return none. 06055 */ 06056 void arm_mean_q15( 06057 q15_t * pSrc, 06058 uint32_t blockSize, 06059 q15_t * pResult); 06060 06061 /** 06062 * @brief Mean value of a Q31 vector. 06063 * @param[in] *pSrc is input pointer 06064 * @param[in] blockSize is the number of samples to process 06065 * @param[out] *pResult is output value. 06066 * @return none. 06067 */ 06068 void arm_mean_q31( 06069 q31_t * pSrc, 06070 uint32_t blockSize, 06071 q31_t * pResult); 06072 06073 /** 06074 * @brief Mean value of a floating-point vector. 06075 * @param[in] *pSrc is input pointer 06076 * @param[in] blockSize is the number of samples to process 06077 * @param[out] *pResult is output value. 06078 * @return none. 06079 */ 06080 void arm_mean_f32( 06081 float32_t * pSrc, 06082 uint32_t blockSize, 06083 float32_t * pResult); 06084 06085 /** 06086 * @brief Variance of the elements of a floating-point vector. 06087 * @param[in] *pSrc is input pointer 06088 * @param[in] blockSize is the number of samples to process 06089 * @param[out] *pResult is output value. 06090 * @return none. 06091 */ 06092 06093 void arm_var_f32( 06094 float32_t * pSrc, 06095 uint32_t blockSize, 06096 float32_t * pResult); 06097 06098 /** 06099 * @brief Variance of the elements of a Q31 vector. 06100 * @param[in] *pSrc is input pointer 06101 * @param[in] blockSize is the number of samples to process 06102 * @param[out] *pResult is output value. 06103 * @return none. 06104 */ 06105 06106 void arm_var_q31( 06107 q31_t * pSrc, 06108 uint32_t blockSize, 06109 q63_t * pResult); 06110 06111 /** 06112 * @brief Variance of the elements of a Q15 vector. 06113 * @param[in] *pSrc is input pointer 06114 * @param[in] blockSize is the number of samples to process 06115 * @param[out] *pResult is output value. 06116 * @return none. 06117 */ 06118 06119 void arm_var_q15( 06120 q15_t * pSrc, 06121 uint32_t blockSize, 06122 q31_t * pResult); 06123 06124 /** 06125 * @brief Root Mean Square of the elements of a floating-point vector. 06126 * @param[in] *pSrc is input pointer 06127 * @param[in] blockSize is the number of samples to process 06128 * @param[out] *pResult is output value. 06129 * @return none. 06130 */ 06131 06132 void arm_rms_f32( 06133 float32_t * pSrc, 06134 uint32_t blockSize, 06135 float32_t * pResult); 06136 06137 /** 06138 * @brief Root Mean Square of the elements of a Q31 vector. 06139 * @param[in] *pSrc is input pointer 06140 * @param[in] blockSize is the number of samples to process 06141 * @param[out] *pResult is output value. 06142 * @return none. 06143 */ 06144 06145 void arm_rms_q31( 06146 q31_t * pSrc, 06147 uint32_t blockSize, 06148 q31_t * pResult); 06149 06150 /** 06151 * @brief Root Mean Square of the elements of a Q15 vector. 06152 * @param[in] *pSrc is input pointer 06153 * @param[in] blockSize is the number of samples to process 06154 * @param[out] *pResult is output value. 06155 * @return none. 06156 */ 06157 06158 void arm_rms_q15( 06159 q15_t * pSrc, 06160 uint32_t blockSize, 06161 q15_t * pResult); 06162 06163 /** 06164 * @brief Standard deviation of the elements of a floating-point vector. 06165 * @param[in] *pSrc is input pointer 06166 * @param[in] blockSize is the number of samples to process 06167 * @param[out] *pResult is output value. 06168 * @return none. 06169 */ 06170 06171 void arm_std_f32( 06172 float32_t * pSrc, 06173 uint32_t blockSize, 06174 float32_t * pResult); 06175 06176 /** 06177 * @brief Standard deviation of the elements of a Q31 vector. 06178 * @param[in] *pSrc is input pointer 06179 * @param[in] blockSize is the number of samples to process 06180 * @param[out] *pResult is output value. 06181 * @return none. 06182 */ 06183 06184 void arm_std_q31( 06185 q31_t * pSrc, 06186 uint32_t blockSize, 06187 q31_t * pResult); 06188 06189 /** 06190 * @brief Standard deviation of the elements of a Q15 vector. 06191 * @param[in] *pSrc is input pointer 06192 * @param[in] blockSize is the number of samples to process 06193 * @param[out] *pResult is output value. 06194 * @return none. 06195 */ 06196 06197 void arm_std_q15( 06198 q15_t * pSrc, 06199 uint32_t blockSize, 06200 q15_t * pResult); 06201 06202 /** 06203 * @brief Floating-point complex magnitude 06204 * @param[in] *pSrc points to the complex input vector 06205 * @param[out] *pDst points to the real output vector 06206 * @param[in] numSamples number of complex samples in the input vector 06207 * @return none. 06208 */ 06209 06210 void arm_cmplx_mag_f32( 06211 float32_t * pSrc, 06212 float32_t * pDst, 06213 uint32_t numSamples); 06214 06215 /** 06216 * @brief Q31 complex magnitude 06217 * @param[in] *pSrc points to the complex input vector 06218 * @param[out] *pDst points to the real output vector 06219 * @param[in] numSamples number of complex samples in the input vector 06220 * @return none. 06221 */ 06222 06223 void arm_cmplx_mag_q31( 06224 q31_t * pSrc, 06225 q31_t * pDst, 06226 uint32_t numSamples); 06227 06228 /** 06229 * @brief Q15 complex magnitude 06230 * @param[in] *pSrc points to the complex input vector 06231 * @param[out] *pDst points to the real output vector 06232 * @param[in] numSamples number of complex samples in the input vector 06233 * @return none. 06234 */ 06235 06236 void arm_cmplx_mag_q15( 06237 q15_t * pSrc, 06238 q15_t * pDst, 06239 uint32_t numSamples); 06240 06241 /** 06242 * @brief Q15 complex dot product 06243 * @param[in] *pSrcA points to the first input vector 06244 * @param[in] *pSrcB points to the second input vector 06245 * @param[in] numSamples number of complex samples in each vector 06246 * @param[out] *realResult real part of the result returned here 06247 * @param[out] *imagResult imaginary part of the result returned here 06248 * @return none. 06249 */ 06250 06251 void arm_cmplx_dot_prod_q15( 06252 q15_t * pSrcA, 06253 q15_t * pSrcB, 06254 uint32_t numSamples, 06255 q31_t * realResult, 06256 q31_t * imagResult); 06257 06258 /** 06259 * @brief Q31 complex dot product 06260 * @param[in] *pSrcA points to the first input vector 06261 * @param[in] *pSrcB points to the second input vector 06262 * @param[in] numSamples number of complex samples in each vector 06263 * @param[out] *realResult real part of the result returned here 06264 * @param[out] *imagResult imaginary part of the result returned here 06265 * @return none. 06266 */ 06267 06268 void arm_cmplx_dot_prod_q31( 06269 q31_t * pSrcA, 06270 q31_t * pSrcB, 06271 uint32_t numSamples, 06272 q63_t * realResult, 06273 q63_t * imagResult); 06274 06275 /** 06276 * @brief Floating-point complex dot product 06277 * @param[in] *pSrcA points to the first input vector 06278 * @param[in] *pSrcB points to the second input vector 06279 * @param[in] numSamples number of complex samples in each vector 06280 * @param[out] *realResult real part of the result returned here 06281 * @param[out] *imagResult imaginary part of the result returned here 06282 * @return none. 06283 */ 06284 06285 void arm_cmplx_dot_prod_f32( 06286 float32_t * pSrcA, 06287 float32_t * pSrcB, 06288 uint32_t numSamples, 06289 float32_t * realResult, 06290 float32_t * imagResult); 06291 06292 /** 06293 * @brief Q15 complex-by-real multiplication 06294 * @param[in] *pSrcCmplx points to the complex input vector 06295 * @param[in] *pSrcReal points to the real input vector 06296 * @param[out] *pCmplxDst points to the complex output vector 06297 * @param[in] numSamples number of samples in each vector 06298 * @return none. 06299 */ 06300 06301 void arm_cmplx_mult_real_q15( 06302 q15_t * pSrcCmplx, 06303 q15_t * pSrcReal, 06304 q15_t * pCmplxDst, 06305 uint32_t numSamples); 06306 06307 /** 06308 * @brief Q31 complex-by-real multiplication 06309 * @param[in] *pSrcCmplx points to the complex input vector 06310 * @param[in] *pSrcReal points to the real input vector 06311 * @param[out] *pCmplxDst points to the complex output vector 06312 * @param[in] numSamples number of samples in each vector 06313 * @return none. 06314 */ 06315 06316 void arm_cmplx_mult_real_q31( 06317 q31_t * pSrcCmplx, 06318 q31_t * pSrcReal, 06319 q31_t * pCmplxDst, 06320 uint32_t numSamples); 06321 06322 /** 06323 * @brief Floating-point complex-by-real multiplication 06324 * @param[in] *pSrcCmplx points to the complex input vector 06325 * @param[in] *pSrcReal points to the real input vector 06326 * @param[out] *pCmplxDst points to the complex output vector 06327 * @param[in] numSamples number of samples in each vector 06328 * @return none. 06329 */ 06330 06331 void arm_cmplx_mult_real_f32( 06332 float32_t * pSrcCmplx, 06333 float32_t * pSrcReal, 06334 float32_t * pCmplxDst, 06335 uint32_t numSamples); 06336 06337 /** 06338 * @brief Minimum value of a Q7 vector. 06339 * @param[in] *pSrc is input pointer 06340 * @param[in] blockSize is the number of samples to process 06341 * @param[out] *result is output pointer 06342 * @param[in] index is the array index of the minimum value in the input buffer. 06343 * @return none. 06344 */ 06345 06346 void arm_min_q7( 06347 q7_t * pSrc, 06348 uint32_t blockSize, 06349 q7_t * result, 06350 uint32_t * index); 06351 06352 /** 06353 * @brief Minimum value of a Q15 vector. 06354 * @param[in] *pSrc is input pointer 06355 * @param[in] blockSize is the number of samples to process 06356 * @param[out] *pResult is output pointer 06357 * @param[in] *pIndex is the array index of the minimum value in the input buffer. 06358 * @return none. 06359 */ 06360 06361 void arm_min_q15( 06362 q15_t * pSrc, 06363 uint32_t blockSize, 06364 q15_t * pResult, 06365 uint32_t * pIndex); 06366 06367 /** 06368 * @brief Minimum value of a Q31 vector. 06369 * @param[in] *pSrc is input pointer 06370 * @param[in] blockSize is the number of samples to process 06371 * @param[out] *pResult is output pointer 06372 * @param[out] *pIndex is the array index of the minimum value in the input buffer. 06373 * @return none. 06374 */ 06375 void arm_min_q31( 06376 q31_t * pSrc, 06377 uint32_t blockSize, 06378 q31_t * pResult, 06379 uint32_t * pIndex); 06380 06381 /** 06382 * @brief Minimum value of a floating-point vector. 06383 * @param[in] *pSrc is input pointer 06384 * @param[in] blockSize is the number of samples to process 06385 * @param[out] *pResult is output pointer 06386 * @param[out] *pIndex is the array index of the minimum value in the input buffer. 06387 * @return none. 06388 */ 06389 06390 void arm_min_f32( 06391 float32_t * pSrc, 06392 uint32_t blockSize, 06393 float32_t * pResult, 06394 uint32_t * pIndex); 06395 06396 /** 06397 * @brief Maximum value of a Q7 vector. 06398 * @param[in] *pSrc points to the input buffer 06399 * @param[in] blockSize length of the input vector 06400 * @param[out] *pResult maximum value returned here 06401 * @param[out] *pIndex index of maximum value returned here 06402 * @return none. 06403 */ 06404 06405 void arm_max_q7( 06406 q7_t * pSrc, 06407 uint32_t blockSize, 06408 q7_t * pResult, 06409 uint32_t * pIndex); 06410 06411 /** 06412 * @brief Maximum value of a Q15 vector. 06413 * @param[in] *pSrc points to the input buffer 06414 * @param[in] blockSize length of the input vector 06415 * @param[out] *pResult maximum value returned here 06416 * @param[out] *pIndex index of maximum value returned here 06417 * @return none. 06418 */ 06419 06420 void arm_max_q15( 06421 q15_t * pSrc, 06422 uint32_t blockSize, 06423 q15_t * pResult, 06424 uint32_t * pIndex); 06425 06426 /** 06427 * @brief Maximum value of a Q31 vector. 06428 * @param[in] *pSrc points to the input buffer 06429 * @param[in] blockSize length of the input vector 06430 * @param[out] *pResult maximum value returned here 06431 * @param[out] *pIndex index of maximum value returned here 06432 * @return none. 06433 */ 06434 06435 void arm_max_q31( 06436 q31_t * pSrc, 06437 uint32_t blockSize, 06438 q31_t * pResult, 06439 uint32_t * pIndex); 06440 06441 /** 06442 * @brief Maximum value of a floating-point vector. 06443 * @param[in] *pSrc points to the input buffer 06444 * @param[in] blockSize length of the input vector 06445 * @param[out] *pResult maximum value returned here 06446 * @param[out] *pIndex index of maximum value returned here 06447 * @return none. 06448 */ 06449 06450 void arm_max_f32( 06451 float32_t * pSrc, 06452 uint32_t blockSize, 06453 float32_t * pResult, 06454 uint32_t * pIndex); 06455 06456 /** 06457 * @brief Q15 complex-by-complex multiplication 06458 * @param[in] *pSrcA points to the first input vector 06459 * @param[in] *pSrcB points to the second input vector 06460 * @param[out] *pDst points to the output vector 06461 * @param[in] numSamples number of complex samples in each vector 06462 * @return none. 06463 */ 06464 06465 void arm_cmplx_mult_cmplx_q15( 06466 q15_t * pSrcA, 06467 q15_t * pSrcB, 06468 q15_t * pDst, 06469 uint32_t numSamples); 06470 06471 /** 06472 * @brief Q31 complex-by-complex multiplication 06473 * @param[in] *pSrcA points to the first input vector 06474 * @param[in] *pSrcB points to the second input vector 06475 * @param[out] *pDst points to the output vector 06476 * @param[in] numSamples number of complex samples in each vector 06477 * @return none. 06478 */ 06479 06480 void arm_cmplx_mult_cmplx_q31( 06481 q31_t * pSrcA, 06482 q31_t * pSrcB, 06483 q31_t * pDst, 06484 uint32_t numSamples); 06485 06486 /** 06487 * @brief Floating-point complex-by-complex multiplication 06488 * @param[in] *pSrcA points to the first input vector 06489 * @param[in] *pSrcB points to the second input vector 06490 * @param[out] *pDst points to the output vector 06491 * @param[in] numSamples number of complex samples in each vector 06492 * @return none. 06493 */ 06494 06495 void arm_cmplx_mult_cmplx_f32( 06496 float32_t * pSrcA, 06497 float32_t * pSrcB, 06498 float32_t * pDst, 06499 uint32_t numSamples); 06500 06501 /** 06502 * @brief Converts the elements of the floating-point vector to Q31 vector. 06503 * @param[in] *pSrc points to the floating-point input vector 06504 * @param[out] *pDst points to the Q31 output vector 06505 * @param[in] blockSize length of the input vector 06506 * @return none. 06507 */ 06508 void arm_float_to_q31( 06509 float32_t * pSrc, 06510 q31_t * pDst, 06511 uint32_t blockSize); 06512 06513 /** 06514 * @brief Converts the elements of the floating-point vector to Q15 vector. 06515 * @param[in] *pSrc points to the floating-point input vector 06516 * @param[out] *pDst points to the Q15 output vector 06517 * @param[in] blockSize length of the input vector 06518 * @return none 06519 */ 06520 void arm_float_to_q15( 06521 float32_t * pSrc, 06522 q15_t * pDst, 06523 uint32_t blockSize); 06524 06525 /** 06526 * @brief Converts the elements of the floating-point vector to Q7 vector. 06527 * @param[in] *pSrc points to the floating-point input vector 06528 * @param[out] *pDst points to the Q7 output vector 06529 * @param[in] blockSize length of the input vector 06530 * @return none 06531 */ 06532 void arm_float_to_q7( 06533 float32_t * pSrc, 06534 q7_t * pDst, 06535 uint32_t blockSize); 06536 06537 06538 /** 06539 * @brief Converts the elements of the Q31 vector to Q15 vector. 06540 * @param[in] *pSrc is input pointer 06541 * @param[out] *pDst is output pointer 06542 * @param[in] blockSize is the number of samples to process 06543 * @return none. 06544 */ 06545 void arm_q31_to_q15( 06546 q31_t * pSrc, 06547 q15_t * pDst, 06548 uint32_t blockSize); 06549 06550 /** 06551 * @brief Converts the elements of the Q31 vector to Q7 vector. 06552 * @param[in] *pSrc is input pointer 06553 * @param[out] *pDst is output pointer 06554 * @param[in] blockSize is the number of samples to process 06555 * @return none. 06556 */ 06557 void arm_q31_to_q7( 06558 q31_t * pSrc, 06559 q7_t * pDst, 06560 uint32_t blockSize); 06561 06562 /** 06563 * @brief Converts the elements of the Q15 vector to floating-point vector. 06564 * @param[in] *pSrc is input pointer 06565 * @param[out] *pDst is output pointer 06566 * @param[in] blockSize is the number of samples to process 06567 * @return none. 06568 */ 06569 void arm_q15_to_float( 06570 q15_t * pSrc, 06571 float32_t * pDst, 06572 uint32_t blockSize); 06573 06574 06575 /** 06576 * @brief Converts the elements of the Q15 vector to Q31 vector. 06577 * @param[in] *pSrc is input pointer 06578 * @param[out] *pDst is output pointer 06579 * @param[in] blockSize is the number of samples to process 06580 * @return none. 06581 */ 06582 void arm_q15_to_q31( 06583 q15_t * pSrc, 06584 q31_t * pDst, 06585 uint32_t blockSize); 06586 06587 06588 /** 06589 * @brief Converts the elements of the Q15 vector to Q7 vector. 06590 * @param[in] *pSrc is input pointer 06591 * @param[out] *pDst is output pointer 06592 * @param[in] blockSize is the number of samples to process 06593 * @return none. 06594 */ 06595 void arm_q15_to_q7( 06596 q15_t * pSrc, 06597 q7_t * pDst, 06598 uint32_t blockSize); 06599 06600 06601 /** 06602 * @ingroup groupInterpolation 06603 */ 06604 06605 /** 06606 * @defgroup BilinearInterpolate Bilinear Interpolation 06607 * 06608 * Bilinear interpolation is an extension of linear interpolation applied to a two dimensional grid. 06609 * The underlying function <code>f(x, y)</code> is sampled on a regular grid and the interpolation process 06610 * determines values between the grid points. 06611 * Bilinear interpolation is equivalent to two step linear interpolation, first in the x-dimension and then in the y-dimension. 06612 * Bilinear interpolation is often used in image processing to rescale images. 06613 * The CMSIS DSP library provides bilinear interpolation functions for Q7, Q15, Q31, and floating-point data types. 06614 * 06615 * <b>Algorithm</b> 06616 * \par 06617 * The instance structure used by the bilinear interpolation functions describes a two dimensional data table. 06618 * For floating-point, the instance structure is defined as: 06619 * <pre> 06620 * typedef struct 06621 * { 06622 * uint16_t numRows; 06623 * uint16_t numCols; 06624 * float32_t *pData; 06625 * } arm_bilinear_interp_instance_f32; 06626 * </pre> 06627 * 06628 * \par 06629 * where <code>numRows</code> specifies the number of rows in the table; 06630 * <code>numCols</code> specifies the number of columns in the table; 06631 * and <code>pData</code> points to an array of size <code>numRows*numCols</code> values. 06632 * The data table <code>pTable</code> is organized in row order and the supplied data values fall on integer indexes. 06633 * That is, table element (x,y) is located at <code>pTable[x + y*numCols]</code> where x and y are integers. 06634 * 06635 * \par 06636 * Let <code>(x, y)</code> specify the desired interpolation point. Then define: 06637 * <pre> 06638 * XF = floor(x) 06639 * YF = floor(y) 06640 * </pre> 06641 * \par 06642 * The interpolated output point is computed as: 06643 * <pre> 06644 * f(x, y) = f(XF, YF) * (1-(x-XF)) * (1-(y-YF)) 06645 * + f(XF+1, YF) * (x-XF)*(1-(y-YF)) 06646 * + f(XF, YF+1) * (1-(x-XF))*(y-YF) 06647 * + f(XF+1, YF+1) * (x-XF)*(y-YF) 06648 * </pre> 06649 * Note that the coordinates (x, y) contain integer and fractional components. 06650 * The integer components specify which portion of the table to use while the 06651 * fractional components control the interpolation processor. 06652 * 06653 * \par 06654 * if (x,y) are outside of the table boundary, Bilinear interpolation returns zero output. 06655 */ 06656 06657 /** 06658 * @addtogroup BilinearInterpolate 06659 * @{ 06660 */ 06661 06662 /** 06663 * 06664 * @brief Floating-point bilinear interpolation. 06665 * @param[in,out] *S points to an instance of the interpolation structure. 06666 * @param[in] X interpolation coordinate. 06667 * @param[in] Y interpolation coordinate. 06668 * @return out interpolated value. 06669 */ 06670 06671 06672 static __INLINE float32_t arm_bilinear_interp_f32( 06673 const arm_bilinear_interp_instance_f32 * S, 06674 float32_t X, 06675 float32_t Y) 06676 { 06677 float32_t out; 06678 float32_t f00, f01, f10, f11; 06679 float32_t *pData = S->pData; 06680 int32_t xIndex, yIndex, index; 06681 float32_t xdiff, ydiff; 06682 float32_t b1, b2, b3, b4; 06683 06684 xIndex = (int32_t) X; 06685 yIndex = (int32_t) Y; 06686 06687 /* Care taken for table outside boundary */ 06688 /* Returns zero output when values are outside table boundary */ 06689 if(xIndex < 0 || xIndex > (S->numRows-1) || yIndex < 0 || yIndex > ( S->numCols-1)) 06690 { 06691 return(0); 06692 } 06693 06694 /* Calculation of index for two nearest points in X-direction */ 06695 index = (xIndex - 1) + (yIndex - 1) * S->numRows; 06696 06697 06698 /* Read two nearest points in X-direction */ 06699 f00 = pData[index]; 06700 f01 = pData[index + 1]; 06701 06702 /* Calculation of index for two nearest points in Y-direction */ 06703 index = (xIndex - 1) + (yIndex) * S->numRows; 06704 06705 06706 /* Read two nearest points in Y-direction */ 06707 f10 = pData[index]; 06708 f11 = pData[index + 1]; 06709 06710 /* Calculation of intermediate values */ 06711 b1 = f00; 06712 b2 = f01 - f00; 06713 b3 = f10 - f00; 06714 b4 = f00 - f01 - f10 + f11; 06715 06716 /* Calculation of fractional part in X */ 06717 xdiff = X - xIndex; 06718 06719 /* Calculation of fractional part in Y */ 06720 ydiff = Y - yIndex; 06721 06722 /* Calculation of bi-linear interpolated output */ 06723 out = b1 + b2 * xdiff + b3 * ydiff + b4 * xdiff * ydiff; 06724 06725 /* return to application */ 06726 return (out); 06727 06728 } 06729 06730 /** 06731 * 06732 * @brief Q31 bilinear interpolation. 06733 * @param[in,out] *S points to an instance of the interpolation structure. 06734 * @param[in] X interpolation coordinate in 12.20 format. 06735 * @param[in] Y interpolation coordinate in 12.20 format. 06736 * @return out interpolated value. 06737 */ 06738 06739 static __INLINE q31_t arm_bilinear_interp_q31( 06740 arm_bilinear_interp_instance_q31 * S, 06741 q31_t X, 06742 q31_t Y) 06743 { 06744 q31_t out; /* Temporary output */ 06745 q31_t acc = 0; /* output */ 06746 q31_t xfract, yfract; /* X, Y fractional parts */ 06747 q31_t x1, x2, y1, y2; /* Nearest output values */ 06748 int32_t rI, cI; /* Row and column indices */ 06749 q31_t *pYData = S->pData; /* pointer to output table values */ 06750 uint32_t nRows = S->numRows; /* num of rows */ 06751 06752 06753 /* Input is in 12.20 format */ 06754 /* 12 bits for the table index */ 06755 /* Index value calculation */ 06756 rI = ((X & 0xFFF00000) >> 20u); 06757 06758 /* Input is in 12.20 format */ 06759 /* 12 bits for the table index */ 06760 /* Index value calculation */ 06761 cI = ((Y & 0xFFF00000) >> 20u); 06762 06763 /* Care taken for table outside boundary */ 06764 /* Returns zero output when values are outside table boundary */ 06765 if(rI < 0 || rI > (S->numRows-1) || cI < 0 || cI > ( S->numCols-1)) 06766 { 06767 return(0); 06768 } 06769 06770 /* 20 bits for the fractional part */ 06771 /* shift left xfract by 11 to keep 1.31 format */ 06772 xfract = (X & 0x000FFFFF) << 11u; 06773 06774 /* Read two nearest output values from the index */ 06775 x1 = pYData[(rI) + nRows * (cI)]; 06776 x2 = pYData[(rI) + nRows * (cI) + 1u]; 06777 06778 /* 20 bits for the fractional part */ 06779 /* shift left yfract by 11 to keep 1.31 format */ 06780 yfract = (Y & 0x000FFFFF) << 11u; 06781 06782 /* Read two nearest output values from the index */ 06783 y1 = pYData[(rI) + nRows * (cI + 1)]; 06784 y2 = pYData[(rI) + nRows * (cI + 1) + 1u]; 06785 06786 /* Calculation of x1 * (1-xfract ) * (1-yfract) and acc is in 3.29(q29) format */ 06787 out = ((q31_t) (((q63_t) x1 * (0x7FFFFFFF - xfract)) >> 32)); 06788 acc = ((q31_t) (((q63_t) out * (0x7FFFFFFF - yfract)) >> 32)); 06789 06790 /* x2 * (xfract) * (1-yfract) in 3.29(q29) and adding to acc */ 06791 out = ((q31_t) ((q63_t) x2 * (0x7FFFFFFF - yfract) >> 32)); 06792 acc += ((q31_t) ((q63_t) out * (xfract) >> 32)); 06793 06794 /* y1 * (1 - xfract) * (yfract) in 3.29(q29) and adding to acc */ 06795 out = ((q31_t) ((q63_t) y1 * (0x7FFFFFFF - xfract) >> 32)); 06796 acc += ((q31_t) ((q63_t) out * (yfract) >> 32)); 06797 06798 /* y2 * (xfract) * (yfract) in 3.29(q29) and adding to acc */ 06799 out = ((q31_t) ((q63_t) y2 * (xfract) >> 32)); 06800 acc += ((q31_t) ((q63_t) out * (yfract) >> 32)); 06801 06802 /* Convert acc to 1.31(q31) format */ 06803 return (acc << 2u); 06804 06805 } 06806 06807 /** 06808 * @brief Q15 bilinear interpolation. 06809 * @param[in,out] *S points to an instance of the interpolation structure. 06810 * @param[in] X interpolation coordinate in 12.20 format. 06811 * @param[in] Y interpolation coordinate in 12.20 format. 06812 * @return out interpolated value. 06813 */ 06814 06815 static __INLINE q15_t arm_bilinear_interp_q15( 06816 arm_bilinear_interp_instance_q15 * S, 06817 q31_t X, 06818 q31_t Y) 06819 { 06820 q63_t acc = 0; /* output */ 06821 q31_t out; /* Temporary output */ 06822 q15_t x1, x2, y1, y2; /* Nearest output values */ 06823 q31_t xfract, yfract; /* X, Y fractional parts */ 06824 int32_t rI, cI; /* Row and column indices */ 06825 q15_t *pYData = S->pData; /* pointer to output table values */ 06826 uint32_t nRows = S->numRows; /* num of rows */ 06827 06828 /* Input is in 12.20 format */ 06829 /* 12 bits for the table index */ 06830 /* Index value calculation */ 06831 rI = ((X & 0xFFF00000) >> 20); 06832 06833 /* Input is in 12.20 format */ 06834 /* 12 bits for the table index */ 06835 /* Index value calculation */ 06836 cI = ((Y & 0xFFF00000) >> 20); 06837 06838 /* Care taken for table outside boundary */ 06839 /* Returns zero output when values are outside table boundary */ 06840 if(rI < 0 || rI > (S->numRows-1) || cI < 0 || cI > ( S->numCols-1)) 06841 { 06842 return(0); 06843 } 06844 06845 /* 20 bits for the fractional part */ 06846 /* xfract should be in 12.20 format */ 06847 xfract = (X & 0x000FFFFF); 06848 06849 /* Read two nearest output values from the index */ 06850 x1 = pYData[(rI) + nRows * (cI)]; 06851 x2 = pYData[(rI) + nRows * (cI) + 1u]; 06852 06853 06854 /* 20 bits for the fractional part */ 06855 /* yfract should be in 12.20 format */ 06856 yfract = (Y & 0x000FFFFF); 06857 06858 /* Read two nearest output values from the index */ 06859 y1 = pYData[(rI) + nRows * (cI + 1)]; 06860 y2 = pYData[(rI) + nRows * (cI + 1) + 1u]; 06861 06862 /* Calculation of x1 * (1-xfract ) * (1-yfract) and acc is in 13.51 format */ 06863 06864 /* x1 is in 1.15(q15), xfract in 12.20 format and out is in 13.35 format */ 06865 /* convert 13.35 to 13.31 by right shifting and out is in 1.31 */ 06866 out = (q31_t) (((q63_t) x1 * (0xFFFFF - xfract)) >> 4u); 06867 acc = ((q63_t) out * (0xFFFFF - yfract)); 06868 06869 /* x2 * (xfract) * (1-yfract) in 1.51 and adding to acc */ 06870 out = (q31_t) (((q63_t) x2 * (0xFFFFF - yfract)) >> 4u); 06871 acc += ((q63_t) out * (xfract)); 06872 06873 /* y1 * (1 - xfract) * (yfract) in 1.51 and adding to acc */ 06874 out = (q31_t) (((q63_t) y1 * (0xFFFFF - xfract)) >> 4u); 06875 acc += ((q63_t) out * (yfract)); 06876 06877 /* y2 * (xfract) * (yfract) in 1.51 and adding to acc */ 06878 out = (q31_t) (((q63_t) y2 * (xfract)) >> 4u); 06879 acc += ((q63_t) out * (yfract)); 06880 06881 /* acc is in 13.51 format and down shift acc by 36 times */ 06882 /* Convert out to 1.15 format */ 06883 return (acc >> 36); 06884 06885 } 06886 06887 /** 06888 * @brief Q7 bilinear interpolation. 06889 * @param[in,out] *S points to an instance of the interpolation structure. 06890 * @param[in] X interpolation coordinate in 12.20 format. 06891 * @param[in] Y interpolation coordinate in 12.20 format. 06892 * @return out interpolated value. 06893 */ 06894 06895 static __INLINE q7_t arm_bilinear_interp_q7( 06896 arm_bilinear_interp_instance_q7 * S, 06897 q31_t X, 06898 q31_t Y) 06899 { 06900 q63_t acc = 0; /* output */ 06901 q31_t out; /* Temporary output */ 06902 q31_t xfract, yfract; /* X, Y fractional parts */ 06903 q7_t x1, x2, y1, y2; /* Nearest output values */ 06904 int32_t rI, cI; /* Row and column indices */ 06905 q7_t *pYData = S->pData; /* pointer to output table values */ 06906 uint32_t nRows = S->numRows; /* num of rows */ 06907 06908 /* Input is in 12.20 format */ 06909 /* 12 bits for the table index */ 06910 /* Index value calculation */ 06911 rI = ((X & 0xFFF00000) >> 20); 06912 06913 /* Input is in 12.20 format */ 06914 /* 12 bits for the table index */ 06915 /* Index value calculation */ 06916 cI = ((Y & 0xFFF00000) >> 20); 06917 06918 /* Care taken for table outside boundary */ 06919 /* Returns zero output when values are outside table boundary */ 06920 if(rI < 0 || rI > (S->numRows-1) || cI < 0 || cI > ( S->numCols-1)) 06921 { 06922 return(0); 06923 } 06924 06925 /* 20 bits for the fractional part */ 06926 /* xfract should be in 12.20 format */ 06927 xfract = (X & 0x000FFFFF); 06928 06929 /* Read two nearest output values from the index */ 06930 x1 = pYData[(rI) + nRows * (cI)]; 06931 x2 = pYData[(rI) + nRows * (cI) + 1u]; 06932 06933 06934 /* 20 bits for the fractional part */ 06935 /* yfract should be in 12.20 format */ 06936 yfract = (Y & 0x000FFFFF); 06937 06938 /* Read two nearest output values from the index */ 06939 y1 = pYData[(rI) + nRows * (cI + 1)]; 06940 y2 = pYData[(rI) + nRows * (cI + 1) + 1u]; 06941 06942 /* Calculation of x1 * (1-xfract ) * (1-yfract) and acc is in 16.47 format */ 06943 out = ((x1 * (0xFFFFF - xfract))); 06944 acc = (((q63_t) out * (0xFFFFF - yfract))); 06945 06946 /* x2 * (xfract) * (1-yfract) in 2.22 and adding to acc */ 06947 out = ((x2 * (0xFFFFF - yfract))); 06948 acc += (((q63_t) out * (xfract))); 06949 06950 /* y1 * (1 - xfract) * (yfract) in 2.22 and adding to acc */ 06951 out = ((y1 * (0xFFFFF - xfract))); 06952 acc += (((q63_t) out * (yfract))); 06953 06954 /* y2 * (xfract) * (yfract) in 2.22 and adding to acc */ 06955 out = ((y2 * (yfract))); 06956 acc += (((q63_t) out * (xfract))); 06957 06958 /* acc in 16.47 format and down shift by 40 to convert to 1.7 format */ 06959 return (acc >> 40); 06960 06961 } 06962 06963 /** 06964 * @} end of BilinearInterpolate group 06965 */ 06966 06967 06968 06969 06970 06971 06972 #ifdef __cplusplus 06973 } 06974 #endif 06975 06976 06977 #endif /* _ARM_MATH_H */ 06978 06979 06980 /** 06981 * 06982 * End of file. 06983 */
Generated on Tue Jul 12 2022 19:55:43 by
1.7.2
