CMSIS-DSP  Version 1.7.0
CMSIS DSP Software Library
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
arm_linear_interp_example_f32.c
/* ----------------------------------------------------------------------
* Copyright (C) 2010-2012 ARM Limited. All rights reserved.
*
* $Date: 17. January 2013
* $Revision: V1.4.0
*
* Project: CMSIS DSP Library
* Title: arm_linear_interp_example_f32.c
*
* Description: Example code demonstrating usage of sin function
* and uses linear interpolation to get higher precision
*
* Target Processor: Cortex-M4/Cortex-M3
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* - Neither the name of ARM LIMITED nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* -------------------------------------------------------------------- */
#include "arm_math.h"
#include "math_helper.h"
#define SNR_THRESHOLD 90
#define TEST_LENGTH_SAMPLES 10
#define XSPACING (0.00005f)
/* ----------------------------------------------------------------------
* Test input data for F32 SIN function
* Generated by the MATLAB rand() function
* randn('state', 0)
* xi = (((1/4.18318581819710)* randn(blockSize, 1) * 2* pi));
* --------------------------------------------------------------------*/
{
-0.649716504673081170, -2.501723745497831200,
0.188250329003310100, 0.432092748487532540,
-1.722010988459680800, 1.788766476323060600,
1.786136060975809500, -0.056525543169408797,
0.491596272728153760, 0.262309671126153390
};
/*------------------------------------------------------------------------------
* Reference out of SIN F32 function for Block Size = 10
* Calculated from sin(testInputSin_f32)
*------------------------------------------------------------------------------*/
{
-0.604960695383043530, -0.597090287967934840,
0.187140422442966500, 0.418772124875992690,
-0.988588831792106880, 0.976338412038794010,
0.976903856413481100, -0.056495446835214236,
0.472033731854734240, 0.259311907228582830
};
/*------------------------------------------------------------------------------
* Method 1: Test out Buffer Calculated from Cubic Interpolation
*------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
* Method 2: Test out buffer Calculated from Linear Interpolation
*------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
* External table used for linear interpolation
*------------------------------------------------------------------------------*/
extern float arm_linear_interep_table[188495];
/* ----------------------------------------------------------------------
* Global Variables for caluclating SNR's for Method1 & Method 2
* ------------------------------------------------------------------- */
/* ----------------------------------------------------------------------------
* Calculation of Sine values from Cubic Interpolation and Linear interpolation
* ---------------------------------------------------------------------------- */
int32_t main(void)
{
uint32_t i;
arm_linear_interp_instance_f32 S = {188495, -3.141592653589793238, XSPACING, &arm_linear_interep_table[0]};
/*------------------------------------------------------------------------------
* Method 1: Test out Calculated from Cubic Interpolation
*------------------------------------------------------------------------------*/
for(i=0; i< TEST_LENGTH_SAMPLES; i++)
{
}
/*------------------------------------------------------------------------------
* Method 2: Test out Calculated from Cubic Interpolation and Linear interpolation
*------------------------------------------------------------------------------*/
for(i=0; i< TEST_LENGTH_SAMPLES; i++)
{
}
/*------------------------------------------------------------------------------
* SNR calculation for method 1
*------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
* SNR calculation for method 2
*------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
* Initialise status depending on SNR calculations
*------------------------------------------------------------------------------*/
if ( snr2 > snr1)
{
status = ARM_MATH_SUCCESS;
}
else
{
}
/* ----------------------------------------------------------------------
** Loop here if the signals fail the PASS check.
** This denotes a test failure
** ------------------------------------------------------------------- */
if ( status != ARM_MATH_SUCCESS)
{
while (1);
}
while (1); /* main function does not return */
}