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