⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 remote.c

📁 此程序为遥控器接收程序,以通过测试,可放心使用,我是参照网上资料修改的,单片机是NEC78f0547,希望对个需要的人有所帮助
💻 C
字号:
/*
*********************************************************************************
*********************************************************************************
*/
#include "function.h"
#define IR_NONE                0x00
//#define IR_NUM0                0x00
#define IR_NUM1                0xB3
#define IR_NUM2                0xAF
#define IR_NUM3                0xAE
#define IR_NUM4                0xF0
#define IR_NUM5                0xAB
#define IR_NUM6                0xAA
#define IR_NUM7                0xEC
#define IR_NUM8                0xE8
#define IR_NUM9                0xA7

#define IR_POWER               0xF4
#define IR_OUT                 0xB7
#define IR_MODE                0xB5
#define IR_BAND                0xF3
//#define  IR_AS_PS              0x
#define IR_EQ                  0xE2
#define IR_MO_ST               0xE4
#define IR_LOC                 0xE6
#define IR_STOP	               0xAD
#define IR_DISPLAY	           0xBA
#define IR_PREV                0xBB
#define IR_NEXT		             0xA5
#define IR_SPEED	             0xB1//>>
#define IR_BACK	               0xEE//<<,
#define IR_TITLE               0xFF
//#define IR_MENU	               0x20
//#define IR_UP		               0x21
#define IR_DOWN		             0xBD
#define IR_LEFT		             0xFE
//#define IR_RIGHT		           0x24
//#define IR_OK	                 0x25
#define IR_SETUP		           0xFB
#define IR_SUBT		             0xF7

#define IR_RPT	               0xEB
#define IR_SLOW_UP		         0xF8
#define IR_SLOW_DOWN	         0xB9
#define IR_PROG		             0xEF
//#define IR_S_M	               0x
#define IR_VOL_ADD		         0xF8
#define IR_VOL_SUB		         0xB9
#define IR_MUTE		             0xFA
#define IR_A_B		             0xE7
#define IR_GOTO		             0xEA
#define IR_ROM		             0xE3
#define IR_P_N		             0xFC
#define IR_AUD		             0xF6
#define IR_ZOOM	               0xF2
#define IR_DISP		             0xB6
#define IR_ANG		             0xBF
/*
*********************************************************************************************
*********************************************************************************************
*/
#define IR_WAIT_NEW_CODE        0
#define IR_WAIT_LEAD_CODE       1
#define IR_READ_CUSTOM_CODE     2
#define IR_READ_SUB_CUSTOM_CODE 3
#define IR_READ_DATA_CODE       4
#define IR_READ_DATA_CODE_INV   5
#define IR_READ_REPEAT_CODE     6
#ifndef UINT8 unsigned char
#define UINT8 unsigned char
#endif
#ifndef UINT16 unsigned int
#define UINT16 unsigned int
#endif
#define FALSE  0
#define TRUE    1
#define IR_SYSTEM_CODE  0xee11 
/*
*********************************************************************************************
function:variable  define
*********************************************************************************************
*/
UINT8  _bIRStatus=0,_bIRBitCnt=0,Rep_flag=0;
UINT16 _bIRKeyBuf=0,_IR_key_fan=0x00,_IR_key=0x00;
/*
*********************************************************************************************
*********************************************************************************************
*/
void IrInit(void) 
{
 // reset IR related variable
  _bIRStatus = 1; 
  _bIRBitCnt = 0;
  _bIRKeyBuf = 0;
  return;
}
/*
*********************************************************************************************
*********************************************************************************************
*/
void vIrRecv()
{
	switch(_bIRStatus)
	{
		case  IR_WAIT_NEW_CODE:
			    _bIRStatus=IR_WAIT_LEAD_CODE;		    
			break;
		case   IR_WAIT_LEAD_CODE:											
					if( (Remote_count>114)&&(Remote_count<145))		//13ms 13.8ms //Remote_count=141 
					{
					_bIRStatus=IR_READ_CUSTOM_CODE;	
					Rep_flag++;	
					}
					else
					IrInit();			
		 break;	
		case 	IR_READ_CUSTOM_CODE:
					_bIRBitCnt++;
					_bIRKeyBuf>>=1;				
					if((Remote_count>20)&&(Remote_count<26)) 		//2.25ms//Remote_count=22~24   
					{
					  _bIRKeyBuf|=0x8000;
					}				  	
					else if((Remote_count>8)&&(Remote_count<14)) 		//1.25ms//Remote_count=10~12   
					{
					 _bIRKeyBuf&=0x7fff;	
					}
		     	else		
				  IrInit();	
					if((_bIRBitCnt==16))
					{
						if(_bIRKeyBuf==IR_SYSTEM_CODE)	
							{
								_bIRStatus=IR_READ_SUB_CUSTOM_CODE;
								_bIRKeyBuf=0;
							}
						else		
							IrInit();				
					}		
			break;	
		case  IR_READ_SUB_CUSTOM_CODE:
			   _bIRBitCnt++;
			   _bIRKeyBuf>>=1;
				if((Remote_count>20)&&(Remote_count<26)) 		//2.25ms   0bb8
				{
				_bIRKeyBuf|=0x8000;									
				}
				else if((Remote_count>8)&&(Remote_count<14)) 		//1.25ms   05dc	
				{
					_bIRKeyBuf&=0x7fff;				
				}												
				else		
					IrInit();			
			 if((Remote_count>8)&&(Remote_count<14)) 		//1.25ms   05dc	
				{
					_bIRKeyBuf&=0x7fff;				
				}		
						   
				if(_bIRBitCnt==32)
				{
					_IR_key=_bIRKeyBuf&0x00ff;
					_IR_key_fan=_bIRKeyBuf&0xff00;			
				// _IR_key=_pbIRKeyTbl[_bIRKeyBuf&0x00ff];					
				//_fgIRKeyValid=TRUE;
				IrInit();
				Rep_flag=0;
				}	
				break;
			}		
}
/*
*********************************************************************************
*********************************************************************************
*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -