From 1b186a0c2f5fd9767121ce5aef9e4587304c06fa Mon Sep 17 00:00:00 2001 From: Ciaran Woodward Date: Thu, 9 Dec 2021 14:55:38 +0000 Subject: [PATCH] Remove test-specific information from hid_report_descriptor.h --- .../test_multi_report/hid_report_descriptor.h | 23 +----------------- .../test_multi_report/test_hid_multi_report.c | 24 +++++++++++++++---- .../src/test_simple/hid_report_descriptor.h | 12 ---------- .../xua_unit_tests/src/test_simple/test_hid.c | 20 ++++++++++++---- 4 files changed, 35 insertions(+), 44 deletions(-) diff --git a/tests/xua_unit_tests/src/test_multi_report/hid_report_descriptor.h b/tests/xua_unit_tests/src/test_multi_report/hid_report_descriptor.h index 75721cbf..6acefced 100644 --- a/tests/xua_unit_tests/src/test_multi_report/hid_report_descriptor.h +++ b/tests/xua_unit_tests/src/test_multi_report/hid_report_descriptor.h @@ -6,21 +6,6 @@ #include "xua_hid_report_descriptor.h" -#define REPORT1_MAX_VALID_BIT ( 3 ) -#define REPORT1_MAX_VALID_BYTE ( 0 ) -#define REPORT1_MIN_VALID_BIT ( 0 ) -#define REPORT1_MIN_VALID_BYTE ( 0 ) - -#define REPORT2_MAX_VALID_BIT ( 7 ) -#define REPORT2_MAX_VALID_BYTE ( 1 ) -#define REPORT2_MIN_VALID_BIT ( 0 ) -#define REPORT2_MIN_VALID_BYTE ( 0 ) - -#define REPORT3_MAX_VALID_BIT ( 1 ) -#define REPORT3_MAX_VALID_BYTE ( 0 ) -#define REPORT3_MIN_VALID_BIT ( 0 ) -#define REPORT3_MIN_VALID_BYTE ( 0 ) - #define USB_HID_REPORT_ID_KEYBOARD ( 0x01 ) #define USB_HID_REPORT_ID_CONSUMER ( 0x02 ) #define USB_HID_REPORT_ID_TELEPHONY ( 0x03 ) @@ -155,7 +140,7 @@ static USB_HID_Report_Element_t* const hidConfigurableElements[] = { }; /* - * List HID Reports, one per Report ID. This should be a usage page item with the relevant + * List HID Reports, one per Report ID. This should be a usage page item with the locator filled out with ID and size * If not using report IDs - still have one with report ID 0 */ static const USB_HID_Report_Element_t* const hidReports[] = { @@ -235,12 +220,6 @@ static const USB_HID_Short_Item_t* const hidReportDescriptorItems[] = { &hidCollectionEnd }; -/* - * Define the length of the HID Report. - * This value must match the number of Report bytes defined by hidReportDescriptorItems. - */ -#define HID_REPORT_LENGTH ( 3 ) - /* * Define the number of HID Reports * Due to XC not supporting designated initializers, this constant has a hard-coded value. diff --git a/tests/xua_unit_tests/src/test_multi_report/test_hid_multi_report.c b/tests/xua_unit_tests/src/test_multi_report/test_hid_multi_report.c index cc5a2371..17024e6e 100644 --- a/tests/xua_unit_tests/src/test_multi_report/test_hid_multi_report.c +++ b/tests/xua_unit_tests/src/test_multi_report/test_hid_multi_report.c @@ -5,13 +5,27 @@ #include "xua_unit_tests.h" #include "xua_hid_report_descriptor.h" -#include "hid_report_descriptor.h" -#define HID_REPORT_ITEM_TYPE_GLOBAL ( 0x01 ) -#define HID_REPORT_ITEM_TYPE_LOCAL ( 0x02 ) -#define HID_REPORT_ITEM_TYPE_MAIN ( 0x00 ) -#define HID_REPORT_ITEM_TYPE_RESERVED ( 0x03 ) +// Test constants related to the report descriptor defined in hid_report_descriptor.h +#define REPORT1_MAX_VALID_BIT ( 3 ) +#define REPORT1_MAX_VALID_BYTE ( 0 ) +#define REPORT1_MIN_VALID_BIT ( 0 ) +#define REPORT1_MIN_VALID_BYTE ( 0 ) +#define REPORT2_MAX_VALID_BIT ( 7 ) +#define REPORT2_MAX_VALID_BYTE ( 1 ) +#define REPORT2_MIN_VALID_BIT ( 0 ) +#define REPORT2_MIN_VALID_BYTE ( 0 ) + +#define REPORT3_MAX_VALID_BIT ( 1 ) +#define REPORT3_MAX_VALID_BYTE ( 0 ) +#define REPORT3_MIN_VALID_BIT ( 0 ) +#define REPORT3_MIN_VALID_BYTE ( 0 ) + +#define HID_REPORT_LENGTH ( 3 ) +#define HID_REPORT_COUNT ( 3 ) + +// Constants from USB HID Usage Tables #define KEYBOARD_PAGE ( 0x07 ) #define CONSUMER_PAGE ( 0x0C ) #define TELEPHONY_DEVICE_PAGE ( 0x0B ) diff --git a/tests/xua_unit_tests/src/test_simple/hid_report_descriptor.h b/tests/xua_unit_tests/src/test_simple/hid_report_descriptor.h index aad5bb49..561c8f28 100644 --- a/tests/xua_unit_tests/src/test_simple/hid_report_descriptor.h +++ b/tests/xua_unit_tests/src/test_simple/hid_report_descriptor.h @@ -6,12 +6,6 @@ #include "xua_hid_report_descriptor.h" -#define MAX_VALID_BIT ( 7 ) -#define MAX_VALID_BYTE ( 1 ) - -#define MIN_VALID_BIT ( 0 ) -#define MIN_VALID_BYTE ( 0 ) - #define USB_HID_USAGE_PAGE_ID_CONSUMER ( 0x0C ) /* @@ -112,12 +106,6 @@ static const USB_HID_Short_Item_t* const hidReportDescriptorItems[] = { &hidCollectionEnd }; -/* - * Define the length of the HID Report. - * This value must match the number of Report bytes defined by hidReportDescriptorItems. - */ -#define HID_REPORT_LENGTH ( 2 ) - /* * Define the number of HID Reports * Due to XC not supporting designated initializers, this constant has a hard-coded value. diff --git a/tests/xua_unit_tests/src/test_simple/test_hid.c b/tests/xua_unit_tests/src/test_simple/test_hid.c index 4ab9bac0..11353744 100644 --- a/tests/xua_unit_tests/src/test_simple/test_hid.c +++ b/tests/xua_unit_tests/src/test_simple/test_hid.c @@ -5,17 +5,27 @@ #include "xua_unit_tests.h" #include "xua_hid_report_descriptor.h" -#include "hid_report_descriptor.h" + +// Test constants related to the report descriptor defined in hid_report_descriptor.h +#define MAX_VALID_BIT ( 7 ) +#define MAX_VALID_BYTE ( 1 ) + +#define MIN_VALID_BIT ( 0 ) +#define MIN_VALID_BYTE ( 0 ) + +#define HID_REPORT_LENGTH ( 2 ) +#define HID_REPORT_COUNT ( 1 ) + +// Constants from the USB HID Usage Tables +#define CONSUMER_CONTROL_PAGE ( 0x0C ) +#define LOUDNESS_CONTROL ( 0xE7 ) +#define AL_CONTROL_PANEL ( 0x019F ) #define HID_REPORT_ITEM_TYPE_GLOBAL ( 0x01 ) #define HID_REPORT_ITEM_TYPE_LOCAL ( 0x02 ) #define HID_REPORT_ITEM_TYPE_MAIN ( 0x00 ) #define HID_REPORT_ITEM_TYPE_RESERVED ( 0x03 ) -#define CONSUMER_CONTROL_PAGE ( 0x0C ) -#define LOUDNESS_CONTROL ( 0xE7 ) -#define AL_CONTROL_PANEL ( 0x019F ) - static unsigned construct_usage_header( unsigned size ) { unsigned header = 0x00;