
// include realtek base dll header
#ifndef _BT_MP_CALIBRATION_H_
#define _BT_MP_CALIBRATION_H_
//--------------- define calibration ---------------------
#ifndef RTKBTMP_API
	//define by RtlBluetoothMP.h
#ifndef _IsVCType_
	#define _IsVCType_
	#define REALTEKDLL_EXPORTS
#endif
	#ifdef REALTEKDLL_EXPORTS
		#define RTKBTMP_API __declspec(dllexport)
	#else
		#define RTKBTMP_API __declspec(dllimport)
	#endif

#endif //end #ifndef RTKBTMP_API

#include "RtlBluetoothMP.h"

#ifndef BASE_CAL_DEFINE
#define BASE_CAL_DEFINE

typedef struct BASE_CAL_ARRARY_TAG   				CAL_ARRARY;
typedef struct BASE_CAL_RTK_TXPOWERK_PARAMETER_TAG  CAL_RTK_TXPOWERK_PARAMETER;	
typedef struct BASE_CAL_PARAMETER_TAG   			CAL_PARAMETER;


//----------------------------------------------------------
//FP define
typedef int
(*BASE_FP_CAL_MEASUREMENT_CW)(
	CAL_PARAMETER *pCalParameter,
	double *pMeasueFreqOffset_MHz,
	double *pMeasueTxPower_dBm
	);
	
typedef int
(*BASE_FP_CAL_MEASUREMENT_TX)(
	CAL_PARAMETER *pCalParameter,
	double *pMeasueTxPower_dBm
	);

typedef int
(*pfApi_calculate_XtalBoundary)(
   	BASE_BTMPDLL_MODULE *pDLLBtBaseModule,
	CAL_PARAMETER *pParameter,
	int cal_freq_MHz,
	double MeasureFreq_MHz,
	unsigned int *pData
	);

typedef int
(*pfApi_calculate_XtalNormal)(
        BASE_BTMPDLL_MODULE *pDLLBtBaseModule,
        CAL_PARAMETER *pParameter,
        double MeasureFreqOffset_KHz,
        unsigned int InitCFCapValue,
        unsigned int *pNewCFCapValue
	);
	
	
//----------------------------------------------------------	
#define MAX_BYTES_ARRARY_SIZE  4096
#define MAX_DOUBLE_ARRARY_SIZE 128

typedef struct BASE_CAL_ARRARY_TAG{
		unsigned Arrary8bit[MAX_BYTES_ARRARY_SIZE];
		double   ArraryDouble[MAX_DOUBLE_ARRARY_SIZE];
}BASE_CAL_ARRARY_TAG;

typedef struct BASE_CAL_RTK_TXPOWERK_PARAMETER_TAG{
		unsigned char TxGainKVlaue;
		unsigned int  TxFlatnessKValue;  
}BASE_CAL_RTK_TXPOWERK_PARAMETER_TAG;

struct BASE_CAL_PARAMETER_TAG
{
			int Index;
			int chipID;
			BASE_CAL_ARRARY_TAG input;
			BASE_CAL_ARRARY_TAG output;
			BASE_CAL_RTK_TXPOWERK_PARAMETER_TAG txpowK;
			////////////////////////////////////////////
			// Function point define 
			BASE_FP_CAL_MEASUREMENT_CW fpMeasurementCW;
			BASE_FP_CAL_MEASUREMENT_TX fpMeasurementTX;
			void  *pUserdefinePoint;
			void  **ppUserdefineFuncPoint;

};
#endif  //end #ifndef BASE_CAL_DEFINE

//---------------------------------------------------------
//API releasse 
//---------------------------------------------------------
// Tx power Calibration
RTKBTMP_API int Api_Calibration_TxPowerFlow(CAL_PARAMETER *pParameter,unsigned char *pData);

//XTAL Calibration
RTKBTMP_API int Api_Calibration_CrystalFlow(CAL_PARAMETER *pParameter,unsigned char *pData);

//XTAL calculate
RTKBTMP_API int Api_calculate_XtalBoundary(BASE_BTMPDLL_MODULE *pDLLBtBaseModule,CAL_PARAMETER *pParameter,int cal_freq_MHz,double MeasureFreq_MHz,unsigned int *pData);
RTKBTMP_API int Api_calculate_XtalNormal(BASE_BTMPDLL_MODULE *pDLLBtBaseModule,CAL_PARAMETER *pParameter,double MeasureFreqOffset_KHz,unsigned int pInitCFCapValue,unsigned int *pNewCFCapValue);

//---------------------------------------------------------
#endif //end #ifndef _BT_MP_CALIBRATION_H_
