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