以下是我写的代码,请支援!谢谢
void start()
{
SCL=1;
delay();
SDA=1;
delay();
SDA=0;
delay();
}
void stop()
{
SCL=1;
delay();
SDA=0;
delay();
SDA=1;
delay();
}
void sack()
{
SCL=1;
delay();
flog=0;
if(SDA==0)
{
flog=1 ;
}
delay();
SCL=0;
}
void noack()
{
SCL=1;
delay();
SDA=1;
delay();
}
void writr(unchar com)
{
unchar kk;
kk=com;
for(x=0;x<8;x++)
{
SCL=0;
delay();
kk=kk<<1;
SDA=CY;
delay();
SCL=1;
delay();
}
SDA=1;
delay();
SCL=0;
delay();
}
unchar read_8951()
{
unchar date;
for(x=0;x<8;x++)
{
SCL=1;
delay();
date=SDA&0x80;
date=date<<1;
delay();
SCL=0;
delay();
}
return(date);
}
void init_8951()//这里有错误吗?
{
start();
writr(0x90);
sack();
writr(0x42);
sack();
delay1(1);
start();
writr(0x91);
sack();
dd=read_8951();
stop();
}