*HTML is ON *UBB Code is OFF Smilies Legend
Smilies Legend
If you have previously registered, but forgotten your password, click here.
T O P I C R E V I E WclauswkGreetings,I am currently working on a project which must handle one USB HID mouse, one USB HID keyboard, one vendor specific HID interface and one Mass Storage Device.I am using a C8051F340.I have earlier implemented the mouse, the keyboard and the vendor HID interfaces, all interrupt driven, with success. (It passed the USB-IF test suite, AND works on the PC)I did not use ReportIDs, instead I used different endpoints for the different interfaces. Trying to implement the MSD on top of that gives me a lot of headache:I am trying to use the same endpoint (EP1 in interrupt mode) for the three interfaces with reportIDs, and then use EP3 in bulk mode for the MSD.I have trawled through all kind of application notes and the USB bibles with no luck.Can anyone out there give me a couple of hints, what to do and what to avoid etc.Thanks------------------Best regards,Claus KnudsenTsuneo"I am currently working on a project which must handle one USB HID mouse, one USB HID keyboard, one vendor specific HID interface and one Mass Storage Device...I am trying to use the same endpoint (EP1 in interrupt mode) for the three interfaces with reportIDs"I recommend you this composite device configuration.- Interface 0, EP2 IN/OUT, interrupt: vendor specific HID- Interface 1, EP1 IN/OUT, interrupt: HID mouse + HID keyboard- Interface 2, EP3 IN/OUT, bulk: Mass Storage, bulk-only transferThe reasons are,a) HID mouse + keyboard on single interface is an established technique.b) Windows grab mouse and keyboard as system device. Direct access to these device instances from your host app is not allowed. When you add another collection (report ID) to this interface, the access to this collection may be refused by Windows.The HID spec shows the outline for mouse + keyboard on single interface.8.5 Report Example (HID1_11.pdf p57)The combined report descriptor is made just by appending keyboard and mouse report descriptor. (revised the bug on report ID numbering on the example)Collection (Application) Keyboard Report ID (01) Input (Variable, Absolute) Modifier keys Output (Variable, Absolute) LEDs Input (Array, Absolute) Main keysEnd CollectionCollection (Application) Mouse Report ID (02) Collection (Physical) Pointer Input (Variable, Relative) X, Y Input (Variable, Absolute) Button End CollectionEnd CollectionOn this combined interface, you cannot apply boot device.(bInterfaceClass, bInterfaceSubclass, bInterfaceProtocol)= (0x03, 0x00, 0x00) = (HID class, no subclass, no protocol)The detailed report descriptor is as follows.I just appended the keyboard and mouse report descriptor on the HID spec.And inserted the Report ID fields. Usage Page (Generic Desktop),Usage (Keyboard),Collection (Application), Report ID (01), Report Size (1), Report Count (8), Usage Page (Key Codes), Usage Minimum (224), Usage Maximum (231), Logical Minimum (0), Logical Maximum (1), Input (Data, Variable, Absolute), ;Modifier byte Report Count (1), Report Size (8), Input (Constant), ;Reserved byte Report Count (5), Report Size (1), Usage Page (LEDs), Usage Minimum (1), Usage Maximum (5), Output (Data, Variable, Absolute), ;LED report Report Count (1), Report Size (3), Output (Constant), ;LED report padding Report Count (6), Report Size (8), Logical Minimum (0), Logical Maximum(255), Usage Page (Key Codes), Usage Minimum (0), Usage Maximum (101), Input (Data, Array),End CollectionUsage Page (Generic Desktop),Usage (Mouse),Collection (Application), Usage (Pointer), Collection (Physical), Report ID (02), Report Count (3), Report Size (1), Usage Page (Buttons), Usage Minimum (1), Usage Maximum (3), Logical Minimum (0), Logical Maximum (1), Input (Data, Variable, Absolute), Report Count (1), Report Size (5), Input (Constant), Report Size (8), Report Count (2), Usage Page (Generic Desktop), Usage (X), Usage (Y), Logical Minimum (-127), Logical Maximum (127), Input (Data, Variable, Relative), End Collection,End CollectionTsuneo[This message has been edited by Tsuneo (edited January 24, 2008).]PatrykTsuneo:"Windows grab mouse and keyboard as system device. Direct access to these device instances from your host app is not allowed."WriteFile() and ReadFile() will fail, but HidD_SetFeature()/HidD_GetFeature() and HidD_GetInputReport()/HidD_SetOutputReport() works. Just need to use 0 for dwDesiredAccess and (FILE_SHARE_READ | FILE_SHARE_WRITE) for dwShareMode in a call to CreateFile().clauswkThank you very much, Tsuneo, for your quick and, as always, precise and enlightening answer.I just tried to implement a mouse and a keyboard to the HID Blinky example for the -340, and it just works excellent: The mouse is circling on the screen, and a test text is repeatedly written in my editor. And at the same time the LEDs are blinking in patterns controlled by the potmeter on the -340 DK.Thanks,------------------Best regards,Claus KnudsenTsuneoThis topic on MSDN shows the way how Windows handle the combined report descriptor for keyboard and mouse.Top-Level Collectionshttp://msdn2.microsoft.com/en-us/library/ms789908.aspxMicrosoft defines a top-level collection as a HID collection that is not nested within another collection. An unnested collection is always a top-level collection, regardless of its HID type. In particular, a top-level collection does not have to be an Application collection, as defined by the USB HID standard.A report descriptor can include more than one top-level collection. The HID class driver enumerates the top-level collections of an input device and creates a physical device object (PDO) for each top-level collection. User-mode applications or kernel-mode drivers can access a top-level collection by opening its PDO and using the HIDClass support routines and the HID class driver IOCTLs.TsuneoUmetsuI'd like to USB composite device such as HID keyboard and mouse.So, I tried it implementing the above Report-descriptor which is written by Mr. Tsuneo.ReportID #1 = keyboard.ReportID #2 = Mouse.For keyboard, I can received two byte data vir EP0 OUT. ReportID=0x01 and 8bit of keyboard LED(combination of NumLock, ScrLock and so on).Now where, I'd like to send key code(ex. key 'A' is 0x04) to PC.So I prepared 8 bytes data - 1 byte modifier keys, 1 byte reserved 0x00, 6 bytes of key code(such as 0x04='A', 0x00, 0x00, 0x00, 0x00, 0x00) vir EP0 IN.But, my PC can't receive anything...I'd like to ask why this didn't work correctly.Does the keyboard report ID needed to send key code to PC? In case of this, 1+8 bytes data transmittion is needed? (Report ID, Modifier keys, 0x00 reserved, 6 key code)??If any specification or source code sample are available, could you please tell me?[This message has been edited by Umetsu (edited March 26, 2009).]ElectroLundSorry to everyone for resurrecting a very old post! But I'm in the beginning stages of doing a similar exercise... making a HID-based USB device which is both mouse and keyboard.I don't need other functions like storage.Tsuneo, your post is most helpful. However, I have a problem with one area in your keyboard descriptor section. You listed a "Usage Maximum (101)". When I use the HID Descriptor Tool and open its keybrd.hid example, the USAGE_MAXIMUM has predefined values (like Keyboard RightAlt, etc.), none of which will allow me the value of 101.Did you mean to put 101 in the Logical Maximum? The HID Descriptor Tool's default value for Logical Maximum was 101, which seems to be the number of keys.Tsuneo> none of which will allow me the value of 101.101 is in decimal. Choose this keycode,0x65 Keyboard ApplicationTsuneoElectroLundTsuneo, thanks for your reply! I am working with Freescale's JS16. Using your method of multiple reports, single interface, I am able to have both mouse and keyboard HID descriptors register on host PC correctly.However, my data buffers now are not sent to the host PC. None of my mouse and keyboard inputs seem to get sent to the host. I assume there is some collision happening. TsuneoHowever, my data buffers now are not sent to the host PC. None of my mouse and keyboard inputs seem to get sent to the host.Check the USB traffic using a hardware analyzer or software sniffer.There are two possibility,a) The device doesn't return any packet for interrupt IN transaction- NAKing or timeout errorb) The device returns packets, but HID device driver drops them on the PC.a) means- The interrupt IN endpoint is not enabled on the firmwareOR- The packet is not actually loaded to the endpointb) means the format of the input reports is wrong.For above report descriptor with multiple TLCs (Top-Level Collections), the input report format is as followsFor keyboard,offset (byte) 0 report ID (01) 1 modifier keys 2 padding 3 - 8 keycode arrayFor mouse,offset (byte) 0 report ID (02) 1 buttons 2 X asis 3 Y axisSoftware sniffersSniffUSB (Open source)http://www.pcausa.com/Utilities/UsbSnoop/default.htmUsblyzer (commercial with free trial)http://www.usblyzer.com/ etc.> I am working with Freescale's JS16.Then, continue on Freescale forum - 8-Bit Microcontrollers, if any.http://forums.freescale.com/t5/8-Bit-Microcontrollers/bd-p/8BITCOMMI have account on the Freescale forum, too, though I'm not active on the forum. TsuneoTsuneoThis discussion with ElectroLund (irob) continues to this topic on Freescale forum,DEMO9S08JS16 - hybrid USB peripheral?http://forums.freescale.com/t5/8-Bit-Microcontrollers/DEMO9S08JS16-hybrid-USB-peripheral/td-p/53244Tsuneo[This message has been edited by Tsuneo (edited April 22, 2010).]
I am currently working on a project which must handle one USB HID mouse, one USB HID keyboard, one vendor specific HID interface and one Mass Storage Device.I am using a C8051F340.I have earlier implemented the mouse, the keyboard and the vendor HID interfaces, all interrupt driven, with success. (It passed the USB-IF test suite, AND works on the PC)
I did not use ReportIDs, instead I used different endpoints for the different interfaces.
Trying to implement the MSD on top of that gives me a lot of headache:I am trying to use the same endpoint (EP1 in interrupt mode) for the three interfaces with reportIDs, and then use EP3 in bulk mode for the MSD.
I have trawled through all kind of application notes and the USB bibles with no luck.Can anyone out there give me a couple of hints, what to do and what to avoid etc.
Thanks
------------------Best regards,Claus Knudsen
I recommend you this composite device configuration.- Interface 0, EP2 IN/OUT, interrupt: vendor specific HID- Interface 1, EP1 IN/OUT, interrupt: HID mouse + HID keyboard- Interface 2, EP3 IN/OUT, bulk: Mass Storage, bulk-only transfer
The reasons are,a) HID mouse + keyboard on single interface is an established technique.
b) Windows grab mouse and keyboard as system device. Direct access to these device instances from your host app is not allowed. When you add another collection (report ID) to this interface, the access to this collection may be refused by Windows.
The HID spec shows the outline for mouse + keyboard on single interface.8.5 Report Example (HID1_11.pdf p57)
The combined report descriptor is made just by appending keyboard and mouse report descriptor. (revised the bug on report ID numbering on the example)
Collection (Application) Keyboard Report ID (01) Input (Variable, Absolute) Modifier keys Output (Variable, Absolute) LEDs Input (Array, Absolute) Main keysEnd CollectionCollection (Application) Mouse Report ID (02) Collection (Physical) Pointer Input (Variable, Relative) X, Y Input (Variable, Absolute) Button End CollectionEnd Collection
The detailed report descriptor is as follows.I just appended the keyboard and mouse report descriptor on the HID spec.And inserted the Report ID fields.
Usage Page (Generic Desktop),Usage (Keyboard),Collection (Application), Report ID (01), Report Size (1), Report Count (8), Usage Page (Key Codes), Usage Minimum (224), Usage Maximum (231), Logical Minimum (0), Logical Maximum (1), Input (Data, Variable, Absolute), ;Modifier byte Report Count (1), Report Size (8), Input (Constant), ;Reserved byte Report Count (5), Report Size (1), Usage Page (LEDs), Usage Minimum (1), Usage Maximum (5), Output (Data, Variable, Absolute), ;LED report Report Count (1), Report Size (3), Output (Constant), ;LED report padding Report Count (6), Report Size (8), Logical Minimum (0), Logical Maximum(255), Usage Page (Key Codes), Usage Minimum (0), Usage Maximum (101), Input (Data, Array),End CollectionUsage Page (Generic Desktop),Usage (Mouse),Collection (Application), Usage (Pointer), Collection (Physical), Report ID (02), Report Count (3), Report Size (1), Usage Page (Buttons), Usage Minimum (1), Usage Maximum (3), Logical Minimum (0), Logical Maximum (1), Input (Data, Variable, Absolute), Report Count (1), Report Size (5), Input (Constant), Report Size (8), Report Count (2), Usage Page (Generic Desktop), Usage (X), Usage (Y), Logical Minimum (-127), Logical Maximum (127), Input (Data, Variable, Relative), End Collection,End Collection
Usage Page (Generic Desktop),Usage (Mouse),Collection (Application), Usage (Pointer), Collection (Physical), Report ID (02), Report Count (3), Report Size (1), Usage Page (Buttons), Usage Minimum (1), Usage Maximum (3), Logical Minimum (0), Logical Maximum (1), Input (Data, Variable, Absolute), Report Count (1), Report Size (5), Input (Constant), Report Size (8), Report Count (2), Usage Page (Generic Desktop), Usage (X), Usage (Y), Logical Minimum (-127), Logical Maximum (127), Input (Data, Variable, Relative), End Collection,End Collection
Tsuneo
[This message has been edited by Tsuneo (edited January 24, 2008).]
I just tried to implement a mouse and a keyboard to the HID Blinky example for the -340, and it just works excellent: The mouse is circling on the screen, and a test text is repeatedly written in my editor. And at the same time the LEDs are blinking in patterns controlled by the potmeter on the -340 DK.
Thanks,
Top-Level Collectionshttp://msdn2.microsoft.com/en-us/library/ms789908.aspxMicrosoft defines a top-level collection as a HID collection that is not nested within another collection. An unnested collection is always a top-level collection, regardless of its HID type. In particular, a top-level collection does not have to be an Application collection, as defined by the USB HID standard.A report descriptor can include more than one top-level collection. The HID class driver enumerates the top-level collections of an input device and creates a physical device object (PDO) for each top-level collection. User-mode applications or kernel-mode drivers can access a top-level collection by opening its PDO and using the HIDClass support routines and the HID class driver IOCTLs.
Microsoft defines a top-level collection as a HID collection that is not nested within another collection. An unnested collection is always a top-level collection, regardless of its HID type. In particular, a top-level collection does not have to be an Application collection, as defined by the USB HID standard.
A report descriptor can include more than one top-level collection. The HID class driver enumerates the top-level collections of an input device and creates a physical device object (PDO) for each top-level collection. User-mode applications or kernel-mode drivers can access a top-level collection by opening its PDO and using the HIDClass support routines and the HID class driver IOCTLs.
So, I tried it implementing the above Report-descriptor which is written by Mr. Tsuneo.
ReportID #1 = keyboard.ReportID #2 = Mouse.
For keyboard, I can received two byte data vir EP0 OUT. ReportID=0x01 and 8bit of keyboard LED(combination of NumLock, ScrLock and so on).
Now where, I'd like to send key code(ex. key 'A' is 0x04) to PC.So I prepared 8 bytes data - 1 byte modifier keys, 1 byte reserved 0x00, 6 bytes of key code(such as 0x04='A', 0x00, 0x00, 0x00, 0x00, 0x00) vir EP0 IN.
But, my PC can't receive anything...
I'd like to ask why this didn't work correctly.
Does the keyboard report ID needed to send key code to PC? In case of this, 1+8 bytes data transmittion is needed? (Report ID, Modifier keys, 0x00 reserved, 6 key code)??
If any specification or source code sample are available, could you please tell me?
[This message has been edited by Umetsu (edited March 26, 2009).]
I don't need other functions like storage.
Tsuneo, your post is most helpful. However, I have a problem with one area in your keyboard descriptor section. You listed a "Usage Maximum (101)". When I use the HID Descriptor Tool and open its keybrd.hid example, the USAGE_MAXIMUM has predefined values (like Keyboard RightAlt, etc.), none of which will allow me the value of 101.
Did you mean to put 101 in the Logical Maximum? The HID Descriptor Tool's default value for Logical Maximum was 101, which seems to be the number of keys.
101 is in decimal. Choose this keycode,0x65 Keyboard Application
However, my data buffers now are not sent to the host PC. None of my mouse and keyboard inputs seem to get sent to the host. I assume there is some collision happening.
Check the USB traffic using a hardware analyzer or software sniffer.There are two possibility,
a) The device doesn't return any packet for interrupt IN transaction- NAKing or timeout error
b) The device returns packets, but HID device driver drops them on the PC.
a) means- The interrupt IN endpoint is not enabled on the firmwareOR- The packet is not actually loaded to the endpoint
b) means the format of the input reports is wrong.For above report descriptor with multiple TLCs (Top-Level Collections), the input report format is as follows
For keyboard,
offset (byte) 0 report ID (01) 1 modifier keys 2 padding 3 - 8 keycode array
For mouse,
offset (byte) 0 report ID (02) 1 buttons 2 X asis 3 Y axis
Software sniffersSniffUSB (Open source)http://www.pcausa.com/Utilities/UsbSnoop/default.htm
Usblyzer (commercial with free trial)http://www.usblyzer.com/ etc.
> I am working with Freescale's JS16.
Then, continue on Freescale forum - 8-Bit Microcontrollers, if any.http://forums.freescale.com/t5/8-Bit-Microcontrollers/bd-p/8BITCOMMI have account on the Freescale forum, too, though I'm not active on the forum.
DEMO9S08JS16 - hybrid USB peripheral?http://forums.freescale.com/t5/8-Bit-Microcontrollers/DEMO9S08JS16-hybrid-USB-peripheral/td-p/53244
[This message has been edited by Tsuneo (edited April 22, 2010).]
Have you seen our MCU Knowledge Base? Ultimate Bulletin Board Version 5.47b
Ultimate Bulletin Board Version 5.47b