你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

STM32F767 USB 端点0发送数据长度问题

[复制链接]
法兰克伍 提问时间:2017-10-11 12:11 /
   问题详细描述如下:
1.      我使用的是F767的主芯片,使用了ST的USB库;
2.      我USB的配置描述符如下:
__ALIGN_BEGIN static uint8_tUSBD_HID_CfgDesc[USB_HID_CONFIG_DESC_SIZ] __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 describing
  the 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,          /*bIntervalolling 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,          /*bIntervalolling 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,          /*bIntervalolling 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=0x9
USBD_HID_GetCfgDesc
USBD_GetDescriptor,len=9
USBD_StdDevReq,req=0x80, request=0x6, value=0x200, index=0x0, len=0x2e
USBD_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字节的数据。这个可能是什么原因呢?



1.jpg
Bus Hound.jpg
收藏 评论5 发布时间:2017-10-11 12:11

举报

5个回答
斜阳 回答时间:2017-10-11 13:14:08
看圈圈的讲解。第一次返回描述符的时候,不是必须返回完整的。但是能告知host完整的描述符有多长

评分

参与人数 1ST金币 +2 收起 理由
zero99 + 2

查看全部评分

衔胆栖冰 回答时间:2017-10-11 15:51:58
把bus huond的长度显示出来
衔胆栖冰 回答时间:2017-10-11 16:48:14
0x09,.......0x00,0x0A。没毛病,数组里的配置数据全部发送出去了。2E不是PC请求的,是你自己填进去的。好好理解一下USB的枚举过程吧。

评分

参与人数 1ST金币 +2 收起 理由
zero99 + 2

查看全部评分

uwyciw100 回答时间:2017-10-12 10:29:07
楼主用的是nucleo_f767的板做的吗?两个问题请教一下:
1、楼主有CDC的工程吗?我直接用cube生成的一直在PC端显示设备无法正常运行。
2、怎么用bus hound抓取usb设备则插入电脑时的通信数据。
谢谢!
uwyciw100 回答时间:2017-10-12 10:29:28
楼主用的是nucleo_f767的板做的吗?两个问题请教一下:
1、楼主有CDC的工程吗?我直接用cube生成的一直在PC端显示设备无法正常运行。
2、怎么用bus hound抓取usb设备则插入电脑时的通信数据。
谢谢!

所属标签

相似问题

官网相关资源

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
STM32N6 AI生态系统
STM32MCU,MPU高性能GUI
ST ACEPACK电源模块
意法半导体生物传感器
STM32Cube扩展软件包
关注我们
st-img 微信公众号
st-img 手机版