cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F072 USB HID related question

alexygoncharov
Associate II
Posted on January 02, 2015 at 10:44

Dear all,

I'm working on a STM32F072-based device that needs to exchange data with PC in both directions. I chose the USB HID, because of data volumes are really not impressive and there is no need to install additional drivers. From the PC side the libusb has been used to interact with the device.

The device has 2 interrupt endpoints: IN and OUT. Data transfer to PC is implemented with USBD_HID_SendReport . But I can't figure out,

how to receive the data from PC

. HID-related examples that come with the STM32F0x2_USB-FS-Device_Lib demonstrate only IN transfer. So.. could you please share some demo code or link where this question/issue can become unveiled.

Thank you!

#hid #usb #stm32f0
3 REPLIES 3
alexygoncharov
Associate II
Posted on January 02, 2015 at 15:07

Comparing the STM32F0 USB FS library with the same for STM32F4 I've figured out that there is no USBD_HID_DataOut method implemented for STM32F0. I guess it should be declared in:

STM32F0x2_USB-FS-Device_Lib V1.0.0/Libraries/STM32_USB_Device_Library/Class/hid/inc/usbd_hid_core.h

Does anybody have an implementation of this and all relevant methods? Or there is another way to receive data from PC in STM32F0 USB FS lib?

tsuneo
Senior
Posted on January 02, 2015 at 19:06

STM32F0x2_USB-FS-Device_Lib V1.0.0 (STSW-STM32092) has three HID examples,

a) Custom_HID

b) HID

c) HID_LPM_test

a) Custom_HID implements HID interrupt OUT endpoint, and USBD_HID_DataOut() subroutine in usbd_custom_hid_core.c

But b) and c) examples, based on usbd_hid_core.c, have neither any interrupt OUT EP nor USBD_HID_DataOut()

And then, start on Custom_HID example.

> I chose the USB HID, ... From the PC side the libusb has been used to interact with the device.

As libusb is a generic driver, you may chose ANY USB class.

But surely, as ST doesn’t provide ''bulk'' example, HID device example would be simpler one

While you are assigning libusb, the HID report descriptor doesn’t make sense at all.

You don’t need to worry about the report descriptor.

Tsuneo

alexygoncharov
Associate II
Posted on January 03, 2015 at 10:08

> And then, start on Custom_HID example.

You're definitely right. Files which I was asking for were actually close...:

STM32F0x2_USB-FS-Device_Lib V1.0.0/Libraries/STM32_USB_Device_Library/Class/hid/src/usbd_custom_hid_core.c

STM32F0x2_USB-FS-Device_Lib V1.0.0/Libraries/STM32_USB_Device_Library/Class/hid/inc/usbd_custom_hid_core.h

Thank you, Tsuneo!