USB Component  Version 6.0
MDK-Professional Middleware for USB Device and Host
 All Data Structures Functions Variables Enumerations Enumerator Groups Pages
USB Host

Structure of the USB Host Component and its use for creating application.

This chapter describes the software structure of an USB Host Component and explains its use for creating an USB Host application.

The USB Host Component simplifies software development of microcontroller systems that allow to connect USB Devices. The attributes of the USB Host Component are:

RTE Components

The following picture shows the relationships of the RTE Components with the microcontroller's USB Host peripheral (USB Controller). RTE Components provide configuration files that specify connections between RTE Components (indicated by dashed lines), hardware interfaces, memory resources, and USB Host driver parameters.

usb_host_blocks_config_files.png
USB Host Structure

Create an USB Host Application

The steps to create a microcontroller application that functions as an USB Host are:

  1. Select RTE Components that are required for your application.
  2. Enable and configure the USB Host Driver.
  3. Configure the USB Host that connects the Middleware to the microcontroller USB peripheral.
  4. Configure the parameters of the attached USB Devices.

RTE Component Selection

The RTE Component selection is done in a few steps:

  1. From the USB Component:
    • Select USB:CORE that provides the basic functionality required for USB communication.
    • Set USB:Host to '1'. This creates one USB Host for communication with attached USB Devices.
    • Select the desired support for USB Classes (HID/MSC/Class). For example, select USB:Host:HID to support HID Class Devices only.
  2. From the Drivers Component:
    • Select an appropriate USB Host driver suitable for your application. Some microcontrollers may have specific drivers for USB Full-Speed and High-Speed whereas other microcontrollers may have a combined driver.
  3. From the Device Component:
    • Additional device specific drivers may be required according to the validation output.
  4. From the CMSIS Component:
    • Select the CMSIS:CORE to provide the core interface to the processor.
    • Select a suitable CMSIS:RTOS that is a required for the USB Component.
USBH_RTE.png
RTE Component Selection

USB Driver and Controller

The USB Host Driver and the USB Controller of the microcontroller need to be correctly configured. In particular this means:

  • The USB Host Driver selected under the Drivers Component is typically configured with the RTE_Device.h configuration file. While this file provides multiple options, it is typically sufficient to enable the USB Host peripheral related to this driver. Some microcontrollers may require settings that related to a physical layer interface (PHY), the USB VBUS power and Overcurrent protection.
  • The USB Controller of the microcontroller needs typically specific clock settings. Consult the user's guide of the microcontroller to understand the requirements. Alternatively you may copy the setup of an USB Host example that is provided for various evaluation boards.

USB Host Configuration

The USBH_Config_n.c file contains additional settings for the specific USB Host:

  • The Driver Number is set according to the selected USB Controller. For single USB Device Controllers it will be '0'.
  • Some microcontrollers can make use of different hardware Controller Interfaces. Consult the user's guide of the selected microcontroller to choose the correct setting.

Configuration of Attachable USB Devices

In the USBH_Config_HID.h, USBH_Config_MSC.h or USBH_Config_Class.h you can specify the number of concurrent USB Devices that the USB Host will support. This has an impact on the amount of memory that will be reserved in your application for the attachment of USB Devices. The USB Host Examples shows how to configure an USB Host to interact with different HID or MSC peripheral devices.