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

📄 avsys.c

📁 车载电子影音系统dvd播放系统原程序代码
💻 C
📖 第 1 页 / 共 4 页
字号:
                }
            }
        }
        // [2] Update PANEL info.
        PANEL_Output(MSG_STATION, NULL);

        // [3] Program tuner IC by specify band & frequency
        //     Then, return the status.
        __bTemp = bAction & 0xF0; // first, get manaul/ auto scan action info.
        __bTemp |= __StationInfo->bBand; // then, merge band info.
        return CHIPS_ProgramTuner(__bTemp);
    }
    else  // down tuning
    {
        // LLY2.78b, re-adjust the next frequency calculation procedure
        // Step 1: check if current frequency stay at maximum
        // Step 2: check if current frequency is valid (gap boundary)
        // Step 3: decrease the frequency to match valid frequency
        // Step 4: check if underflow
        if(__StationInfo->bBand==BAND_FM)  // FM mode
        {
            // [1.1] If current frequency stay at minimum value
            if(__StationInfo->wFreq[BAND_FM] == MIN_FM_FREQ)
            {
                // reset to maximum frequency
                __StationInfo->wFreq[BAND_FM] = MAX_FM_FREQ;
            }
            else // must decrease frequency for others
            {
                // [1.2] Check if current frequency is valid (gap boundary)
                __bTemp=(BYTE)(__StationInfo->wFreq[BAND_FM]%FM_GAP_PER_TUNING);

                // [1.3] Decrease frequency to match valid frequency
                if(__bTemp) // not gap boundary
                {
                    __StationInfo->wFreq[BAND_FM] -= __bTemp;
                }
                else
                {
                    __StationInfo->wFreq[BAND_FM] -= FM_GAP_PER_TUNING;
                }

                // [1.4] Check if the frequency is underflow
                if(__StationInfo->wFreq[BAND_FM] < MIN_FM_FREQ)
                {
                    // stay at minimum frequency
                    __StationInfo->wFreq[BAND_FM] = MIN_FM_FREQ;
                }
            }
        }
        else    // AM mode
        {
            // [1.1] If current frequency stay at minimum value
            if(__StationInfo->wFreq[BAND_AM] == MIN_AM_FREQ)
            {
                // reset to maximum frequency
                __StationInfo->wFreq[BAND_AM] = MAX_AM_FREQ;
            }
            else // must decrease frequency for others
            {
                // [1.2] Check if current frequency is valid (gap boundary)
                __bTemp=(BYTE)(__StationInfo->wFreq[BAND_AM]%AM_GAP_PER_TUNING);

                // [1.3] Decrease frequency to match valid value
                if(__bTemp) // not gap boundary
                {
                    __StationInfo->wFreq[BAND_AM] -= __bTemp;
                }
                else
                {
                    __StationInfo->wFreq[BAND_AM] -= AM_GAP_PER_TUNING;
                }

                // [1.4] Check if the frequency is underflow
                if(__StationInfo->wFreq[BAND_AM] < MIN_AM_FREQ)
                {
                    // stay at minimum frequency
                    __StationInfo->wFreq[BAND_AM] = MIN_AM_FREQ;
                }
            }
        }

        // [2] Update PANEL info.
        PANEL_Output(MSG_STATION, NULL);

        // [3] Program tuner IC by specify band & frequency
        //     Then, return the status.
        __bTemp = bAction & 0xF0; // first, get manaul/ auto scan action info.
        __bTemp |= __StationInfo->bBand; // then, merge band info.
        return CHIPS_ProgramTuner(__bTemp);
    }


#endif  // #ifndef NO_TUNER
    return  STATION_UNLOCK;
}


//  *************************************************************************
//  Function    :   _TUNER_AutoScan
//  Description :   Enable/ Disable auto-scan feature, ex __bTunerMode
//  Argument    :   bAction, specify the enable or disable action
//  Return      :   None
//  Side Effect :   __bTunerMode will be modified
//  *************************************************************************
void _TUNER_AutoScan(BYTE bAction)
{
#ifndef NO_TUNER
    if(bAction==DISABLE_AUTO_SCAN) // disable auto-scan mode
    {
        // LLY2.78b, must disable auto-scan & search scan mode together
        //__bTunerMode &= ~ TUNER_MODE_AUTO_SCAN;
        __bTunerMode &= ~ TUNER_MODE_SEARCH_SCAN;

        // clear up/down scan mode
        __bTunerMode &= 0xF0;
    }
    else // enable auto-scan mode
    {
        __bTunerMode |= TUNER_MODE_AUTO_SCAN;
        // merge up/down scan action
        __bTunerMode |= bAction;
    }

#endif  // #ifndef NO_TUNER
}


