This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

STM32F4 USB Host HID application

“We are trying to develop a USB Host HID application where using the controller STM32F4, and the USB stack library available on the ST website, we are trying to send data/command to an USB HID device. But in the library we downloaded from ST site, the host HID application has examples for mouse and keyboard application only.In case of Mouse and keyboard, Host receives but does not transmit back anything while in our application we need to also transmit data.

So do you have any particular HID host example codes or guideline documents for STM32F4xx controller which demonstrates how to transmit the data to the attached external USB device using the ST USB library? “,

Parents
  • Maybe, he is developing it on Keil ;-)

    > we need to also transmit data

    Based on STM32_USB-Host-Device_Lib_V2.1.0
    www.st.com/.../PF257882

    In usbh_hid_core.c,

    1) USBH_HID_InterfaceInit()
    This function is called by the stack, after enumeration, to identify the target device. The original routine examines Interface subclass and protocol for boot keyboard/mouse. For generic HID, check VID/PID of the target, instead. VID/PID on the device descriptor is already read out by the stack at this call.

    VID: pphost->device_prop.Dev_Desc.idVendor
    PID: pphost->device_prop.Dev_Desc.idProduct

    If VID/PID doesn't match, this routine returns USBH_BUSY (ie. other than USBH_OK)

    This original code also traverses endpoint descriptors. It opens the channel (pipe) for the interrupt OUT EP on HID_Machine.hc_num_out channel.

    To send to the interrupt OUT EP,
    2) USBH_HID_Handle()
    In a new state of state machine,
    - Put data to HID_Machine.buff, and write its size to HID_Machine.length
    - Call USBH_InterruptSendData(pdev, HID_Machine.buff, HID_Machine.length, HID_Machine.hc_num_out);

    At the next state,
    Poll the return value of HCD_GetURB_State(pdev , HID_Machine.hc_num_out). When the transfer finishes, HCD_GetURB_State() returns URB_DONE

    To send Output/Feature report over the default EP,
    2') USBH_HID_Handle()
    Put data to HID_Machine.buff, and call USBH_Set_Report() repeatedly, while it returns USBH_BUSY.
    when finishes, it returns USBH_OK / USBH_FAIL / USBH_NOT_SUPPORTED (got STALL from device)

    Tsuneo

Reply
  • Maybe, he is developing it on Keil ;-)

    > we need to also transmit data

    Based on STM32_USB-Host-Device_Lib_V2.1.0
    www.st.com/.../PF257882

    In usbh_hid_core.c,

    1) USBH_HID_InterfaceInit()
    This function is called by the stack, after enumeration, to identify the target device. The original routine examines Interface subclass and protocol for boot keyboard/mouse. For generic HID, check VID/PID of the target, instead. VID/PID on the device descriptor is already read out by the stack at this call.

    VID: pphost->device_prop.Dev_Desc.idVendor
    PID: pphost->device_prop.Dev_Desc.idProduct

    If VID/PID doesn't match, this routine returns USBH_BUSY (ie. other than USBH_OK)

    This original code also traverses endpoint descriptors. It opens the channel (pipe) for the interrupt OUT EP on HID_Machine.hc_num_out channel.

    To send to the interrupt OUT EP,
    2) USBH_HID_Handle()
    In a new state of state machine,
    - Put data to HID_Machine.buff, and write its size to HID_Machine.length
    - Call USBH_InterruptSendData(pdev, HID_Machine.buff, HID_Machine.length, HID_Machine.hc_num_out);

    At the next state,
    Poll the return value of HCD_GetURB_State(pdev , HID_Machine.hc_num_out). When the transfer finishes, HCD_GetURB_State() returns URB_DONE

    To send Output/Feature report over the default EP,
    2') USBH_HID_Handle()
    Put data to HID_Machine.buff, and call USBH_Set_Report() repeatedly, while it returns USBH_BUSY.
    when finishes, it returns USBH_OK / USBH_FAIL / USBH_NOT_SUPPORTED (got STALL from device)

    Tsuneo

Children