DDK Sample Design |
ZiLOG Application Note |
---|
How to create and install a XINU driver for eZ80 family of processors |
Author: Andrei Kovalev FAE ZiLOG Germany |
There are two methods of driver initialization.
One method is direct where the driver initialized on its own
and the physical channel initialized using control
function.
The other method is where the UART is initialized by
IPWorks originally and then the driver is installed and used on that
channel. This method is provided to allow the user to use the IPWorks
serial API while working with the COM driver.
Using direct method is very simple.
First, the con_init()
function must be called to install the
driver. After that the control
function is used to setup
the UART parameters. See the following example.
con_init(); xprintf("\nSerial COM driver installed\n"); hReceiver = open( hCOM1, "COM1:", (char*)0 ); xprintf("\nOpened COM1:"); // setup the serial port control( hReceiver, SET_RATE, (char*)56700, 0); // set the line control value control( hReceiver, SET_LINE, (char*)lcr_value , 0); // set the flow control control( hReceiver, SET_FLOW, (char*)COM_FLOW_HARD, 0);
Notice that the xprintf(char*)
should be used as soon
the port is opened.
To provide maximum compatibility to IPWorks and to avoid excessive
reconfiguration most of the low level hardware initialization is left to be
done by the IPWorks. Use the standard serparams
structure
of IPWorks to define the serial communication parameters.
struct serialparam serparams[2] = { {57600, 8, 2, PARNONE, SERSET_ONLCR | SERSET_IGNHUP}, {57600, 8, 1, PARNONE, } };
The serparams
structure is defined in the serial_conf.c
file which is typically can be located in the conf subdirectory of
IPWorks installation.
the com_init()
function is used to install the driver in a XINU
device table. This function creates the two new serial devices - hCOM1 and
hCOM2 and add the corresponding device entries to the XINU device table using
the following command sequence
extern struct devsw comdev; int comdevice; if( (comdevice=adddevice( &comdev, 0)) != SYSERR ) { devtab[comdevice]. dvinit(&devtab[comdevice]); . . .
The comdev
structure of the type struct devws
already exists in the driver and is taken from the library.
The addevice
function of XINU API uses this descriptor to
put the structure information into the system device table devtab
.
The variable devtab
is described in the conf.h header
file.
As soon as a COM device is initialized and opened the interrupt for the corresponding UART is enabled. The character transmission and reception can then begin.