⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 input.c

📁 ct952 source code use for Digital Frame Photo
💻 C
📖 第 1 页 / 共 4 页
字号:
               break;                                                                                                                                                                                      case 18:                                                                                                    if(REG_PLAT_IR_STATUS & FALLING_EDGE)  // 1                                                      return;                                                                                                  if((dwTemp-_dwTimeISRKeyPrev2)==2)  // it is 0                                                     {                                                                                                       bDataCode&= ~0x01;                                                                               }                                                                                             else if((dwTemp-_dwTimeISRKeyPrev2)==3)  // it is 1                                                      {                                                                                                      bDataCode|= 0x01;                                                                                 }                                                                                             else                                                                                                 goto INVALID_IR; // or break?                                                                              break;                                                                           }                                                                                       //    printf("time gap = %lx \n",dwTemp1);                                                        if (bIRStep==18) // && _bCustomerCode == 0x06 )  // finish one key receiving, clear flag, map the real key, and return    {//Alan2.05        _bKeyGet = aIRMap[bDataCode];  // get the key map        _bKeyGet = _IRInfo.aIRMap[bDataCode];  // get the key map        bIRStep = 0;  // must clear the flag        bIRFlag = 1;  // get one ir key// printf("time gap = %lx \n",dwTemp1);                    return;    }    else if(bIRStep<18)   // continue to detect next edge    {        _dwTimeISRKeyPrev2 = dwTemp;          bIRStep++;  // 0 -> 1 none --> leader begin //     printf("time gap = %lx \n",dwTemp1);        return;    }INVALID_IR:   //its not valid IR singal    bIRStep = 0;    _bKeyGet = KEY_NO_KEY;    return;}#endif  // #if (IR_CODE_TYPE == SW_KONKA)/*** Many of the following codes will be moved out of the INPUT module ***///  *********************************************************************//  Function    :   INPUT_InitIR//  Description :   Set IR parameters//  Arguments   :   None//  Return      :   None//  Side Effect :   None//  *********************************************************************VOID    INPUT_InitIR(PIR_INFO pIRInfo){    BYTE i;    if (NULL == pIRInfo)    {        _IRInfo.bIR_Type = IR_TYPE;        _IRInfo.bCustomerCode = CUSTOMER_CODE;        _IRInfo.bCustomerCode1 = CUSTOMER_CODE1;        _IRInfo.aIRMap = aIRMap;        _IRInfo.bIRMapSize = sizeof(aIRMap) / sizeof(BYTE);        for (i = 0; i < 8; i++)        {            _bCustomerCode |= ( (CUSTOMER_CODE>>i) & 1 ) << (7-i);            _bCustomerCode1 |= ( (CUSTOMER_CODE1>>i) & 1 ) << (7-i);        }    }    else    {        INPUT_SetIRInfo(pIRInfo);    }            // LLY2.36, call API to enable IR interrupt and config IR checking mode    //REG_PLAT_PROC1_2ND_INT_MASK_DISABLE = INT_PROC1_2ND_IR;//some of interrupt is not available yet. ->mask off    INPUT_SetIRCheckMode(IR_CHECK_MODE_INT);    _ResetIR();}VOID    _ResetIR(VOID) //kevin0.75{    DWORD dwSaveInt;    HAL_DISABLE_INTERRUPTS( dwSaveInt );    // Disable INT to avoid different threads accessing    REG_PLAT_RESET_CONTROL_ENABLE = PLAT_RESET_IR_ENABLE;    REG_PLAT_RESET_CONTROL_DISABLE = PLAT_RESET_IR_DISABLE;    HAL_RESTORE_INTERRUPTS( dwSaveInt );    // Restore INT.             //IR control registers    //REG_PLAT_IR_TIMING_CONTROL1 = 0x13880bb8;       REG_PLAT_IR_TIMING_CONTROL1 = 0x13880008;    REG_PLAT_IR_TIMING_CONTROL2 = 0x01c20384;    REG_PLAT_IR_TIMING_CONTROL3 = 0x232800e1;#if (IR_CODE_TYPE == HW_NEC)    REG_PLAT_IR_TIMING_CONTROL4 = 0x0040105a#if defined(CT909P_IC_SYSTEM) || defined(CT909G_IC_SYSTEM)    | (0x3 << 23)#endif    ;#else        REG_PLAT_IR_TIMING_CONTROL4 = 0x0060105a; #endif    #ifdef SUPPORT_GAME_IR    _blGameIRMode = FALSE;#endif}VOID    INPUT_SetIRInfo(PIR_INFO pIRInfo){    BYTE i;    if (pIRInfo->bIRMapSize > 255)    {#ifdef DEBUG_IR        printf("IR size is overflow.\n");#endif        return;    }    _IRInfo.bIR_Type = pIRInfo->bIR_Type;    _IRInfo.bCustomerCode = pIRInfo->bCustomerCode;    _IRInfo.bCustomerCode1 = pIRInfo->bCustomerCode1;    _IRInfo.aIRMap = pIRInfo->aIRMap;    _IRInfo.bIRMapSize = pIRInfo->bIRMapSize;    for (i = 0; i < 8; i++)    {        _bCustomerCode |= ( (pIRInfo->bCustomerCode>>i) & 1 ) << (7-i);        _bCustomerCode1 |= ( (pIRInfo->bCustomerCode1>>i) & 1 ) << (7-i);    }}PIR_INFO INPUT_GetIRInfo(){    return &_IRInfo;}#ifdef SUPPORT_GAME_IRVOID    INPUT_SetGameIR(VOID){    DWORD dwSaveInt;    HAL_DISABLE_INTERRUPTS( dwSaveInt );        // Disable INT to avoid different threads accessing    REG_PLAT_RESET_CONTROL_ENABLE = PLAT_RESET_IR_ENABLE;    REG_PLAT_RESET_CONTROL_DISABLE = PLAT_RESET_IR_DISABLE;    HAL_RESTORE_INTERRUPTS( dwSaveInt );        // Restore INT.    //IR control registers    REG_PLAT_IR_TIMING_CONTROL1 = 0x0FA0000A;    REG_PLAT_IR_TIMING_CONTROL2 = 0x00C80190;    REG_PLAT_IR_TIMING_CONTROL3 = 0x0A140064;    REG_PLAT_IR_TIMING_CONTROL4 = 0x0040103C    // port aron's code, 20070315#if defined(CT909P_IC_SYSTEM) || defined(CT909G_IC_SYSTEM)        | (0x3 << 23) // Set 32bits data mode#endif        ;    _blGameIRMode = TRUE;}BYTE INPUT_Game_RemoteScan(VOID){    static  BYTE    bGameIRstage = IR_STAGE_IDLE;    DWORD   dwData;    DWORD   dwRawCode;    BYTE    bIRINT;#if (PLATFORM == ECOS_OS)    dwData = __INTISRintProc12ndStatus.dwPLAT_IR_DATA;    dwRawCode = __INTISRintProc12ndStatus.dwPLAT_IR_RAW_CODE;#else    dwData = REG_PLAT_IR_DATA;    dwRawCode = REG_PLAT_IR_RAW_CODE;#endif//printf("dwData = %lx, dwRawCode = %lx\n", dwData, dwRawCode);        //Decide IR INT source        if ( (OS_GetSysTimer() - _dwTimeISRKeyPrev2) < COUNT_50_MSEC )        {                bIRINT = IR_INT_REPEAT;        }        else if ( !(dwData & 0x00000500) )        {                bIRINT = IR_INT_DATA;        }        else        {                bIRINT = IR_INT_INVALID;        }        if (IR_INT_INVALID != bIRINT)        {            if (( (BYTE)(dwRawCode>>24) == _bCustomerCode ) &&          // Custom code : 00 FF                ( (BYTE)(dwRawCode>>16) == _bCustomerCode1 ))            {                // Operation Key                __wISRGameKey = (WORD) ((~dwData) & 0x000000FF);            }            else if (( (BYTE)(dwRawCode>>24) == _bCustomerCode1 ) &&                     ( (BYTE)(dwRawCode>>16) == _bCustomerCode ))            {                // External Key                if (0x0 == (dwData & 0x000000FF))                {                    _ResetIR();                    bIRINT = IR_INT_INVALID;                }                else                {                    __wISRGameKey = 0x0001 << ((dwData & 0x000000FF) + 7);                }            }            else            {                bIRINT = IR_INT_INVALID;            }        }        //Read data        if ( bGameIRstage & IR_STAGE_IDLE)        {                if (bIRINT & IR_INT_DATA)       //data code                {                        bGameIRstage = IR_STAGE_DATA;                }                else //IR_INT_REPEAT/IR_INT_INVALID                {                        __wISRGameKey = 0xFFFF;                        //bGameIRstage remains unchanged                }        }        else // IR_STAGE_DATA/IR_STAGE_REPEAT        {                if (bIRINT & IR_INT_DATA) //data code                {                        //bGameIRstage remains unchanged                }                else if (bIRINT & IR_INT_REPEAT) //repeat code                {                        bGameIRstage = IR_INT_REPEAT;                }                else //IR_INT_INVALID                {                        __wISRGameKey = 0xFFFF;                        bGameIRstage = IR_STAGE_IDLE;                }        }    return KEY_NO_KEY;}#endif   // ifdef SUPPORT_GAME_IR// LLY2.36 create//  ********************************************************************************//  Function    :   INPUT_SetIRCheckMode//  Description :   Config IR key checking mode//  Arguments   :   bMode, specify the desired mode//  Return      :   None//  ********************************************************************************void    INPUT_SetIRCheckMode(BYTE bMode){// LLY2.38, keep IR working mode when power down.#ifdef  KEEP_IR_WORKING_MODE_WHEN_POWERDOWN    // Must change mode first, then enable IR_INT    _bIRCheckMode=IR_CHECK_MODE_INT;    REG_PLAT_PROC1_2ND_INT_MASK_DISABLE = INT_PROC1_2ND_IR; // enable IR interrupt#else   // #ifdef  KEEP_IR_WORKING_MODE_WHEN_POWERDOWN    if(bMode==IR_CHECK_MODE_INT) // interrupt mode    {        // Must change mode first, then enable IR_INT        _bIRCheckMode=IR_CHECK_MODE_INT;        REG_PLAT_PROC1_2ND_INT_MASK_DISABLE = INT_PROC1_2ND_IR; // enable IR interrupt    }    else    // Polling mode    {        // Must disable IR_INT first, then change mode        REG_PLAT_PROC1_2ND_INT_MASK_ENABLE = INT_PROC1_2ND_IR; //ddisable IR interrupt        _bIRCheckMode=IR_CHECK_MODE_POLLING;    }#endif  //  #ifdef  KEEP_IR_WORKING_MODE_WHEN_POWERDOWN}//  ********************************************************************************//  Function    :   INPUT_GetIRCheckMode//  Description :   Get current IR key checking mode//  Arguments   :   None//  Return      :   IR_CHECK_MODE_INT, interrupt mode//                  IR_CHECK_MODE_POLLING, polling mode//  ********************************************************************************BYTE    INPUT_GetIRCheckMode(void){    return _bIRCheckMode;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -