44b0+ch375外置固件設(shè)備方式問題

按照論壇上的貼子修改的程序,程序如附件所示,用串口取到的消息如下: Ch375 init ... init successed! Set device mode done! 外置固件從機(jī)模式 InterruptStatus:07 中斷狀態(tài),此時(shí)表示USB總線復(fù)位 InterruptStatus:07 InterruptStatus:07 InterruptStatus:07 InterruptStatus:07 InterruptStatus:07 InterruptStatus:0c [80] [06] [00] [01] [00] [00] [40] [00] 收到setup包 12 01 10 01 00 00 00 08 InterruptStatus:08 6EP0_IN 表示6號(hào)命令的ep0_in事務(wù) 8f 05 80 93 00 02 00 00 InterruptStatus:00 EP0_OUT InterruptStatus:00 EP0_OUT InterruptStatus:00 EP0_OUT InterruptStatus:00 EP0_OUT InterruptStatus:0c [00] [05] [38] [00] [00] [00] [00] [00] ---設(shè)置USB新地址 InterruptStatus:08 5EP0_IN new adderss:56 InterruptStatus:0c [80] [06] [00] [01] [00] [00] [12] [00] ---重新請求描述符 12 01 10 01 00 00 00 08 InterruptStatus:08 6EP0_IN 8f 05 80 93 00 02 00 00 InterruptStatus:08 6EP0_IN 00 01 InterruptStatus:08 6EP0_IN         設(shè)備描述符已經(jīng)傳完了,接著復(fù)位了 InterruptStatus:00 EP0_OUT InterruptStatus:07 ------------下面開始又重復(fù)一次,三次過后,電腦提示無法識(shí)別

InterruptStatus:07 InterruptStatus:07 InterruptStatus:07 InterruptStatus:07 InterruptStatus:07 InterruptStatus:07 InterruptStatus:07 InterruptStatus:07 InterruptStatus:0c [80] [06] [00] [01] [00] [00] [40] [00] 12 01 10 01 00 00 00 08 InterruptStatus:08 6EP0_IN 8f 05 80 93 00 02 00 00 InterruptStatus:00 EP0_OUT InterruptStatus:00 EP0_OUT InterruptStatus:00 EP0_OUT InterruptStatus:0c [00] [05] [39] [00] [00] [00] [00] [00] InterruptStatus:08 5EP0_IN new adderss:57 InterruptStatus:0c [80] [06] [00] [01] [00] [00] [12] [00] 12 01 10 01 00 00 00 08 InterruptStatus:08 6EP0_IN 8f 05 80 93 00 02 00 00 InterruptStatus:08 6EP0_IN 00 01 InterruptStatus:08 6EP0_IN InterruptStatus:00 EP0_OUT InterruptStatus:07 InterruptStatus:07 InterruptStatus:07 InterruptStatus:07 InterruptStatus:07 InterruptStatus:07 InterruptStatus:07 InterruptStatus:07 InterruptStatus:07 InterruptStatus:0c [80] [06] [00] [01] [00] [00] [40] [00] 12 01 10 01 00 00 00 08 InterruptStatus:08 6EP0_IN 8f 05 80 93 00 02 00 00 InterruptStatus:00 EP0_OUT InterruptStatus:00 EP0_OUT InterruptStatus:00 EP0_OUT InterruptStatus:00 EP0_OUT InterruptStatus:00 EP0_OUT InterruptStatus:0c [00] [05] [3a] [00] [00] [00] [00] [00] InterruptStatus:08 5EP0_IN new adderss:58 InterruptStatus:0c [80] [06] [00] [01] [00] [00] [12] [00] 12 01 10 01 00 00 00 08 InterruptStatus:08 6EP0_IN 8f 05 80 93 00 02 00 00 InterruptStatus:08 6EP0_IN 00 01 InterruptStatus:08 6EP0_IN InterruptStatus:00 EP0_OUT

-----這就提示無法識(shí)別了,從現(xiàn)象來看,好像電腦這邊為什么會(huì)老是復(fù)位呢?另外EP0_OUT和SETUP之間有什么關(guān)系呢,總之還請做過CH375外置從機(jī)程序的同行們指點(diǎn)一下,翻來復(fù)去都測一周多了,先謝謝了。

附件沒傳上來,代碼發(fā)上來。

unsigned char USBDISK[2*1024*1024];

unsigned char SystemBuffer[520]; unsigned char UsbBuffer[2048]; unsigned char SystemStatus; unsigned int UsbReadPoint,UsbWritePoint; unsigned char dCBWTag[4]; unsigned int dCBWDataTransferLength; unsigned char CBWCBLength; unsigned int LBA_adder,Block,Page; unsigned short BlockLength; unsigned char SendFlag,NewAddr=0;

//================外置固件設(shè)備模式=================== unsigned char mVarSetupRequest; // USB請求碼 unsigned char mVarSetupLength; // 后續(xù)數(shù)據(jù)長度 unsigned char * VarSetupDescr; // 描述符偏移地址 unsigned char VarUsbAddress=0; // 暫存主機(jī)分來的地址 unsigned char CH375CONFLAG; // 配置標(biāo)志

mREQUEST_PACKET Request; unsigned char DevDes[]={ 0x12 //描述符大小 , 0x01 //常數(shù)DEVICE , 0x10 //USB規(guī)范版本信息 , 0x01 , 0x00 //類別碼, , 0x00 //子類別碼 , 0x00 //協(xié)議碼 , 0x08 //端點(diǎn)0的最大信息包大小 , 0x8f //廠商ID , 0x05 , 0x80 //產(chǎn)品ID , 0x93 , 0x00 //設(shè)備版本信息 , 0x02 , 0x00 //索引值 , 0x00 , 0x00 , 0x01 //可能配置的數(shù)目 }; //配置描述符 unsigned char ConDes[]={ 0x09, //描述符大小 0x02, //配置描述符 0x2e, 0x00, //此配置所返回的所有數(shù)據(jù)大小 0x01, //此配置支持的接口數(shù) 0x01, //Set_Configration中的參數(shù) 0x00, //描述此配置的字符串索引值 0x80, //供電模式的選擇 0x32, //設(shè)備從總線提取的最大電流50ma 0x09, //描述符大小 0x04, //接口描述符 0x00, //該接口編號(hào) 0x00, //該接口使用的端點(diǎn)數(shù),不算端點(diǎn)0 0x04, //該接口使用的端點(diǎn)數(shù),不算端點(diǎn)0 0x08, //接口類型 Mass Storage Class 0x06, //接口子類型 存儲(chǔ)介質(zhì) 0x50, //協(xié)議代碼 BULK-ONLY TRANSPORT 0x00, //描述該接口的字符串索引值 0x07,0x05,0x82, 0x02, 0x40, 0x00, 0x00, 0x07,0x05,0x02, 0x02, 0x40, 0x00, 0x00, 0x07,0x05,0x81, 0x03, 0x08, 0x00, 0x01, 0x07,0x05,0x01, 0x02, 0x08, 0x00, 0x00, }; //端點(diǎn)0數(shù)據(jù)上傳 void mCh375Ep0Up(void) { unsigned char i,len; if(mVarSetupLength) { //長度不為0傳輸具體長度的數(shù)據(jù) if(mVarSetupLength<=8) { len=mVarSetupLength; mVarSetupLength=0; } //長度小于8則長輸要求的長度 else { len=8; mVarSetupLength-=8; } //長度大于8則傳輸8個(gè),切總長度減8 CH375_WR_CMD_PORT(CMD_WR_USB_DATA3); //發(fā)出寫端點(diǎn)0的命令 CH375_WR_DAT_PORT(len); //寫入長度 for(i=0;i!=len;i++) { Uart_Printf("%02x ",Request.buffer[i]); CH375_WR_DAT_PORT(Request.buffer[i]); //循環(huán)寫入數(shù)據(jù) } Uart_Printf("\n"); } else { CH375_WR_CMD_PORT(CMD_WR_USB_DATA3); //發(fā)出寫端點(diǎn)0的命令 CH375_WR_DAT_PORT(0); //上傳0長度數(shù)據(jù),這是一個(gè)狀態(tài)階段 } }

//復(fù)制描述符以便上傳 void mCh375DesUp(void) { unsigned char k; for (k=0; k!=8; k++ ) { Request.buffer[k]=*VarSetupDescr; //依次復(fù)制8個(gè)描述符, VarSetupDescr++; } } //===================================================

//INIT ch375 void CH375_Init( void ) { unsigned char i, k; unsigned char RD_Data; Uart_Printf("Ch375 init ...\n"); for( k=10; k!=0; k-- ) { CH375_COMM=CMD_RESET_ALL; EZUSB_Delay(100); CH375_COMM=CMD_CHECK_EXIST; EZUSB_Delay(1); i = 0xa5; CH375_DATA= i; EZUSB_Delay(1); i = ~i; RD_Data = CH375_DATA; EZUSB_Delay(1); if ( RD_Data != i ) { for ( i=5; i!=0; i-- ) CH375_COMM=CMD_RESET_ALL; EZUSB_Delay(100); } else { Uart_Printf("init successed!\n"); break; } } if( k==0 ) { Uart_Printf("init falure!\n"); } //CH375_COMM=CMD_GET_IC_VER; //EZUSB_Delay(100); //Uart_Printf("Ver=%d\n",CH375_DATA); CH375_WR_CMD_PORT( CMD_SET_USB_MODE ); CH375_WR_DAT_PORT( 1 ); /* 設(shè)置為使用外置固件的USB設(shè)備方式 */ for ( ;; ) { /* 等待操作成功,通常需要等待10uS-20uS */ if ( CH375_RD_DAT_PORT( )==CMD_RET_SUCCESS ) break; } Uart_Printf("Set device mode done!\n"); }

// CH375中斷服務(wù)程序,CH375的INT#引腳連接到eint0 void __irq CH375Interrupt(void) { unsigned char InterruptStatus; unsigned char length, len,c1,CH375FLAGERR; unsigned char cbw_error; unsigned int point; unsigned char tmp,command; rI_ISPC=BIT_EINT0; CH375_WR_CMD_PORT(CMD_GET_STATUS); //獲取中斷狀態(tài)并取消中斷請求 CH375FLAGERR =0; InterruptStatus = CH375_RD_DAT_PORT(); //獲取中斷狀態(tài) Uart_Printf("InterruptStatus:%02x\n",InterruptStatus); switch( InterruptStatus ) //分析中斷狀態(tài) { case USB_INT_EP2_OUT: // 批量端點(diǎn)下傳成功 CH375_WR_CMD_PORT( CMD_RD_USB_DATA ); //從當(dāng)前USB中斷的端點(diǎn)緩沖區(qū)讀取數(shù)據(jù)塊,并釋放緩沖區(qū) length = CH375_RD_DAT_PORT(); //首先讀取后續(xù)數(shù)據(jù)長度 if ( length != 0 ) //如果長度為0則不處理 { for (len=0;len { SystemBuffer[len] = CH375_RD_DAT_PORT(); Uart_Printf("%02x ",SystemBuffer[len]); } Uart_Printf("\n"); } break; case USB_INT_EP2_IN: //批量端點(diǎn)上傳成功 CH375_WR_CMD_PORT( CMD_UNLOCK_USB ); //釋放緩沖區(qū) break; //========================================================================== case USB_INT_EP0_SETUP: //控制端點(diǎn)建立成功 CH375_WR_CMD_PORT(CMD_RD_USB_DATA); length=CH375_RD_DAT_PORT(); for( len=0;len { Request.buffer[len] = CH375_RD_DAT_PORT(); // 取出數(shù)據(jù) Uart_Printf("[%02x] ",Request.buffer[len]); } Uart_Printf("\n"); // 取出數(shù)據(jù) if(length==0x08) { mVarSetupLength=Request.buffer[6]; //控制傳輸數(shù)據(jù)長度最大設(shè)置為128 //if((c1=Request.r.bmReuestType)&0x40) //{ //廠商請求,未處理 //} //if((c1=Request.r.bmReuestType)&0x20) //{// printf("b\n"); //類請求,未處理 // if(Request.buffer[1]==0x0a) // {//printf("c\n"); // } //SET_IDLE // else if(Request.buffer[1]==0x09) // { // // } //} if(!((c1=Request.r.bmReuestType)&0x60)) { //標(biāo)準(zhǔn)請求 mVarSetupRequest=Request.r.bRequest; //暫存標(biāo)準(zhǔn)請求碼 switch(Request.r.bRequest) { // 分析標(biāo)準(zhǔn)請求 case DEF_USB_CLR_FEATURE: //清除特性 if((c1=Request.r.bmReuestType&0x1F)==0X02) { //不是端點(diǎn)不支持 switch(Request.buffer[4]) { case 0x82: CH375_WR_CMD_PORT(CMD_SET_ENDP7); //清除端點(diǎn)2上傳 CH375_WR_DAT_PORT(0x8E); //發(fā)命令清除端點(diǎn) break; case 0x02: CH375_WR_CMD_PORT(CMD_SET_ENDP6); CH375_WR_DAT_PORT(0x80); //清除端點(diǎn)2下傳 break; case 0x81: CH375_WR_CMD_PORT(CMD_SET_ENDP5); //清除端點(diǎn)1上傳 CH375_WR_DAT_PORT(0x8E); break; case 0x01: CH375_WR_CMD_PORT(CMD_SET_ENDP4); //清除端點(diǎn)1下傳 CH375_WR_DAT_PORT(0x80); break; default: break; } } else { CH375FLAGERR=1; //不支持的清除特性,置錯(cuò)誤標(biāo)志 } break; case DEF_USB_GET_STATUS: //獲得狀態(tài) Request.buffer[0]=0; Request.buffer[1]=0; //上傳狀態(tài) break; case DEF_USB_SET_ADDRESS: //設(shè)置地址 VarUsbAddress=Request.buffer[2]; //暫存USB主機(jī)發(fā)來的地址 break; case DEF_USB_GET_DESCR: //獲得描述符 if(Request.buffer[3]==1) //設(shè)備描述符上傳 { VarSet


附加問一句,CH375內(nèi)置從機(jī)固件是用U盤還是模擬軟盤,我使用過內(nèi)置固件方式,用到BULK-ONLY中0x23,0x25,0x28甚至還有0x5a,好像挺復(fù)雜,不知道有沒有使用375內(nèi)置固件的實(shí)例呢?


上傳描述符的流程沒什么問題 不知道你串口波特率是多少,盡量調(diào)高一點(diǎn),57600試試


首先謝謝您的回復(fù),實(shí)際上我串口波特率就是57600,從現(xiàn)象來看是USB總線為什么在得到設(shè)備描述符后,沒有接著獲取配置描述符,相反而莫名其妙的出現(xiàn)USB總線復(fù)位,


您在監(jiān)控程序的過程中加入了許多的打印輸出,這樣就無法保證PC機(jī)枚舉的時(shí)間的及時(shí)性,PC機(jī)枚舉的時(shí)候時(shí)間方面是有要求的,你加了許多的打印輸出,這樣就相當(dāng)與許多的延時(shí),PC機(jī)在相應(yīng)的時(shí)間內(nèi)沒有獲取到描述符,所以就回不斷的復(fù)位,直到告之無法識(shí)別此設(shè)備,所以建議您這個(gè)時(shí)候?qū)⑺械拇蛴≥敵鋈サ粼僭囈幌?如果程序沒有問題的話,PC機(jī)應(yīng)該能找到設(shè)備!


樓上所述很正確。


只有登錄才能回復(fù),可以選擇微信賬號(hào)登錄

国产91精品新入口,国产成人综合网在线播放,九热这里只有精品,本道在线观看,美女视频a美女视频,韩国美女激情视频,日本美女pvp视频