Skip to content

This repository contains the project that was shown in the "Working with STM32 Devices" webinar.

License

Notifications You must be signed in to change notification settings

Arm-Examples/Middleware_USB_FS

Repository files navigation

Using MDK-Middleware with Keil Studio

Developing with MDK-Middleware

This repository explains how to extend a MDK-Middleware example to an user application. This application starts with USB Device MassStorage example and adds the File System for data storage on a SD Card. The BOTTON0 switches data storage access between USB Host (SD Card appears as USB memory device on Host computer) and embedded application for file access.

Initial development starts on the STM32F746G-DISCO board with a compatible board layer. A copy of this layer is then modified for the user hardware. In USB_Device.csolution.yml two target-types enable development on DISCO board or CustomHW.

The device peripherals are configured using STM32CubeMX and with it A/D converter functionality is added. For debugging ST-LINK, a CMSIS-DAP adapter, or J-Link may be used.

Watch this video to learn more...

Quick Start

  1. Install Keil Studio for VS Code from the VS Code marketplace.
  2. Clone this repository (for example using Git in VS Code) or download the ZIP file. Then open the base folder in VS Code.
  3. Open the CMSIS View. This should show the USB_Device application with the selected project MassStorage.
  4. The related tools and software packs are downloaded and installed. Review progress with View - Output - CMSIS Solution.
  5. In the CMSIS view, use the Action buttons to build, load and debug the example on the hardware.

Tip

Examples can be explored using the Keil MDK Community edition that is free-to-use for training and evaluation.

How it works

  • Initial State (USB owns the media):

    When the application starts, USBD_MSC0_SetMediaOwnerUSB() is called in the function app_main_thread(). The storage media is then controlled by the USB interface and the host PC can read/write files to the device.

  • When Button is Pressed:

    The application calls USBD_MSC0_SetMediaOwnerFS() which transfers media ownership from USB to the user File System interface. Now the embedded application can safely access the file system. The application reads the file Test.txt and once this is complete, it calls USBD_MSC0_SetMediaOwnerUSB() to return ownership back to USB.

Git Workflow

This repository is configured as a Git workspace for VS Code and can be effectively used with the VS Code Git integration via the following files:

Files and Directories

This is a list of the relevant files and directories:

File/Directory Description
vcpkg-configuration.json List of tools installed (by Arm Tools Environment Manager) in VS Code
USB_Device.csolution.yml Main solution file containing USB Device example projects
HID USB HID Device example project (not used for the application)
MassStorage USB Mass Storage Device example project (adapted for user application)
VirtualCOM USB Virtual COM Port Device example project (not used for the application)
Board Board support layers for STM32F746G-DISCO and custom hardware

References

About

This repository contains the project that was shown in the "Working with STM32 Devices" webinar.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •