|
驱动程序
unsigned long ReadCount(void)
{
unsigned long Count;
unsigned char i;
SCL=0; //使能AD(PD_SCL 置低)
Count=0;
while(SDA); //AD转换未结束则等待,否则开始读取
for (i = 0; i < 24; i++)
{
SCL = 1; //PD_SCL 置高(发送脉冲)
Count=Count<<1; //下降沿来时变量Count左移一位,右侧补零
SCL=0; //PD_SCL 置低
if(SDA) Count++;
}
SCL=1;
Count=Count^0x800000;//第25个脉冲下降沿来时,转换数据
SCL=0;
return(Count);
}
---------------------
|
|