//************************************** //I2C transmit a byte data //************************************** u8 I2C_SendByte(u8 dat) { u8 i; for (i=0; i<8; i++) { I2C_SDA =((dat<<i)&0x80)>>7; delay_us(2); I2C_SCL=1; delay_us(2); I2C_SCL=0; } return I2C_RecvACK(); }
//***************************************************************************************************** //向I2C总线发送一个字节数据 //***************************************************************************************************** void I2C_SendByte(uchar dat) { uchar i; for (i=0; i<8; i++) //8位计数器 { dat <<= 1; //移出数据的最高位 SDA = CY; //送数据口 SCL = 1; //拉高时钟线 Delay5us(); //延时 SCL = 0; //拉低时钟线 Delay5us(); //延时 } I2C_RecvACK(); }
void I2C_SendByte(u8 dat) { u8 i; for (i=0; i<8; i++) //8位计数器 { dat <<= 1; //移出数据的最高位 MSDA = CY; //送数据口 MSCL = 1; //拉高时钟线 Delay_5us(); //延时 MSCL = 0; //拉低时钟线 Delay_5us(); //延时 } I2C_RecvACK(); }
void I2C_SendByte(unsigned char dat) { unsigned char i; for(i=0; i<8; i++) { dat <<= 1; SDA = CY; SCL = 1; Delay5us(); SCL = 0; Delay5us(); } I2C_RecvACK(); }
//************************************** //向I2C总线发送一个字节数据 //************************************** void I2C_SendByte(uint8_t dat) { uint8_t i; for (i = 0; i < 8; i++) { //8位计数器 dat <<= 1; //移出数据的最高位 SDA = CY; //送数据口 SCL = 1; //拉高时钟线 Delay2us(); //延时 SCL = 0; //拉低时钟线 Delay2us(); //延时 } I2C_RecvACK(); }