阅读:7927回复:29
Philips PDIUSBD12编程
打开USB设备
// USB Get device name procedure int TianUSB::USB_GetDeviceName() { GUID mGuid = GUID_CLASS_PDIUSBD12_BULK; HDEVINFO hInfo; int i = 0; char name[MAX_PATH]; // Get device information set获取设备信息集合 hInfo = SetupDiGetClassDevs(&mGuid,NULL,NULL,DIGCF_PRESENT | DIGCF_INTERFACEDEVICE); if(hInfo == INVALID_HANDLE_VALUE) { // Cannot find USB device return 0; } for (i=0; ; ++i) { SP_INTERFACE_DEVICE_DATA Interface_Info; // interface information data Interface_Info.cbSize = sizeof(Interface_Info); // Enumerate device枚举设备 if (!SetupDiEnumInterfaceDevice(hInfo, NULL, (LPGUID) &mGuid,i, &Interface_Info)) { // Enumerate fail SetupDiDestroyDeviceInfoList(hInfo); m_nUsbNumber = i; return(i); } DWORD needed; // get the required lenght SetupDiGetInterfaceDeviceDetail(hInfo, &Interface_Info, NULL, 0, &needed, NULL); PSP_INTERFACE_DEVICE_DETAIL_DATA detail = (PSP_INTERFACE_DEVICE_DETAIL_DATA) malloc(needed); if (!detail) { SetupDiDestroyDeviceInfoList(hInfo); m_nUsbNumber = i; return(i); } // fill the device details detail->cbSize = sizeof(SP_INTERFACE_DEVICE_DETAIL_DATA); if (!SetupDiGetInterfaceDeviceDetail(hInfo, &Interface_Info,detail, needed,NULL, NULL)) { free((PVOID) detail); SetupDiDestroyDeviceInfoList(hInfo); m_nUsbNumber = i; return(i); } strncpy(name, detail->DevicePath, sizeof(name)); free((PVOID) detail); m_strDeviceName = name; // keep a copy of each device name } // end of for loop SetupDiDestroyDeviceInfoList(hInfo); m_nUsbNumber = i; return i; } // Open USB device HANDLE TianUSB::USB_OpenDevice() { HANDLE hUsb; HANDLE hDevice; CString strDevice; IO_BLOCK ioBlock; BOOLEAN bResult = FALSE; ULONG nBytes = 0; char c; int i; if(!USB_GetDeviceName()) return NULL; for(i=0;i<m_nUsbNumber;i++) { // 利用设备名加端口名(PIPE00)打开USB设备-->文件句柄 strDevice = m_strDeviceName; strDevice += "\\PIPE1"; hUsb = CreateFile(strDevice,GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL ); if(hUsb) break; } hMyUsb = hUsb; if(hUsb != INVALID_HANDLE_VALUE) { if(!USB_GetDeviceName()) return NULL; for(i=0;i<m_nUsbNumber;i++) { // 利用设备名加端口名(PIPE00)打开USB设备-->文件句柄 strDevice = m_strDeviceName; strDevice += "\\PIPE00"; hDevice = CreateFile(strDevice,GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL ); //DWORD t=IOCTL_READ_REGISTERS; bResult = DeviceIoControl(hDevice, // device handle IOCTL_READ_REGISTERS, // control code (PVOID)&ioBlock, // input buffer sizeof(IO_BLOCK), // input buffer size in byte (PVOID)&c, // output buffer 1, // output buffer size in byte &nBytes, // return output buffer length in byte NULL); // overlapped structure if(bResult == FALSE) { UINT err = GetLastError(); CloseHandle(hUsb); CloseHandle(hDevice); } } } return hUsb; } |
|
最新喜欢:![]() |
沙发#
发布于:2008-07-01 13:14
能打个包.这样小弟也看不懂
|
|
板凳#
发布于:2008-06-25 22:55
不懂,回复你.
|
|
地板#
发布于:2008-06-18 10:59
第一次插入USB HOST的USB设备收到的第一个数据包
80 6 0 1 0 0 40 0 ,如不是第一次40的数据有可能就改为你的控制端点的缓冲长度。 |
|
地下室#
发布于:2008-06-18 10:54
今天无奈又来这里看旧帐。幸好往日依旧。两种连接过程依然还在
|
|
5楼#
发布于:2007-01-11 15:13
有点雾里看花
|
|
6楼#
发布于:2007-01-04 16:10
免驱动的D12 HID协议联机通信
D12SuspendProc() 80 D12BusRstProc() 40 D12SuspendProc() 80 D12SuspendProc() 80 D12BusRstProc() 40 0x80 0x06 0x00 0x01 0x00 0x00 0x40 0x00 USB_DataInStage() cnt = 16 EP0Data.Count = 18 0x12 0x01 0x10 0x01 0x00 0x00 0x00 0x10 0x51 0xC2 0x01 0x13 0x00 0x01 0x01 0x04 USB_DataInStage() cnt = 2 EP0Data.Count = 2 0x00 0x01 D12BusRstProc() 40 0x00 0x05 0x01 0x00 0x00 0x00 0x00 0x00 USB_REQUEST_SET_ADDRESS = 5 D12_SetAddressEnable() REQUEST_TO_DEVICE = 0 0x80 0x06 0x00 0x01 0x00 0x00 0x12 0x00 USB_DataInStage() cnt = 16 EP0Data.Count = 18 0x12 0x01 0x10 0x01 0x00 0x00 0x00 0x10 0x51 0xC2 0x01 0x13 0x00 0x01 0x01 0x04 USB_DataInStage() cnt = 2 EP0Data.Count = 2 0x00 0x01 0x80 0x06 0x00 0x02 0x00 0x00 0x09 0x00 USB_DataInStage() cnt = 9 EP0Data.Count = 9 0x09 0x02 0x22 0x00 0x01 0x01 0x00 0x80 0x32 0x80 0x06 0x00 0x02 0x00 0x00 0xFF 0x00 USB_DataInStage() cnt = 16 EP0Data.Count = 34 0x09 0x02 0x22 0x00 0x01 0x01 0x00 0x80 0x32 0x09 0x04 0x00 0x00 0x01 0x03 0x00 USB_DataInStage() cnt = 16 EP0Data.Count = 18 0x00 0x5C 0x09 0x21 0x00 0x01 0x00 0x01 0x22 0x1D 0x00 0x07 0x05 0x81 0x03 0x10 USB_DataInStage() cnt = 2 EP0Data.Count = 2 0x00 0x10 0x80 0x06 0x00 0x03 0x00 0x00 0xFF 0x00 USB_DataInStage() cnt = 4 EP0Data.Count = 4 0x04 0x03 0x09 0x04 0x80 0x06 0x04 0x03 0x09 0x04 0xFF 0x00 USB_DataInStage() cnt = 16 EP0Data.Count = 45 0x2D 0x03 0x4E 0x00 0x45 0x00 0x57 0x00 0x41 0x00 0x52 0x00 0x45 0x00 0x20 0x00 USB_DataInStage() cnt = 16 EP0Data.Count = 29 0x50 0x00 0x54 0x00 0x53 0x00 0x31 0x00 0x2E 0x00 0x30 0x00 0x31 0x00 0x54 0x00 USB_DataInStage() cnt = 13 EP0Data.Count = 13 0x52 0x00 0x43 0x00 0xEF 0xCC 0x00 0xD9 0xC8 0x00 0xC5 0xB2 0x00 0x80 0x06 0x00 0x03 0x00 0x00 0xFF 0x00 USB_DataInStage() cnt = 4 EP0Data.Count = 4 0x04 0x03 0x09 0x04 0x80 0x06 0x04 0x03 0x09 0x04 0xFF 0x00 USB_DataInStage() cnt = 16 EP0Data.Count = 45 0x2D 0x03 0x4E 0x00 0x45 0x00 0x57 0x00 0x41 0x00 0x52 0x00 0x45 0x00 0x20 0x00 USB_DataInStage() cnt = 16 EP0Data.Count = 29 0x50 0x00 0x54 0x00 0x53 0x00 0x31 0x00 0x2E 0x00 0x30 0x00 0x31 0x00 0x54 0x00 USB_DataInStage() cnt = 13 EP0Data.Count = 13 0x52 0x00 0x43 0x00 0xEF 0xCC 0x00 0xD9 0xC8 0x00 0xC5 0xB2 0x00 0x80 0x06 0x00 0x01 0x00 0x00 0x12 0x00 USB_DataInStage() cnt = 16 EP0Data.Count = 18 0x12 0x01 0x10 0x01 0x00 0x00 0x00 0x10 0x51 0xC2 0x01 0x13 0x00 0x01 0x01 0x04 USB_DataInStage() cnt = 2 EP0Data.Count = 2 0x00 0x01 0x80 0x06 0x00 0x02 0x00 0x00 0x09 0x00 USB_DataInStage() cnt = 9 EP0Data.Count = 9 0x09 0x02 0x22 0x00 0x01 0x01 0x00 0x80 0x32 0x80 0x06 0x00 0x02 0x00 0x00 0x22 0x00 USB_DataInStage() cnt = 16 EP0Data.Count = 34 0x09 0x02 0x22 0x00 0x01 0x01 0x00 0x80 0x32 0x09 0x04 0x00 0x00 0x01 0x03 0x00 USB_DataInStage() cnt = 16 EP0Data.Count = 18 0x00 0x5C 0x09 0x21 0x00 0x01 0x00 0x01 0x22 0x1D 0x00 0x07 0x05 0x81 0x03 0x10 USB_DataInStage() cnt = 2 EP0Data.Count = 2 0x00 0x10 0x00 0x09 0x01 0x00 0x00 0x00 0x00 0x00 0x21 0x0A 0x00 0x00 0x00 0x00 0x00 0x00 0x81 0x06 0x00 0x22 0x00 0x00 0x5D 0x00 USB_DataInStage() cnt = 16 EP0Data.Count = 29 0x06 0x00 0xFF 0x09 0x01 0xA1 0x01 0xB2 0x01 0x82 0x19 0x01 0x29 0x3F 0x15 0x00 USB_DataInStage() cnt = 13 EP0Data.Count = 13 0x25 0xFF 0x95 0x3F 0x75 0x08 0x82 0x01 0x02 0x92 0x01 0x02 0xC0 D12Ep1InProc() 8 D12Ep1InProc() 8 D12BusRstProc() 40 0x80 0x06 0x00 0x01 0x00 0x00 0x40 0x00 USB_DataInStage() cnt = 16 EP0Data.Count = 18 0x12 0x01 0x10 0x01 0x00 0x00 0x00 0x10 0x51 0xC2 0x01 0x13 0x00 0x01 0x01 0x04 USB_DataInStage() cnt = 2 EP0Data.Count = 2 0x00 0x01 D12BusRstProc() 40 0x00 0x05 0x02 0x00 0x00 0x00 0x00 0x00 USB_REQUEST_SET_ADDRESS = 5 D12_SetAddressEnable() REQUEST_TO_DEVICE = 0 0x80 0x06 0x00 0x01 0x00 0x00 0x12 0x00 USB_DataInStage() cnt = 16 EP0Data.Count = 18 0x12 0x01 0x10 0x01 0x00 0x00 0x00 0x10 0x51 0xC2 0x01 0x13 0x00 0x01 0x01 0x04 USB_DataInStage() cnt = 2 EP0Data.Count = 2 0x00 0x01 0x80 0x06 0x00 0x02 0x00 0x00 0x09 0x00 USB_DataInStage() cnt = 9 EP0Data.Count = 9 0x09 0x02 0x22 0x00 0x01 0x01 0x00 0x80 0x32 0x00 0x09 0x01 0x00 0x00 0x00 0x00 0x00 0x02 0x01 0x00 0x00 0x81 0x00 0x00 0x00 D12Ep1InProc() 8 D12Ep1InProc() 8 |
|
7楼#
发布于:2005-08-03 16:46
什么都不东,还居然完成PDIUSBD12的驱动,应用及嵌入式3个程序
1. 驱动程序由XP DDK的样板程序修改而成(E:\WINDDK\2600.1106\src\wdm\usb\bulkusb).1] 更改GUID为如下: #ifndef _BULKUSB_USER_H #define _BULKUSB_USER_H #include <initguid.h> // {00873FDF-61A8-11d1-AA5E-00C04FB1728B} for BULKUSB.SYS DEFINE_GUID(GUID_CLASS_I82930_BULK, 0x77f49320, 0x16ef, 0x11d2, 0xad, 0x51, 0x0, 0x60, 0x97, 0xb5, 0x14, 0xdd); 2] INF文件为 [Version] Signature="$CHICAGO$" Class=USB ;// USB class intsall GUID ;ClassGUID={36FC9E60-C465-11CF-8056-444553540000} provider=%PHILIPS% ;DriverVer=15/07/2005 LayoutFile=layout.inf ;[SourceDisksNames] ;1="BulkUsb Installation Disk",,, ;[SourceDisksFiles] ;BULKUSB.sys = 1 ;BULKUSB.inf = 1 [Manufacturer] %MfgName%=Philips [Philips] %USB\VID_0471&PID_0222.DeviceDesc%=D12TEST.Dev, USB\VID_0471&PID_0222 %USB\VID_0471&PID_0666.DeviceDesc%=D12TEST.Dev, USB\VID_0471&PID_0666 %USB\VID_0471&PID_0888.DeviceDesc%=D12TEST.Dev, USB\VID_0471&PID_0888 [PreCopySection] HKR,,NoSetupUI,,1 [DestinationDirs] D12TEST.Files.Ext = 10,System32\Drivers D12TEST.Files.Inf = 10,INF [D12TEST.Dev] CopyFiles=D12TEST.Files.Ext AddReg=D12TEST.AddReg [D12TEST.Dev.NT] CopyFiles=D12TEST.Files.Ext AddReg=D12TEST.AddReg [D12TEST.Dev.NT.Services] Addservice = D12TEST, 0x00000002, D12TEST.AddService [D12TEST.AddService] DisplayName = %D12TEST.SvcDesc% ServiceType = 1 ; SERVICE_KERNEL_DRIVER StartType = 2 ; SERVICE_AUTO_START ErrorControl = 1 ; SERVICE_ERROR_NORMAL ServiceBinary = %10%\System32\Drivers\D12TEST.sys LoadOrderGroup = Base [D12TEST.AddReg] HKR,,DevLoader,,*ntkern HKR,,NTMPDriver,,D12TEST.sys HKLM,"System\Currentcontrolset\Services\D12TEST\Parameters","MaximumTransferSize",0x10001,65536 HKLM,"System\Currentcontrolset\Services\D12TEST\Parameters","DebugLevel",0x10001,2 [D12TEST.Files.Ext] D12TEST.sys ;---------------------------------------------------------------; [Strings] PHILIPS="Philips Semiconductors" MfgName="Philips" USB\VID_0471&PID_0222.DeviceDesc="Philips PDIUSBD12 Evaluation Board" USB\VID_0471&PID_0666.DeviceDesc="Philips PDIUSBD12 SMART Evaluation Board" USB\VID_0471&PID_0888.DeviceDesc="Philips PDIUSBD12 USB-EPP Evaluation Board" D12TEST.SvcDesc="D12TEST.Sys PDIUSBD12 Bulk IO test driver" 2. 应用程序解决ReadFile()阻塞方法如下: DWORD mByte = *len; DWORD lent; if(m_hEP2Read != INVALID_HANDLE_VALUE) { ReadFile(m_hEP2Read,buf,mByte,&mByte,&m_OvRead /*NULL*/); return *len = mByte; } if(GetLastError()==ERROR_IO_PENDING) { if(WaitForSingleObject(m_OvRead.hEvent, 100)==WAIT_TIMEOUT) { CancelIo(m_hEP2Read); } GetOverlappedResult(m_hEP2Read, &m_OvRead, &lent, FALSE); } return 0; 3. 嵌入式按照以上个帖即可实现连接USB,安装USB驱动程序. |
|
8楼#
发布于:2005-07-26 17:12
/**********************************************************************
* * HandleIrp_PerformCancel * * This function removes the specified IRP from the list. * **********************************************************************/ NTSTATUS HandleIrp_PerformCancel(PIRPLISTHEAD pIrpListHead, PIRP pIrp) { NTSTATUS NtStatus = STATUS_UNSUCCESSFUL; KIRQL kOldIrql; PIRPLIST pIrpListCurrent, pIrpListPrevious; KeAcquireSpinLock(&pIrpListHead->kspIrpListLock, &kOldIrql); pIrpListPrevious = NULL; pIrpListCurrent = pIrpListHead->pListFront; while(pIrpListCurrent && NtStatus == STATUS_UNSUCCESSFUL) { if(pIrpListCurrent->pIrp == pIrp) { if(pIrpListPrevious) { pIrpListPrevious->pNextIrp = pIrpListCurrent->pNextIrp; } if(pIrpListHead->pListFront == pIrpListCurrent) { pIrpListHead->pListFront = pIrpListCurrent->pNextIrp; } if(pIrpListHead->pListBack == pIrpListCurrent) { pIrpListHead->pListBack = pIrpListPrevious; } KeReleaseSpinLock(&pIrpListHead->kspIrpListLock, kOldIrql); NtStatus = STATUS_SUCCESS; /* * We are going to allow the clean up function to complete the IRP. */ pIrpListCurrent->pfnCleanUpIrp(pIrpListCurrent->pIrp, pIrpListCurrent->pContext); DbgPrint("HandleIrp_PerformCancel Complete Free Memory = 0x%0x \r\n", pIrpListCurrent); KMem_FreeNonPagedMemory(pIrpListCurrent); pIrpListCurrent = NULL; KeAcquireSpinLock(&pIrpListHead->kspIrpListLock, &kOldIrql); } else { pIrpListPrevious = pIrpListCurrent; pIrpListCurrent = pIrpListCurrent->pNextIrp; } } KeReleaseSpinLock(&pIrpListHead->kspIrpListLock, kOldIrql); return NtStatus; } /********************************************************************** * * TdiExample_CancelRoutine * * This function is called if the IRP is ever canceled * * CancelIo() from user mode, IoCancelIrp() from the Kernel * **********************************************************************/ VOID TdiExample_CancelRoutine(PDEVICE_OBJECT DeviceObject, PIRP pIrp) { PIRPLISTHEAD pIrpListHead = NULL; /* * We must release the cancel spin lock */ IoReleaseCancelSpinLock(pIrp->CancelIrql); DbgPrint("TdiExample_CancelRoutine Called IRP = 0x%0x \r\n", pIrp); /* * We stored the IRPLISTHEAD context in our DriverContext on the IRP * before adding it to the queue so it should not be NULL here. */ pIrpListHead = (PIRPLISTHEAD)pIrp->Tail.Overlay.DriverContext[0]; pIrp->Tail.Overlay.DriverContext[0] = NULL; /* * We can then just throw the IRP to the PerformCancel * routine since it will find it in the queue, remove it and * then call our clean up routine. Our clean up routine * will then complete the IRP. If this does not occur then * our completion of the IRP will occur in another context * since it is not in the list. */ HandleIrp_PerformCancel(pIrpListHead, pIrp); } |
|
9楼#
发布于:2005-07-26 17:02
IoCancelIrp
VOIDCancelPendingIrp( PDEVICE_EXTENSION DeviceExtension ) /*++ This function tries to cancel the PendingIrp if it is not already completed. Note that the IRP may not be completed and freed when the function returns. Therefore, if you are calling this from your PNP Remove device handle, you must wait on the IrpEvent to make sure the IRP is indeed completed before successfully completing the remove request and allowing the driver to unload. --*/ { if (InterlockedExchange((PVOID)&DeviceExtension->IrpLock, IRPLOCK_CANCEL_STARTED) == IRPLOCK_CANCELABLE) { // // You got it to the IRP before it was completed. You can cancel // the IRP without fear of losing it, as the completion routine // will not let go of the IRP until you say so. // IoCancelIrp(DeviceExtension->PendingIrp); // // Release the completion routine. If it already got there, // then you need to free it yourself. Otherwise, you got // through IoCancelIrp before the IRP completed entirely. // if (InterlockedExchange((PVOID)&DeviceExtension->IrpLock, IRPLOCK_CANCEL_COMPLETE) == IRPLOCK_COMPLETED) { IoFreeIrp(DeviceExtension->PendingIrp); DeviceExtension->PendingIrp = NULL; KeSetEvent(&DeviceExtension->IrpEvent, IO_NO_INCREMENT, FALSE); } } return ; } |
|
10楼#
发布于:2005-07-26 16:54
IoCancelIrp
//// An IRPLOCK allows for safe cancellation. The idea is to protect the IRP // while the canceller is calling IoCancelIrp. This is done by wrapping the // call in InterlockedExchange(s). The roles are as follows: // // Initiator/completion: Cancelable --> IoCallDriver() --> Completed // Canceller: CancelStarted --> IoCancelIrp() --> CancelCompleted // // No cancellation: // Cancelable-->Completed // // Cancellation, IoCancelIrp returns before completion: // Cancelable --> CancelStarted --> CancelCompleted --> Completed // // Canceled after completion: // Cancelable --> Completed -> CancelStarted // // Cancellation, IRP completed during call to IoCancelIrp(): // Cancelable --> CancelStarted -> Completed --> CancelCompleted // // The transition from CancelStarted to Completed tells the completer to block // postprocessing (IRP ownership is transferred to the canceller). Similarly, // the canceller learns it owns IRP postprocessing (free, completion, etc) // during a Completed->CancelCompleted transition. // status = IoCallDriver(TopOfDeviceStack, irp); if (status == STATUS_PENDING) { dueTime.QuadPart = -10000 * Milliseconds; status = KeWaitForSingleObject( &event, Executive, KernelMode, FALSE, &dueTime ); if (status == STATUS_TIMEOUT) { if (InterlockedExchange((PVOID)&lock, IRPLOCK_CANCEL_STARTED) == IRPLOCK_CANCELABLE) { // // You got it to the IRP before it was completed. You can cancel // the IRP without fear of losing it, because the completion routine // does not let go of the IRP until you allow it. // IoCancelIrp(irp); // // Release the completion routine. If it already got there, // then you need to complete it yourself. Otherwise, you got // through IoCancelIrp before the IRP completed entirely. // if (InterlockedExchange(&lock, IRPLOCK_CANCEL_COMPLETE) == IRPLOCK_COMPLETED) { IoCompleteRequest(irp, IO_NO_INCREMENT); } } KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL); ioStatus.Status = status; // Return STATUS_TIMEOUT } else { status = ioStatus.Status; } |
|
11楼#
发布于:2005-07-26 16:30
#pragma PAGEDCODE
NTSTATUS SendAwaitUrb(PDEVICE_OBJECT fdo, PURB urb, UINT8 timeout) { // SendAwaitUrb PAGED_CODE(); ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL); PDEVICE_EXTENSION pdx = (PDEVICE_EXTENSION) fdo->DeviceExtension; KEVENT event; KeInitializeEvent(&event, NotificationEvent, FALSE); IO_STATUS_BLOCK iostatus; PIRP Irp = IoBuildDeviceIoControlRequest(IOCTL_INTERNAL_USB_SUBMIT_URB, pdx->LowerDeviceObject, NULL, 0, NULL, 0, TRUE, &event, &iostatus); if (!Irp) { KdPrint((DRIVERNAME " - Unable to allocate IRP for sending URB\n")); return STATUS_INSUFFICIENT_RESOURCES; } PIO_STACK_LOCATION stack = IoGetNextIrpStackLocation(Irp); stack->Parameters.Others.Argument1 = (PVOID) urb; if(timeout != 0) IoSetCompletionRoutine(Irp, OnComplete, (PVOID)&event, TRUE, TRUE, TRUE); NTSTATUS status = IoCallDriver(pdx->LowerDeviceObject, Irp); if (status == STATUS_PENDING) { if(timeout != 0) { KdPrint((DRIVERNAME " - timeout: %x \n", timeout)); //the received timeout is in seconds. We'll have to transform it in //units of 100ns. LARGE_INTEGER dueTime; dueTime.QuadPart = -10000000 * timeout; status = KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, &dueTime); if(status == STATUS_TIMEOUT) { KdPrint((DRIVERNAME " - KeWaitForSingleObject returned STATUS_TIMEOUT! \n")); IoCancelIrp(Irp); KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL); } KdPrint((DRIVERNAME " - KeWaitForSingleObject finished successfully! \n")); } else { KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL); status = iostatus.Status; } } if(timeout != 0) IoCompleteRequest(Irp, IO_NO_INCREMENT); return status; } // SendAwaitUrb #pragma PAGEDCODE NTSTATUS OnComplete(PDEVICE_OBJECT devObject, PIRP Irp, PVOID pevent) { if(Irp->PendingReturned) KeSetEvent((PKEVENT)pevent, IO_NO_INCREMENT, FALSE); return STATUS_MORE_PROCESSING_REQUIRED; } |
|
12楼#
发布于:2005-07-25 16:50
PDIUSBD12速度慢,设备句柄有时需要连续打开数百次才能成功!
|
|
13楼#
发布于:2005-07-25 14:19
本例子驱动程序是异步IO操作.用函数BulkUsb_BuildAsyncRequest()建立异步读写请求.因此CreateFile,ReadFile and WriteFile OVERLAPPED 不能为NULL.
|
|
14楼#
发布于:2005-07-25 12:03
PDIUSBD12编程 PIPE00 ~ PIPE03
PIPE00 and PIPE02 are all readfile handle.PIPE01 and PIPE03 are all writefile handle.Whichever PIPE handle for DeviceIoControl is corresponding to EndPoint0.How Strange. |
|
15楼#
发布于:2005-07-23 17:36
Pipe and EndPoint Relationship
{{ // //设备描述符 UsbDevDescSize, UsbDevDescType, 0x110, // version v1.10 0xDC, 0, 0, Ep0PacketSize, 0x471, //PHILIPS公司的设备ID 0x222, 0x0001, 0, 0, 0, 1 //可能的配置数 1个 }, { //配置描述符 UsbCfgDescSize, UsbCfgDescType, //UsbTotalCfgDescSize, 0, 0x2E,0x00, 1, 1, 0, 0x60, 0x32 }, { //接口描述符 UsbItfDescSize, UsbItfDescType, 0, 0, EndpCnt, // 4 0xDC, 0xA0, 0xB0, 0 }, { //端点1输入 UsbEndpDescSize, UsbEndpDescType, 0x81, UsbEndpBulk, Ep2PacketSize, 0, 10 }, { //端点1输出 UsbEndpDescSize, UsbEndpDescType, 0x1, UsbEndpBulk, Ep2PacketSize, 0, 10 }, { //端点2输入 UsbEndpDescSize, UsbEndpDescType, 0x82, UsbEndpBulk, Ep2PacketSize, 0, 10 }, { //端点2输出 UsbEndpDescSize, UsbEndpDescType, 0x2, UsbEndpBulk, Ep2PacketSize, 0, 10 } }; PC收到以上描述符后,PIPE00 对应与ENDPOINT1, PIPE01对应与ENDPOINT2. |
|
16楼#
发布于:2005-07-23 17:28
ReadFile时 D12的响应
D12Ep3IntProc() 8 D12Ep3IntProc() 8 本例子.没有上传数据给PC,Endpoit1为中断模式.D12产生Endpoit1 的IN中断.要求上传数据. |
|
17楼#
发布于:2005-07-23 17:21
我已经把周立功的描述符放到正常的ARM程序中测试.ReadFile and WriteFile are normal.证明我对D12的操作掌握不够多.因此应该集中精力了解D12的操作.
|
|
18楼#
发布于:2005-07-23 16:33
周立功的端点描述符有错
上贴不是端点最大包的大小为0的错,而是传输查询间隔应该为0,因为是BULK传输. |
|
19楼#
发布于:2005-07-23 16:28
周立功的端点描述符有错
OffsetField Size Value Description 0 bLength 1 Number Size of Descriptor in Bytes (7 bytes) 1 bDescriptorType 1 Constant Endpoint Descriptor (0x05) 2 bEndpointAddress 1 Endpoint Endpoint Address Bits 0..3b Endpoint Number. Bits 4..6b Reserved. Set to Zero Bits 7 Direction 0 = Out, 1 = In (Ignored for Control Endpoints) 3 bmAttributes 1 Bitmap Bits 0..1 Transfer Type 00 = Control 01 = Isochronous 10 = Bulk 11 = Interrupt Bits 2..7 are reserved. If Isochronous endpoint, Bits 3..2 = Synchronisation Type (Iso Mode) 00 = No Synchonisation 01 = Asynchronous 10 = Adaptive 11 = Synchronous Bits 5..4 = Usage Type (Iso Mode) 00 = Data Endpoint 01 = Feedback Endpoint 10 = Explicit Feedback Data Endpoint 11 = Reserved 4 wMaxPacketSize 2 Number Maximum Packet Size this endpoint is capable of sending or receiving 6 bInterval 1 Number Interval for polling endpoint data transfers. Value in frame counts. Ignored for Bulk & Control Endpoints. Isochronous must equal 1 and field may range from 1 to 255 for interrupt endpoints. //端点2输出 { sizeof(USB_ENDPOINT_DESCRIPTOR), //端点描述符长度,= 07H USB_ENDPOINT_DESCRIPTOR_TYPE, //端点描述符类型,= 05H 0x2, //端点2 IN USB_ENDPOINT_TYPE_BULK, //批量传输,= 02H EP2_PACKET_SIZE,0x00, //端点最大包的大小,= 0040H 10 //批量传输时该设备无效 } 错端点最大包的大小为0,见以上的USB端点描述符标准. |
|
上一页
下一页