📄 infraredray_basic_change.c
字号:
if(channel==9) B=StoreCodes[9][1];
// B=StoreCodes[4][1];
#pragma ASM
;发送原码
jb B.0,Out1001
lcall OutZero
ajmp next1002
Out1001:
lcall OutOne
next1002:
jb B.1,Out1011
lcall OutZero
ajmp next1102
Out1011:
lcall OutOne
next1102:
jb B.2,Out1021
lcall OutZero
ajmp next1202
Out1021:
lcall OutOne
next1202:
jb B.3,Out1031
lcall OutZero
ajmp next1302
Out1031:
lcall OutOne
next1302:
jb B.4,Out1041
lcall OutZero
ajmp next1402
Out1041:
lcall OutOne
next1402:
jb B.5,Out1051
lcall OutZero
ajmp next1502
Out1051:
lcall OutOne
next1502:
jb B.6,Out1061
lcall OutZero
ajmp next1602
Out1061:
lcall OutOne
next1602:
jb B.7,Out1071
lcall OutZero
ajmp next1702
Out1071:
lcall OutOne
next1702:
;发送反码
jnb B.0,Out1000
lcall OutZero
ajmp next1003
Out1000:
lcall OutOne
next1003:
jnb B.1,Out1010
lcall OutZero
ajmp next1103
Out1010:
lcall OutOne
next1103:
jnb B.2,Out1020
lcall OutZero
ajmp next1203
Out1020:
lcall OutOne
next1203:
jnb B.3,Out1030
lcall OutZero
ajmp next1303
Out1030:
lcall OutOne
next1303:
jnb B.4,Out1040
lcall OutZero
ajmp next1403
Out1040:
lcall OutOne
next1403:
jnb B.5,Out1050
lcall OutZero
ajmp next1503
Out1050:
lcall OutOne
next1503:
jnb B.6,Out1060
lcall OutZero
ajmp next1603
Out1060:
lcall OutOne
next1603:
jnb B.7,Out1070
lcall OutZero
ajmp next1703
Out1070:
lcall OutOne
next1703:
lcall OutOne
#pragma ENDASM
}
}
if(Model==2)//为SFR状态
{
// while(1)
// {
PreCode();
B=buffer[0];
#pragma ASM
mov p0,B
;发送原码
jb B.0,Out201
lcall OutZero
ajmp next20
Out201:
lcall OutOne
next20:
jb B.1,Out211
lcall OutZero
ajmp next21
Out211:
lcall OutOne
next21:
jb B.2,Out221
lcall OutZero
ajmp next22
Out221:
lcall OutOne
next22:
jb B.3,Out231
lcall OutZero
ajmp next23
Out231:
lcall OutOne
next23:
jb B.4,Out241
lcall OutZero
ajmp next24
Out241:
lcall OutOne
next24:
jb B.5,Out251
lcall OutZero
ajmp next25
Out251:
lcall OutOne
next25:
jb B.6,Out261
lcall OutZero
ajmp next26
Out261:
lcall OutOne
next26:
jb B.7,Out271
lcall OutZero
ajmp next27
Out271:
lcall OutOne
next27:
;发送反码
jnb B.0,Out200
lcall OutZero
ajmp next2001
Out200:
lcall OutOne
next2001:
jnb B.1,Out210
lcall OutZero
ajmp next2101
Out210:
lcall OutOne
next2101:
jnb B.2,Out220
lcall OutZero
ajmp next2201
Out220:
lcall OutOne
next2201:
jnb B.3,Out230
lcall OutZero
ajmp next2301
Out230:
lcall OutOne
next2301:
jnb B.4,Out240
lcall OutZero
ajmp next2401
Out240:
lcall OutOne
next2401:
jnb B.5,Out250
lcall OutZero
ajmp next2501
Out250:
lcall OutOne
next2501:
jnb B.6,Out260
lcall OutZero
ajmp next2601
Out260:
lcall OutOne
next2601:
jnb B.7,Out270
lcall OutZero
ajmp next2701
Out270:
lcall OutOne
next2701:
#pragma ENDASM
B=buffer[1];
#pragma ASM
mov p0,B
;发送原码
jb B.0,Out2001
lcall OutZero
ajmp next2002
Out2001:
lcall OutOne
next2002:
jb B.1,Out2011
lcall OutZero
ajmp next2102
Out2011:
lcall OutOne
next2102:
jb B.2,Out2021
lcall OutZero
ajmp next2202
Out2021:
lcall OutOne
next2202:
jb B.3,Out2031
lcall OutZero
ajmp next2302
Out2031:
lcall OutOne
next2302:
jb B.4,Out2041
lcall OutZero
ajmp next2402
Out2041:
lcall OutOne
next2402:
jb B.5,Out2051
lcall OutZero
ajmp next2502
Out2051:
lcall OutOne
next2502:
jb B.6,Out2061
lcall OutZero
ajmp next2602
Out2061:
lcall OutOne
next2602:
jb B.7,Out2071
lcall OutZero
ajmp next2702
Out2071:
lcall OutOne
next2702:
;发送反码
jnb B.0,Out2000
lcall OutZero
ajmp next2003
Out2000:
lcall OutOne
next2003:
jnb B.1,Out2010
lcall OutZero
ajmp next2103
Out2010:
lcall OutOne
next2103:
jnb B.2,Out2020
lcall OutZero
ajmp next2203
Out2020:
lcall OutOne
next2203:
jnb B.3,Out2030
lcall OutZero
ajmp next2303
Out2030:
lcall OutOne
next2303:
jnb B.4,Out2040
lcall OutZero
ajmp next2403
Out2040:
lcall OutOne
next2403:
jnb B.5,Out2050
lcall OutZero
ajmp next2503
Out2050:
lcall OutOne
next2503:
jnb B.6,Out2060
lcall OutZero
ajmp next2603
Out2060:
lcall OutOne
next2603:
jnb B.7,Out2070
lcall OutZero
ajmp next2703
Out2070:
lcall OutOne
next2703:
#pragma ENDASM
// }
}
/* B=buffer[0];
while(1)
{
for(i=0;i<8;i++)
{
if(B^i==0) OutZero();
else OutOne();
}
}*/
/*
int tempa,tempb;
tempa=buffer[0];
tempb=buffer[0]&0xfe;
while(1)
{
// if(Model==2)
// {
for(i=0;i<8;i++)
{
transbuf[i]=TempBuffer%TempValue;
TempBuffer=TempBuffer>>1;
TempValue=TempValue>>1;
TempValue=TempValue&0xfe;
}
while(1)
{
PreCode();
for(i=0;i<8;i++)
{
if(transbuf[i]==1)
OutOne();
else OutZero();
}
}
// }
}
/* int transbuf[8];
int TempBuffer,i,TempValue;
TempBuffer=buffer[0];
TempValue=TempBuffer;
TempValue=TempValue&0xfe;
if(Model==2)
{
}*/
}
void OutZero(void)//位0
{
uint x,y;
x=1;
y=19;
while(y)
{
output=0;
x+=1;
x+=1;
output=1;
y-=1;
x+=1;
x+=1;
x+=1;
}
y=19;
while(y)
{
output=0;
x--;
x--;
x--;
output=0;
y--;
x--;
x--;
}
}
void OutOne(void)//位1
{
uint x,y;
x=1;
y=19;
while(y)
{
output=0;
x+=1;
x+=1;
output=1;
y-=1;
x+=1;
x+=1;
x+=1;
}
y=54;
while(y)
{
output=0;
x--;
x--;
x--;
output=0;
y--;
x--;
x--;
}
}
void PreCode(void)
{
uint x,y;
x=1;
y=315;
while(y)
{
output=0;
x+=1;
x+=1;
output=1;
y-=1;
x+=1;
x+=1;
x+=1;
}
y=141;
while(y)
{
output=0;
x--;
x--;
x--;
output=0;
y--;
x--;
x--;
}
}
//串口初始化,晶振为12M 方式1 波特率4800
void InitCom(void)
{
P0=0xff;
Inttrupt1=1;
SCON=0x50;//串口方式1,允许接收
TMOD=0x20;//定时器1用方式2,定时器0用方式1
TCON=0x40;//设定时器1开始计数
TH1=0xF3;//设波特率为4800
TL1=0xF3;
PCON=0x80;//波特率加倍控制
RI=0;//清收发标志
TI=0;
TR1=1;//启动定时器??重复启动?
}
void delay528us(void)
{
uint x;
for(x=64;x>0;x--);
}
void Delay8_44ms(void)
{
uint x;
for(x=1058;x>0;x--);
}
//void Delay1ms(uint z)
//{
// uint x,y;
// for(y=z;y>=0;y--)
// {
// for(x=110;x>0;x--);
// }
//}
void Delay1ms(uint z) //延时z*500微秒
{
uint x,y;
for(x=z;x>0;x--)
for(y=55;y>0;y--);
}
void Delay4_22ms(void)
{
uint x;
for(x=529;x>0;x--);
}
void Delay3_5ms(void)
{
uint x;
for(x=450;x>0;x--);
}
void Delay800us(void)
{
uint x;
for(x=99;x>0;x--);
}
void Delay100us(void)
{
uint x;
for(x=30;x>0;x--);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -