初中生
最后登录1970-1-1
在线时间 小时
注册时间2018-9-7
|
本人使用外部flash模拟为u盘的例程改为模拟成键盘,修改了MASS_ConfigDescriptor数组,在main函数把Set_System()函数注释掉了,但主机没有反应,请求大佬指教,谢谢
const uint8_t MASS_ConfigDescriptor[MASS_SIZ_CONFIG_DESC] =
{
0x09, /* bLength: Configuration Descriptor size */
0x02, /* bDescriptorType: Configuration */
MASS_SIZ_CONFIG_DESC,
0x00,
0x01, /* bNumInterfaces: 2 interface mayh debug ¸ÃÅäÖðüo¬μĽó¿úêy£¬¸′oÏé豸,ὸö½ó¿*/
0x01, /* bConfigurationValue: */
/* Configuration value */
0x00, /* iConfiguration: */
/* Index of string descriptor */
/* describing the configuration */
0xC0, /* bmAttributes: ¸Ãé豸μÄêôDÔ£¬USB_CONFIG_SELF_POWERED=0xc0*/
/* bus powered */
0x32, /* MaxPower 100 mA £¬¸Ãé豸DèòaμÄ×î′óμçá÷á¿*/
0x09, //bLength×ֶΡ£½ó¿úÃèêö·ûμÄ3¤¶èÎa9×Ö½ú
0x04, //bDescriptorType×ֶΡ£½ó¿úÃèêö·ûμıàoÅÎa0x04¡£
0x00, //bInterfaceNumber×Ö¶Î,¸Ã½ó¿úμıàoÅ£¬μú¶t¸ö½ó¿ú£¬±àoÅÎa1¡£
0x00, //bAlternateSetting×Ö¶Î,¸Ã½ó¿úμı¸óñàoÅ£¬Îa0
0x02, //bNumEndpoints×ֶΣ¬·Ç0¶ËμãμÄêyÄ¿¡£¸Ã½ó¿úóD2¸öÅúῶËμã
0x03, //bInterfaceClass×Ö¶Î,¸Ã½ó¿úËùê1óÃμÄàà¡£′óèYá¿′æ′¢é豸½ó¿úààμÄ′úÂëÎa0x08¡£HIDé豸Îa0x03£¬USB_DEVICE_CLASS_HUMAN_INTERFACE=0x03
0x01, //bInterfaceSubClass×ֶΣ¬¸Ã½ó¿úËùê1óÃμÄ×óàà¡£ÔúHID1.1D-òéÖD£¬Ö»1涨áËò»ÖÖ×óàà£oÖ§3ÖBIOSòyμ¼Æô¶ˉμÄ×óàà¡£USB¼üÅì¡¢êó±êêôóú¸Ã×óà࣬×óàà′úÂëÎa0x01¡£
0x01, //bInterfaceProtocol×ֶΣ¬èç1û×óààÎaÖ§3Öòyμ¼Æô¶ˉμÄ×óà࣬ÔòD-òé¿éÑ¡Ôñêó±êoí¼üÅì¡£¼üÅì′úÂëÎa0x01£¬êó±ê′úÂëÎa0x02¡£×Ô¶¨òåμÄHIDé豸£¬ò22»ê1óÃD-òé¡£
0x00, //iConfiguration×Ö¶Î,¸Ã½ó¿úμÄ×Ö·û′®Ë÷òyÖμ¡£ÕaàïûóD£¬Îa0¡£
/******************HIDÃèêö·û************************/
0x09, //bLength×ֶΣ¬±¾HIDÃèêö·ûÏÂÖ»óDò»¸öϼ¶Ãèêö·û¡£ËùòÔ3¤¶èÎa9×Ö½ú¡£
0x21, //bDescriptorType×Ö¶Î,HIDÃèêö·ûμıàoÅÎa0x21
//0x10, //bcdHID×ֶΣ¬±¾D-òéê1óÃμÄHID1.1D-òé¡£×¢òaμí×Ö½úÔúÏè¡£
0x00,
0x01,
0x21, //bCountyCode×Ö¶Î,é豸êêóÃμÄ1ú¼ò′úÂ룬ÕaàïÑ¡ÔñÎaÃà1ú£¬′úÂë0x21¡£
0x01, //bNumDescriptors×ֶΣ¬Ï¼¶Ãèêö·ûμÄêyÄ¿¡£ÎòÃÇÖ»óDò»¸ö±¨¸æÃèêö·û¡£
0x22, //bDescriptorType×Ö¶Î,ϼ¶Ãèêö·ûμÄààDí£¬Îa±¨¸æÃèêö·û£¬±àoÅÎa0x22¡£
//bDescriptorLength×ֶΡ£
//ϼ¶Ãèêö·ûμÄ3¤¶è¡£ϼ¶Ãèêö·ûÎa¼üÅ챨¸æÃèêö·û¡£
sizeof(KeyboardReportDescriptor)&0xFF,
(sizeof(KeyboardReportDescriptor)>>8)&0xFF,
/**********************êäèë¶ËμãÃèêö·û***********************/
0x07, //bLength×ֶΣ¬¶ËμãÃèêö·û3¤¶èÎa7×Ö½ú¡£
0x05, //bDescriptorType×ֶΣ¬¶ËμãÃèêö·û±àoÅÎa0x05¡£
0x81, //bEndpointAddress×Ö¶Î,¶ËμãμÄμØÖ·¡£ÎòÃÇê1óÃD12μÄêäèë¶Ëμã1¡£
0x03, //bmAttributes×ֶΣ¬D1~D0Îa¶Ëμã′«êäààDíÑ¡Ôñ¡£0x03 //ÖD¶Ï¶Ëμã
0x10, //wMaxPacketSize×ֶΡ£¸Ã¶ËμãμÄ×î′ó°ü3¤¡£×î′ó°ü3¤Îa64×Ö½ú¡£
0x00,
0x0A, //bInterval×Ö¶Î
/**********************êä3ö¶ËμãÃèêö·û***********************/
0x07, //bLength×Ö¶Î
0x05, //bDescriptorType×Ö¶Î
0x02, //bEndpointAddress×Ö¶Î
0x03, //bmAttributes×ֶΣ¬0x03 //ÖD¶Ï¶Ëμã
0x10, //wMaxPacketSize×Ö¶Î
0x00,
0x0A, //bInterval×Ö¶Î
};
////////////////////////ÅäÖÃÃèêö·û¼ˉoÏíê±Ï//////////////////////////
//USB¼üÅ챨¸æÃèêö·ûμĶ¨òå
const u8 KeyboardReportDescriptor[63]=
{
0x05, 0x01, // USAGE_PAGE (Generic Desktop) //63
0x09, 0x06, // USAGE (Keyboard)
0xa1, 0x01, // COLLECTION (Application)
0x05, 0x07, // USAGE_PAGE (Keyboard)
0x19, 0xe0, // USAGE_MINIMUM (Keyboard LeftControl)
0x29, 0xe7, // USAGE_MAXIMUM (Keyboard Right GUI)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x01, // LOGICAL_MAXIMUM (1)
0x75, 0x01, // REPORT_SIZE (1)
0x95, 0x08, // REPORT_COUNT (8)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x95, 0x01, // REPORT_COUNT (1)
0x75, 0x08, // REPORT_SIZE (8)
0x81, 0x03, // INPUT (Cnst,Var,Abs)
0x95, 0x05, // REPORT_COUNT (5)
0x75, 0x01, // REPORT_SIZE (1)
0x05, 0x08, // USAGE_PAGE (LEDs)
0x19, 0x01, // USAGE_MINIMUM (Num Lock)
0x29, 0x05, // USAGE_MAXIMUM (Kana)
0x91, 0x02, // OUTPUT (Data,Var,Abs)
0x95, 0x01, // REPORT_COUNT (1)
0x75, 0x03, // REPORT_SIZE (3)
0x91, 0x03, // OUTPUT (Cnst,Var,Abs)
0x95, 0x06, // REPORT_COUNT (6)
0x75, 0x08, // REPORT_SIZE (8)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x65, // LOGICAL_MAXIMUM (101)
0x05, 0x07, // USAGE_PAGE (Keyboard)
0x19, 0x00, // USAGE_MINIMUM (Reserved (no event indicated))
0x29, 0x65, // USAGE_MAXIMUM (Keyboard Application)
0x81, 0x00, // INPUT (Data,Ary,Abs)
0xc0, // END_COLLECTION
//0xc0,
}; /* Joystick_ReportDescriptor */
///////////////////////////¼üÅ챨¸æÃèêö·ûíê±Ï////////////////////////////
[img]file:///C:\Users\Administrator\AppData\Roaming\Tencent\Users\2733601780\QQ\WinTemp\RichOle\YX88I1{W6[`QHG_4@QXK}P6.png[/img]
[img]file:///C:\Users\Administrator\AppData\Roaming\Tencent\Users\2733601780\QQ\WinTemp\RichOle\YX88I1{W6[`QHG_4@QXK}P6.png[/img]
|
|