LCD Display
The LCD Driver DLL
The LCD display requires a complex sequence of instructions for displaying characters on the display. These instructions are abstracted away from user or application programs so that the precise implementation of the display does not have to be known by the application programmer.
The Interface
Data is sent to the LCD display in essentially two ways. Either a control sequence is sent or a data sequence is sent. When a control byte is sent, the RS line is dropped low. Likewise, when a data byte is sent, this RS line is held high.
On both data sequences and control sequences, the Enable line is held high, the data byte is sent, and finally the enable line is dropped low again. A delay is required between each command or data byte sent to the LCD display, and this is implemented via the Sleep(time) call.
The CE interface
In order to send bytes to the LCD display using the ISA interface, a write to a port must be performed. In Windows CE, this is allowed by using calls from CEDDK.DLL. Specifically, the call necessary to write to a port is WRITE_PORT_UCHAR(). The device driver for the LCD display relies on the CEDDK.DLL file. The LCD driver DLL is implemented as a user-mode, monolithic device driver. Since the hardware interface allows RS and Enable lines are written using port 0x3e1 and the data lines written using port 0x3e0, two different ports are written in this driver.
The Applications Interface
Two calls are exported by this DLL. LCD_init() is used by the application to initialize the LCD screen. LCD_put_data_string() is used to output a particular data string to the display. The LCD_put_data_string() resets the starting position of the cursor to the beginning of the display. Both of these functions call other functions within the DLL (but are not exported) to handle the specifics of outputting to a port.
The LCD Display driver could have been a lot cleaner, requiring only one app to access it at once, and even looking at tuning the timings down. However, this driver works and serves as a building block for a more complex and robust driver.
Miscellaneous DLL Information
Functions are exported by the DLL by using the __declspec(dllexport) identifier before the function declaration. Another requirement for a DLL is that it contains an entry point. This entry point typically can perform initializations, but in this case it simply returns true, indicating a successful link to the DLL. This entry point was created by using the wizard to create a DLL within Platform Builder.
Click here to view the DLL file