Share via


Port the Sample Stream Driver (Compact 7)

3/12/2014

Because most Windows Embedded Compact 7 device drivers are stream drivers, Microsoft provides a sample stream driver that you can use to begin developing your device driver. The sample driver code that is described in the following steps does not actually work with specific hardware; you must modify this driver code for it to function correctly with your target device. To port the sample stream driver:

  1. If you have not already done so, use the integrated development environment (IDE) in Platform Builder to create an OS design. For more information about creating an OS design, see Design Your First OS.

  2. Copy the sample stream driver to your OS design. The sample stream driver is located at %_WINCEROOT%\platform\BSPTemplate\src\drivers\streamdriver.

  3. Rename the sample stream driver source files to names that correspond with the functionality you intended for your device driver. You can rename the SDT prefix of each function to a prefix that you choose for your device driver.

  4. Edit the TARGETNAME and SOURCES values in the sources file so that your driver corresponds with your new file names.

  5. Verify that your driver entry points are correctly exposed to the build system. As shown in the sample stream driver source, you should include each function in the .def file and preface each function with an extern "C" declaration in the .cpp file.

    Note

    After you complete steps 1-5 and have a basic driver shell, verify that you can build your device driver, include it in a run-time image, and access it from a simple test application before adding more functionality in steps 6-9.

  6. Modify the source code for your driver to implement the stream interface functions. You can start by implementing code to manage open and device contexts. For more information about managing context, see Manage Device Driver Context.

  7. Add functionality to control your hardware, including interrupt handling, DMA processing, data marshaling, device interface support, and power management as required. We recommend that you first create header files with constants and data structures that represent your hardware before writing hardware-specific code. Note that adding functionality to control your hardware is typically the bulk of the process to implement your device driver.

  8. Add code to connect the functionality you implement in step 7 to the stream interfaces of your driver.

  9. If your driver must support additional functionality beyond that which the stream interface functions expose, you can choose to implement custom I/O control codes in the IOControl function of your driver.

When you are ready to build your device driver, see Build and Test Your Device Driver for information about how to add registry information for your driver to the Platform.reg file, how to modify Platform.bib and build system files so that the OS design includes your driver, how to build a run-time image with your device driver, and how to test your device driver.

See Also

Concepts

Implement Your Device Driver