📄 function.c
字号:
/*************** XXXXXX CONFIDENTIAL ****************/
/*************** ****************/
/*************** Description : All functions ****************/
/*************** for Docking devices ****************/
/*************** ****************/
/*************** Company : XXXXXXTek Inc. ****************/
/*************** Programmer : Steven Chu ****************/
/*************** Date : 04/10/2007 ****************/
/**********************************************************************/
#define _C_FUNCTION_
#include "general.h"
#pragma NOAREGS
/************************************************************************
Function : void PWROnInital(void)
Description : Power On initialization
Parameter : None
Return : None
************************************************************************/
void PWROnInital(void)
{
MDisableINT(); // Disable interrupt
SetPort0High(); // Set Port 0(P0) High
SetPort1High(); // Set Switch Port(P1) High
P2 = 0xEF;
SetPowerOff(); // Power function control OFF
SetMuteOff(); // Mute function control OFF
ClrVolUp(); // Volume Up function control OFF
ClrVolDn(); // Volume Down function control OFF
PWRLEDOff(); // Set Power LED off
MuteLEDOff(); // Set Mute LED off
VolUpLEDOff(); // Set Volume Up LED off
VolDnLEDOff(); // Set Volume Down LED off
ExpCardLEDOff(); // ExpressCard LED Off
ResetVar(); // Set default value
_bAllKeyStatus = 0xFF; // All Switch(Port 1) Status
_bOldAllKeyStatus = 0xFF; // All Switch(Port 1) Old Status
_bSystemMode = POWER_OFF_NORMAL; // initial set system mode as power off normal mode
EnableEX0Int(); // Enable external interrupt 0 (P3.2)
InitTimer(); // Initial Timer Int
#ifdef _RS232_DEBUG_
RS232Initial(); // Initial RS232
#endif
MEnableINT(); // Enable interrupt
}
/************************************************************************
Function : void ResetVar(void)
Description : Power On initialization
Parameter : None
Return : None
************************************************************************/
void ResetVar(void)
{
_fgTimeout = 0; // timer 2 timeout flag
_fgMuteOn = 0; // Mute on flag
_fgPWRLEDFlash = 0; // Power LED flash enable flag
_fgExpCardLEDFlash = 0; // Express Card LED Flash flag
_fgMuteLEDFlash = 0; // Mute LED Flash flag
_fgVolUpLEDFlash = 0; // Volume Up LED Flash flag
_fgVolDnLEDFlash = 0; // Volume Down LED Flash flag
_fgPWRLEDOn = 0; // Power LED on flag
_fgExpCardLEDOn = 0; // Express Card LED on flag
_fgMuteLEDOn = 0; // Mute LED on flag
_fgVolUpLEDOn = 0; // Volume Up LED on flag
_fgVolDnLEDOn = 0; // Volume Down LED on flag
_fgPWRKeyPressed = 0; // Power key pressed
_fgMuteKeyPressed = 0; // Mute key pressed
_fgExpCardPlug = 0; // ExpressCard plug on
_fgExpCardBreak = 0; // ExpressCard break
_bFlashCount = 0; // Flash hold Counter
_b20msTimeUp = 0; // 20ms timer
_bSystemCount = 0; // System 20ms timer count
_bPWRLEDBlinkRate = 0; // Power LED Blink Rate
_bExpCardLEDBlinkRate = 0; // Express Card LED Blink Rat
_bMuteLEDBlinkRate = 0; // Mute LED Blink Rate
_bVolUpLEDBlinkRate = 0; // Volume Up LED Blink Rate
_bVolDnLEDBlinkRate = 0; // Volume Down LED Blink Rate
_bPWRLEDBlinkTime = 0; // Power LED blink time count
_bPWRKeyStatus = SW_NORMAL; // Initial Power key status
_bVolUpKeyStatus = SW_NORMAL; // Initial Volume Up key status
_bVolDnKeyStatus = SW_NORMAL; // Initial Volume Up key status
_bMuteKeyStatus = SW_NORMAL; // Initial Mute key status
_bExpCardStatus = SW_NORMAL; // Initial ExpressCard connect status
_bPEXResetStatus = SW_NORMAL; // Initial PEX_RST pin status
_bOldAllKeyStatus = 0xFF; // Initial All Key status
_bAllKeyStatus = 0xFF; // Initial All Key status
}
/************************************************************************
Function : void ChkPowerSwitch(void)
Description : Check Power On/Off Switch status
Parameter : None
Return : None
************************************************************************/
void ChkPowerSwitch(void)
{
switch (_bPWRKeyStatus)
{
case SW_NORMAL:
// POWER SW from H->L
if (_fgOldPWRKey && (!_fgPWRKey)) // POWER SW just press
{
_bPWRKeyStatus = SW_PRESS;
}
break;
case SW_PRESS:
// POWER SW from L->L
if ((!_fgOldPWRKey) && (!_fgPWRKey)) // POWER SW press hold
{
PWRLEDOn(); // Power On LED ON
_bSystemCount = 100; // Set Power SW hold timer counter as 2 sec
_fgPWRKeyPressed = 1;
_bPWRKeyStatus = SW_HOLD;
}
// POWER SW from L->H
else if ((!_fgOldPWRKey) && _fgPWRKey) // POWER SW just release
{
_bPWRKeyStatus = SW_NORMAL; // for De-bounds
}
break;
case SW_HOLD:
// POWER SW from L->H
if ((!_fgOldPWRKey) && _fgPWRKey) // POWER SW just release
{
_bPWRKeyStatus = SW_RELEASE;
}
break;
case SW_RELEASE:
// POWER SW from H->H
if (_fgOldPWRKey && _fgPWRKey)
{
if (_bSystemMode != POWER_ON_TRIG_POWER_OFF)
{
PWRLEDOff(); // Power LED off
}
_fgPWRKeyPressed = 0;
_bPWRKeyStatus = SW_NORMAL;
}
// POWER SW from H->L
else if (_fgOldPWRKey && (!_fgPWRKey))
{
_bPWRKeyStatus = SW_HOLD; // for De-bounds
}
break;
}
}
/************************************************************************
Function : void ChkVolumeUpSwitch(void)
Description : Check Volume Up Switch status
Parameter : None
Return : None
************************************************************************/
void ChkVolumeUpSwitch(void)
{
switch (_bVolUpKeyStatus)
{
case SW_NORMAL:
// Volume Up SW from H->L
if (_fgOldVolUpKey && (!_fgVolUpKey)) // Volume Up key just press
{
_bVolUpKeyStatus = SW_PRESS;
}
break;
case SW_PRESS:
// Vloume Up SW from L->L
if (!_fgOldVolUpKey && (!_fgVolUpKey)) // Volume Up key Hold
{
_bVolUpKeyStatus = SW_HOLD;
}
// Volume Up SW from L->H
if (!_fgOldVolUpKey && (_fgVolUpKey)) // Volume Up key Hold
{
_bVolUpKeyStatus = SW_NORMAL; // for De-bounds
}
break;
case SW_HOLD:
// Volume Up SW from L->H
if (!_fgOldVolUpKey && (_fgVolUpKey)) // Volume Up key just release
{
_bVolUpKeyStatus = SW_RELEASE;
}
break;
case SW_RELEASE:
// Volume Up SW from H->H
if (_fgOldVolUpKey && (_fgVolUpKey)) // Volume Up key Hold
{
_bVolUpKeyStatus = SW_NORMAL;
}
// Volume Up SW from H->L
if (_fgOldVolUpKey && (!_fgVolUpKey))
{
_bVolUpKeyStatus = SW_HOLD; // for De-bounds
}
break;
}
}
/************************************************************************
Function : void ChkVolumeDownSwitch(void)
Description : Check Volume Down Switch status
Parameter : None
Return : None
************************************************************************/
void ChkVolumeDownSwitch(void)
{
switch (_bVolDnKeyStatus)
{
case SW_NORMAL:
// Volume Down SW from H->L
if (_fgOldVolDnKey && (!_fgVolDnKey)) // Volume Down key just press
{
_bVolDnKeyStatus = SW_PRESS;
}
break;
case SW_PRESS:
// Vloume Down SW from L->L
if (!_fgOldVolDnKey && (!_fgVolDnKey)) // Volume Down key Hold
{
_bVolDnKeyStatus = SW_HOLD;
}
// Volume Down SW from L->H
if (!_fgOldVolDnKey && (_fgVolDnKey)) // Volume Down key Hold
{
_bVolDnKeyStatus = SW_NORMAL; // for De-bounds
}
break;
case SW_HOLD:
// Volume Down SW from L->H
if (!_fgOldVolDnKey && (_fgVolDnKey)) // Volume Down key just release
{
_bVolDnKeyStatus = SW_RELEASE;
}
break;
case SW_RELEASE:
// Volume Down SW from H->H
if (_fgOldVolDnKey && (_fgVolDnKey)) // Volume Down key Hold
{
_bVolDnKeyStatus = SW_NORMAL;
}
// Volume Down SW from H->L
if (_fgOldVolDnKey && (!_fgVolDnKey))
{
_bVolDnKeyStatus = SW_HOLD; // for De-bounds
}
break;
}
}
/************************************************************************
Function : void ChkMuteSwitch(void)
Description : Check Mute Switch status
Parameter : None
Return : None
************************************************************************/
void ChkMuteSwitch(void)
{
switch (_bMuteKeyStatus)
{
case SW_NORMAL:
// Mute SW from H->L
if (_fgOldMuteKey && (!_fgMuteKey)) // Mute key just press
{
_bMuteKeyStatus = SW_PRESS;
}
break;
case SW_PRESS:
// Mute SW from L->L
if (!_fgOldMuteKey && (!_fgMuteKey)) // Mute key Hold
{
_fgMuteKeyPressed = 1;
_bMuteKeyStatus = SW_HOLD;
}
// Mute SW from L->H
if (!_fgOldMuteKey && _fgMuteKey) // Mute key Hold
{
_bMuteKeyStatus = SW_NORMAL; // for De-bounds
}
break;
case SW_HOLD:
// Mute SW from L->H
if (!_fgOldMuteKey && (_fgMuteKey)) // Mute key just release
{
_bMuteKeyStatus = SW_RELEASE;
}
break;
case SW_RELEASE:
// Mute SW from H->H
if (_fgOldMuteKey && (_fgMuteKey)) // Mute key released
{
SetMuteOff(); // Mute function control OFF
_fgMuteKeyPressed = 0;
_bMuteKeyStatus = SW_NORMAL;
}
// Mute SW from H->L
if (_fgOldMuteKey && (!_fgMuteKey)) // Mute key Hold
{
_bMuteKeyStatus = SW_HOLD; // for De-bounds
}
break;
}
}
/***************************************************************************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -