//发送一字节
void writebyte(uchar date)
{
uchar i,temp;
temp=date;
for(i=0;i<8;i++)
{
temp=temp<<1;
scl=0;
delay();
sda=CY;
delay();
scl=1;
delay();
}
scl=0;
delay();
sda=1;
delay();
}
//向指定地址发送字节
void writer(uchar address,uchar date)
{
start();
writebyte(0xa0);
respons();//应答
writebyte(address);
respons();
writebyte(date);
respons();
stop();
}
|