#define I2C_SCL_0()#define I2C_SCL_1()#define I2C_SDA_0()#define I2C_SDA_1()#define I2C_DELAY()#define I2C_ReadSDA();void I2cStart(void){ I2C_SCL_1(); I2C_SDA_1(); I2C_DELAY(); I2C_SDA_0(); I2C_DELAY();}void I2cStop(void){ I2C_SCL_1(); I2C_SDA_0(); I2C_DELAY(); I2C_SDA_1(); I2C_DELAY();}uint8_t I2cReadAck(void){ uint8_t val = 0; uint8_t timeout = 0; I2C_SCL_0(); I2C_DELAY(); do { val = I2C_ReadSDA(); if (++timeout > 50) { break; } }while(val == 0); I2C_SCL_1(); I2C_DELAY(); return val;}void I2cSendByte(uint8_t data);{ uint8_t i; for (i = 0; i < 8; i++) { I2C_SCL_0(); I2C_DELAY(); if (data & 0x80) { I2C_SDA_1(); } else { I2C_SDA_0(); } data = data << 1; I2C_SCL_1(); I2C_DELAY(); }}uint8_t I2cReadByte(void){ uint8_t val = 0; for (i = 0; i < 8; i++) { data = data << 1; I2C_SCL_0(); I2C_DELAY(); if (I2C_ReadSDA()) { data |= 0x01; } I2C_SCL_1(); I2C_DELAY(); }}void I2cWrite(uint8_t addr, uint8_t *buff, uint32_t len){ uint32_t i; uint8_t t; I2cStart(); t = (addr << 1) | 0; I2cSendByte(t); for (i = 0; i < len; i++) { I2cSendByte(buff[i]); } I2cStop();}void I2cRead(uint8_t addr, uint8_t *buff, uint32_t len){ uint32_t i; uint8_t t; I2cStart(); t = (addr << 1) | 1; I2cSendByte(t); for (i = 0; i < len; i++) { I2cReadByte(buff[i]); } I2cStop();}