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

This example implements a USB Host that receives data from a USB Device (Keyboard) using HID: Human Interface Device Class.

The Standard I/O on the evaluation board (typically debugger Virtual COM) is used to show the keyboard inputs.

The following picture shows an exemplary connection of the development board, USB Keyboard and development computer.

USB Host Keyboard example hardware setup

Project Organization

The USB Host Keyboard project is available as part of the USB Host Reference examples.

Application Source Files

Following files implement application-specific logic in the example:

  • Keyboard.c: contains the application main thread which initializes the USB Host Component. It also reads the input from the attached keyboard and outputs it via the Standard I/O.

Software Components Configuration Files

Configuration files for the software components used in the project are available in the ./RTE/ directory and can be modified by users to adjust the operation of related components. Section RTE Components gives an overview about the components and their dependencies.

Following configuration files are provided with this example:

When a board layer is added to the project, corresponding configuration files for the board and device components will become available in the local ./Board/ directory.

Board Layer

In order to build the project it shall be extended with a compatible board layer that provides following interfaces as connections:

  • CMSIS_USB_Host: CMSIS-Driver for USB Host interface.

Build the Project

Working with MDK-Middleware Examples explains the workflow for accessing, configuring and building an MDK-Middleware example project for your target hardware.

  1. Open the USB_Host MDK-Middleware reference example.
  2. Make sure the compatible board layer is configured.
  3. Select Keyboard as an active project for the build process.
  4. Build the project and observe that no errors are reported.

Run the Example

Board-specific hardware setup such as jumpers, USB ports, power supply, etc. is documented in the board layer description (README.md) of your selected target.

  1. Load the executable image to the target development board.
  2. Connect a USB keyboard to the USB Host port on the development board.
  3. When the program runs on the board you should be able to see something similar on the Standard I/O:
    USB Host HID Keyboard example
    Keyboard connected!
    <text entered via USB Keyboard>