summaryrefslogtreecommitdiff
path: root/examples/device/cdc_msc_hid/src/usb_descriptors.c
diff options
context:
space:
mode:
Diffstat (limited to 'examples/device/cdc_msc_hid/src/usb_descriptors.c')
-rw-r--r--examples/device/cdc_msc_hid/src/usb_descriptors.c45
1 files changed, 25 insertions, 20 deletions
diff --git a/examples/device/cdc_msc_hid/src/usb_descriptors.c b/examples/device/cdc_msc_hid/src/usb_descriptors.c
index 1692151a0..ee79f4ece 100644
--- a/examples/device/cdc_msc_hid/src/usb_descriptors.c
+++ b/examples/device/cdc_msc_hid/src/usb_descriptors.c
@@ -24,6 +24,7 @@
*/
#include "tusb.h"
+#include "usb_descriptors.h"
/* A combination of interfaces must have a unique product id, since PC will save device driver after the first plug.
* Same VID/PID with different interface e.g MSC (first), then CDC (later) will possibly cause system error on PC.
@@ -32,9 +33,12 @@
* [MSB] HID | MSC | CDC [LSB]
*/
#define _PID_MAP(itf, n) ( (CFG_TUD_##itf) << (n) )
-#define USB_PID (0x4000 | _PID_MAP(CDC, 0) | _PID_MAP(MSC, 1) | _PID_MAP(HID, 2) | _PID_MAP(MIDI, 3) )
+#define USB_PID (0x4000 | _PID_MAP(CDC, 0) | _PID_MAP(MSC, 1) | _PID_MAP(HID, 2) | \
+ _PID_MAP(MIDI, 3) | _PID_MAP(VENDOR, 4) )
-//------------- Device Descriptors -------------//
+//--------------------------------------------------------------------+
+// Device Descriptors
+//--------------------------------------------------------------------+
tusb_desc_device_t const desc_device =
{
.bLength = sizeof(tusb_desc_device_t),
@@ -66,13 +70,17 @@ tusb_desc_device_t const desc_device =
.bNumConfigurations = 0x01
};
-//------------- HID Report Descriptor -------------//
-#if CFG_TUD_HID
-enum
+// Invoked when received GET DEVICE DESCRIPTOR
+// Application return pointer to descriptor
+uint8_t const * tud_descriptor_device_cb(void)
{
- REPORT_ID_KEYBOARD = 1,
- REPORT_ID_MOUSE
-};
+ return (uint8_t const *) &desc_device;
+}
+
+//--------------------------------------------------------------------+
+// HID Report Descriptor
+//--------------------------------------------------------------------+
+#if CFG_TUD_HID
uint8_t const desc_hid_report[] =
{
@@ -90,7 +98,10 @@ uint8_t const * tud_hid_descriptor_report_cb(void)
#endif
-//------------- Configuration Descriptor -------------//
+//--------------------------------------------------------------------+
+// Configuration Descriptor
+//--------------------------------------------------------------------+
+
enum
{
#if CFG_TUD_CDC
@@ -109,10 +120,7 @@ enum
ITF_NUM_TOTAL
};
-enum
-{
- CONFIG_TOTAL_LEN = TUD_CONFIG_DESC_LEN + CFG_TUD_CDC*TUD_CDC_DESC_LEN + CFG_TUD_MSC*TUD_MSC_DESC_LEN + CFG_TUD_HID*TUD_HID_DESC_LEN
-};
+#define CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + CFG_TUD_CDC*TUD_CDC_DESC_LEN + CFG_TUD_MSC*TUD_MSC_DESC_LEN + CFG_TUD_HID*TUD_HID_DESC_LEN)
#if CFG_TUSB_MCU == OPT_MCU_LPC175X_6X || CFG_TUSB_MCU == OPT_MCU_LPC177X_8X || CFG_TUSB_MCU == OPT_MCU_LPC40XX
// LPC 17xx and 40xx endpoint type (bulk/interrupt/iso) are fixed by its number
@@ -145,12 +153,6 @@ uint8_t const desc_configuration[] =
#endif
};
-// Invoked when received GET DEVICE DESCRIPTOR
-// Application return pointer to descriptor
-uint8_t const * tud_descriptor_device_cb(void)
-{
- return (uint8_t const *) &desc_device;
-}
// Invoked when received GET CONFIGURATION DESCRIPTOR
// Application return pointer to descriptor
@@ -160,7 +162,10 @@ uint8_t const * tud_descriptor_configuration_cb(uint8_t index)
(void) index; // for multiple configurations
return desc_configuration;
}
-//------------- String Descriptors -------------//
+
+//--------------------------------------------------------------------+
+// String Descriptors
+//--------------------------------------------------------------------+
// array of pointer to string descriptors
char const* string_desc_arr [] =