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

This examples implements a USB Host that accesses a USB Mass Storage Device (USB memory stick) using MSC: Mass Storage Class.

This example will create or overwrite a Test.txt file on the connected USB Stick with the content USB Host Mass Storage!.

The following picture shows an exemplary connection of the development board and a USB memory stick.

USB Host Mass Storage example hardware setup

Project Organization

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

Application Source Files

Following files implement application-specific logic in the example:

  • MassStorage.c: contains the application main thread which initializes the flash storage device and the USB Host Component. Also, it contains that code that will write a file with a message onto the attached USB stick.
  • USBH_MSC.c and USBH_MSC.h: adapted code template for the application specific functionality of the USB Host MSC class. It implements the access to a USB storage device and allows file I/O via the File System component.

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 MassStorage 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. Insert a USB memory stick to the USB Host port on the development board.
  3. Press reset button to ensure the firmware is executed.
  4. Detach the USB memory stick and connected it to a PC to check the availability of the Test.txt file.