📄 myremotereception.c
字号:
#pragma SFR //special function register
#pragma NOP
#pragma DI
#pragma EI
//interrupt serve function name inter_P0.
#pragma INTERRUPT INTP0 Inter_P0
//interrupt serve function name Inter_TM1.
#pragma interrupt INTTM01 Inter_TM1
/*
**PROJECT = HDTV REMOTE CONTROL RECEPTION PROCESSING
**MODULE = MyRemoteReceptionModi.c
**SHORT DESC. = Remote control reception && key value processing
**DEVICE = UPD789417
**VERSION = 0.1
**DATE = 03.07.2003
**LAST CHANGE = -
*/
#include "MyDefine.h"
#include "MyRemoteReception.h"
//the bit for remote control infrared ray reception
#define g_btIR P2.4
//g_TempRMDATA:(Valid data storage area)the ReMote input DATA is saved.
sreg Uchar g_TempRMDATA;
sreg Uchar s_tempCodes[4];
//The prefix "s_g_" indicates Static Outer variables.
//s_g_RPTCT -- RePeaT code valid time CounTer
static sreg Uchar s_g_RPTCT;
//s_g_RMENDCT -- input time CounTer for ReMote data input end
static sreg Uchar s_g_RMENDCT;
static sreg Uchar s_g_SELMODE; //s_g_SELMODE -- SELection MODE
//s_g_LD_CT -- Leader signal Detection CounTer
static sreg Uchar s_g_LD_CT = 5;
//static sreg Uchar TM1CntValue; //TM1CntValue -- TM1 Count Value
/*s_tempCodes[0] -- custom code; s_tempCodes[1] -- custom code inverted;
s_tempCodes[2] -- data code; s_tempCodes[3] -- data code inverted
*/
//static sreg Uchar s_tempCodes[4];
//s_tempByte -- assigned temporarily to code by byte
//static sreg Uchar s_tempByte;
//s_byteCntAccepted -- byte counts that have been accepted
//static sreg Uchar s_byteCntAccepted;
//s_bitCntAccepted -- bit counts that have been accepted
//static sreg Uchar s_bitCntAccepted;
bit g_btRPT; //g_btRPT -- RePeaT(flag for repeat valid time)
bit g_btRMDTSET; //g_btRMDTSET -- ReMote DaTa SET
//g_btIPDTFG -- Decision FlaG indicating the presence of a valid InPut
// DaTa signal
bit g_btIPDTFG;
extern bit btTwoKeys750ms;//add new
//bit btkeyPress; //present the status of any keys
bit btKeyPressedTooLong;
static bit s_g_btRMDTOK;//Presence of a valid input ReMote DaTa signal
Uchar g_keyFlgCnt = 0; //2003-9-24 14:51
void S_LOWCT();
void S_M0SET();
void Delay100usIR();
void LEAD_H();
void LEAD_L();
void CDCODE();
void REPCD();
void ENDCHK();
Uchar CR_READ();
void S_M5SET();
/*
** Function name: InitReceive
**
** Description:
** The function initializes the variables used firstly.
**
** Note: sreg variables is automatically set to 0 by system, so we are
** allowed not to initialize the variables manually.
** But I should adopt the good routine. If ROM is not enough,
** then consider deleting the step of initialization.
**
** Input parameters:
** no
**
** Output parameters:
** no
**
** Return value:
** no
*/
void InitReceive()
{
//g_TempRMDATA -- (Valid data storage area)the ReMote input DATA
// is saved.
g_TempRMDATA = 0;
s_g_RPTCT = 0; //s_g_RPTCT -- RePeaT code valid time CounTer
s_g_RMENDCT = 0;
s_g_btRMDTOK = 0;
s_g_SELMODE = 0;
g_btRPT = 0; //g_btRPT -- RePeaT(flag for repeat valid time)
g_btRMDTSET = 0; //g_btRMDTSET -- ReMote DaTa SET
//g_btIPDTFG -- Decision FlaG indicating the presence of a valid
// InPut DaTa signal
g_btIPDTFG = 0;
}
/*
**====================================================================
** leader code:9mS(L) 4.5mS(H) <NEC FORMATE -- L:low;H:high>
** __ _____ _ __ ___________________________
** \________/ \_/ \_/ \_..\_/
**
**====================================================================
*/
/*
** Function name: Inter_TM1
**
** Description:
** The function is ISR - Interrupt Service Routine of timer1
** interval timer and used for remote control signal timer
** processing.
**
** Input parameters:
** no
**
** Output parameters:
** no
**
** Return value:
** no
*/
void Inter_TM1()
{
EI(); //Enable multiplexed interrupt.
if(g_btIPDTFG) //Is the InPut DaTa signal present?
{
if(s_g_btRMDTOK) //Is ReMote DaTa valid?
{
S_LOWCT(); //Leader code detection
s_g_RPTCT--; //RePeaT code valid time CounTer is decreased by 1.
if(0 == s_g_RPTCT) //RePeaT code invalid time is up.
{
g_btRPT = 0; //RePeaT code becomes invalid state after 250ms.
g_btIPDTFG = 0;
s_g_btRMDTOK = 0;
//****the following????????
btKeyPressedTooLong = 1; //Show key is pressed too long.
//03-7-16 11:25 殠貨倫韼幯旈檸箞幉廁弫曵墛泿紱幜1侤侤侤侤侤侤
//嫀覛ybtkeyPress棊☉儧幀擮侹恏拵跈幭弾珛幤崫n岕108ms殠貛幯昻250ms-40.5ms+3*1.5ms
//btkeyPress = 0;
//TCE02 = 0; //stop timing when the key is lifted.
/*
if((TM02Cnt > 33)&&(TM02Cnt < 217)&&(key800msCnt = 1))
{
TM02Cnt = 0;
key800msCnt = 0;
btShortTime = 1;
}
if(key800msCnt > 1)
{
btShortTime = 0;
btLongTime = 1;
}
*/
//殠貖幧妿
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -