27,375
社区成员
发帖
与我相关
我的任务
分享
unsigned int Ir_Get_Low(void)
{
TL0=0;
TH0=0;
TR0=1;
while(!Ir_Pin && (TH0&0x80)==0);
TR0=0;
return TH0*256+TL0;
}
unsigned int Ir_Get_High(void)
{
TL0=0;
TH0=0;
TR0=1;
while(Ir_Pin && (TH0&0x80)==0);
TR0=0;
return TH0*256+TL0;
}
void IR_Process(void)
{
unsigned int temp;
char i,j;
do{
init();
restart:
while(Ir_Pin);
temp=Ir_Get_Low();
if(temp<c(8500) || temp>c(9500)) continue;//引导脉冲低电平9000
temp=Ir_Get_High();
if(temp<c(3000) ) Goto ReCode; //加这样一个判断,如果是小于3ms的就执行重复码代码ReCode 可以吗? 不知道我的表达式对不对?
if(temp<c(4000) || temp>c(5000)) continue;//引导脉冲高电平4500
for(i=0;i<4;i++) //4个字节
{
for(j=0;j<8;j++) //每个字节8位
{
temp=Ir_Get_Low();
if(temp<c(200) || temp>c(800)) goto restart;
temp=Ir_Get_High();
if(temp<c(200) || temp>c(2000)) goto restart;
Ir_Buf[i]>>=1;
if(temp>c(1120)) Ir_Buf[i]|=0x80;
}
}
unsigned int Ir_Get_Low(void)
{
TL0=0;
TH0=0;
TR0=1;
while(!Ir_Pin && (TH0&0x80)==0);
TR0=0;
return TH0*256+TL0;
}
unsigned int Ir_Get_High(void)
{
TL0=0;
TH0=0;
TR0=1;
while(Ir_Pin && (TH0&0x80)==0);
TR0=0;
return TH0*256+TL0;
}
void IR_Process(void)
{
unsigned int temp;
char i,j;
do{
init();
restart:
while(Ir_Pin);
temp=Ir_Get_Low();
if(temp<c(8500) || temp>c(9500)) continue;//引导脉冲低电平9000
temp=Ir_Get_High();
if(temp<c(4000) || temp>c(5000)) continue;//引导脉冲高电平4500
for(i=0;i<4;i++) //4个字节
{
for(j=0;j<8;j++) //每个字节8位
{
temp=Ir_Get_Low();
if(temp<c(200) || temp>c(800)) goto restart;
temp=Ir_Get_High();
if(temp<c(200) || temp>c(2000)) goto restart;
Ir_Buf[i]>>=1;
if(temp>c(1120)) Ir_Buf[i]|=0x80;
}