
#include "ADC0831.H"
#include <AT89x51.h>

sbit adc_CS = P3^5;
sbit adc_CLK = P3^6;
sbit adc_DATA = P3^7;

void InitADC0831()
{
	adc_CLK = 0;
	adc_CS = 1;
	adc_DATA = 1;
}

unsigned char ReadADC0831()
{
	unsigned char Data;
	unsigned char i;
	adc_CS = 0;
	;;;;;;;
	for(i = 0; i < 10; i ++)
	{
		adc_CLK = 1;;;;;;;;
		Data <<= 1;
		Data |= adc_DATA;
		adc_CLK = 0;;;;;;;;
	}
	adc_CS = 1;
	return Data;
}

