📄 tecclockzhicuankou.c
字号:
//串口的初始化程序
#define uchar unsigned char
#define uint unsigned int
#include "public.h"
#include "reg52.h"
#include "stdio.h"
#include "def.h"
#define PUBLIC_GLOBALS
uchar code menu[] =
"\n"
"+***************** REMOTE MEASUREMENT RECORDER *****************+\n"
"| This program is a simple Measurement Recorder. It is based on |\n"
"| the MCU51 and records the state of time |\n"
"+ command -+ syntax -----+ function ----------------------------+\n"
"| autohor | a | read author name |\n"
"| Time | t | display time |\n"
"+----------+-------------+--------------------------------------+\n";
void uart0int()
{
TMOD |= 0x20;
TH1 = 0xf3;
TL1 = 0xf3;
EA = 1;
ES = 1;
TR1 = 1;
SCON = 0x50;
}
void putchar1(uchar ch)
{
if(ch == LF)
{
SBUF = CR;
while(!TI);
TI = 0;
}
SBUF = ch;
while(!TI);
TI = 0;
}
void uartsendstr(uchar *sp)
{
do
{
if(*sp != '\n')
{
SBUF = *sp;
sp ++;
while(!TI);
TI = 0;
}
else
{
SBUF = 0x0d;
sp ++;
while(!TI);
TI = 0;
SBUF = 0x0a;
while(!TI);
TI = 0;
}
}
while(*sp != '\0');
}
void com(void) interrupt 4 using 1
{
char temp;
uchar c;
if(RI)
{
RI = 0;
c = SBUF;
if(gTimeDisplay == FALSE)
{
if((gCommandDeal == FALSE)&&(gUart0RecCount < (MAXCOMMLENGTH - 1)))
{
if(c == CR)
{
c = LF;
gCommandDeal = TURE;
}
if(c == BACKSPACE || c == DEL)
{
if(gUart0RecCount != 0)
{
gUart0RecCount--; /* decrement count */
putchar1 (BACKSPACE); /* echo backspace */
putchar1 (' ');
putchar1 (BACKSPACE);
}
}
else if(c != CNTLQ && c != CNTLS)
{
gUart0Buf[gUart0RecCount]=c;
gUart0RecCount++;
putchar1(c);
}
}
else
{
temp = SBUF;
}
if(c == LF)
{
gUart0RecCount --;
gUart0Buf[gUart0RecCount] = 0;
gCommandDeal = TURE;
}
if (gUart0RecCount >= (MAXCOMMLENGTH-2))
{
gUart0RecCount --;
gUart0Buf[gUart0RecCount] = 0;
gCommandDeal = TURE;
}
}
else
{
if(c == ESC)
{
SBUF = CR;
while(!TI);
TI = 0;
SBUF = LF;
while(!TI);
TI = 0;
gTimeDisplay = FALSE;
gCommandDeal=FALSE;
gUart0RecCount=0;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -