serial.c
来自「一个通过8051来控制8019上网的程序 该程序已经通过并成功用于键盘」· C语言 代码 · 共 49 行
C
49 行
//-----------------------------------------------------------------------------
// Net SERIAL.C
//
// This module handles RS-232 messages and associated tasks
//-----------------------------------------------------------------------------
#include <reg52.h>
#include <intrins.h>
#include "net.h"
#include "serial.h"
void init_serial(void)
{
// ClearCommRecBuffer();
// OpenComm();
}
//------------------------------------------------------------------------
// This function converts an integer to an ASCII string. It is a
// normally provided as a standard library function but the Keil
// libraries do not include it. Caution: The string passed to this
// must be at least 12 bytes long
//------------------------------------------------------------------------
char * itoa(UINT value, char * buf, UCHAR radix)
{
UINT i;
char * ptr;
char * temphold;
temphold = buf;
ptr = buf + 12;
*--ptr = 0; // Insert NULL char
do
{
// First create string in reverse order
i = (value % radix) + 0x30;
if(i > 0x39) i += 7;
*--ptr = i;
value = value / radix;
} while(value != 0);
// Next, move the string 6 places to the left
// Include NULL character
for( ; (*buf++ = *ptr++); );
return(temphold);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?