AnsweredAssumed Answered

usb host

Question asked by mazarei.mohammad on Feb 26, 2017
Latest reply on Jun 21, 2018 by pokorny.igor.001

Hi Everyone,
I'm trying to read from the USB keyboard with  a custom board STM32F205RCT6 MCU.

I am using USB FS host (host only) with HAL library.but  it just works with some keyboards!

Other keyboards are detected by host but can not read data.
Can any one help me?

My Code:

int main(void)
  /* STM32F4xx HAL library initialization:
       - Configure the Flash prefetch, instruction and Data caches
       - Configure the Systick to generate an interrupt each 1 msec
       - Set NVIC Group Priority to 4
       - Global MSP (MCU Support Package) initialization

  /* Configure the system clock to 120 MHz */

/* Init Host Library */
  USBH_Init(&hUSBHost, USBH_UserProcess, 0);
  /* Add Supported Class */
  USBH_RegisterClass(&hUSBHost, USBH_HID_CLASS);
  /* Start Host Process */
  /* Run Application (Blocking mode) */
  while (1)
    /* USB Host Background task */
      if(USBH_HID_GetDeviceType(&hUSBHost) == HID_KEYBOARD)

        hid_demo.keyboard_state = HID_KEYBOARD_IDLE;
        hid_demo.state = HID_DEMO_KEYBOARD;
                    HID_KEYBD_Info_TypeDef *k_pinfo;
                    char c;
                    k_pinfo = USBH_HID_GetKeybdInfo(&hUSBHost);
                    if(k_pinfo != NULL)
                         c = USBH_HID_GetASCIICode(k_pinfo);
                         char str[5];


Result (only detected Not read data)

USB Device Attached
PID: 1h
VID: 258ah
Address (#1) assigned.
Manufacturer : SINO WEALTH
Serial Number : N/A
Enumeration done.
This device has only 1 configuration.
Default configuration set.
Switching to Interface (#0)
Class    : 3h
SubClass : 1h
Protocol : 1h
KeyBoard device found!
HID class started.