⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dsplib_keil.h

📁 基于c166的 FFT算法源程序
💻 H
字号:
/**********************************************************************************
*	Module		Header File	
*	Filename	DspLib_Keil.h
*	Project		DSP Library for XC16x Microcontroller
*----------------------------------------------------------------------------------
*	Compiler:	Keil
*
*	Version:	V 1.2
*
*	Description:
*				This header file lists
*				1. Typedef statements 
*				2. All the functions of DSP Library   
*----------------------------------------------------------------------------------
*	Date:		April 2003	
*
*	History:           
**********************************************************************************/ 	

#include <XC161.h>                /* special function register XC161   */


typedef short  	DataS;	    	//16-bit data 
typedef long	DataL;	        //32-bit data 

//*********************************************************************************
// This contains the user defined data types for the complex functions  
//-----------------------------------------------------------------------------

typedef struct
{
	short real;
	short imag;
}CplxS;

typedef struct
{
	long real;
	long imag;
}CplxL;


//****************** Arithmetic Operations ****************************************
extern void CplxAdd_16(
					CplxS* 	X,			// first 1Q15 data
					CplxS* 	Y,			// second 1Q15 data
					CplxS*	R			// output
					);
extern void CplxSub_16(
					CplxS* 	X,			// first 1Q15 data
					CplxS* 	Y,			// second 1Q15 data
					CplxS*	R			// output
					);
extern void  CplxMul_16(
					CplxS* 	X,			// first 1Q15 data
					CplxS* 	Y,			// second 1Q15 data
					CplxS*	R			// result
				);
extern DataL Mul_32(
				 DataL* 	X,			// first 1Q15 data
				 DataL* 	Y			// second 1Q15 data
				);				

//***************************** FIR Filters ***************************************
extern DataS Fir_16(
				DataS* 	H,			// pointer to filter coefficient vector
				DataS*	IN,			// the new input sample
				DataS	N_h,		// Filter order
				DataS*	D_buffer	// pointer to delay buffer
				);	
extern DataS Fir_32(
				DataL* 	H,			// pointer to filter coefficient vector
				DataS*	IN,			// the new input sample
				DataS	N_h,		// Filter order
				DataS*	D_buffer	// pointer to delay buffer
				);	
extern DataS Fir_dec(
				DataS* 	x,			// pointer to input x
				DataS*	h,			// pointer to coefficent vector h
				DataS*	y,			// pointer to output y
				DataS*	d_buffer,	// pointer to delay buffer
				DataS	N_x,		// size of x
				DataS	N_h,		// filter order
				DataS	D			// decimating factor
		   	  	);
extern DataS Fir_inter(
				DataS* 	x,			// pointer to input x
				DataS*	h,			// pointer to coefficent vector h
				DataS*	y,			// pointer to output y
				DataS*	d_buffer,	// pointer to delay buffer
				DataS	N_x,		// size of x
				DataS	N_h,		// filter order
				DataS	I			// interpolating factor
		   	  	);
extern DataS Fir_lat(
				DataS* 	x,			// pointer to input x
				DataS*	K,			// pointer to lattice coefficent vector K
				DataS*	y,			// pointer to output y
				DataS*	u,			// pointer to delay buffer
				DataS	N_x,		// size of x
				DataS	M			// filter nummber of stages
		   	  	);   
extern DataS Fir_sym(
				DataS* 	x,			// pointer to input x
				DataS*	h,			// pointer to coefficent vector h
				DataS*	y,			// pointer to output y
				DataS*	d_buffer,	// pointer to delay buffer
				DataS	N_x,		// size of x
				DataS	N_h			// half of filter order
		   	  	);	 
extern DataS Fir_cplx(
				CplxS* 	x,			// pointer to complex input x
				CplxS*	h,			// pointer to complex coefficent vector h
				CplxS*	y,			// pointer to complex output y
				DataS*	d_buffer,	// pointer to delay buffer
				DataS	N_x,		// size of x
				DataS	N_h			// half of filter order
		   	  	);	
   	 
//***************************** IIR Filters ***************************************	
extern DataS IIR_1(
				DataS* 	B_A,	// pointer to filter coefficients
				DataS*	IN,		// the new input sample
 				DataS	N,		// Filter order for input X
				DataS*	x_y		// delay buffer
				);	
extern DataS IIR_2(
				DataS* 	h,		// pointer to filter coefficients
				DataS*	IN,		// the new input sample
 				DataS	N,		// Filter order 
				DataS*	u		// state variable vector
				);	
extern DataS IIR_bi_1(
				DataS* 	x,			// pointer to complex input x
				DataS*	h,			// pointer to complex coefficent vector h
				DataS*	y,			// pointer to complex output y
				DataS*	u_w,		// pointer to state veriables
				DataS	N_x,		// size of x
				DataS	N_biq		// number of the biquads
				);	
extern DataS IIR_bi_2(
				DataS* 	x,			// pointer to complex input x
				DataS*	h,			// pointer to complex coefficent vector h
				DataS*	y,			// pointer to complex output y
				DataS*	u,			// pointer to state veriables
				DataS	N_x,		// size of x
				DataS	N_biq		// number of the biquads
				);
extern DataS IIR_bi2_32(
				DataS* 	x,			// pointer to complex input x
				DataL*	h,			// pointer to complex 32-bit coefficent vector h
				DataS*	y,			// pointer to complex output y
				DataS*	u,			// pointer to state veriables
				DataS	N_x,		// size of x
				DataS	N_biq		// number of the biquads
				);					
extern DataS IIR_lat(
				DataS* 	x,			// pointer to input x
				DataS*	K,			// pointer to lattice coefficent vector K
				DataS*	y,			// pointer to output y
				DataS*	u,			// pointer to delay buffer
				DataS	N_x,		// size of x
				DataS	N_h			// filter order
		   	  	); 
extern DataS IIR_bi_24(
				DataS* 	x,			// pointer to complex input x
				DataS*	h,			// pointer to complex coefficent vector h
				DataS*	y,			// pointer to complex output y
				DataS*	u,			// pointer to state veriables
				DataS	N_x,		// size of x
				DataS	N_biq		// number of the biquads
				);
//***************************** Mathematical functions ****************************
extern DataS P_series(
				DataS* 	a,		// pointer to coefficients
				DataS*	IN,		// pointer to the input value
				DataS	N		// the order of series
				);	
extern void Windowing(
				DataS* 	h,		// pointer to coefficients
				DataS*	x,		// pointer to the input value vector
				DataS*	y,		// poniter to output vector
				DataS	N		// the length of the window
				);	
extern DataS Sine(
					  DataS	x 			//input
				);
extern DataS div_q15(
				      DataS 	x,		// dividend
				      DataS  	y		// divisor
				);
extern DataS div_q31(
				   	  DataL 	x,		// dividend
				      DataS  	y		// divisor
				);
extern DataS Sqrt(	DataS 	x );
				
//***************************** Matrix ********************************************
extern void	 Matrix_mul(
				DataS* 	x_1,	// pointer to 1. input matrix
				DataS* 	x_2,	// pointer to 2. input matrix
				DataS*	y,		// poniter to output matrix
				DataS	row1,	// number of rows in matrix 1
				DataS	col1,	// number of columns in matrix 1
				DataS	row2,	// number of rows in matrix 2
				DataS	col2	// number of columns in matrix 2
				);	
extern void	 Matrix_trans(
				DataS* 	x,		// pointer to input matrix
				DataS*	y,		// poniter to output matrix
				DataS	row,	// number of rows in matrix 
				DataS	col		// number of columns in matrix 
				);

//***************************** Adaptive Filters **********************************
extern DataS Adap_filter_16(
				DataS* 	h,			// pointer to coeffcient vector h with 16 bits
 				DataS*	IN,			// pointer to the new input sample
				DataS*	D,			// pointer to expected signal at time n
				DataS*	error,		// pointer to error signal
				DataS	N_h,		// filter order
				DataS	Step, 		// adaptive gain
				DataS*	d_buffer    // delay buffer
				);	


