#include<reg52.h>
#define uchar unsigned char
sbit SDA=P2^0;
sbit SCL=P2^1;
void delay() //延时5us
{
;
;
}
void delay_10ms() //延时
{
uchar a,b;
for(a=50;a>0;a–)
for(b=200;b>0;b–);
}
void start() //起始信号
{
SDA = 1;
SCL = 1;
delay();
SDA = 0;
delay();
}
void stop() //停止信号
{
SDA = 0;
SCL = 1;
delay();
SDA = 1;
delay();
}
void ack() //应答信号
{
uchar i;
SCL = 1;
delay();
while((SDA==1)&&(i<250))i++;
SCL = 0;
delay();
}
void nack() //非应答信号
{
SCL = 1;
delay();
SDA = 1;
SCL = 0;
delay();
}
void write_byte(uchar date) //写入数据函数
{
uchar