myusb_corc.c中USB的描述段如下:有一个接口,包含一进一出两个Bulk方式的端点
__ALIGN_BEGIN const usb_descriptor_device_struct device_descripter __ALIGN_END =
{
.Header =
{
.bLength = USB_DEVICE_DESC_SIZE,
.bDescriptorType = USB_DESCTYPE_DEVICE
},
.bcdUSB = 0x0200,
.bDeviceClass = 0xff, // 厂商定义的描述符
.bDeviceSubClass = 0x00,
.bDeviceProtocol = 0x00,
.bMaxPacketSize0 = USB_MAX_EP0_SIZE,
.idVendor = USBD_VID,
.idProduct = USBD_PID,
.bcdDevice = 0x0100,
.iManufacturer = USBD_MFC_STR_IDX,
.iProduct = USBD_PRODUCT_STR_IDX,
.iSerialNumber = USBD_SERIAL_STR_IDX,
.bNumberConfigurations = USBD_CFG_MAX_NUM
};
/* USB device configuration descriptor */
__ALIGN_BEGIN const usb_descriptor_configuration_set_struct configuration_descriptor __ALIGN_END =
{
.Config = // 9Bytes
{
.Header =
{
.bLength = sizeof(usb_descriptor_configuration_struct),
.bDescriptorType = USB_DESCTYPE_CONFIGURATION
},
.wTotalLength = USB_MY_CONFIG_DESC_SIZE, // 32Bytes
.bNumInterfaces = 0x01,
.bConfigurationValue = 0x01,
.iConfiguration = 0x00,
.bmAttributes = 0xC0, // 自给电源
.bMaxPower = 0x32
},
.Printer_Interface = // 9Bytes
{
.Header =
{
.bLength = sizeof(usb_descriptor_interface_struct),
.bDescriptorType = USB_DESCTYPE_INTERFACE
},
.bInterfaceNumber = 0x00,
.bAlternateSetting = 0x00,
.bNumEndpoints = 0x02,
.bInterfaceClass = 0x00,
.bInterfaceSubClass = 0x00,
.bInterfaceProtocol = 0x00,
.iInterface = 0x00
},
.Printer_IN_Endpoint = // 7Bytes
{
.Header =
{
.bLength = sizeof(usb_descriptor_endpoint_struct),
.bDescriptorType = USB_DESCTYPE_ENDPOINT
},
.bEndpointAddress = DEVICE_IN_EP,
.bmAttributes = 0x02, // Bulk
.wMaxPacketSize = DEVICE_IN_PACKET,
.bInterval = 0x00
},
.Printer_OUT_Endpoint = // 7Bytes
{
.Header =
{
.bLength = sizeof(usb_descriptor_endpoint_struct),
.bDescriptorType = USB_DESCTYPE_ENDPOINT
},
.bEndpointAddress = DEVICE_OUT_EP,
.bmAttributes = 0x02,
.wMaxPacketSize = DEVICE_OUT_PACKET,
.bInterval = 0x00
},
};
/* USB language ID Descriptor */
__ALIGN_BEGIN const usb_descriptor_language_id_struct usbd_language_id_desc __ALIGN_END =
{
.Header =
{
.bLength = sizeof(usb_descriptor_language_id_struct),
.bDescriptorType = USB_DESCTYPE_STRING
},
.wLANGID = ENG_LANGID
};
__ALIGN_BEGIN uint8_t* usbd_strings[] __ALIGN_END =
{
[USBD_LANGID_STR_IDX] = (uint8_t *)&usbd_language_id_desc,
[USBD_MFC_STR_IDX] = USBD_STRING_DESC("GigaDevice"),
[USBD_PRODUCT_STR_IDX] = USBD_STRING_DESC("GD32 USB in HS Mode"),
[USBD_SERIAL_STR_IDX] = USBD_STRING_DESC("GD32F4xx-1.0.0-5f9e10dma")
};
|