}
IIC_stop ();
return ;
}
void IIC_send_adder ( uchar adder , uchar sub , uchar ddata )
{
bit ack;
IIC_str();
ack=IIC_send_byte ( adder );//发送从机地址
if ( !ack )
{
alarm=0;
return ;}
ack=IIC_send_byte ( sub );//发送从机子地址
if ( !ack )
{ alarm=0;
return ;}
ack=IIC_send_byte ( ddata );//发送数据
if ( !ack )
{ alarm=0;
return ;}
IIC_stop ();
return ;
}
void IIC_read_adder ( uchar adder, uchar sub, uchar *buf, uchar num )
{
bit ack;
uchar i;
IIC_str ();
ack=IIC_send_byte ( adder );//发送从机地址
if ( !ack )
{ alarm=0;
return ;}
ack=IIC_send_byte ( sub );//发送从机子地址
if ( !ack )
{ alarm=0;
return ;}
for ( i=0; i{
*( buf++ )=IIC_read_byte ( 1 );//接收数据存储倒*buf
}
IIC_stop ();
return ;
}