|
![]() USB
![]() multiple HID and one MSD on a -340
|
| next newest topic | next oldest topic |
| Author | Topic: multiple HID and one MSD on a -340 |
|
clauswk New Member |
Greetings, 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 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 have trawled through all kind of application notes and the USB bibles with no luck. Thanks ------------------ IP: Logged |
|
Tsuneo Member |
"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. The reasons are, 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 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 On 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. Usage Page (Generic Desktop), Tsuneo [This message has been edited by Tsuneo (edited January 24, 2008).] IP: Logged |
|
Patryk Member |
Tsuneo: "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(). IP: Logged |
|
clauswk New Member |
Thank 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, ------------------ IP: Logged |
|
Tsuneo Member |
This topic on MSDN shows the way how Windows handle the combined report descriptor for keyboard and mouse. Top-Level Collections Tsuneo IP: Logged |
|
Umetsu New Member |
I'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. 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. 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?
[This message has been edited by Umetsu (edited March 26, 2009).] IP: Logged |
|
ElectroLund New Member |
Sorry 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. IP: Logged |
|
Tsuneo Member |
> none of which will allow me the value of 101. 101 is in decimal. Choose this keycode, Tsuneo IP: Logged |
|
ElectroLund New Member |
Tsuneo, 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.
IP: Logged |
|
Tsuneo Member |
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. Check the USB traffic using a hardware analyzer or software sniffer. a) The device doesn't return any packet for interrupt IN transaction b) The device returns packets, but HID device driver drops them on the PC. a) means b) means the format of the input reports is wrong. For keyboard, offset (byte) For mouse, offset (byte)
Usblyzer (commercial with free trial) > I am working with Freescale's JS16. Then, continue on Freescale forum - 8-Bit Microcontrollers, if any. Tsuneo IP: Logged |
|
Tsuneo Member |
This discussion with ElectroLund (irob) continues to this topic on Freescale forum, DEMO9S08JS16 - hybrid USB peripheral? Tsuneo [This message has been edited by Tsuneo (edited April 22, 2010).] IP: Logged |
All times are CT (US) | next newest topic | next oldest topic |
![]() |
|
Have you seen our MCU Knowledge Base?