?? tirsony.c.svn-base
字號:
/**
* 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:
* 20/01/2005 Created by Lewis 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 Dword dwRemoteShift = REMOTE_SHIFT_START; /*used to count shift times and generate s_RemoteData.ucRemoteTemp*/
static Byte ucRemoteLastCodeSaved = 0;
/*the following two global variables are used by remote routines*/
static Void tdRemoteCodeDetect(Byte ucRemoteCode);
static Gdata struct tagRemoteData
{
Byte ucRemoteTemp; /*store the temporary value of a code,tdRemoteCodeDetect was call definite times to generate a code*/
Byte ucRemoteShift; /*used to count shift times and generate s_RemoteData.ucRemoteTemp*/
Byte ucPreviousCountVal; /*timer count value of last time*/
Byte ucDataCode; /*store the data code part*/
Byte ucRemoteCode;
Byte ucOffset;
Byte ucKeyNum;
} s_RemoteData;
static Void tdIRSONY1msTimer(Void)
{
if (t_RemoteData.wCount)
t_RemoteData.wCount--;
else
ucRemoteLastCodeSaved = 0;
}
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 tdIRSONYService(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 i;
IByte datatemp;
if((s_ucRemoteFlag & _RF_SONY_STARTED_) != 0)
{
if((pSONYRemote->Remote_Code_0_Min <= ucRemoteCode) && (ucRemoteCode <= pSONYRemote->Remote_Code_0_Max))
{
//Check if code "0".
tdLeftShift1(s_RemoteData.ucRemoteShift);
}else if((pSONYRemote->Remote_Code_1_Min <= ucRemoteCode) && ( ucRemoteCode <= pSONYRemote->Remote_Code_1_Max)) /*code 1*/
{
//Check if code "1".
s_RemoteData.ucRemoteTemp += s_RemoteData.ucRemoteShift;
tdLeftShift1(s_RemoteData.ucRemoteShift);
}else
{
//if error remote code,do not translate, and recheck the sync head pulse.
s_ucRemoteFlag = 0;
goto detect_head;
}
if((s_ucRemoteFlag & _RF_SONY_DATACODE_) != 0)
{
if(s_RemoteData.ucRemoteShift == 0x80)
{
s_RemoteData.ucDataCode = s_RemoteData.ucRemoteTemp; // Store data code
s_RemoteData.ucRemoteTemp = 0;
s_RemoteData.ucRemoteShift = REMOTE_SHIFT_START;
s_ucRemoteFlag &= ~_RF_SONY_DATACODE_;
s_ucRemoteFlag |= _RF_SONY_SYSTEMCODE_;
}
return;
}
if((s_ucRemoteFlag & _RF_SONY_SYSTEMCODE_) != 0)
{
if(s_RemoteData.ucRemoteShift == (1 << 4)) //pSONYRemote->System_Bit_Num can not be achieved from tool
{
s_ucRemoteFlag &= ~_RF_SONY_SYSTEMCODE_;
for(ucIndex = 0; ucIndex < pSONYRemote->System_Code_Num; ucIndex++)
{
if(pSONYRemote->RemoteKeySet[ucIndex].ucSystemCode == s_RemoteData.ucRemoteTemp)
break;
}
if(ucIndex == pSONYRemote->System_Code_Num)
{
s_ucRemoteFlag =0;
goto detect_head;
}
else
{
s_RemoteData.ucOffset = pSONYRemote->RemoteKeySet[ucIndex].ucKeySetOffset;
s_RemoteData.ucKeyNum = pSONYRemote->RemoteKeySet[ucIndex].ucKeyNum << 1;
}
while((*((RPByte)pSONYRemote + s_RemoteData.ucOffset + ucIndex) != s_RemoteData.ucDataCode) && (ucIndex < s_RemoteData.ucKeyNum))
{
ucIndex += 2;
}
if(ucIndex < s_RemoteData.ucKeyNum)
{
s_RemoteData.ucRemoteCode = *((RPByte)pSONYRemote + s_RemoteData.ucOffset + ucIndex + 1);
if (s_RemoteData.ucRemoteCode == ucRemoteLastCodeSaved)
{
if (t_RemoteData.wCount < t_RemoteData.wRepeatDelay)
{
tdAddVirtualKey(s_RemoteData.ucRemoteCode /*| _VK_STATUS_DOWN_*/);
t_RemoteData.wCount = (2*t_RemoteData.wRepeatDelay);
}
}
else
{
tdAddVirtualKey(s_RemoteData.ucRemoteCode);
t_RemoteData.wCount = (t_RemoteData.wFirstDelay/2 + t_RemoteData.wRepeatDelay);
}
s_RemoteData.ucRemoteShift = REMOTE_SHIFT_START;
s_RemoteData.ucRemoteTemp = 0;
s_RemoteData.ucDataCode = 0;
ucRemoteLastCodeSaved = s_RemoteData.ucRemoteCode;
s_RemoteData.ucRemoteCode = 0;
}
else
{
s_ucRemoteFlag = 0;
s_RemoteData.ucRemoteShift = REMOTE_SHIFT_START;
}
}
return;
}
}
detect_head:
if((pSONYRemote->Remote_Code_Sync_Min <= ucRemoteCode) && (ucRemoteCode <= pSONYRemote->Remote_Code_Sync_Max)) //sync code
{
//started parsing.
s_ucRemoteFlag |= _RF_SONY_DATACODE_;
//set the initial value of shifting.
s_RemoteData.ucRemoteShift = REMOTE_SHIFT_START;
s_RemoteData.ucRemoteTemp = 0;
s_RemoteData.ucDataCode = 0;
}
else
{
//if error remote code,do not translate.
s_ucRemoteFlag &= ~_RF_SONY_STARTED_;
}
return;
}
Code RemoteControllerDriver f_IRSONYDriver =
{
tdIRSONY1msTimer, tdIRSONYService
};
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -