#include "OB6710.h"
#include "ADC.h"

#define PGA_GAIN_10X  0x02
#define PGA_GAIN_20X  0x00
#define PGA_ENABLE 0x01 
#define PGA_OUT           0x08
#define PGA_OUT_FILTER    0x0C

#define PGA_CURRENT_0UA   0x00
#define PGA_CURRENT_16UA  0x20
#define PGA_CURRENT_30UA0 0x30
#define PGA_BY_PASS 0x40

unsigned char xdata *pData;
unsigned int ResultData[4];
void main(void)
{
	unsigned char Loop, Length;
	DACVAL0 = 5;
	DACVAL1 = 5;	
	DACCON = 0x03;
	ADC_Init();
	ADC_SetInputSource(d_ADC_INPUT_1ST, d_ADC_OPA_OUT_IN, d_ADC_MODE_continue);
//	ADC_SetInputSource(d_ADC_INPUT_2ND, d_ADC_CH0_IN, d_ADC_MODE_continue);// ADC channel_0 = P2.7	
//	ADC_SetInputSource(d_ADC_INPUT_3RD, d_ADC_OPA_OUT_IN, d_ADC_MODE_continue);// ADC channel_0 = P2.7	


  P2BUFFEN = 0x38;
	P2M0 = 0x00;
	P2M1 = 0xB8;	
	OPACON = PGA_GAIN_10X | PGA_ENABLE | PGA_OUT  ;
//	OPACON = PGA_BY_PASS | PGA_ENABLE | PGA_OUT;
	
	for(Loop = 0x00;Loop<200;Loop++);
	Length = 0x01;

	while(1)
	{
		ADC_start(Length);
		ADC_GetSampleResult(ResultData, Length);		
	}
}
