1 Star 1 Fork 0

jackeer/test

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
main.c 2.85 KB
一键复制 编辑 原始数据 按行查看 历史
jackeer@hotmail.com 提交于 2016-07-21 10:34 . Chang Test
#include <Def_INC.h>
#include <Test.h>
#include <View.h>
#include <System.h>
#include <Macro.h>
BYTE xdata _bFocusViewIndex;
BYTE xdata _bKeyProcessViewIndex;
BYTE xdata UI_kwy_buffer,Time_Out;
WORD xdata Time_Count;
BYTE xdata STATUS_TSK;
BOOL keypress;
/*
#ifdef Time0_support
#define PERIOD -250
#endif
*/
/*
enum ALERT_BUTTON_TYPE
{
ALERT_BTN_OK,
ALERT_BTN_CANCEL,
MAX_ALERT_BTN_NUM
};
*/
/*
struct Clock_Show
{
BYTE Hour;
BYTE Min;
BYTE Sec;
}Clock_Show;
BYTE Clock_Show;
*/
//BYTE SEC_timer_0;
BYTE Init_All_Func(BYTE TSK)
{
BYTE init_Tsk = TSK;
if(init_Tsk >=UI_MAX || Time_Out >= 100)
init_Tsk = UI_INIT;
else if (!init_Tsk)
init_Tsk = UI_INIT;
else
init_Tsk = UI_DETECT;
return init_Tsk;
}
void InitIO(void)
{
P2 = 0xFF;
}
void InitTimer(void)
{
TMOD = 0x12; //timer0 = mode2, timer1 = mode1
TH0 = (65535L - 65000L) / 256; //timer0 = 60 mSec
TL0 = (65535L -65000L) % 256;
IE = 0x82; // EA = 1 ,ET0 = 1
IP = 0x02;
}
void timer_0(void) interrupt T0INT using TIMER0_BANK
{
MStopTimer0Cnt();
InitTimer();
Time_Out++;
MTrgTimer0Cnt();
}
void main(void)
{
BYTE xdata Task_loop;
/*
#ifdef Time0_support
TH0 = (unsigned char) PERIOD; // set timer period
TL0 = (unsigned char) PERIOD;
TMOD = TMOD | 0x02; // select mode 2
TR0 = 1; // start timer 0
ET0 = 1; // enable timer 0 interrupt
EA = 1; // global interrupt enable
#endif
SCON = 0x50; // SCON: mode 1, 8-bit UART, enable rcvr
TMOD |= 0x20; // TMOD: timer 1, mode 2, 8-bit reload
TH1 = 221; // TH1: reload value for 1200 baud @ 16MHz
TR1 = 1; // TR1: timer 1 run
TI = 1; // TI: set TI to send first char of UART
*/
InitTimer();
TR0 = 1;
Task_loop = Init_All_Func(STATUS_TSK);
while(1)
{
switch(Task_loop)
{
case UI_WAIT_INIT:
if (Time_Out >= 100)
STATUS_TSK = UI_DETECT;
break;
case UI_INIT:
STATUS_TSK = UI_WAIT_INIT;
InitIO();
InitTimer();
Time_Count = 0;
Time_Out = 0;
UI_kwy_buffer = 0xFF;
_bFocusViewIndex = 0;
_bKeyProcessViewIndex = 0;
TR0 = 1;
break;
case UI_DETECT:
if(P0 != 0xFF)
{
if(!keypress)
{
if(key_Power)
break;
else
{
keypress = 1;
vViewInit();
STATUS_TSK = UI_RUN;
Time_Out = 0;
break;
}
}
}
else
{
keypress = 0;
break;
}
case UI_RUN:
vViewProcess();
P2 = UI_kwy_buffer;
/*
if(Time_Out > 1000L)
{
// STATUS_TSK = UI_DETECT;
Time_Out = 0;
}
*/
break;
case UI_STANDBY:
STATUS_TSK = UI_INIT;
break;
default:
break;
}
Task_loop = STATUS_TSK;
}
// AUTO_COLOR_TEST();
// getchar();
// try_test();
// Test_Char_Key();
/*
#pragma asm
#pragma endasm
*/
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/jackeer/test.git
git@gitee.com:jackeer/test.git
jackeer
test
test
master

搜索帮助