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.
The USB Host Mass Storage project is available as part of the USB Host Reference examples.
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.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:
./RTE/USB/
folder:USBD_Config_MSC_0.h
: USB Host MSC configuration.USBH_Config_0.h
: USB Host Core configuration.USB_Debug.h
: USB Host Debug configuration../RTE/File_System/
folder:FS_Config.h
, FS_Config_MC_0.h
, FS_Debug.h
: File System configuration files./RTE/CMSIS/
folder:RTX_Config.h
and RTX_Config.c
: CMSIS-RTX Configuration files for the RTOS Kernel.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.
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.Working with MDK-Middleware Examples explains the workflow for accessing, configuring and building an MDK-Middleware example project for your target hardware.
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.
Test.txt
file.