#ifndef __adc_H
#define __adc_H

#include "f28x_project.h"
//通用定义
#define  ADCTOVAUL_K     (0.0008056640625f)

#define  VAULTOADC_K     (1241.21212121f)
//采样滤波系数
#define  FILT_A         (float)(0.7901)
#define  FILT_B         (float)(0.2099)
//#define  IBUS_FILT_A    (float)(0.7901)
//#define  IBUS_FILT_A    (float)(0.2099)

  // adc比例值
#define  VBUS_DSP_GAIN       (0.00434f)
#define  VDSP_BUS_GAIN       (230.4147465437f)


#define  Icur_DSP_GAIN       (0.6659f)
#define  DSP_Icur_GAIN       (1.501726986f)

#define  VBUS_ADCTOREL      (float)((float)ADCTOVAUL_K*(float)VDSP_BUS_GAIN)    

#define  VBUS_ADCTOREL_A    (float)((float)VBUS_ADCTOREL*(float)(0.9643))
#define  VBUS_ADCTOREL_B    (float)(0.964)

#define  VBUS_RELTOADC      (float)((float)1.0/(float)VBUS_ADCTOREL)  

#define  IBUS_ADCTOREL      (float)((float)ADCTOVAUL_K*(float)DSP_Icur_GAIN)   
#define  IBUS_ADCTOREL_cal      (float)((float)IBUS_ADCTOREL*(float)(10.0))   

#define  IBUS_RELTOADC      (float)((float)1.0/(float)IBUS_ADCTOREL)   

struct	SAMPLERESULT
{
	float	sample_iout;			    //
	float	sample_bat;		            //
	float	sample_vbus;            	//
	float	sample_vbus_pcs;            	//
	float	sample_ibus;			    //
	float	sample_ir;			         //
	float	sample_temp;			    //	
};

struct	SAMPLEFILT
{
	float	iout;			    //
	float	bat;		//
	float	vbus;            	//
	float	vbus_pcs;            	//
	float	ibus;			    //
	float	temp;			    //	
	float	power;			    //	
};

struct	SAMPLETIME
{
    Uint16 uFiltCyc;//
    
};

struct	ADCMES
{
    struct  SAMPLERESULT    SampleResult;
    struct	SAMPLEFILT      SampleFilt;
    struct	SAMPLETIME      SampleTime;
};


//全局变量//
extern struct	ADCMES	ADCmes;

//==================================================================================================
//
//==================================================================================================
//函数定义//
void ADC_INIT(void);
void my_memset(void *dest, int set, unsigned len);
void vADC_TIME(void);
//void ADC_get(void);

void ADC_DATA_INIT(void);
__interrupt void adcA1ISR(void);


#endif /* APP_INIT_PWM_H_ */
