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