www.pudn.com > tcpip5151.rar > Serial.c
//----------------------------------------------------------------------------- // Net SERIAL.C // // This module handles RS-232 messages and associated tasks //----------------------------------------------------------------------------- #include#include #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); }