![Elektor EPROM Скачать руководство пользователя страница 20](http://html1.mh-extra.com/html/elektor/eprom/eprom_manual_2386336020.webp)
selected VID and PID numbers. This means
that conflicts can arise with devices from
other manufacturers. We suggest changing
the VID number to ‘8B16’ and the PID number
to ‘A001’.
The VID (vendor ID), PID (product ID) and
DID (device ID) form a set of three 16-bit data
words that the Cypress IC reports to the ope-
rating system. The VID and PID numbers are
used to search for, install and load
the device driver.
In order to be able to use your
VID and PID with the Cypress IC,
you will need an EEPROM.
Figure 2
shows how an 8-KB EEPROM can be
added to the circuit used in Part 1 of
this article series. Program the follo-
wing sequence of numbers into the
EEPROM, starting at address 0:
B0h
start byte
copy IDs
16h, 8Bh VID = 8B16h
01h, A0h PID = A001h
01h, 00h DID = 0001h
The next time the USB device is
plugged in, the Cypress IC will
report this new identifier to the ope-
rating system, allowing Windows to
install a suitable driver.
Using C++ to modify the
SYS device driver
Start Visual C++ Studio, select
‘Open Working Area’ from the ‘File’
menu and open the file named
MICRO
CONTROLLER
32
Elektor Electronics
11/2002
Figure 3. Testing the device driver in BinTerm.
Table 2
NTSTATUS DriverEntry( IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath)
{ NTSTATUS ntStatus = STATUS_SUCCESS;
PDEVICE_OBJECT deviceObject = NULL;
: :
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = Ezusb_ProcessIOCTL;
: :
DriverObject->DriverExtension->AddDevice = Ezusb_PnPAddDevice;
: :
}
Table 3
NTSTATUS Ezusb_CreateDeviceObject(IN PDRIVER_OBJECT DriverObject,
IN PDEVICE_OBJECT *DeviceObject, LONG Instance)
{ NTSTATUS ntStatus;
WCHAR deviceLinkBuffer[] = L
”\\DosDevices\\Ezusb-0”
;
UNICODE_STRING deviceLinkUnicodeString;
WCHAR deviceNameBuffer[] = L
”\\Device\\Ezusb-0”
;
: :
deviceLinkBuffer[
18
] = (USHORT) (‘0’ + Instance);
deviceNameBuffer[
14
] = (USHORT) (‘0’ + Instance);
Table 4
NTSTATUS Ezusb_ProcessIOCTL(IN PDEVICE_OBJECT fdo, IN PIRP Irp)
{ : :
switch (ioControlCode)
{
case
IOCTL_Ezusb_VENDOR_REQUEST: // = $00222014
length = Ezusb_VendorRequest (fdo, (PVENDOR_REQUEST_IN) ioBuffer);
if (length)
{ Irp->IoStatus.Information = length;
Irp->IoStatus.Status = STATUS_SUCCESS;
} else
{ Irp->IoStatus.Status = STATUS_SUCCESS;
}
break;
Содержание EPROM
Страница 1: ......