Motorola USB08 User Manual

Page 145

Advertising
background image

Universal USB Device Driver (USBIO)

Architecture

USB08 Evaluation Board

Designer Reference Manual

MOTOROLA

Universal USB Device Driver (USBIO)

145

// setup the data structure for configuration

// use the configuration descriptor with index 0
SetConfiguration.ConfigurationIndex = 0;

// device has 1 interface

SetConfiguration.NbOfInterfaces = 1;

// first interface is 0
SetConfiguration.InterfaceList[0].InterfaceIndex = 0;

// alternate setting for first interface is 0

SetConfiguration.InterfaceList[0].AlternateSettingIndex = 0;

// maximum buffer size for read/write operation is 4069 bytes
SetConfiguration.InterfaceList[0].MaximumTransferSize = 4096;

// configure the device

DeviceIoControl(FileHandle,

IOCTL_USBIO_SET_CONFIGURATION,

&SetConfiguration, sizeof(SetConfiguration),

NULL,0,

&BytesReturned,
NULL

);

// setup the data structure to bind the file handle
BindPipe.EndpointAddress = 0x81; // the device has an endpoint 0x81

// bind the file handle

DeviceIoControl(FileHandle,

IOCTL_USBIO_BIND_PIPE
&BindPipe, sizeof(BindPipe),

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.

Advertising