Next: , Previous: , Up: Code Listings   [Contents]


A.5 I/O code sample

#include "w89k.h"

/*
 * outbyte -- shove a byte out the serial port. We wait till the byte 
 */
int
outbyte(byte)
     unsigned char byte;
{
  while ((inp(RS232REG) & TRANSMIT) == 0x0) {  } ;
  return (outp(RS232PORT, byte));
}

/*
 * inbyte -- get a byte from the serial port
 */
unsigned char
inbyte()
{
  while ((inp(RS232REG) & RECEIVE) == 0x0) { };
  return (inp(RS232PORT));
}