📄 rfinput.c
字号:
/*********************************************************************************************************
** Small RTOS(51)
** The Real-Time Kernel(For Keil c51)
**
** (c) Copyright 2002-2002, chenmingji
** All Rights Reserved
**
** V1.12.1
**
**
**--------------文件信息--------------------------------------------------------------------------------
**文 件 名: lcd1602.c
**创 建 人: 陈明计
**最后修改日期: 2003年4月27日
**描 述: DP-51的液晶TC1602A的驱动程序
**
**--------------历史版本信息----------------------------------------------------------------------------
** 修改人: 陈明计
** 版 本: V1.0
** 日 期: 2003年4月27日
** 描 述: 原始版本,应用于Small RTOS 51 v1.12.1
**------------------------------------------------------------------------------------------------------
**--------------当前版本修订------------------------------------------------------------------------------
** 修改人:
** 日 期:
** 描 述:
**
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
#include "config.h"
/*********************************************************************************************************
** 函数名称: RFInputScan()
** 功能描述: 扫描键盘
**
** 输 入: 无
** 输 出: 无
** 全局变量:
** 调用模块: 无
**
** 作 者: 龚树强
** 日 期: 2003年7月18日
**-------------------------------------------------------------------------------------------------------
** 修改人:
** 日 期:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
extern uint8 _InputBuf;
extern uint16 _Address;
void RFInputScan(void)
{
static uint16 timer[2];
static uint16 input_addr;
static uint8 input_command;
static uint8 i,j;
static uint16 k;
OS_ENTER_CRITICAL();
P2|=0X01;
for(j=200;(j--)&&(_RF_Input););
timer[0]=TH0;
timer[0]<<=8;
timer[0]+=TL0;
TH0=0;
TL0=0;
TR0=1;
for(k=1000;(k--)&&(!_RF_Input););
timer[1]=TH0;
timer[1]<<=8;
timer[1]+=TL0;
TH0=0;
TL0=0;
TR0=1;
if((timer[1]>timer[0]*20)&&(timer[0]>80))
{
input_addr=0;
input_command=0;
for(i=0;i<16;i++)
{
for(j=250;(j--)&&(_RF_Input););
timer[0]=TH0;
timer[0]<<=8;
timer[0]+=TL0;
TH0=0;
TL0=0;
TR0=1;
for(j=250;(j--)&&(!_RF_Input););
timer[1]=TH0;
timer[1]<<=8;
timer[1]+=TL0;
TH0=0;
TL0=0;
TR0=1;
if(timer[1]>timer[0])
{
input_addr<<=1;
}
else
{
input_addr<<=1;
input_addr++;
}
}
for(;i<24;i++)
{
for(j=250;(j--)&&(_RF_Input););
timer[0]=TH0;
timer[0]<<=8;
timer[0]+=TL0;
TH0=0;
TL0=0;
TR0=1;
for(j=250;(j--)&&(!_RF_Input););
timer[1]=TH0;
timer[1]<<=8;
timer[1]+=TL0;
TH0=0;
TL0=0;
TR0=1;
if(timer[1]>timer[0])
{
input_command<<=1;
}
else
{
input_command<<=1;
input_command++;
}
}
if(input_addr==_Address)
{
switch(input_command)
{
case 0X03 : _InputBuf=ENTER;
OSSemPost(Input_SEM);
break;
case 0X0C : _InputBuf=EXIT;
OSSemPost(Input_SEM);
break;
case 0X30 : _InputBuf=UP;
OSSemPost(Input_SEM);
break;
case 0XC0 : _InputBuf=DOWN;
OSSemPost(Input_SEM);
break;
default : break;
}
for(k=15000;k--;);
}
}
OS_EXIT_CRITICAL();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -