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

📄 mcu.c

📁 realtek LCD monitor, TV开发源代码
💻 C
字号:
//**********************************************************************************************************
//  The  Software  is  proprietary,  confidential,  and  valuable to Realtek Semiconductor
//  Corporation  ("Realtek").  All  rights, including but not limited  to  copyrights,
//  patents,  trademarks, trade secrets, mask work rights, and other similar rights and interests,
//  are reserved to Realtek. Without  prior  written  consent  from  Realtek,  copying, reproduction,
//  modification,  distribution,  or  otherwise  is strictly prohibited. The Software  shall  be
//  kept  strictly  in  confidence,  and  shall  not be  disclosed to or otherwise accessed by
//  any third party. @ <2003> - <2008>   The Software is provided "AS IS" without any warranty of any kind,
//  express, implied, statutory or otherwise.
//**********************************************************************************************************
//----------------------------------------------------------------------------------------------------
// ID Code      : Mcu.c No.0000
// Update Note  :
//----------------------------------------------------------------------------------------------------

#define __MCU__

#include  "Common\Header\Include.h"


#if(_MCU_TYPE == _REALTEK_EMBEDDED)

//--------------------------------------------------
// RTD Embeded MCU Initial
//--------------------------------------------------
void CMcuInitial(void)
{
    IE      = 0x00;                         // Disable all interrupts
    TMOD    = 0x11;                         // Program Timer0 & Timer1 to Mode#1
    TR0     = 0;                            // Stop Timer0
    TF0     = 0;                            // Clear Timer0 Overflow Bit
    TL0     = _TIMER0_COUNT_LBYTE;          // Load Timer0 low-byte   (for 1ms)
    TH0     = _TIMER0_COUNT_HBYTE;          // Load Timer0 high-byte  (for 1ms)
    TR1     = 0;                            // Stop Timer1
    TF1     = 0;                            // Clear Timer1 Overflow Bit
    IE      = 0x8a;                         // Enable interrupts of Timer0
    CKCON   = 0x00;

// V010 Patch Note (4) : Add the setting of Flash Write Protect.
    MCU_COMM_INST_EN_FF60   =0x42;
    MCU_COMM_OP_CODE_FF61 =0x05;
    MCU_COMM_INST_EN_FF60   =0x43;
    MCU_WREN_OP_CODE_FF62 = 0x06;

    pData[0] = MCU_COMM_INST_READ_P0_FF67;
    if((pData[0]&0x1C)!=0x1C)
    {
        MCU_COMM_INST_EN_FF60 = 0x68;
        MCU_COMM_OP_CODE_FF61 = 0x01;
        MCU_FLASH_PROG_ISP0_FF64 = 0x1C;
        MCU_COMM_INST_EN_FF60 = 0x69;
    }

//cyyeh 20080326 Setting lvds default current = 3.5mA , the ic default is 2.5mA!!
#if(_SCALER_TYPE == _RTD2472D)
    MCU_PIN_DRIV_CTRL11_FFA7 = 0x08;
#elif((_SCALER_TYPE == _RTD247xRD) || (_SCALER_TYPE == _RTD248xRD))
    CScalerPageSelect(_PAGE10);
    CScalerSetByte(_P10_PIN_DRIVING_CTRL0_B4,0x04);
#elif(_SCALER_TYPE == _RTD2545LR)
    CScalerPageSelect(_PAGEE);
    CScalerSetByte(_PE_PIN_DRIVING_CTRL10_D8, 0x20);
#else
    No Setting !!
#endif // End of #if(_SCALER_TYPE == _RTD2472D)


    MCU_DDCRAM_PART_FF21 = 0x16; //cyyeh 20080314 for ddc1 128,ddc2 256, ddc3 256

//cyyeh 20080217 for cec setting
    MCU_CEC_CR0_FFAB = 0x5f;

    MCU_WATCHDOG_TIMER_FFEA |= 0x80;    //enable wdt, V009_20080822
    MCU_WATCHDOG_TIMER_FFEA |= 0x40;    //clr wdt.
    MCU_CTRL_FFED           = 0x80;     //FlashDIV=1
#if(_EMBEDDED_EDID == _ON)
    MCU_ADC_DDC_ENA_FF1B = 0x02;
    MCU_DVI_DDC_ENA_FF1E = 0x02;
    MCU_HDMI_DDC_ENA_FF2C = 0x02;
#else
    MCU_ADC_DDC_ENA_FF1B = 0xe2;
#if(((_DDC_CHANNEL_FOR_D0 == _DDC2) && (_D0_INPUT_PORT_TYPE == _D0_DP_PORT)) ||((_DDC_CHANNEL_FOR_D1 == _DDC2) && (_D1_INPUT_PORT_TYPE == _D1_DP_PORT)))
    MCU_DVI_DDC_ENA_FF1E = 0x02;
    MCU_HDMI_DDC_ENA_FF2C = 0xe2;
#else
    MCU_DVI_DDC_ENA_FF1E = 0xe2;
    MCU_HDMI_DDC_ENA_FF2C = 0x02;
#endif
#endif

    MCU_BANK_SWITCH_CTRL_FFFC = 0x0b;   // enable global XFR (」 For Bank Switching System 」)
    MCU_BANK_START_FFFD     = 0x03;     //Xdata_Bstart
    MCU_BANK_SEL_FFFE       = 0x00;     //Xdata_bank_sel, Bank0
    MCU_CLOCK_CTRL_FFEE     |= 0x40;    // non-stop timer when spi flash access

#if(_FAST_READ == _ON)

    //   M2PLL Enable
    MCU_SCA_INF_CTRL_FFF3 = 0x20; //BWR data enable, Non_INC
    MCU_SCA_INF_ADDR_FFF4 = 0x9f; //DDC_addr
    MCU_SCA_INF_DATA_FFF5 = 0x01; //DDC_data, page-1
    MCU_SCA_INF_ADDR_FFF4 = 0xE0; //M2-PLL Reg Ctrl Address
    MCU_SCA_INF_DATA_FFF5 = 0x10; //Enable M code =18
    MCU_SCA_INF_ADDR_FFF4 = 0xE4; //M2-PLL Reg Ctrl Address
    MCU_SCA_INF_DATA_FFF5 = 0x01; //Enable P code= 2

    //  Power-saving mode Enable ?
    MCU_SCA_INF_ADDR_FFF4 = 0x01; //DDC_addr - Host Ctrl
    MCU_SCA_INF_DATA_FFF5 = 0x00; //DDC_data - Disable power-saving mode

    //  M2PLL output enable
    MCU_SCA_INF_ADDR_FFF4 = 0xE5; //M2-PLL Reg Ctrl Address
    MCU_SCA_INF_DATA_FFF5 = 0x09; //Enable M2PLL


    //  Enable FastRead mode
    MCU_CEN_CTRL_FF76 = ( ((0x3)<<4) | ((0x1)<<2) | ((0x1)<<0) );  //ChipEnable Timing Setup

#if (_TURBO_MODE==_ON)
    MCU_FAST_READ_OP_CODE_FF6B = 0x3B;  //Fast Dual data read for winbond flash only
    MCU_READ_INSTRUCTION_FF6C |= ( ((0x2)<<6) | ((0x1)<<5) | ((0x0)<<4) | ((0x0)<<2) | ((0x0)<<0) ); //Fast Read mode, DI@half cycle, Dout@one cycle
#else
    MCU_FAST_READ_OP_CODE_FF6B = 0x0B;  //Fast Read for all kind of flash
    MCU_READ_INSTRUCTION_FF6C |= ( ((0x1)<<6) | ((0x1)<<5) | ((0x0)<<4) | ((0x0)<<2) | ((0x0)<<0) ); //Fast Read mode, DI@half cycle, Dout@one cycle
#endif // End of #if (_TURBO_MODE==_ON)

//  CMcuSelectFlashClk(_FLASH_CLK);

#endif // End of #if(_FAST_READ == _ON)



// GPIO Control By PCB Type
#if(_PCB_TYPE == _RTD2482D_QISDA_PCB)

    MCU_PWM_CK_SEL_FF3A = 0x03;  // PWM0(backlight) ,PWM1(volume),PLL output
    MCU_PWM03_M_FF3B = 0x03;     // PWM0 M=3 , PWM1 M=0, first stage Divider [1:0]
    MCU_PWM01_N_MSB_FF3D=0x00;      // PWM0 ,PWM1 second stage Divider MSB [11:8]
    //200Hz
#if((_PROJECT==_VK246H) || (_PROJECT==_VW246H) || (_PROJECT==_G2410HD)|| (_PROJECT==_W2408))
    MCU_PWM0_N_LSB_FF3E=0x24;       // PWM0 second stage Divider LSB [7:0]
#elif((_PROJECT==_VH226H) || (_PROJECT == _V2400HD))
    MCU_PWM0_N_LSB_FF3E=0x2B;       // PWM0 second stage Divider LSB [7:0]
#else
    No Setting !!
#endif

    MCU_PWM1_N_LSB_FF3F         = 0x00; // PWM1 second stage Divider LSB [7:0]
    MCU_PWM_VS_CTRL_FF47        = 0x00; // Disable PWM0 PWM1 reset by DVS
    MCU_PWM_EN_FF48             = 0x03; // PWM0 PWM1 output Enable
    MCU_PWM_CK_FF49             = 0x03; // PWM0 PWM1 second stage output
    MCU_PIN_SHARE_CTRL0F_FFA3   = 0x80;
    MCU_PIN_SHARE_CTRL0A_FF9E   = 0x58;
    MCU_PIN_SHARE_CTRL0B_FF9F   = 0x7A;
    MCU_PIN_SHARE_CTRL10_FFA4   = 0x20;
    MCU_PIN_SHARE_CTRL11_FFA5   = 0x20;
    MCU_PORT_READ_CTRL_FFC0     = 0xfd; //read All GPIO value from bus,except p3
    bEEPROM_WRITE_PROTECT       = _HIGH;

#endif // End of #if((_PCB_TYPE == _RTD2482D_QISDA_PCB))

}

//--------------------------------------------------
// RTD Embeded MCU Setting
//--------------------------------------------------
#if(_FAST_READ == _ON)

void CMcuFlashClkDiv(BYTE clkdiv) // _FlashClkDiv(x=0-15): SPI Flash Clock Generator (OSC/PLL埃

⌨️ 快捷键说明

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