|
|
View previous topic :: View next topic |
Author |
Message |
Will Reeve
Joined: 30 Oct 2003 Posts: 209 Location: Norfolk, England
|
USB HID Descriptor help! |
Posted: Tue Oct 19, 2004 6:28 am |
|
|
Hi all,
As there seems a lot of interest is USB on the forum recently I thought I would post my questions!
I decided to do my current USB project using the HID system and the CCS USB Dev Kit. I�ve used the FTDI system on another project but wanted to learn about USB and develop a �proper� USB device / application.
I guess this is directed to our self confessed USB guru Darren
Anyway:
Code: | const char USB_HID_DESC[] = {
6, 0, 255, // Usage Page = Vendor Defined
9, 1, // Usage = IO device
0xa1, 1, // Collection = Application
// The input report (PIC to the PC)
0x19, 1, // Usage minimum
0x29, 8, // Usage maximum
0x15, 0x80, // Logical minimum (-128)
0x25, 0x7F, // Logical maximum (127)
0x75, 8, // Report size = 8 (bits)
0x95, 13, // Report count = 16 bits (2 bytes)
0x81, 2, // Input (Data, Var, Abs)
// The output report (PC to the PIC)
0x19, 1, // Usage minimum
0x29, 8, // Usage maximum
0x15, 0x80, // Logical minimum (-128)
0x25, 0x7F, // Logical maximum (127)
0x75, 8, // Report size = 8 (bits)
0x95, 9, // Report count = 16 bits (2 bytes)
0x91, 2, // Output (Data, Var, Abs)
0xc0 // End Collection
}; |
I have modified the USB_HID_DESC[] for my application to send 13 and receive 9 bytes.
Code: | //endpoint descriptor
USB_DESC_ENDPOINT_LEN, //length of descriptor ==28
USB_DESC_ENDPOINT_TYPE, //constant ENDPOINT (ENDPOINT 0x05) ==29
0x81, //endpoint number and direction (0x81 = EP1 IN) ==30
0x03, //transfer type supported (0x03 is interrupt) ==31
// 0x08,0x00, //maximum packet size supported ==32,33
0x40,0x00, //maximum packet size supported ==32,33
10, //polling interval, in ms. (cant be smaller than 10) ==34
//endpoint descriptor
USB_DESC_ENDPOINT_LEN, //length of descriptor ==35
USB_DESC_ENDPOINT_TYPE, //constant ENDPOINT (ENDPOINT 0x05) ==36
0x01, //endpoint number and direction (0x01 = EP1 OUT) ==37
0x03, //transfer type supported (0x03 is interrupt) ==38
// 0x08,0x00, //maximum packet size supported ==39,40
0x40,0x00, //maximum packet size supported ==39,40
10 //polling interval, in ms. (cant be smaller than 10) ==41
}; |
I have changed the endpoint descriptor to support 64 bytes in either direction but left the polling interval to 10ms. Is this allowed? It seems to work OK.
I refer to the comments at the beginning of the file:
Code: | //// - On slow speed devices the max packet size is 8. ////
//// On a full speed device the max packet size is 64. |
Question 1:I can�t see where you set the device speed in the config descriptor.
Question 2: Can someone explain what the Usage minimum and Usage Maximum fields in the hid descriptor mean?
I am using the excellent book �USB Complete� and it just says they are �Vendor specific!�
Keep well all,
Will |
|
|
Darren Rook
Joined: 06 Sep 2003 Posts: 287 Location: Milwaukee, WI
|
|
Posted: Tue Oct 19, 2004 8:14 am |
|
|
Well I haven't looked at USB in a while (6 months, maybe) but I can offer some insights.
Quote: | Question 1:I can�t see where you set the device speed in the config descriptor. |
You can't. If you're talking about the difference between the 1.5Mb/s, 12Mb/s and 480Mb/s this isn't set in the descriptor. This is set by changing the pullup resistors on the D+ and D- lines. The USB Kit CCS sells with the national part has the pull-up resistors for 12Mb/s.
What you can do is change the polling rate. You can set your polling rate to 1. 10 is the minimum for slow speed (1.5Mb/s) which is what the PIC16C7x5 uses, which is what I was using when I initially wrote that USB code. That's why it says 10 is the minimum, but if you are using the new PIC18 USB parts or the National USB parts you can use less than 10.
Quote: | Question 2: Can someone explain what the Usage minimum and Usage Maximum fields in the hid descriptor mean? |
I can't remember. I'm pretty sure they are dependent on the usage page being used. If you are using your own vendor specific page then you should be able to ignore it. |
|
|
Guest
|
Re: USB HID Descriptor help! |
Posted: Tue Oct 19, 2004 3:02 pm |
|
|
Will Reeve wrote: | Hi all,
I�ve used the FTDI system on another project but wanted to learn about USB and develop a �proper� USB device / application. |
So what's not "proper" about the FTDI !
I did a few projects with Cypress parts, wnet through all the BS including device driver for Win2K and then moved onto FTDI.... It's USB 1.1 and as "proper" as it gets, and without the BS baggage.
If you are concerned about speed, HID is a dead end ... |
|
|
Darren Rook
Joined: 06 Sep 2003 Posts: 287 Location: Milwaukee, WI
|
|
Posted: Tue Oct 19, 2004 4:08 pm |
|
|
"proper" would be a USB mouse, keyboard, joystick, point-of-sale device or mass storage device.
Oops, FTDI can't do those things. |
|
|
Will Reeve
Joined: 30 Oct 2003 Posts: 209 Location: Norfolk, England
|
|
Posted: Wed Oct 20, 2004 7:49 am |
|
|
Maybe it�s me but there is something a bit clunky about using the FTDI chip. It emulates a serial port at both ends. I�ve used one along with a Bluetooth equivalent and it does work OK. But you might as well just fit a 9pinD on the end and use one of those serial to USB cables you can buy! In fact I am ashamed to say (although it wasn�t my decision) this is exactly what happened to that product as the customer didn�t want three different versions (serial, USB, or Bluetooth) so he saved by just having serial and Bluetooth and used a USB to serial cable to support USB!
I would have finished this job by now if I had used a FTDI chip and it had crossed my mind to switch as I have to admit it�s taken me a while to get by head around some of these descriptors and end ports but I�ve not got a reliable 2 way communication going with the USB development kit, 13 bytes in one direction and 9 in the other. My only niggle is the USBN9603 is a little power hungry at 40mA, shame you can�t power it from a PIC pin. I will experiment in powering it from the USB bus.
Will |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1635 Location: Perth, Australia
|
|
Posted: Wed Oct 20, 2004 8:10 am |
|
|
Quote: | Maybe it�s me but there is something a bit clunky about using the FTDI chip. It emulates a serial port at both ends. |
THe FTDI232 emulates a 232 port at both ends but the FTDI245 presents a parallel byte wide interface at the USB end. The USB end does not know anything about RS232.[/quote] |
|
|
Guest
|
|
Posted: Wed Oct 20, 2004 1:46 pm |
|
|
Will Reeve wrote: | Maybe it�s me but there is something a bit clunky about using the FTDI chip. Will |
Will,
It's you.... :-)
FTDI 245 chips is a parallel version that does not emulate RS-232 at all. It can do 1 Mega-BYTE per second transfer rate.
I use it for a product as a means to trasnfer data to the PC and the USB installation comes up with my clients product name and it also has it own ID (issued free by FTDI) there is NOTHING RS-232 about it. NO virtual COM ports on the PC.
When the XP program starts it checks to see if the device is out there, and complains if it is not, then informs the user to either plug in the USB cable or switch on the device.
For the unit where I'm using the FT-245 the data rate is 12 bit sampled at 50K samples per second, that�s 100,000 bytes per second (slow for this chip) for the data, and some extra bytes for GPS and house keeping.
The whole interface is as USB as it can get, nothing clunky or strange about it.
For most implementations Bluetooth replaces the serial cable, and most BT modules do just that.
Even if your BT is using a network connection, it's STILL SERIAL data. i.e. Bluetooth is a serial device nothing more and nothing less.
If at your end of the BT implemenatation it exposes the connection to be RS-232 then it your issue.
Either way the bytes get transferred one byte at a time..... i.e. serial.
Hans Wedemeyer
Ex. Norwich, Norfolk. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|