OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 7576|回复: 5

求包养,求F401 USB CDC DEMO

[复制链接]

13

主题

49

帖子

1

精华

中级会员

Rank: 3Rank: 3

积分
315
金钱
315
注册时间
2012-8-28
在线时间
22 小时
发表于 2014-7-16 10:56:12 | 显示全部楼层 |阅读模式
5金钱

弄了几天头都弄了晕了,移植STM32F401 USB  CDC  (用HID改过去的),电脑驱动安装了(VID  ID使用PL2303的),能识别到到虚拟串口


本以为可以用了,坑爹的,用串口调试助手打开傻眼了,


提示串口被占用或其他错误,我马上修改串口好,还是这样,按照以前做的USB描述符改了一点东西,还是一样,心灰意冷了~  不想弄了
唉~哪位大神可以提供个DEMO 或着帮我看看这个代码。

Keil_f4boot .rar

3.15 MB, 下载次数: 124

最佳答案

查看完整内容[请看2#楼]

弄好了!! 调试STLINK 还是真是方便,没这玩意还不知道要找多久。
正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

13

主题

49

帖子

1

精华

中级会员

Rank: 3Rank: 3

积分
315
金钱
315
注册时间
2012-8-28
在线时间
22 小时
 楼主| 发表于 2014-7-16 10:56:13 | 显示全部楼层
弄好了!! 调试STLINK 还是真是方便,没这玩意还不知道要找多久。
回复

使用道具 举报

38

主题

2061

帖子

6

精华

论坛大神

Rank: 7Rank: 7Rank: 7

积分
3273
金钱
3273
注册时间
2012-1-16
在线时间
37 小时
发表于 2014-7-16 20:23:55 | 显示全部楼层
帮顶。。。。
站在巨人的肩膀上不断的前进。。。
回复

使用道具 举报

530

主题

11万

帖子

34

精华

管理员

Rank: 12Rank: 12Rank: 12

积分
165371
金钱
165371
注册时间
2010-12-1
在线时间
2110 小时
发表于 2014-7-16 22:48:25 | 显示全部楼层
官方的demo搞通了么?
我是开源电子网www.openedv.com站长,有关站务问题请与我联系。
正点原子STM32开发板购买店铺http://openedv.taobao.com
正点原子官方微信公众平台,点击这里关注“正点原子”
回复

使用道具 举报

13

主题

49

帖子

1

精华

中级会员

Rank: 3Rank: 3

积分
315
金钱
315
注册时间
2012-8-28
在线时间
22 小时
 楼主| 发表于 2014-7-16 23:47:05 | 显示全部楼层

官方的是HID的DEMO,移植到我这个工程上来是可以的,(HID,鼠标会正常移动)。但是CDC就是不行,今天下午把描述符又改了一堆,后来用STLINK调试(表示好久没用过这玩意)发现有进异常中断,
void HardFault_Handler(void)
{
 if(++j == 1000000)
 {
  j = 0;
  if(i)
  {
   i=0;
   GPIOD->BSRRL |= 1<<13;
  }
  else
  {
   i=1;
   GPIOD->BSRRH |= 1<<13;
  }
 }
}

我的发送接收FIFO都是设置64个字节长度,命令包长8个字节,发送端点0x81 接收端点0x03  CMD端点 0x82

__ALIGN_BEGIN uint8_t usbd_cdc_CfgDesc[USB_CDC_CONFIG_DESC_SIZ]  __ALIGN_END =
{
  /*Configuration Descriptor*/
  0x09,   /* bLength: Configuration Descriptor size */
  USB_CONFIGURATION_DESCRIPTOR_TYPE,      /* bDescriptorType: Configuration */
  USB_CDC_CONFIG_DESC_SIZ,                /* wTotalLength:no of returned bytes */
  0x00,
  0x02,   /* bNumInterfaces: 2 interface */
  0x01,   /* bConfigurationValue: Configuration value */
  0x00,   /* iConfiguration: Index of string descriptor describing the configuration */
  0xC0,   /* bmAttributes: self powered */
  0x00,   /* MaxPower 0 mA */
 
  /*---------------------------------------------------------------------------*/
 
  /*Interface Descriptor */
  0x09,   /* bLength: Interface Descriptor size */
  USB_INTERFACE_DESCRIPTOR_TYPE,  /* bDescriptorType: Interface */
  /* Interface descriptor type */
  0x00,   /* bInterfaceNumber: Number of Interface */
  0x00,   /* bAlternateSetting: Alternate setting */
  0x01,   /* bNumEndpoints: One endpoints used */
  0x02,   /* bInterfaceClass: Communication Interface Class */
  0x02,   /* bInterfaceSubClass: Abstract Control Model */
  0x01,   /* bInterfaceProtocol: Common AT commands */
  0x00,   /* iInterface: */
 
  /*Header Functional Descriptor*/
  0x05,   /* bLength: Endpoint Descriptor size */
  0x24,   /* bDescriptorType: CS_INTERFACE */
  0x00,   /* bDescriptorSubtype: Header Func Desc */
  0x10,   /* bcdCDC: spec release number */
  0x01,
 
  /*Call Management Functional Descriptor*/
  0x05,   /* bFunctionLength */
  0x24,   /* bDescriptorType: CS_INTERFACE */
  0x01,   /* bDescriptorSubtype: Call Management Func Desc */
  0x00,   /* bmCapabilities: D0+D1 */
  0x01,   /* bDataInterface: 1 */
 
  /*ACM Functional Descriptor*/
  0x04,   /* bFunctionLength */
  0x24,   /* bDescriptorType: CS_INTERFACE */
  0x02,   /* bDescriptorSubtype: Abstract Control Management desc */
  0x02,   /* bmCapabilities */
 
  /*Union Functional Descriptor*/
  0x05,   /* bFunctionLength */
  0x24,   /* bDescriptorType: CS_INTERFACE */
  0x06,   /* bDescriptorSubtype: Union func desc */
  0x00,   /* bMasterInterface: Communication class interface */
  0x01,   /* bSlaveInterface0: Data Class Interface */
 
  /*Endpoint 2 Descriptor*/
  0x07,                           /* bLength: Endpoint Descriptor size */
  USB_ENDPOINT_DESCRIPTOR_TYPE,   /* bDescriptorType: Endpoint */
  CDC_CMD_EP,                     /* bEndpointAddress */
  0x03,                           /* bmAttributes: Interrupt */
  LOBYTE(CDC_CMD_PACKET_SZE),     /* wMaxPacketSize: */
  HIBYTE(CDC_CMD_PACKET_SZE),
#ifdef USE_USB_OTG_HS
  0x10,                           /* bInterval: */
#else
  0xFF,                           /* bInterval: */
#endif /* USE_USB_OTG_HS */
 
  /*---------------------------------------------------------------------------*/
 
  /*Data class interface descriptor*/
  0x09,   /* bLength: Endpoint Descriptor size */
  USB_INTERFACE_DESCRIPTOR_TYPE,  /* bDescriptorType: */
  0x01,   /* bInterfaceNumber: Number of Interface */
  0x00,   /* bAlternateSetting: Alternate setting */
  0x02,   /* bNumEndpoints: Two endpoints used */
  0x0A,   /* bInterfaceClass: CDC */
  0x00,   /* bInterfaceSubClass: */
  0x00,   /* bInterfaceProtocol: */
  0x00,   /* iInterface: */
 
  /*Endpoint OUT Descriptor*/
  0x07,   /* bLength: Endpoint Descriptor size */
  USB_ENDPOINT_DESCRIPTOR_TYPE,      /* bDescriptorType: Endpoint */
  CDC_OUT_EP,                        /* bEndpointAddress */
  0x02,                              /* bmAttributes: Bulk */
  LOBYTE(CDC_DATA_MAX_PACKET_SIZE),  /* wMaxPacketSize: */
  HIBYTE(CDC_DATA_MAX_PACKET_SIZE),
  0x00,                              /* bInterval: ignore for Bulk transfer */
 
  /*Endpoint IN Descriptor*/
  0x07,   /* bLength: Endpoint Descriptor size */
  USB_ENDPOINT_DESCRIPTOR_TYPE,      /* bDescriptorType: Endpoint */
  CDC_IN_EP,                         /* bEndpointAddress */
  0x02,                              /* bmAttributes: Bulk */
  LOBYTE(CDC_DATA_MAX_PACKET_SIZE),  /* wMaxPacketSize: */
  HIBYTE(CDC_DATA_MAX_PACKET_SIZE),
  0x00                               /* bInterval: ignore for Bulk transfer */
} ;
我怀疑是PC指针跑到偏了

回复

使用道具 举报

1

主题

2

帖子

0

精华

新手入门

积分
31
金钱
31
注册时间
2015-9-22
在线时间
0 小时
发表于 2015-9-29 20:12:20 | 显示全部楼层
楼主,我遇到了同样的问题,你是怎么解决的,快分享一下
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-2-25 09:23

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表