|
#include <rtx51tny.h>
#include <reg51.h>
unsigned char k=0;
/**********************************/
unsigned char code displaycode[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x00};
sbit P10=P1^0;
sbit P11=P1^1;
sbit P12=P1^2;
sbit P13=P1^3;
sbit P14=P1^4;
sbit P15=P1^5;
sbit P16=P1^6;
sbit P17=P1^7;
sbit P33=P3^3;
/***************任务0,显示******************/
job0 () _task_ 0 {
os_create_task (1);
os_create_task (2);
while (1) {
P2=displaycode[k]; //xianshi
os_wait (K_TMO, 5, 2);
}
}
/******************任务一,键盘处理函数************************/
job1 () _task_ 1 {
while (1) {
if(P1!=0xff)
{
switch(P1)
{
case 0xfe: k=1,P0=0xfe;break;
case 0xfd: k=2,P0=0xfd;break;
case 0xfb: k=3,P0=0xfd;break;
case 0xf7: k=4,P0=0xf7;break;
case 0xef: k=5,P0=0xef;break;
case 0xdf: k=6,P0=0xdf;break;
case 0xbf: k=7,P0=0xbf;break;
case 0x7f: k=8,P0=0x7f;break;
default: break;
}
os_delete_task (1); //删除任务1;
}
os_wait (K_TMO, 3, 0);
}
}
/****************任务二,复位按键*********************/
job2 () _task_ 2 {
while(1)
{
if(P33==0)
{
k=0;
P0=0xff;
os_create_task (1); // 复位。启动任务1
os_wait (K_TMO, 3, 0);
}
}
}
|
|