
STM32H5 USB Composite(DFU+HID)
前言
很多人在使用STM32建置USB Composite官方基本上僅給H503 CDC+HID,但部分客戶會有需求為DFU+other,這邊依據外掛包去修改
I-CUBE-USBD-Composite
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
第一步在usbd_conf.h修改數字0變成1
#define USBD_DEBUG_LEVEL 1U
第二步在usbd_conf.修改&hpcd_USB_FS;變成&hpcd_USB_DRD_FS;因H5定義不同
第三步在usbd_dfu.c數字要設定相反(如圖右邊NBR為1)

第四步增加usbd_dfu.h右側定義


第五步把usbd_composite.c中DFU順序往上

再來是生成時候會少的部分在usb.c中並把中斷優先序往上



在中斷stm32h5xx_it.c需要加上TP1_Set();和TP1_Reset();
這部分在使用軟體包生成stm32h5xx_it.h會缺少需要額外加上

修改以上後基本上USB DFU剩下依據各系列去調整usbd_dfu_if.c/usbd_dfu_if.h這2塊即可
HID或其他部分記本上已經完整所以不太需要修正
Driver Setting
因微軟Driver這邊沒有設定好所以需要手動讓系統認到需要照以下方式使用



這時會出現一個未知的裝置需要再次操作




