02.03.2014 Views

BSP Developer's Guide

BSP Developer's Guide

BSP Developer's Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

VxWorks 5.5<br />

<strong>BSP</strong> Developer’s <strong>Guide</strong><br />

driver would not reside in the target/src/drv directory but in a <strong>BSP</strong>-specific<br />

directory (from which the <strong>BSP</strong>’s sysLib.c can include the driver when needed).<br />

F.2 Serial Drivers<br />

Generic serial drivers reside in the directory target/src/drv/serial. Included in this<br />

directory is templateSerial.c and its corresponding header file, templateSerial.h.<br />

These files contain very detailed information on the design and construction of a<br />

typical serial driver. When writing a serial driver, base the driver on this template,<br />

then modify the <strong>BSP</strong>’s sysLib.c or sysSerial.c files to include the driver as needed.<br />

NOTE: Serial drivers are provided for backward compatibility with VxWorks 5.2<br />

and earlier. All Tornado-era <strong>BSP</strong>s should instead use the SIO drivers.<br />

To manage information about a serial device, sysLib.c uses a device descriptor.<br />

This device descriptor also encapsulates board-specific information. For example,<br />

it typically includes the frequency of the clock and the addresses of the registers,<br />

although the details are dictated by the device in question. In sysLib.c, the serial<br />

device descriptor is declared outside the function definitions as:<br />

TY_CO_DEV tyCoDv [NUM_TTY]; /* structure for serial ports */<br />

This array is initialized at run-time in sysHwInit( ). The TY_CO_DEV structure is<br />

defined in the device header file (for example, target/h/drv/serial/z8530.h). The<br />

following members of the TY_CO_DEV structure are common to all serial drivers:<br />

tyDev<br />

Required by tyLib, the VxWorks tty driver support library.<br />

created<br />

A flag that must be initialized to FALSE in sysHwInit( ).<br />

numChannels<br />

Used for parameter checking.<br />

The following macros must be defined for all <strong>BSP</strong>s:<br />

NUM_TTY<br />

Defines the number of serial channels supported. In configAll.h, the default<br />

defined as 2. To override the default, first undefine then define NUM_TTY in<br />

config.h. If there are no serial channels, define NUM_TTY as NONE.<br />

248

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!