clean up usb descriptors in example

This commit is contained in:
hathach
2019-07-12 16:28:38 +07:00
parent 164b26ee6b
commit fdf39dd4ae
6 changed files with 160 additions and 92 deletions

View File

@@ -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),
@@ -66,7 +68,17 @@ 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
//--------------------------------------------------------------------+
#if CFG_TUD_HID
enum
{
@@ -90,7 +102,10 @@ uint8_t const * tud_hid_descriptor_report_cb(void)
#endif
//------------- Configuration Descriptor -------------//
//--------------------------------------------------------------------+
// Configuration Descriptor
//--------------------------------------------------------------------+
enum
{
#if CFG_TUD_CDC
@@ -145,12 +160,7 @@ 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
@@ -161,7 +171,9 @@ uint8_t const * tud_descriptor_configuration_cb(uint8_t index)
return desc_configuration;
}
//------------- String Descriptors -------------//
//--------------------------------------------------------------------+
// String Descriptors
//--------------------------------------------------------------------+
// array of pointer to string descriptors
char const* string_desc_arr [] =