How to Create a Device Driver (Windows Embedded CE 6.0)

1/6/2010

After you create an OS design, you can create a device driver for a specific target device to operate under the Windows Embedded CE operating system (OS). You create your driver once you have identified the hardware that you want use with the OS.

Hardware and Software Assumptions

  • The sample driver code demonstrated in the following steps is merely a starting point and does not actually work with specific hardware. You must modify the driver code in order for it to function correctly for your target device.
  • You are creating a power-managed stream interface driver. For more information about stream interface drivers, see Stream Interface Driver Development Concepts. For more information about power management, see Power Management.
  • You are familiar with using the Platform Builder command line build tool. For more information, see Build Tool.
  • You are familiar with the driver development tools for Windows Embedded CE. **
Step Topic

1. Familiarize yourself with the code structure for Windows Embedded CE device drivers.

Layered Drivers vs. Monolithic Drivers

2. Familiarize yourself with driver development for Windows Embedded CE.

Developing a Device Driver

3. If you have not already done so, in the Platform Builder integrated development environment (IDE), create an OS design.

Creating an OS Design

4. Copy the power management development sample driver to your OS design.

For example, copy %_WINCEROOT%\Public\Common\Oak\Drivers\PM\Test\Devsample to %_WINCEROOT%\Platform\<your OS design>\drivers\<your driver name>.

Not applicable

5. Rename the power management development sample driver files to names that correspond with the intended functionality of your driver.

Not applicable

6. Edit the TARGETNAME and SOURCES values in the sources file for your driver to correspond with your new file names.

Not applicable

7. Add WINCEOEM=1 to the sources file for your driver to allow your driver access to %_WINCEROOT%\Public. For more information on sources files, see Sources File.

Not applicable

8. Modify the source code for your driver to implement the correct stream interface functions.

The power management development sample includes support for the stream interface functions. The XXX prefix for these functions has been replaced with PDX.

Stream Interface Driver Implementation

9. If your driver requires functionality in addition to the functionality provided by the stream interface functions, you may choose to implement custom I/O control codes.

I/O Control Codes

10. Verify that the entry points for your driver are exposed correctly. The functions should either be declared using a .def file or by using the extern "C" declarator.

The sample .def file for the power management development sample driver is located at %_WINCEROOT%\Public\Common\Oak\Drivers\PM\Test\Devsample\Pmdevsample.def.

For more information on the extern "C" declarator, see Stream Interface Driver Implementation.

Not applicable

11. Add registry information for your driver to the Platform.reg file for your OS design.

For example, you can add the following code example to the Platform.reg file to specify the correct registry information for your driver.

#include "$(_winceroot)\platform\<your OS design>\drivers\<your driver name>\<your driver name>.reg"

Registry File

12. Modify the Platform.bib file for your OS design to include your driver.

For example, you can add the following code example to the Modules section of the Platform.bib file to specify the correct location of your driver.

MyDriver.dll    $(_FLATRELEASEDIR)\<your driver name>.dll          NK SH

Binary Image Builder File

13. Edit the dirs file for your OS design to include your driver.

Dirs File

14. From %_WINCEROOT%\Platform\<your OS design>\Drivers\<your driver name> in your OS design, build your driver.

Building a Device Driver from the Command Line

15. In the IDE, build your run-time image to include your driver.

Building a Run-Time Image

16. Test your driver using the Windows Embedded CE 6.0 Test Kit (CETK).

How to Use the CETK to Test a Driver

See Also

Tasks

Troubleshooting a Device Driver

Concepts

Layered Drivers vs. Monolithic Drivers
Stream Interface Driver Development Concepts

Other Resources

Device Driver Development How-to Topics
Device Driver Development Overview
Build Tool
Sources File