
Universal USB Device Driver (USBIO)
Architecture
USB08 Evaluation Board Designer Reference Manual
MOTOROLA Universal USB Device Driver (USBIO) 145
// setup the data struc ture for configuration
// use the configuration descrip to r wi th index 0
SetConfiguration.Config ur ati onIndex = 0;
// device has 1 interface
SetConfiguration.NbOfIn te rfa ces = 1;
// first interface is 0
SetConfiguration.Interf ac eLi st[0].InterfaceIndex = 0;
// alternate setting fo r first interface is 0
SetConfiguration.Interf aceList[0].AlternateSett ingIndex = 0;
// maximum buffer size for read/write operation is 4069 bytes
SetConfiguration.Interf aceList[0].MaximumTransf erSize = 4096;
// configure the device
DeviceIoControl(FileHan dle,
IOCTL_USBIO_SET_CONFIGU RATION,
&SetConfiguration, sizeof (Se tC onfiguration),
NULL,0,
&BytesReturned,
NULL
);
// setup the data structure to bind th e fil e ha ndle
BindPipe.EndpointAddres s = 0x8 1; // the device has an endpoint 0x81
// bind the file handle
DeviceIoControl(FileHan dle,
IOCTL_USBIO_BIND_PIPE
&BindPipe, sizeof(BindPip e),
NULL,0,
&BytesReturned,
NULL
);
// read (or write) data from (to) the device
// use OVERLAPPED structure if necessary
ReadFile(FileHandle, ...) ;
// close file handle
CloseHandle(FileHandle) ;
Refer to the Win32 API documentation for the syntax and the
parameters of the functions SetupDiXxx, CreateFile,
DeviceIoControl, ReadFile, WriteFile, CloseHandle. The file
handle can be opened with the FILE_FLAG_OVERLAPPED flag if
asynchronous behaviour is required.
More code samples that show the usage of the USBIO programming
interface can be found in the USBIO Class Library (USBIOLIB), the
USBIO demo application (USBIOAPP), and the simple console
applications ReaderCpp and ReadPipe.