We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I am working on the USB HID devices. I have downloaded the HID tool from the http://www.usb.org link. I have question that while making the mouse or keyboard some times we use the generic desktop as a usage page and sometimes not. also what is usage max and usage min. what is the actual need of this generic desktopp?? please do needful for this. thanking you, Sapna.
Usage Page
The HID spec defines Usage Page as follows,
5.5 Usages (HID1_11.pdf p17) A Usage is interpreted as a 32 bit unsigned value where the high order 16 bits defines the Usage Page and the low order 16 bits defines a Usage ID. Usage IDs are used to select individual Usage on a Usage Page.
Usage Page and Usage (Usage ID) are pair. But as Usage Page is a global item, you don't need to attach it to every Usage. Once a Usage Page is declared, it takes effect to all Usage after it, until another Usage Page is declared. Usage Minimum and Usage Maximum
You can declare Usages one by one, like
Usage (Keyboard_LeftControl) Usage (Keyboard_LeftShift) Usage (Keyboard_LeftAlt) ... Usage (Keyboard_Right_GUI)
But this method is too heavy for many Usages. For example, it's unrealistic to write down the Usage of each key for 101 keyboard.
When the Usages are assigned to contiguous number, you can define all Usages with the first one (Usage Minimum) and the last one (Usage Maximum).
Usage Minimum (Keyboard_LeftControl) Usage Maximum (Keyboard_Right_GUI)
[Reference] The HID spec 1.1 www.usb.org/.../HID1_11.pdf
Tsuneo
anybody can tell me how device reply host OUT request, like SET_REPORT request (HID USB-> data sent from HOST/PC to device) i'm using MAX3420.. how i can configure report descriptor to do that?
thank you
"how device reply host OUT request, like SET_REPORT request... how i can configure report descriptor to do that?"
This question shows that you don't understand 1) USB request sequence and its handling. 2) what the report descriptor means.
1) and 2) don't have direct relation so much.
1) USB request handling USB request is carried by control read or control write transfer on the default endpoint (Endpoint 0). SET_REPORT request is carried by control write transfer.
Control transfer consists of three stages, SETUP, DATA and STATUS. See "Control Transfer" on this web page. "USB Made Simple, Part 3 - Data Flow" www.usbmadesimple.co.uk/ums_3.htm
The device firmware handles control transfer as follows. a) SETUP stage Just after the SETUP stage is received by the USB engine on the device, the firmware is notified, usually by interrupt. The firmware unloads the SETUP packet from the default endpoint, parses the SETUP packet, knows the request type and dispatches to the handler of each request type.
SETUP packet of SET_REPORT( Output ) request bmRequestType: 00100001 bRequest: SET_REPORT (0x09) wValue: MSB: Report Type (Output: 0x02), LSB: Report ID wIndex: Interface number wLength: Report Length
For SET_REPORT( Output ), the firmware checks if the Report Length (wLength) matches to those of the Output report of the Report ID (wValue.LSB). If it doesn't match, set STALL to the endpoint. It it matches, the firmware prepares the buffer for the Output report, sets a flag (status) to expect OUT transaction(s) in following DATA stage, and finishes the SETUP stage handling once (returns from ISR).
If the firmware doesn't support the request, it sets STALL to the endpoint. This STALL is sent to the host on the following DATA stage transaction.
b) DATA stage DATA stage consists of one or more IN/OUT transactions. - control write transfer: OUT transaction(s) - control read transfer: IN transaction(s)
For SET_REPORT( Output ) request, host sends the body of the Output report in these OUT transactions. When the length of the report is greater than the bMaxPacketSize0 of the default endpoint, the report is split into multiple transactions by the host.
Every time the firmware is notified of the arrival of OUT transaction, the firmware knows that this OUT transaction is a part of SET_REPORT( Output ) request by the flag (status), set in the SETUP stage. Then, the firmware does the next step of the request handling; it unloads the data (Output report) from the default endpoint to the buffer for the Output report.
When the all data specified by the wLength of SETUP packet is retrieved, the DATA stage finishes. The firmware changes the flag (status) for the following STATUS stage.
Now that the all data is completely received, the firmware "executes" the request. For SET_REPORT( Output ), the firmware parses the report and sets the parameters on the firmware, lights a LED, or switches the motor on, etc.
The result of the execution is reported back to the host in the STATUS stage; If the firmware detects error on the report, it returns STALL on the STATUS stage.
c) STATUS stage STATUS stage consists of single IN/OUT transactions. - control write transfer: IN transaction - control read transfer: OUT transaction
When the firmware handles above stages successfully, it sends Zero-Length Packet (ZLP) on the default IN endpoint. Otherwise, it sets STALL on the endpoint. USB beginners often misunderstand that the handling of control transfer (USB request) finishes completely in a single USB ISR call. Actually, the handling is split into, at least, three transactions for three stages. Each transaction causes a USB ISR call. Then the handling is carried over multiple USB ISR calls. Therefore, flags or state machine is applied to this handling. 2) Report descriptor Report descriptor defines the format of the report(s), Input, Output and Feature report. It defines - The meaning (usage) of the report. - The order of each field on the report. - The length (bits and bytes) of the field. - The possible value (usage) range of the field. etc.
thanks for your help Mr. Tsuneo
But after several weeks I try HID class, I still confused... maybe i change to CDC..