extern DataS Adap_filter_32(
				DataL* 	h,			// pointer to coeffcient vector h with 32 bits
 				DataS*	IN,			// pointer to the new input sample
				DataS*	D,			// pointer to expected signal at time n 
				DataS*	error,		// pointer to error signal
				DataS	N_h,		// filter order
				DataS	Step, 		// adaptive gain
				DataS*	d_buffer    // delay buffer
				);	

//***************************** FFT Transform *************************************
extern DataS FloatTo1Q15(
				float 	x				// floating input value
 				);	
extern float Q15toFloat(
				DataS 	x				//1Q15 input
				);
extern DataS Bit_reverse(
				DataS* 	X,		// index input vector
				DataS	N		// the size of the vector
 				);	
extern void real_DIT_FFT(
				DataS* 	x,			// inpu vector
 				DataS*	index,		// bit reversed input indecies
		        DataS   exp,        // exponent of vector size
				DataS*  table,		// trigonomic function table
 				DataS*	X			// output of FFT
				);	
extern void real_DIF_IFFT(
				DataS* 	x,			// output of IFFT
 				DataS*	index,		// bit reversed input indecies
		      	DataS   exp,       	// exponent of vector size
				DataS*  table,		// trigonomic function table
 				DataS*	X			// inpu vector
				);	
extern void real_DIT_IFFT(
				DataS* 	x,			// output of IFFT
 				DataS*	index,		// bit reversed input indecies
		        DataS   exp,       	// exponent of vector size
				DataS*  table,		// trigonomic function table
 				DataS*	X			// inpu vector
				);										                    	
//***************************** Statistical functions **************************
extern void Auto_raw(	
				DataS* 	x,			// Pointer to input vector in 1Q15 format
				DataS*	y,			// Pointer to output vector in 1Q15 format
				DataS	N_x,		// Size of input vector
				DataS	N_y			// Size of output vector, N_y <= N_x
		   	  );
extern void Auto_bias(	
				DataS* 	x,			// Pointer to input vector in 1Q15 format
				DataS*	y,			// Pointer to output vector in 1Q15 format
				DataS	N_x,		// Size of input vector
				DataS	N_y			// Size of output vector, N_y <= N_x
		   	  );
extern void Auto_unbias(	
				DataS* 	x,			// Pointer to input vector in 1Q15 format
				DataS*	y,			// Pointer to output vector in 1Q15 format
				DataS	N_x,		// Size of input vector
				DataS	N_y			// Size of output vector, N_y <= N_x
		   	  );
extern void Cross_raw(	
				DataS* 	x1,			// Pointer to the first input vector in 1Q15 format
				DataS* 	x2,			// Pointer to the second input vector in 1Q15 format
				DataS*	y,			// Pointer to output vector in 1Q15 format
				DataS	N_x1,		// Size of first input vector
				DataS	N_x2		// Size of second input vector, N_x2 <= N_x1
		   	  );
extern void Cross_bias(	
				DataS* 	x1,			// Pointer to the first input vector in 1Q15 format
				DataS* 	x2,			// Pointer to the second input vector in 1Q15 format
				DataS*	y,			// Pointer to output vector in 1Q15 format
				DataS	N_x1,		// Size of first input vector
				DataS	N_x2		// Size of second input vector, N_x2 <= N_x1
		   	  );
extern void Cross_unbias(	
				DataS* 	x1,			// Pointer to the first input vector in 1Q15 format
				DataS* 	x2,			// Pointer to the second input vector in 1Q15 format
				DataS*	y,			// Pointer to output vector in 1Q15 format
				DataS	N_x1,		// Size of first input vector
				DataS	N_x2		// Size of second input vector, N_x2 <= N_x1
		   	  );
extern DataS Convol(
				DataS* 	x,			// pointer to vector x
				DataS*	h,			// pointer to input vector x
				DataS*	y,			// pointer to output	  
				DataS*	d_buffer,	// pointer to delay buffer
				DataS	N_x,		// size of vector x
				DataS	N_h			// size of vector h
			  );
//------------------- END OF FILE ----------------------------------------------


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -