/*;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ú)法枚舉