Logo
MSP DSP Library
Common

Macros

#define DSPLIB_TABLE_OFFSET   2
 Offset used to store table size.
 
#define CMPLX_INCREMENT   (2)
 Increment size for complex data.
 
#define CMPLX_REAL(ptr)   ((ptr)[0])
 Access the real portion of complex data.
 
#define CMPLX_IMAG(ptr)   ((ptr)[1])
 Access the imaginary portion of complex data.
 
#define _Q15(A)
 Convert number to Q15 fixed point. More...
 
#define _IQ31(A)
 Convert number to IQ31 fixed point. More...
 
#define _Q31(A)   (_IQ31(A))
 Convert number to IQ31 fixed point.
 
#define __saturate(x, min, max)   (((x)>(max))?(max):(((x)<(min))?(min):(x)))
 Saturate input to minimum or maximum value and return value.
 
#define DSPLIB_DATA(var, align)
 Place data with alignment, when LEA is used data is placed into the shared RAM section.
 

Functions

static _q15 __saturated_add_q15 (_q15 x, _q15 y)
 Add Q15 arguments with saturation.
 
static _q15 __saturated_sub_q15 (_q15 x, _q15 y)
 Subtract Q15 arguments with saturation.
 
static _iq31 __saturated_add_iq31 (_iq31 x, _iq31 y)
 Add IQ31 arguments with saturation.
 
static _iq31 __saturated_sub_iq31 (_iq31 x, _iq31 y)
 Subtract IQ31 arguments with saturation.
 
static void msp_checkStatus (msp_status status)
 Check status flag and loop forever if not MSP_SUCCESS. More...
 
static void msp_benchmarkStart (uint16_t baseAddress, uint8_t res)
 Start benchmark using Timer_A or Timer_B with SMCLK as the clock source. More...
 
static uint32_t msp_benchmarkStop (uint16_t baseAddress)
 Stop timer benchmark and return cycle counts. More...
 
static int16_t __q15mpy (int16_t a, int16_t b)
 Real Q15 multiply with result returned. More...
 
static int32_t __q15mpyl (int16_t a, int16_t b)
 Real Q15 multiply with 32-bit result returned. More...
 
static int32_t __q31mpy (int32_t a, int32_t b)
 Real Q31 multiply with result returned. More...
 
static void __q15cmpy (int16_t *aR, int16_t *aI, const int16_t *bR, const int16_t *bI)
 Complex Q15 multiply with result stored back to a. More...
 
static void __q15iq31cmpy (int32_t *aR, int32_t *aI, const int32_t *bR, const int32_t *bI)
 Complex IQ31 by IQ31 multiply with result stored back to a. More...
 

Detailed Description

This file provides common definitions, useful conversion macros and abstracted functions to support the core DSPLib functions. While not all macros and functions in this file are useful outside of DSPLib the main application can use any of them as needed.

Macro Definition Documentation

#define _IQ31 (   A)
Value:
((_iq31)((((uint32_t)1 << 31) * \
__saturate(A,-1.0,2147483647.0/2147483648.0))))
int32_t _iq31
Signed fixed point data type with 1 integer bit and 31 fractional bits.
Definition: DSPLib_types.h:100
#define __saturate(x, min, max)
Saturate input to minimum or maximum value and return value.
Definition: DSPLib_support.h:106

Convert number to IQ31 fixed point.

Examples:
filter_ex2_fir_iq31.c.
#define _Q15 (   A)
Value:
((_q15)((((uint32_t)1 << 15) * \
__saturate(A,-1.0,32767.0/32768.0))))
#define __saturate(x, min, max)
Saturate input to minimum or maximum value and return value.
Definition: DSPLib_support.h:106
int16_t _q15
Signed fixed point data type with 1 integer bit and 15 fractional bits.
Definition: DSPLib_types.h:79

Convert number to Q15 fixed point.

Examples:
filter_ex1_fir_q15.c, filter_ex2_fir_iq31.c, filter_ex3_biquad_cascade_df1_q15.c, filter_ex4_biquad_cascade_df2_q15.c, filter_ex5_biquad_cascade_df2_ext_q15.c, matrix_ex1_add_q15.c, matrix_ex2_trans_q15.c, matrix_ex3_mpy_q15.c, transform_ex1_fft_fixed_q15.c, transform_ex2_cmplx_fft_auto_q15.c, transform_ex3_fft_iq31.c, vector_ex1_max_q15.c, and vector_ex2_complex_add_q15.c.

Function Documentation

static void __q15cmpy ( int16_t *  aR,
int16_t *  aI,
const int16_t *  bR,
const int16_t *  bI 
)
inlinestatic

Complex Q15 multiply with result stored back to a.

Parameters
aRFirst real Q15 input
aIFirst imaginary Q15 input
bRSecond real Q15 input
bISecond imaginary Q15 input
Returns
Q15 result
static void __q15iq31cmpy ( int32_t *  aR,
int32_t *  aI,
const int32_t *  bR,
const int32_t *  bI 
)
inlinestatic

Complex IQ31 by IQ31 multiply with result stored back to a.

Parameters
aRFirst real IQ31 input
aIFirst imaginary IQ31 input
bRSecond real IQ31 input
bISecond imaginary IQ31 input
Returns
IQ31 result
static int16_t __q15mpy ( int16_t  a,
int16_t  b 
)
inlinestatic

Real Q15 multiply with result returned.

Parameters
aFirst Q15 input
bSecond Q15 input
Returns
Q15 result
static int32_t __q15mpyl ( int16_t  a,
int16_t  b 
)
inlinestatic

Real Q15 multiply with 32-bit result returned.

Parameters
aFirst Q15 input
bSecond Q15 input
Returns
IQ31 result
static int32_t __q31mpy ( int32_t  a,
int32_t  b 
)
inlinestatic

Real Q31 multiply with result returned.

Parameters
aFirst Q31 input
bSecond Q31 input
Returns
Q31 result
static void msp_benchmarkStart ( uint16_t  baseAddress,
uint8_t  res 
)
inlinestatic

Start benchmark using Timer_A or Timer_B with SMCLK as the clock source.

Parameters
baseAddressBase address of timer peripheral to use.
resResolution of the benchmark, valid values are:
  • 1 (16-bit result)
  • 2 (17-bit result)
  • 4 (18-bit result)
  • 8 (19-bit result)
  • 16 (20-bit result)
  • 32 (21-bit result)
  • 64 (22-bit result)
Returns
None
Examples:
filter_ex1_fir_q15.c, filter_ex2_fir_iq31.c, filter_ex3_biquad_cascade_df1_q15.c, filter_ex4_biquad_cascade_df2_q15.c, filter_ex5_biquad_cascade_df2_ext_q15.c, matrix_ex1_add_q15.c, matrix_ex2_trans_q15.c, matrix_ex3_mpy_q15.c, transform_ex1_fft_fixed_q15.c, transform_ex2_cmplx_fft_auto_q15.c, transform_ex3_fft_iq31.c, vector_ex1_max_q15.c, and vector_ex2_complex_add_q15.c.
static uint32_t msp_benchmarkStop ( uint16_t  baseAddress)
inlinestatic