mirror of
https://github.com/hathach/tinyusb.git
synced 2025-02-23 00:40:12 +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)
|
TUSB_CFG_ATTR_USBRAM ATTR_ALIGNED(4)
|
||||||
const app_descriptor_string_t app_tusb_desc_strings =
|
const app_descriptor_string_t app_tusb_desc_strings =
|
||||||
{
|
{
|
||||||
.LangID = { .bLength = 0x04, .bDescriptorType = TUSB_DESC_TYPE_STRING },
|
//------------- index 0 -------------//
|
||||||
.strLangID= {0x0409}, // US English
|
.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 },
|
//------------- index 1 -------------//
|
||||||
.strManufacturer = {'t', 'i', 'n', 'y', 'U', 'S', 'B'},
|
.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 },
|
//------------- index 2 -------------//
|
||||||
.strProduct = {'D', 'e', 'v', 'i', 'c', 'e', ' ', 'K', 'e', 'y', 'b', 'o', 'a', 'r', 'd'},
|
.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 },
|
//------------- index 3 -------------//
|
||||||
.strSerial = {'1', '2', '3', '4'}
|
.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)
|
typedef ATTR_PACKED_STRUCT(struct)
|
||||||
{
|
{
|
||||||
tusb_descriptor_header_t LangID;
|
uint8_t bLength ; ///< Size of this descriptor in bytes
|
||||||
uint16_t strLangID[1];
|
uint8_t bDescriptorType ; ///< Descriptor Type
|
||||||
|
uint16_t unicode_string[];
|
||||||
|
} tusb_descriptor_string_t;
|
||||||
|
|
||||||
tusb_descriptor_header_t Manufacturer;
|
typedef ATTR_PACKED_STRUCT(struct)
|
||||||
uint16_t strManufacturer[sizeof(TUSB_CFG_DEVICE_STRING_MANUFACTURER)-1]; // exclude null-character
|
{
|
||||||
|
//------------- index 0 -------------//
|
||||||
|
struct {
|
||||||
|
uint8_t const bLength;
|
||||||
|
uint8_t const bDescriptorType;
|
||||||
|
uint16_t id;
|
||||||
|
}language;
|
||||||
|
|
||||||
tusb_descriptor_header_t Product;
|
//------------- index 1 -------------//
|
||||||
uint16_t strProduct[sizeof(TUSB_CFG_DEVICE_STRING_PRODUCT)-1]; // exclude null-character
|
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;
|
} app_descriptor_string_t;
|
||||||
|
|
||||||
// USB Interface Assosication Descriptor
|
// USB Interface Assosication Descriptor
|
||||||
|
Loading…
x
Reference in New Issue
Block a user