I'm trying to drive USB host as MSC and HID on STM32F4, I have one STM32F407 Discovery board and one custom design PCB based on STM32F407.

I'm using Keil compiler and ST std periph library, and for USB using STM32_USB-Host-Device_Lib_V2.1.0 (and V2.2.0). For MSC part after some tries it worked and know I can read and write data on USB flash. But for HID it doesn't work correctly. I've tested many projects on both boards with many HID devices (mouse, kbd, barcode scanner, ...), in all cases the board detects device attachment and its speed, but it doesn't proceed more. Actually it remains in HOST_CTRL_XFER state and doesn't complete the enumeration phase (I found this in debug mode, the MCU works but it loops in some functions).

As the ST document says it's an intermediate stage that should be passed:

ST Doc

But for me it doesn't pass successfully.


I think I have problem with descriptor configuration for HID device, I don't know how I can edit the descriptor to pass successfully from enumeration phase.

  • \$\begingroup\$ Have you sniffed the handshake on PC side? The OS driver can halt the device if it doesn't respond accordingly to the OS driver. \$\endgroup\$ – Marko Buršič Aug 7 '17 at 7:20
  • 1
    \$\begingroup\$ @MarkoBuršič I don't have PC side, I have a MCU board as USB host for USB flash and HID device. \$\endgroup\$ – electro Aug 7 '17 at 7:31
  • \$\begingroup\$ I needed to make some modifications to st library to make it work in the file usbh_hid.c for example. Dont know if they are correct, but it works for me at least. Code comes here: switch (HID_Handle->state) <br> { <br> case HID_INIT: <br> HID_Handle->Init(phost); <br> HID_Handle->state = HID_SYNC; /* modification / <br> break; / modification */ <br> case HID_IDLE: <br> \$\endgroup\$ – staringlizard Aug 17 '17 at 14:18
  • 3
    \$\begingroup\$ I'm voting to close this question as off-topic because it fails to provide code to demonstrate the problem or state the issue with sufficient accuracy for help to meaningfully be provided. Likely your best approach would be to find a fully working HID host example and learn from that - look to things like Discovery board examples, 3rd part examples, etc. \$\endgroup\$ – Chris Stratton Aug 19 '17 at 20:33
  • \$\begingroup\$ @staringlizard, Thanks, but I can't understand your code and modifications, my library doesn't have file named "usbh_hid.c". Also my problem is before reaching that stage and it's in enumeration stage. \$\endgroup\$ – electro Aug 28 '17 at 13:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.