//  *************************************************************************
//  Function    :   _TUNER_Output
//  Description :   Output the same info. while calling PANEL_Output()
//                  Only for debug usage in 8051/ DOS environment
//  Argument    :   bMessage, the desired message type
//                  wParam, the desired message parameter
//  Return      :   None
//  Side Effect :
//  *************************************************************************
#ifdef  TUNER_DEBUG_MODE
void _TUNER_Output(BYTE bMessage, WORD wParam)
{
    switch(bMessage)
    {
    case    MSG_STATION:
        if(__StationInfo->bBand==BAND_FM)
            strcpy(__bMsgString, "FM");
        else
            strcpy(__bMsgString, "AM");
        OSD_Output(MSG_STRING, 0, 0x1);
        UTL_DelayTime((WORD)COUNT_1_SEC, FALSE);
        OSD_Output(MSG_VERSION, __StationInfo->wFreq[__StationInfo->bBand], 0x1);
        UTL_DelayTime((WORD)COUNT_1_SEC, FALSE);
        break;

    case    MSG_MEMORY:
        if(wParam==INITIAL_MSG)
        {
            strcpy(__bMsgString, "MEMORY");
            OSD_Output(MSG_STRING, 0, 0xFF);
        }
        else if(wParam==CLEAR_MSG)
        {
            OSD_Output(MSG_STRING, 0, 0x0);
        }
        else
        {
            if(__StationInfo->bBand==BAND_FM)
                strcpy(__bMsgString, "FM");
            else
                strcpy(__bMsgString, "AM");
            OSD_Output(MSG_STRING, 0, 0x1);
            UTL_DelayTime((WORD)COUNT_1_SEC, FALSE);
            OSD_Output(MSG_VERSION, wParam,  0x1);
            UTL_DelayTime((WORD)COUNT_1_SEC, FALSE);
            OSD_Output(MSG_VERSION, __StationInfo->wFreq[__StationInfo->bBand], 0x1);
        }
        UTL_DelayTime((WORD)COUNT_1_SEC, FALSE);
        break;

    case    MSG_NUMBER:
        OSD_Output(MSG_VERSION, wParam, 0x1);
        UTL_DelayTime((WORD)COUNT_1_SEC, FALSE);
        break;

    case    MSG_AUX:
        if(wParam==AUX_CHANNEL_DVD)
            strcpy(__bMsgString, "DVD");
        else if(wParam==AUX_CHANNEL_TUNER)
            strcpy(__bMsgString, "RADIO");
        else if(wParam==AUX_CHANNEL_AV1)
            strcpy(__bMsgString, "AV1");
        else
            strcpy(__bMsgString, "AV2");
        OSD_Output(MSG_STRING, 0x0, 0x1);
        UTL_DelayTime((WORD)COUNT_1_SEC, FALSE);
        break;

    default:
        break;
    }
}
#endif  // #ifdef TUNER_DEBUG_MODE


// LLY.278a, support earphone mode
//  **************************************************************************
//  Function    :   _Earphone_Control
//  Description :   Detect Earphone input or not first.
//                  If Earphone input, disable speaker output
//                  Otherwise, enable speaker output
//  Arguments   :   None
//  Return      :   None
//  Side Effect :
//  **************************************************************************
void _Earphone_Control(void)
{
#ifdef  SUPPORT_AV_SYSTEM
#ifdef  SUPPORT_EARPHONE

    // Step 1: Get earphone status
#ifdef  EXT_IO
    // wyc2.80, rename this function
    __bTemp=HAL1_ExtIOStatus();
#endif  // #ifdef EXT_IO

    // Step 2: Mute or de-mute speaker output base on earphone status
    if(__bTemp & 0x01) // earphone input
    {
        // Something need to do while 1st detect earphone input
        if( !(__bPeripheralIN & EARPHONE_ACTIVE) )
        {
            // Enable earphone active flag
            __bPeripheralIN |= EARPHONE_ACTIVE;

            // Disable Speaker output
            // wyc2.80, rename function name to AMP_mute
            AMP_mute(DAC_MUTE_AMPLIFIER);

            // Display debug info.
#ifdef  _DEBUG_INFO
            strcpy(__bMsgString, "EARPHONE V");
            OSD_Output(MSG_STRING, NULL, 0x1);
#endif  // #ifdef _DEBUG_INFO
        }
    }
    else // no earphone input
    {
        // Something need to do while 1st dis-connect the earphone input
        if(__bPeripheralIN & EARPHONE_ACTIVE)
        {
            // Disable eraphone active flag
            __bPeripheralIN &= ~EARPHONE_ACTIVE;

            // Enable Speaker output
            // wyc2.80, rename function name to AMP_mute
            AMP_mute(DAC_MUTE_OFF);

            // Display debug info.
#ifdef  _DEBUG_INFO
            strcpy(__bMsgString, "EARPHONE X");
            OSD_Output(MSG_STRING, NULL, 0x1);
#endif  // #ifdef _DEBUG_INFO
        }
    }

#endif  // #ifdef SUPPORT_EARPHONE
#endif  // #ifdef SUPPORT_AV_SYSTEM
}


