refractor string descriptors, allow one-stop configure descriptor for
- manufacturer, product etc ... (only english now)
This commit is contained in:
@@ -81,6 +81,13 @@
|
||||
//--------------------------------------------------------------------+
|
||||
// DEVICE CONFIGURATION
|
||||
//--------------------------------------------------------------------+
|
||||
#define TUSB_CFG_DEVICE_STRING_MANUFACTURER "tinyusb.org"
|
||||
#define TUSB_CFG_DEVICE_STRING_PRODUCT "Device Example"
|
||||
#define TUSB_CFG_DEVICE_STRING_SERIAL "1234"
|
||||
#define TUSB_CFG_DEVICE_VENDORID 0x1FC9 // NXP
|
||||
//#define TUSB_CFG_DEVICE_PRODUCTID 0x4567
|
||||
|
||||
|
||||
#define TUSB_CFG_DEVICE_USE_ROM_DRIVER 1
|
||||
|
||||
//------------- CLASS -------------//
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
#if TUSB_CFG_DEVICE_HID_KEYBOARD
|
||||
TUSB_CFG_ATTR_USBRAM ATTR_ALIGNED(4)
|
||||
const uint8_t app_tusb_keyboard_desc_report[] = {
|
||||
uint8_t app_tusb_keyboard_desc_report[] = {
|
||||
HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ),
|
||||
HID_USAGE ( HID_USAGE_DESKTOP_KEYBOARD ),
|
||||
HID_COLLECTION ( HID_COLLECTION_APPLICATION ),
|
||||
@@ -83,7 +83,7 @@ const uint8_t app_tusb_keyboard_desc_report[] = {
|
||||
|
||||
#if TUSB_CFG_DEVICE_HID_MOUSE
|
||||
TUSB_CFG_ATTR_USBRAM ATTR_ALIGNED(4)
|
||||
const uint8_t mouse_report_descriptor[] = {
|
||||
uint8_t mouse_report_descriptor[] = {
|
||||
HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ),
|
||||
HID_USAGE ( HID_USAGE_DESKTOP_MOUSE ),
|
||||
HID_COLLECTION ( HID_COLLECTION_APPLICATION ),
|
||||
@@ -120,7 +120,7 @@ const uint8_t mouse_report_descriptor[] = {
|
||||
#endif
|
||||
|
||||
TUSB_CFG_ATTR_USBRAM ATTR_ALIGNED(4)
|
||||
tusb_descriptor_device_t const app_tusb_desc_device =
|
||||
tusb_descriptor_device_t app_tusb_desc_device =
|
||||
{
|
||||
.bLength = sizeof(tusb_descriptor_device_t),
|
||||
.bDescriptorType = TUSB_DESC_TYPE_DEVICE,
|
||||
@@ -144,7 +144,7 @@ tusb_descriptor_device_t const app_tusb_desc_device =
|
||||
|
||||
|
||||
TUSB_CFG_ATTR_USBRAM ATTR_ALIGNED(4)
|
||||
const app_descriptor_configuration_t app_tusb_desc_configuration =
|
||||
app_descriptor_configuration_t app_tusb_desc_configuration =
|
||||
{
|
||||
.configuration =
|
||||
{
|
||||
@@ -379,7 +379,7 @@ 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 =
|
||||
app_descriptor_string_t app_tusb_desc_strings =
|
||||
{
|
||||
//------------- index 0 -------------//
|
||||
.language = {
|
||||
@@ -392,20 +392,17 @@ const app_descriptor_string_t app_tusb_desc_strings =
|
||||
.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'}
|
||||
},
|
||||
|
||||
//------------- 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'}
|
||||
},
|
||||
|
||||
//------------- index 3 -------------//
|
||||
.serials = {
|
||||
.serial = {
|
||||
.bLength = USB_STRING_LEN(sizeof(TUSB_CFG_DEVICE_STRING_SERIAL)-1),
|
||||
.bDescriptorType = TUSB_DESC_TYPE_STRING,
|
||||
.unicode_string = {'1', '2', '3', '4'}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -35,11 +35,7 @@
|
||||
|
||||
#include "tusb.h"
|
||||
|
||||
#define TUSB_CFG_DEVICE_STRING_MANUFACTURER "tinyUSB"
|
||||
#define TUSB_CFG_DEVICE_STRING_PRODUCT "Device Keyboard"
|
||||
#define TUSB_CFG_DEVICE_STRING_SERIAL "1234"
|
||||
#define TUSB_CFG_DEVICE_VENDORID 0x1FC9 // NXP
|
||||
//#define TUSB_CFG_DEVICE_PRODUCTID
|
||||
|
||||
|
||||
/* USB Serial uses the MCUs unique 128-bit chip ID via an IAP call = 32 hex chars */
|
||||
#define USB_STRING_SERIAL_LEN 32
|
||||
@@ -81,7 +77,7 @@ typedef ATTR_PACKED_STRUCT(struct)
|
||||
uint8_t const bLength;
|
||||
uint8_t const bDescriptorType;
|
||||
uint16_t unicode_string[sizeof(TUSB_CFG_DEVICE_STRING_SERIAL)-1]; // exclude null-character
|
||||
} serials;
|
||||
} serial;
|
||||
|
||||
//------------- more string index -------------//
|
||||
|
||||
@@ -180,11 +176,11 @@ typedef ATTR_PACKED_STRUCT(struct)
|
||||
uint8_t null_termination; // NXP rom driver requires this to work
|
||||
} app_descriptor_configuration_t;
|
||||
|
||||
extern const tusb_descriptor_device_t app_tusb_desc_device;
|
||||
extern const app_descriptor_configuration_t app_tusb_desc_configuration;
|
||||
extern const app_descriptor_string_t app_tusb_desc_strings;
|
||||
extern tusb_descriptor_device_t app_tusb_desc_device;
|
||||
extern app_descriptor_configuration_t app_tusb_desc_configuration;
|
||||
extern app_descriptor_string_t app_tusb_desc_strings;
|
||||
|
||||
extern const uint8_t app_tusb_keyboard_desc_report[];
|
||||
extern uint8_t app_tusb_keyboard_desc_report[];
|
||||
|
||||
//extern const uint8_t HID_MouseReportDescriptor[];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user