📄 function.c
字号:
/*******************************
双机通信功能实现C源程序
*******************************/
#include "双机通信.h"
void delay_10ms() //10ms delay routine
{ uint i;
for(i = 0; i < 10000; i++);
}
void init() //serial communication initial routine
{ TMOD = 0x20;TH1 = 0xE6;TL1 = 0xE6;TR1 = 1;
SCON = 0x50;
EA=1;ES=1;
}
uchar keyscan() //keyscan routine
{ uchar temp,keycode = 0;
P1 = 0xff;
temp = P1;
if( temp != 0xff)
{ delay_10ms();
temp = P1;
if( temp != 0xff)
{ if( P1_0 == 0) return 1;
else if (P1_1 == 0) return 2;
else if (P1_2 == 0) return 3;
else if (P1_3 == 0) return 4;
else if (P1_4 == 0) return 5;
else if (P1_5 == 0) return 6;
else if (P1_6 == 0) return 7;
else return 8;
}
}
return 0xff;
}
void send(uchar x,uchar *p) // 串口查询发送程序
{ uchar temp;
temp = p[x];// ES=0;EA=0;
SBUF = temp;
while( !TI );
TI = 0;// ES=1;EA=1;
}
int_es() interrupt 4 //串口接受中断程序
{ if(RI)
{ RI = 0;
P2 = SBUF;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -