In all of Keil's USBHID examples, there are two items in the Report Descriptor called UsageMin and UsageMax. Thy are set to 1 and 3. I have reviewed the USB Usage Spec and several other examples and I still don't understand the need for these two items of range. I can find no other example of these two items. In MSDN2, I find the HIDP_Value_CAPS structure that includes the RANGE.UsageMin and RANGE.UsageMax that tells about the bounds but what is their use? In Keil's HIDClient code, I see no place where the two items are used. Of course when I comment out the two lines of code, the code fails. Probably I'm breaking an array count somewhere when I comment out the code. I'm hoping that someone like Tsuneo can educate me on the two items. I have sent a query to Keil Support but it will be awhile before I expect an answer. Al Bradford
I'll show a little more generalized form. In the simplified report descriptor, it just defines the number of bytes of each report. This numbers are extracted with #define as follows. Then, you don't need to worry about the report descriptor any more. When you add more reports using report ID, this code works as the template for the modification.
//----------------------------------------- // HID Report Descriptor //----------------------------------------- // // Bit Input Output // 0 Button 1 LED1 // 1 Button 2 LED2 // 2 Button 3 LED3 // 3 (padding) LED4 // 4 --- LED5 // 5 --- LED6 // 6 --- LED7 // 7 --- LED8 // #define HID_INPUT_REPORT_BYTES 1 // up to 127 bytes #define HID_OUTPUT_REPORT_BYTES 1 // up to 127 bytes #define HID_FEATURE_REPORT_BYTES 1 // up to 127 bytes const BYTE HID_ReportDescriptor[] = { HID_UsagePageVendor( 0x00 ), HID_Usage ( 0x01 ), HID_Collection ( HID_Application ), HID_LogicalMin ( 0 ), // value range: 0 - 0xFF HID_LogicalMaxS ( 0xFF ), HID_ReportSize ( 8 ), // 8 bits HID_ReportCount ( HID_INPUT_REPORT_BYTES ), HID_Usage ( 0x01 ), HID_Input ( HID_Data | HID_Variable | HID_Absolute ), HID_ReportCount ( HID_OUTPUT_REPORT_BYTES ), HID_Usage ( 0x01 ), HID_Output ( HID_Data | HID_Variable | HID_Absolute ), HID_ReportCount ( HID_FEATURE_REPORT_BYTES ), HID_Usage ( 0x01 ), HID_Feature ( HID_Data | HID_Variable | HID_Absolute ), HID_EndCollection, }; const WORD HID_ReportDescSize = sizeof(HID_ReportDescriptor);
Tsuneo
Tsuneo; Thank you for your effort in my education. You have been a great help to me and I'm sure others that monitor this forum. I have the DT tool you referenced. It also was a help until I stumbled and fell on the point of UsageMin/UsageMax. Actually your description of the keyboard code was also a great help in defining how to handle my 12 buttons of input with the Usage range items. I have USB communication between my target and HID Client working and I was attempting to finalize my report formats. This education has saved me several more days of effort. Thanks again. Al Bradford