程序片段如下:
unsigned char I2cSendByte(unsigned char dat)
{
unsigned char a=0,b=0;//最大255,一個機器周期為1us,最大延時
255us。
for(a=0;a<8;a++)//要發送8 位,從最高位開始
{
SDA=dat>>7; //起始信號之后SCL=0,所以可以直接改變SDA 信
號
dat=dat<<1;
Delay10us();
SCL=1;
Delay10us();//建立時間>4.7us
SCL=0;
Delay10us();//時間大于4us
}
SDA=1;
Delay10us();
SCL=1;
while(SDA)//等待應答,也就是等待從設備把SDA 拉低
{
b++;
if(b>200) //如果超過2000us 沒有應答發送失敗,或者為非應答,
表示接收結束
{
SCL=0;
Delay10us();
return 0;
}
}
SCL=0;
Delay10us();
return 1;
}
void At24c02Write(unsigned char addr,unsigned char dat)
{
I2cStart();
I2cSendByte(0xa0);//發送寫器件地址
I2cSendByte(addr);//發送要寫入內存地址
I2cSendByte(dat); //發送數據
I2cStop();
}
請問unsigned char I2cSendByte(unsigned char dat)函數中黃色背景標注的return,整個程序中都沒有對此返回值做什么操作,加此返回值顯得沒什么意義,請問此返回值有什么作用?
先謝了
|