📄 text2.c
字号:
/******************************************************************************/
/* */
/* Task 2: it is a key task */
/* */
/******************************************************************************/
#include <rtx51tny.h> /* RTX-51 tiny functions & defines */
#include "reg52.h"
sbit Key1 = P2^6;
sbit Key2 = P2^7;
sbit KeyOn = P3^3;
sbit KeyText = P3^4;
sbit Single1 = P1^4;
sbit Single2 = P1^3;
sbit LedRed = P1^6;
sbit LedGrn = P1^5;
/******************************************************************************/
/* Task 2 'job1': RTX-51 tiny starts this task with os_create_task (2) */
/******************************************************************************/
void job2 (void) _task_ 2 {
while (1) { /* endless loop */
KeyOn = 1;
Key1 = 0;
if(KeyText==0)
{
os_wait (K_TMO, 4, 0); /* wait for timeout: 4 ticks */
if(KeyText==0){
Single1 = 0;
LedRed = 0;
os_wait (K_TMO, 2, 0);
Single1 = 1;}
do{
KeyText = 1;
Key1 = 0;}
while(KeyText==0);
LedRed =~LedRed;
Key1 = 1;
}
Key1 = 1;
KeyOn = 1;
Key2 = 0;
if(KeyText==0)
{
os_wait (K_TMO, 4, 0); /* wait for timeout: 4 ticks */
if(KeyText==0){
Single2 = 0;
LedGrn = 0;
os_wait (K_TMO, 2, 0);
Single2 = 1;}
do{
KeyText = 1;
Key2 = 0;}
while(KeyText==0);
LedGrn =~LedGrn;
Key2 = 1;
}
Key2 = 1;
os_wait (K_TMO, 2, 0); /* wait for timeout: 2 ticks */
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -