/*****main.c 文件程序源代码**/#include unsigned char T0RH = 0; //T0 重载值的高字节
unsigned char T0RL = 0; //T0 重载值的低字节
void ConfigTimer0(unsigned int ms);
extern void UartDriver();
extern void ConfigUART(unsigned int baud);
extern void UartRxMonitor(unsigned char ms);
extern void UartWrite(unsigned char *buf, unsigned char len);
void main(){
EA = 1; //开总中断
ConfigTimer0(1); //配置 T0 定时 1ms
ConfigUART(9600); //配置波特率为 9600
while (1){
UartDriver(); //调用串口驱动
}
}
/* 串口动作函数,根据接收到的命令帧执行响应的动作
buf-接收到的命令帧指针,len-命令帧长度 */
void UartAction(unsigned char *buf, unsigned char len){
//在接收到的数据帧后添加换车换行符后发回
buf[len++] = '\r';
buf[len++] = '\n';
UartWrite(buf, len);
}
/* 配置并启动 T0,ms-T0 定时