There may be times when you choose to write your driver directly, without using DriverWizard. In such cases, either follow the steps outlined in this section to create a new driver project, or use one of the WinDriver samples, which most closely resembles your target driver, and modify the sample to suit your specific requirements.
Include the relevant WinDriver header files in your driver project.
All header files are found under the
WinDriver/include directory.
On Mac OS X, when using the WDAPI framework, the header files include path
is
/Library/Frameworks/WDAPI.framework/Headers.
All WinDriver projects require the windrvr.h
header file.
When using the WDC_xxx API [B.2], include the
wdc_lib.h and
wdc_defs. header files (these files
already include windrvr.h).
Include any other header file that provides APIs that you wish to use from your code (e.g., files from the WinDriver/samples/shared directory, which provide convenient diagnostics functions.)
#include "windrvr.h"
You can also include the library's source files in your project instead of linking the project with the library. The C source files are located under the WinDriver/src/wdapi directory.
![]() | |
|
When linking your project with the WDAPI library/framework/shared object, you will need to
distribute this binary with your driver. For Windows, get wdapi1020.dll / wdapi1020_32.dll (for 32-bit applications targeted at 64-bit platforms) from the WinDriver\redist directory. For Mac OS X, get WDAPI.framework from the OS /Library/Frameworks directory. For Linux, get libwdapi1020.so / libwdapi1020_32.so (for 32-bit applications targeted at 64-bit platforms) from the WinDriver/lib directory. |
Note: On Windows and Linux, when using the DLL/shared object file
for 32-bit applications on 64-bit platforms
(wdapi1020_32.dll /
libwdapi1020_32.so), rename the
copy of the file in the distribution package, by removing the
_32 portion [A.2].
For detailed distribution instructions, refer to
Chapter 14.
This section outlines the calling sequence when using the
WDC_xxx API [B.2].
WDC_DriverOpen() [B.3.2]
to open a handle to WinDriver and the WDC library, compare the version of the
loaded driver with that of your driver source files, and register your
WinDriver license (for registered users).
WDC_PciScanDevices() [B.3.4]
WDC_PcmciaScanDevices() [B.3.7] to scan the PCI/PCMCIA bus and locate
your device.
WDC_PciGetDeviceInfo() [B.3.8]
WDC_PcmciaGetDeviceInfo() [B.3.9] to retrieve the resources
information for your selected device.WD_CARD structure.
WDC_PciDeviceOpen() [B.3.10]
WDC_PcmciaDeviceOpen() [B.3.11]
WDC_IsaDeviceOpen() [B.3.12]
(depending on your device) and pass to the function the device's resources
information. These functions return a handle to the device, which you can
later use to communicate with the device using the WDC_xxx
API.
WDC_xxx API (see
description in Appendix B).WDC_IntEnable() [B.3.46].WDC_EventRegister() [B.3.49].
WDC_IntDisable() [B.3.47] to disable interrupt handling (if previously
enabled), call WDC_EventRegister() [B.3.49] to unregister Plug-and-Play and power
management event handling (if previously registered), and then call
WDC_PciDeviceClose() [B.3.13]
WDC_PcmciaDeviceClose() [B.3.14]
WDC_IsaDeviceClose() [B.3.15] (depending on your device) in order to
close the handle to the device.
WDC_DriverClose() [B.3.3] to close the handles to WinDriver and the WDC
library.
After including the required files and writing your code, make sure that the required build flags and environment variables are set, then build your code.
![]() | |
Before building your code, verify that the WD_BASEDIR environment
variable is set to the location of the of the WinDriver installation directory.
On Windows, Windows CE, and Linux you can define the WD_BASEDIR
environment variable globally – as explained in Chapter 3: For Windows – refer to the
Windows WD_BASEDIR note in
section 3.2.1; for Windows CE – refer
to section 3.2.2.3; for Linux:
refer to section 3.2.4.2,
step 9.
On Mac OS X, you need to add a WD_BASEDIR definition to each driver
project. When generating code with DriverWizard [4], this is done automatically. To add this definition
manually – open your project with Xcode, select , and add a
WD_BASEDIR definition that points to your WinDriver installation
directory.
|