关于IIC总线的发送和接受
void Send_IIC(unsigned char Data)
{
unsigned char i=8;
unsigned char temp;
temp = Data;
for(i = 0; i < 8; i++){
temp = temp<<1;
SCL = 0;
_nop_();
SDA = CY;
_nop_();
SCL = 1;
_nop_();
}
SCL = 0;//?
_nop_();
SDA = 1;//?
_nop_();
}
/*------------------------------------------------
读入一个字节并返回
------------------------------------------------*/
unsigned char Read_IIC(void)
{
unsigned char i,k;
SCL = 0;//?
_nop_();
SDA = 1;//?
for(i = 0; i < 8; i++){
SCL = 1;
_nop_();
k = (k << 1) | SDA;
SCL = 0;
_nop_();
}
_nop_();
return k;
}