aboutsummaryrefslogtreecommitdiff
path: root/lib/arm_atsam/packs/arm
diff options
context:
space:
mode:
authorpatrickmt <40182064+patrickmt@users.noreply.github.com>2018-08-29 15:07:52 -0400
committerJack Humbert <jack.humb@gmail.com>2018-08-29 15:07:52 -0400
commit30680c6eb396a2bb06928afd69edae9908ac84fb (patch)
treea4a6c2598faa25dec208377a70dc0fb895ee9c8a /lib/arm_atsam/packs/arm
parenta6c770432f1348c44bc199029ce17b1b9ff4191c (diff)
downloadqmk_firmware-30680c6eb396a2bb06928afd69edae9908ac84fb.tar.gz
qmk_firmware-30680c6eb396a2bb06928afd69edae9908ac84fb.zip
Massdrop keyboard support (#3780)
* Massdrop SAMD51 Massdrop SAMD51 keyboards initial project upload * Removing relocated files Removing files that were relocated and not deleted from previous location * LED queue fix and cleaning Cleaned some white space or comments. Fix for LED I2C command queue. Cleaned up interrupts. Added debug function for printing numbers to scope through m15 line. * Factory programmed serial usage Ability to use factory programmed serial in hub and keyboard usb descriptors * USB serial number and bugfix Added support for factory programmed serial and usage. Incorporated bootloader's conditional compiling to align project closer. Fixed issue when USB device attempted to send before enabled. General white space and comment cleanup. * Project cleanup Cleaned up project in terms of white space, commented code, and unecessary files. NKRO keyboard is now using correct setreport although KBD was fine to use. Fixed broken linkage to __xprintf for serial debug statements. * Fix for extra keys Fixed possible USB hang on extra keys report set missing * I2C cleanup I2C cleanup and file renames necessary for master branch merge * Boot tracing and clocks cleanup Added optional boot debug trace mode through debug LED codes. General clock code cleanup. * Relocate ARM/Atmel headers Moved ARM/Atmel header folder from drivers to lib and made necessary makefile changes. * Pull request changes Pull request changes * Keymap and compile flag fix Keymap fix for momentary layer. Potential compile flag fix for Travis CI failure. * va_list include fix Fix for va_list compile failure * Include file case fixes Fixes for include files with incorrect case * ctrl and alt67 keyboard readme Added ctrl and alt67 keyboard readme files
Diffstat (limited to 'lib/arm_atsam/packs/arm')
-rw-r--r--lib/arm_atsam/packs/arm/cmsis/5.0.1/CMSIS/Include/arm_math.h7226
-rw-r--r--lib/arm_atsam/packs/arm/cmsis/5.0.1/CMSIS/Include/cmsis_compiler.h223
-rw-r--r--lib/arm_atsam/packs/arm/cmsis/5.0.1/CMSIS/Include/cmsis_gcc.h1899
-rw-r--r--lib/arm_atsam/packs/arm/cmsis/5.0.1/CMSIS/Include/core_cm4.h2103
-rw-r--r--lib/arm_atsam/packs/arm/cmsis/5.0.1/LICENSE.txt201
5 files changed, 11652 insertions, 0 deletions
diff --git a/lib/arm_atsam/packs/arm/cmsis/5.0.1/CMSIS/Include/arm_math.h b/lib/arm_atsam/packs/arm/cmsis/5.0.1/CMSIS/Include/arm_math.h
new file mode 100644
index 000000000..4be7e8c84
--- /dev/null
+++ b/lib/arm_atsam/packs/arm/cmsis/5.0.1/CMSIS/Include/arm_math.h
@@ -0,0 +1,7226 @@
1/* ----------------------------------------------------------------------
2 * Project: CMSIS DSP Library
3 * Title: arm_math.h
4 * Description: Public header file for CMSIS DSP Library
5 *
6 * $Date: 27. January 2017
7 * $Revision: V.1.5.1
8 *
9 * Target Processor: Cortex-M cores
10 * -------------------------------------------------------------------- */
11/*
12 * Copyright (C) 2010-2017 ARM Limited or its affiliates. All rights reserved.
13 *
14 * SPDX-License-Identifier: Apache-2.0
15 *
16 * Licensed under the Apache License, Version 2.0 (the License); you may
17 * not use this file except in compliance with the License.
18 * You may obtain a copy of the License at
19 *
20 * www.apache.org/licenses/LICENSE-2.0
21 *
22 * Unless required by applicable law or agreed to in writing, software
23 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
24 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25 * See the License for the specific language governing permissions and
26 * limitations under the License.
27 */
28
29/**
30 \mainpage CMSIS DSP Software Library
31 *
32 * Introduction
33 * ------------
34 *
35 * This user manual describes the CMSIS DSP software library,
36 * a suite of common signal processing functions for use on Cortex-M processor based devices.
37 *
38 * The library is divided into a number of functions each covering a specific category:
39 * - Basic math functions
40 * - Fast math functions
41 * - Complex math functions
42 * - Filters
43 * - Matrix functions
44 * - Transforms
45 * - Motor control functions
46 * - Statistical functions
47 * - Support functions
48 * - Interpolation functions
49 *
50 * The library has separate functions for operating on 8-bit integers, 16-bit integers,
51 * 32-bit integer and 32-bit floating-point values.
52 *
53 * Using the Library
54 * ------------
55 *
56 * The library installer contains prebuilt versions of the libraries in the <code>Lib</code> folder.
57 * - arm_cortexM7lfdp_math.lib (Cortex-M7, Little endian, Double Precision Floating Point Unit)
58 * - arm_cortexM7bfdp_math.lib (Cortex-M7, Big endian, Double Precision Floating Point Unit)
59 * - arm_cortexM7lfsp_math.lib (Cortex-M7, Little endian, Single Precision Floating Point Unit)
60 * - arm_cortexM7bfsp_math.lib (Cortex-M7, Big endian and Single Precision Floating Point Unit on)
61 * - arm_cortexM7l_math.lib (Cortex-M7, Little endian)
62 * - arm_cortexM7b_math.lib (Cortex-M7, Big endian)
63 * - arm_cortexM4lf_math.lib (Cortex-M4, Little endian, Floating Point Unit)
64 * - arm_cortexM4bf_math.lib (Cortex-M4, Big endian, Floating Point Unit)
65 * - arm_cortexM4l_math.lib (Cortex-M4, Little endian)
66 * - arm_cortexM4b_math.lib (Cortex-M4, Big endian)
67 * - arm_cortexM3l_math.lib (Cortex-M3, Little endian)
68 * - arm_cortexM3b_math.lib (Cortex-M3, Big endian)
69 * - arm_cortexM0l_math.lib (Cortex-M0 / Cortex-M0+, Little endian)
70 * - arm_cortexM0b_math.lib (Cortex-M0 / Cortex-M0+, Big endian)
71 * - arm_ARMv8MBLl_math.lib (ARMv8M Baseline, Little endian)
72 * - arm_ARMv8MMLl_math.lib (ARMv8M Mainline, Little endian)
73 * - arm_ARMv8MMLlfsp_math.lib (ARMv8M Mainline, Little endian, Single Precision Floating Point Unit)
74 * - arm_ARMv8MMLld_math.lib (ARMv8M Mainline, Little endian, DSP instructions)
75 * - arm_ARMv8MMLldfsp_math.lib (ARMv8M Mainline, Little endian, DSP instructions, Single Precision Floating Point Unit)
76 *
77 * The library functions are declared in the public file <code>arm_math.h</code> which is placed in the <code>Include</code> folder.
78 * Simply include this file and link the appropriate library in the application and begin calling the library functions. The Library supports single
79 * 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.
80 * Define the appropriate pre processor MACRO ARM_MATH_CM7 or ARM_MATH_CM4 or ARM_MATH_CM3 or
81 * ARM_MATH_CM0 or ARM_MATH_CM0PLUS depending on the target processor in the application.
82 * For ARMv8M cores define pre processor MACRO ARM_MATH_ARMV8MBL or ARM_MATH_ARMV8MML.
83 * Set Pre processor MACRO __DSP_PRESENT if ARMv8M Mainline core supports DSP instructions.
84 *
85 *
86 * Examples
87 * --------
88 *
89 * The library ships with a number of examples which demonstrate how to use the library functions.
90 *
91 * Toolchain Support
92 * ------------
93 *
94 * The library has been developed and tested with MDK-ARM version 5.14.0.0
95 * The library is being tested in GCC and IAR toolchains and updates on this activity will be made available shortly.
96 *
97 * Building the Library
98 * ------------
99 *
100 * The library installer contains a project file to re build libraries on MDK-ARM Tool chain in the <code>CMSIS\\DSP_Lib\\Source\\ARM</code> folder.
101 * - arm_cortexM_math.uvprojx
102 *
103 *
104 * The libraries can be built by opening the arm_cortexM_math.uvprojx project in MDK-ARM, selecting a specific target, and defining the optional pre processor MACROs detailed above.
105 *
106 * Pre-processor Macros
107 * ------------
108 *
109 * Each library project have differant pre-processor macros.
110 *
111 * - UNALIGNED_SUPPORT_DISABLE:
112 *
113 * Define macro UNALIGNED_SUPPORT_DISABLE, If the silicon does not support unaligned memory access
114 *
115 * - ARM_MATH_BIG_ENDIAN:
116 *
117 * Define macro ARM_MATH_BIG_ENDIAN to build the library for big endian targets. By default library builds for little endian targets.
118 *
119 * - ARM_MATH_MATRIX_CHECK:
120 *
121 * Define macro ARM_MATH_MATRIX_CHECK for checking on the input and output sizes of matrices
122 *
123 * - ARM_MATH_ROUNDING:
124 *
125 * Define macro ARM_MATH_ROUNDING for rounding on support functions
126 *
127 * - ARM_MATH_CMx:
128 *
129 * Define macro ARM_MATH_CM4 for building the library on Cortex-M4 target, ARM_MATH_CM3 for building library on Cortex-M3 target
130 * and ARM_MATH_CM0 for building library on Cortex-M0 target, ARM_MATH_CM0PLUS for building library on Cortex-M0+ target, and
131 * ARM_MATH_CM7 for building the library on cortex-M7.
132 *
133 * - ARM_MATH_ARMV8MxL:
134 *
135 * Define macro ARM_MATH_ARMV8MBL for building the library on ARMv8M Baseline target, ARM_MATH_ARMV8MBL for building library
136 * on ARMv8M Mainline target.
137 *
138 * - __FPU_PRESENT:
139 *
140 * Initialize macro __FPU_PRESENT = 1 when building on FPU supported Targets. Enable this macro for floating point libraries.
141 *
142 * - __DSP_PRESENT:
143 *
144 * Initialize macro __DSP_PRESENT = 1 when ARMv8M Mainline core supports DSP instructions.
145 *
146 * <hr>
147 * CMSIS-DSP in ARM::CMSIS Pack
148 * -----------------------------
149 *
150 * The following files relevant to CMSIS-DSP are present in the <b>ARM::CMSIS</b> Pack directories:
151 * |File/Folder |Content |
152 * |------------------------------|------------------------------------------------------------------------|
153 * |\b CMSIS\\Documentation\\DSP | This documentation |
154 * |\b CMSIS\\DSP_Lib | Software license agreement (license.txt) |
155 * |\b CMSIS\\DSP_Lib\\Examples | Example projects demonstrating the usage of the library functions |
156 * |\b CMSIS\\DSP_Lib\\Source | Source files for rebuilding the library |
157 *
158 * <hr>
159 * Revision History of CMSIS-DSP
160 * ------------
161 * Please refer to \ref ChangeLog_pg.
162 *
163 * Copyright Notice
164 * ------------
165 *
166 * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
167 */
168
169
170/**
171 * @defgroup groupMath Basic Math Functions
172 */
173
174/**
175 * @defgroup groupFastMath Fast Math Functions
176 * This set of functions provides a fast approximation to sine, cosine, and square root.
177 * As compared to most of the other functions in the CMSIS math library, the fast math functions
178 * operate on individual values and not arrays.
179 * There are separate functions for Q15, Q31, and floating-point data.
180 *
181 */
182
183/**
184 * @defgroup groupCmplxMath Complex Math Functions
185 * This set of functions operates on complex data vectors.
186 * The data in the complex arrays is stored in an interleaved fashion
187 * (real, imag, real, imag, ...).
188 * In the API functions, the number of samples in a complex array refers
189 * to the number of complex values; the array contains twice this number of
190 * real values.
191 */
192
193/**
194 * @defgroup groupFilters Filtering Functions
195 */
196
197/**
198 * @defgroup groupMatrix Matrix Functions
199 *
200 * This set of functions provides basic matrix math operations.
201 * The functions operate on matrix data structures. For example,
202 * the type
203 * definition for the floating-point matrix structure is shown
204 * below:
205 * <pre>
206 * typedef struct
207 * {
208 * uint16_t numRows; // number of rows of the matrix.
209 * uint16_t numCols; // number of columns of the matrix.
210 * float32_t *pData; // points to the data of the matrix.
211 * } arm_matrix_instance_f32;
212 * </pre>
213 * There are similar definitions for Q15 and Q31 data types.
214 *
215 * The structure specifies the size of the matrix and then points to
216 * an array of data. The array is of size <code>numRows X numCols</code>
217 * and the values are arranged in row order. That is, the
218 * matrix element (i, j) is stored at:
219 * <pre>
220 * pData[i*numCols + j]
221 * </pre>
222 *
223 * \par Init Functions
224 * There is an associated initialization function for each type of matrix
225 * data structure.
226 * The initialization function sets the values of the internal structure fields.
227 * Refer to the function <code>arm_mat_init_f32()</code>, <code>arm_mat_init_q31()</code>
228 * and <code>arm_mat_init_q15()</code> for floating-point, Q31 and Q15 types, respectively.
229 *
230 * \par
231 * Use of the initialization function is optional. However, if initialization function is used
232 * then the instance structure cannot be placed into a const data section.
233 * To place the instance structure in a const data
234 * section, manually initialize the data structure. For example:
235 * <pre>
236 * <code>arm_matrix_instance_f32 S = {nRows, nColumns, pData};</code>
237 * <code>arm_matrix_instance_q31 S = {nRows, nColumns, pData};</code>
238 * <code>arm_matrix_instance_q15 S = {nRows, nColumns, pData};</code>
239 * </pre>
240 * where <code>nRows</code> specifies the number of rows, <code>nColumns</code>
241 * specifies the number of columns, and <code>pData</code> points to the
242 * data array.
243 *
244 * \par Size Checking
245 * By default all of the matrix functions perform size checking on the input and
246 * output matrices. For example, the matrix addition function verifies that the
247 * two input matrices and the output matrix all have the same number of rows and
248 * columns. If the size check fails the functions return:
249 * <pre>
250 * ARM_MATH_SIZE_MISMATCH
251 * </pre>
252 * Otherwise the functions return
253 * <pre>
254 * ARM_MATH_SUCCESS
255 * </pre>
256 * There is some overhead associated with this matrix size checking.
257 * The matrix size checking is enabled via the \#define
258 * <pre>
259 * ARM_MATH_MATRIX_CHECK
260 * </pre>
261 * within the library project settings. By default this macro is defined
262 * and size checking is enabled. By changing the project settings and
263 * undefining this macro size checking is eliminated and the functions
264 * run a bit faster. With size checking disabled the functions always
265 * return <code>ARM_MATH_SUCCESS</code>.
266 */
267
268/**
269 * @defgroup groupTransforms Transform Functions
270 */
271
272/**
273 * @defgroup groupController Controller Functions
274 */
275
276/**
277 * @defgroup groupStats Statistics Functions
278 */
279/**
280 * @defgroup groupSupport Support Functions
281 */
282
283/**
284 * @defgroup groupInterpolation Interpolation Functions
285 * These functions perform 1- and 2-dimensional interpolation of data.
286 * Linear interpolation is used for 1-dimensional data and
287 * bilinear interpolation is used for 2-dimensional data.
288 */
289
290/**
291 * @defgroup groupExamples Examples
292 */
293#ifndef _ARM_MATH_H
294#define _ARM_MATH_H
295
296/* ignore some GCC warnings */
297#if defined ( __GNUC__ )
298#pragma GCC diagnostic push
299#pragma GCC diagnostic ignored "-Wsign-conversion"
300#pragma GCC diagnostic ignored "-Wconversion"
301#pragma GCC diagnostic ignored "-Wunused-parameter"
302#endif
303
304#define __CMSIS_GENERIC /* disable NVIC and Systick functions */
305
306#if defined(ARM_MATH_CM7)
307 #include "core_cm7.h"
308 #define ARM_MATH_DSP
309#elif defined (ARM_MATH_CM4)
310 #include "core_cm4.h"
311 #define ARM_MATH_DSP
312#elif defined (ARM_MATH_CM3)
313 #include "core_cm3.h"
314#elif defined (ARM_MATH_CM0)
315 #include "core_cm0.h"
316 #define ARM_MATH_CM0_FAMILY
317#elif defined (ARM_MATH_CM0PLUS)
318 #include "core_cm0plus.h"
319 #define ARM_MATH_CM0_FAMILY
320#elif defined (ARM_MATH_ARMV8MBL)
321 #include "core_armv8mbl.h"
322 #define ARM_MATH_CM0_FAMILY
323#elif defined (ARM_MATH_ARMV8MML)
324 #include "core_armv8mml.h"
325 #if (defined (__DSP_PRESENT) && (__DSP_PRESENT == 1))
326 #define ARM_MATH_DSP
327 #endif
328#else
329 #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"
330#endif
331
332#undef __CMSIS_GENERIC /* enable NVIC and Systick functions */
333#include "string.h"
334#include "math.h"
335#ifdef __cplusplus
336extern "C"
337{
338#endif
339
340
341 /**
342 * @brief Macros required for reciprocal calculation in Normalized LMS
343 */
344
345#define DELTA_Q31 (0x100)
346#define DELTA_Q15 0x5
347#define INDEX_MASK 0x0000003F
348#ifndef PI
349 #define PI 3.14159265358979f
350#endif
351
352 /**
353 * @brief Macros required for SINE and COSINE Fast math approximations
354 */
355
356#define FAST_MATH_TABLE_SIZE 512
357#define FAST_MATH_Q31_SHIFT (32 - 10)
358#define FAST_MATH_Q15_SHIFT (16 - 10)
359#define CONTROLLER_Q31_SHIFT (32 - 9)
360#define TABLE_SPACING_Q31 0x400000
361#define TABLE_SPACING_Q15 0x80
362
363 /**
364 * @brief Macros required for SINE and COSINE Controller functions
365 */
366 /* 1.31(q31) Fixed value of 2/360 */
367 /* -1 to +1 is divided into 360 values so total spacing is (2/360) */
368#define INPUT_SPACING 0xB60B61
369
370 /**
371 * @brief Macro for Unaligned Support
372 */
373#ifndef UNALIGNED_SUPPORT_DISABLE
374 #define ALIGN4
375#else
376 #if defined (__GNUC__)
377 #define ALIGN4 __attribute__((aligned(4)))
378 #else
379 #define ALIGN4 __align(4)
380 #endif
381#endif /* #ifndef UNALIGNED_SUPPORT_DISABLE */
382
383 /**
384 * @brief Error status returned by some functions in the library.
385 */
386
387 typedef enum
388 {
389 ARM_MATH_SUCCESS = 0, /**< No error */
390 ARM_MATH_ARGUMENT_ERROR = -1, /**< One or more arguments are incorrect */
391 ARM_MATH_LENGTH_ERROR = -2, /**< Length of data buffer is incorrect */
392 ARM_MATH_SIZE_MISMATCH = -3, /**< Size of matrices is not compatible with the operation. */
393 ARM_MATH_NANINF = -4, /**< Not-a-number (NaN) or infinity is generated */
394 ARM_MATH_SINGULAR = -5, /**< Generated by matrix inversion if the input matrix is singular and cannot be inverted. */
395 ARM_MATH_TEST_FAILURE = -6 /**< Test Failed */
396 } arm_status;
397
398 /**
399 * @brief 8-bit fractional data type in 1.7 format.
400 */
401 typedef int8_t q7_t;
402
403 /**
404 * @brief 16-bit fractional data type in 1.15 format.
405 */
406 typedef int16_t q15_t;
407
408 /**
409 * @brief 32-bit fractional data type in 1.31 format.
410 */
411 typedef int32_t q31_t;
412
413 /**
414 * @brief 64-bit fractional data type in 1.63 format.
415 */
416 typedef int64_t q63_t;
417
418 /**
419 * @brief 32-bit floating-point type definition.
420 */
421 typedef float float32_t;
422
423 /**
424 * @brief 64-bit floating-point type definition.
425 */
426 typedef double float64_t;
427
428 /**
429 * @brief definition to read/write two 16 bit values.
430 */
431#if defined ( __CC_ARM )
432 #define __SIMD32_TYPE int32_t __packed
433 #define CMSIS_UNUSED __attribute__((unused))
434 #define CMSIS_INLINE __attribute__((always_inline))
435
436#elif defined ( __ARMCC_VERSION ) && ( __ARMCC_VERSION >= 6010050 )
437 #define __SIMD32_TYPE int32_t
438 #define CMSIS_UNUSED __attribute__((unused))
439 #define CMSIS_INLINE __attribute__((always_inline))
440
441#elif defined ( __GNUC__ )
442 #define __SIMD32_TYPE int32_t
443 #define CMSIS_UNUSED __attribute__((unused))
444 #define CMSIS_INLINE __attribute__((always_inline))
445
446#elif defined ( __ICCARM__ )
447 #define __SIMD32_TYPE int32_t __packed
448 #define CMSIS_UNUSED
449 #define CMSIS_INLINE
450
451#elif defined ( __TI_ARM__ )
452 #define __SIMD32_TYPE int32_t
453 #define CMSIS_UNUSED __attribute__((unused))
454 #define CMSIS_INLINE
455
456#elif defined ( __CSMC__ )
457 #define __SIMD32_TYPE int32_t
458 #define CMSIS_UNUSED
459 #define CMSIS_INLINE
460
461#elif defined ( __TASKING__ )
462 #define __SIMD32_TYPE __unaligned int32_t
463 #define CMSIS_UNUSED
464 #define CMSIS_INLINE
465
466#else
467 #error Unknown compiler
468#endif
469
470#define __SIMD32(addr) (*(__SIMD32_TYPE **) & (addr))
471#define __SIMD32_CONST(addr) ((__SIMD32_TYPE *)(addr))
472#define _SIMD32_OFFSET(addr) (*(__SIMD32_TYPE *) (addr))
473#define __SIMD64(addr) (*(int64_t **) & (addr))
474
475/* #if defined (ARM_MATH_CM3) || defined (ARM_MATH_CM0_FAMILY) */
476#if !defined (ARM_MATH_DSP)
477 /**
478 * @brief definition to pack two 16 bit values.
479 */
480#define __PKHBT(ARG1, ARG2, ARG3) ( (((int32_t)(ARG1) << 0) & (int32_t)0x0000FFFF) | \
481 (((int32_t)(ARG2) << ARG3) & (int32_t)0xFFFF0000) )
482#define __PKHTB(ARG1, ARG2, ARG3) ( (((int32_t)(ARG1) << 0) & (int32_t)0xFFFF0000) | \
483 (((int32_t)(ARG2) >> ARG3) & (int32_t)0x0000FFFF) )
484
485/* #endif // defined (ARM_MATH_CM3) || defined (ARM_MATH_CM0_FAMILY) */
486#endif /* !defined (ARM_MATH_DSP) */
487
488 /**
489 * @brief definition to pack four 8 bit values.
490 */
491#ifndef ARM_MATH_BIG_ENDIAN
492
493#define __PACKq7(v0,v1,v2,v3) ( (((int32_t)(v0) << 0) & (int32_t)0x000000FF) | \
494 (((int32_t)(v1) << 8) & (int32_t)0x0000FF00) | \
495 (((int32_t)(v2) << 16) & (int32_t)0x00FF0000) | \
496 (((int32_t)(v3) << 24) & (int32_t)0xFF000000) )
497#else
498
499#define __PACKq7(v0,v1,v2,v3) ( (((int32_t)(v3) << 0) & (int32_t)0x000000FF) | \
500 (((int32_t)(v2) << 8) & (int32_t)0x0000FF00) | \
501 (((int32_t)(v1) << 16) & (int32_t)0x00FF0000) | \
502 (((int32_t)(v0) << 24) & (int32_t)0xFF000000) )
503
504#endif
505
506
507 /**
508 * @brief Clips Q63 to Q31 values.
509 */
510 CMSIS_INLINE __STATIC_INLINE q31_t clip_q63_to_q31(
511 q63_t x)
512 {
513 return ((q31_t) (x >> 32) != ((q31_t) x >> 31)) ?
514 ((0x7FFFFFFF ^ ((q31_t) (x >> 63)))) : (q31_t) x;
515 }
516
517 /**
518 * @brief Clips Q63 to Q15 values.
519 */
520 CMSIS_INLINE __STATIC_INLINE q15_t clip_q63_to_q15(
521 q63_t x)
522 {
523 return ((q31_t) (x >> 32) != ((q31_t) x >> 31)) ?
524 ((0x7FFF ^ ((q15_t) (x >> 63)))) : (q15_t) (x >> 15);
525 }
526
527 /**
528 * @brief Clips Q31 to Q7 values.
529 */
530 CMSIS_INLINE __STATIC_INLINE q7_t clip_q31_to_q7(
531 q31_t x)
532 {
533 return ((q31_t) (x >> 24) != ((q31_t) x >> 23)) ?
534 ((0x7F ^ ((q7_t) (x >> 31)))) : (q7_t) x;
535 }
536
537 /**
538 * @brief Clips Q31 to Q15 values.
539 */
540 CMSIS_INLINE __STATIC_INLINE q15_t clip_q31_to_q15(
541 q31_t x)
542 {
543 return ((q31_t) (x >> 16) != ((q31_t) x >> 15)) ?
544 ((0x7FFF ^ ((q15_t) (x >> 31)))) : (q15_t) x;
545 }
546
547 /**
548 * @brief Multiplies 32 X 64 and returns 32 bit result in 2.30 format.
549 */
550
551 CMSIS_INLINE __STATIC_INLINE q63_t mult32x64(
552 q63_t x,
553 q31_t y)
554 {
555 return ((((q63_t) (x & 0x00000000FFFFFFFF) * y) >> 32) +
556 (((q63_t) (x >> 32) * y)));
557 }
558
559/*
560 #if defined (ARM_MATH_CM0_FAMILY) && defined ( __CC_ARM )
561 #define __CLZ __clz
562 #endif
563 */
564/* note: function can be removed when all toolchain support __CLZ for Cortex-M0 */
565#if defined (ARM_MATH_CM0_FAMILY) && ((defined (__ICCARM__)) )
566 CMSIS_INLINE __STATIC_INLINE uint32_t __CLZ(
567 q31_t data);
568
569 CMSIS_INLINE __STATIC_INLINE uint32_t __CLZ(
570 q31_t data)
571 {
572 uint32_t count = 0;
573 uint32_t mask = 0x80000000;
574
575 while ((data & mask) == 0)
576 {
577 count += 1u;
578 mask = mask >> 1u;
579 }
580
581 return (count);
582 }
583#endif
584
585 /**
586 * @brief Function to Calculates 1/in (reciprocal) value of Q31 Data type.
587 */
588
589 CMSIS_INLINE __STATIC_INLINE uint32_t arm_recip_q31(
590 q31_t in,
591 q31_t * dst,
592 q31_t * pRecipTable)
593 {
594 q31_t out;
595 uint32_t tempVal;
596 uint32_t index, i;
597 uint32_t signBits;
598
599 if (in > 0)
600 {
601 signBits = ((uint32_t) (__CLZ( in) - 1));
602 }
603 else
604 {
605 signBits = ((uint32_t) (__CLZ(-in) - 1));
606 }
607
608 /* Convert input sample to 1.31 format */
609 in = (in << signBits);
610
611 /* calculation of index for initial approximated Val */
612 index = (uint32_t)(in >> 24);
613 index = (index & INDEX_MASK);
614
615 /* 1.31 with exp 1 */
616 out = pRecipTable[index];
617
618 /* calculation of reciprocal value */
619 /* running approximation for two iterations */
620 for (i = 0u; i < 2u; i++)
621 {
622 tempVal = (uint32_t) (((q63_t) in * out) >> 31);
623 tempVal = 0x7FFFFFFFu - tempVal;
624 /* 1.31 with exp 1 */
625 /* out = (q31_t) (((q63_t) out * tempVal) >> 30); */
626 out = clip_q63_to_q31(((q63_t) out * tempVal) >> 30);
627 }
628
629 /* write output */
630 *dst = out;
631
632 /* return num of signbits of out = 1/in value */
633 return (signBits + 1u);
634 }
635
636
637 /**
638 * @brief Function to Calculates 1/in (reciprocal) value of Q15 Data type.
639 */
640 CMSIS_INLINE __STATIC_INLINE uint32_t arm_recip_q15(
641 q15_t in,
642 q15_t * dst,
643 q15_t * pRecipTable)
644 {
645 q15_t out = 0;
646 uint32_t tempVal = 0;
647 uint32_t index = 0, i = 0;
648 uint32_t signBits = 0;
649
650 if (in > 0)
651 {
652 signBits = ((uint32_t)(__CLZ( in) - 17));
653 }
654 else
655 {
656 signBits = ((uint32_t)(__CLZ(-in) - 17));
657 }
658
659 /* Convert input sample to 1.15 format */
660 in = (in << signBits);
661
662 /* calculation of index for initial approximated Val */
663 index = (uint32_t)(in >> 8);
664 index = (index & INDEX_MASK);
665
666 /* 1.15 with exp 1 */
667 out = pRecipTable[index];
668
669 /* calculation of reciprocal value */
670 /* running approximation for two iterations */
671 for (i = 0u; i < 2u; i++)
672 {
673 tempVal = (uint32_t) (((q31_t) in * out) >> 15);
674 tempVal = 0x7FFFu - tempVal;
675 /* 1.15 with exp 1 */
676 out = (q15_t) (((q31_t) out * tempVal) >> 14);
677 /* out = clip_q31_to_q15(((q31_t) out * tempVal) >> 14); */
678 }
679
680 /* write output */
681 *dst = out;
682
683 /* return num of signbits of out = 1/in value */
684 return (signBits + 1);
685 }
686
687
688 /*
689 * @brief C custom defined intrinisic function for only M0 processors
690 */
691#if defined(ARM_MATH_CM0_FAMILY)
692 CMSIS_INLINE __STATIC_INLINE q31_t __SSAT(
693 q31_t x,
694 uint32_t y)
695 {
696 int32_t posMax, negMin;
697 uint32_t i;
698
699 posMax = 1;
700 for (i = 0; i < (y - 1); i++)
701 {
702 posMax = posMax * 2;
703 }
704
705 if (x > 0)
706 {
707 posMax = (posMax - 1);
708
709 if (x > posMax)
710 {
711 x = posMax;
712 }
713 }
714 else
715 {
716 negMin = -posMax;
717
718 if (x < negMin)
719 {
720 x = negMin;
721 }
722 }
723 return (x);
724 }
725#endif /* end of ARM_MATH_CM0_FAMILY */
726
727
728 /*
729 * @brief C custom defined intrinsic function for M3 and M0 processors
730 */
731/* #if defined (ARM_MATH_CM3) || defined (ARM_MATH_CM0_FAMILY) */
732#if !defined (ARM_MATH_DSP)
733
734 /*
735 * @brief C custom defined QADD8 for M3 and M0 processors
736 */
737 CMSIS_INLINE __STATIC_INLINE uint32_t __QADD8(
738 uint32_t x,
739 uint32_t y)
740 {
741 q31_t r, s, t, u;
742
743 r = __SSAT(((((q31_t)x << 24) >> 24) + (((q31_t)y << 24) >> 24)), 8) & (int32_t)0x000000FF;
744 s = __SSAT(((((q31_t)x << 16) >> 24) + (((q31_t)y << 16) >> 24)), 8) & (int32_t)0x000000FF;
745 t = __SSAT(((((q31_t)x << 8) >> 24) + (((q31_t)y << 8) >> 24)), 8) & (int32_t)0x000000FF;
746 u = __SSAT(((((q31_t)x ) >> 24) + (((q31_t)y ) >> 24)), 8) & (int32_t)0x000000FF;
747
748 return ((uint32_t)((u << 24) | (t << 16) | (s << 8) | (r )));
749 }
750
751
752 /*
753 * @brief C custom defined QSUB8 for M3 and M0 processors
754 */
755 CMSIS_INLINE __STATIC_INLINE uint32_t __QSUB8(
756 uint32_t x,
757 uint32_t y)
758 {
759 q31_t r, s, t, u;
760
761 r = __SSAT(((((q31_t)x << 24) >> 24) - (((q31_t)y << 24) >> 24)), 8) & (int32_t)0x000000FF;
762 s = __SSAT(((((q31_t)x << 16) >> 24) - (((q31_t)y << 16) >> 24)), 8) & (int32_t)0x000000FF;
763 t = __SSAT(((((q31_t)x << 8) >> 24) - (((q31_t)y << 8) >> 24)), 8) & (int32_t)0x000000FF;
764 u = __SSAT(((((q31_t)x ) >> 24) - (((q31_t)y ) >> 24)), 8) & (int32_t)0x000000FF;
765
766 return ((uint32_t)((u << 24) | (t << 16) | (s << 8) | (r )));
767 }
768
769
770 /*
771 * @brief C custom defined QADD16 for M3 and M0 processors
772 */
773 CMSIS_INLINE __STATIC_INLINE uint32_t __QADD16(
774 uint32_t x,
775 uint32_t y)
776 {
777/* q31_t r, s; without initialisation 'arm_offset_q15 test' fails but 'intrinsic' tests pass! for armCC */
778 q31_t r = 0, s = 0;
779
780 r = __SSAT(((((q31_t)x << 16) >> 16) + (((q31_t)y << 16) >> 16)), 16) & (int32_t)0x0000FFFF;
781 s = __SSAT(((((q31_t)x ) >> 16) + (((q31_t)y ) >> 16)), 16) & (int32_t)0x0000FFFF;
782
783 return ((uint32_t)((s << 16) | (r )));
784 }
785
786
787 /*
788 * @brief C custom defined SHADD16 for M3 and M0 processors
789 */
790 CMSIS_INLINE __STATIC_INLINE uint32_t __SHADD16(
791 uint32_t x,
792 uint32_t y)
793 {
794 q31_t r, s;
795
796 r = (((((q31_t)x << 16) >> 16) + (((q31_t)y << 16) >> 16)) >> 1) & (int32_t)0x0000FFFF;
797 s = (((((q31_t)x ) >> 16) + (((q31_t)y ) >> 16)) >> 1) & (int32_t)0x0000FFFF;
798
799 return ((uint32_t)((s << 16) | (r )));
800 }
801
802
803 /*
804 * @brief C custom defined QSUB16 for M3 and M0 processors
805 */
806 CMSIS_INLINE __STATIC_INLINE uint32_t __QSUB16(
807 uint32_t x,
808 uint32_t y)
809 {
810 q31_t r, s;
811
812 r = __SSAT(((((q31_t)x << 16) >> 16) - (((q31_t)y << 16) >> 16)), 16) & (int32_t)0x0000FFFF;
813 s = __SSAT(((((q31_t)x ) >> 16) - (((q31_t)y ) >> 16)), 16) & (int32_t)0x0000FFFF;
814
815 return ((uint32_t)((s << 16) | (r )));
816 }
817
818
819 /*
820 * @brief C custom defined SHSUB16 for M3 and M0 processors
821 */
822 CMSIS_INLINE __STATIC_INLINE uint32_t __SHSUB16(
823 uint32_t x,
824 uint32_t y)
825 {
826 q31_t r, s;
827
828 r = (((((q31_t)x << 16) >> 16) - (((q31_t)y << 16) >> 16)) >> 1) & (int32_t)0x0000FFFF;
829 s = (((((q31_t)x ) >> 16) - (((q31_t)y ) >> 16)) >> 1) & (int32_t)0x0000FFFF;
830
831 return ((uint32_t)((s << 16) | (r )));
832 }
833
834
835 /*
836 * @brief C custom defined QASX for M3 and M0 processors
837 */
838 CMSIS_INLINE __STATIC_INLINE uint32_t __QASX(
839 uint32_t x,
840 uint32_t y)
841 {
842 q31_t r, s;
843
844 r = __SSAT(((((q31_t)x << 16) >> 16) - (((q31_t)y ) >> 16)), 16) & (int32_t)0x0000FFFF;
845 s = __SSAT(((((q31_t)x ) >> 16) + (((q31_t)y << 16) >> 16)), 16) & (int32_t)0x0000FFFF;
846
847 return ((uint32_t)((s << 16) | (r )));
848 }
849
850
851 /*
852 * @brief C custom defined SHASX for M3 and M0 processors
853 */
854 CMSIS_INLINE __STATIC_INLINE uint32_t __SHASX(
855 uint32_t x,
856 uint32_t y)
857 {
858 q31_t r, s;
859
860 r = (((((q31_t)x << 16) >> 16) - (((q31_t)y ) >> 16)) >> 1) & (int32_t)0x0000FFFF;
861 s = (((((q31_t)x ) >> 16) + (((q31_t)y << 16) >> 16)) >> 1) & (int32_t)0x0000FFFF;
862
863 return ((uint32_t)((s << 16) | (r )));
864 }
865
866
867 /*
868 * @brief C custom defined QSAX for M3 and M0 processors
869 */
870 CMSIS_INLINE __STATIC_INLINE uint32_t __QSAX(
871 uint32_t x,
872 uint32_t y)
873 {
874 q31_t r, s;
875
876 r = __SSAT(((((q31_t)x << 16) >> 16) + (((q31_t)y ) >> 16)), 16) & (int32_t)0x0000FFFF;
877 s = __SSAT(((((q31_t)x ) >> 16) - (((q31_t)y << 16) >> 16)), 16) & (int32_t)0x0000FFFF;
878
879 return ((uint32_t)((s << 16) | (r )));
880 }
881
882
883 /*
884 * @brief C custom defined SHSAX for M3 and M0 processors
885 */
886 CMSIS_INLINE __STATIC_INLINE uint32_t __SHSAX(
887 uint32_t x,
888 uint32_t y)
889 {
890 q31_t r, s;
891
892 r = (((((q31_t)x << 16) >> 16) + (((q31_t)y ) >> 16)) >> 1) & (int32_t)0x0000FFFF;
893 s = (((((q31_t)x ) >> 16) - (((q31_t)y << 16) >> 16)) >> 1) & (int32_t)0x0000FFFF;
894
895 return ((uint32_t)((s << 16) | (r )));
896 }
897
898
899 /*
900 * @brief C custom defined SMUSDX for M3 and M0 processors
901 */
902 CMSIS_INLINE __STATIC_INLINE uint32_t __SMUSDX(
903 uint32_t x,
904 uint32_t y)
905 {
906 return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y ) >> 16)) -
907 ((((q31_t)x ) >> 16) * (((q31_t)y << 16) >> 16)) ));
908 }
909
910 /*
911 * @brief C custom defined SMUADX for M3 and M0 processors
912 */
913 CMSIS_INLINE __STATIC_INLINE uint32_t __SMUADX(
914 uint32_t x,
915 uint32_t y)
916 {
917 return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y ) >> 16)) +
918 ((((q31_t)x ) >> 16) * (((q31_t)y << 16) >> 16)) ));
919 }
920
921
922 /*
923 * @brief C custom defined QADD for M3 and M0 processors
924 */
925 CMSIS_INLINE __STATIC_INLINE int32_t __QADD(
926 int32_t x,
927 int32_t y)
928 {
929 return ((int32_t)(clip_q63_to_q31((q63_t)x + (q31_t)y)));
930 }
931
932
933 /*
934 * @brief C custom defined QSUB for M3 and M0 processors
935 */
936 CMSIS_INLINE __STATIC_INLINE int32_t __QSUB(
937 int32_t x,
938 int32_t y)
939 {
940 return ((int32_t)(clip_q63_to_q31((q63_t)x - (q31_t)y)));
941 }
942
943
944 /*
945 * @brief C custom defined SMLAD for M3 and M0 processors
946 */
947 CMSIS_INLINE __STATIC_INLINE uint32_t __SMLAD(
948 uint32_t x,
949 uint32_t y,
950 uint32_t sum)
951 {
952 return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y << 16) >> 16)) +
953 ((((q31_t)x ) >> 16) * (((q31_t)y ) >> 16)) +
954 ( ((q31_t)sum ) ) ));
955 }
956
957
958 /*
959 * @brief C custom defined SMLADX for M3 and M0 processors
960 */
961 CMSIS_INLINE __STATIC_INLINE uint32_t __SMLADX(
962 uint32_t x,
963 uint32_t y,
964 uint32_t sum)
965 {
966 return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y ) >> 16)) +
967 ((((q31_t)x ) >> 16) * (((q31_t)y << 16) >> 16)) +
968 ( ((q31_t)sum ) ) ));
969 }
970
971
972 /*
973 * @brief C custom defined SMLSDX for M3 and M0 processors
974 */
975 CMSIS_INLINE __STATIC_INLINE uint32_t __SMLSDX(
976 uint32_t x,
977 uint32_t y,
978 uint32_t sum)
979 {
980 return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y ) >> 16)) -
981 ((((q31_t)x ) >> 16) * (((q31_t)y << 16) >> 16)) +
982 ( ((q31_t)sum ) ) ));
983 }
984
985
986 /*
987 * @brief C custom defined SMLALD for M3 and M0 processors
988 */
989 CMSIS_INLINE __STATIC_INLINE uint64_t __SMLALD(
990 uint32_t x,
991 uint32_t y,
992 uint64_t sum)
993 {
994/* return (sum + ((q15_t) (x >> 16) * (q15_t) (y >> 16)) + ((q15_t) x * (q15_t) y)); */
995 return ((uint64_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y << 16) >> 16)) +
996 ((((q31_t)x ) >> 16) * (((q31_t)y ) >> 16)) +
997 ( ((q63_t)sum ) ) ));
998 }
999
1000
1001 /*
1002 * @brief C custom defined SMLALDX for M3 and M0 processors
1003 */
1004 CMSIS_INLINE __STATIC_INLINE uint64_t __SMLALDX(
1005 uint32_t x,
1006 uint32_t y,
1007 uint64_t sum)
1008 {
1009/* return (sum + ((q15_t) (x >> 16) * (q15_t) y)) + ((q15_t) x * (q15_t) (y >> 16)); */
1010 return ((uint64_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y ) >> 16)) +
1011 ((((q31_t)x ) >> 16) * (((q31_t)y << 16) >> 16)) +
1012 ( ((q63_t)sum ) ) ));
1013 }
1014
1015
1016 /*
1017 * @brief C custom defined SMUAD for M3 and M0 processors
1018 */
1019 CMSIS_INLINE __STATIC_INLINE uint32_t __SMUAD(
1020 uint32_t x,
1021 uint32_t y)
1022 {
1023 return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y << 16) >> 16)) +
1024 ((((q31_t)x ) >> 16) * (((q31_t)y ) >> 16)) ));
1025 }
1026
1027
1028 /*
1029 * @brief C custom defined SMUSD for M3 and M0 processors
1030 */
1031 CMSIS_INLINE __STATIC_INLINE uint32_t __SMUSD(
1032 uint32_t x,
1033 uint32_t y)
1034 {
1035 return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y << 16) >> 16)) -
1036 ((((q31_t)x ) >> 16) * (((q31_t)y ) >> 16)) ));
1037 }
1038
1039
1040 /*
1041 * @brief C custom defined SXTB16 for M3 and M0 processors
1042 */
1043 CMSIS_INLINE __STATIC_INLINE uint32_t __SXTB16(
1044 uint32_t x)
1045 {
1046 return ((uint32_t)(((((q31_t)x << 24) >> 24) & (q31_t)0x0000FFFF) |
1047 ((((q31_t)x << 8) >> 8) & (q31_t)0xFFFF0000) ));
1048 }
1049
1050 /*
1051 * @brief C custom defined SMMLA for M3 and M0 processors
1052 */
1053 CMSIS_INLINE __STATIC_INLINE int32_t __SMMLA(
1054 int32_t x,
1055 int32_t y,
1056 int32_t sum)
1057 {
1058 return (sum + (int32_t) (((int64_t) x * y) >> 32));
1059 }
1060
1061#if 0
1062 /*
1063 * @brief C custom defined PKHBT for unavailable DSP extension
1064 */
1065 CMSIS_INLINE __STATIC_INLINE uint32_t __PKHBT(
1066 uint32_t x,
1067 uint32_t y,
1068 uint32_t leftshift)
1069 {
1070 return ( ((x ) & 0x0000FFFFUL) |
1071 ((y << leftshift) & 0xFFFF0000UL) );
1072 }
1073
1074 /*
1075 * @brief C custom defined PKHTB for unavailable DSP extension
1076 */
1077 CMSIS_INLINE __STATIC_INLINE uint32_t __PKHTB(
1078 uint32_t x,
1079 uint32_t y,
1080 uint32_t rightshift)
1081 {
1082 return ( ((x ) & 0xFFFF0000UL) |
1083 ((y >> rightshift) & 0x0000FFFFUL) );
1084 }
1085#endif
1086
1087/* #endif // defined (ARM_MATH_CM3) || defined (ARM_MATH_CM0_FAMILY) */
1088#endif /* !defined (ARM_MATH_DSP) */
1089
1090
1091 /**
1092 * @brief Instance structure for the Q7 FIR filter.
1093 */
1094 typedef struct
1095 {
1096 uint16_t numTaps; /**< number of filter coefficients in the filter. */
1097 q7_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
1098 q7_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
1099 } arm_fir_instance_q7;
1100
1101 /**
1102 * @brief Instance structure for the Q15 FIR filter.
1103 */
1104 typedef struct
1105 {
1106 uint16_t numTaps; /**< number of filter coefficients in the filter. */
1107 q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
1108 q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
1109 } arm_fir_instance_q15;
1110
1111 /**
1112 * @brief Instance structure for the Q31 FIR filter.
1113 */
1114 typedef struct
1115 {
1116 uint16_t numTaps; /**< number of filter coefficients in the filter. */
1117 q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
1118 q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
1119 } arm_fir_instance_q31;
1120
1121 /**
1122 * @brief Instance structure for the floating-point FIR filter.
1123 */
1124 typedef struct
1125 {
1126 uint16_t numTaps; /**< number of filter coefficients in the filter. */
1127 float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
1128 float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
1129 } arm_fir_instance_f32;
1130
1131
1132 /**
1133 * @brief Processing function for the Q7 FIR filter.
1134 * @param[in] S points to an instance of the Q7 FIR filter structure.
1135 * @param[in] pSrc points to the block of input data.
1136 * @param[out] pDst points to the block of output data.
1137 * @param[in] blockSize number of samples to process.
1138 */
1139 void arm_fir_q7(
1140 const arm_fir_instance_q7 * S,
1141 q7_t * pSrc,
1142 q7_t * pDst,
1143 uint32_t blockSize);
1144
1145
1146 /**
1147 * @brief Initialization function for the Q7 FIR filter.
1148 * @param[in,out] S points to an instance of the Q7 FIR structure.
1149 * @param[in] numTaps Number of filter coefficients in the filter.
1150 * @param[in] pCoeffs points to the filter coefficients.
1151 * @param[in] pState points to the state buffer.
1152 * @param[in] blockSize number of samples that are processed.
1153 */
1154 void arm_fir_init_q7(
1155 arm_fir_instance_q7 * S,
1156 uint16_t numTaps,
1157 q7_t * pCoeffs,
1158 q7_t * pState,
1159 uint32_t blockSize);
1160
1161
1162 /**
1163 * @brief Processing function for the Q15 FIR filter.
1164 * @param[in] S points to an instance of the Q15 FIR structure.
1165 * @param[in] pSrc points to the block of input data.
1166 * @param[out] pDst points to the block of output data.
1167 * @param[in] blockSize number of samples to process.
1168 */
1169 void arm_fir_q15(
1170 const arm_fir_instance_q15 * S,
1171 q15_t * pSrc,
1172 q15_t * pDst,
1173 uint32_t blockSize);
1174
1175
1176 /**
1177 * @brief Processing function for the fast Q15 FIR filter for Cortex-M3 and Cortex-M4.
1178 * @param[in] S points to an instance of the Q15 FIR filter structure.
1179 * @param[in] pSrc points to the block of input data.
1180 * @param[out] pDst points to the block of output data.
1181 * @param[in] blockSize number of samples to process.
1182 */
1183 void arm_fir_fast_q15(
1184 const arm_fir_instance_q15 * S,
1185 q15_t * pSrc,
1186 q15_t * pDst,
1187 uint32_t blockSize);
1188
1189
1190 /**
1191 * @brief Initialization function for the Q15 FIR filter.
1192 * @param[in,out] S points to an instance of the Q15 FIR filter structure.
1193 * @param[in] numTaps Number of filter coefficients in the filter. Must be even and greater than or equal to 4.
1194 * @param[in] pCoeffs points to the filter coefficients.
1195 * @param[in] pState points to the state buffer.
1196 * @param[in] blockSize number of samples that are processed at a time.
1197 * @return The function returns ARM_MATH_SUCCESS if initialization was successful or ARM_MATH_ARGUMENT_ERROR if
1198 * <code>numTaps</code> is not a supported value.
1199 */
1200 arm_status arm_fir_init_q15(
1201 arm_fir_instance_q15 * S,
1202 uint16_t numTaps,
1203 q15_t * pCoeffs,
1204 q15_t * pState,
1205 uint32_t blockSize);
1206
1207
1208 /**
1209 * @brief Processing function for the Q31 FIR filter.
1210 * @param[in] S points to an instance of the Q31 FIR filter structure.
1211 * @param[in] pSrc points to the block of input data.
1212 * @param[out] pDst points to the block of output data.
1213 * @param[in] blockSize number of samples to process.
1214 */
1215 void arm_fir_q31(
1216 const arm_fir_instance_q31 * S,
1217 q31_t * pSrc,
1218 q31_t * pDst,
1219 uint32_t blockSize);
1220
1221
1222 /**
1223 * @brief Processing function for the fast Q31 FIR filter for Cortex-M3 and Cortex-M4.
1224 * @param[in] S points to an instance of the Q31 FIR structure.
1225 * @param[in] pSrc points to the block of input data.
1226 * @param[out] pDst points to the block of output data.
1227 * @param[in] blockSize number of samples to process.
1228 */
1229 void arm_fir_fast_q31(
1230 const arm_fir_instance_q31 * S,
1231 q31_t * pSrc,
1232 q31_t * pDst,
1233 uint32_t blockSize);
1234
1235
1236 /**
1237 * @brief Initialization function for the Q31 FIR filter.
1238 * @param[in,out] S points to an instance of the Q31 FIR structure.
1239 * @param[in] numTaps Number of filter coefficients in the filter.
1240 * @param[in] pCoeffs points to the filter coefficients.
1241 * @param[in] pState points to the state buffer.
1242 * @param[in] blockSize number of samples that are processed at a time.
1243 */
1244 void arm_fir_init_q31(
1245 arm_fir_instance_q31 * S,
1246 uint16_t numTaps,
1247 q31_t * pCoeffs,
1248 q31_t * pState,
1249 uint32_t blockSize);
1250
1251
1252 /**
1253 * @brief Processing function for the floating-point FIR filter.
1254 * @param[in] S points to an instance of the floating-point FIR structure.
1255 * @param[in] pSrc points to the block of input data.
1256 * @param[out] pDst points to the block of output data.
1257 * @param[in] blockSize number of samples to process.
1258 */
1259 void arm_fir_f32(
1260 const arm_fir_instance_f32 * S,
1261 float32_t * pSrc,
1262 float32_t * pDst,
1263 uint32_t blockSize);
1264
1265
1266 /**
1267 * @brief Initialization function for the floating-point FIR filter.
1268 * @param[in,out] S points to an instance of the floating-point FIR filter structure.
1269 * @param[in] numTaps Number of filter coefficients in the filter.
1270 * @param[in] pCoeffs points to the filter coefficients.
1271 * @param[in] pState points to the state buffer.
1272 * @param[in] blockSize number of samples that are processed at a time.
1273 */
1274 void arm_fir_init_f32(
1275 arm_fir_instance_f32 * S,
1276 uint16_t numTaps,
1277 float32_t * pCoeffs,
1278 float32_t * pState,
1279 uint32_t blockSize);
1280
1281
1282 /**
1283 * @brief Instance structure for the Q15 Biquad cascade filter.
1284 */
1285 typedef struct
1286 {
1287 int8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
1288 q15_t *pState; /**< Points to the array of state coefficients. The array is of length 4*numStages. */
1289 q15_t *pCoeffs; /**< Points to the array of coefficients. The array is of length 5*numStages. */
1290 int8_t postShift; /**< Additional shift, in bits, applied to each output sample. */
1291 } arm_biquad_casd_df1_inst_q15;
1292
1293 /**
1294 * @brief Instance structure for the Q31 Biquad cascade filter.
1295 */
1296 typedef struct
1297 {
1298 uint32_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
1299 q31_t *pState; /**< Points to the array of state coefficients. The array is of length 4*numStages. */
1300 q31_t *pCoeffs; /**< Points to the array of coefficients. The array is of length 5*numStages. */
1301 uint8_t postShift; /**< Additional shift, in bits, applied to each output sample. */
1302 } arm_biquad_casd_df1_inst_q31;
1303
1304 /**
1305 * @brief Instance structure for the floating-point Biquad cascade filter.
1306 */
1307 typedef struct
1308 {
1309 uint32_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
1310 float32_t *pState; /**< Points to the array of state coefficients. The array is of length 4*numStages. */
1311 float32_t *pCoeffs; /**< Points to the array of coefficients. The array is of length 5*numStages. */
1312 } arm_biquad_casd_df1_inst_f32;
1313
1314
1315 /**
1316 * @brief Processing function for the Q15 Biquad cascade filter.
1317 * @param[in] S points to an instance of the Q15 Biquad cascade structure.
1318 * @param[in] pSrc points to the block of input data.
1319 * @param[out] pDst points to the block of output data.
1320 * @param[in] blockSize number of samples to process.
1321 */
1322 void arm_biquad_cascade_df1_q15(
1323 const arm_biquad_casd_df1_inst_q15 * S,
1324 q15_t * pSrc,
1325 q15_t * pDst,
1326 uint32_t blockSize);
1327
1328
1329 /**
1330 * @brief Initialization function for the Q15 Biquad cascade filter.
1331 * @param[in,out] S points to an instance of the Q15 Biquad cascade structure.
1332 * @param[in] numStages number of 2nd order stages in the filter.
1333 * @param[in] pCoeffs points to the filter coefficients.
1334 * @param[in] pState points to the state buffer.
1335 * @param[in] postShift Shift to be applied to the output. Varies according to the coefficients format
1336 */
1337 void arm_biquad_cascade_df1_init_q15(
1338 arm_biquad_casd_df1_inst_q15 * S,
1339 uint8_t numStages,
1340 q15_t * pCoeffs,
1341 q15_t * pState,
1342 int8_t postShift);
1343
1344
1345 /**
1346 * @brief Fast but less precise processing function for the Q15 Biquad cascade filter for Cortex-M3 and Cortex-M4.
1347 * @param[in] S points to an instance of the Q15 Biquad cascade structure.
1348 * @param[in] pSrc points to the block of input data.
1349 * @param[out] pDst points to the block of output data.
1350 * @param[in] blockSize number of samples to process.
1351 */
1352 void arm_biquad_cascade_df1_fast_q15(
1353 const arm_biquad_casd_df1_inst_q15 * S,
1354 q15_t * pSrc,
1355 q15_t * pDst,
1356 uint32_t blockSize);
1357
1358
1359 /**
1360 * @brief Processing function for the Q31 Biquad cascade filter
1361 * @param[in] S points to an instance of the Q31 Biquad cascade structure.
1362 * @param[in] pSrc points to the block of input data.
1363 * @param[out] pDst points to the block of output data.
1364 * @param[in] blockSize number of samples to process.
1365 */
1366 void arm_biquad_cascade_df1_q31(
1367 const arm_biquad_casd_df1_inst_q31 * S,
1368 q31_t * pSrc,
1369 q31_t * pDst,
1370 uint32_t blockSize);
1371
1372
1373 /**
1374 * @brief Fast but less precise processing function for the Q31 Biquad cascade filter for Cortex-M3 and Cortex-M4.
1375 * @param[in] S points to an instance of the Q31 Biquad cascade structure.
1376 * @param[in] pSrc points to the block of input data.
1377 * @param[out] pDst points to the block of output data.
1378 * @param[in] blockSize number of samples to process.
1379 */
1380 void arm_biquad_cascade_df1_fast_q31(
1381 const arm_biquad_casd_df1_inst_q31 * S,
1382 q31_t * pSrc,
1383 q31_t * pDst,
1384 uint32_t blockSize);
1385
1386
1387 /**
1388 * @brief Initialization function for the Q31 Biquad cascade filter.
1389 * @param[in,out] S points to an instance of the Q31 Biquad cascade structure.
1390 * @param[in] numStages number of 2nd order stages in the filter.
1391 * @param[in] pCoeffs points to the filter coefficients.
1392 * @param[in] pState points to the state buffer.
1393 * @param[in] postShift Shift to be applied to the output. Varies according to the coefficients format
1394 */
1395 void arm_biquad_cascade_df1_init_q31(
1396 arm_biquad_casd_df1_inst_q31 * S,
1397 uint8_t numStages,
1398 q31_t * pCoeffs,
1399 q31_t * pState,
1400 int8_t postShift);
1401
1402
1403 /**
1404 * @brief Processing function for the floating-point Biquad cascade filter.
1405 * @param[in] S points to an instance of the floating-point Biquad cascade structure.
1406 * @param[in] pSrc points to the block of input data.
1407 * @param[out] pDst points to the block of output data.
1408 * @param[in] blockSize number of samples to process.
1409 */
1410 void arm_biquad_cascade_df1_f32(
1411 const arm_biquad_casd_df1_inst_f32 * S,
1412 float32_t * pSrc,
1413 float32_t * pDst,
1414 uint32_t blockSize);
1415
1416
1417 /**
1418 * @brief Initialization function for the floating-point Biquad cascade filter.
1419 * @param[in,out] S points to an instance of the floating-point Biquad cascade structure.
1420 * @param[in] numStages number of 2nd order stages in the filter.
1421 * @param[in] pCoeffs points to the filter coefficients.
1422 * @param[in] pState points to the state buffer.
1423 */
1424 void arm_biquad_cascade_df1_init_f32(
1425 arm_biquad_casd_df1_inst_f32 * S,
1426 uint8_t numStages,
1427 float32_t * pCoeffs,
1428 float32_t * pState);
1429
1430
1431 /**
1432 * @brief Instance structure for the floating-point matrix structure.
1433 */
1434 typedef struct
1435 {
1436 uint16_t numRows; /**< number of rows of the matrix. */
1437 uint16_t numCols; /**< number of columns of the matrix. */
1438 float32_t *pData; /**< points to the data of the matrix. */
1439 } arm_matrix_instance_f32;
1440
1441
1442 /**
1443 * @brief Instance structure for the floating-point matrix structure.
1444 */
1445 typedef struct
1446 {
1447 uint16_t numRows; /**< number of rows of the matrix. */
1448 uint16_t numCols; /**< number of columns of the matrix. */
1449 float64_t *pData; /**< points to the data of the matrix. */
1450 } arm_matrix_instance_f64;
1451
1452 /**
1453 * @brief Instance structure for the Q15 matrix structure.
1454 */
1455 typedef struct
1456 {
1457 uint16_t numRows; /**< number of rows of the matrix. */
1458 uint16_t numCols; /**< number of columns of the matrix. */
1459 q15_t *pData; /**< points to the data of the matrix. */
1460 } arm_matrix_instance_q15;
1461
1462 /**
1463 * @brief Instance structure for the Q31 matrix structure.
1464 */
1465 typedef struct
1466 {
1467 uint16_t numRows; /**< number of rows of the matrix. */
1468 uint16_t numCols; /**< number of columns of the matrix. */
1469 q31_t *pData; /**< points to the data of the matrix. */
1470 } arm_matrix_instance_q31;
1471
1472
1473 /**
1474 * @brief Floating-point matrix addition.
1475 * @param[in] pSrcA points to the first input matrix structure
1476 * @param[in] pSrcB points to the second input matrix structure
1477 * @param[out] pDst points to output matrix structure
1478 * @return The function returns either
1479 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1480 */
1481 arm_status arm_mat_add_f32(
1482 const arm_matrix_instance_f32 * pSrcA,
1483 const arm_matrix_instance_f32 * pSrcB,
1484 arm_matrix_instance_f32 * pDst);
1485
1486
1487 /**
1488 * @brief Q15 matrix addition.
1489 * @param[in] pSrcA points to the first input matrix structure
1490 * @param[in] pSrcB points to the second input matrix structure
1491 * @param[out] pDst points to output matrix structure
1492 * @return The function returns either
1493 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1494 */
1495 arm_status arm_mat_add_q15(
1496 const arm_matrix_instance_q15 * pSrcA,
1497 const arm_matrix_instance_q15 * pSrcB,
1498 arm_matrix_instance_q15 * pDst);
1499
1500
1501 /**
1502 * @brief Q31 matrix addition.
1503 * @param[in] pSrcA points to the first input matrix structure
1504 * @param[in] pSrcB points to the second input matrix structure
1505 * @param[out] pDst points to output matrix structure
1506 * @return The function returns either
1507 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1508 */
1509 arm_status arm_mat_add_q31(
1510 const arm_matrix_instance_q31 * pSrcA,
1511 const arm_matrix_instance_q31 * pSrcB,
1512 arm_matrix_instance_q31 * pDst);
1513
1514
1515 /**
1516 * @brief Floating-point, complex, matrix multiplication.
1517 * @param[in] pSrcA points to the first input matrix structure
1518 * @param[in] pSrcB points to the second input matrix structure
1519 * @param[out] pDst points to output matrix structure
1520 * @return The function returns either
1521 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1522 */
1523 arm_status arm_mat_cmplx_mult_f32(
1524 const arm_matrix_instance_f32 * pSrcA,
1525 const arm_matrix_instance_f32 * pSrcB,
1526 arm_matrix_instance_f32 * pDst);
1527
1528
1529 /**
1530 * @brief Q15, complex, matrix multiplication.
1531 * @param[in] pSrcA points to the first input matrix structure
1532 * @param[in] pSrcB points to the second input matrix structure
1533 * @param[out] pDst points to output matrix structure
1534 * @return The function returns either
1535 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1536 */
1537 arm_status arm_mat_cmplx_mult_q15(
1538 const arm_matrix_instance_q15 * pSrcA,
1539 const arm_matrix_instance_q15 * pSrcB,
1540 arm_matrix_instance_q15 * pDst,
1541 q15_t * pScratch);
1542
1543
1544 /**
1545 * @brief Q31, complex, matrix multiplication.
1546 * @param[in] pSrcA points to the first input matrix structure
1547 * @param[in] pSrcB points to the second input matrix structure
1548 * @param[out] pDst points to output matrix structure
1549 * @return The function returns either
1550 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1551 */
1552 arm_status arm_mat_cmplx_mult_q31(
1553 const arm_matrix_instance_q31 * pSrcA,
1554 const arm_matrix_instance_q31 * pSrcB,
1555 arm_matrix_instance_q31 * pDst);
1556
1557
1558 /**
1559 * @brief Floating-point matrix transpose.
1560 * @param[in] pSrc points to the input matrix
1561 * @param[out] pDst points to the output matrix
1562 * @return The function returns either <code>ARM_MATH_SIZE_MISMATCH</code>
1563 * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1564 */
1565 arm_status arm_mat_trans_f32(
1566 const arm_matrix_instance_f32 * pSrc,
1567 arm_matrix_instance_f32 * pDst);
1568
1569
1570 /**
1571 * @brief Q15 matrix transpose.
1572 * @param[in] pSrc points to the input matrix
1573 * @param[out] pDst points to the output matrix
1574 * @return The function returns either <code>ARM_MATH_SIZE_MISMATCH</code>
1575 * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1576 */
1577 arm_status arm_mat_trans_q15(
1578 const arm_matrix_instance_q15 * pSrc,
1579 arm_matrix_instance_q15 * pDst);
1580
1581
1582 /**
1583 * @brief Q31 matrix transpose.
1584 * @param[in] pSrc points to the input matrix
1585 * @param[out] pDst points to the output matrix
1586 * @return The function returns either <code>ARM_MATH_SIZE_MISMATCH</code>
1587 * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1588 */
1589 arm_status arm_mat_trans_q31(
1590 const arm_matrix_instance_q31 * pSrc,
1591 arm_matrix_instance_q31 * pDst);
1592
1593
1594 /**
1595 * @brief Floating-point matrix multiplication
1596 * @param[in] pSrcA points to the first input matrix structure
1597 * @param[in] pSrcB points to the second input matrix structure
1598 * @param[out] pDst points to output matrix structure
1599 * @return The function returns either
1600 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1601 */
1602 arm_status arm_mat_mult_f32(
1603 const arm_matrix_instance_f32 * pSrcA,
1604 const arm_matrix_instance_f32 * pSrcB,
1605 arm_matrix_instance_f32 * pDst);
1606
1607
1608 /**
1609 * @brief Q15 matrix multiplication
1610 * @param[in] pSrcA points to the first input matrix structure
1611 * @param[in] pSrcB points to the second input matrix structure
1612 * @param[out] pDst points to output matrix structure
1613 * @param[in] pState points to the array for storing intermediate results
1614 * @return The function returns either
1615 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1616 */
1617 arm_status arm_mat_mult_q15(
1618 const arm_matrix_instance_q15 * pSrcA,
1619 const arm_matrix_instance_q15 * pSrcB,
1620 arm_matrix_instance_q15 * pDst,
1621 q15_t * pState);
1622
1623
1624 /**
1625 * @brief Q15 matrix multiplication (fast variant) for Cortex-M3 and Cortex-M4
1626 * @param[in] pSrcA points to the first input matrix structure
1627 * @param[in] pSrcB points to the second input matrix structure
1628 * @param[out] pDst points to output matrix structure
1629 * @param[in] pState points to the array for storing intermediate results
1630 * @return The function returns either
1631 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1632 */
1633 arm_status arm_mat_mult_fast_q15(
1634 const arm_matrix_instance_q15 * pSrcA,
1635 const arm_matrix_instance_q15 * pSrcB,
1636 arm_matrix_instance_q15 * pDst,
1637 q15_t * pState);
1638
1639
1640 /**
1641 * @brief Q31 matrix multiplication
1642 * @param[in] pSrcA points to the first input matrix structure
1643 * @param[in] pSrcB points to the second input matrix structure
1644 * @param[out] pDst points to output matrix structure
1645 * @return The function returns either
1646 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1647 */
1648 arm_status arm_mat_mult_q31(
1649 const arm_matrix_instance_q31 * pSrcA,
1650 const arm_matrix_instance_q31 * pSrcB,
1651 arm_matrix_instance_q31 * pDst);
1652
1653
1654 /**
1655 * @brief Q31 matrix multiplication (fast variant) for Cortex-M3 and Cortex-M4
1656 * @param[in] pSrcA points to the first input matrix structure
1657 * @param[in] pSrcB points to the second input matrix structure
1658 * @param[out] pDst points to output matrix structure
1659 * @return The function returns either
1660 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1661 */
1662 arm_status arm_mat_mult_fast_q31(
1663 const arm_matrix_instance_q31 * pSrcA,
1664 const arm_matrix_instance_q31 * pSrcB,
1665 arm_matrix_instance_q31 * pDst);
1666
1667
1668 /**
1669 * @brief Floating-point matrix subtraction
1670 * @param[in] pSrcA points to the first input matrix structure
1671 * @param[in] pSrcB points to the second input matrix structure
1672 * @param[out] pDst points to output matrix structure
1673 * @return The function returns either
1674 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1675 */
1676 arm_status arm_mat_sub_f32(
1677 const arm_matrix_instance_f32 * pSrcA,
1678 const arm_matrix_instance_f32 * pSrcB,
1679 arm_matrix_instance_f32 * pDst);
1680
1681
1682 /**
1683 * @brief Q15 matrix subtraction
1684 * @param[in] pSrcA points to the first input matrix structure
1685 * @param[in] pSrcB points to the second input matrix structure
1686 * @param[out] pDst points to output matrix structure
1687 * @return The function returns either
1688 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1689 */
1690 arm_status arm_mat_sub_q15(
1691 const arm_matrix_instance_q15 * pSrcA,
1692 const arm_matrix_instance_q15 * pSrcB,
1693 arm_matrix_instance_q15 * pDst);
1694
1695
1696 /**
1697 * @brief Q31 matrix subtraction
1698 * @param[in] pSrcA points to the first input matrix structure
1699 * @param[in] pSrcB points to the second input matrix structure
1700 * @param[out] pDst points to output matrix structure
1701 * @return The function returns either
1702 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1703 */
1704 arm_status arm_mat_sub_q31(
1705 const arm_matrix_instance_q31 * pSrcA,
1706 const arm_matrix_instance_q31 * pSrcB,
1707 arm_matrix_instance_q31 * pDst);
1708
1709
1710 /**
1711 * @brief Floating-point matrix scaling.
1712 * @param[in] pSrc points to the input matrix
1713 * @param[in] scale scale factor
1714 * @param[out] pDst points to the output matrix
1715 * @return The function returns either
1716 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1717 */
1718 arm_status arm_mat_scale_f32(
1719 const arm_matrix_instance_f32 * pSrc,
1720 float32_t scale,
1721 arm_matrix_instance_f32 * pDst);
1722
1723
1724 /**
1725 * @brief Q15 matrix scaling.
1726 * @param[in] pSrc points to input matrix
1727 * @param[in] scaleFract fractional portion of the scale factor
1728 * @param[in] shift number of bits to shift the result by
1729 * @param[out] pDst points to output matrix
1730 * @return The function returns either
1731 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1732 */
1733 arm_status arm_mat_scale_q15(
1734 const arm_matrix_instance_q15 * pSrc,
1735 q15_t scaleFract,
1736 int32_t shift,
1737 arm_matrix_instance_q15 * pDst);
1738
1739
1740 /**
1741 * @brief Q31 matrix scaling.
1742 * @param[in] pSrc points to input matrix
1743 * @param[in] scaleFract fractional portion of the scale factor
1744 * @param[in] shift number of bits to shift the result by
1745 * @param[out] pDst points to output matrix structure
1746 * @return The function returns either
1747 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1748 */
1749 arm_status arm_mat_scale_q31(
1750 const arm_matrix_instance_q31 * pSrc,
1751 q31_t scaleFract,
1752 int32_t shift,
1753 arm_matrix_instance_q31 * pDst);
1754
1755
1756 /**
1757 * @brief Q31 matrix initialization.
1758 * @param[in,out] S points to an instance of the floating-point matrix structure.
1759 * @param[in] nRows number of rows in the matrix.
1760 * @param[in] nColumns number of columns in the matrix.
1761 * @param[in] pData points to the matrix data array.
1762 */
1763 void arm_mat_init_q31(
1764 arm_matrix_instance_q31 * S,
1765 uint16_t nRows,
1766 uint16_t nColumns,
1767 q31_t * pData);
1768
1769
1770 /**
1771 * @brief Q15 matrix initialization.
1772 * @param[in,out] S points to an instance of the floating-point matrix structure.
1773 * @param[in] nRows number of rows in the matrix.
1774 * @param[in] nColumns number of columns in the matrix.
1775 * @param[in] pData points to the matrix data array.
1776 */
1777 void arm_mat_init_q15(
1778 arm_matrix_instance_q15 * S,
1779 uint16_t nRows,
1780 uint16_t nColumns,
1781 q15_t * pData);
1782
1783
1784 /**
1785 * @brief Floating-point matrix initialization.
1786 * @param[in,out] S points to an instance of the floating-point matrix structure.
1787 * @param[in] nRows number of rows in the matrix.
1788 * @param[in] nColumns number of columns in the matrix.
1789 * @param[in] pData points to the matrix data array.
1790 */
1791 void arm_mat_init_f32(
1792 arm_matrix_instance_f32 * S,
1793 uint16_t nRows,
1794 uint16_t nColumns,
1795 float32_t * pData);
1796
1797
1798
1799 /**
1800 * @brief Instance structure for the Q15 PID Control.
1801 */
1802 typedef struct
1803 {
1804 q15_t A0; /**< The derived gain, A0 = Kp + Ki + Kd . */
1805#if !defined (ARM_MATH_DSP)
1806 q15_t A1;
1807 q15_t A2;
1808#else
1809 q31_t A1; /**< The derived gain A1 = -Kp - 2Kd | Kd.*/
1810#endif
1811 q15_t state[3]; /**< The state array of length 3. */
1812 q15_t Kp; /**< The proportional gain. */
1813 q15_t Ki; /**< The integral gain. */
1814 q15_t Kd; /**< The derivative gain. */
1815 } arm_pid_instance_q15;
1816
1817 /**
1818 * @brief Instance structure for the Q31 PID Control.
1819 */
1820 typedef struct
1821 {
1822 q31_t A0; /**< The derived gain, A0 = Kp + Ki + Kd . */
1823 q31_t A1; /**< The derived gain, A1 = -Kp - 2Kd. */
1824 q31_t A2; /**< The derived gain, A2 = Kd . */
1825 q31_t state[3]; /**< The state array of length 3. */
1826 q31_t Kp; /**< The proportional gain. */
1827 q31_t Ki; /**< The integral gain. */
1828 q31_t Kd; /**< The derivative gain. */
1829 } arm_pid_instance_q31;
1830
1831 /**
1832 * @brief Instance structure for the floating-point PID Control.
1833 */
1834 typedef struct
1835 {
1836 float32_t A0; /**< The derived gain, A0 = Kp + Ki + Kd . */
1837 float32_t A1; /**< The derived gain, A1 = -Kp - 2Kd. */
1838 float32_t A2; /**< The derived gain, A2 = Kd . */
1839 float32_t state[3]; /**< The state array of length 3. */
1840 float32_t Kp; /**< The proportional gain. */
1841 float32_t Ki; /**< The integral gain. */
1842 float32_t Kd; /**< The derivative gain. */
1843 } arm_pid_instance_f32;
1844
1845
1846
1847 /**
1848 * @brief Initialization function for the floating-point PID Control.
1849 * @param[in,out] S points to an instance of the PID structure.
1850 * @param[in] resetStateFlag flag to reset the state. 0 = no change in state 1 = reset the state.
1851 */
1852 void arm_pid_init_f32(
1853 arm_pid_instance_f32 * S,
1854 int32_t resetStateFlag);
1855
1856
1857 /**
1858 * @brief Reset function for the floating-point PID Control.
1859 * @param[in,out] S is an instance of the floating-point PID Control structure
1860 */
1861 void arm_pid_reset_f32(
1862 arm_pid_instance_f32 * S);
1863
1864
1865 /**
1866 * @brief Initialization function for the Q31 PID Control.
1867 * @param[in,out] S points to an instance of the Q15 PID structure.
1868 * @param[in] resetStateFlag flag to reset the state. 0 = no change in state 1 = reset the state.
1869 */
1870 void arm_pid_init_q31(
1871 arm_pid_instance_q31 * S,
1872 int32_t resetStateFlag);
1873
1874
1875 /**
1876 * @brief Reset function for the Q31 PID Control.
1877 * @param[in,out] S points to an instance of the Q31 PID Control structure
1878 */
1879
1880 void arm_pid_reset_q31(
1881 arm_pid_instance_q31 * S);
1882
1883
1884 /**
1885 * @brief Initialization function for the Q15 PID Control.
1886 * @param[in,out] S points to an instance of the Q15 PID structure.
1887 * @param[in] resetStateFlag flag to reset the state. 0 = no change in state 1 = reset the state.
1888 */
1889 void arm_pid_init_q15(
1890 arm_pid_instance_q15 * S,
1891 int32_t resetStateFlag);
1892
1893
1894 /**
1895 * @brief Reset function for the Q15 PID Control.
1896 * @param[in,out] S points to an instance of the q15 PID Control structure
1897 */
1898 void arm_pid_reset_q15(
1899 arm_pid_instance_q15 * S);
1900
1901
1902 /**
1903 * @brief Instance structure for the floating-point Linear Interpolate function.
1904 */
1905 typedef struct
1906 {
1907 uint32_t nValues; /**< nValues */
1908 float32_t x1; /**< x1 */
1909 float32_t xSpacing; /**< xSpacing */
1910 float32_t *pYData; /**< pointer to the table of Y values */
1911 } arm_linear_interp_instance_f32;
1912
1913 /**
1914 * @brief Instance structure for the floating-point bilinear interpolation function.
1915 */
1916 typedef struct
1917 {
1918 uint16_t numRows; /**< number of rows in the data table. */
1919 uint16_t numCols; /**< number of columns in the data table. */
1920 float32_t *pData; /**< points to the data table. */
1921 } arm_bilinear_interp_instance_f32;
1922
1923 /**
1924 * @brief Instance structure for the Q31 bilinear interpolation function.
1925 */
1926 typedef struct
1927 {
1928 uint16_t numRows; /**< number of rows in the data table. */
1929 uint16_t numCols; /**< number of columns in the data table. */
1930 q31_t *pData; /**< points to the data table. */
1931 } arm_bilinear_interp_instance_q31;
1932
1933 /**
1934 * @brief Instance structure for the Q15 bilinear interpolation function.
1935 */
1936 typedef struct
1937 {
1938 uint16_t numRows; /**< number of rows in the data table. */
1939 uint16_t numCols; /**< number of columns in the data table. */
1940 q15_t *pData; /**< points to the data table. */
1941 } arm_bilinear_interp_instance_q15;
1942
1943 /**
1944 * @brief Instance structure for the Q15 bilinear interpolation function.
1945 */
1946 typedef struct
1947 {
1948 uint16_t numRows; /**< number of rows in the data table. */
1949 uint16_t numCols; /**< number of columns in the data table. */
1950 q7_t *pData; /**< points to the data table. */
1951 } arm_bilinear_interp_instance_q7;
1952
1953
1954 /**
1955 * @brief Q7 vector multiplication.
1956 * @param[in] pSrcA points to the first input vector
1957 * @param[in] pSrcB points to the second input vector
1958 * @param[out] pDst points to the output vector
1959 * @param[in] blockSize number of samples in each vector
1960 */
1961 void arm_mult_q7(
1962 q7_t * pSrcA,
1963 q7_t * pSrcB,
1964 q7_t * pDst,
1965 uint32_t blockSize);
1966
1967
1968 /**
1969 * @brief Q15 vector multiplication.
1970 * @param[in] pSrcA points to the first input vector
1971 * @param[in] pSrcB points to the second input vector
1972 * @param[out] pDst points to the output vector
1973 * @param[in] blockSize number of samples in each vector
1974 */
1975 void arm_mult_q15(
1976 q15_t * pSrcA,
1977 q15_t * pSrcB,
1978 q15_t * pDst,
1979 uint32_t blockSize);
1980
1981
1982 /**
1983 * @brief Q31 vector multiplication.
1984 * @param[in] pSrcA points to the first input vector
1985 * @param[in] pSrcB points to the second input vector
1986 * @param[out] pDst points to the output vector
1987 * @param[in] blockSize number of samples in each vector
1988 */
1989 void arm_mult_q31(
1990 q31_t * pSrcA,
1991 q31_t * pSrcB,
1992 q31_t * pDst,
1993 uint32_t blockSize);
1994
1995
1996 /**
1997 * @brief Floating-point vector multiplication.
1998 * @param[in] pSrcA points to the first input vector
1999 * @param[in] pSrcB points to the second input vector
2000 * @param[out] pDst points to the output vector
2001 * @param[in] blockSize number of samples in each vector
2002 */
2003 void arm_mult_f32(
2004 float32_t * pSrcA,
2005 float32_t * pSrcB,
2006 float32_t * pDst,
2007 uint32_t blockSize);
2008
2009
2010 /**
2011 * @brief Instance structure for the Q15 CFFT/CIFFT function.
2012 */
2013 typedef struct
2014 {
2015 uint16_t fftLen; /**< length of the FFT. */
2016 uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
2017 uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
2018 q15_t *pTwiddle; /**< points to the Sin twiddle factor table. */
2019 uint16_t *pBitRevTable; /**< points to the bit reversal table. */
2020 uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
2021 uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
2022 } arm_cfft_radix2_instance_q15;
2023
2024/* Deprecated */
2025 arm_status arm_cfft_radix2_init_q15(
2026 arm_cfft_radix2_instance_q15 * S,
2027 uint16_t fftLen,
2028 uint8_t ifftFlag,
2029 uint8_t bitReverseFlag);
2030
2031/* Deprecated */
2032 void arm_cfft_radix2_q15(
2033 const arm_cfft_radix2_instance_q15 * S,
2034 q15_t * pSrc);
2035
2036
2037 /**
2038 * @brief Instance structure for the Q15 CFFT/CIFFT function.
2039 */
2040 typedef struct
2041 {
2042 uint16_t fftLen; /**< length of the FFT. */
2043 uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
2044 uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
2045 q15_t *pTwiddle; /**< points to the twiddle factor table. */
2046 uint16_t *pBitRevTable; /**< points to the bit reversal table. */
2047 uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
2048 uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
2049 } arm_cfft_radix4_instance_q15;
2050
2051/* Deprecated */
2052 arm_status arm_cfft_radix4_init_q15(
2053 arm_cfft_radix4_instance_q15 * S,
2054 uint16_t fftLen,
2055 uint8_t ifftFlag,
2056 uint8_t bitReverseFlag);
2057
2058/* Deprecated */
2059 void arm_cfft_radix4_q15(
2060 const arm_cfft_radix4_instance_q15 * S,
2061 q15_t * pSrc);
2062
2063 /**
2064 * @brief Instance structure for the Radix-2 Q31 CFFT/CIFFT function.
2065 */
2066 typedef struct
2067 {
2068 uint16_t fftLen; /**< length of the FFT. */
2069 uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
2070 uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
2071 q31_t *pTwiddle; /**< points to the Twiddle factor table. */
2072 uint16_t *pBitRevTable; /**< points to the bit reversal table. */
2073 uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
2074 uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
2075 } arm_cfft_radix2_instance_q31;
2076
2077/* Deprecated */
2078 arm_status arm_cfft_radix2_init_q31(
2079 arm_cfft_radix2_instance_q31 * S,
2080 uint16_t fftLen,
2081 uint8_t ifftFlag,
2082 uint8_t bitReverseFlag);
2083
2084/* Deprecated */
2085 void arm_cfft_radix2_q31(
2086 const arm_cfft_radix2_instance_q31 * S,
2087 q31_t * pSrc);
2088
2089 /**
2090 * @brief Instance structure for the Q31 CFFT/CIFFT function.
2091 */
2092 typedef struct
2093 {
2094 uint16_t fftLen; /**< length of the FFT. */
2095 uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
2096 uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
2097 q31_t *pTwiddle; /**< points to the twiddle factor table. */
2098 uint16_t *pBitRevTable; /**< points to the bit reversal table. */
2099 uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
2100 uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
2101 } arm_cfft_radix4_instance_q31;
2102
2103/* Deprecated */
2104 void arm_cfft_radix4_q31(
2105 const arm_cfft_radix4_instance_q31 * S,
2106 q31_t * pSrc);
2107
2108/* Deprecated */
2109 arm_status arm_cfft_radix4_init_q31(
2110 arm_cfft_radix4_instance_q31 * S,
2111 uint16_t fftLen,
2112 uint8_t ifftFlag,
2113 uint8_t bitReverseFlag);
2114
2115 /**
2116 * @brief Instance structure for the floating-point CFFT/CIFFT function.
2117 */
2118 typedef struct
2119 {
2120 uint16_t fftLen; /**< length of the FFT. */
2121 uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
2122 uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
2123 float32_t *pTwiddle; /**< points to the Twiddle factor table. */
2124 uint16_t *pBitRevTable; /**< points to the bit reversal table. */
2125 uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
2126 uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
2127 float32_t onebyfftLen; /**< value of 1/fftLen. */
2128 } arm_cfft_radix2_instance_f32;
2129
2130/* Deprecated */
2131 arm_status arm_cfft_radix2_init_f32(
2132 arm_cfft_radix2_instance_f32 * S,
2133 uint16_t fftLen,
2134 uint8_t ifftFlag,
2135 uint8_t bitReverseFlag);
2136
2137/* Deprecated */
2138 void arm_cfft_radix2_f32(
2139 const arm_cfft_radix2_instance_f32 * S,
2140 float32_t * pSrc);
2141
2142 /**
2143 * @brief Instance structure for the floating-point CFFT/CIFFT function.
2144 */
2145 typedef struct
2146 {
2147 uint16_t fftLen; /**< length of the FFT. */
2148 uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
2149 uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
2150 float32_t *pTwiddle; /**< points to the Twiddle factor table. */
2151 uint16_t *pBitRevTable; /**< points to the bit reversal table. */
2152 uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
2153 uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
2154 float32_t onebyfftLen; /**< value of 1/fftLen. */
2155 } arm_cfft_radix4_instance_f32;
2156
2157/* Deprecated */
2158 arm_status arm_cfft_radix4_init_f32(
2159 arm_cfft_radix4_instance_f32 * S,
2160 uint16_t fftLen,
2161 uint8_t ifftFlag,
2162 uint8_t bitReverseFlag);
2163
2164/* Deprecated */
2165 void arm_cfft_radix4_f32(
2166 const arm_cfft_radix4_instance_f32 * S,
2167 float32_t * pSrc);
2168
2169 /**
2170 * @brief Instance structure for the fixed-point CFFT/CIFFT function.
2171 */
2172 typedef struct
2173 {
2174 uint16_t fftLen; /**< length of the FFT. */
2175 const q15_t *pTwiddle; /**< points to the Twiddle factor table. */
2176 const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
2177 uint16_t bitRevLength; /**< bit reversal table length. */
2178 } arm_cfft_instance_q15;
2179
2180void arm_cfft_q15(
2181 const arm_cfft_instance_q15 * S,
2182 q15_t * p1,
2183 uint8_t ifftFlag,
2184 uint8_t bitReverseFlag);
2185
2186 /**
2187 * @brief Instance structure for the fixed-point CFFT/CIFFT function.
2188 */
2189 typedef struct
2190 {
2191 uint16_t fftLen; /**< length of the FFT. */
2192 const q31_t *pTwiddle; /**< points to the Twiddle factor table. */
2193 const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
2194 uint16_t bitRevLength; /**< bit reversal table length. */
2195 } arm_cfft_instance_q31;
2196
2197void arm_cfft_q31(
2198 const arm_cfft_instance_q31 * S,
2199 q31_t * p1,
2200 uint8_t ifftFlag,
2201 uint8_t bitReverseFlag);
2202
2203 /**
2204 * @brief Instance structure for the floating-point CFFT/CIFFT function.
2205 */
2206 typedef struct
2207 {
2208 uint16_t fftLen; /**< length of the FFT. */
2209 const float32_t *pTwiddle; /**< points to the Twiddle factor table. */
2210 const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
2211 uint16_t bitRevLength; /**< bit reversal table length. */
2212 } arm_cfft_instance_f32;
2213
2214 void arm_cfft_f32(
2215 const arm_cfft_instance_f32 * S,
2216 float32_t * p1,
2217 uint8_t ifftFlag,
2218 uint8_t bitReverseFlag);
2219
2220 /**
2221 * @brief Instance structure for the Q15 RFFT/RIFFT function.
2222 */
2223 typedef struct
2224 {
2225 uint32_t fftLenReal; /**< length of the real FFT. */
2226 uint8_t ifftFlagR; /**< flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. */
2227 uint8_t bitReverseFlagR; /**< flag that enables (bitReverseFlagR=1) or disables (bitReverseFlagR=0) bit reversal of output. */
2228 uint32_t twidCoefRModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
2229 q15_t *pTwiddleAReal; /**< points to the real twiddle factor table. */
2230 q15_t *pTwiddleBReal; /**< points to the imag twiddle factor table. */
2231 const arm_cfft_instance_q15 *pCfft; /**< points to the complex FFT instance. */
2232 } arm_rfft_instance_q15;
2233
2234 arm_status arm_rfft_init_q15(
2235 arm_rfft_instance_q15 * S,
2236 uint32_t fftLenReal,
2237 uint32_t ifftFlagR,
2238 uint32_t bitReverseFlag);
2239
2240 void arm_rfft_q15(
2241 const arm_rfft_instance_q15 * S,
2242 q15_t * pSrc,
2243 q15_t * pDst);
2244
2245 /**
2246 * @brief Instance structure for the Q31 RFFT/RIFFT function.
2247 */
2248 typedef struct
2249 {
2250 uint32_t fftLenReal; /**< length of the real FFT. */
2251 uint8_t ifftFlagR; /**< flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. */
2252 uint8_t bitReverseFlagR; /**< flag that enables (bitReverseFlagR=1) or disables (bitReverseFlagR=0) bit reversal of output. */
2253 uint32_t twidCoefRModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
2254 q31_t *pTwiddleAReal; /**< points to the real twiddle factor table. */
2255 q31_t *pTwiddleBReal; /**< points to the imag twiddle factor table. */
2256 const arm_cfft_instance_q31 *pCfft; /**< points to the complex FFT instance. */
2257 } arm_rfft_instance_q31;
2258
2259 arm_status arm_rfft_init_q31(
2260 arm_rfft_instance_q31 * S,
2261 uint32_t fftLenReal,
2262 uint32_t ifftFlagR,
2263 uint32_t bitReverseFlag);
2264
2265 void arm_rfft_q31(
2266 const arm_rfft_instance_q31 * S,
2267 q31_t * pSrc,
2268 q31_t * pDst);
2269
2270 /**
2271 * @brief Instance structure for the floating-point RFFT/RIFFT function.
2272 */
2273 typedef struct
2274 {
2275 uint32_t fftLenReal; /**< length of the real FFT. */
2276 uint16_t fftLenBy2; /**< length of the complex FFT. */
2277 uint8_t ifftFlagR; /**< flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. */
2278 uint8_t bitReverseFlagR; /**< flag that enables (bitReverseFlagR=1) or disables (bitReverseFlagR=0) bit reversal of output. */
2279 uint32_t twidCoefRModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
2280 float32_t *pTwiddleAReal; /**< points to the real twiddle factor table. */
2281 float32_t *pTwiddleBReal; /**< points to the imag twiddle factor table. */
2282 arm_cfft_radix4_instance_f32 *pCfft; /**< points to the complex FFT instance. */
2283 } arm_rfft_instance_f32;
2284
2285 arm_status arm_rfft_init_f32(
2286 arm_rfft_instance_f32 * S,
2287 arm_cfft_radix4_instance_f32 * S_CFFT,
2288 uint32_t fftLenReal,
2289 uint32_t ifftFlagR,
2290 uint32_t bitReverseFlag);
2291
2292 void arm_rfft_f32(
2293 const arm_rfft_instance_f32 * S,
2294 float32_t * pSrc,
2295 float32_t * pDst);
2296
2297 /**
2298 * @brief Instance structure for the floating-point RFFT/RIFFT function.
2299 */
2300typedef struct
2301 {
2302 arm_cfft_instance_f32 Sint; /**< Internal CFFT structure. */
2303 uint16_t fftLenRFFT; /**< length of the real sequence */
2304 float32_t * pTwiddleRFFT; /**< Twiddle factors real stage */
2305 } arm_rfft_fast_instance_f32 ;
2306
2307arm_status arm_rfft_fast_init_f32 (
2308 arm_rfft_fast_instance_f32 * S,
2309 uint16_t fftLen);
2310
2311void arm_rfft_fast_f32(
2312 arm_rfft_fast_instance_f32 * S,
2313 float32_t * p, float32_t * pOut,
2314 uint8_t ifftFlag);
2315
2316 /**
2317 * @brief Instance structure for the floating-point DCT4/IDCT4 function.
2318 */
2319 typedef struct
2320 {
2321 uint16_t N; /**< length of the DCT4. */
2322 uint16_t Nby2; /**< half of the length of the DCT4. */
2323 float32_t normalize; /**< normalizing factor. */
2324 float32_t *pTwiddle; /**< points to the twiddle factor table. */
2325 float32_t *pCosFactor; /**< points to the cosFactor table. */
2326 arm_rfft_instance_f32 *pRfft; /**< points to the real FFT instance. */
2327 arm_cfft_radix4_instance_f32 *pCfft; /**< points to the complex FFT instance. */
2328 } arm_dct4_instance_f32;
2329
2330
2331 /**
2332 * @brief Initialization function for the floating-point DCT4/IDCT4.
2333 * @param[in,out] S points to an instance of floating-point DCT4/IDCT4 structure.
2334 * @param[in] S_RFFT points to an instance of floating-point RFFT/RIFFT structure.
2335 * @param[in] S_CFFT points to an instance of floating-point CFFT/CIFFT structure.
2336 * @param[in] N length of the DCT4.
2337 * @param[in] Nby2 half of the length of the DCT4.
2338 * @param[in] normalize normalizing factor.
2339 * @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.
2340 */
2341 arm_status arm_dct4_init_f32(
2342 arm_dct4_instance_f32 * S,
2343 arm_rfft_instance_f32 * S_RFFT,
2344 arm_cfft_radix4_instance_f32 * S_CFFT,
2345 uint16_t N,
2346 uint16_t Nby2,
2347 float32_t normalize);
2348
2349
2350 /**
2351 * @brief Processing function for the floating-point DCT4/IDCT4.
2352 * @param[in] S points to an instance of the floating-point DCT4/IDCT4 structure.
2353 * @param[in] pState points to state buffer.
2354 * @param[in,out] pInlineBuffer points to the in-place input and output buffer.
2355 */
2356 void arm_dct4_f32(
2357 const arm_dct4_instance_f32 * S,
2358 float32_t * pState,
2359 float32_t * pInlineBuffer);
2360
2361
2362 /**
2363 * @brief Instance structure for the Q31 DCT4/IDCT4 function.
2364 */
2365 typedef struct
2366 {
2367 uint16_t N; /**< length of the DCT4. */
2368 uint16_t Nby2; /**< half of the length of the DCT4. */
2369 q31_t normalize; /**< normalizing factor. */
2370 q31_t *pTwiddle; /**< points to the twiddle factor table. */
2371 q31_t *pCosFactor; /**< points to the cosFactor table. */
2372 arm_rfft_instance_q31 *pRfft; /**< points to the real FFT instance. */
2373 arm_cfft_radix4_instance_q31 *pCfft; /**< points to the complex FFT instance. */
2374 } arm_dct4_instance_q31;
2375
2376
2377 /**
2378 * @brief Initialization function for the Q31 DCT4/IDCT4.
2379 * @param[in,out] S points to an instance of Q31 DCT4/IDCT4 structure.
2380 * @param[in] S_RFFT points to an instance of Q31 RFFT/RIFFT structure
2381 * @param[in] S_CFFT points to an instance of Q31 CFFT/CIFFT structure
2382 * @param[in] N length of the DCT4.
2383 * @param[in] Nby2 half of the length of the DCT4.
2384 * @param[in] normalize normalizing factor.
2385 * @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.
2386 */
2387 arm_status arm_dct4_init_q31(
2388 arm_dct4_instance_q31 * S,
2389 arm_rfft_instance_q31 * S_RFFT,
2390 arm_cfft_radix4_instance_q31 * S_CFFT,
2391 uint16_t N,
2392 uint16_t Nby2,
2393 q31_t normalize);
2394
2395
2396 /**
2397 * @brief Processing function for the Q31 DCT4/IDCT4.
2398 * @param[in] S points to an instance of the Q31 DCT4 structure.
2399 * @param[in] pState points to state buffer.
2400 * @param[in,out] pInlineBuffer points to the in-place input and output buffer.
2401 */
2402 void arm_dct4_q31(
2403 const arm_dct4_instance_q31 * S,
2404 q31_t * pState,
2405 q31_t * pInlineBuffer);
2406
2407
2408 /**
2409 * @brief Instance structure for the Q15 DCT4/IDCT4 function.
2410 */
2411 typedef struct
2412 {
2413 uint16_t N; /**< length of the DCT4. */
2414 uint16_t Nby2; /**< half of the length of the DCT4. */
2415 q15_t normalize; /**< normalizing factor. */
2416 q15_t *pTwiddle; /**< points to the twiddle factor table. */
2417 q15_t *pCosFactor; /**< points to the cosFactor table. */
2418 arm_rfft_instance_q15 *pRfft; /**< points to the real FFT instance. */
2419 arm_cfft_radix4_instance_q15 *pCfft; /**< points to the complex FFT instance. */
2420 } arm_dct4_instance_q15;
2421
2422
2423 /**
2424 * @brief Initialization function for the Q15 DCT4/IDCT4.
2425 * @param[in,out] S points to an instance of Q15 DCT4/IDCT4 structure.
2426 * @param[in] S_RFFT points to an instance of Q15 RFFT/RIFFT structure.
2427 * @param[in] S_CFFT points to an instance of Q15 CFFT/CIFFT structure.
2428 * @param[in] N length of the DCT4.
2429 * @param[in] Nby2 half of the length of the DCT4.
2430 * @param[in] normalize normalizing factor.
2431 * @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.
2432 */
2433 arm_status arm_dct4_init_q15(
2434 arm_dct4_instance_q15 * S,
2435 arm_rfft_instance_q15 * S_RFFT,
2436 arm_cfft_radix4_instance_q15 * S_CFFT,
2437 uint16_t N,
2438 uint16_t Nby2,
2439 q15_t normalize);
2440
2441
2442 /**
2443 * @brief Processing function for the Q15 DCT4/IDCT4.
2444 * @param[in] S points to an instance of the Q15 DCT4 structure.
2445 * @param[in] pState points to state buffer.
2446 * @param[in,out] pInlineBuffer points to the in-place input and output buffer.
2447 */
2448 void arm_dct4_q15(
2449 const arm_dct4_instance_q15 * S,
2450 q15_t * pState,
2451 q15_t * pInlineBuffer);
2452
2453
2454 /**
2455 * @brief Floating-point vector addition.
2456 * @param[in] pSrcA points to the first input vector
2457 * @param[in] pSrcB points to the second input vector
2458 * @param[out] pDst points to the output vector
2459 * @param[in] blockSize number of samples in each vector
2460 */
2461 void arm_add_f32(
2462 float32_t * pSrcA,
2463 float32_t * pSrcB,
2464 float32_t * pDst,
2465 uint32_t blockSize);
2466
2467
2468 /**
2469 * @brief Q7 vector addition.
2470 * @param[in] pSrcA points to the first input vector
2471 * @param[in] pSrcB points to the second input vector
2472 * @param[out] pDst points to the output vector
2473 * @param[in] blockSize number of samples in each vector
2474 */
2475 void arm_add_q7(
2476 q7_t * pSrcA,
2477 q7_t * pSrcB,
2478 q7_t * pDst,
2479 uint32_t blockSize);
2480
2481
2482 /**
2483 * @brief Q15 vector addition.
2484 * @param[in] pSrcA points to the first input vector
2485 * @param[in] pSrcB points to the second input vector
2486 * @param[out] pDst points to the output vector
2487 * @param[in] blockSize number of samples in each vector
2488 */
2489 void arm_add_q15(
2490 q15_t * pSrcA,
2491 q15_t * pSrcB,
2492 q15_t * pDst,
2493 uint32_t blockSize);
2494
2495
2496 /**
2497 * @brief Q31 vector addition.
2498 * @param[in] pSrcA points to the first input vector
2499 * @param[in] pSrcB points to the second input vector
2500 * @param[out] pDst points to the output vector
2501 * @param[in] blockSize number of samples in each vector
2502 */
2503 void arm_add_q31(
2504 q31_t * pSrcA,
2505 q31_t * pSrcB,
2506 q31_t * pDst,
2507 uint32_t blockSize);
2508
2509
2510 /**
2511 * @brief Floating-point vector subtraction.
2512 * @param[in] pSrcA points to the first input vector
2513 * @param[in] pSrcB points to the second input vector
2514 * @param[out] pDst points to the output vector
2515 * @param[in] blockSize number of samples in each vector
2516 */
2517 void arm_sub_f32(
2518 float32_t * pSrcA,
2519 float32_t * pSrcB,
2520 float32_t * pDst,
2521 uint32_t blockSize);
2522
2523
2524 /**
2525 * @brief Q7 vector subtraction.
2526 * @param[in] pSrcA points to the first input vector
2527 * @param[in] pSrcB points to the second input vector
2528 * @param[out] pDst points to the output vector
2529 * @param[in] blockSize number of samples in each vector
2530 */
2531 void arm_sub_q7(
2532 q7_t * pSrcA,
2533 q7_t * pSrcB,
2534 q7_t * pDst,
2535 uint32_t blockSize);
2536
2537
2538 /**
2539 * @brief Q15 vector subtraction.
2540 * @param[in] pSrcA points to the first input vector
2541 * @param[in] pSrcB points to the second input vector
2542 * @param[out] pDst points to the output vector
2543 * @param[in] blockSize number of samples in each vector
2544 */
2545 void arm_sub_q15(
2546 q15_t * pSrcA,
2547 q15_t * pSrcB,
2548 q15_t * pDst,
2549 uint32_t blockSize);
2550
2551
2552 /**
2553 * @brief Q31 vector subtraction.
2554 * @param[in] pSrcA points to the first input vector
2555 * @param[in] pSrcB points to the second input vector
2556 * @param[out] pDst points to the output vector
2557 * @param[in] blockSize number of samples in each vector
2558 */
2559 void arm_sub_q31(
2560 q31_t * pSrcA,
2561 q31_t * pSrcB,
2562 q31_t * pDst,
2563 uint32_t blockSize);
2564
2565
2566 /**
2567 * @brief Multiplies a floating-point vector by a scalar.
2568 * @param[in] pSrc points to the input vector
2569 * @param[in] scale scale factor to be applied
2570 * @param[out] pDst points to the output vector
2571 * @param[in] blockSize number of samples in the vector
2572 */
2573 void arm_scale_f32(
2574 float32_t * pSrc,
2575 float32_t scale,
2576 float32_t * pDst,
2577 uint32_t blockSize);
2578
2579
2580 /**
2581 * @brief Multiplies a Q7 vector by a scalar.
2582 * @param[in] pSrc points to the input vector
2583 * @param[in] scaleFract fractional portion of the scale value
2584 * @param[in] shift number of bits to shift the result by
2585 * @param[out] pDst points to the output vector
2586 * @param[in] blockSize number of samples in the vector
2587 */
2588 void arm_scale_q7(
2589 q7_t * pSrc,
2590 q7_t scaleFract,
2591 int8_t shift,
2592 q7_t * pDst,
2593 uint32_t blockSize);
2594
2595
2596 /**
2597 * @brief Multiplies a Q15 vector by a scalar.
2598 * @param[in] pSrc points to the input vector
2599 * @param[in] scaleFract fractional portion of the scale value
2600 * @param[in] shift number of bits to shift the result by
2601 * @param[out] pDst points to the output vector
2602 * @param[in] blockSize number of samples in the vector
2603 */
2604 void arm_scale_q15(
2605 q15_t * pSrc,
2606 q15_t scaleFract,
2607 int8_t shift,
2608 q15_t * pDst,
2609 uint32_t blockSize);
2610
2611
2612 /**
2613 * @brief Multiplies a Q31 vector by a scalar.
2614 * @param[in] pSrc points to the input vector
2615 * @param[in] scaleFract fractional portion of the scale value
2616 * @param[in] shift number of bits to shift the result by
2617 * @param[out] pDst points to the output vector
2618 * @param[in] blockSize number of samples in the vector
2619 */
2620 void arm_scale_q31(
2621 q31_t * pSrc,
2622 q31_t scaleFract,
2623 int8_t shift,
2624 q31_t * pDst,
2625 uint32_t blockSize);
2626
2627
2628 /**
2629 * @brief Q7 vector absolute value.
2630 * @param[in] pSrc points to the input buffer
2631 * @param[out] pDst points to the output buffer
2632 * @param[in] blockSize number of samples in each vector
2633 */
2634 void arm_abs_q7(
2635 q7_t * pSrc,
2636 q7_t * pDst,
2637 uint32_t blockSize);
2638
2639
2640 /**
2641 * @brief Floating-point vector absolute value.
2642 * @param[in] pSrc points to the input buffer
2643 * @param[out] pDst points to the output buffer
2644 * @param[in] blockSize number of samples in each vector
2645 */
2646 void arm_abs_f32(
2647 float32_t * pSrc,
2648 float32_t * pDst,
2649 uint32_t blockSize);
2650
2651
2652 /**
2653 * @brief Q15 vector absolute value.
2654 * @param[in] pSrc points to the input buffer
2655 * @param[out] pDst points to the output buffer
2656 * @param[in] blockSize number of samples in each vector
2657 */
2658 void arm_abs_q15(
2659 q15_t * pSrc,
2660 q15_t * pDst,
2661 uint32_t blockSize);
2662
2663
2664 /**
2665 * @brief Q31 vector absolute value.
2666 * @param[in] pSrc points to the input buffer
2667 * @param[out] pDst points to the output buffer
2668 * @param[in] blockSize number of samples in each vector
2669 */
2670 void arm_abs_q31(
2671 q31_t * pSrc,
2672 q31_t * pDst,
2673 uint32_t blockSize);
2674
2675
2676 /**
2677 * @brief Dot product of floating-point vectors.
2678 * @param[in] pSrcA points to the first input vector
2679 * @param[in] pSrcB points to the second input vector
2680 * @param[in] blockSize number of samples in each vector
2681 * @param[out] result output result returned here
2682 */
2683 void arm_dot_prod_f32(
2684 float32_t * pSrcA,
2685 float32_t * pSrcB,
2686 uint32_t blockSize,
2687 float32_t * result);
2688
2689
2690 /**
2691 * @brief Dot product of Q7 vectors.
2692 * @param[in] pSrcA points to the first input vector
2693 * @param[in] pSrcB points to the second input vector
2694 * @param[in] blockSize number of samples in each vector
2695 * @param[out] result output result returned here
2696 */
2697 void arm_dot_prod_q7(
2698 q7_t * pSrcA,
2699 q7_t * pSrcB,
2700 uint32_t blockSize,
2701 q31_t * result);
2702
2703
2704 /**
2705 * @brief Dot product of Q15 vectors.
2706 * @param[in] pSrcA points to the first input vector
2707 * @param[in] pSrcB points to the second input vector
2708 * @param[in] blockSize number of samples in each vector
2709 * @param[out] result output result returned here
2710 */
2711 void arm_dot_prod_q15(
2712 q15_t * pSrcA,
2713 q15_t * pSrcB,
2714 uint32_t blockSize,
2715 q63_t * result);
2716
2717
2718 /**
2719 * @brief Dot product of Q31 vectors.
2720 * @param[in] pSrcA points to the first input vector
2721 * @param[in] pSrcB points to the second input vector
2722 * @param[in] blockSize number of samples in each vector
2723 * @param[out] result output result returned here
2724 */
2725 void arm_dot_prod_q31(
2726 q31_t * pSrcA,
2727 q31_t * pSrcB,
2728 uint32_t blockSize,
2729 q63_t * result);
2730
2731
2732 /**
2733 * @brief Shifts the elements of a Q7 vector a specified number of bits.
2734 * @param[in] pSrc points to the input vector
2735 * @param[in] shiftBits number of bits to shift. A positive value shifts left; a negative value shifts right.
2736 * @param[out] pDst points to the output vector
2737 * @param[in] blockSize number of samples in the vector
2738 */
2739 void arm_shift_q7(
2740 q7_t * pSrc,
2741 int8_t shiftBits,
2742 q7_t * pDst,
2743 uint32_t blockSize);
2744
2745
2746 /**
2747 * @brief Shifts the elements of a Q15 vector a specified number of bits.
2748 * @param[in] pSrc points to the input vector
2749 * @param[in] shiftBits number of bits to shift. A positive value shifts left; a negative value shifts right.
2750 * @param[out] pDst points to the output vector
2751 * @param[in] blockSize number of samples in the vector
2752 */
2753 void arm_shift_q15(
2754 q15_t * pSrc,
2755 int8_t shiftBits,
2756 q15_t * pDst,
2757 uint32_t blockSize);
2758
2759
2760 /**
2761 * @brief Shifts the elements of a Q31 vector a specified number of bits.
2762 * @param[in] pSrc points to the input vector
2763 * @param[in] shiftBits number of bits to shift. A positive value shifts left; a negative value shifts right.
2764 * @param[out] pDst points to the output vector
2765 * @param[in] blockSize number of samples in the vector
2766 */
2767 void arm_shift_q31(
2768 q31_t * pSrc,
2769 int8_t shiftBits,
2770 q31_t * pDst,
2771 uint32_t blockSize);
2772
2773
2774 /**
2775 * @brief Adds a constant offset to a floating-point vector.
2776 * @param[in] pSrc points to the input vector
2777 * @param[in] offset is the offset to be added
2778 * @param[out] pDst points to the output vector
2779 * @param[in] blockSize number of samples in the vector
2780 */
2781 void arm_offset_f32(
2782 float32_t * pSrc,
2783 float32_t offset,
2784 float32_t * pDst,
2785 uint32_t blockSize);
2786
2787
2788 /**
2789 * @brief Adds a constant offset to a Q7 vector.
2790 * @param[in] pSrc points to the input vector
2791 * @param[in] offset is the offset to be added
2792 * @param[out] pDst points to the output vector
2793 * @param[in] blockSize number of samples in the vector
2794 */
2795 void arm_offset_q7(
2796 q7_t * pSrc,
2797 q7_t offset,
2798 q7_t * pDst,
2799 uint32_t blockSize);
2800
2801
2802 /**
2803 * @brief Adds a constant offset to a Q15 vector.
2804 * @param[in] pSrc points to the input vector
2805 * @param[in] offset is the offset to be added
2806 * @param[out] pDst points to the output vector
2807 * @param[in] blockSize number of samples in the vector
2808 */
2809 void arm_offset_q15(
2810 q15_t * pSrc,
2811 q15_t offset,
2812 q15_t * pDst,
2813 uint32_t blockSize);
2814
2815
2816 /**
2817 * @brief Adds a constant offset to a Q31 vector.
2818 * @param[in] pSrc points to the input vector
2819 * @param[in] offset is the offset to be added
2820 * @param[out] pDst points to the output vector
2821 * @param[in] blockSize number of samples in the vector
2822 */
2823 void arm_offset_q31(
2824 q31_t * pSrc,
2825 q31_t offset,
2826 q31_t * pDst,
2827 uint32_t blockSize);
2828
2829
2830 /**
2831 * @brief Negates the elements of a floating-point vector.
2832 * @param[in] pSrc points to the input vector
2833 * @param[out] pDst points to the output vector
2834 * @param[in] blockSize number of samples in the vector
2835 */
2836 void arm_negate_f32(
2837 float32_t * pSrc,
2838 float32_t * pDst,
2839 uint32_t blockSize);
2840
2841
2842 /**
2843 * @brief Negates the elements of a Q7 vector.
2844 * @param[in] pSrc points to the input vector
2845 * @param[out] pDst points to the output vector
2846 * @param[in] blockSize number of samples in the vector
2847 */
2848 void arm_negate_q7(
2849 q7_t * pSrc,
2850 q7_t * pDst,
2851 uint32_t blockSize);
2852
2853
2854 /**
2855 * @brief Negates the elements of a Q15 vector.
2856 * @param[in] pSrc points to the input vector
2857 * @param[out] pDst points to the output vector
2858 * @param[in] blockSize number of samples in the vector
2859 */
2860 void arm_negate_q15(
2861 q15_t * pSrc,
2862 q15_t * pDst,
2863 uint32_t blockSize);
2864
2865
2866 /**
2867 * @brief Negates the elements of a Q31 vector.
2868 * @param[in] pSrc points to the input vector
2869 * @param[out] pDst points to the output vector
2870 * @param[in] blockSize number of samples in the vector
2871 */
2872 void arm_negate_q31(
2873 q31_t * pSrc,
2874 q31_t * pDst,
2875 uint32_t blockSize);
2876
2877
2878 /**
2879 * @brief Copies the elements of a floating-point vector.
2880 * @param[in] pSrc input pointer
2881 * @param[out] pDst output pointer
2882 * @param[in] blockSize number of samples to process
2883 */
2884 void arm_copy_f32(
2885 float32_t * pSrc,
2886 float32_t * pDst,
2887 uint32_t blockSize);
2888
2889
2890 /**
2891 * @brief Copies the elements of a Q7 vector.
2892 * @param[in] pSrc input pointer
2893 * @param[out] pDst output pointer
2894 * @param[in] blockSize number of samples to process
2895 */
2896 void arm_copy_q7(
2897 q7_t * pSrc,
2898 q7_t * pDst,
2899 uint32_t blockSize);
2900
2901
2902 /**
2903 * @brief Copies the elements of a Q15 vector.
2904 * @param[in] pSrc input pointer
2905 * @param[out] pDst output pointer
2906 * @param[in] blockSize number of samples to process
2907 */
2908 void arm_copy_q15(
2909 q15_t * pSrc,
2910 q15_t * pDst,
2911 uint32_t blockSize);
2912
2913
2914 /**
2915 * @brief Copies the elements of a Q31 vector.
2916 * @param[in] pSrc input pointer
2917 * @param[out] pDst output pointer
2918 * @param[in] blockSize number of samples to process
2919 */
2920 void arm_copy_q31(
2921 q31_t * pSrc,
2922 q31_t * pDst,
2923 uint32_t blockSize);
2924
2925
2926 /**
2927 * @brief Fills a constant value into a floating-point vector.
2928 * @param[in] value input value to be filled
2929 * @param[out] pDst output pointer
2930 * @param[in] blockSize number of samples to process
2931 */
2932 void arm_fill_f32(
2933 float32_t value,
2934 float32_t * pDst,
2935 uint32_t blockSize);
2936
2937
2938 /**
2939 * @brief Fills a constant value into a Q7 vector.
2940 * @param[in] value input value to be filled
2941 * @param[out] pDst output pointer
2942 * @param[in] blockSize number of samples to process
2943 */
2944 void arm_fill_q7(
2945 q7_t value,
2946 q7_t * pDst,
2947 uint32_t blockSize);
2948
2949
2950 /**
2951 * @brief Fills a constant value into a Q15 vector.
2952 * @param[in] value input value to be filled
2953 * @param[out] pDst output pointer
2954 * @param[in] blockSize number of samples to process
2955 */
2956 void arm_fill_q15(
2957 q15_t value,
2958 q15_t * pDst,
2959 uint32_t blockSize);
2960
2961
2962 /**
2963 * @brief Fills a constant value into a Q31 vector.
2964 * @param[in] value input value to be filled
2965 * @param[out] pDst output pointer
2966 * @param[in] blockSize number of samples to process
2967 */
2968 void arm_fill_q31(
2969 q31_t value,
2970 q31_t * pDst,
2971 uint32_t blockSize);
2972
2973
2974/**
2975 * @brief Convolution of floating-point sequences.
2976 * @param[in] pSrcA points to the first input sequence.
2977 * @param[in] srcALen length of the first input sequence.
2978 * @param[in] pSrcB points to the second input sequence.
2979 * @param[in] srcBLen length of the second input sequence.
2980 * @param[out] pDst points to the location where the output result is written. Length srcALen+srcBLen-1.
2981 */
2982 void arm_conv_f32(
2983 float32_t * pSrcA,
2984 uint32_t srcALen,
2985 float32_t * pSrcB,
2986 uint32_t srcBLen,
2987 float32_t * pDst);
2988
2989
2990 /**
2991 * @brief Convolution of Q15 sequences.
2992 * @param[in] pSrcA points to the first input sequence.
2993 * @param[in] srcALen length of the first input sequence.
2994 * @param[in] pSrcB points to the second input sequence.
2995 * @param[in] srcBLen length of the second input sequence.
2996 * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1.
2997 * @param[in] pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
2998 * @param[in] pScratch2 points to scratch buffer of size min(srcALen, srcBLen).
2999 */
3000 void arm_conv_opt_q15(
3001 q15_t * pSrcA,
3002 uint32_t srcALen,
3003 q15_t * pSrcB,
3004 uint32_t srcBLen,
3005 q15_t * pDst,
3006 q15_t * pScratch1,
3007 q15_t * pScratch2);
3008
3009
3010/**
3011 * @brief Convolution of Q15 sequences.
3012 * @param[in] pSrcA points to the first input sequence.
3013 * @param[in] srcALen length of the first input sequence.
3014 * @param[in] pSrcB points to the second input sequence.
3015 * @param[in] srcBLen length of the second input sequence.
3016 * @param[out] pDst points to the location where the output result is written. Length srcALen+srcBLen-1.
3017 */
3018 void arm_conv_q15(
3019 q15_t * pSrcA,
3020 uint32_t srcALen,
3021 q15_t * pSrcB,
3022 uint32_t srcBLen,
3023 q15_t * pDst);
3024
3025
3026 /**
3027 * @brief Convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4
3028 * @param[in] pSrcA points to the first input sequence.
3029 * @param[in] srcALen length of the first input sequence.
3030 * @param[in] pSrcB points to the second input sequence.
3031 * @param[in] srcBLen length of the second input sequence.
3032 * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1.
3033 */
3034 void arm_conv_fast_q15(
3035 q15_t * pSrcA,
3036 uint32_t srcALen,
3037 q15_t * pSrcB,
3038 uint32_t srcBLen,
3039 q15_t * pDst);
3040
3041
3042 /**
3043 * @brief Convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4
3044 * @param[in] pSrcA points to the first input sequence.
3045 * @param[in] srcALen length of the first input sequence.
3046 * @param[in] pSrcB points to the second input sequence.
3047 * @param[in] srcBLen length of the second input sequence.
3048 * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1.
3049 * @param[in] pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
3050 * @param[in] pScratch2 points to scratch buffer of size min(srcALen, srcBLen).
3051 */
3052 void arm_conv_fast_opt_q15(
3053 q15_t * pSrcA,
3054 uint32_t srcALen,
3055 q15_t * pSrcB,
3056 uint32_t srcBLen,
3057 q15_t * pDst,
3058 q15_t * pScratch1,
3059 q15_t * pScratch2);
3060
3061
3062 /**
3063 * @brief Convolution of Q31 sequences.
3064 * @param[in] pSrcA points to the first input sequence.
3065 * @param[in] srcALen length of the first input sequence.
3066 * @param[in] pSrcB points to the second input sequence.
3067 * @param[in] srcBLen length of the second input sequence.
3068 * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1.
3069 */
3070 void arm_conv_q31(
3071 q31_t * pSrcA,
3072 uint32_t srcALen,
3073 q31_t * pSrcB,
3074 uint32_t srcBLen,
3075 q31_t * pDst);
3076
3077
3078 /**
3079 * @brief Convolution of Q31 sequences (fast version) for Cortex-M3 and Cortex-M4
3080 * @param[in] pSrcA points to the first input sequence.
3081 * @param[in] srcALen length of the first input sequence.
3082 * @param[in] pSrcB points to the second input sequence.
3083 * @param[in] srcBLen length of the second input sequence.
3084 * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1.
3085 */
3086 void arm_conv_fast_q31(
3087 q31_t * pSrcA,
3088 uint32_t srcALen,
3089 q31_t * pSrcB,
3090 uint32_t srcBLen,
3091 q31_t * pDst);
3092
3093
3094 /**
3095 * @brief Convolution of Q7 sequences.
3096 * @param[in] pSrcA points to the first input sequence.
3097 * @param[in] srcALen length of the first input sequence.
3098 * @param[in] pSrcB points to the second input sequence.
3099 * @param[in] srcBLen length of the second input sequence.
3100 * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1.
3101 * @param[in] pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
3102 * @param[in] pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen).
3103 */
3104 void arm_conv_opt_q7(
3105 q7_t * pSrcA,
3106 uint32_t srcALen,
3107 q7_t * pSrcB,
3108 uint32_t srcBLen,
3109 q7_t * pDst,
3110 q15_t * pScratch1,
3111 q15_t * pScratch2);
3112
3113
3114 /**
3115 * @brief Convolution of Q7 sequences.
3116 * @param[in] pSrcA points to the first input sequence.
3117 * @param[in] srcALen length of the first input sequence.
3118 * @param[in] pSrcB points to the second input sequence.
3119 * @param[in] srcBLen length of the second input sequence.
3120 * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1.
3121 */
3122 void arm_conv_q7(
3123 q7_t * pSrcA,
3124 uint32_t srcALen,
3125 q7_t * pSrcB,
3126 uint32_t srcBLen,
3127 q7_t * pDst);
3128
3129
3130 /**
3131 * @brief Partial convolution of floating-point sequences.
3132 * @param[in] pSrcA points to the first input sequence.
3133 * @param[in] srcALen length of the first input sequence.
3134 * @param[in] pSrcB points to the second input sequence.
3135 * @param[in] srcBLen length of the second input sequence.
3136 * @param[out] pDst points to the block of output data
3137 * @param[in] firstIndex is the first output sample to start with.
3138 * @param[in] numPoints is the number of output points to be computed.
3139 * @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].
3140 */
3141 arm_status arm_conv_partial_f32(
3142 float32_t * pSrcA,
3143 uint32_t srcALen,
3144 float32_t * pSrcB,
3145 uint32_t srcBLen,
3146 float32_t * pDst,
3147 uint32_t firstIndex,
3148 uint32_t numPoints);
3149
3150
3151 /**
3152 * @brief Partial convolution of Q15 sequences.
3153 * @param[in] pSrcA points to the first input sequence.
3154 * @param[in] srcALen length of the first input sequence.
3155 * @param[in] pSrcB points to the second input sequence.
3156 * @param[in] srcBLen length of the second input sequence.
3157 * @param[out] pDst points to the block of output data
3158 * @param[in] firstIndex is the first output sample to start with.
3159 * @param[in] numPoints is the number of output points to be computed.
3160 * @param[in] pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
3161 * @param[in] pScratch2 points to scratch buffer of size min(srcALen, srcBLen).
3162 * @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].
3163 */
3164 arm_status arm_conv_partial_opt_q15(
3165 q15_t * pSrcA,
3166 uint32_t srcALen,
3167 q15_t * pSrcB,
3168 uint32_t srcBLen,
3169 q15_t * pDst,
3170 uint32_t firstIndex,
3171 uint32_t numPoints,
3172 q15_t * pScratch1,
3173 q15_t * pScratch2);
3174
3175
3176 /**
3177 * @brief Partial convolution of Q15 sequences.
3178 * @param[in] pSrcA points to the first input sequence.
3179 * @param[in] srcALen length of the first input sequence.
3180 * @param[in] pSrcB points to the second input sequence.
3181 * @param[in] srcBLen length of the second input sequence.
3182 * @param[out] pDst points to the block of output data
3183 * @param[in] firstIndex is the first output sample to start with.
3184 * @param[in] numPoints is the number of output points to be computed.
3185 * @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].
3186 */
3187 arm_status arm_conv_partial_q15(
3188 q15_t * pSrcA,
3189 uint32_t srcALen,
3190 q15_t * pSrcB,
3191 uint32_t srcBLen,
3192 q15_t * pDst,
3193 uint32_t firstIndex,
3194 uint32_t numPoints);
3195
3196
3197 /**
3198 * @brief Partial convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4
3199 * @param[in] pSrcA points to the first input sequence.
3200 * @param[in] srcALen length of the first input sequence.
3201 * @param[in] pSrcB points to the second input sequence.
3202 * @param[in] srcBLen length of the second input sequence.
3203 * @param[out] pDst points to the block of output data
3204 * @param[in] firstIndex is the first output sample to start with.
3205 * @param[in] numPoints is the number of output points to be computed.
3206 * @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].
3207 */
3208 arm_status arm_conv_partial_fast_q15(
3209 q15_t * pSrcA,
3210 uint32_t srcALen,
3211 q15_t * pSrcB,
3212 uint32_t srcBLen,
3213 q15_t * pDst,
3214 uint32_t firstIndex,
3215 uint32_t numPoints);
3216
3217
3218 /**
3219 * @brief Partial convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4
3220 * @param[in] pSrcA points to the first input sequence.
3221 * @param[in] srcALen length of the first input sequence.
3222 * @param[in] pSrcB points to the second input sequence.
3223 * @param[in] srcBLen length of the second input sequence.
3224 * @param[out] pDst points to the block of output data
3225 * @param[in] firstIndex is the first output sample to start with.
3226 * @param[in] numPoints is the number of output points to be computed.
3227 * @param[in] pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
3228 * @param[in] pScratch2 points to scratch buffer of size min(srcALen, srcBLen).
3229 * @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].
3230 */
3231 arm_status arm_conv_partial_fast_opt_q15(
3232 q15_t * pSrcA,
3233 uint32_t srcALen,
3234 q15_t * pSrcB,
3235 uint32_t srcBLen,
3236 q15_t * pDst,
3237 uint32_t firstIndex,
3238 uint32_t numPoints,
3239 q15_t * pScratch1,
3240 q15_t * pScratch2);
3241
3242
3243 /**
3244 * @brief Partial convolution of Q31 sequences.
3245 * @param[in] pSrcA points to the first input sequence.
3246 * @param[in] srcALen length of the first input sequence.
3247 * @param[in] pSrcB points to the second input sequence.
3248 * @param[in] srcBLen length of the second input sequence.
3249 * @param[out] pDst points to the block of output data
3250 * @param[in] firstIndex is the first output sample to start with.
3251 * @param[in] numPoints is the number of output points to be computed.
3252 * @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].
3253 */
3254 arm_status arm_conv_partial_q31(
3255 q31_t * pSrcA,
3256 uint32_t srcALen,
3257 q31_t * pSrcB,
3258 uint32_t srcBLen,
3259 q31_t * pDst,
3260 uint32_t firstIndex,
3261 uint32_t numPoints);
3262
3263
3264 /**
3265 * @brief Partial convolution of Q31 sequences (fast version) for Cortex-M3 and Cortex-M4
3266 * @param[in] pSrcA points to the first input sequence.
3267 * @param[in] srcALen length of the first input sequence.
3268 * @param[in] pSrcB points to the second input sequence.
3269 * @param[in] srcBLen length of the second input sequence.
3270 * @param[out] pDst points to the block of output data
3271 * @param[in] firstIndex is the first output sample to start with.
3272 * @param[in] numPoints is the number of output points to be computed.
3273 * @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].
3274 */
3275 arm_status arm_conv_partial_fast_q31(
3276 q31_t * pSrcA,
3277 uint32_t srcALen,
3278 q31_t * pSrcB,
3279 uint32_t srcBLen,
3280 q31_t * pDst,
3281 uint32_t firstIndex,
3282 uint32_t numPoints);
3283
3284
3285 /**
3286 * @brief Partial convolution of Q7 sequences
3287 * @param[in] pSrcA points to the first input sequence.
3288 * @param[in] srcALen length of the first input sequence.
3289 * @param[in] pSrcB points to the second input sequence.
3290 * @param[in] srcBLen length of the second input sequence.
3291 * @param[out] pDst points to the block of output data
3292 * @param[in] firstIndex is the first output sample to start with.
3293 * @param[in] numPoints is the number of output points to be computed.
3294 * @param[in] pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
3295 * @param[in] pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen).
3296 * @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].
3297 */
3298 arm_status arm_conv_partial_opt_q7(
3299 q7_t * pSrcA,
3300 uint32_t srcALen,
3301 q7_t * pSrcB,
3302 uint32_t srcBLen,
3303 q7_t * pDst,
3304 uint32_t firstIndex,
3305 uint32_t numPoints,
3306 q15_t * pScratch1,
3307 q15_t * pScratch2);
3308
3309
3310/**
3311 * @brief Partial convolution of Q7 sequences.
3312 * @param[in] pSrcA points to the first input sequence.
3313 * @param[in] srcALen length of the first input sequence.
3314 * @param[in] pSrcB points to the second input sequence.
3315 * @param[in] srcBLen length of the second input sequence.
3316 * @param[out] pDst points to the block of output data
3317 * @param[in] firstIndex is the first output sample to start with.
3318 * @param[in] numPoints is the number of output points to be computed.
3319 * @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].
3320 */
3321 arm_status arm_conv_partial_q7(
3322 q7_t * pSrcA,
3323 uint32_t srcALen,
3324 q7_t * pSrcB,
3325 uint32_t srcBLen,
3326 q7_t * pDst,
3327 uint32_t firstIndex,
3328 uint32_t numPoints);
3329
3330
3331 /**
3332 * @brief Instance structure for the Q15 FIR decimator.
3333 */
3334 typedef struct
3335 {
3336 uint8_t M; /**< decimation factor. */
3337 uint16_t numTaps; /**< number of coefficients in the filter. */
3338 q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
3339 q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
3340 } arm_fir_decimate_instance_q15;
3341
3342 /**
3343 * @brief Instance structure for the Q31 FIR decimator.
3344 */
3345 typedef struct
3346 {
3347 uint8_t M; /**< decimation factor. */
3348 uint16_t numTaps; /**< number of coefficients in the filter. */
3349 q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
3350 q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
3351 } arm_fir_decimate_instance_q31;
3352
3353 /**
3354 * @brief Instance structure for the floating-point FIR decimator.
3355 */
3356 typedef struct
3357 {
3358 uint8_t M; /**< decimation factor. */
3359 uint16_t numTaps; /**< number of coefficients in the filter. */
3360 float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
3361 float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
3362 } arm_fir_decimate_instance_f32;
3363
3364
3365 /**
3366 * @brief Processing function for the floating-point FIR decimator.
3367 * @param[in] S points to an instance of the floating-point FIR decimator structure.
3368 * @param[in] pSrc points to the block of input data.
3369 * @param[out] pDst points to the block of output data
3370 * @param[in] blockSize number of input samples to process per call.
3371 */
3372 void arm_fir_decimate_f32(
3373 const arm_fir_decimate_instance_f32 * S,
3374 float32_t * pSrc,
3375 float32_t * pDst,
3376 uint32_t blockSize);
3377
3378
3379 /**
3380 * @brief Initialization function for the floating-point FIR decimator.
3381 * @param[in,out] S points to an instance of the floating-point FIR decimator structure.
3382 * @param[in] numTaps number of coefficients in the filter.
3383 * @param[in] M decimation factor.
3384 * @param[in] pCoeffs points to the filter coefficients.
3385 * @param[in] pState points to the state buffer.
3386 * @param[in] blockSize number of input samples to process per call.
3387 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
3388 * <code>blockSize</code> is not a multiple of <code>M</code>.
3389 */
3390 arm_status arm_fir_decimate_init_f32(
3391 arm_fir_decimate_instance_f32 * S,
3392 uint16_t numTaps,
3393 uint8_t M,
3394 float32_t * pCoeffs,
3395 float32_t * pState,
3396 uint32_t blockSize);
3397
3398
3399 /**
3400 * @brief Processing function for the Q15 FIR decimator.
3401 * @param[in] S points to an instance of the Q15 FIR decimator structure.
3402 * @param[in] pSrc points to the block of input data.
3403 * @param[out] pDst points to the block of output data
3404 * @param[in] blockSize number of input samples to process per call.
3405 */
3406 void arm_fir_decimate_q15(
3407 const arm_fir_decimate_instance_q15 * S,
3408 q15_t * pSrc,
3409 q15_t * pDst,
3410 uint32_t blockSize);
3411
3412
3413 /**
3414 * @brief Processing function for the Q15 FIR decimator (fast variant) for Cortex-M3 and Cortex-M4.
3415 * @param[in] S points to an instance of the Q15 FIR decimator structure.
3416 * @param[in] pSrc points to the block of input data.
3417 * @param[out] pDst points to the block of output data
3418 * @param[in] blockSize number of input samples to process per call.
3419 */
3420 void arm_fir_decimate_fast_q15(
3421 const arm_fir_decimate_instance_q15 * S,
3422 q15_t * pSrc,
3423 q15_t * pDst,
3424 uint32_t blockSize);
3425
3426
3427 /**
3428 * @brief Initialization function for the Q15 FIR decimator.
3429 * @param[in,out] S points to an instance of the Q15 FIR decimator structure.
3430 * @param[in] numTaps number of coefficients in the filter.
3431 * @param[in] M decimation factor.
3432 * @param[in] pCoeffs points to the filter coefficients.
3433 * @param[in] pState points to the state buffer.
3434 * @param[in] blockSize number of input samples to process per call.
3435 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
3436 * <code>blockSize</code> is not a multiple of <code>M</code>.
3437 */
3438 arm_status arm_fir_decimate_init_q15(
3439 arm_fir_decimate_instance_q15 * S,
3440 uint16_t numTaps,
3441 uint8_t M,
3442 q15_t * pCoeffs,
3443 q15_t * pState,
3444 uint32_t blockSize);
3445
3446
3447 /**
3448 * @brief Processing function for the Q31 FIR decimator.
3449 * @param[in] S points to an instance of the Q31 FIR decimator structure.
3450 * @param[in] pSrc points to the block of input data.
3451 * @param[out] pDst points to the block of output data
3452 * @param[in] blockSize number of input samples to process per call.
3453 */
3454 void arm_fir_decimate_q31(
3455 const arm_fir_decimate_instance_q31 * S,
3456 q31_t * pSrc,
3457 q31_t * pDst,
3458 uint32_t blockSize);
3459
3460 /**
3461 * @brief Processing function for the Q31 FIR decimator (fast variant) for Cortex-M3 and Cortex-M4.
3462 * @param[in] S points to an instance of the Q31 FIR decimator structure.
3463 * @param[in] pSrc points to the block of input data.
3464 * @param[out] pDst points to the block of output data
3465 * @param[in] blockSize number of input samples to process per call.
3466 */
3467 void arm_fir_decimate_fast_q31(
3468 arm_fir_decimate_instance_q31 * S,
3469 q31_t * pSrc,
3470 q31_t * pDst,
3471 uint32_t blockSize);
3472
3473
3474 /**
3475 * @brief Initialization function for the Q31 FIR decimator.
3476 * @param[in,out] S points to an instance of the Q31 FIR decimator structure.
3477 * @param[in] numTaps number of coefficients in the filter.
3478 * @param[in] M decimation factor.
3479 * @param[in] pCoeffs points to the filter coefficients.
3480 * @param[in] pState points to the state buffer.
3481 * @param[in] blockSize number of input samples to process per call.
3482 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
3483 * <code>blockSize</code> is not a multiple of <code>M</code>.
3484 */
3485 arm_status arm_fir_decimate_init_q31(
3486 arm_fir_decimate_instance_q31 * S,
3487 uint16_t numTaps,
3488 uint8_t M,
3489 q31_t * pCoeffs,
3490 q31_t * pState,
3491 uint32_t blockSize);
3492
3493
3494 /**
3495 * @brief Instance structure for the Q15 FIR interpolator.
3496 */
3497 typedef struct
3498 {
3499 uint8_t L; /**< upsample factor. */
3500 uint16_t phaseLength; /**< length of each polyphase filter component. */
3501 q15_t *pCoeffs; /**< points to the coefficient array. The array is of length L*phaseLength. */
3502 q15_t *pState; /**< points to the state variable array. The array is of length blockSize+phaseLength-1. */
3503 } arm_fir_interpolate_instance_q15;
3504
3505 /**
3506 * @brief Instance structure for the Q31 FIR interpolator.
3507 */
3508 typedef struct
3509 {
3510 uint8_t L; /**< upsample factor. */
3511 uint16_t phaseLength; /**< length of each polyphase filter component. */
3512 q31_t *pCoeffs; /**< points to the coefficient array. The array is of length L*phaseLength. */
3513 q31_t *pState; /**< points to the state variable array. The array is of length blockSize+phaseLength-1. */
3514 } arm_fir_interpolate_instance_q31;
3515
3516 /**
3517 * @brief Instance structure for the floating-point FIR interpolator.
3518 */
3519 typedef struct
3520 {
3521 uint8_t L; /**< upsample factor. */
3522 uint16_t phaseLength; /**< length of each polyphase filter component. */
3523 float32_t *pCoeffs; /**< points to the coefficient array. The array is of length L*phaseLength. */
3524 float32_t *pState; /**< points to the state variable array. The array is of length phaseLength+numTaps-1. */
3525 } arm_fir_interpolate_instance_f32;
3526
3527
3528 /**
3529 * @brief Processing function for the Q15 FIR interpolator.
3530 * @param[in] S points to an instance of the Q15 FIR interpolator structure.
3531 * @param[in] pSrc points to the block of input data.
3532 * @param[out] pDst points to the block of output data.
3533 * @param[in] blockSize number of input samples to process per call.
3534 */
3535 void arm_fir_interpolate_q15(
3536 const arm_fir_interpolate_instance_q15 * S,
3537 q15_t * pSrc,
3538 q15_t * pDst,
3539 uint32_t blockSize);
3540
3541
3542 /**
3543 * @brief Initialization function for the Q15 FIR interpolator.
3544 * @param[in,out] S points to an instance of the Q15 FIR interpolator structure.
3545 * @param[in] L upsample factor.
3546 * @param[in] numTaps number of filter coefficients in the filter.
3547 * @param[in] pCoeffs points to the filter coefficient buffer.
3548 * @param[in] pState points to the state buffer.
3549 * @param[in] blockSize number of input samples to process per call.
3550 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
3551 * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>.
3552 */
3553 arm_status arm_fir_interpolate_init_q15(
3554 arm_fir_interpolate_instance_q15 * S,
3555 uint8_t L,
3556 uint16_t numTaps,
3557 q15_t * pCoeffs,
3558 q15_t * pState,
3559 uint32_t blockSize);
3560
3561
3562 /**
3563 * @brief Processing function for the Q31 FIR interpolator.
3564 * @param[in] S points to an instance of the Q15 FIR interpolator structure.
3565 * @param[in] pSrc points to the block of input data.
3566 * @param[out] pDst points to the block of output data.
3567 * @param[in] blockSize number of input samples to process per call.
3568 */
3569 void arm_fir_interpolate_q31(
3570 const arm_fir_interpolate_instance_q31 * S,
3571 q31_t * pSrc,
3572 q31_t * pDst,
3573 uint32_t blockSize);
3574
3575
3576 /**
3577 * @brief Initialization function for the Q31 FIR interpolator.
3578 * @param[in,out] S points to an instance of the Q31 FIR interpolator structure.
3579 * @param[in] L upsample factor.
3580 * @param[in] numTaps number of filter coefficients in the filter.
3581 * @param[in] pCoeffs points to the filter coefficient buffer.
3582 * @param[in] pState points to the state buffer.
3583 * @param[in] blockSize number of input samples to process per call.
3584 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
3585 * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>.
3586 */
3587 arm_status arm_fir_interpolate_init_q31(
3588 arm_fir_interpolate_instance_q31 * S,
3589 uint8_t L,
3590 uint16_t numTaps,
3591 q31_t * pCoeffs,
3592 q31_t * pState,
3593 uint32_t blockSize);
3594
3595
3596 /**
3597 * @brief Processing function for the floating-point FIR interpolator.
3598 * @param[in] S points to an instance of the floating-point FIR interpolator structure.
3599 * @param[in] pSrc points to the block of input data.
3600 * @param[out] pDst points to the block of output data.
3601 * @param[in] blockSize number of input samples to process per call.
3602 */
3603 void arm_fir_interpolate_f32(
3604 const arm_fir_interpolate_instance_f32 * S,
3605 float32_t * pSrc,
3606 float32_t * pDst,
3607 uint32_t blockSize);
3608
3609
3610 /**
3611 * @brief Initialization function for the floating-point FIR interpolator.
3612 * @param[in,out] S points to an instance of the floating-point FIR interpolator structure.
3613 * @param[in] L upsample factor.
3614 * @param[in] numTaps number of filter coefficients in the filter.
3615 * @param[in] pCoeffs points to the filter coefficient buffer.
3616 * @param[in] pState points to the state buffer.
3617 * @param[in] blockSize number of input samples to process per call.
3618 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
3619 * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>.
3620 */
3621 arm_status arm_fir_interpolate_init_f32(
3622 arm_fir_interpolate_instance_f32 * S,
3623 uint8_t L,
3624 uint16_t numTaps,
3625 float32_t * pCoeffs,
3626 float32_t * pState,
3627 uint32_t blockSize);
3628
3629
3630 /**
3631 * @brief Instance structure for the high precision Q31 Biquad cascade filter.
3632 */
3633 typedef struct
3634 {
3635 uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
3636 q63_t *pState; /**< points to the array of state coefficients. The array is of length 4*numStages. */
3637 q31_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */
3638 uint8_t postShift; /**< additional shift, in bits, applied to each output sample. */
3639 } arm_biquad_cas_df1_32x64_ins_q31;
3640
3641
3642 /**
3643 * @param[in] S points to an instance of the high precision Q31 Biquad cascade filter structure.
3644 * @param[in] pSrc points to the block of input data.
3645 * @param[out] pDst points to the block of output data
3646 * @param[in] blockSize number of samples to process.
3647 */
3648 void arm_biquad_cas_df1_32x64_q31(
3649 const arm_biquad_cas_df1_32x64_ins_q31 * S,
3650 q31_t * pSrc,
3651 q31_t * pDst,
3652 uint32_t blockSize);
3653
3654
3655 /**
3656 * @param[in,out] S points to an instance of the high precision Q31 Biquad cascade filter structure.
3657 * @param[in] numStages number of 2nd order stages in the filter.
3658 * @param[in] pCoeffs points to the filter coefficients.
3659 * @param[in] pState points to the state buffer.
3660 * @param[in] postShift shift to be applied to the output. Varies according to the coefficients format
3661 */
3662 void arm_biquad_cas_df1_32x64_init_q31(
3663 arm_biquad_cas_df1_32x64_ins_q31 * S,
3664 uint8_t numStages,
3665 q31_t * pCoeffs,
3666 q63_t * pState,
3667 uint8_t postShift);
3668
3669
3670 /**
3671 * @brief Instance structure for the floating-point transposed direct form II Biquad cascade filter.
3672 */
3673 typedef struct
3674 {
3675 uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
3676 float32_t *pState; /**< points to the array of state coefficients. The array is of length 2*numStages. */
3677 float32_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */
3678 } arm_biquad_cascade_df2T_instance_f32;
3679
3680 /**
3681 * @brief Instance structure for the floating-point transposed direct form II Biquad cascade filter.
3682 */
3683 typedef struct
3684 {
3685 uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
3686 float32_t *pState; /**< points to the array of state coefficients. The array is of length 4*numStages. */
3687 float32_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */
3688 } arm_biquad_cascade_stereo_df2T_instance_f32;
3689
3690 /**
3691 * @brief Instance structure for the floating-point transposed direct form II Biquad cascade filter.
3692 */
3693 typedef struct
3694 {
3695 uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
3696 float64_t *pState; /**< points to the array of state coefficients. The array is of length 2*numStages. */
3697 float64_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */
3698 } arm_biquad_cascade_df2T_instance_f64;
3699
3700
3701 /**
3702 * @brief Processing function for the floating-point transposed direct form II Biquad cascade filter.
3703 * @param[in] S points to an instance of the filter data structure.
3704 * @param[in] pSrc points to the block of input data.
3705 * @param[out] pDst points to the block of output data
3706 * @param[in] blockSize number of samples to process.
3707 */
3708 void arm_biquad_cascade_df2T_f32(
3709 const arm_biquad_cascade_df2T_instance_f32 * S,
3710 float32_t * pSrc,
3711 float32_t * pDst,
3712 uint32_t blockSize);
3713
3714
3715 /**
3716 * @brief Processing function for the floating-point transposed direct form II Biquad cascade filter. 2 channels
3717 * @param[in] S points to an instance of the filter data structure.
3718 * @param[in] pSrc points to the block of input data.
3719 * @param[out] pDst points to the block of output data
3720 * @param[in] blockSize number of samples to process.
3721 */
3722 void arm_biquad_cascade_stereo_df2T_f32(
3723 const arm_biquad_cascade_stereo_df2T_instance_f32 * S,
3724 float32_t * pSrc,
3725 float32_t * pDst,
3726 uint32_t blockSize);
3727
3728
3729 /**
3730 * @brief Processing function for the floating-point transposed direct form II Biquad cascade filter.
3731 * @param[in] S points to an instance of the filter data structure.
3732 * @param[in] pSrc points to the block of input data.
3733 * @param[out] pDst points to the block of output data
3734 * @param[in] blockSize number of samples to process.
3735 */
3736 void arm_biquad_cascade_df2T_f64(
3737 const arm_biquad_cascade_df2T_instance_f64 * S,
3738 float64_t * pSrc,
3739 float64_t * pDst,
3740 uint32_t blockSize);
3741
3742
3743 /**
3744 * @brief Initialization function for the floating-point transposed direct form II Biquad cascade filter.
3745 * @param[in,out] S points to an instance of the filter data structure.
3746 * @param[in] numStages number of 2nd order stages in the filter.
3747 * @param[in] pCoeffs points to the filter coefficients.
3748 * @param[in] pState points to the state buffer.
3749 */
3750 void arm_biquad_cascade_df2T_init_f32(
3751 arm_biquad_cascade_df2T_instance_f32 * S,
3752 uint8_t numStages,
3753 float32_t * pCoeffs,
3754 float32_t * pState);
3755
3756
3757 /**
3758 * @brief Initialization function for the floating-point transposed direct form II Biquad cascade filter.
3759 * @param[in,out] S points to an instance of the filter data structure.
3760 * @param[in] numStages number of 2nd order stages in the filter.
3761 * @param[in] pCoeffs points to the filter coefficients.
3762 * @param[in] pState points to the state buffer.
3763 */
3764 void arm_biquad_cascade_stereo_df2T_init_f32(
3765 arm_biquad_cascade_stereo_df2T_instance_f32 * S,
3766 uint8_t numStages,
3767 float32_t * pCoeffs,
3768 float32_t * pState);
3769
3770
3771 /**
3772 * @brief Initialization function for the floating-point transposed direct form II Biquad cascade filter.
3773 * @param[in,out] S points to an instance of the filter data structure.
3774 * @param[in] numStages number of 2nd order stages in the filter.
3775 * @param[in] pCoeffs points to the filter coefficients.
3776 * @param[in] pState points to the state buffer.
3777 */
3778 void arm_biquad_cascade_df2T_init_f64(
3779 arm_biquad_cascade_df2T_instance_f64 * S,
3780 uint8_t numStages,
3781 float64_t * pCoeffs,
3782 float64_t * pState);
3783
3784
3785 /**
3786 * @brief Instance structure for the Q15 FIR lattice filter.
3787 */
3788 typedef struct
3789 {
3790 uint16_t numStages; /**< number of filter stages. */
3791 q15_t *pState; /**< points to the state variable array. The array is of length numStages. */
3792 q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numStages. */
3793 } arm_fir_lattice_instance_q15;
3794
3795 /**
3796 * @brief Instance structure for the Q31 FIR lattice filter.
3797 */
3798 typedef struct
3799 {
3800 uint16_t numStages; /**< number of filter stages. */
3801 q31_t *pState; /**< points to the state variable array. The array is of length numStages. */
3802 q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numStages. */
3803 } arm_fir_lattice_instance_q31;
3804
3805 /**
3806 * @brief Instance structure for the floating-point FIR lattice filter.
3807 */
3808 typedef struct
3809 {
3810 uint16_t numStages; /**< number of filter stages. */
3811 float32_t *pState; /**< points to the state variable array. The array is of length numStages. */
3812 float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numStages. */
3813 } arm_fir_lattice_instance_f32;
3814
3815
3816 /**
3817 * @brief Initialization function for the Q15 FIR lattice filter.
3818 * @param[in] S points to an instance of the Q15 FIR lattice structure.
3819 * @param[in] numStages number of filter stages.
3820 * @param[in] pCoeffs points to the coefficient buffer. The array is of length numStages.
3821 * @param[in] pState points to the state buffer. The array is of length numStages.
3822 */
3823 void arm_fir_lattice_init_q15(
3824 arm_fir_lattice_instance_q15 * S,
3825 uint16_t numStages,
3826 q15_t * pCoeffs,
3827 q15_t * pState);
3828
3829
3830 /**
3831 * @brief Processing function for the Q15 FIR lattice filter.
3832 * @param[in] S points to an instance of the Q15 FIR lattice structure.
3833 * @param[in] pSrc points to the block of input data.
3834 * @param[out] pDst points to the block of output data.
3835 * @param[in] blockSize number of samples to process.
3836 */
3837 void arm_fir_lattice_q15(
3838 const arm_fir_lattice_instance_q15 * S,
3839 q15_t * pSrc,
3840 q15_t * pDst,
3841 uint32_t blockSize);
3842
3843
3844 /**
3845 * @brief Initialization function for the Q31 FIR lattice filter.
3846 * @param[in] S points to an instance of the Q31 FIR lattice structure.
3847 * @param[in] numStages number of filter stages.
3848 * @param[in] pCoeffs points to the coefficient buffer. The array is of length numStages.
3849 * @param[in] pState points to the state buffer. The array is of length numStages.
3850 */
3851 void arm_fir_lattice_init_q31(
3852 arm_fir_lattice_instance_q31 * S,
3853 uint16_t numStages,
3854 q31_t * pCoeffs,
3855 q31_t * pState);
3856
3857
3858 /**
3859 * @brief Processing function for the Q31 FIR lattice filter.
3860 * @param[in] S points to an instance of the Q31 FIR lattice structure.
3861 * @param[in] pSrc points to the block of input data.
3862 * @param[out] pDst points to the block of output data
3863 * @param[in] blockSize number of samples to process.
3864 */
3865 void arm_fir_lattice_q31(
3866 const arm_fir_lattice_instance_q31 * S,
3867 q31_t * pSrc,
3868 q31_t * pDst,
3869 uint32_t blockSize);
3870
3871
3872/**
3873 * @brief Initialization function for the floating-point FIR lattice filter.
3874 * @param[in] S points to an instance of the floating-point FIR lattice structure.
3875 * @param[in] numStages number of filter stages.
3876 * @param[in] pCoeffs points to the coefficient buffer. The array is of length numStages.
3877 * @param[in] pState points to the state buffer. The array is of length numStages.
3878 */
3879 void arm_fir_lattice_init_f32(
3880 arm_fir_lattice_instance_f32 * S,
3881 uint16_t numStages,
3882 float32_t * pCoeffs,
3883 float32_t * pState);
3884
3885
3886 /**
3887 * @brief Processing function for the floating-point FIR lattice filter.
3888 * @param[in] S points to an instance of the floating-point FIR lattice structure.
3889 * @param[in] pSrc points to the block of input data.
3890 * @param[out] pDst points to the block of output data
3891 * @param[in] blockSize number of samples to process.
3892 */
3893 void arm_fir_lattice_f32(
3894 const arm_fir_lattice_instance_f32 * S,
3895 float32_t * pSrc,
3896 float32_t * pDst,
3897 uint32_t blockSize);
3898
3899
3900 /**
3901 * @brief Instance structure for the Q15 IIR lattice filter.
3902 */
3903 typedef struct
3904 {
3905 uint16_t numStages; /**< number of stages in the filter. */
3906 q15_t *pState; /**< points to the state variable array. The array is of length numStages+blockSize. */
3907 q15_t *pkCoeffs; /**< points to the reflection coefficient array. The array is of length numStages. */
3908 q15_t *pvCoeffs; /**< points to the ladder coefficient array. The array is of length numStages+1. */
3909 } arm_iir_lattice_instance_q15;
3910
3911 /**
3912 * @brief Instance structure for the Q31 IIR lattice filter.
3913 */
3914 typedef struct
3915 {
3916 uint16_t numStages; /**< number of stages in the filter. */
3917 q31_t *pState; /**< points to the state variable array. The array is of length numStages+blockSize. */
3918 q31_t *pkCoeffs; /**< points to the reflection coefficient array. The array is of length numStages. */
3919 q31_t *pvCoeffs; /**< points to the ladder coefficient array. The array is of length numStages+1. */
3920 } arm_iir_lattice_instance_q31;
3921
3922 /**
3923 * @brief Instance structure for the floating-point IIR lattice filter.
3924 */
3925 typedef struct
3926 {
3927 uint16_t numStages; /**< number of stages in the filter. */
3928 float32_t *pState; /**< points to the state variable array. The array is of length numStages+blockSize. */
3929 float32_t *pkCoeffs; /**< points to the reflection coefficient array. The array is of length numStages. */
3930 float32_t *pvCoeffs; /**< points to the ladder coefficient array. The array is of length numStages+1. */
3931 } arm_iir_lattice_instance_f32;
3932
3933
3934 /**
3935 * @brief Processing function for the floating-point IIR lattice filter.
3936 * @param[in] S points to an instance of the floating-point IIR lattice structure.
3937 * @param[in] pSrc points to the block of input data.
3938 * @param[out] pDst points to the block of output data.
3939 * @param[in] blockSize number of samples to process.
3940 */
3941 void arm_iir_lattice_f32(
3942 const arm_iir_lattice_instance_f32 * S,
3943 float32_t * pSrc,
3944 float32_t * pDst,
3945 uint32_t blockSize);
3946
3947
3948 /**
3949 * @brief Initialization function for the floating-point IIR lattice filter.
3950 * @param[in] S points to an instance of the floating-point IIR lattice structure.
3951 * @param[in] numStages number of stages in the filter.
3952 * @param[in] pkCoeffs points to the reflection coefficient buffer. The array is of length numStages.
3953 * @param[in] pvCoeffs points to the ladder coefficient buffer. The array is of length numStages+1.
3954 * @param[in] pState points to the state buffer. The array is of length numStages+blockSize-1.
3955 * @param[in] blockSize number of samples to process.
3956 */
3957 void arm_iir_lattice_init_f32(
3958 arm_iir_lattice_instance_f32 * S,
3959 uint16_t numStages,
3960 float32_t * pkCoeffs,
3961 float32_t * pvCoeffs,
3962 float32_t * pState,
3963 uint32_t blockSize);
3964
3965
3966 /**
3967 * @brief Processing function for the Q31 IIR lattice filter.
3968 * @param[in] S points to an instance of the Q31 IIR lattice structure.
3969 * @param[in] pSrc points to the block of input data.
3970 * @param[out] pDst points to the block of output data.
3971 * @param[in] blockSize number of samples to process.
3972 */
3973 void arm_iir_lattice_q31(
3974 const arm_iir_lattice_instance_q31 * S,
3975 q31_t * pSrc,
3976 q31_t * pDst,
3977 uint32_t blockSize);
3978
3979
3980 /**
3981 * @brief Initialization function for the Q31 IIR lattice filter.
3982 * @param[in] S points to an instance of the Q31 IIR lattice structure.
3983 * @param[in] numStages number of stages in the filter.
3984 * @param[in] pkCoeffs points to the reflection coefficient buffer. The array is of length numStages.
3985 * @param[in] pvCoeffs points to the ladder coefficient buffer. The array is of length numStages+1.
3986 * @param[in] pState points to the state buffer. The array is of length numStages+blockSize.
3987 * @param[in] blockSize number of samples to process.
3988 */
3989 void arm_iir_lattice_init_q31(
3990 arm_iir_lattice_instance_q31 * S,
3991 uint16_t numStages,
3992 q31_t * pkCoeffs,
3993 q31_t * pvCoeffs,
3994 q31_t * pState,
3995 uint32_t blockSize);
3996
3997
3998 /**
3999 * @brief Processing function for the Q15 IIR lattice filter.
4000 * @param[in] S points to an instance of the Q15 IIR lattice structure.
4001 * @param[in] pSrc points to the block of input data.
4002 * @param[out] pDst points to the block of output data.
4003 * @param[in] blockSize number of samples to process.
4004 */
4005 void arm_iir_lattice_q15(
4006 const arm_iir_lattice_instance_q15 * S,
4007 q15_t * pSrc,
4008 q15_t * pDst,
4009 uint32_t blockSize);
4010
4011
4012/**
4013 * @brief Initialization function for the Q15 IIR lattice filter.
4014 * @param[in] S points to an instance of the fixed-point Q15 IIR lattice structure.
4015 * @param[in] numStages number of stages in the filter.
4016 * @param[in] pkCoeffs points to reflection coefficient buffer. The array is of length numStages.
4017 * @param[in] pvCoeffs points to ladder coefficient buffer. The array is of length numStages+1.
4018 * @param[in] pState points to state buffer. The array is of length numStages+blockSize.
4019 * @param[in] blockSize number of samples to process per call.
4020 */
4021 void arm_iir_lattice_init_q15(
4022 arm_iir_lattice_instance_q15 * S,
4023 uint16_t numStages,
4024 q15_t * pkCoeffs,
4025 q15_t * pvCoeffs,
4026 q15_t * pState,
4027 uint32_t blockSize);
4028
4029
4030 /**
4031 * @brief Instance structure for the floating-point LMS filter.
4032 */
4033 typedef struct
4034 {
4035 uint16_t numTaps; /**< number of coefficients in the filter. */
4036 float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
4037 float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
4038 float32_t mu; /**< step size that controls filter coefficient updates. */
4039 } arm_lms_instance_f32;
4040
4041
4042 /**
4043 * @brief Processing function for floating-point LMS filter.
4044 * @param[in] S points to an instance of the floating-point LMS filter structure.
4045 * @param[in] pSrc points to the block of input data.
4046 * @param[in] pRef points to the block of reference data.
4047 * @param[out] pOut points to the block of output data.
4048 * @param[out] pErr points to the block of error data.
4049 * @param[in] blockSize number of samples to process.
4050 */
4051 void arm_lms_f32(
4052 const arm_lms_instance_f32 * S,
4053 float32_t * pSrc,
4054 float32_t * pRef,
4055 float32_t * pOut,
4056 float32_t * pErr,
4057 uint32_t blockSize);
4058
4059
4060 /**
4061 * @brief Initialization function for floating-point LMS filter.
4062 * @param[in] S points to an instance of the floating-point LMS filter structure.
4063 * @param[in] numTaps number of filter coefficients.
4064 * @param[in] pCoeffs points to the coefficient buffer.
4065 * @param[in] pState points to state buffer.
4066 * @param[in] mu step size that controls filter coefficient updates.
4067 * @param[in] blockSize number of samples to process.
4068 */
4069 void arm_lms_init_f32(
4070 arm_lms_instance_f32 * S,
4071 uint16_t numTaps,
4072 float32_t * pCoeffs,
4073 float32_t * pState,
4074 float32_t mu,
4075 uint32_t blockSize);
4076
4077
4078 /**
4079 * @brief Instance structure for the Q15 LMS filter.
4080 */
4081 typedef struct
4082 {
4083 uint16_t numTaps; /**< number of coefficients in the filter. */
4084 q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
4085 q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
4086 q15_t mu; /**< step size that controls filter coefficient updates. */
4087 uint32_t postShift; /**< bit shift applied to coefficients. */
4088 } arm_lms_instance_q15;
4089
4090
4091 /**
4092 * @brief Initialization function for the Q15 LMS filter.
4093 * @param[in] S points to an instance of the Q15 LMS filter structure.
4094 * @param[in] numTaps number of filter coefficients.
4095 * @param[in] pCoeffs points to the coefficient buffer.
4096 * @param[in] pState points to the state buffer.
4097 * @param[in] mu step size that controls filter coefficient updates.
4098 * @param[in] blockSize number of samples to process.
4099 * @param[in] postShift bit shift applied to coefficients.
4100 */
4101 void arm_lms_init_q15(
4102 arm_lms_instance_q15 * S,
4103 uint16_t numTaps,
4104 q15_t * pCoeffs,
4105 q15_t * pState,
4106 q15_t mu,
4107 uint32_t blockSize,
4108 uint32_t postShift);
4109
4110
4111 /**
4112 * @brief Processing function for Q15 LMS filter.
4113 * @param[in] S points to an instance of the Q15 LMS filter structure.
4114 * @param[in] pSrc points to the block of input data.
4115 * @param[in] pRef points to the block of reference data.
4116 * @param[out] pOut points to the block of output data.
4117 * @param[out] pErr points to the block of error data.
4118 * @param[in] blockSize number of samples to process.
4119 */
4120 void arm_lms_q15(
4121 const arm_lms_instance_q15 * S,
4122 q15_t * pSrc,
4123 q15_t * pRef,
4124 q15_t * pOut,
4125 q15_t * pErr,
4126 uint32_t blockSize);
4127
4128
4129 /**
4130 * @brief Instance structure for the Q31 LMS filter.
4131 */
4132 typedef struct
4133 {
4134 uint16_t numTaps; /**< number of coefficients in the filter. */
4135 q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
4136 q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
4137 q31_t mu; /**< step size that controls filter coefficient updates. */
4138 uint32_t postShift; /**< bit shift applied to coefficients. */
4139 } arm_lms_instance_q31;
4140
4141
4142 /**
4143 * @brief Processing function for Q31 LMS filter.
4144 * @param[in] S points to an instance of the Q15 LMS filter structure.
4145 * @param[in] pSrc points to the block of input data.
4146 * @param[in] pRef points to the block of reference data.
4147 * @param[out] pOut points to the block of output data.
4148 * @param[out] pErr points to the block of error data.
4149 * @param[in] blockSize number of samples to process.
4150 */
4151 void arm_lms_q31(
4152 const arm_lms_instance_q31 * S,
4153 q31_t * pSrc,
4154 q31_t * pRef,
4155 q31_t * pOut,
4156 q31_t * pErr,
4157 uint32_t blockSize);
4158
4159
4160 /**
4161 * @brief Initialization function for Q31 LMS filter.
4162 * @param[in] S points to an instance of the Q31 LMS filter structure.
4163 * @param[in] numTaps number of filter coefficients.
4164 * @param[in] pCoeffs points to coefficient buffer.
4165 * @param[in] pState points to state buffer.
4166 * @param[in] mu step size that controls filter coefficient updates.
4167 * @param[in] blockSize number of samples to process.
4168 * @param[in] postShift bit shift applied to coefficients.
4169 */
4170 void arm_lms_init_q31(
4171 arm_lms_instance_q31 * S,
4172 uint16_t numTaps,
4173 q31_t * pCoeffs,
4174 q31_t * pState,
4175 q31_t mu,
4176 uint32_t blockSize,
4177 uint32_t postShift);
4178
4179
4180 /**
4181 * @brief Instance structure for the floating-point normalized LMS filter.
4182 */
4183 typedef struct
4184 {
4185 uint16_t numTaps; /**< number of coefficients in the filter. */
4186 float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
4187 float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
4188 float32_t mu; /**< step size that control filter coefficient updates. */
4189 float32_t energy; /**< saves previous frame energy. */
4190 float32_t x0; /**< saves previous input sample. */
4191 } arm_lms_norm_instance_f32;
4192
4193
4194 /**
4195 * @brief Processing function for floating-point normalized LMS filter.
4196 * @param[in] S points to an instance of the floating-point normalized LMS filter structure.
4197 * @param[in] pSrc points to the block of input data.
4198 * @param[in] pRef points to the block of reference data.
4199 * @param[out] pOut points to the block of output data.
4200 * @param[out] pErr points to the block of error data.
4201 * @param[in] blockSize number of samples to process.
4202 */
4203 void arm_lms_norm_f32(
4204 arm_lms_norm_instance_f32 * S,
4205 float32_t * pSrc,
4206 float32_t * pRef,
4207 float32_t * pOut,
4208 float32_t * pErr,
4209 uint32_t blockSize);
4210
4211
4212 /**
4213 * @brief Initialization function for floating-point normalized LMS filter.
4214 * @param[in] S points to an instance of the floating-point LMS filter structure.
4215 * @param[in] numTaps number of filter coefficients.
4216 * @param[in] pCoeffs points to coefficient buffer.
4217 * @param[in] pState points to state buffer.
4218 * @param[in] mu step size that controls filter coefficient updates.
4219 * @param[in] blockSize number of samples to process.
4220 */
4221 void arm_lms_norm_init_f32(
4222 arm_lms_norm_instance_f32 * S,
4223 uint16_t numTaps,
4224 float32_t * pCoeffs,
4225 float32_t * pState,
4226 float32_t mu,
4227 uint32_t blockSize);
4228
4229
4230 /**
4231 * @brief Instance structure for the Q31 normalized LMS filter.
4232 */
4233 typedef struct
4234 {
4235 uint16_t numTaps; /**< number of coefficients in the filter. */
4236 q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
4237 q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
4238 q31_t mu; /**< step size that controls filter coefficient updates. */
4239 uint8_t postShift; /**< bit shift applied to coefficients. */
4240 q31_t *recipTable; /**< points to the reciprocal initial value table. */
4241 q31_t energy; /**< saves previous frame energy. */
4242 q31_t x0; /**< saves previous input sample. */
4243 } arm_lms_norm_instance_q31;
4244
4245
4246 /**
4247 * @brief Processing function for Q31 normalized LMS filter.
4248 * @param[in] S points to an instance of the Q31 normalized LMS filter structure.
4249 * @param[in] pSrc points to the block of input data.
4250 * @param[in] pRef points to the block of reference data.
4251 * @param[out] pOut points to the block of output data.
4252 * @param[out] pErr points to the block of error data.
4253 * @param[in] blockSize number of samples to process.
4254 */
4255 void arm_lms_norm_q31(
4256 arm_lms_norm_instance_q31 * S,
4257 q31_t * pSrc,
4258 q31_t * pRef,
4259 q31_t * pOut,
4260 q31_t * pErr,
4261 uint32_t blockSize);
4262
4263
4264 /**
4265 * @brief Initialization function for Q31 normalized LMS filter.
4266 * @param[in] S points to an instance of the Q31 normalized LMS filter structure.
4267 * @param[in] numTaps number of filter coefficients.
4268 * @param[in] pCoeffs points to coefficient buffer.
4269 * @param[in] pState points to state buffer.
4270 * @param[in] mu step size that controls filter coefficient updates.
4271 * @param[in] blockSize number of samples to process.
4272 * @param[in] postShift bit shift applied to coefficients.
4273 */
4274 void arm_lms_norm_init_q31(
4275 arm_lms_norm_instance_q31 * S,
4276 uint16_t numTaps,
4277 q31_t * pCoeffs,
4278 q31_t * pState,
4279 q31_t mu,
4280 uint32_t blockSize,
4281 uint8_t postShift);
4282
4283
4284 /**
4285 * @brief Instance structure for the Q15 normalized LMS filter.
4286 */
4287 typedef struct
4288 {
4289 uint16_t numTaps; /**< Number of coefficients in the filter. */
4290 q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
4291 q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
4292 q15_t mu; /**< step size that controls filter coefficient updates. */
4293 uint8_t postShift; /**< bit shift applied to coefficients. */
4294 q15_t *recipTable; /**< Points to the reciprocal initial value table. */
4295 q15_t energy; /**< saves previous frame energy. */
4296 q15_t x0; /**< saves previous input sample. */
4297 } arm_lms_norm_instance_q15;
4298
4299
4300 /**
4301 * @brief Processing function for Q15 normalized LMS filter.
4302 * @param[in] S points to an instance of the Q15 normalized LMS filter structure.
4303 * @param[in] pSrc points to the block of input data.
4304 * @param[in] pRef points to the block of reference data.
4305 * @param[out] pOut points to the block of output data.
4306 * @param[out] pErr points to the block of error data.
4307 * @param[in] blockSize number of samples to process.
4308 */
4309 void arm_lms_norm_q15(
4310 arm_lms_norm_instance_q15 * S,
4311 q15_t * pSrc,
4312 q15_t * pRef,
4313 q15_t * pOut,
4314 q15_t * pErr,
4315 uint32_t blockSize);
4316
4317
4318 /**
4319 * @brief Initialization function for Q15 normalized LMS filter.
4320 * @param[in] S points to an instance of the Q15 normalized LMS filter structure.
4321 * @param[in] numTaps number of filter coefficients.
4322 * @param[in] pCoeffs points to coefficient buffer.
4323 * @param[in] pState points to state buffer.
4324 * @param[in] mu step size that controls filter coefficient updates.
4325 * @param[in] blockSize number of samples to process.
4326 * @param[in] postShift bit shift applied to coefficients.
4327 */
4328 void arm_lms_norm_init_q15(
4329 arm_lms_norm_instance_q15 * S,
4330 uint16_t numTaps,
4331 q15_t * pCoeffs,
4332 q15_t * pState,
4333 q15_t mu,
4334 uint32_t blockSize,
4335 uint8_t postShift);
4336
4337
4338 /**
4339 * @brief Correlation of floating-point sequences.
4340 * @param[in] pSrcA points to the first input sequence.
4341 * @param[in] srcALen length of the first input sequence.
4342 * @param[in] pSrcB points to the second input sequence.
4343 * @param[in] srcBLen length of the second input sequence.
4344 * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
4345 */
4346 void arm_correlate_f32(
4347 float32_t * pSrcA,
4348 uint32_t srcALen,
4349 float32_t * pSrcB,
4350 uint32_t srcBLen,
4351 float32_t * pDst);
4352
4353
4354 /**
4355 * @brief Correlation of Q15 sequences
4356 * @param[in] pSrcA points to the first input sequence.
4357 * @param[in] srcALen length of the first input sequence.
4358 * @param[in] pSrcB points to the second input sequence.
4359 * @param[in] srcBLen length of the second input sequence.
4360 * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
4361 * @param[in] pScratch points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
4362 */
4363 void arm_correlate_opt_q15(
4364 q15_t * pSrcA,
4365 uint32_t srcALen,
4366 q15_t * pSrcB,
4367 uint32_t srcBLen,
4368 q15_t * pDst,
4369 q15_t * pScratch);
4370
4371
4372 /**
4373 * @brief Correlation of Q15 sequences.
4374 * @param[in] pSrcA points to the first input sequence.
4375 * @param[in] srcALen length of the first input sequence.
4376 * @param[in] pSrcB points to the second input sequence.
4377 * @param[in] srcBLen length of the second input sequence.
4378 * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
4379 */
4380
4381 void arm_correlate_q15(
4382 q15_t * pSrcA,
4383 uint32_t srcALen,
4384 q15_t * pSrcB,
4385 uint32_t srcBLen,
4386 q15_t * pDst);
4387
4388
4389 /**
4390 * @brief Correlation of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4.
4391 * @param[in] pSrcA points to the first input sequence.
4392 * @param[in] srcALen length of the first input sequence.
4393 * @param[in] pSrcB points to the second input sequence.
4394 * @param[in] srcBLen length of the second input sequence.
4395 * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
4396 */
4397
4398 void arm_correlate_fast_q15(
4399 q15_t * pSrcA,
4400 uint32_t srcALen,
4401 q15_t * pSrcB,
4402 uint32_t srcBLen,
4403 q15_t * pDst);
4404
4405
4406 /**
4407 * @brief Correlation of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4.
4408 * @param[in] pSrcA points to the first input sequence.
4409 * @param[in] srcALen length of the first input sequence.
4410 * @param[in] pSrcB points to the second input sequence.
4411 * @param[in] srcBLen length of the second input sequence.
4412 * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
4413 * @param[in] pScratch points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
4414 */
4415 void arm_correlate_fast_opt_q15(
4416 q15_t * pSrcA,
4417 uint32_t srcALen,
4418 q15_t * pSrcB,
4419 uint32_t srcBLen,
4420 q15_t * pDst,
4421 q15_t * pScratch);
4422
4423
4424 /**
4425 * @brief Correlation of Q31 sequences.
4426 * @param[in] pSrcA points to the first input sequence.
4427 * @param[in] srcALen length of the first input sequence.
4428 * @param[in] pSrcB points to the second input sequence.
4429 * @param[in] srcBLen length of the second input sequence.
4430 * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
4431 */
4432 void arm_correlate_q31(
4433 q31_t * pSrcA,
4434 uint32_t srcALen,
4435 q31_t * pSrcB,
4436 uint32_t srcBLen,
4437 q31_t * pDst);
4438
4439
4440 /**
4441 * @brief Correlation of Q31 sequences (fast version) for Cortex-M3 and Cortex-M4
4442 * @param[in] pSrcA points to the first input sequence.
4443 * @param[in] srcALen length of the first input sequence.
4444 * @param[in] pSrcB points to the second input sequence.
4445 * @param[in] srcBLen length of the second input sequence.
4446 * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
4447 */
4448 void arm_correlate_fast_q31(
4449 q31_t * pSrcA,
4450 uint32_t srcALen,
4451 q31_t * pSrcB,
4452 uint32_t srcBLen,
4453 q31_t * pDst);
4454
4455
4456 /**
4457 * @brief Correlation of Q7 sequences.
4458 * @param[in] pSrcA points to the first input sequence.
4459 * @param[in] srcALen length of the first input sequence.
4460 * @param[in] pSrcB points to the second input sequence.
4461 * @param[in] srcBLen length of the second input sequence.
4462 * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
4463 * @param[in] pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
4464 * @param[in] pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen).
4465 */
4466 void arm_correlate_opt_q7(
4467 q7_t * pSrcA,
4468 uint32_t srcALen,
4469 q7_t * pSrcB,
4470 uint32_t srcBLen,
4471 q7_t * pDst,
4472 q15_t * pScratch1,
4473 q15_t * pScratch2);
4474
4475
4476 /**
4477 * @brief Correlation of Q7 sequences.
4478 * @param[in] pSrcA points to the first input sequence.
4479 * @param[in] srcALen length of the first input sequence.
4480 * @param[in] pSrcB points to the second input sequence.
4481 * @param[in] srcBLen length of the second input sequence.
4482 * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
4483 */
4484 void arm_correlate_q7(
4485 q7_t * pSrcA,
4486 uint32_t srcALen,
4487 q7_t * pSrcB,
4488 uint32_t srcBLen,
4489 q7_t * pDst);
4490
4491
4492 /**
4493 * @brief Instance structure for the floating-point sparse FIR filter.
4494 */
4495 typedef struct
4496 {
4497 uint16_t numTaps; /**< number of coefficients in the filter. */
4498 uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */
4499 float32_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */
4500 float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
4501 uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */
4502 int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */
4503 } arm_fir_sparse_instance_f32;
4504
4505 /**
4506 * @brief Instance structure for the Q31 sparse FIR filter.
4507 */
4508 typedef struct
4509 {
4510 uint16_t numTaps; /**< number of coefficients in the filter. */
4511 uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */
4512 q31_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */
4513 q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
4514 uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */
4515 int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */
4516 } arm_fir_sparse_instance_q31;
4517
4518 /**
4519 * @brief Instance structure for the Q15 sparse FIR filter.
4520 */
4521 typedef struct
4522 {
4523 uint16_t numTaps; /**< number of coefficients in the filter. */
4524 uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */
4525 q15_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */
4526 q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
4527 uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */
4528 int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */
4529 } arm_fir_sparse_instance_q15;
4530
4531 /**
4532 * @brief Instance structure for the Q7 sparse FIR filter.
4533 */
4534 typedef struct
4535 {
4536 uint16_t numTaps; /**< number of coefficients in the filter. */
4537 uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */
4538 q7_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */
4539 q7_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
4540 uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */
4541 int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */
4542 } arm_fir_sparse_instance_q7;
4543
4544
4545 /**
4546 * @brief Processing function for the floating-point sparse FIR filter.
4547 * @param[in] S points to an instance of the floating-point sparse FIR structure.
4548 * @param[in] pSrc points to the block of input data.
4549 * @param[out] pDst points to the block of output data
4550 * @param[in] pScratchIn points to a temporary buffer of size blockSize.
4551 * @param[in] blockSize number of input samples to process per call.
4552 */
4553 void arm_fir_sparse_f32(
4554 arm_fir_sparse_instance_f32 * S,
4555 float32_t * pSrc,
4556 float32_t * pDst,
4557 float32_t * pScratchIn,
4558 uint32_t blockSize);
4559
4560
4561 /**
4562 * @brief Initialization function for the floating-point sparse FIR filter.
4563 * @param[in,out] S points to an instance of the floating-point sparse FIR structure.
4564 * @param[in] numTaps number of nonzero coefficients in the filter.
4565 * @param[in] pCoeffs points to the array of filter coefficients.
4566 * @param[in] pState points to the state buffer.
4567 * @param[in] pTapDelay points to the array of offset times.
4568 * @param[in] maxDelay maximum offset time supported.
4569 * @param[in] blockSize number of samples that will be processed per block.
4570 */
4571 void arm_fir_sparse_init_f32(
4572 arm_fir_sparse_instance_f32 * S,
4573 uint16_t numTaps,
4574 float32_t * pCoeffs,
4575 float32_t * pState,
4576 int32_t * pTapDelay,
4577 uint16_t maxDelay,
4578 uint32_t blockSize);
4579
4580
4581 /**
4582 * @brief Processing function for the Q31 sparse FIR filter.
4583 * @param[in] S points to an instance of the Q31 sparse FIR structure.
4584 * @param[in] pSrc points to the block of input data.
4585 * @param[out] pDst points to the block of output data
4586 * @param[in] pScratchIn points to a temporary buffer of size blockSize.
4587 * @param[in] blockSize number of input samples to process per call.
4588 */
4589 void arm_fir_sparse_q31(
4590 arm_fir_sparse_instance_q31 * S,
4591 q31_t * pSrc,
4592 q31_t * pDst,
4593 q31_t * pScratchIn,
4594 uint32_t blockSize);
4595
4596
4597 /**
4598 * @brief Initialization function for the Q31 sparse FIR filter.
4599 * @param[in,out] S points to an instance of the Q31 sparse FIR structure.
4600 * @param[in] numTaps number of nonzero coefficients in the filter.
4601 * @param[in] pCoeffs points to the array of filter coefficients.
4602 * @param[in] pState points to the state buffer.
4603 * @param[in] pTapDelay points to the array of offset times.
4604 * @param[in] maxDelay maximum offset time supported.
4605 * @param[in] blockSize number of samples that will be processed per block.
4606 */
4607 void arm_fir_sparse_init_q31(
4608 arm_fir_sparse_instance_q31 * S,
4609 uint16_t numTaps,
4610 q31_t * pCoeffs,
4611 q31_t * pState,
4612 int32_t * pTapDelay,
4613 uint16_t maxDelay,
4614 uint32_t blockSize);
4615
4616
4617 /**
4618 * @brief Processing function for the Q15 sparse FIR filter.
4619 * @param[in] S points to an instance of the Q15 sparse FIR structure.
4620 * @param[in] pSrc points to the block of input data.
4621 * @param[out] pDst points to the block of output data
4622 * @param[in] pScratchIn points to a temporary buffer of size blockSize.
4623 * @param[in] pScratchOut points to a temporary buffer of size blockSize.
4624 * @param[in] blockSize number of input samples to process per call.
4625 */
4626 void arm_fir_sparse_q15(
4627 arm_fir_sparse_instance_q15 * S,
4628 q15_t * pSrc,
4629 q15_t * pDst,
4630 q15_t * pScratchIn,
4631 q31_t * pScratchOut,
4632 uint32_t blockSize);
4633
4634
4635 /**
4636 * @brief Initialization function for the Q15 sparse FIR filter.
4637 * @param[in,out] S points to an instance of the Q15 sparse FIR structure.
4638 * @param[in] numTaps number of nonzero coefficients in the filter.
4639 * @param[in] pCoeffs points to the array of filter coefficients.
4640 * @param[in] pState points to the state buffer.
4641 * @param[in] pTapDelay points to the array of offset times.
4642 * @param[in] maxDelay maximum offset time supported.
4643 * @param[in] blockSize number of samples that will be processed per block.
4644 */
4645 void arm_fir_sparse_init_q15(
4646 arm_fir_sparse_instance_q15 * S,
4647 uint16_t numTaps,
4648 q15_t * pCoeffs,
4649 q15_t * pState,
4650 int32_t * pTapDelay,
4651 uint16_t maxDelay,
4652 uint32_t blockSize);
4653
4654
4655 /**
4656 * @brief Processing function for the Q7 sparse FIR filter.
4657 * @param[in] S points to an instance of the Q7 sparse FIR structure.
4658 * @param[in] pSrc points to the block of input data.
4659 * @param[out] pDst points to the block of output data
4660 * @param[in] pScratchIn points to a temporary buffer of size blockSize.
4661 * @param[in] pScratchOut points to a temporary buffer of size blockSize.
4662 * @param[in] blockSize number of input samples to process per call.
4663 */
4664 void arm_fir_sparse_q7(
4665 arm_fir_sparse_instance_q7 * S,
4666 q7_t * pSrc,
4667 q7_t * pDst,
4668 q7_t * pScratchIn,
4669 q31_t * pScratchOut,
4670 uint32_t blockSize);
4671
4672
4673 /**
4674 * @brief Initialization function for the Q7 sparse FIR filter.
4675 * @param[in,out] S points to an instance of the Q7 sparse FIR structure.
4676 * @param[in] numTaps number of nonzero coefficients in the filter.
4677 * @param[in] pCoeffs points to the array of filter coefficients.
4678 * @param[in] pState points to the state buffer.
4679 * @param[in] pTapDelay points to the array of offset times.
4680 * @param[in] maxDelay maximum offset time supported.
4681 * @param[in] blockSize number of samples that will be processed per block.
4682 */
4683 void arm_fir_sparse_init_q7(
4684 arm_fir_sparse_instance_q7 * S,
4685 uint16_t numTaps,
4686 q7_t * pCoeffs,
4687 q7_t * pState,
4688 int32_t * pTapDelay,
4689 uint16_t maxDelay,
4690 uint32_t blockSize);
4691
4692
4693 /**
4694 * @brief Floating-point sin_cos function.
4695 * @param[in] theta input value in degrees
4696 * @param[out] pSinVal points to the processed sine output.
4697 * @param[out] pCosVal points to the processed cos output.
4698 */
4699 void arm_sin_cos_f32(
4700 float32_t theta,
4701 float32_t * pSinVal,
4702 float32_t * pCosVal);
4703
4704
4705 /**
4706 * @brief Q31 sin_cos function.
4707 * @param[in] theta scaled input value in degrees
4708 * @param[out] pSinVal points to the processed sine output.
4709 * @param[out] pCosVal points to the processed cosine output.
4710 */
4711 void arm_sin_cos_q31(
4712 q31_t theta,
4713 q31_t * pSinVal,
4714 q31_t * pCosVal);
4715
4716
4717 /**
4718 * @brief Floating-point complex conjugate.
4719 * @param[in] pSrc points to the input vector
4720 * @param[out] pDst points to the output vector
4721 * @param[in] numSamples number of complex samples in each vector
4722 */
4723 void arm_cmplx_conj_f32(
4724 float32_t * pSrc,
4725 float32_t * pDst,
4726 uint32_t numSamples);
4727
4728 /**
4729 * @brief Q31 complex conjugate.
4730 * @param[in] pSrc points to the input vector
4731 * @param[out] pDst points to the output vector
4732 * @param[in] numSamples number of complex samples in each vector
4733 */
4734 void arm_cmplx_conj_q31(
4735 q31_t * pSrc,
4736 q31_t * pDst,
4737 uint32_t numSamples);
4738
4739
4740 /**
4741 * @brief Q15 complex conjugate.
4742 * @param[in] pSrc points to the input vector
4743 * @param[out] pDst points to the output vector
4744 * @param[in] numSamples number of complex samples in each vector
4745 */
4746 void arm_cmplx_conj_q15(
4747 q15_t * pSrc,
4748 q15_t * pDst,
4749 uint32_t numSamples);
4750
4751
4752 /**
4753 * @brief Floating-point complex magnitude squared
4754 * @param[in] pSrc points to the complex input vector
4755 * @param[out] pDst points to the real output vector
4756 * @param[in] numSamples number of complex samples in the input vector
4757 */
4758 void arm_cmplx_mag_squared_f32(
4759 float32_t * pSrc,
4760 float32_t * pDst,
4761 uint32_t numSamples);
4762
4763
4764 /**
4765 * @brief Q31 complex magnitude squared
4766 * @param[in] pSrc points to the complex input vector
4767 * @param[out] pDst points to the real output vector
4768 * @param[in] numSamples number of complex samples in the input vector
4769 */
4770 void arm_cmplx_mag_squared_q31(
4771 q31_t * pSrc,
4772 q31_t * pDst,
4773 uint32_t numSamples);
4774
4775
4776 /**
4777 * @brief Q15 complex magnitude squared
4778 * @param[in] pSrc points to the complex input vector
4779 * @param[out] pDst points to the real output vector
4780 * @param[in] numSamples number of complex samples in the input vector
4781 */
4782 void arm_cmplx_mag_squared_q15(
4783 q15_t * pSrc,
4784 q15_t * pDst,
4785 uint32_t numSamples);
4786
4787
4788 /**
4789 * @ingroup groupController
4790 */
4791
4792 /**
4793 * @defgroup PID PID Motor Control
4794 *
4795 * A Proportional Integral Derivative (PID) controller is a generic feedback control
4796 * loop mechanism widely used in industrial control systems.
4797 * A PID controller is the most commonly used type of feedback controller.
4798 *
4799 * This set of functions implements (PID) controllers
4800 * for Q15, Q31, and floating-point data types. The functions operate on a single sample
4801 * of data and each call to the function returns a single processed value.
4802 * <code>S</code> points to an instance of the PID control data structure. <code>in</code>
4803 * is the input sample value. The functions return the output value.
4804 *
4805 * \par Algorithm:
4806 * <pre>
4807 * y[n] = y[n-1] + A0 * x[n] + A1 * x[n-1] + A2 * x[n-2]
4808 * A0 = Kp + Ki + Kd
4809 * A1 = (-Kp ) - (2 * Kd )
4810 * A2 = Kd </pre>
4811 *
4812 * \par
4813 * where \c Kp is proportional constant, \c Ki is Integral constant and \c Kd is Derivative constant
4814 *
4815 * \par
4816 * \image html PID.gif "Proportional Integral Derivative Controller"
4817 *
4818 * \par
4819 * The PID controller calculates an "error" value as the difference between
4820 * the measured output and the reference input.
4821 * The controller attempts to minimize the error by adjusting the process control inputs.
4822 * The proportional value determines the reaction to the current error,
4823 * the integral value determines the reaction based on the sum of recent errors,
4824 * and the derivative value determines the reaction based on the rate at which the error has been changing.
4825 *
4826 * \par Instance Structure
4827 * The Gains A0, A1, A2 and state variables for a PID controller are stored together in an instance data structure.
4828 * A separate instance structure must be defined for each PID Controller.
4829 * There are separate instance structure declarations for each of the 3 supported data types.
4830 *
4831 * \par Reset Functions
4832 * There is also an associated reset function for each data type which clears the state array.
4833 *
4834 * \par Initialization Functions
4835 * There is also an associated initialization function for each data type.
4836 * The initialization function performs the following operations:
4837 * - Initializes the Gains A0, A1, A2 from Kp,Ki, Kd gains.
4838 * - Zeros out the values in the state buffer.
4839 *
4840 * \par
4841 * Instance structure cannot be placed into a const data section and it is recommended to use the initialization function.
4842 *
4843 * \par Fixed-Point Behavior
4844 * Care must be taken when using the fixed-point versions of the PID Controller functions.
4845 * In particular, the overflow and saturation behavior of the accumulator used in each function must be considered.
4846 * Refer to the function specific documentation below for usage guidelines.
4847 */
4848
4849 /**
4850 * @addtogroup PID
4851 * @{
4852 */
4853
4854 /**
4855 * @brief Process function for the floating-point PID Control.
4856 * @param[in,out] S is an instance of the floating-point PID Control structure
4857 * @param[in] in input sample to process
4858 * @return out processed output sample.
4859 */
4860 CMSIS_INLINE __STATIC_INLINE float32_t arm_pid_f32(
4861 arm_pid_instance_f32 * S,
4862 float32_t in)
4863 {
4864 float32_t out;
4865
4866 /* y[n] = y[n-1] + A0 * x[n] + A1 * x[n-1] + A2 * x[n-2] */
4867 out = (S->A0 * in) +
4868 (S->A1 * S->state[0]) + (S->A2 * S->state[1]) + (S->state[2]);
4869
4870 /* Update state */
4871 S->state[1] = S->state[0];
4872 S->state[0] = in;
4873 S->state[2] = out;
4874
4875 /* return to application */
4876 return (out);
4877
4878 }
4879
4880 /**
4881 * @brief Process function for the Q31 PID Control.
4882 * @param[in,out] S points to an instance of the Q31 PID Control structure
4883 * @param[in] in input sample to process
4884 * @return out processed output sample.
4885 *
4886 * <b>Scaling and Overflow Behavior:</b>
4887 * \par
4888 * The function is implemented using an internal 64-bit accumulator.
4889 * The accumulator has a 2.62 format and maintains full precision of the intermediate multiplication results but provides only a single guard bit.
4890 * Thus, if the accumulator result overflows it wraps around rather than clip.
4891 * In order to avoid overflows completely the input signal must be scaled down by 2 bits as there are four additions.
4892 * After all multiply-accumulates are performed, the 2.62 accumulator is truncated to 1.32 format and then saturated to 1.31 format.
4893 */
4894 CMSIS_INLINE __STATIC_INLINE q31_t arm_pid_q31(
4895 arm_pid_instance_q31 * S,
4896 q31_t in)
4897 {
4898 q63_t acc;
4899 q31_t out;
4900
4901 /* acc = A0 * x[n] */
4902 acc = (q63_t) S->A0 * in;
4903
4904 /* acc += A1 * x[n-1] */
4905 acc += (q63_t) S->A1 * S->state[0];
4906
4907 /* acc += A2 * x[n-2] */
4908 acc += (q63_t) S->A2 * S->state[1];
4909
4910 /* convert output to 1.31 format to add y[n-1] */
4911 out = (q31_t) (acc >> 31u);
4912
4913 /* out += y[n-1] */
4914 out += S->state[2];
4915
4916 /* Update state */
4917 S->state[1] = S->state[0];
4918 S->state[0] = in;
4919 S->state[2] = out;
4920
4921 /* return to application */
4922 return (out);
4923 }
4924
4925
4926 /**
4927 * @brief Process function for the Q15 PID Control.
4928 * @param[in,out] S points to an instance of the Q15 PID Control structure
4929 * @param[in] in input sample to process
4930 * @return out processed output sample.
4931 *
4932 * <b>Scaling and Overflow Behavior:</b>
4933 * \par
4934 * The function is implemented using a 64-bit internal accumulator.
4935 * Both Gains and state variables are represented in 1.15 format and multiplications yield a 2.30 result.
4936 * The 2.30 intermediate results are accumulated in a 64-bit accumulator in 34.30 format.
4937 * There is no risk of internal overflow with this approach and the full precision of intermediate multiplications is preserved.
4938 * After all additions have been performed, the accumulator is truncated to 34.15 format by discarding low 15 bits.
4939 * Lastly, the accumulator is saturated to yield a result in 1.15 format.
4940 */
4941 CMSIS_INLINE __STATIC_INLINE q15_t arm_pid_q15(
4942 arm_pid_instance_q15 * S,
4943 q15_t in)
4944 {
4945 q63_t acc;
4946 q15_t out;
4947
4948#if defined (ARM_MATH_DSP)
4949 __SIMD32_TYPE *vstate;
4950
4951 /* Implementation of PID controller */
4952
4953 /* acc = A0 * x[n] */
4954 acc = (q31_t) __SMUAD((uint32_t)S->A0, (uint32_t)in);
4955
4956 /* acc += A1 * x[n-1] + A2 * x[n-2] */
4957 vstate = __SIMD32_CONST(S->state);
4958 acc = (q63_t)__SMLALD((uint32_t)S->A1, (uint32_t)*vstate, (uint64_t)acc);
4959#else
4960 /* acc = A0 * x[n] */
4961 acc = ((q31_t) S->A0) * in;
4962
4963 /* acc += A1 * x[n-1] + A2 * x[n-2] */
4964 acc += (q31_t) S->A1 * S->state[0];
4965 acc += (q31_t) S->A2 * S->state[1];
4966#endif
4967
4968 /* acc += y[n-1] */
4969 acc += (q31_t) S->state[2] << 15;
4970
4971 /* saturate the output */
4972 out = (q15_t) (__SSAT((acc >> 15), 16));
4973
4974 /* Update state */
4975 S->state[1] = S->state[0];
4976 S->state[0] = in;
4977 S->state[2] = out;
4978
4979 /* return to application */
4980 return (out);
4981 }
4982
4983 /**
4984 * @} end of PID group
4985 */
4986
4987
4988 /**
4989 * @brief Floating-point matrix inverse.
4990 * @param[in] src points to the instance of the input floating-point matrix structure.
4991 * @param[out] dst points to the instance of the output floating-point matrix structure.
4992 * @return The function returns ARM_MATH_SIZE_MISMATCH, if the dimensions do not match.
4993 * If the input matrix is singular (does not have an inverse), then the algorithm terminates and returns error status ARM_MATH_SINGULAR.
4994 */
4995 arm_status arm_mat_inverse_f32(
4996 const arm_matrix_instance_f32 * src,
4997 arm_matrix_instance_f32 * dst);
4998
4999
5000 /**
5001 * @brief Floating-point matrix inverse.
5002 * @param[in] src points to the instance of the input floating-point matrix structure.
5003 * @param[out] dst points to the instance of the output floating-point matrix structure.
5004 * @return The function returns ARM_MATH_SIZE_MISMATCH, if the dimensions do not match.
5005 * If the input matrix is singular (does not have an inverse), then the algorithm terminates and returns error status ARM_MATH_SINGULAR.
5006 */
5007 arm_status arm_mat_inverse_f64(
5008 const arm_matrix_instance_f64 * src,
5009 arm_matrix_instance_f64 * dst);
5010
5011
5012
5013 /**
5014 * @ingroup groupController
5015 */
5016
5017 /**
5018 * @defgroup clarke Vector Clarke Transform
5019 * Forward Clarke transform converts the instantaneous stator phases into a two-coordinate time invariant vector.
5020 * Generally the Clarke transform uses three-phase currents <code>Ia, Ib and Ic</code> to calculate currents
5021 * in the two-phase orthogonal stator axis <code>Ialpha</code> and <code>Ibeta</code>.
5022 * When <code>Ialpha</code> is superposed with <code>Ia</code> as shown in the figure below
5023 * \image html clarke.gif Stator current space vector and its components in (a,b).
5024 * and <code>Ia + Ib + Ic = 0</code>, in this condition <code>Ialpha</code> and <code>Ibeta</code>
5025 * can be calculated using only <code>Ia</code> and <code>Ib</code>.
5026 *
5027 * The function operates on a single sample of data and each call to the function returns the processed output.
5028 * The library provides separate functions for Q31 and floating-point data types.
5029 * \par Algorithm
5030 * \image html clarkeFormula.gif
5031 * where <code>Ia</code> and <code>Ib</code> are the instantaneous stator phases and
5032 * <code>pIalpha</code> and <code>pIbeta</code> are the two coordinates of time invariant vector.
5033 * \par Fixed-Point Behavior
5034 * Care must be taken when using the Q31 version of the Clarke transform.
5035 * In particular, the overflow and saturation behavior of the accumulator used must be considered.
5036 * Refer to the function specific documentation below for usage guidelines.
5037 */
5038
5039 /**
5040 * @addtogroup clarke
5041 * @{
5042 */
5043
5044 /**
5045 *
5046 * @brief Floating-point Clarke transform
5047 * @param[in] Ia input three-phase coordinate <code>a</code>
5048 * @param[in] Ib input three-phase coordinate <code>b</code>
5049 * @param[out] pIalpha points to output two-phase orthogonal vector axis alpha
5050 * @param[out] pIbeta points to output two-phase orthogonal vector axis beta
5051 */
5052 CMSIS_INLINE __STATIC_INLINE void arm_clarke_f32(
5053 float32_t Ia,
5054 float32_t Ib,
5055 float32_t * pIalpha,
5056 float32_t * pIbeta)
5057 {
5058 /* Calculate pIalpha using the equation, pIalpha = Ia */
5059 *pIalpha = Ia;
5060
5061 /* Calculate pIbeta using the equation, pIbeta = (1/sqrt(3)) * Ia + (2/sqrt(3)) * Ib */
5062 *pIbeta = ((float32_t) 0.57735026919 * Ia + (float32_t) 1.15470053838 * Ib);
5063 }
5064
5065
5066 /**
5067 * @brief Clarke transform for Q31 version
5068 * @param[in] Ia input three-phase coordinate <code>a</code>
5069 * @param[in] Ib input three-phase coordinate <code>b</code>
5070 * @param[out] pIalpha points to output two-phase orthogonal vector axis alpha
5071 * @param[out] pIbeta points to output two-phase orthogonal vector axis beta
5072 *
5073 * <b>Scaling and Overflow Behavior:</b>
5074 * \par
5075 * The function is implemented using an internal 32-bit accumulator.
5076 * The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format.
5077 * There is saturation on the addition, hence there is no risk of overflow.
5078 */
5079 CMSIS_INLINE __STATIC_INLINE void arm_clarke_q31(
5080 q31_t Ia,
5081 q31_t Ib,
5082 q31_t * pIalpha,
5083 q31_t * pIbeta)
5084 {
5085 q31_t product1, product2; /* Temporary variables used to store intermediate results */
5086
5087 /* Calculating pIalpha from Ia by equation pIalpha = Ia */
5088 *pIalpha = Ia;
5089
5090 /* Intermediate product is calculated by (1/(sqrt(3)) * Ia) */
5091 product1 = (q31_t) (((q63_t) Ia * 0x24F34E8B) >> 30);
5092
5093 /* Intermediate product is calculated by (2/sqrt(3) * Ib) */
5094 product2 = (q31_t) (((q63_t) Ib * 0x49E69D16) >> 30);
5095
5096 /* pIbeta is calculated by adding the intermediate products */
5097 *pIbeta = __QADD(product1, product2);
5098 }
5099
5100 /**
5101 * @} end of clarke group
5102 */
5103
5104 /**
5105 * @brief Converts the elements of the Q7 vector to Q31 vector.
5106 * @param[in] pSrc input pointer
5107 * @param[out] pDst output pointer
5108 * @param[in] blockSize number of samples to process
5109 */
5110 void arm_q7_to_q31(
5111 q7_t * pSrc,
5112 q31_t * pDst,
5113 uint32_t blockSize);
5114
5115
5116
5117 /**
5118 * @ingroup groupController
5119 */
5120
5121 /**
5122 * @defgroup inv_clarke Vector Inverse Clarke Transform
5123 * Inverse Clarke transform converts the two-coordinate time invariant vector into instantaneous stator phases.
5124 *
5125 * The function operates on a single sample of data and each call to the function returns the processed output.
5126 * The library provides separate functions for Q31 and floating-point data types.
5127 * \par Algorithm
5128 * \image html clarkeInvFormula.gif
5129 * where <code>pIa</code> and <code>pIb</code> are the instantaneous stator phases and
5130 * <code>Ialpha</code> and <code>Ibeta</code> are the two coordinates of time invariant vector.
5131 * \par Fixed-Point Behavior
5132 * Care must be taken when using the Q31 version of the Clarke transform.
5133 * In particular, the overflow and saturation behavior of the accumulator used must be considered.
5134 * Refer to the function specific documentation below for usage guidelines.
5135 */
5136
5137 /**
5138 * @addtogroup inv_clarke
5139 * @{
5140 */
5141
5142 /**
5143 * @brief Floating-point Inverse Clarke transform
5144 * @param[in] Ialpha input two-phase orthogonal vector axis alpha
5145 * @param[in] Ibeta input two-phase orthogonal vector axis beta
5146 * @param[out] pIa points to output three-phase coordinate <code>a</code>
5147 * @param[out] pIb points to output three-phase coordinate <code>b</code>
5148 */
5149 CMSIS_INLINE __STATIC_INLINE void arm_inv_clarke_f32(
5150 float32_t Ialpha,
5151 float32_t Ibeta,
5152 float32_t * pIa,
5153 float32_t * pIb)
5154 {
5155 /* Calculating pIa from Ialpha by equation pIa = Ialpha */
5156 *pIa = Ialpha;
5157
5158 /* Calculating pIb from Ialpha and Ibeta by equation pIb = -(1/2) * Ialpha + (sqrt(3)/2) * Ibeta */
5159 *pIb = -0.5f * Ialpha + 0.8660254039f * Ibeta;
5160 }
5161
5162
5163 /**
5164 * @brief Inverse Clarke transform for Q31 version
5165 * @param[in] Ialpha input two-phase orthogonal vector axis alpha
5166 * @param[in] Ibeta input two-phase orthogonal vector axis beta
5167 * @param[out] pIa points to output three-phase coordinate <code>a</code>
5168 * @param[out] pIb points to output three-phase coordinate <code>b</code>
5169 *
5170 * <b>Scaling and Overflow Behavior:</b>
5171 * \par
5172 * The function is implemented using an internal 32-bit accumulator.
5173 * The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format.
5174 * There is saturation on the subtraction, hence there is no risk of overflow.
5175 */
5176 CMSIS_INLINE __STATIC_INLINE void arm_inv_clarke_q31(
5177 q31_t Ialpha,
5178 q31_t Ibeta,
5179 q31_t * pIa,
5180 q31_t * pIb)
5181 {
5182 q31_t product1, product2; /* Temporary variables used to store intermediate results */
5183
5184 /* Calculating pIa from Ialpha by equation pIa = Ialpha */
5185 *pIa = Ialpha;
5186
5187 /* Intermediate product is calculated by (1/(2*sqrt(3)) * Ia) */
5188 product1 = (q31_t) (((q63_t) (Ialpha) * (0x40000000)) >> 31);
5189
5190 /* Intermediate product is calculated by (1/sqrt(3) * pIb) */
5191 product2 = (q31_t) (((q63_t) (Ibeta) * (0x6ED9EBA1)) >> 31);
5192
5193 /* pIb is calculated by subtracting the products */
5194 *pIb = __QSUB(product2, product1);
5195 }
5196
5197 /**
5198 * @} end of inv_clarke group
5199 */
5200
5201 /**
5202 * @brief Converts the elements of the Q7 vector to Q15 vector.
5203 * @param[in] pSrc input pointer
5204 * @param[out] pDst output pointer
5205 * @param[in] blockSize number of samples to process
5206 */
5207 void arm_q7_to_q15(
5208 q7_t * pSrc,
5209 q15_t * pDst,
5210 uint32_t blockSize);
5211
5212
5213
5214 /**
5215 * @ingroup groupController
5216 */
5217
5218 /**
5219 * @defgroup park Vector Park Transform
5220 *
5221 * Forward Park transform converts the input two-coordinate vector to flux and torque components.
5222 * The Park transform can be used to realize the transformation of the <code>Ialpha</code> and the <code>Ibeta</code> currents
5223 * from the stationary to the moving reference frame and control the spatial relationship between
5224 * the stator vector current and rotor flux vector.
5225 * If we consider the d axis aligned with the rotor flux, the diagram below shows the
5226 * current vector and the relationship from the two reference frames:
5227 * \image html park.gif "Stator current space vector and its component in (a,b) and in the d,q rotating reference frame"
5228 *
5229 * The function operates on a single sample of data and each call to the function returns the processed output.
5230 * The library provides separate functions for Q31 and floating-point data types.
5231 * \par Algorithm
5232 * \image html parkFormula.gif
5233 * where <code>Ialpha</code> and <code>Ibeta</code> are the stator vector components,
5234 * <code>pId</code> and <code>pIq</code> are rotor vector components and <code>cosVal</code> and <code>sinVal</code> are the
5235 * cosine and sine values of theta (rotor flux position).
5236 * \par Fixed-Point Behavior
5237 * Care must be taken when using the Q31 version of the Park transform.
5238 * In particular, the overflow and saturation behavior of the accumulator used must be considered.
5239 * Refer to the function specific documentation below for usage guidelines.
5240 */
5241
5242 /**
5243 * @addtogroup park
5244 * @{
5245 */
5246
5247 /**
5248 * @brief Floating-point Park transform
5249 * @param[in] Ialpha input two-phase vector coordinate alpha
5250 * @param[in] Ibeta input two-phase vector coordinate beta
5251 * @param[out] pId points to output rotor reference frame d
5252 * @param[out] pIq points to output rotor reference frame q
5253 * @param[in] sinVal sine value of rotation angle theta
5254 * @param[in] cosVal cosine value of rotation angle theta
5255 *
5256 * The function implements the forward Park transform.
5257 *
5258 */
5259 CMSIS_INLINE __STATIC_INLINE void arm_park_f32(
5260 float32_t Ialpha,
5261 float32_t Ibeta,
5262 float32_t * pId,
5263 float32_t * pIq,
5264 float32_t sinVal,
5265 float32_t cosVal)
5266 {
5267 /* Calculate pId using the equation, pId = Ialpha * cosVal + Ibeta * sinVal */
5268 *pId = Ialpha * cosVal + Ibeta * sinVal;
5269
5270 /* Calculate pIq using the equation, pIq = - Ialpha * sinVal + Ibeta * cosVal */
5271 *pIq = -Ialpha * sinVal + Ibeta * cosVal;
5272 }
5273
5274
5275 /**
5276 * @brief Park transform for Q31 version
5277 * @param[in] Ialpha input two-phase vector coordinate alpha
5278 * @param[in] Ibeta input two-phase vector coordinate beta
5279 * @param[out] pId points to output rotor reference frame d
5280 * @param[out] pIq points to output rotor reference frame q
5281 * @param[in] sinVal sine value of rotation angle theta
5282 * @param[in] cosVal cosine value of rotation angle theta
5283 *
5284 * <b>Scaling and Overflow Behavior:</b>
5285 * \par
5286 * The function is implemented using an internal 32-bit accumulator.
5287 * The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format.
5288 * There is saturation on the addition and subtraction, hence there is no risk of overflow.
5289 */
5290 CMSIS_INLINE __STATIC_INLINE void arm_park_q31(
5291 q31_t Ialpha,
5292 q31_t Ibeta,
5293 q31_t * pId,
5294 q31_t * pIq,
5295 q31_t sinVal,
5296 q31_t cosVal)
5297 {
5298 q31_t product1, product2; /* Temporary variables used to store intermediate results */
5299 q31_t product3, product4; /* Temporary variables used to store intermediate results */
5300
5301 /* Intermediate product is calculated by (Ialpha * cosVal) */
5302 product1 = (q31_t) (((q63_t) (Ialpha) * (cosVal)) >> 31);
5303
5304 /* Intermediate product is calculated by (Ibeta * sinVal) */
5305 product2 = (q31_t) (((q63_t) (Ibeta) * (sinVal)) >> 31);
5306
5307
5308 /* Intermediate product is calculated by (Ialpha * sinVal) */
5309 product3 = (q31_t) (((q63_t) (Ialpha) * (sinVal)) >> 31);
5310
5311 /* Intermediate product is calculated by (Ibeta * cosVal) */
5312 product4 = (q31_t) (((q63_t) (Ibeta) * (cosVal)) >> 31);
5313
5314 /* Calculate pId by adding the two intermediate products 1 and 2 */
5315 *pId = __QADD(product1, product2);
5316
5317 /* Calculate pIq by subtracting the two intermediate products 3 from 4 */
5318 *pIq = __QSUB(product4, product3);
5319 }
5320
5321 /**
5322 * @} end of park group
5323 */
5324
5325 /**
5326 * @brief Converts the elements of the Q7 vector to floating-point vector.
5327 * @param[in] pSrc is input pointer
5328 * @param[out] pDst is output pointer
5329 * @param[in] blockSize is the number of samples to process
5330 */
5331 void arm_q7_to_float(
5332 q7_t * pSrc,
5333 float32_t * pDst,
5334 uint32_t blockSize);
5335
5336
5337 /**
5338 * @ingroup groupController
5339 */
5340
5341 /**
5342 * @defgroup inv_park Vector Inverse Park transform
5343 * Inverse Park transform converts the input flux and torque components to two-coordinate vector.
5344 *
5345 * The function operates on a single sample of data and each call to the function returns the processed output.
5346 * The library provides separate functions for Q31 and floating-point data types.
5347 * \par Algorithm
5348 * \image html parkInvFormula.gif
5349 * where <code>pIalpha</code> and <code>pIbeta</code> are the stator vector components,
5350 * <code>Id</code> and <code>Iq</code> are rotor vector components and <code>cosVal</code> and <code>sinVal</code> are the
5351 * cosine and sine values of theta (rotor flux position).
5352 * \par Fixed-Point Behavior
5353 * Care must be taken when using the Q31 version of the Park transform.
5354 * In particular, the overflow and saturation behavior of the accumulator used must be considered.
5355 * Refer to the function specific documentation below for usage guidelines.
5356 */
5357
5358 /**
5359 * @addtogroup inv_park
5360 * @{
5361 */
5362
5363 /**
5364 * @brief Floating-point Inverse Park transform
5365 * @param[in] Id input coordinate of rotor reference frame d
5366 * @param[in] Iq input coordinate of rotor reference frame q
5367 * @param[out] pIalpha points to output two-phase orthogonal vector axis alpha
5368 * @param[out] pIbeta points to output two-phase orthogonal vector axis beta
5369 * @param[in] sinVal sine value of rotation angle theta
5370 * @param[in] cosVal cosine value of rotation angle theta
5371 */
5372 CMSIS_INLINE __STATIC_INLINE void arm_inv_park_f32(
5373 float32_t Id,
5374 float32_t Iq,
5375 float32_t * pIalpha,
5376 float32_t * pIbeta,
5377 float32_t sinVal,
5378 float32_t cosVal)
5379 {
5380 /* Calculate pIalpha using the equation, pIalpha = Id * cosVal - Iq * sinVal */
5381 *pIalpha = Id * cosVal - Iq * sinVal;
5382
5383 /* Calculate pIbeta using the equation, pIbeta = Id * sinVal + Iq * cosVal */
5384 *pIbeta = Id * sinVal + Iq * cosVal;
5385 }
5386
5387
5388 /**
5389 * @brief Inverse Park transform for Q31 version
5390 * @param[in] Id input coordinate of rotor reference frame d
5391 * @param[in] Iq input coordinate of rotor reference frame q
5392 * @param[out] pIalpha points to output two-phase orthogonal vector axis alpha
5393 * @param[out] pIbeta points to output two-phase orthogonal vector axis beta
5394 * @param[in] sinVal sine value of rotation angle theta
5395 * @param[in] cosVal cosine value of rotation angle theta
5396 *
5397 * <b>Scaling and Overflow Behavior:</b>
5398 * \par
5399 * The function is implemented using an internal 32-bit accumulator.
5400 * The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format.
5401 * There is saturation on the addition, hence there is no risk of overflow.
5402 */
5403 CMSIS_INLINE __STATIC_INLINE void arm_inv_park_q31(
5404 q31_t Id,
5405 q31_t Iq,
5406 q31_t * pIalpha,
5407 q31_t * pIbeta,
5408 q31_t sinVal,
5409 q31_t cosVal)
5410 {
5411 q31_t product1, product2; /* Temporary variables used to store intermediate results */
5412 q31_t product3, product4; /* Temporary variables used to store intermediate results */
5413
5414 /* Intermediate product is calculated by (Id * cosVal) */
5415 product1 = (q31_t) (((q63_t) (Id) * (cosVal)) >> 31);
5416
5417 /* Intermediate product is calculated by (Iq * sinVal) */
5418 product2 = (q31_t) (((q63_t) (Iq) * (sinVal)) >> 31);
5419
5420
5421 /* Intermediate product is calculated by (Id * sinVal) */
5422 product3 = (q31_t) (((q63_t) (Id) * (sinVal)) >> 31);
5423
5424 /* Intermediate product is calculated by (Iq * cosVal) */
5425 product4 = (q31_t) (((q63_t) (Iq) * (cosVal)) >> 31);
5426
5427 /* Calculate pIalpha by using the two intermediate products 1 and 2 */
5428 *pIalpha = __QSUB(product1, product2);
5429
5430 /* Calculate pIbeta by using the two intermediate products 3 and 4 */
5431 *pIbeta = __QADD(product4, product3);
5432 }
5433
5434 /**
5435 * @} end of Inverse park group
5436 */
5437
5438
5439 /**
5440 * @brief Converts the elements of the Q31 vector to floating-point vector.
5441 * @param[in] pSrc is input pointer
5442 * @param[out] pDst is output pointer
5443 * @param[in] blockSize is the number of samples to process
5444 */
5445 void arm_q31_to_float(
5446 q31_t * pSrc,
5447 float32_t * pDst,
5448 uint32_t blockSize);
5449
5450 /**
5451 * @ingroup groupInterpolation
5452 */
5453
5454 /**
5455 * @defgroup LinearInterpolate Linear Interpolation
5456 *
5457 * Linear interpolation is a method of curve fitting using linear polynomials.
5458 * Linear interpolation works by effectively drawing a straight line between two neighboring samples and returning the appropriate point along that line
5459 *
5460 * \par
5461 * \image html LinearInterp.gif "Linear interpolation"
5462 *
5463 * \par
5464 * A Linear Interpolate function calculates an output value(y), for the input(x)
5465 * using linear interpolation of the input values x0, x1( nearest input values) and the output values y0 and y1(nearest output values)
5466 *
5467 * \par Algorithm:
5468 * <pre>
5469 * y = y0 + (x - x0) * ((y1 - y0)/(x1-x0))
5470 * where x0, x1 are nearest values of input x
5471 * y0, y1 are nearest values to output y
5472 * </pre>
5473 *
5474 * \par
5475 * This set of functions implements Linear interpolation process
5476 * for Q7, Q15, Q31, and floating-point data types. The functions operate on a single
5477 * sample of data and each call to the function returns a single processed value.
5478 * <code>S</code> points to an instance of the Linear Interpolate function data structure.
5479 * <code>x</code> is the input sample value. The functions returns the output value.
5480 *
5481 * \par
5482 * if x is outside of the table boundary, Linear interpolation returns first value of the table
5483 * if x is below input range and returns last value of table if x is above range.
5484 */
5485
5486 /**
5487 * @addtogroup LinearInterpolate
5488 * @{
5489 */
5490
5491 /**
5492 * @brief Process function for the floating-point Linear Interpolation Function.
5493 * @param[in,out] S is an instance of the floating-point Linear Interpolation structure
5494 * @param[in] x input sample to process
5495 * @return y processed output sample.
5496 *
5497 */
5498 CMSIS_INLINE __STATIC_INLINE float32_t arm_linear_interp_f32(
5499 arm_linear_interp_instance_f32 * S,
5500 float32_t x)
5501 {
5502 float32_t y;
5503 float32_t x0, x1; /* Nearest input values */
5504 float32_t y0, y1; /* Nearest output values */
5505 float32_t xSpacing = S->xSpacing; /* spacing between input values */
5506 int32_t i; /* Index variable */
5507 float32_t *pYData = S->pYData; /* pointer to output table */
5508
5509 /* Calculation of index */
5510 i = (int32_t) ((x - S->x1) / xSpacing);
5511
5512 if (i < 0)
5513 {
5514 /* Iniatilize output for below specified range as least output value of table */
5515 y = pYData[0];
5516 }
5517 else if ((uint32_t)i >= S->nValues)
5518 {
5519 /* Iniatilize output for above specified range as last output value of table */
5520 y = pYData[S->nValues - 1];
5521 }
5522 else
5523 {
5524 /* Calculation of nearest input values */
5525 x0 = S->x1 + i * xSpacing;
5526 x1 = S->x1 + (i + 1) * xSpacing;
5527
5528 /* Read of nearest output values */
5529 y0 = pYData[i];
5530 y1 = pYData[i + 1];
5531
5532 /* Calculation of output */
5533 y = y0 + (x - x0) * ((y1 - y0) / (x1 - x0));
5534
5535 }
5536
5537 /* returns output value */
5538 return (y);
5539 }
5540
5541
5542 /**
5543 *
5544 * @brief Process function for the Q31 Linear Interpolation Function.
5545 * @param[in] pYData pointer to Q31 Linear Interpolation table
5546 * @param[in] x input sample to process
5547 * @param[in] nValues number of table values
5548 * @return y processed output sample.
5549 *
5550 * \par
5551 * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part.
5552 * This function can support maximum of table size 2^12.
5553 *
5554 */
5555 CMSIS_INLINE __STATIC_INLINE q31_t arm_linear_interp_q31(
5556 q31_t * pYData,
5557 q31_t x,
5558 uint32_t nValues)
5559 {
5560 q31_t y; /* output */
5561 q31_t y0, y1; /* Nearest output values */
5562 q31_t fract; /* fractional part */
5563 int32_t index; /* Index to read nearest output values */
5564
5565 /* Input is in 12.20 format */
5566 /* 12 bits for the table index */
5567 /* Index value calculation */
5568 index = ((x & (q31_t)0xFFF00000) >> 20);
5569
5570 if (index >= (int32_t)(nValues - 1))
5571 {
5572 return (pYData[nValues - 1]);
5573 }
5574 else if (index < 0)
5575 {
5576 return (pYData[0]);
5577 }
5578 else
5579 {
5580 /* 20 bits for the fractional part */
5581 /* shift left by 11 to keep fract in 1.31 format */
5582 fract = (x & 0x000FFFFF) << 11;
5583
5584 /* Read two nearest output values from the index in 1.31(q31) format */
5585 y0 = pYData[index];
5586 y1 = pYData[index + 1];
5587
5588 /* Calculation of y0 * (1-fract) and y is in 2.30 format */
5589 y = ((q31_t) ((q63_t) y0 * (0x7FFFFFFF - fract) >> 32));
5590
5591 /* Calculation of y0 * (1-fract) + y1 *fract and y is in 2.30 format */
5592 y += ((q31_t) (((q63_t) y1 * fract) >> 32));
5593
5594 /* Convert y to 1.31 format */
5595 return (y << 1u);
5596 }
5597 }
5598
5599
5600 /**
5601 *
5602 * @brief Process function for the Q15 Linear Interpolation Function.
5603 * @param[in] pYData pointer to Q15 Linear Interpolation table
5604 * @param[in] x input sample to process
5605 * @param[in] nValues number of table values
5606 * @return y processed output sample.
5607 *
5608 * \par
5609 * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part.
5610 * This function can support maximum of table size 2^12.
5611 *
5612 */
5613 CMSIS_INLINE __STATIC_INLINE q15_t arm_linear_interp_q15(
5614 q15_t * pYData,
5615 q31_t x,
5616 uint32_t nValues)
5617 {
5618 q63_t y; /* output */
5619 q15_t y0, y1; /* Nearest output values */
5620 q31_t fract; /* fractional part */
5621 int32_t index; /* Index to read nearest output values */
5622
5623 /* Input is in 12.20 format */
5624 /* 12 bits for the table index */
5625 /* Index value calculation */
5626 index = ((x & (int32_t)0xFFF00000) >> 20);
5627
5628 if (index >= (int32_t)(nValues - 1))
5629 {
5630 return (pYData[nValues - 1]);
5631 }
5632 else if (index < 0)
5633 {
5634 return (pYData[0]);
5635 }
5636 else
5637 {
5638 /* 20 bits for the fractional part */
5639 /* fract is in 12.20 format */
5640 fract = (x & 0x000FFFFF);
5641
5642 /* Read two nearest output values from the index */
5643 y0 = pYData[index];
5644 y1 = pYData[index + 1];
5645
5646 /* Calculation of y0 * (1-fract) and y is in 13.35 format */
5647 y = ((q63_t) y0 * (0xFFFFF - fract));
5648
5649 /* Calculation of (y0 * (1-fract) + y1 * fract) and y is in 13.35 format */
5650 y += ((q63_t) y1 * (fract));
5651
5652 /* convert y to 1.15 format */
5653 return (q15_t) (y >> 20);
5654 }
5655 }
5656
5657
5658 /**
5659 *
5660 * @brief Process function for the Q7 Linear Interpolation Function.
5661 * @param[in] pYData pointer to Q7 Linear Interpolation table
5662 * @param[in] x input sample to process
5663 * @param[in] nValues number of table values
5664 * @return y processed output sample.
5665 *
5666 * \par
5667 * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part.
5668 * This function can support maximum of table size 2^12.
5669 */
5670 CMSIS_INLINE __STATIC_INLINE q7_t arm_linear_interp_q7(
5671 q7_t * pYData,
5672 q31_t x,
5673 uint32_t nValues)
5674 {
5675 q31_t y; /* output */
5676 q7_t y0, y1; /* Nearest output values */
5677 q31_t fract; /* fractional part */
5678 uint32_t index; /* Index to read nearest output values */
5679
5680 /* Input is in 12.20 format */
5681 /* 12 bits for the table index */
5682 /* Index value calculation */
5683 if (x < 0)
5684 {
5685 return (pYData[0]);
5686 }
5687 index = (x >> 20) & 0xfff;
5688
5689 if (index >= (nValues - 1))
5690 {
5691 return (pYData[nValues - 1]);
5692 }
5693 else
5694 {
5695 /* 20 bits for the fractional part */
5696 /* fract is in 12.20 format */
5697 fract = (x & 0x000FFFFF);
5698
5699 /* Read two nearest output values from the index and are in 1.7(q7) format */
5700 y0 = pYData[index];
5701 y1 = pYData[index + 1];
5702
5703 /* Calculation of y0 * (1-fract ) and y is in 13.27(q27) format */
5704 y = ((y0 * (0xFFFFF - fract)));
5705
5706 /* Calculation of y1 * fract + y0 * (1-fract) and y is in 13.27(q27) format */
5707 y += (y1 * fract);
5708
5709 /* convert y to 1.7(q7) format */
5710 return (q7_t) (y >> 20);
5711 }
5712 }
5713
5714 /**
5715 * @} end of LinearInterpolate group
5716 */
5717
5718 /**
5719 * @brief Fast approximation to the trigonometric sine function for floating-point data.
5720 * @param[in] x input value in radians.
5721 * @return sin(x).
5722 */
5723 float32_t arm_sin_f32(
5724 float32_t x);
5725
5726
5727 /**
5728 * @brief Fast approximation to the trigonometric sine function for Q31 data.
5729 * @param[in] x Scaled input value in radians.
5730 * @return sin(x).
5731 */
5732 q31_t arm_sin_q31(
5733 q31_t x);
5734
5735
5736 /**
5737 * @brief Fast approximation to the trigonometric sine function for Q15 data.
5738 * @param[in] x Scaled input value in radians.
5739 * @return sin(x).
5740 */
5741 q15_t arm_sin_q15(
5742 q15_t x);
5743
5744
5745 /**
5746 * @brief Fast approximation to the trigonometric cosine function for floating-point data.
5747 * @param[in] x input value in radians.
5748 * @return cos(x).
5749 */
5750 float32_t arm_cos_f32(
5751 float32_t x);
5752
5753
5754 /**
5755 * @brief Fast approximation to the trigonometric cosine function for Q31 data.
5756 * @param[in] x Scaled input value in radians.
5757 * @return cos(x).
5758 */
5759 q31_t arm_cos_q31(
5760 q31_t x);
5761
5762
5763 /**
5764 * @brief Fast approximation to the trigonometric cosine function for Q15 data.
5765 * @param[in] x Scaled input value in radians.
5766 * @return cos(x).
5767 */
5768 q15_t arm_cos_q15(
5769 q15_t x);
5770
5771
5772 /**
5773 * @ingroup groupFastMath
5774 */
5775
5776
5777 /**
5778 * @defgroup SQRT Square Root
5779 *
5780 * Computes the square root of a number.
5781 * There are separate functions for Q15, Q31, and floating-point data types.
5782 * The square root function is computed using the Newton-Raphson algorithm.
5783 * This is an iterative algorithm of the form:
5784 * <pre>
5785 * x1 = x0 - f(x0)/f'(x0)
5786 * </pre>
5787 * where <code>x1</code> is the current estimate,
5788 * <code>x0</code> is the previous estimate, and
5789 * <code>f'(x0)</code> is the derivative of <code>f()</code> evaluated at <code>x0</code>.
5790 * For the square root function, the algorithm reduces to:
5791 * <pre>
5792 * x0 = in/2 [initial guess]
5793 * x1 = 1/2 * ( x0 + in / x0) [each iteration]
5794 * </pre>
5795 */
5796
5797
5798 /**
5799 * @addtogroup SQRT
5800 * @{
5801 */
5802
5803 /**
5804 * @brief Floating-point square root function.
5805 * @param[in] in input value.
5806 * @param[out] pOut square root of input value.
5807 * @return The function returns ARM_MATH_SUCCESS if input value is positive value or ARM_MATH_ARGUMENT_ERROR if
5808 * <code>in</code> is negative value and returns zero output for negative values.
5809 */
5810 CMSIS_INLINE __STATIC_INLINE arm_status arm_sqrt_f32(
5811 float32_t in,
5812 float32_t * pOut)
5813 {
5814 if (in >= 0.0f)
5815 {
5816
5817#if (__FPU_USED == 1) && defined ( __CC_ARM )
5818 *pOut = __sqrtf(in);
5819#elif (__FPU_USED == 1) && (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
5820 *pOut = __builtin_sqrtf(in);
5821#elif (__FPU_USED == 1) && defined(__GNUC__)
5822 *pOut = __builtin_sqrtf(in);
5823#elif (__FPU_USED == 1) && defined ( __ICCARM__ ) && (__VER__ >= 6040000)
5824 __ASM("VSQRT.F32 %0,%1" : "=t"(*pOut) : "t"(in));
5825#else
5826 *pOut = sqrtf(in);
5827#endif
5828
5829 return (ARM_MATH_SUCCESS);
5830 }
5831 else
5832 {
5833 *pOut = 0.0f;
5834 return (ARM_MATH_ARGUMENT_ERROR);
5835 }
5836 }
5837
5838
5839 /**
5840 * @brief Q31 square root function.
5841 * @param[in] in input value. The range of the input value is [0 +1) or 0x00000000 to 0x7FFFFFFF.
5842 * @param[out] pOut square root of input value.
5843 * @return The function returns ARM_MATH_SUCCESS if input value is positive value or ARM_MATH_ARGUMENT_ERROR if
5844 * <code>in</code> is negative value and returns zero output for negative values.
5845 */
5846 arm_status arm_sqrt_q31(
5847 q31_t in,
5848 q31_t * pOut);
5849
5850
5851 /**
5852 * @brief Q15 square root function.
5853 * @param[in] in input value. The range of the input value is [0 +1) or 0x0000 to 0x7FFF.
5854 * @param[out] pOut square root of input value.
5855 * @return The function returns ARM_MATH_SUCCESS if input value is positive value or ARM_MATH_ARGUMENT_ERROR if
5856 * <code>in</code> is negative value and returns zero output for negative values.
5857 */
5858 arm_status arm_sqrt_q15(
5859 q15_t in,
5860 q15_t * pOut);
5861
5862 /**
5863 * @} end of SQRT group
5864 */
5865
5866
5867 /**
5868 * @brief floating-point Circular write function.
5869 */
5870 CMSIS_INLINE __STATIC_INLINE void arm_circularWrite_f32(
5871 int32_t * circBuffer,
5872 int32_t L,
5873 uint16_t * writeOffset,
5874 int32_t bufferInc,
5875 const int32_t * src,
5876 int32_t srcInc,
5877 uint32_t blockSize)
5878 {
5879 uint32_t i = 0u;
5880 int32_t wOffset;
5881
5882 /* Copy the value of Index pointer that points
5883 * to the current location where the input samples to be copied */
5884 wOffset = *writeOffset;
5885
5886 /* Loop over the blockSize */
5887 i = blockSize;
5888
5889 while (i > 0u)
5890 {
5891 /* copy the input sample to the circular buffer */
5892 circBuffer[wOffset] = *src;
5893
5894 /* Update the input pointer */
5895 src += srcInc;
5896
5897 /* Circularly update wOffset. Watch out for positive and negative value */
5898 wOffset += bufferInc;
5899 if (wOffset >= L)
5900 wOffset -= L;
5901
5902 /* Decrement the loop counter */
5903 i--;
5904 }
5905
5906 /* Update the index pointer */
5907 *writeOffset = (uint16_t)wOffset;
5908 }
5909
5910
5911
5912 /**
5913 * @brief floating-point Circular Read function.
5914 */
5915 CMSIS_INLINE __STATIC_INLINE void arm_circularRead_f32(
5916 int32_t * circBuffer,
5917 int32_t L,
5918 int32_t * readOffset,
5919 int32_t bufferInc,
5920 int32_t * dst,
5921 int32_t * dst_base,
5922 int32_t dst_length,
5923 int32_t dstInc,
5924 uint32_t blockSize)
5925 {
5926 uint32_t i = 0u;
5927 int32_t rOffset, dst_end;
5928
5929 /* Copy the value of Index pointer that points
5930 * to the current location from where the input samples to be read */
5931 rOffset = *readOffset;
5932 dst_end = (int32_t) (dst_base + dst_length);
5933
5934 /* Loop over the blockSize */
5935 i = blockSize;
5936
5937 while (i > 0u)
5938 {
5939 /* copy the sample from the circular buffer to the destination buffer */
5940 *dst = circBuffer[rOffset];
5941
5942 /* Update the input pointer */
5943 dst += dstInc;
5944
5945 if (dst == (int32_t *) dst_end)
5946 {
5947 dst = dst_base;
5948 }
5949
5950 /* Circularly update rOffset. Watch out for positive and negative value */
5951 rOffset += bufferInc;
5952
5953 if (rOffset >= L)
5954 {
5955 rOffset -= L;
5956 }
5957
5958 /* Decrement the loop counter */
5959 i--;
5960 }
5961
5962 /* Update the index pointer */
5963 *readOffset = rOffset;
5964 }
5965
5966
5967 /**
5968 * @brief Q15 Circular write function.
5969 */
5970 CMSIS_INLINE __STATIC_INLINE void arm_circularWrite_q15(
5971 q15_t * circBuffer,
5972 int32_t L,
5973 uint16_t * writeOffset,
5974 int32_t bufferInc,
5975 const q15_t * src,
5976 int32_t srcInc,
5977 uint32_t blockSize)
5978 {
5979 uint32_t i = 0u;
5980 int32_t wOffset;
5981
5982 /* Copy the value of Index pointer that points
5983 * to the current location where the input samples to be copied */
5984 wOffset = *writeOffset;
5985
5986 /* Loop over the blockSize */
5987 i = blockSize;
5988
5989 while (i > 0u)
5990 {
5991 /* copy the input sample to the circular buffer */
5992 circBuffer[wOffset] = *src;
5993
5994 /* Update the input pointer */
5995 src += srcInc;
5996
5997 /* Circularly update wOffset. Watch out for positive and negative value */
5998 wOffset += bufferInc;
5999 if (wOffset >= L)
6000 wOffset -= L;
6001
6002 /* Decrement the loop counter */
6003 i--;
6004 }
6005
6006 /* Update the index pointer */
6007 *writeOffset = (uint16_t)wOffset;
6008 }
6009
6010
6011 /**
6012 * @brief Q15 Circular Read function.
6013 */
6014 CMSIS_INLINE __STATIC_INLINE void arm_circularRead_q15(
6015 q15_t * circBuffer,
6016 int32_t L,
6017 int32_t * readOffset,
6018 int32_t bufferInc,
6019 q15_t * dst,
6020 q15_t * dst_base,
6021 int32_t dst_length,
6022 int32_t dstInc,
6023 uint32_t blockSize)
6024 {
6025 uint32_t i = 0;
6026 int32_t rOffset, dst_end;
6027
6028 /* Copy the value of Index pointer that points
6029 * to the current location from where the input samples to be read */
6030 rOffset = *readOffset;
6031
6032 dst_end = (int32_t) (dst_base + dst_length);
6033
6034 /* Loop over the blockSize */
6035 i = blockSize;
6036
6037 while (i > 0u)
6038 {
6039 /* copy the sample from the circular buffer to the destination buffer */
6040 *dst = circBuffer[rOffset];
6041
6042 /* Update the input pointer */
6043 dst += dstInc;
6044
6045 if (dst == (q15_t *) dst_end)
6046 {
6047 dst = dst_base;
6048 }
6049
6050 /* Circularly update wOffset. Watch out for positive and negative value */
6051 rOffset += bufferInc;
6052
6053 if (rOffset >= L)
6054 {
6055 rOffset -= L;
6056 }
6057
6058 /* Decrement the loop counter */
6059 i--;
6060 }
6061
6062 /* Update the index pointer */
6063 *readOffset = rOffset;
6064 }
6065
6066
6067 /**
6068 * @brief Q7 Circular write function.
6069 */
6070 CMSIS_INLINE __STATIC_INLINE void arm_circularWrite_q7(
6071 q7_t * circBuffer,
6072 int32_t L,
6073 uint16_t * writeOffset,
6074 int32_t bufferInc,
6075 const q7_t * src,
6076 int32_t srcInc,
6077 uint32_t blockSize)
6078 {
6079 uint32_t i = 0u;
6080 int32_t wOffset;
6081
6082 /* Copy the value of Index pointer that points
6083 * to the current location where the input samples to be copied */
6084 wOffset = *writeOffset;
6085
6086 /* Loop over the blockSize */
6087 i = blockSize;
6088
6089 while (i > 0u)
6090 {
6091 /* copy the input sample to the circular buffer */
6092 circBuffer[wOffset] = *src;
6093
6094 /* Update the input pointer */
6095 src += srcInc;
6096
6097 /* Circularly update wOffset. Watch out for positive and negative value */
6098 wOffset += bufferInc;
6099 if (wOffset >= L)
6100 wOffset -= L;
6101
6102 /* Decrement the loop counter */
6103 i--;
6104 }
6105
6106 /* Update the index pointer */
6107 *writeOffset = (uint16_t)wOffset;
6108 }
6109
6110
6111 /**
6112 * @brief Q7 Circular Read function.
6113 */
6114 CMSIS_INLINE __STATIC_INLINE void arm_circularRead_q7(
6115 q7_t * circBuffer,
6116 int32_t L,
6117 int32_t * readOffset,
6118 int32_t bufferInc,
6119 q7_t * dst,
6120 q7_t * dst_base,
6121 int32_t dst_length,
6122 int32_t dstInc,
6123 uint32_t blockSize)
6124 {
6125 uint32_t i = 0;
6126 int32_t rOffset, dst_end;
6127
6128 /* Copy the value of Index pointer that points
6129 * to the current location from where the input samples to be read */
6130 rOffset = *readOffset;
6131
6132 dst_end = (int32_t) (dst_base + dst_length);
6133
6134 /* Loop over the blockSize */
6135 i = blockSize;
6136
6137 while (i > 0u)
6138 {
6139 /* copy the sample from the circular buffer to the destination buffer */
6140 *dst = circBuffer[rOffset];
6141
6142 /* Update the input pointer */
6143 dst += dstInc;
6144
6145 if (dst == (q7_t *) dst_end)
6146 {
6147 dst = dst_base;
6148 }
6149
6150 /* Circularly update rOffset. Watch out for positive and negative value */
6151 rOffset += bufferInc;
6152
6153 if (rOffset >= L)
6154 {
6155 rOffset -= L;
6156 }
6157
6158 /* Decrement the loop counter */
6159 i--;
6160 }
6161
6162 /* Update the index pointer */
6163 *readOffset = rOffset;
6164 }
6165
6166
6167 /**
6168 * @brief Sum of the squares of the elements of a Q31 vector.
6169 * @param[in] pSrc is input pointer
6170 * @param[in] blockSize is the number of samples to process
6171 * @param[out] pResult is output value.
6172 */
6173 void arm_power_q31(
6174 q31_t * pSrc,
6175 uint32_t blockSize,
6176 q63_t * pResult);
6177
6178
6179 /**
6180 * @brief Sum of the squares of the elements of a floating-point vector.
6181 * @param[in] pSrc is input pointer
6182 * @param[in] blockSize is the number of samples to process
6183 * @param[out] pResult is output value.
6184 */
6185 void arm_power_f32(
6186 float32_t * pSrc,
6187 uint32_t blockSize,
6188 float32_t * pResult);
6189
6190
6191 /**
6192 * @brief Sum of the squares of the elements of a Q15 vector.
6193 * @param[in] pSrc is input pointer
6194 * @param[in] blockSize is the number of samples to process
6195 * @param[out] pResult is output value.
6196 */
6197 void arm_power_q15(
6198 q15_t * pSrc,
6199 uint32_t blockSize,
6200 q63_t * pResult);
6201
6202
6203 /**
6204 * @brief Sum of the squares of the elements of a Q7 vector.
6205 * @param[in] pSrc is input pointer
6206 * @param[in] blockSize is the number of samples to process
6207 * @param[out] pResult is output value.
6208 */
6209 void arm_power_q7(
6210 q7_t * pSrc,
6211 uint32_t blockSize,
6212 q31_t * pResult);
6213
6214
6215 /**
6216 * @brief Mean value of a Q7 vector.
6217 * @param[in] pSrc is input pointer
6218 * @param[in] blockSize is the number of samples to process
6219 * @param[out] pResult is output value.
6220 */
6221 void arm_mean_q7(
6222 q7_t * pSrc,
6223 uint32_t blockSize,
6224 q7_t * pResult);
6225
6226
6227 /**
6228 * @brief Mean value of a Q15 vector.
6229 * @param[in] pSrc is input pointer
6230 * @param[in] blockSize is the number of samples to process
6231 * @param[out] pResult is output value.
6232 */
6233 void arm_mean_q15(
6234 q15_t * pSrc,
6235 uint32_t blockSize,
6236 q15_t * pResult);
6237
6238
6239 /**
6240 * @brief Mean value of a Q31 vector.
6241 * @param[in] pSrc is input pointer
6242 * @param[in] blockSize is the number of samples to process
6243 * @param[out] pResult is output value.
6244 */
6245 void arm_mean_q31(
6246 q31_t * pSrc,
6247 uint32_t blockSize,
6248 q31_t * pResult);
6249
6250
6251 /**
6252 * @brief Mean value of a floating-point vector.
6253 * @param[in] pSrc is input pointer
6254 * @param[in] blockSize is the number of samples to process
6255 * @param[out] pResult is output value.
6256 */
6257 void arm_mean_f32(
6258 float32_t * pSrc,
6259 uint32_t blockSize,
6260 float32_t * pResult);
6261
6262
6263 /**
6264 * @brief Variance of the elements of a floating-point vector.
6265 * @param[in] pSrc is input pointer
6266 * @param[in] blockSize is the number of samples to process
6267 * @param[out] pResult is output value.
6268 */
6269 void arm_var_f32(
6270 float32_t * pSrc,
6271 uint32_t blockSize,
6272 float32_t * pResult);
6273
6274
6275 /**
6276 * @brief Variance of the elements of a Q31 vector.
6277 * @param[in] pSrc is input pointer
6278 * @param[in] blockSize is the number of samples to process
6279 * @param[out] pResult is output value.
6280 */
6281 void arm_var_q31(
6282 q31_t * pSrc,
6283 uint32_t blockSize,
6284 q31_t * pResult);
6285
6286
6287 /**
6288 * @brief Variance of the elements of a Q15 vector.
6289 * @param[in] pSrc is input pointer
6290 * @param[in] blockSize is the number of samples to process
6291 * @param[out] pResult is output value.
6292 */
6293 void arm_var_q15(
6294 q15_t * pSrc,
6295 uint32_t blockSize,
6296 q15_t * pResult);
6297
6298
6299 /**
6300 * @brief Root Mean Square of the elements of a floating-point vector.
6301 * @param[in] pSrc is input pointer
6302 * @param[in] blockSize is the number of samples to process
6303 * @param[out] pResult is output value.
6304 */
6305 void arm_rms_f32(
6306 float32_t * pSrc,
6307 uint32_t blockSize,
6308 float32_t * pResult);
6309
6310
6311 /**
6312 * @brief Root Mean Square of the elements of a Q31 vector.
6313 * @param[in] pSrc is input pointer
6314 * @param[in] blockSize is the number of samples to process
6315 * @param[out] pResult is output value.
6316 */
6317 void arm_rms_q31(
6318 q31_t * pSrc,
6319 uint32_t blockSize,
6320 q31_t * pResult);
6321
6322
6323 /**
6324 * @brief Root Mean Square of the elements of a Q15 vector.
6325 * @param[in] pSrc is input pointer
6326 * @param[in] blockSize is the number of samples to process
6327 * @param[out] pResult is output value.
6328 */
6329 void arm_rms_q15(
6330 q15_t * pSrc,
6331 uint32_t blockSize,
6332 q15_t * pResult);
6333
6334
6335 /**
6336 * @brief Standard deviation of the elements of a floating-point vector.
6337 * @param[in] pSrc is input pointer
6338 * @param[in] blockSize is the number of samples to process
6339 * @param[out] pResult is output value.
6340 */
6341 void arm_std_f32(
6342 float32_t * pSrc,
6343 uint32_t blockSize,
6344 float32_t * pResult);
6345
6346
6347 /**
6348 * @brief Standard deviation of the elements of a Q31 vector.
6349 * @param[in] pSrc is input pointer
6350 * @param[in] blockSize is the number of samples to process
6351 * @param[out] pResult is output value.
6352 */
6353 void arm_std_q31(
6354 q31_t * pSrc,
6355 uint32_t blockSize,
6356 q31_t * pResult);
6357
6358
6359 /**
6360 * @brief Standard deviation of the elements of a Q15 vector.
6361 * @param[in] pSrc is input pointer
6362 * @param[in] blockSize is the number of samples to process
6363 * @param[out] pResult is output value.
6364 */
6365 void arm_std_q15(
6366 q15_t * pSrc,
6367 uint32_t blockSize,
6368 q15_t * pResult);
6369
6370
6371 /**
6372 * @brief Floating-point complex magnitude
6373 * @param[in] pSrc points to the complex input vector
6374 * @param[out] pDst points to the real output vector
6375 * @param[in] numSamples number of complex samples in the input vector
6376 */
6377 void arm_cmplx_mag_f32(
6378 float32_t * pSrc,
6379 float32_t * pDst,
6380 uint32_t numSamples);
6381
6382
6383 /**
6384 * @brief Q31 complex magnitude
6385 * @param[in] pSrc points to the complex input vector
6386 * @param[out] pDst points to the real output vector
6387 * @param[in] numSamples number of complex samples in the input vector
6388 */
6389 void arm_cmplx_mag_q31(
6390 q31_t * pSrc,
6391 q31_t * pDst,
6392 uint32_t numSamples);
6393
6394
6395 /**
6396 * @brief Q15 complex magnitude
6397 * @param[in] pSrc points to the complex input vector
6398 * @param[out] pDst points to the real output vector
6399 * @param[in] numSamples number of complex samples in the input vector
6400 */
6401 void arm_cmplx_mag_q15(
6402 q15_t * pSrc,
6403 q15_t * pDst,
6404 uint32_t numSamples);
6405
6406
6407 /**
6408 * @brief Q15 complex dot product
6409 * @param[in] pSrcA points to the first input vector
6410 * @param[in] pSrcB points to the second input vector
6411 * @param[in] numSamples number of complex samples in each vector
6412 * @param[out] realResult real part of the result returned here
6413 * @param[out] imagResult imaginary part of the result returned here
6414 */
6415 void arm_cmplx_dot_prod_q15(
6416 q15_t * pSrcA,
6417 q15_t * pSrcB,
6418 uint32_t numSamples,
6419 q31_t * realResult,
6420 q31_t * imagResult);
6421
6422
6423 /**
6424 * @brief Q31 complex dot product
6425 * @param[in] pSrcA points to the first input vector
6426 * @param[in] pSrcB points to the second input vector
6427 * @param[in] numSamples number of complex samples in each vector
6428 * @param[out] realResult real part of the result returned here
6429 * @param[out] imagResult imaginary part of the result returned here
6430 */
6431 void arm_cmplx_dot_prod_q31(
6432 q31_t * pSrcA,
6433 q31_t * pSrcB,
6434 uint32_t numSamples,
6435 q63_t * realResult,
6436 q63_t * imagResult);
6437
6438
6439 /**
6440 * @brief Floating-point complex dot product
6441 * @param[in] pSrcA points to the first input vector
6442 * @param[in] pSrcB points to the second input vector
6443 * @param[in] numSamples number of complex samples in each vector
6444 * @param[out] realResult real part of the result returned here
6445 * @param[out] imagResult imaginary part of the result returned here
6446 */
6447 void arm_cmplx_dot_prod_f32(
6448 float32_t * pSrcA,
6449 float32_t * pSrcB,
6450 uint32_t numSamples,
6451 float32_t * realResult,
6452 float32_t * imagResult);
6453
6454
6455 /**
6456 * @brief Q15 complex-by-real multiplication
6457 * @param[in] pSrcCmplx points to the complex input vector
6458 * @param[in] pSrcReal points to the real input vector
6459 * @param[out] pCmplxDst points to the complex output vector
6460 * @param[in] numSamples number of samples in each vector
6461 */
6462 void arm_cmplx_mult_real_q15(
6463 q15_t * pSrcCmplx,
6464 q15_t * pSrcReal,
6465 q15_t * pCmplxDst,
6466 uint32_t numSamples);
6467
6468
6469 /**
6470 * @brief Q31 complex-by-real multiplication
6471 * @param[in] pSrcCmplx points to the complex input vector
6472 * @param[in] pSrcReal points to the real input vector
6473 * @param[out] pCmplxDst points to the complex output vector
6474 * @param[in] numSamples number of samples in each vector
6475 */
6476 void arm_cmplx_mult_real_q31(
6477 q31_t * pSrcCmplx,
6478 q31_t * pSrcReal,
6479 q31_t * pCmplxDst,
6480 uint32_t numSamples);
6481
6482
6483 /**
6484 * @brief Floating-point complex-by-real multiplication
6485 * @param[in] pSrcCmplx points to the complex input vector
6486 * @param[in] pSrcReal points to the real input vector
6487 * @param[out] pCmplxDst points to the complex output vector
6488 * @param[in] numSamples number of samples in each vector
6489 */
6490 void arm_cmplx_mult_real_f32(
6491 float32_t * pSrcCmplx,
6492 float32_t * pSrcReal,
6493 float32_t * pCmplxDst,
6494 uint32_t numSamples);
6495
6496
6497 /**
6498 * @brief Minimum value of a Q7 vector.
6499 * @param[in] pSrc is input pointer
6500 * @param[in] blockSize is the number of samples to process
6501 * @param[out] result is output pointer
6502 * @param[in] index is the array index of the minimum value in the input buffer.
6503 */
6504 void arm_min_q7(
6505 q7_t * pSrc,
6506 uint32_t blockSize,
6507 q7_t * result,
6508 uint32_t * index);
6509
6510
6511 /**
6512 * @brief Minimum value of a Q15 vector.
6513 * @param[in] pSrc is input pointer
6514 * @param[in] blockSize is the number of samples to process
6515 * @param[out] pResult is output pointer
6516 * @param[in] pIndex is the array index of the minimum value in the input buffer.
6517 */
6518 void arm_min_q15(
6519 q15_t * pSrc,
6520 uint32_t blockSize,
6521 q15_t * pResult,
6522 uint32_t * pIndex);
6523
6524
6525 /**
6526 * @brief Minimum value of a Q31 vector.
6527 * @param[in] pSrc is input pointer
6528 * @param[in] blockSize is the number of samples to process
6529 * @param[out] pResult is output pointer
6530 * @param[out] pIndex is the array index of the minimum value in the input buffer.
6531 */
6532 void arm_min_q31(
6533 q31_t * pSrc,
6534 uint32_t blockSize,
6535 q31_t * pResult,
6536 uint32_t * pIndex);
6537
6538
6539 /**
6540 * @brief Minimum value of a floating-point vector.
6541 * @param[in] pSrc is input pointer
6542 * @param[in] blockSize is the number of samples to process
6543 * @param[out] pResult is output pointer
6544 * @param[out] pIndex is the array index of the minimum value in the input buffer.
6545 */
6546 void arm_min_f32(
6547 float32_t * pSrc,
6548 uint32_t blockSize,
6549 float32_t * pResult,
6550 uint32_t * pIndex);
6551
6552
6553/**
6554 * @brief Maximum value of a Q7 vector.
6555 * @param[in] pSrc points to the input buffer
6556 * @param[in] blockSize length of the input vector
6557 * @param[out] pResult maximum value returned here
6558 * @param[out] pIndex index of maximum value returned here
6559 */
6560 void arm_max_q7(
6561 q7_t * pSrc,
6562 uint32_t blockSize,
6563 q7_t * pResult,
6564 uint32_t * pIndex);
6565
6566
6567/**
6568 * @brief Maximum value of a Q15 vector.
6569 * @param[in] pSrc points to the input buffer
6570 * @param[in] blockSize length of the input vector
6571 * @param[out] pResult maximum value returned here
6572 * @param[out] pIndex index of maximum value returned here
6573 */
6574 void arm_max_q15(
6575 q15_t * pSrc,
6576 uint32_t blockSize,
6577 q15_t * pResult,
6578 uint32_t * pIndex);
6579
6580
6581/**
6582 * @brief Maximum value of a Q31 vector.
6583 * @param[in] pSrc points to the input buffer
6584 * @param[in] blockSize length of the input vector
6585 * @param[out] pResult maximum value returned here
6586 * @param[out] pIndex index of maximum value returned here
6587 */
6588 void arm_max_q31(
6589 q31_t * pSrc,
6590 uint32_t blockSize,
6591 q31_t * pResult,
6592 uint32_t * pIndex);
6593
6594
6595/**
6596 * @brief Maximum value of a floating-point vector.
6597 * @param[in] pSrc points to the input buffer
6598 * @param[in] blockSize length of the input vector
6599 * @param[out] pResult maximum value returned here
6600 * @param[out] pIndex index of maximum value returned here
6601 */
6602 void arm_max_f32(
6603 float32_t * pSrc,
6604 uint32_t blockSize,
6605 float32_t * pResult,
6606 uint32_t * pIndex);
6607
6608
6609 /**
6610 * @brief Q15 complex-by-complex multiplication
6611 * @param[in] pSrcA points to the first input vector
6612 * @param[in] pSrcB points to the second input vector
6613 * @param[out] pDst points to the output vector
6614 * @param[in] numSamples number of complex samples in each vector
6615 */
6616 void arm_cmplx_mult_cmplx_q15(
6617 q15_t * pSrcA,
6618 q15_t * pSrcB,
6619 q15_t * pDst,
6620 uint32_t numSamples);
6621
6622
6623 /**
6624 * @brief Q31 complex-by-complex multiplication
6625 * @param[in] pSrcA points to the first input vector
6626 * @param[in] pSrcB points to the second input vector
6627 * @param[out] pDst points to the output vector
6628 * @param[in] numSamples number of complex samples in each vector
6629 */
6630 void arm_cmplx_mult_cmplx_q31(
6631 q31_t * pSrcA,
6632 q31_t * pSrcB,
6633 q31_t * pDst,
6634 uint32_t numSamples);
6635
6636
6637 /**
6638 * @brief Floating-point complex-by-complex multiplication
6639 * @param[in] pSrcA points to the first input vector
6640 * @param[in] pSrcB points to the second input vector
6641 * @param[out] pDst points to the output vector
6642 * @param[in] numSamples number of complex samples in each vector
6643 */
6644 void arm_cmplx_mult_cmplx_f32(
6645 float32_t * pSrcA,
6646 float32_t * pSrcB,
6647 float32_t * pDst,
6648 uint32_t numSamples);
6649
6650
6651 /**
6652 * @brief Converts the elements of the floating-point vector to Q31 vector.
6653 * @param[in] pSrc points to the floating-point input vector
6654 * @param[out] pDst points to the Q31 output vector
6655 * @param[in] blockSize length of the input vector
6656 */
6657 void arm_float_to_q31(
6658 float32_t * pSrc,
6659 q31_t * pDst,
6660 uint32_t blockSize);
6661
6662
6663 /**
6664 * @brief Converts the elements of the floating-point vector to Q15 vector.
6665 * @param[in] pSrc points to the floating-point input vector
6666 * @param[out] pDst points to the Q15 output vector
6667 * @param[in] blockSize length of the input vector
6668 */
6669 void arm_float_to_q15(
6670 float32_t * pSrc,
6671 q15_t * pDst,
6672 uint32_t blockSize);
6673
6674
6675 /**
6676 * @brief Converts the elements of the floating-point vector to Q7 vector.
6677 * @param[in] pSrc points to the floating-point input vector
6678 * @param[out] pDst points to the Q7 output vector
6679 * @param[in] blockSize length of the input vector
6680 */
6681 void arm_float_to_q7(
6682 float32_t * pSrc,
6683 q7_t * pDst,
6684 uint32_t blockSize);
6685
6686
6687 /**
6688 * @brief Converts the elements of the Q31 vector to Q15 vector.
6689 * @param[in] pSrc is input pointer
6690 * @param[out] pDst is output pointer
6691 * @param[in] blockSize is the number of samples to process
6692 */
6693 void arm_q31_to_q15(
6694 q31_t * pSrc,
6695 q15_t * pDst,
6696 uint32_t blockSize);
6697
6698
6699 /**
6700 * @brief Converts the elements of the Q31 vector to Q7 vector.
6701 * @param[in] pSrc is input pointer
6702 * @param[out] pDst is output pointer
6703 * @param[in] blockSize is the number of samples to process
6704 */
6705 void arm_q31_to_q7(
6706 q31_t * pSrc,
6707 q7_t * pDst,
6708 uint32_t blockSize);
6709
6710
6711 /**
6712 * @brief Converts the elements of the Q15 vector to floating-point vector.
6713 * @param[in] pSrc is input pointer
6714 * @param[out] pDst is output pointer
6715 * @param[in] blockSize is the number of samples to process
6716 */
6717 void arm_q15_to_float(
6718 q15_t * pSrc,
6719 float32_t * pDst,
6720 uint32_t blockSize);
6721
6722
6723 /**
6724 * @brief Converts the elements of the Q15 vector to Q31 vector.
6725 * @param[in] pSrc is input pointer
6726 * @param[out] pDst is output pointer
6727 * @param[in] blockSize is the number of samples to process
6728 */
6729 void arm_q15_to_q31(
6730 q15_t * pSrc,
6731 q31_t * pDst,
6732 uint32_t blockSize);
6733
6734
6735 /**
6736 * @brief Converts the elements of the Q15 vector to Q7 vector.
6737 * @param[in] pSrc is input pointer
6738 * @param[out] pDst is output pointer
6739 * @param[in] blockSize is the number of samples to process
6740 */
6741 void arm_q15_to_q7(
6742 q15_t * pSrc,
6743 q7_t * pDst,
6744 uint32_t blockSize);
6745
6746
6747 /**
6748 * @ingroup groupInterpolation
6749 */
6750
6751 /**
6752 * @defgroup BilinearInterpolate Bilinear Interpolation
6753 *
6754 * Bilinear interpolation is an extension of linear interpolation applied to a two dimensional grid.
6755 * The underlying function <code>f(x, y)</code> is sampled on a regular grid and the interpolation process
6756 * determines values between the grid points.
6757 * Bilinear interpolation is equivalent to two step linear interpolation, first in the x-dimension and then in the y-dimension.
6758 * Bilinear interpolation is often used in image processing to rescale images.
6759 * The CMSIS DSP library provides bilinear interpolation functions for Q7, Q15, Q31, and floating-point data types.
6760 *
6761 * <b>Algorithm</b>
6762 * \par
6763 * The instance structure used by the bilinear interpolation functions describes a two dimensional data table.
6764 * For floating-point, the instance structure is defined as:
6765 * <pre>
6766 * typedef struct
6767 * {
6768 * uint16_t numRows;
6769 * uint16_t numCols;
6770 * float32_t *pData;
6771 * } arm_bilinear_interp_instance_f32;
6772 * </pre>
6773 *
6774 * \par
6775 * where <code>numRows</code> specifies the number of rows in the table;
6776 * <code>numCols</code> specifies the number of columns in the table;
6777 * and <code>pData</code> points to an array of size <code>numRows*numCols</code> values.
6778 * The data table <code>pTable</code> is organized in row order and the supplied data values fall on integer indexes.
6779 * That is, table element (x,y) is located at <code>pTable[x + y*numCols]</code> where x and y are integers.
6780 *
6781 * \par
6782 * Let <code>(x, y)</code> specify the desired interpolation point. Then define:
6783 * <pre>
6784 * XF = floor(x)
6785 * YF = floor(y)
6786 * </pre>
6787 * \par
6788 * The interpolated output point is computed as:
6789 * <pre>
6790 * f(x, y) = f(XF, YF) * (1-(x-XF)) * (1-(y-YF))
6791 * + f(XF+1, YF) * (x-XF)*(1-(y-YF))
6792 * + f(XF, YF+1) * (1-(x-XF))*(y-YF)
6793 * + f(XF+1, YF+1) * (x-XF)*(y-YF)
6794 * </pre>
6795 * Note that the coordinates (x, y) contain integer and fractional components.
6796 * The integer components specify which portion of the table to use while the
6797 * fractional components control the interpolation processor.
6798 *
6799 * \par
6800 * if (x,y) are outside of the table boundary, Bilinear interpolation returns zero output.
6801 */
6802
6803 /**
6804 * @addtogroup BilinearInterpolate
6805 * @{
6806 */
6807
6808
6809 /**
6810 *
6811 * @brief Floating-point bilinear interpolation.
6812 * @param[in,out] S points to an instance of the interpolation structure.
6813 * @param[in] X interpolation coordinate.
6814 * @param[in] Y interpolation coordinate.
6815 * @return out interpolated value.
6816 */
6817 CMSIS_INLINE __STATIC_INLINE float32_t arm_bilinear_interp_f32(
6818 const arm_bilinear_interp_instance_f32 * S,
6819 float32_t X,
6820 float32_t Y)
6821 {
6822 float32_t out;
6823 float32_t f00, f01, f10, f11;
6824 float32_t *pData = S->pData;
6825 int32_t xIndex, yIndex, index;
6826 float32_t xdiff, ydiff;
6827 float32_t b1, b2, b3, b4;
6828
6829 xIndex = (int32_t) X;
6830 yIndex = (int32_t) Y;
6831
6832 /* Care taken for table outside boundary */
6833 /* Returns zero output when values are outside table boundary */
6834 if (xIndex < 0 || xIndex > (S->numRows - 1) || yIndex < 0 || yIndex > (S->numCols - 1))
6835 {
6836 return (0);
6837 }
6838
6839 /* Calculation of index for two nearest points in X-direction */
6840 index = (xIndex - 1) + (yIndex - 1) * S->numCols;
6841
6842
6843 /* Read two nearest points in X-direction */
6844 f00 = pData[index];
6845 f01 = pData[index + 1];
6846
6847 /* Calculation of index for two nearest points in Y-direction */
6848 index = (xIndex - 1) + (yIndex) * S->numCols;
6849
6850
6851 /* Read two nearest points in Y-direction */
6852 f10 = pData[index];
6853 f11 = pData[index + 1];
6854
6855 /* Calculation of intermediate values */
6856 b1 = f00;
6857 b2 = f01 - f00;
6858 b3 = f10 - f00;
6859 b4 = f00 - f01 - f10 + f11;
6860
6861 /* Calculation of fractional part in X */
6862 xdiff = X - xIndex;
6863
6864 /* Calculation of fractional part in Y */
6865 ydiff = Y - yIndex;
6866
6867 /* Calculation of bi-linear interpolated output */
6868 out = b1 + b2 * xdiff + b3 * ydiff + b4 * xdiff * ydiff;
6869
6870 /* return to application */
6871 return (out);
6872 }
6873
6874
6875 /**
6876 *
6877 * @brief Q31 bilinear interpolation.
6878 * @param[in,out] S points to an instance of the interpolation structure.
6879 * @param[in] X interpolation coordinate in 12.20 format.
6880 * @param[in] Y interpolation coordinate in 12.20 format.
6881 * @return out interpolated value.
6882 */
6883 CMSIS_INLINE __STATIC_INLINE q31_t arm_bilinear_interp_q31(
6884 arm_bilinear_interp_instance_q31 * S,
6885 q31_t X,
6886 q31_t Y)
6887 {
6888 q31_t out; /* Temporary output */
6889 q31_t acc = 0; /* output */
6890 q31_t xfract, yfract; /* X, Y fractional parts */
6891 q31_t x1, x2, y1, y2; /* Nearest output values */
6892 int32_t rI, cI; /* Row and column indices */
6893 q31_t *pYData = S->pData; /* pointer to output table values */
6894 uint32_t nCols = S->numCols; /* num of rows */
6895
6896 /* Input is in 12.20 format */
6897 /* 12 bits for the table index */
6898 /* Index value calculation */
6899 rI = ((X & (q31_t)0xFFF00000) >> 20);
6900
6901 /* Input is in 12.20 format */
6902 /* 12 bits for the table index */
6903 /* Index value calculation */
6904 cI = ((Y & (q31_t)0xFFF00000) >> 20);
6905
6906 /* Care taken for table outside boundary */
6907 /* Returns zero output when values are outside table boundary */
6908 if (rI < 0 || rI > (S->numRows - 1) || cI < 0 || cI > (S->numCols - 1))
6909 {
6910 return (0);
6911 }
6912
6913 /* 20 bits for the fractional part */
6914 /* shift left xfract by 11 to keep 1.31 format */
6915 xfract = (X & 0x000FFFFF) << 11u;
6916
6917 /* Read two nearest output values from the index */
6918 x1 = pYData[(rI) + (int32_t)nCols * (cI) ];
6919 x2 = pYData[(rI) + (int32_t)nCols * (cI) + 1];
6920
6921 /* 20 bits for the fractional part */
6922 /* shift left yfract by 11 to keep 1.31 format */
6923 yfract = (Y & 0x000FFFFF) << 11u;
6924
6925 /* Read two nearest output values from the index */
6926 y1 = pYData[(rI) + (int32_t)nCols * (cI + 1) ];
6927 y2 = pYData[(rI) + (int32_t)nCols * (cI + 1) + 1];
6928
6929 /* Calculation of x1 * (1-xfract ) * (1-yfract) and acc is in 3.29(q29) format */
6930 out = ((q31_t) (((q63_t) x1 * (0x7FFFFFFF - xfract)) >> 32));
6931 acc = ((q31_t) (((q63_t) out * (0x7FFFFFFF - yfract)) >> 32));
6932
6933 /* x2 * (xfract) * (1-yfract) in 3.29(q29) and adding to acc */
6934 out = ((q31_t) ((q63_t) x2 * (0x7FFFFFFF - yfract) >> 32));
6935 acc += ((q31_t) ((q63_t) out * (xfract) >> 32));
6936
6937 /* y1 * (1 - xfract) * (yfract) in 3.29(q29) and adding to acc */
6938 out = ((q31_t) ((q63_t) y1 * (0x7FFFFFFF - xfract) >> 32));
6939 acc += ((q31_t) ((q63_t) out * (yfract) >> 32));
6940
6941 /* y2 * (xfract) * (yfract) in 3.29(q29) and adding to acc */
6942 out = ((q31_t) ((q63_t) y2 * (xfract) >> 32));
6943 acc += ((q31_t) ((q63_t) out * (yfract) >> 32));
6944
6945 /* Convert acc to 1.31(q31) format */
6946 return ((q31_t)(acc << 2));
6947 }
6948
6949
6950 /**
6951 * @brief Q15 bilinear interpolation.
6952 * @param[in,out] S points to an instance of the interpolation structure.
6953 * @param[in] X interpolation coordinate in 12.20 format.
6954 * @param[in] Y interpolation coordinate in 12.20 format.
6955 * @return out interpolated value.
6956 */
6957 CMSIS_INLINE __STATIC_INLINE q15_t arm_bilinear_interp_q15(
6958 arm_bilinear_interp_instance_q15 * S,
6959 q31_t X,
6960 q31_t Y)
6961 {
6962 q63_t acc = 0; /* output */
6963 q31_t out; /* Temporary output */
6964 q15_t x1, x2, y1, y2; /* Nearest output values */
6965 q31_t xfract, yfract; /* X, Y fractional parts */
6966 int32_t rI, cI; /* Row and column indices */
6967 q15_t *pYData = S->pData; /* pointer to output table values */
6968 uint32_t nCols = S->numCols; /* num of rows */
6969
6970 /* Input is in 12.20 format */
6971 /* 12 bits for the table index */
6972 /* Index value calculation */
6973 rI = ((X & (q31_t)0xFFF00000) >> 20);
6974
6975 /* Input is in 12.20 format */
6976 /* 12 bits for the table index */
6977 /* Index value calculation */
6978 cI = ((Y & (q31_t)0xFFF00000) >> 20);
6979
6980 /* Care taken for table outside boundary */
6981 /* Returns zero output when values are outside table boundary */
6982 if (rI < 0 || rI > (S->numRows - 1) || cI < 0 || cI > (S->numCols - 1))
6983 {
6984 return (0);
6985 }
6986
6987 /* 20 bits for the fractional part */
6988 /* xfract should be in 12.20 format */
6989 xfract = (X & 0x000FFFFF);
6990
6991 /* Read two nearest output values from the index */
6992 x1 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI) ];
6993 x2 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI) + 1];
6994
6995 /* 20 bits for the fractional part */
6996 /* yfract should be in 12.20 format */
6997 yfract = (Y & 0x000FFFFF);
6998
6999 /* Read two nearest output values from the index */
7000 y1 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI + 1) ];
7001 y2 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI + 1) + 1];
7002
7003 /* Calculation of x1 * (1-xfract ) * (1-yfract) and acc is in 13.51 format */
7004
7005 /* x1 is in 1.15(q15), xfract in 12.20 format and out is in 13.35 format */
7006 /* convert 13.35 to 13.31 by right shifting and out is in 1.31 */
7007 out = (q31_t) (((q63_t) x1 * (0xFFFFF - xfract)) >> 4u);
7008 acc = ((q63_t) out * (0xFFFFF - yfract));
7009
7010 /* x2 * (xfract) * (1-yfract) in 1.51 and adding to acc */
7011 out = (q31_t) (((q63_t) x2 * (0xFFFFF - yfract)) >> 4u);
7012 acc += ((q63_t) out * (xfract));
7013
7014 /* y1 * (1 - xfract) * (yfract) in 1.51 and adding to acc */
7015 out = (q31_t) (((q63_t) y1 * (0xFFFFF - xfract)) >> 4u);
7016 acc += ((q63_t) out * (yfract));
7017
7018 /* y2 * (xfract) * (yfract) in 1.51 and adding to acc */
7019 out = (q31_t) (((q63_t) y2 * (xfract)) >> 4u);
7020 acc += ((q63_t) out * (yfract));
7021
7022 /* acc is in 13.51 format and down shift acc by 36 times */
7023 /* Convert out to 1.15 format */
7024 return ((q15_t)(acc >> 36));
7025 }
7026
7027
7028 /**
7029 * @brief Q7 bilinear interpolation.
7030 * @param[in,out] S points to an instance of the interpolation structure.
7031 * @param[in] X interpolation coordinate in 12.20 format.
7032 * @param[in] Y interpolation coordinate in 12.20 format.
7033 * @return out interpolated value.
7034 */
7035 CMSIS_INLINE __STATIC_INLINE q7_t arm_bilinear_interp_q7(
7036 arm_bilinear_interp_instance_q7 * S,
7037 q31_t X,
7038 q31_t Y)
7039 {
7040 q63_t acc = 0; /* output */
7041 q31_t out; /* Temporary output */
7042 q31_t xfract, yfract; /* X, Y fractional parts */
7043 q7_t x1, x2, y1, y2; /* Nearest output values */
7044 int32_t rI, cI; /* Row and column indices */
7045 q7_t *pYData = S->pData; /* pointer to output table values */
7046 uint32_t nCols = S->numCols; /* num of rows */
7047
7048 /* Input is in 12.20 format */
7049 /* 12 bits for the table index */
7050 /* Index value calculation */
7051 rI = ((X & (q31_t)0xFFF00000) >> 20);
7052
7053 /* Input is in 12.20 format */
7054 /* 12 bits for the table index */
7055 /* Index value calculation */
7056 cI = ((Y & (q31_t)0xFFF00000) >> 20);
7057
7058 /* Care taken for table outside boundary */
7059 /* Returns zero output when values are outside table boundary */
7060 if (rI < 0 || rI > (S->numRows - 1) || cI < 0 || cI > (S->numCols - 1))
7061 {
7062 return (0);
7063 }
7064
7065 /* 20 bits for the fractional part */
7066 /* xfract should be in 12.20 format */
7067 xfract = (X & (q31_t)0x000FFFFF);
7068
7069 /* Read two nearest output values from the index */
7070 x1 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI) ];
7071 x2 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI) + 1];
7072
7073 /* 20 bits for the fractional part */
7074 /* yfract should be in 12.20 format */
7075 yfract = (Y & (q31_t)0x000FFFFF);
7076
7077 /* Read two nearest output values from the index */
7078 y1 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI + 1) ];
7079 y2 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI + 1) + 1];
7080
7081 /* Calculation of x1 * (1-xfract ) * (1-yfract) and acc is in 16.47 format */
7082 out = ((x1 * (0xFFFFF - xfract)));
7083 acc = (((q63_t) out * (0xFFFFF - yfract)));
7084
7085 /* x2 * (xfract) * (1-yfract) in 2.22 and adding to acc */
7086 out = ((x2 * (0xFFFFF - yfract)));
7087 acc += (((q63_t) out * (xfract)));
7088
7089 /* y1 * (1 - xfract) * (yfract) in 2.22 and adding to acc */
7090 out = ((y1 * (0xFFFFF - xfract)));
7091 acc += (((q63_t) out * (yfract)));
7092
7093 /* y2 * (xfract) * (yfract) in 2.22 and adding to acc */
7094 out = ((y2 * (yfract)));
7095 acc += (((q63_t) out * (xfract)));
7096
7097 /* acc in 16.47 format and down shift by 40 to convert to 1.7 format */
7098 return ((q7_t)(acc >> 40));
7099 }
7100
7101 /**
7102 * @} end of BilinearInterpolate group
7103 */
7104
7105
7106/* SMMLAR */
7107#define multAcc_32x32_keep32_R(a, x, y) \
7108 a = (q31_t) (((((q63_t) a) << 32) + ((q63_t) x * y) + 0x80000000LL ) >> 32)
7109
7110/* SMMLSR */
7111#define multSub_32x32_keep32_R(a, x, y) \
7112 a = (q31_t) (((((q63_t) a) << 32) - ((q63_t) x * y) + 0x80000000LL ) >> 32)
7113
7114/* SMMULR */
7115#define mult_32x32_keep32_R(a, x, y) \
7116 a = (q31_t) (((q63_t) x * y + 0x80000000LL ) >> 32)
7117
7118/* SMMLA */
7119#define multAcc_32x32_keep32(a, x, y) \
7120 a += (q31_t) (((q63_t) x * y) >> 32)
7121
7122/* SMMLS */
7123#define multSub_32x32_keep32(a, x, y) \
7124 a -= (q31_t) (((q63_t) x * y) >> 32)
7125
7126/* SMMUL */
7127#define mult_32x32_keep32(a, x, y) \
7128 a = (q31_t) (((q63_t) x * y ) >> 32)
7129
7130
7131#if defined ( __CC_ARM )
7132 /* Enter low optimization region - place directly above function definition */
7133 #if defined( ARM_MATH_CM4 ) || defined( ARM_MATH_CM7)
7134 #define LOW_OPTIMIZATION_ENTER \
7135 _Pragma ("push") \
7136 _Pragma ("O1")
7137 #else
7138 #define LOW_OPTIMIZATION_ENTER
7139 #endif
7140
7141 /* Exit low optimization region - place directly after end of function definition */
7142 #if defined ( ARM_MATH_CM4 ) || defined ( ARM_MATH_CM7 )
7143 #define LOW_OPTIMIZATION_EXIT \
7144 _Pragma ("pop")
7145 #else
7146 #define LOW_OPTIMIZATION_EXIT
7147 #endif
7148
7149 /* Enter low optimization region - place directly above function definition */
7150 #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
7151
7152 /* Exit low optimization region - place directly after end of function definition */
7153 #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
7154
7155#elif defined (__ARMCC_VERSION ) && ( __ARMCC_VERSION >= 6010050 )
7156 #define LOW_OPTIMIZATION_ENTER
7157 #define LOW_OPTIMIZATION_EXIT
7158 #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
7159 #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
7160
7161#elif defined ( __GNUC__ )
7162 #define LOW_OPTIMIZATION_ENTER \
7163 __attribute__(( optimize("-O1") ))
7164 #define LOW_OPTIMIZATION_EXIT
7165 #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
7166 #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
7167
7168#elif defined ( __ICCARM__ )
7169 /* Enter low optimization region - place directly above function definition */
7170 #if defined ( ARM_MATH_CM4 ) || defined ( ARM_MATH_CM7 )
7171 #define LOW_OPTIMIZATION_ENTER \
7172 _Pragma ("optimize=low")
7173 #else
7174 #define LOW_OPTIMIZATION_ENTER
7175 #endif
7176
7177 /* Exit low optimization region - place directly after end of function definition */
7178 #define LOW_OPTIMIZATION_EXIT
7179
7180 /* Enter low optimization region - place directly above function definition */
7181 #if defined ( ARM_MATH_CM4 ) || defined ( ARM_MATH_CM7 )
7182 #define IAR_ONLY_LOW_OPTIMIZATION_ENTER \
7183 _Pragma ("optimize=low")
7184 #else
7185 #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
7186 #endif
7187
7188 /* Exit low optimization region - place directly after end of function definition */
7189 #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
7190
7191#elif defined ( __TI_ARM__ )
7192 #define LOW_OPTIMIZATION_ENTER
7193 #define LOW_OPTIMIZATION_EXIT
7194 #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
7195 #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
7196
7197#elif defined ( __CSMC__ )
7198 #define LOW_OPTIMIZATION_ENTER
7199 #define LOW_OPTIMIZATION_EXIT
7200 #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
7201 #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
7202
7203#elif defined ( __TASKING__ )
7204 #define LOW_OPTIMIZATION_ENTER
7205 #define LOW_OPTIMIZATION_EXIT
7206 #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
7207 #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
7208
7209#endif
7210
7211
7212#ifdef __cplusplus
7213}
7214#endif
7215
7216
7217#if defined ( __GNUC__ )
7218#pragma GCC diagnostic pop
7219#endif
7220
7221#endif /* _ARM_MATH_H */
7222
7223/**
7224 *
7225 * End of file.
7226 */
diff --git a/lib/arm_atsam/packs/arm/cmsis/5.0.1/CMSIS/Include/cmsis_compiler.h b/lib/arm_atsam/packs/arm/cmsis/5.0.1/CMSIS/Include/cmsis_compiler.h
new file mode 100644
index 000000000..8b989f851
--- /dev/null
+++ b/lib/arm_atsam/packs/arm/cmsis/5.0.1/CMSIS/Include/cmsis_compiler.h
@@ -0,0 +1,223 @@
1/**************************************************************************//**
2 * @file cmsis_compiler.h
3 * @brief CMSIS compiler generic header file
4 * @version V5.0.1
5 * @date 30. January 2017
6 ******************************************************************************/
7/*
8 * Copyright (c) 2009-2017 ARM Limited. All rights reserved.
9 *
10 * SPDX-License-Identifier: Apache-2.0
11 *
12 * Licensed under the Apache License, Version 2.0 (the License); you may
13 * not use this file except in compliance with the License.
14 * You may obtain a copy of the License at
15 *
16 * www.apache.org/licenses/LICENSE-2.0
17 *
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
20 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
23 */
24
25#ifndef __CMSIS_COMPILER_H
26#define __CMSIS_COMPILER_H
27
28#include <stdint.h>
29
30/*
31 * ARM Compiler 4/5
32 */
33#if defined ( __CC_ARM )
34 #include "cmsis_armcc.h"
35
36
37/*
38 * ARM Compiler 6 (armclang)
39 */
40#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
41 #include "cmsis_armclang.h"
42
43
44/*
45 * GNU Compiler
46 */
47#elif defined ( __GNUC__ )
48 #include "cmsis_gcc.h"
49
50
51/*
52 * IAR Compiler
53 */
54#elif defined ( __ICCARM__ )
55
56 #ifndef __ASM
57 #define __ASM __asm
58 #endif
59 #ifndef __INLINE
60 #define __INLINE inline
61 #endif
62 #ifndef __STATIC_INLINE
63 #define __STATIC_INLINE static inline
64 #endif
65
66 #include <cmsis_iar.h>
67
68 #ifndef __NO_RETURN
69 #define __NO_RETURN __noreturn
70 #endif
71 #ifndef __USED
72 #define __USED __root
73 #endif
74 #ifndef __WEAK
75 #define __WEAK __weak
76 #endif
77 #ifndef __UNALIGNED_UINT32
78 __packed struct T_UINT32 { uint32_t v; };
79 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
80 #endif
81 #ifndef __ALIGNED
82 #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored.
83 #define __ALIGNED(x)
84 #endif
85 #ifndef __PACKED
86 #define __PACKED __packed
87 #endif
88 #ifndef __PACKED_STRUCT
89 #define __PACKED_STRUCT __packed struct
90 #endif
91
92
93/*
94 * TI ARM Compiler
95 */
96#elif defined ( __TI_ARM__ )
97 #include <cmsis_ccs.h>
98
99 #ifndef __ASM
100 #define __ASM __asm
101 #endif
102 #ifndef __INLINE
103 #define __INLINE inline
104 #endif
105 #ifndef __STATIC_INLINE
106 #define __STATIC_INLINE static inline
107 #endif
108 #ifndef __NO_RETURN
109 #define __NO_RETURN __attribute__((noreturn))
110 #endif
111 #ifndef __USED
112 #define __USED __attribute__((used))
113 #endif
114 #ifndef __WEAK
115 #define __WEAK __attribute__((weak))
116 #endif
117 #ifndef __UNALIGNED_UINT32
118 struct __attribute__((packed)) T_UINT32 { uint32_t v; };
119 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
120 #endif
121 #ifndef __ALIGNED
122 #define __ALIGNED(x) __attribute__((aligned(x)))
123 #endif
124 #ifndef __PACKED
125 #define __PACKED __attribute__((packed))
126 #endif
127 #ifndef __PACKED_STRUCT
128 #define __PACKED_STRUCT struct __attribute__((packed))
129 #endif
130
131
132/*
133 * TASKING Compiler
134 */
135#elif defined ( __TASKING__ )
136 /*
137 * The CMSIS functions have been implemented as intrinsics in the compiler.
138 * Please use "carm -?i" to get an up to date list of all intrinsics,
139 * Including the CMSIS ones.
140 */
141
142 #ifndef __ASM
143 #define __ASM __asm
144 #endif
145 #ifndef __INLINE
146 #define __INLINE inline
147 #endif
148 #ifndef __STATIC_INLINE
149 #define __STATIC_INLINE static inline
150 #endif
151 #ifndef __NO_RETURN
152 #define __NO_RETURN __attribute__((noreturn))
153 #endif
154 #ifndef __USED
155 #define __USED __attribute__((used))
156 #endif
157 #ifndef __WEAK
158 #define __WEAK __attribute__((weak))
159 #endif
160 #ifndef __UNALIGNED_UINT32
161 struct __packed__ T_UINT32 { uint32_t v; };
162 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
163 #endif
164 #ifndef __ALIGNED
165 #define __ALIGNED(x) __align(x)
166 #endif
167 #ifndef __PACKED
168 #define __PACKED __packed__
169 #endif
170 #ifndef __PACKED_STRUCT
171 #define __PACKED_STRUCT struct __packed__
172 #endif
173
174
175/*
176 * COSMIC Compiler
177 */
178#elif defined ( __CSMC__ )
179 #include <cmsis_csm.h>
180
181 #ifndef __ASM
182 #define __ASM _asm
183 #endif
184 #ifndef __INLINE
185 #define __INLINE inline
186 #endif
187 #ifndef __STATIC_INLINE
188 #define __STATIC_INLINE static inline
189 #endif
190 #ifndef __NO_RETURN
191 // NO RETURN is automatically detected hence no warning here
192 #define __NO_RETURN
193 #endif
194 #ifndef __USED
195 #warning No compiler specific solution for __USED. __USED is ignored.
196 #define __USED
197 #endif
198 #ifndef __WEAK
199 #define __WEAK __weak
200 #endif
201 #ifndef __UNALIGNED_UINT32
202 @packed struct T_UINT32 { uint32_t v; };
203 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
204 #endif
205 #ifndef __ALIGNED
206 #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored.
207 #define __ALIGNED(x)
208 #endif
209 #ifndef __PACKED
210 #define __PACKED @packed
211 #endif
212 #ifndef __PACKED_STRUCT
213 #define __PACKED_STRUCT @packed struct
214 #endif
215
216
217#else
218 #error Unknown compiler.
219#endif
220
221
222#endif /* __CMSIS_COMPILER_H */
223
diff --git a/lib/arm_atsam/packs/arm/cmsis/5.0.1/CMSIS/Include/cmsis_gcc.h b/lib/arm_atsam/packs/arm/cmsis/5.0.1/CMSIS/Include/cmsis_gcc.h
new file mode 100644
index 000000000..074cd7ab3
--- /dev/null
+++ b/lib/arm_atsam/packs/arm/cmsis/5.0.1/CMSIS/Include/cmsis_gcc.h
@@ -0,0 +1,1899 @@
1/**************************************************************************//**
2 * @file cmsis_gcc.h
3 * @brief CMSIS compiler GCC header file
4 * @version V5.0.1
5 * @date 02. February 2017
6 ******************************************************************************/
7/*
8 * Copyright (c) 2009-2017 ARM Limited. All rights reserved.
9 *
10 * SPDX-License-Identifier: Apache-2.0
11 *
12 * Licensed under the Apache License, Version 2.0 (the License); you may
13 * not use this file except in compliance with the License.
14 * You may obtain a copy of the License at
15 *
16 * www.apache.org/licenses/LICENSE-2.0
17 *
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
20 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
23 */
24
25#ifndef __CMSIS_GCC_H
26#define __CMSIS_GCC_H
27
28/* ignore some GCC warnings */
29#pragma GCC diagnostic push
30#pragma GCC diagnostic ignored "-Wsign-conversion"
31#pragma GCC diagnostic ignored "-Wconversion"
32#pragma GCC diagnostic ignored "-Wunused-parameter"
33
34/* CMSIS compiler specific defines */
35#ifndef __ASM
36 #define __ASM __asm
37#endif
38#ifndef __INLINE
39 #define __INLINE inline
40#endif
41#ifndef __STATIC_INLINE
42 #define __STATIC_INLINE static inline
43#endif
44#ifndef __NO_RETURN
45 #define __NO_RETURN __attribute__((noreturn))
46#endif
47#ifndef __USED
48 #define __USED __attribute__((used))
49#endif
50#ifndef __WEAK
51 #define __WEAK __attribute__((weak))
52#endif
53#ifndef __UNALIGNED_UINT32
54#pragma GCC diagnostic push
55#pragma GCC diagnostic ignored "-Wpacked"
56#pragma GCC diagnostic ignored "-Wattributes"
57 struct __attribute__((packed)) T_UINT32 { uint32_t v; };
58#pragma GCC diagnostic pop
59 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
60#endif
61#ifndef __ALIGNED
62 #define __ALIGNED(x) __attribute__((aligned(x)))
63#endif
64#ifndef __PACKED
65 #define __PACKED __attribute__((packed, aligned(1)))
66#endif
67#ifndef __PACKED_STRUCT
68 #define __PACKED_STRUCT struct __attribute__((packed, aligned(1)))
69#endif
70
71
72/* ########################### Core Function Access ########################### */
73/** \ingroup CMSIS_Core_FunctionInterface
74 \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
75 @{
76 */
77
78/**
79 \brief Enable IRQ Interrupts
80 \details Enables IRQ interrupts by clearing the I-bit in the CPSR.
81 Can only be executed in Privileged modes.
82 */
83__attribute__((always_inline)) __STATIC_INLINE void __enable_irq(void)
84{
85 __ASM volatile ("cpsie i" : : : "memory");
86}
87
88
89/**
90 \brief Disable IRQ Interrupts
91 \details Disables IRQ interrupts by setting the I-bit in the CPSR.
92 Can only be executed in Privileged modes.
93 */
94__attribute__((always_inline)) __STATIC_INLINE void __disable_irq(void)
95{
96 __ASM volatile ("cpsid i" : : : "memory");
97}
98
99
100/**
101 \brief Get Control Register
102 \details Returns the content of the Control Register.
103 \return Control Register value
104 */
105__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_CONTROL(void)
106{
107 uint32_t result;
108
109 __ASM volatile ("MRS %0, control" : "=r" (result) );
110 return(result);
111}
112
113
114#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
115/**
116 \brief Get Control Register (non-secure)
117 \details Returns the content of the non-secure Control Register when in secure mode.
118 \return non-secure Control Register value
119 */
120__attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_CONTROL_NS(void)
121{
122 uint32_t result;
123
124 __ASM volatile ("MRS %0, control_ns" : "=r" (result) );
125 return(result);
126}
127#endif
128
129
130/**
131 \brief Set Control Register
132 \details Writes the given value to the Control Register.
133 \param [in] control Control Register value to set
134 */
135__attribute__((always_inline)) __STATIC_INLINE void __set_CONTROL(uint32_t control)
136{
137 __ASM volatile ("MSR control, %0" : : "r" (control) : "memory");
138}
139
140
141#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
142/**
143 \brief Set Control Register (non-secure)
144 \details Writes the given value to the non-secure Control Register when in secure state.
145 \param [in] control Control Register value to set
146 */
147__attribute__((always_inline)) __STATIC_INLINE void __TZ_set_CONTROL_NS(uint32_t control)
148{
149 __ASM volatile ("MSR control_ns, %0" : : "r" (control) : "memory");
150}
151#endif
152
153
154/**
155 \brief Get IPSR Register
156 \details Returns the content of the IPSR Register.
157 \return IPSR Register value
158 */
159__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_IPSR(void)
160{
161 uint32_t result;
162
163 __ASM volatile ("MRS %0, ipsr" : "=r" (result) );
164 return(result);
165}
166
167
168/**
169 \brief Get APSR Register
170 \details Returns the content of the APSR Register.
171 \return APSR Register value
172 */
173__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_APSR(void)
174{
175 uint32_t result;
176
177 __ASM volatile ("MRS %0, apsr" : "=r" (result) );
178 return(result);
179}
180
181
182/**
183 \brief Get xPSR Register
184 \details Returns the content of the xPSR Register.
185 \return xPSR Register value
186 */
187__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_xPSR(void)
188{
189 uint32_t result;
190
191 __ASM volatile ("MRS %0, xpsr" : "=r" (result) );
192 return(result);
193}
194
195
196/**
197 \brief Get Process Stack Pointer
198 \details Returns the current value of the Process Stack Pointer (PSP).
199 \return PSP Register value
200 */
201__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PSP(void)
202{
203 register uint32_t result;
204
205 __ASM volatile ("MRS %0, psp" : "=r" (result) );
206 return(result);
207}
208
209
210#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
211/**
212 \brief Get Process Stack Pointer (non-secure)
213 \details Returns the current value of the non-secure Process Stack Pointer (PSP) when in secure state.
214 \return PSP Register value
215 */
216__attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_PSP_NS(void)
217{
218 register uint32_t result;
219
220 __ASM volatile ("MRS %0, psp_ns" : "=r" (result) );
221 return(result);
222}
223#endif
224
225
226/**
227 \brief Set Process Stack Pointer
228 \details Assigns the given value to the Process Stack Pointer (PSP).
229 \param [in] topOfProcStack Process Stack Pointer value to set
230 */
231__attribute__((always_inline)) __STATIC_INLINE void __set_PSP(uint32_t topOfProcStack)
232{
233 __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : );
234}
235
236
237#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
238/**
239 \brief Set Process Stack Pointer (non-secure)
240 \details Assigns the given value to the non-secure Process Stack Pointer (PSP) when in secure state.
241 \param [in] topOfProcStack Process Stack Pointer value to set
242 */
243__attribute__((always_inline)) __STATIC_INLINE void __TZ_set_PSP_NS(uint32_t topOfProcStack)
244{
245 __ASM volatile ("MSR psp_ns, %0" : : "r" (topOfProcStack) : );
246}
247#endif
248
249
250/**
251 \brief Get Main Stack Pointer
252 \details Returns the current value of the Main Stack Pointer (MSP).
253 \return MSP Register value
254 */
255__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_MSP(void)
256{
257 register uint32_t result;
258
259 __ASM volatile ("MRS %0, msp" : "=r" (result) );
260 return(result);
261}
262
263
264#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
265/**
266 \brief Get Main Stack Pointer (non-secure)
267 \details Returns the current value of the non-secure Main Stack Pointer (MSP) when in secure state.
268 \return MSP Register value
269 */
270__attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_MSP_NS(void)
271{
272 register uint32_t result;
273
274 __ASM volatile ("MRS %0, msp_ns" : "=r" (result) );
275 return(result);
276}
277#endif
278
279
280/**
281 \brief Set Main Stack Pointer
282 \details Assigns the given value to the Main Stack Pointer (MSP).
283 \param [in] topOfMainStack Main Stack Pointer value to set
284 */
285__attribute__((always_inline)) __STATIC_INLINE void __set_MSP(uint32_t topOfMainStack)
286{
287 __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : );
288}
289
290
291#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
292/**
293 \brief Set Main Stack Pointer (non-secure)
294 \details Assigns the given value to the non-secure Main Stack Pointer (MSP) when in secure state.
295 \param [in] topOfMainStack Main Stack Pointer value to set
296 */
297__attribute__((always_inline)) __STATIC_INLINE void __TZ_set_MSP_NS(uint32_t topOfMainStack)
298{
299 __ASM volatile ("MSR msp_ns, %0" : : "r" (topOfMainStack) : );
300}
301#endif
302
303
304/**
305 \brief Get Priority Mask
306 \details Returns the current state of the priority mask bit from the Priority Mask Register.
307 \return Priority Mask value
308 */
309__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PRIMASK(void)
310{
311 uint32_t result;
312
313 __ASM volatile ("MRS %0, primask" : "=r" (result) );
314 return(result);
315}
316
317
318#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
319/**
320 \brief Get Priority Mask (non-secure)
321 \details Returns the current state of the non-secure priority mask bit from the Priority Mask Register when in secure state.
322 \return Priority Mask value
323 */
324__attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_PRIMASK_NS(void)
325{
326 uint32_t result;
327
328 __ASM volatile ("MRS %0, primask_ns" : "=r" (result) );
329 return(result);
330}
331#endif
332
333
334/**
335 \brief Set Priority Mask
336 \details Assigns the given value to the Priority Mask Register.
337 \param [in] priMask Priority Mask
338 */
339__attribute__((always_inline)) __STATIC_INLINE void __set_PRIMASK(uint32_t priMask)
340{
341 __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory");
342}
343
344
345#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
346/**
347 \brief Set Priority Mask (non-secure)
348 \details Assigns the given value to the non-secure Priority Mask Register when in secure state.
349 \param [in] priMask Priority Mask
350 */
351__attribute__((always_inline)) __STATIC_INLINE void __TZ_set_PRIMASK_NS(uint32_t priMask)
352{
353 __ASM volatile ("MSR primask_ns, %0" : : "r" (priMask) : "memory");
354}
355#endif
356
357
358#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
359 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
360 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
361/**
362 \brief Enable FIQ
363 \details Enables FIQ interrupts by clearing the F-bit in the CPSR.
364 Can only be executed in Privileged modes.
365 */
366__attribute__((always_inline)) __STATIC_INLINE void __enable_fault_irq(void)
367{
368 __ASM volatile ("cpsie f" : : : "memory");
369}
370
371
372/**
373 \brief Disable FIQ
374 \details Disables FIQ interrupts by setting the F-bit in the CPSR.
375 Can only be executed in Privileged modes.
376 */
377__attribute__((always_inline)) __STATIC_INLINE void __disable_fault_irq(void)
378{
379 __ASM volatile ("cpsid f" : : : "memory");
380}
381
382
383/**
384 \brief Get Base Priority
385 \details Returns the current value of the Base Priority register.
386 \return Base Priority register value
387 */
388__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_BASEPRI(void)
389{
390 uint32_t result;
391
392 __ASM volatile ("MRS %0, basepri" : "=r" (result) );
393 return(result);
394}
395
396
397#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
398/**
399 \brief Get Base Priority (non-secure)
400 \details Returns the current value of the non-secure Base Priority register when in secure state.
401 \return Base Priority register value
402 */
403__attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_BASEPRI_NS(void)
404{
405 uint32_t result;
406
407 __ASM volatile ("MRS %0, basepri_ns" : "=r" (result) );
408 return(result);
409}
410#endif
411
412
413/**
414 \brief Set Base Priority
415 \details Assigns the given value to the Base Priority register.
416 \param [in] basePri Base Priority value to set
417 */
418__attribute__((always_inline)) __STATIC_INLINE void __set_BASEPRI(uint32_t basePri)
419{
420 __ASM volatile ("MSR basepri, %0" : : "r" (basePri) : "memory");
421}
422
423
424#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
425/**
426 \brief Set Base Priority (non-secure)
427 \details Assigns the given value to the non-secure Base Priority register when in secure state.
428 \param [in] basePri Base Priority value to set
429 */
430__attribute__((always_inline)) __STATIC_INLINE void __TZ_set_BASEPRI_NS(uint32_t basePri)
431{
432 __ASM volatile ("MSR basepri_ns, %0" : : "r" (basePri) : "memory");
433}
434#endif
435
436
437/**
438 \brief Set Base Priority with condition
439 \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled,
440 or the new value increases the BASEPRI priority level.
441 \param [in] basePri Base Priority value to set
442 */
443__attribute__((always_inline)) __STATIC_INLINE void __set_BASEPRI_MAX(uint32_t basePri)
444{
445 __ASM volatile ("MSR basepri_max, %0" : : "r" (basePri) : "memory");
446}
447
448
449/**
450 \brief Get Fault Mask
451 \details Returns the current value of the Fault Mask register.
452 \return Fault Mask register value
453 */
454__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_FAULTMASK(void)
455{
456 uint32_t result;
457
458 __ASM volatile ("MRS %0, faultmask" : "=r" (result) );
459 return(result);
460}
461
462
463#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
464/**
465 \brief Get Fault Mask (non-secure)
466 \details Returns the current value of the non-secure Fault Mask register when in secure state.
467 \return Fault Mask register value
468 */
469__attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_FAULTMASK_NS(void)
470{
471 uint32_t result;
472
473 __ASM volatile ("MRS %0, faultmask_ns" : "=r" (result) );
474 return(result);
475}
476#endif
477
478
479/**
480 \brief Set Fault Mask
481 \details Assigns the given value to the Fault Mask register.
482 \param [in] faultMask Fault Mask value to set
483 */
484__attribute__((always_inline)) __STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask)
485{
486 __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory");
487}
488
489
490#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
491/**
492 \brief Set Fault Mask (non-secure)
493 \details Assigns the given value to the non-secure Fault Mask register when in secure state.
494 \param [in] faultMask Fault Mask value to set
495 */
496__attribute__((always_inline)) __STATIC_INLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask)
497{
498 __ASM volatile ("MSR faultmask_ns, %0" : : "r" (faultMask) : "memory");
499}
500#endif
501
502#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
503 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
504 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
505
506
507#if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
508 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
509
510/**
511 \brief Get Process Stack Pointer Limit
512 \details Returns the current value of the Process Stack Pointer Limit (PSPLIM).
513 \return PSPLIM Register value
514 */
515__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PSPLIM(void)
516{
517 register uint32_t result;
518
519 __ASM volatile ("MRS %0, psplim" : "=r" (result) );
520 return(result);
521}
522
523
524#if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
525 (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
526/**
527 \brief Get Process Stack Pointer Limit (non-secure)
528 \details Returns the current value of the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state.
529 \return PSPLIM Register value
530 */
531__attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_PSPLIM_NS(void)
532{
533 register uint32_t result;
534
535 __ASM volatile ("MRS %0, psplim_ns" : "=r" (result) );
536 return(result);
537}
538#endif
539
540
541/**
542 \brief Set Process Stack Pointer Limit
543 \details Assigns the given value to the Process Stack Pointer Limit (PSPLIM).
544 \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set
545 */
546__attribute__((always_inline)) __STATIC_INLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit)
547{
548 __ASM volatile ("MSR psplim, %0" : : "r" (ProcStackPtrLimit));
549}
550
551
552#if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
553 (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
554/**
555 \brief Set Process Stack Pointer (non-secure)
556 \details Assigns the given value to the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state.
557 \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set
558 */
559__attribute__((always_inline)) __STATIC_INLINE void __TZ_set_PSPLIM_NS(uint32_t ProcStackPtrLimit)
560{
561 __ASM volatile ("MSR psplim_ns, %0\n" : : "r" (ProcStackPtrLimit));
562}
563#endif
564
565
566/**
567 \brief Get Main Stack Pointer Limit
568 \details Returns the current value of the Main Stack Pointer Limit (MSPLIM).
569 \return MSPLIM Register value
570 */
571__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_MSPLIM(void)
572{
573 register uint32_t result;
574
575 __ASM volatile ("MRS %0, msplim" : "=r" (result) );
576
577 return(result);
578}
579
580
581#if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
582 (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
583/**
584 \brief Get Main Stack Pointer Limit (non-secure)
585 \details Returns the current value of the non-secure Main Stack Pointer Limit(MSPLIM) when in secure state.
586 \return MSPLIM Register value
587 */
588__attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_MSPLIM_NS(void)
589{
590 register uint32_t result;
591
592 __ASM volatile ("MRS %0, msplim_ns" : "=r" (result) );
593 return(result);
594}
595#endif
596
597
598/**
599 \brief Set Main Stack Pointer Limit
600 \details Assigns the given value to the Main Stack Pointer Limit (MSPLIM).
601 \param [in] MainStackPtrLimit Main Stack Pointer Limit value to set
602 */
603__attribute__((always_inline)) __STATIC_INLINE void __set_MSPLIM(uint32_t MainStackPtrLimit)
604{
605 __ASM volatile ("MSR msplim, %0" : : "r" (MainStackPtrLimit));
606}
607
608
609#if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
610 (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
611/**
612 \brief Set Main Stack Pointer Limit (non-secure)
613 \details Assigns the given value to the non-secure Main Stack Pointer Limit (MSPLIM) when in secure state.
614 \param [in] MainStackPtrLimit Main Stack Pointer value to set
615 */
616__attribute__((always_inline)) __STATIC_INLINE void __TZ_set_MSPLIM_NS(uint32_t MainStackPtrLimit)
617{
618 __ASM volatile ("MSR msplim_ns, %0" : : "r" (MainStackPtrLimit));
619}
620#endif
621
622#endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
623 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
624
625
626#if ((defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
627 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
628
629/**
630 \brief Get FPSCR
631 \details Returns the current value of the Floating Point Status/Control register.
632 \return Floating Point Status/Control register value
633 */
634__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_FPSCR(void)
635{
636#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
637 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
638 uint32_t result;
639
640 __ASM volatile ("VMRS %0, fpscr" : "=r" (result) );
641 return(result);
642#else
643 return(0U);
644#endif
645}
646
647
648/**
649 \brief Set FPSCR
650 \details Assigns the given value to the Floating Point Status/Control register.
651 \param [in] fpscr Floating Point Status/Control value to set
652 */
653__attribute__((always_inline)) __STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
654{
655#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
656 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
657 __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) : "vfpcc", "memory");
658#else
659 (void)fpscr;
660#endif
661}
662
663#endif /* ((defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
664 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
665
666
667
668/*@} end of CMSIS_Core_RegAccFunctions */
669
670
671/* ########################## Core Instruction Access ######################### */
672/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface
673 Access to dedicated instructions
674 @{
675*/
676
677/* Define macros for porting to both thumb1 and thumb2.
678 * For thumb1, use low register (r0-r7), specified by constraint "l"
679 * Otherwise, use general registers, specified by constraint "r" */
680#if defined (__thumb__) && !defined (__thumb2__)
681#define __CMSIS_GCC_OUT_REG(r) "=l" (r)
682#define __CMSIS_GCC_RW_REG(r) "+l" (r)
683#define __CMSIS_GCC_USE_REG(r) "l" (r)
684#else
685#define __CMSIS_GCC_OUT_REG(r) "=r" (r)
686#define __CMSIS_GCC_RW_REG(r) "+r" (r)
687#define __CMSIS_GCC_USE_REG(r) "r" (r)
688#endif
689
690/**
691 \brief No Operation
692 \details No Operation does nothing. This instruction can be used for code alignment purposes.
693 */
694//__attribute__((always_inline)) __STATIC_INLINE void __NOP(void)
695//{
696// __ASM volatile ("nop");
697//}
698#define __NOP() __ASM volatile ("nop") /* This implementation generates debug information */
699
700/**
701 \brief Wait For Interrupt
702 \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs.
703 */
704//__attribute__((always_inline)) __STATIC_INLINE void __WFI(void)
705//{
706// __ASM volatile ("wfi");
707//}
708#define __WFI() __ASM volatile ("wfi") /* This implementation generates debug information */
709
710
711/**
712 \brief Wait For Event
713 \details Wait For Event is a hint instruction that permits the processor to enter
714 a low-power state until one of a number of events occurs.
715 */
716//__attribute__((always_inline)) __STATIC_INLINE void __WFE(void)
717//{
718// __ASM volatile ("wfe");
719//}
720#define __WFE() __ASM volatile ("wfe") /* This implementation generates debug information */
721
722
723/**
724 \brief Send Event
725 \details Send Event is a hint instruction. It causes an event to be signaled to the CPU.
726 */
727//__attribute__((always_inline)) __STATIC_INLINE void __SEV(void)
728//{
729// __ASM volatile ("sev");
730//}
731#define __SEV() __ASM volatile ("sev") /* This implementation generates debug information */
732
733
734/**
735 \brief Instruction Synchronization Barrier
736 \details Instruction Synchronization Barrier flushes the pipeline in the processor,
737 so that all instructions following the ISB are fetched from cache or memory,
738 after the instruction has been completed.
739 */
740__attribute__((always_inline)) __STATIC_INLINE void __ISB(void)
741{
742 __ASM volatile ("isb 0xF":::"memory");
743}
744
745
746/**
747 \brief Data Synchronization Barrier
748 \details Acts as a special kind of Data Memory Barrier.
749 It completes when all explicit memory accesses before this instruction complete.
750 */
751__attribute__((always_inline)) __STATIC_INLINE void __DSB(void)
752{
753 __ASM volatile ("dsb 0xF":::"memory");
754}
755
756
757/**
758 \brief Data Memory Barrier
759 \details Ensures the apparent order of the explicit memory operations before
760 and after the instruction, without ensuring their completion.
761 */
762__attribute__((always_inline)) __STATIC_INLINE void __DMB(void)
763{
764 __ASM volatile ("dmb 0xF":::"memory");
765}
766
767
768/**
769 \brief Reverse byte order (32 bit)
770 \details Reverses the byte order in integer value.
771 \param [in] value Value to reverse
772 \return Reversed value
773 */
774__attribute__((always_inline)) __STATIC_INLINE uint32_t __REV(uint32_t value)
775{
776#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
777 return __builtin_bswap32(value);
778#else
779 uint32_t result;
780
781 __ASM volatile ("rev %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
782 return(result);
783#endif
784}
785
786
787/**
788 \brief Reverse byte order (16 bit)
789 \details Reverses the byte order in two unsigned short values.
790 \param [in] value Value to reverse
791 \return Reversed value
792 */
793__attribute__((always_inline)) __STATIC_INLINE uint32_t __REV16(uint32_t value)
794{
795 uint32_t result;
796
797 __ASM volatile ("rev16 %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
798 return(result);
799}
800
801
802/**
803 \brief Reverse byte order in signed short value
804 \details Reverses the byte order in a signed short value with sign extension to integer.
805 \param [in] value Value to reverse
806 \return Reversed value
807 */
808__attribute__((always_inline)) __STATIC_INLINE int32_t __REVSH(int32_t value)
809{
810#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
811 return (short)__builtin_bswap16(value);
812#else
813 int32_t result;
814
815 __ASM volatile ("revsh %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
816 return(result);
817#endif
818}
819
820
821/**
822 \brief Rotate Right in unsigned value (32 bit)
823 \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
824 \param [in] op1 Value to rotate
825 \param [in] op2 Number of Bits to rotate
826 \return Rotated value
827 */
828__attribute__((always_inline)) __STATIC_INLINE uint32_t __ROR(uint32_t op1, uint32_t op2)
829{
830 return (op1 >> op2) | (op1 << (32U - op2));
831}
832
833
834/**
835 \brief Breakpoint
836 \details Causes the processor to enter Debug state.
837 Debug tools can use this to investigate system state when the instruction at a particular address is reached.
838 \param [in] value is ignored by the processor.
839 If required, a debugger can use it to store additional information about the breakpoint.
840 */
841#define __BKPT(value) __ASM volatile ("bkpt "#value)
842
843
844/**
845 \brief Reverse bit order of value
846 \details Reverses the bit order of the given value.
847 \param [in] value Value to reverse
848 \return Reversed value
849 */
850__attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value)
851{
852 uint32_t result;
853
854#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
855 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
856 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
857 __ASM volatile ("rbit %0, %1" : "=r" (result) : "r" (value) );
858#else
859 int32_t s = (4 /*sizeof(v)*/ * 8) - 1; /* extra shift needed at end */
860
861 result = value; /* r will be reversed bits of v; first get LSB of v */
862 for (value >>= 1U; value; value >>= 1U)
863 {
864 result <<= 1U;
865 result |= value & 1U;
866 s--;
867 }
868 result <<= s; /* shift when v's highest bits are zero */
869#endif
870 return(result);
871}
872
873
874/**
875 \brief Count leading zeros
876 \details Counts the number of leading zeros of a data value.
877 \param [in] value Value to count the leading zeros
878 \return number of leading zeros in value
879 */
880#define __CLZ __builtin_clz
881
882
883#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
884 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
885 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
886 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
887/**
888 \brief LDR Exclusive (8 bit)
889 \details Executes a exclusive LDR instruction for 8 bit value.
890 \param [in] ptr Pointer to data
891 \return value of type uint8_t at (*ptr)
892 */
893__attribute__((always_inline)) __STATIC_INLINE uint8_t __LDREXB(volatile uint8_t *addr)
894{
895 uint32_t result;
896
897#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
898 __ASM volatile ("ldrexb %0, %1" : "=r" (result) : "Q" (*addr) );
899#else
900 /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not
901 accepted by assembler. So has to use following less efficient pattern.
902 */
903 __ASM volatile ("ldrexb %0, [%1]" : "=r" (result) : "r" (addr) : "memory" );
904#endif
905 return ((uint8_t) result); /* Add explicit type cast here */
906}
907
908
909/**
910 \brief LDR Exclusive (16 bit)
911 \details Executes a exclusive LDR instruction for 16 bit values.
912 \param [in] ptr Pointer to data
913 \return value of type uint16_t at (*ptr)
914 */
915__attribute__((always_inline)) __STATIC_INLINE uint16_t __LDREXH(volatile uint16_t *addr)
916{
917 uint32_t result;
918
919#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
920 __ASM volatile ("ldrexh %0, %1" : "=r" (result) : "Q" (*addr) );
921#else
922 /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not
923 accepted by assembler. So has to use following less efficient pattern.
924 */
925 __ASM volatile ("ldrexh %0, [%1]" : "=r" (result) : "r" (addr) : "memory" );
926#endif
927 return ((uint16_t) result); /* Add explicit type cast here */
928}
929
930
931/**
932 \brief LDR Exclusive (32 bit)
933 \details Executes a exclusive LDR instruction for 32 bit values.
934 \param [in] ptr Pointer to data
935 \return value of type uint32_t at (*ptr)
936 */
937__attribute__((always_inline)) __STATIC_INLINE uint32_t __LDREXW(volatile uint32_t *addr)
938{
939 uint32_t result;
940
941 __ASM volatile ("ldrex %0, %1" : "=r" (result) : "Q" (*addr) );
942 return(result);
943}
944
945
946/**
947 \brief STR Exclusive (8 bit)
948 \details Executes a exclusive STR instruction for 8 bit values.
949 \param [in] value Value to store
950 \param [in] ptr Pointer to location
951 \return 0 Function succeeded
952 \return 1 Function failed
953 */
954__attribute__((always_inline)) __STATIC_INLINE uint32_t __STREXB(uint8_t value, volatile uint8_t *addr)
955{
956 uint32_t result;
957
958 __ASM volatile ("strexb %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) );
959 return(result);
960}
961
962
963/**
964 \brief STR Exclusive (16 bit)
965 \details Executes a exclusive STR instruction for 16 bit values.
966 \param [in] value Value to store
967 \param [in] ptr Pointer to location
968 \return 0 Function succeeded
969 \return 1 Function failed
970 */
971__attribute__((always_inline)) __STATIC_INLINE uint32_t __STREXH(uint16_t value, volatile uint16_t *addr)
972{
973 uint32_t result;
974
975 __ASM volatile ("strexh %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) );
976 return(result);
977}
978
979
980/**
981 \brief STR Exclusive (32 bit)
982 \details Executes a exclusive STR instruction for 32 bit values.
983 \param [in] value Value to store
984 \param [in] ptr Pointer to location
985 \return 0 Function succeeded
986 \return 1 Function failed
987 */
988__attribute__((always_inline)) __STATIC_INLINE uint32_t __STREXW(uint32_t value, volatile uint32_t *addr)
989{
990 uint32_t result;
991
992 __ASM volatile ("strex %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" (value) );
993 return(result);
994}
995
996
997/**
998 \brief Remove the exclusive lock
999 \details Removes the exclusive lock which is created by LDREX.
1000 */
1001__attribute__((always_inline)) __STATIC_INLINE void __CLREX(void)
1002{
1003 __ASM volatile ("clrex" ::: "memory");
1004}
1005
1006#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
1007 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
1008 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1009 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
1010
1011
1012#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
1013 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
1014 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
1015/**
1016 \brief Signed Saturate
1017 \details Saturates a signed value.
1018 \param [in] value Value to be saturated
1019 \param [in] sat Bit position to saturate to (1..32)
1020 \return Saturated value
1021 */
1022#define __SSAT(ARG1,ARG2) \
1023({ \
1024 int32_t __RES, __ARG1 = (ARG1); \
1025 __ASM ("ssat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
1026 __RES; \
1027 })
1028
1029
1030/**
1031 \brief Unsigned Saturate
1032 \details Saturates an unsigned value.
1033 \param [in] value Value to be saturated
1034 \param [in] sat Bit position to saturate to (0..31)
1035 \return Saturated value
1036 */
1037#define __USAT(ARG1,ARG2) \
1038({ \
1039 uint32_t __RES, __ARG1 = (ARG1); \
1040 __ASM ("usat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
1041 __RES; \
1042 })
1043
1044
1045/**
1046 \brief Rotate Right with Extend (32 bit)
1047 \details Moves each bit of a bitstring right by one bit.
1048 The carry input is shifted in at the left end of the bitstring.
1049 \param [in] value Value to rotate
1050 \return Rotated value
1051 */
1052__attribute__((always_inline)) __STATIC_INLINE uint32_t __RRX(uint32_t value)
1053{
1054 uint32_t result;
1055
1056 __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
1057 return(result);
1058}
1059
1060
1061/**
1062 \brief LDRT Unprivileged (8 bit)
1063 \details Executes a Unprivileged LDRT instruction for 8 bit value.
1064 \param [in] ptr Pointer to data
1065 \return value of type uint8_t at (*ptr)
1066 */
1067__attribute__((always_inline)) __STATIC_INLINE uint8_t __LDRBT(volatile uint8_t *ptr)
1068{
1069 uint32_t result;
1070
1071#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
1072 __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) );
1073#else
1074 /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not
1075 accepted by assembler. So has to use following less efficient pattern.
1076 */
1077 __ASM volatile ("ldrbt %0, [%1]" : "=r" (result) : "r" (ptr) : "memory" );
1078#endif
1079 return ((uint8_t) result); /* Add explicit type cast here */
1080}
1081
1082
1083/**
1084 \brief LDRT Unprivileged (16 bit)
1085 \details Executes a Unprivileged LDRT instruction for 16 bit values.
1086 \param [in] ptr Pointer to data
1087 \return value of type uint16_t at (*ptr)
1088 */
1089__attribute__((always_inline)) __STATIC_INLINE uint16_t __LDRHT(volatile uint16_t *ptr)
1090{
1091 uint32_t result;
1092
1093#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
1094 __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) );
1095#else
1096 /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not
1097 accepted by assembler. So has to use following less efficient pattern.
1098 */
1099 __ASM volatile ("ldrht %0, [%1]" : "=r" (result) : "r" (ptr) : "memory" );
1100#endif
1101 return ((uint16_t) result); /* Add explicit type cast here */
1102}
1103
1104
1105/**
1106 \brief LDRT Unprivileged (32 bit)
1107 \details Executes a Unprivileged LDRT instruction for 32 bit values.
1108 \param [in] ptr Pointer to data
1109 \return value of type uint32_t at (*ptr)
1110 */
1111__attribute__((always_inline)) __STATIC_INLINE uint32_t __LDRT(volatile uint32_t *ptr)
1112{
1113 uint32_t result;
1114
1115 __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) );
1116 return(result);
1117}
1118
1119
1120/**
1121 \brief STRT Unprivileged (8 bit)
1122 \details Executes a Unprivileged STRT instruction for 8 bit values.
1123 \param [in] value Value to store
1124 \param [in] ptr Pointer to location
1125 */
1126__attribute__((always_inline)) __STATIC_INLINE void __STRBT(uint8_t value, volatile uint8_t *ptr)
1127{
1128 __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1129}
1130
1131
1132/**
1133 \brief STRT Unprivileged (16 bit)
1134 \details Executes a Unprivileged STRT instruction for 16 bit values.
1135 \param [in] value Value to store
1136 \param [in] ptr Pointer to location
1137 */
1138__attribute__((always_inline)) __STATIC_INLINE void __STRHT(uint16_t value, volatile uint16_t *ptr)
1139{
1140 __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1141}
1142
1143
1144/**
1145 \brief STRT Unprivileged (32 bit)
1146 \details Executes a Unprivileged STRT instruction for 32 bit values.
1147 \param [in] value Value to store
1148 \param [in] ptr Pointer to location
1149 */
1150__attribute__((always_inline)) __STATIC_INLINE void __STRT(uint32_t value, volatile uint32_t *ptr)
1151{
1152 __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) );
1153}
1154
1155#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
1156 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
1157 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
1158
1159
1160#if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1161 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
1162/**
1163 \brief Load-Acquire (8 bit)
1164 \details Executes a LDAB instruction for 8 bit value.
1165 \param [in] ptr Pointer to data
1166 \return value of type uint8_t at (*ptr)
1167 */
1168__attribute__((always_inline)) __STATIC_INLINE uint8_t __LDAB(volatile uint8_t *ptr)
1169{
1170 uint32_t result;
1171
1172 __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) );
1173 return ((uint8_t) result);
1174}
1175
1176
1177/**
1178 \brief Load-Acquire (16 bit)
1179 \details Executes a LDAH instruction for 16 bit values.
1180 \param [in] ptr Pointer to data
1181 \return value of type uint16_t at (*ptr)
1182 */
1183__attribute__((always_inline)) __STATIC_INLINE uint16_t __LDAH(volatile uint16_t *ptr)
1184{
1185 uint32_t result;
1186
1187 __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) );
1188 return ((uint16_t) result);
1189}
1190
1191
1192/**
1193 \brief Load-Acquire (32 bit)
1194 \details Executes a LDA instruction for 32 bit values.
1195 \param [in] ptr Pointer to data
1196 \return value of type uint32_t at (*ptr)
1197 */
1198__attribute__((always_inline)) __STATIC_INLINE uint32_t __LDA(volatile uint32_t *ptr)
1199{
1200 uint32_t result;
1201
1202 __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) );
1203 return(result);
1204}
1205
1206
1207/**
1208 \brief Store-Release (8 bit)
1209 \details Executes a STLB instruction for 8 bit values.
1210 \param [in] value Value to store
1211 \param [in] ptr Pointer to location
1212 */
1213__attribute__((always_inline)) __STATIC_INLINE void __STLB(uint8_t value, volatile uint8_t *ptr)
1214{
1215 __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1216}
1217
1218
1219/**
1220 \brief Store-Release (16 bit)
1221 \details Executes a STLH instruction for 16 bit values.
1222 \param [in] value Value to store
1223 \param [in] ptr Pointer to location
1224 */
1225__attribute__((always_inline)) __STATIC_INLINE void __STLH(uint16_t value, volatile uint16_t *ptr)
1226{
1227 __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1228}
1229
1230
1231/**
1232 \brief Store-Release (32 bit)
1233 \details Executes a STL instruction for 32 bit values.
1234 \param [in] value Value to store
1235 \param [in] ptr Pointer to location
1236 */
1237__attribute__((always_inline)) __STATIC_INLINE void __STL(uint32_t value, volatile uint32_t *ptr)
1238{
1239 __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1240}
1241
1242
1243/**
1244 \brief Load-Acquire Exclusive (8 bit)
1245 \details Executes a LDAB exclusive instruction for 8 bit value.
1246 \param [in] ptr Pointer to data
1247 \return value of type uint8_t at (*ptr)
1248 */
1249__attribute__((always_inline)) __STATIC_INLINE uint8_t __LDAEXB(volatile uint8_t *ptr)
1250{
1251 uint32_t result;
1252
1253 __ASM volatile ("ldaexb %0, %1" : "=r" (result) : "Q" (*ptr) );
1254 return ((uint8_t) result);
1255}
1256
1257
1258/**
1259 \brief Load-Acquire Exclusive (16 bit)
1260 \details Executes a LDAH exclusive instruction for 16 bit values.
1261 \param [in] ptr Pointer to data
1262 \return value of type uint16_t at (*ptr)
1263 */
1264__attribute__((always_inline)) __STATIC_INLINE uint16_t __LDAEXH(volatile uint16_t *ptr)
1265{
1266 uint32_t result;
1267
1268 __ASM volatile ("ldaexh %0, %1" : "=r" (result) : "Q" (*ptr) );
1269 return ((uint16_t) result);
1270}
1271
1272
1273/**
1274 \brief Load-Acquire Exclusive (32 bit)
1275 \details Executes a LDA exclusive instruction for 32 bit values.
1276 \param [in] ptr Pointer to data
1277 \return value of type uint32_t at (*ptr)
1278 */
1279__attribute__((always_inline)) __STATIC_INLINE uint32_t __LDAEX(volatile uint32_t *ptr)
1280{
1281 uint32_t result;
1282
1283 __ASM volatile ("ldaex %0, %1" : "=r" (result) : "Q" (*ptr) );
1284 return(result);
1285}
1286
1287
1288/**
1289 \brief Store-Release Exclusive (8 bit)
1290 \details Executes a STLB exclusive instruction for 8 bit values.
1291 \param [in] value Value to store
1292 \param [in] ptr Pointer to location
1293 \return 0 Function succeeded
1294 \return 1 Function failed
1295 */
1296__attribute__((always_inline)) __STATIC_INLINE uint32_t __STLEXB(uint8_t value, volatile uint8_t *ptr)
1297{
1298 uint32_t result;
1299
1300 __ASM volatile ("stlexb %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) );
1301 return(result);
1302}
1303
1304
1305/**
1306 \brief Store-Release Exclusive (16 bit)
1307 \details Executes a STLH exclusive instruction for 16 bit values.
1308 \param [in] value Value to store
1309 \param [in] ptr Pointer to location
1310 \return 0 Function succeeded
1311 \return 1 Function failed
1312 */
1313__attribute__((always_inline)) __STATIC_INLINE uint32_t __STLEXH(uint16_t value, volatile uint16_t *ptr)
1314{
1315 uint32_t result;
1316
1317 __ASM volatile ("stlexh %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) );
1318 return(result);
1319}
1320
1321
1322/**
1323 \brief Store-Release Exclusive (32 bit)
1324 \details Executes a STL exclusive instruction for 32 bit values.
1325 \param [in] value Value to store
1326 \param [in] ptr Pointer to location
1327 \return 0 Function succeeded
1328 \return 1 Function failed
1329 */
1330__attribute__((always_inline)) __STATIC_INLINE uint32_t __STLEX(uint32_t value, volatile uint32_t *ptr)
1331{
1332 uint32_t result;
1333
1334 __ASM volatile ("stlex %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) );
1335 return(result);
1336}
1337
1338#endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1339 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
1340
1341/*@}*/ /* end of group CMSIS_Core_InstructionInterface */
1342
1343
1344/* ################### Compiler specific Intrinsics ########################### */
1345/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics
1346 Access to dedicated SIMD instructions
1347 @{
1348*/
1349
1350#if (__ARM_FEATURE_DSP == 1) /* ToDo ARMCLANG: This should be ARCH >= ARMv7-M + SIMD */
1351
1352__attribute__((always_inline)) __STATIC_INLINE uint32_t __SADD8(uint32_t op1, uint32_t op2)
1353{
1354 uint32_t result;
1355
1356 __ASM volatile ("sadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1357 return(result);
1358}
1359
1360__attribute__((always_inline)) __STATIC_INLINE uint32_t __QADD8(uint32_t op1, uint32_t op2)
1361{
1362 uint32_t result;
1363
1364 __ASM volatile ("qadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1365 return(result);
1366}
1367
1368__attribute__((always_inline)) __STATIC_INLINE uint32_t __SHADD8(uint32_t op1, uint32_t op2)
1369{
1370 uint32_t result;
1371
1372 __ASM volatile ("shadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1373 return(result);
1374}
1375
1376__attribute__((always_inline)) __STATIC_INLINE uint32_t __UADD8(uint32_t op1, uint32_t op2)
1377{
1378 uint32_t result;
1379
1380 __ASM volatile ("uadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1381 return(result);
1382}
1383
1384__attribute__((always_inline)) __STATIC_INLINE uint32_t __UQADD8(uint32_t op1, uint32_t op2)
1385{
1386 uint32_t result;
1387
1388 __ASM volatile ("uqadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1389 return(result);
1390}
1391
1392__attribute__((always_inline)) __STATIC_INLINE uint32_t __UHADD8(uint32_t op1, uint32_t op2)
1393{
1394 uint32_t result;
1395
1396 __ASM volatile ("uhadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1397 return(result);
1398}
1399
1400
1401__attribute__((always_inline)) __STATIC_INLINE uint32_t __SSUB8(uint32_t op1, uint32_t op2)
1402{
1403 uint32_t result;
1404
1405 __ASM volatile ("ssub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1406 return(result);
1407}
1408
1409__attribute__((always_inline)) __STATIC_INLINE uint32_t __QSUB8(uint32_t op1, uint32_t op2)
1410{
1411 uint32_t result;
1412
1413 __ASM volatile ("qsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1414 return(result);
1415}
1416
1417__attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSUB8(uint32_t op1, uint32_t op2)
1418{
1419 uint32_t result;
1420
1421 __ASM volatile ("shsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1422 return(result);
1423}
1424
1425__attribute__((always_inline)) __STATIC_INLINE uint32_t __USUB8(uint32_t op1, uint32_t op2)
1426{
1427 uint32_t result;
1428
1429 __ASM volatile ("usub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1430 return(result);
1431}
1432
1433__attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSUB8(uint32_t op1, uint32_t op2)
1434{
1435 uint32_t result;
1436
1437 __ASM volatile ("uqsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1438 return(result);
1439}
1440
1441__attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSUB8(uint32_t op1, uint32_t op2)
1442{
1443 uint32_t result;
1444
1445 __ASM volatile ("uhsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1446 return(result);
1447}
1448
1449
1450__attribute__((always_inline)) __STATIC_INLINE uint32_t __SADD16(uint32_t op1, uint32_t op2)
1451{
1452 uint32_t result;
1453
1454 __ASM volatile ("sadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1455 return(result);
1456}
1457
1458__attribute__((always_inline)) __STATIC_INLINE uint32_t __QADD16(uint32_t op1, uint32_t op2)
1459{
1460 uint32_t result;
1461
1462 __ASM volatile ("qadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1463 return(result);
1464}
1465
1466__attribute__((always_inline)) __STATIC_INLINE uint32_t __SHADD16(uint32_t op1, uint32_t op2)
1467{
1468 uint32_t result;
1469
1470 __ASM volatile ("shadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1471 return(result);
1472}
1473
1474__attribute__((always_inline)) __STATIC_INLINE uint32_t __UADD16(uint32_t op1, uint32_t op2)
1475{
1476 uint32_t result;
1477
1478 __ASM volatile ("uadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1479 return(result);
1480}
1481
1482__attribute__((always_inline)) __STATIC_INLINE uint32_t __UQADD16(uint32_t op1, uint32_t op2)
1483{
1484 uint32_t result;
1485
1486 __ASM volatile ("uqadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1487 return(result);
1488}
1489
1490__attribute__((always_inline)) __STATIC_INLINE uint32_t __UHADD16(uint32_t op1, uint32_t op2)
1491{
1492 uint32_t result;
1493
1494 __ASM volatile ("uhadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1495 return(result);
1496}
1497
1498__attribute__((always_inline)) __STATIC_INLINE uint32_t __SSUB16(uint32_t op1, uint32_t op2)
1499{
1500 uint32_t result;
1501
1502 __ASM volatile ("ssub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1503 return(result);
1504}
1505
1506__attribute__((always_inline)) __STATIC_INLINE uint32_t __QSUB16(uint32_t op1, uint32_t op2)
1507{
1508 uint32_t result;
1509
1510 __ASM volatile ("qsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1511 return(result);
1512}
1513
1514__attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSUB16(uint32_t op1, uint32_t op2)
1515{
1516 uint32_t result;
1517
1518 __ASM volatile ("shsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1519 return(result);
1520}
1521
1522__attribute__((always_inline)) __STATIC_INLINE uint32_t __USUB16(uint32_t op1, uint32_t op2)
1523{
1524 uint32_t result;
1525
1526 __ASM volatile ("usub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1527 return(result);
1528}
1529
1530__attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSUB16(uint32_t op1, uint32_t op2)
1531{
1532 uint32_t result;
1533
1534 __ASM volatile ("uqsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1535 return(result);
1536}
1537
1538__attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSUB16(uint32_t op1, uint32_t op2)
1539{
1540 uint32_t result;
1541
1542 __ASM volatile ("uhsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1543 return(result);
1544}
1545
1546__attribute__((always_inline)) __STATIC_INLINE uint32_t __SASX(uint32_t op1, uint32_t op2)
1547{
1548 uint32_t result;
1549
1550 __ASM volatile ("sasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1551 return(result);
1552}
1553
1554__attribute__((always_inline)) __STATIC_INLINE uint32_t __QASX(uint32_t op1, uint32_t op2)
1555{
1556 uint32_t result;
1557
1558 __ASM volatile ("qasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1559 return(result);
1560}
1561
1562__attribute__((always_inline)) __STATIC_INLINE uint32_t __SHASX(uint32_t op1, uint32_t op2)
1563{
1564 uint32_t result;
1565
1566 __ASM volatile ("shasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1567 return(result);
1568}
1569
1570__attribute__((always_inline)) __STATIC_INLINE uint32_t __UASX(uint32_t op1, uint32_t op2)
1571{
1572 uint32_t result;
1573
1574 __ASM volatile ("uasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1575 return(result);
1576}
1577
1578__attribute__((always_inline)) __STATIC_INLINE uint32_t __UQASX(uint32_t op1, uint32_t op2)
1579{
1580 uint32_t result;
1581
1582 __ASM volatile ("uqasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1583 return(result);
1584}
1585
1586__attribute__((always_inline)) __STATIC_INLINE uint32_t __UHASX(uint32_t op1, uint32_t op2)
1587{
1588 uint32_t result;
1589
1590 __ASM volatile ("uhasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1591 return(result);
1592}
1593
1594__attribute__((always_inline)) __STATIC_INLINE uint32_t __SSAX(uint32_t op1, uint32_t op2)
1595{
1596 uint32_t result;
1597
1598 __ASM volatile ("ssax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1599 return(result);
1600}
1601
1602__attribute__((always_inline)) __STATIC_INLINE uint32_t __QSAX(uint32_t op1, uint32_t op2)
1603{
1604 uint32_t result;
1605
1606 __ASM volatile ("qsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1607 return(result);
1608}
1609
1610__attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSAX(uint32_t op1, uint32_t op2)
1611{
1612 uint32_t result;
1613
1614 __ASM volatile ("shsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1615 return(result);
1616}
1617
1618__attribute__((always_inline)) __STATIC_INLINE uint32_t __USAX(uint32_t op1, uint32_t op2)
1619{
1620 uint32_t result;
1621
1622 __ASM volatile ("usax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1623 return(result);
1624}
1625
1626__attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSAX(uint32_t op1, uint32_t op2)
1627{
1628 uint32_t result;
1629
1630 __ASM volatile ("uqsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1631 return(result);
1632}
1633
1634__attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSAX(uint32_t op1, uint32_t op2)
1635{
1636 uint32_t result;
1637
1638 __ASM volatile ("uhsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1639 return(result);
1640}
1641
1642__attribute__((always_inline)) __STATIC_INLINE uint32_t __USAD8(uint32_t op1, uint32_t op2)
1643{
1644 uint32_t result;
1645
1646 __ASM volatile ("usad8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1647 return(result);
1648}
1649
1650__attribute__((always_inline)) __STATIC_INLINE uint32_t __USADA8(uint32_t op1, uint32_t op2, uint32_t op3)
1651{
1652 uint32_t result;
1653
1654 __ASM volatile ("usada8 %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1655 return(result);
1656}
1657
1658#define __SSAT16(ARG1,ARG2) \
1659({ \
1660 int32_t __RES, __ARG1 = (ARG1); \
1661 __ASM ("ssat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
1662 __RES; \
1663 })
1664
1665#define __USAT16(ARG1,ARG2) \
1666({ \
1667 uint32_t __RES, __ARG1 = (ARG1); \
1668 __ASM ("usat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
1669 __RES; \
1670 })
1671
1672__attribute__((always_inline)) __STATIC_INLINE uint32_t __UXTB16(uint32_t op1)
1673{
1674 uint32_t result;
1675
1676 __ASM volatile ("uxtb16 %0, %1" : "=r" (result) : "r" (op1));
1677 return(result);
1678}
1679
1680__attribute__((always_inline)) __STATIC_INLINE uint32_t __UXTAB16(uint32_t op1, uint32_t op2)
1681{
1682 uint32_t result;
1683
1684 __ASM volatile ("uxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1685 return(result);
1686}
1687
1688__attribute__((always_inline)) __STATIC_INLINE uint32_t __SXTB16(uint32_t op1)
1689{
1690 uint32_t result;
1691
1692 __ASM volatile ("sxtb16 %0, %1" : "=r" (result) : "r" (op1));
1693 return(result);
1694}
1695
1696__attribute__((always_inline)) __STATIC_INLINE uint32_t __SXTAB16(uint32_t op1, uint32_t op2)
1697{
1698 uint32_t result;
1699
1700 __ASM volatile ("sxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1701 return(result);
1702}
1703
1704__attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUAD (uint32_t op1, uint32_t op2)
1705{
1706 uint32_t result;
1707
1708 __ASM volatile ("smuad %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1709 return(result);
1710}
1711
1712__attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUADX (uint32_t op1, uint32_t op2)
1713{
1714 uint32_t result;
1715
1716 __ASM volatile ("smuadx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1717 return(result);
1718}
1719
1720__attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLAD (uint32_t op1, uint32_t op2, uint32_t op3)
1721{
1722 uint32_t result;
1723
1724 __ASM volatile ("smlad %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1725 return(result);
1726}
1727
1728__attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLADX (uint32_t op1, uint32_t op2, uint32_t op3)
1729{
1730 uint32_t result;
1731
1732 __ASM volatile ("smladx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1733 return(result);
1734}
1735
1736__attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLALD (uint32_t op1, uint32_t op2, uint64_t acc)
1737{
1738 union llreg_u{
1739 uint32_t w32[2];
1740 uint64_t w64;
1741 } llr;
1742 llr.w64 = acc;
1743
1744#ifndef __ARMEB__ /* Little endian */
1745 __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) );
1746#else /* Big endian */
1747 __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) );
1748#endif
1749
1750 return(llr.w64);
1751}
1752
1753__attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLALDX (uint32_t op1, uint32_t op2, uint64_t acc)
1754{
1755 union llreg_u{
1756 uint32_t w32[2];
1757 uint64_t w64;
1758 } llr;
1759 llr.w64 = acc;
1760
1761#ifndef __ARMEB__ /* Little endian */
1762 __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) );
1763#else /* Big endian */
1764 __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) );
1765#endif
1766
1767 return(llr.w64);
1768}
1769
1770__attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUSD (uint32_t op1, uint32_t op2)
1771{
1772 uint32_t result;
1773
1774 __ASM volatile ("smusd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1775 return(result);
1776}
1777
1778__attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUSDX (uint32_t op1, uint32_t op2)
1779{
1780 uint32_t result;
1781
1782 __ASM volatile ("smusdx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1783 return(result);
1784}
1785
1786__attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLSD (uint32_t op1, uint32_t op2, uint32_t op3)
1787{
1788 uint32_t result;
1789
1790 __ASM volatile ("smlsd %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1791 return(result);
1792}
1793
1794__attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLSDX (uint32_t op1, uint32_t op2, uint32_t op3)
1795{
1796 uint32_t result;
1797
1798 __ASM volatile ("smlsdx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1799 return(result);
1800}
1801
1802__attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLSLD (uint32_t op1, uint32_t op2, uint64_t acc)
1803{
1804 union llreg_u{
1805 uint32_t w32[2];
1806 uint64_t w64;
1807 } llr;
1808 llr.w64 = acc;
1809
1810#ifndef __ARMEB__ /* Little endian */
1811 __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) );
1812#else /* Big endian */
1813 __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) );
1814#endif
1815
1816 return(llr.w64);
1817}
1818
1819__attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLSLDX (uint32_t op1, uint32_t op2, uint64_t acc)
1820{
1821 union llreg_u{
1822 uint32_t w32[2];
1823 uint64_t w64;
1824 } llr;
1825 llr.w64 = acc;
1826
1827#ifndef __ARMEB__ /* Little endian */
1828 __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) );
1829#else /* Big endian */
1830 __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) );
1831#endif
1832
1833 return(llr.w64);
1834}
1835
1836__attribute__((always_inline)) __STATIC_INLINE uint32_t __SEL (uint32_t op1, uint32_t op2)
1837{
1838 uint32_t result;
1839
1840 __ASM volatile ("sel %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1841 return(result);
1842}
1843
1844__attribute__((always_inline)) __STATIC_INLINE int32_t __QADD( int32_t op1, int32_t op2)
1845{
1846 int32_t result;
1847
1848 __ASM volatile ("qadd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1849 return(result);
1850}
1851
1852__attribute__((always_inline)) __STATIC_INLINE int32_t __QSUB( int32_t op1, int32_t op2)
1853{
1854 int32_t result;
1855
1856 __ASM volatile ("qsub %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1857 return(result);
1858}
1859
1860#if 0
1861#define __PKHBT(ARG1,ARG2,ARG3) \
1862({ \
1863 uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \
1864 __ASM ("pkhbt %0, %1, %2, lsl %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \
1865 __RES; \
1866 })
1867
1868#define __PKHTB(ARG1,ARG2,ARG3) \
1869({ \
1870 uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \
1871 if (ARG3 == 0) \
1872 __ASM ("pkhtb %0, %1, %2" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2) ); \
1873 else \
1874 __ASM ("pkhtb %0, %1, %2, asr %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \
1875 __RES; \
1876 })
1877#endif
1878
1879#define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \
1880 ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) )
1881
1882#define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \
1883 ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) )
1884
1885__attribute__((always_inline)) __STATIC_INLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3)
1886{
1887 int32_t result;
1888
1889 __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) );
1890 return(result);
1891}
1892
1893#endif /* (__ARM_FEATURE_DSP == 1) */
1894/*@} end of group CMSIS_SIMD_intrinsics */
1895
1896
1897#pragma GCC diagnostic pop
1898
1899#endif /* __CMSIS_GCC_H */
diff --git a/lib/arm_atsam/packs/arm/cmsis/5.0.1/CMSIS/Include/core_cm4.h b/lib/arm_atsam/packs/arm/cmsis/5.0.1/CMSIS/Include/core_cm4.h
new file mode 100644
index 000000000..2da78d398
--- /dev/null
+++ b/lib/arm_atsam/packs/arm/cmsis/5.0.1/CMSIS/Include/core_cm4.h
@@ -0,0 +1,2103 @@
1/**************************************************************************//**
2 * @file core_cm4.h
3 * @brief CMSIS Cortex-M4 Core Peripheral Access Layer Header File
4 * @version V5.0.1
5 * @date 30. January 2017
6 ******************************************************************************/
7/*
8 * Copyright (c) 2009-2016 ARM Limited. All rights reserved.
9 *
10 * SPDX-License-Identifier: Apache-2.0
11 *
12 * Licensed under the Apache License, Version 2.0 (the License); you may
13 * not use this file except in compliance with the License.
14 * You may obtain a copy of the License at
15 *
16 * www.apache.org/licenses/LICENSE-2.0
17 *
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
20 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
23 */
24
25#if defined ( __ICCARM__ )
26 #pragma system_include /* treat file as system include file for MISRA check */
27#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
28 #pragma clang system_header /* treat file as system include file */
29#endif
30
31#ifndef __CORE_CM4_H_GENERIC
32#define __CORE_CM4_H_GENERIC
33
34#include <stdint.h>
35
36#ifdef __cplusplus
37 extern "C" {
38#endif
39
40/**
41 \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions
42 CMSIS violates the following MISRA-C:2004 rules:
43
44 \li Required Rule 8.5, object/function definition in header file.<br>
45 Function definitions in header files are used to allow 'inlining'.
46
47 \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.<br>
48 Unions are used for effective representation of core registers.
49
50 \li Advisory Rule 19.7, Function-like macro defined.<br>
51 Function-like macros are used to allow more efficient code.
52 */
53
54
55/*******************************************************************************
56 * CMSIS definitions
57 ******************************************************************************/
58/**
59 \ingroup Cortex_M4
60 @{
61 */
62
63/* CMSIS CM4 definitions */
64#define __CM4_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS HAL main version */
65#define __CM4_CMSIS_VERSION_SUB ( 0U) /*!< [15:0] CMSIS HAL sub version */
66#define __CM4_CMSIS_VERSION ((__CM4_CMSIS_VERSION_MAIN << 16U) | \
67 __CM4_CMSIS_VERSION_SUB ) /*!< CMSIS HAL version number */
68
69#define __CORTEX_M (4U) /*!< Cortex-M Core */
70
71/** __FPU_USED indicates whether an FPU is used or not.
72 For this, __FPU_PRESENT has to be checked prior to making use of FPU specific registers and functions.
73*/
74#if defined ( __CC_ARM )
75 #if defined __TARGET_FPU_VFP
76 #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)
77 #define __FPU_USED 1U
78 #else
79 #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
80 #define __FPU_USED 0U
81 #endif
82 #else
83 #define __FPU_USED 0U
84 #endif
85
86#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
87 #if defined __ARM_PCS_VFP
88 #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)
89 #define __FPU_USED 1U
90 #else
91 #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
92 #define __FPU_USED 0U
93 #endif
94 #else
95 #define __FPU_USED 0U
96 #endif
97
98#elif defined ( __GNUC__ )
99 #if defined (__VFP_FP__) && !defined(__SOFTFP__)
100 #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)
101 #define __FPU_USED 1U
102 #else
103 #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
104 #define __FPU_USED 0U
105 #endif
106 #else
107 #define __FPU_USED 0U
108 #endif
109
110#elif defined ( __ICCARM__ )
111 #if defined __ARMVFP__
112 #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)
113 #define __FPU_USED 1U
114 #else
115 #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
116 #define __FPU_USED 0U
117 #endif
118 #else
119 #define __FPU_USED 0U
120 #endif
121
122#elif defined ( __TI_ARM__ )
123 #if defined __TI_VFP_SUPPORT__
124 #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)
125 #define __FPU_USED 1U
126 #else
127 #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
128 #define __FPU_USED 0U
129 #endif
130 #else
131 #define __FPU_USED 0U
132 #endif
133
134#elif defined ( __TASKING__ )
135 #if defined __FPU_VFP__
136 #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)
137 #define __FPU_USED 1U
138 #else
139 #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
140 #define __FPU_USED 0U
141 #endif
142 #else
143 #define __FPU_USED 0U
144 #endif
145
146#elif defined ( __CSMC__ )
147 #if ( __CSMC__ & 0x400U)
148 #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)
149 #define __FPU_USED 1U
150 #else
151 #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
152 #define __FPU_USED 0U
153 #endif
154 #else
155 #define __FPU_USED 0U
156 #endif
157
158#endif
159
160#include "cmsis_compiler.h" /* CMSIS compiler specific defines */
161
162
163#ifdef __cplusplus
164}
165#endif
166
167#endif /* __CORE_CM4_H_GENERIC */
168
169#ifndef __CMSIS_GENERIC
170
171#ifndef __CORE_CM4_H_DEPENDANT
172#define __CORE_CM4_H_DEPENDANT
173
174#ifdef __cplusplus
175 extern "C" {
176#endif
177
178/* check device defines and use defaults */
179#if defined __CHECK_DEVICE_DEFINES
180 #ifndef __CM4_REV
181 #define __CM4_REV 0x0000U
182 #warning "__CM4_REV not defined in device header file; using default!"
183 #endif
184
185 #ifndef __FPU_PRESENT
186 #define __FPU_PRESENT 0U
187 #warning "__FPU_PRESENT not defined in device header file; using default!"
188 #endif
189
190 #ifndef __MPU_PRESENT
191 #define __MPU_PRESENT 0U
192 #warning "__MPU_PRESENT not defined in device header file; using default!"
193 #endif
194
195 #ifndef __NVIC_PRIO_BITS
196 #define __NVIC_PRIO_BITS 3U
197 #warning "__NVIC_PRIO_BITS not defined in device header file; using default!"
198 #endif
199
200 #ifndef __Vendor_SysTickConfig
201 #define __Vendor_SysTickConfig 0U
202 #warning "__Vendor_SysTickConfig not defined in device header file; using default!"
203 #endif
204#endif
205
206/* IO definitions (access restrictions to peripheral registers) */
207/**
208 \defgroup CMSIS_glob_defs CMSIS Global Defines
209
210 <strong>IO Type Qualifiers</strong> are used
211 \li to specify the access to peripheral variables.
212 \li for automatic generation of peripheral register debug information.
213*/
214#ifdef __cplusplus
215 #define __I volatile /*!< Defines 'read only' permissions */
216#else
217 #define __I volatile const /*!< Defines 'read only' permissions */
218#endif
219#define __O volatile /*!< Defines 'write only' permissions */
220#define __IO volatile /*!< Defines 'read / write' permissions */
221
222/* following defines should be used for structure members */
223#define __IM volatile const /*! Defines 'read only' structure member permissions */
224#define __OM volatile /*! Defines 'write only' structure member permissions */
225#define __IOM volatile /*! Defines 'read / write' structure member permissions */
226
227/*@} end of group Cortex_M4 */
228
229
230
231/*******************************************************************************
232 * Register Abstraction
233 Core Register contain:
234 - Core Register
235 - Core NVIC Register
236 - Core SCB Register
237 - Core SysTick Register
238 - Core Debug Register
239 - Core MPU Register
240 - Core FPU Register
241 ******************************************************************************/
242/**
243 \defgroup CMSIS_core_register Defines and Type Definitions
244 \brief Type definitions and defines for Cortex-M processor based devices.
245*/
246
247/**
248 \ingroup CMSIS_core_register
249 \defgroup CMSIS_CORE Status and Control Registers
250 \brief Core Register type definitions.
251 @{
252 */
253
254/**
255 \brief Union type to access the Application Program Status Register (APSR).
256 */
257typedef union
258{
259 struct
260 {
261 uint32_t _reserved0:16; /*!< bit: 0..15 Reserved */
262 uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */
263 uint32_t _reserved1:7; /*!< bit: 20..26 Reserved */
264 uint32_t Q:1; /*!< bit: 27 Saturation condition flag */
265 uint32_t V:1; /*!< bit: 28 Overflow condition code flag */
266 uint32_t C:1; /*!< bit: 29 Carry condition code flag */
267 uint32_t Z:1; /*!< bit: 30 Zero condition code flag */
268 uint32_t N:1; /*!< bit: 31 Negative condition code flag */
269 } b; /*!< Structure used for bit access */
270 uint32_t w; /*!< Type used for word access */
271} APSR_Type;
272
273/* APSR Register Definitions */
274#define APSR_N_Pos 31U /*!< APSR: N Position */
275#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */
276
277#define APSR_Z_Pos 30U /*!< APSR: Z Position */
278#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */
279
280#define APSR_C_Pos 29U /*!< APSR: C Position */
281#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */
282
283#define APSR_V_Pos 28U /*!< APSR: V Position */
284#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */
285
286#define APSR_Q_Pos 27U /*!< APSR: Q Position */
287#define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */
288
289#define APSR_GE_Pos 16U /*!< APSR: GE Position */
290#define APSR_GE_Msk (0xFUL << APSR_GE_Pos) /*!< APSR: GE Mask */
291
292
293/**
294 \brief Union type to access the Interrupt Program Status Register (IPSR).
295 */
296typedef union
297{
298 struct
299 {
300 uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */
301 uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */
302 } b; /*!< Structure used for bit access */
303 uint32_t w; /*!< Type used for word access */
304} IPSR_Type;
305
306/* IPSR Register Definitions */
307#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */
308#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */
309
310
311/**
312 \brief Union type to access the Special-Purpose Program Status Registers (xPSR).
313 */
314typedef union
315{
316 struct
317 {
318 uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */
319 uint32_t _reserved0:1; /*!< bit: 9 Reserved */
320 uint32_t ICI_IT_1:6; /*!< bit: 10..15 ICI/IT part 1 */
321 uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */
322 uint32_t _reserved1:4; /*!< bit: 20..23 Reserved */
323 uint32_t T:1; /*!< bit: 24 Thumb bit */
324 uint32_t ICI_IT_2:2; /*!< bit: 25..26 ICI/IT part 2 */
325 uint32_t Q:1; /*!< bit: 27 Saturation condition flag */
326 uint32_t V:1; /*!< bit: 28 Overflow condition code flag */
327 uint32_t C:1; /*!< bit: 29 Carry condition code flag */
328 uint32_t Z:1; /*!< bit: 30 Zero condition code flag */
329 uint32_t N:1; /*!< bit: 31 Negative condition code flag */
330 } b; /*!< Structure used for bit access */
331 uint32_t w; /*!< Type used for word access */
332} xPSR_Type;
333
334/* xPSR Register Definitions */
335#define xPSR_N_Pos 31U /*!< xPSR: N Position */
336#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */
337
338#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */
339#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */
340
341#define xPSR_C_Pos 29U /*!< xPSR: C Position */
342#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */
343
344#define xPSR_V_Pos 28U /*!< xPSR: V Position */
345#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */
346
347#define xPSR_Q_Pos 27U /*!< xPSR: Q Position */
348#define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */
349
350#define xPSR_ICI_IT_2_Pos 25U /*!< xPSR: ICI/IT part 2 Position */
351#define xPSR_ICI_IT_2_Msk (3UL << xPSR_ICI_IT_2_Pos) /*!< xPSR: ICI/IT part 2 Mask */
352
353#define xPSR_T_Pos 24U /*!< xPSR: T Position */
354#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */
355
356#define xPSR_GE_Pos 16U /*!< xPSR: GE Position */
357#define xPSR_GE_Msk (0xFUL << xPSR_GE_Pos) /*!< xPSR: GE Mask */
358
359#define xPSR_ICI_IT_1_Pos 10U /*!< xPSR: ICI/IT part 1 Position */
360#define xPSR_ICI_IT_1_Msk (0x3FUL << xPSR_ICI_IT_1_Pos) /*!< xPSR: ICI/IT part 1 Mask */
361
362#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */
363#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */
364
365
366/**
367 \brief Union type to access the Control Registers (CONTROL).
368 */
369typedef union
370{
371 struct
372 {
373 uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */
374 uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */
375 uint32_t FPCA:1; /*!< bit: 2 FP extension active flag */
376 uint32_t _reserved0:29; /*!< bit: 3..31 Reserved */
377 } b; /*!< Structure used for bit access */
378 uint32_t w; /*!< Type used for word access */
379} CONTROL_Type;
380
381/* CONTROL Register Definitions */
382#define CONTROL_FPCA_Pos 2U /*!< CONTROL: FPCA Position */
383#define CONTROL_FPCA_Msk (1UL << CONTROL_FPCA_Pos) /*!< CONTROL: FPCA Mask */
384
385#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */
386#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */
387
388#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */
389#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */
390
391/*@} end of group CMSIS_CORE */
392
393
394/**
395 \ingroup CMSIS_core_register
396 \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC)
397 \brief Type definitions for the NVIC Registers
398 @{
399 */
400
401/**
402 \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC).
403 */
404typedef struct
405{
406 __IOM uint32_t ISER[8U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */
407 uint32_t RESERVED0[24U];
408 __IOM uint32_t ICER[8U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */
409 uint32_t RSERVED1[24U];
410 __IOM uint32_t ISPR[8U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */
411 uint32_t RESERVED2[24U];
412 __IOM uint32_t ICPR[8U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */
413 uint32_t RESERVED3[24U];
414 __IOM uint32_t IABR[8U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */
415 uint32_t RESERVED4[56U];
416 __IOM uint8_t IP[240U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */
417 uint32_t RESERVED5[644U];
418 __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */
419} NVIC_Type;
420
421/* Software Triggered Interrupt Register Definitions */
422#define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */
423#define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */
424
425/*@} end of group CMSIS_NVIC */
426
427
428/**
429 \ingroup CMSIS_core_register
430 \defgroup CMSIS_SCB System Control Block (SCB)
431 \brief Type definitions for the System Control Block Registers
432 @{
433 */
434
435/**
436 \brief Structure type to access the System Control Block (SCB).
437 */
438typedef struct
439{
440 __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */
441 __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */
442 __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */
443 __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */
444 __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */
445 __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */
446 __IOM uint8_t SHP[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */
447 __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */
448 __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */
449 __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */
450 __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */
451 __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */
452 __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */
453 __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */
454 __IM uint32_t PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */
455 __IM uint32_t DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */
456 __IM uint32_t ADR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */
457 __IM uint32_t MMFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */
458 __IM uint32_t ISAR[5U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */
459 uint32_t RESERVED0[5U];
460 __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */
461} SCB_Type;
462
463/* SCB CPUID Register Definitions */
464#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */
465#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */
466
467#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */
468#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */
469
470#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */
471#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */
472
473#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */
474#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */
475
476#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */
477#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */
478
479/* SCB Interrupt Control State Register Definitions */
480#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */
481#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */
482
483#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */
484#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */
485
486#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */
487#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */
488
489#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */
490#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */
491
492#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */
493#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */
494
495#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */
496#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */
497
498#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */
499#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */
500
501#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */
502#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */
503
504#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */
505#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */
506
507#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */
508#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */
509
510/* SCB Vector Table Offset Register Definitions */
511#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */
512#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */
513
514/* SCB Application Interrupt and Reset Control Register Definitions */
515#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */
516#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */
517
518#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */
519#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */
520
521#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */
522#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */
523
524#define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */
525#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */
526
527#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */
528#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */
529
530#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */
531#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */
532
533#define SCB_AIRCR_VECTRESET_Pos 0U /*!< SCB AIRCR: VECTRESET Position */
534#define SCB_AIRCR_VECTRESET_Msk (1UL /*<< SCB_AIRCR_VECTRESET_Pos*/) /*!< SCB AIRCR: VECTRESET Mask */
535
536/* SCB System Control Register Definitions */
537#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */
538#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */
539
540#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */
541#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */
542
543#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */
544#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */
545
546/* SCB Configuration Control Register Definitions */
547#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */
548#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */
549
550#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */
551#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */
552
553#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */
554#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */
555
556#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */
557#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */
558
559#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */
560#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */
561
562#define SCB_CCR_NONBASETHRDENA_Pos 0U /*!< SCB CCR: NONBASETHRDENA Position */
563#define SCB_CCR_NONBASETHRDENA_Msk (1UL /*<< SCB_CCR_NONBASETHRDENA_Pos*/) /*!< SCB CCR: NONBASETHRDENA Mask */
564
565/* SCB System Handler Control and State Register Definitions */
566#define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */
567#define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */
568
569#define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */
570#define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */
571
572#define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */
573#define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */
574
575#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */
576#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */
577
578#define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */
579#define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */
580
581#define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */
582#define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */
583
584#define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */
585#define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */
586
587#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */
588#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */
589
590#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */
591#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */
592
593#define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */
594#define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */
595
596#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */
597#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */
598
599#define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */
600#define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */
601
602#define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */
603#define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */
604
605#define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */
606#define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */
607
608/* SCB Configurable Fault Status Register Definitions */
609#define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */
610#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */
611
612#define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */
613#define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */
614
615#define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */
616#define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */
617
618/* MemManage Fault Status Register (part of SCB Configurable Fault Status Register) */
619#define SCB_CFSR_MMARVALID_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 7U) /*!< SCB CFSR (MMFSR): MMARVALID Position */
620#define SCB_CFSR_MMARVALID_Msk (1UL << SCB_CFSR_MMARVALID_Pos) /*!< SCB CFSR (MMFSR): MMARVALID Mask */
621
622#define SCB_CFSR_MLSPERR_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 5U) /*!< SCB CFSR (MMFSR): MLSPERR Position */
623#define SCB_CFSR_MLSPERR_Msk (1UL << SCB_CFSR_MLSPERR_Pos) /*!< SCB CFSR (MMFSR): MLSPERR Mask */
624
625#define SCB_CFSR_MSTKERR_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 4U) /*!< SCB CFSR (MMFSR): MSTKERR Position */
626#define SCB_CFSR_MSTKERR_Msk (1UL << SCB_CFSR_MSTKERR_Pos) /*!< SCB CFSR (MMFSR): MSTKERR Mask */
627
628#define SCB_CFSR_MUNSTKERR_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 3U) /*!< SCB CFSR (MMFSR): MUNSTKERR Position */
629#define SCB_CFSR_MUNSTKERR_Msk (1UL << SCB_CFSR_MUNSTKERR_Pos) /*!< SCB CFSR (MMFSR): MUNSTKERR Mask */
630
631#define SCB_CFSR_DACCVIOL_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 1U) /*!< SCB CFSR (MMFSR): DACCVIOL Position */
632#define SCB_CFSR_DACCVIOL_Msk (1UL << SCB_CFSR_DACCVIOL_Pos) /*!< SCB CFSR (MMFSR): DACCVIOL Mask */
633
634#define SCB_CFSR_IACCVIOL_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 0U) /*!< SCB CFSR (MMFSR): IACCVIOL Position */
635#define SCB_CFSR_IACCVIOL_Msk (1UL /*<< SCB_CFSR_IACCVIOL_Pos*/) /*!< SCB CFSR (MMFSR): IACCVIOL Mask */
636
637/* BusFault Status Register (part of SCB Configurable Fault Status Register) */
638#define SCB_CFSR_BFARVALID_Pos (SCB_CFSR_BUSFAULTSR_Pos + 7U) /*!< SCB CFSR (BFSR): BFARVALID Position */
639#define SCB_CFSR_BFARVALID_Msk (1UL << SCB_CFSR_BFARVALID_Pos) /*!< SCB CFSR (BFSR): BFARVALID Mask */
640
641#define SCB_CFSR_LSPERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 5U) /*!< SCB CFSR (BFSR): LSPERR Position */
642#define SCB_CFSR_LSPERR_Msk (1UL << SCB_CFSR_LSPERR_Pos) /*!< SCB CFSR (BFSR): LSPERR Mask */
643
644#define SCB_CFSR_STKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 4U) /*!< SCB CFSR (BFSR): STKERR Position */
645#define SCB_CFSR_STKERR_Msk (1UL << SCB_CFSR_STKERR_Pos) /*!< SCB CFSR (BFSR): STKERR Mask */
646
647#define SCB_CFSR_UNSTKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 3U) /*!< SCB CFSR (BFSR): UNSTKERR Position */
648#define SCB_CFSR_UNSTKERR_Msk (1UL << SCB_CFSR_UNSTKERR_Pos) /*!< SCB CFSR (BFSR): UNSTKERR Mask */
649
650#define SCB_CFSR_IMPRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 2U) /*!< SCB CFSR (BFSR): IMPRECISERR Position */
651#define SCB_CFSR_IMPRECISERR_Msk (1UL << SCB_CFSR_IMPRECISERR_Pos) /*!< SCB CFSR (BFSR): IMPRECISERR Mask */
652
653#define SCB_CFSR_PRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 1U) /*!< SCB CFSR (BFSR): PRECISERR Position */
654#define SCB_CFSR_PRECISERR_Msk (1UL << SCB_CFSR_PRECISERR_Pos) /*!< SCB CFSR (BFSR): PRECISERR Mask */
655
656#define SCB_CFSR_IBUSERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 0U) /*!< SCB CFSR (BFSR): IBUSERR Position */
657#define SCB_CFSR_IBUSERR_Msk (1UL << SCB_CFSR_IBUSERR_Pos) /*!< SCB CFSR (BFSR): IBUSERR Mask */
658
659/* UsageFault Status Register (part of SCB Configurable Fault Status Register) */
660#define SCB_CFSR_DIVBYZERO_Pos (SCB_CFSR_USGFAULTSR_Pos + 9U) /*!< SCB CFSR (UFSR): DIVBYZERO Position */
661#define SCB_CFSR_DIVBYZERO_Msk (1UL << SCB_CFSR_DIVBYZERO_Pos) /*!< SCB CFSR (UFSR): DIVBYZERO Mask */
662
663#define SCB_CFSR_UNALIGNED_Pos (SCB_CFSR_USGFAULTSR_Pos + 8U) /*!< SCB CFSR (UFSR): UNALIGNED Position */
664#define SCB_CFSR_UNALIGNED_Msk (1UL << SCB_CFSR_UNALIGNED_Pos) /*!< SCB CFSR (UFSR): UNALIGNED Mask */
665
666#define SCB_CFSR_NOCP_Pos (SCB_CFSR_USGFAULTSR_Pos + 3U) /*!< SCB CFSR (UFSR): NOCP Position */
667#define SCB_CFSR_NOCP_Msk (1UL << SCB_CFSR_NOCP_Pos) /*!< SCB CFSR (UFSR): NOCP Mask */
668
669#define SCB_CFSR_INVPC_Pos (SCB_CFSR_USGFAULTSR_Pos + 2U) /*!< SCB CFSR (UFSR): INVPC Position */
670#define SCB_CFSR_INVPC_Msk (1UL << SCB_CFSR_INVPC_Pos) /*!< SCB CFSR (UFSR): INVPC Mask */
671
672#define SCB_CFSR_INVSTATE_Pos (SCB_CFSR_USGFAULTSR_Pos + 1U) /*!< SCB CFSR (UFSR): INVSTATE Position */
673#define SCB_CFSR_INVSTATE_Msk (1UL << SCB_CFSR_INVSTATE_Pos) /*!< SCB CFSR (UFSR): INVSTATE Mask */
674
675#define SCB_CFSR_UNDEFINSTR_Pos (SCB_CFSR_USGFAULTSR_Pos + 0U) /*!< SCB CFSR (UFSR): UNDEFINSTR Position */
676#define SCB_CFSR_UNDEFINSTR_Msk (1UL << SCB_CFSR_UNDEFINSTR_Pos) /*!< SCB CFSR (UFSR): UNDEFINSTR Mask */
677
678/* SCB Hard Fault Status Register Definitions */
679#define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */
680#define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */
681
682#define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */
683#define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */
684
685#define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */
686#define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */
687
688/* SCB Debug Fault Status Register Definitions */
689#define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */
690#define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */
691
692#define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */
693#define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */
694
695#define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */
696#define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */
697
698#define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */
699#define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */
700
701#define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */
702#define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */
703
704/*@} end of group CMSIS_SCB */
705
706
707/**
708 \ingroup CMSIS_core_register
709 \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB)
710 \brief Type definitions for the System Control and ID Register not in the SCB
711 @{
712 */
713
714/**
715 \brief Structure type to access the System Control and ID Register not in the SCB.
716 */
717typedef struct
718{
719 uint32_t RESERVED0[1U];
720 __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */
721 __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */
722} SCnSCB_Type;
723
724/* Interrupt Controller Type Register Definitions */
725#define SCnSCB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */
726#define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */
727
728/* Auxiliary Control Register Definitions */
729#define SCnSCB_ACTLR_DISOOFP_Pos 9U /*!< ACTLR: DISOOFP Position */
730#define SCnSCB_ACTLR_DISOOFP_Msk (1UL << SCnSCB_ACTLR_DISOOFP_Pos) /*!< ACTLR: DISOOFP Mask */
731
732#define SCnSCB_ACTLR_DISFPCA_Pos 8U /*!< ACTLR: DISFPCA Position */
733#define SCnSCB_ACTLR_DISFPCA_Msk (1UL << SCnSCB_ACTLR_DISFPCA_Pos) /*!< ACTLR: DISFPCA Mask */
734
735#define SCnSCB_ACTLR_DISFOLD_Pos 2U /*!< ACTLR: DISFOLD Position */
736#define SCnSCB_ACTLR_DISFOLD_Msk (1UL << SCnSCB_ACTLR_DISFOLD_Pos) /*!< ACTLR: DISFOLD Mask */
737
738#define SCnSCB_ACTLR_DISDEFWBUF_Pos 1U /*!< ACTLR: DISDEFWBUF Position */
739#define SCnSCB_ACTLR_DISDEFWBUF_Msk (1UL << SCnSCB_ACTLR_DISDEFWBUF_Pos) /*!< ACTLR: DISDEFWBUF Mask */
740
741#define SCnSCB_ACTLR_DISMCYCINT_Pos 0U /*!< ACTLR: DISMCYCINT Position */
742#define SCnSCB_ACTLR_DISMCYCINT_Msk (1UL /*<< SCnSCB_ACTLR_DISMCYCINT_Pos*/) /*!< ACTLR: DISMCYCINT Mask */
743
744/*@} end of group CMSIS_SCnotSCB */
745
746
747/**
748 \ingroup CMSIS_core_register
749 \defgroup CMSIS_SysTick System Tick Timer (SysTick)
750 \brief Type definitions for the System Timer Registers.
751 @{
752 */
753
754/**
755 \brief Structure type to access the System Timer (SysTick).
756 */
757typedef struct
758{
759 __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */
760 __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */
761 __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */
762 __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */
763} SysTick_Type;
764
765/* SysTick Control / Status Register Definitions */
766#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */
767#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */
768
769#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */
770#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */
771
772#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */
773#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */
774
775#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */
776#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */
777
778/* SysTick Reload Register Definitions */
779#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */
780#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */
781
782/* SysTick Current Register Definitions */
783#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */
784#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */
785
786/* SysTick Calibration Register Definitions */
787#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */
788#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */
789
790#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */
791#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */
792
793#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */
794#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */
795
796/*@} end of group CMSIS_SysTick */
797
798
799/**
800 \ingroup CMSIS_core_register
801 \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM)
802 \brief Type definitions for the Instrumentation Trace Macrocell (ITM)
803 @{
804 */
805
806/**
807 \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM).
808 */
809typedef struct
810{
811 __OM union
812 {
813 __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */
814 __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */
815 __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */
816 } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */
817 uint32_t RESERVED0[864U];
818 __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */
819 uint32_t RESERVED1[15U];
820 __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */
821 uint32_t RESERVED2[15U];
822 __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */
823 uint32_t RESERVED3[29U];
824 __OM uint32_t IWR; /*!< Offset: 0xEF8 ( /W) ITM Integration Write Register */
825 __IM uint32_t IRR; /*!< Offset: 0xEFC (R/ ) ITM Integration Read Register */
826 __IOM uint32_t IMCR; /*!< Offset: 0xF00 (R/W) ITM Integration Mode Control Register */
827 uint32_t RESERVED4[43U];
828 __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */
829 __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */
830 uint32_t RESERVED5[6U];
831 __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */
832 __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */
833 __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */
834 __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */
835 __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */
836 __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */
837 __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */
838 __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */
839 __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */
840 __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */
841 __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */
842 __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */
843} ITM_Type;
844
845/* ITM Trace Privilege Register Definitions */
846#define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */
847#define ITM_TPR_PRIVMASK_Msk (0xFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */
848
849/* ITM Trace Control Register Definitions */
850#define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */
851#define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */
852
853#define ITM_TCR_TraceBusID_Pos 16U /*!< ITM TCR: ATBID Position */
854#define ITM_TCR_TraceBusID_Msk (0x7FUL << ITM_TCR_TraceBusID_Pos) /*!< ITM TCR: ATBID Mask */
855
856#define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */
857#define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */
858
859#define ITM_TCR_TSPrescale_Pos 8U /*!< ITM TCR: TSPrescale Position */
860#define ITM_TCR_TSPrescale_Msk (3UL << ITM_TCR_TSPrescale_Pos) /*!< ITM TCR: TSPrescale Mask */
861
862#define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */
863#define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */
864
865#define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */
866#define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */
867
868#define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */
869#define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */
870
871#define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */
872#define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */
873
874#define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */
875#define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */
876
877/* ITM Integration Write Register Definitions */
878#define ITM_IWR_ATVALIDM_Pos 0U /*!< ITM IWR: ATVALIDM Position */
879#define ITM_IWR_ATVALIDM_Msk (1UL /*<< ITM_IWR_ATVALIDM_Pos*/) /*!< ITM IWR: ATVALIDM Mask */
880
881/* ITM Integration Read Register Definitions */
882#define ITM_IRR_ATREADYM_Pos 0U /*!< ITM IRR: ATREADYM Position */
883#define ITM_IRR_ATREADYM_Msk (1UL /*<< ITM_IRR_ATREADYM_Pos*/) /*!< ITM IRR: ATREADYM Mask */
884
885/* ITM Integration Mode Control Register Definitions */
886#define ITM_IMCR_INTEGRATION_Pos 0U /*!< ITM IMCR: INTEGRATION Position */
887#define ITM_IMCR_INTEGRATION_Msk (1UL /*<< ITM_IMCR_INTEGRATION_Pos*/) /*!< ITM IMCR: INTEGRATION Mask */
888
889/* ITM Lock Status Register Definitions */
890#define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */
891#define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */
892
893#define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */
894#define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */
895
896#define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */
897#define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */
898
899/*@}*/ /* end of group CMSIS_ITM */
900
901
902/**
903 \ingroup CMSIS_core_register
904 \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT)
905 \brief Type definitions for the Data Watchpoint and Trace (DWT)
906 @{
907 */
908
909/**
910 \brief Structure type to access the Data Watchpoint and Trace Register (DWT).
911 */
912typedef struct
913{
914 __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */
915 __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */
916 __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */
917 __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */
918 __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */
919 __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */
920 __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */
921 __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */
922 __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */
923 __IOM uint32_t MASK0; /*!< Offset: 0x024 (R/W) Mask Register 0 */
924 __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */
925 uint32_t RESERVED0[1U];
926 __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */
927 __IOM uint32_t MASK1; /*!< Offset: 0x034 (R/W) Mask Register 1 */
928 __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */
929 uint32_t RESERVED1[1U];
930 __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */
931 __IOM uint32_t MASK2; /*!< Offset: 0x044 (R/W) Mask Register 2 */
932 __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */
933 uint32_t RESERVED2[1U];
934 __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */
935 __IOM uint32_t MASK3; /*!< Offset: 0x054 (R/W) Mask Register 3 */
936 __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */
937} DWT_Type;
938
939/* DWT Control Register Definitions */
940#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */
941#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */
942
943#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */
944#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */
945
946#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */
947#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */
948
949#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */
950#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */
951
952#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */
953#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */
954
955#define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */
956#define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */
957
958#define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */
959#define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */
960
961#define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */
962#define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */
963
964#define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */
965#define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */
966
967#define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */
968#define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */
969
970#define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */
971#define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */
972
973#define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */
974#define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */
975
976#define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */
977#define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */
978
979#define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */
980#define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */
981
982#define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */
983#define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */
984
985#define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */
986#define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */
987
988#define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */
989#define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */
990
991#define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */
992#define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */
993
994/* DWT CPI Count Register Definitions */
995#define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */
996#define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */
997
998/* DWT Exception Overhead Count Register Definitions */
999#define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */
1000#define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */
1001
1002/* DWT Sleep Count Register Definitions */
1003#define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */
1004#define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */
1005
1006/* DWT LSU Count Register Definitions */
1007#define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */
1008#define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */
1009
1010/* DWT Folded-instruction Count Register Definitions */
1011#define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */
1012#define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */
1013
1014/* DWT Comparator Mask Register Definitions */
1015#define DWT_MASK_MASK_Pos 0U /*!< DWT MASK: MASK Position */
1016#define DWT_MASK_MASK_Msk (0x1FUL /*<< DWT_MASK_MASK_Pos*/) /*!< DWT MASK: MASK Mask */
1017
1018/* DWT Comparator Function Register Definitions */
1019#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */
1020#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */
1021
1022#define DWT_FUNCTION_DATAVADDR1_Pos 16U /*!< DWT FUNCTION: DATAVADDR1 Position */
1023#define DWT_FUNCTION_DATAVADDR1_Msk (0xFUL << DWT_FUNCTION_DATAVADDR1_Pos) /*!< DWT FUNCTION: DATAVADDR1 Mask */
1024
1025#define DWT_FUNCTION_DATAVADDR0_Pos 12U /*!< DWT FUNCTION: DATAVADDR0 Position */
1026#define DWT_FUNCTION_DATAVADDR0_Msk (0xFUL << DWT_FUNCTION_DATAVADDR0_Pos) /*!< DWT FUNCTION: DATAVADDR0 Mask */
1027
1028#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */
1029#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */
1030
1031#define DWT_FUNCTION_LNK1ENA_Pos 9U /*!< DWT FUNCTION: LNK1ENA Position */
1032#define DWT_FUNCTION_LNK1ENA_Msk (0x1UL << DWT_FUNCTION_LNK1ENA_Pos) /*!< DWT FUNCTION: LNK1ENA Mask */
1033
1034#define DWT_FUNCTION_DATAVMATCH_Pos 8U /*!< DWT FUNCTION: DATAVMATCH Position */
1035#define DWT_FUNCTION_DATAVMATCH_Msk (0x1UL << DWT_FUNCTION_DATAVMATCH_Pos) /*!< DWT FUNCTION: DATAVMATCH Mask */
1036
1037#define DWT_FUNCTION_CYCMATCH_Pos 7U /*!< DWT FUNCTION: CYCMATCH Position */
1038#define DWT_FUNCTION_CYCMATCH_Msk (0x1UL << DWT_FUNCTION_CYCMATCH_Pos) /*!< DWT FUNCTION: CYCMATCH Mask */
1039
1040#define DWT_FUNCTION_EMITRANGE_Pos 5U /*!< DWT FUNCTION: EMITRANGE Position */
1041#define DWT_FUNCTION_EMITRANGE_Msk (0x1UL << DWT_FUNCTION_EMITRANGE_Pos) /*!< DWT FUNCTION: EMITRANGE Mask */
1042
1043#define DWT_FUNCTION_FUNCTION_Pos 0U /*!< DWT FUNCTION: FUNCTION Position */
1044#define DWT_FUNCTION_FUNCTION_Msk (0xFUL /*<< DWT_FUNCTION_FUNCTION_Pos*/) /*!< DWT FUNCTION: FUNCTION Mask */
1045
1046/*@}*/ /* end of group CMSIS_DWT */
1047
1048
1049/**
1050 \ingroup CMSIS_core_register
1051 \defgroup CMSIS_TPI Trace Port Interface (TPI)
1052 \brief Type definitions for the Trace Port Interface (TPI)
1053 @{
1054 */
1055
1056/**
1057 \brief Structure type to access the Trace Port Interface Register (TPI).
1058 */
1059typedef struct
1060{
1061 __IOM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Size Register */
1062 __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Size Register */
1063 uint32_t RESERVED0[2U];
1064 __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */
1065 uint32_t RESERVED1[55U];
1066 __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */
1067 uint32_t RESERVED2[131U];
1068 __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */
1069 __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */
1070 __IM uint32_t FSCR; /*!< Offset: 0x308 (R/ ) Formatter Synchronization Counter Register */
1071 uint32_t RESERVED3[759U];
1072 __IM uint32_t TRIGGER; /*!< Offset: 0xEE8 (R/ ) TRIGGER */
1073 __IM uint32_t FIFO0; /*!< Offset: 0xEEC (R/ ) Integration ETM Data */
1074 __IM uint32_t ITATBCTR2; /*!< Offset: 0xEF0 (R/ ) ITATBCTR2 */
1075 uint32_t RESERVED4[1U];
1076 __IM uint32_t ITATBCTR0; /*!< Offset: 0xEF8 (R/ ) ITATBCTR0 */
1077 __IM uint32_t FIFO1; /*!< Offset: 0xEFC (R/ ) Integration ITM Data */
1078 __IOM uint32_t ITCTRL; /*!< Offset: 0xF00 (R/W) Integration Mode Control */
1079 uint32_t RESERVED5[39U];
1080 __IOM uint32_t CLAIMSET; /*!< Offset: 0xFA0 (R/W) Claim tag set */
1081 __IOM uint32_t CLAIMCLR; /*!< Offset: 0xFA4 (R/W) Claim tag clear */
1082 uint32_t RESERVED7[8U];
1083 __IM uint32_t DEVID; /*!< Offset: 0xFC8 (R/ ) TPIU_DEVID */
1084 __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) TPIU_DEVTYPE */
1085} TPI_Type;
1086
1087/* TPI Asynchronous Clock Prescaler Register Definitions */
1088#define TPI_ACPR_PRESCALER_Pos 0U /*!< TPI ACPR: PRESCALER Position */
1089#define TPI_ACPR_PRESCALER_Msk (0x1FFFUL /*<< TPI_ACPR_PRESCALER_Pos*/) /*!< TPI ACPR: PRESCALER Mask */
1090
1091/* TPI Selected Pin Protocol Register Definitions */
1092#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */
1093#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */
1094
1095/* TPI Formatter and Flush Status Register Definitions */
1096#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */
1097#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */
1098
1099#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */
1100#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */
1101
1102#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */
1103#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */
1104
1105#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */
1106#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */
1107
1108/* TPI Formatter and Flush Control Register Definitions */
1109#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */
1110#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */
1111
1112#define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */
1113#define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */
1114
1115/* TPI TRIGGER Register Definitions */
1116#define TPI_TRIGGER_TRIGGER_Pos 0U /*!< TPI TRIGGER: TRIGGER Position */
1117#define TPI_TRIGGER_TRIGGER_Msk (0x1UL /*<< TPI_TRIGGER_TRIGGER_Pos*/) /*!< TPI TRIGGER: TRIGGER Mask */
1118
1119/* TPI Integration ETM Data Register Definitions (FIFO0) */
1120#define TPI_FIFO0_ITM_ATVALID_Pos 29U /*!< TPI FIFO0: ITM_ATVALID Position */
1121#define TPI_FIFO0_ITM_ATVALID_Msk (0x3UL << TPI_FIFO0_ITM_ATVALID_Pos) /*!< TPI FIFO0: ITM_ATVALID Mask */
1122
1123#define TPI_FIFO0_ITM_bytecount_Pos 27U /*!< TPI FIFO0: ITM_bytecount Position */
1124#define TPI_FIFO0_ITM_bytecount_Msk (0x3UL << TPI_FIFO0_ITM_bytecount_Pos) /*!< TPI FIFO0: ITM_bytecount Mask */
1125
1126#define TPI_FIFO0_ETM_ATVALID_Pos 26U /*!< TPI FIFO0: ETM_ATVALID Position */
1127#define TPI_FIFO0_ETM_ATVALID_Msk (0x3UL << TPI_FIFO0_ETM_ATVALID_Pos) /*!< TPI FIFO0: ETM_ATVALID Mask */
1128
1129#define TPI_FIFO0_ETM_bytecount_Pos 24U /*!< TPI FIFO0: ETM_bytecount Position */
1130#define TPI_FIFO0_ETM_bytecount_Msk (0x3UL << TPI_FIFO0_ETM_bytecount_Pos) /*!< TPI FIFO0: ETM_bytecount Mask */
1131
1132#define TPI_FIFO0_ETM2_Pos 16U /*!< TPI FIFO0: ETM2 Position */
1133#define TPI_FIFO0_ETM2_Msk (0xFFUL << TPI_FIFO0_ETM2_Pos) /*!< TPI FIFO0: ETM2 Mask */
1134
1135#define TPI_FIFO0_ETM1_Pos 8U /*!< TPI FIFO0: ETM1 Position */
1136#define TPI_FIFO0_ETM1_Msk (0xFFUL << TPI_FIFO0_ETM1_Pos) /*!< TPI FIFO0: ETM1 Mask */
1137
1138#define TPI_FIFO0_ETM0_Pos 0U /*!< TPI FIFO0: ETM0 Position */
1139#define TPI_FIFO0_ETM0_Msk (0xFFUL /*<< TPI_FIFO0_ETM0_Pos*/) /*!< TPI FIFO0: ETM0 Mask */
1140
1141/* TPI ITATBCTR2 Register Definitions */
1142#define TPI_ITATBCTR2_ATREADY_Pos 0U /*!< TPI ITATBCTR2: ATREADY Position */
1143#define TPI_ITATBCTR2_ATREADY_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY_Pos*/) /*!< TPI ITATBCTR2: ATREADY Mask */
1144
1145/* TPI Integration ITM Data Register Definitions (FIFO1) */
1146#define TPI_FIFO1_ITM_ATVALID_Pos 29U /*!< TPI FIFO1: ITM_ATVALID Position */
1147#define TPI_FIFO1_ITM_ATVALID_Msk (0x3UL << TPI_FIFO1_ITM_ATVALID_Pos) /*!< TPI FIFO1: ITM_ATVALID Mask */
1148
1149#define TPI_FIFO1_ITM_bytecount_Pos 27U /*!< TPI FIFO1: ITM_bytecount Position */
1150#define TPI_FIFO1_ITM_bytecount_Msk (0x3UL << TPI_FIFO1_ITM_bytecount_Pos) /*!< TPI FIFO1: ITM_bytecount Mask */
1151
1152#define TPI_FIFO1_ETM_ATVALID_Pos 26U /*!< TPI FIFO1: ETM_ATVALID Position */
1153#define TPI_FIFO1_ETM_ATVALID_Msk (0x3UL << TPI_FIFO1_ETM_ATVALID_Pos) /*!< TPI FIFO1: ETM_ATVALID Mask */
1154
1155#define TPI_FIFO1_ETM_bytecount_Pos 24U /*!< TPI FIFO1: ETM_bytecount Position */
1156#define TPI_FIFO1_ETM_bytecount_Msk (0x3UL << TPI_FIFO1_ETM_bytecount_Pos) /*!< TPI FIFO1: ETM_bytecount Mask */
1157
1158#define TPI_FIFO1_ITM2_Pos 16U /*!< TPI FIFO1: ITM2 Position */
1159#define TPI_FIFO1_ITM2_Msk (0xFFUL << TPI_FIFO1_ITM2_Pos) /*!< TPI FIFO1: ITM2 Mask */
1160
1161#define TPI_FIFO1_ITM1_Pos 8U /*!< TPI FIFO1: ITM1 Position */
1162#define TPI_FIFO1_ITM1_Msk (0xFFUL << TPI_FIFO1_ITM1_Pos) /*!< TPI FIFO1: ITM1 Mask */
1163
1164#define TPI_FIFO1_ITM0_Pos 0U /*!< TPI FIFO1: ITM0 Position */
1165#define TPI_FIFO1_ITM0_Msk (0xFFUL /*<< TPI_FIFO1_ITM0_Pos*/) /*!< TPI FIFO1: ITM0 Mask */
1166
1167/* TPI ITATBCTR0 Register Definitions */
1168#define TPI_ITATBCTR0_ATREADY_Pos 0U /*!< TPI ITATBCTR0: ATREADY Position */
1169#define TPI_ITATBCTR0_ATREADY_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY_Pos*/) /*!< TPI ITATBCTR0: ATREADY Mask */
1170
1171/* TPI Integration Mode Control Register Definitions */
1172#define TPI_ITCTRL_Mode_Pos 0U /*!< TPI ITCTRL: Mode Position */
1173#define TPI_ITCTRL_Mode_Msk (0x1UL /*<< TPI_ITCTRL_Mode_Pos*/) /*!< TPI ITCTRL: Mode Mask */
1174
1175/* TPI DEVID Register Definitions */
1176#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */
1177#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */
1178
1179#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */
1180#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */
1181
1182#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */
1183#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */
1184
1185#define TPI_DEVID_MinBufSz_Pos 6U /*!< TPI DEVID: MinBufSz Position */
1186#define TPI_DEVID_MinBufSz_Msk (0x7UL << TPI_DEVID_MinBufSz_Pos) /*!< TPI DEVID: MinBufSz Mask */
1187
1188#define TPI_DEVID_AsynClkIn_Pos 5U /*!< TPI DEVID: AsynClkIn Position */
1189#define TPI_DEVID_AsynClkIn_Msk (0x1UL << TPI_DEVID_AsynClkIn_Pos) /*!< TPI DEVID: AsynClkIn Mask */
1190
1191#define TPI_DEVID_NrTraceInput_Pos 0U /*!< TPI DEVID: NrTraceInput Position */
1192#define TPI_DEVID_NrTraceInput_Msk (0x1FUL /*<< TPI_DEVID_NrTraceInput_Pos*/) /*!< TPI DEVID: NrTraceInput Mask */
1193
1194/* TPI DEVTYPE Register Definitions */
1195#define TPI_DEVTYPE_MajorType_Pos 4U /*!< TPI DEVTYPE: MajorType Position */
1196#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */
1197
1198#define TPI_DEVTYPE_SubType_Pos 0U /*!< TPI DEVTYPE: SubType Position */
1199#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */
1200
1201/*@}*/ /* end of group CMSIS_TPI */
1202
1203
1204#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U)
1205/**
1206 \ingroup CMSIS_core_register
1207 \defgroup CMSIS_MPU Memory Protection Unit (MPU)
1208 \brief Type definitions for the Memory Protection Unit (MPU)
1209 @{
1210 */
1211
1212/**
1213 \brief Structure type to access the Memory Protection Unit (MPU).
1214 */
1215typedef struct
1216{
1217 __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */
1218 __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */
1219 __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */
1220 __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */
1221 __IOM uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */
1222 __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Alias 1 Region Base Address Register */
1223 __IOM uint32_t RASR_A1; /*!< Offset: 0x018 (R/W) MPU Alias 1 Region Attribute and Size Register */
1224 __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Alias 2 Region Base Address Register */
1225 __IOM uint32_t RASR_A2; /*!< Offset: 0x020 (R/W) MPU Alias 2 Region Attribute and Size Register */
1226 __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Alias 3 Region Base Address Register */
1227 __IOM uint32_t RASR_A3; /*!< Offset: 0x028 (R/W) MPU Alias 3 Region Attribute and Size Register */
1228} MPU_Type;
1229
1230/* MPU Type Register Definitions */
1231#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */
1232#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */
1233
1234#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */
1235#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */
1236
1237#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */
1238#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */
1239
1240/* MPU Control Register Definitions */
1241#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */
1242#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */
1243
1244#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */
1245#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */
1246
1247#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */
1248#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */
1249
1250/* MPU Region Number Register Definitions */
1251#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */
1252#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */
1253
1254/* MPU Region Base Address Register Definitions */
1255#define MPU_RBAR_ADDR_Pos 5U /*!< MPU RBAR: ADDR Position */
1256#define MPU_RBAR_ADDR_Msk (0x7FFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */
1257
1258#define MPU_RBAR_VALID_Pos 4U /*!< MPU RBAR: VALID Position */
1259#define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */
1260
1261#define MPU_RBAR_REGION_Pos 0U /*!< MPU RBAR: REGION Position */
1262#define MPU_RBAR_REGION_Msk (0xFUL /*<< MPU_RBAR_REGION_Pos*/) /*!< MPU RBAR: REGION Mask */
1263
1264/* MPU Region Attribute and Size Register Definitions */
1265#define MPU_RASR_ATTRS_Pos 16U /*!< MPU RASR: MPU Region Attribute field Position */
1266#define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */
1267
1268#define MPU_RASR_XN_Pos 28U /*!< MPU RASR: ATTRS.XN Position */
1269#define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */
1270
1271#define MPU_RASR_AP_Pos 24U /*!< MPU RASR: ATTRS.AP Position */
1272#define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */
1273
1274#define MPU_RASR_TEX_Pos 19U /*!< MPU RASR: ATTRS.TEX Position */
1275#define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */
1276
1277#define MPU_RASR_S_Pos 18U /*!< MPU RASR: ATTRS.S Position */
1278#define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */
1279
1280#define MPU_RASR_C_Pos 17U /*!< MPU RASR: ATTRS.C Position */
1281#define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */
1282
1283#define MPU_RASR_B_Pos 16U /*!< MPU RASR: ATTRS.B Position */
1284#define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */
1285
1286#define MPU_RASR_SRD_Pos 8U /*!< MPU RASR: Sub-Region Disable Position */
1287#define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */
1288
1289#define MPU_RASR_SIZE_Pos 1U /*!< MPU RASR: Region Size Field Position */
1290#define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */
1291
1292#define MPU_RASR_ENABLE_Pos 0U /*!< MPU RASR: Region enable bit Position */
1293#define MPU_RASR_ENABLE_Msk (1UL /*<< MPU_RASR_ENABLE_Pos*/) /*!< MPU RASR: Region enable bit Disable Mask */
1294
1295/*@} end of group CMSIS_MPU */
1296#endif /* defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) */
1297
1298
1299/**
1300 \ingroup CMSIS_core_register
1301 \defgroup CMSIS_FPU Floating Point Unit (FPU)
1302 \brief Type definitions for the Floating Point Unit (FPU)
1303 @{
1304 */
1305
1306/**
1307 \brief Structure type to access the Floating Point Unit (FPU).
1308 */
1309typedef struct
1310{
1311 uint32_t RESERVED0[1U];
1312 __IOM uint32_t FPCCR; /*!< Offset: 0x004 (R/W) Floating-Point Context Control Register */
1313 __IOM uint32_t FPCAR; /*!< Offset: 0x008 (R/W) Floating-Point Context Address Register */
1314 __IOM uint32_t FPDSCR; /*!< Offset: 0x00C (R/W) Floating-Point Default Status Control Register */
1315 __IM uint32_t MVFR0; /*!< Offset: 0x010 (R/ ) Media and FP Feature Register 0 */
1316 __IM uint32_t MVFR1; /*!< Offset: 0x014 (R/ ) Media and FP Feature Register 1 */
1317} FPU_Type;
1318
1319/* Floating-Point Context Control Register Definitions */
1320#define FPU_FPCCR_ASPEN_Pos 31U /*!< FPCCR: ASPEN bit Position */
1321#define FPU_FPCCR_ASPEN_Msk (1UL << FPU_FPCCR_ASPEN_Pos) /*!< FPCCR: ASPEN bit Mask */
1322
1323#define FPU_FPCCR_LSPEN_Pos 30U /*!< FPCCR: LSPEN Position */
1324#define FPU_FPCCR_LSPEN_Msk (1UL << FPU_FPCCR_LSPEN_Pos) /*!< FPCCR: LSPEN bit Mask */
1325
1326#define FPU_FPCCR_MONRDY_Pos 8U /*!< FPCCR: MONRDY Position */
1327#define FPU_FPCCR_MONRDY_Msk (1UL << FPU_FPCCR_MONRDY_Pos) /*!< FPCCR: MONRDY bit Mask */
1328
1329#define FPU_FPCCR_BFRDY_Pos 6U /*!< FPCCR: BFRDY Position */
1330#define FPU_FPCCR_BFRDY_Msk (1UL << FPU_FPCCR_BFRDY_Pos) /*!< FPCCR: BFRDY bit Mask */
1331
1332#define FPU_FPCCR_MMRDY_Pos 5U /*!< FPCCR: MMRDY Position */
1333#define FPU_FPCCR_MMRDY_Msk (1UL << FPU_FPCCR_MMRDY_Pos) /*!< FPCCR: MMRDY bit Mask */
1334
1335#define FPU_FPCCR_HFRDY_Pos 4U /*!< FPCCR: HFRDY Position */
1336#define FPU_FPCCR_HFRDY_Msk (1UL << FPU_FPCCR_HFRDY_Pos) /*!< FPCCR: HFRDY bit Mask */
1337
1338#define FPU_FPCCR_THREAD_Pos 3U /*!< FPCCR: processor mode bit Position */
1339#define FPU_FPCCR_THREAD_Msk (1UL << FPU_FPCCR_THREAD_Pos) /*!< FPCCR: processor mode active bit Mask */
1340
1341#define FPU_FPCCR_USER_Pos 1U /*!< FPCCR: privilege level bit Position */
1342#define FPU_FPCCR_USER_Msk (1UL << FPU_FPCCR_USER_Pos) /*!< FPCCR: privilege level bit Mask */
1343
1344#define FPU_FPCCR_LSPACT_Pos 0U /*!< FPCCR: Lazy state preservation active bit Position */
1345#define FPU_FPCCR_LSPACT_Msk (1UL /*<< FPU_FPCCR_LSPACT_Pos*/) /*!< FPCCR: Lazy state preservation active bit Mask */
1346
1347/* Floating-Point Context Address Register Definitions */
1348#define FPU_FPCAR_ADDRESS_Pos 3U /*!< FPCAR: ADDRESS bit Position */
1349#define FPU_FPCAR_ADDRESS_Msk (0x1FFFFFFFUL << FPU_FPCAR_ADDRESS_Pos) /*!< FPCAR: ADDRESS bit Mask */
1350
1351/* Floating-Point Default Status Control Register Definitions */
1352#define FPU_FPDSCR_AHP_Pos 26U /*!< FPDSCR: AHP bit Position */
1353#define FPU_FPDSCR_AHP_Msk (1UL << FPU_FPDSCR_AHP_Pos) /*!< FPDSCR: AHP bit Mask */
1354
1355#define FPU_FPDSCR_DN_Pos 25U /*!< FPDSCR: DN bit Position */
1356#define FPU_FPDSCR_DN_Msk (1UL << FPU_FPDSCR_DN_Pos) /*!< FPDSCR: DN bit Mask */
1357
1358#define FPU_FPDSCR_FZ_Pos 24U /*!< FPDSCR: FZ bit Position */
1359#define FPU_FPDSCR_FZ_Msk (1UL << FPU_FPDSCR_FZ_Pos) /*!< FPDSCR: FZ bit Mask */
1360
1361#define FPU_FPDSCR_RMode_Pos 22U /*!< FPDSCR: RMode bit Position */
1362#define FPU_FPDSCR_RMode_Msk (3UL << FPU_FPDSCR_RMode_Pos) /*!< FPDSCR: RMode bit Mask */
1363
1364/* Media and FP Feature Register 0 Definitions */
1365#define FPU_MVFR0_FP_rounding_modes_Pos 28U /*!< MVFR0: FP rounding modes bits Position */
1366#define FPU_MVFR0_FP_rounding_modes_Msk (0xFUL << FPU_MVFR0_FP_rounding_modes_Pos) /*!< MVFR0: FP rounding modes bits Mask */
1367
1368#define FPU_MVFR0_Short_vectors_Pos 24U /*!< MVFR0: Short vectors bits Position */
1369#define FPU_MVFR0_Short_vectors_Msk (0xFUL << FPU_MVFR0_Short_vectors_Pos) /*!< MVFR0: Short vectors bits Mask */
1370
1371#define FPU_MVFR0_Square_root_Pos 20U /*!< MVFR0: Square root bits Position */
1372#define FPU_MVFR0_Square_root_Msk (0xFUL << FPU_MVFR0_Square_root_Pos) /*!< MVFR0: Square root bits Mask */
1373
1374#define FPU_MVFR0_Divide_Pos 16U /*!< MVFR0: Divide bits Position */
1375#define FPU_MVFR0_Divide_Msk (0xFUL << FPU_MVFR0_Divide_Pos) /*!< MVFR0: Divide bits Mask */
1376
1377#define FPU_MVFR0_FP_excep_trapping_Pos 12U /*!< MVFR0: FP exception trapping bits Position */
1378#define FPU_MVFR0_FP_excep_trapping_Msk (0xFUL << FPU_MVFR0_FP_excep_trapping_Pos) /*!< MVFR0: FP exception trapping bits Mask */
1379
1380#define FPU_MVFR0_Double_precision_Pos 8U /*!< MVFR0: Double-precision bits Position */
1381#define FPU_MVFR0_Double_precision_Msk (0xFUL << FPU_MVFR0_Double_precision_Pos) /*!< MVFR0: Double-precision bits Mask */
1382
1383#define FPU_MVFR0_Single_precision_Pos 4U /*!< MVFR0: Single-precision bits Position */
1384#define FPU_MVFR0_Single_precision_Msk (0xFUL << FPU_MVFR0_Single_precision_Pos) /*!< MVFR0: Single-precision bits Mask */
1385
1386#define FPU_MVFR0_A_SIMD_registers_Pos 0U /*!< MVFR0: A_SIMD registers bits Position */
1387#define FPU_MVFR0_A_SIMD_registers_Msk (0xFUL /*<< FPU_MVFR0_A_SIMD_registers_Pos*/) /*!< MVFR0: A_SIMD registers bits Mask */
1388
1389/* Media and FP Feature Register 1 Definitions */
1390#define FPU_MVFR1_FP_fused_MAC_Pos 28U /*!< MVFR1: FP fused MAC bits Position */
1391#define FPU_MVFR1_FP_fused_MAC_Msk (0xFUL << FPU_MVFR1_FP_fused_MAC_Pos) /*!< MVFR1: FP fused MAC bits Mask */
1392
1393#define FPU_MVFR1_FP_HPFP_Pos 24U /*!< MVFR1: FP HPFP bits Position */
1394#define FPU_MVFR1_FP_HPFP_Msk (0xFUL << FPU_MVFR1_FP_HPFP_Pos) /*!< MVFR1: FP HPFP bits Mask */
1395
1396#define FPU_MVFR1_D_NaN_mode_Pos 4U /*!< MVFR1: D_NaN mode bits Position */
1397#define FPU_MVFR1_D_NaN_mode_Msk (0xFUL << FPU_MVFR1_D_NaN_mode_Pos) /*!< MVFR1: D_NaN mode bits Mask */
1398
1399#define FPU_MVFR1_FtZ_mode_Pos 0U /*!< MVFR1: FtZ mode bits Position */
1400#define FPU_MVFR1_FtZ_mode_Msk (0xFUL /*<< FPU_MVFR1_FtZ_mode_Pos*/) /*!< MVFR1: FtZ mode bits Mask */
1401
1402/*@} end of group CMSIS_FPU */
1403
1404
1405/**
1406 \ingroup CMSIS_core_register
1407 \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug)
1408 \brief Type definitions for the Core Debug Registers
1409 @{
1410 */
1411
1412/**
1413 \brief Structure type to access the Core Debug Register (CoreDebug).
1414 */
1415typedef struct
1416{
1417 __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */
1418 __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */
1419 __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */
1420 __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */
1421} CoreDebug_Type;
1422
1423/* Debug Halting Control and Status Register Definitions */
1424#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< CoreDebug DHCSR: DBGKEY Position */
1425#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< CoreDebug DHCSR: DBGKEY Mask */
1426
1427#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< CoreDebug DHCSR: S_RESET_ST Position */
1428#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< CoreDebug DHCSR: S_RESET_ST Mask */
1429
1430#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< CoreDebug DHCSR: S_RETIRE_ST Position */
1431#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< CoreDebug DHCSR: S_RETIRE_ST Mask */
1432
1433#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< CoreDebug DHCSR: S_LOCKUP Position */
1434#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< CoreDebug DHCSR: S_LOCKUP Mask */
1435
1436#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< CoreDebug DHCSR: S_SLEEP Position */
1437#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< CoreDebug DHCSR: S_SLEEP Mask */
1438
1439#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< CoreDebug DHCSR: S_HALT Position */
1440#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< CoreDebug DHCSR: S_HALT Mask */
1441
1442#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< CoreDebug DHCSR: S_REGRDY Position */
1443#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< CoreDebug DHCSR: S_REGRDY Mask */
1444
1445#define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5U /*!< CoreDebug DHCSR: C_SNAPSTALL Position */
1446#define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< CoreDebug DHCSR: C_SNAPSTALL Mask */
1447
1448#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< CoreDebug DHCSR: C_MASKINTS Position */
1449#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< CoreDebug DHCSR: C_MASKINTS Mask */
1450
1451#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< CoreDebug DHCSR: C_STEP Position */
1452#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< CoreDebug DHCSR: C_STEP Mask */
1453
1454#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< CoreDebug DHCSR: C_HALT Position */
1455#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< CoreDebug DHCSR: C_HALT Mask */
1456
1457#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< CoreDebug DHCSR: C_DEBUGEN Position */
1458#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< CoreDebug DHCSR: C_DEBUGEN Mask */
1459
1460/* Debug Core Register Selector Register Definitions */
1461#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< CoreDebug DCRSR: REGWnR Position */
1462#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< CoreDebug DCRSR: REGWnR Mask */
1463
1464#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< CoreDebug DCRSR: REGSEL Position */
1465#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< CoreDebug DCRSR: REGSEL Mask */
1466
1467/* Debug Exception and Monitor Control Register Definitions */
1468#define CoreDebug_DEMCR_TRCENA_Pos 24U /*!< CoreDebug DEMCR: TRCENA Position */
1469#define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< CoreDebug DEMCR: TRCENA Mask */
1470
1471#define CoreDebug_DEMCR_MON_REQ_Pos 19U /*!< CoreDebug DEMCR: MON_REQ Position */
1472#define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< CoreDebug DEMCR: MON_REQ Mask */
1473
1474#define CoreDebug_DEMCR_MON_STEP_Pos 18U /*!< CoreDebug DEMCR: MON_STEP Position */
1475#define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< CoreDebug DEMCR: MON_STEP Mask */
1476
1477#define CoreDebug_DEMCR_MON_PEND_Pos 17U /*!< CoreDebug DEMCR: MON_PEND Position */
1478#define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< CoreDebug DEMCR: MON_PEND Mask */
1479
1480#define CoreDebug_DEMCR_MON_EN_Pos 16U /*!< CoreDebug DEMCR: MON_EN Position */
1481#define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< CoreDebug DEMCR: MON_EN Mask */
1482
1483#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< CoreDebug DEMCR: VC_HARDERR Position */
1484#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< CoreDebug DEMCR: VC_HARDERR Mask */
1485
1486#define CoreDebug_DEMCR_VC_INTERR_Pos 9U /*!< CoreDebug DEMCR: VC_INTERR Position */
1487#define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< CoreDebug DEMCR: VC_INTERR Mask */
1488
1489#define CoreDebug_DEMCR_VC_BUSERR_Pos 8U /*!< CoreDebug DEMCR: VC_BUSERR Position */
1490#define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< CoreDebug DEMCR: VC_BUSERR Mask */
1491
1492#define CoreDebug_DEMCR_VC_STATERR_Pos 7U /*!< CoreDebug DEMCR: VC_STATERR Position */
1493#define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< CoreDebug DEMCR: VC_STATERR Mask */
1494
1495#define CoreDebug_DEMCR_VC_CHKERR_Pos 6U /*!< CoreDebug DEMCR: VC_CHKERR Position */
1496#define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< CoreDebug DEMCR: VC_CHKERR Mask */
1497
1498#define CoreDebug_DEMCR_VC_NOCPERR_Pos 5U /*!< CoreDebug DEMCR: VC_NOCPERR Position */
1499#define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< CoreDebug DEMCR: VC_NOCPERR Mask */
1500
1501#define CoreDebug_DEMCR_VC_MMERR_Pos 4U /*!< CoreDebug DEMCR: VC_MMERR Position */
1502#define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< CoreDebug DEMCR: VC_MMERR Mask */
1503
1504#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< CoreDebug DEMCR: VC_CORERESET Position */
1505#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< CoreDebug DEMCR: VC_CORERESET Mask */
1506
1507/*@} end of group CMSIS_CoreDebug */
1508
1509
1510/**
1511 \ingroup CMSIS_core_register
1512 \defgroup CMSIS_core_bitfield Core register bit field macros
1513 \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk).
1514 @{
1515 */
1516
1517/**
1518 \brief Mask and shift a bit field value for use in a register bit range.
1519 \param[in] field Name of the register bit field.
1520 \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type.
1521 \return Masked and shifted value.
1522*/
1523#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk)
1524
1525/**
1526 \brief Mask and shift a register value to extract a bit filed value.
1527 \param[in] field Name of the register bit field.
1528 \param[in] value Value of register. This parameter is interpreted as an uint32_t type.
1529 \return Masked and shifted bit field value.
1530*/
1531#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos)
1532
1533/*@} end of group CMSIS_core_bitfield */
1534
1535
1536/**
1537 \ingroup CMSIS_core_register
1538 \defgroup CMSIS_core_base Core Definitions
1539 \brief Definitions for base addresses, unions, and structures.
1540 @{
1541 */
1542
1543/* Memory mapping of Core Hardware */
1544#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */
1545#define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */
1546#define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */
1547#define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */
1548#define CoreDebug_BASE (0xE000EDF0UL) /*!< Core Debug Base Address */
1549#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */
1550#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */
1551#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */
1552
1553#define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */
1554#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */
1555#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */
1556#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */
1557#define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */
1558#define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */
1559#define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */
1560#define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE) /*!< Core Debug configuration struct */
1561
1562#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U)
1563 #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */
1564 #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */
1565#endif
1566
1567#define FPU_BASE (SCS_BASE + 0x0F30UL) /*!< Floating Point Unit */
1568#define FPU ((FPU_Type *) FPU_BASE ) /*!< Floating Point Unit */
1569
1570/*@} */
1571
1572
1573
1574/*******************************************************************************
1575 * Hardware Abstraction Layer
1576 Core Function Interface contains:
1577 - Core NVIC Functions
1578 - Core SysTick Functions
1579 - Core Debug Functions
1580 - Core Register Access Functions
1581 ******************************************************************************/
1582/**
1583 \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference
1584*/
1585
1586
1587
1588/* ########################## NVIC functions #################################### */
1589/**
1590 \ingroup CMSIS_Core_FunctionInterface
1591 \defgroup CMSIS_Core_NVICFunctions NVIC Functions
1592 \brief Functions that manage interrupts and exceptions via the NVIC.
1593 @{
1594 */
1595
1596#ifdef CMSIS_NVIC_VIRTUAL
1597 #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE
1598 #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h"
1599 #endif
1600 #include CMSIS_NVIC_VIRTUAL_HEADER_FILE
1601#else
1602 #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping
1603 #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping
1604 #define NVIC_EnableIRQ __NVIC_EnableIRQ
1605 #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ
1606 #define NVIC_DisableIRQ __NVIC_DisableIRQ
1607 #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ
1608 #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ
1609 #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ
1610 #define NVIC_GetActive __NVIC_GetActive
1611 #define NVIC_SetPriority __NVIC_SetPriority
1612 #define NVIC_GetPriority __NVIC_GetPriority
1613 #define NVIC_SystemReset __NVIC_SystemReset
1614#endif /* CMSIS_NVIC_VIRTUAL */
1615
1616#ifdef CMSIS_VECTAB_VIRTUAL
1617 #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE
1618 #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h"
1619 #endif
1620 #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE
1621#else
1622 #define NVIC_SetVector __NVIC_SetVector
1623 #define NVIC_GetVector __NVIC_GetVector
1624#endif /* (CMSIS_VECTAB_VIRTUAL) */
1625
1626#define NVIC_USER_IRQ_OFFSET 16
1627
1628
1629
1630/**
1631 \brief Set Priority Grouping
1632 \details Sets the priority grouping field using the required unlock sequence.
1633 The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field.
1634 Only values from 0..7 are used.
1635 In case of a conflict between priority grouping and available
1636 priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set.
1637 \param [in] PriorityGroup Priority grouping field.
1638 */
1639__STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup)
1640{
1641 uint32_t reg_value;
1642 uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */
1643
1644 reg_value = SCB->AIRCR; /* read old register configuration */
1645 reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */
1646 reg_value = (reg_value |
1647 ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) |
1648 (PriorityGroupTmp << 8U) ); /* Insert write key and priorty group */
1649 SCB->AIRCR = reg_value;
1650}
1651
1652
1653/**
1654 \brief Get Priority Grouping
1655 \details Reads the priority grouping field from the NVIC Interrupt Controller.
1656 \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field).
1657 */
1658__STATIC_INLINE uint32_t __NVIC_GetPriorityGrouping(void)
1659{
1660 return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos));
1661}
1662
1663
1664/**
1665 \brief Enable Interrupt
1666 \details Enables a device specific interrupt in the NVIC interrupt controller.
1667 \param [in] IRQn Device specific interrupt number.
1668 \note IRQn must not be negative.
1669 */
1670__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn)
1671{
1672 if ((int32_t)(IRQn) >= 0)
1673 {
1674 NVIC->ISER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
1675 }
1676}
1677
1678
1679/**
1680 \brief Get Interrupt Enable status
1681 \details Returns a device specific interrupt enable status from the NVIC interrupt controller.
1682 \param [in] IRQn Device specific interrupt number.
1683 \return 0 Interrupt is not enabled.
1684 \return 1 Interrupt is enabled.
1685 \note IRQn must not be negative.
1686 */
1687__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn)
1688{
1689 if ((int32_t)(IRQn) >= 0)
1690 {
1691 return((uint32_t)(((NVIC->ISER[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
1692 }
1693 else
1694 {
1695 return(0U);
1696 }
1697}
1698
1699
1700/**
1701 \brief Disable Interrupt
1702 \details Disables a device specific interrupt in the NVIC interrupt controller.
1703 \param [in] IRQn Device specific interrupt number.
1704 \note IRQn must not be negative.
1705 */
1706__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn)
1707{
1708 if ((int32_t)(IRQn) >= 0)
1709 {
1710 NVIC->ICER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
1711 __DSB();
1712 __ISB();
1713 }
1714}
1715
1716
1717/**
1718 \brief Get Pending Interrupt
1719 \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt.
1720 \param [in] IRQn Device specific interrupt number.
1721 \return 0 Interrupt status is not pending.
1722 \return 1 Interrupt status is pending.
1723 \note IRQn must not be negative.
1724 */
1725__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn)
1726{
1727 if ((int32_t)(IRQn) >= 0)
1728 {
1729 return((uint32_t)(((NVIC->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
1730 }
1731 else
1732 {
1733 return(0U);
1734 }
1735}
1736
1737
1738/**
1739 \brief Set Pending Interrupt
1740 \details Sets the pending bit of a device specific interrupt in the NVIC pending register.
1741 \param [in] IRQn Device specific interrupt number.
1742 \note IRQn must not be negative.
1743 */
1744__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn)
1745{
1746 if ((int32_t)(IRQn) >= 0)
1747 {
1748 NVIC->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
1749 }
1750}
1751
1752
1753/**
1754 \brief Clear Pending Interrupt
1755 \details Clears the pending bit of a device specific interrupt in the NVIC pending register.
1756 \param [in] IRQn Device specific interrupt number.
1757 \note IRQn must not be negative.
1758 */
1759__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn)
1760{
1761 if ((int32_t)(IRQn) >= 0)
1762 {
1763 NVIC->ICPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
1764 }
1765}
1766
1767
1768/**
1769 \brief Get Active Interrupt
1770 \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt.
1771 \param [in] IRQn Device specific interrupt number.
1772 \return 0 Interrupt status is not active.
1773 \return 1 Interrupt status is active.
1774 \note IRQn must not be negative.
1775 */
1776__STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn)
1777{
1778 if ((int32_t)(IRQn) >= 0)
1779 {
1780 return((uint32_t)(((NVIC->IABR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
1781 }
1782 else
1783 {
1784 return(0U);
1785 }
1786}
1787
1788
1789/**
1790 \brief Set Interrupt Priority
1791 \details Sets the priority of a device specific interrupt or a processor exception.
1792 The interrupt number can be positive to specify a device specific interrupt,
1793 or negative to specify a processor exception.
1794 \param [in] IRQn Interrupt number.
1795 \param [in] priority Priority to set.
1796 \note The priority cannot be set for every processor exception.
1797 */
1798__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
1799{
1800 if ((int32_t)(IRQn) >= 0)
1801 {
1802 NVIC->IP[((uint32_t)(int32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL);
1803 }
1804 else
1805 {
1806 SCB->SHP[(((uint32_t)(int32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL);
1807 }
1808}
1809
1810
1811/**
1812 \brief Get Interrupt Priority
1813 \details Reads the priority of a device specific interrupt or a processor exception.
1814 The interrupt number can be positive to specify a device specific interrupt,
1815 or negative to specify a processor exception.
1816 \param [in] IRQn Interrupt number.
1817 \return Interrupt Priority.
1818 Value is aligned automatically to the implemented priority bits of the microcontroller.
1819 */
1820__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn)
1821{
1822
1823 if ((int32_t)(IRQn) >= 0)
1824 {
1825 return(((uint32_t)NVIC->IP[((uint32_t)(int32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS)));
1826 }
1827 else
1828 {
1829 return(((uint32_t)SCB->SHP[(((uint32_t)(int32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS)));
1830 }
1831}
1832
1833
1834/**
1835 \brief Encode Priority
1836 \details Encodes the priority for an interrupt with the given priority group,
1837 preemptive priority value, and subpriority value.
1838 In case of a conflict between priority grouping and available
1839 priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set.
1840 \param [in] PriorityGroup Used priority group.
1841 \param [in] PreemptPriority Preemptive priority value (starting from 0).
1842 \param [in] SubPriority Subpriority value (starting from 0).
1843 \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority().
1844 */
1845__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority)
1846{
1847 uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */
1848 uint32_t PreemptPriorityBits;
1849 uint32_t SubPriorityBits;
1850
1851 PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp);
1852 SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS));
1853
1854 return (
1855 ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) |
1856 ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL)))
1857 );
1858}
1859
1860
1861/**
1862 \brief Decode Priority
1863 \details Decodes an interrupt priority value with a given priority group to
1864 preemptive priority value and subpriority value.
1865 In case of a conflict between priority grouping and available
1866 priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set.
1867 \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority().
1868 \param [in] PriorityGroup Used priority group.
1869 \param [out] pPreemptPriority Preemptive priority value (starting from 0).
1870 \param [out] pSubPriority Subpriority value (starting from 0).
1871 */
1872__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority)
1873{
1874 uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */
1875 uint32_t PreemptPriorityBits;
1876 uint32_t SubPriorityBits;
1877
1878 PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp);
1879 SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS));
1880
1881 *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL);
1882 *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL);
1883}
1884
1885
1886/**
1887 \brief Set Interrupt Vector
1888 \details Sets an interrupt vector in SRAM based interrupt vector table.
1889 The interrupt number can be positive to specify a device specific interrupt,
1890 or negative to specify a processor exception.
1891 VTOR must been relocated to SRAM before.
1892 \param [in] IRQn Interrupt number
1893 \param [in] vector Address of interrupt handler function
1894 */
1895__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector)
1896{
1897 uint32_t *vectors = (uint32_t *)SCB->VTOR;
1898 vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector;
1899}
1900
1901
1902/**
1903 \brief Get Interrupt Vector
1904 \details Reads an interrupt vector from interrupt vector table.
1905 The interrupt number can be positive to specify a device specific interrupt,
1906 or negative to specify a processor exception.
1907 \param [in] IRQn Interrupt number.
1908 \return Address of interrupt handler function
1909 */
1910__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn)
1911{
1912 uint32_t *vectors = (uint32_t *)SCB->VTOR;
1913 return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET];
1914}
1915
1916
1917/**
1918 \brief System Reset
1919 \details Initiates a system reset request to reset the MCU.
1920 */
1921__STATIC_INLINE void __NVIC_SystemReset(void)
1922{
1923 __DSB(); /* Ensure all outstanding memory accesses included
1924 buffered write are completed before reset */
1925 SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) |
1926 (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) |
1927 SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */
1928 __DSB(); /* Ensure completion of memory access */
1929
1930 for(;;) /* wait until reset */
1931 {
1932 __NOP();
1933 }
1934}
1935
1936/*@} end of CMSIS_Core_NVICFunctions */
1937
1938
1939/* ########################## FPU functions #################################### */
1940/**
1941 \ingroup CMSIS_Core_FunctionInterface
1942 \defgroup CMSIS_Core_FpuFunctions FPU Functions
1943 \brief Function that provides FPU type.
1944 @{
1945 */
1946
1947/**
1948 \brief get FPU type
1949 \details returns the FPU type
1950 \returns
1951 - \b 0: No FPU
1952 - \b 1: Single precision FPU
1953 - \b 2: Double + Single precision FPU
1954 */
1955__STATIC_INLINE uint32_t SCB_GetFPUType(void)
1956{
1957 uint32_t mvfr0;
1958
1959 mvfr0 = FPU->MVFR0;
1960 if ((mvfr0 & (FPU_MVFR0_Single_precision_Msk | FPU_MVFR0_Double_precision_Msk)) == 0x020U)
1961 {
1962 return 1U; /* Single precision FPU */
1963 }
1964 else
1965 {
1966 return 0U; /* No FPU */
1967 }
1968}
1969
1970
1971/*@} end of CMSIS_Core_FpuFunctions */
1972
1973
1974
1975/* ################################## SysTick function ############################################ */
1976/**
1977 \ingroup CMSIS_Core_FunctionInterface
1978 \defgroup CMSIS_Core_SysTickFunctions SysTick Functions
1979 \brief Functions that configure the System.
1980 @{
1981 */
1982
1983#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U)
1984
1985/**
1986 \brief System Tick Configuration
1987 \details Initializes the System Timer and its interrupt, and starts the System Tick Timer.
1988 Counter is in free running mode to generate periodic interrupts.
1989 \param [in] ticks Number of ticks between two interrupts.
1990 \return 0 Function succeeded.
1991 \return 1 Function failed.
1992 \note When the variable <b>__Vendor_SysTickConfig</b> is set to 1, then the
1993 function <b>SysTick_Config</b> is not included. In this case, the file <b><i>device</i>.h</b>
1994 must contain a vendor-specific implementation of this function.
1995 */
1996__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks)
1997{
1998 if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk)
1999 {
2000 return (1UL); /* Reload value impossible */
2001 }
2002
2003 SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */
2004 NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */
2005 SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
2006 SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk |
2007 SysTick_CTRL_TICKINT_Msk |
2008 SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */
2009 return (0UL); /* Function successful */
2010}
2011
2012#endif
2013
2014/*@} end of CMSIS_Core_SysTickFunctions */
2015
2016
2017
2018/* ##################################### Debug In/Output function ########################################### */
2019/**
2020 \ingroup CMSIS_Core_FunctionInterface
2021 \defgroup CMSIS_core_DebugFunctions ITM Functions
2022 \brief Functions that access the ITM debug interface.
2023 @{
2024 */
2025
2026extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */
2027#define ITM_RXBUFFER_EMPTY ((int32_t)0x5AA55AA5U) /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */
2028
2029
2030/**
2031 \brief ITM Send Character
2032 \details Transmits a character via the ITM channel 0, and
2033 \li Just returns when no debugger is connected that has booked the output.
2034 \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted.
2035 \param [in] ch Character to transmit.
2036 \returns Character to transmit.
2037 */
2038__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch)
2039{
2040 if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */
2041 ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */
2042 {
2043 while (ITM->PORT[0U].u32 == 0UL)
2044 {
2045 __NOP();
2046 }
2047 ITM->PORT[0U].u8 = (uint8_t)ch;
2048 }
2049 return (ch);
2050}
2051
2052
2053/**
2054 \brief ITM Receive Character
2055 \details Inputs a character via the external variable \ref ITM_RxBuffer.
2056 \return Received character.
2057 \return -1 No character pending.
2058 */
2059__STATIC_INLINE int32_t ITM_ReceiveChar (void)
2060{
2061 int32_t ch = -1; /* no character available */
2062
2063 if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY)
2064 {
2065 ch = ITM_RxBuffer;
2066 ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */
2067 }
2068
2069 return (ch);
2070}
2071
2072
2073/**
2074 \brief ITM Check Character
2075 \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer.
2076 \return 0 No character available.
2077 \return 1 Character available.
2078 */
2079__STATIC_INLINE int32_t ITM_CheckChar (void)
2080{
2081
2082 if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY)
2083 {
2084 return (0); /* no character available */
2085 }
2086 else
2087 {
2088 return (1); /* character available */
2089 }
2090}
2091
2092/*@} end of CMSIS_core_DebugFunctions */
2093
2094
2095
2096
2097#ifdef __cplusplus
2098}
2099#endif
2100
2101#endif /* __CORE_CM4_H_DEPENDANT */
2102
2103#endif /* __CMSIS_GENERIC */
diff --git a/lib/arm_atsam/packs/arm/cmsis/5.0.1/LICENSE.txt b/lib/arm_atsam/packs/arm/cmsis/5.0.1/LICENSE.txt
new file mode 100644
index 000000000..8dada3eda
--- /dev/null
+++ b/lib/arm_atsam/packs/arm/cmsis/5.0.1/LICENSE.txt
@@ -0,0 +1,201 @@
1 Apache License
2 Version 2.0, January 2004
3 http://www.apache.org/licenses/
4
5 TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
7 1. Definitions.
8
9 "License" shall mean the terms and conditions for use, reproduction,
10 and distribution as defined by Sections 1 through 9 of this document.
11
12 "Licensor" shall mean the copyright owner or entity authorized by
13 the copyright owner that is granting the License.
14
15 "Legal Entity" shall mean the union of the acting entity and all
16 other entities that control, are controlled by, or are under common
17 control with that entity. For the purposes of this definition,
18 "control" means (i) the power, direct or indirect, to cause the
19 direction or management of such entity, whether by contract or
20 otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 outstanding shares, or (iii) beneficial ownership of such entity.
22
23 "You" (or "Your") shall mean an individual or Legal Entity
24 exercising permissions granted by this License.
25
26 "Source" form shall mean the preferred form for making modifications,
27 including but not limited to software source code, documentation
28 source, and configuration files.
29
30 "Object" form shall mean any form resulting from mechanical
31 transformation or translation of a Source form, including but
32 not limited to compiled object code, generated documentation,
33 and conversions to other media types.
34
35 "Work" shall mean the work of authorship, whether in Source or
36 Object form, made available under the License, as indicated by a
37 copyright notice that is included in or attached to the work
38 (an example is provided in the Appendix below).
39
40 "Derivative Works" shall mean any work, whether in Source or Object
41 form, that is based on (or derived from) the Work and for which the
42 editorial revisions, annotations, elaborations, or other modifications
43 represent, as a whole, an original work of authorship. For the purposes
44 of this License, Derivative Works shall not include works that remain
45 separable from, or merely link (or bind by name) to the interfaces of,
46 the Work and Derivative Works thereof.
47
48 "Contribution" shall mean any work of authorship, including
49 the original version of the Work and any modifications or additions
50 to that Work or Derivative Works thereof, that is intentionally
51 submitted to Licensor for inclusion in the Work by the copyright owner
52 or by an individual or Legal Entity authorized to submit on behalf of
53 the copyright owner. For the purposes of this definition, "submitted"
54 means any form of electronic, verbal, or written communication sent
55 to the Licensor or its representatives, including but not limited to
56 communication on electronic mailing lists, source code control systems,
57 and issue tracking systems that are managed by, or on behalf of, the
58 Licensor for the purpose of discussing and improving the Work, but
59 excluding communication that is conspicuously marked or otherwise
60 designated in writing by the copyright owner as "Not a Contribution."
61
62 "Contributor" shall mean Licensor and any individual or Legal Entity
63 on behalf of whom a Contribution has been received by Licensor and
64 subsequently incorporated within the Work.
65
66 2. Grant of Copyright License. Subject to the terms and conditions of
67 this License, each Contributor hereby grants to You a perpetual,
68 worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 copyright license to reproduce, prepare Derivative Works of,
70 publicly display, publicly perform, sublicense, and distribute the
71 Work and such Derivative Works in Source or Object form.
72
73 3. Grant of Patent License. Subject to the terms and conditions of
74 this License, each Contributor hereby grants to You a perpetual,
75 worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 (except as stated in this section) patent license to make, have made,
77 use, offer to sell, sell, import, and otherwise transfer the Work,
78 where such license applies only to those patent claims licensable
79 by such Contributor that are necessarily infringed by their
80 Contribution(s) alone or by combination of their Contribution(s)
81 with the Work to which such Contribution(s) was submitted. If You
82 institute patent litigation against any entity (including a
83 cross-claim or counterclaim in a lawsuit) alleging that the Work
84 or a Contribution incorporated within the Work constitutes direct
85 or contributory patent infringement, then any patent licenses
86 granted to You under this License for that Work shall terminate
87 as of the date such litigation is filed.
88
89 4. Redistribution. You may reproduce and distribute copies of the
90 Work or Derivative Works thereof in any medium, with or without
91 modifications, and in Source or Object form, provided that You
92 meet the following conditions:
93
94 (a) You must give any other recipients of the Work or
95 Derivative Works a copy of this License; and
96
97 (b) You must cause any modified files to carry prominent notices
98 stating that You changed the files; and
99
100 (c) You must retain, in the Source form of any Derivative Works
101 that You distribute, all copyright, patent, trademark, and
102 attribution notices from the Source form of the Work,
103 excluding those notices that do not pertain to any part of
104 the Derivative Works; and
105
106 (d) If the Work includes a "NOTICE" text file as part of its
107 distribution, then any Derivative Works that You distribute must
108 include a readable copy of the attribution notices contained
109 within such NOTICE file, excluding those notices that do not
110 pertain to any part of the Derivative Works, in at least one
111 of the following places: within a NOTICE text file distributed
112 as part of the Derivative Works; within the Source form or
113 documentation, if provided along with the Derivative Works; or,
114 within a display generated by the Derivative Works, if and
115 wherever such third-party notices normally appear. The contents
116 of the NOTICE file are for informational purposes only and
117 do not modify the License. You may add Your own attribution
118 notices within Derivative Works that You distribute, alongside
119 or as an addendum to the NOTICE text from the Work, provided
120 that such additional attribution notices cannot be construed
121 as modifying the License.
122
123 You may add Your own copyright statement to Your modifications and
124 may provide additional or different license terms and conditions
125 for use, reproduction, or distribution of Your modifications, or
126 for any such Derivative Works as a whole, provided Your use,
127 reproduction, and distribution of the Work otherwise complies with
128 the conditions stated in this License.
129
130 5. Submission of Contributions. Unless You explicitly state otherwise,
131 any Contribution intentionally submitted for inclusion in the Work
132 by You to the Licensor shall be under the terms and conditions of
133 this License, without any additional terms or conditions.
134 Notwithstanding the above, nothing herein shall supersede or modify
135 the terms of any separate license agreement you may have executed
136 with Licensor regarding such Contributions.
137
138 6. Trademarks. This License does not grant permission to use the trade
139 names, trademarks, service marks, or product names of the Licensor,
140 except as required for reasonable and customary use in describing the
141 origin of the Work and reproducing the content of the NOTICE file.
142
143 7. Disclaimer of Warranty. Unless required by applicable law or
144 agreed to in writing, Licensor provides the Work (and each
145 Contributor provides its Contributions) on an "AS IS" BASIS,
146 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 implied, including, without limitation, any warranties or conditions
148 of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 PARTICULAR PURPOSE. You are solely responsible for determining the
150 appropriateness of using or redistributing the Work and assume any
151 risks associated with Your exercise of permissions under this License.
152
153 8. Limitation of Liability. In no event and under no legal theory,
154 whether in tort (including negligence), contract, or otherwise,
155 unless required by applicable law (such as deliberate and grossly
156 negligent acts) or agreed to in writing, shall any Contributor be
157 liable to You for damages, including any direct, indirect, special,
158 incidental, or consequential damages of any character arising as a
159 result of this License or out of the use or inability to use the
160 Work (including but not limited to damages for loss of goodwill,
161 work stoppage, computer failure or malfunction, or any and all
162 other commercial damages or losses), even if such Contributor
163 has been advised of the possibility of such damages.
164
165 9. Accepting Warranty or Additional Liability. While redistributing
166 the Work or Derivative Works thereof, You may choose to offer,
167 and charge a fee for, acceptance of support, warranty, indemnity,
168 or other liability obligations and/or rights consistent with this
169 License. However, in accepting such obligations, You may act only
170 on Your own behalf and on Your sole responsibility, not on behalf
171 of any other Contributor, and only if You agree to indemnify,
172 defend, and hold each Contributor harmless for any liability
173 incurred by, or claims asserted against, such Contributor by reason
174 of your accepting any such warranty or additional liability.
175
176 END OF TERMS AND CONDITIONS
177
178 APPENDIX: How to apply the Apache License to your work.
179
180 To apply the Apache License to your work, attach the following
181 boilerplate notice, with the fields enclosed by brackets "{}"
182 replaced with your own identifying information. (Don't include
183 the brackets!) The text should be enclosed in the appropriate
184 comment syntax for the file format. We also recommend that a
185 file or class name and description of purpose be included on the
186 same "printed page" as the copyright notice for easier
187 identification within third-party archives.
188
189 Copyright {yyyy} {name of copyright owner}
190
191 Licensed under the Apache License, Version 2.0 (the "License");
192 you may not use this file except in compliance with the License.
193 You may obtain a copy of the License at
194
195 http://www.apache.org/licenses/LICENSE-2.0
196
197 Unless required by applicable law or agreed to in writing, software
198 distributed under the License is distributed on an "AS IS" BASIS,
199 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 See the License for the specific language governing permissions and
201 limitations under the License.