forked from PAWPAW-Mirror/lib_xua
Add function to return the length of the HID Report
This commit is contained in:
@@ -12,6 +12,9 @@
|
||||
#define MIN_VALID_BIT ( 0 )
|
||||
#define MIN_VALID_BYTE ( 0 )
|
||||
|
||||
/*
|
||||
* Define non-configurable items in the HID Report descriptor.
|
||||
*/
|
||||
static const USB_HID_Short_Item_t hidCollectionApplication = { .header = 0xA1, .data = { 0x01, 0x00 }, .location = 0x00 };
|
||||
static const USB_HID_Short_Item_t hidCollectionEnd = { .header = 0xC0, .data = { 0x00, 0x00 }, .location = 0x00 };
|
||||
static const USB_HID_Short_Item_t hidCollectionLogical = { .header = 0xA1, .data = { 0x02, 0x00 }, .location = 0x00 };
|
||||
@@ -32,17 +35,26 @@ static const USB_HID_Short_Item_t hidUsageConsumerControl = { .header = 0x09,
|
||||
|
||||
static const USB_HID_Short_Item_t hidUsagePageConsumer = { .header = 0x05, .data = { 0x0C, 0x00 }, .location = 0x00 };
|
||||
|
||||
/*
|
||||
* Define configurable items in the HID Report descriptor.
|
||||
*/
|
||||
static USB_HID_Short_Item_t hidUsageByte0Bit0 = { .header = 0x09, .data = { 0xE2, 0x00 }, .location = 0x00 }; // Mute
|
||||
|
||||
static USB_HID_Short_Item_t hidUsageByte1Bit7 = { .header = 0x09, .data = { 0xEA, 0x00 }, .location = 0x71 }; // Vol-
|
||||
static USB_HID_Short_Item_t hidUsageByte1Bit0 = { .header = 0x09, .data = { 0xE9, 0x00 }, .location = 0x01 }; // Vol+
|
||||
|
||||
/*
|
||||
* List the configurable items in the HID Report descriptor.
|
||||
*/
|
||||
static USB_HID_Short_Item_t* const hidConfigurableItems[] = {
|
||||
&hidUsageByte0Bit0,
|
||||
&hidUsageByte1Bit0,
|
||||
&hidUsageByte1Bit7
|
||||
};
|
||||
|
||||
/*
|
||||
* List all items in the HID Report descriptor.
|
||||
*/
|
||||
static const USB_HID_Short_Item_t* const hidReportDescriptorItems[] = {
|
||||
&hidUsagePageConsumer,
|
||||
&hidUsageConsumerControl,
|
||||
@@ -73,4 +85,10 @@ 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 )
|
||||
|
||||
#endif // __hid_report_descriptor_h__
|
||||
|
||||
@@ -36,6 +36,9 @@ void test_unprepared_hidGetReportDescriptor( void )
|
||||
{
|
||||
unsigned char* reportDescPtr = hidGetReportDescriptor();
|
||||
TEST_ASSERT_NULL( reportDescPtr );
|
||||
|
||||
unsigned reportLength = hidGetReportLength();
|
||||
TEST_ASSERT_EQUAL_UINT( 0, reportLength );
|
||||
}
|
||||
|
||||
void test_prepared_hidGetReportDescriptor( void )
|
||||
@@ -43,6 +46,9 @@ void test_prepared_hidGetReportDescriptor( void )
|
||||
hidPrepareReportDescriptor();
|
||||
unsigned char* reportDescPtr = hidGetReportDescriptor();
|
||||
TEST_ASSERT_NOT_NULL( reportDescPtr );
|
||||
|
||||
unsigned reportLength = hidGetReportLength();
|
||||
TEST_ASSERT_EQUAL_UINT( HID_REPORT_LENGTH, reportLength );
|
||||
}
|
||||
|
||||
void test_reset_unprepared_hidGetReportDescriptor( void )
|
||||
|
||||
Reference in New Issue
Block a user