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

📄 iop_8202r.c

📁 IOP
💻 C
字号:
/**************************************************************************
 *                                                                        *
 *         Copyright (c) 2002 by Sunplus Technology Co., Ltd.             *
 *                                                                        *
 *  This software is copyrighted by and is the property of Sunplus        *
 *  Technology Co., Ltd. All rights are reserved by Sunplus Technology    *
 *  Co., Ltd. This software may only be used in accordance with the       *
 *  corresponding license agreement. Any unauthorized use, duplication,   *
 *  distribution, or disclosure of this software is expressly forbidden.  *
 *                                                                        *
 *  This Copyright notice MUST not be removed or modified without prior   *
 *  written consent of Sunplus Technology Co., Ltd.                       *
 *                                                                        *
 *  Sunplus Technology Co., Ltd. reserves the right to modify this        *
 *  software without notice.                                              *
 *                                                                        *
 *  Sunplus Technology Co., Ltd.                                          *
 *  19, Innovation First Road, Science-Based Industrial Park,             *
 *  Hsin-Chu, Taiwan, R.O.C.                                              *
 **************************************************************************/
/*--------------------------------------------------------------------------
|  File Name   : iop.c
|
|  Description : This file main contains three parts.
|                1. Include 8200 and 8202 iop normal play inc.
|                2. Include iop normal and standby reset function.
|                3. Include I2C(24C02) read and write function.
|
|  Version    :  0.1  
| 
| 
|  Rev  Date            Author(s)      Status & Comments
|---------------------------------------------------------------------------------
|       2004/12/20        Lijd           Updating
|       2006/04/06        Terry          Creat
|--------------------------------------------------------------------------------*/
#define IOP_RESET() (regs0->iop_control = IOPHW_RESET)
#define IOP_GO()    (regs0->iop_control = 0)


#ifdef SOFT_UART_OUT 
    int PutSoftUartChar(BYTE *,int);
    int GetSoftUartChar(BYTE *,int);    
    BYTE bResetIop=0;       
#endif  

BYTE bSleepFlag = 0; // keep standby mode flag

extern const BYTE ir_mapcode[256];
extern const BYTE vfd_keycode[40];

extern void LoadModual(UINT16);

/**************************************************************************
 *  Function Name: void reset_iop(void)                                   *
 *  Purposes:                                                             *
 *              Reset iop for normal / standby mode.                      *
 *  Descriptions:                                                         *
 *              This function contains three parts                        *   
 *              1.   reset iop                                            *
 *              2.   Set I2C,VFD,IR,GAME GPIOS for iop use.               *
 *                   if system is coming into standby mode. then pass     *
 *                   the IR or VFD power key value and flag to reset code.*
 *              3.   LoadModual(MODUAL_IOP_RESET) /LoadModual(MODUAL_IOP) *
 *  Arguments:                                                            *
 *              (None)                                                    *
 *  Returns:                                                              *
 *              (None)                                                    *
 *  See also:                                                             *
 *              (None)                                                    *
 **************************************************************************/

