From ab96a726d68dda06bc2d41197729f8c744542ef9 Mon Sep 17 00:00:00 2001 From: Angel Cascarino Date: Mon, 20 Dec 2021 12:51:26 +0000 Subject: [PATCH] Altered format on test report_descriptor.h --- .../hid_report_descriptor.h | 83 +++++++++++-------- 1 file changed, 47 insertions(+), 36 deletions(-) diff --git a/legacy_tests/app_test_i2s_loopback/hid_report_descriptor.h b/legacy_tests/app_test_i2s_loopback/hid_report_descriptor.h index f133eb7e..6ba8ea01 100644 --- a/legacy_tests/app_test_i2s_loopback/hid_report_descriptor.h +++ b/legacy_tests/app_test_i2s_loopback/hid_report_descriptor.h @@ -5,6 +5,8 @@ #include "xua_hid_report.h" +#define USB_HID_REPORT_ID_CONSUMER ( 0x02 ) + #if 0 /* Existing static report descriptor kept for reference */ unsigned char hidReportDescriptor[] = @@ -29,8 +31,6 @@ unsigned char hidReportDescriptor[] = }; #endif -#define USB_HID_REPORT_ID_CONSUMER ( 0x02 ) - /* * Define non-configurable items in the HID Report descriptor. */ @@ -64,41 +64,56 @@ static const USB_HID_Short_Item_t hidReportCount2 = { static const USB_HID_Short_Item_t hidReportCount6 = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_COUNT), .data = { 0x06, 0x00 } }; - static const USB_HID_Short_Item_t hidReportSize1 = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_SIZE), .data = { 0x01, 0x00 } }; + static const USB_HID_Short_Item_t hidUsageConsumerControl = { .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE), .data = { 0x01, 0x00 } }; -static const USB_HID_Short_Item_t hidUsagePageConsumer = { - .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_USAGE_PAGE), - .data = { 0x0C, 0x00 } }; + +/* + * Define the HID Report Descriptor Item, Usage Page, Report ID and length for each HID Report + * For internal purposes, a report element with ID of 0 must be included if report IDs are not being used. + */ +static const USB_HID_Report_Element_t hidReportPageConsumer = { + .item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_USAGE_PAGE), + .item.data = { USB_HID_USAGE_PAGE_ID_CONSUMER, 0x00 }, + .location = HID_REPORT_SET_LOC( USB_HID_REPORT_ID_CONSUMER, 1, 0, 0 ) }; /* * Define configurable items in the HID Report descriptor. */ -static USB_HID_Report_Element_t hidUsageByte0Bit5 = { .item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE), .item.data = { 0xE2, 0x00 }, - .location = HID_REPORT_SET_LOC( USB_HID_REPORT_ID_CONSUMER, 0, 0, 5 ) }; // Mute -static USB_HID_Report_Element_t hidUsageByte0Bit4 = { .item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE), .item.data = { 0xEA, 0x00 }, - .location = HID_REPORT_SET_LOC( USB_HID_REPORT_ID_CONSUMER, 0, 0, 4 ) }; // Vol- -static USB_HID_Report_Element_t hidUsageByte0Bit3 = { .item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE), .item.data = { 0xE9, 0x00 }, - .location = HID_REPORT_SET_LOC( USB_HID_REPORT_ID_CONSUMER, 0, 0, 3 ) }; // Vol+ -static USB_HID_Report_Element_t hidUsageByte0Bit2 = { .item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE), .item.data = { 0xB6, 0x00 }, - .location = HID_REPORT_SET_LOC( USB_HID_REPORT_ID_CONSUMER, 0, 0, 2 ) }; // Scan Prev -static USB_HID_Report_Element_t hidUsageByte0Bit1 = { .item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE), .item.data = { 0xB5, 0x00 }, - .location = HID_REPORT_SET_LOC( USB_HID_REPORT_ID_CONSUMER, 0, 0, 1 ) }; // Scan Next -static USB_HID_Report_Element_t hidUsageByte0Bit0 = { .item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE), .item.data = { 0xB0, 0x00 }, - .location = HID_REPORT_SET_LOC( USB_HID_REPORT_ID_CONSUMER, 0, 0, 0 ) }; // Play - -static USB_HID_Short_Item_t hidReportID1 = { - .header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_REPORT_ID), - .data = { USB_HID_USAGE_PAGE_ID_CONSUMER, 0x00} }; -static const USB_HID_Report_Element_t hidReportConsumer = { - .item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_GLOBAL, HID_REPORT_ITEM_TAG_USAGE_PAGE), - .item.data = { USB_HID_USAGE_PAGE_ID_CONSUMER, 0x00 }, - .location = HID_REPORT_SET_LOC( USB_HID_REPORT_ID_CONSUMER, 1, 0, 0 ) -}; +static USB_HID_Report_Element_t hidUsageByte0Bit5 = { + .item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE), + .item.data = { 0xE2, 0x00 }, + .location = HID_REPORT_SET_LOC( USB_HID_REPORT_ID_CONSUMER, 0, 0, 5 ) +}; // Mute +static USB_HID_Report_Element_t hidUsageByte0Bit4 = { + .item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE), + .item.data = { 0xEA, 0x00 }, + .location = HID_REPORT_SET_LOC( USB_HID_REPORT_ID_CONSUMER, 0, 0, 4 ) +}; // Vol- +static USB_HID_Report_Element_t hidUsageByte0Bit3 = { + .item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE), + .item.data = { 0xE9, 0x00 }, + .location = HID_REPORT_SET_LOC( USB_HID_REPORT_ID_CONSUMER, 0, 0, 3 ) +}; // Vol+ +static USB_HID_Report_Element_t hidUsageByte0Bit2 = { + .item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE), + .item.data = { 0xB6, 0x00 }, + .location = HID_REPORT_SET_LOC( USB_HID_REPORT_ID_CONSUMER, 0, 0, 2 ) +}; // Scan Prev +static USB_HID_Report_Element_t hidUsageByte0Bit1 = { + .item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE), + .item.data = { 0xB5, 0x00 }, + .location = HID_REPORT_SET_LOC( USB_HID_REPORT_ID_CONSUMER, 0, 0, 1 ) +}; // Scan Next +static USB_HID_Report_Element_t hidUsageByte0Bit0 = { + .item.header = HID_REPORT_SET_HEADER(1, HID_REPORT_ITEM_TYPE_LOCAL, HID_REPORT_ITEM_TAG_USAGE), + .item.data = { 0xB0, 0x00 }, + .location = HID_REPORT_SET_LOC( USB_HID_REPORT_ID_CONSUMER, 0, 0, 0 ) +}; // Play /* * List the configurable items in the HID Report descriptor. @@ -113,18 +128,18 @@ static USB_HID_Report_Element_t* const hidConfigurableElements[] = { }; /* - * List Usage pages in the HID Report descriptor, one per byte. + * List HID Reports, one per Report ID. This should be a usage page item with the relevant + * If not using report IDs - still have one with report ID 0 */ -static const USB_HID_Short_Item_t * const hidUsagePages[] = { - &hidUsagePageConsumer +static const USB_HID_Report_Element_t* const hidReports[] = { + &hidReportPageConsumer }; /* * List all items in the HID Report descriptor. */ static const USB_HID_Short_Item_t * const hidReportDescriptorItems[] = { - &(hidReportConsumer.item), - &hidUsagePageConsumer, + &(hidReportPageConsumer.item), &hidUsageConsumerControl, &hidCollectionApplication, &hidLogicalMinimum0, @@ -144,10 +159,6 @@ static const USB_HID_Short_Item_t * const hidReportDescriptorItems[] = { &hidCollectionEnd }; -static const USB_HID_Report_Element_t* const hidReports[] = { - &hidReportConsumer -}; - /* * Define the number of HID Reports * Due to XC not supporting designated initializers, this constant has a hard-coded value.