Add hidReportIdInUse command to determine whether report IDs are used

This commit is contained in:
Ciaran Woodward
2021-12-17 14:34:13 +00:00
parent c3e95a379f
commit d3d9b5ba23
4 changed files with 30 additions and 0 deletions

View File

@@ -242,6 +242,13 @@ unsigned hidGetReportIdLimit ( void ) {
return retVal;
}
unsigned hidIsReportIdInUse ( void ) {
if ( hidGetElementReportId( hidReports[ 0 ]->location ) ) {
return 1;
}
return 0;
}
#define HID_CONFIGURABLE_ELEMENT_COUNT ( sizeof hidConfigurableElements / sizeof ( USB_HID_Report_Element_t* ))
unsigned hidGetReportItem(
const unsigned id,

View File

@@ -181,6 +181,19 @@ size_t hidGetReportDescriptorLength( void );
*/
unsigned hidGetReportIdLimit ( void );
/**
* @brief Does the application use Report IDs?
*
* If the application is not using Report IDs, then the id value that is passed around
* everywhere can just be zero. Otherwise zero is an invalid ID that has a special meaning
* in some cases (read the documentation for each function).
*
* @return Boolean
* @retval 1 Report IDs are in use
* @retval 0 Report IDs are not in use
*/
unsigned hidIsReportIdInUse ( void );
/**
* @brief Get a HID Report descriptor item
*

View File

@@ -58,6 +58,11 @@ void test_validate_report( void ) {
TEST_ASSERT_EQUAL_UINT( HID_STATUS_GOOD, retVal );
}
void test_reportid_in_use( void ) {
unsigned reportIdInUse = hidIsReportIdInUse();
TEST_ASSERT_EQUAL_UINT( 1, reportIdInUse );
}
// Basic report descriptor tests
void test_unprepared_hidGetReportDescriptor( void )
{

View File

@@ -45,6 +45,11 @@ void test_validate_report( void ) {
TEST_ASSERT_EQUAL_UINT( HID_STATUS_GOOD, retVal );
}
void test_reportid_in_use( void ) {
unsigned reportIdInUse = hidIsReportIdInUse();
TEST_ASSERT_EQUAL_UINT( 0, reportIdInUse );
}
// Basic report descriptor tests
void test_unprepared_hidGetReportDescriptor( void )
{