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

📄 initial.c

📁 车载电子影音系统dvd播放系统原程序代码
💻 C
📖 第 1 页 / 共 5 页
字号:
//  Function    :   INITIAL_uProcessor
//  Description :   The initalization of uProcessor; Set IRQ and Timer
//  Arguments   :   NONE
//  Return      :   NONE
//  Side Effect :   After the function, will enable Interrupt...
//  *********************************************************************
void INITIAL_uProcessor(void)
{
#ifdef  SYSTEM_8051
    // Interrupt Enable Register.
    IE = 0x01 ;
    EX0= 1;     // for IR
    EX1= 0;
#ifdef SUPPORT_PORTABLE_PROJECT
   EIE |= 0x04;   // EX4INT    // Added for portable, KCHong, 20031117
#endif        
    // Chuan0.84p, SW IR use EX5 IR, Temporal solution
#if !defined(W99132_IR)
    EX0= 0;     // for IR
    EIE|=0x08;  // EX5INT
    T2MOD |= 0x80; //LJY0.83b-3, auto clear EX5INT flag.
#endif
           /*   0  EA        0x80 :enable all.      0x0: disable all
                0  Reverved
                0  ET2       0x20 :enable Timer2.   0x0: disable.
                0  ES        0x10 :enable Serial.   0x0: disable.
                0  ET1       0x08 :enable Timer1.   0x0: disable.
                1  EX1       0x04 :enable External1. 0x0: disable.
                0  ET0       0x02 :enable Timer0.   0x0: disable.
                0  EX0       0x01 :enable External0. 0x0: disable.
           */

    // Interrupt Priority Register.
    IP   = 0x00 ;
          /*    0 Reserved
                0 Reserved
                0 PT2       0x20 :Timer2 priotity 1   0: priotity 0
                0 PS        0x10 :Serial priority 1   0: priority 0
                0 PT1       0x08 :Timer1 priority 1   0: priority 0
                1 PX1       0x04 :Exter1 priority 1   0: priority 0
                0 PT0       0x02 :Timer0 priority 1   0: priority 0
                0 PX0       0x01 :Exter0 priority 1   0: priority 0
          */

    // trigger condition
    // Chuan0.84p, HW IR need use low level trigger, Lihung check now.
    // Micky0.95, 908AC can use edge trigger.
    IT0=1;          /* falling edge trigger */      //EX0
    IT1=1;          /* falling edge trigger */      //EX1

    // Set timer relative register
    _SetTimer ();

    // Set IR relative register
#ifdef  W99132_IR
    CPU132_InitIR ();
#endif  // #ifdef W99132_IR

    // brian.276-4th, Initialize Watchdog relative register
    // Must check if disable "watchdog" while enable serail-debug mode
    // wyc1.11a, support watch dog
    // Brian1.10-3, BE vesrion support Watchdog
    // And we use SUPPORT_WATCHDOG to enable it. 
    // but we usually don't enable Watchdog when: 
    // [1] serial debug, for some long time operation like dump DRAM, Auto-upgrade
    //     may cause Watchdog timer time out, unless it will update __dwProgressCount in the loop
    // [2] debug mode, we may want to keep the state as it is when something wrong, so we don't enable watchdog

#ifdef SUPPORT_WATCHDOG
    CKCON |= 0xC0;  // 2^26, about 2 sec on 33.25M Turbo51 ==> (2^26)/33250000
    TIMED_ACCESS();
    WTCON = 0x03;
#endif // #ifdef SUPPORT_WATCHDOG


    //Initialize serial-debug relative register for setting baud rate
#ifdef SERIAL_DEBUG
    //SYSDEBUG_Init();
    SCON=0x50;      //Mode1
    T2CON=0x30;     //Enable mode1 and mode 3 for Timer2
    RCAP2H=R2HV;    //set baud rate
    RCAP2L=R2LV;    //set baud rate
    TR2=1;          //Enable Timer 2
    ES = 1;         //Enable serial port interrupt
    TI = 0;         //The flag for Tx
    IP = 0x10;      //Set the interrupt of serial port as high priority
#endif  // #ifdef SERIAL_DEBUG

// wyc.278-3, initial time2 relative register for volume adjustment button
#ifdef  ENABLE_PANEL_VOLUME_ADJUSTMENT_BUTTON
    TH2=0;
    TL2=0;
    RCAP2H=0;
    RCAP2L=0;

    C_T2=0;
    BGEN=1;
    CP_RL2=0;
    ET2=1;
    TR2=0;
#endif  // #ifdef ENABLE_PANEL_VOLUME_ADJUSTMENT_BUTTON

    ///* enable interrupt */
    EA  = 1;

#endif  // #ifdef SYSTEM_8051
    return;
}

