📄 ir.c
字号:
/******************************************************************************
* Compiler: WinAVR(GCC)
* Device: ATtiny13
* File name: IR.c
* Description: IR
* Programmer: Liansen.Wang
* Revision: 1.0
* Modification Time: 2005-08-22 14:43
******************************************************************************/
#include "IR.h"
/*===========================================================
===========================================================*/
unsigned char IR_Time_detect(unsigned int time1,unsigned int time2)
{
unsigned int i=0;
unsigned char j=0;
while((PINB & (1<<IR))>=j)
{
i++;
if((PINB & (1<<IR))!=0) {j=1;}
if(i>time2) {return 0xFF;}
}
if(i>time1){return 1;}
else {return 0;}
}
/*===========================================================
============================================================*/
unsigned char IR_Value_Read(void)
{
unsigned char i,j,k;
unsigned char IR_Value_time[4];
if (IR_Time_detect(2400,3360)!=1)
{
GIFR|=(1<<PCIF);
return 0xFF;
}
for(i=0;i<4;i++)
{
for(j=0;j<8;j++)
{
IR_Value_time[i]>>=1;
k=IR_Time_detect(800,1440);
if(k==0xFF)
{
GIFR|=(1<<PCIF);
return 0xFF;
}
if(k==1)
{
IR_Value_time[i]|=0x80;
}
}
}
if((IR_Value_time[2] & IR_Value_time[3])==0)
return IR_Value_time[2];
else
return 0xFF;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -