eric2013 发表于 2020-6-16 01:59:42

RL-USB V6.X自定义描述符



原始定义:

/* USB Device 0 Endpoint 0 Descriptor */
extern const uint8_t usbd0_ep0_descriptor[];
__WEAK const uint8_t usbd0_ep0_descriptor[] __ALIGNED(4) = { USBD_EP0(0) };

/* USB Device 0 Standard Descriptor */
extern const uint8_t usbd0_device_descriptor[];
__WEAK const uint8_t usbd0_device_descriptor[] __ALIGNED(4) = {
USB_DEVICE_DESC_SIZE,               /* bLength */
USB_DEVICE_DESCRIPTOR_TYPE,         /* bDescriptorType */
WBVAL(USBD0_BDC_USB),               /* bcdUSB */
#if (USBD0_USE_IAD)
USB_DEVICE_CLASS_MISCELLANEOUS,       /* bDeviceClass    (use from Interface Association Descriptors) */
0x02,                                 /* bDeviceSubClass (use from Interface Association Descriptors) */
0x01,                                 /* bDeviceProtocol (use from Interface Association Descriptors) */
#elif (((USBD0_CDC_CNT == 1U) && (USBD0_CDC_ACM_CNT == 1U)) || \
       ((USBD0_CDC_CNT == 1U) && (USBD0_CDC_NCM_CNT == 1U)))
CDC_COMMUNICATION_INTERFACE_CLASS,    /* bDeviceClass */
0x00,                                 /* bDeviceSubClass */
0x00,                                 /* bDeviceProtocol */
#else
0x00,                                 /* bDeviceClass    (use from Interface Descriptors) */
0x00,                                 /* bDeviceSubClass (use from Interface Descriptors) */
0x00,                                 /* bDeviceProtocol (use from Interface Descriptors) */
#endif
USBD0_MAX_PACKET0,                  /* bMaxPacketSize0 */
WBVAL(USBD0_DEV_DESC_IDVENDOR),       /* idVendor */
WBVAL(USBD0_DEV_DESC_IDPRODUCT),      /* idProduct */
WBVAL(USBD0_DEV_DESC_BCDDEVICE),      /* bcdDevice */
0x01,                                 /* iManufacturer */
0x02,                                 /* iProduct */
0x03*USBD0_STR_DESC_SER_EN,         /* iSerialNumber */
0x01                                  /* bNumConfigurations: one possible configuration */
};


自定义:
const uint8_t usbd0_device_descriptor[] __ALIGNED(4) = {
      0x12,               /* bLength */
      0x01,
      0x10,
      0x01,
      0xef,
      0x02,
      0x01,
      0x08,
      0x51,
      0xC2,
      0x05,
      0x35,
      0x00,
      0x01,
      0x01,
      0x02,
      0x03,
      0x01
};


页: [1]
查看完整版本: RL-USB V6.X自定义描述符