我根据范例修改usb_desc.c .部分内容如下
const u8 CustomHID_ConfigDescriptor[CUSTOMHID_SIZ_CONFIG_DESC] =
{
0x09, /* bLength: Configuation Descriptor size */
USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType: Configuration */
CUSTOMHID_SIZ_CONFIG_DESC,
/* wTotalLength: Bytes returned */
0x00,
0x01, /* bNumInterfaces: 1 interface */
0x01, /* bConfigurationValue: Configuration value */
0x00, /* iConfiguration: Index of string descriptor describing
the configuration*/
0xC0, /* bmAttributes: Bus powered */
/*Bus powered: 7th bit, Self Powered: 6th bit, Remote wakeup: 5th bit, reserved: 4..0 bits */
0x32, /* MaxPower 100 mA: this current is used for detecting Vbus */
// 0x96, /* MaxPower 300 mA: this current is used for detecting Vbus */
/************** Descriptor of Custom HID interface ****************/
/* 09 */
0x09, /* bLength: Interface Descriptor size */
USB_INTERFACE_DESCRIPTOR_TYPE,/* bDescriptorType: Interface descriptor type */
0x00, /* bInterfaceNumber: Number of Interface */
0x00, /* bAlternateSetting: Alternate setting */
0x02, /* bNumEndpoints */
0x03, /* bInterfaceClass: HID */
0x00, /* bInterfaceSubClass : 1=BOOT, 0=no boot */
0x00, /* nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse */
0, /* iInterface: Index of string descriptor */
/******************** Descriptor of Custom HID HID ********************/
/* 18 */
0x09, /* bLength: HID Descriptor size */
HID_DESCRIPTOR_TYPE, /* bDescriptorType: HID */
0x10, /* bcdHID: HID Class Spec release number */
0x01,
0x00, /* bCountryCode: Hardware target country */
0x01, /* bNumDescriptors: Number of HID class descriptors to follow */
0x22, /* bDescriptorType */
CUSTOMHID_SIZ_REPORT_DESC,/* wItemLength: Total length of Report descriptor */
0x00,
/******************** Descriptor of Custom HID endpoints ******************/
/* 27 */
0x07, /* bLength: Endpoint Descriptor size */
USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: */
0x82, /* bEndpointAddress: Endpoint Address (IN) */
// bit 3...0 : the endpoint number
// bit 6...4 : reserved
// bit 7 : 0(OUT), 1(IN)
0x03, /* bmAttributes: Interrupt endpoint */
0x40,//0x02, /* wMaxPacketSize: 20 Bytes max */
0x00,
//0x20, /* bInterval: Polling Interval (21 ms) */
0x0A, /*bInterval: Polling Interval (10 ms)*/
/* 34 */
0x07, /* bLength: Endpoint Descriptor size */
USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: */
/* Endpoint descriptor type */
0x01, /* bEndpointAddress: */
/* Endpoint Address (OUT) */
0x03, /* bmAttributes: Interrupt endpoint */
0x40,//0x02, /* wMaxPacketSize: 20 Bytes max */
0x00,
// 0x10, /* bInterval: Polling Interval (32 ms) */
0x0A, /*bInterval: Polling Interval (10 ms)*/
/* 41 */
}
想设置为一包64字节的~用USB调试助手发送 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 到端点2.有中断。void EP1_OUT_Callback(void)
{
USB_ReceiveFlg = TRUE;
PMAToUserBufferCopy(Receive_Buffer, ENDP1_RXADDR,60);
MsgCmd = Receive_Buffer[0];
SetEPRxStatus(ENDP1, EP_RX_VALID);
}
在这里将缓冲区数据存到Receive_Buffer[64]里。但是在线调试看到的结果是Receive_Buffer[0]到Receive_Buffer[21]的内容是正确的。后面的都乱了~如果我把 wMaxPacketSize的内容改为0x02.则只有Receive_Buffer[0]和Receive_Buffer[1]的数据是对的。。
求解是哪里不对?
修改完desc.c中的CustomHID_ReportDescriptor 需要在desc.h中修改#define CUSTOMHID_SIZ_REPORT_DESC
---------------------------------
多谢回复。根据你的提示,修改了CustomHID_ReportDescriptor中的REPORT_COUNT就好了。万分感谢啊
一周热门 更多>