📄 irstandby.c
字号:
//030816 - Use high memory
#ifdef SOFT_STANDBY_ENABLE
/*====================================================================
*
* Copyright (C) 1997 Acer Labs, Inc. All Rights Reserved.
*
* File: ir.c
*
* Contents: Get IR key code and translate the customer special key code
* to Ali physical key code
*
* History:
* Date By Reason
* =========== ========= ======
* 21-Jun-1999 Elisa Lee
* 22-Apr-2001 Dick Ma Reform
* 27-Aug-2002 Tom gao Modify and add it into M3325
********************************************************************/
#include <comsub.h>
#include <ui.h>
//#include "ir.h"//x
//#include "ir.c"//x
#include "frntp.h"
#include <platform.h>
/************************* 30210-01jf start **************************/
#include <panel.h>
#include<atapi.h>
#include<gpio51.h>
#define COUNTS_PER_MICROSECOND_standby (10)
#define readGPIODAT_standby() (inw_standby(GPIODAT))
#define readGPIORW_standby() (inw_standby(GPIORW))
#define writeGPIODAT_standby(gpiodata) (outw_standby(GPIODAT,gpiodata))
#define writeGPIORW_standby(gpiorw) (outw_standby(GPIORW,gpiorw))
#define SET_GPIO_R_standby(dwPorts) Gpio_Opr_standby(SET_READ,dwPorts)
#define SET_GPIO_W_standby(dwPorts) Gpio_Opr_standby(SET_WRITE,dwPorts)
#define SET_GPIO_HI_standby(dwPorts) Gpio_Opr_standby(SET_HI,dwPorts)
#define SET_GPIO_LOW_standby(dwPorts) Gpio_Opr_standby(SET_LOW,dwPorts)
#define GET_GPIO_DATA_standby(dwPorts) Gpio_Opr_standby(GET_DATA,dwPorts)
#define USE_LATCH_W_HI_standby(dwPorts) Gpio_Opr_standby(LATCH_W_HI,dwPorts)
#define USE_LATCH_W_LOW_standby(dwPorts) Gpio_Opr_standby(LATCH_W_LOW,dwPorts)
#define inw_standby(a) (*((volatile unsigned int *)(a)))
#define outw_standby(a,v) (*((volatile unsigned int *)(a))=(v))
#define TDR ((volatile unsigned int *)0xFF102004) //30216-01jf
/************************* 30210-01jf end**************************/
//BYTE IR_Check_Code_standby(DWORD);
extern unsigned char IR_Custom_Code1 , IR_Custom_Code2 ; //30124-01jf
/////need define to spend in IR_IRQ_STANDBY for standby/////////////////////////
#define inw(a) (*((volatile DWORD *)(a)))/* Input register value */ //
#define TCNT ((volatile int *)0xff100000) //
//extern volatile unsigned int count ; // watchdog CNT
extern unsigned long PnlKeyTrans[32]; //30210-01jf
volatile unsigned int count_STB __attribute__ ((section ("IRstandby_DATA"))) = 0; // watchdog CNT
extern void WakeUp_Standby(void); //
extern void StandbyCodeFillCache(void);
extern void Servo_ADC_Audio_TVDAC_MPEG_CPU_powerdown(void);
KEYPAD *p_key_STB __attribute__ ((section ("IRstandby_DATA")));//30210-01jf
KEYPAD keyPad_STB __attribute__ ((section ("IRstandby_DATA")))={0,0xff,0xff};//30210-01jf
DWORD LastKey_standby __attribute__ ((section ("IRstandby_DATA"))) = C_KEY_POWER;
WORD _key_count_standby __attribute__ ((section ("IRstandby_DATA"))) = 0; //30216-01jf
/////need define to spend in IR_IRQ_STANDBY for standby/////////////////////////
//#define GPIORW_STB 0xff101004
//#define GPIODAT_STB 0xff101000
//#define dwPorts_STB 0x00000008 //GPIO8
//#define inw_STB(a) (*((volatile unsigned int *)(a)))
//#define outw_STB(a,v) (*((volatile unsigned int *)(a))=(v))
//#define readGPIODAT_STB() (inw_STB(GPIODAT_STB))
//#define readGPIORW_STB() (inw_STB(GPIORW_STB))
//#define writeGPIODAT_STB(gpiodata_STB) (outw_STB(GPIODAT_STB,gpiodata_STB))
//#define writeGPIORW_STB(gpiorw_STB) (outw_STB(GPIORW_STB,gpiorw_STB))
//#define IR_Custom_Code1 0x01/*customer code*///ok
//#define IR_Custom_Code2 0xFE/*customer code*//ok
extern unsigned long KeyTable[96];//ok
#define Start_CNT_Hi_Band (324+40)//ok
#define Start_CNT_Low_Band (324-40)//ok
#define Repeat_CNT_Hi_Band (270+30)//ok
#define Repeat_CNT_Low_Band (270-30)//ok
#define _1_CNT_Hi_Band (54+20)//ok
#define _1_CNT_Low_Band (54-13)//ok
#define _0_CNT_Hi_Band (27+13) //ok
#define _0_CNT_Low_Band (27-20)//ok
//BYTE IR_Custom_Code1_standby __attribute__ ((section ("IRstandby_DATA"))) , IR_Custom_Code2_standby __attribute__ ((section ("IRstandby_DATA"))); //30124-01jf
BYTE StandbyMode __attribute__ ((section ("IRstandby_DATA"))) = 0; // 1:standby status; 0:normal status
//BYTE wakeupreset_STB __attribute__ ((section ("IRstandby_DATA"))) = 0; // 1:to wakeup status; 0:nowakeup status //30210-01jf
//DWORD TESTCOUNTLOOP __attribute__ ((section ("IRstandby_DATA"))) = 0; //30210-01jf
/* Private variable */
BYTE *M3323ByteReg_STB __attribute__ ((section ("IRstandby_DATA")));
WORD index_STB __attribute__ ((section ("IRstandby_DATA"))), data_STB __attribute__ ((section ("IRstandby_DATA")));
WORD Addr_STB __attribute__ ((section ("IRstandby_DATA"))), Value_STB __attribute__ ((section ("IRstandby_DATA")));
BYTE *M3323ByteReg_STB_volatile __attribute__ ((section ("IRstandby_DATA")));
DWORD IR_PreCount_standby __attribute__ ((section ("IRstandby_DATA")))=0 ,IR_NowCount_standby __attribute__ ((section ("IRstandby_DATA")))=0 ,IR_Between_CNT_standby __attribute__ ((section ("IRstandby_DATA")))=0;
BYTE bRepeatCount_standby __attribute__ ((section ("IRstandby_DATA"))) = 0 ;
WORD IR_StepFlag_standby __attribute__ ((section ("IRstandby_DATA"))) = 0 ;
DWORD LAST_IR_CODE_standby __attribute__ ((section ("IRstandby_DATA"))) = 0 ;
/* Public variable */
DWORD volatile IR_FreeCNT_standby __attribute__ ((section ("IRstandby_DATA"))) = 0 ;
BYTE IR_Error_Flag_standby __attribute__ ((section ("IRstandby_DATA"))) = 0 ;
BYTE IR_Key_code_standby __attribute__ ((section ("IRstandby_DATA"))) = 0 ;
DWORD IR_code_standby __attribute__ ((section ("IRstandby_DATA"))) = 0 ;
DWORD GET_IR_CODE_standby __attribute__ ((section ("IRstandby_DATA"))) = 0 ;
DWORD tmpGET_IR_CODE_standby __attribute__ ((section ("IRstandby_DATA"))) = 0 ;
BOOL flag_UserSetKey_standby __attribute__ ((section ("IRstandby_DATA"))) = 0; //30216-01jf
/* Private Function */
unsigned long int LastCNT_standby __attribute__ ((section ("IRstandby_DATA"))) = 0 ;
unsigned char start_flag_standby __attribute__ ((section ("IRstandby_DATA"))) = 0 ;
unsigned char IR_byte3_standby __attribute__ ((section ("IRstandby_DATA"))) = 0 , IR_byte2_standby __attribute__ ((section ("IRstandby_DATA"))) = 0 , IR_byte1_standby __attribute__ ((section ("IRstandby_DATA"))) = 0 , IR_byte0_standby __attribute__ ((section ("IRstandby_DATA"))) = 0 ;
#ifndef NEW_REFERENCE_BOARD
#define HEAD_HIGH 155
#define HEAD_LOW 316
#define BIT1_HIGH 53
#define BIT0_HIGH 16
#define BIT_LOW 21
#else
#define HEAD_HIGH 284
#define HEAD_LOW 580
#define BIT1_HIGH 106
#define BIT0_HIGH 28
#define BIT_LOW 40
#endif
//////////to clean the warning message generated by compiler //////////
BYTE IR_Check_Code_standby(void);
void Ready_to_WakeUp_Standby(void);
void FpReceiveKey_standby(KEYPAD* key);
unsigned long PnlGetKey_STB();
DWORD VfdGetKeys_standby();
void VfdHold_standby();
void SciDelay_standby(WORD w);
void VfdRelease_standby();
BYTE SciGetByte_standby();
void SciSetByte_standby(BYTE bData);
DWORD Gpio_Opr_standby(BYTE operate,DWORD dwPorts);
//////////to clean the warning message generated by compiler //////////
/*----------------------------------------------------------------------
* Function_Name: IR_IRQ_standby()
*
* Description: irq service routine,
* receive the remote control signal from IRQ then send MSG to UI
*
* Arguments:
*
* Return Value: void
*
*----------------------------------------------------------------------*/
void IR_IRQ_standby(void)
{
BYTE temp; //30216-01jf
//gamble added
#if (_TRANSFER_ALI_BOARD_ == _TRANSFER_ALI_BOARD_DISABLE_)
return ;
#endif
//unsigned long int LastCNT_standby=0;
LastCNT_standby = 0;
IR_FreeCNT_standby = inw(TCNT) - 0xfffff2d0 + count_STB;
// IR_FreeCNT_standby = getWDTcnt();
IR_FreeCNT_standby/=141; /*2250/16=140.625*/
IR_NowCount_standby=IR_FreeCNT_standby;/*Get count Between two interrupts*/
IR_Between_CNT_standby=IR_NowCount_standby-IR_PreCount_standby;
if((IR_Between_CNT_standby <= 18)||((IR_Between_CNT_standby <= 230)&&(IR_Between_CNT_standby >= 90)))//for cover CPU status 20030507 Tom Yang with experience value
{
;
}
else //for cover CPU status 20030507 Tom Yang
{
IR_PreCount_standby=IR_NowCount_standby;
//alert_STB("dddddddddddddddddd ok \n\r\0");
if (IR_StepFlag_standby == 0)
{
//static unsigned char start_flag_standby = 0;
start_flag_standby = 0;
if ((IR_Between_CNT_standby>=Start_CNT_Low_Band)&&(IR_Between_CNT_standby<=Start_CNT_Hi_Band))
{
IR_StepFlag_standby=1; /*goto Step1 when next interrupt*/
IR_Error_Flag_standby=0; /*init the value*/
}
// 30210-01jf removed by Jeff to reduce code to match cache size
// else if ((IR_Between_CNT_standby>=Repeat_CNT_Low_Band)&&(IR_Between_CNT_standby<=Repeat_CNT_Hi_Band))
// {
// if(LAST_IR_CODE_standby == C_KEY_STEP)
// {
// if (bRepeatCount_standby <= 45) /* wait about 1 second */
// /* 1(sec)/0.108(ms) = 9 */
// bRepeatCount_standby++;
// else
// {}//GET_IR_CODE_standby = LAST_IR_CODE_standby;
// }
// }
else if(start_flag_standby==1) /* garbage signal testing */
{
IR_Between_CNT_standby += LastCNT_standby;
if ((IR_Between_CNT_standby>=Start_CNT_Low_Band)&&(IR_Between_CNT_standby<=Start_CNT_Hi_Band))
{
IR_StepFlag_standby=1; /*goto Step1 when next interrupt*/
IR_Error_Flag_standby=0; /*init the value*/
}
start_flag_standby=0;
LastCNT_standby=0;
}
else if (IR_Between_CNT_standby<=Start_CNT_Hi_Band)
{
start_flag_standby=1; /* starting garbage signal test */
LastCNT_standby=IR_Between_CNT_standby;
}
else if (IR_Between_CNT_standby>2500)/*timeout*/
{
IR_Error_Flag_standby=1;
}
}
else if ((IR_StepFlag_standby>=1)&&(IR_StepFlag_standby<=32))/*Get IR_Key*/
{
if ((IR_Between_CNT_standby>=_0_CNT_Low_Band) && (IR_Between_CNT_standby <= _0_CNT_Hi_Band))
{
IR_code_standby = IR_code_standby>>1; /* get bit 0 */
IR_StepFlag_standby++;
}
else if ((IR_Between_CNT_standby>=_1_CNT_Low_Band)&&(IR_Between_CNT_standby<=_1_CNT_Hi_Band))
{
IR_code_standby = IR_code_standby>>1; /* get bit 1 */
IR_code_standby |= 0x80000000;
IR_StepFlag_standby++;
}
else
{
IR_StepFlag_standby=0;
IR_Error_Flag_standby=1;
}
if (IR_StepFlag_standby==33)
{
IR_StepFlag_standby=0;/* Clear IR_StepFlag_standby */
//IR_Key_code_standby = IR_Check_Code_standby(IR_code_standby);/*check key is valid and return key data code*/
IR_Key_code_standby = IR_Check_Code_standby();/*check key is valid and return key data code*/
if (IR_Error_Flag_standby == 0)
{
#if 0 //sean Keycounter
tmpGET_IR_CODE_standby = KeyTable[IR_Key_code_standby];
if( KeyPassOnCheck||(KeyCounter<MAXKEYCOUNTER)||(tmpGET_IR_CODE_standby==C_KEY_OPEN) )
{
LAST_IR_CODE_standby = GET_IR_CODE_standby = tmpGET_IR_CODE_standby;
bRepeatCount_standby = 0;
}
#endif
// LAST_IR_CODE_standby = GET_IR_CODE_standby = KeyTable[IR_Key_code_standby]; //30210-01jf
GET_IR_CODE_standby = KeyTable[IR_Key_code_standby]; //30210-01jf
/////////////////////////////// jeff&tom (standby mode ==> normal mode)
if ( GET_IR_CODE_standby == C_KEY_OPEN ) //30216-01jf
{
temp = (*(TDR));//30216-01jf
*(TDR) = temp |0x02;//30216-01jf
}
if ((GET_IR_CODE_standby == C_KEY_POWER)||(GET_IR_CODE_standby == C_KEY_PLAY)||(GET_IR_CODE_standby == C_KEY_OPEN))//play,open
{
///////////// 30210-01jf mark start /////////
/* asm volatile(".set noreorder
Clear_Intrupt2: #Allow_Nested_Int
li $8, 0xFF101000 # GPIO Base
lw $9, 0x0($8) # Read GPIODAT
nop
and $9, $9, 0x1fffffff # mask for GPIO29
or $9, $9, 0x40000000
sw $9, 0x0($8) # clear IP2
or $9, $9, 0x20000000
sw $9, 0x0($8) # mask for GPIO30:IPSEL
EnIRInt2:
mfc0 $8, $12
nop
#and $8,0xFFFF0000
or $8, 0x00000401 #enable ir_mask and interrupt_enable(IE)
and $8, 0xFFFF24F9 #Enable watch_dog_mask, disable EXL and ERL
mtc0 $8, $12
nop
nop
nop
*/ /*##########################################################fair
li $9, 0xff101004 #GPIORW_STB
lw $8, 0x0($9)
nop
or $8, 0x00000008
sw $8, 0x0($9)
nop
li $9, 0xff101000 #GPIODAT_STB GPIO3==high
lw $8, 0x0($9)
nop
or $8, 0x00000008
sw $8, 0x0($9)
nop
########################################################## */
/* ################# 1 before HWreset must to do Servo Power ON
li $3, 0xDF010000 # set uP wait delay
li $2, 0xC000
sw $2, 0($3)
li $3, 0xDF001000
li $2, 0x0
sb $2, 0x138($3)
li $2, 0x0
sb $2, 0x139($3)
li $2, 0x0
sb $2, 0x88($3)
lb $2, 0x138($3)
lb $2, 0x139($3)
lb $2, 0x88($3)
.set reorder
"
::);
*/
///////////// 30210-01jf mark end /////////
GET_IR_CODE_standby=0;
//StandbyMode = 0;
//wakeupreset_STB = 1;
//ReStartUP();// SHardware reset by SERVO DSP
//WakeUp_Standby(); //30210-01jf // Software reset by pc jump to 0xbfc00000
temp = (*(TDR));//30216-01jf
*(TDR) = temp |0x08;//30216-01jf
Ready_to_WakeUp_Standby(); //30210-01jf
}
///////////////////////////////jeff&tom
bRepeatCount_standby = 0;
}
#if 1//sean Keycounter
else
{
GET_IR_CODE_standby = 254;
IR_Key_code_standby = 254;
}
#endif
}
}
}//endif error
}
/*----------------------------------------------------------------------
* Function_Name: IR_Check_Code_standby()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -