Replies: 3 comments
-
Thanks for your interest of TinyUSB, your changes looks good. I can test with a H573-DK, I think we are get it merged with minor style format. |
Beta Was this translation helpful? Give feedback.
-
Hi, thanks for your reply. I will open a pull request then. Let me know if I and where I should change formatting. BTW, you are doing great work with TinyUSB, I really appreciate your commitment. |
Beta Was this translation helpful? Give feedback.
-
After some minor changes we managed to merge H503 support into master. Thanks again for everyone involved, it's nice to have it officially supported. |
Beta Was this translation helpful? Give feedback.
-
Hi,
I noticed that STM32 H5 recently got support from TinyUSB and I was disappointed that STM32H503 line was sadly not included in this release. But TinyUSB being an open source project gives me opportunity to change it and I want to ask your opinion on my approach.
STM32H503 differs slightly from STM32H563 and STM32H573. Code in
hw/bsp/stm32h5/family.c
was written with only former two in mind. I made following changes to make all these boards coexist peacefully:Make GPIO clock enabling dependent on board
In respective
board.h
files I changed clock setup function name fromSystemClock_Config()
toboard_clock_init()
and I moved all__HAL_RCC_GPIOx_CLK_ENABLE
calls to this function. It is necessary to make GPIO clocks dependent on board because H503 line does not have some of GPIO ports that are required by H563/H573. It is done in a similar way in F4 family.Make call to HAL_PWREx_EnableVddUSB() dependent on board
Similarly to GPIO ports, H503 does not utilize PWR->USBSCR register. USB peripheral is on by default. So I wrapped call to
HAL_PWREx_EnableVddUSB()
in a functionboard_enable_vdd_usb()
. Inboard.h
files for H563/H573 it callsHAL_PWREx_EnableVddUSB()
:In H503 it is left empty:
Again, it is done in a similar way in F4 family to handle VBUS detection.
Redefine USB_DRD_BASE to USB_DRD_FS_BASE
For some reason equivalent of
USB_DRD_BASE
definition fromstm32h563xx.h
is defined asUSB_DRD_FS_BASE
forstm32h503xx.h
. Nevertheless, they point to the same peripheral addressUSB_DRD_BASE_NS
. To work around this I took following approach: in the filedcd_stm32_fsdev.h
i check ifSTM32H503xx
is defined and if it is, I redefineUSB_DRD_BASE
asUSB_DRD_FS_BASE
.Normal implementation of H503RB-NUCLEO board support files
I created directory for
stm32h503nucleo
and added modifiedboard.cmake
,board.mk
andboard.h
files. The only notable changes are GPIO and UART definitions and clock configuration specific for H503RB-NUCLEO.Result
I was able to successfully compile code for all 3 boards and I tested dcd_msc and cdc_dual_ports examples on H503RB-NUCLEO. However, I don't have proper hardware to test other two boards.
Discussion
Before I create pull request I want to know your opinion on these changes. I am mostly concerned about
USB_DRD_BASE
redefinition. It works fine for now, but is it "clean", proper way of doing things?You can preview my changes on TinyUSB fork here:
master...wjklimek1:tinyusb:master
Beta Was this translation helpful? Give feedback.
All reactions