CS 273

Homework 9

Due Friday, May 4, 2001

note -- since I have to leave on Saturday, May 5, it won't be possible to grant extensions on this assignment

Not From the Book

You guessed it: a driver for the serial port. Since the serial port can do both input and output (it's the first device we've dealt with that does), you'll need two functions this time. Also, since the serial port has to be initialized before use, an initialization function is needed.

serinit

Synopsis
void serinit(void)

This function initializes the serial port to run at 9600 baud.

serin

Synopsis
unsigned char serin(void)
No parameters
Return Value
Character sent down serial line. If there is an error (framing error, data overrun, or noise) return -1.
Known Bug
As with the analog driver, there is no way to distinguish an error return from a DEL character.

When the user calls serin(), the program blocks until a character is available in the serial port. When the character becomes available, read and return it.

serout

Synopsis
void serout(unsigned char val)
Parameter
character to be written
No return value

When the user calls serout(), it waits until it's possible to send a character, and sends it down the line.

Testing the Driver

The other drivers you've written have been tested by using them in the lab. For this driver, I want a test program that will go into a loop, and for every character entered by the user, echo it three times.


Last modified: Wed Apr 25 10:55:17 MDT 2001