//  *********************************************************************
//  Function    :   INITIAL_CheckServo
//  Description :   Check the SERVO. Decide which kind of title that puts in Drive
//  Arguments   :   NONE
//  Return      :   ERR_NOERR
//  Side Effect :
//  *********************************************************************
WORD INITIAL_CheckServo(void)
{

    // ** S-TCH; first suppose no disc in SERVO
    __wDiscType= NO_DISC_IN_DRIVE;

    // Micky1.05-2, Fix Loading-> Setup-> exit setup-> will detect as wrong disc
    // must clear __bDiscInfo for each title detection.
    __bDiscInfo= DISCINFO_NONE;

    // check if Drive is OPEN ot CLOSE
    if ( __btDriveOpen )
    {
        // wyc.172r, remove this code for not doing close command twice to avoid the result of mode select command to make 
        // DVD title detection fail.
        // wyc.273-1, make __bCloseCommand =1 when close by extra force.
        //CDINFO_CloseTray ( TRUE );
        extern BYTE __bCloseCommand ;
        __bCloseCommand = TRUE;
        __btDriveOpen= FALSE;
    }
//LJY2.37, port KCHong's code
#ifdef SUPPORT_TOPLOADING // hwtan1.11e for portable  for fuss 0419

    if(__bTopOpen) //Do not show "loading" when tray cover open

        {

        OSD_OUTPUT_MACRO(MSG_OPEN, TRUE, 0XFF);

        }

        else

#endif  //  for fuss 0419
    OSD_OUTPUT_MACRO ( MSG_WAITING, NULL, 0xFF );

#ifdef  SERVO_AUTO_SPINUP   // ** TCH0.361;
    //For some loader, it spins up itself after "power on" or "close tray"
    //and in the period of time, any command from MPEG F/W  is ignored.
    //So F/W must wait for moments until servo is more stable.
    __dwCheckTime= 35;      // Wait 3.5 seconds
    while( __dwCheckTime)
    {
        UTL_DelayTime (COUNT_100_MSEC, TRUE);
        __dwCheckTime--;
    }
#endif  // #ifdef  SERVO_AUTO_SPINUP

    __dwTimeTorelence = 0;

    // Check the exist of CD-Drive
    if ( CDINFO_CheckStatus ( NO_DISC_IN_DRIVE ) )
    {
        //LJY1.05-2, the below code was moved to CDINFO.C.
        //LJY1.05, stop loader for wrong disc or no disc
        // Micky1.05-2, Fix Loading-> Setup-> exit setup-> servo won't run.
        // How to wake up from POWER_STOP?
//        SERVO_PowerMode (SERVO_POWER_STOP) ;
//        SERVO_Stop ();
        // wyc1.25, add one variable to record flow when detected as wrong disc for debug usage,
        __bTestFlow |= 0x1;
    }
    else
    {
        _Check_CDROMStatus ();  // ** S-TCH; really check title
    }

    //LJY1.21, use UTL_QueryCapability() instead of "if ( ( __bISRKey == KEY_OPEN_CLOSE ) || (__bISRKey==KEY_POWER) ) return ERR_NOERR;"
    if (  UTL_QueryCapability ( QUERY_ABORT_MAINFLOW )  )
        return TRUE;
       

    _INITIAL_gcShowStatus(TRUE);

    if ( __wDiscType == NO_DISC_IN_DRIVE )
    {
// DVD_172Micky, FLOW_CONTROL begin
        // Assume the no disc is interruptted(WaitStable) by SETUP,
        // just go ahead do the SETUP, don't need show no_disc too.
        // but need re-checking disc after exit setup.
#ifdef  SUPPORT_LOADING_SETUP
        if (__bISRKey == KEY_SETUP)
        {
            __bFlowState |= FLOW_RELEASE_DETECTION;
            return ERR_NOERR;
        }
#endif  //#ifdef  SUPPORT_LOADING_SETUP
        // else really no disc.
// DVD_172Micky, FLOW_CONTROL end

        // Micky1.10, must clear all trigger state when no disc or invalid disc
        // Ex. FLOW_KEEP_RESUME/FLOW_RELEASE_DETECTION-> power on->
        // encouner title detection error or no disc
        __bFlowState = FLOW_NORMAL;

        __bTemp= 0xFF;
    }
    else
    {
        __bTemp= 3;
    }

    // LLY.161, let DISCTYPE info display later while CDDA title
    // DVD_170Micky, must show abnormal disc for encrypt disc.
    // now CD-DA disc type will be shown later, as need distinguish CDDA or DTS CDDA
// DVD_172Micky, FLOW_CONTROL begin
    // show disctype except for CD-DA, as need distinguish CDDA or DTS.
    if ( !(__wDiscType & BOOK_CDDA) )
    {
        // if unplayable bit is set(unrecoganize/invalid region code...)
        // don't show MSG_DISCTYPE, show ABNORMAL_DISC
        if (__bDiscInfo & DISCINFO_UNPLAYABLE)
        {
            OSD_OUTPUT_MACRO(MSG_ABNORMAL_DISC, __bDiscInfo, 0xff);

            // Micky1.10, must clear all trigger state when no disc or invalid disc
            // Ex. FLOW_KEEP_RESUME/FLOW_RELEASE_DETECTION-> power on->
            // encouner title detection error or no disc
            __bFlowState = FLOW_NORMAL;
            //LJY1.25, fix MP3 erroneous playback when it detects wrong disc.
			   // Micky1.25-2, can't clear DVD when region code error
            if ( !(__wDiscType & BOOK_DVD) )
                __wDiscType = BOOK_UNKNOW;            
        }
        else
        {
            // wyc.277-1_CDROM_OSD
            if (__wDiscType & BOOK_M1)
                UTL_DelayTime(COUNT_500_MSEC, 1);
            OSD_OUTPUT_MACRO (MSG_DISCTYPE, __wDiscType, __bTemp );
        }
    }
// DVD_172Micky, FLOW_CONTROL end

    HAL_SetDiscType(__wDiscType);

    //LLY.049, set correct A/V buffer size while playing MP3 w/ LOGO, ie.
    //nobody will set it in original control
    W99AV_InitialVideo();

    // LLY.161, display DISCTYPE info after get real CDDA format: pure/DTS
    if(__wDiscType & BOOK_CDDA)
    {
        // LLY.161-2, must give the parameter
        UTL_GetCDDAFormat(UTL_GETCDDAFORMAT_INITIAL);
        OSD_OUTPUT_MACRO (MSG_DISCTYPE, __wDiscType, 0x3 );
    }

    // Micky1.24-3, fix CD/ JVC-CDDA power on resume don't work
    // still don't lnow the real issue.
    if (( __bFlowState & FLOW_KEEP_RESUME ))
	{
    	extern BYTE gbServoRunning;
		if (__wDiscType & BOOK_VCD)
            SERVO_ReadSectors(__dwResumeTime, 0xFFFFFFFF);
		gbServoRunning=FALSE;
	}

#ifdef  SUPPORT_DVD_T  //Kevin1.24aDVD_T, DVD_T no delay to save resume time
    if (!__bReduceSTBtoDVDtime)
#endif
    // LLY.161, it's unnecessary because there are action have been inserted
    // f/w 0.47, let DiscType can display longer
    UTL_DelayTime ( (WORD)COUNT_1_SEC, FALSE );

#ifdef  SUPPORT_DVD_T     
    __bReduceSTBtoDVDtime = FALSE;    //Kevin1.24aDVD_T, clear __bReduceSTBtoDVDtime at last use
#endif   

    // Show LOGO for play CD-DA disc
    if (__wDiscType & BOOK_CDDA)
    {
        OSD_Output (MSG_LOGO, NULL, 0xff);
    }

#ifndef NO_MP3
    // LLY.274p-3, re-think the procedure to prepare 1st Menu Mode:
    // [1] Kodak Picture CD : don't enter Menu Mode
    // [2] MP3/ MP3+JPG/ JPG : enter Menu Mode
    if( !(__bDiscInfo & DISCINFO_UNPLAYABLE) && (__wDiscType & CDROM_M1) ) // playable CDROM title
    {
        // LLY0.84, do File Manager initial action for all CDROM title
        // It will handle if enter menu or not by itself.
        FM_Initial();

		//Kevin2.31, 908 doesn't need to pre-decode MP3
		/*
        if( !(__wDiscType & CDROM_PICTURECD) ) // Non-Kodak Picture CD
        {
            // LLY.275a, fix "water.noise" for MP3 while H/W power on
            UTL_CheckPlayItemMode(0x1);
            if(__bAttrPlayNew==ATTR_MP3
//Alex1.10, 20031105 System will support MP2 format audio
            || (__bAttrPlayNew == ATTR_MP2)
                )
            {
                UTL_SetPlayMode(MODE_PLAYAUDIO);
                W99AV_Command1(COMMAND_PLAY, NULL);
                UTL_GetPlayRange(0x1);
                UTL_PlayFromTime(__dwTimeBegin);
                _dwINITIALTemp=UTL_GetSysTimer();
                while( (UTL_GetSysTimer()-_dwINITIALTemp) < COUNT_500_MSEC)
                {
                    SERVO_Monitor();
                    if(HAL_Monitor(HAL_MONITOR_AUDIO_FREQ))
                    {
                        // DSP start decoding audio stream
                        break;
                    }
                }
                // LLY2.79, let it go the same flow of KEY_NEXT while playing MP3 title
                // And, Close CDIF & Reset Audio action will be done within CC_KeyCommand(KEY_STOP)
                // Fix, no audio output for MP2 bitstream as 1st song within MP3 title (XQ report)
                //HAL_ControlCDIF(HAL_CDIF_CLOSE);
                //HAL_Reset(HAL_RESET_AUDIO);
                CC_KeyCommand(KEY_STOP);
            }
        }
		*/

    }
#endif  // #ifndef NO_MP3

    return ERR_NOERR;
}

//  *********************************************************************
//  Function    :   _INITIAL_gcShowStatus
//  Description :   Prepare the ALL data for OSD/PANEL module
//  Arguments   :   bFlag   : TRUE means will sends MSG_STOPWAIT to PANEL module
//  Return      :   NONE
//  Side Effect :
//  *********************************************************************
void _INITIAL_gcShowStatus(BYTE bFlag)
{
    STATUS StatusInfo;
    extern BYTE __bSurround;        // Record Surround kind
    extern char __bEchoLevel;       // Record the echo level

⌨️ 快捷键说明

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