PDA

View Full Version : USB CDC + HID + IAD interface



bidouille
11th October 2011, 21:16
Well, Let me introduce myself. I'm at least 40, I have a big interest in Mechatronics robotics everything related to mechanics and electronics.
Ihave registered 2 days ago as a licensed user.
I would like first say a great hello to my big captainslarry!:pig:
I have followed long post with USB and HID. It was really nice to follow your story. Sorry for the others but joesaliba, don't be frustrated you did also very good hints :D
Now I have made a lot of efforts in understanding descriptor for USB. I have done some experiment with 18F4550 + proton 3.5.0.6. and 3.5.2.6.
My computer is equiped with XP SP3.

Now the issues :
I have tried HID wich is working. I have tried CDC wich is working.
I have made my own descriptor (grabbed a lot informations on the web, understood well and followed).
The point is the descriptor is recognized, HID is OK, CDC is OK + inf file. Everything is pointed out correctly in windows device manager. But I can't open hyperteminal communication. I always get the message "can't open the serial port, check parameters".
Has anybody been experienced with HID and CDC, and /or IAD descriptor ? Enclosed are the files descriptor (wich is not IAD but working!! found on the web with an other language assembler), the inf file from proton, changed to adress the interface MI_00 and the short Bas file issued from the proton example.
I have forgotten to tell that I have the bootloader for Captain installed on the PIC.
************************************************** ************************************************** ****************
Hints for the developper and Lester : I have read on Microchip www that there could be some errors in the adress of endpoint if using HID + CDC.
see here : http://www.microchip.com/forums/m573792.aspx post #3
Could it be my solution ?
************************************************** ************************************************** ****************

ElektroArt
12th October 2011, 15:12
Hi bidouille,

Thank you for your project.


The descriptor belove, generated from MCP2200 device board. MCP2200 is programmed PIC18F14k50. And it look like composite device(IAD, HID +CDC). I have test it by pickit2 programmer.

I know Windows xp sp3 or higher versions needed for IAD devices.

Anyway, I need smilar descriptor and working PDS project . This descriptor may useful or not. I'm not sure.




USB Composite Device





Connection Status

Device connected



Current Configuration

1



Speed

Full



Device Address

1



Number Of Open Pipes

5







Device Descriptor MCP2200 USB Serial Port Emulator





bLength

1

12h




1

bDescriptorType

1

01h

Device



2

bcdUSB

2

0200h

USB Spec 2.0



4

bDeviceClass

1

EFh

Miscellaneous



5

bDeviceSubClass

1

02h

Common Class



6

bDeviceProtocol

1

01h

Interface Association Descriptor



7

bMaxPacketSize0

1

08h

8 bytes



8

idVendor

2

04D8h

Microchip Technology, Inc.



10

idProduct

2

00DFh




12

bcdDevice

2

0101h

1.01



14

iManufacturer

1

01h

"Microchip Technology Inc."



15

iProduct

1

02h

"MCP2200 USB Serial Port Emulator"



16

iSerialNumber

1

03h

"0000133170"



17

bNumConfigurations

1

01h








Configuration Descriptor 1 Bus Powered, 100 mA





bLength

1

09h




1

bDescriptorType

1

02h

Configuration



2

wTotalLength

2

006Bh




4

bNumInterfaces

1

03h




5

bConfigurationValue

1

01h




6

iConfiguration

1

00h




7

bmAttributes

1

80h

Bus Powered




4..0: Reserved


...00000





5: Remote Wakeup


..0.....

No




6: Self Powered


.0......

No, Bus Powered




7: Reserved (set to one)
(bus-powered for 1.0)


1.......




8

bMaxPower

1

32h

100 mA







Interface Association Descriptor Abstract Control Model





bLength

1

08h




1

bDescriptorType

1

0Bh

Interface Association



2

bFirstInterface

1

00h




3

bInterfaceCount

1