// LLY2.78b create
//  ***********************************************************************
//  Function    :   _TUNER_JumpStation
//  Description :   [1] Jump to correspond station by input number and
//                  [2] Output the info. on panel, and
//                  [3] Program Tuner IC by desired station info.
//  Arguments   :   wNumber, the input number value
//  Return      :   None
//  Side Effect :   __StationInfo->wFreq[] value will be updated
//  ***********************************************************************
void _TUNER_JumpStation(WORD wNumber)
{
#ifndef NO_TUNER
    // Step 1: Calculate the correspond station info. by input number
    if(__StationInfo->bBand == BAND_FM) // FM BAND
    {
        // FM final number = input number * 10
        wNumber *= 10;

        // Check if overflow or underflow
        if(wNumber<MIN_FM_FREQ)
            wNumber=MIN_FM_FREQ;
        else if(wNumber>MAX_FM_FREQ)
            wNumber=MAX_FM_FREQ;
    }
    else // AM BAND
    {
        // AM final number = input number
        // So, nothing need to do

        // Check if overflow or underflow
        if(wNumber<MIN_AM_FREQ)
            wNumber=MIN_AM_FREQ;
        else if(wNumber>MAX_AM_FREQ)
            wNumber=MAX_AM_FREQ;
    }

    // Step 2: Keep the final station info. in __StationInfo->wFreq[]
    __StationInfo->wFreq[__StationInfo->bBand]=wNumber;

    // Step 3: Output info. on PANEL
    PANEL_Output(MSG_STATION, NULL);

    // Step 4: Program Tuner IC by desired info.
    CHIPS_ProgramTuner((BYTE)(SET_BAND|__StationInfo->bBand));
#endif  // #ifndef NO_TUNER
}


// LLY2.78b create
//  ************************************************************************
//  Function    :   _TUNER_QuerySearchScan
//  Description :   Query if continue to do search scan action
//                  It's ok while there is empty space for memory array, and
//                  current frequency don't exceed max value
//  Arguments   :   None
//  Return      :   SEARCH_SCAN_CONTINUE, need contine the search scan procedure
//                  SEARCH_SCAN_STOP, disable search scan procedure
//                  SEARCH_SCAN_POSTPOND, postpond the search scan precedure
//                  until time-out (3 sec)
//  Side Effect :
//  ************************************************************************
BYTE _TUNER_QuerySearchScan(void)
{
#ifndef NO_TUNER
    // [1] Delay a while (5 sec) between two search scan action
    if( (UTL_GetSysTimer()- __dwPreGetTime) < TIME_GAP_FOR_SEARCH_SCAN )
        return  SEARCH_SCAN_POSTPOND;

    // [2] Stop search scan action while
    // current frequency is max, or memory is full
    if(__StationInfo->bBand == BAND_FM)
    {
        if( (__bProgramCurrentIndex>=MAX_FM_STATION_NO) ||
            (__StationInfo->wFreq[BAND_FM]>=MAX_FM_FREQ) )
            return  SEARCH_SCAN_STOP;
    }
    else
    {
        if( (__bProgramCurrentIndex>=MAX_AM_STATION_NO) ||
            (__StationInfo->wFreq[BAND_AM]>=MAX_AM_FREQ) )
            return  SEARCH_SCAN_STOP;
    }

    return SEARCH_SCAN_CONTINUE;

#endif  // #ifndef NO_TUNER
    return  SEARCH_SCAN_STOP;
}

⌨️ 快捷键说明

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