void I2cSerialRead(uchar device,uint address,uchar count,uchar *buff)
{ //从slave接收count字节数据
uchar i;
uchar addressh,addressl;
addressl = address&0xFF; //低位字节地址
addressh = address> > 8; //高位字节地址
I2cStart();
I2cSendByte(device);//写入器件地址
I2cSendByte(addressh); // 向slave写入高位字节地址
I2cSendByte(addressl); // 向slave写入低位字节地址
I2cStart();
I2cSendByte(device|0x01); //传送“读取信号”,即device地址加1
for(i=0;i <count;i++)
{
buff[i]=I2cReceiveByte();
if(i!=count-1)
SendAck(0); //应答
else
SendAck(1);
}
SendAck(1); //不应答
I2cStop();
}