
68
void init_rs232(void)
{
outportb(RS232+3,0x80);
//Enable
DLAB
outportb(RS232+1,0x00);
//600bps-115200bps
outportb(RS232,0x0c);
//9600bps
outportb(RS232+3,0x03);
//LCR
(8N1)
outportb(RS232+4,0x03);
//MCR
outportb(RS232+1,0x00);
//IER
}
void send_buffer(char *buffer
//Send a string to RS-232
{
unsigned int i;
for
(i=0;i<=20;i++)
{
send(buffer[i]);
putchar(buffer[i]);
if
(buffer[i]=='\n')
break;
}
}
void
tkecho(char
*buffer)
//Wait for a specific string
{
unsigned int i=0;
while
(1)
{
if(buffer[i]==read())
{
putchar(buffer[i]);
if
(buffer[i]=='\n')
break;
i++;
}
}
}
char* tkdata(char* buffer)
//Get a string from RS232 and return the decimal point position.
{
unsigned int i=0;
while
(1)
{
buffer[i]=read();
if
(((i>0)&&(buffer[i]=='\n'))||(i>30))
break;
if((buffer[i]>33)&&(buffer[i]<126))
i++;
}
+i]=0;
return buffer;
}
void send(char p)
{
unsigned int retry=0;