diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 7de64616..518aab7b 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,15 @@ lib_xua Change Log ================== +3.0.0 +----- + + * ADDED: Support for HID Report IDs + * REMOVED: Support for HID Reports containing controls from mixed Usage + pages + * CHANGED: Renamed the HID API file xua_hid_report_descriptor.h to + xua_hid_report.h + 2.1.1 ----- diff --git a/examples/AN00246_xua_example/src/hid_report_descriptor.h b/examples/AN00246_xua_example/src/hid_report_descriptor.h index a049576e..ec2c13e5 100644 --- a/examples/AN00246_xua_example/src/hid_report_descriptor.h +++ b/examples/AN00246_xua_example/src/hid_report_descriptor.h @@ -3,7 +3,7 @@ #ifndef __hid_report_descriptor_h__ #define __hid_report_descriptor_h__ -#include "xua_hid_report_descriptor.h" +#include "xua_hid_report.h" #if 0 /* Existing static report descriptor kept for reference */ diff --git a/examples/AN00247_xua_example_spdif_tx/src/hid_report_descriptor.h b/examples/AN00247_xua_example_spdif_tx/src/hid_report_descriptor.h index a049576e..ec2c13e5 100644 --- a/examples/AN00247_xua_example_spdif_tx/src/hid_report_descriptor.h +++ b/examples/AN00247_xua_example_spdif_tx/src/hid_report_descriptor.h @@ -3,7 +3,7 @@ #ifndef __hid_report_descriptor_h__ #define __hid_report_descriptor_h__ -#include "xua_hid_report_descriptor.h" +#include "xua_hid_report.h" #if 0 /* Existing static report descriptor kept for reference */ diff --git a/examples/AN00248_xua_example_pdm_mics/src/hid_report_descriptor.h b/examples/AN00248_xua_example_pdm_mics/src/hid_report_descriptor.h index a049576e..ec2c13e5 100644 --- a/examples/AN00248_xua_example_pdm_mics/src/hid_report_descriptor.h +++ b/examples/AN00248_xua_example_pdm_mics/src/hid_report_descriptor.h @@ -3,7 +3,7 @@ #ifndef __hid_report_descriptor_h__ #define __hid_report_descriptor_h__ -#include "xua_hid_report_descriptor.h" +#include "xua_hid_report.h" #if 0 /* Existing static report descriptor kept for reference */ 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 23bda6f7..e2b9b4d8 100644 --- a/legacy_tests/app_test_i2s_loopback/hid_report_descriptor.h +++ b/legacy_tests/app_test_i2s_loopback/hid_report_descriptor.h @@ -3,7 +3,7 @@ #ifndef __hid_report_descriptor_h__ #define __hid_report_descriptor_h__ -#include "xua_hid_report_descriptor.h" +#include "xua_hid_report.h" #if 0 /* Existing static report descriptor kept for reference */ diff --git a/lib_xua/module_build_info b/lib_xua/module_build_info index 39b0476e..e566c11b 100644 --- a/lib_xua/module_build_info +++ b/lib_xua/module_build_info @@ -1,4 +1,4 @@ -VERSION = 2.1.1 +VERSION = 3.0.0 DEPENDENT_MODULES = lib_logging(>=3.0.0) \ lib_xassert(>=4.0.0) \ diff --git a/lib_xua/src/core/buffer/ep/ep_buffer.xc b/lib_xua/src/core/buffer/ep/ep_buffer.xc index 27b25751..0324bc0b 100644 --- a/lib_xua/src/core/buffer/ep/ep_buffer.xc +++ b/lib_xua/src/core/buffer/ep/ep_buffer.xc @@ -21,7 +21,7 @@ #include "testct_byref.h" #if( 0 < HID_CONTROLS ) -#include "xua_hid_report_descriptor.h" +#include "xua_hid_report.h" #include "user_hid.h" #include "xua_hid.h" unsigned char g_hidData[HID_MAX_DATA_BYTES] = {0}; diff --git a/lib_xua/src/core/endpoint0/xua_endpoint0.c b/lib_xua/src/core/endpoint0/xua_endpoint0.c index a89f6330..b282319b 100755 --- a/lib_xua/src/core/endpoint0/xua_endpoint0.c +++ b/lib_xua/src/core/endpoint0/xua_endpoint0.c @@ -28,7 +28,7 @@ #if( 0 < HID_CONTROLS ) #include "hid.h" #include "xua_hid.h" -#include "xua_hid_report_descriptor.h" +#include "xua_hid_report.h" #endif #if DSD_CHANS_DAC > 0 @@ -525,6 +525,7 @@ void XUA_Endpoint0_init(chanend c_ep0_out, chanend c_ep0_in, NULLABLE_RESOURCE(c #endif #if( 0 < HID_CONTROLS ) + hidReportInit(); hidPrepareReportDescriptor(); size_t hidReportDescriptorLength = hidGetReportDescriptorLength(); diff --git a/lib_xua/src/hid/hid.xc b/lib_xua/src/hid/hid.xc index 83286bce..fd8f6fab 100644 --- a/lib_xua/src/hid/hid.xc +++ b/lib_xua/src/hid/hid.xc @@ -7,7 +7,7 @@ #include "xud.h" #include "xud_std_requests.h" #include "xua_hid.h" -#include "xua_hid_report_descriptor.h" +#include "xua_hid_report.h" #if( 0 < HID_CONTROLS ) static unsigned HidCalcNewReportTime( const unsigned currentPeriod, const unsigned reportTime, const unsigned reportToSetIdleInterval, const unsigned newPeriod ); diff --git a/lib_xua/src/hid/hid_report_descriptor.c b/lib_xua/src/hid/hid_report.c similarity index 96% rename from lib_xua/src/hid/hid_report_descriptor.c rename to lib_xua/src/hid/hid_report.c index cadefca4..1695976b 100644 --- a/lib_xua/src/hid/hid_report_descriptor.c +++ b/lib_xua/src/hid/hid_report.c @@ -4,7 +4,7 @@ #include #include #include "descriptor_defs.h" -#include "xua_hid_report_descriptor.h" +#include "xua_hid_report.h" #include "hid_report_descriptor.h" #include @@ -16,15 +16,15 @@ /* * Each element in s_hidChangePending corresponds to an element in hidReports. */ -static unsigned s_hidChangePending[ HID_REPORT_COUNT ] = { 0U }; +static unsigned s_hidChangePending[ HID_REPORT_COUNT ]; static unsigned char s_hidReportDescriptor[ HID_REPORT_DESCRIPTOR_MAX_LENGTH ]; -static size_t s_hidReportDescriptorLength = 0U; -static unsigned s_hidReportDescriptorPrepared = 0U; +static size_t s_hidReportDescriptorLength; +static unsigned s_hidReportDescriptorPrepared; -static unsigned s_hidCurrentPeriod[ HID_REPORT_COUNT ] = { ENDPOINT_INT_INTERVAL_IN_HID * MS_IN_TICKS }; -static unsigned s_hidIdleActive[ HID_REPORT_COUNT ] = { 0U }; -static unsigned s_hidNextReportTime[ HID_REPORT_COUNT ] = { 0U }; -static unsigned s_hidReportTime[ HID_REPORT_COUNT ] = { 0U }; +static unsigned s_hidCurrentPeriod[ HID_REPORT_COUNT ]; +static unsigned s_hidIdleActive[ HID_REPORT_COUNT ]; +static unsigned s_hidNextReportTime[ HID_REPORT_COUNT ]; +static unsigned s_hidReportTime[ HID_REPORT_COUNT ]; /** * @brief Get the bit position from the location of a report element @@ -370,6 +370,13 @@ void hidPrepareReportDescriptor( void ) } } +void hidReportInit( void ) +{ + for( unsigned idx = 0U; idx < HID_REPORT_COUNT; ++idx ) { + s_hidCurrentPeriod[ idx ] = ENDPOINT_INT_INTERVAL_IN_HID * MS_IN_TICKS; + } +} + void hidResetReportDescriptor( void ) { s_hidReportDescriptorPrepared = 0U; diff --git a/lib_xua/src/hid/xua_hid_report_descriptor.h b/lib_xua/src/hid/xua_hid_report.h similarity index 99% rename from lib_xua/src/hid/xua_hid_report_descriptor.h rename to lib_xua/src/hid/xua_hid_report.h index 8043d1c3..65d51c2c 100644 --- a/lib_xua/src/hid/xua_hid_report_descriptor.h +++ b/lib_xua/src/hid/xua_hid_report.h @@ -350,6 +350,13 @@ unsigned hidIsIdleActive( const unsigned id ); */ void hidPrepareReportDescriptor( void ); +/** + * @brief Initialise the USB HID Report functionality + * + * Call this function before using any other functions in this API. + */ +void hidReportInit( void ); + /** * @brief Reset the USB HID Report descriptor * 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 2d8a675a..1da6dc7b 100644 --- a/tests/xua_unit_tests/src/test_simple/test_hid.c +++ b/tests/xua_unit_tests/src/test_simple/test_hid.c @@ -4,7 +4,7 @@ #include #include "xua_unit_tests.h" -#include "xua_hid_report_descriptor.h" +#include "xua_hid_report.h" // Test constants related to the report descriptor defined in hid_report_descriptor.h #define MAX_VALID_BIT ( 7 ) @@ -59,6 +59,7 @@ void test_unprepared_hidGetReportDescriptor( void ) void test_prepared_hidGetReportDescriptor( void ) { const unsigned reportId = 0; + hidReportInit(); hidPrepareReportDescriptor(); unsigned char* reportDescPtr = hidGetReportDescriptor(); TEST_ASSERT_NOT_NULL( reportDescPtr ); @@ -69,6 +70,7 @@ void test_prepared_hidGetReportDescriptor( void ) void test_reset_unprepared_hidGetReportDescriptor( void ) { + hidReportInit(); hidPrepareReportDescriptor(); hidResetReportDescriptor(); unsigned char* reportDescPtr = hidGetReportDescriptor(); @@ -77,6 +79,7 @@ void test_reset_unprepared_hidGetReportDescriptor( void ) void test_reset_prepared_hidGetReportDescriptor( void ) { + hidReportInit(); hidPrepareReportDescriptor(); hidResetReportDescriptor(); hidPrepareReportDescriptor(); @@ -450,6 +453,7 @@ void test_initial_modification_with_subsequent_preparation( void ) const unsigned char header = construct_usage_header( sizeof data / sizeof( unsigned char )); const unsigned char page = CONSUMER_CONTROL_PAGE; + hidReportInit(); unsigned retVal = hidSetReportItem( reportId, byte, bit, page, header, data ); TEST_ASSERT_EQUAL_UINT( HID_STATUS_GOOD, retVal ); @@ -532,6 +536,7 @@ void test_initial_modification_with_subsequent_verification_2( void ) void test_modification_without_subsequent_preparation( void ) { + hidReportInit(); hidPrepareReportDescriptor(); unsigned char* reportDescPtr = hidGetReportDescriptor(); TEST_ASSERT_NOT_NULL( reportDescPtr ); @@ -553,6 +558,7 @@ void test_modification_without_subsequent_preparation( void ) void test_modification_with_subsequent_preparation( void ) { + hidReportInit(); hidPrepareReportDescriptor(); unsigned char* reportDescPtr = hidGetReportDescriptor(); TEST_ASSERT_NOT_NULL( reportDescPtr );