阅读:1493回复:9
各位侠客帮忙看一下,读68013的ep6fifobuf,怎么读不出来数据?
我用EZ-USB自带的一个例子bulksrc,用自带的控制面板download到USB的RAM,
这个例子的一部分功能是把一些递增数据储存到EP6FIFOBUF里。 我在VC里这样写: void CZCFDlg::OnButton2() { BULK_TRANSFER_CONTROL bulkControl; BOOLEAN bResult = FALSE; UCHAR inBuffer[90000]; DWORD nBytes, dwTotalBytes; bulkControl.pipeNum = 2; bResult = DeviceIoControl (hDeviceFX2, IOCTL_EZUSB_BULK_READ, &bulkControl, sizeof(bulkControl), &inBuffer[dwTotalBytes], 512, &nBytes, NULL); } 然后在VC中调试,通过设置断点和观察memory中inbuffer,发现并没读上来数据,请问这是怎么回事? |
|
|
沙发#
发布于:2003-10-21 17:17
赞同。你再看看那个例子的说明。
|
|
板凳#
发布于:2003-10-21 17:09
如果你用的是例子代码并且没有修改过的话,说明你没有弄明白例子的意思!
BULKSRC的主要流程是先把主机通过EP2或着EP4传到设备的数据存储到哪个64K的RAM里,然后当主机通过EP6或者EP8读取数据的时候再把数据从RAM里读出来回传给主机! 但是你贴出来的那一段程序显然用的是EP4和EP8,直接REARM EP2和EP6,你读EP6当然没有数据了,也有可能读到的是随机数。 你这样做,先写一批数据到EP4,然后再用EP8读回去试试! |
|
地板#
发布于:2003-10-21 16:48
你的固件程序看的我头都有点歪,
现在你最直接的方法是看deviceiocontrol函数的错误返回值,用getlasterror,再去查相应的错误代码,先判断是什么。。 |
|
地下室#
发布于:2003-10-20 13:13
这是里面那个写的子程序,包括初始化和任务,请指教指教 #pragma NOIV // Do not generate interrupt vectors //----------------------------------------------------------------------------- // File: bulksrc.c // Contents: Hooks required to implement USB peripheral function. // // $Archive: /USB/Examples/Fx2/bulksrc/bulksrc.c $ // $Date: 11/10/01 11:41a $ // $Revision: 9 $ // // Copyright (c) 2000 Cypress Semiconductor All rights reserved //----------------------------------------------------------------------------- #include \"fx2.h\" #include \"fx2regs.h\" #include \"fx2sdly.h\" // SYNCDELAY macro extern BOOL GotSUD; // Received setup data flag extern BOOL Sleep; extern BOOL Rwuen; extern BOOL Selfpwr; BYTE Configuration; // Current configuration BYTE AlternateSetting; // Alternate settings BYTE xdata myBuffer[512]; WORD myBufferCount; //----------------------------------------------------------------------------- // Task Dispatcher hooks // The following hooks are called by the task dispatcher. //----------------------------------------------------------------------------- void TD_Init(void) // Called once at startup { int i; // set the CPU clock to 48MHz CPUCS = ((CPUCS & ~bmCLKSPD) | bmCLKSPD1) ; // set the slave FIFO interface to 48MHz IFCONFIG |= 0x40; //*************ZCF************* IFCONFIG &= 0XFC; // PORT MODE //***************************** // Registers which require a synchronization delay, see section 15.14 // FIFORESET FIFOPINPOLAR // INPKTEND OUTPKTEND // EPxBCH:L REVCTL // GPIFTCB3 GPIFTCB2 // GPIFTCB1 GPIFTCB0 // EPxFIFOPFH:L EPxAUTOINLENH:L // EPxFIFOCFG EPxGPIFFLGSEL // PINFLAGSxx EPxFIFOIRQ // EPxFIFOIE GPIFIRQ // GPIFIE GPIFADRH:L // UDMACRCH:L EPxGPIFTRIG // GPIFTRIG // Note: The pre-REVE EPxGPIFTCH/L register are affected, as well... // ...these have been replaced by GPIFTC[B3:B0] registers // default: all endpoints have their VALID bit set // default: TYPE1 = 1 and TYPE0 = 0 --> BULK // default: EP2 and EP4 DIR bits are 0 (OUT direction) // default: EP6 and EP8 DIR bits are 1 (IN direction) // default: EP2, EP4, EP6, and EP8 are double buffered // we are just using the default values, yes this is not necessary... EP1OUTCFG = 0xA0; EP1INCFG = 0xA0; SYNCDELAY; // see TRM section 15.14 EP2CFG = 0xA2; SYNCDELAY; // EP4CFG = 0xA0; SYNCDELAY; // EP6CFG = 0xE2; //USB IN,VALID,DOUBLE BUFFER, SYNCDELAY; // EP8CFG = 0xE0; // out endpoints do not come up armed // since the defaults are double buffered we must write dummy byte counts twice SYNCDELAY; // EP2BCL = 0x80; // arm EP2OUT by writing byte count w/skip. SYNCDELAY; // EP4BCL = 0x80; SYNCDELAY; // EP2BCL = 0x80; // arm EP4OUT by writing byte count w/skip. SYNCDELAY; // EP4BCL = 0x80; //*********ZCF************ SYNCDELAY; // EP6BCL = 0x80; //************************** // fill up both IN endpoints for (i=0;i<512;i++) EP6FIFOBUF = i+2; SYNCDELAY; // EP6BCH = 0x02; SYNCDELAY; // EP6BCL = 0x00; for (i=0;i<512;i++) EP6FIFOBUF = i+2; SYNCDELAY; // EP6BCH = 0x02; SYNCDELAY; // EP6BCL = 0x00; myBufferCount = 0; // enable dual autopointer(s) AUTOPTRSETUP |= 0x01; Rwuen = TRUE; // Enable remote-wakeup } void TD_Poll(void) // Called repeatedly while the device is idle { int i; // if there is some data in EP2 OUT, re-arm it if(!(EP2468STAT & bmEP2EMPTY)) { SYNCDELAY; // EP2BCL = 0x80; } // if EP6 IN is available, re-arm it if(!(EP2468STAT & bmEP6FULL)) { SYNCDELAY; // EP6BCH = 0x02; SYNCDELAY; // EP6BCL = 0x00; } // if there is new data in EP4FIFOBUF, then copy it to a temporary buffer if(!(EP2468STAT & bmEP4EMPTY)) { APTR1H = MSB( &EP4FIFOBUF ); APTR1L = LSB( &EP4FIFOBUF ); AUTOPTRH2 = MSB( &myBuffer ); AUTOPTRL2 = LSB( &myBuffer ); myBufferCount = (EP4BCH << 8) + EP4BCL; for( i = 0x0000; i < myBufferCount; i++ ) { EXTAUTODAT2 = EXTAUTODAT1; } SYNCDELAY; // EP4BCL = 0x80; // re(arm) EP4OUT } // if there is room in EP8IN, then copy the contents of the temporarty buffer to it if(!(EP2468STAT & bmEP8FULL) && myBufferCount) { APTR1H = MSB( &myBuffer ); APTR1L = LSB( &myBuffer ); AUTOPTRH2 = MSB( &EP8FIFOBUF ); AUTOPTRL2 = LSB( &EP8FIFOBUF ); for( i = 0x0000; i < myBufferCount; i++ ) { // setup to transfer EP4OUT buffer to EP8IN buffer using AUTOPOINTER(s) in SFR space EXTAUTODAT2 = EXTAUTODAT1; } SYNCDELAY; // EP8BCH = MSB(myBufferCount); SYNCDELAY; // EP8BCL = LSB(myBufferCount); // arm EP8IN } } BOOL TD_Suspend(void) // Called before the device goes into suspend mode { return(TRUE); } BOOL TD_Resume(void) // Called after the device resumes { return(TRUE); } //----------------------------------------------------------------------------- // Device Request hooks // The following hooks are called by the end point 0 device request parser. //----------------------------------------------------------------------------- BOOL DR_GetDescriptor(void) { return(TRUE); } BOOL DR_SetConfiguration(void) // Called when a Set Configuration command is received { Configuration = SETUPDAT[2]; return(TRUE); // Handled by user code } BOOL DR_GetConfiguration(void) // Called when a Get Configuration command is received { EP0BUF[0] = Configuration; EP0BCH = 0; EP0BCL = 1; return(TRUE); // Handled by user code } BOOL DR_SetInterface(void) // Called when a Set Interface command is received { AlternateSetting = SETUPDAT[2]; return(TRUE); // Handled by user code } BOOL DR_GetInterface(void) // Called when a Set Interface command is received { EP0BUF[0] = AlternateSetting; EP0BCH = 0; EP0BCL = 1; return(TRUE); // Handled by user code }............ ................. |
|
|
5楼#
发布于:2003-10-18 23:02
固件是来控制USB芯片工作的,驱动是用来让应用来和设备通信的。
你要了解他们的协议和工作原理。你要快的话,你就用工具。你是开发板吗。固件的程序贴出来看看。你要读那个端点的数据。你是发数据到EP6,然后呢你要从那里读出来呢。一个端点只有一个方向(除了EP0). |
|
6楼#
发布于:2003-10-16 12:52
还有大下给提示吗?
|
|
|
7楼#
发布于:2003-10-16 08:04
驱动是厂家带的EZUSB.SYS,例子也是厂家带的,不知道如何才能知道
是否匹配和固件是否正常工作了? |
|
|
8楼#
发布于:2003-10-15 23:04
你要和驱动联系起来调试,在驱动中要对你的传输管道配置进行确认,如果不匹配的话,那就不工作了。
你的程序是从设备里读数据出来,那你的固件对吗,工作了吗。你以要确认。 |
|
9楼#
发布于:2003-10-15 18:20
我的问题是不是十分的简单?
怎么没人回答? 我很想把这个搞定,可就是搞不定,哪位侠客支支招? |
|
|