STM32 USB_Device(DFU_Standalone)-1

Preface

Currently, ST has two sets of USB drivers. One is the early independent version USB driver, referred to as the Legacy library in official training materials. The other is the driver for its Cube series, which may vary depending on the chip used. Please refer to the corresponding Cube driver package for the specific chip, referred to as the Cube library in official training materials.

USB Structure

The following diagram shows the overall system architecture of the USB application.

USB device library

The architecture of the entire USB driver library is shown in the following diagram:

USB device library process

USB device library Usage

  1. Organize the required source code: USB OTG source code, USB Device Core source code, USB Device Class source code.

Step 2: Implement the underlying hardware resources required by USB in the usb_bsp.c/h file. Specific functions can be found in the previous text and the comments of the attached source code files.
Step 3: Implement various descriptors of the USB Device in the usbd_desc.c/h file. Specific functions can be found in the previous text and the comments of the attached source code files.
Step 4: Modify the usbd_usr.c/h file according to your needs.
Step 5: Configure according to the source code.

  • USB OTG configuration file usb_conf.h. Specific configuration options can be found in the previous text and comments in the source code.
  • USB Device configuration file usbd_conf.h. Specific configuration options can be found in the previous text and comments in the source code.

Step 6: Implement the source file of the class used by the USB Device. For example, this article uses the CDC class of USB Device, so the usbd_cdc_vcp.c/h file appears in the above diagram.
Step 7: Add the USB interrupt processing function in the stm32f4xx_it.c file corresponding to your chip.
Step 8: In the main.c file, define the USB_OTG_CORE_HANDLE USB_OTG_dev global variable, and then call the following function to initialize the USB Device.

Leave a Comment

Your email address will not be published. Required fields are marked *

Shopping Cart