CH372 鍵盤(pán)模式(HID)連續(xù)上傳數(shù)據(jù)(3)[求助]

/*;CH372/CH375 USB device mode & external firmware ; U2(AT89C51) Program ; ; Website: http://winchiphead.com ; Email: 個(gè)人信息保護(hù),已隱藏 ; Author: W.ch 2003.12, 2005.03 ; ;**************************************************************************** CH375 外部固件方式范例 這里僅處理標(biāo)準(zhǔn)請(qǐng)求和端點(diǎn)2的簡(jiǎn)單讀寫(xiě) */

/* MCS-51單片機(jī)C語(yǔ)言的示例程序 */ #pragma NOAREGS #include #include "stdio.h" #include "CH375INC.H" unsigned char ch451_key; unsigned char a; #include "CH451.h" #include "hid.h" // sundy

sbit SEND_FLAG = P1^2;

unsigned char bord; unsigned char idata UPDATA_FLAG; //unsigned char idata buf[8]; typedef union _REQUEST_PACK{ unsigned char buffer[8]; struct{ unsigned char bmReuestType; //標(biāo)準(zhǔn)請(qǐng)求字 unsigned char bRequest; //請(qǐng)求代碼 unsigned int wValue; //特性選擇高 unsigned int wIndx; //索引 unsigned int wLength; //數(shù)據(jù)長(zhǎng)度 }r; } mREQUEST_PACKET, *mpREQUEST_PACKET;

//unsigned char code LangDes[]={0x04,0x03,0x09,0x04}; //語(yǔ)言描述符 //unsigned char code SerDes[]={0x12,0x03,'C',0,'H',0,'3',0,'7',0,'5',0,'U',0,'S',0,'B',0}; //字符串描述符 unsigned char code Key_Hid_des[]={ /* from WCH 0x05, 0x01, 0x09, 0x06, 0xa1, 0x01, 0x05, 0x07, 0x19, 0xe0, 0x29, 0xe7, 0x15, 0x00, 0x25, 0x01, 0x95, 0x08, 0x75, 0x01, 0x81, 0x02, 0x95, 0x08, 0x75, 0x01, 0x81, 0x01, 0x05, 0x08, 0x19, 0x01, 0x29, 0x05, 0x95, 0x05, 0x75, 0x01, 0x91, 0x02, 0x95, 0x01, 0x75, 0x03, 0x91, 0x01, 0x05, 0x07, 0x19, 0x00, 0x2a, 0xff, 0x00, 0x15, 0x00, 0x26, 0xff, 0x00, 0x95, 0x06, 0x75, 0x08, 0x81, 0x00, 0xc0 // */ // 從USB鍵盤(pán)芯片來(lái) HID_UsagePage(HID_USAGE_PAGE_GENERIC), //0x05, 0x01, HID_Usage(HID_USAGE_GENERIC_KEYBOARD), //0x09, 0x06, HID_Collection(HID_Application), //0xa1, 0x01, HID_UsagePage(HID_USAGE_PAGE_LED), //0x05, 0x08, HID_UsageMin(HID_USAGE_LED_NUM_LOCK), //0x19, 0x01, HID_UsageMax(HID_USAGE_LED_SCROLL_LOCK), //0x29, 0x03, HID_LogicalMin(0), //0x15, 0x00, HID_LogicalMax(1), //0x25, 0x01, HID_ReportSize(1), //0x75, 0x01, HID_ReportCount(3), //0x95, 0x03, HID_Output(2), //0x91, 0x02, HID_Data+HID_Variable+HID_Absolute HID_ReportCount(5), //0x95, 0x05, HID_Output(1), //0x91, 0x01, HID_UsagePage(HID_USAGE_PAGE_KEYBOARD), //0x05, 0x07, HID_Constant HID_UsageMin(HID_USAGE_KEYBOARD_LCTRL), //0x19, 0xe0, HID_UsageMax(HID_USAGE_KEYBOARD_RGUI), //0x29, 0xe7, HID_ReportCount(8), //0x95, 0x08, HID_Input(2), //0x81, 0x02, HID_ReportSize(8), //0x75, 0x08, HID_ReportCount(1), //0x95, 0x01, HID_Input(1), //0x81, 0x01, HID_UsageMin(0), //0x19, 0x00, HID_UsageMax(0x91), //0x29, 0x91, HID_LogicalMaxS(0x00ff), //0x26, 0xff, 0x00, HID_ReportCount(6), //0x95, 0x06, HID_Input(0), //0x81, 0x00, HID_EndCollection //0xc0 // */ };

unsigned char code Mouse_Hid_des[]={ /* from WCH 0x05, 0x01, 0x09, 0x02, 0xa1, 0x01, 0x85, 0x01, 0x09, 0x01, 0xa1, 0x00, 0x05, 0x09, 0x19, 0x01, 0x29, 0x03, 0x15, 0x00, 0x25, 0x01, 0x75, 0x01, 0x95, 0x03, 0x81, 0x02, 0x95, 0x05, 0x81, 0x01, 0x05, 0x01, 0x09, 0x30, 0x09, 0x31, 0x09, 0x38, 0x15, 0x81, 0x25, 0x7f, 0x95, 0x03, 0x75, 0x08, 0x81, 0x06, 0xc0, 0xc0, 0x09, 0x80, 0xa1, 0x01, 0x85, 0x02, 0x05, 0x01, 0x19, 0x81, 0x29, 0x88, 0x15, 0x00, 0x25, 0x01, 0x95, 0x08, 0x75, 0x01, 0x81, 0x02, 0xc0 // */ //* WCH HID_UsagePage(HID_USAGE_PAGE_GENERIC), //0x05, 0x01, HID_Usage(HID_USAGE_GENERIC_MOUSE), //0x09, 0x02, HID_Collection(HID_Application), //0xa1, 0x01, HID_ReportID(1), //0x85, 0x01, // HID_Usage(HID_USAGE_GENERIC_POINTER), //0x09, 0x01, // HID_Collection(HID_Physical), //0xa1, 0x00, // HID_UsagePage(HID_USAGE_PAGE_BUTTON), //0x05, 0x09, // HID_UsageMin(1), //0x19, 0x01, // HID_UsageMax(3), //0x29, 0x03, // HID_LogicalMin(0), //0x15, 0x00, // HID_LogicalMax(1), //0x25, 0x01, // HID_ReportSize(1), //0x75, 0x01, // HID_ReportCount(3), //0x95, 0x03, // HID_Input(2), //0x81, 0x02, // HID_ReportCount(5), //0x95, 0x05, // HID_Input(1), //0x81, 0x01, HID_Data+HID_Array 3 HID_UsagePage(HID_USAGE_PAGE_GENERIC), //0x05, 0x01, // HID_Usage(HID_USAGE_GENERIC_X), //0x09, 0x30, // HID_Usage(HID_USAGE_GENERIC_Y), //0x09, 0x31, // HID_Usage(HID_USAGE_GENERIC_WHEEL), //0x09, 0x38, // HID_LogicalMin(0x81), //0x15, 0x81, // -127 HID_LogicalMax(0x7F), //0x25, 0x7f, // HID_ReportCount(3), //0x95, 0x03, // HID_ReportSize(8), //0x75, 0x08, // HID_Input(6), //0x81, 0x06, //HID_Data+HID_Variable+HID_Relative HID_EndCollection, //0xc0, /* HID_EndCollection, //0xc0, // HID_Usage(HID_USAGE_GENERIC_SYSTEM_CTL), //0x09, 0x80, // HID_Collection(HID_Application), //0xa1, 0x01, // HID_ReportID(2), //0x85, 0x02, // HID_UsagePage(HID_USAGE_PAGE_GENERIC), //0x05, 0x01, //HID_USAGE_PAGE_DEV_CONTROLS HID_UsageMin(HID_USAGE_GENERIC_SYSCTL_POWER), //0x19, 0x81, // HID_UsageMax(HID_USAGE_GENERIC_SYSCTL_MENU_EXIT),//0x29, 0x88, // HID_LogicalMin(0), //0x15, 0x00, // HID_LogicalMax(1), //0x25, 0x01, // HID_ReportCount(8), //0x95, 0x08, // HID_ReportSize(1), //0x75, 0x01, // HID_Input(2), //0x81, 0x02, // HID_Data+HID_Variable+HID_Absolute // 這一段是WCH提供的配置里的,注釋后不影響 sundy */ /* HID_EndCollection, //0xc0, // HID_Usage(HID_USAGE_GENERIC_SYSTEM_CTL), //0x09, 0x80, // HID_Collection(HID_Application), //0xa1, 0x01, // HID_ReportID(2), //0x85, 0x02, // HID_UsagePage(HID_USAGE_PAGE_DEV_CONTROLS), //0x05, 0x01, // //HID_UsageMin(HID_USAGE_GENERIC_SYSCTL_POWER), //0x19, 0x81, // //HID_UsageMax(HID_USAGE_GENERIC_SYSCTL_MENU_EXIT),//0x29, 0x88, // HID_LogicalMin(0), //0x15, 0x00, // HID_LogicalMax(0xFF), //0x25, 0x01, // HID_ReportCount(8), //0x95, 0x08, // HID_ReportSize(8), //0x75, 0x01, // HID_Output(2), // 這一段是我增加的,配置后PC無(wú)法枚舉

我汗?。。?! 給你解釋了不下5遍,你居然還沒(méi)明白。 最后和你解釋一遍,每次發(fā)送一包8個(gè)字節(jié)的數(shù)據(jù),等待CH372中斷,解鎖之后在發(fā)送8個(gè)字節(jié)的0X00等待CH372中斷。再次解鎖,之后才能發(fā)送下一個(gè)按鍵值。 而不是你上面所寫(xiě)的,你見(jiàn)過(guò)誰(shuí)按鍵是微秒級(jí)的啊?????


大哥啊,原理我也重復(fù)過(guò)了,你們都說(shuō)正確,可現(xiàn)在得看實(shí)際結(jié)果啊,不能剛說(shuō)原理

我已近列出了兩種結(jié)果,一種正常,一種異常,這個(gè)怎么解釋?zhuān)?/p>


呵呵,看樣子你還是沒(méi)理解,這樣吧,你把程序發(fā)到fqb@wch.cn,我來(lái)幫你把程序改好。改好之后麻煩你在回頭看下我們解釋的是否正確。


我們已經(jīng)給你解釋了幾次正確的流程應(yīng)該怎么做。我們也不希望去給你解釋一個(gè)錯(cuò)誤的行為產(chǎn)生的現(xiàn)象。請(qǐng)按照我們提供的流程去做。 產(chǎn)生這個(gè)現(xiàn)象是由于USBHOST發(fā)送IN令牌的時(shí)候?qū)纹瑱C(jī)來(lái)說(shuō)這個(gè)時(shí)間并不是一定在一個(gè)固定的位置。取數(shù)據(jù)有個(gè)時(shí)間差可能會(huì)導(dǎo)致這個(gè)問(wèn)題。一句話,你的流程錯(cuò)誤。

按照我們給你說(shuō)的流程,絕對(duì)不會(huì)有任何問(wèn)題。為什么不能去修改呢? 這樣你下載一個(gè)軟件叫BUSHOUDN軟件,對(duì)你調(diào)試軟件也有幫助。


哈,這里好多CODE是我寫(xiě)的噢。


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

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