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