void reset_iop(void)
{
    int     i;
   
    // reset iop
    IOP_RESET();

//=========================== I2C =============================

#ifdef I2C_SHARE_WITH_GPIO
#ifdef PORTABLE_DVD
    #ifdef IC_8202R
    GPIO_M_SET(21,0);        //I2C_DATA
    GPIO_M_SET(20,0);        //I2C_CLK
    #else
    GPIO_M_SET(11,0);        //I2C_DATA
    GPIO_M_SET(10,0);        //I2C_CLK
    #endif
#else
    GPIO_M_SET(21,0);        //I2C_DATA
    GPIO_M_SET(20,0);        //I2C_CLK
#endif
#endif


//========================== GAME PAD ============================
#if defined(SUPPORT_NESGAME)||defined(SUPPORT_SPG_GAME) || defined(SUPPORT_GAMEPAD_MOUSE)
#ifndef SUPPORT_IR_GAME
    #if defined(GAME_GPIO_INTERFACE_TYPE2)//16m sdram default use
        regs0->gpio_master[27 / 16] &= ~(0x1 << (27 % 16)); //D1    gpio 27 (M_BA1)
        regs0->gpio_master[29 / 16] &= ~(0x1 << (29 % 16)); //D0    gpio 29 (M_A11)
        regs0->gpio_master[20 / 16] &= ~(0x1 << (20 % 16)); //LATCH gpio 20 (VFD_STB)        
        regs0->gpio_master[21 / 16] &= ~(0x1 << (21 % 16)); //CLK   gpio 21 (VFD_DATA)
    #elif defined(GAME_GPIO_INTERFACE_TYPE1)//64m sdram default use
        regs0->gpio_master[10 / 16] &= ~(0x1 << (10 % 16)); //D1    gpio 10 (M_DQM3)
        regs0->gpio_master[29 / 16] &= ~(0x1 << (29 % 16)); //D0    gpio 29 (M_DQM2)
        regs0->gpio_master[20 / 16] &= ~(0x1 << (20 % 16)); //LATCH gpio 20 (VFD_STB)        
        regs0->gpio_master[21 / 16] &= ~(0x1 << (21 % 16)); //CLK   gpio 32 (VFD_DATA)    
    #elif defined(SDRAM_32Mb_Mode)
        #ifdef SDRAM_32Mb_One_Chip
        regs0->gpio_master[ 7 / 16] &= ~(0x1 << ( 7 % 16)); //D1    gpio 7 (M_DQM3)
        regs0->gpio_master[21 / 16] &= ~(0x1 << (21 % 16)); //D0    gpio 21 (M_DQM2)
        regs0->gpio_master[ 6 / 16] &= ~(0x1 << ( 6 % 16)); //LATCH gpio 6 (VFD_STB)        
        regs0->gpio_master[ 4 / 16] &= ~(0x1 << ( 4 % 16)); //CLK   gpio 4 (VFD_DATA)   
        #elif defined(SDRAM_32Mb_Two_Chip) //!SDRAM_32Mb_One_Chip, SDRAM_32Mb_Two_Chip defined
    #error "Please fill in goip registers in reset iop, thanks."
        #else  //neither SDRAM_32Mb_One_Chip nor SDRAM_32Mb_Two_Chip..
    #error "Please check GPIO 8202L setting."
        #endif  //one or two chip setting
    #else
    //#error "8bit game enabled but SDRAM configuration not specified, pliz check reset_iop"
    #endif
#endif  //SUPPORT_IR_GAME
#endif  //SUPPORT_NESGAME

//============================ IR ==============================

    GPIO_M_SET(19,0);        //GPIO 19 as IR on 8202R 

//============================ VFD ==============================

#ifndef SUPPORT_VFD
    GPIO_M_SET(16,0);       //VFD_CLK GPIO 16
    GPIO_M_SET(17,0);       //VFD_STB GPIO 17
    GPIO_M_SET(18,0);       //VFD_DATA GPIO 18
#endif

    
    // reset IOP/RISC interface
    for (i = 0; i < 7; i++) regs0->iop_data[i] = 0;

// below registers' value are used only for first time gotten by IOP
// regs0->iop_data[1]: in standby mode or not (1:Y, 0:N)
// regs0->iop_data[2]: store IR power key value
// regs0->iop_data[3]: store VFD power key value
// regs0->iop_data[4]: IR power key exist or not
// regs0->iop_data[5]: VFD power key exist or not
//
    if (bSleepFlag)
    {
        BYTE nIndex, bVFD_MASK, nIndex2 = 0;

        regs0->iop_data[1] = 1;
        // get IR code
        for (nIndex = 0; nIndex <= 255; nIndex++)
        {
            if (ir_mapcode[nIndex] == IRC_POWER)
            {
                regs0->iop_data[4] = 1;
                nIndex2 = nIndex;
                break;
            }
        }

#if   defined(IR_NEC)||defined(IR_M50560)||defined(IR_AS1213)||defined(IR_ORITRON)||defined(IR_THOMSON_ANGUS)||defined(IR_MRC2222)
        nIndex = reverse_fun(nIndex);
#endif
        regs0->iop_data[2] = nIndex;
        printf("IR IRC_POWER = %d\n", nIndex); 


#if (VFD_DRIVER == HT1621)||defined(SUPPORT_EX_IR) // Robert 031024
        //if vfd driver is HT1621, we check another IR power key.
        for (nIndex = nIndex2 + 1; nIndex <= 255; nIndex++)
        {
            if (ir_mapcode[nIndex] == IRC_POWER)
            {
                regs0->iop_data[5] = 1;
                break;
            }
        }

        #if defined (IR_NEC)||defined(IR_MRC2222)

        nIndex = reverse_fun(nIndex);
        #endif
        regs0->iop_data[3] = nIndex;
        printf("IR IRC_POWER 2 = %d\n", nIndex); 

#else // (VFD_DRIVER == HT1621)
        // get VFD code

        #ifdef SUPPORT_VFD//nono 2003-11-24 12:06
        for (nIndex = 0; nIndex < 40; nIndex++)
        {
            #ifdef QISHENG_DVD
            if (vfd_keycode[nIndex] == IRC_STOP)
            #elif defined(GBM_POWER_ON_USE_EJECT_KEY)       //gerry add it for eject,04-1-28 17:39
            if (vfd_keycode[nIndex] == IRC_EJECT)
            #elif defined(GBM_POWER_ON_USE_PAUSEPLAY_KEY)       //gerry add it for pauseplay,04-1-28 17:39
            if (vfd_keycode[nIndex] == IRC_PAUSEPLAY)
            #else
            if (vfd_keycode[nIndex] == IRC_POWER)
            #endif          
            {
                regs0->iop_data[5] = 1;
                nIndex++;
                break;
            }
        }
        #endif//SUPPORT_VFD

        #if (VFD_DRIVER == SPL10)
        regs0->iop_data[3]=nIndex;//2004-2-9 12:48 LIJD
        #else
        if(nIndex==40)
        {
            regs0->iop_data[3] =0x0f;
        }
        else if(nIndex==8)
        {
            regs0->iop_data[3] =0x80;
        }
        else if(nIndex==16)
        {
            regs0->iop_data[3] =0x180;
        }
        else if(nIndex==24)
        {
            regs0->iop_data[3] =0x280;
        }
        else if(nIndex==32)
        {
            regs0->iop_data[3] =0x380;
        }
        else
        {       
            bVFD_MASK = nIndex % 8;
            bVFD_MASK = 1 << (bVFD_MASK - 1);
            nIndex = nIndex / 8;
            regs0->iop_data[3] = nIndex;
            regs0->iop_data[3] <<= 8;
            regs0->iop_data[3] |= bVFD_MASK;
        }
        #endif
        printf("VFD IRC_POWER = %x\n", regs0->iop_data[3]);
#endif // (VFD_DRIVER == HT1621)


#ifdef TCL_STANDBY
        regs0->sft_cfg1 &= ~(0x1 << 3);//gpio 3 enable
        regs0->gpio_master[ 3/16 ] &= ~(0x1 << (3%16));//gpio 3 for iop
        regs0->gpio_master[ 2/16 ] &= ~(0x1 << (2%16));//gpio 2 for iop
#endif
       
#ifdef RISC_ALIVE_STANDBY       
    #ifdef VIDEO_IN_CONTROL
    if(AVin_step == 0x0f)
	{
	  AVin_step = 0;
	  go_into_prestandby = 1;
	}
	#endif    
#elif defined(ALONE_GPIO_KEY)//Jack 20040930
        GPIO_M_SET(STANDBY_KEY_GPIO,0);
        GPIO_M_SET(STANDBY_LED_GPIO,0);
        GPIO_M_SET(EJECT_KEY_GPIO,0);
        GPIO_M_SET(STOP_EJECT_KEY_GPIO,0);
        GPIO_M_SET(BACKWARD_KEY_GPIO,0);
        GPIO_M_SET(FORWARD_KEY_GPIO,0);
        GPIO_M_SET(44,0);
#endif //endif #ifdef RISC_ALIVE_STANDBY
        
       #ifdef AD_HL_USE 
        GPIO_M_SET(12,1);  //lxg add for led display error when power off
       #endif
        LoadModual(MODUAL_IOP_RESET);
        printf("iop modual: iop standby mode\n"); //terry,2005/4/4 03:18

⌨️ 快捷键说明

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