USB HID driver

Discussions and support about ChibiOS/HAL, the MCU Hardware Abstraction Layer.
Post Reply
e_l_tang
Posts: 33
Joined: Sun Jul 03, 2016 7:58 pm
Been thanked: 2 times

USB HID driver

Post by e_l_tang »

Does the HAL include a USB HID driver, and if so would it be possible to use it simultaneously with the Serial over USB driver? Here is my other post with more context.
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: USB HID driver

Post by Giovanni »

Hi,

Search the forum, several HID examples have been posted. Probably HID is too "generic" for a specific driver like we have for CDC.

Giovanni
e_l_tang
Posts: 33
Joined: Sun Jul 03, 2016 7:58 pm
Been thanked: 2 times

Re: USB HID driver

Post by e_l_tang »

I found a few examples of projects which implement a HID device, but none which implement both a HID device and a CDC device. Do you know of one?
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: USB HID driver

Post by Giovanni »

Hi,

You need to implement a "IAD" device, there are IAD examples with 2 CDC but none with HID. The effort is into creating the descriptors, you may try to use the descriptors of some existing device then modify them.

Giovanni
e_l_tang
Posts: 33
Joined: Sun Jul 03, 2016 7:58 pm
Been thanked: 2 times

Re: USB HID driver

Post by e_l_tang »

So I can't use the existing Serial over USB driver? Actually I already have working descriptors in my project, and it's integrating them with ChibiOS that I can't figure out how to do. I'm not sure how to make both HID and CDC work at the same time without them interfering with each other.
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: USB HID driver

Post by Giovanni »

Hi,

You can use the driver, it is just matter of descriptors. Make HID and CDC use different endpoints and map the CDC endpoints in the serial driver.

It is better if you start from the CDC-IAD demo.

Giovanni
e_l_tang
Posts: 33
Joined: Sun Jul 03, 2016 7:58 pm
Been thanked: 2 times

Re: USB HID driver

Post by e_l_tang »

I've found a few projects which implement a HID device using ChibiOS, but they vary wildly in how they do it and I've managed to confuse myself more by looking at them. Are you sure that there can't be a dedicated HID driver in ChibiOS? The library I'm currently using has both a HID driver and a CDC driver, and I can post some code from my project to show how they are used.
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: USB HID driver

Post by Giovanni »

You wrote it yourselves, HID "varies wildly" so you would make a series of HID drivers for various scenarios rather than a single driver.

An HID application just requires descriptors and the normal USB API.

Giovanni
e_l_tang
Posts: 33
Joined: Sun Jul 03, 2016 7:58 pm
Been thanked: 2 times

Re: USB HID driver

Post by e_l_tang »

As far as I know, the library I'm using only has one HID driver. So far I have not noticed any limitations to this approach. I may be wrong, of course, so I have posted my code here in case you want to check if my understanding is correct.
Post Reply