资源简介
RC6遥控器解码程序,希望对大家有帮助。
代码片段和文件信息
BYTE xdata _bIRRecvBuf[100];
BYTE irRC6Decode(void) large
{
BYTE irVal irCnt = 1 irBitCnt = 1 irCodeVal = 1;
WORD irHead = 0;
BYTE i = 1;
#if 0
for(i=0;i<_bIRRecvCnt;i++)
{
DRS232LogB(_bIRRecvBuf[i] i _bIRRecvCnt 0xff);
}
i=0;
#endif
if ((_bIRRecvCnt<0x20) || (_bIRRecvCnt>0x30))
return (_bIRKeyBuf = IR_NONE);
_bIRStatus = IR_WAIT_LEAD_CODE;
#if 1
while (i < _bIRRecvCnt)
{
if ((i<_bIRRecvCnt) && (_bIRRecvBuf[i] <= 1))
_bIRRecvBuf[i-1] = _bIRRecvBuf[i-1]-1;
i++;
}
i=0;
#endif
while (i < _bIRRecvCnt)
{
irVal = _bIRRecvBuf[i];
if (_bIRStatus == IR_WAIT_LEAD_CODE) /* leader */
{
switch (irVal)
{
case 0xff:
irHead = 0xff;
break;
case 0x0F:
case 0x10:
case 0x11:
case 0x12:
irHead = (irHead<<8) | 0x11;
break;
case 0x04:
case 0x05:
case 0x06:
if (irHead != 0xff11)
{
irHead = 0;
return (_bIRKeyBuf = IR_NONE);
}
irHead = 0;
_bIRStatus = IR_WAIT_NEW_CODE;
break;
default:
irHead = 0;
return (_bIRKeyBuf = IR_NONE);
}
}
else if(_bIRStatus >= IR_WAIT_NEW_CODE) //normal bit
{
/* 对于TR bit,长度视为与normal bit 相同*/
if (_bIRStatus == IR_WAIT_TR_CODE)
{
if (irVal < 7)
irVal = NARROWPULTIME-1;
}
if (irCnt & 0x01) // Singular
{
if (irCnt == 7)
_bIRStatus = IR_WAIT_TR_CODE;
irCnt++;
}
else // plural
{
if (irCnt == 10)
_bIRStatus = IR_WAIT_NEW_CODE;
if (irVal < NARROWPULTIME) //时间短,保持位
{
irCodeVal = (irCodeVal<<1) | (irCodeVal & 0x01);
irCnt++;
irBitCnt++;
}
else //时间较长,位翻转
{
irCodeVal = (~(irCodeVal & 0x01) & 0x1) | (irCodeVal<<1);
irCnt += 2;
irBitCnt++;
}
switch(irBitCnt)
{
case 4:
//DRS232LogB(irCodeVal 0 0 0);
if (irCodeVal != 0x08)
return (_bIRKeyBuf = IR_NONE);
irCodeVal &= 0x1;
break;
case 5:
irCodeVal &= 0x1;
break;
/* IR_CUSTOM_CODE_RC6 */
case 13:
//DRS232LogB(irCodeVal 1 1 1);
if (irCodeVal != IR_CUSTOM_CODE_RC6)
return (_bIRKeyBuf = IR_NONE);
irCodeVal &= 0x1;
break;
/* 解出码值 */
case 21:
//DRS232LogB(irCodeVal 2 2 2);
#if 1
if ((irVal < NARROWPULTIME)
&&((i==(_bIRRecvCnt-1))||(_bIRRecvBuf[i+1]> NARROWPULTIME))
)
return (_bIRKeyBuf = IR_NONE);
#endif
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 3314 2013-10-18 15:24 RC6.c
----------- --------- ---------- ----- ----
3314 1
- 上一篇:JsonView.zip
- 下一篇:某小区网络设计方案
评论
共有 条评论