想請(qǐng)教CH583 Demo中的HostU2Enum這個(gè)例子,關(guān)于枚舉復(fù)合的usb hid類(lèi)設(shè)備過(guò)程

如題,想請(qǐng)教CH583 Demo中的HostU2Enum這個(gè)例子,關(guān)于枚舉復(fù)合的usb hid類(lèi)設(shè)備過(guò)程?



例程的usb hid類(lèi)枚舉過(guò)程,從代碼中可發(fā)現(xiàn),只支持只有一個(gè)接口的Mouse與KEYBOARD設(shè)備;

????????????????/*?分析配置描述符,獲取端點(diǎn)數(shù)據(jù)/各端點(diǎn)地址/各端點(diǎn)大小等,更新變量endp_addr和endp_size等?*/
????????????????cfg?=?((PUSB_CFG_DESCR)U2Com_Buffer)->bConfigurationValue;
????????????????if_cls?=?((PUSB_CFG_DESCR_LONG)U2Com_Buffer)->itf_descr.bInterfaceClass;?//?接口類(lèi)代碼???

????????????????if((dv_cls?==?0x00)?&&?(if_cls?==?USB_DEV_CLASS_HID)?&&?((PUSB_CFG_DESCR_LONG)U2Com_Buffer)->itf_descr.bInterfaceSubClass?<=?0x01)
????????????????{?//?是HID類(lèi)設(shè)備,鍵盤(pán)/鼠標(biāo)等
????????????????????//??從描述符中分析出HID中斷端點(diǎn)的地址
????????????????????s?=?AnalyzeU2HidIntEndp(U2Com_Buffer,?0);?//?從描述符中分析出HID中斷端點(diǎn)的地址
????????????????????PRINT("AnalyzeU2HidIntEndp?%02x\n",?(uint16_t)s);
????????????????????//??保存中斷端點(diǎn)的地址,位7用于同步標(biāo)志位,清0
????????????????????if_cls?=?((PUSB_CFG_DESCR_LONG)U2Com_Buffer)->itf_descr.bInterfaceProtocol;
????????????????????s?=?CtrlSetUsb2Config(cfg);?//?設(shè)置USB設(shè)備配置
????????????????????if(s?==?ERR_SUCCESS)
????????????????????{
????????????????????????//	????					Set_Idle(?);
????????????????????????//	需保存端點(diǎn)信息以便主程序進(jìn)行USB傳輸
????????????????????????ThisUsb2Dev.DeviceStatus?=?ROOT_DEV_SUCCESS;

????????????????????????????if(if_cls?==?1)
????????????????????????????{
????????????????????????????????ThisUsb2Dev.DeviceType?=?DEV_TYPE_KEYBOARD;
????????????????????????????????//	進(jìn)一步初始化,例如設(shè)備鍵盤(pán)指示燈LED等
????????????????????????????????PRINT("U2?USB-Keyboard?Ready\n");
????????????????????????????????SetUsb2Speed(1);?//?默認(rèn)為全速
????????????????????????????????return?(ERR_SUCCESS);
????????????????????????????}
????????????????????????????else?if(if_cls?==?2)
????????????????????????????{
????????????????????????????????ThisUsb2Dev.DeviceType?=?DEV_TYPE_MOUSE;
????????????????????????????????//	為了以后查詢(xún)鼠標(biāo)狀態(tài),應(yīng)該分析描述符,取得中斷端口的地址,長(zhǎng)度等信息
????????????????????????????????PRINT("U2?USB-Mouse?Ready\n");
????????????????????????????????SetUsb2Speed(1);?//?默認(rèn)為全速
????????????????????????????????return?(ERR_SUCCESS);
????????????????????????????}else{


????????????????????????????}

????????????????????????s?=?ERR_USB_UNSUPPORT;
????????????????????}
????????????????}


但是我們公司開(kāi)發(fā)的設(shè)備都是custom hid類(lèi)設(shè)備;一般都是Joystick,mouse,keyboard多個(gè)接口的復(fù)合;

我打算先判斷接口數(shù)量bNumInterfaces,然后獲取各個(gè)接口的bInterfaceProtocol,如果bInterfaceProtocol=0則為復(fù)合或其他設(shè)備,然后判斷各個(gè)接口下的報(bào)告描述符的Usage 部分從而判斷該接口是Mouse接口,還是gamepad或其他;

Usage Page (Generic Desktop)05?01?Usage (Mouse)09?02?


請(qǐng)問(wèn)這個(gè)解析復(fù)合設(shè)備過(guò)程是否有例程可參考,或請(qǐng)給我一些建議;


另外

hisUsb2Dev.DeviceType?=?DEV_TYPE_KEYBOARD;

里面的

#define DEV_TYPE_KEYBOARD? ? ? (USB_DEV_CLASS_HID | 0x20)

#define DEV_TYPE_MOUSE? ? ? ? ?(USB_DEV_CLASS_HID | 0x30)

typedef?struct
{
????uint8_t??DeviceStatus;??//?設(shè)備狀態(tài),0-無(wú)設(shè)備,1-有設(shè)備但尚未初始化,2-有設(shè)備但初始化枚舉失敗,3-有設(shè)備且初始化枚舉成功
????uint8_t??DeviceAddress;?//?設(shè)備被分配的USB地址
????uint8_t??DeviceSpeed;???//?0為低速,非0為全速
????uint8_t??DeviceType;????//?設(shè)備類(lèi)型
????uint16_t?DeviceVID;
????uint16_t?DevicePID;
????uint8_t??GpVar[4];?????//?通用變量,存放端點(diǎn)
????uint8_t??GpHUBPortNum;?//?通用變量,如果是HUB,表示HUB端口數(shù)
}?_RootHubDev;

我想問(wèn)一下_RootHubDev.DeviceType 是自定義的嗎?是否可以作以下定義

#define DEV_TYPE_KEYBOARD? ? ? (USB_DEV_CLASS_HID | 0x20)

#define DEV_TYPE_MOUSE? ? ? ? ?(USB_DEV_CLASS_HID | 0x30)

#define DEV_TYPE_GAMEPAD? ? ? (USB_DEV_CLASS_HID | 0x40)

#define DEV_TYPE_JOYSTICK? ? ? ? ?(USB_DEV_CLASS_HID | 0x50)

#define DEV_TYPE_OTHER? ? ? ? ?(USB_DEV_CLASS_HID | 0x60)



熱門(mén)產(chǎn)品 : USB3.0 HUB控制器:CH634

http://www.findthetime.net/downloads/CH559EVT_ZIP.html
可以參考559的USB主機(jī)例子,USB這塊基本都是一樣的可以參考。?


559的USB主機(jī)例子跟ch583的完全一樣,都是一個(gè)接口設(shè)備的主機(jī)枚舉過(guò)程,沒(méi)有復(fù)合設(shè)備的;


image.png

分析多接口的,看例子的這個(gè)地方


j_0069.gif好的,看到了,感謝,膜拜大佬?。。?/p>


請(qǐng)問(wèn)樓主怎么解決的呢?我這也遇到相同問(wèn)題了


您好,可以參考559例程中的處理,583EVT中沒(méi)有識(shí)別多接口的代碼。


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

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