|
发表于 2017-10-13 11:27:42
|
显示全部楼层
不过 STM32F072 端点不够用,不能实现 4 个 CDC UART,只能实现 3 个, 这里有个例子
- /* bespoke struct for this device; struct members are added and removed as needed */
- struct configuration_1
- {
- struct configuration_descriptor config;
- struct cdc_interface cdc[NUM_OF_CDC_UARTS];
- };
- /* fully initialize the bespoke struct as a const */
- __ALIGN_BEGIN static const struct configuration_1 USBD_Composite_CfgFSDesc __ALIGN_END =
- {
- {
- /*Configuration Descriptor*/
- sizeof(struct configuration_descriptor), /* bLength */
- USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType */
- USB_UINT16(sizeof(USBD_Composite_CfgFSDesc)), /* wTotalLength */
- USBD_MAX_NUM_INTERFACES, /* bNumInterfaces */
- 0x01, /* bConfigurationValue */
- 0x00, /* iConfiguration */
- 0x80, /* bmAttributes */
- 50, /* MaxPower */
- },
- {
- #if (NUM_OF_CDC_UARTS > 0)
- /* CDC1 */
- CDC_DESCRIPTOR(/* Command ITF */ 0x00, /* Data ITF */ 0x01, /* Command EP */ 0x82, /* DataOut EP */ 0x01, /* DataIn EP */ 0x81)
- #endif
- #if (NUM_OF_CDC_UARTS > 1)
- /* CDC2 */
- CDC_DESCRIPTOR(/* Command ITF */ 0x02, /* Data ITF */ 0x03, /* Command EP */ 0x84, /* DataOut EP */ 0x03, /* DataIn EP */ 0x83)
- #endif
- #if (NUM_OF_CDC_UARTS > 2)
- /* CDC3 */
- CDC_DESCRIPTOR(/* Command ITF */ 0x04, /* Data ITF */ 0x05, /* Command EP */ 0x86, /* DataOut EP */ 0x05, /* DataIn EP */ 0x85)
- #endif
- },
- };
复制代码
|
|