Code Example: A Timer-Based Driver

This modified version of the parallel port driver disables interrupts and uses a CustomTimerDpc routine to transfer data at fixed intervals. The code for this example is included on the companion CD and on the companion Web site, http://www.W2KDriverBook.com.

Device Extension Additions

The Device Extension is modified to include the DPC and Timer objects, plus a polling interval value, stored in microseconds.

 typedef struct _DEVICE_EXTENSION { ... KDPC pollingDPC; // reserve custom DPC object KTIMER pollingTimer; // and the Timer object LARGE_INTEGER pollingInterval; // timeout counter // in us ... } DEVICE_EXTENSION, *PDEVICE_EXTENSION; // Define the interval between polls of device in us // 100 us #define ...

Get Windows® 2000 Device Driver Book: A Guide for Programmers, Second Edition, The now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.