USB Component  Version 6.13.6
MDK Middleware for USB Device and Host Communication
 All Data Structures Functions Variables Enumerations Enumerator Groups Pages
USB Device HID

The Human Interface Device (HID) example shows simple data exchange between the USB Device and an USB Host Computer. The examples accesses the board LEDs and push buttons from the USB Host Computer using the HID client program. The following picture shows an exemplary connection of the development board and the USB Host Computer.

hid_example_setup.png

The Abstract.txt file contained in the Documentation group of the Project window gives you more information on the general setup and the available I/O of the development board.

Build the "USB Device HID" Project

Open the example project in MDK. The ┬ÁVision Project window should display a similar project structure:

usb_hid_example_proj_window.png
Typical Project Structure of an USB HID Example

Source Files

  • HID.c contains the main C function that initializes the board hardware and the USB Device Component. It also sends the current input status (typical buttons) via USBD_HID_GetReportTrigger to the USB Host.
  • The USBD_User_HID_0.c is an adapted code template that implements all necessary functions I/O communication. Refer to HID: Human Interface Class for details about these template functions.

If you are using RTOS other than CMSIS-RTOS2 RTX5 for your project please make sure to satisfy USB Device Resource Requirements.

You may now build and download the example project to the evaluation board using the ┬ÁVision commands:

  • Project –> Build target (F7)
  • Flash   –> Download (F8)

After these steps, the project should start executing on your evaluation kit. In case of errors, refer to the Evaluation Board User's Guide for configuration information.

Using the "USB Device HID" Project

Hardware Setup

The setup of the Evaluation Board hardware is described in the Abstract.txt file.

  • Verify all jumper settings on the target hardware.
  • Use an USB cable to connect your development board to the Host PC and power up your board.
  • Wait for the driver installation on the PC to complete. First you will see "Installing device driver software" and after a successful installation "USB Input Device":
    hid_install.png

PC Software

The USB Device HID example can be tested on a Windows PC using the HIDClient.exe utility (located in "C:\Keil\ARM\Utilities\HID_Client\Release"). The program runs stand-alone without installation.


Steps to check the USB communication using the client utility:

  • Run "C:\Keil\ARM\Utilities\HID_Client\Release\HIDClient.exe".
  • Select the Keil USB Device to establish the communication channel.
  • Press buttons on the target hardware and/or use the check boxes in the HID Client to interact with the application.
hid_client_test.png