summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2013-05-31 16:31:13 +0700
committerhathach <[email protected]>2013-05-31 16:37:40 +0700
commitabf105474529a9831851ea78bcc06d1e5ad4e173 (patch)
tree2f13ef6193eeb10b39b4f247a2e2ebe8307e4ddc
parent376482558a943434b13c155962e78923ba46cbbc (diff)
refractor & beautify string descriptors
-rw-r--r--demos/device/keyboard/tusb_descriptors.c32
-rw-r--r--demos/device/keyboard/tusb_descriptors.h42
2 files changed, 58 insertions, 16 deletions
diff --git a/demos/device/keyboard/tusb_descriptors.c b/demos/device/keyboard/tusb_descriptors.c
index 1d01c0eb1..527a56730 100644
--- a/demos/device/keyboard/tusb_descriptors.c
+++ b/demos/device/keyboard/tusb_descriptors.c
@@ -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'}
+ }
};
diff --git a/demos/device/keyboard/tusb_descriptors.h b/demos/device/keyboard/tusb_descriptors.h
index 2192fe119..8a9edad84 100644
--- a/demos/device/keyboard/tusb_descriptors.h
+++ b/demos/device/keyboard/tusb_descriptors.h
@@ -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;
+
+ //------------- 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;
- tusb_descriptor_header_t Product;
- uint16_t strProduct[sizeof(TUSB_CFG_DEVICE_STRING_PRODUCT)-1]; // exclude null-character
+ //------------- 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