Wince usb client driver develop steps

1) implement 3 APIinterface for USB stack

BOOLUSBInstallDriver(LPCWSTR szDriverLibFile);

BOOLUSBUnInstallDriver(void);

BOOL USBDeviceAttach/*DGCPP2ISQP-ISQP Metric 7-SCC_GRANT_0005*/

(

USB_HANDLE hDevice,// @parm [IN] - USBdevice handle

LPCUSB_FUNCS lpUsbFuncs,// @parm [IN] - Pointer toUSBDI function table

LPCUSB_INTERFACE lpInterface,// @parm [IN] - If client isbeing loaded as an interface

LPCWSTR szUniqueDriverId,// @parm [IN] - Contains client driver idstring

LPBOOL fAcceptControl,// @parm [OUT]- Filled inwith TRUE if we accept control

LPCUSB_DRIVER_SETTINGSlpDriverSettings,// @parm [IN] -Contains pointer to USB_DRIVER_SETTINGS

DWORD dwUnused);

Hcd enume interface, foreach interface, hcd will compare to registery load path and find the best fitone, and then load the dll pointed in the registery key. In the dll we needimplement the above 3 functions. Then USB stack will call the USBDeviceAttachfunction. In this function, we need to check if the interface is we support, ifyes, to parse descriptors and get some information what we need, such as maxpacket size.


2)configure settings andprepare transfer data

After we get theLPCUSB_FUNCS from USB stack by USBDeviceAttach function, we can useLPCUSB_FUNCS IssueVendorTransfer to get and set some configurations.

And we can open pipe bylpOpenPipe of LPCUSB_FUNCS, then we can use the handle of pipe to read or writedata


3)processing detach

When usb deviceattaching, we need to do another thing to register a call back function to getevent or status from USB stack by the function lpRegisterNotificationRoutine ofLPCUSB_FUNCS.

So if device detach, USBstack will the the registered callback function to notify client driver thedevice detach, here we need to stop application and exit itself and deletesource alloced when usb device attach.


你可能感兴趣的:(driver,client,usb)