STM32H5 USB Composite(DFU+HID)

Prefer

Many developers using STM32 to build USB Composite find that the official support only provides H503 CDC+HID. However, some customers require DFU+other, which we modify here based on external add-on packages.

I-CUBE-USBD-Composite

I-CUBE-USBD-Composite is an unofficial software package that helps us quickly build a template. Basically, it can be used by modifying certain components.

How to install the package

download path:I-CUBE-USBD-Composite

1. Download AL94.I-CUBE-USBD-COMPOSITE.1.0.0.pack from repo.

2. Add AL94.I-CUBE-USBD-COMPOSITE.1.0.0.pack to CubeMX.

Enable the classes you want

Coding

Step 1: In usbd_conf.h, change the value from 0 to 1.

#define USBD_DEBUG_LEVEL                  1U

Step 2: In usbd_conf., replace &hpcd_USB_FS with &hpcd_USB_DRD_FS (since H5 uses a different definition).
Step 3: In usbd_dfu.c, set the number to the opposite value (e.g., NBR = 1 as shown on the right).

Step 4: Add the definition on the right side in usbd_dfu.h.

Step 5: Move the DFU sequence upward in usbd_composite.c.

Next, address the missing part during generation in usb.c and raise the interrupt priority.

In the interrupt file stm32h5xx_it.c, you need to add TP1_Set(); and TP1_Reset();.

When generating with the package, stm32h5xx_it.h will be incomplete, so you’ll need to add the missing parts manually.

After these modifications, for USB DFU you only need to adjust usbd_dfu_if.c and usbd_dfu_if.h according to each series.
The HID and other parts are already complete and usually don’t require further changes.

Driver Setting

Since the Microsoft driver is not properly configured, you need to manually let the system recognize it by following the steps below.

At this point, an unknown device will appear, requiring you to perform the operation again.

Leave a Comment

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

Shopping Cart