📄 serial.c
字号:
//serial.c
#include <reg51.h>
#include "serial.h"
/******************************************************************************
函数:Ser_Delay()
功能:
参数:
uchDly:延时长度
返回:
******************************************************************************/
void Ser_Delay(unsigned char uchDly)
{
//unsigned char uchTmp;
unsigned char i,j;
for(i = 0;i < uchDly;i++);
}
/******************************************************************************
函数:Ser_SendByte()
功能:主机通过串行总线发送一个字节的数据
参数:
uchValue:要发送的数据
返回:
******************************************************************************/
void Ser_SendByte(unsigned char uchValue)
{
unsigned char i;
for(i = 0;i < 8;i++)
{
SER_SCLK = 1;
Ser_Delay(10);
if(uchValue & 0x80)
{
SER_SID = 1;
Ser_Delay(20);
}
else
{ SER_SID = 0;
Ser_Delay(20);
}
SER_SCLK = 0;
Ser_Delay(10);
uchValue = uchValue << 1;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -