// tlv1544.h
#ifndef _1544_H
#define _1544_H
#include <reg52.h>
typedef unsigned int UINT16;
typedef unsigned char UINT8;
sbit AD_1544_DOUT=P3^0;
sbit AD_1544_CLK=P3^1;
sbit AD_1544_CS=P3^2;
sbit AD_1544_EOC=P3^3;
UINT16 ADconvert_for_1544(void);
#endif
//tlv1544.c
#include "1544.h"
UINT16 ADconvert_for_1544(void)
{
UINT16 temp = 0;
if(AD_1544_EOC==1)
{
UINT8 i;
AD_1544_CS=0;
for(i=0;i<10;i++) // 10 bit ADC Data
{
AD_1544_CLK=1;
temp=((temp<<1)|AD_1544_DOUT);
AD_1544_CLK=0;
}
AD_1544_CS=1;
temp=temp&0x3ff;
}
return temp;
}