/********************************** (C) COPYRIGHT ******************************* * File Name : usb_desc.c * Author : WCH * Version : V1.0.0 * Date : 2022/08/20 * Description : usb device descriptor,configuration descriptor, * string descriptors and other descriptors. ********************************************************************************* * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. * Attention: This software (modified or not) and binary are used for * microcontroller manufactured by Nanjing Qinheng Microelectronics. *******************************************************************************/ #include "usb_desc.h" /* Device Descriptor */ const uint8_t MyDevDescr[] = { 0x12, // bLength 0x01, // bDescriptorType (Device) 0x10, 0x01, // bcdUSB 1.10 0x02, // bDeviceClass 0x00, // bDeviceSubClass 0x00, // bDeviceProtocol DEF_USBD_UEP0_SIZE, // bMaxPacketSize0 64 (uint8_t)DEF_USB_VID, (uint8_t)(DEF_USB_VID >> 8), // idVendor 0x1A86 (uint8_t)DEF_USB_PID, (uint8_t)(DEF_USB_PID >> 8), // idProduct 0x5537 DEF_IC_PRG_VER, 0x00, // bcdDevice 0.01 0x01, // iManufacturer (String Index) 0x02, // iProduct (String Index) 0x03, // iSerialNumber (String Index) 0x01, // bNumConfigurations 1 }; /* Configuration Descriptor */ const uint8_t MyCfgDescr[] = { /* Configure descriptor */ 0x09, 0x02, 0x43, 0x00, 0x02, 0x01, 0x00, 0x80, 0x32, /* Interface 0 (CDC) descriptor */ 0x09, 0x04, 0x00, 0x00, 0x01, 0x02, 0x02, 0x01, 0x00, /* Functional Descriptors */ 0x05, 0x24, 0x00, 0x10, 0x01, /* Length/management descriptor (data class interface 1) */ 0x05, 0x24, 0x01, 0x00, 0x01, 0x04, 0x24, 0x02, 0x02, 0x05, 0x24, 0x06, 0x00, 0x01, /* Interrupt upload endpoint descriptor */ 0x07, 0x05, 0x81, 0x03, (uint8_t)DEF_USBD_ENDP1_SIZE, (uint8_t)( DEF_USBD_ENDP1_SIZE >> 8 ), 0x01, /* Interface 1 (data interface) descriptor */ 0x09, 0x04, 0x01, 0x00, 0x02, 0x0A, 0x00, 0x00, 0x00, /* Endpoint descriptor */ 0x07, 0x05, 0x02, 0x02, (uint8_t)DEF_USBD_ENDP2_SIZE, (uint8_t)( DEF_USBD_ENDP2_SIZE >> 8 ), 0x00, /* Endpoint descriptor */ 0x07, 0x05, 0x83, 0x02, (uint8_t)DEF_USBD_ENDP3_SIZE, (uint8_t)( DEF_USBD_ENDP3_SIZE >> 8 ), 0x00, }; #define USB_DTYPE_STRING 3u /* Language Descriptor */ const uint8_t MyLangDescr[] = { 0x04, 0x03, 0x09, 0x04 }; template struct w_text { uint8_t len, typ; const char16_t str [N]; }__attribute__((packed)); #define WSTR1 (u"Kizarm Labs.") #define WSTR2 (u"USB <=> USART") #define WSTR3 (u"0001") static const w_text<(sizeof WSTR1 >> 1u)> str_1 = {sizeof (str_1) - 2u, USB_DTYPE_STRING, {WSTR1}}; static const w_text<(sizeof WSTR2 >> 1u)> str_2 = {sizeof (str_2) - 2u, USB_DTYPE_STRING, {WSTR2}}; static const w_text<(sizeof WSTR3 >> 1u)> str_3 = {sizeof (str_3) - 2u, USB_DTYPE_STRING, {WSTR3}}; const uint8_t * MyManuInfo = reinterpret_cast (&str_1); const uint8_t * MyProdInfo = reinterpret_cast (&str_2); const uint8_t * MySerNumInfo = reinterpret_cast (&str_3);