Microsoft Windows CE 3.0  

Sample Serial Port Driver

Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

The serial port driver handles any I/O devices that behave like serial ports, including those based on 16450 and 16550 universal asynchronous receiver-transmitter (UART) chips and those that use direct memory access (DMA). Many Windows CE–based platforms have devices of this type, including ordinary nine-pin serial ports, infrared I/O ports, and PC Card serial devices, such as modems. If multiple types of serial ports exist on a platform, you can either create several different serial drivers, one per serial port type, or create several different PDD layers and link them to a single MDD, thus creating one multipurpose serial driver. Either approach is equally acceptable. Creating separate drivers can simplify debugging and maintenance because each driver supports only one type of port. Creating a multipurpose driver, such as the sample serial port driver for the Windows CE reference platform, is more complex but gives a small memory savings.

The Windows CE Platform Builder 3.0 contains implementations of the serial port MDD. The first implementation was included with Windows CE version 2.12, and is provided for use by legacy PDDs. This legacy MDD code is located in the \Public\Common\Oak\Drivers\Serial directory of your Platform Builder installation. There is also a new serial MDD which addresses some transmission performance issues in the original MDD, but requires some modifications to existing PDDs. This new serial MDD is in the \Public\Common\Oak\Drivers\Com_mdd2 directory. The sample Odo PDD still uses the original MDD, and is located in the Platform\Odo\Drivers\Serial directory. The sample CEPC platform includes PDD implementations for both the original and new MDDs. The legacy CEPC PDD implementation is in the \Platform\CEPC\Drivers\Serial.pdd directory, while the new PDD is located in the \Platform\CEPC\Drivers\Com16550 directory.

In addition to the serial MDDs and PPDs, Microsoft supplies a library for supporting 16550 compatible UARTS. This library is in the \Public\Common\Oak\Drivers\Ser16550, and is used by the CEPC sample PDDs.

The COM_Openfunction in the serial port MDD does not implement the fErrorChar, fNull, and fAbortOnCharmembers of the serial device control block (DCB) structure. OEMs must add support for this functionality in your PDD layer, if it is appropriate for their serial port hardware.

Because the functionality of serial ports maps easily to the functionality provided by standard stream interface functions, the serial port driver uses the stream interface functions as its DDI. Like other drivers that expose stream interface functions, the serial driver is loaded by the Device Manager.

Serial port devices make extensive use of I/O control codes to set and query various attributes of a serial port. For example, there are I/O control codes for setting and clearing the Data Terminal Ready (DTR) line, for purging any undelivered data, and for getting the status of a modem device. Therefore, you should support as many IOCTL_SERIALI/O control codes as possible in your implementation of COM_IOControl.

The following list shows the DDI functions for the serial port driver:

COM_Close COM_PowerDown
COM_Deinit COM_PowerUp
COM_INIT COM_Read
COM_IOControl COM_Write
COM_Open  

The following list shows the DDSI functions for the sample serial port driver:

GetSerialObject HWGetModemStatus HWPutBytes
HWClearBreak HWGetRxBufferSize HWReset
HWClearDTR HWGetRxStart HWSetBreak
HWClearRTS HWGetStatus HWSetCommTimeouts
HWClose HWInit HWSetDCB
HWDeinit HWIoctl HWSetDTR
HWDisableIR HWLineIntrHandler HWSetRTS
HWEnableIR HWOpen HWTxIntrHandler
HWGetBytes HWPowerOff HWXmitComChar
HWGetCommProperties HWPowerOn  
HWGetIntrType HWPurgeComm  

These function names are listed as they are defined in the sample serial port code. You can change this set of functions or the function names by modifying the serial object table, which is a table of HWOBJtype objects, in the serial port PDD.

Windows CE 3.0 introduces a new serial port MDD implementation, in addition to the original MDD which is still included in Platform Builder to support legacy OEMs. OEMs whose PDDs use the original MDD should make note of the changes in the new MDD, as they significantly improve overall serial port performance. The new design eliminates a large number of thread switches in the data transmit path and thus reduces latency between transmission bursts and improves throughput. The new MDD code is in the Public\Common\Oak\Drivers\Com_mdd directory. New PDD sample code for the CEPC platform, to support the 16550 UART and PC Card-based serial ports, is in Public\Common\Oak\Drivers\Ser_card and Platform\CEPC\Drivers\Com_card.

The new MDD layer makes some changes to the set of serial port DDSI functions.