02h




4

bFunctionClass

1

02h

CDC Control



5

bFunctionSubClass

1

02h

Abstract Control Model



6

bFunctionProtocol

1

01h

AT Commands: V.250 etc



7

iFunction

1

00h








Interface Descriptor 0/0 CDC Control, 1 Endpoint





bLength

1

09h




1

bDescriptorType

1

04h

Interface



2

bInterfaceNumber

1

00h




3

bAlternateSetting

1

00h




4

bNumEndpoints

1

01h




5

bInterfaceClass

1

02h

CDC Control



6

bInterfaceSubClass

1

02h

Abstract Control Model



7

bInterfaceProtocol

1

01h

AT Commands: V.250 etc



8

iInterface

1

00h








Header Functional Descriptor





bFunctionLength

1

05h




1

bDescriptorType

1

24h

CS Interface



2

bDescriptorSubtype

1

00h

Header



3

bcdCDC

2

0110h

1.10







Abstract Control Management Functional Descriptor





bFunctionLength

1

04h




1

bDescriptorType

1

24h

CS Interface



2

bDescriptorSubtype

1

02h

Abstract Control Management



3

bmCapabilities

1

06h





7..4: Reserved


0000....





3: Connection


....0...





2: Send Break


.....1..

Send Break request supported




1: Line Coding


......1.

Line Coding requests and Serial State notification supported




0: Comm Features


.......0








Union Functional Descriptor





bFunctionLength

1

05h




1

bDescriptorType

1

24h

CS Interface



2

bDescriptorSubtype

1

06h

Union



3

bControlInterface

1

00h




4

bSubordinateInterface0

1

01h

CDC Data







Call Management Functional Descriptor





bFunctionLength

1

05h




1

bDescriptorType

1

24h

CS Interface



2

bDescriptorSubtype

1

01h

Call Management



3

bmCapabilities

1

00h





7..2: Reserved


000000..





1: Data Ifc Usage


......0.

Call management only over Comm Ifc




0: Call Management


.......0

Does not handle call management itself



4

bDataInterface

1

01h








Endpoint Descriptor 82 2 In, Interrupt, 2 ms





bLength

1

07h




1

bDescriptorType

1

05h

Endpoint



2

bEndpointAddress

1

82h

2 In



3

bmAttributes

1

03h

Interrupt




1..0: Transfer Type


......11

Interrupt




7..2: Reserved


000000..




4

wMaxPacketSize

2

0008h

8 bytes



6

bInterval

1

02h

2 ms








Interface Descriptor 1/0 CDC Data, 2 Endpoints





bLength

1

09h




1

bDescriptorType

1

04h

Interface



2

bInterfaceNumber

1

01h




3

bAlternateSetting

1

00h




4

bNumEndpoints

1

02h




5

bInterfaceClass

1

0Ah

CDC Data



6

bInterfaceSubClass

1

00h




7

bInterfaceProtocol

1

00h




8

iInterface

1

00h








Endpoint Descriptor 03 3 Out, Bulk, 32 bytes





bLength

1

07h




1

bDescriptorType

1

05h

Endpoint



2

bEndpointAddress

1

03h

3 Out



3

bmAttributes

1

02h

Bulk




1..0: Transfer Type


......10

Bulk




7..2: Reserved


000000..




4

wMaxPacketSize

2

0020h

32 bytes



6

bInterval

1

00h








Endpoint Descriptor 83 3 In, Bulk, 64 bytes





bLength

1

07h




1

bDescriptorType

1

05h

Endpoint



2

bEndpointAddress

1

83h

3 In



3

bmAttributes

1

02h

Bulk




1..0: Transfer Type


......10

Bulk




7..2: Reserved


000000..




4

wMaxPacketSize

2

0040h

64 bytes



6

bInterval

1

00h











Interface Descriptor 2/0 HID, 2 Endpoints





bLength

1

09h




1

