?? tirthomson.c.svn-base
字號(hào):
/**
* This code and information is part of Trident DPTV API (TDAPI)
*
* Copyright (C) Trident Multimedia Technologies (Shanghai) Co., Ltd.
* 2002 - 2003 All rights reserved.
*
* This file provides functions for TV or demoboard remote controller.
*
* Revision:
* 03/04/2004 Modify RC5 part(decode & repeat) by Max and Joy
* 04/18/2003 Added repeat key support by Archie
* 08/01/2002 Created by Rick, York, Joy and Archie
*
*/
#include "tdefs.h"
#include "tio.h"
#include "tutils.h"
#include "tvkey.h"
#include "tRemote.h"
#include "thilevel.h"
#include "ttimer.h"
/*remote flag*/
static Byte s_ucRemoteFlag = 0;
static Void tdRemoteCodeDetect(Byte ucRemoteCode);
/*the following two global variables are used by remote routines*/
static Gdata struct tagRemoteData
{
Byte ucRemoteTemp;
Byte ucRemoteShift;
Byte ucToggelBit;
Byte ucPreviousCountVal; /*timer count value of last time*/
Byte ucSystemCode;
Byte ucRemoteCode;
Byte ucOffset;
Byte ucKeyNum;
} s_RemoteData;
static Void tdIRThomson1msTimer(Void)
{
if (t_RemoteData.wCount == t_RemoteData.wFirstDelay)
{
tdAddVirtualKey(s_RemoteData.ucRemoteCode);
t_RemoteData.wCount--;
} else if (t_RemoteData.wCount)
{
t_RemoteData.wCount--;
if (tdTestValBitTrue(s_ucRemoteFlag, _RF_TM_LEADERCODE_))
{
if (t_RemoteData.wCount == 0)
{
tdAddVirtualKey(s_RemoteData.ucRemoteCode /*| _VK_STATUS_DOWN_*/);
tdClearValBit(s_ucRemoteFlag, _RF_TM_LEADERCODE_);
t_RemoteData.wCount = t_RemoteData.wRepeatDelay - 1;
}
}
}
}
static Byte tdGetTimeInterval(Byte ucCurrentCountVal)
{
/* when the INT0 interrupt the timer interrupt service */
if (!ucCurrentCountVal)
ucCurrentCountVal = tdLoadInitTimerCount();
#ifdef _TIMERCOUNT_DOWN_
if (ucCurrentCountVal < s_RemoteData.ucPreviousCountVal)
ucCurrentCountVal = s_RemoteData.ucPreviousCountVal - ucCurrentCountVal;
else
ucCurrentCountVal = s_RemoteData.ucPreviousCountVal + tdGetTimerBInterval() - ucCurrentCountVal;
#else
if (ucCurrentCountVal >= s_RemoteData.ucPreviousCountVal)
ucCurrentCountVal = ucCurrentCountVal - s_RemoteData.ucPreviousCountVal;
else
ucCurrentCountVal = ucCurrentCountVal + tdGetTimerBInterval() - s_RemoteData.ucPreviousCountVal;
#endif
return ucCurrentCountVal;
}
static Void tdIRThomsonService(Void)
{
IByte ucRemoteCode;
IByte ucCurrentCountVal;
ucCurrentCountVal = tdGetTimerBCurrentCount();
#ifdef _TIMERCOUNT_DOWN_
if(ucCurrentCountVal > tdLoadInitTimerCount())
#else
if(ucCurrentCountVal < tdLoadInitTimerCount())
#endif
ucCurrentCountVal = tdLoadInitTimerCount();
tdClearInterruptPend();
ucRemoteCode = tdGetTimeInterval(ucCurrentCountVal);
s_RemoteData.ucPreviousCountVal = ucCurrentCountVal;
tdRemoteCodeDetect(ucRemoteCode); /* Analyse remote key */
}
static Void tdRemoteCodeDetect(Byte ucRemoteCode)
{
IByte ucIndex;
IByte ucToggel;
static IByte ucRemoteToggle = 3;
if(tdTestValBitTrue(s_ucRemoteFlag, _RF_TM_STARTED_))
{
if((pThomsonRemote->Remote_Code_0_Min <= ucRemoteCode) && (ucRemoteCode <= pThomsonRemote->Remote_Code_0_Max))
{
//Check if code "0".
tdLeftShift1(s_RemoteData.ucRemoteShift);
tdLeftShift1(s_RemoteData.ucRemoteTemp);
}else
{
if((pThomsonRemote->Remote_Code_1_Min <= ucRemoteCode) && ( ucRemoteCode <= pThomsonRemote->Remote_Code_1_Max)) /*code 1*/
{
//Check if code "1".
tdLeftShift1(s_RemoteData.ucRemoteTemp);
s_RemoteData.ucRemoteTemp += 1;
tdLeftShift1(s_RemoteData.ucRemoteShift);
}else
{
//if error remote code,do not translate, and recheck the sync head pulse.
tdClearValBit(s_ucRemoteFlag, (_RF_TM_STARTED_|_RF_TM_SYSTEMCODE_|_RF_TM_DATABITS_ | _RF_TM_TOGGELBITS_));
goto detect_head;
}
}
if(tdTestValBitTrue(s_ucRemoteFlag, _RF_TM_SYSTEMCODE_))
{
if(s_RemoteData.ucRemoteShift == 1 << pThomsonRemote->System_Bit_Num)
{
if(s_RemoteData.ucRemoteTemp != pThomsonRemote->RemoteKeySet[0].ucSystemCode)
{
tdClearValBit(s_ucRemoteFlag, _RF_TM_STARTED_|_RF_TM_SYSTEMCODE_);
goto detect_head;
}
tdClearValBit(s_ucRemoteFlag, _RF_TM_SYSTEMCODE_);
tdSetValBit(s_ucRemoteFlag, _RF_TM_TOGGELBITS_);
s_RemoteData.ucRemoteTemp = 0;
s_RemoteData.ucRemoteShift =REMOTE_SHIFT_START;
}
return;
}
//Process toggelbits.
if(tdTestValBitTrue(s_ucRemoteFlag, _RF_TM_TOGGELBITS_))
{
if(ucRemoteToggle == s_RemoteData.ucRemoteTemp)
{
ucToggel = 0;
}else
{
ucToggel = 1;
ucRemoteToggle = s_RemoteData.ucRemoteTemp;
}
s_RemoteData.ucRemoteTemp = 0;
s_RemoteData.ucRemoteShift = REMOTE_SHIFT_START;
tdClearValBit(s_ucRemoteFlag, _RF_TM_TOGGELBITS_);
tdSetValBit(s_ucRemoteFlag, _RF_TM_DATABITS_);
return;
}
//Process databits.
if(tdTestValBitTrue(s_ucRemoteFlag, _RF_TM_DATABITS_))
{
if(s_RemoteData.ucRemoteShift == 0x80)
{
ucIndex = 0;
while ((*((RPByte)pThomsonRemote + pThomsonRemote->RemoteKeySet[0].ucKeySetOffset + ucIndex) != (s_RemoteData.ucRemoteTemp & 0x7F)) && (ucIndex < 2 * pThomsonRemote->RemoteKeySet[0].ucKeyNum))
{
ucIndex += 2;
}
if(ucIndex < pThomsonRemote->RemoteKeySet[0].ucKeyNum)
{
s_RemoteData.ucRemoteTemp = *((RPByte)pThomsonRemote + pThomsonRemote->RemoteKeySet[0].ucKeySetOffset + ucIndex + 1); /*set repeat data*/
if(ucToggel == 1 ||(ucToggel == 0 && s_RemoteData.ucRemoteTemp != s_RemoteData.ucRemoteCode)/*&& s_RemoteData.ucRemoteTemp != s_RemoteData.ucRemoteCode*/ )
{
t_RemoteData.wCount = t_RemoteData.wFirstDelay;
s_RemoteData.ucRemoteCode = s_RemoteData.ucRemoteTemp;
}else if(ucToggel == 0 && s_RemoteData.ucRemoteTemp == s_RemoteData.ucRemoteCode)
{
tdSetValBit(s_ucRemoteFlag, _RF_TM_LEADERCODE_);
if(t_RemoteData.wCount == 0)
{
t_RemoteData.wCount = 1;
}
}
}
tdClearValBit(s_ucRemoteFlag, _RF_TM_DATABITS_ |_RF_TM_STARTED_ |_RF_TM_SYSTEMCODE_);
}
return;
}
}
detect_head:
if(100 <= ucRemoteCode)
{
s_RemoteData.ucRemoteTemp = 0;
s_RemoteData.ucRemoteShift = REMOTE_SHIFT_START;
tdSetValBit(s_ucRemoteFlag, (_RF_TM_STARTED_|_RF_TM_SYSTEMCODE_));
}
}
Code RemoteControllerDriver f_IRThomsonDriver =
{
tdIRThomson1msTimer, tdIRThomsonService
};
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -