void flash() { ; ; }
void x24c08_init() //24c08初始化子程序 { scl=1; flash(); sda=1; flash(); } void start() //启动I2C总线 { sda=1; flash(); scl=1; flash(); sda=0; flash(); scl=0; flash(); } void stop() //停止I2C总线 { sda=0; flash(); scl=1; flash(); sda=1; flash(); } void writex(unsigned char j) //写一个字节 { unsigned char i,temp; temp=j; for (i=0;i<8;i++) { temp=temp<<1; scl=0; flash(); sda=CY; flash(); scl=1; flash(); } scl=0; flash(); sda=1; flash(); } unsigned char readx() //读一个字节 { unsigned char i,j,k=0; scl=0; flash(); sda=1; for (i=0;i<8;i++) { flash(); scl=1; flash(); if (sda==1) j=1; else j=0; k=(k<<1)|j; scl=0; } flash(); return(k); } void clock() //I2C总线时钟 { unsigned char i=0; scl=1; flash(); while ((sda==1)&&(i<255)) i++; scl=0; flash(); } |