summaryrefslogtreecommitdiff
path: root/examples/device/hid_generic_inout/src
diff options
context:
space:
mode:
authorhathach <[email protected]>2019-07-12 16:28:38 +0700
committerhathach <[email protected]>2019-07-12 16:28:38 +0700
commitfdf39dd4aee82dc63d94a5a4e9423ecc15a268a1 (patch)
tree4854288f736527bf12a876f08be5ba368b4904a8 /examples/device/hid_generic_inout/src
parent164b26ee6bb0a24924e9736178808b676288845e (diff)
clean up usb descriptors in example
Diffstat (limited to 'examples/device/hid_generic_inout/src')
-rw-r--r--examples/device/hid_generic_inout/src/usb_descriptors.c49
1 files changed, 29 insertions, 20 deletions
diff --git a/examples/device/hid_generic_inout/src/usb_descriptors.c b/examples/device/hid_generic_inout/src/usb_descriptors.c
index cb7c92a57..516dab646 100644
--- a/examples/device/hid_generic_inout/src/usb_descriptors.c
+++ b/examples/device/hid_generic_inout/src/usb_descriptors.c
@@ -34,7 +34,9 @@
#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) )
-//------------- Device Descriptors -------------//
+//--------------------------------------------------------------------+
+// Device Descriptors
+//--------------------------------------------------------------------+
tusb_desc_device_t const desc_device =
{
.bLength = sizeof(tusb_desc_device_t),
@@ -56,13 +58,34 @@ tusb_desc_device_t const desc_device =
.bNumConfigurations = 0x01
};
-//------------- HID Report Descriptor -------------//
+// 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;
+}
+
+//--------------------------------------------------------------------+
+// HID Report Descriptor
+//--------------------------------------------------------------------+
+
uint8_t const desc_hid_report[] =
{
TUD_HID_REPORT_DESC_GENERIC_INOUT(CFG_TUD_HID_BUFSIZE)
};
-//------------- Configuration Descriptor -------------//
+// Invoked when received GET HID REPORT DESCRIPTOR
+// Application return pointer to descriptor
+// Descriptor contents must exist long enough for transfer to complete
+uint8_t const * tud_hid_descriptor_report_cb(void)
+{
+ return desc_hid_report;
+}
+
+//--------------------------------------------------------------------+
+// Configuration Descriptor
+//--------------------------------------------------------------------+
+
enum
{
ITF_NUM_HID,
@@ -88,14 +111,6 @@ uint8_t const desc_configuration[] =
TUD_HID_INOUT_DESCRIPTOR(ITF_NUM_HID, 0, HID_PROTOCOL_NONE, sizeof(desc_hid_report), EPNUM_HID, 0x80 | EPNUM_HID, CFG_TUD_HID_BUFSIZE, 10)
};
-
-// 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
// Descriptor contents must exist long enough for transfer to complete
@@ -105,15 +120,9 @@ uint8_t const * tud_descriptor_configuration_cb(uint8_t index)
return desc_configuration;
}
-// Invoked when received GET HID REPORT DESCRIPTOR
-// Application return pointer to descriptor
-// Descriptor contents must exist long enough for transfer to complete
-uint8_t const * tud_hid_descriptor_report_cb(void)
-{
- return desc_hid_report;
-}
-
-//------------- String Descriptors -------------//
+//--------------------------------------------------------------------+
+// String Descriptors
+//--------------------------------------------------------------------+
// array of pointer to string descriptors
char const* string_desc_arr [] =