?? main.bak
字號:
/*************** XXXXXX CONFIDENTIAL ****************/
/*************** ****************/
/*************** Description : MAIN control procs used ****************/
/*************** for Docking devices ****************/
/*************** ****************/
/*************** Company : XXXXXXTek Inc. ****************/
/*************** Programmer : Steven Chu ****************/
/*************** Date : 03/26/2007 ****************/
/**********************************************************************/
#define _C_MAIN_
#include "general.h"
#pragma NOAREGS
/************************************************************************
Function : void main(void)
Description : MAIN ROUTINE
Parameter : None
Return : None
************************************************************************/
void main(void)
{
#ifdef _RS232_DEBUG_
BYTE bTmpCnt = 50; // 1 sec time out
#endif
PWROnInital(); // Power on initial Hardware
#ifdef _RS232_DEBUG_
RS232Data1(0xAA, 0xAA, 0xAA);
#endif
/*====================================================================*/
/*========================= MAIN LOOP ================================*/
/*====================================================================*/
while(TRUE)
{
/**** Increase Pause Timer Count Every 20ms ****/
if (_testbit_(_fgTimeout)) // 500us time up
{
if (_b20msTimeUp)
{
_b20msTimeUp--;
}
if ((_bSystemMode != POWER_OFF_NORMAL) &&
(_bSystemMode != POWER_OFF_IDLE) &&
(_bSystemMode != POWER_OFF_SLEEP))
{
ProcLEDBlink1();
if (_bSystemCount)
{
ProcLEDBlink2(); // Process All LED Blinking
}
}
}
if (!_b20msTimeUp)
{
_b20msTimeUp = 40;
#ifdef _RS232_DEBUG_
if (bTmpCnt)
{
bTmpCnt--; // Temp Timer Count for Debug
}
else // 1 sec time out
{
bTmpCnt = 50;
RS232Data1('2','3','2');
}
#endif
if (_bSystemCount)
{
_bSystemCount--; // System Timer Count
}
ReadSwStatus(); // Read All key status
CheckExpressCard(); // Check ExpressCard Connect status
//CheckPEXReset(); // Check PEX_RST pin status
ChkPowerSwitch(); // check Power key status
ChkVolumeUpSwitch(); // Check Volume Up key status
ChkVolumeDownSwitch(); // Check Volume Down key status
ChkMuteSwitch(); // Check Mute key status
_bOldAllKeyStatus = _bAllKeyStatus; // Save current status to old_status for next 20ms cycle to compare the different status
// Flash Power LED if prepare Power Off
if (_fgPWRLEDFlash) // Power LED flash enable?
{
if (--_bFlashCount == 0) // flash hold time up change LED on/off status
{
P2 ^= 0x01; // toggle Power LED
_bFlashCount = _bPWRLEDBlinkTime; // Reset flash hold count
}
}
// Check System Mode
switch (_bSystemMode)
{
case POWER_OFF_NORMAL:
if (_testbit_(_fgPWRKeyPressed)) // Power key pressed
{
PWRLEDOn(); // Set Power LED on
_bSystemCount = 50; // Power on hold 1 sec
_bSystemMode = POWER_ON_CHECK_HOST; // Change Mode
}
else if (!_bSystemCount) // idle time out
{
_bSystemCount = 250; // idle mode over 5 sec entering sleep mode
_bSystemMode = POWER_OFF_IDLE; // Change to idle mode
PCON |=0x01; // Entering Idle Mode Wake up by Power key press
}
break;
case POWER_OFF_IDLE:
if (_testbit_(_fgPWRKeyPressed)) // Power key pressed
{
SetPowerOff(); // Power function control OFF
SetMuteOff(); // Mute function control OFF
ClrVolUp(); // Volume Up function control OFF
ClrVolDn(); // Volume Down function control OFF
PWRLEDOn(); // Set Power LED on
MuteLEDOff(); // Set Mute LED off
VolUpLEDOff(); // Set Volume Up LED off
VolDnLEDOff(); // Set Volume Down LED off
ExpCardLEDOff(); // ExpressCard LED Off
SetPort1High(); // Set Switch Port(P1) High
ResetVar(); // Set default value
_bOldAllKeyStatus = 0xEF; // Initial All Key status
_bAllKeyStatus = 0xEF; // Initial All Key status
_bSystemCount = 50; // Power on hold 1 sec
_bSystemMode = POWER_ON_CHECK_HOST; // Change Mode
}
else if (!_bSystemCount) // idle time over 5 sec entering sleep mode
{
_fgExt0Int = 0; // Clear External Interrupt 0 flag
_bSystemMode = POWER_OFF_SLEEP;
PCON |=0x02; // Entering Power Down Mode Wake up by Power key press
}
break;
case POWER_OFF_SLEEP:
if (_testbit_(_fgExt0Int)) // Power key pressed and external 0 interrupt
{
SetPowerOff(); // Power function control OFF
SetMuteOff(); // Mute function control OFF
ClrVolUp(); // Volume Up function control OFF
ClrVolDn(); // Volume Down function control OFF
PWRLEDOn(); // Set Power LED on
MuteLEDOff(); // Set Mute LED off
VolUpLEDOff(); // Set Volume Up LED off
VolDnLEDOff(); // Set Volume Down LED off
ExpCardLEDOff(); // ExpressCard LED Off
SetPort1High(); // Set Switch Port(P1) High
ResetVar(); // Set default value
_bOldAllKeyStatus = 0xEF; // Initial All Key status
_bAllKeyStatus = 0xEF; // Initial All Key status
_bSystemCount = 50; // Power on hold 1 sec
_bSystemMode = POWER_ON_CHECK_HOST; // Change Mode
}
break;
case POWER_ON_HOLD:
if (!_bSystemCount)
{
_fgMuteLEDFlash = 1; // Mute LED Flash flag
_fgVolUpLEDFlash = 1; // Volume Up LED Flash flag
_fgVolDnLEDFlash = 1; // Volume Down LED Flash flag
_fgExpCardLEDFlash = 1; // ExpressCard LED On
_bSystemCount = 250; // All LED on hold 5 sec
_bSystemMode = POWER_ON_CONNECTED;
}
break;
case POWER_ON_CHECK_HOST: // Power on check ExpressCard plug or not
if (_bExpCardStatus == SW_HOLD) // ExpressCard hold
{
SetPowerOn(); // Set Power On
_bSystemCount = 75; // Power on hold 1.5 sec
_bSystemMode = POWER_ON_HOLD;
}
if (_testbit_(_fgPWRKeyPressed)) // Power key pressed
{
_bSystemCount = 100; // Power key hold must over 2 sec
PWRLEDOn(); // Power LED off
_bSystemMode = POWER_ON_PWRSW_HOLD;
}
break;
case POWER_ON_CONNECTED:
if (_bExpCardStatus == SW_NORMAL) // ExpressCard break
{
_fgExpCardLEDFlash = 0; // ExpressCard LED Off
SetPowerOff(); // Set Power control off
_bSystemMode = POWER_ON_CHECK_HOST; // Change Mode
}
//if (_bPEXResetStatus == SW_HOLD) // Host PEX_RST pin low -> Reset
//{
// SetPowerOff(); // Set Power control off
// _bSystemMode = POWER_ON_CHECK_HOST;
//}
if (_testbit_(_fgPWRKeyPressed)) // Power key pressed
{
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -