This release of eCos ships with an implementation of serial device drivers for the evaluation board.
A C API is provided to allow programs to access the devices, although not all details of the API are firm in this release, and they might change significantly in the future.
C programs which want to access the serial device driver should include the file cyg/devs/common/table.h
Most serial port system calls use a cookie, which is a handle for the particular serial device, and an I/O Request Block (IORB).
An IORB contains several fields. The following are of interest to the C API:
The address of the data to be read or written.
The length (in bytes) of the data block.
The amount of data (measured in bytes) which was actually read or written.
Flags which modify the behavior of the read and write operations, for example specifying that a block of linked IORBs should be written atomically. These flags are not yet implemented.
A code describing the status of the I/O operation is placed here. This is currently always set to 0, which means OK.
Data which can be used by the callback routine.
This is a function which the user can install and will be invoked by the asynchronous versions of the read and write calls, as soon as the operation is complete. pcallback() will be invoked with the very same IORB as an argument. For the blocking versions of read and write, this field is used internally.
A pointer to the next IORB when a linked chain of requests is used. This is currently only used internally.
Programmers who use the device driver calls will want to examine (and maybe change) the following configuration options, which are not available with the Configuration Tool.
In the files serial_mn10300_1.h and serial_mn10300_2.h you will find the options CYG_DEVICE_SERIAL_RS232_MN10300_1_KMODE_POLLED (enabled by default) and CYG_DEVICE_SERIAL_RS232_MN10300_2_KMODE_POLLED (enabled by default). These affect the basic mode of operation by allowing polled reads and writes.
You will also find CYG_DEVICE_SERIAL_RS232_MN10300_1_KMODE_INTERRUPT and CYG_DEVICE_SERIAL_RS232_MN10300_2_KMODE_INTERRUPT which allow the two serial ports to be accessed in interrupt driven mode. If DSRs are configured in the kernel (see the section called Component: Use delayed service routines (DSRs) in Chapter 14), both of these options will be enabled by default .
The serial port baud rates are also defined in these files: the default settings are
#define CYG_DEVICE_SERIAL_RS232_MN10300_1_DEFAULT_BAUD_RATE 19200 #define CYG_DEVICE_SERIAL_RS232_MN10300_2_DEFAULT_BAUD_RATE 38400
In the file serial_tx39.h you will find the option CYG_DEVICE_SERIAL_RS232_TX39_KMODE_POLLED which is enabled by default. This option affects the basic mode of operation by allowing polled reads and writes.
You will also find CYG_DEVICE_SERIAL_RS232_TX39_KMODE_INTERRUPT which allows the serial ports to be accessed in interrupt driven mode. If DSRs are configured in the kernel (see the section called Component: Use delayed service routines (DSRs) in Chapter 14), this option will be enabled by default .
The serial port default baud rate is also defined in this file. The default setting is:
#define CYG_DEVICE_SERIAL_RS232_TX39_DEFAULT_BAUD_RATE 38400