USB Component  
MDK Middleware for USB Device and Host Communication
 
Loading...
Searching...
No Matches
PC Utilities

The USB Component comes with a set of software utilities that you can use as templates to create your own programs for a PC. The utilities are specific for the different USB Device Classes. These are the available utilities:

  • The HID Client can be used to interact with a USB HID Device. You can toggle LEDs on the development board and check the state of the on-board push-buttons.

HID Client

The HID Client utility is a graphical application for a PC (running Microsoft Windows) that can be used for testing the USB Device HID implementation. It is available as a part of Keil MDK uVision and the executable file HID_Client.exe is available in the <mdk_install_dir>/ARM/Utilities/HID_Client/Release folder, where <mdk_install_dir> refers to the Keil MDK uVision installation directory. This program runs stand-alone without installation.

To check the HID Client utility with your board, do the following:

  1. Download the USB Device HID example application to your board.
  2. Verify all jumper settings on the board.
  3. Connect the board to a PC. The PC should recognize the HID device and install the correct driver automatically.
  4. Run HIDClient.exe application.
  5. Select the Device to establish the communication channel.
  6. Test the application and HID device operation by pressing the buttons on your development board and watch Inputs change and/or check/un-check the check-boxes in the Outputs to see the LEDs on the board change state.
HID Client app

Source Code

The source code of the HID Client application is available in <install_dir>/ARM/Utilities/HID_Client. A Visual Studio 2010 (or later) based solution named HIDClient_VS2010.sln is available. The following is a summary of what you will find in each of the files that make up your HID Client application.

HID Client app solution view

Header Files

  • HID.h includes the function declarations of the functions that are defined in HID.cpp.
  • HIDClient.h is the main header file for the application. It includes other project specific headers (including Resource.h) and declares the CHIDClientApp application class.
  • HIDClientDlg.h defines the behavior of the application's main dialog.

Resource Files

  • HIDClient.ico is an icon file, which is used as the application's icon. This icon is included by the main resource file HIDClient.rc.
  • HIDClient.rc2 contains resources that are not edited by Microsoft Visual C++. You should place all resources not editable by the resource editor in this file.

Source Files

  • HID.cpp contains the necessary functions that are used in this example application to communicate with an USB HID device. All available functions in Windows for HID interaction are explained here: Introduction to HID Concepts. The function:
    • HID_Init initializes the HID class to be used with the USB Host.
    • HID_UnInit de-initializes the HID class from the USB Host.
    • HID_FindDevices scans the USB Bus and lists all available HID devices for connection to the application. This information is obtained from the Device Descriptor that is generated by the USB Component using the configuration files.
    • HID_GetName evaluates the Product String of the device to be shown in the drop down box of the application.
    • HID_GetInputReportSize extracts the value of USBD_HIDn_IN_REPORT_MAX_SZ as specified in the USBD_Config_HID_n.h file.
    • HID_GetOutputReportSize extracts the value of USBD_HIDn_OUT_REPORT_MAX_SZ as specified in the USBD_Config_HID_n.h file.
    • HID_GetFeatureReportSize extracts the value of USBD_HIDn_FEAT_REPORT_MAX_SZ as specified in the USBD_Config_HID_n.h file.
    • HID_Open opens the device.
    • HID_GetSelectedDevice returns the selected device.
    • HID_Close closes the device.
    • HID_Read initiates a USBD_HIDn_GetReport within the device to send data to the USB Host.
    • HID_Write triggers a USBD_HIDn_SetReport within the device to read data sent from the USB Host.
    • HID_GetFeature and HID_SetFeature work on the USB HID Device's feature report (which is optional).
  • HIDClient.cpp is the main application source file that contains the application class CHIDClientApp.
  • HIDClient.rc is a listing of all of the Microsoft Windows resources that the program uses (located in the res subdirectory).
  • HIDClientDlg.cpp implements the code of the client's dialog and calls the functions specified in HID.cpp. This is the actual place where the interaction between the USB Host and the USB Device is defined.