阅读:1294回复:5
那位高人看看?!
ZBoard 的FirmWare只采用了端点2,我现在想使用端点1,有几个问题想请教一下:
1、驱动程序是否要修改,怎么改? 2、驱动程序是怎样识别是哪个端点的数据?怎样建立联系? 那位大侠帮忙一下,在下感激不尽! :P |
|
沙发#
发布于:2003-06-04 11:42
端点1包含了输入和输出,描述都有,上面是我写错了,输出端点的定义是0x01。
主要是我在驱动中如何读取它?我感觉难度还是在驱动,另外我刚才提到的,如果不在请求中提供采用那个端点是否可以?下面是驱动中的读函数: NTSTATUS ZBoarduDevice::Read(KIrp I) { t << \"Entering ZBoarduDevice::Read, \" << I << EOL; NTSTATUS status; if (FALSE) // If (Request is invalid) { // Invalid parameter in the Read request I.Information() = 0; return I.PnpComplete(this, STATUS_INVALID_PARAMETER); } // Always ok to read 0 elements. if (I.ReadSize() == 0) { I.Information() = 0; return I.PnpComplete(this, STATUS_SUCCESS); } // Declare a memory object KMemory Mem(I.Mdl()); ULONG dwTotalSize = I.ReadSize(CURRENT); ULONG dwMaxSize = m_Endpoint2IN.MaximumTransferSize(); // If the total requested read size is greater than the Maximum Transfer // Size for the Pipe, request to read only the Maximum Transfer Size since // the bus driver will fail an URB with a TransferBufferLength of greater // than the Maximum Transfer Size. if (dwTotalSize > dwMaxSize) { ASSERT(dwMaxSize); dwTotalSize = dwMaxSize; } //#define ASYNC_READ #ifdef ASYNC_READ //The following codes used for asynchronous reading...... // Allocate a new context structure for Irp completion USB_COMPLETION_INFO* pCompInfo = new (NonPagedPool) USB_COMPLETION_INFO; if (pCompInfo == NULL) { I.Information() = 0; return I.PnpComplete(this, STATUS_INSUFFICIENT_RESOURCES); } // TODO: Select the correct pipe to read from // Create an URB to do actual Bulk read from the pipe PURB pUrb = m_Endpoint2IN.BuildBulkTransfer( Mem, // Where is data coming from? dwTotalSize, // How much data to read? TRUE, // direction (TRUE = IN) NULL, // Link to next URB FALSE//TRUE // Allow a short transfer ); if (pUrb == NULL) { delete pCompInfo; I.Information() = 0; return I.PnpComplete(this, STATUS_INSUFFICIENT_RESOURCES); } // Initialize context structure pCompInfo->m_pClass = this; pCompInfo->m_pUrb = pUrb; // Submit the URB to our USB device status = m_Endpoint2IN.SubmitUrb(I, pUrb, LinkTo(ReadComplete), pCompInfo, NULL); return status; #else // TODO: Select the correct pipe to read from // Create an URB to do actual Bulk read from the pipe PURB pUrb = m_Endpoint1IN.BuildBulkTransfer( Mem, // Where is data coming from? dwTotalSize, // How much data to read? TRUE, // direction (TRUE = IN) NULL, // Link to next URB FALSE//TRUE // Allow a short transfer ); if (pUrb == NULL) { I.Information() = 0; return I.PnpComplete(this, STATUS_INSUFFICIENT_RESOURCES); } status = m_Endpoint2IN.SubmitUrb(pUrb, NULL, NULL, 5000L); ULONG nBytesRead = 0; if(NT_SUCCESS(status)) { nBytesRead = pUrb->UrbBulkOrInterruptTransfer.TransferBufferLength; #ifdef DBG // Declare a memory object KMemory Mem(I.Mdl()); // Use the memory object to create a pointer to the caller\'s buffer PUCHAR pBuffer = (PUCHAR) Mem.MapToSystemSpace(); t << \"Read() got \" << nBytesRead<< \" bytes from USB\\n\"; for(ULONG i=0; i<nBytesRead; i++) { t.Trace(TraceInfo, \"%02x \", *(pBuffer + i)); } t << EOL; #endif } delete pUrb; ///******************************** Release Memory I.Information() = nBytesRead; return I.PnpComplete(this, status); #endif } |
|
板凳#
发布于:2003-06-04 11:28
endpoint是有方向的(有的是硬件已经设定好,不能更改;有的可以由软件自己定,一旦定好,也就不能改了),从你说的看,endpoint 2是OUT端点,如果你要从endpoint 1中读取数据,那么endpoint 1也要是OUT端点,如果不是OUT端点的话,是不能得到数据的,如果是IN端点,只能向这个端点写数据。端点工作是单工的。
你的0x81是把端点1作为输入(此时只能向里写,bit 7是方向位,0:输出;1:输入),改为0x01 |
|
|
地板#
发布于:2003-06-04 11:25
endpoint是有方向的(有的是硬件已经设定好,不能更改;有的可以由软件自己定,一旦定好,也就不能改了),从你说的看,endpoint 2是OUT端点,如果你要从endpoint 1中读取数据,那么endpoint 1也要是OUT端点,如果不是OUT端点的话,是不能得到数据的,如果是IN端点,只能向这个端点写数据。端点工作是单工的。
而endpoint descriptor中有方向的设置位 |
|
|
地下室#
发布于:2003-06-04 11:15
如果想使用端点1,那么你的firmware就得修改 flycat0101兄弟,多谢了! 1、我的firmware已经有了端点1的描述,如下是输出端点, code USB_ENDPOINT_DESCRIPTOR EP1_TXDescr = { sizeof(USB_ENDPOINT_DESCRIPTOR), USB_ENDPOINT_DESCRIPTOR_TYPE, 0x81, USB_ENDPOINT_TYPE_BULK, SWAP(EP1_PACKET_SIZE), 0 }; 2、Firmware 好像没有识别客户请求使用那个端点,而是默认了采用端点2进行数据传输,是否我理解有错误? 驱动程序只有端点2的读,我怎样才能读端点1。 我搞得时间不长,还希望不吝赐教。 |
|
5楼#
发布于:2003-06-03 11:30
如果想使用端点1,那么你的firmware就得修改
驱动程序是根据从firmware得到得endpoint descriptor信息来使用端点得,也就是说,如果没有端点1的descriptor,驱动程序是不会使用它的,所以你要修改firmware 第二个问题是这样的,在发生一个传输事务时,是由host端发起的 在同一个事务内,host端决定使用哪个端口,所以,host的驱动程序是知道使用哪个端口传输数据的,所以也就不需要再进行识别 |
|
|