#include <usb/usb_descriptor_types.h>
#include <utils/types.h>
static usb_dev_descr_t usb_device_descriptor_ums =
{
.bLength = 18,
.bDescriptorType = USB_DESCRIPTOR_DEVICE,
.bcdUSB = 0x210,
.bDeviceClass = 0x00,
.bDeviceSubClass = 0x00,
.bDeviceProtocol = 0x00,
.bMaxPacketSize = 0x40,
.idVendor = 0x11EC,
.idProduct = 0xA7E0,
.bcdDevice = 0x0101,
.iManufacturer = 1,
.iProduct = 2,
.iSerialNumber = 3,
.bNumConfigs = 1
};
static usb_dev_qual_descr_t usb_device_qualifier_descriptor =
{
.bLength = 10,
.bDescriptorType = USB_DESCRIPTOR_DEVICE_QUALIFIER,
.bcdUSB = 0x210,
.bDeviceClass = 0x00,
.bDeviceSubClass = 0x00,
.bDeviceProtocol = 0x00,
.bMaxPacketSize = 0x40,
.bNumOtherConfigs = 0x01,
.bReserved = 0x00
};
static usb_cfg_simple_descr_t usb_configuration_descriptor_ums =
{
.config.bLength = 9,
.config.bDescriptorType = USB_DESCRIPTOR_CONFIGURATION,
.config.wTotalLength = 0x20,
.config.bNumInterfaces = 0x01,
.config.bConfigurationValue = 0x01,
.config.iConfiguration = 0x00,
.config.bmAttributes = USB_ATTR_SELF_POWERED | USB_ATTR_BUS_POWERED_RSVD,
.config.bMaxPower = 32 / 2,
.interface.bLength = 9,
.interface.bDescriptorType = USB_DESCRIPTOR_INTERFACE,
.interface.bInterfaceNumber = 0,
.interface.bAlternateSetting = 0,
.interface.bNumEndpoints = 2,
.interface.bInterfaceClass = 0x08,
.interface.bInterfaceSubClass = 0x06,
.interface.bInterfaceProtocol = 0x50,
.interface.iInterface = 0x00,
.endpoint[0].bLength = 7,
.endpoint[0].bDescriptorType = USB_DESCRIPTOR_ENDPOINT,
.endpoint[0].bEndpointAddress = 0x81,
.endpoint[0].bmAttributes = USB_EP_TYPE_BULK,
.endpoint[0].wMaxPacketSize = 0x200,
.endpoint[0].bInterval = 0x00,
.endpoint[1].bLength = 7,
.endpoint[1].bDescriptorType = USB_DESCRIPTOR_ENDPOINT,
.endpoint[1].bEndpointAddress = 0x01,
.endpoint[1].bmAttributes = USB_EP_TYPE_BULK,
.endpoint[1].wMaxPacketSize = 0x200,
.endpoint[1].bInterval = 0x00
};
static usb_cfg_simple_descr_t usb_other_speed_config_descriptor_ums =
{
.config.bLength = 9,
.config.bDescriptorType = USB_DESCRIPTOR_OTHER_SPEED_CONFIGURATION,
.config.wTotalLength = 0x20,
.config.bNumInterfaces = 0x01,
.config.bConfigurationValue = 0x01,
.config.iConfiguration = 0x00,
.config.bmAttributes = USB_ATTR_SELF_POWERED | USB_ATTR_BUS_POWERED_RSVD,
.config.bMaxPower = 32 / 2,
.interface.bLength = 9,
.interface.bDescriptorType = USB_DESCRIPTOR_INTERFACE,
.interface.bInterfaceNumber = 0x00,
.interface.bAlternateSetting = 0x00,
.interface.bNumEndpoints = 2,
.interface.bInterfaceClass = 0x08,
.interface.bInterfaceSubClass = 0x06,
.interface.bInterfaceProtocol = 0x50,
.interface.iInterface = 0x00,
.endpoint[0].bLength = 7,
.endpoint[0].bDescriptorType = USB_DESCRIPTOR_ENDPOINT,
.endpoint[0].bEndpointAddress = 0x81,
.endpoint[0].bmAttributes = USB_EP_TYPE_BULK,
.endpoint[0].wMaxPacketSize = 0x40,
.endpoint[0].bInterval = 0,
.endpoint[1].bLength = 7,
.endpoint[1].bDescriptorType = USB_DESCRIPTOR_ENDPOINT,
.endpoint[1].bEndpointAddress = 0x01,
.endpoint[1].bmAttributes = USB_EP_TYPE_BULK,
.endpoint[1].wMaxPacketSize = 0x40,
.endpoint[1].bInterval = 0
};
static usb_dev_bot_t usb_device_binary_object_descriptor =
{
.bLength = 5,
.bDescriptorType = USB_DESCRIPTOR_DEVICE_BINARY_OBJECT,
.wTotalLength = 22,
.bNumDeviceCaps = 2,
.bLengthCap0 = 7,
.bDescriptorTypeCap0 = USB_DESCRIPTOR_DEVICE_BINARY_OBJECT_CAP,
.bDevCapabilityTypeCap0 = 2,
.bmAttributesCap0 = 0,
.bLengthCap1 = 10,
.bDescriptorTypeCap1 = USB_DESCRIPTOR_DEVICE_BINARY_OBJECT_CAP,
.bDevCapabilityTypeCap1 = 3,
.bmAttributesCap1 = 0,
.wSpeedsSupported = 0x6,
.bFunctionalitySupport = 1,
.bU1DevExitLat = 0,
.wU2DevExitLat = 0
};
static u8 usb_lang_id_string_descriptor[4] =
{
4, 3,
0x09, 0x04
};
static u8 usb_serial_string_descriptor[26] =
{
26, 0x03,
'C', 0x00, '7', 0x00, 'C', 0x00, '0', 0x00,
'9', 0x00, '2', 0x00, '4', 0x00, '2', 0x00, 'F', 0x00, '7', 0x00, '0', 0x00, '3', 0x00
};
static u8 usb_vendor_string_descriptor_ums[32] =
{
26, 0x03,
'N', 0, 'y', 0, 'x', 0, ' ', 0, 'U', 0, 'S', 0, 'B', 0, ' ', 0,
'D', 0, 'i', 0, 's', 0, 'k', 0
};
static u8 usb_product_string_descriptor_ums[22] =
{
8, 0x03,
'U', 0, 'M', 0, 'S', 0
};
static usb_ms_os_descr_t usb_ms_os_descriptor =
{
.bLength = 0x28,
.bDescriptorType = 0x03,
.wSignature[0] = 'M',
.wSignature[1] = 'S',
.wSignature[2] = 'F',
.wSignature[3] = 'T',
.wSignature[4] = '1',
.wSignature[5] = '0',
.wSignature[6] = '0',
.bVendorCode = 0x99,
};
static usb_ms_cid_descr_t usb_ms_cid_descriptor =
{
.dLength = 0x28,
.wVersion = 0x100,
.wCompatibilityId = USB_DESCRIPTOR_MS_COMPAT_ID,
.bSections = 1,
.bInterfaceNumber = 0,
.bReserved1 = 1,
.bCompatibleId[0] = 'N',
.bCompatibleId[1] = 'Y',
.bCompatibleId[2] = 'X',
.bCompatibleId[3] = 'U',
.bCompatibleId[4] = 'S',
.bCompatibleId[5] = 'B',
};
static usb_ms_ext_prop_descr_t usb_ms_ext_prop_descriptor_ums =
{
.dLength = 0x48,
.wVersion = 0x100,
.wExtendedProperty = USB_DESCRIPTOR_MS_EXTENDED_PROPERTIES,
.wSections = 1,
.dPropertySize = 0x3E,
.dPropertyType = 4,
.wPropertyNameLength = 0x2C,
.wPropertyName[0] = 'M',
.wPropertyName[1] = 'a',
.wPropertyName[2] = 'x',
.wPropertyName[3] = 'i',
.wPropertyName[4] = 'm',
.wPropertyName[5] = 'u',
.wPropertyName[6] = 'm',
.wPropertyName[7] = 'T',
.wPropertyName[8] = 'r',
.wPropertyName[9] = 'a',
.wPropertyName[10] = 'n',
.wPropertyName[11] = 's',
.wPropertyName[12] = 'f',
.wPropertyName[13] = 'e',
.wPropertyName[14] = 'r',
.wPropertyName[15] = 'L',
.wPropertyName[16] = 'e',
.wPropertyName[17] = 'n',
.wPropertyName[18] = 'g',
.wPropertyName[19] = 't',
.wPropertyName[20] = 'h',
.wPropertyName[21] = 0,
.dPropertyDataLength = 0x4,
.wPropertyData[0] = 0x00,
.wPropertyData[1] = 0x10,
};
static usb_ms_ext_prop_descr_t usb_ms_ext_prop_descriptor_hid =
{
.dLength = 7,
.wVersion = 0x100,
.wExtendedProperty = USB_DESCRIPTOR_MS_EXTENDED_PROPERTIES,
.wSections = 0,
};
static usb_dev_descr_t usb_device_descriptor_hid_jc =
{
.bLength = 18,
.bDescriptorType = USB_DESCRIPTOR_DEVICE,
.bcdUSB = 0x210,
.bDeviceClass = 0x00,
.bDeviceSubClass = 0x00,
.bDeviceProtocol = 0x00,
.bMaxPacketSize = 0x40,
.idVendor = 0x11EC,
.idProduct = 0xA7E1,
.bcdDevice = 0x0101,
.iManufacturer = 1,
.iProduct = 2,
.iSerialNumber = 3,
.bNumConfigs = 1
};
static usb_dev_descr_t usb_device_descriptor_hid_touch =
{
.bLength = 18,
.bDescriptorType = USB_DESCRIPTOR_DEVICE,
.bcdUSB = 0x210,
.bDeviceClass = 0x00,
.bDeviceSubClass = 0x00,
.bDeviceProtocol = 0x00,
.bMaxPacketSize = 0x40,
.idVendor = 0x11EC,
.idProduct = 0xA7E2,
.bcdDevice = 0x0101,
.iManufacturer = 1,
.iProduct = 2,
.iSerialNumber = 3,
.bNumConfigs = 1
};
u8 hid_report_descriptor_jc[] =
{
0x05, 0x01,
0x09, 0x04,
0xa1, 0x01,
0xa1, 0x02,
0x75, 0x08,
0x95, 0x04,
0x15, 0x00,
0x26, 0xff, 0x00,
0x35, 0x00,
0x46, 0xff, 0x00,
0x09, 0x30,
0x09, 0x31,
0x09, 0x32,
0x09, 0x35,
0x81, 0x02,
0x75, 0x04,
0x95, 0x01,
0x25, 0x07,
0x46, 0x3b, 0x01,
0x65, 0x14,
0x09, 0x39,
0x81, 0x42,
0x65, 0x00,
0x75, 0x01,
0x95, 0x0c,
0x25, 0x01,
0x45, 0x01,
0x05, 0x09,
0x19, 0x01,
0x29, 0x0c,
0x81, 0x02,
0xc0,
0xc0
};
u32 hid_report_descriptor_jc_size = sizeof(hid_report_descriptor_jc);
u8 hid_report_descriptor_touch[] =
{
0x05, 0x0d,
0x09, 0x05,
0xa1, 0x01,
0x85, 0x05,
0x09, 0x22,
0xa1, 0x02,
0x15, 0x00,
0x25, 0x01,
0x09, 0x42,
0x95, 0x01,
0x75, 0x01,
0x81, 0x02,
0x15, 0x00,
0x25, 0x01,
0x75, 0x01,
0x95, 0x07,
0x09, 0x54,
0x81, 0x02,
0x95, 0x01,
0x75, 0x08,
0x15, 0x00,
0x25, 0x0A,
0x09, 0x51,
0x81, 0x02,
0x05, 0x01,
0x15, 0x00,
0x26, 0xff, 0x04,
0x75, 0x10,
0x55, 0x0e,
0x65, 0x13,
0x09, 0x30,
0x35, 0x00,
0x46, 0xFF, 0x04,
0x95, 0x01,
0x81, 0x02,
0x26, 0xCF, 0x02,
0x46, 0xCF, 0x02,
0x09, 0x31,
0x81, 0x02,
0x05, 0x0d,
0xc0,
0xc0,
};
u32 hid_report_descriptor_touch_size = sizeof(hid_report_descriptor_touch);
static usb_cfg_hid_descr_t usb_configuration_descriptor_hid_jc =
{
.config.bLength = 9,
.config.bDescriptorType = USB_DESCRIPTOR_CONFIGURATION,
.config.wTotalLength = sizeof(usb_cfg_hid_descr_t),
.config.bNumInterfaces = 0x01,
.config.bConfigurationValue = 0x01,
.config.iConfiguration = 0x00,
.config.bmAttributes = USB_ATTR_SELF_POWERED | USB_ATTR_BUS_POWERED_RSVD,
.config.bMaxPower = 32 / 2,
.interface.bLength = 9,
.interface.bDescriptorType = USB_DESCRIPTOR_INTERFACE,
.interface.bInterfaceNumber = 0,
.interface.bAlternateSetting = 0,
.interface.bNumEndpoints = 2,
.interface.bInterfaceClass = 0x03,
.interface.bInterfaceSubClass = 0x00,
.interface.bInterfaceProtocol = 0x00,
.interface.iInterface = 0x00,
.hid.bLength = 9,
.hid.bDescriptorType = USB_DESCRIPTOR_HID,
.hid.bcdHID = 0x110,
.hid.bCountryCode = 0,
.hid.bNumDescriptors = 1,
.hid.bClassDescriptorType = USB_DESCRIPTOR_HID_REPORT,
.hid.bDescriptorLength = sizeof(hid_report_descriptor_jc),
.endpoint[0].bLength = 7,
.endpoint[0].bDescriptorType = USB_DESCRIPTOR_ENDPOINT,
.endpoint[0].bEndpointAddress = 0x81,
.endpoint[0].bmAttributes = USB_EP_TYPE_INTR,
.endpoint[0].wMaxPacketSize = 0x200,
.endpoint[0].bInterval = 4,
.endpoint[1].bLength = 7,
.endpoint[1].bDescriptorType = USB_DESCRIPTOR_ENDPOINT,
.endpoint[1].bEndpointAddress = 0x01,
.endpoint[1].bmAttributes = USB_EP_TYPE_INTR,
.endpoint[1].wMaxPacketSize = 0x200,
.endpoint[1].bInterval = 4
};
static u8 usb_vendor_string_descriptor_hid[22] =
{
16, 0x03,
'N', 0, 'y', 0, 'x', 0, ' ', 0,
'U', 0, 'S', 0, 'B', 0
};
static u8 usb_product_string_descriptor_hid_jc[24] =
{
24, 0x03,
'N', 0, 'y', 0, 'x', 0, ' ', 0,
'J', 0, 'o', 0, 'y', 0, '-', 0, 'C', 0, 'o', 0, 'n', 0
};
static u8 usb_product_string_descriptor_hid_touch[26] =
{
26, 0x03,
'N', 0, 'y', 0, 'x', 0, ' ', 0,
'T', 0, 'o', 0, 'u', 0, 'c', 0, 'h', 0, 'p', 0, 'a', 0, 'd', 0
};
static usb_cfg_hid_descr_t usb_configuration_descriptor_hid_touch =
{
.config.bLength = 9,
.config.bDescriptorType = USB_DESCRIPTOR_CONFIGURATION,
.config.wTotalLength = sizeof(usb_cfg_hid_descr_t),
.config.bNumInterfaces = 0x01,
.config.bConfigurationValue = 0x01,
.config.iConfiguration = 0x00,
.config.bmAttributes = USB_ATTR_SELF_POWERED | USB_ATTR_BUS_POWERED_RSVD,
.config.bMaxPower = 32 / 2,
.interface.bLength = 9,
.interface.bDescriptorType = USB_DESCRIPTOR_INTERFACE,
.interface.bInterfaceNumber = 0,
.interface.bAlternateSetting = 0,
.interface.bNumEndpoints = 2,
.interface.bInterfaceClass = 0x03,
.interface.bInterfaceSubClass = 0x00,
.interface.bInterfaceProtocol = 0x00,
.interface.iInterface = 0x00,
.hid.bLength = 9,
.hid.bDescriptorType = USB_DESCRIPTOR_HID,
.hid.bcdHID = 0x111,
.hid.bCountryCode = 0,
.hid.bNumDescriptors = 1,
.hid.bClassDescriptorType = USB_DESCRIPTOR_HID_REPORT,
.hid.bDescriptorLength = sizeof(hid_report_descriptor_touch),
.endpoint[0].bLength = 7,
.endpoint[0].bDescriptorType = USB_DESCRIPTOR_ENDPOINT,
.endpoint[0].bEndpointAddress = 0x81,
.endpoint[0].bmAttributes = USB_EP_TYPE_INTR,
.endpoint[0].wMaxPacketSize = 0x200,
.endpoint[0].bInterval = 3,
.endpoint[1].bLength = 7,
.endpoint[1].bDescriptorType = USB_DESCRIPTOR_ENDPOINT,
.endpoint[1].bEndpointAddress = 0x01,
.endpoint[1].bmAttributes = USB_EP_TYPE_INTR,
.endpoint[1].wMaxPacketSize = 0x200,
.endpoint[1].bInterval = 3
};
usb_desc_t usb_gadget_ums_descriptors =
{
.dev = &usb_device_descriptor_ums,
.dev_qual = &usb_device_qualifier_descriptor,
.cfg = &usb_configuration_descriptor_ums,
.cfg_other = &usb_other_speed_config_descriptor_ums,
.dev_bot = &usb_device_binary_object_descriptor,
.vendor = usb_vendor_string_descriptor_ums,
.product = usb_product_string_descriptor_ums,
.serial = usb_serial_string_descriptor,
.lang_id = usb_lang_id_string_descriptor,
.ms_os = &usb_ms_os_descriptor,
.ms_cid = &usb_ms_cid_descriptor,
.mx_ext = &usb_ms_ext_prop_descriptor_ums
};
usb_desc_t usb_gadget_hid_jc_descriptors =
{
.dev = &usb_device_descriptor_hid_jc,
.dev_qual = &usb_device_qualifier_descriptor,
.cfg = (usb_cfg_simple_descr_t *)&usb_configuration_descriptor_hid_jc,
.cfg_other = NULL,
.dev_bot = &usb_device_binary_object_descriptor,
.vendor = usb_vendor_string_descriptor_hid,
.product = usb_product_string_descriptor_hid_jc,
.serial = usb_serial_string_descriptor,
.lang_id = usb_lang_id_string_descriptor,
.ms_os = &usb_ms_os_descriptor,
.ms_cid = &usb_ms_cid_descriptor,
.mx_ext = &usb_ms_ext_prop_descriptor_hid
};
usb_desc_t usb_gadget_hid_touch_descriptors =
{
.dev = &usb_device_descriptor_hid_touch,
.dev_qual = &usb_device_qualifier_descriptor,
.cfg = (usb_cfg_simple_descr_t *)&usb_configuration_descriptor_hid_touch,
.cfg_other = NULL,
.dev_bot = &usb_device_binary_object_descriptor,
.vendor = usb_vendor_string_descriptor_hid,
.product = usb_product_string_descriptor_hid_touch,
.serial = usb_serial_string_descriptor,
.lang_id = usb_lang_id_string_descriptor,
.ms_os = &usb_ms_os_descriptor,
.ms_cid = &usb_ms_cid_descriptor,
.mx_ext = &usb_ms_ext_prop_descriptor_hid
};