?? interrupt.c
字號:
//===========================================================
// Project Name(項目名稱): SPCA755 rebuild
// File Name(模塊名稱): interrupt.c
// Built Date(創建日期):2004-09-14
// Abstract(模塊描述): 中斷功能函數模塊
// Revision History(版本信息):
// Rev Date Author Comment(修改說明)
// 1.0 2004-09-14 XYQ created
//================================================================================================
#include "..\userdefine.h"
#include "interrupt.h"
#include "userinit.h"
#include "user.h"
#include "main.h"
//================================================================================================
data U8 gc_KeyValue=0;
data U8 gc_BatteryValue=0xff;
data U8 gc_ADCOldKey=0;
data U8 gc_LongKeyDelay=0;
data U8 gc_LongKeyTimer=0;
data U8 gc_QuarterTimer=0;
data U8 gc_BlinkTimer;
data U8 gc_SysSecondTimer;
//================================================================================================
data U8 gc_SecondTimer;
data U8 gc_minuteTimer;
data U8 gc_basetimerx4;//lyh add
//================================================================================================
#define K_USE_SPCA759_KEYB
//================================================================================================
void UserExtInterrupt() interrupt 0 using 1
{
INTR_Int0();
}
void User_Timer() interrupt 1 using 2
{//每7.8ms會進行中斷一次(into this intterrupt per 7.8ms)
//該函數用戶不能刪除,否則定時器會不準確
TIMER0_Routine();//the function must call here(該函數在此必須調用,該函數為設置定時器初值)
gc_QuarterTimer = (gc_QuarterTimer >= 3)?0:gc_QuarterTimer+1;
switch(gc_QuarterTimer)
{
case 0:
if (gc_SysSecondTimer)
{
gc_SysSecondTimer--;
}else{
gc_SysSecondTimer = SECONDTIMER_VALUE;
}
break;
case 1:
gc_BatteryValue = USER_READSAR(2); //read SAR output
if (USB_PlugDetect())
{
gc_BatteryValue = 0xff;
}
if (gc_BlinkTimer)gc_BlinkTimer--;
if (gc_LongKeyTimer) gc_LongKeyTimer++;
break;
case 2:
if (!gc_KeyValue)
{//if oldevent haven't been deal with, not to get new keyValue
if (1)
{
data U8 tc_ADCCurrentKey;
tc_ADCCurrentKey = USER_READSAR(0); //read SAR output
#if 0
#ifdef K_USE_SPCA759_KEYB
if (tc_ADCCurrentKey>240) tc_ADCCurrentKey=0;
else if(tc_ADCCurrentKey>171) tc_ADCCurrentKey=1;
else if(tc_ADCCurrentKey>149) tc_ADCCurrentKey=2;
else if(tc_ADCCurrentKey>124) tc_ADCCurrentKey=3;
else if(tc_ADCCurrentKey>96) tc_ADCCurrentKey=4;
else if(tc_ADCCurrentKey>66) tc_ADCCurrentKey=5;
else if(tc_ADCCurrentKey>36) tc_ADCCurrentKey=6;
else if(tc_ADCCurrentKey>11) tc_ADCCurrentKey=7;
else tc_ADCCurrentKey = 8;
/* if (tc_ADCCurrentKey>240) tc_ADCCurrentKey=0;
else if(tc_ADCCurrentKey>217) tc_ADCCurrentKey=1;
else if(tc_ADCCurrentKey>182) tc_ADCCurrentKey=2;
else if(tc_ADCCurrentKey>139) tc_ADCCurrentKey=3;
else if(tc_ADCCurrentKey>104) tc_ADCCurrentKey=4;
else if(tc_ADCCurrentKey>75) tc_ADCCurrentKey=5;
else if(tc_ADCCurrentKey>41) tc_ADCCurrentKey=6;
else if(tc_ADCCurrentKey>14) tc_ADCCurrentKey=7;
else tc_ADCCurrentKey = 8;*/
#else
if (tc_ADCCurrentKey>240) tc_ADCCurrentKey=0;
else if(tc_ADCCurrentKey>220) tc_ADCCurrentKey=1;
else if(tc_ADCCurrentKey>202) tc_ADCCurrentKey=2;
else if(tc_ADCCurrentKey>181) tc_ADCCurrentKey=3;
else if(tc_ADCCurrentKey>147) tc_ADCCurrentKey=4;
else if(tc_ADCCurrentKey>105) tc_ADCCurrentKey=5;
else if(tc_ADCCurrentKey>61) tc_ADCCurrentKey=6;
else if(tc_ADCCurrentKey>20) tc_ADCCurrentKey=7;
else tc_ADCCurrentKey = 8;
#endif
#else//MoonBox key value V2.0
if (tc_ADCCurrentKey>240) tc_ADCCurrentKey=0;
else if(tc_ADCCurrentKey>217) tc_ADCCurrentKey=7;
else if(tc_ADCCurrentKey>182) tc_ADCCurrentKey=8;
else if(tc_ADCCurrentKey>139) tc_ADCCurrentKey=5;
else if(tc_ADCCurrentKey>104) tc_ADCCurrentKey=4; //VOL+
else if(tc_ADCCurrentKey>75) tc_ADCCurrentKey=6; //MODE
else if(tc_ADCCurrentKey>41) tc_ADCCurrentKey=2; //LAST
else if(tc_ADCCurrentKey>14) tc_ADCCurrentKey=1; //NEXT
else tc_ADCCurrentKey = 3; //PLAY
/*
if (tc_ADCCurrentKey>240) tc_ADCCurrentKey=0;
else if(tc_ADCCurrentKey>210) tc_ADCCurrentKey=1;
else if(tc_ADCCurrentKey>180) tc_ADCCurrentKey=2;
else if(tc_ADCCurrentKey>140) tc_ADCCurrentKey=3;
else if(tc_ADCCurrentKey>96) tc_ADCCurrentKey=4;
else if(tc_ADCCurrentKey>66) tc_ADCCurrentKey=5;
else if(tc_ADCCurrentKey>36) tc_ADCCurrentKey=6;
else if(tc_ADCCurrentKey>11) tc_ADCCurrentKey=7;
else tc_ADCCurrentKey = 8;*/
#endif
if ((gc_ADCOldKey & 0x0f) == tc_ADCCurrentKey)
{//按鍵未釋放
if (tc_ADCCurrentKey != KEY_NONEKEY)
{
if (gc_LongKeyTimer > gc_LongKeyDelay)
{
gc_ADCOldKey = gc_ADCOldKey | 0x10; //長按鍵
gc_KeyValue = gc_ADCOldKey & 0x7f;
gc_LongKeyTimer = REPEATKEY_DELAYVALUE; //設置重復按鍵延時起始值
gc_LongKeyDelay = (gc_LongKeyDelay < MIN_REPEATKEYDELAY)?MIN_REPEATKEYDELAY:gc_LongKeyDelay-3; //加速重復按鍵
}
else
{
gc_ADCOldKey |= 0x80;
}
}
}
else if (tc_ADCCurrentKey == KEY_NONEKEY){//按鍵釋放
if ((gc_ADCOldKey & 0x90) == 0x80)
{
gc_KeyValue = gc_ADCOldKey & 0x7f; //獲取短按鍵值
}else if ((gc_ADCOldKey & 0x90) == 0x90){
gc_KeyValue = (gc_ADCOldKey | 0x20) & 0x7f;//key value will be 0x3x
}
gc_ADCOldKey = KEY_NONEKEY;
gc_LongKeyTimer = 0; //關閉按鍵計時器
gc_LongKeyDelay = 0; //復位重復按鍵延時值
}
else{//有鍵按下
gc_ADCOldKey = tc_ADCCurrentKey;
gc_LongKeyTimer = 1; //觸發按鍵計時器
if (!gc_LongKeyDelay) gc_LongKeyDelay = MAX_REPEATKEYDELAY; //若外部未初始化重復按鍵延時初始值則默認初始化
}
}else{
gc_ADCOldKey = KEY_NONEKEY;
}
}
break;
case 3:
gc_SecondTimer--;
if (!gc_SecondTimer)
{
gc_SecondTimer = SECONDTIMER_VALUE;
if(gw_PowerOffTimer)
{
// printf("gw_PowerOffTimer =%x \n",gw_PowerOffTimer);
gw_PowerOffTimer--;//lizhn modify
}
if(gc_Busy_Timer)
{
gc_Busy_Timer--;//lyh add
}
if(gc_FileNameRollTimer)
{
gc_FileNameRollTimer--;//lyh add 0.125s
}
if (gc_minuteTimer)
{
gc_minuteTimer--;
}else{
gc_minuteTimer = MINUTETIMER_VALUE;
}
}
gb_UIEvent=TRUE;//lyh add
gc_basetimerx4--;//lyh add
if(!gc_basetimerx4)
{
gc_basetimerx4=BASETIMERX4_VALUE;
/*
if(gc_Busy_Timer)gc_Busy_Timer--;//lyh add 0.125s
if(gc_FileNameRollTimer)gc_FileNameRollTimer--;//lyh add 0.125s*/
if(gc_Battery_Detect_Timer)gc_Battery_Detect_Timer--;//lyh add 0.125s
}
break;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -