Establishing A Connection To The Device - Motorola USB08 Reference Manual

Universal serial bus evaluation board using the mc68hc908jb8
Table of Contents

Advertisement

Universal USB Device Driver (USBIO)
E.4.2 Establishing a Connection to the Device
Designer Reference Manual
144
Handle2 and Handle3 are called pipe handles. Note that while Handle1
cannot be used to communicate with a pipe, any operation on the device
can be executed by using Handle2 or Handle3, too.
The following code sample demonstrates the steps that are necessary
at the USBIO API to establish a handle for a device and a pipe. The code
is not complete, no error handling is included.
// include the interface header file of USBIO.SYS
#include "usbio_i.h"
// device instance number
#define DEVICE_NUMBER
// some local variables
HANDLE FileHandle;
USBIO_SET_CONFIGURATION SetConfiguration;
USBIO_BIND_PIPE BindPipe;
HDEVINFO DevInfo;
GUID g_UsbioID = USBIO_IID;
SP_DEVICE_INTERFACE_DATA DevData;
SP_INTERFACE_DEVICE_DETAIL_DATA *DevDetail = NULL;
DWORD ReqLen;
DWORD BytesReturned;
// enumerate the devices
// get a handle to the device list
DevInfo = SetupDiGetClassDevs (&g_UsbioID,
NULL,NULL,DIGCF_DEVICEINTERFACE|DIGCF_PRESENT);
// get the device with index DEVICE_NUMBER
SetupDiEnumDeviceInterfaces (DevInfo, NULL,
&g_usbioID, DEVICE_NUMBER, &DevData );
// get length of detailed information
SetupDiGetDeviceInterfaceDetail (DevInfo, &DevData, NULL,
// allocate a buffer
DevDetail = (SP_INTERFACE_DEVICE_DETAIL_DATA*) malloc (ReqLen);
// now get the detailed device information
DevDetail->cbSize = sizeof(SP_INTERFACE_DEVICE_DETAIL_DATA);
SetupDiGetDeviceInterfaceDetail (DevInfo, &DevData, DevDetail,
// open the device, use OVERLAPPED flag if necessary
// use DevDetail->DevicePath as device name
FileHandle = CreateFile(
DevDetail->DevicePath,
GENERIC_READ|GENERIC_WRITE,
FILE_SHARE_WRITE|FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
0 /* or FILE_FLAG_OVERLAPPED */,
NULL);
Universal USB Device Driver (USBIO)
0
0, &ReqLen, NULL);
ReqLen, &ReqLen, NULL);
USB08 Evaluation Board
MOTOROLA

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mc68hc908jb8

Table of Contents