bDescriptorType

1

04h

Interface



2

bInterfaceNumber

1

02h




3

bAlternateSetting

1

00h




4

bNumEndpoints

1

02h




5

bInterfaceClass

1

03h

HID



6

bInterfaceSubClass

1

00h




7

bInterfaceProtocol

1

00h




8

iInterface

1

00h








HID Descriptor





bLength

1

09h




1

bDescriptorType

1

21h

HID



2

bcdHID

2

0111h

1.11



4

bCountryCode

1

00h




5

bNumDescriptors

1

01h




6

bDescriptorType

1

22h

Report



7

wDescriptorLength

2

001Dh

29 bytes







Endpoint Descriptor 81 1 In, Interrupt, 1 ms





bLength

1

07h




1

bDescriptorType

1

05h

Endpoint



2

bEndpointAddress

1

81h

1 In



3

bmAttributes

1

03h

Interrupt




1..0: Transfer Type


......11

Interrupt




7..2: Reserved


000000..




4

wMaxPacketSize

2

0010h

16 bytes



6

bInterval

1

01h

1 ms







Endpoint Descriptor 01 1 Out, Interrupt, 1 ms





bLength

1

07h




1

bDescriptorType

1

05h

Endpoint



2

bEndpointAddress

1

01h

1 Out



3

bmAttributes

1

03h

Interrupt




1..0: Transfer Type


......11

Interrupt




7..2: Reserved


000000..




4

wMaxPacketSize

2

0010h

16 bytes



6

bInterval

1

01h

1 ms









Interface 2 HID Report Descriptor Vendor-Defined 1




Usage Page (Vendor-Defined 1)

06 00 FF



Usage (Vendor-Defined 1)

09 01



Collection (Application)

A1 01



Usage Minimum (Vendor-Defined 1)

19 01



Usage Maximum (Vendor-Defined 16)

29 10



Logical Minimum (0)

15 00



Logical Maximum (255)

26 FF 00



Report Size (8)

75 08



Report Count (16)

95 10



Input (Data,Ary,Abs)

81 00



Usage Minimum (Vendor-Defined 1)

19 01



Usage Maximum (Vendor-Defined 16)

29 10



Output (Data,Ary,Abs,NWrp,Lin,Pref,NNul,NVol,Bit)

91 00



End Collection

C0

bidouille
12th October 2011, 16:58
Hello ElektroArt,
Thank you for this one I will give it a try and compare to mine.
Let you know durin this day.
Cheers.

bidouille
12th October 2011, 19:23
Elektroart : thank you I have tested with no success :sorrow:. Did you ever tried with PDS and if yes cuold you post an example.

@ anybody else : Any ideas ?

@Les and Developpers : do you think if it could be an issue in PDS; Is it possible to mix HID and CDC with PDS ?

ElektroArt
12th October 2011, 20:36
I think we can build IAD project bsed on Proton CDC example. Unfortunately I don't have enough deep macro and pds knowledge to do.

bidouille
13th October 2011, 17:32
Any ideas I'm still stucked
HELP Please !!!!! ??????

Kapitan
14th October 2011, 05:54
Hi Bidouille, thankyou for the kind comments. :)
If you look at the thread (Sorry it is so long) re USB Joystick, you may already have done ?, but this explains the long larning process I went through with HID.
I have never used HID and CDC together, I have used Hid in the Bootloader, and then loaded cdc, but once loaded the bootloader is not active so it is either one or the other, not together.
However, using HID, I have used multiple hid devices together. I think some of the joystick code has examples for multiple instances of joysticks for example in the same hid,
As with most projects like these, I tried to make as many notes and post as mcuh info as possible, but evn after a few months of not using it and moving on to different projects, it is so easy to forget 90% of what you were actually doing lol :) .
I will have a look back through my notes to see if I can find an example, I also think usb complete - the book - has an example of keyboard mouse combined hid, as does the microchip hid download though.
I just, unfortuantely have not got the time as I am working to a tight deadline on a project for early next week that must be finished,
Try the joystick hid, then the mouse hid, then a ketboard hid all as individual units, then try combining say mouse and joystick, mouse and keyboard etc.
I certainly had at one time 4 instances of full featured joysticks from a single 4550 all working on xp.
Again, sorry, I dont know of any way of combining cdc and hid.
Joe.

