serial.c
来自「用8051采用pwm方式播放 串口语音数据」· C语言 代码 · 共 64 行
C
64 行
/***************************************************************\
name : serial.c
desctiption : this file is used for serial port
author : coolfire
update : 6/17/07
/***************************************************************/
//includes
#include "serial.h"
//global Variables
Uchar pf;
/***************************************************************\
name : init()
desctiption : initialise the serial port
in Parameters : no
out Parameters : no
/***************************************************************/
void serial_init()
{
TMOD=0x20;
TH1 =0xe8;
TL1 =0xe8;
PCON=0x80;
TR1 =1;
SCON=0x50;
}
/***************************************************************\
name : init()
desctiption : tranfer data to serial port
in Parameters : no
out Parameters : no
/***************************************************************/
/*
void serial_send(Uchar idata *d)
{
Uchar i;
SBUF=d[i];
pf+=d[i];
while(TI==0);
TI=0;
}
*/
/***************************************************************\
name : serial_receive()
desctiption : receive data from serial port
in Parameters : no
out Parameters : no
/***************************************************************/
void serial_receive(Uchar idata *d)
{
Uchar i;
while(RI==0);
RI=0;
d[i]=SBUF;
//pf+=d[i];
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?