cancel
Showing results for 
Search instead for 
Did you mean: 

Setup Custom HID device

juliuscaesar
Associate III
Posted on February 27, 2017 at 23:01

Hey guys.

I'm trying to setup Custom HID. I'd like to use an output- and input Buffer.

I have managed to setup the descriptors. I think i have done that right: Windows is correct enumerating my device.

On the other side I got a C# HID API. The Initialisation works, the HID descriptors are successfully exchanged (Output Buffer Size, Input Buffer Size are correctly recognised).

However when I try to send to send/receive message the sending/receiving fails.

in the usbd_custom_hid.c the is an USBD_ClassTypeDef  USBD_CUSTOM_HID which contains pointer to serveral functions

USBD_ClassTypeDef  USBD_CUSTOM_HID =

{

  USBD_CUSTOM_HID_Init,

  USBD_CUSTOM_HID_DeInit,

  USBD_CUSTOM_HID_Setup,

  NULL, /*EP0_TxSent*/  

  USBD_CUSTOM_HID_EP0_RxReady, /*EP0_RxReady*/ /* STATUS STAGE IN */

  USBD_CUSTOM_HID_DataIn, /*DataIn*/

  USBD_CUSTOM_HID_DataOut,

  NULL, /*SOF */

  NULL,

  NULL,      

  USBD_CUSTOM_HID_GetCfgDesc,

  USBD_CUSTOM_HID_GetCfgDesc,

  USBD_CUSTOM_HID_GetCfgDesc,

  USBD_CUSTOM_HID_GetDeviceQualifierDesc,

};

However these functions are never called. I tried calling the USBD_CUSTOM_HID_Init function manually but this did not solve the problem.

Could you help me out what to do with this ClassTypedef?

greets Julian

8 REPLIES 8
fb2
Associate II
Posted on May 26, 2017 at 18:07

Hello Julian, I'm facing the same issue, did you make it work?

Thank you!

Fernando

Posted on May 27, 2017 at 11:45

 ,

 ,

hey,

yep i did cost me some time to figure it out, but after searching on the internet for some time i found a really helpful tutorial

https://www.youtube.com/watch?v=xufZyQf4O7Y

 ,

i configured the Custom HID driver exactly the same as the guy in the video and it worked

To verfiy that the driver works, i tested some C ♯ Hid libraries. I think it was simplehid and mightyhid. Turned out that both of them worked with my disco board. Hope that helps

Posted on May 29, 2017 at 10:04

Hi

Blaha.Fernando

,

To have more insight into the USB HID, you can review the USB libraries and start from the

USB HID

example of the STM32Cube firmware package relevant to the device that you are using.

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Posted on May 29, 2017 at 13:51

Thank you Julian! I will follow your advice with this tutorial, surelly it will be helpfull.

Thank you again!

Fernando

fb2
Associate II
Posted on May 29, 2017 at 13:52

Thank you Imen, that's what I did, but found the limitation that the library is not prepared yet to receive data, only transmit with HID.

I need bidirectional communication.

Thank you!

Fernando

Posted on May 29, 2017 at 22:03

the report descriptor in the STM Cube example is for a keyboard. That's why you can only send data. A keyboard does not need to receive data. In windows device manager your HID device will appear as keyboard.

I had the same problem: My communication needed to be both ways as well, that's why I used the report descriptor (shown in the youtube video) for a CUSTOM Hid device. Windows recognises the custom hid device properly as 'Custom HID Device'

FYI: in HID protocol (HID and Custom HID) you can only transfer max 64 bytes per interrupt since the HID protocol was originally developed for input devices which needed to respond fast. This site is really helpful for understanding the basics of USB. 

http://www.beyondlogic.org/usbnutshell/usb1.shtml

Posted on May 30, 2017 at 13:45

Hi! 

I've already worked with HID, but only with Microchip microcontrollers, and the library already was quite finished. Now with ST I'm facing this issues, that needs to get a little more involved with USB to finish the full functionallity.

I'm working on it, I'll let you know

Thank you very much Julian for your help!

Fernando

fb2
Associate II
Posted on June 15, 2017 at 20:32

It worked

Thank you very much! You really helped me.

Fernando