void NC_Read(unsigned char addr,unsigned char n,unsigned char *buf)
你把這個函數改一下不就可以了嗎?
unsigned char I2cSendByte(unsigned char dat)
這個函數是有返回值的,你在寫入IIC器件的時候,得使用這個返回值呀,你得讓這個返回值派上用場呀
如果都不用這個返回值,那還返回干嘛,直接等待不就行了
void NC_Read(unsigned char addr,unsigned char n,unsigned char *buf)
{
// unsigned char num;
unsigned char a;
I2cStart();
a=I2cSendByte(0xa0); //發送寫器件地址
if(a==0).................................//a==0時,器件是沒有正常應答的,這里要處理
a=I2cSendByte(addr); //發送要讀取的地址
I2cStart();
a=I2cSendByte(0xa1); //發送讀器件地址
while(n--)
{
*buf++=I2cReadByte();
{
當N=0時
要使函數I2cSendByte(unsigned char dat)返回0,這個表達式怎么寫;
}
}
I2cStop();
|