bidouille
14th October 2011, 07:13
Hi Captainslarty,

Thank you for your comments and support.
This is the long story in a few words : I have tried ALONE (one by one), Joystick (your example full max), I have tried keyboard, have tried mouse, modified my own HID descriptor to see If my understanding was the right one, have tested the CDC descriptor alone. Everything ALONE is working properly, smoothly, nicely... Well I was really proud and made a lot of steps due to you comments on this forum and some others.
:heart-borken:Unfortunatly as soon as I try to combined keyboard + mouse or Joystick+ keyboard then it fails. the device are well enumerated but with CDC i can't communicate.
If I mix 2 HID (keyboard + mouse) the second one is always in defect(error 10), if have change to mouse + keyboard ==> then the keyboard gets the error 10 and mouse is OK.

I can take away the CDC and Use one HID with 3 interfaces : to simulate Joystick (Digital IN+Dig out+analog In), one interface keyboard to simulate Macros key and a third interface to make my own protocol for settings the 2 others, then It will avoid CDC, wich is never easy. THe point is that I need to separate Joystick, keyboard and settings interface channels.

If you have any valuable example (However, using HID, I have used multiple hid devices together) that includes 2 HID interfaces, I would be very interested.

ElektroArt
14th October 2011, 07:43
IF 1 interface used but device as 2 device. (joystick and joystick) this is easy.
This is not composite device. but looks like 2 different device. you can do it by editing descriptor file. of course you will send data only via 1 endpoint.

But if 2 interface used, this is composite device. "HID composite device" very hard job. It is not possible by simple descriptor editing etc. But Hidmaker FS does it! unfortunately PDS not supported. Only pic18f2550 series available. I think Hidmaker FS author don't like PDS. But PicbasicPro Code generated.
http://www.tracesystemsinc.com/usb/composite-devices.html

bidouille
14th October 2011, 16:26
@elekroart : thank you for the advice, have got a look but for $500! they do not support PDS. I don't have such big money.
I'm sure that my descriptor are working properly as they are well identified wy Windows.

I just think that PDS itself is not able to handle multiple HID interfaces in the same descriptor.

Lester, JoeSaliba, developpers (...) any ideas, any hints ?
or should I go to buy something else ? I have looked over MikroE and they have example of HID+MSD+CDC do you think it can work better ?

bidouille
20th October 2011, 21:12
Hello,

Always the same issues even with 2 HID devices in a composite.
Has anybody never tred to do it ?

ElektroArt
20th October 2011, 21:31
I have tried Proton HID + Microphone composite device. Device ok by Windows. No error. But I couldnt send voice data due to my pic limitation. and of course there is not voice data in my pic. But microchip exapmle generates sample data as mic.

I think HID composite device, "working" PDS example code, cost about least 1000 usd ! and not achieved yet!

Why you need HID composite device?

Midi descriptor may be modified as composite or custom devices but not HID
http://www.protonbasic.co.uk/showthread.php/54010-USB-Midi-Class-Streaming?p=439519&highlight=midi#post439519

Could you send mikrobasic HID +CDC+ MSD EXAPMLE ? where can I download it?

bidouille
22nd October 2011, 17:48
Hello Elekroart,
Follow this link: http://www.rosseeld.be/DRO/PIC/
You have tons of example. unfortunatly in Mikropascal, but can be translate to Mikrobasic. It's just a matter of time.
Then you need to buy MikroB or MikroP wich is not so expensive($200).