//IIC开始voidStart(){SDA=1;SCL=1;NOP4();SDA=0;NOP4();SCL=0;}//IIC结束voidStop(){SDA=0;SCL=0;NOP4();SCL=1;NOP4();SDA=1;}//IIC读取应答voidRACK(){SDA=1;NOP4();SCL=1;NOP4();SCL=0;}//IIC发送非应答voidNO_ACK(){SDA=1;SCL=1;NOP4();SCL=0;SDA=0;}//IIC向从设备写入一字节数据voidWrite_A_Byte(ucharb){uchari;for(i=0;i8;i++){b=1;SDA=CY;_nop_();SCL=1;NOP4();SCL=0;}RACK();}//IIC向从设备的指定地址写入数据voidWrite_IIC(ucharaddr,uchardat){Start();Write_A_Byte(0xa0);Write_A_Byte(addr);Write_A_Byte(dat);Stop();DelayMS(10);}//IIC从从设备读取数据ucharRead_A_Byte(){uchari,b;for(i=0;i8;i++){SCL=1;b=1;B|=SDA;SCL=0;}returnb;}//IIC从从设备的当前地址读取数据ucharRead_Current(){uchard;Start();Write_A_Byte(0xa1);d=Read_A_Byte();NO_ACK();Stop();returnd;}//IIC从从设备的任意地址读取数据ucharRandom_Read(ucharaddr){Start();Write_A_Byte(0xa0);Write_A_Byte(addr);Stop();returnRead_Current();}