mirror of
https://github.com/hathach/tinyusb.git
synced 2025-02-22 15:40:06 +00:00
refractor & beautify string descriptors
This commit is contained in:
parent
376482558a
commit
abf1054745
@ -381,15 +381,31 @@ const app_descriptor_configuration_t app_tusb_desc_configuration =
|
||||
TUSB_CFG_ATTR_USBRAM ATTR_ALIGNED(4)
|
||||
const app_descriptor_string_t app_tusb_desc_strings =
|
||||
{
|
||||
.LangID = { .bLength = 0x04, .bDescriptorType = TUSB_DESC_TYPE_STRING },
|
||||
.strLangID= {0x0409}, // US English
|
||||
//------------- index 0 -------------//
|
||||
.language = {
|
||||
.bLength = 0x04,
|
||||
.bDescriptorType = TUSB_DESC_TYPE_STRING,
|
||||
.id = 0x0409, // US English
|
||||
},
|
||||
|
||||
.Manufacturer = { .bLength = USB_STRING_LEN(sizeof(TUSB_CFG_DEVICE_STRING_MANUFACTURER)-1), .bDescriptorType = TUSB_DESC_TYPE_STRING },
|
||||
.strManufacturer = {'t', 'i', 'n', 'y', 'U', 'S', 'B'},
|
||||
//------------- index 1 -------------//
|
||||
.manufacturer = {
|
||||
.bLength = USB_STRING_LEN(sizeof(TUSB_CFG_DEVICE_STRING_MANUFACTURER)-1),
|
||||
.bDescriptorType = TUSB_DESC_TYPE_STRING,
|
||||
.unicode_string = {'t', 'i', 'n', 'y', 'U', 'S', 'B'}
|
||||
},
|
||||
|
||||
.Product = { .bLength = USB_STRING_LEN(sizeof(TUSB_CFG_DEVICE_STRING_PRODUCT)-1), .bDescriptorType = TUSB_DESC_TYPE_STRING },
|
||||
.strProduct = {'D', 'e', 'v', 'i', 'c', 'e', ' ', 'K', 'e', 'y', 'b', 'o', 'a', 'r', 'd'},
|
||||
//------------- index 2 -------------//
|
||||
.product = {
|
||||
.bLength = USB_STRING_LEN(sizeof(TUSB_CFG_DEVICE_STRING_PRODUCT)-1),
|
||||
.bDescriptorType = TUSB_DESC_TYPE_STRING,
|
||||
.unicode_string = {'D', 'e', 'v', 'i', 'c', 'e', ' ', 'K', 'e', 'y', 'b', 'o', 'a', 'r', 'd'}
|
||||
},
|
||||
|
||||
.Serial = { .bLength = USB_STRING_LEN(sizeof(TUSB_CFG_DEVICE_STRING_SERIAL)-1), .bDescriptorType = TUSB_DESC_TYPE_STRING },
|
||||
.strSerial = {'1', '2', '3', '4'}
|
||||
//------------- index 3 -------------//
|
||||
.serials = {
|
||||
.bLength = USB_STRING_LEN(sizeof(TUSB_CFG_DEVICE_STRING_SERIAL)-1),
|
||||
.bDescriptorType = TUSB_DESC_TYPE_STRING,
|
||||
.unicode_string = {'1', '2', '3', '4'}
|
||||
}
|
||||
};
|
||||
|
@ -48,17 +48,43 @@
|
||||
|
||||
typedef ATTR_PACKED_STRUCT(struct)
|
||||
{
|
||||
tusb_descriptor_header_t LangID;
|
||||
uint16_t strLangID[1];
|
||||
uint8_t bLength ; ///< Size of this descriptor in bytes
|
||||
uint8_t bDescriptorType ; ///< Descriptor Type
|
||||
uint16_t unicode_string[];
|
||||
} tusb_descriptor_string_t;
|
||||
|
||||
tusb_descriptor_header_t Manufacturer;
|
||||
uint16_t strManufacturer[sizeof(TUSB_CFG_DEVICE_STRING_MANUFACTURER)-1]; // exclude null-character
|
||||
typedef ATTR_PACKED_STRUCT(struct)
|
||||
{
|
||||
//------------- index 0 -------------//
|
||||
struct {
|
||||
uint8_t const bLength;
|
||||
uint8_t const bDescriptorType;
|
||||
uint16_t id;
|
||||
}language;
|
||||
|
||||
tusb_descriptor_header_t Product;
|
||||
uint16_t strProduct[sizeof(TUSB_CFG_DEVICE_STRING_PRODUCT)-1]; // exclude null-character
|
||||
//------------- index 1 -------------//
|
||||
struct {
|
||||
uint8_t const bLength;
|
||||
uint8_t const bDescriptorType;
|
||||
uint16_t unicode_string[sizeof(TUSB_CFG_DEVICE_STRING_MANUFACTURER)-1]; // exclude null-character
|
||||
} manufacturer;
|
||||
|
||||
//------------- index 2 -------------//
|
||||
struct {
|
||||
uint8_t const bLength;
|
||||
uint8_t const bDescriptorType;
|
||||
uint16_t unicode_string[sizeof(TUSB_CFG_DEVICE_STRING_PRODUCT)-1]; // exclude null-character
|
||||
} product;
|
||||
|
||||
//------------- index 3 -------------//
|
||||
struct {
|
||||
uint8_t const bLength;
|
||||
uint8_t const bDescriptorType;
|
||||
uint16_t unicode_string[sizeof(TUSB_CFG_DEVICE_STRING_SERIAL)-1]; // exclude null-character
|
||||
} serials;
|
||||
|
||||
//------------- more string index -------------//
|
||||
|
||||
tusb_descriptor_header_t Serial;
|
||||
uint16_t strSerial[sizeof(TUSB_CFG_DEVICE_STRING_SERIAL)-1];
|
||||
} app_descriptor_string_t;
|
||||
|
||||
// USB Interface Assosication Descriptor
|
||||
|
Loading…
x
Reference in New Issue
Block a user