求教一个简单的i2c协议的问题
时间:10-02
整理:3721RD
点击:
i2c总线中发送字节的程序,标红的地方看不明白额,求指点!
void Send(unsigned char Data)
{
unsigned char BitCounter=8;
unsigned char temp;
do
{
temp=Data;
Scl=0;
_nop_();
if((temp&0x80)==0x80)
Sda=1;
else
Sda=0;
Scl=1;
temp=Data<<1;
Data=temp;
BitCounter--;
}
while(BitCounter);
Scl=0;
}
void Send(unsigned char Data)
{
unsigned char BitCounter=8;
unsigned char temp;
do
{
temp=Data;
Scl=0;
_nop_();
if((temp&0x80)==0x80)
Sda=1;
else
Sda=0;
Scl=1;
temp=Data<<1;
Data=temp;
BitCounter--;
}
while(BitCounter);
Scl=0;
}
判断最高位是否为1,为1,则 Sda=1;,否则 Sda=0;
这个我是知道,只是不知道为什么要写这步额
因为串行数据是按位取出来发送的
哦哦,总算看明白了,谢~
对我很有帮助,顶一个
还没学到哪里啊!