STM32F767 USB 端点0发送数据长度问题
问题详细描述如下: 1. 我使用的是F767的主芯片,使用了ST的USB库;2. 我USB的配置描述符如下:__ALIGN_BEGIN static uint8_tUSBD_HID_CfgDesc __ALIGN_END ={0x09, /* bLength: Configuration Descriptor size */USB_CONFIGURATION_DESCRIPTOR_TYPE, /*bDescriptorType: Configuration */USB_HID_CONFIG_DESC_SIZ,/* wTotalLength: Bytes returned */0x00, 0x01, /*bNumInterfaces: 1interface*/ 0x01, /*bConfigurationValue:Configuration value*/0x00, /*iConfiguration: Index of string descriptor describingthe configuration*/ 0xE0, /*bmAttributes: buspowered and Support Remote Wake-up */ 0x32, /*MaxPower 100 mA: thiscurrent is used for detecting Vbus*//************** Descriptor of Joystick Mouseinterface ****************//* 09 */ 0x09, /*bLength: InterfaceDescriptor size*/USB_INTERFACE_DESCRIPTOR_TYPE,/*bDescriptorType:Interface descriptor type*/ 0x00, /*bInterfaceNumber:Number of Interface*/ 0x00, /*bAlternateSetting:Alternate setting*/ 0x04, /*bNumEndpoints*/ 0x00, /*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 Mouse endpoint********************//* 18 */ 0x07, /*bLength: EndpointDescriptor size*/USB_ENDPOINT_DESCRIPTOR_TYPE, /*bDescriptorType:*/HID_IN_EP, /*bEndpointAddress: Endpoint Address (IN)*/ 0x03, /*bmAttributes:Interrupt endpoint*/HID_IN_PACKET, /*wMaxPacketSize: 4 Byte max */0x00, 0x0A, /*bInterval: PollingInterval (10 ms)*//******************** Descriptor of Mouse endpoint********************//* 25 */ 0x07, /*bLength: Endpoint Descriptor size*/USB_ENDPOINT_DESCRIPTOR_TYPE, /*bDescriptorType:*/HID_OUT_EP, /*bEndpointAddress: Endpoint Address (IN)*/ 0x03, /*bmAttributes:Interrupt endpoint*/HID_IN_PACKET, /*wMaxPacketSize: 4 Byte max */0x00, 0x0A, /*bInterval:Polling Interval (10 ms)*//******************** Descriptor of Mouse endpoint********************//* 32 */ 0x07, /*bLength: EndpointDescriptor size*/USB_ENDPOINT_DESCRIPTOR_TYPE, /*bDescriptorType:*/HID_IN_BULK_EP, /*bEndpointAddress: Endpoint Address (IN)*/ 0x02, /*bmAttributes:bulk endpoint*/HID_IN_BULK_PACKET, /*wMaxPacketSize: 64 Byte max*/0x00, 0x0A, /*bInterval:Polling Interval (10 ms)*//******************** Descriptor of Mouse endpoint********************//* 39 */ 0x07, /*bLength: EndpointDescriptor size*/USB_ENDPOINT_DESCRIPTOR_TYPE, /*bDescriptorType:*/HID_OUT_BULK_EP, /*bEndpointAddress: Endpoint Address (OUT)*/ 0x02, /*bmAttributes:bulk endpoint*/HID_OUT_BULK_PACKET, /*wMaxPacketSize: 64 Byte max*/0x00, 0x0A, /*bInterval:Polling Interval (10 ms)*//* 46 */} ; 3. 插入USB端口后,STM32端的打印信息:USBD_StdDevReq,req=0x80, request=0x6, value=0x100, index=0x0, len=0x12 USBD_GetDescriptor,len=18 USBD_StdDevReq,req=0x80, request=0x6, value=0x200, index=0x0, len=0x9USBD_HID_GetCfgDesc USBD_GetDescriptor,len=9 USBD_StdDevReq,req=0x80, request=0x6, value=0x200, index=0x0, len=0x2eUSBD_HID_GetCfgDescè这里是获取配置描述符 USBD_GetDescriptor,len=46è打印显示配置描述符的长度是46字节 USBD_StdDevReq,req=0x0, request=0x9, value=0x0, index=0x0, len=0x0 对应的函数如下:staticvoid USBD_GetDescriptor(USB_OTG_CORE_HANDLE*pdev, USB_SETUP_REQ*req)函数内容见1.jpg;
4. 在PC端观察到的数据传输如下: 见附件 Bus Hound.jpg 图片。PC请求0x2e长度的描述符,但STM32只发送了32字节的数据。这个可能是什么原因呢?
看圈圈的讲解。第一次返回描述符的时候,不是必须返回完整的。但是能告知host完整的描述符有多长 把bus huond的长度显示出来 0x09,.......0x00,0x0A。没毛病,数组里的配置数据全部发送出去了。2E不是PC请求的,是你自己填进去的。好好理解一下USB的枚举过程吧。 楼主用的是nucleo_f767的板做的吗?两个问题请教一下:
1、楼主有CDC的工程吗?我直接用cube生成的一直在PC端显示设备无法正常运行。
2、怎么用bus hound抓取usb设备则插入电脑时的通信数据。
谢谢! 楼主用的是nucleo_f767的板做的吗?两个问题请教一下:
1、楼主有CDC的工程吗?我直接用cube生成的一直在PC端显示设备无法正常运行。
2、怎么用bus hound抓取usb设备则插入电脑时的通信数据。
谢谢!
页:
[1]