}

void RH(void)

{

//主机拉低18ms

io=0;

Delay(180);

io=1;

//总线由上拉电阻拉高 主机延时20us

Delay_10us();

Delay_10us();

Delay_10us();

Delay_10us();

//主机设为输入判断从机响应信号

io=1;

//判断从机是否有低电平响应信号如不响应则跳出,响应则向下运行

if(!io)//T !

{

U8FLAG=2;

//判断从机是否发出 80us 的低电平响应信号是否结束

while((!io)&&U8FLAG++);

U8FLAG=2;

//判断从机是否发出 80us 的高电平,如发出则进入数据接收状态

while((io)&&U8FLAG++);

//数据接收状态

COM();

U8RH_data_H_temp=U8comdata;

COM();

U8RH_data_L_temp=U8comdata;

COM();

U8T_data_H_temp=U8comdata;

COM();

U8T_data_L_temp=U8comdata;

COM();

U8checkdata_temp=U8comdata;

io=1;

//数据校验

U8temp=(U8T_data_H_temp+U8T_data_L_temp+U8RH_data_H_temp+U8RH_data_L_temp);

if(U8temp==U8checkdata_temp)

{

U8RH_data_H=U8RH_data_H_temp;U8RH_data_L=U8RH_data_L_temp;

U8T_data_H=U8T_data_H_temp;

U8T_data_L=U8T_data_L_temp;

U8checkdata=U8checkdata_temp;

}

//湿度整数部分

s1[0] = (char)(0X30+U8RH_data_H/10);

s1[1] = (char)(0X30+U8RH_data_H);

//湿度小数部分

s1[2] = (char)(0X30+U8RH_data_L/10);

//温度整数部分

s2[0] = (char)(0X30+U8T_data_H/10);

s2[1] = (char)(0X30+U8T_data_H);

//温度小数部分

s2[2] = (char)(0X30+U8T_data_L/10);

}

}

//*******************************

//液晶显示函数

void disp()

{

LCD_disp_char(0,1,‘s’);

LCD_disp_char(1,1,‘h’);

LCD_disp_char(2,1,‘i’);

LCD_disp_char(3,1,‘d’);

LCD_disp_char(4,1,‘u’);

LCD_disp_char(5,1,‘:’);

LCD_disp_char(6,1,s1[0]);

LCD_disp_char(7,1,s1[1]);

LCD_disp_char(8,1,‘。’);

LCD_disp_char(9,1,s1[2]);

LCD_disp_char(10,1,‘%’);

LCD_disp_char(11,1,‘R’);

LCD_disp_char(12,1,‘H’);

LCD_disp_char(0,2,‘w’);

LCD_disp_char(1,2,‘e’);

LCD_disp_char(2,2,‘n’);

LCD_disp_char(3,2,‘d’);

LCD_disp_char(4,2,‘u’);

LCD_disp_char(5,2,‘:’);

LCD_disp_char(6,2,s2[0]);

LCD_disp_char(7,2,s2[1]);

LCD_disp_char(8,2,‘。’);

LCD_disp_char(9,2,s2[2]);