#include "MDRFxx_SFR.h"
#include "main.h"
#include "Adc.h"
#include "Motor.h"

void Adc_Init (void)
{
	ADCCONT = ADCCONT_REGS;
	ADCSTR = ADCSTR_REGS | OPA_GAIN_REGS;
}

unsigned short Adc_Cannel (unsigned char Channel)
{
	unsigned short Temp;
	ADCCONT = (ADCCONT | Channel);
	ADCSTR = (ADCSTR | 0x01);
	while((ADCSTR & 0x08) == 0x08){}; //Check ADC Busy end
	Temp = ADCD1<<8 | ADCD2;
	ADCCONT = (ADCCONT & 0xF8);
	
//	ADCCONT = (ADCCONT & 0xF8) | Channel; 
//	ADCSTR = (ADCSTR | START);
//	while((ADCSTR & BUSY) == BUSY){}; //Check ADC Busy end
//	*(((unsigned char *)&Temp)+1) = ADCD2;
//	*(((unsigned char *)&Temp)+0) = ADCD1;
	return Temp;
}
